镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Commit ce56853

Browse files
committed
fix(buddy): resolve build and test actions through narrow entry
Use the existing actions/run-action entry instead of loading the full tooling barrel. The real frontend command no longer resolves unrelated database tooling, and test registers before dispatching its action. Retain the failing-action exit-code harness for both public entries. Validation: 23 focused command tests pass (40 assertions); real Bun frontend reference generates all 5 pages. Exact zig-js/Home candidate build and test still fail honestly at missing Bun.spawn. Pickier retains the same 4 baseline warnings (0 errors). No test262 corpus run or whole-consumer pass is claimed.
1 parent 85df359 commit ce56853

3 files changed

Lines changed: 17 additions & 16 deletions

File tree

‎storage/framework/core/buddy/src/commands/build.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import { projectPath } from '@stacksjs/path'
77
import { ExitCode } from '@stacksjs/types'
88
import { resultFailed } from '../result'
99

10-
// Lazy-load @stacksjs/actions — importing it at module level forces every
11-
// `buddy <anything>` invocation to resolve the actions barrel before
12-
// `--help` can render. Pulling it in only when a build subcommand
13-
// actually fires keeps `buddy --help` snappy.
14-
let _runAction: typeof import('@stacksjs/actions').runAction | undefined
15-
async function runAction(...args: Parameters<typeof import('@stacksjs/actions').runAction>): ReturnType<typeof import('@stacksjs/actions').runAction> {
16-
if (!_runAction) _runAction = (await import('@stacksjs/actions')).runAction
10+
// Load only the action resolver when a build runs. The package root also
11+
// imports generators, database tooling and dev servers that are unrelated to
12+
// the selected target. Keep help lazy and let the child load its own action.
13+
let _runAction: typeof import('@stacksjs/actions/run-action').runAction | undefined
14+
async function runAction(...args: Parameters<typeof import('@stacksjs/actions/run-action').runAction>): ReturnType<typeof import('@stacksjs/actions/run-action').runAction> {
15+
if (!_runAction) _runAction = (await import('@stacksjs/actions/run-action')).runAction
1716
return _runAction(...args)
1817
}
1918

‎storage/framework/core/buddy/src/commands/test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { CLI, TestingOptions } from '@stacksjs/types'
22
import process from 'node:process'
3-
import { runAction } from '@stacksjs/actions'
3+
import { runAction } from '@stacksjs/actions/run-action'
44
import { intro, log, onUnknownSubcommand, outro } from "@stacksjs/cli"
55
import { Action } from '@stacksjs/enums'
66
import { projectPath } from '@stacksjs/path'

‎storage/framework/core/buddy/tests/fixtures/failing-actions.ts‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ import { plugin } from 'bun'
55
plugin({
66
name: 'failing-actions',
77
setup(build) {
8-
build.module('@stacksjs/actions', () => ({
9-
loader: 'object',
10-
exports: {
11-
runAction: async (action: string) => {
12-
console.log(`ran ${action}`)
13-
return { isErr: true, isOk: false, error: new Error(`${action} failed`) }
8+
for (const entry of ['@stacksjs/actions', '@stacksjs/actions/run-action']) {
9+
build.module(entry, () => ({
10+
loader: 'object',
11+
exports: {
12+
runAction: async (action: string) => {
13+
console.log(`ran ${action}`)
14+
return { isErr: true, isOk: false, error: new Error(`${action} failed`) }
15+
},
1416
},
15-
},
16-
}))
17+
}))
18+
}
1719
},
1820
})

0 commit comments

Comments
 (0)