@shogo-ai/cli 1.10.0 → 2.4.1
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/{chunk-L635SMF7.js → chunk-HCXMH2GQ.js} +92 -13
- package/dist/index.cjs +101 -12
- package/dist/index.js +1 -1
- package/dist/pkg.cjs +103 -12
- package/dist/pkg.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,80 @@
|
|
|
1
|
+
// src/child-process.ts
|
|
2
|
+
import * as cp from "child_process";
|
|
3
|
+
import { promisify } from "util";
|
|
4
|
+
function isOptions(value) {
|
|
5
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
function mergeHide(opts) {
|
|
8
|
+
if (opts.windowsHide !== void 0) return opts;
|
|
9
|
+
return { ...opts, windowsHide: true };
|
|
10
|
+
}
|
|
11
|
+
function hideExecArgs(args) {
|
|
12
|
+
const out = args.slice();
|
|
13
|
+
const slot = out[1];
|
|
14
|
+
if (out.length < 2 || typeof slot === "function") {
|
|
15
|
+
out.splice(1, 0, { windowsHide: true });
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
if (slot == null) {
|
|
19
|
+
out[1] = { windowsHide: true };
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
if (isOptions(slot)) {
|
|
23
|
+
out[1] = mergeHide(slot);
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
function hideSpawnArgs(args) {
|
|
29
|
+
const out = args.slice();
|
|
30
|
+
let callbackAt = -1;
|
|
31
|
+
for (let i = 1; i < out.length; i++) {
|
|
32
|
+
if (typeof out[i] === "function") {
|
|
33
|
+
callbackAt = i;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const end = callbackAt === -1 ? out.length : callbackAt;
|
|
38
|
+
for (let i = 1; i < end; i++) {
|
|
39
|
+
if (isOptions(out[i])) {
|
|
40
|
+
out[i] = mergeHide(out[i]);
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const slot = end > 1 && (Array.isArray(out[1]) || out[1] == null) ? 2 : 1;
|
|
45
|
+
if (slot >= end) out.splice(end, 0, { windowsHide: true });
|
|
46
|
+
else if (out[slot] == null) out[slot] = { windowsHide: true };
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
var customPromisify = promisify.custom;
|
|
50
|
+
function wrap(hide, getFn) {
|
|
51
|
+
const wrapped = function(...args) {
|
|
52
|
+
const fn = getFn();
|
|
53
|
+
return Reflect.apply(fn, this, hide(args));
|
|
54
|
+
};
|
|
55
|
+
Object.defineProperty(wrapped, customPromisify, {
|
|
56
|
+
enumerable: false,
|
|
57
|
+
configurable: true,
|
|
58
|
+
writable: false,
|
|
59
|
+
value(...args) {
|
|
60
|
+
const fn = getFn();
|
|
61
|
+
const custom = fn[customPromisify];
|
|
62
|
+
if (typeof custom === "function") return Reflect.apply(custom, fn, hide(args));
|
|
63
|
+
const promisified = promisify(fn);
|
|
64
|
+
return Reflect.apply(promisified, this, hide(args));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return wrapped;
|
|
68
|
+
}
|
|
69
|
+
var spawn2 = wrap(hideSpawnArgs, () => cp.spawn);
|
|
70
|
+
var spawnSync2 = wrap(hideSpawnArgs, () => cp.spawnSync);
|
|
71
|
+
var exec2 = wrap(hideExecArgs, () => cp.exec);
|
|
72
|
+
var execSync2 = wrap(hideExecArgs, () => cp.execSync);
|
|
73
|
+
var execFile2 = wrap(hideSpawnArgs, () => cp.execFile);
|
|
74
|
+
var execFileSync2 = wrap(hideSpawnArgs, () => cp.execFileSync);
|
|
75
|
+
var fork2 = wrap(hideSpawnArgs, () => cp.fork);
|
|
76
|
+
|
|
1
77
|
// src/pkg.ts
|
|
2
|
-
import { execSync as nodeExecSync, spawn } from "child_process";
|
|
3
78
|
import { existsSync, readlinkSync, lstatSync } from "fs";
|
|
4
79
|
import { isAbsolute, join, resolve as resolvePath, dirname } from "path";
|
|
5
80
|
var NodeMissingError = class extends Error {
|
|
@@ -106,7 +181,7 @@ var PlatformPackageManager = class {
|
|
|
106
181
|
if (IS_WINDOWS) {
|
|
107
182
|
if (isNodeAvailableOnWindows(env.PATH)) {
|
|
108
183
|
try {
|
|
109
|
-
|
|
184
|
+
execSync2("npm.cmd install --loglevel=error", {
|
|
110
185
|
cwd,
|
|
111
186
|
timeout,
|
|
112
187
|
stdio,
|
|
@@ -121,7 +196,7 @@ var PlatformPackageManager = class {
|
|
|
121
196
|
console.warn(
|
|
122
197
|
"[platform-pkg] npm install hit ERESOLVE \u2014 retrying with --legacy-peer-deps."
|
|
123
198
|
);
|
|
124
|
-
|
|
199
|
+
execSync2("npm.cmd install --loglevel=error --legacy-peer-deps", {
|
|
125
200
|
cwd,
|
|
126
201
|
timeout,
|
|
127
202
|
stdio,
|
|
@@ -140,12 +215,12 @@ var PlatformPackageManager = class {
|
|
|
140
215
|
const bun = this.bunBinary;
|
|
141
216
|
if (opts?.frozen) {
|
|
142
217
|
try {
|
|
143
|
-
|
|
218
|
+
execSync2(`"${bun}" install --frozen-lockfile 2>&1`, { cwd, timeout, stdio, env });
|
|
144
219
|
return;
|
|
145
220
|
} catch {
|
|
146
221
|
}
|
|
147
222
|
}
|
|
148
|
-
|
|
223
|
+
execSync2(`"${bun}" install`, { cwd, timeout, stdio, env });
|
|
149
224
|
}
|
|
150
225
|
/**
|
|
151
226
|
* Windows-only fallback path: `bun install [--frozen-lockfile]
|
|
@@ -170,7 +245,7 @@ var PlatformPackageManager = class {
|
|
|
170
245
|
);
|
|
171
246
|
if (opts?.frozen) {
|
|
172
247
|
try {
|
|
173
|
-
|
|
248
|
+
execSync2(`"${bun}" install --frozen-lockfile --backend=copyfile`, {
|
|
174
249
|
cwd,
|
|
175
250
|
timeout,
|
|
176
251
|
stdio,
|
|
@@ -180,7 +255,7 @@ var PlatformPackageManager = class {
|
|
|
180
255
|
} catch {
|
|
181
256
|
}
|
|
182
257
|
}
|
|
183
|
-
|
|
258
|
+
execSync2(`"${bun}" install --backend=copyfile`, { cwd, timeout, stdio, env });
|
|
184
259
|
}
|
|
185
260
|
// ---------------------------------------------------------------------------
|
|
186
261
|
// Install — async with spawn (used by RuntimeManager)
|
|
@@ -188,7 +263,8 @@ var PlatformPackageManager = class {
|
|
|
188
263
|
installAsync(cwd, opts) {
|
|
189
264
|
if (IS_WINDOWS) {
|
|
190
265
|
const env = this.spawnEnv(opts?.env);
|
|
191
|
-
|
|
266
|
+
const requestedBackend = env.SHOGO_WINDOWS_INSTALL_BACKEND?.toLowerCase();
|
|
267
|
+
if (requestedBackend !== "bun" && isNodeAvailableOnWindows(env.PATH)) {
|
|
192
268
|
return this.installAsyncWindowsNpm(cwd, opts).catch((err) => {
|
|
193
269
|
if (err instanceof NodeMissingError) {
|
|
194
270
|
return this.installAsyncBunCopyfile(cwd, opts);
|
|
@@ -196,6 +272,9 @@ var PlatformPackageManager = class {
|
|
|
196
272
|
throw err;
|
|
197
273
|
});
|
|
198
274
|
}
|
|
275
|
+
if (requestedBackend === "bun") {
|
|
276
|
+
console.log("[platform-pkg] Windows install backend=bun (copyfile)");
|
|
277
|
+
}
|
|
199
278
|
return this.installAsyncBunCopyfile(cwd, opts);
|
|
200
279
|
}
|
|
201
280
|
return this.installAsyncBun(cwd, opts);
|
|
@@ -205,7 +284,7 @@ var PlatformPackageManager = class {
|
|
|
205
284
|
const env = this.spawnEnv(opts?.env);
|
|
206
285
|
const cmd = "npm.cmd";
|
|
207
286
|
const runOnce = (extraArgs) => new Promise((resolvePromise, rejectPromise) => {
|
|
208
|
-
const proc =
|
|
287
|
+
const proc = spawn2(cmd, ["install", "--loglevel=error", ...extraArgs], {
|
|
209
288
|
cwd,
|
|
210
289
|
stdio: "pipe",
|
|
211
290
|
env,
|
|
@@ -263,7 +342,7 @@ ${first.stderr}`);
|
|
|
263
342
|
const baseArgs = ["install", ...extraArgs];
|
|
264
343
|
const frozenArgs = opts?.frozen ? ["install", "--frozen-lockfile", ...extraArgs] : null;
|
|
265
344
|
const runOnce = (args) => new Promise((resolve, reject) => {
|
|
266
|
-
const proc =
|
|
345
|
+
const proc = spawn2(bun, args, {
|
|
267
346
|
cwd,
|
|
268
347
|
stdio: "pipe",
|
|
269
348
|
env
|
|
@@ -309,7 +388,7 @@ ${first.stderr}`);
|
|
|
309
388
|
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
310
389
|
const bun = this.bunBinary;
|
|
311
390
|
const cmd = IS_WINDOWS ? `npx ${tool}${argStr}` : `"${bun}" x ${opts?.useBunFlag ? "--bun " : ""}${tool}${argStr}`;
|
|
312
|
-
return
|
|
391
|
+
return execSync2(cmd, {
|
|
313
392
|
cwd,
|
|
314
393
|
timeout,
|
|
315
394
|
stdio,
|
|
@@ -353,7 +432,7 @@ ${first.stderr}`);
|
|
|
353
432
|
useShell = false;
|
|
354
433
|
}
|
|
355
434
|
return new Promise((resolvePromise, rejectPromise) => {
|
|
356
|
-
const proc =
|
|
435
|
+
const proc = spawn2(cmd, argv, {
|
|
357
436
|
cwd,
|
|
358
437
|
env,
|
|
359
438
|
stdio,
|
|
@@ -463,4 +542,4 @@ export {
|
|
|
463
542
|
isEresolveStderr,
|
|
464
543
|
pkg
|
|
465
544
|
};
|
|
466
|
-
//# sourceMappingURL=chunk-
|
|
545
|
+
//# sourceMappingURL=chunk-HCXMH2GQ.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -255,8 +265,83 @@ async function runDeploy(options) {
|
|
|
255
265
|
return { status: res.status, body };
|
|
256
266
|
}
|
|
257
267
|
|
|
268
|
+
// src/child-process.ts
|
|
269
|
+
var cp = __toESM(require("child_process"), 1);
|
|
270
|
+
var import_node_util = require("util");
|
|
271
|
+
function isOptions(value) {
|
|
272
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
273
|
+
}
|
|
274
|
+
function mergeHide(opts) {
|
|
275
|
+
if (opts.windowsHide !== void 0) return opts;
|
|
276
|
+
return { ...opts, windowsHide: true };
|
|
277
|
+
}
|
|
278
|
+
function hideExecArgs(args) {
|
|
279
|
+
const out = args.slice();
|
|
280
|
+
const slot = out[1];
|
|
281
|
+
if (out.length < 2 || typeof slot === "function") {
|
|
282
|
+
out.splice(1, 0, { windowsHide: true });
|
|
283
|
+
return out;
|
|
284
|
+
}
|
|
285
|
+
if (slot == null) {
|
|
286
|
+
out[1] = { windowsHide: true };
|
|
287
|
+
return out;
|
|
288
|
+
}
|
|
289
|
+
if (isOptions(slot)) {
|
|
290
|
+
out[1] = mergeHide(slot);
|
|
291
|
+
return out;
|
|
292
|
+
}
|
|
293
|
+
return out;
|
|
294
|
+
}
|
|
295
|
+
function hideSpawnArgs(args) {
|
|
296
|
+
const out = args.slice();
|
|
297
|
+
let callbackAt = -1;
|
|
298
|
+
for (let i = 1; i < out.length; i++) {
|
|
299
|
+
if (typeof out[i] === "function") {
|
|
300
|
+
callbackAt = i;
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const end = callbackAt === -1 ? out.length : callbackAt;
|
|
305
|
+
for (let i = 1; i < end; i++) {
|
|
306
|
+
if (isOptions(out[i])) {
|
|
307
|
+
out[i] = mergeHide(out[i]);
|
|
308
|
+
return out;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
const slot = end > 1 && (Array.isArray(out[1]) || out[1] == null) ? 2 : 1;
|
|
312
|
+
if (slot >= end) out.splice(end, 0, { windowsHide: true });
|
|
313
|
+
else if (out[slot] == null) out[slot] = { windowsHide: true };
|
|
314
|
+
return out;
|
|
315
|
+
}
|
|
316
|
+
var customPromisify = import_node_util.promisify.custom;
|
|
317
|
+
function wrap(hide, getFn) {
|
|
318
|
+
const wrapped = function(...args) {
|
|
319
|
+
const fn = getFn();
|
|
320
|
+
return Reflect.apply(fn, this, hide(args));
|
|
321
|
+
};
|
|
322
|
+
Object.defineProperty(wrapped, customPromisify, {
|
|
323
|
+
enumerable: false,
|
|
324
|
+
configurable: true,
|
|
325
|
+
writable: false,
|
|
326
|
+
value(...args) {
|
|
327
|
+
const fn = getFn();
|
|
328
|
+
const custom = fn[customPromisify];
|
|
329
|
+
if (typeof custom === "function") return Reflect.apply(custom, fn, hide(args));
|
|
330
|
+
const promisified = (0, import_node_util.promisify)(fn);
|
|
331
|
+
return Reflect.apply(promisified, this, hide(args));
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
return wrapped;
|
|
335
|
+
}
|
|
336
|
+
var spawn2 = wrap(hideSpawnArgs, () => cp.spawn);
|
|
337
|
+
var spawnSync2 = wrap(hideSpawnArgs, () => cp.spawnSync);
|
|
338
|
+
var exec2 = wrap(hideExecArgs, () => cp.exec);
|
|
339
|
+
var execSync2 = wrap(hideExecArgs, () => cp.execSync);
|
|
340
|
+
var execFile2 = wrap(hideSpawnArgs, () => cp.execFile);
|
|
341
|
+
var execFileSync2 = wrap(hideSpawnArgs, () => cp.execFileSync);
|
|
342
|
+
var fork2 = wrap(hideSpawnArgs, () => cp.fork);
|
|
343
|
+
|
|
258
344
|
// src/pkg.ts
|
|
259
|
-
var import_node_child_process = require("child_process");
|
|
260
345
|
var import_node_fs = require("fs");
|
|
261
346
|
var import_node_path = require("path");
|
|
262
347
|
var NodeMissingError = class extends Error {
|
|
@@ -363,7 +448,7 @@ var PlatformPackageManager = class {
|
|
|
363
448
|
if (IS_WINDOWS) {
|
|
364
449
|
if (isNodeAvailableOnWindows(env.PATH)) {
|
|
365
450
|
try {
|
|
366
|
-
(
|
|
451
|
+
execSync2("npm.cmd install --loglevel=error", {
|
|
367
452
|
cwd,
|
|
368
453
|
timeout,
|
|
369
454
|
stdio,
|
|
@@ -378,7 +463,7 @@ var PlatformPackageManager = class {
|
|
|
378
463
|
console.warn(
|
|
379
464
|
"[platform-pkg] npm install hit ERESOLVE \u2014 retrying with --legacy-peer-deps."
|
|
380
465
|
);
|
|
381
|
-
(
|
|
466
|
+
execSync2("npm.cmd install --loglevel=error --legacy-peer-deps", {
|
|
382
467
|
cwd,
|
|
383
468
|
timeout,
|
|
384
469
|
stdio,
|
|
@@ -397,12 +482,12 @@ var PlatformPackageManager = class {
|
|
|
397
482
|
const bun = this.bunBinary;
|
|
398
483
|
if (opts?.frozen) {
|
|
399
484
|
try {
|
|
400
|
-
(
|
|
485
|
+
execSync2(`"${bun}" install --frozen-lockfile 2>&1`, { cwd, timeout, stdio, env });
|
|
401
486
|
return;
|
|
402
487
|
} catch {
|
|
403
488
|
}
|
|
404
489
|
}
|
|
405
|
-
(
|
|
490
|
+
execSync2(`"${bun}" install`, { cwd, timeout, stdio, env });
|
|
406
491
|
}
|
|
407
492
|
/**
|
|
408
493
|
* Windows-only fallback path: `bun install [--frozen-lockfile]
|
|
@@ -427,7 +512,7 @@ var PlatformPackageManager = class {
|
|
|
427
512
|
);
|
|
428
513
|
if (opts?.frozen) {
|
|
429
514
|
try {
|
|
430
|
-
(
|
|
515
|
+
execSync2(`"${bun}" install --frozen-lockfile --backend=copyfile`, {
|
|
431
516
|
cwd,
|
|
432
517
|
timeout,
|
|
433
518
|
stdio,
|
|
@@ -437,7 +522,7 @@ var PlatformPackageManager = class {
|
|
|
437
522
|
} catch {
|
|
438
523
|
}
|
|
439
524
|
}
|
|
440
|
-
(
|
|
525
|
+
execSync2(`"${bun}" install --backend=copyfile`, { cwd, timeout, stdio, env });
|
|
441
526
|
}
|
|
442
527
|
// ---------------------------------------------------------------------------
|
|
443
528
|
// Install — async with spawn (used by RuntimeManager)
|
|
@@ -445,7 +530,8 @@ var PlatformPackageManager = class {
|
|
|
445
530
|
installAsync(cwd, opts) {
|
|
446
531
|
if (IS_WINDOWS) {
|
|
447
532
|
const env = this.spawnEnv(opts?.env);
|
|
448
|
-
|
|
533
|
+
const requestedBackend = env.SHOGO_WINDOWS_INSTALL_BACKEND?.toLowerCase();
|
|
534
|
+
if (requestedBackend !== "bun" && isNodeAvailableOnWindows(env.PATH)) {
|
|
449
535
|
return this.installAsyncWindowsNpm(cwd, opts).catch((err) => {
|
|
450
536
|
if (err instanceof NodeMissingError) {
|
|
451
537
|
return this.installAsyncBunCopyfile(cwd, opts);
|
|
@@ -453,6 +539,9 @@ var PlatformPackageManager = class {
|
|
|
453
539
|
throw err;
|
|
454
540
|
});
|
|
455
541
|
}
|
|
542
|
+
if (requestedBackend === "bun") {
|
|
543
|
+
console.log("[platform-pkg] Windows install backend=bun (copyfile)");
|
|
544
|
+
}
|
|
456
545
|
return this.installAsyncBunCopyfile(cwd, opts);
|
|
457
546
|
}
|
|
458
547
|
return this.installAsyncBun(cwd, opts);
|
|
@@ -462,7 +551,7 @@ var PlatformPackageManager = class {
|
|
|
462
551
|
const env = this.spawnEnv(opts?.env);
|
|
463
552
|
const cmd = "npm.cmd";
|
|
464
553
|
const runOnce = (extraArgs) => new Promise((resolvePromise, rejectPromise) => {
|
|
465
|
-
const proc = (
|
|
554
|
+
const proc = spawn2(cmd, ["install", "--loglevel=error", ...extraArgs], {
|
|
466
555
|
cwd,
|
|
467
556
|
stdio: "pipe",
|
|
468
557
|
env,
|
|
@@ -520,7 +609,7 @@ ${first.stderr}`);
|
|
|
520
609
|
const baseArgs = ["install", ...extraArgs];
|
|
521
610
|
const frozenArgs = opts?.frozen ? ["install", "--frozen-lockfile", ...extraArgs] : null;
|
|
522
611
|
const runOnce = (args) => new Promise((resolve, reject) => {
|
|
523
|
-
const proc = (
|
|
612
|
+
const proc = spawn2(bun, args, {
|
|
524
613
|
cwd,
|
|
525
614
|
stdio: "pipe",
|
|
526
615
|
env
|
|
@@ -566,7 +655,7 @@ ${first.stderr}`);
|
|
|
566
655
|
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
567
656
|
const bun = this.bunBinary;
|
|
568
657
|
const cmd = IS_WINDOWS ? `npx ${tool}${argStr}` : `"${bun}" x ${opts?.useBunFlag ? "--bun " : ""}${tool}${argStr}`;
|
|
569
|
-
return (
|
|
658
|
+
return execSync2(cmd, {
|
|
570
659
|
cwd,
|
|
571
660
|
timeout,
|
|
572
661
|
stdio,
|
|
@@ -610,7 +699,7 @@ ${first.stderr}`);
|
|
|
610
699
|
useShell = false;
|
|
611
700
|
}
|
|
612
701
|
return new Promise((resolvePromise, rejectPromise) => {
|
|
613
|
-
const proc = (
|
|
702
|
+
const proc = spawn2(cmd, argv, {
|
|
614
703
|
cwd,
|
|
615
704
|
env,
|
|
616
705
|
stdio,
|
package/dist/index.js
CHANGED
package/dist/pkg.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/pkg.ts
|
|
@@ -30,7 +40,84 @@ __export(pkg_exports, {
|
|
|
30
40
|
resolveBinInvocation: () => resolveBinInvocation
|
|
31
41
|
});
|
|
32
42
|
module.exports = __toCommonJS(pkg_exports);
|
|
33
|
-
|
|
43
|
+
|
|
44
|
+
// src/child-process.ts
|
|
45
|
+
var cp = __toESM(require("child_process"), 1);
|
|
46
|
+
var import_node_util = require("util");
|
|
47
|
+
function isOptions(value) {
|
|
48
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
49
|
+
}
|
|
50
|
+
function mergeHide(opts) {
|
|
51
|
+
if (opts.windowsHide !== void 0) return opts;
|
|
52
|
+
return { ...opts, windowsHide: true };
|
|
53
|
+
}
|
|
54
|
+
function hideExecArgs(args) {
|
|
55
|
+
const out = args.slice();
|
|
56
|
+
const slot = out[1];
|
|
57
|
+
if (out.length < 2 || typeof slot === "function") {
|
|
58
|
+
out.splice(1, 0, { windowsHide: true });
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
if (slot == null) {
|
|
62
|
+
out[1] = { windowsHide: true };
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
if (isOptions(slot)) {
|
|
66
|
+
out[1] = mergeHide(slot);
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
function hideSpawnArgs(args) {
|
|
72
|
+
const out = args.slice();
|
|
73
|
+
let callbackAt = -1;
|
|
74
|
+
for (let i = 1; i < out.length; i++) {
|
|
75
|
+
if (typeof out[i] === "function") {
|
|
76
|
+
callbackAt = i;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const end = callbackAt === -1 ? out.length : callbackAt;
|
|
81
|
+
for (let i = 1; i < end; i++) {
|
|
82
|
+
if (isOptions(out[i])) {
|
|
83
|
+
out[i] = mergeHide(out[i]);
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const slot = end > 1 && (Array.isArray(out[1]) || out[1] == null) ? 2 : 1;
|
|
88
|
+
if (slot >= end) out.splice(end, 0, { windowsHide: true });
|
|
89
|
+
else if (out[slot] == null) out[slot] = { windowsHide: true };
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
var customPromisify = import_node_util.promisify.custom;
|
|
93
|
+
function wrap(hide, getFn) {
|
|
94
|
+
const wrapped = function(...args) {
|
|
95
|
+
const fn = getFn();
|
|
96
|
+
return Reflect.apply(fn, this, hide(args));
|
|
97
|
+
};
|
|
98
|
+
Object.defineProperty(wrapped, customPromisify, {
|
|
99
|
+
enumerable: false,
|
|
100
|
+
configurable: true,
|
|
101
|
+
writable: false,
|
|
102
|
+
value(...args) {
|
|
103
|
+
const fn = getFn();
|
|
104
|
+
const custom = fn[customPromisify];
|
|
105
|
+
if (typeof custom === "function") return Reflect.apply(custom, fn, hide(args));
|
|
106
|
+
const promisified = (0, import_node_util.promisify)(fn);
|
|
107
|
+
return Reflect.apply(promisified, this, hide(args));
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
return wrapped;
|
|
111
|
+
}
|
|
112
|
+
var spawn2 = wrap(hideSpawnArgs, () => cp.spawn);
|
|
113
|
+
var spawnSync2 = wrap(hideSpawnArgs, () => cp.spawnSync);
|
|
114
|
+
var exec2 = wrap(hideExecArgs, () => cp.exec);
|
|
115
|
+
var execSync2 = wrap(hideExecArgs, () => cp.execSync);
|
|
116
|
+
var execFile2 = wrap(hideSpawnArgs, () => cp.execFile);
|
|
117
|
+
var execFileSync2 = wrap(hideSpawnArgs, () => cp.execFileSync);
|
|
118
|
+
var fork2 = wrap(hideSpawnArgs, () => cp.fork);
|
|
119
|
+
|
|
120
|
+
// src/pkg.ts
|
|
34
121
|
var import_node_fs = require("fs");
|
|
35
122
|
var import_node_path = require("path");
|
|
36
123
|
var NodeMissingError = class extends Error {
|
|
@@ -137,7 +224,7 @@ var PlatformPackageManager = class {
|
|
|
137
224
|
if (IS_WINDOWS) {
|
|
138
225
|
if (isNodeAvailableOnWindows(env.PATH)) {
|
|
139
226
|
try {
|
|
140
|
-
(
|
|
227
|
+
execSync2("npm.cmd install --loglevel=error", {
|
|
141
228
|
cwd,
|
|
142
229
|
timeout,
|
|
143
230
|
stdio,
|
|
@@ -152,7 +239,7 @@ var PlatformPackageManager = class {
|
|
|
152
239
|
console.warn(
|
|
153
240
|
"[platform-pkg] npm install hit ERESOLVE \u2014 retrying with --legacy-peer-deps."
|
|
154
241
|
);
|
|
155
|
-
(
|
|
242
|
+
execSync2("npm.cmd install --loglevel=error --legacy-peer-deps", {
|
|
156
243
|
cwd,
|
|
157
244
|
timeout,
|
|
158
245
|
stdio,
|
|
@@ -171,12 +258,12 @@ var PlatformPackageManager = class {
|
|
|
171
258
|
const bun = this.bunBinary;
|
|
172
259
|
if (opts?.frozen) {
|
|
173
260
|
try {
|
|
174
|
-
(
|
|
261
|
+
execSync2(`"${bun}" install --frozen-lockfile 2>&1`, { cwd, timeout, stdio, env });
|
|
175
262
|
return;
|
|
176
263
|
} catch {
|
|
177
264
|
}
|
|
178
265
|
}
|
|
179
|
-
(
|
|
266
|
+
execSync2(`"${bun}" install`, { cwd, timeout, stdio, env });
|
|
180
267
|
}
|
|
181
268
|
/**
|
|
182
269
|
* Windows-only fallback path: `bun install [--frozen-lockfile]
|
|
@@ -201,7 +288,7 @@ var PlatformPackageManager = class {
|
|
|
201
288
|
);
|
|
202
289
|
if (opts?.frozen) {
|
|
203
290
|
try {
|
|
204
|
-
(
|
|
291
|
+
execSync2(`"${bun}" install --frozen-lockfile --backend=copyfile`, {
|
|
205
292
|
cwd,
|
|
206
293
|
timeout,
|
|
207
294
|
stdio,
|
|
@@ -211,7 +298,7 @@ var PlatformPackageManager = class {
|
|
|
211
298
|
} catch {
|
|
212
299
|
}
|
|
213
300
|
}
|
|
214
|
-
(
|
|
301
|
+
execSync2(`"${bun}" install --backend=copyfile`, { cwd, timeout, stdio, env });
|
|
215
302
|
}
|
|
216
303
|
// ---------------------------------------------------------------------------
|
|
217
304
|
// Install — async with spawn (used by RuntimeManager)
|
|
@@ -219,7 +306,8 @@ var PlatformPackageManager = class {
|
|
|
219
306
|
installAsync(cwd, opts) {
|
|
220
307
|
if (IS_WINDOWS) {
|
|
221
308
|
const env = this.spawnEnv(opts?.env);
|
|
222
|
-
|
|
309
|
+
const requestedBackend = env.SHOGO_WINDOWS_INSTALL_BACKEND?.toLowerCase();
|
|
310
|
+
if (requestedBackend !== "bun" && isNodeAvailableOnWindows(env.PATH)) {
|
|
223
311
|
return this.installAsyncWindowsNpm(cwd, opts).catch((err) => {
|
|
224
312
|
if (err instanceof NodeMissingError) {
|
|
225
313
|
return this.installAsyncBunCopyfile(cwd, opts);
|
|
@@ -227,6 +315,9 @@ var PlatformPackageManager = class {
|
|
|
227
315
|
throw err;
|
|
228
316
|
});
|
|
229
317
|
}
|
|
318
|
+
if (requestedBackend === "bun") {
|
|
319
|
+
console.log("[platform-pkg] Windows install backend=bun (copyfile)");
|
|
320
|
+
}
|
|
230
321
|
return this.installAsyncBunCopyfile(cwd, opts);
|
|
231
322
|
}
|
|
232
323
|
return this.installAsyncBun(cwd, opts);
|
|
@@ -236,7 +327,7 @@ var PlatformPackageManager = class {
|
|
|
236
327
|
const env = this.spawnEnv(opts?.env);
|
|
237
328
|
const cmd = "npm.cmd";
|
|
238
329
|
const runOnce = (extraArgs) => new Promise((resolvePromise, rejectPromise) => {
|
|
239
|
-
const proc = (
|
|
330
|
+
const proc = spawn2(cmd, ["install", "--loglevel=error", ...extraArgs], {
|
|
240
331
|
cwd,
|
|
241
332
|
stdio: "pipe",
|
|
242
333
|
env,
|
|
@@ -294,7 +385,7 @@ ${first.stderr}`);
|
|
|
294
385
|
const baseArgs = ["install", ...extraArgs];
|
|
295
386
|
const frozenArgs = opts?.frozen ? ["install", "--frozen-lockfile", ...extraArgs] : null;
|
|
296
387
|
const runOnce = (args) => new Promise((resolve, reject) => {
|
|
297
|
-
const proc = (
|
|
388
|
+
const proc = spawn2(bun, args, {
|
|
298
389
|
cwd,
|
|
299
390
|
stdio: "pipe",
|
|
300
391
|
env
|
|
@@ -340,7 +431,7 @@ ${first.stderr}`);
|
|
|
340
431
|
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
341
432
|
const bun = this.bunBinary;
|
|
342
433
|
const cmd = IS_WINDOWS ? `npx ${tool}${argStr}` : `"${bun}" x ${opts?.useBunFlag ? "--bun " : ""}${tool}${argStr}`;
|
|
343
|
-
return (
|
|
434
|
+
return execSync2(cmd, {
|
|
344
435
|
cwd,
|
|
345
436
|
timeout,
|
|
346
437
|
stdio,
|
|
@@ -384,7 +475,7 @@ ${first.stderr}`);
|
|
|
384
475
|
useShell = false;
|
|
385
476
|
}
|
|
386
477
|
return new Promise((resolvePromise, rejectPromise) => {
|
|
387
|
-
const proc = (
|
|
478
|
+
const proc = spawn2(cmd, argv, {
|
|
388
479
|
cwd,
|
|
389
480
|
env,
|
|
390
481
|
stdio,
|
package/dist/pkg.js
CHANGED