@icebreakers/monorepo 1.0.16 → 1.1.0
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-3HPT6GQE.js → chunk-VXG3KCQ5.js} +238 -224
- package/dist/cli.cjs +170 -156
- package/dist/cli.js +2 -2
- package/dist/index.cjs +237 -223
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/package.json +4 -2
- package/templates/tsup-template/package.json +2 -2
- package/templates/vue-lib-template/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -244,95 +244,154 @@ init_cjs_shims();
|
|
|
244
244
|
// src/monorepo/index.ts
|
|
245
245
|
init_cjs_shims();
|
|
246
246
|
|
|
247
|
-
// src/monorepo/
|
|
247
|
+
// src/monorepo/clean.ts
|
|
248
248
|
init_cjs_shims();
|
|
249
|
-
var
|
|
249
|
+
var import_checkbox = __toESM(require("@inquirer/checkbox"), 1);
|
|
250
250
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
251
|
-
var
|
|
251
|
+
var import_pathe2 = __toESM(require("pathe"), 1);
|
|
252
|
+
var import_set_value = __toESM(require_set_value(), 1);
|
|
252
253
|
|
|
253
|
-
// src/monorepo/
|
|
254
|
+
// src/monorepo/workspace/index.ts
|
|
254
255
|
init_cjs_shims();
|
|
255
|
-
var
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
NODEJS_ORG_MIRROR: "https://cdn.npmmirror.com/binaries/node",
|
|
259
|
-
NVM_NODEJS_ORG_MIRROR: "https://cdn.npmmirror.com/binaries/node",
|
|
260
|
-
PHANTOMJS_CDNURL: "https://cdn.npmmirror.com/binaries/phantomjs",
|
|
261
|
-
CHROMEDRIVER_CDNURL: "https://cdn.npmmirror.com/binaries/chromedriver",
|
|
262
|
-
OPERADRIVER_CDNURL: "https://cdn.npmmirror.com/binaries/operadriver",
|
|
263
|
-
CYPRESS_DOWNLOAD_PATH_TEMPLATE: "https://cdn.npmmirror.com/binaries/cypress/${version}/${platform}-${arch}/cypress.zip",
|
|
264
|
-
ELECTRON_MIRROR: "https://cdn.npmmirror.com/binaries/electron/",
|
|
265
|
-
ELECTRON_BUILDER_BINARIES_MIRROR: "https://cdn.npmmirror.com/binaries/electron-builder-binaries/",
|
|
266
|
-
SASS_BINARY_SITE: "https://cdn.npmmirror.com/binaries/node-sass",
|
|
267
|
-
SWC_BINARY_SITE: "https://cdn.npmmirror.com/binaries/node-swc",
|
|
268
|
-
NWJS_URLBASE: "https://cdn.npmmirror.com/binaries/nwjs/v",
|
|
269
|
-
PUPPETEER_DOWNLOAD_HOST: "https://cdn.npmmirror.com/binaries/chrome-for-testing",
|
|
270
|
-
PUPPETEER_DOWNLOAD_BASE_URL: "https://cdn.npmmirror.com/binaries/chrome-for-testing",
|
|
271
|
-
PLAYWRIGHT_DOWNLOAD_HOST: "https://cdn.npmmirror.com/binaries/playwright",
|
|
272
|
-
SENTRYCLI_CDNURL: "https://cdn.npmmirror.com/binaries/sentry-cli",
|
|
273
|
-
SAUCECTL_INSTALL_BINARY_MIRROR: "https://cdn.npmmirror.com/binaries/saucectl",
|
|
274
|
-
RE2_DOWNLOAD_MIRROR: "https://cdn.npmmirror.com/binaries/node-re2",
|
|
275
|
-
RE2_DOWNLOAD_SKIP_PATH: "true",
|
|
276
|
-
PRISMA_ENGINES_MIRROR: "https://cdn.npmmirror.com/binaries/prisma",
|
|
277
|
-
npm_config_better_sqlite3_binary_host: "https://cdn.npmmirror.com/binaries/better-sqlite3",
|
|
278
|
-
npm_config_keytar_binary_host: "https://cdn.npmmirror.com/binaries/keytar",
|
|
279
|
-
npm_config_sharp_binary_host: "https://cdn.npmmirror.com/binaries/sharp",
|
|
280
|
-
npm_config_sharp_libvips_binary_host: "https://cdn.npmmirror.com/binaries/sharp-libvips",
|
|
281
|
-
npm_config_robotjs_binary_host: "https://cdn.npmmirror.com/binaries/robotjs"
|
|
282
|
-
};
|
|
256
|
+
var import_find_workspace_dir = require("@pnpm/find-workspace-dir");
|
|
257
|
+
var import_workspace = require("@pnpm/workspace.find-packages");
|
|
258
|
+
var import_workspace2 = require("@pnpm/workspace.read-manifest");
|
|
283
259
|
|
|
284
|
-
//
|
|
260
|
+
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
285
261
|
init_cjs_shims();
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
262
|
+
function isPlainObject(value) {
|
|
263
|
+
if (value === null || typeof value !== "object") {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
const prototype = Object.getPrototypeOf(value);
|
|
267
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
if (Symbol.iterator in value) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
if (Symbol.toStringTag in value) {
|
|
274
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
275
|
+
}
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
279
|
+
if (!isPlainObject(defaults)) {
|
|
280
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
281
|
+
}
|
|
282
|
+
const object = Object.assign({}, defaults);
|
|
283
|
+
for (const key in baseObject) {
|
|
284
|
+
if (key === "__proto__" || key === "constructor") {
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const value = baseObject[key];
|
|
288
|
+
if (value === null || value === void 0) {
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
295
|
+
object[key] = [...value, ...object[key]];
|
|
296
|
+
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
297
|
+
object[key] = _defu(
|
|
298
|
+
value,
|
|
299
|
+
object[key],
|
|
300
|
+
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
301
|
+
merger
|
|
302
|
+
);
|
|
303
|
+
} else {
|
|
304
|
+
object[key] = value;
|
|
293
305
|
}
|
|
294
306
|
}
|
|
307
|
+
return object;
|
|
308
|
+
}
|
|
309
|
+
function createDefu(merger) {
|
|
310
|
+
return (...arguments_) => (
|
|
311
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
312
|
+
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
313
|
+
);
|
|
295
314
|
}
|
|
315
|
+
var defu = createDefu();
|
|
316
|
+
var defuFn = createDefu((object, key, currentValue) => {
|
|
317
|
+
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
318
|
+
object[key] = currentValue(object[key]);
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
323
|
+
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
324
|
+
object[key] = currentValue(object[key]);
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
});
|
|
296
328
|
|
|
297
|
-
// src/monorepo/
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
329
|
+
// src/monorepo/workspace/index.ts
|
|
330
|
+
var import_pathe = __toESM(require("pathe"), 1);
|
|
331
|
+
async function getWorkspacePackages(workspaceDir, options) {
|
|
332
|
+
const { ignoreRootPackage, ignorePrivatePackage, patterns } = defu(options, {
|
|
333
|
+
ignoreRootPackage: true,
|
|
334
|
+
ignorePrivatePackage: true
|
|
335
|
+
});
|
|
336
|
+
const manifest = await (0, import_workspace2.readWorkspaceManifest)(workspaceDir);
|
|
337
|
+
const packages = await (0, import_workspace.findWorkspacePackages)(workspaceDir, {
|
|
338
|
+
patterns: patterns ?? (manifest == null ? void 0 : manifest.packages)
|
|
339
|
+
});
|
|
340
|
+
let pkgs = packages.filter((x) => {
|
|
341
|
+
if (ignorePrivatePackage && x.manifest.private) {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
return true;
|
|
345
|
+
}).map((project) => {
|
|
346
|
+
const pkgJsonPath = import_pathe.default.resolve(project.rootDir, "package.json");
|
|
347
|
+
return {
|
|
348
|
+
...project,
|
|
349
|
+
pkgJsonPath
|
|
350
|
+
};
|
|
351
|
+
});
|
|
352
|
+
if (ignoreRootPackage) {
|
|
353
|
+
pkgs = pkgs.filter((x) => {
|
|
354
|
+
return x.rootDir !== workspaceDir;
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
return pkgs;
|
|
358
|
+
}
|
|
359
|
+
async function getWorkspaceData(cwd, options) {
|
|
360
|
+
const workspaceDir = await (0, import_find_workspace_dir.findWorkspaceDir)(cwd) ?? cwd;
|
|
361
|
+
const packages = await getWorkspacePackages(workspaceDir, options);
|
|
362
|
+
return {
|
|
363
|
+
cwd,
|
|
364
|
+
workspaceDir,
|
|
365
|
+
packages
|
|
366
|
+
};
|
|
305
367
|
}
|
|
306
368
|
|
|
307
369
|
// src/monorepo/clean.ts
|
|
308
|
-
init_cjs_shims();
|
|
309
|
-
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
310
|
-
var import_pathe2 = __toESM(require("pathe"), 1);
|
|
311
|
-
var import_set_value2 = __toESM(require_set_value(), 1);
|
|
312
|
-
var cleanDirs = [
|
|
313
|
-
"packages/monorepo",
|
|
314
|
-
"packages/tsup-template",
|
|
315
|
-
"packages/vue-lib-template",
|
|
316
|
-
// 'packages/foo',
|
|
317
|
-
// 'apps/cli',
|
|
318
|
-
// 'apps/website',
|
|
319
|
-
"apps"
|
|
320
|
-
];
|
|
321
370
|
async function cleanProjects(cwd) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
371
|
+
const { packages, workspaceDir } = await getWorkspaceData(cwd);
|
|
372
|
+
const cleanDirs = await (0, import_checkbox.default)({
|
|
373
|
+
message: "\u8BF7\u9009\u62E9\u9700\u8981\u6E05\u7406\u7684\u76EE\u5F55",
|
|
374
|
+
choices: packages.map((x) => {
|
|
375
|
+
return {
|
|
376
|
+
name: import_pathe2.default.relative(workspaceDir, x.rootDir),
|
|
377
|
+
value: x.rootDir,
|
|
378
|
+
checked: true,
|
|
379
|
+
description: x.manifest.name
|
|
380
|
+
};
|
|
381
|
+
})
|
|
382
|
+
});
|
|
383
|
+
for (const dir of cleanDirs) {
|
|
384
|
+
await import_fs_extra.default.remove(dir);
|
|
326
385
|
}
|
|
327
|
-
const name2 = "package.json";
|
|
328
|
-
const pkgJson = await
|
|
329
|
-
(0,
|
|
330
|
-
await
|
|
386
|
+
const name2 = import_pathe2.default.resolve(workspaceDir, "package.json");
|
|
387
|
+
const pkgJson = await import_fs_extra.default.readJson(name2);
|
|
388
|
+
(0, import_set_value.default)(pkgJson, "devDependencies.@icebreakers/monorepo", "latest", { preservePaths: false });
|
|
389
|
+
await import_fs_extra.default.outputJson(name2, pkgJson, {
|
|
331
390
|
spaces: 2
|
|
332
391
|
});
|
|
333
392
|
}
|
|
334
393
|
|
|
335
|
-
// src/monorepo/git.ts
|
|
394
|
+
// src/monorepo/git/index.ts
|
|
336
395
|
init_cjs_shims();
|
|
337
396
|
|
|
338
397
|
// ../../node_modules/.pnpm/get-value@4.0.1/node_modules/get-value/dist/index.mjs
|
|
@@ -423,7 +482,7 @@ var getValue = /* @__PURE__ */ __name((target, path10, options = {}) => {
|
|
|
423
482
|
}, "getValue");
|
|
424
483
|
var index_default = getValue;
|
|
425
484
|
|
|
426
|
-
// src/monorepo/git.ts
|
|
485
|
+
// src/monorepo/git/index.ts
|
|
427
486
|
var import_git_url_parse = __toESM(require("git-url-parse"), 1);
|
|
428
487
|
var import_simple_git = require("simple-git");
|
|
429
488
|
var GitClient = class {
|
|
@@ -471,125 +530,17 @@ var GitClient = class {
|
|
|
471
530
|
}
|
|
472
531
|
};
|
|
473
532
|
|
|
474
|
-
// src/monorepo/init.ts
|
|
533
|
+
// src/monorepo/init/index.ts
|
|
475
534
|
init_cjs_shims();
|
|
476
535
|
|
|
477
|
-
// src/monorepo/context.ts
|
|
536
|
+
// src/monorepo/context/index.ts
|
|
478
537
|
init_cjs_shims();
|
|
479
|
-
var import_pathe4 = __toESM(require("pathe"), 1);
|
|
480
|
-
|
|
481
|
-
// src/monorepo/workspace.ts
|
|
482
|
-
init_cjs_shims();
|
|
483
|
-
var import_workspace = require("@pnpm/workspace.find-packages");
|
|
484
|
-
|
|
485
|
-
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
486
|
-
init_cjs_shims();
|
|
487
|
-
function isPlainObject(value) {
|
|
488
|
-
if (value === null || typeof value !== "object") {
|
|
489
|
-
return false;
|
|
490
|
-
}
|
|
491
|
-
const prototype = Object.getPrototypeOf(value);
|
|
492
|
-
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
493
|
-
return false;
|
|
494
|
-
}
|
|
495
|
-
if (Symbol.iterator in value) {
|
|
496
|
-
return false;
|
|
497
|
-
}
|
|
498
|
-
if (Symbol.toStringTag in value) {
|
|
499
|
-
return Object.prototype.toString.call(value) === "[object Module]";
|
|
500
|
-
}
|
|
501
|
-
return true;
|
|
502
|
-
}
|
|
503
|
-
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
504
|
-
if (!isPlainObject(defaults)) {
|
|
505
|
-
return _defu(baseObject, {}, namespace, merger);
|
|
506
|
-
}
|
|
507
|
-
const object = Object.assign({}, defaults);
|
|
508
|
-
for (const key in baseObject) {
|
|
509
|
-
if (key === "__proto__" || key === "constructor") {
|
|
510
|
-
continue;
|
|
511
|
-
}
|
|
512
|
-
const value = baseObject[key];
|
|
513
|
-
if (value === null || value === void 0) {
|
|
514
|
-
continue;
|
|
515
|
-
}
|
|
516
|
-
if (merger && merger(object, key, value, namespace)) {
|
|
517
|
-
continue;
|
|
518
|
-
}
|
|
519
|
-
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
520
|
-
object[key] = [...value, ...object[key]];
|
|
521
|
-
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
522
|
-
object[key] = _defu(
|
|
523
|
-
value,
|
|
524
|
-
object[key],
|
|
525
|
-
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
526
|
-
merger
|
|
527
|
-
);
|
|
528
|
-
} else {
|
|
529
|
-
object[key] = value;
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
return object;
|
|
533
|
-
}
|
|
534
|
-
function createDefu(merger) {
|
|
535
|
-
return (...arguments_) => (
|
|
536
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
537
|
-
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
var defu = createDefu();
|
|
541
|
-
var defuFn = createDefu((object, key, currentValue) => {
|
|
542
|
-
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
543
|
-
object[key] = currentValue(object[key]);
|
|
544
|
-
return true;
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
548
|
-
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
549
|
-
object[key] = currentValue(object[key]);
|
|
550
|
-
return true;
|
|
551
|
-
}
|
|
552
|
-
});
|
|
553
|
-
|
|
554
|
-
// src/monorepo/workspace.ts
|
|
555
538
|
var import_pathe3 = __toESM(require("pathe"), 1);
|
|
556
|
-
async function getWorkspacePackages(cwd, options) {
|
|
557
|
-
const posixCwd = import_pathe3.default.normalize(cwd);
|
|
558
|
-
const { ignoreRootPackage, ignorePrivatePackage, patterns } = defu(options, {
|
|
559
|
-
ignoreRootPackage: true,
|
|
560
|
-
ignorePrivatePackage: true
|
|
561
|
-
});
|
|
562
|
-
const packages = await (0, import_workspace.findWorkspacePackages)(cwd, {
|
|
563
|
-
patterns
|
|
564
|
-
});
|
|
565
|
-
let pkgs = packages.filter((x) => {
|
|
566
|
-
if (ignorePrivatePackage && x.manifest.private) {
|
|
567
|
-
return false;
|
|
568
|
-
}
|
|
569
|
-
return true;
|
|
570
|
-
}).map((project) => {
|
|
571
|
-
const pkgJsonPath = import_pathe3.default.resolve(project.rootDir, "package.json");
|
|
572
|
-
return {
|
|
573
|
-
...project,
|
|
574
|
-
pkgJsonPath
|
|
575
|
-
};
|
|
576
|
-
});
|
|
577
|
-
if (ignoreRootPackage) {
|
|
578
|
-
pkgs = pkgs.filter((x) => {
|
|
579
|
-
return import_pathe3.default.normalize(
|
|
580
|
-
x.rootDir
|
|
581
|
-
) !== posixCwd;
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
return pkgs;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
// src/monorepo/context.ts
|
|
588
539
|
var import_types = require("@pnpm/types");
|
|
589
540
|
async function createContext(cwd) {
|
|
590
541
|
const git = new GitClient();
|
|
591
|
-
const
|
|
592
|
-
const
|
|
542
|
+
const { packages, workspaceDir } = await getWorkspaceData(cwd);
|
|
543
|
+
const workspaceFilepath = import_pathe3.default.resolve(workspaceDir, "pnpm-workspace.yaml");
|
|
593
544
|
const gitUrl = await git.getGitUrl();
|
|
594
545
|
const gitUser = await git.getUser();
|
|
595
546
|
return {
|
|
@@ -597,44 +548,45 @@ async function createContext(cwd) {
|
|
|
597
548
|
git,
|
|
598
549
|
gitUrl,
|
|
599
550
|
gitUser,
|
|
551
|
+
workspaceDir,
|
|
600
552
|
workspaceFilepath,
|
|
601
|
-
|
|
553
|
+
packages
|
|
602
554
|
};
|
|
603
555
|
}
|
|
604
556
|
|
|
605
|
-
// src/monorepo/setChangeset.ts
|
|
557
|
+
// src/monorepo/init/setChangeset.ts
|
|
606
558
|
init_cjs_shims();
|
|
607
|
-
var
|
|
608
|
-
var
|
|
609
|
-
var
|
|
559
|
+
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
560
|
+
var import_pathe4 = __toESM(require("pathe"), 1);
|
|
561
|
+
var import_set_value2 = __toESM(require_set_value(), 1);
|
|
610
562
|
async function setChangeset_default(ctx) {
|
|
611
563
|
const { gitUrl, workspaceFilepath } = ctx;
|
|
612
|
-
if (gitUrl && await
|
|
613
|
-
const changesetConfigPath =
|
|
614
|
-
if (await
|
|
615
|
-
const changesetConfig = await
|
|
564
|
+
if (gitUrl && await import_fs_extra2.default.exists(workspaceFilepath)) {
|
|
565
|
+
const changesetConfigPath = import_pathe4.default.resolve(import_pathe4.default.dirname(workspaceFilepath), ".changeset/config.json");
|
|
566
|
+
if (await import_fs_extra2.default.exists(changesetConfigPath)) {
|
|
567
|
+
const changesetConfig = await import_fs_extra2.default.readJson(
|
|
616
568
|
changesetConfigPath
|
|
617
569
|
);
|
|
618
570
|
if (gitUrl.full_name) {
|
|
619
|
-
(0,
|
|
620
|
-
await
|
|
571
|
+
(0, import_set_value2.default)(changesetConfig, "changelog.1.repo", gitUrl.full_name);
|
|
572
|
+
await import_fs_extra2.default.outputJson(changesetConfigPath, changesetConfig, { spaces: 2 });
|
|
621
573
|
}
|
|
622
574
|
}
|
|
623
575
|
}
|
|
624
576
|
}
|
|
625
577
|
|
|
626
|
-
// src/monorepo/setPkgJson.ts
|
|
578
|
+
// src/monorepo/init/setPkgJson.ts
|
|
627
579
|
init_cjs_shims();
|
|
628
|
-
var
|
|
629
|
-
var
|
|
630
|
-
var
|
|
580
|
+
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
581
|
+
var import_pathe5 = __toESM(require("pathe"), 1);
|
|
582
|
+
var import_set_value3 = __toESM(require_set_value(), 1);
|
|
631
583
|
async function setPkgJson_default(ctx) {
|
|
632
|
-
const { gitUrl, gitUser,
|
|
633
|
-
if (gitUrl && await
|
|
634
|
-
for (const
|
|
635
|
-
const pkgJson =
|
|
636
|
-
const directory =
|
|
637
|
-
(0,
|
|
584
|
+
const { gitUrl, gitUser, packages, cwd, workspaceFilepath } = ctx;
|
|
585
|
+
if (gitUrl && await import_fs_extra3.default.exists(workspaceFilepath)) {
|
|
586
|
+
for (const pkg of packages) {
|
|
587
|
+
const pkgJson = pkg.manifest;
|
|
588
|
+
const directory = import_pathe5.default.relative(cwd, pkg.rootDir);
|
|
589
|
+
(0, import_set_value3.default)(pkgJson, "bugs.url", `https://github.com/${gitUrl.full_name}/issues`);
|
|
638
590
|
const repository = {
|
|
639
591
|
type: "git",
|
|
640
592
|
url: `git+https://github.com/${gitUrl.full_name}.git`
|
|
@@ -642,23 +594,23 @@ async function setPkgJson_default(ctx) {
|
|
|
642
594
|
if (directory) {
|
|
643
595
|
repository.directory = directory;
|
|
644
596
|
}
|
|
645
|
-
(0,
|
|
597
|
+
(0, import_set_value3.default)(pkgJson, "repository", repository);
|
|
646
598
|
if (gitUser) {
|
|
647
|
-
(0,
|
|
599
|
+
(0, import_set_value3.default)(pkgJson, "author", `${gitUser.name} <${gitUser.email}>`);
|
|
648
600
|
}
|
|
649
|
-
await
|
|
601
|
+
await import_fs_extra3.default.writeJSON(pkg.pkgJsonPath, pkgJson, {
|
|
650
602
|
spaces: 2
|
|
651
603
|
});
|
|
652
604
|
}
|
|
653
605
|
}
|
|
654
606
|
}
|
|
655
607
|
|
|
656
|
-
// src/monorepo/setReadme.ts
|
|
608
|
+
// src/monorepo/init/setReadme.ts
|
|
657
609
|
init_cjs_shims();
|
|
658
|
-
var
|
|
659
|
-
var
|
|
610
|
+
var import_fs_extra4 = __toESM(require("fs-extra"), 1);
|
|
611
|
+
var import_pathe6 = __toESM(require("pathe"), 1);
|
|
660
612
|
async function getRows(ctx) {
|
|
661
|
-
const {
|
|
613
|
+
const { packages, git, cwd } = ctx;
|
|
662
614
|
const gitUrl = await git.getGitUrl();
|
|
663
615
|
const gitUser = await git.getUser();
|
|
664
616
|
const rows = [];
|
|
@@ -666,12 +618,12 @@ async function getRows(ctx) {
|
|
|
666
618
|
rows.push(`# ${gitUrl.name}
|
|
667
619
|
`);
|
|
668
620
|
}
|
|
669
|
-
rows.push("##
|
|
670
|
-
for (const
|
|
671
|
-
const p =
|
|
621
|
+
rows.push("## Packages\n");
|
|
622
|
+
for (const pkg of packages) {
|
|
623
|
+
const p = import_pathe6.default.relative(cwd, pkg.rootDirRealPath);
|
|
672
624
|
if (p) {
|
|
673
|
-
const description =
|
|
674
|
-
rows.push(`- [${
|
|
625
|
+
const description = pkg.manifest.description ? `- ${pkg.manifest.description}` : "";
|
|
626
|
+
rows.push(`- [${pkg.manifest.name}](${p}) ${description}`);
|
|
675
627
|
}
|
|
676
628
|
}
|
|
677
629
|
if (gitUrl) {
|
|
@@ -696,11 +648,11 @@ async function getRows(ctx) {
|
|
|
696
648
|
}
|
|
697
649
|
async function setReadme_default(ctx) {
|
|
698
650
|
const rows = await getRows(ctx);
|
|
699
|
-
await
|
|
651
|
+
await import_fs_extra4.default.writeFile(import_pathe6.default.resolve(ctx.cwd, "README.md"), `${rows.join("\n")}
|
|
700
652
|
`);
|
|
701
653
|
}
|
|
702
654
|
|
|
703
|
-
// src/monorepo/init.ts
|
|
655
|
+
// src/monorepo/init/index.ts
|
|
704
656
|
async function init(cwd) {
|
|
705
657
|
const ctx = await createContext(cwd);
|
|
706
658
|
await setChangeset_default(ctx);
|
|
@@ -708,6 +660,68 @@ async function init(cwd) {
|
|
|
708
660
|
await setReadme_default(ctx);
|
|
709
661
|
}
|
|
710
662
|
|
|
663
|
+
// src/monorepo/mirror/binaryMirror.ts
|
|
664
|
+
init_cjs_shims();
|
|
665
|
+
var import_comment_json = require("comment-json");
|
|
666
|
+
var import_fs_extra5 = __toESM(require("fs-extra"), 1);
|
|
667
|
+
var import_pathe7 = __toESM(require("pathe"), 1);
|
|
668
|
+
|
|
669
|
+
// src/monorepo/mirror/utils.ts
|
|
670
|
+
init_cjs_shims();
|
|
671
|
+
var import_set_value4 = __toESM(require_set_value(), 1);
|
|
672
|
+
|
|
673
|
+
// src/monorepo/mirror/sources.ts
|
|
674
|
+
init_cjs_shims();
|
|
675
|
+
var chinaMirrorsEnvs = {
|
|
676
|
+
COREPACK_NPM_REGISTRY: "https://registry.npmmirror.com",
|
|
677
|
+
EDGEDRIVER_CDNURL: "https://npmmirror.com/mirrors/edgedriver",
|
|
678
|
+
NODEJS_ORG_MIRROR: "https://cdn.npmmirror.com/binaries/node",
|
|
679
|
+
NVM_NODEJS_ORG_MIRROR: "https://cdn.npmmirror.com/binaries/node",
|
|
680
|
+
PHANTOMJS_CDNURL: "https://cdn.npmmirror.com/binaries/phantomjs",
|
|
681
|
+
CHROMEDRIVER_CDNURL: "https://cdn.npmmirror.com/binaries/chromedriver",
|
|
682
|
+
OPERADRIVER_CDNURL: "https://cdn.npmmirror.com/binaries/operadriver",
|
|
683
|
+
CYPRESS_DOWNLOAD_PATH_TEMPLATE: "https://cdn.npmmirror.com/binaries/cypress/${version}/${platform}-${arch}/cypress.zip",
|
|
684
|
+
ELECTRON_MIRROR: "https://cdn.npmmirror.com/binaries/electron/",
|
|
685
|
+
ELECTRON_BUILDER_BINARIES_MIRROR: "https://cdn.npmmirror.com/binaries/electron-builder-binaries/",
|
|
686
|
+
SASS_BINARY_SITE: "https://cdn.npmmirror.com/binaries/node-sass",
|
|
687
|
+
SWC_BINARY_SITE: "https://cdn.npmmirror.com/binaries/node-swc",
|
|
688
|
+
NWJS_URLBASE: "https://cdn.npmmirror.com/binaries/nwjs/v",
|
|
689
|
+
PUPPETEER_DOWNLOAD_HOST: "https://cdn.npmmirror.com/binaries/chrome-for-testing",
|
|
690
|
+
PUPPETEER_DOWNLOAD_BASE_URL: "https://cdn.npmmirror.com/binaries/chrome-for-testing",
|
|
691
|
+
PLAYWRIGHT_DOWNLOAD_HOST: "https://cdn.npmmirror.com/binaries/playwright",
|
|
692
|
+
SENTRYCLI_CDNURL: "https://cdn.npmmirror.com/binaries/sentry-cli",
|
|
693
|
+
SAUCECTL_INSTALL_BINARY_MIRROR: "https://cdn.npmmirror.com/binaries/saucectl",
|
|
694
|
+
RE2_DOWNLOAD_MIRROR: "https://cdn.npmmirror.com/binaries/node-re2",
|
|
695
|
+
RE2_DOWNLOAD_SKIP_PATH: "true",
|
|
696
|
+
PRISMA_ENGINES_MIRROR: "https://cdn.npmmirror.com/binaries/prisma",
|
|
697
|
+
npm_config_better_sqlite3_binary_host: "https://cdn.npmmirror.com/binaries/better-sqlite3",
|
|
698
|
+
npm_config_keytar_binary_host: "https://cdn.npmmirror.com/binaries/keytar",
|
|
699
|
+
npm_config_sharp_binary_host: "https://cdn.npmmirror.com/binaries/sharp",
|
|
700
|
+
npm_config_sharp_libvips_binary_host: "https://cdn.npmmirror.com/binaries/sharp-libvips",
|
|
701
|
+
npm_config_robotjs_binary_host: "https://cdn.npmmirror.com/binaries/robotjs"
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
// src/monorepo/mirror/utils.ts
|
|
705
|
+
function setMirror(obj) {
|
|
706
|
+
const platforms = ["linux", "windows", "osx"];
|
|
707
|
+
const prefix = "terminal.integrated.env";
|
|
708
|
+
if (typeof obj === "object" && obj) {
|
|
709
|
+
for (const platform of platforms) {
|
|
710
|
+
(0, import_set_value4.default)(obj, [prefix, platform].join(".").replaceAll(".", "\\."), chinaMirrorsEnvs);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
// src/monorepo/mirror/binaryMirror.ts
|
|
716
|
+
async function setVscodeBinaryMirror(cwd) {
|
|
717
|
+
const targetJsonPath = import_pathe7.default.resolve(cwd, ".vscode/settings.json");
|
|
718
|
+
await import_fs_extra5.default.ensureFile(targetJsonPath);
|
|
719
|
+
const json = (0, import_comment_json.parse)(await import_fs_extra5.default.readFile(targetJsonPath, "utf8"), void 0, false);
|
|
720
|
+
json && typeof json === "object" && setMirror(json);
|
|
721
|
+
await import_fs_extra5.default.writeFile(targetJsonPath, `${(0, import_comment_json.stringify)(json, void 0, 2)}
|
|
722
|
+
`, "utf8");
|
|
723
|
+
}
|
|
724
|
+
|
|
711
725
|
// src/monorepo/sync.ts
|
|
712
726
|
init_cjs_shims();
|
|
713
727
|
var import_node_os = __toESM(require("os"), 1);
|
|
@@ -723,9 +737,9 @@ var logger = (0, import_consola.createConsola)();
|
|
|
723
737
|
|
|
724
738
|
// src/monorepo/sync.ts
|
|
725
739
|
async function syncNpmMirror(cwd, options) {
|
|
726
|
-
const packages = await
|
|
740
|
+
const { packages, workspaceDir } = await getWorkspaceData(cwd, options);
|
|
727
741
|
logger.info(`[\u5F53\u524D\u5DE5\u4F5C\u533ARepo]:
|
|
728
|
-
${packages.map((x) => `- ${import_picocolors.default.green(x.manifest.name)} : ${import_pathe8.default.relative(
|
|
742
|
+
${packages.map((x) => `- ${import_picocolors.default.green(x.manifest.name)} : ${import_pathe8.default.relative(workspaceDir, x.rootDir)}`).join("\n")}
|
|
729
743
|
`);
|
|
730
744
|
const set6 = new Set(packages.map((x) => x.manifest.name));
|
|
731
745
|
logger.info(`[\u5373\u5C06\u540C\u6B65\u7684\u5305]:
|
|
@@ -748,7 +762,7 @@ ${Array.from(set6).map((x) => `- ${import_picocolors.default.green(x)}`).join("\
|
|
|
748
762
|
init_cjs_shims();
|
|
749
763
|
var import_node_process = __toESM(require("process"), 1);
|
|
750
764
|
var import_node_url = require("url");
|
|
751
|
-
var
|
|
765
|
+
var import_checkbox2 = __toESM(require("@inquirer/checkbox"), 1);
|
|
752
766
|
var import_confirm = __toESM(require("@inquirer/confirm"), 1);
|
|
753
767
|
var import_fs_extra6 = __toESM(require("fs-extra"), 1);
|
|
754
768
|
var import_klaw = __toESM(require("klaw"), 1);
|
|
@@ -762,7 +776,7 @@ init_cjs_shims();
|
|
|
762
776
|
|
|
763
777
|
// package.json
|
|
764
778
|
var name = "@icebreakers/monorepo";
|
|
765
|
-
var version = "1.0
|
|
779
|
+
var version = "1.1.0";
|
|
766
780
|
|
|
767
781
|
// src/scripts.ts
|
|
768
782
|
init_cjs_shims();
|
|
@@ -893,7 +907,7 @@ async function upgradeMonorepo(opts) {
|
|
|
893
907
|
const repoName = await gitClient.getRepoName();
|
|
894
908
|
let targets = getAssetTargets(raw);
|
|
895
909
|
if (interactive) {
|
|
896
|
-
targets = await (0,
|
|
910
|
+
targets = await (0, import_checkbox2.default)({
|
|
897
911
|
message: "\u9009\u62E9\u4F60\u9700\u8981\u7684\u6587\u4EF6",
|
|
898
912
|
choices: targets.map((x) => {
|
|
899
913
|
return {
|
package/dist/index.d.cts
CHANGED
|
@@ -10,7 +10,7 @@ interface GetWorkspacePackagesOptions {
|
|
|
10
10
|
ignorePrivatePackage?: boolean;
|
|
11
11
|
patterns?: string[];
|
|
12
12
|
}
|
|
13
|
-
declare function getWorkspacePackages(
|
|
13
|
+
declare function getWorkspacePackages(workspaceDir: string, options?: GetWorkspacePackagesOptions): Promise<{
|
|
14
14
|
pkgJsonPath: string;
|
|
15
15
|
rootDir: _pnpm_types.ProjectRootDir;
|
|
16
16
|
rootDirRealPath: _pnpm_types.ProjectRootDirRealPath;
|
|
@@ -19,8 +19,6 @@ declare function getWorkspacePackages(cwd: string, options?: GetWorkspacePackage
|
|
|
19
19
|
writeProjectManifest: (manifest: _pnpm_types.ProjectManifest, force?: boolean | undefined) => Promise<void>;
|
|
20
20
|
}[]>;
|
|
21
21
|
|
|
22
|
-
declare function setVscodeBinaryMirror(cwd: string): Promise<void>;
|
|
23
|
-
|
|
24
22
|
declare function cleanProjects(cwd: string): Promise<void>;
|
|
25
23
|
|
|
26
24
|
interface CliOpts {
|
|
@@ -48,6 +46,8 @@ declare class GitClient {
|
|
|
48
46
|
|
|
49
47
|
declare function init(cwd: string): Promise<void>;
|
|
50
48
|
|
|
49
|
+
declare function setVscodeBinaryMirror(cwd: string): Promise<void>;
|
|
50
|
+
|
|
51
51
|
declare function syncNpmMirror(cwd: string, options?: GetWorkspacePackagesOptions): Promise<void>;
|
|
52
52
|
|
|
53
53
|
declare function setPkgJson(sourcePkgJson: PackageJson, targetPkgJson: PackageJson): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ interface GetWorkspacePackagesOptions {
|
|
|
10
10
|
ignorePrivatePackage?: boolean;
|
|
11
11
|
patterns?: string[];
|
|
12
12
|
}
|
|
13
|
-
declare function getWorkspacePackages(
|
|
13
|
+
declare function getWorkspacePackages(workspaceDir: string, options?: GetWorkspacePackagesOptions): Promise<{
|
|
14
14
|
pkgJsonPath: string;
|
|
15
15
|
rootDir: _pnpm_types.ProjectRootDir;
|
|
16
16
|
rootDirRealPath: _pnpm_types.ProjectRootDirRealPath;
|
|
@@ -19,8 +19,6 @@ declare function getWorkspacePackages(cwd: string, options?: GetWorkspacePackage
|
|
|
19
19
|
writeProjectManifest: (manifest: _pnpm_types.ProjectManifest, force?: boolean | undefined) => Promise<void>;
|
|
20
20
|
}[]>;
|
|
21
21
|
|
|
22
|
-
declare function setVscodeBinaryMirror(cwd: string): Promise<void>;
|
|
23
|
-
|
|
24
22
|
declare function cleanProjects(cwd: string): Promise<void>;
|
|
25
23
|
|
|
26
24
|
interface CliOpts {
|
|
@@ -48,6 +46,8 @@ declare class GitClient {
|
|
|
48
46
|
|
|
49
47
|
declare function init(cwd: string): Promise<void>;
|
|
50
48
|
|
|
49
|
+
declare function setVscodeBinaryMirror(cwd: string): Promise<void>;
|
|
50
|
+
|
|
51
51
|
declare function syncNpmMirror(cwd: string, options?: GetWorkspacePackagesOptions): Promise<void>;
|
|
52
52
|
|
|
53
53
|
declare function setPkgJson(sourcePkgJson: PackageJson, targetPkgJson: PackageJson): void;
|