@nemo-cli/shared 0.1.4 → 0.1.6
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/adapters-C49sidhk.js +246 -0
- package/dist/adapters-C49sidhk.js.map +1 -0
- package/dist/adapters-CRVRGWT9.js +246 -0
- package/dist/adapters-CRVRGWT9.js.map +1 -0
- package/dist/adapters-VexOYXht.js +234 -0
- package/dist/adapters-VexOYXht.js.map +1 -0
- package/dist/index.d.ts +331 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1338 -278
- package/dist/index.js.map +1 -1
- package/dist/prompts-BpcevOrt.js +380 -0
- package/dist/prompts-BpcevOrt.js.map +1 -0
- package/package.json +8 -9
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import path, { dirname as dirname$1, resolve } from "node:path";
|
|
2
|
+
import path, { basename, dirname as dirname$1, join, parse, resolve } from "node:path";
|
|
3
3
|
import fse from "fs-extra";
|
|
4
4
|
import { glob as glob$1 } from "glob";
|
|
5
5
|
import { cancel, confirm, group, groupMultiselect, intro, isCancel, log as log$1, multiselect, note, outro, progress, select, spinner, stream, taskLog, tasks, text } from "@clack/prompts";
|
|
@@ -7,20 +7,19 @@ import ansiEscapes, { clearScreen as clearScreen$1, clearTerminal as clearTermin
|
|
|
7
7
|
import chalk, { default as colors } from "chalk";
|
|
8
8
|
import winston from "winston";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
|
-
import {
|
|
11
|
-
import open, { apps, openApp } from "open";
|
|
10
|
+
import fs, { existsSync } from "node:fs";
|
|
12
11
|
import process$1 from "node:process";
|
|
12
|
+
import fs$1 from "node:fs/promises";
|
|
13
13
|
import { Command } from "commander";
|
|
14
14
|
import { x as x$1 } from "tinyexec";
|
|
15
15
|
import { $ } from "zx";
|
|
16
16
|
import { ErrorMessage } from "@nemo-cli/ui";
|
|
17
|
-
import { existsSync } from "node:fs";
|
|
18
|
-
import { homedir } from "node:os";
|
|
19
|
-
import Configstore from "configstore";
|
|
20
17
|
import { search } from "@inquirer/prompts";
|
|
21
18
|
import Fuse from "fuse.js";
|
|
22
|
-
import
|
|
23
|
-
import
|
|
19
|
+
import open, { apps, openApp } from "open";
|
|
20
|
+
import { homedir } from "node:os";
|
|
21
|
+
import Configstore from "configstore";
|
|
22
|
+
import oraPkg, { spinners } from "ora";
|
|
24
23
|
import yaml from "yaml";
|
|
25
24
|
|
|
26
25
|
//#region \0rolldown/runtime.js
|
|
@@ -201,9 +200,520 @@ const log = {
|
|
|
201
200
|
const filename = (importMate) => fileURLToPath(importMate.url);
|
|
202
201
|
const dirname = (importMate) => dirname$1(filename(importMate));
|
|
203
202
|
const cwdPathname = (dirname) => resolve(process.cwd(), dirname);
|
|
203
|
+
/**
|
|
204
|
+
* Join path segments and resolve to absolute path from current working directory
|
|
205
|
+
* @param segments - Path segments to join
|
|
206
|
+
* @returns Absolute path
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* joinPath('packages', 'workspace', 'package.json')
|
|
210
|
+
* // Returns: /Users/user/project/packages/workspace/package.json
|
|
211
|
+
*/
|
|
212
|
+
const joinPath = (...segments) => resolve(process.cwd(), join(...segments));
|
|
204
213
|
const REGEXP_SPLIT_NAMES = /\W+/gm;
|
|
205
214
|
const parseNames = (names) => names.split(REGEXP_SPLIT_NAMES);
|
|
206
215
|
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region ../../node_modules/.pnpm/unconfig@7.5.0/node_modules/unconfig/dist/dist-DBY4ctBk.mjs
|
|
218
|
+
function toArray(array) {
|
|
219
|
+
array = array ?? [];
|
|
220
|
+
return Array.isArray(array) ? array : [array];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region ../../node_modules/.pnpm/quansync@1.0.0/node_modules/quansync/dist/src-C2Pm6gXo.js
|
|
225
|
+
const GET_IS_ASYNC = Symbol.for("quansync.getIsAsync");
|
|
226
|
+
var QuansyncError = class extends Error {
|
|
227
|
+
constructor(message = "Unexpected promise in sync context") {
|
|
228
|
+
super(message);
|
|
229
|
+
this.name = "QuansyncError";
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
function isThenable(value) {
|
|
233
|
+
return value && typeof value === "object" && typeof value.then === "function";
|
|
234
|
+
}
|
|
235
|
+
function isQuansyncGenerator(value) {
|
|
236
|
+
return value && typeof value === "object" && typeof value[Symbol.iterator] === "function" && "__quansync" in value;
|
|
237
|
+
}
|
|
238
|
+
function fromObject(options) {
|
|
239
|
+
const generator = function* (...args) {
|
|
240
|
+
if (yield GET_IS_ASYNC) return yield options.async.apply(this, args);
|
|
241
|
+
return options.sync.apply(this, args);
|
|
242
|
+
};
|
|
243
|
+
function fn(...args) {
|
|
244
|
+
const iter = generator.apply(this, args);
|
|
245
|
+
iter.then = (...thenArgs) => options.async.apply(this, args).then(...thenArgs);
|
|
246
|
+
iter.__quansync = true;
|
|
247
|
+
return iter;
|
|
248
|
+
}
|
|
249
|
+
fn.sync = options.sync;
|
|
250
|
+
fn.async = options.async;
|
|
251
|
+
return fn;
|
|
252
|
+
}
|
|
253
|
+
function fromPromise(promise) {
|
|
254
|
+
return fromObject({
|
|
255
|
+
async: () => Promise.resolve(promise),
|
|
256
|
+
sync: () => {
|
|
257
|
+
if (isThenable(promise)) throw new QuansyncError();
|
|
258
|
+
return promise;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
function unwrapYield(value, isAsync) {
|
|
263
|
+
if (value === GET_IS_ASYNC) return isAsync;
|
|
264
|
+
if (isQuansyncGenerator(value)) return isAsync ? iterateAsync(value) : iterateSync(value);
|
|
265
|
+
if (!isAsync && isThenable(value)) throw new QuansyncError();
|
|
266
|
+
return value;
|
|
267
|
+
}
|
|
268
|
+
const DEFAULT_ON_YIELD = (value) => value;
|
|
269
|
+
function iterateSync(generator, onYield = DEFAULT_ON_YIELD) {
|
|
270
|
+
let current = generator.next();
|
|
271
|
+
while (!current.done) try {
|
|
272
|
+
current = generator.next(unwrapYield(onYield(current.value, false)));
|
|
273
|
+
} catch (err) {
|
|
274
|
+
current = generator.throw(err);
|
|
275
|
+
}
|
|
276
|
+
return unwrapYield(current.value);
|
|
277
|
+
}
|
|
278
|
+
async function iterateAsync(generator, onYield = DEFAULT_ON_YIELD) {
|
|
279
|
+
let current = generator.next();
|
|
280
|
+
while (!current.done) try {
|
|
281
|
+
current = generator.next(await unwrapYield(onYield(current.value, true), true));
|
|
282
|
+
} catch (err) {
|
|
283
|
+
current = generator.throw(err);
|
|
284
|
+
}
|
|
285
|
+
return current.value;
|
|
286
|
+
}
|
|
287
|
+
function fromGeneratorFn(generatorFn, options) {
|
|
288
|
+
return fromObject({
|
|
289
|
+
name: generatorFn.name,
|
|
290
|
+
async(...args) {
|
|
291
|
+
return iterateAsync(generatorFn.apply(this, args), options?.onYield);
|
|
292
|
+
},
|
|
293
|
+
sync(...args) {
|
|
294
|
+
return iterateSync(generatorFn.apply(this, args), options?.onYield);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
function quansync$1(input, options) {
|
|
299
|
+
if (isThenable(input)) return fromPromise(input);
|
|
300
|
+
if (typeof input === "function") return fromGeneratorFn(input, options);
|
|
301
|
+
else return fromObject(input);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* @returns `true` if the current context is async, `false` otherwise.
|
|
305
|
+
*/
|
|
306
|
+
const getIsAsync = quansync$1({
|
|
307
|
+
async: () => Promise.resolve(true),
|
|
308
|
+
sync: () => false
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region ../../node_modules/.pnpm/@quansync+fs@1.0.0/node_modules/@quansync/fs/dist/index.mjs
|
|
313
|
+
/**
|
|
314
|
+
* @link https://nodejs.org/api/fs.html#fspromisesreadfilepath-options
|
|
315
|
+
*/
|
|
316
|
+
const readFile$1 = quansync$1({
|
|
317
|
+
sync: fs.readFileSync,
|
|
318
|
+
async: fs.promises.readFile
|
|
319
|
+
});
|
|
320
|
+
/**
|
|
321
|
+
* @link https://nodejs.org/api/fs.html#fspromiseswritefilefile-data-options
|
|
322
|
+
*/
|
|
323
|
+
const writeFile = quansync$1({
|
|
324
|
+
sync: fs.writeFileSync,
|
|
325
|
+
async: fs.promises.writeFile
|
|
326
|
+
});
|
|
327
|
+
/**
|
|
328
|
+
* @link https://nodejs.org/api/fs.html#fspromisesunlinkpath
|
|
329
|
+
*/
|
|
330
|
+
const unlink = quansync$1({
|
|
331
|
+
sync: fs.unlinkSync,
|
|
332
|
+
async: fs.promises.unlink
|
|
333
|
+
});
|
|
334
|
+
/**
|
|
335
|
+
* @link https://nodejs.org/api/fs.html#fspromisesaccesspath-mode
|
|
336
|
+
*/
|
|
337
|
+
const access = quansync$1({
|
|
338
|
+
sync: fs.accessSync,
|
|
339
|
+
async: fs.promises.access
|
|
340
|
+
});
|
|
341
|
+
/**
|
|
342
|
+
* @link https://nodejs.org/api/fs.html#fspromisesstatpath-options
|
|
343
|
+
*/
|
|
344
|
+
const stat = quansync$1({
|
|
345
|
+
sync: fs.statSync,
|
|
346
|
+
async: fs.promises.stat
|
|
347
|
+
});
|
|
348
|
+
const lstat = quansync$1({
|
|
349
|
+
sync: fs.lstatSync,
|
|
350
|
+
async: fs.promises.lstat
|
|
351
|
+
});
|
|
352
|
+
/**
|
|
353
|
+
* @link https://nodejs.org/api/fs.html#fspromisescpsrc-dest-options
|
|
354
|
+
*/
|
|
355
|
+
const cp = quansync$1({
|
|
356
|
+
sync: fs.copyFileSync,
|
|
357
|
+
async: fs.promises.copyFile
|
|
358
|
+
});
|
|
359
|
+
/**
|
|
360
|
+
* @link https://nodejs.org/api/fs.html#fspromisesrmpath-options
|
|
361
|
+
*/
|
|
362
|
+
const rm = quansync$1({
|
|
363
|
+
sync: fs.rmSync,
|
|
364
|
+
async: fs.promises.rm
|
|
365
|
+
});
|
|
366
|
+
/**
|
|
367
|
+
* @link https://nodejs.org/api/fs.html#fspromisesmkdirpath-options
|
|
368
|
+
*/
|
|
369
|
+
const mkdir = quansync$1({
|
|
370
|
+
sync: fs.mkdirSync,
|
|
371
|
+
async: fs.promises.mkdir
|
|
372
|
+
});
|
|
373
|
+
/**
|
|
374
|
+
* @link https://nodejs.org/api/fs.html#fspromisesrenameoldpath-newpath
|
|
375
|
+
*/
|
|
376
|
+
const rename = quansync$1({
|
|
377
|
+
sync: fs.renameSync,
|
|
378
|
+
async: fs.promises.rename
|
|
379
|
+
});
|
|
380
|
+
/**
|
|
381
|
+
* @link https://nodejs.org/api/fs.html#fspromisesreaddirpath-options
|
|
382
|
+
*/
|
|
383
|
+
const readdir = quansync$1({
|
|
384
|
+
sync: fs.readdirSync,
|
|
385
|
+
async: fs.promises.readdir
|
|
386
|
+
});
|
|
387
|
+
/**
|
|
388
|
+
* @link https://nodejs.org/api/fs.html#fspromisesrealpathpath-options
|
|
389
|
+
*/
|
|
390
|
+
const realpath = quansync$1({
|
|
391
|
+
sync: fs.realpathSync,
|
|
392
|
+
async: fs.promises.realpath
|
|
393
|
+
});
|
|
394
|
+
/**
|
|
395
|
+
* @link https://nodejs.org/api/fs.html#fspromisesreadlinkpath-options
|
|
396
|
+
*/
|
|
397
|
+
const readlink = quansync$1({
|
|
398
|
+
sync: fs.readlinkSync,
|
|
399
|
+
async: fs.promises.readlink
|
|
400
|
+
});
|
|
401
|
+
/**
|
|
402
|
+
* @link https://nodejs.org/api/fs.html#fspromisessymlinktarget-path-type
|
|
403
|
+
*/
|
|
404
|
+
const symlink = quansync$1({
|
|
405
|
+
sync: fs.symlinkSync,
|
|
406
|
+
async: fs.promises.symlink
|
|
407
|
+
});
|
|
408
|
+
/**
|
|
409
|
+
* @link https://nodejs.org/api/fs.html#fspromiseschownpath-uid-gid
|
|
410
|
+
*/
|
|
411
|
+
const chown = quansync$1({
|
|
412
|
+
sync: fs.chownSync,
|
|
413
|
+
async: fs.promises.chown
|
|
414
|
+
});
|
|
415
|
+
/**
|
|
416
|
+
* @link https://nodejs.org/api/fs.html#fspromiseslchownpath-uid-gid
|
|
417
|
+
*/
|
|
418
|
+
const lchown = quansync$1({
|
|
419
|
+
sync: fs.lchownSync,
|
|
420
|
+
async: fs.promises.lchown
|
|
421
|
+
});
|
|
422
|
+
/**
|
|
423
|
+
* @link https://nodejs.org/api/fs.html#fspromiseschmodpath-mode
|
|
424
|
+
*/
|
|
425
|
+
const chmod = quansync$1({
|
|
426
|
+
sync: fs.chmodSync,
|
|
427
|
+
async: fs.promises.chmod
|
|
428
|
+
});
|
|
429
|
+
/**
|
|
430
|
+
* @link https://nodejs.org/api/fs.html#fspromisesutimespath-atime-mtime
|
|
431
|
+
*/
|
|
432
|
+
const utimes = quansync$1({
|
|
433
|
+
sync: fs.utimesSync,
|
|
434
|
+
async: fs.promises.utimes
|
|
435
|
+
});
|
|
436
|
+
/**
|
|
437
|
+
* @link https://nodejs.org/api/fs.html#fspromiseslutimespath-atime-mtime
|
|
438
|
+
*/
|
|
439
|
+
const lutimes = quansync$1({
|
|
440
|
+
sync: fs.lutimesSync,
|
|
441
|
+
async: fs.promises.lutimes
|
|
442
|
+
});
|
|
443
|
+
/**
|
|
444
|
+
* @link https://nodejs.org/api/fs.html#fspromisesmkdtempprefix-options
|
|
445
|
+
*/
|
|
446
|
+
const mkdtemp = quansync$1({
|
|
447
|
+
sync: fs.mkdtempSync,
|
|
448
|
+
async: fs.promises.mkdtemp
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
453
|
+
function isPlainObject$2(value) {
|
|
454
|
+
if (value === null || typeof value !== "object") return false;
|
|
455
|
+
const prototype = Object.getPrototypeOf(value);
|
|
456
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
|
|
457
|
+
if (Symbol.iterator in value) return false;
|
|
458
|
+
if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
|
|
459
|
+
return true;
|
|
460
|
+
}
|
|
461
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
462
|
+
if (!isPlainObject$2(defaults)) return _defu(baseObject, {}, namespace, merger);
|
|
463
|
+
const object = Object.assign({}, defaults);
|
|
464
|
+
for (const key in baseObject) {
|
|
465
|
+
if (key === "__proto__" || key === "constructor") continue;
|
|
466
|
+
const value = baseObject[key];
|
|
467
|
+
if (value === null || value === void 0) continue;
|
|
468
|
+
if (merger && merger(object, key, value, namespace)) continue;
|
|
469
|
+
if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
|
|
470
|
+
else if (isPlainObject$2(value) && isPlainObject$2(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
|
|
471
|
+
else object[key] = value;
|
|
472
|
+
}
|
|
473
|
+
return object;
|
|
474
|
+
}
|
|
475
|
+
function createDefu(merger) {
|
|
476
|
+
return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
|
|
477
|
+
}
|
|
478
|
+
const defu = createDefu();
|
|
479
|
+
const defuFn = createDefu((object, key, currentValue) => {
|
|
480
|
+
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
481
|
+
object[key] = currentValue(object[key]);
|
|
482
|
+
return true;
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
const defuArrayFn = createDefu((object, key, currentValue) => {
|
|
486
|
+
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
487
|
+
object[key] = currentValue(object[key]);
|
|
488
|
+
return true;
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region ../../node_modules/.pnpm/quansync@1.0.0/node_modules/quansync/dist/macro.js
|
|
494
|
+
/**
|
|
495
|
+
* This function is equivalent to `quansync` from main entry
|
|
496
|
+
* but accepts a fake argument type of async functions.
|
|
497
|
+
*
|
|
498
|
+
* This requires to be used with the macro transformer `unplugin-quansync`.
|
|
499
|
+
* Do NOT use it directly.
|
|
500
|
+
*
|
|
501
|
+
* @internal
|
|
502
|
+
*/
|
|
503
|
+
const quansync = quansync$1;
|
|
504
|
+
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region ../../node_modules/.pnpm/unconfig-core@7.5.0/node_modules/unconfig-core/dist/index.mjs
|
|
507
|
+
const isFile = quansync(function* (path, allowSymlinks) {
|
|
508
|
+
try {
|
|
509
|
+
return (yield (allowSymlinks ? stat : lstat)(path)).isFile();
|
|
510
|
+
} catch {
|
|
511
|
+
return false;
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
const findUp = quansync(function* (paths, options = {}) {
|
|
515
|
+
const { cwd = process$1.cwd(), stopAt = parse(cwd).root, multiple = false, allowSymlinks = true } = options;
|
|
516
|
+
let current = cwd;
|
|
517
|
+
const files = [];
|
|
518
|
+
while (current && current !== stopAt) {
|
|
519
|
+
for (const path of paths) {
|
|
520
|
+
const filepath = resolve(current, path);
|
|
521
|
+
if (yield isFile(filepath, allowSymlinks)) {
|
|
522
|
+
files.push(filepath);
|
|
523
|
+
if (!multiple) return files;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
const parent = dirname$1(current);
|
|
527
|
+
if (parent === current) break;
|
|
528
|
+
current = parent;
|
|
529
|
+
}
|
|
530
|
+
return files;
|
|
531
|
+
});
|
|
532
|
+
const loadConfigFile$1 = quansync(function* (filepath, source) {
|
|
533
|
+
try {
|
|
534
|
+
const config = yield source.parser(filepath);
|
|
535
|
+
if (!config) return;
|
|
536
|
+
return {
|
|
537
|
+
config,
|
|
538
|
+
source: filepath
|
|
539
|
+
};
|
|
540
|
+
} catch (e) {
|
|
541
|
+
if (source.skipOnError) return;
|
|
542
|
+
throw e;
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
function createConfigCoreLoader(options) {
|
|
546
|
+
const { cwd = process$1.cwd(), multiple, sources } = options;
|
|
547
|
+
const results = [];
|
|
548
|
+
let matchedFiles;
|
|
549
|
+
const findConfigs = quansync(function* () {
|
|
550
|
+
if (matchedFiles == null) matchedFiles = [];
|
|
551
|
+
matchedFiles.length = 0;
|
|
552
|
+
for (const source of sources) {
|
|
553
|
+
const { extensions } = source;
|
|
554
|
+
const files = yield findUp(source.files.flatMap((file) => !extensions?.length ? [file] : extensions.map((ext) => ext ? `${file}.${ext}` : file)), {
|
|
555
|
+
cwd,
|
|
556
|
+
stopAt: options.stopAt,
|
|
557
|
+
multiple
|
|
558
|
+
});
|
|
559
|
+
matchedFiles.push([source, files]);
|
|
560
|
+
}
|
|
561
|
+
return matchedFiles.flatMap((i) => i[1]);
|
|
562
|
+
});
|
|
563
|
+
return {
|
|
564
|
+
load: quansync(function* (force = false) {
|
|
565
|
+
if (matchedFiles == null || force) yield findConfigs();
|
|
566
|
+
for (const [source, files] of matchedFiles) {
|
|
567
|
+
if (!files.length) continue;
|
|
568
|
+
if (!multiple) {
|
|
569
|
+
const result = yield loadConfigFile$1(files[0], source);
|
|
570
|
+
if (result) return [result];
|
|
571
|
+
} else for (const file of files) {
|
|
572
|
+
const result = yield loadConfigFile$1(file, source);
|
|
573
|
+
if (result) results.push(result);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
return results;
|
|
577
|
+
}),
|
|
578
|
+
findConfigs
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
//#endregion
|
|
583
|
+
//#region ../../node_modules/.pnpm/unconfig@7.5.0/node_modules/unconfig/dist/index.mjs
|
|
584
|
+
function interopDefault(mod) {
|
|
585
|
+
if (mod == null || typeof mod !== "object" || !("default" in mod) || mod.default == null) return mod;
|
|
586
|
+
const defaultValue = mod.default;
|
|
587
|
+
if (typeof defaultValue !== "object") return defaultValue;
|
|
588
|
+
for (const key in mod) try {
|
|
589
|
+
if (key in defaultValue || key === "default" || mod[key] === defaultValue) continue;
|
|
590
|
+
Object.defineProperty(defaultValue, key, {
|
|
591
|
+
configurable: true,
|
|
592
|
+
enumerable: true,
|
|
593
|
+
get() {
|
|
594
|
+
return mod[key];
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
} catch {}
|
|
598
|
+
return defaultValue;
|
|
599
|
+
}
|
|
600
|
+
const defaultExtensions = [
|
|
601
|
+
"mts",
|
|
602
|
+
"cts",
|
|
603
|
+
"ts",
|
|
604
|
+
"mjs",
|
|
605
|
+
"cjs",
|
|
606
|
+
"js",
|
|
607
|
+
"json",
|
|
608
|
+
""
|
|
609
|
+
];
|
|
610
|
+
const require$2 = createRequire(import.meta.url);
|
|
611
|
+
const loadConfigFile = quansync(function* (filepath, source) {
|
|
612
|
+
let config;
|
|
613
|
+
let parser = source.parser || "auto";
|
|
614
|
+
let bundleFilepath = filepath;
|
|
615
|
+
let code;
|
|
616
|
+
let dependencies;
|
|
617
|
+
const read = quansync(function* () {
|
|
618
|
+
if (code == null) code = yield readFile$1(filepath, "utf8");
|
|
619
|
+
return code;
|
|
620
|
+
});
|
|
621
|
+
const importModule = quansync({
|
|
622
|
+
sync: () => {
|
|
623
|
+
const { createJiti } = require$2("jiti");
|
|
624
|
+
const jiti = createJiti(import.meta.url, {
|
|
625
|
+
fsCache: false,
|
|
626
|
+
moduleCache: false,
|
|
627
|
+
interopDefault: true
|
|
628
|
+
});
|
|
629
|
+
config = interopDefault(jiti(bundleFilepath));
|
|
630
|
+
dependencies = Object.values(jiti.cache).map((i) => i.filename).filter(Boolean);
|
|
631
|
+
},
|
|
632
|
+
async: async () => {
|
|
633
|
+
const { createJiti } = await import("jiti");
|
|
634
|
+
const jiti = createJiti(import.meta.url, {
|
|
635
|
+
fsCache: false,
|
|
636
|
+
moduleCache: false,
|
|
637
|
+
interopDefault: true
|
|
638
|
+
});
|
|
639
|
+
config = interopDefault(await jiti.import(bundleFilepath, { default: true }));
|
|
640
|
+
dependencies = Object.values(jiti.cache).map((i) => i.filename).filter(Boolean);
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
if (source.transform) {
|
|
644
|
+
const transformed = yield source.transform(yield read(), filepath);
|
|
645
|
+
if (transformed) {
|
|
646
|
+
bundleFilepath = join(dirname$1(filepath), `__unconfig_${basename(filepath)}`);
|
|
647
|
+
yield writeFile(bundleFilepath, transformed, "utf8");
|
|
648
|
+
code = transformed;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
if (parser === "auto") try {
|
|
652
|
+
config = JSON.parse(yield read());
|
|
653
|
+
parser = "json";
|
|
654
|
+
} catch {
|
|
655
|
+
parser = "import";
|
|
656
|
+
}
|
|
657
|
+
try {
|
|
658
|
+
if (!config) {
|
|
659
|
+
if (typeof parser === "function") config = yield parser(filepath);
|
|
660
|
+
else if (parser === "import") yield importModule();
|
|
661
|
+
else if (parser === "json") config = JSON.parse(yield read());
|
|
662
|
+
}
|
|
663
|
+
if (!config) return;
|
|
664
|
+
const rewritten = source.rewrite ? yield source.rewrite(config, filepath) : config;
|
|
665
|
+
if (!rewritten) return void 0;
|
|
666
|
+
return [rewritten, dependencies];
|
|
667
|
+
} finally {
|
|
668
|
+
if (bundleFilepath !== filepath) try {
|
|
669
|
+
yield unlink(bundleFilepath);
|
|
670
|
+
} catch {}
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
function createConfigLoader(options) {
|
|
674
|
+
const { merge, defaults, sources, ...coreOptions } = options;
|
|
675
|
+
const coreSources = toArray(sources || []).map((source) => {
|
|
676
|
+
return {
|
|
677
|
+
...source,
|
|
678
|
+
files: toArray(source.files),
|
|
679
|
+
extensions: source.extensions || defaultExtensions,
|
|
680
|
+
parser: (filepath) => loadConfigFile(filepath, source)
|
|
681
|
+
};
|
|
682
|
+
});
|
|
683
|
+
const core = createConfigCoreLoader({
|
|
684
|
+
...coreOptions,
|
|
685
|
+
multiple: merge,
|
|
686
|
+
sources: coreSources
|
|
687
|
+
});
|
|
688
|
+
return {
|
|
689
|
+
load: quansync(function* (force = false) {
|
|
690
|
+
const results = yield core.load(force);
|
|
691
|
+
if (!results.length) return {
|
|
692
|
+
config: defaults,
|
|
693
|
+
sources: []
|
|
694
|
+
};
|
|
695
|
+
if (!merge) return {
|
|
696
|
+
config: results[0].config[0],
|
|
697
|
+
sources: [results[0].source],
|
|
698
|
+
dependencies: results[0].config[1]
|
|
699
|
+
};
|
|
700
|
+
return {
|
|
701
|
+
config: applyDefaults(...results.map((i) => i.config[0]), defaults),
|
|
702
|
+
sources: results.map((i) => i.source),
|
|
703
|
+
dependencies: results.flatMap((i) => i.config[1] || [])
|
|
704
|
+
};
|
|
705
|
+
}),
|
|
706
|
+
findConfigs: core.findConfigs
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
function applyDefaults(...args) {
|
|
710
|
+
return defu(...args.map((i) => ({ config: i }))).config;
|
|
711
|
+
}
|
|
712
|
+
const loadConfig = quansync(function* (options) {
|
|
713
|
+
return createConfigLoader(options).load();
|
|
714
|
+
});
|
|
715
|
+
const loadConfigSync = loadConfig.sync;
|
|
716
|
+
|
|
207
717
|
//#endregion
|
|
208
718
|
//#region src/utils/file.ts
|
|
209
719
|
const readPackage = (importMeta, ...paths) => {
|
|
@@ -271,20 +781,698 @@ const readGitignore = (cwd = process.cwd()) => {
|
|
|
271
781
|
log.verbose("gitignore", `未找到 .gitignore 文件: ${gitignorePath}`);
|
|
272
782
|
return [];
|
|
273
783
|
}
|
|
274
|
-
try {
|
|
275
|
-
const content = fse.readFileSync(gitignorePath, "utf-8");
|
|
276
|
-
log.verbose("gitignore", `成功读取 .gitignore 文件: ${gitignorePath}`);
|
|
277
|
-
return content.split("\n");
|
|
278
|
-
} catch (err) {
|
|
279
|
-
log.error("gitignore", `读取 .gitignore 文件失败: ${err.message}`);
|
|
280
|
-
return [];
|
|
784
|
+
try {
|
|
785
|
+
const content = fse.readFileSync(gitignorePath, "utf-8");
|
|
786
|
+
log.verbose("gitignore", `成功读取 .gitignore 文件: ${gitignorePath}`);
|
|
787
|
+
return content.split("\n");
|
|
788
|
+
} catch (err) {
|
|
789
|
+
log.error("gitignore", `读取 .gitignore 文件失败: ${err.message}`);
|
|
790
|
+
return [];
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
//#endregion
|
|
795
|
+
//#region src/constants.ts
|
|
796
|
+
const LOWEST_NODE_VERSION = "18.0.0";
|
|
797
|
+
const CONFIG_NAME = ".nemoclirc";
|
|
798
|
+
|
|
799
|
+
//#endregion
|
|
800
|
+
//#region src/package-manager/adapters/bun.ts
|
|
801
|
+
/**
|
|
802
|
+
* Bun adapter - translates operations to bun-specific commands
|
|
803
|
+
*/
|
|
804
|
+
var BunAdapter = class {
|
|
805
|
+
name = "bun";
|
|
806
|
+
supportsWorkspaces = true;
|
|
807
|
+
command = "bun";
|
|
808
|
+
buildAddCommand(packages, options) {
|
|
809
|
+
const args = ["add"];
|
|
810
|
+
args.push(...packages);
|
|
811
|
+
if (options.saveDev) args.push("--development");
|
|
812
|
+
if (options.exact) args.push("--exact");
|
|
813
|
+
if (options.root) args.push("--workspace");
|
|
814
|
+
else if (options.workspaces && options.workspaces.length > 0) options.workspaces.forEach((ws) => {
|
|
815
|
+
args.push("--workspace", ws);
|
|
816
|
+
});
|
|
817
|
+
return args;
|
|
818
|
+
}
|
|
819
|
+
buildRemoveCommand(packages, options) {
|
|
820
|
+
const args = ["remove", ...packages];
|
|
821
|
+
if (options.root) args.push("--workspace");
|
|
822
|
+
else if (options.workspaces && options.workspaces.length > 0) options.workspaces.forEach((ws) => {
|
|
823
|
+
args.push("--workspace", ws);
|
|
824
|
+
});
|
|
825
|
+
return args;
|
|
826
|
+
}
|
|
827
|
+
buildUpgradeCommand(packages, options) {
|
|
828
|
+
const target = options.target || "latest";
|
|
829
|
+
const packagesWithTarget = packages.map((pkg) => `${pkg}@${target}`);
|
|
830
|
+
return this.buildAddCommand(packagesWithTarget, {});
|
|
831
|
+
}
|
|
832
|
+
parsePackageSpec(packageSpec) {
|
|
833
|
+
const match = packageSpec.match(/^(@?[^@]+)(?:@(.+))?$/);
|
|
834
|
+
if (!match) return { name: packageSpec };
|
|
835
|
+
return {
|
|
836
|
+
name: match[1] ?? packageSpec,
|
|
837
|
+
version: match[2]
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
//#endregion
|
|
843
|
+
//#region src/package-manager/adapters/deno.ts
|
|
844
|
+
/**
|
|
845
|
+
* Deno adapter - translates operations to deno-specific commands
|
|
846
|
+
*
|
|
847
|
+
* Note: Deno has a different model (URL-based imports) so some operations
|
|
848
|
+
* are limited or not applicable.
|
|
849
|
+
*/
|
|
850
|
+
var DenoAdapter = class {
|
|
851
|
+
name = "deno";
|
|
852
|
+
supportsWorkspaces = false;
|
|
853
|
+
command = "deno";
|
|
854
|
+
buildAddCommand(packages, options) {
|
|
855
|
+
const args = ["add", ...packages];
|
|
856
|
+
if (options.saveDev) args.push("--dev");
|
|
857
|
+
return args;
|
|
858
|
+
}
|
|
859
|
+
buildRemoveCommand(packages, options) {
|
|
860
|
+
return ["remove", ...packages];
|
|
861
|
+
}
|
|
862
|
+
buildUpgradeCommand(packages, options) {
|
|
863
|
+
return this.buildAddCommand(packages, {});
|
|
864
|
+
}
|
|
865
|
+
parsePackageSpec(packageSpec) {
|
|
866
|
+
const match = packageSpec.match(/^(@?[^@]+)(?:@(.+))?$/);
|
|
867
|
+
if (!match) return { name: packageSpec };
|
|
868
|
+
return {
|
|
869
|
+
name: match[1] ?? packageSpec,
|
|
870
|
+
version: match[2]
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
//#endregion
|
|
876
|
+
//#region src/package-manager/adapters/npm.ts
|
|
877
|
+
/**
|
|
878
|
+
* NPM adapter - translates operations to npm-specific commands
|
|
879
|
+
*/
|
|
880
|
+
var NpmAdapter = class {
|
|
881
|
+
name = "npm";
|
|
882
|
+
supportsWorkspaces = true;
|
|
883
|
+
command = "npm";
|
|
884
|
+
buildAddCommand(packages, options) {
|
|
885
|
+
const args = ["install"];
|
|
886
|
+
args.push(...packages);
|
|
887
|
+
if (options.saveDev) args.push("--save-dev");
|
|
888
|
+
if (options.exact) args.push("--save-exact");
|
|
889
|
+
if (options.savePeer) args.push("--save-peer");
|
|
890
|
+
if (options.saveOptional) args.push("--save-optional");
|
|
891
|
+
if (options.root) args.push("-w");
|
|
892
|
+
else if (options.workspaces && options.workspaces.length > 0) if (options.workspaces.length === 1) args.push("--workspace", options.workspaces[0] ?? "");
|
|
893
|
+
else options.workspaces.forEach((ws) => {
|
|
894
|
+
args.push("--workspace", ws);
|
|
895
|
+
});
|
|
896
|
+
return args;
|
|
897
|
+
}
|
|
898
|
+
buildRemoveCommand(packages, options) {
|
|
899
|
+
const args = ["uninstall", ...packages];
|
|
900
|
+
if (options.root) args.push("-w");
|
|
901
|
+
else if (options.workspaces && options.workspaces.length > 0) if (options.workspaces.length === 1) args.push("--workspace", options.workspaces[0] ?? "");
|
|
902
|
+
else options.workspaces.forEach((ws) => {
|
|
903
|
+
args.push("--workspace", ws);
|
|
904
|
+
});
|
|
905
|
+
return args;
|
|
906
|
+
}
|
|
907
|
+
buildUpgradeCommand(packages, options) {
|
|
908
|
+
const target = options.target || "latest";
|
|
909
|
+
const packagesWithTarget = packages.map((pkg) => `${pkg}@${target}`);
|
|
910
|
+
return this.buildAddCommand(packagesWithTarget, {});
|
|
911
|
+
}
|
|
912
|
+
parsePackageSpec(packageSpec) {
|
|
913
|
+
const match = packageSpec.match(/^(@?[^@]+)(?:@(.+))?$/);
|
|
914
|
+
if (!match) return { name: packageSpec };
|
|
915
|
+
return {
|
|
916
|
+
name: match[1] ?? packageSpec,
|
|
917
|
+
version: match[2]
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
//#endregion
|
|
923
|
+
//#region src/package-manager/adapters/pnpm.ts
|
|
924
|
+
/**
|
|
925
|
+
* pnpm adapter - translates operations to pnpm-specific commands
|
|
926
|
+
*/
|
|
927
|
+
var PnpmAdapter = class {
|
|
928
|
+
name = "pnpm";
|
|
929
|
+
supportsWorkspaces = true;
|
|
930
|
+
command = "pnpm";
|
|
931
|
+
buildAddCommand(packages, options) {
|
|
932
|
+
const args = ["add"];
|
|
933
|
+
args.push(...packages);
|
|
934
|
+
if (options.saveDev) args.push("--save-dev");
|
|
935
|
+
if (options.exact) args.push("--save-exact");
|
|
936
|
+
if (options.savePeer) args.push("--save-peer");
|
|
937
|
+
if (options.saveOptional) args.push("--save-optional");
|
|
938
|
+
if (options.root) args.push("-w");
|
|
939
|
+
else if (options.workspaces && options.workspaces.length > 0) options.workspaces.forEach((ws) => {
|
|
940
|
+
args.push("--filter", ws);
|
|
941
|
+
});
|
|
942
|
+
return args;
|
|
943
|
+
}
|
|
944
|
+
buildRemoveCommand(packages, options) {
|
|
945
|
+
const args = ["remove", ...packages];
|
|
946
|
+
if (options.root) args.push("-w");
|
|
947
|
+
else if (options.workspaces && options.workspaces.length > 0) options.workspaces.forEach((ws) => {
|
|
948
|
+
args.push("--filter", ws);
|
|
949
|
+
});
|
|
950
|
+
return args;
|
|
951
|
+
}
|
|
952
|
+
buildUpgradeCommand(packages, options) {
|
|
953
|
+
const target = options.target || "latest";
|
|
954
|
+
const packagesWithTarget = packages.map((pkg) => `${pkg}@${target}`);
|
|
955
|
+
return this.buildAddCommand(packagesWithTarget, {});
|
|
956
|
+
}
|
|
957
|
+
parsePackageSpec(packageSpec) {
|
|
958
|
+
const match = packageSpec.match(/^(@?[^@]+)(?:@(.+))?$/);
|
|
959
|
+
if (!match) return { name: packageSpec };
|
|
960
|
+
return {
|
|
961
|
+
name: match[1] ?? packageSpec,
|
|
962
|
+
version: match[2]
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
|
|
967
|
+
//#endregion
|
|
968
|
+
//#region src/package-manager/adapters/yarn.ts
|
|
969
|
+
/**
|
|
970
|
+
* Yarn adapter - translates operations to yarn-specific commands
|
|
971
|
+
*/
|
|
972
|
+
var YarnAdapter = class {
|
|
973
|
+
name = "yarn";
|
|
974
|
+
supportsWorkspaces = true;
|
|
975
|
+
command = "yarn";
|
|
976
|
+
buildAddCommand(packages, options) {
|
|
977
|
+
const args = ["add"];
|
|
978
|
+
args.push(...packages);
|
|
979
|
+
if (options.saveDev) args.push("--dev");
|
|
980
|
+
if (options.exact) args.push("--exact");
|
|
981
|
+
if (options.savePeer) args.push("--peer");
|
|
982
|
+
if (options.saveOptional) args.push("--optional");
|
|
983
|
+
if (options.root) args.push("-W");
|
|
984
|
+
else if (options.workspaces && options.workspaces.length > 0) {
|
|
985
|
+
if (options.workspaces.length === 1) args.unshift("-c", "--", `workspace:${options.workspaces[0]}`);
|
|
986
|
+
}
|
|
987
|
+
return args;
|
|
988
|
+
}
|
|
989
|
+
buildRemoveCommand(packages, options) {
|
|
990
|
+
const args = ["remove", ...packages];
|
|
991
|
+
if (options.root) args.push("-W");
|
|
992
|
+
else if (options.workspaces && options.workspaces.length > 0) {
|
|
993
|
+
if (options.workspaces.length === 1) args.unshift("-c", "--", `workspace:${options.workspaces[0]}`);
|
|
994
|
+
}
|
|
995
|
+
return args;
|
|
996
|
+
}
|
|
997
|
+
buildUpgradeCommand(packages, options) {
|
|
998
|
+
const target = options.target || "latest";
|
|
999
|
+
const packagesWithTarget = packages.map((pkg) => `${pkg}@${target}`);
|
|
1000
|
+
return this.buildAddCommand(packagesWithTarget, {});
|
|
1001
|
+
}
|
|
1002
|
+
parsePackageSpec(packageSpec) {
|
|
1003
|
+
const match = packageSpec.match(/^(@?[^@]+)(?:@(.+))?$/);
|
|
1004
|
+
if (!match) return { name: packageSpec };
|
|
1005
|
+
return {
|
|
1006
|
+
name: match[1] ?? packageSpec,
|
|
1007
|
+
version: match[2]
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1012
|
+
//#endregion
|
|
1013
|
+
//#region src/package-manager/adapters/index.ts
|
|
1014
|
+
/**
|
|
1015
|
+
* Adapter registry
|
|
1016
|
+
*/
|
|
1017
|
+
const adapters = {
|
|
1018
|
+
npm: new NpmAdapter(),
|
|
1019
|
+
pnpm: new PnpmAdapter(),
|
|
1020
|
+
yarn: new YarnAdapter(),
|
|
1021
|
+
bun: new BunAdapter(),
|
|
1022
|
+
deno: new DenoAdapter()
|
|
1023
|
+
};
|
|
1024
|
+
/**
|
|
1025
|
+
* Get adapter for a specific package manager
|
|
1026
|
+
*/
|
|
1027
|
+
function getAdapter(packageManager) {
|
|
1028
|
+
return adapters[packageManager];
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Get all available adapters
|
|
1032
|
+
*/
|
|
1033
|
+
function getAllAdapters() {
|
|
1034
|
+
return { ...adapters };
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
//#endregion
|
|
1038
|
+
//#region ../../node_modules/.pnpm/es-toolkit@1.44.0/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
|
|
1039
|
+
function isPlainObject$1(value) {
|
|
1040
|
+
if (!value || typeof value !== "object") return false;
|
|
1041
|
+
const proto = Object.getPrototypeOf(value);
|
|
1042
|
+
if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false;
|
|
1043
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
//#endregion
|
|
1047
|
+
//#region ../../node_modules/.pnpm/es-toolkit@1.44.0/node_modules/es-toolkit/dist/_internal/isUnsafeProperty.mjs
|
|
1048
|
+
function isUnsafeProperty(key) {
|
|
1049
|
+
return key === "__proto__";
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
//#endregion
|
|
1053
|
+
//#region ../../node_modules/.pnpm/es-toolkit@1.44.0/node_modules/es-toolkit/dist/object/merge.mjs
|
|
1054
|
+
function merge(target, source) {
|
|
1055
|
+
const sourceKeys = Object.keys(source);
|
|
1056
|
+
for (let i = 0; i < sourceKeys.length; i++) {
|
|
1057
|
+
const key = sourceKeys[i];
|
|
1058
|
+
if (isUnsafeProperty(key)) continue;
|
|
1059
|
+
const sourceValue = source[key];
|
|
1060
|
+
const targetValue = target[key];
|
|
1061
|
+
if (isMergeableValue(sourceValue) && isMergeableValue(targetValue)) target[key] = merge(targetValue, sourceValue);
|
|
1062
|
+
else if (Array.isArray(sourceValue)) target[key] = merge([], sourceValue);
|
|
1063
|
+
else if (isPlainObject$1(sourceValue)) target[key] = merge({}, sourceValue);
|
|
1064
|
+
else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue;
|
|
1065
|
+
}
|
|
1066
|
+
return target;
|
|
1067
|
+
}
|
|
1068
|
+
function isMergeableValue(value) {
|
|
1069
|
+
return isPlainObject$1(value) || Array.isArray(value);
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
//#endregion
|
|
1073
|
+
//#region src/utils/error.ts
|
|
1074
|
+
const handleError = (err, message) => {
|
|
1075
|
+
if (isError(err)) ErrorMessage({ text: `${message}: ${err.message}` });
|
|
1076
|
+
else if (isString(err)) ErrorMessage({ text: `${message}: ${err}` });
|
|
1077
|
+
else log.error(message, err);
|
|
1078
|
+
};
|
|
1079
|
+
|
|
1080
|
+
//#endregion
|
|
1081
|
+
//#region src/utils/command.ts
|
|
1082
|
+
const exit = (code) => process$1.exit(code);
|
|
1083
|
+
const createHelpExample = (...commands) => {
|
|
1084
|
+
return `
|
|
1085
|
+
Example:
|
|
1086
|
+
${commands.map((command) => ` $ ${command}`).join("\n")}
|
|
1087
|
+
`;
|
|
1088
|
+
};
|
|
1089
|
+
const createCommand = (name) => {
|
|
1090
|
+
const command = new Command(name);
|
|
1091
|
+
command.allowExcessArguments();
|
|
1092
|
+
command.allowUnknownOption();
|
|
1093
|
+
return command;
|
|
1094
|
+
};
|
|
1095
|
+
const buildCommand = (command, dynamicParts = []) => {
|
|
1096
|
+
return {
|
|
1097
|
+
command,
|
|
1098
|
+
parts: dynamicParts.filter((part) => !isEmpty(part)).map((part) => part?.toString())
|
|
1099
|
+
};
|
|
1100
|
+
};
|
|
1101
|
+
const x = (command, args, options = {}) => {
|
|
1102
|
+
return x$1(command, args, merge({
|
|
1103
|
+
nodeOptions: {
|
|
1104
|
+
cwd: process$1.cwd(),
|
|
1105
|
+
FORCE_COLOR: "1"
|
|
1106
|
+
},
|
|
1107
|
+
throwOnError: true
|
|
1108
|
+
}, options));
|
|
1109
|
+
};
|
|
1110
|
+
const zx = (baseCommand, dynamicParts = [], options = {}) => {
|
|
1111
|
+
const { command, parts } = buildCommand(baseCommand, dynamicParts);
|
|
1112
|
+
const { signal } = new AbortController();
|
|
1113
|
+
try {
|
|
1114
|
+
return (isEmpty(options) ? $ : $({
|
|
1115
|
+
...options,
|
|
1116
|
+
signal
|
|
1117
|
+
}))`${command} ${parts}`;
|
|
1118
|
+
} catch (error) {
|
|
1119
|
+
handleError(error, `Failed to execute dynamic command: ${command}`);
|
|
1120
|
+
throw error;
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
const xASync = async (command, args, options) => {
|
|
1124
|
+
try {
|
|
1125
|
+
const { timeout, quiet, ...execOptions } = options ?? {};
|
|
1126
|
+
const execPromise = x$1(command, args, merge({
|
|
1127
|
+
nodeOptions: {
|
|
1128
|
+
cwd: process$1.cwd(),
|
|
1129
|
+
FORCE_COLOR: "1"
|
|
1130
|
+
},
|
|
1131
|
+
throwOnError: true
|
|
1132
|
+
}, execOptions));
|
|
1133
|
+
let result;
|
|
1134
|
+
if (timeout) {
|
|
1135
|
+
let timer;
|
|
1136
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
1137
|
+
timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`Command timeout after ${timeout}ms`)), timeout);
|
|
1138
|
+
});
|
|
1139
|
+
try {
|
|
1140
|
+
result = await Promise.race([execPromise, timeoutPromise]);
|
|
1141
|
+
} finally {
|
|
1142
|
+
timer && clearTimeout(timer);
|
|
1143
|
+
}
|
|
1144
|
+
} else result = await execPromise;
|
|
1145
|
+
if (result.exitCode) {
|
|
1146
|
+
if (!quiet) {
|
|
1147
|
+
log.show(`Failed to execute command ${command}. Command exited with code ${result.exitCode}.`, { type: "error" });
|
|
1148
|
+
log.show(result.stderr, { type: "error" });
|
|
1149
|
+
}
|
|
1150
|
+
return [new Error(result.stderr), null];
|
|
1151
|
+
}
|
|
1152
|
+
return [null, result];
|
|
1153
|
+
} catch (error) {
|
|
1154
|
+
handleError(error, `Failed to execute command ${command}.`);
|
|
1155
|
+
return [isError(error) ? error : new Error(error), null];
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
//#endregion
|
|
1160
|
+
//#region src/utils/prompts.ts
|
|
1161
|
+
const createOptions = (options) => options.map((option) => ({
|
|
1162
|
+
label: option.toString(),
|
|
1163
|
+
value: option
|
|
1164
|
+
}));
|
|
1165
|
+
const createPrompt = (fn) => {
|
|
1166
|
+
return async (options) => {
|
|
1167
|
+
const result = await fn(options);
|
|
1168
|
+
if (isCancel(result)) {
|
|
1169
|
+
cancel("User cancelled");
|
|
1170
|
+
exit(0);
|
|
1171
|
+
}
|
|
1172
|
+
return result;
|
|
1173
|
+
};
|
|
1174
|
+
};
|
|
1175
|
+
const createShowList = createPrompt((options) => {
|
|
1176
|
+
options.map((option) => {
|
|
1177
|
+
return isString(option) ? option : option.label;
|
|
1178
|
+
}).forEach((item) => {
|
|
1179
|
+
log.show(item, { type: "step" });
|
|
1180
|
+
});
|
|
1181
|
+
});
|
|
1182
|
+
const createSearch = ({ message, options }) => {
|
|
1183
|
+
const fuse = new Fuse(options, { keys: ["label"] });
|
|
1184
|
+
return search({
|
|
1185
|
+
message,
|
|
1186
|
+
source: (term) => {
|
|
1187
|
+
if (!term) return options;
|
|
1188
|
+
return fuse.search(term).map(({ item }) => item);
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
};
|
|
1192
|
+
process.on("uncaughtException", (error) => {
|
|
1193
|
+
if (error instanceof Error && error.name === "ExitPromptError") log.show("User cancelled", { type: "error" });
|
|
1194
|
+
else throw error;
|
|
1195
|
+
});
|
|
1196
|
+
const createCheckbox = async (opts) => {
|
|
1197
|
+
const result = await multiselect(opts);
|
|
1198
|
+
if (isCancel(result)) {
|
|
1199
|
+
cancel("User cancelled");
|
|
1200
|
+
exit(0);
|
|
1201
|
+
}
|
|
1202
|
+
return result;
|
|
1203
|
+
};
|
|
1204
|
+
const createNote = ({ message = "", title = "", opts }) => note(message, title, opts);
|
|
1205
|
+
const createConfirm = createPrompt(confirm);
|
|
1206
|
+
const createTasks = createPrompt(tasks);
|
|
1207
|
+
const createSelect = async (opts) => {
|
|
1208
|
+
const result = await select(opts);
|
|
1209
|
+
if (isCancel(result)) {
|
|
1210
|
+
cancel("User cancelled");
|
|
1211
|
+
exit(0);
|
|
1212
|
+
}
|
|
1213
|
+
return result;
|
|
1214
|
+
};
|
|
1215
|
+
const createInput = async (opts) => {
|
|
1216
|
+
const result = await text(opts);
|
|
1217
|
+
if (isCancel(result)) {
|
|
1218
|
+
cancel("User cancelled");
|
|
1219
|
+
exit(0);
|
|
1220
|
+
}
|
|
1221
|
+
return result;
|
|
1222
|
+
};
|
|
1223
|
+
const createGroupMultiSelect = async (opts) => {
|
|
1224
|
+
const result = await groupMultiselect(opts);
|
|
1225
|
+
if (isCancel(result)) {
|
|
1226
|
+
cancel("User cancelled");
|
|
1227
|
+
process.exit(0);
|
|
1228
|
+
}
|
|
1229
|
+
return result;
|
|
1230
|
+
};
|
|
1231
|
+
const createGroup = async (opts) => {
|
|
1232
|
+
const result = await group(opts);
|
|
1233
|
+
if (isCancel(result)) {
|
|
1234
|
+
cancel("User cancelled");
|
|
1235
|
+
exit(0);
|
|
1236
|
+
}
|
|
1237
|
+
return result;
|
|
1238
|
+
};
|
|
1239
|
+
const createSpinner = (message, options) => {
|
|
1240
|
+
const s = spinner(options);
|
|
1241
|
+
s.start(message);
|
|
1242
|
+
return s;
|
|
1243
|
+
};
|
|
1244
|
+
const createTaskLog = (title, options) => taskLog({
|
|
1245
|
+
title,
|
|
1246
|
+
...options
|
|
1247
|
+
});
|
|
1248
|
+
|
|
1249
|
+
//#endregion
|
|
1250
|
+
//#region src/package-manager/types.ts
|
|
1251
|
+
/**
|
|
1252
|
+
* Lock file patterns for detection
|
|
1253
|
+
*/
|
|
1254
|
+
const LOCK_FILE_PATTERNS = {
|
|
1255
|
+
npm: ["package-lock.json"],
|
|
1256
|
+
pnpm: ["pnpm-lock.yaml"],
|
|
1257
|
+
yarn: ["yarn.lock"],
|
|
1258
|
+
bun: ["bun.lockb", "bun.lock"],
|
|
1259
|
+
deno: ["deno.json", "deno.jsonc"]
|
|
1260
|
+
};
|
|
1261
|
+
/**
|
|
1262
|
+
* Package manager display names
|
|
1263
|
+
*/
|
|
1264
|
+
const PACKAGE_MANAGER_NAMES = {
|
|
1265
|
+
npm: "npm",
|
|
1266
|
+
pnpm: "pnpm",
|
|
1267
|
+
yarn: "yarn",
|
|
1268
|
+
bun: "Bun",
|
|
1269
|
+
deno: "Deno"
|
|
1270
|
+
};
|
|
1271
|
+
|
|
1272
|
+
//#endregion
|
|
1273
|
+
//#region src/package-manager/detector.ts
|
|
1274
|
+
/**
|
|
1275
|
+
* Cache file location
|
|
1276
|
+
*/
|
|
1277
|
+
const CACHE_FILE = ".nemo/package-manager.json";
|
|
1278
|
+
const CACHE_DURATION = 10080 * 60 * 1e3;
|
|
1279
|
+
/**
|
|
1280
|
+
* PackageManagerDetector - Detects the package manager used by a project
|
|
1281
|
+
*
|
|
1282
|
+
* Detection priority:
|
|
1283
|
+
* 1. Lock file analysis (package-lock.json, pnpm-lock.yaml, yarn.lock, bun.lockb)
|
|
1284
|
+
* 2. package.json packageManager field
|
|
1285
|
+
* 3. Interactive user selection
|
|
1286
|
+
*/
|
|
1287
|
+
var PackageManagerDetector = class {
|
|
1288
|
+
projectRoot;
|
|
1289
|
+
cachePath;
|
|
1290
|
+
constructor(projectRoot = process.cwd()) {
|
|
1291
|
+
console.log("🚀 : PackageManagerDetector : constructor : projectRoot:", projectRoot);
|
|
1292
|
+
this.projectRoot = projectRoot;
|
|
1293
|
+
this.cachePath = path.join(projectRoot, CACHE_FILE);
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Detect the package manager for the project
|
|
1297
|
+
*/
|
|
1298
|
+
async detect(forceRefresh = false) {
|
|
1299
|
+
if (!forceRefresh) {
|
|
1300
|
+
const cached = await this.loadCache();
|
|
1301
|
+
if (cached && !this.isCacheExpired(cached)) {
|
|
1302
|
+
log.info(`Using cached package manager: ${cached.result.packageManager}`);
|
|
1303
|
+
return cached.result;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
const lockFileResult = await this.detectByLockFile();
|
|
1307
|
+
if (lockFileResult) {
|
|
1308
|
+
const result = await this.createDetectionResult(lockFileResult, "lock-file");
|
|
1309
|
+
await this.saveCache(result);
|
|
1310
|
+
return result;
|
|
1311
|
+
}
|
|
1312
|
+
const packageJsonResult = await this.detectByPackageJson();
|
|
1313
|
+
if (packageJsonResult) {
|
|
1314
|
+
const result = await this.createDetectionResult(packageJsonResult, "package-json");
|
|
1315
|
+
await this.saveCache(result);
|
|
1316
|
+
return result;
|
|
1317
|
+
}
|
|
1318
|
+
log.warn("Could not auto-detect package manager");
|
|
1319
|
+
const userSelection = await this.promptUser();
|
|
1320
|
+
const result = await this.createDetectionResult(userSelection, "user-selection");
|
|
1321
|
+
await this.saveCache(result);
|
|
1322
|
+
return result;
|
|
1323
|
+
}
|
|
1324
|
+
/**
|
|
1325
|
+
* Detect package manager from lock files
|
|
1326
|
+
*/
|
|
1327
|
+
async detectByLockFile() {
|
|
1328
|
+
for (const pm of [
|
|
1329
|
+
"pnpm",
|
|
1330
|
+
"yarn",
|
|
1331
|
+
"npm",
|
|
1332
|
+
"bun",
|
|
1333
|
+
"deno"
|
|
1334
|
+
]) {
|
|
1335
|
+
const patterns = LOCK_FILE_PATTERNS[pm];
|
|
1336
|
+
for (const pattern of patterns) {
|
|
1337
|
+
const lockFilePath = path.join(this.projectRoot, pattern);
|
|
1338
|
+
console.log("🚀 : PackageManagerDetector : detectByLockFile : lockFilePath:", lockFilePath);
|
|
1339
|
+
if (existsSync(lockFilePath)) {
|
|
1340
|
+
log.info(`Detected ${pm} from lock file: ${pattern}`);
|
|
1341
|
+
return pm;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
return null;
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Detect package manager from package.json packageManager field
|
|
1349
|
+
*/
|
|
1350
|
+
async detectByPackageJson() {
|
|
1351
|
+
const packageJsonPath = path.join(this.projectRoot, "package.json");
|
|
1352
|
+
try {
|
|
1353
|
+
const content = await fs$1.readFile(packageJsonPath, "utf-8");
|
|
1354
|
+
const packageManagerField = JSON.parse(content).packageManager;
|
|
1355
|
+
if (!packageManagerField) return null;
|
|
1356
|
+
const match = packageManagerField.match(/^([a-z]+)@/);
|
|
1357
|
+
if (match) {
|
|
1358
|
+
const pm = match[1];
|
|
1359
|
+
if (this.isValidPackageManager(pm)) {
|
|
1360
|
+
log.info(`Detected ${pm} from package.json packageManager field`);
|
|
1361
|
+
return pm;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
return null;
|
|
1365
|
+
} catch (error) {
|
|
1366
|
+
log.error(`Could not read package.json: ${error}`);
|
|
1367
|
+
return null;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Prompt user to select package manager interactively
|
|
1372
|
+
*/
|
|
1373
|
+
async promptUser() {
|
|
1374
|
+
const selected = await createSelect({
|
|
1375
|
+
message: "Could not detect package manager. Please select one:",
|
|
1376
|
+
options: Object.entries(PACKAGE_MANAGER_NAMES).map(([value, label]) => ({
|
|
1377
|
+
value,
|
|
1378
|
+
label
|
|
1379
|
+
}))
|
|
1380
|
+
});
|
|
1381
|
+
if (!selected || !this.isValidPackageManager(selected)) {
|
|
1382
|
+
log.error("Invalid selection. Defaulting to npm.");
|
|
1383
|
+
return "npm";
|
|
1384
|
+
}
|
|
1385
|
+
return selected;
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Check if a package manager is installed and available
|
|
1389
|
+
*/
|
|
1390
|
+
async checkAvailability(pm) {
|
|
1391
|
+
try {
|
|
1392
|
+
return (await x(pm, ["--version"])).exitCode === 0;
|
|
1393
|
+
} catch {
|
|
1394
|
+
return false;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Create a detection result with metadata
|
|
1399
|
+
*/
|
|
1400
|
+
async createDetectionResult(packageManager, method) {
|
|
1401
|
+
const isAvailable = await this.checkAvailability(packageManager);
|
|
1402
|
+
return {
|
|
1403
|
+
packageManager,
|
|
1404
|
+
method,
|
|
1405
|
+
detectedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1406
|
+
isAvailable
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* Load cached detection result
|
|
1411
|
+
*/
|
|
1412
|
+
async loadCache() {
|
|
1413
|
+
try {
|
|
1414
|
+
if (!existsSync(this.cachePath)) return null;
|
|
1415
|
+
const content = await fs$1.readFile(this.cachePath, "utf-8");
|
|
1416
|
+
return JSON.parse(content);
|
|
1417
|
+
} catch {
|
|
1418
|
+
return null;
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Save detection result to cache
|
|
1423
|
+
*/
|
|
1424
|
+
async saveCache(result) {
|
|
1425
|
+
try {
|
|
1426
|
+
const cacheDir = path.dirname(this.cachePath);
|
|
1427
|
+
await fs$1.mkdir(cacheDir, { recursive: true });
|
|
1428
|
+
const cache = {
|
|
1429
|
+
result,
|
|
1430
|
+
expiresAt: new Date(Date.now() + CACHE_DURATION).toISOString()
|
|
1431
|
+
};
|
|
1432
|
+
await fs$1.writeFile(this.cachePath, JSON.stringify(cache, null, 2));
|
|
1433
|
+
} catch (error) {
|
|
1434
|
+
log.error(`Could not save cache: ${error}`);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
/**
|
|
1438
|
+
* Check if cache has expired
|
|
1439
|
+
*/
|
|
1440
|
+
isCacheExpired(cache) {
|
|
1441
|
+
return new Date(cache.expiresAt) < /* @__PURE__ */ new Date();
|
|
1442
|
+
}
|
|
1443
|
+
/**
|
|
1444
|
+
* Validate package manager enum
|
|
1445
|
+
*/
|
|
1446
|
+
isValidPackageManager(pm) {
|
|
1447
|
+
return [
|
|
1448
|
+
"npm",
|
|
1449
|
+
"pnpm",
|
|
1450
|
+
"yarn",
|
|
1451
|
+
"bun",
|
|
1452
|
+
"deno"
|
|
1453
|
+
].includes(pm);
|
|
1454
|
+
}
|
|
1455
|
+
/**
|
|
1456
|
+
* Clear the cache (useful for testing or force re-detection)
|
|
1457
|
+
*/
|
|
1458
|
+
async clearCache() {
|
|
1459
|
+
try {
|
|
1460
|
+
if (existsSync(this.cachePath)) {
|
|
1461
|
+
await fs$1.unlink(this.cachePath);
|
|
1462
|
+
log.info("Package manager cache cleared");
|
|
1463
|
+
}
|
|
1464
|
+
} catch (error) {
|
|
1465
|
+
log.error(`Could not clear cache: ${error}`);
|
|
1466
|
+
}
|
|
281
1467
|
}
|
|
282
1468
|
};
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const
|
|
1469
|
+
/**
|
|
1470
|
+
* Get adapter for detected or specified package manager
|
|
1471
|
+
*/
|
|
1472
|
+
async function getPackageManagerAdapter(packageManager) {
|
|
1473
|
+
const detector = new PackageManagerDetector();
|
|
1474
|
+
return getAdapter(packageManager || (await detector.detect()).packageManager);
|
|
1475
|
+
}
|
|
288
1476
|
|
|
289
1477
|
//#endregion
|
|
290
1478
|
//#region src/utils/browser.ts
|
|
@@ -303,117 +1491,6 @@ const getBrowserApps = () => {
|
|
|
303
1491
|
const clearScreen = () => console.log(clearScreen$1);
|
|
304
1492
|
const clearTerminal = () => console.log(clearTerminal$1);
|
|
305
1493
|
|
|
306
|
-
//#endregion
|
|
307
|
-
//#region ../../node_modules/.pnpm/es-toolkit@1.44.0/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
|
|
308
|
-
function isPlainObject$1(value) {
|
|
309
|
-
if (!value || typeof value !== "object") return false;
|
|
310
|
-
const proto = Object.getPrototypeOf(value);
|
|
311
|
-
if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false;
|
|
312
|
-
return Object.prototype.toString.call(value) === "[object Object]";
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
//#endregion
|
|
316
|
-
//#region ../../node_modules/.pnpm/es-toolkit@1.44.0/node_modules/es-toolkit/dist/_internal/isUnsafeProperty.mjs
|
|
317
|
-
function isUnsafeProperty(key) {
|
|
318
|
-
return key === "__proto__";
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
//#endregion
|
|
322
|
-
//#region ../../node_modules/.pnpm/es-toolkit@1.44.0/node_modules/es-toolkit/dist/object/merge.mjs
|
|
323
|
-
function merge(target, source) {
|
|
324
|
-
const sourceKeys = Object.keys(source);
|
|
325
|
-
for (let i = 0; i < sourceKeys.length; i++) {
|
|
326
|
-
const key = sourceKeys[i];
|
|
327
|
-
if (isUnsafeProperty(key)) continue;
|
|
328
|
-
const sourceValue = source[key];
|
|
329
|
-
const targetValue = target[key];
|
|
330
|
-
if (isMergeableValue(sourceValue) && isMergeableValue(targetValue)) target[key] = merge(targetValue, sourceValue);
|
|
331
|
-
else if (Array.isArray(sourceValue)) target[key] = merge([], sourceValue);
|
|
332
|
-
else if (isPlainObject$1(sourceValue)) target[key] = merge({}, sourceValue);
|
|
333
|
-
else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue;
|
|
334
|
-
}
|
|
335
|
-
return target;
|
|
336
|
-
}
|
|
337
|
-
function isMergeableValue(value) {
|
|
338
|
-
return isPlainObject$1(value) || Array.isArray(value);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
//#endregion
|
|
342
|
-
//#region src/utils/error.ts
|
|
343
|
-
const handleError = (err, message) => {
|
|
344
|
-
if (isError(err)) ErrorMessage({ text: `${message}: ${err.message}` });
|
|
345
|
-
else if (isString(err)) ErrorMessage({ text: `${message}: ${err}` });
|
|
346
|
-
else log.error(message, err);
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
//#endregion
|
|
350
|
-
//#region src/utils/command.ts
|
|
351
|
-
const exit = (code) => process$1.exit(code);
|
|
352
|
-
const createHelpExample = (...commands) => {
|
|
353
|
-
return `
|
|
354
|
-
Example:
|
|
355
|
-
${commands.map((command) => ` $ ${command}`).join("\n")}
|
|
356
|
-
`;
|
|
357
|
-
};
|
|
358
|
-
const createCommand = (name) => {
|
|
359
|
-
const command = new Command(name);
|
|
360
|
-
command.allowExcessArguments();
|
|
361
|
-
command.allowUnknownOption();
|
|
362
|
-
return command;
|
|
363
|
-
};
|
|
364
|
-
const buildCommand = (command, dynamicParts = []) => {
|
|
365
|
-
return {
|
|
366
|
-
command,
|
|
367
|
-
parts: dynamicParts.filter((part) => !isEmpty(part)).map((part) => part?.toString())
|
|
368
|
-
};
|
|
369
|
-
};
|
|
370
|
-
const x = (command, args, options = {}) => {
|
|
371
|
-
return x$1(command, args, merge({
|
|
372
|
-
nodeOptions: {
|
|
373
|
-
cwd: process$1.cwd(),
|
|
374
|
-
FORCE_COLOR: "1"
|
|
375
|
-
},
|
|
376
|
-
throwOnError: true
|
|
377
|
-
}, options));
|
|
378
|
-
};
|
|
379
|
-
const zx = (baseCommand, dynamicParts = [], options = {}) => {
|
|
380
|
-
const { command, parts } = buildCommand(baseCommand, dynamicParts);
|
|
381
|
-
const { signal } = new AbortController();
|
|
382
|
-
try {
|
|
383
|
-
return (isEmpty(options) ? $ : $({
|
|
384
|
-
...options,
|
|
385
|
-
signal
|
|
386
|
-
}))`${command} ${parts}`;
|
|
387
|
-
} catch (error) {
|
|
388
|
-
handleError(error, `Failed to execute dynamic command: ${command}`);
|
|
389
|
-
throw error;
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
const xASync = async (command, args, options) => {
|
|
393
|
-
try {
|
|
394
|
-
const { timeout, quiet, ...execOptions } = options ?? {};
|
|
395
|
-
const execPromise = x$1(command, args, merge({
|
|
396
|
-
nodeOptions: {
|
|
397
|
-
cwd: process$1.cwd(),
|
|
398
|
-
FORCE_COLOR: "1"
|
|
399
|
-
},
|
|
400
|
-
throwOnError: true
|
|
401
|
-
}, execOptions));
|
|
402
|
-
const result = timeout ? await Promise.race([execPromise, new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error(`Command timeout after ${timeout}ms`)), timeout))]) : await execPromise;
|
|
403
|
-
if (result.exitCode) {
|
|
404
|
-
if (!quiet) {
|
|
405
|
-
log.show(`Failed to execute command ${command}. Command exited with code ${result.exitCode}.`, { type: "error" });
|
|
406
|
-
log.show(result.stderr, { type: "error" });
|
|
407
|
-
}
|
|
408
|
-
return [new Error(result.stderr), null];
|
|
409
|
-
}
|
|
410
|
-
return [null, result];
|
|
411
|
-
} catch (error) {
|
|
412
|
-
handleError(error, `Failed to execute command ${command}.`);
|
|
413
|
-
return [isError(error) ? error : new Error(error), null];
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
|
|
417
1494
|
//#endregion
|
|
418
1495
|
//#region src/utils/common.ts
|
|
419
1496
|
const cached = (fn) => {
|
|
@@ -433,11 +1510,11 @@ const sleep = (millisecond, controller) => {
|
|
|
433
1510
|
};
|
|
434
1511
|
|
|
435
1512
|
//#endregion
|
|
436
|
-
//#region ../../node_modules/.pnpm/dotenv@17.
|
|
1513
|
+
//#region ../../node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/package.json
|
|
437
1514
|
var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
438
1515
|
module.exports = {
|
|
439
1516
|
"name": "dotenv",
|
|
440
|
-
"version": "17.
|
|
1517
|
+
"version": "17.3.1",
|
|
441
1518
|
"description": "Loads environment variables from .env file",
|
|
442
1519
|
"main": "lib/main.js",
|
|
443
1520
|
"types": "lib/main.d.ts",
|
|
@@ -496,9 +1573,9 @@ var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
496
1573
|
}));
|
|
497
1574
|
|
|
498
1575
|
//#endregion
|
|
499
|
-
//#region ../../node_modules/.pnpm/dotenv@17.
|
|
1576
|
+
//#region ../../node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.js
|
|
500
1577
|
var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
501
|
-
const fs$
|
|
1578
|
+
const fs$3 = __require("fs");
|
|
502
1579
|
const path$13 = __require("path");
|
|
503
1580
|
const os = __require("os");
|
|
504
1581
|
const crypto = __require("crypto");
|
|
@@ -507,12 +1584,9 @@ var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
507
1584
|
"🔐 encrypt with Dotenvx: https://dotenvx.com",
|
|
508
1585
|
"🔐 prevent committing .env to code: https://dotenvx.com/precommit",
|
|
509
1586
|
"🔐 prevent building .env in docker: https://dotenvx.com/prebuild",
|
|
510
|
-
"
|
|
511
|
-
"
|
|
512
|
-
"
|
|
513
|
-
"✅ audit secrets and track compliance: https://dotenvx.com/ops",
|
|
514
|
-
"🔄 add secrets lifecycle management: https://dotenvx.com/ops",
|
|
515
|
-
"🔑 add access controls to secrets: https://dotenvx.com/ops",
|
|
1587
|
+
"🤖 agentic secret storage: https://dotenvx.com/as2",
|
|
1588
|
+
"⚡️ secrets for agents: https://dotenvx.com/as2",
|
|
1589
|
+
"🛡️ auth for agents: https://vestauth.com",
|
|
516
1590
|
"🛠️ run anywhere with `dotenvx run -- yourcommand`",
|
|
517
1591
|
"⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
|
|
518
1592
|
"⚙️ enable debug logging with { debug: true }",
|
|
@@ -635,10 +1709,10 @@ var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
635
1709
|
function _vaultPath(options) {
|
|
636
1710
|
let possibleVaultPath = null;
|
|
637
1711
|
if (options && options.path && options.path.length > 0) if (Array.isArray(options.path)) {
|
|
638
|
-
for (const filepath of options.path) if (fs$
|
|
1712
|
+
for (const filepath of options.path) if (fs$3.existsSync(filepath)) possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
639
1713
|
} else possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
640
1714
|
else possibleVaultPath = path$13.resolve(process.cwd(), ".env.vault");
|
|
641
|
-
if (fs$
|
|
1715
|
+
if (fs$3.existsSync(possibleVaultPath)) return possibleVaultPath;
|
|
642
1716
|
return null;
|
|
643
1717
|
}
|
|
644
1718
|
function _resolveHome(envPath) {
|
|
@@ -672,7 +1746,7 @@ var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
672
1746
|
let lastError;
|
|
673
1747
|
const parsedAll = {};
|
|
674
1748
|
for (const path of optionPaths) try {
|
|
675
|
-
const parsed = DotenvModule.parse(fs$
|
|
1749
|
+
const parsed = DotenvModule.parse(fs$3.readFileSync(path, { encoding }));
|
|
676
1750
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
677
1751
|
} catch (e) {
|
|
678
1752
|
if (debug) _debug(`Failed to load ${path} ${e.message}`);
|
|
@@ -1252,7 +2326,7 @@ var require_clone = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1252
2326
|
//#endregion
|
|
1253
2327
|
//#region ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js
|
|
1254
2328
|
var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1255
|
-
var fs$
|
|
2329
|
+
var fs$2 = __require("fs");
|
|
1256
2330
|
var polyfills = require_polyfills();
|
|
1257
2331
|
var legacy = require_legacy_streams();
|
|
1258
2332
|
var clone = require_clone();
|
|
@@ -1281,36 +2355,36 @@ var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1281
2355
|
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
1282
2356
|
console.error(m);
|
|
1283
2357
|
};
|
|
1284
|
-
if (!fs$
|
|
1285
|
-
publishQueue(fs$
|
|
1286
|
-
fs$
|
|
2358
|
+
if (!fs$2[gracefulQueue]) {
|
|
2359
|
+
publishQueue(fs$2, global[gracefulQueue] || []);
|
|
2360
|
+
fs$2.close = (function(fs$close) {
|
|
1287
2361
|
function close(fd, cb) {
|
|
1288
|
-
return fs$close.call(fs$
|
|
2362
|
+
return fs$close.call(fs$2, fd, function(err) {
|
|
1289
2363
|
if (!err) resetQueue();
|
|
1290
2364
|
if (typeof cb === "function") cb.apply(this, arguments);
|
|
1291
2365
|
});
|
|
1292
2366
|
}
|
|
1293
2367
|
Object.defineProperty(close, previousSymbol, { value: fs$close });
|
|
1294
2368
|
return close;
|
|
1295
|
-
})(fs$
|
|
1296
|
-
fs$
|
|
2369
|
+
})(fs$2.close);
|
|
2370
|
+
fs$2.closeSync = (function(fs$closeSync) {
|
|
1297
2371
|
function closeSync(fd) {
|
|
1298
|
-
fs$closeSync.apply(fs$
|
|
2372
|
+
fs$closeSync.apply(fs$2, arguments);
|
|
1299
2373
|
resetQueue();
|
|
1300
2374
|
}
|
|
1301
2375
|
Object.defineProperty(closeSync, previousSymbol, { value: fs$closeSync });
|
|
1302
2376
|
return closeSync;
|
|
1303
|
-
})(fs$
|
|
2377
|
+
})(fs$2.closeSync);
|
|
1304
2378
|
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) process.on("exit", function() {
|
|
1305
|
-
debug(fs$
|
|
1306
|
-
__require("assert").equal(fs$
|
|
2379
|
+
debug(fs$2[gracefulQueue]);
|
|
2380
|
+
__require("assert").equal(fs$2[gracefulQueue].length, 0);
|
|
1307
2381
|
});
|
|
1308
2382
|
}
|
|
1309
|
-
if (!global[gracefulQueue]) publishQueue(global, fs$
|
|
1310
|
-
module.exports = patch(clone(fs$
|
|
1311
|
-
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs$
|
|
1312
|
-
module.exports = patch(fs$
|
|
1313
|
-
fs$
|
|
2383
|
+
if (!global[gracefulQueue]) publishQueue(global, fs$2[gracefulQueue]);
|
|
2384
|
+
module.exports = patch(clone(fs$2));
|
|
2385
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs$2.__patched) {
|
|
2386
|
+
module.exports = patch(fs$2);
|
|
2387
|
+
fs$2.__patched = true;
|
|
1314
2388
|
}
|
|
1315
2389
|
function patch(fs) {
|
|
1316
2390
|
polyfills(fs);
|
|
@@ -1565,23 +2639,23 @@ var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1565
2639
|
}
|
|
1566
2640
|
function enqueue(elem) {
|
|
1567
2641
|
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
1568
|
-
fs$
|
|
2642
|
+
fs$2[gracefulQueue].push(elem);
|
|
1569
2643
|
retry();
|
|
1570
2644
|
}
|
|
1571
2645
|
var retryTimer;
|
|
1572
2646
|
function resetQueue() {
|
|
1573
2647
|
var now = Date.now();
|
|
1574
|
-
for (var i = 0; i < fs$
|
|
1575
|
-
fs$
|
|
1576
|
-
fs$
|
|
2648
|
+
for (var i = 0; i < fs$2[gracefulQueue].length; ++i) if (fs$2[gracefulQueue][i].length > 2) {
|
|
2649
|
+
fs$2[gracefulQueue][i][3] = now;
|
|
2650
|
+
fs$2[gracefulQueue][i][4] = now;
|
|
1577
2651
|
}
|
|
1578
2652
|
retry();
|
|
1579
2653
|
}
|
|
1580
2654
|
function retry() {
|
|
1581
2655
|
clearTimeout(retryTimer);
|
|
1582
2656
|
retryTimer = void 0;
|
|
1583
|
-
if (fs$
|
|
1584
|
-
var elem = fs$
|
|
2657
|
+
if (fs$2[gracefulQueue].length === 0) return;
|
|
2658
|
+
var elem = fs$2[gracefulQueue].shift();
|
|
1585
2659
|
var fn = elem[0];
|
|
1586
2660
|
var args = elem[1];
|
|
1587
2661
|
var err = elem[2];
|
|
@@ -1600,7 +2674,7 @@ var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1600
2674
|
if (sinceAttempt >= Math.min(sinceStart * 1.2, 100)) {
|
|
1601
2675
|
debug("RETRY", fn.name, args);
|
|
1602
2676
|
fn.apply(null, args.concat([startTime]));
|
|
1603
|
-
} else fs$
|
|
2677
|
+
} else fs$2[gracefulQueue].push(elem);
|
|
1604
2678
|
}
|
|
1605
2679
|
if (retryTimer === void 0) retryTimer = setTimeout(retry, 0);
|
|
1606
2680
|
}
|
|
@@ -2892,102 +3966,16 @@ const safeAwait = async (promise) => {
|
|
|
2892
3966
|
}
|
|
2893
3967
|
};
|
|
2894
3968
|
|
|
2895
|
-
//#endregion
|
|
2896
|
-
//#region src/utils/prompts.ts
|
|
2897
|
-
const createOptions = (options) => options.map((option) => ({
|
|
2898
|
-
label: option.toString(),
|
|
2899
|
-
value: option
|
|
2900
|
-
}));
|
|
2901
|
-
const createPrompt = (fn) => {
|
|
2902
|
-
return async (options) => {
|
|
2903
|
-
const result = await fn(options);
|
|
2904
|
-
if (isCancel(result)) {
|
|
2905
|
-
cancel("User cancelled");
|
|
2906
|
-
exit(0);
|
|
2907
|
-
}
|
|
2908
|
-
return result;
|
|
2909
|
-
};
|
|
2910
|
-
};
|
|
2911
|
-
const createShowList = createPrompt((options) => {
|
|
2912
|
-
options.map((option) => {
|
|
2913
|
-
return isString(option) ? option : option.label;
|
|
2914
|
-
}).forEach((item) => {
|
|
2915
|
-
log.show(item, { type: "step" });
|
|
2916
|
-
});
|
|
2917
|
-
});
|
|
2918
|
-
const createSearch = ({ message, options }) => {
|
|
2919
|
-
const fuse = new Fuse(options, { keys: ["label"] });
|
|
2920
|
-
return search({
|
|
2921
|
-
message,
|
|
2922
|
-
source: (term) => {
|
|
2923
|
-
if (!term) return options;
|
|
2924
|
-
return fuse.search(term).map(({ item }) => item);
|
|
2925
|
-
}
|
|
2926
|
-
});
|
|
2927
|
-
};
|
|
2928
|
-
process.on("uncaughtException", (error) => {
|
|
2929
|
-
if (error instanceof Error && error.name === "ExitPromptError") log.show("User cancelled", { type: "error" });
|
|
2930
|
-
else throw error;
|
|
2931
|
-
});
|
|
2932
|
-
const createCheckbox = async (opts) => {
|
|
2933
|
-
const result = await multiselect(opts);
|
|
2934
|
-
if (isCancel(result)) {
|
|
2935
|
-
cancel("User cancelled");
|
|
2936
|
-
exit(0);
|
|
2937
|
-
}
|
|
2938
|
-
return result;
|
|
2939
|
-
};
|
|
2940
|
-
const createNote = ({ message = "", title = "", opts }) => note(message, title, opts);
|
|
2941
|
-
const createConfirm = createPrompt(confirm);
|
|
2942
|
-
const createTasks = createPrompt(tasks);
|
|
2943
|
-
const createSelect = async (opts) => {
|
|
2944
|
-
const result = await select(opts);
|
|
2945
|
-
if (isCancel(result)) {
|
|
2946
|
-
cancel("User cancelled");
|
|
2947
|
-
exit(0);
|
|
2948
|
-
}
|
|
2949
|
-
return result;
|
|
2950
|
-
};
|
|
2951
|
-
const createInput = async (opts) => {
|
|
2952
|
-
const result = await text(opts);
|
|
2953
|
-
if (isCancel(result)) {
|
|
2954
|
-
cancel("User cancelled");
|
|
2955
|
-
exit(0);
|
|
2956
|
-
}
|
|
2957
|
-
return result;
|
|
2958
|
-
};
|
|
2959
|
-
const createGroupMultiSelect = async (opts) => {
|
|
2960
|
-
const result = await groupMultiselect(opts);
|
|
2961
|
-
if (isCancel(result)) {
|
|
2962
|
-
cancel("User cancelled");
|
|
2963
|
-
process.exit(0);
|
|
2964
|
-
}
|
|
2965
|
-
return result;
|
|
2966
|
-
};
|
|
2967
|
-
const createGroup = async (opts) => {
|
|
2968
|
-
const result = await group(opts);
|
|
2969
|
-
if (isCancel(result)) {
|
|
2970
|
-
cancel("User cancelled");
|
|
2971
|
-
exit(0);
|
|
2972
|
-
}
|
|
2973
|
-
return result;
|
|
2974
|
-
};
|
|
2975
|
-
const createSpinner = (message, options) => {
|
|
2976
|
-
const s = spinner(options);
|
|
2977
|
-
s.start(message);
|
|
2978
|
-
return s;
|
|
2979
|
-
};
|
|
2980
|
-
const createTaskLog = (title, options) => taskLog({
|
|
2981
|
-
title,
|
|
2982
|
-
...options
|
|
2983
|
-
});
|
|
2984
|
-
|
|
2985
3969
|
//#endregion
|
|
2986
3970
|
//#region src/utils/spinner.ts
|
|
2987
3971
|
const BASE_OPTIONS = { timeout: 1e4 };
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
3972
|
+
/**
|
|
3973
|
+
* Create an ora spinner with green text
|
|
3974
|
+
* This is a convenience wrapper around the ora package
|
|
3975
|
+
*/
|
|
3976
|
+
const createOra = (options) => {
|
|
3977
|
+
if (!isString(options)) return oraPkg(options);
|
|
3978
|
+
return oraPkg({
|
|
2991
3979
|
spinner: spinners.circleHalves,
|
|
2992
3980
|
text: chalk.green(options)
|
|
2993
3981
|
});
|
|
@@ -2995,34 +3983,103 @@ const ora = (options) => {
|
|
|
2995
3983
|
|
|
2996
3984
|
//#endregion
|
|
2997
3985
|
//#region src/utils/workspace.ts
|
|
3986
|
+
/**
|
|
3987
|
+
* Workspace configuration files and their detection patterns
|
|
3988
|
+
*/
|
|
3989
|
+
const WORKSPACE_CONFIGS = {
|
|
3990
|
+
pnpm: { file: "pnpm-workspace.yaml" },
|
|
3991
|
+
yarn: {
|
|
3992
|
+
file: "package.json",
|
|
3993
|
+
checkField: "workspaces"
|
|
3994
|
+
},
|
|
3995
|
+
npm: {
|
|
3996
|
+
file: "package.json",
|
|
3997
|
+
checkField: "workspaces"
|
|
3998
|
+
},
|
|
3999
|
+
bun: {
|
|
4000
|
+
file: "package.json",
|
|
4001
|
+
checkField: "workspaces"
|
|
4002
|
+
},
|
|
4003
|
+
deno: {
|
|
4004
|
+
file: "package.json",
|
|
4005
|
+
checkField: "workspaces"
|
|
4006
|
+
}
|
|
4007
|
+
};
|
|
4008
|
+
/**
|
|
4009
|
+
* Priority order for workspace detection (matches package manager detector)
|
|
4010
|
+
*/
|
|
4011
|
+
const WORKSPACE_PRIORITY = [
|
|
4012
|
+
"pnpm",
|
|
4013
|
+
"yarn",
|
|
4014
|
+
"npm",
|
|
4015
|
+
"bun"
|
|
4016
|
+
];
|
|
4017
|
+
/**
|
|
4018
|
+
* Find workspace root by detecting workspace configuration files
|
|
4019
|
+
* Supports pnpm, yarn, npm, and bun workspace configurations
|
|
4020
|
+
*/
|
|
2998
4021
|
async function findWorkspaceRoot(startDir = process.cwd()) {
|
|
2999
4022
|
let currentDir = startDir;
|
|
3000
|
-
while (true)
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
4023
|
+
while (true) {
|
|
4024
|
+
for (const pm of WORKSPACE_PRIORITY) {
|
|
4025
|
+
const config = WORKSPACE_CONFIGS[pm];
|
|
4026
|
+
const configPath = path.join(currentDir, config.file);
|
|
4027
|
+
try {
|
|
4028
|
+
await fs$1.access(configPath);
|
|
4029
|
+
if (config.checkField === "workspaces") {
|
|
4030
|
+
if (readJSON(configPath)?.workspaces) {
|
|
4031
|
+
log.info(`Found ${pm} workspace at: ${currentDir}`);
|
|
4032
|
+
return {
|
|
4033
|
+
root: currentDir,
|
|
4034
|
+
packageManager: pm
|
|
4035
|
+
};
|
|
4036
|
+
}
|
|
4037
|
+
} else {
|
|
4038
|
+
log.info(`Found ${pm} workspace at: ${currentDir}`);
|
|
4039
|
+
return {
|
|
4040
|
+
root: currentDir,
|
|
4041
|
+
packageManager: pm
|
|
4042
|
+
};
|
|
4043
|
+
}
|
|
4044
|
+
} catch {}
|
|
4045
|
+
}
|
|
3004
4046
|
const parentDir = path.dirname(currentDir);
|
|
3005
|
-
if (parentDir === currentDir) throw new Error("pnpm-workspace.yaml
|
|
4047
|
+
if (parentDir === currentDir) throw new Error("Workspace configuration not found. Supported: pnpm-workspace.yaml or package.json with workspaces field");
|
|
3006
4048
|
currentDir = parentDir;
|
|
3007
4049
|
}
|
|
3008
4050
|
}
|
|
4051
|
+
/**
|
|
4052
|
+
* Get workspace directories based on detected package manager
|
|
4053
|
+
* Supports pnpm-workspace.yaml and package.json workspaces field
|
|
4054
|
+
*/
|
|
3009
4055
|
async function getWorkspaceDirs() {
|
|
3010
|
-
const workspaceRoot = await findWorkspaceRoot();
|
|
4056
|
+
const { root: workspaceRoot, packageManager } = await findWorkspaceRoot();
|
|
3011
4057
|
try {
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
4058
|
+
let packagePatterns = [];
|
|
4059
|
+
if (packageManager === "pnpm") {
|
|
4060
|
+
const workspaceConfigPath = path.join(workspaceRoot, "pnpm-workspace.yaml");
|
|
4061
|
+
const configFileContent = await fs$1.readFile(workspaceConfigPath, "utf8");
|
|
4062
|
+
const workspaceConfig = yaml.parse(configFileContent);
|
|
4063
|
+
if (workspaceConfig?.packages?.length) packagePatterns = workspaceConfig.packages;
|
|
4064
|
+
} else {
|
|
4065
|
+
const packageJsonPath = path.join(workspaceRoot, "package.json");
|
|
4066
|
+
const packageJson = JSON.parse(await fs$1.readFile(packageJsonPath, "utf8"));
|
|
4067
|
+
if (packageJson?.workspaces) {
|
|
4068
|
+
if (Array.isArray(packageJson.workspaces)) packagePatterns = packageJson.workspaces;
|
|
4069
|
+
else if (packageJson.workspaces?.packages && Array.isArray(packageJson.workspaces.packages)) packagePatterns = packageJson.workspaces.packages;
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
if (!packagePatterns.length) {
|
|
4073
|
+
log.warn("No packages defined in workspace configuration or file is empty.");
|
|
3018
4074
|
return {
|
|
3019
4075
|
root: workspaceRoot,
|
|
3020
|
-
packages: []
|
|
4076
|
+
packages: [],
|
|
4077
|
+
packageManager
|
|
3021
4078
|
};
|
|
3022
4079
|
}
|
|
3023
|
-
log.info(`Workspace package patterns: ${
|
|
4080
|
+
log.info(`Workspace package patterns: ${packagePatterns.join(", ")}`);
|
|
3024
4081
|
const dirs = [];
|
|
3025
|
-
for (const pattern of
|
|
4082
|
+
for (const pattern of packagePatterns) {
|
|
3026
4083
|
const packagePaths = await glob(pattern, {
|
|
3027
4084
|
cwd: workspaceRoot,
|
|
3028
4085
|
absolute: true
|
|
@@ -3031,13 +4088,15 @@ async function getWorkspaceDirs() {
|
|
|
3031
4088
|
}
|
|
3032
4089
|
return {
|
|
3033
4090
|
root: workspaceRoot,
|
|
3034
|
-
packages: filterDirList(dirs)
|
|
4091
|
+
packages: filterDirList(dirs),
|
|
4092
|
+
packageManager
|
|
3035
4093
|
};
|
|
3036
4094
|
} catch (err) {
|
|
3037
4095
|
handleError(err, "Failed to get workspace dirs: ");
|
|
3038
4096
|
return {
|
|
3039
4097
|
root: workspaceRoot,
|
|
3040
|
-
packages: []
|
|
4098
|
+
packages: [],
|
|
4099
|
+
packageManager
|
|
3041
4100
|
};
|
|
3042
4101
|
}
|
|
3043
4102
|
}
|
|
@@ -3045,6 +4104,7 @@ async function getWorkspaceNames() {
|
|
|
3045
4104
|
const workspacePackages = [];
|
|
3046
4105
|
try {
|
|
3047
4106
|
const { root, packages } = await getWorkspaceDirs();
|
|
4107
|
+
console.log("🚀 : getWorkspaceNames : root, packages:", root, packages);
|
|
3048
4108
|
for (const packageDir of packages) {
|
|
3049
4109
|
const packageJson = readJSON(`${packageDir}/package.json`);
|
|
3050
4110
|
if (packageJson) workspacePackages.push({
|
|
@@ -3066,5 +4126,5 @@ async function getWorkspaceNames() {
|
|
|
3066
4126
|
const pkg = readPackage(import.meta, "..");
|
|
3067
4127
|
|
|
3068
4128
|
//#endregion
|
|
3069
|
-
export { $, BASE_OPTIONS, CONFIG_NAME, Configstore, LOWEST_NODE_VERSION, addFiles, buildCommand, cached, checkFile, clearScreen, clearTerminal, colors, copyFile, createCheckbox, createCommand, createConfirm, createGroup, createGroupMultiSelect, createHelpExample, createInput, createNote, createOptions, createSearch, createSelect, createShowList, createSpinner, createStore, createTaskLog, createTasks, cwdPathname, deleteFile, deleteFiles, dirList, dirname, emptyDir, emptyDirs, exit, fileList, filename, filterDirList, getBrowserApps, getCurrentBranch, getDiffFiles, getGitStatus, getLocalBranches, getPackageDependencies, getWorkspaceDirs, getWorkspaceNames, glob, handleError, has, hasOwn, intro, isArray, isBoolean, isChinese, isDate, isDebug, isEmpty, isEmptyDir, isError, isFormData, isFunction, isMap, isNull, isNumber, isPlainObject, isPromise, isSet, isString, isSymbol, isURLSearchParams, isUndefined, loadConfig, loadEnv, log, logger, openBrowser, openBrowserApp,
|
|
4129
|
+
export { $, BASE_OPTIONS, CONFIG_NAME, Configstore, LOCK_FILE_PATTERNS, LOWEST_NODE_VERSION, PACKAGE_MANAGER_NAMES, PackageManagerDetector, addFiles, buildCommand, cached, checkFile, clearScreen, clearTerminal, colors, copyFile, createCheckbox, createCommand, createConfirm, createGroup, createGroupMultiSelect, createHelpExample, createInput, createNote, createOptions, createOra, createSearch, createSelect, createShowList, createSpinner, createStore, createTaskLog, createTasks, cwdPathname, deleteFile, deleteFiles, dirList, dirname, emptyDir, emptyDirs, exit, fileList, filename, filterDirList, getAdapter, getAllAdapters, getBrowserApps, getCurrentBranch, getDiffFiles, getGitStatus, getLocalBranches, getPackageDependencies, getPackageManagerAdapter, getWorkspaceDirs, getWorkspaceNames, glob, handleError, has, hasOwn, intro, isArray, isBoolean, isChinese, isDate, isDebug, isEmpty, isEmptyDir, isError, isFormData, isFunction, isMap, isNull, isNumber, isPlainObject, isPromise, isSet, isString, isSymbol, isURLSearchParams, isUndefined, joinPath, loadConfig, loadEnv, log, logger, openBrowser, openBrowserApp, outro, parseNames, pkg, progress, readFile, readGitignore, readJSON, readPackage, require$1 as require, safeAwait, sleep, stream, writeJSON, x, xASync, zx };
|
|
3070
4130
|
//# sourceMappingURL=index.js.map
|