@fugood/bricks-ctor 2.25.0-beta.61 → 2.25.0-beta.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@fugood/bricks-ctor",
3
- "version": "2.25.0-beta.61",
3
+ "version": "2.25.0-beta.63",
4
4
  "description": "Deprecated: ctor tooling moved to the `bricks ctor` commands in @fugood/bricks-cli. This package now only forwards legacy project scripts and triggers migration.",
5
5
  "dependencies": {
6
- "@fugood/bricks-cli": "^2.25.0-beta.61"
6
+ "@fugood/bricks-cli": "^2.25.0-beta.63"
7
7
  },
8
- "gitHead": "342701683311c7e0dc295bac19a2f9a9517d3160"
8
+ "gitHead": "c298a2ceeab7fb5f94db9a165bb31e4486b7f025"
9
9
  }
@@ -0,0 +1,91 @@
1
+ const mockSpawnSync = jest.fn()
2
+ const mockExistsSync = jest.fn()
3
+
4
+ jest.mock('node:child_process', () => ({
5
+ __esModule: true,
6
+ spawnSync: (...args) => mockSpawnSync(...args),
7
+ }))
8
+
9
+ jest.mock('node:fs', () => ({
10
+ __esModule: true,
11
+ existsSync: (...args) => mockExistsSync(...args),
12
+ }))
13
+
14
+ const loadForwarder = () => require('../_forward.ts')
15
+
16
+ describe('legacy bricks-ctor forwarder', () => {
17
+ let exitSpy
18
+ let errorSpy
19
+
20
+ beforeEach(() => {
21
+ jest.resetModules()
22
+ mockSpawnSync.mockReset()
23
+ mockExistsSync.mockReset()
24
+ exitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {})
25
+ errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {})
26
+ })
27
+
28
+ afterEach(() => {
29
+ exitSpy.mockRestore()
30
+ errorSpy.mockRestore()
31
+ })
32
+
33
+ it('prefers the local bricks CLI next to the legacy package', () => {
34
+ mockExistsSync.mockReturnValue(true)
35
+ mockSpawnSync.mockReturnValue({ status: 0 })
36
+ const { forwardLegacyCtorTool } = loadForwarder()
37
+
38
+ forwardLegacyCtorTool(
39
+ 'deploy',
40
+ 'file:///repo/node_modules/@fugood/bricks-ctor/tools/deploy.ts',
41
+ ['--target', 'device'],
42
+ )
43
+
44
+ expect(mockSpawnSync).toHaveBeenCalledWith(
45
+ '/repo/node_modules/.bin/bricks',
46
+ ['ctor', 'deploy', '--target', 'device'],
47
+ { stdio: 'inherit' },
48
+ )
49
+ expect(exitSpy).toHaveBeenCalledWith(0)
50
+ })
51
+
52
+ it('falls back to PATH when the local bricks CLI is missing', () => {
53
+ mockExistsSync.mockReturnValue(false)
54
+ mockSpawnSync.mockReturnValue({ status: 3 })
55
+ const { forwardLegacyCtorTool } = loadForwarder()
56
+
57
+ forwardLegacyCtorTool('pull', 'file:///repo/node_modules/@fugood/bricks-ctor/tools/pull.ts', [])
58
+
59
+ expect(mockSpawnSync).toHaveBeenCalledWith('bricks', ['ctor', 'pull'], { stdio: 'inherit' })
60
+ expect(exitSpy).toHaveBeenCalledWith(3)
61
+ })
62
+
63
+ it('reports spawn errors and exits with failure', () => {
64
+ mockExistsSync.mockReturnValue(false)
65
+ mockSpawnSync.mockReturnValue({ error: new Error('ENOENT') })
66
+ const { forwardLegacyCtorTool } = loadForwarder()
67
+
68
+ forwardLegacyCtorTool(
69
+ 'mcp',
70
+ 'file:///repo/node_modules/@fugood/bricks-ctor/tools/mcp-server.ts',
71
+ [],
72
+ )
73
+
74
+ expect(errorSpy).toHaveBeenCalledWith('bricks-ctor forwarder failed to run `bricks`: ENOENT')
75
+ expect(exitSpy).toHaveBeenCalledWith(1)
76
+ })
77
+
78
+ it('treats a missing child status as failure', () => {
79
+ mockExistsSync.mockReturnValue(false)
80
+ mockSpawnSync.mockReturnValue({})
81
+ const { forwardLegacyCtorTool } = loadForwarder()
82
+
83
+ forwardLegacyCtorTool(
84
+ 'simulator',
85
+ 'file:///repo/node_modules/@fugood/bricks-ctor/tools/simulator.ts',
86
+ [],
87
+ )
88
+
89
+ expect(exitSpy).toHaveBeenCalledWith(1)
90
+ })
91
+ })
@@ -0,0 +1,26 @@
1
+ import { spawnSync } from 'node:child_process'
2
+ import { existsSync } from 'node:fs'
3
+ import { fileURLToPath } from 'node:url'
4
+
5
+ // @fugood/bricks-ctor is deprecated; all tooling now lives in @fugood/bricks-cli.
6
+ // This shared forwarder keeps legacy project scripts working until postinstall migrates them.
7
+ export function resolveLegacyBricksCommand(baseUrl: string) {
8
+ const localBricks = fileURLToPath(new URL('../../../.bin/bricks', baseUrl))
9
+ return existsSync(localBricks) ? localBricks : 'bricks'
10
+ }
11
+
12
+ export function forwardLegacyCtorTool(
13
+ command: string,
14
+ baseUrl: string,
15
+ args = process.argv.slice(2),
16
+ ) {
17
+ const bricks = resolveLegacyBricksCommand(baseUrl)
18
+ const result = spawnSync(bricks, ['ctor', command, ...args], { stdio: 'inherit' })
19
+
20
+ if (result.error) {
21
+ console.error(`bricks-ctor forwarder failed to run \`${bricks}\`: ${result.error.message}`)
22
+ process.exit(1)
23
+ }
24
+
25
+ process.exit(result.status ?? 1)
26
+ }
package/tools/deploy.ts CHANGED
@@ -1,19 +1,4 @@
1
1
  #!/usr/bin/env bun
