@take-out/cli 0.1.39 → 0.1.41

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.
@@ -1,6 +1,6 @@
1
1
  import { spawn } from 'node:child_process'
2
- import { existsSync, readFileSync, statSync } from 'node:fs'
3
- import { resolve, join, parse } from 'node:path'
2
+ import { existsSync, statSync } from 'node:fs'
3
+ import { join } from 'node:path'
4
4
 
5
5
  import { defineCommand } from 'citty'
6
6
 
@@ -29,10 +29,13 @@ export const runCommand = defineCommand({
29
29
 
30
30
  // Check if it's a category directory
31
31
  if (existsSync(categoryPath) && statSync(categoryPath).isDirectory()) {
32
- // Check if --all flag is present
33
- const hasAllFlag = secondArg === '--all'
32
+ // only run all when flags come before any sub-script name
33
+ const nonFlagArgs = scriptArgs.slice(1).filter((a) => !a.startsWith('--'))
34
+ const hasSubScript = nonFlagArgs.length > 0
35
+ const hasAllFlag = secondArg === '--all' && !hasSubScript
36
+ const hasDefaultAllFlag = scriptArgs.includes('--default-all') && !hasSubScript
34
37
 
35
- if (hasAllFlag) {
38
+ if (hasAllFlag || hasDefaultAllFlag) {
36
39
  // Run all scripts in this category in parallel
37
40
  const { discoverScripts } = await import('../utils/script-utils')
38
41
  const { runScriptsInParallel } = await import('../utils/parallel-runner')
@@ -110,7 +113,9 @@ export const runCommand = defineCommand({
110
113
 
111
114
  if (scriptPath) {
112
115
  // Use spawn instead of Bun's $ helper since we're in a compiled context
113
- const scriptArgsToPass = scriptArgs.slice(1)
116
+ const scriptArgsToPass = scriptArgs
117
+ .slice(1)
118
+ .filter((a) => a !== '--default-all' && a !== '--all')
114
119
  const child = spawn('bun', [scriptPath, ...scriptArgsToPass], {
115
120
  stdio: 'inherit',
116
121
  shell: false,
@@ -123,44 +128,8 @@ export const runCommand = defineCommand({
123
128
  }
124
129
  }
125
130
 
126
- // Fall back to the original run.ts behavior for package.json scripts
127
- // Find the project root by looking for package.json with workspaces or takeout field
128
- let currentDir = process.cwd()
129
- let projectRoot = ''
130
-
131
- while (currentDir !== parse(currentDir).root) {
132
- const packageJsonPath = resolve(currentDir, 'package.json')
133
- if (existsSync(packageJsonPath)) {
134
- try {
135
- const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
136
- if (pkg.workspaces || pkg.takeout) {
137
- projectRoot = currentDir
138
- break
139
- }
140
- } catch {}
141
- }
142
- currentDir = resolve(currentDir, '..')
143
- }
144
-
145
- if (!projectRoot) {
146
- console.error('Could not find project root')
147
- process.exit(1)
148
- }
149
-
150
- // check if local packages/scripts exists (takeout monorepo), otherwise use installed package
151
- const localScriptsPath = resolve(projectRoot, 'packages/scripts/src/run.ts')
152
- const scriptPath = existsSync(localScriptsPath)
153
- ? localScriptsPath
154
- : resolve(projectRoot, 'node_modules/@take-out/scripts/src/run.ts')
155
-
156
- const child = spawn('bun', [scriptPath, ...scriptArgs], {
157
- stdio: 'inherit',
158
- shell: false,
159
- })
160
-
161
- const code = await new Promise<number>((resolve) => {
162
- child.on('exit', (code) => resolve(code || 0))
163
- })
164
- process.exit(code)
131
+ // fall back to runParallelScripts for package.json scripts (direct import, no subprocess)
132
+ const { runParallelScripts, parseRunArgs } = await import('@take-out/run')
133
+ await runParallelScripts(parseRunArgs(scriptArgs))
165
134
  },
166
135
  })
@@ -131,7 +131,7 @@ function runSingleScript(script: ScriptToRun, colorIndex: number): Promise<void>
131
131
  const proc = spawn('bun', [script.path, ...(script.args || [])], {
132
132
  stdio: ['pipe', 'pipe', 'pipe'],
133
133
  shell: false,
134
- env: { ...process.env, FORCE_COLOR: '3' } as any,
134
+ env: { ...process.env, FORCE_COLOR: '3', TKO_IS_RUNNING_ALL: '1' } as any,
135
135
  detached: true,
136
136
  })
137
137
 
@@ -1 +1 @@
1
- {"version":3,"file":"run-all.d.ts","sourceRoot":"","sources":["../../src/commands/run-all.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa;;;;;;EA0DxB,CAAA"}
1
+ {"version":3,"file":"run-all.d.ts","sourceRoot":"","sources":["../../src/commands/run-all.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa;;;;;;EA6CxB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU;;;;;;EA+JrB,CAAA"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU;;;;;;EAgIrB,CAAA"}