@icebreakers/monorepo 0.6.2 → 0.6.4

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.5.0",
39
39
  "@commitlint/prompt-cli": "^19.5.0",
40
40
  "@commitlint/types": "^19.5.0",
41
- "@icebreakers/eslint-config": "^0.5.4",
41
+ "@icebreakers/eslint-config": "^0.6.0",
42
42
  "@icebreakers/monorepo": "workspace:*",
43
43
  "@icebreakers/stylelint-config": "^0.1.1",
44
44
  "@types/fs-extra": "^11.0.4",
@@ -61,13 +61,13 @@
61
61
  "micromatch": "^4.0.8",
62
62
  "only-allow": "^1.2.1",
63
63
  "pathe": "^1.1.2",
64
- "pkg-types": "^1.2.0",
64
+ "pkg-types": "^1.2.1",
65
65
  "rimraf": "^6.0.1",
66
66
  "tslib": "^2.7.0",
67
67
  "tsup": "^8.3.0",
68
68
  "tsx": "^4.19.1",
69
69
  "turbo": "^2.1.3",
70
- "typescript": "^5.6.2",
70
+ "typescript": "^5.6.3",
71
71
  "unbuild": "^2.0.0",
72
72
  "vitest": "~2.0.5",
73
73
  "yaml": "^2.5.1"
@@ -13,7 +13,7 @@ import set from "set-value";
13
13
 
14
14
  // package.json
15
15
  var name = "@icebreakers/monorepo";
16
- var version = "0.6.2";
16
+ var version = "0.6.4";
17
17
 
18
18
  // src/logger.ts
19
19
  import { createConsola } from "consola";
@@ -149,19 +149,31 @@ var __dirname2 = path.dirname(__filename2);
149
149
  var assetsDir = path.join(__dirname2, "../assets");
150
150
  var templatesDir = path.join(__dirname2, "../templates");
151
151
  var cwd = process.cwd();