2
- // @fugood/bricks-ctor is deprecated all tooling now lives in the `bricks ctor *` commands
3
- // (the @fugood/bricks-cli package). This thin forwarder keeps legacy project scripts working
4
- // and lets `bricks ctor postinstall` migrate the project onto the new commands.
5
- import { spawnSync } from 'node:child_process'
6
- import { existsSync } from 'node:fs'
7
- import { fileURLToPath } from 'node:url'
2
+ import { forwardLegacyCtorTool } from './_forward.ts'
8
3
 
9
- // Prefer the CLI installed next to this shim (@fugood/bricks-cli is our only dependency)
10
- // over a PATH lookup, so the forwarder works without a global install.
11
- const localBricks = fileURLToPath(new URL('../../../.bin/bricks', import.meta.url))
12
- const bricks = existsSync(localBricks) ? localBricks : 'bricks'
13
-
14
- const result = spawnSync(bricks, ['ctor', 'deploy', ...process.argv.slice(2)], { stdio: 'inherit' })
15
- if (result.error) {
16
- console.error(`bricks-ctor forwarder failed to run \`${bricks}\`: ${result.error.message}`)
17
- process.exit(1)
18
- }
19
- process.exit(result.status ?? 1)
4
+ forwardLegacyCtorTool('deploy', import.meta.url)
@@ -1,19 +1,4 @@
1
1
  #!/usr/bin/env bun
2
- // @fugood/bricks-ctor is deprecated all tooling now lives in the `bricks ctor *` commands
3
- // (the @fugood/bricks-cli package). This thin forwarder keeps legacy project scripts working
4
- // and lets `bricks ctor postinstall` migrate the project onto the new commands.
5
- import { spawnSync } from 'node:child_process'
6
- import { existsSync } from 'node:fs'
7
- import { fileURLToPath } from 'node:url'
2
+ import { forwardLegacyCtorTool } from './_forward.ts'
8
3
 
9
- // Prefer the CLI installed next to this shim (@fugood/bricks-cli is our only dependency)
10
- // over a PATH lookup, so the forwarder works without a global install.
11
- const localBricks = fileURLToPath(new URL('../../../.bin/bricks', import.meta.url))
12
- const bricks = existsSync(localBricks) ? localBricks : 'bricks'
13
-
14
- const result = spawnSync(bricks, ['ctor', 'mcp', ...process.argv.slice(2)], { stdio: 'inherit' })
15
- if (result.error) {
16
- console.error(`bricks-ctor forwarder failed to run \`${bricks}\`: ${result.error.message}`)
17
- process.exit(1)
18
- }
19
- process.exit(result.status ?? 1)
4
+ forwardLegacyCtorTool('mcp', import.meta.url)
@@ -1,21 +1,4 @@
1
1
  #!/usr/bin/env bun
2
- // @fugood/bricks-ctor is deprecated all tooling now lives in the `bricks ctor *` commands
3
- // (the @fugood/bricks-cli package). This thin forwarder keeps legacy project scripts working
4
- // and lets `bricks ctor postinstall` migrate the project onto the new commands.
5
- import { spawnSync } from 'node:child_process'
6
- import { existsSync } from 'node:fs'
7
- import { fileURLToPath } from 'node:url'
2
+ import { forwardLegacyCtorTool } from './_forward.ts'
8
3
 
