@icebreakers/monorepo 1.0.0 → 1.0.2

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.
Files changed (39) hide show
  1. package/assets/package.json +3 -3
  2. package/assets/turbo.json +1 -1
  3. package/assets/vitest.config.ts +3 -0
  4. package/dist/{chunk-VOROHSAI.js → chunk-L7MRLUKD.js} +85 -61
  5. package/dist/cli.cjs +131 -83
  6. package/dist/cli.js +29 -5
  7. package/dist/index.cjs +85 -61
  8. package/dist/index.js +1 -1
  9. package/package.json +3 -1
  10. package/templates/{bar → tsup-template}/package.json +3 -3
  11. package/templates/{foo → unbuild-template}/package.json +3 -3
  12. package/templates/vue-lib-template/eslint.config.js +9 -0
  13. package/templates/vue-lib-template/index.html +13 -0
  14. package/templates/vue-lib-template/lib/HelloWorld.vue +19 -0
  15. package/templates/vue-lib-template/lib/index.ts +3 -0
  16. package/templates/vue-lib-template/package.json +57 -0
  17. package/templates/vue-lib-template/src/App.vue +9 -0
  18. package/templates/vue-lib-template/src/main.ts +5 -0
  19. package/templates/vue-lib-template/src/style.css +0 -0
  20. package/templates/vue-lib-template/src/vite-env.d.ts +1 -0
  21. package/templates/vue-lib-template/test/index.test.ts +13 -0
  22. package/templates/vue-lib-template/tsconfig.app.json +29 -0
  23. package/templates/vue-lib-template/tsconfig.json +14 -0
  24. package/templates/vue-lib-template/tsconfig.node.json +25 -0
  25. package/templates/vue-lib-template/tsconfig.test.json +40 -0
  26. package/templates/vue-lib-template/vite.config.ts +36 -0
  27. package/templates/vue-lib-template/vite.shared.config.ts +16 -0
  28. package/templates/vue-lib-template/vitest.config.ts +10 -0
  29. /package/templates/{bar → tsup-template}/src/index.ts +0 -0
  30. /package/templates/{bar → tsup-template}/test/index.test.ts +0 -0
  31. /package/templates/{bar → tsup-template}/tsconfig.json +0 -0
  32. /package/templates/{bar → tsup-template}/tsup.config.ts +0 -0
  33. /package/templates/{bar → tsup-template}/vitest.config.ts +0 -0
  34. /package/templates/{foo → unbuild-template}/build.config.ts +0 -0
  35. /package/templates/{foo → unbuild-template}/src/index.ts +0 -0
  36. /package/templates/{foo → unbuild-template}/src/utils.ts +0 -0
  37. /package/templates/{foo → unbuild-template}/test/index.test.ts +0 -0
  38. /package/templates/{foo → unbuild-template}/tsconfig.json +0 -0
  39. /package/templates/{foo → unbuild-template}/vitest.config.ts +0 -0
@@ -42,13 +42,13 @@
42
42
  "@icebreakers/monorepo": "workspace:*",
43
43
  "@icebreakers/stylelint-config": "^1.0.1",
44
44
  "@types/fs-extra": "^11.0.4",
45
- "@types/node": "^22.15.18",
45
+ "@types/node": "^22.15.29",
46
46
  "@vitest/coverage-v8": "~3.1.4",
47
47
  "ci-info": "^4.2.0",
48
48
  "cross-env": "^7.0.3",
49
49
  "defu": "^6.1.4",
50
50
  "es-toolkit": "^1.38.0",
51
- "eslint": "^9.27.0",
51
+ "eslint": "^9.28.0",
52
52
  "execa": "^9.5.2",
53
53
  "fs-extra": "^11.3.0",
54
54
  "husky": "^9.1.6",
@@ -60,7 +60,7 @@
60
60
  "tslib": "^2.8.0",
61
61
  "tsup": "^8.5.0",
62
62
  "tsx": "^4.19.4",
