@take-out/cli 0.4.3 → 0.4.5
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 +53 -35
- package/dist/cjs/commands/changed.cjs +133 -95
- package/dist/cjs/commands/docs.cjs +276 -203
- package/dist/cjs/commands/env-setup.cjs +45 -33
- package/dist/cjs/commands/onboard.cjs +668 -224
- package/dist/cjs/commands/run-all.cjs +54 -45
- package/dist/cjs/commands/run.cjs +80 -65
- package/dist/cjs/commands/script.cjs +263 -187
- package/dist/cjs/commands/skills.cjs +174 -118
- package/dist/cjs/commands/sync.cjs +193 -93
- package/dist/cjs/constants/ascii.cjs +14 -12
- package/dist/cjs/index.cjs +12 -10
- package/dist/cjs/types.cjs +7 -5
- package/dist/cjs/utils/env-categories.cjs +53 -48
- package/dist/cjs/utils/env-setup.cjs +214 -106
- package/dist/cjs/utils/env.cjs +65 -44
- package/dist/cjs/utils/files.cjs +186 -113
- package/dist/cjs/utils/parallel-runner.cjs +125 -75
- package/dist/cjs/utils/ports.cjs +21 -21
- package/dist/cjs/utils/prerequisites.cjs +42 -34
- package/dist/cjs/utils/prompts.cjs +66 -41
- package/dist/cjs/utils/script-listing.cjs +130 -60
- package/dist/cjs/utils/script-utils.cjs +29 -19
- package/dist/cjs/utils/sync.cjs +67 -45
- package/dist/esm/cli.mjs +40 -24
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/commands/changed.mjs +104 -68
- package/dist/esm/commands/changed.mjs.map +1 -1
- package/dist/esm/commands/docs.mjs +245 -174
- package/dist/esm/commands/docs.mjs.map +1 -1
- package/dist/esm/commands/env-setup.mjs +18 -8
- package/dist/esm/commands/env-setup.mjs.map +1 -1
- package/dist/esm/commands/onboard.mjs +631 -189
- package/dist/esm/commands/onboard.mjs.map +1 -1
- package/dist/esm/commands/run-all.mjs +26 -19
- package/dist/esm/commands/run-all.mjs.map +1 -1
- package/dist/esm/commands/run.mjs +52 -39
- package/dist/esm/commands/run.mjs.map +1 -1
- package/dist/esm/commands/script.mjs +230 -156
- package/dist/esm/commands/script.mjs.map +1 -1
- package/dist/esm/commands/skills.mjs +143 -89
- package/dist/esm/commands/skills.mjs.map +1 -1
- package/dist/esm/commands/sync.mjs +160 -62
- package/dist/esm/commands/sync.mjs.map +1 -1
- package/dist/esm/constants/ascii.mjs +2 -2
- package/dist/esm/constants/ascii.mjs.map +1 -1
- package/dist/esm/utils/env-categories.mjs +29 -26
- package/dist/esm/utils/env-categories.mjs.map +1 -1
- package/dist/esm/utils/env-setup.mjs +184 -78
- package/dist/esm/utils/env-setup.mjs.map +1 -1
- package/dist/esm/utils/env.mjs +50 -31
- package/dist/esm/utils/env.mjs.map +1 -1
- package/dist/esm/utils/files.mjs +171 -100
- package/dist/esm/utils/files.mjs.map +1 -1
- package/dist/esm/utils/parallel-runner.mjs +111 -63
- package/dist/esm/utils/parallel-runner.mjs.map +1 -1
- package/dist/esm/utils/ports.mjs +9 -11
- package/dist/esm/utils/ports.mjs.map +1 -1
- package/dist/esm/utils/prerequisites.mjs +30 -24
- package/dist/esm/utils/prerequisites.mjs.map +1 -1
- package/dist/esm/utils/prompts.mjs +40 -17
- package/dist/esm/utils/prompts.mjs.map +1 -1
- package/dist/esm/utils/script-listing.mjs +101 -33
- package/dist/esm/utils/script-listing.mjs.map +1 -1
- package/dist/esm/utils/script-utils.mjs +14 -6
- package/dist/esm/utils/script-utils.mjs.map +1 -1
- package/dist/esm/utils/sync.mjs +38 -18
- package/dist/esm/utils/sync.mjs.map +1 -1
- package/package.json +5 -5
package/dist/cjs/utils/files.cjs
CHANGED
|
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var files_exports = {};
|
|
22
24
|
__export(files_exports, {
|
|
@@ -28,166 +30,237 @@ __export(files_exports, {
|
|
|
28
30
|
updatePackageJsonEnv: () => updatePackageJsonEnv
|
|
29
31
|
});
|
|
30
32
|
module.exports = __toCommonJS(files_exports);
|
|
31
|
-
var import_node_child_process = require("node:child_process")
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
var import_node_child_process = require("node:child_process");
|
|
34
|
+
var import_node_fs = require("node:fs");
|
|
35
|
+
var import_node_path = require("node:path");
|
|
34
36
|
function updatePackageJson(cwd, updates) {
|
|
35
37
|
const packagePath = (0, import_node_path.join)(cwd, "package.json");
|
|
36
|
-
if (!(0, import_node_fs.existsSync)(packagePath))
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
if (!(0, import_node_fs.existsSync)(packagePath)) {
|
|
39
|
+
return {
|
|
40
|
+
success: false,
|
|
41
|
+
error: "package.json not found"
|
|
42
|
+
};
|
|
43
|
+
}
|
|
40
44
|
try {
|
|
41
|
-
const content = (0, import_node_fs.readFileSync)(packagePath, "utf-8")
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
const content = (0, import_node_fs.readFileSync)(packagePath, "utf-8");
|
|
46
|
+
const pkg = JSON.parse(content);
|
|
47
|
+
if (updates.name) pkg.name = updates.name;
|
|
48
|
+
if (updates.description) pkg.description = updates.description;
|
|
49
|
+
(0, import_node_fs.writeFileSync)(packagePath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
50
|
+
return {
|
|
51
|
+
success: true
|
|
46
52
|
};
|
|
47
53
|
} catch (error) {
|
|
48
54
|
return {
|
|
49
|
-
success:
|
|
55
|
+
success: false,
|
|
50
56
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
51
57
|
};
|
|
52
58
|
}
|
|
53
59
|
}
|
|
54
60
|
function updateAppConfig(cwd, updates) {
|
|
55
61
|
const configPath = (0, import_node_path.join)(cwd, "app.config.ts");
|
|
56
|
-
if (!(0, import_node_fs.existsSync)(configPath))
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
if (!(0, import_node_fs.existsSync)(configPath)) {
|
|
63
|
+
return {
|
|
64
|
+
success: false,
|
|
65
|
+
error: "app.config.ts not found"
|
|
66
|
+
};
|
|
67
|
+
}
|
|
60
68
|
try {
|
|
61
69
|
let content = (0, import_node_fs.readFileSync)(configPath, "utf-8");
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
if (updates.name) {
|
|
71
|
+
content = content.replace(/(name:\s*['"])([^'"]+)(['"])/, `$1${updates.name}$3`);
|
|
72
|
+
}
|
|
73
|
+
if (updates.slug) {
|
|
74
|
+
content = content.replace(/(slug:\s*['"])([^'"]+)(['"])/, `$1${updates.slug}$3`);
|
|
75
|
+
}
|
|
76
|
+
if (updates.bundleId) {
|
|
77
|
+
content = content.replace(/(bundleIdentifier:\s*['"])([^'"]+)(['"])/, `$1${updates.bundleId}$3`);
|
|
78
|
+
content = content.replace(/(package:\s*['"])([^'"]+)(['"])/, `$1${updates.bundleId}$3`);
|
|
79
|
+
}
|
|
80
|
+
(0, import_node_fs.writeFileSync)(configPath, content, "utf-8");
|
|
81
|
+
return {
|
|
82
|
+
success: true
|
|
64
83
|
};
|
|
65
84
|
} catch (error) {
|
|
66
85
|
return {
|
|
67
|
-
success:
|
|
86
|
+
success: false,
|
|
68
87
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
69
88
|
};
|
|
70
89
|
}
|
|
71
90
|
}
|
|
72
91
|
function checkOnboarded(cwd) {
|
|
73
92
|
const packagePath = (0, import_node_path.join)(cwd, "package.json");
|
|
74
|
-
if (!(0, import_node_fs.existsSync)(packagePath)) return
|
|
93
|
+
if (!(0, import_node_fs.existsSync)(packagePath)) return false;
|
|
75
94
|
try {
|
|
76
|
-
|
|
95
|
+
const pkg = JSON.parse((0, import_node_fs.readFileSync)(packagePath, "utf-8"));
|
|
96
|
+
return pkg.takeout?.onboarded === true;
|
|
77
97
|
} catch {
|
|
78
|
-
return
|
|
98
|
+
return false;
|
|
79
99
|
}
|
|
80
100
|
}
|
|
81
101
|
function markOnboarded(cwd) {
|
|
82
102
|
const packagePath = (0, import_node_path.join)(cwd, "package.json");
|
|
83
|
-
if (!(0, import_node_fs.existsSync)(packagePath))
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
103
|
+
if (!(0, import_node_fs.existsSync)(packagePath)) {
|
|
104
|
+
return {
|
|
105
|
+
success: false,
|
|
106
|
+
error: "package.json not found"
|
|
107
|
+
};
|
|
108
|
+
}
|
|
87
109
|
try {
|
|
88
|
-
const content = (0, import_node_fs.readFileSync)(packagePath, "utf-8")
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
110
|
+
const content = (0, import_node_fs.readFileSync)(packagePath, "utf-8");
|
|
111
|
+
const pkg = JSON.parse(content);
|
|
112
|
+
if (!pkg.takeout) {
|
|
113
|
+
pkg.takeout = {};
|
|
114
|
+
}
|
|
115
|
+
pkg.takeout.onboarded = true;
|
|
116
|
+
(0, import_node_fs.writeFileSync)(packagePath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
117
|
+
return {
|
|
118
|
+
success: true
|
|
93
119
|
};
|
|
94
120
|
} catch (error) {
|
|
95
121
|
return {
|
|
96
|
-
success:
|
|
122
|
+
success: false,
|
|
97
123
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
98
124
|
};
|
|
99
125
|
}
|
|
100
126
|
}
|
|
101
127
|
function updatePackageJsonEnv(cwd, platform) {
|
|
102
128
|
const packagePath = (0, import_node_path.join)(cwd, "package.json");
|
|
103
|
-
if (!(0, import_node_fs.existsSync)(packagePath))
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
129
|
+
if (!(0, import_node_fs.existsSync)(packagePath)) {
|
|
130
|
+
return {
|
|
131
|
+
success: false,
|
|
132
|
+
error: "package.json not found"
|
|
133
|
+
};
|
|
134
|
+
}
|
|
107
135
|
try {
|
|
108
|
-
const content = (0, import_node_fs.readFileSync)(packagePath, "utf-8")
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
136
|
+
const content = (0, import_node_fs.readFileSync)(packagePath, "utf-8");
|
|
137
|
+
const pkg = JSON.parse(content);
|
|
138
|
+
if (!pkg.env) {
|
|
139
|
+
return {
|
|
140
|
+
success: false,
|
|
141
|
+
error: "env section not found in package.json"
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (platform === "sst") {
|
|
145
|
+
delete pkg.env.DEPLOY_HOST;
|
|
146
|
+
delete pkg.env.DEPLOY_USER;
|
|
147
|
+
delete pkg.env.DEPLOY_SSH_KEY;
|
|
148
|
+
} else if (platform === "uncloud") {
|
|
149
|
+
delete pkg.env.CLOUDFLARE_API_TOKEN;
|
|
150
|
+
delete pkg.env.AWS_ACCESS_KEY_ID;
|
|
151
|
+
delete pkg.env.AWS_SECRET_ACCESS_KEY;
|
|
152
|
+
}
|
|
153
|
+
(0, import_node_fs.writeFileSync)(packagePath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
154
|
+
return {
|
|
155
|
+
success: true
|
|
116
156
|
};
|
|
117
157
|
} catch (error) {
|
|
118
158
|
return {
|
|
119
|
-
success:
|
|
159
|
+
success: false,
|
|
120
160
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
121
161
|
};
|
|
122
162
|
}
|
|
123
163
|
}
|
|
124
164
|
async function ejectFromMonorepo(cwd, options = {}) {
|
|
125
165
|
const {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (!(0, import_node_fs.existsSync)(packagePath))
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
166
|
+
dryRun = false
|
|
167
|
+
} = options;
|
|
168
|
+
const packagePath = (0, import_node_path.join)(cwd, "package.json");
|
|
169
|
+
const packagesDir = (0, import_node_path.join)(cwd, "packages");
|
|
170
|
+
const warnings = [];
|
|
171
|
+
if (!(0, import_node_fs.existsSync)(packagePath)) {
|
|
172
|
+
return {
|
|
173
|
+
success: false,
|
|
174
|
+
error: "package.json not found"
|
|
175
|
+
};
|
|
176
|
+
}
|
|
135
177
|
try {
|
|
136
|
-
const content = (0, import_node_fs.readFileSync)(packagePath, "utf-8")
|
|
137
|
-
|
|
138
|
-
if (!(0, import_node_fs.existsSync)(packagesDir))
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
178
|
+
const content = (0, import_node_fs.readFileSync)(packagePath, "utf-8");
|
|
179
|
+
const pkg = JSON.parse(content);
|
|
180
|
+
if (!(0, import_node_fs.existsSync)(packagesDir)) {
|
|
181
|
+
return {
|
|
182
|
+
success: false,
|
|
183
|
+
error: "packages directory not found - already ejected?"
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
if (!pkg.workspaces) {
|
|
187
|
+
return {
|
|
188
|
+
success: false,
|
|
189
|
+
error: "no workspaces field found - already ejected?"
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
const workspacePackages = [];
|
|
193
|
+
const entries = (0, import_node_fs.readdirSync)(packagesDir, {
|
|
194
|
+
withFileTypes: true
|
|
195
|
+
});
|
|
150
196
|
for (const entry of entries) {
|
|
151
197
|
if (!entry.isDirectory()) continue;
|
|
152
198
|
const pkgJsonPath = (0, import_node_path.join)(packagesDir, entry.name, "package.json");
|
|
153
|
-
if ((0, import_node_fs.existsSync)(pkgJsonPath))
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
name
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
199
|
+
if ((0, import_node_fs.existsSync)(pkgJsonPath)) {
|
|
200
|
+
try {
|
|
201
|
+
const pkgJson = JSON.parse((0, import_node_fs.readFileSync)(pkgJsonPath, "utf-8"));
|
|
202
|
+
if (pkgJson.name && pkgJson.version) {
|
|
203
|
+
workspacePackages.push({
|
|
204
|
+
name: pkgJson.name,
|
|
205
|
+
version: pkgJson.version
|
|
206
|
+
});
|
|
207
|
+
} else {
|
|
208
|
+
warnings.push(`skipped ${entry.name}: missing name or version`);
|
|
209
|
+
}
|
|
210
|
+
} catch (e) {
|
|
211
|
+
warnings.push(`skipped ${entry.name}: invalid package.json`);
|
|
212
|
+
}
|
|
161
213
|
}
|
|
162
214
|
}
|
|
163
|
-
if (workspacePackages.length === 0)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const unresolvedDeps = [],
|
|
168
|
-
allDeps = {
|
|
169
|
-
...pkg.dependencies,
|
|
170
|
-
...pkg.devDependencies
|
|
215
|
+
if (workspacePackages.length === 0) {
|
|
216
|
+
return {
|
|
217
|
+
success: false,
|
|
218
|
+
error: "no valid workspace packages found"
|
|
171
219
|
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
};
|
|
178
|
-
if (dryRun) return {
|
|
179
|
-
success: !0,
|
|
180
|
-
packages: workspacePackages,
|
|
181
|
-
warnings: warnings.length > 0 ? warnings : void 0
|
|
220
|
+
}
|
|
221
|
+
const unresolvedDeps = [];
|
|
222
|
+
const allDeps = {
|
|
223
|
+
...pkg.dependencies,
|
|
224
|
+
...pkg.devDependencies
|
|
182
225
|
};
|
|
226
|
+
for (const [name, version] of Object.entries(allDeps)) {
|
|
227
|
+
if (version === "workspace:*") {
|
|
228
|
+
const found = workspacePackages.find(p => p.name === name);
|
|
229
|
+
if (!found) {
|
|
230
|
+
unresolvedDeps.push(name);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (unresolvedDeps.length > 0) {
|
|
235
|
+
return {
|
|
236
|
+
success: false,
|
|
237
|
+
error: `unresolved workspace dependencies: ${unresolvedDeps.join(", ")}`,
|
|
238
|
+
packages: workspacePackages
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
if (dryRun) {
|
|
242
|
+
return {
|
|
243
|
+
success: true,
|
|
244
|
+
packages: workspacePackages,
|
|
245
|
+
warnings: warnings.length > 0 ? warnings : void 0
|
|
246
|
+
};
|
|
247
|
+
}
|
|
183
248
|
for (const {
|
|
184
249
|
name,
|
|
185
250
|
version
|
|
186
|
-
} of workspacePackages)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
251
|
+
} of workspacePackages) {
|
|
252
|
+
if (pkg.dependencies?.[name] === "workspace:*") {
|
|
253
|
+
pkg.dependencies[name] = `^${version}`;
|
|
254
|
+
}
|
|
255
|
+
if (pkg.devDependencies?.[name] === "workspace:*") {
|
|
256
|
+
pkg.devDependencies[name] = `^${version}`;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
delete pkg.workspaces;
|
|
260
|
+
(0, import_node_fs.writeFileSync)(packagePath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
261
|
+
(0, import_node_fs.rmSync)(packagesDir, {
|
|
262
|
+
recursive: true,
|
|
263
|
+
force: true
|
|
191
264
|
});
|
|
192
265
|
try {
|
|
193
266
|
(0, import_node_child_process.execSync)("bun install", {
|
|
@@ -196,19 +269,19 @@ async function ejectFromMonorepo(cwd, options = {}) {
|
|
|
196
269
|
});
|
|
197
270
|
} catch {
|
|
198
271
|
return {
|
|
199
|
-
success:
|
|
272
|
+
success: false,
|
|
200
273
|
error: 'failed to install published packages. package.json was modified but install failed. try running "bun install" manually, or restore from git.',
|
|
201
274
|
packages: workspacePackages
|
|
202
275
|
};
|
|
203
276
|
}
|
|
204
277
|
return {
|
|
205
|
-
success:
|
|
278
|
+
success: true,
|
|
206
279
|
packages: workspacePackages,
|
|
207
280
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
208
281
|
};
|
|
209
282
|
} catch (error) {
|
|
210
283
|
return {
|
|
211
|
-
success:
|
|
284
|
+
success: false,
|
|
212
285
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
213
286
|
};
|
|
214
287
|
}
|
|
@@ -3,44 +3,46 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var parallel_runner_exports = {};
|
|
22
24
|
__export(parallel_runner_exports, {
|
|
23
25
|
runScriptsInParallel: () => runScriptsInParallel
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(parallel_runner_exports);
|
|
26
|
-
var import_node_child_process = require("node:child_process")
|
|
27
|
-
|
|
28
|
+
var import_node_child_process = require("node:child_process");
|
|
29
|
+
var import_node_os = require("node:os");
|
|
28
30
|
const colors = ["\x1B[36m",
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
// Cyan
|
|
32
|
+
"\x1B[35m",
|
|
33
|
+
// Magenta
|
|
34
|
+
"\x1B[33m",
|
|
35
|
+
// Yellow
|
|
36
|
+
"\x1B[32m",
|
|
37
|
+
// Green
|
|
38
|
+
"\x1B[34m",
|
|
39
|
+
// Blue
|
|
40
|
+
"\x1B[31m",
|
|
41
|
+
// Red
|
|
42
|
+
"\x1B[90m"
|
|
43
|
+
// Gray
|
|
44
|
+
];
|
|
45
|
+
const reset = "\x1B[0m";
|
|
44
46
|
function isBunShellNoise(line) {
|
|
45
47
|
const stripped = line.replace(/\x1b\[[0-9;]*m/g, "").trim();
|
|
46
48
|
return stripped.startsWith("ShellError:") || stripped.startsWith("exitCode:") || stripped.startsWith("stdout:") || stripped.startsWith("stderr:") || stripped.startsWith("at ShellPromise") || stripped.startsWith("at BunShell") || stripped.startsWith("Bun v") || /^\d+\s*\|/.test(stripped) ||
|
|
@@ -48,21 +50,29 @@ function isBunShellNoise(line) {
|
|
|
48
50
|
/^\s*\^$/.test(stripped);
|
|
49
51
|
}
|
|
50
52
|
const spawnedProcesses = [];
|
|
51
|
-
let cleaning =
|
|
53
|
+
let cleaning = false;
|
|
52
54
|
function killAllProcessGroups(signal = "SIGTERM") {
|
|
53
|
-
for (const proc of spawnedProcesses)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
for (const proc of spawnedProcesses) {
|
|
56
|
+
if (proc.pid) {
|
|
57
|
+
try {
|
|
58
|
+
process.kill(-proc.pid, signal);
|
|
59
|
+
} catch (_) {
|
|
60
|
+
try {
|
|
61
|
+
process.kill(proc.pid, signal);
|
|
62
|
+
} catch (_2) {}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
67
|
function cleanupAndExit() {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
if (cleaning) return;
|
|
69
|
+
cleaning = true;
|
|
70
|
+
process.stdout.write("\n\x1B[0m");
|
|
71
|
+
killAllProcessGroups("SIGTERM");
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
killAllProcessGroups("SIGKILL");
|
|
74
|
+
process.exit(0);
|
|
75
|
+
}, 150);
|
|
66
76
|
}
|
|
67
77
|
process.on("SIGINT", cleanupAndExit);
|
|
68
78
|
process.on("SIGTERM", cleanupAndExit);
|
|
@@ -72,56 +82,96 @@ async function runScriptsInParallel(scripts, options = {}) {
|
|
|
72
82
|
onError = "exit",
|
|
73
83
|
maxParallelism = (0, import_node_os.cpus)().length
|
|
74
84
|
} = options;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
85
|
+
if (title) {
|
|
86
|
+
console.info();
|
|
87
|
+
console.info(title);
|
|
88
|
+
console.info();
|
|
89
|
+
}
|
|
90
|
+
const allPromises = [];
|
|
91
|
+
const executing = /* @__PURE__ */new Set();
|
|
78
92
|
for (let i = 0; i < scripts.length; i++) {
|
|
79
|
-
const script = scripts[i]
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
allPromises.push(scriptPromise)
|
|
93
|
+
const script = scripts[i];
|
|
94
|
+
const scriptPromise = runSingleScript(script, i).finally(() => {
|
|
95
|
+
executing.delete(scriptPromise);
|
|
96
|
+
});
|
|
97
|
+
allPromises.push(scriptPromise);
|
|
98
|
+
executing.add(scriptPromise);
|
|
99
|
+
if (executing.size >= maxParallelism) {
|
|
100
|
+
await Promise.race(executing);
|
|
101
|
+
}
|
|
84
102
|
}
|
|
85
|
-
const
|
|
86
|
-
failures.
|
|
103
|
+
const settledResults = await Promise.allSettled(allPromises);
|
|
104
|
+
const failures = settledResults.filter(r => r.status === "rejected");
|
|
105
|
+
if (failures.length > 0) {
|
|
106
|
+
console.error(`
|
|
87
107
|
${reset}\x1B[31m\u2717 ${failures.length} script(s) failed${reset}
|
|
88
|
-
`)
|
|
108
|
+
`);
|
|
109
|
+
if (onError === "exit") {
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
console.info(`
|
|
89
114
|
${reset}\x1B[32m\u2713 All scripts completed successfully${reset}
|
|
90
115
|
`);
|
|
116
|
+
}
|
|
91
117
|
}
|
|
92
118
|
function runSingleScript(script, colorIndex) {
|
|
93
119
|
return new Promise((resolve, reject) => {
|
|
94
|
-
const color = colors[colorIndex % colors.length]
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
120
|
+
const color = colors[colorIndex % colors.length];
|
|
121
|
+
const prefixLabel = script.name;
|
|
122
|
+
const proc = (0, import_node_child_process.spawn)("bun", [script.path, ...(script.args || [])], {
|
|
123
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
124
|
+
shell: false,
|
|
125
|
+
env: {
|
|
126
|
+
...process.env,
|
|
127
|
+
FORCE_COLOR: "3",
|
|
128
|
+
TKO_IS_RUNNING_ALL: "1"
|
|
129
|
+
},
|
|
130
|
+
detached: true
|
|
131
|
+
});
|
|
106
132
|
spawnedProcesses.push(proc);
|
|
107
133
|
let stderrBuffer = "";
|
|
108
134
|
proc.stdout.on("data", data => {
|
|
109
135
|
if (cleaning) return;
|
|
110
|
-
const lines = data.toString().split(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
136
|
+
const lines = data.toString().split("\n");
|
|
137
|
+
for (const line of lines) {
|
|
138
|
+
if (line) console.info(`${color}${prefixLabel}${reset} ${line}`);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
proc.stderr.on("data", data => {
|
|
114
142
|
const dataStr = data.toString();
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
for (const line of lines)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
143
|
+
stderrBuffer += dataStr;
|
|
144
|
+
if (cleaning) return;
|
|
145
|
+
const lines = dataStr.split("\n");
|
|
146
|
+
for (const line of lines) {
|
|
147
|
+
if (line && !isBunShellNoise(line)) {
|
|
148
|
+
console.error(`${color}${prefixLabel}${reset} ${line}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
proc.on("error", error => {
|
|
153
|
+
console.error(`${color}${prefixLabel}${reset} Failed to start: ${error.message}`);
|
|
154
|
+
reject(error);
|
|
155
|
+
});
|
|
156
|
+
proc.on("close", code => {
|
|
157
|
+
if (cleaning) return;
|
|
158
|
+
if (code && code !== 0) {
|
|
159
|
+
const isBunShellError = stderrBuffer.includes("ShellError") || stderrBuffer.includes("at BunShell");
|
|
160
|
+
if (!isBunShellError) {
|
|
161
|
+
console.error(`${color}${prefixLabel}${reset} Process exited with code ${code}`);
|
|
162
|
+
if (stderrBuffer.trim()) {
|
|
163
|
+
console.error(`
|
|
164
|
+
${color}${prefixLabel}${reset} Error output:`);
|
|
165
|
+
console.error("\x1B[90m" + "\u2500".repeat(80) + "\x1B[0m");
|
|
166
|
+
console.error(stderrBuffer);
|
|
167
|
+
console.error("\x1B[90m" + "\u2500".repeat(80) + "\x1B[0m\n");
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
reject(new Error(`Script ${prefixLabel} failed with code ${code}`));
|
|
171
|
+
} else {
|
|
172
|
+
console.info(`${color}${prefixLabel}${reset} \x1B[32m\u2713 completed${reset}`);
|
|
173
|
+
resolve();
|
|
174
|
+
}
|
|
125
175
|
});
|
|
126
176
|
});
|
|
127
177
|
}
|