Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Feb 14, 2024
1 parent b3037cb commit e46c400
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
11 changes: 10 additions & 1 deletion app/Actions/LogAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { Action } from '@stacksjs/actions'
import { validator } from '@stacksjs/validation'
import { log } from '@stacksjs/logging'

interface Request {
message: string
level: 'info' | 'warn' | 'error'
}

export default new Action({
name: 'Dummy Logger',
description: 'This action is used to demo how to POST to a server and upon success, log a message.',
Expand All @@ -19,7 +24,11 @@ export default new Action({
},

// handle(request: { message: string, level: 'info' | 'warn' | 'error' }) {
handle(request: Request) {
handle(request?: Request) {
if (!request)
return 'No request was provided.'

// TODO: need to vine validate
log[request.level](request.message)

return `Logged "${request.message}" at "${request.level}" level`
Expand Down
4 changes: 2 additions & 2 deletions storage/framework/core/actions/src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface ActionOptions {
tries?: JobOptions['tries']
backoff?: JobOptions['backoff']
enabled?: JobOptions['enabled']
handle: (request?: Request) => Promise<any> | string
handle: (request?: Request) => Promise<any> | object | string
}

export class Action {
Expand All @@ -35,7 +35,7 @@ export class Action {
tries?: JobOptions['tries']
backoff?: JobOptions['backoff']
enabled?: boolean
handle: (request?: Request) => Promise<any> | string
handle: (request?: Request) => Promise<any> | object | string

constructor({ name, description, fields, handle, rate, tries, backoff, enabled }: ActionOptions) {
// log.debug(`Action ${name} created`) // TODO: this does not yet work because the cloud does not yet have proper file system (efs) access
Expand Down
11 changes: 6 additions & 5 deletions storage/framework/core/actions/src/upgrade/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import process from 'node:process'
import { ExitCode, parseArgs } from '@stacksjs/cli'
import { parseArgs } from '@stacksjs/cli'
import { Action } from '@stacksjs/enums'
import { ExitCode } from '@stacksjs/types'
import { runAction } from '../helpers'

const options = parseArgs()
const options: any = parseArgs()

// run all the upgrade actions
if (options?.framework || options?.all)
await updateFramework(options)
// if (options?.framework || options?.all)
// await updateFramework(options)

if (options?.dependencies || options?.all)
await updateDependencies(options)
await runAction(Action.UpgradeDeps, options)

if (options?.bun || options?.all)
await runAction(Action.UpgradeBun, options)
Expand Down
1 change: 1 addition & 0 deletions storage/framework/core/enums/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,5 @@ export enum Action {
Typecheck = 'typecheck',
Upgrade = 'upgrade/index',
UpgradeBun = 'upgrade/bun',
UpgradeDeps = 'upgrade/dependencies',
}

0 comments on commit e46c400

Please sign in to comment.