@icebreakers/monorepo 0.6.21 → 0.6.22

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.
@@ -38,7 +38,7 @@
38
38
  "@commitlint/config-conventional": "^19.6.0",
39
39
  "@commitlint/prompt-cli": "^19.7.0",
40
40
  "@commitlint/types": "^19.5.0",
41
- "@icebreakers/eslint-config": "^0.7.8",
41
+ "@icebreakers/eslint-config": "^0.7.10",
42
42
  "@icebreakers/monorepo": "workspace:*",
43
43
  "@icebreakers/stylelint-config": "^0.1.3",
44
44
  "@types/fs-extra": "^11.0.4",
@@ -73,7 +73,7 @@
73
73
  "tsup": "^8.3.5",
74
74
  "tsx": "^4.19.2",
75
75
  "turbo": "^2.3.3",
76
- "typescript": "^5.7.2",
76
+ "typescript": "^5.7.3",
77
77
  "unbuild": "^3.2.0",
78
78
  "vitest": "~2.1.8",
79
79
  "yaml": "^2.7.0"
@@ -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.5_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.7.0/node_modules/tsup/assets/esm_shims.js
30
+ // ../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/esm_shims.js
31
31
  var init_esm_shims = __esm({
32
- "../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.7.0/node_modules/tsup/assets/esm_shims.js"() {
32
+ "../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/esm_shims.js"() {
33
33
  "use strict";
34
34
  }
35
35
  });
@@ -741,7 +741,7 @@ init_esm_shims();
741
741
 
742
742
  // package.json
743
743
  var name = "@icebreakers/monorepo";
744
- var version = "0.6.21";
744
+ var version = "0.6.22";
745
745
 
746
746
  // src/scripts.ts
747
747
  init_esm_shims();
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.5_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js
31
+ // ../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.3_yaml@2.7.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.5_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js"() {
34
+ "../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.3_yaml@2.7.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.21";
323
+ var version = "0.6.22";
324
324
 
325
325
  // src/create.ts
326
326
  init_cjs_shims();
@@ -399,6 +399,7 @@ var defuArrayFn = createDefu((object, key, currentValue) => {
399
399
  // src/create.ts
400
400
  var import_fs_extra = __toESM(require("fs-extra"), 1);
401
401
  var import_pathe = __toESM(require("pathe"), 1);
402
+ var import_picocolors = __toESM(require("picocolors"), 1);
402
403
  var import_set_value = __toESM(require_set_value(), 1);
403
404
 
404
405
  // src/logger.ts
@@ -410,29 +411,33 @@ var logger = (0, import_consola.createConsola)();
410
411
  var __filename2 = (0, import_node_url.fileURLToPath)(importMetaUrl);
411
412
  var __dirname = import_pathe.default.dirname(__filename2);
412
413
  var templatesDir = import_pathe.default.join(__dirname, "../templates");
414
+ var defaultTemplate = "tsup";
415
+ var fromMap = {
416
+ tsup: "bar",
417
+ unbuild: "foo"
418
+ };
413
419
  async function createNewProject(options) {
414
- const defaultTemplate = "bar";
415
- const { name: name2, renameJson, cwd: cwd2 } = defu(options, {
420
+ const { name: targetName, renameJson, cwd: cwd2, type } = defu(options, {
416
421
  cwd: import_node_process.default.cwd(),
417
- name: defaultTemplate,
422
+ name: fromMap[defaultTemplate],
418
423
  renameJson: false
419
424
  });
420
- const targetTemplate = name2;
421
- const from = import_pathe.default.join(templatesDir, defaultTemplate);
422
- const to = import_pathe.default.join(cwd2, targetTemplate);
425
+ const bundlerName = type ?? defaultTemplate;
426
+ const from = import_pathe.default.join(templatesDir, fromMap[bundlerName]);
427
+ const to = import_pathe.default.join(cwd2, targetName);
423
428
  const filelist = await import_fs_extra.default.readdir(from);
424
429
  for (const filename of filelist) {
425
430
  if (filename === "package.json") {
426
431
  const sourceJsonPath = import_pathe.default.resolve(from, filename);
427
432
  const sourceJson = await import_fs_extra.default.readJson(sourceJsonPath);
428
433
  (0, import_set_value.default)(sourceJson, "version", "0.0.0");
429
- (0, import_set_value.default)(sourceJson, "name", import_pathe.default.basename(targetTemplate));
434
+ (0, import_set_value.default)(sourceJson, "name", import_pathe.default.basename(targetName));
430
435
  await import_fs_extra.default.outputJson(import_pathe.default.resolve(to, renameJson ? "package.mock.json" : filename), sourceJson, { spaces: 2 });
431
436
  } else {
432
437
  await import_fs_extra.default.copy(import_pathe.default.resolve(from, filename), import_pathe.default.resolve(to, filename));
433
438
  }
434
439
  }
435
- logger.success(`${targetTemplate} \u9879\u76EE\u521B\u5EFA\u6210\u529F\uFF01`);
440
+ logger.success(`${import_picocolors.default.bgGreenBright(import_picocolors.default.white(`[${bundlerName}]`))} ${targetName} \u9879\u76EE\u521B\u5EFA\u6210\u529F\uFF01`);
436
441
  }
437
442
 
438
443
  // src/monorepo/index.ts
@@ -722,15 +727,15 @@ var import_node_os = __toESM(require("os"), 1);
722
727
  var import_execa = require("execa");
723
728
  var import_p_queue = __toESM(require("p-queue"), 1);
724
729
  var import_pathe8 = __toESM(require("pathe"), 1);
725
- var import_picocolors = __toESM(require("picocolors"), 1);
730
+ var import_picocolors2 = __toESM(require("picocolors"), 1);
726
731
  async function syncNpmMirror(cwd2) {
727
732
  const packages = await getWorkspacePackages(cwd2);
728
733
  logger.info(`[\u5F53\u524D\u5DE5\u4F5C\u533ARepo]:
729
- ${packages.map((x) => `- ${import_picocolors.default.green(x.manifest.name)} : ${import_pathe8.default.relative(cwd2, x.rootDir)}`).join("\n")}
734
+ ${packages.map((x) => `- ${import_picocolors2.default.green(x.manifest.name)} : ${import_pathe8.default.relative(cwd2, x.rootDir)}`).join("\n")}
730
735
  `);
731
736
  const set6 = new Set(packages.map((x) => x.manifest.name));
732
737
  logger.info(`[\u5373\u5C06\u540C\u6B65\u7684\u5305]:
733
- ${Array.from(set6).map((x) => `- ${import_picocolors.default.green(x)}`).join("\n")}
738
+ ${Array.from(set6).map((x) => `- ${import_picocolors2.default.green(x)}`).join("\n")}
734
739
  `);
735
740
  const concurrency = Math.max(import_node_os.default.cpus().length, 1);
736
741
  const queue2 = new import_p_queue.default({ concurrency });
@@ -756,7 +761,7 @@ var import_get_value2 = __toESM(require_get_value(), 1);
756
761
  var import_klaw = __toESM(require("klaw"), 1);
757
762
  var import_p_queue2 = __toESM(require("p-queue"), 1);
758
763
  var import_pathe9 = __toESM(require("pathe"), 1);
759
- var import_picocolors2 = __toESM(require("picocolors"), 1);
764
+ var import_picocolors3 = __toESM(require("picocolors"), 1);
760
765
  var import_set_value5 = __toESM(require_set_value(), 1);
761
766
 
762
767
  // src/scripts.ts
@@ -872,7 +877,7 @@ function setPkgJson(sourcePkgJson, targetPkgJson) {
872
877
  }
873
878
  }
874
879
  function confirmOverwrite(filename) {
875
- return (0, import_confirm.default)({ message: `${import_picocolors2.default.greenBright(filename)} \u6587\u4EF6\u5185\u5BB9\u53D1\u751F\u6539\u53D8,\u662F\u5426\u8986\u76D6?`, default: false });
880
+ return (0, import_confirm.default)({ message: `${import_picocolors3.default.greenBright(filename)} \u6587\u4EF6\u5185\u5BB9\u53D1\u751F\u6539\u53D8,\u662F\u5426\u8986\u76D6?`, default: false });
876
881
  }
877
882
  async function upgradeMonorepo(opts) {
878
883
  const { outDir, raw, interactive, cwd: cwd2 } = defu(opts, {
@@ -977,10 +982,12 @@ import_commander.program.command("mirror").description("\u8BBE\u7F6E VscodeBinar
977
982
  await setVscodeBinaryMirror(cwd);
978
983
  logger.success("set vscode binary mirror finished!");
979
984
  });
980
- import_commander.program.command("new").description("\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u5B50\u5305").alias("create").argument("[name]").action(async (name2) => {
985
+ import_commander.program.command("new").description("\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u5B50\u5305").alias("create").argument("[name]").option("--tsup").option("--unbuild").action(async (name2, options) => {
986
+ const type = options.tsup ? "tsup" : options.unbuild ? "unbuild" : void 0;
981
987
  await createNewProject({
982
988
  name: name2,
983
- cwd
989
+ cwd,
990
+ type
984
991
  });
985
992
  logger.success("create a package");
986
993
  });
package/dist/cli.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  syncNpmMirror,
12
12
  upgradeMonorepo,
13
13
  version
14
- } from "./chunk-54PKU7G6.js";
14
+ } from "./chunk-QU6W43GW.js";
15
15
 
16
16
  // src/cli.ts
17
17
  init_esm_shims();
@@ -28,32 +28,37 @@ import { fileURLToPath } from "node:url";
28
28
  var import_set_value = __toESM(require_set_value(), 1);
29
29
  import fs from "fs-extra";
30
30
  import path from "pathe";
31
+ import pc from "picocolors";
31
32
  var __filename = fileURLToPath(import.meta.url);
32
33
  var __dirname = path.dirname(__filename);
33
34
  var templatesDir = path.join(__dirname, "../templates");
35
+ var defaultTemplate = "tsup";
36
+ var fromMap = {
37
+ tsup: "bar",
38
+ unbuild: "foo"
39
+ };
34
40
  async function createNewProject(options) {
35
- const defaultTemplate = "bar";
36
- const { name: name2, renameJson, cwd: cwd2 } = defu(options, {
41
+ const { name: targetName, renameJson, cwd: cwd2, type } = defu(options, {
37
42
  cwd: process.cwd(),
38
- name: defaultTemplate,
43
+ name: fromMap[defaultTemplate],
39
44
  renameJson: false
40
45
  });
41
- const targetTemplate = name2;
42
- const from = path.join(templatesDir, defaultTemplate);
43
- const to = path.join(cwd2, targetTemplate);
46
+ const bundlerName = type ?? defaultTemplate;
47
+ const from = path.join(templatesDir, fromMap[bundlerName]);
48
+ const to = path.join(cwd2, targetName);
44
49
  const filelist = await fs.readdir(from);
45
50
  for (const filename of filelist) {
46
51
  if (filename === "package.json") {
47
52
  const sourceJsonPath = path.resolve(from, filename);
48
53
  const sourceJson = await fs.readJson(sourceJsonPath);
49
54
  (0, import_set_value.default)(sourceJson, "version", "0.0.0");
50
- (0, import_set_value.default)(sourceJson, "name", path.basename(targetTemplate));
55
+ (0, import_set_value.default)(sourceJson, "name", path.basename(targetName));
51
56
  await fs.outputJson(path.resolve(to, renameJson ? "package.mock.json" : filename), sourceJson, { spaces: 2 });
52
57
  } else {
53
58
  await fs.copy(path.resolve(from, filename), path.resolve(to, filename));
54
59
  }
55
60
  }
56
- logger.success(`${targetTemplate} \u9879\u76EE\u521B\u5EFA\u6210\u529F\uFF01`);
61
+ logger.success(`${pc.bgGreenBright(pc.white(`[${bundlerName}]`))} ${targetName} \u9879\u76EE\u521B\u5EFA\u6210\u529F\uFF01`);
57
62
  }
58
63
 
59
64
  // src/program.ts
@@ -79,10 +84,12 @@ program.command("mirror").description("\u8BBE\u7F6E VscodeBinaryMirror").action(
79
84
  await setVscodeBinaryMirror(cwd);
80
85
  logger.success("set vscode binary mirror finished!");
81
86
  });
82
- program.command("new").description("\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u5B50\u5305").alias("create").argument("[name]").action(async (name2) => {
87
+ program.command("new").description("\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u5B50\u5305").alias("create").argument("[name]").option("--tsup").option("--unbuild").action(async (name2, options) => {
88
+ const type = options.tsup ? "tsup" : options.unbuild ? "unbuild" : void 0;
83
89
  await createNewProject({
84
90
  name: name2,
85
- cwd
91
+ cwd,
92
+ type
86
93
  });
87
94
  logger.success("create a package");
88
95
  });
package/dist/index.cjs CHANGED
@@ -33,10 +33,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // ../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js
36
+ // ../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js
37
37
  var getImportMetaUrl, importMetaUrl;
38
38
  var init_cjs_shims = __esm({
39
- "../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js"() {
39
+ "../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js"() {
40
40
  "use strict";
41
41
  getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
42
42
  importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
@@ -738,7 +738,7 @@ init_cjs_shims();
738
738
 
739
739
  // package.json
740
740
  var name = "@icebreakers/monorepo";
741
- var version = "0.6.21";
741
+ var version = "0.6.22";
742
742
 
743
743
  // src/scripts.ts
744
744
  init_cjs_shims();
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  setVscodeBinaryMirror,
13
13
  syncNpmMirror,
14
14
  upgradeMonorepo
15
- } from "./chunk-54PKU7G6.js";
15
+ } from "./chunk-QU6W43GW.js";
16
16
 
17
17
  // src/index.ts
18
18
  init_esm_shims();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/monorepo",
3
3
  "type": "module",
4
- "version": "0.6.21",
4
+ "version": "0.6.22",
5
5
  "description": "icebreaker's monorepo config generator",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -37,8 +37,8 @@
37
37
  "@inquirer/checkbox": "^4.0.4",
38
38
  "@inquirer/confirm": "^5.1.1",
39
39
  "@pnpm/logger": "^1000.0.0",
40
- "@pnpm/types": "^1000.0.0",
41
- "@pnpm/workspace.find-packages": "^1000.0.3",
40
+ "@pnpm/types": "^1000.1.0",
41
+ "@pnpm/workspace.find-packages": "^1000.0.5",
42
42
  "commander": "^13.0.0",
43
43
  "comment-json": "^4.2.5",
44
44
  "consola": "^3.3.3",
@@ -0,0 +1,25 @@
1
+ import path from 'node:path'
2
+ import { defineBuildConfig } from 'unbuild'
3
+
4
+ export default defineBuildConfig({
5
+ // entries: ['./src/index', './src/cli'],
6
+ entries: ['./src/index'],
7
+ rollup: {
8
+ // 内联,相当于 nodeResolve
9
+ inlineDependencies: true,
10
+ // cjs
11
+ emitCJS: true,
12
+ // 添加 cjs 注入
13
+ cjsBridge: true,
14
+ dts: {
15
+ // https://github.com/unjs/unbuild/issues/135
16
+ respectExternal: false,
17
+ },
18
+ },
19
+ alias: {
20
+ // 别名
21
+ '@': path.resolve(__dirname, './src'),
22
+ },
23
+ // dts
24
+ declaration: true,
25
+ })
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@icebreakers/foo",
3
+ "type": "module",
4
+ "version": "0.1.2",
5
+ "description": "esbuild(rollup) build package template",
6
+ "author": "ice breaker <1324318532@qq.com>",
7
+ "license": "ISC",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/sonofmagic/monorepo-template.git",
11
+ "directory": "packages/foo"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/sonofmagic/monorepo-template/issues"
15
+ },
16
+ "keywords": [],
17
+ "sideEffects": false,
18
+ "exports": {
19
+ ".": "./src/index.ts"
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "scripts": {
25
+ "dev": "unbuild --watch --sourcemap",
26
+ "build": "unbuild",
27
+ "test": "vitest run",
28
+ "test:dev": "vitest",
29
+ "release": "pnpm publish",
30
+ "lint": "eslint .",
31
+ "lint:fix": "eslint . --fix"
32
+ },
33
+ "publishConfig": {
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "import": "./dist/index.mjs",
38
+ "require": "./dist/index.cjs"
39
+ }
40
+ },
41
+ "main": "./dist/index.cjs",
42
+ "module": "./dist/index.mjs",
43
+ "types": "./dist/index.d.ts"
44
+ }
45
+ }
@@ -0,0 +1,7 @@
1
+ export function foo() {
2
+ return 'bar'
3
+ }
4
+
5
+ export function getDirname() {
6
+ return __dirname
7
+ }
@@ -0,0 +1,7 @@
1
+ import { foo } from '@/index'
2
+
3
+ describe('index', () => {
4
+ it('foo bar', () => {
5
+ expect(foo()).toBe('bar')
6
+ })
7
+ })
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "paths": {
6
+ "@/*": [
7
+ "src/*"
8
+ ]
9
+ }
10
+ },
11
+ "include": [
12
+ "src",
13
+ "test"
14
+ ]
15
+ }
@@ -0,0 +1,15 @@
1
+ import path from 'node:path'
2
+ import { defineProject } from 'vitest/config'
3
+
4
+ export default defineProject({
5
+ test: {
6
+ alias: [
7
+ {
8
+ find: '@',
9
+ replacement: path.resolve(__dirname, './src'),
10
+ },
11
+ ],
12
+ globals: true,
13
+ testTimeout: 60_000,
14
+ },
15
+ })