@take-out/cli 0.1.39 → 0.1.40
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/dist/cjs/cli.cjs +10 -3
- package/dist/cjs/cli.js +9 -2
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/commands/run-all.cjs +47 -29
- package/dist/cjs/commands/run-all.js +38 -23
- package/dist/cjs/commands/run-all.js.map +1 -1
- package/dist/cjs/commands/run.cjs +16 -32
- package/dist/cjs/commands/run.js +10 -29
- package/dist/cjs/commands/run.js.map +2 -2
- package/dist/cjs/utils/parallel-runner.cjs +2 -1
- package/dist/cjs/utils/parallel-runner.js +1 -1
- package/dist/cjs/utils/parallel-runner.js.map +1 -1
- package/dist/esm/cli.js +9 -2
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/cli.mjs +10 -3
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/commands/run-all.js +28 -21
- package/dist/esm/commands/run-all.js.map +1 -1
- package/dist/esm/commands/run-all.mjs +31 -24
- package/dist/esm/commands/run-all.mjs.map +1 -1
- package/dist/esm/commands/run.js +12 -31
- package/dist/esm/commands/run.js.map +2 -2
- package/dist/esm/commands/run.mjs +18 -34
- package/dist/esm/commands/run.mjs.map +1 -1
- package/dist/esm/utils/parallel-runner.js +1 -1
- package/dist/esm/utils/parallel-runner.js.map +1 -1
- package/dist/esm/utils/parallel-runner.mjs +2 -1
- package/dist/esm/utils/parallel-runner.mjs.map +1 -1
- package/package.json +4 -3
- package/src/cli.ts +10 -7
- package/src/commands/run-all.ts +40 -36
- package/src/commands/run.ts +14 -45
- package/src/utils/parallel-runner.ts +1 -1
- package/types/commands/run-all.d.ts.map +1 -1
- package/types/commands/run.d.ts.map +1 -1
package/src/commands/run.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process'
|
|
2
|
-
import { existsSync,
|
|
3
|
-
import {
|
|
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
|
-
//
|
|
33
|
-
const
|
|
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
|
|
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
|
-
//
|
|
127
|
-
|
|
128
|
-
|
|
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;;;;;;
|
|
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;;;;;;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU;;;;;;EAgIrB,CAAA"}
|