9
- // Prefer the CLI installed next to this shim (@fugood/bricks-cli is our only dependency)
10
- // over a PATH lookup, so the forwarder works without a global install.
11
- const localBricks = fileURLToPath(new URL('../../../.bin/bricks', import.meta.url))
12
- const bricks = existsSync(localBricks) ? localBricks : 'bricks'
13
-
14
- const result = spawnSync(bricks, ['ctor', 'postinstall', ...process.argv.slice(2)], {
15
- stdio: 'inherit',
16
- })
17
- if (result.error) {
18
- console.error(`bricks-ctor forwarder failed to run \`${bricks}\`: ${result.error.message}`)
19
- process.exit(1)
20
- }
21
- process.exit(result.status ?? 1)
4
+ forwardLegacyCtorTool('postinstall', import.meta.url)
package/tools/pull.ts CHANGED
@@ -1,19 +1,4 @@
1
1
  #!/usr/bin/env bun
2
- // @fugood/bricks-ctor is deprecated all tooling now lives in the `bricks ctor *` commands
3
- // (the @fugood/bricks-cli package). This thin forwarder keeps legacy project scripts working
4
- // and lets `bricks ctor postinstall` migrate the project onto the new commands.
5
- import { spawnSync } from 'node:child_process'
6
- import { existsSync } from 'node:fs'
7
- import { fileURLToPath } from 'node:url'
2
+ import { forwardLegacyCtorTool } from './_forward.ts'
8
3
 
9
- // Prefer the CLI installed next to this shim (@fugood/bricks-cli is our only dependency)
10
- // over a PATH lookup, so the forwarder works without a global install.
11
- const localBricks = fileURLToPath(new URL('../../../.bin/bricks', import.meta.url))
12
- const bricks = existsSync(localBricks) ? localBricks : 'bricks'
13
-
14
- const result = spawnSync(bricks, ['ctor', 'pull', ...process.argv.slice(2)], { stdio: 'inherit' })
15
- if (result.error) {
16
- console.error(`bricks-ctor forwarder failed to run \`${bricks}\`: ${result.error.message}`)
17
- process.exit(1)
18
- }
19
- process.exit(result.status ?? 1)
4
+ forwardLegacyCtorTool('pull', import.meta.url)
@@ -1,19 +1,4 @@
1
1
  #!/usr/bin/env bun
2
- // @fugood/bricks-ctor is deprecated all tooling now lives in the `bricks ctor *` commands
3
- // (the @fugood/bricks-cli package). This thin forwarder keeps legacy project scripts working
4
- // and lets `bricks ctor postinstall` migrate the project onto the new commands.
5
- import { spawnSync } from 'node:child_process'
6
- import { existsSync } from 'node:fs'
7
- import { fileURLToPath } from 'node:url'
2
+ import { forwardLegacyCtorTool } from './_forward.ts'
8
3
 
9
- // Prefer the CLI installed next to this shim (@fugood/bricks-cli is our only dependency)
10
- // over a PATH lookup, so the forwarder works without a global install.
11
- const localBricks = fileURLToPath(new URL('../../../.bin/bricks', import.meta.url))
12
- const bricks = existsSync(localBricks) ? localBricks : 'bricks'
13
-
14
- const result = spawnSync(bricks, ['ctor', 'push', ...process.argv.slice(2)], { stdio: 'inherit' })
15
- if (result.error) {
16
- console.error(`bricks-ctor forwarder failed to run \`${bricks}\`: ${result.error.message}`)
17
- process.exit(1)
18
- }
19
- process.exit(result.status ?? 1)
4
+ forwardLegacyCtorTool('push', import.meta.url)
@@ -1,21 +1,4 @@
1
1
  #!/usr/bin/env bun
2
- // @fugood/bricks-ctor is deprecated all tooling now lives in the `bricks ctor *` commands
3
- // (the @fugood/bricks-cli package). This thin forwarder keeps legacy project scripts working
4
- // and lets `bricks ctor postinstall` migrate the project onto the new commands.
5
- import { spawnSync } from 'node:child_process'
6
- import { existsSync } from 'node:fs'
7
- import { fileURLToPath } from 'node:url'
2
+ import { forwardLegacyCtorTool } from './_forward.ts'
8
3
 
9
- // Prefer the CLI installed next to this shim (@fugood/bricks-cli is our only dependency)
10
- // over a PATH lookup, so the forwarder works without a global install.
11
- const localBricks = fileURLToPath(new URL('../../../.bin/bricks', import.meta.url))
12
- const bricks = existsSync(localBricks) ? localBricks : 'bricks'
13
-
14
- const result = spawnSync(bricks, ['ctor', 'simulator', ...process.argv.slice(2)], {
15
- stdio: 'inherit',
16
- })
17
- if (result.error) {
18
- console.error(`bricks-ctor forwarder failed to run \`${bricks}\`: ${result.error.message}`)
19
- process.exit(1)
20
- }
21
- process.exit(result.status ?? 1)
4
+ forwardLegacyCtorTool('simulator', import.meta.url)