63
- "turbo": "^2.5.2",
63
+ "turbo": "^2.5.3",
64
64
  "typescript": "^5.8.2",
65
65
  "unbuild": "^3.5.0",
66
66
  "vitest": "~3.1.4",
package/assets/turbo.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://turbo.build/schema.json",
2
+ "$schema": "https://turborepo.com/schema.json",
3
3
  "tasks": {
4
4
  "build": {
5
5
  "dependsOn": [
@@ -13,6 +13,9 @@ export default defineConfig(
13
13
  all: false,
14
14
  skipFull: true,
15
15
  },
16
+ forceRerunTriggers: [
17
+ '**/{vitest,vite}.config.*/**',
18
+ ],
16
19
  },
17
20
  }
18
21
  },
@@ -27,11 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  mod
28
28
  ));
29
29
 
30
- // ../../node_modules/.pnpm/tsup@8.5.0_jiti@2.4.2_postcss@8.5.3_tsx@4.19.4_typescript@5.8.3_yaml@2.8.0/node_modules/tsup/assets/esm_shims.js
30
+ // ../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.52.8_@types+node@22.15.29__jiti@2.4.2_postcss@8.5_1b01dd7c5f88cff18274d17a466843ec/node_modules/tsup/assets/esm_shims.js
31
31
  import path from "path";
32
32
  import { fileURLToPath } from "url";
