@icebreakers/monorepo 0.6.5 → 0.6.7

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.
@@ -51,7 +51,7 @@
51
51
  "@types/micromatch": "^4.0.9",
52
52
  "@types/node": "^22.7.5",
53
53
  "@types/set-value": "^4.0.3",
54
- "@vitest/coverage-v8": "~2.0.5",
54
+ "@vitest/coverage-v8": "~2.1.3",
55
55
  "ci-info": "^4.0.0",
56
56
  "cross-env": "^7.0.3",
57
57
  "defu": "^6.1.4",
@@ -75,8 +75,8 @@
75
75
  "turbo": "^2.1.3",
76
76
  "typescript": "^5.6.3",
77
77
  "unbuild": "^2.0.0",
78
- "vitest": "~2.0.5",
79
- "yaml": "^2.5.1"
78
+ "vitest": "~2.1.3",
79
+ "yaml": "^2.6.0"
80
80
  },
81
81
  "publishConfig": {
82
82
  "access": "public",
@@ -27,9 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  mod
28
28
  ));
29
29
 
30
- // ../../node_modules/.pnpm/tsup@8.3.0_jiti@2.3.1_postcss@8.4.47_tsx@4.19.1_typescript@5.6.3_yaml@2.5.1/node_modules/tsup/assets/esm_shims.js
30
+ // ../../node_modules/.pnpm/tsup@8.3.0_jiti@2.3.1_postcss@8.4.47_tsx@4.19.1_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/esm_shims.js
31
31
  var init_esm_shims = __esm({
32
- "../../node_modules/.pnpm/tsup@8.3.0_jiti@2.3.1_postcss@8.4.47_tsx@4.19.1_typescript@5.6.3_yaml@2.5.1/node_modules/tsup/assets/esm_shims.js"() {
32
+ "../../node_modules/.pnpm/tsup@8.3.0_jiti@2.3.1_postcss@8.4.47_tsx@4.19.1_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/esm_shims.js"() {
33
33
  "use strict";
34
34
  }
35
35
  });
@@ -51,27 +51,27 @@ var require_get_value = __commonJS({
51
51
  "use strict";
52
52
  init_esm_shims();
53
53
  var isObject = require_isobject();
54
- module.exports = function(target, path2, options) {
54
+ module.exports = function(target, path8, options) {
55
55
  if (!isObject(options)) {
56
56
  options = { default: options };
57
57
  }
58
58
  if (!isValidObject(target)) {
59
59
  return typeof options.default !== "undefined" ? options.default : target;
60
60
  }
61
- if (typeof path2 === "number") {
62
- path2 = String(path2);
61
+ if (typeof path8 === "number") {
62
+ path8 = String(path8);
63
63
  }
64
- const isArray = Array.isArray(path2);
65
- const isString = typeof path2 === "string";
64
+ const isArray = Array.isArray(path8);
65
+ const isString = typeof path8 === "string";
66
66
  const splitChar = options.separator || ".";
67
67
  const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
68
68
  if (!isString && !isArray) {
69
69
  return target;
70
70
  }
71
- if (isString && path2 in target) {
72
- return isValid(path2, target, options) ? target[path2] : options.default;
71
+ if (isString && path8 in target) {
72
+ return isValid(path8, target, options) ? target[path8] : options.default;
73
73
  }
74
- let segs = isArray ? path2 : split(path2, splitChar, options);
74
+ let segs = isArray ? path8 : split(path8, splitChar, options);
75
75
  let len = segs.length;
76
76
  let idx = 0;
77
77
  do {
@@ -117,11 +117,11 @@ var require_get_value = __commonJS({
117
117
  }
118
118
  return segs[0] + joinChar + segs[1];
119
119
  }
120
- function split(path2, splitChar, options) {
120
+ function split(path8, splitChar, options) {
121
121
  if (typeof options.split === "function") {
122
- return options.split(path2);
122
+ return options.split(path8);
123
123
  }
124
- return path2.split(splitChar);
124
+ return path8.split(splitChar);
125
125
  }
126
126
  function isValid(key, target, options) {
127
127
  if (typeof options.isValid === "function") {
@@ -158,7 +158,7 @@ var require_is_plain_object = __commonJS({
158
158
  function isObjectObject(o) {
159
159
  return isObject(o) === true && Object.prototype.toString.call(o) === "[object Object]";
160
160
  }
161
- module.exports = function isPlainObject(o) {
161
+ module.exports = function isPlainObject2(o) {
162
162
  var ctor, prot;
163
163
  if (isObjectObject(o) === false) return false;
164
164
  ctor = o.constructor;
@@ -180,7 +180,7 @@ var require_set_value = __commonJS({
180
180
  init_esm_shims();
181
181
  var { deleteProperty } = Reflect;
182
182
  var isPrimitive = require_is_primitive();
183
- var isPlainObject = require_is_plain_object();
183
+ var isPlainObject2 = require_is_plain_object();
184
184
  var isObject = (value) => {
185
185
  return typeof value === "object" && value !== null || typeof value === "function";
186
186
  };
@@ -261,7 +261,7 @@ var require_set_value = __commonJS({
261
261
  deleteProperty(obj, prop);
262
262
  } else if (options && options.merge) {
263
263
  const merge = options.merge === "function" ? options.merge : Object.assign;
264
- if (merge && isPlainObject(obj[prop]) && isPlainObject(value)) {
264
+ if (merge && isPlainObject2(obj[prop]) && isPlainObject2(value)) {
265
265
  obj[prop] = merge(obj[prop], value);
266
266
  } else {
267
267
  obj[prop] = value;
@@ -271,9 +271,9 @@ var require_set_value = __commonJS({
271
271
  }
272
272
  return obj;
273
273
  };
274
- var setValue = (target, path2, value, options) => {
275
- if (!path2 || !isObject(target)) return target;
276
- const keys = split(path2, options);
274
+ var setValue = (target, path8, value, options) => {
275
+ if (!path8 || !isObject(target)) return target;
276
+ const keys = split(path8, options);
277
277
  let obj = target;
278
278
  for (let i = 0; i < keys.length; i++) {
279
279
  const key = keys[i];
@@ -303,32 +303,6 @@ var require_set_value = __commonJS({
303
303
  }
304
304
  });
305
305
 
306
- // src/lib.ts
307
- init_esm_shims();
308
- var import_get_value2 = __toESM(require_get_value(), 1);
309
- var import_set_value = __toESM(require_set_value(), 1);
310
- import process from "node:process";
311
- import { fileURLToPath } from "node:url";
312
- import checkbox from "@inquirer/checkbox";
313
- import confirm from "@inquirer/confirm";
314
- import fs from "fs-extra";
315
- import klaw from "klaw";
316
- import PQueue from "p-queue";
317
- import path from "pathe";
318
- import pc from "picocolors";
319
-
320
- // src/constants.ts
321
- init_esm_shims();
322
-
323
- // package.json
324
- var name = "@icebreakers/monorepo";
325
- var version = "0.6.5";
326
-
327
- // src/logger.ts
328
- init_esm_shims();
329
- import { createConsola } from "consola";
330
- var logger = createConsola();
331
-
332
306
  // src/monorepo/git.ts
333
307
  init_esm_shims();
334
308
  var import_get_value = __toESM(require_get_value(), 1);
@@ -379,6 +353,65 @@ var GitClient = class {
379
353
  }
380
354
  };
381
355
 
356
+ // src/utils/md5.ts
357
+ init_esm_shims();
358
+ import crypto from "node:crypto";
359
+ function getFileHash(data) {
360
+ const hashSum = crypto.createHash("md5");
361
+ hashSum.update(data);
362
+ return hashSum.digest("hex");
363
+ }
364
+ function isFileChanged(src, dest) {
365
+ try {
366
+ const currentHash = getFileHash(src);
367
+ const previousHash = getFileHash(dest);
368
+ return currentHash !== previousHash;
369
+ } catch (err) {
370
+ console.error("Error calculating file hash:", err);
371
+ return false;
372
+ }
373
+ }
374
+
375
+ // src/utils/regexp.ts
376
+ init_esm_shims();
377
+ function escapeStringRegexp(str) {
378
+ return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
379
+ }
380
+ function isMatch(str, arr) {
381
+ for (const reg of arr) {
382
+ if (reg.test(str)) {
383
+ return true;
384
+ }
385
+ }
386
+ return false;
387
+ }
388
+
389
+ // src/lib.ts
390
+ init_esm_shims();
391
+ var import_get_value2 = __toESM(require_get_value(), 1);
392
+ var import_set_value = __toESM(require_set_value(), 1);
393
+ import process from "node:process";
394
+ import { fileURLToPath } from "node:url";
395
+ import checkbox from "@inquirer/checkbox";
396
+ import confirm from "@inquirer/confirm";
397
+ import fs from "fs-extra";
398
+ import klaw from "klaw";
399
+ import PQueue from "p-queue";
400
+ import path from "pathe";
401
+ import pc from "picocolors";
402
+
403
+ // src/constants.ts
404
+ init_esm_shims();
405
+
406
+ // package.json
407
+ var name = "@icebreakers/monorepo";
408
+ var version = "0.6.7";
409
+
410
+ // src/logger.ts
411
+ init_esm_shims();
412
+ import { createConsola } from "consola";
413
+ var logger = createConsola();
414
+
382
415
  // src/scripts.ts
383
416
  init_esm_shims();
384
417
  var scripts = {
@@ -424,39 +457,6 @@ function getAssetTargets(raw) {
424
457
  return list;
425
458
  }
426
459
 
427
- // src/utils/md5.ts
428
- init_esm_shims();
429
- import crypto from "node:crypto";
430
- function getFileHash(data) {
431
- const hashSum = crypto.createHash("md5");
432
- hashSum.update(data);
433
- return hashSum.digest("hex");
434
- }
435
- function isFileChanged(src, dest) {
436
- try {
437
- const currentHash = getFileHash(src);
438
- const previousHash = getFileHash(dest);
439
- return currentHash !== previousHash;
440
- } catch (err) {
441
- console.error("Error calculating file hash:", err);
442
- return false;
443
- }
444
- }
445
-
446
- // src/utils/regexp.ts
447
- init_esm_shims();
448
- function escapeStringRegexp(str) {
449
- return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
450
- }
451
- function isMatch(str, arr) {
452
- for (const reg of arr) {
453
- if (reg.test(str)) {
454
- return true;
455
- }
456
- }
457
- return false;
458
- }
459
-
460
460
  // src/lib.ts
461
461
  var queue = new PQueue({ concurrency: 1 });
462
462
  var __filename2 = fileURLToPath(import.meta.url);
@@ -583,17 +583,337 @@ async function createNewProject(name2) {
583
583
  logger.success(`${targetTemplate} \u9879\u76EE\u521B\u5EFA\u6210\u529F\uFF01`);
584
584
  }
585
585
 
586
+ // src/monorepo/binaryMirror.ts
587
+ init_esm_shims();
588
+ import { parse, stringify } from "comment-json";
589
+ import fs2 from "fs-extra";
590
+ import path2 from "pathe";
591
+
592
+ // src/monorepo/mirror/sources.ts
593
+ init_esm_shims();
594
+ var chinaMirrorsEnvs = {
595
+ COREPACK_NPM_REGISTRY: "https://registry.npmmirror.com",
596
+ EDGEDRIVER_CDNURL: "https://npmmirror.com/mirrors/edgedriver",
597
+ NODEJS_ORG_MIRROR: "https://cdn.npmmirror.com/binaries/node",
598
+ NVM_NODEJS_ORG_MIRROR: "https://cdn.npmmirror.com/binaries/node",
599
+ PHANTOMJS_CDNURL: "https://cdn.npmmirror.com/binaries/phantomjs",
600
+ CHROMEDRIVER_CDNURL: "https://cdn.npmmirror.com/binaries/chromedriver",
601
+ OPERADRIVER_CDNURL: "https://cdn.npmmirror.com/binaries/operadriver",
602
+ CYPRESS_DOWNLOAD_PATH_TEMPLATE: "https://cdn.npmmirror.com/binaries/cypress/${version}/${platform}-${arch}/cypress.zip",
603
+ ELECTRON_MIRROR: "https://cdn.npmmirror.com/binaries/electron/",
604
+ ELECTRON_BUILDER_BINARIES_MIRROR: "https://cdn.npmmirror.com/binaries/electron-builder-binaries/",
605
+ SASS_BINARY_SITE: "https://cdn.npmmirror.com/binaries/node-sass",
606
+ SWC_BINARY_SITE: "https://cdn.npmmirror.com/binaries/node-swc",
607
+ NWJS_URLBASE: "https://cdn.npmmirror.com/binaries/nwjs/v",
608
+ PUPPETEER_DOWNLOAD_HOST: "https://cdn.npmmirror.com/binaries/chrome-for-testing",
609
+ PUPPETEER_DOWNLOAD_BASE_URL: "https://cdn.npmmirror.com/binaries/chrome-for-testing",
610
+ PLAYWRIGHT_DOWNLOAD_HOST: "https://cdn.npmmirror.com/binaries/playwright",
611
+ SENTRYCLI_CDNURL: "https://cdn.npmmirror.com/binaries/sentry-cli",
612
+ SAUCECTL_INSTALL_BINARY_MIRROR: "https://cdn.npmmirror.com/binaries/saucectl",
613
+ RE2_DOWNLOAD_MIRROR: "https://cdn.npmmirror.com/binaries/node-re2",
614
+ RE2_DOWNLOAD_SKIP_PATH: "true",
615
+ PRISMA_ENGINES_MIRROR: "https://cdn.npmmirror.com/binaries/prisma",
616
+ npm_config_better_sqlite3_binary_host: "https://cdn.npmmirror.com/binaries/better-sqlite3",
617
+ npm_config_keytar_binary_host: "https://cdn.npmmirror.com/binaries/keytar",
618
+ npm_config_sharp_binary_host: "https://cdn.npmmirror.com/binaries/sharp",
619
+ npm_config_sharp_libvips_binary_host: "https://cdn.npmmirror.com/binaries/sharp-libvips",
620
+ npm_config_robotjs_binary_host: "https://cdn.npmmirror.com/binaries/robotjs"
621
+ };
622
+
623
+ // src/monorepo/mirror/utils.ts
624
+ init_esm_shims();
625
+ var import_set_value2 = __toESM(require_set_value(), 1);
626
+ function setMirror(obj) {
627
+ const platforms = ["linux", "windows", "osx"];
628
+ const prefix = "terminal.integrated.env";
629
+ if (typeof obj === "object" && obj) {
630
+ for (const platform of platforms) {
631
+ (0, import_set_value2.default)(obj, [prefix, platform].join(".").replaceAll(".", "\\."), chinaMirrorsEnvs);
632
+ }
633
+ }
634
+ }
635
+
636
+ // src/monorepo/binaryMirror.ts
637
+ async function setVscodeBinaryMirror(cwd2) {
638
+ const targetJsonPath = path2.resolve(cwd2, ".vscode/settings.json");
639
+ await fs2.ensureFile(targetJsonPath);
640
+ const json = parse(await fs2.readFile(targetJsonPath, "utf8"), void 0, false);
641
+ json && typeof json === "object" && setMirror(json);
642
+ await fs2.writeFile(targetJsonPath, `${stringify(json, void 0, 2)}
643
+ `, "utf8");
644
+ }
645
+
646
+ // src/monorepo/clean.ts
647
+ init_esm_shims();
648
+ import fs3 from "fs-extra";
649
+ import path3 from "pathe";
650
+ var dirs = [
651
+ "packages/monorepo",
652
+ "packages/foo",
653
+ // 'apps/cli',
654
+ // 'apps/website',
655
+ "apps"
656
+ ];
657
+ async function cleanProjects(cwd2) {
658
+ for (const dir of dirs.map((x) => {
659
+ return path3.resolve(cwd2, x);
660
+ })) {
661
+ await fs3.remove(dir);
662
+ }
663
+ }
664
+
665
+ // src/monorepo/workspace.ts
666
+ init_esm_shims();
667
+ import { findWorkspacePackages } from "@pnpm/workspace.find-packages";
668
+
669
+ // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
670
+ init_esm_shims();
671
+ function isPlainObject(value) {
672
+ if (value === null || typeof value !== "object") {
673
+ return false;
674
+ }
675
+ const prototype = Object.getPrototypeOf(value);
676
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
677
+ return false;
678
+ }
679
+ if (Symbol.iterator in value) {
680
+ return false;
681
+ }
682
+ if (Symbol.toStringTag in value) {
683
+ return Object.prototype.toString.call(value) === "[object Module]";
684
+ }
685
+ return true;
686
+ }
687
+ function _defu(baseObject, defaults, namespace = ".", merger) {
688
+ if (!isPlainObject(defaults)) {
689
+ return _defu(baseObject, {}, namespace, merger);
690
+ }
691
+ const object = Object.assign({}, defaults);
692
+ for (const key in baseObject) {
693
+ if (key === "__proto__" || key === "constructor") {
694
+ continue;
695
+ }
696
+ const value = baseObject[key];
697
+ if (value === null || value === void 0) {
698
+ continue;
699
+ }
700
+ if (merger && merger(object, key, value, namespace)) {
701
+ continue;
702
+ }
703
+ if (Array.isArray(value) && Array.isArray(object[key])) {
704
+ object[key] = [...value, ...object[key]];
705
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
706
+ object[key] = _defu(
707
+ value,
708
+ object[key],
709
+ (namespace ? `${namespace}.` : "") + key.toString(),
710
+ merger
711
+ );
712
+ } else {
713
+ object[key] = value;
714
+ }
715
+ }
716
+ return object;
717
+ }
718
+ function createDefu(merger) {
719
+ return (...arguments_) => (
720
+ // eslint-disable-next-line unicorn/no-array-reduce
721
+ arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
722
+ );
723
+ }
724
+ var defu = createDefu();
725
+ var defuFn = createDefu((object, key, currentValue) => {
726
+ if (object[key] !== void 0 && typeof currentValue === "function") {
727
+ object[key] = currentValue(object[key]);
728
+ return true;
729
+ }
730
+ });
731
+ var defuArrayFn = createDefu((object, key, currentValue) => {
732
+ if (Array.isArray(object[key]) && typeof currentValue === "function") {
733
+ object[key] = currentValue(object[key]);
734
+ return true;
735
+ }
736
+ });
737
+
738
+ // src/monorepo/workspace.ts
739
+ import path4 from "pathe";
740
+ async function getWorkspacePackages(cwd2, options) {
741
+ const posixCwd = path4.normalize(cwd2);
742
+ const { ignoreRootPackage, ignorePrivatePackage } = defu(options, {
743
+ ignoreRootPackage: true,
744
+ ignorePrivatePackage: true
745
+ });
746
+ const packages = await findWorkspacePackages(cwd2);
747
+ let pkgs = packages.filter((x) => {
748
+ if (ignorePrivatePackage && x.manifest.private) {
749
+ return false;
750
+ }
751
+ return true;
752
+ }).map((project) => {
753
+ const pkgJsonPath = path4.resolve(project.rootDir, "package.json");
754
+ return {
755
+ ...project,
756
+ pkgJsonPath
757
+ };
758
+ });
759
+ if (ignoreRootPackage) {
760
+ pkgs = pkgs.filter((x) => {
761
+ return path4.normalize(
762
+ x.rootDir
763
+ ) !== posixCwd;
764
+ });
765
+ }
766
+ return pkgs;
767
+ }
768
+
769
+ // src/monorepo/init.ts
770
+ init_esm_shims();
771
+
772
+ // src/monorepo/context.ts
773
+ init_esm_shims();
774
+ import path5 from "pathe";
775
+ import "@pnpm/types";
776
+ async function createContext(cwd2) {
777
+ const git = new GitClient();
778
+ const workspaceFilepath = path5.resolve(cwd2, "pnpm-workspace.yaml");
779
+ const projects = await getWorkspacePackages(cwd2);
780
+ return {
781
+ cwd: cwd2,
782
+ git,
783
+ workspaceFilepath,
784
+ projects
785
+ };
786
+ }
787
+
788
+ // src/monorepo/setPkgJson.ts
789
+ init_esm_shims();
790
+ var import_set_value3 = __toESM(require_set_value(), 1);
791
+ import fs4 from "fs-extra";
792
+ import path6 from "pathe";
793
+ async function setPkgJson_default(ctx) {
794
+ const { git, projects, cwd: cwd2, workspaceFilepath } = ctx;
795
+ const gitUrl = await git.getGitUrl();
796
+ const gitUser = await git.getUser();
797
+ if (gitUrl && await fs4.exists(workspaceFilepath)) {
798
+ for (const project of projects) {
799
+ const pkgJson = project.manifest;
800
+ const directory = path6.relative(cwd2, project.rootDir);
801
+ (0, import_set_value3.default)(pkgJson, "bugs.url", `https://github.com/${gitUrl.full_name}/issues`);
802
+ const repository = {
803
+ type: "git",
804
+ url: `git+https://github.com/${gitUrl.full_name}.git`
805
+ };
806
+ if (directory) {
807
+ repository.directory = directory;
808
+ }
809
+ (0, import_set_value3.default)(pkgJson, "repository", repository);
810
+ if (gitUser) {
811
+ (0, import_set_value3.default)(pkgJson, "author", `${gitUser.name} <${gitUser.email}>`);
812
+ }
813
+ await fs4.writeJSON(project.pkgJsonPath, pkgJson, {
814
+ spaces: 2
815
+ });
816
+ }
817
+ }
818
+ }
819
+
820
+ // src/monorepo/setReadme.ts
821
+ init_esm_shims();
822
+ import fs5 from "fs-extra";
823
+ import path7 from "pathe";
824
+ async function getRows(ctx) {
825
+ const { projects, git, cwd: cwd2 } = ctx;
826
+ const gitUrl = await git.getGitUrl();
827
+ const gitUser = await git.getUser();
828
+ const rows = [];
829
+ if (gitUrl) {
830
+ rows.push(`# ${gitUrl.name}
831
+ `);
832
+ }
833
+ rows.push("## Projects\n");
834
+ for (const project of projects) {
835
+ const p = path7.relative(cwd2, project.rootDirRealPath);
836
+ p && rows.push(`- [${project.manifest.name}](${p}) ${project.manifest.description ? `- ${project.manifest.description}` : ""}`);
837
+ }
838
+ if (gitUrl) {
839
+ rows.push("\n## Contributing\n");
840
+ rows.push("Contributions Welcome! You can contribute in the following ways.");
841
+ rows.push("");
842
+ rows.push("- Create an Issue - Propose a new feature. Report a bug.");
843
+ rows.push("- Pull Request - Fix a bug and typo. Refactor the code.");
844
+ rows.push("- Create third-party middleware - Instruct below.");
845
+ rows.push("- Share - Share your thoughts on the Blog, X, and others.");
846
+ rows.push(`- Make your application - Please try to use ${gitUrl.name}.`);
847
+ rows.push("");
848
+ rows.push("For more details, see [CONTRIBUTING.md](CONTRIBUTING.md).");
849
+ rows.push("\n## Contributors\n");
850
+ rows.push(`Thanks to [all contributors](https://github.com/${gitUrl.full_name}/graphs/contributors)!`);
851
+ }
852
+ rows.push("\n## Authors\n");
853
+ rows.push(`${gitUser.name} <${gitUser.email}>`);
854
+ rows.push("\n## License\n");
855
+ rows.push("Distributed under the MIT License. See [LICENSE](LICENSE) for more information.");
856
+ return rows;
857
+ }
858
+ async function setReadme_default(ctx) {
859
+ const rows = await getRows(ctx);
860
+ await fs5.writeFile(path7.resolve(ctx.cwd, "README.md"), `${rows.join("\n")}
861
+ `);
862
+ }
863
+
864
+ // src/monorepo/init.ts
865
+ async function init(cwd2) {
866
+ const ctx = await createContext(cwd2);
867
+ await setPkgJson_default(ctx);
868
+ await setReadme_default(ctx);
869
+ }
870
+
871
+ // src/monorepo/sync.ts
872
+ init_esm_shims();
873
+ import os from "node:os";
874
+ import { execa } from "execa";
875
+ import PQueue2 from "p-queue";
876
+ import pc2 from "picocolors";
877
+ async function syncNpmMirror(cwd2) {
878
+ const packages = await getWorkspacePackages(cwd2);
879
+ const set4 = new Set(packages.map((x) => x.manifest.name));
880
+ logger.info(`[\u5373\u5C06\u540C\u6B65\u7684\u5305]:
881
+ ${Array.from(set4).map((x) => `- ${pc2.green(x)}`).join("\n")}
882
+ `);
883
+ const concurrency = Math.max(os.cpus().length, 1);
884
+ const queue2 = new PQueue2({ concurrency });
885
+ for (const pkgName of set4) {
886
+ if (pkgName) {
887
+ await queue2.add(async () => {
888
+ return execa({
889
+ stdout: ["pipe", "inherit"]
890
+ })`cnpm sync ${pkgName}`;
891
+ });
892
+ }
893
+ }
894
+ }
895
+
896
+ // src/monorepo/index.ts
897
+ init_esm_shims();
898
+
586
899
  export {
587
- __toESM,
588
900
  name,
589
901
  version,
590
902
  init_esm_shims,
591
- require_set_value,
592
903
  logger,
593
904
  GitClient,
905
+ getFileHash,
906
+ isFileChanged,
907
+ escapeStringRegexp,
908
+ isMatch,
594
909
  setPkgJson,
595
910
  upgradeMonorepo,
596
- createNewProject
911
+ createNewProject,
912
+ setVscodeBinaryMirror,
913
+ cleanProjects,
914
+ getWorkspacePackages,
915
+ init,
916
+ syncNpmMirror
597
917
  };
598
918
  /*! Bundled license information:
599
919
 
package/dist/cli.cjs CHANGED
@@ -28,10 +28,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  mod
29
29
  ));
30
30
 
31
- // ../../node_modules/.pnpm/tsup@8.3.0_jiti@2.3.1_postcss@8.4.47_tsx@4.19.1_typescript@5.6.3_yaml@2.5.1/node_modules/tsup/assets/cjs_shims.js
31
+ // ../../node_modules/.pnpm/tsup@8.3.0_jiti@2.3.1_postcss@8.4.47_tsx@4.19.1_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/cjs_shims.js
32
32
  var getImportMetaUrl, importMetaUrl;
33
33
  var init_cjs_shims = __esm({
34
- "../../node_modules/.pnpm/tsup@8.3.0_jiti@2.3.1_postcss@8.4.47_tsx@4.19.1_typescript@5.6.3_yaml@2.5.1/node_modules/tsup/assets/cjs_shims.js"() {
34
+ "../../node_modules/.pnpm/tsup@8.3.0_jiti@2.3.1_postcss@8.4.47_tsx@4.19.1_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/cjs_shims.js"() {
35
35
  "use strict";
36
36
  getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
37
37
  importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
@@ -320,7 +320,7 @@ init_cjs_shims();
320
320
 
321
321
  // package.json
322
322
  var name = "@icebreakers/monorepo";
323
- var version = "0.6.5";
323
+ var version = "0.6.7";
324
324
 
325
325
  // src/lib.ts
326
326
  init_cjs_shims();
@@ -887,18 +887,25 @@ async function init(cwd3) {
887
887
 
888
888
  // src/monorepo/sync.ts
889
889
  init_cjs_shims();
890
+ var import_node_os = __toESM(require("os"), 1);
890
891
  var import_execa = require("execa");
892
+ var import_p_queue2 = __toESM(require("p-queue"), 1);
891
893
  var import_picocolors2 = __toESM(require("picocolors"), 1);
892
894
  async function syncNpmMirror(cwd3) {
893
895
  const packages = await getWorkspacePackages(cwd3);
896
+ const set4 = new Set(packages.map((x) => x.manifest.name));
894
897
  logger.info(`[\u5373\u5C06\u540C\u6B65\u7684\u5305]:
895
- ${packages.filter((x) => x.manifest.name).map((x) => `- ${import_picocolors2.default.green(x.manifest.name)}`).join("\n")}
898
+ ${Array.from(set4).map((x) => `- ${import_picocolors2.default.green(x)}`).join("\n")}
896
899
  `);
897
- for (const project of packages) {
898
- if (project.manifest.name) {
899
- await (0, import_execa.execa)({
900
- stdout: ["pipe", "inherit"]
901
- })`cnpm sync ${project.manifest.name}`;
900
+ const concurrency = Math.max(import_node_os.default.cpus().length, 1);
901
+ const queue2 = new import_p_queue2.default({ concurrency });
902
+ for (const pkgName of set4) {
903
+ if (pkgName) {
904
+ await queue2.add(async () => {
905
+ return (0, import_execa.execa)({
906
+ stdout: ["pipe", "inherit"]
907
+ })`cnpm sync ${pkgName}`;
908
+ });
902
909
  }
903
910
  }
904
911
  }