152
+ function isWorkspace(version2) {
153
+ if (typeof version2 === "string") {
154
+ return version2.startsWith("workspace:");
155
+ }
156
+ return false;
157
+ }
152
158
  function setPkgJson(sourcePkgJson, targetPkgJson) {
153
159
  const packageManager = get2(sourcePkgJson, "packageManager", { default: "" });
154
160
  const deps = get2(sourcePkgJson, "dependencies", { default: {} });
155
161
  const devDeps = get2(sourcePkgJson, "devDependencies", { default: {} });
162
+ const targetDeps = get2(targetPkgJson, "dependencies", { default: {} });
163
+ const targetDevDeps = get2(targetPkgJson, "devDependencies", { default: {} });
156
164
  set(targetPkgJson, "packageManager", packageManager);
157
165
  Object.entries(deps).forEach((x) => {
158
- set(targetPkgJson, `dependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
166
+ if (!isWorkspace(targetDeps[x[0]])) {
167
+ set(targetPkgJson, `dependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
168
+ }
159
169
  });
160
170
  Object.entries(devDeps).forEach((x) => {
161
- if (x[0] === "@icebreakers/monorepo") {
171
+ if (x[0] === name) {
162
172
  set(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, `^${version}`, { preservePaths: false });
163
173
  } else {
164
- set(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
174
+ if (!isWorkspace(targetDevDeps[x[0]])) {
175
+ set(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
176
+ }
165
177
  }
166
178
  });
167
179
  for (const [k, v] of scriptsEntries) {
package/dist/cli.cjs CHANGED
@@ -22,7 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  mod
23
23
  ));
24
24
 
25
- // ../../node_modules/.pnpm/tsup@8.3.0_jiti@2.3.1_postcss@8.4.47_tsx@4.19.1_typescript@5.6.2_yaml@2.5.1/node_modules/tsup/assets/cjs_shims.js
25
+ // ../../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
26
26
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
27
27
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
28
28
 
@@ -32,7 +32,7 @@ var import_commander = require("commander");
32
32
 
33
33
  // package.json
34
34
  var name = "@icebreakers/monorepo";
35
- var version = "0.6.2";
35
+ var version = "0.6.4";
36
36
 
37
37
  // src/lib.ts
38
38
  var import_node_process = __toESM(require("process"), 1);
@@ -181,19 +181,31 @@ var __dirname = import_pathe.default.dirname(__filename2);
181
181
  var assetsDir = import_pathe.default.join(__dirname, "../assets");
182
182
  var templatesDir = import_pathe.default.join(__dirname, "../templates");
183
183
  var cwd = import_node_process.default.cwd();
184
+ function isWorkspace(version2) {
185
+ if (typeof version2 === "string") {
186
+ return version2.startsWith("workspace:");
187
+ }
188
+ return false;
189
+ }
184
190
  function setPkgJson(sourcePkgJson, targetPkgJson) {
185
191
  const packageManager = (0, import_get_value2.default)(sourcePkgJson, "packageManager", { default: "" });
186
192
  const deps = (0, import_get_value2.default)(sourcePkgJson, "dependencies", { default: {} });
187
193
  const devDeps = (0, import_get_value2.default)(sourcePkgJson, "devDependencies", { default: {} });
194
+ const targetDeps = (0, import_get_value2.default)(targetPkgJson, "dependencies", { default: {} });
195
+ const targetDevDeps = (0, import_get_value2.default)(targetPkgJson, "devDependencies", { default: {} });
188
196
  (0, import_set_value.default)(targetPkgJson, "packageManager", packageManager);
189
197
  Object.entries(deps).forEach((x) => {
190
- (0, import_set_value.default)(targetPkgJson, `dependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
198
+ if (!isWorkspace(targetDeps[x[0]])) {
199
+ (0, import_set_value.default)(targetPkgJson, `dependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
200
+ }
191
201
  });
192
202
  Object.entries(devDeps).forEach((x) => {
193
- if (x[0] === "@icebreakers/monorepo") {
203
+ if (x[0] === name) {
194
204
  (0, import_set_value.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, `^${version}`, { preservePaths: false });
195
205
  } else {
196
- (0, import_set_value.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
206
+ if (!isWorkspace(targetDevDeps[x[0]])) {
207
+ (0, import_set_value.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
208
+ }
197
209
  }
198
210
  });
199
211
  for (const [k, v] of scriptsEntries) {
@@ -364,22 +376,106 @@ async function cleanProjects(cwd3) {
364
376
  // src/monorepo/context.ts
365
377
  var import_pathe5 = __toESM(require("pathe"), 1);
366
378
 
367
- // src/monorepo/utils.ts
379
+ // src/monorepo/workspace.ts
368
380
  var import_workspace = require("@pnpm/workspace.find-packages");
381
+
382
+ // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
383
+ function isPlainObject(value) {
384
+ if (value === null || typeof value !== "object") {
385
+ return false;
386
+ }
387
+ const prototype = Object.getPrototypeOf(value);
388
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
389
+ return false;
390
+ }
391
+ if (Symbol.iterator in value) {
392
+ return false;
393
+ }
394
+ if (Symbol.toStringTag in value) {
395
+ return Object.prototype.toString.call(value) === "[object Module]";
396
+ }
397
+ return true;
398
+ }
399
+ function _defu(baseObject, defaults, namespace = ".", merger) {
400
+ if (!isPlainObject(defaults)) {
401
+ return _defu(baseObject, {}, namespace, merger);
402
+ }
403
+ const object = Object.assign({}, defaults);
404
+ for (const key in baseObject) {
405
+ if (key === "__proto__" || key === "constructor") {
406
+ continue;
407
+ }
408
+ const value = baseObject[key];
409
+ if (value === null || value === void 0) {
410
+ continue;
411
+ }
412
+ if (merger && merger(object, key, value, namespace)) {
413
+ continue;
414
+ }
415
+ if (Array.isArray(value) && Array.isArray(object[key])) {
416
+ object[key] = [...value, ...object[key]];
417
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
418
+ object[key] = _defu(
419
+ value,
420
+ object[key],
421
+ (namespace ? `${namespace}.` : "") + key.toString(),
422
+ merger
423
+ );
424
+ } else {
425
+ object[key] = value;
426
+ }
427
+ }
428
+ return object;
429
+ }
430
+ function createDefu(merger) {
431
+ return (...arguments_) => (
432
+ // eslint-disable-next-line unicorn/no-array-reduce
433
+ arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
434
+ );
435
+ }
436
+ var defu = createDefu();
437
+ var defuFn = createDefu((object, key, currentValue) => {
438
+ if (object[key] !== void 0 && typeof currentValue === "function") {
439
+ object[key] = currentValue(object[key]);
440
+ return true;
441
+ }
442
+ });
443
+ var defuArrayFn = createDefu((object, key, currentValue) => {
444
+ if (Array.isArray(object[key]) && typeof currentValue === "function") {
445
+ object[key] = currentValue(object[key]);
446
+ return true;
447
+ }
448
+ });
449
+
450
+ // src/monorepo/workspace.ts
369
451
  var import_pathe4 = __toESM(require("pathe"), 1);
370
- async function getWorkspacePackages(cwd3) {
452
+ async function getWorkspacePackages(cwd3, options) {
453
+ const posixCwd = import_pathe4.default.normalize(cwd3);
454
+ const { ignoreRootPackage, ignorePrivatePackage } = defu(options, {
455
+ ignoreRootPackage: true,
456
+ ignorePrivatePackage: true
457
+ });
371
458
  const packages = await (0, import_workspace.findWorkspacePackages)(cwd3);
372
- return (await Promise.allSettled(packages.map(async (project) => {
459
+ let pkgs = packages.filter((x) => {
460
+ if (ignorePrivatePackage && x.manifest.private) {
461
+ return false;
462
+ }
463
+ return true;
464
+ }).map((project) => {
373
465
  const pkgJsonPath = import_pathe4.default.resolve(project.rootDir, "package.json");
374
466
  return {
375
467
  ...project,
376
468
  pkgJsonPath
377
469
  };
378
- }))).filter((x) => {
379
- return x.status === "fulfilled";
380
- }).map((x) => {
381
- return x.value;
382
470
  });
471
+ if (ignoreRootPackage) {
472
+ pkgs = pkgs.filter((x) => {
473
+ return import_pathe4.default.normalize(
474
+ x.rootDir
475
+ ) !== posixCwd;
476
+ });
477
+ }
478
+ return pkgs;
383
479
  }
384
480
 
385
481
  // src/monorepo/context.ts
@@ -481,6 +577,7 @@ async function init(cwd3) {
481
577
  var import_execa = require("execa");
482
578
  async function syncNpmMirror(cwd3) {
483
579
  const packages = await getWorkspacePackages(cwd3);
580
+ logger.info("[\u5373\u5C06\u540C\u6B65\u7684\u5305]:", packages.filter((x) => x.manifest.name).map((x) => x.manifest.name));
484
581
  for (const project of packages) {
485
582
  if (project.manifest.name) {
486
583
  await (0, import_execa.execa)({
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  name,
6
6
  upgradeMonorepo,
7
7
  version
8
- } from "./chunk-UFDFNNMJ.js";
8
+ } from "./chunk-UU4G2QIU.js";
9
9
 
10
10
  // src/program.ts
11
11
  import process from "node:process";
@@ -87,22 +87,106 @@ async function cleanProjects(cwd2) {
87
87
  // src/monorepo/context.ts
88
88
  import path4 from "pathe";
89
89
 
90
- // src/monorepo/utils.ts
90
+ // src/monorepo/workspace.ts
91
91
  import { findWorkspacePackages } from "@pnpm/workspace.find-packages";
92
+
93
+ // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
94
+ function isPlainObject(value) {
95
+ if (value === null || typeof value !== "object") {
96
+ return false;
97
+ }
98
+ const prototype = Object.getPrototypeOf(value);
99
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
100
+ return false;
101
+ }
102
+ if (Symbol.iterator in value) {
103
+ return false;
104
+ }
105
+ if (Symbol.toStringTag in value) {
106
+ return Object.prototype.toString.call(value) === "[object Module]";
107
+ }
108
+ return true;
109
+ }
110
+ function _defu(baseObject, defaults, namespace = ".", merger) {
111
+ if (!isPlainObject(defaults)) {
112
+ return _defu(baseObject, {}, namespace, merger);
113
+ }
114
+ const object = Object.assign({}, defaults);
115
+ for (const key in baseObject) {
116
+ if (key === "__proto__" || key === "constructor") {
117
+ continue;
118
+ }
119
+ const value = baseObject[key];
120
+ if (value === null || value === void 0) {
121
+ continue;
122
+ }
123
+ if (merger && merger(object, key, value, namespace)) {
124
+ continue;
125
+ }
126
+ if (Array.isArray(value) && Array.isArray(object[key])) {
127
+ object[key] = [...value, ...object[key]];
128
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
129
+ object[key] = _defu(
130
+ value,
131
+ object[key],
132
+ (namespace ? `${namespace}.` : "") + key.toString(),
133
+ merger
134
+ );
135
+ } else {
136
+ object[key] = value;
137
+ }
138
+ }
139
+ return object;
140
+ }
141
+ function createDefu(merger) {
142
+ return (...arguments_) => (
143
+ // eslint-disable-next-line unicorn/no-array-reduce
144
+ arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
145
+ );
146
+ }
147
+ var defu = createDefu();
148
+ var defuFn = createDefu((object, key, currentValue) => {
149
+ if (object[key] !== void 0 && typeof currentValue === "function") {
150
+ object[key] = currentValue(object[key]);
151
+ return true;
152
+ }
153
+ });
154
+ var defuArrayFn = createDefu((object, key, currentValue) => {
155
+ if (Array.isArray(object[key]) && typeof currentValue === "function") {
156
+ object[key] = currentValue(object[key]);
157
+ return true;
158
+ }
159
+ });
160
+
161
+ // src/monorepo/workspace.ts
92
162
  import path3 from "pathe";
93
- async function getWorkspacePackages(cwd2) {
163
+ async function getWorkspacePackages(cwd2, options) {
164
+ const posixCwd = path3.normalize(cwd2);
165
+ const { ignoreRootPackage, ignorePrivatePackage } = defu(options, {
166
+ ignoreRootPackage: true,
167
+ ignorePrivatePackage: true
168
+ });
94
169
  const packages = await findWorkspacePackages(cwd2);
95
- return (await Promise.allSettled(packages.map(async (project) => {
170
+ let pkgs = packages.filter((x) => {
171
+ if (ignorePrivatePackage && x.manifest.private) {
172
+ return false;
173
+ }
174
+ return true;
175
+ }).map((project) => {
96
176
  const pkgJsonPath = path3.resolve(project.rootDir, "package.json");
97
177
  return {
98
178
  ...project,
99
179
  pkgJsonPath
100
180
  };
101
- }))).filter((x) => {
102
- return x.status === "fulfilled";
103
- }).map((x) => {
104
- return x.value;
105
181
  });
182
+ if (ignoreRootPackage) {
183
+ pkgs = pkgs.filter((x) => {
184
+ return path3.normalize(
185
+ x.rootDir
186
+ ) !== posixCwd;
187
+ });
188
+ }
189
+ return pkgs;
106
190
  }
107
191
 
108
192
  // src/monorepo/context.ts
@@ -204,6 +288,7 @@ async function init(cwd2) {
204
288
  import { execa } from "execa";
205
289
  async function syncNpmMirror(cwd2) {
206
290
  const packages = await getWorkspacePackages(cwd2);
291
+ logger.info("[\u5373\u5C06\u540C\u6B65\u7684\u5305]:", packages.filter((x) => x.manifest.name).map((x) => x.manifest.name));
207
292
  for (const project of packages) {
208
293
  if (project.manifest.name) {
209
294
  await execa({
package/dist/index.cjs CHANGED
@@ -36,7 +36,7 @@ __export(src_exports, {
36
36
  });
37
37
  module.exports = __toCommonJS(src_exports);
38
38
 
39
- // ../../node_modules/.pnpm/tsup@8.3.0_jiti@2.3.1_postcss@8.4.47_tsx@4.19.1_typescript@5.6.2_yaml@2.5.1/node_modules/tsup/assets/cjs_shims.js
39
+ // ../../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
40
40
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
41
41
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
42
42
 
@@ -54,7 +54,8 @@ var import_picocolors = __toESM(require("picocolors"), 1);
54
54
  var import_set_value = __toESM(require("set-value"), 1);
55
55
 
56
56
  // package.json
57
- var version = "0.6.2";
57
+ var name = "@icebreakers/monorepo";
58
+ var version = "0.6.4";
58
59
 
59
60
  // src/logger.ts
60
61
  var import_consola = require("consola");
@@ -190,19 +191,31 @@ var __dirname = import_pathe.default.dirname(__filename2);
190
191
  var assetsDir = import_pathe.default.join(__dirname, "../assets");
191
192
  var templatesDir = import_pathe.default.join(__dirname, "../templates");
192
193
  var cwd = import_node_process.default.cwd();
194
+ function isWorkspace(version2) {
195
+ if (typeof version2 === "string") {
196
+ return version2.startsWith("workspace:");
197
+ }
198
+ return false;
199
+ }
193
200
  function setPkgJson(sourcePkgJson, targetPkgJson) {
194
201
  const packageManager = (0, import_get_value2.default)(sourcePkgJson, "packageManager", { default: "" });
195
202
  const deps = (0, import_get_value2.default)(sourcePkgJson, "dependencies", { default: {} });
196
203
  const devDeps = (0, import_get_value2.default)(sourcePkgJson, "devDependencies", { default: {} });
204
+ const targetDeps = (0, import_get_value2.default)(targetPkgJson, "dependencies", { default: {} });
205
+ const targetDevDeps = (0, import_get_value2.default)(targetPkgJson, "devDependencies", { default: {} });
197
206
  (0, import_set_value.default)(targetPkgJson, "packageManager", packageManager);
198
207
  Object.entries(deps).forEach((x) => {
199
- (0, import_set_value.default)(targetPkgJson, `dependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
208
+ if (!isWorkspace(targetDeps[x[0]])) {
209
+ (0, import_set_value.default)(targetPkgJson, `dependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
210
+ }
200
211
  });
201
212
  Object.entries(devDeps).forEach((x) => {
202
- if (x[0] === "@icebreakers/monorepo") {
213
+ if (x[0] === name) {
203
214
  (0, import_set_value.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, `^${version}`, { preservePaths: false });
204
215
  } else {
205
- (0, import_set_value.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
216
+ if (!isWorkspace(targetDevDeps[x[0]])) {
217
+ (0, import_set_value.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
218
+ }
206
219
  }
207
220
  });
208
221
  for (const [k, v] of scriptsEntries) {
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  createNewProject,
3
3
  setPkgJson,
4
4
  upgradeMonorepo
5
- } from "./chunk-UFDFNNMJ.js";
5
+ } from "./chunk-UU4G2QIU.js";
6
6
  export {
7
7
  createNewProject,
8
8
  setPkgJson,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/monorepo",
3
3
  "type": "module",
4
- "version": "0.6.2",
4
+ "version": "0.6.4",
5
5
  "description": "icebreaker's monorepo config generator",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",