33
33
  var init_esm_shims = __esm({
34
- "../../node_modules/.pnpm/tsup@8.5.0_jiti@2.4.2_postcss@8.5.3_tsx@4.19.4_typescript@5.8.3_yaml@2.8.0/node_modules/tsup/assets/esm_shims.js"() {
34
+ "../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.52.8_@types+node@22.15.29__jiti@2.4.2_postcss@8.5_1b01dd7c5f88cff18274d17a466843ec/node_modules/tsup/assets/esm_shims.js"() {
35
35
  "use strict";
36
36
  }
37
37
  });
@@ -183,9 +183,9 @@ var require_set_value = __commonJS({
183
183
  }
184
184
  return obj;
185
185
  };
186
- var setValue = (target, path10, value, options) => {
187
- if (!path10 || !isObject2(target)) return target;
188
- const keys = split2(path10, options);
186
+ var setValue = (target, path11, value, options) => {
187
+ if (!path11 || !isObject2(target)) return target;
188
+ const keys = split2(path11, options);
189
189
  let obj = target;
190
190
  for (let i = 0; i < keys.length; i++) {
191
191
  const key = keys[i];
@@ -280,15 +280,17 @@ init_esm_shims();
280
280
  var import_set_value2 = __toESM(require_set_value(), 1);
281
281
  import fs2 from "fs-extra";
282
282
  import path3 from "pathe";
283
- var dirs = [
283
+ var cleanDirs = [
284
284
  "packages/monorepo",
285
- "packages/foo",
285
+ "packages/tsup-template",
286
+ "packages/vue-lib-template",
287
+ // 'packages/foo',
286
288
  // 'apps/cli',
287
289
  // 'apps/website',
288
290
  "apps"
289
291
  ];
290
292
  async function cleanProjects(cwd) {
291
- for (const dir of dirs.map((x) => {
293
+ for (const dir of cleanDirs.map((x) => {
292
294
  return path3.resolve(cwd, x);
293
295
  })) {
294
296
  await fs2.remove(dir);
@@ -315,14 +317,14 @@ var join = /* @__PURE__ */ __name((segs, joinChar, options) => {
315
317
  }
316
318
  return segs[0] + joinChar + segs[1];
317
319
  }, "join");
318
- var split = /* @__PURE__ */ __name((path10, splitChar, options) => {
320
+ var split = /* @__PURE__ */ __name((path11, splitChar, options) => {
319
321
  if (typeof options.split === "function") {
320
- return options.split(path10);
322
+ return options.split(path11);
321
323
  }
322
- return path10.split(splitChar);
324
+ return path11.split(splitChar);
323
325
  }, "split");
324
326
  var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
325
- if (typeof options?.isValid === "function") {
327
+ if (typeof (options == null ? void 0 : options.isValid) === "function") {
326
328
  return options.isValid(key, target);
327
329
  }
328
330
  return true;
@@ -330,27 +332,27 @@ var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
330
332
  var isValidObject = /* @__PURE__ */ __name((v) => {
331
333
  return isObject(v) || typeof v === "function";
332
334
  }, "isValidObject");
333
- var getValue = /* @__PURE__ */ __name((target, path10, options = {}) => {
335
+ var getValue = /* @__PURE__ */ __name((target, path11, options = {}) => {
334
336
  if (!isObject(options)) {
335
337
  options = { default: options };
336
338
  }
337
339
  if (!isValidObject(target)) {
338
340
  return typeof options.default !== "undefined" ? options.default : target;
339
341
  }
340
- if (typeof path10 === "number") {
341
- path10 = String(path10);
342
+ if (typeof path11 === "number") {
343
+ path11 = String(path11);
342
344
  }
343
- const pathIsArray = Array.isArray(path10);
344
- const pathIsString = typeof path10 === "string";
345
+ const pathIsArray = Array.isArray(path11);
346
+ const pathIsString = typeof path11 === "string";
345
347
  const splitChar = options.separator || ".";
346
348
  const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
347
349
  if (!pathIsString && !pathIsArray) {
348
350
  return target;
349
351
  }
350
- if (target[path10] !== void 0) {
351
- return isValid(path10, target, options) ? target[path10] : options.default;
352
+ if (target[path11] !== void 0) {
353
+ return isValid(path11, target, options) ? target[path11] : options.default;
352
354
  }
353
- const segs = pathIsArray ? path10 : split(path10, splitChar, options);
355
+ const segs = pathIsArray ? path11 : split(path11, splitChar, options);
354
356
  const len = segs.length;
355
357
  let idx = 0;
356
358
  do {
@@ -569,18 +571,39 @@ async function createContext(cwd) {
569
571
  };
570
572
  }
571
573
 
572
- // src/monorepo/setPkgJson.ts
574
+ // src/monorepo/setChangeset.ts
573
575
  init_esm_shims();
574
576
  var import_set_value3 = __toESM(require_set_value(), 1);
575
577
  import fs3 from "fs-extra";
576
578
  import path6 from "pathe";
579
+ async function setChangeset_default(ctx) {
580
+ const { gitUrl, workspaceFilepath } = ctx;
581
+ if (gitUrl && await fs3.exists(workspaceFilepath)) {
582
+ const changesetConfigPath = path6.resolve(path6.dirname(workspaceFilepath), ".changeset/config.json");
583
+ if (await fs3.exists(changesetConfigPath)) {
584
+ const changesetConfig = await fs3.readJson(
585
+ changesetConfigPath
586
+ );
587
+ if (gitUrl.full_name) {
588
+ (0, import_set_value3.default)(changesetConfig, "changelog.1.repo", gitUrl.full_name);
589
+ await fs3.outputJson(changesetConfigPath, changesetConfig, { spaces: 2 });
590
+ }
591
+ }
592
+ }
593
+ }
594
+
595
+ // src/monorepo/setPkgJson.ts
596
+ init_esm_shims();
597
+ var import_set_value4 = __toESM(require_set_value(), 1);
598
+ import fs4 from "fs-extra";
599
+ import path7 from "pathe";
577
600
  async function setPkgJson_default(ctx) {
578
601
  const { gitUrl, gitUser, projects, cwd, workspaceFilepath } = ctx;
579
- if (gitUrl && await fs3.exists(workspaceFilepath)) {
602
+ if (gitUrl && await fs4.exists(workspaceFilepath)) {
580
603
  for (const project of projects) {
581
604
  const pkgJson = project.manifest;
582
- const directory = path6.relative(cwd, project.rootDir);
583
- (0, import_set_value3.default)(pkgJson, "bugs.url", `https://github.com/${gitUrl.full_name}/issues`);
605
+ const directory = path7.relative(cwd, project.rootDir);
606
+ (0, import_set_value4.default)(pkgJson, "bugs.url", `https://github.com/${gitUrl.full_name}/issues`);
584
607
  const repository = {
585
608
  type: "git",
586
609
  url: `git+https://github.com/${gitUrl.full_name}.git`
@@ -588,11 +611,11 @@ async function setPkgJson_default(ctx) {
588
611
  if (directory) {
589
612
  repository.directory = directory;
590
613
  }
591
- (0, import_set_value3.default)(pkgJson, "repository", repository);
614
+ (0, import_set_value4.default)(pkgJson, "repository", repository);
592
615
  if (gitUser) {
593
- (0, import_set_value3.default)(pkgJson, "author", `${gitUser.name} <${gitUser.email}>`);
616
+ (0, import_set_value4.default)(pkgJson, "author", `${gitUser.name} <${gitUser.email}>`);
594
617
  }
595
- await fs3.writeJSON(project.pkgJsonPath, pkgJson, {
618
+ await fs4.writeJSON(project.pkgJsonPath, pkgJson, {
596
619
  spaces: 2
597
620
  });
598
621
  }
@@ -601,8 +624,8 @@ async function setPkgJson_default(ctx) {
601
624
 
602
625
  // src/monorepo/setReadme.ts
603
626
  init_esm_shims();
604
- import fs4 from "fs-extra";
605
- import path7 from "pathe";
627
+ import fs5 from "fs-extra";
628
+ import path8 from "pathe";
606
629
  async function getRows(ctx) {
607
630
  const { projects, git, cwd } = ctx;
608
631
  const gitUrl = await git.getGitUrl();
@@ -614,7 +637,7 @@ async function getRows(ctx) {
614
637
  }
615
638
  rows.push("## Projects\n");
616
639
  for (const project of projects) {
617
- const p = path7.relative(cwd, project.rootDirRealPath);
640
+ const p = path8.relative(cwd, project.rootDirRealPath);
618
641
  if (p) {
619
642
  const description = project.manifest.description ? `- ${project.manifest.description}` : "";
620
643
  rows.push(`- [${project.manifest.name}](${p}) ${description}`);
@@ -642,13 +665,14 @@ async function getRows(ctx) {
642
665
  }
643
666
  async function setReadme_default(ctx) {
644
667
  const rows = await getRows(ctx);
645
- await fs4.writeFile(path7.resolve(ctx.cwd, "README.md"), `${rows.join("\n")}
668
+ await fs5.writeFile(path8.resolve(ctx.cwd, "README.md"), `${rows.join("\n")}
646
669
  `);
647
670
  }
648
671
 
649
672
  // src/monorepo/init.ts
650
673
  async function init(cwd) {
651
674
  const ctx = await createContext(cwd);
675
+ await setChangeset_default(ctx);
652
676
  await setPkgJson_default(ctx);
653
677
  await setReadme_default(ctx);
654
678
  }
@@ -658,7 +682,7 @@ init_esm_shims();
658
682
  import os from "os";
659
683
  import { execa } from "execa";
660
684
  import PQueue from "p-queue";
661
- import path8 from "pathe";
685
+ import path9 from "pathe";
662
686
  import pc from "picocolors";
663
687
 
664
688
  // src/logger.ts
@@ -670,15 +694,15 @@ var logger = createConsola();
670
694
  async function syncNpmMirror(cwd, options) {
671
695
  const packages = await getWorkspacePackages(cwd, options);
672
696
  logger.info(`[\u5F53\u524D\u5DE5\u4F5C\u533ARepo]:
673
- ${packages.map((x) => `- ${pc.green(x.manifest.name)} : ${path8.relative(cwd, x.rootDir)}`).join("\n")}
697
+ ${packages.map((x) => `- ${pc.green(x.manifest.name)} : ${path9.relative(cwd, x.rootDir)}`).join("\n")}
674
698
  `);
675
- const set5 = new Set(packages.map((x) => x.manifest.name));
699
+ const set6 = new Set(packages.map((x) => x.manifest.name));
676
700
  logger.info(`[\u5373\u5C06\u540C\u6B65\u7684\u5305]:
677
- ${Array.from(set5).map((x) => `- ${pc.green(x)}`).join("\n")}
701
+ ${Array.from(set6).map((x) => `- ${pc.green(x)}`).join("\n")}
678
702
  `);
679
703
  const concurrency = Math.max(os.cpus().length, 1);
680
704
  const queue2 = new PQueue({ concurrency });
681
- for (const pkgName of set5) {
705
+ for (const pkgName of set6) {
682
706
  if (pkgName) {
683
707
  await queue2.add(async () => {
684
708
  return execa({
@@ -731,11 +755,11 @@ import process from "process";
731
755
  import { fileURLToPath as fileURLToPath2 } from "url";
732
756
  import checkbox from "@inquirer/checkbox";
733
757
  import confirm from "@inquirer/confirm";
734
- import fs5 from "fs-extra";
735
- var import_set_value4 = __toESM(require_set_value(), 1);
758
+ import fs6 from "fs-extra";
759
+ var import_set_value5 = __toESM(require_set_value(), 1);
736
760
  import klaw from "klaw";
737
761
  import PQueue2 from "p-queue";
738
- import path9 from "pathe";
762
+ import path10 from "pathe";
739
763
  import pc2 from "picocolors";
740
764
 
741
765
  // src/constants.ts
@@ -743,7 +767,7 @@ init_esm_shims();
743
767
 
744
768
  // package.json
745
769
  var name = "@icebreakers/monorepo";
746
- var version = "1.0.0";
770
+ var version = "1.0.2";
747
771
 
748
772
  // src/scripts.ts
749
773
  init_esm_shims();
@@ -794,8 +818,8 @@ function getAssetTargets(raw) {
794
818
  // src/upgrade.ts
795
819
  var queue = new PQueue2({ concurrency: 1 });
796
820
  var __filename2 = fileURLToPath2(import.meta.url);
797
- var __dirname2 = path9.dirname(__filename2);
798
- var assetsDir = path9.join(__dirname2, "../assets");
821
+ var __dirname2 = path10.dirname(__filename2);
822
+ var assetsDir = path10.join(__dirname2, "../assets");
799
823
  function isWorkspace(version2) {
800
824
  if (typeof version2 === "string") {
801
825
  return version2.startsWith("workspace:");
@@ -808,21 +832,21 @@ function setPkgJson(sourcePkgJson, targetPkgJson) {
808
832
  const devDeps = index_default(sourcePkgJson, "devDependencies", { default: {} });
809
833
  const targetDeps = index_default(targetPkgJson, "dependencies", { default: {} });
810
834
  const targetDevDeps = index_default(targetPkgJson, "devDependencies", { default: {} });
811
- (0, import_set_value4.default)(targetPkgJson, "packageManager", packageManager);
835
+ (0, import_set_value5.default)(targetPkgJson, "packageManager", packageManager);
812
836
  Object.entries(deps).forEach((x) => {
813
837
  if (!isWorkspace(targetDeps[x[0]])) {
814
- (0, import_set_value4.default)(targetPkgJson, `dependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
838
+ (0, import_set_value5.default)(targetPkgJson, `dependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
815
839
  }
816
840
  });
817
841
  Object.entries(devDeps).forEach((x) => {
818
842
  if (x[0] === name) {
819
- (0, import_set_value4.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, `^${version}`, { preservePaths: false });
843
+ (0, import_set_value5.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, `^${version}`, { preservePaths: false });
820
844
  } else if (!isWorkspace(targetDevDeps[x[0]])) {
821
- (0, import_set_value4.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
845
+ (0, import_set_value5.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
822
846
  }
823
847
  });
824
848
  for (const [k, v] of scriptsEntries) {
825
- (0, import_set_value4.default)(targetPkgJson, `scripts.${k}`, v);
849
+ (0, import_set_value5.default)(targetPkgJson, `scripts.${k}`, v);
826
850
  }
827
851
  }
828
852
  function confirmOverwrite(filename) {
@@ -833,7 +857,7 @@ async function upgradeMonorepo(opts) {
833
857
  cwd: process.cwd(),
834
858
  outDir: ""
835
859
  });
836
- const absOutDir = path9.isAbsolute(outDir) ? outDir : path9.join(cwd, outDir);
860
+ const absOutDir = path10.isAbsolute(outDir) ? outDir : path10.join(cwd, outDir);
837
861
  const gitClient = new GitClient({
838
862
  baseDir: cwd
839
863
  });
@@ -855,20 +879,20 @@ async function upgradeMonorepo(opts) {
855
879
  });
856
880
  for await (const file of klaw(assetsDir, {
857
881
  filter(p) {
858
- const str = path9.relative(assetsDir, p);
882
+ const str = path10.relative(assetsDir, p);
859
883
  return isMatch(str, regexpArr);
860
884
  }
861
885
  })) {
862
886
  await queue.add(async () => {
863
887
  if (file.stats.isFile()) {
864
- const relPath = path9.relative(assetsDir, file.path);
865
- const targetPath = path9.resolve(absOutDir, relPath);
866
- const targetIsExisted = await fs5.exists(targetPath);
888
+ const relPath = path10.relative(assetsDir, file.path);
889
+ const targetPath = path10.resolve(absOutDir, relPath);
890
+ const targetIsExisted = await fs6.exists(targetPath);
867
891
  async function overwriteOrCopy(target) {
868
892
  let isOverwrite = true;
869
893
  if (targetIsExisted) {
870
- const src = await fs5.readFile(file.path);
871
- const dest = target ?? await fs5.readFile(targetPath);
894
+ const src = await fs6.readFile(file.path);
895
+ const dest = target ?? await fs6.readFile(targetPath);
872
896
  if (await isFileChanged(src, dest)) {
873
897
  isOverwrite = await confirmOverwrite(relPath);
874
898
  }
@@ -878,25 +902,25 @@ async function upgradeMonorepo(opts) {
878
902
  if (relPath === "package.json") {
879
903
  const sourcePath = file.path;
880
904
  if (targetIsExisted) {
881
- const sourcePkgJson = await fs5.readJson(sourcePath);
882
- const targetPkgJson = await fs5.readJson(targetPath);
905
+ const sourcePkgJson = await fs6.readJson(sourcePath);
906
+ const targetPkgJson = await fs6.readJson(targetPath);
883
907
  setPkgJson(sourcePkgJson, targetPkgJson);
884
908
  const data = JSON.stringify(targetPkgJson, void 0, 2);
885
- await fs5.outputFile(targetPath, `${data}
909
+ await fs6.outputFile(targetPath, `${data}
886
910
  `, "utf8");
887
911
  logger.success(targetPath);
888
912
  }
889
913
  } else if (relPath === ".changeset/config.json" && repoName) {
890
- const changesetJson = await fs5.readJson(file.path);
891
- (0, import_set_value4.default)(changesetJson, "changelog.1.repo", repoName);
914
+ const changesetJson = await fs6.readJson(file.path);
915
+ (0, import_set_value5.default)(changesetJson, "changelog.1.repo", repoName);
892
916
  const data = JSON.stringify(changesetJson, void 0, 2);
893
917
  if (await overwriteOrCopy(data)) {
894
- await fs5.outputFile(targetPath, `${data}
918
+ await fs6.outputFile(targetPath, `${data}
895
919
  `, "utf8");
896
920
  logger.success(targetPath);
897
921
  }
898
922
  } else if (await overwriteOrCopy()) {
899
- await fs5.copy(
923
+ await fs6.copy(
900
924
  file.path,
901
925
  targetPath
902
926
  );