@icebreakers/monorepo 0.6.3 → 0.6.5

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/README.md CHANGED
@@ -1,7 +1,17 @@
1
1
  # @icebreakers/monorepo
2
2
 
3
+ `monorepo` 升级同步工具
4
+
5
+ ## 使用方式
6
+
3
7
  ```sh
4
8
  npx @icebreakers/monorepo@latest
5
9
  ```
6
10
 
11
+ ## 文档地址
12
+
13
+ https://monorepo.icebreaker.top/
14
+
15
+ ## 需求环境
16
+
7
17
  Nodejs >= `v20.11.0`
@@ -42,11 +42,15 @@
42
42
  "@icebreakers/monorepo": "workspace:*",
43
43
  "@icebreakers/stylelint-config": "^0.1.1",
44
44
  "@types/fs-extra": "^11.0.4",
45
+ "@types/get-value": "^3.0.5",
46
+ "@types/git-url-parse": "^9.0.3",
47
+ "@types/klaw": "^3.0.6",
45
48
  "@types/lint-staged": "^13.3.0",
46
49
  "@types/lodash": "^4.17.10",
47
50
  "@types/lodash-es": "^4.17.12",
48
51
  "@types/micromatch": "^4.0.9",
49
52
  "@types/node": "^22.7.5",
53
+ "@types/set-value": "^4.0.3",
50
54
  "@vitest/coverage-v8": "~2.0.5",
51
55
  "ci-info": "^4.0.0",
52
56
  "cross-env": "^7.0.3",
@@ -54,6 +58,7 @@
54
58
  "eslint": "^9.12.0",
55
59
  "execa": "^9.4.0",
56
60
  "fs-extra": "^11.2.0",
61
+ "get-value": "^3.0.1",
57
62
  "husky": "^9.1.6",
58
63
  "lint-staged": "^15.2.10",
59
64
  "lodash": "^4.17.21",
@@ -63,6 +68,7 @@
63
68
  "pathe": "^1.1.2",
64
69
  "pkg-types": "^1.2.1",
65
70
  "rimraf": "^6.0.1",
71
+ "set-value": "^4.1.0",
66
72
  "tslib": "^2.7.0",
67
73
  "tsup": "^8.3.0",
68
74
  "tsx": "^4.19.1",
@@ -0,0 +1,639 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
10
+ var __commonJS = (cb, mod) => function __require() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
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
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"() {
33
+ "use strict";
34
+ }
35
+ });
36
+
37
+ // ../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js
38
+ var require_isobject = __commonJS({
39
+ "../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js"(exports, module) {
40
+ "use strict";
41
+ init_esm_shims();
42
+ module.exports = function isObject(val) {
43
+ return val != null && typeof val === "object" && Array.isArray(val) === false;
44
+ };
45
+ }
46
+ });
47
+
48
+ // ../../node_modules/.pnpm/get-value@3.0.1/node_modules/get-value/index.js
49
+ var require_get_value = __commonJS({
50
+ "../../node_modules/.pnpm/get-value@3.0.1/node_modules/get-value/index.js"(exports, module) {
51
+ "use strict";
52
+ init_esm_shims();
53
+ var isObject = require_isobject();
54
+ module.exports = function(target, path2, options) {
55
+ if (!isObject(options)) {
56
+ options = { default: options };
57
+ }
58
+ if (!isValidObject(target)) {
59
+ return typeof options.default !== "undefined" ? options.default : target;
60
+ }
61
+ if (typeof path2 === "number") {
62
+ path2 = String(path2);
63
+ }
64
+ const isArray = Array.isArray(path2);
65
+ const isString = typeof path2 === "string";
66
+ const splitChar = options.separator || ".";
67
+ const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
68
+ if (!isString && !isArray) {
69
+ return target;
70
+ }
71
+ if (isString && path2 in target) {
72
+ return isValid(path2, target, options) ? target[path2] : options.default;
73
+ }
74
+ let segs = isArray ? path2 : split(path2, splitChar, options);
75
+ let len = segs.length;
76
+ let idx = 0;
77
+ do {
78
+ let prop = segs[idx];
79
+ if (typeof prop === "number") {
80
+ prop = String(prop);
81
+ }
82
+ while (prop && prop.slice(-1) === "\\") {
83
+ prop = join([prop.slice(0, -1), segs[++idx] || ""], joinChar, options);
84
+ }
85
+ if (prop in target) {
86
+ if (!isValid(prop, target, options)) {
87
+ return options.default;
88
+ }
89
+ target = target[prop];
90
+ } else {
91
+ let hasProp = false;
92
+ let n = idx + 1;
93
+ while (n < len) {
94
+ prop = join([prop, segs[n++]], joinChar, options);
95
+ if (hasProp = prop in target) {
96
+ if (!isValid(prop, target, options)) {
97
+ return options.default;
98
+ }
99
+ target = target[prop];
100
+ idx = n - 1;
101
+ break;
102
+ }
103
+ }
104
+ if (!hasProp) {
105
+ return options.default;
106
+ }
107
+ }
108
+ } while (++idx < len && isValidObject(target));
109
+ if (idx === len) {
110
+ return target;
111
+ }
112
+ return options.default;
113
+ };
114
+ function join(segs, joinChar, options) {
115
+ if (typeof options.join === "function") {
116
+ return options.join(segs);
117
+ }
118
+ return segs[0] + joinChar + segs[1];
119
+ }
120
+ function split(path2, splitChar, options) {
121
+ if (typeof options.split === "function") {
122
+ return options.split(path2);
123
+ }
124
+ return path2.split(splitChar);
125
+ }
126
+ function isValid(key, target, options) {
127
+ if (typeof options.isValid === "function") {
128
+ return options.isValid(key, target);
129
+ }
130
+ return true;
131
+ }
132
+ function isValidObject(val) {
133
+ return isObject(val) || Array.isArray(val) || typeof val === "function";
134
+ }
135
+ }
136
+ });
137
+
138
+ // ../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js
139
+ var require_is_primitive = __commonJS({
140
+ "../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js"(exports, module) {
141
+ "use strict";
142
+ init_esm_shims();
143
+ module.exports = function isPrimitive(val) {
144
+ if (typeof val === "object") {
145
+ return val === null;
146
+ }
147
+ return typeof val !== "function";
148
+ };
149
+ }
150
+ });
151
+
152
+ // ../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js
153
+ var require_is_plain_object = __commonJS({
154
+ "../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js"(exports, module) {
155
+ "use strict";
156
+ init_esm_shims();
157
+ var isObject = require_isobject();
158
+ function isObjectObject(o) {
159
+ return isObject(o) === true && Object.prototype.toString.call(o) === "[object Object]";
160
+ }
161
+ module.exports = function isPlainObject(o) {
162
+ var ctor, prot;
163
+ if (isObjectObject(o) === false) return false;
164
+ ctor = o.constructor;
165
+ if (typeof ctor !== "function") return false;
166
+ prot = ctor.prototype;
167
+ if (isObjectObject(prot) === false) return false;
168
+ if (prot.hasOwnProperty("isPrototypeOf") === false) {
169
+ return false;
170
+ }
171
+ return true;
172
+ };
173
+ }
174
+ });
175
+
176
+ // ../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js
177
+ var require_set_value = __commonJS({
178
+ "../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js"(exports, module) {
179
+ "use strict";
180
+ init_esm_shims();
181
+ var { deleteProperty } = Reflect;
182
+ var isPrimitive = require_is_primitive();
183
+ var isPlainObject = require_is_plain_object();
184
+ var isObject = (value) => {
185
+ return typeof value === "object" && value !== null || typeof value === "function";
186
+ };
187
+ var isUnsafeKey = (key) => {
188
+ return key === "__proto__" || key === "constructor" || key === "prototype";
189
+ };
190
+ var validateKey = (key) => {
191
+ if (!isPrimitive(key)) {
192
+ throw new TypeError("Object keys must be strings or symbols");
193
+ }
194
+ if (isUnsafeKey(key)) {
195
+ throw new Error(`Cannot set unsafe key: "${key}"`);
196
+ }
197
+ };
198
+ var toStringKey = (input) => {
199
+ return Array.isArray(input) ? input.flat().map(String).join(",") : input;
200
+ };
201
+ var createMemoKey = (input, options) => {
202
+ if (typeof input !== "string" || !options) return input;
203
+ let key = input + ";";
204
+ if (options.arrays !== void 0) key += `arrays=${options.arrays};`;
205
+ if (options.separator !== void 0) key += `separator=${options.separator};`;
206
+ if (options.split !== void 0) key += `split=${options.split};`;
207
+ if (options.merge !== void 0) key += `merge=${options.merge};`;
208
+ if (options.preservePaths !== void 0) key += `preservePaths=${options.preservePaths};`;
209
+ return key;
210
+ };
211
+ var memoize = (input, options, fn) => {
212
+ const key = toStringKey(options ? createMemoKey(input, options) : input);
213
+ validateKey(key);
214
+ const value = setValue.cache.get(key) || fn();
215
+ setValue.cache.set(key, value);
216
+ return value;
217
+ };
218
+ var splitString = (input, options = {}) => {
219
+ const sep = options.separator || ".";
220
+ const preserve = sep === "/" ? false : options.preservePaths;
221
+ if (typeof input === "string" && preserve !== false && /\//.test(input)) {
222
+ return [input];
223
+ }
224
+ const parts = [];
225
+ let part = "";
226
+ const push = (part2) => {
227
+ let number;
228
+ if (part2.trim() !== "" && Number.isInteger(number = Number(part2))) {
229
+ parts.push(number);
230
+ } else {
231
+ parts.push(part2);
232
+ }
233
+ };
234
+ for (let i = 0; i < input.length; i++) {
235
+ const value = input[i];
236
+ if (value === "\\") {
237
+ part += input[++i];
238
+ continue;
239
+ }
240
+ if (value === sep) {
241
+ push(part);
242
+ part = "";
243
+ continue;
244
+ }
245
+ part += value;
246
+ }
247
+ if (part) {
248
+ push(part);
249
+ }
250
+ return parts;
251
+ };
252
+ var split = (input, options) => {
253
+ if (options && typeof options.split === "function") return options.split(input);
254
+ if (typeof input === "symbol") return [input];
255
+ if (Array.isArray(input)) return input;
256
+ return memoize(input, options, () => splitString(input, options));
257
+ };
258
+ var assignProp = (obj, prop, value, options) => {
259
+ validateKey(prop);
260
+ if (value === void 0) {
261
+ deleteProperty(obj, prop);
262
+ } else if (options && options.merge) {
263
+ const merge = options.merge === "function" ? options.merge : Object.assign;
264
+ if (merge && isPlainObject(obj[prop]) && isPlainObject(value)) {
265
+ obj[prop] = merge(obj[prop], value);
266
+ } else {
267
+ obj[prop] = value;
268
+ }
269
+ } else {
270
+ obj[prop] = value;
271
+ }
272
+ return obj;
273
+ };
274
+ var setValue = (target, path2, value, options) => {
275
+ if (!path2 || !isObject(target)) return target;
276
+ const keys = split(path2, options);
277
+ let obj = target;
278
+ for (let i = 0; i < keys.length; i++) {
279
+ const key = keys[i];
280
+ const next = keys[i + 1];
281
+ validateKey(key);
282
+ if (next === void 0) {
283
+ assignProp(obj, key, value, options);
284
+ break;
285
+ }
286
+ if (typeof next === "number" && !Array.isArray(obj[key])) {
287
+ obj = obj[key] = [];
288
+ continue;
289
+ }
290
+ if (!isObject(obj[key])) {
291
+ obj[key] = {};
292
+ }
293
+ obj = obj[key];
294
+ }
295
+ return target;
296
+ };
297
+ setValue.split = split;
298
+ setValue.cache = /* @__PURE__ */ new Map();
299
+ setValue.clear = () => {
300
+ setValue.cache = /* @__PURE__ */ new Map();
301
+ };
302
+ module.exports = setValue;
303
+ }
304
+ });
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
+ // src/monorepo/git.ts
333
+ init_esm_shims();
334
+ var import_get_value = __toESM(require_get_value(), 1);
335
+ import gitUrlParse from "git-url-parse";
336
+ import { simpleGit } from "simple-git";
337
+ var GitClient = class {
338
+ client;
339
+ #config;
340
+ constructor(options = {}) {
341
+ this.client = simpleGit(options);
342
+ }
343
+ listConfig() {
344
+ return this.client.listConfig();
345
+ }
346
+ async init() {
347
+ const listConfig = await this.listConfig();
348
+ this.#config = listConfig.all;
349
+ return this.#config;
350
+ }
351
+ async getConfig() {
352
+ if (this.#config) {
353
+ return this.#config;
354
+ } else {
355
+ return await this.init();
356
+ }
357
+ }
358
+ async getGitUrl() {
359
+ const config = await this.getConfig();
360
+ const x = (0, import_get_value.default)(config, "remote.origin.url");
361
+ if (x) {
362
+ return gitUrlParse(x);
363
+ }
364
+ }
365
+ async getRepoName() {
366
+ const url = await this.getGitUrl();
367
+ if (url) {
368
+ return `${url.owner}/${url.name}`;
369
+ }
370
+ }
371
+ async getUser() {
372
+ const config = await this.getConfig();
373
+ const name2 = (0, import_get_value.default)(config, "user.name");
374
+ const email = (0, import_get_value.default)(config, "user.email");
375
+ return {
376
+ name: name2,
377
+ email
378
+ };
379
+ }
380
+ };
381
+
382
+ // src/scripts.ts
383
+ init_esm_shims();
384
+ var scripts = {
385
+ "script:init": "monorepo init",
386
+ "script:sync": "monorepo sync",
387
+ "script:clean": "monorepo clean",
388
+ "script:mirror": "monorepo mirror"
389
+ };
390
+ var scriptsEntries = Object.entries(scripts);
391
+
392
+ // src/targets.ts
393
+ init_esm_shims();
394
+ function getAssetTargets(raw) {
395
+ const list = [
396
+ ".changeset",
397
+ ".husky",
398
+ ".vscode",
399
+ ".editorconfig",
400
+ ".gitattributes",
401
+ ".gitignore",
402
+ ".npmrc",
403
+ "commitlint.config.ts",
404
+ "eslint.config.js",
405
+ "lint-staged.config.js",
406
+ "stylelint.config.js",
407
+ "package.json",
408
+ // pnpm
409
+ "pnpm-workspace.yaml",
410
+ // base tsconfig
411
+ "tsconfig.json",
412
+ // turbo
413
+ "turbo.json",
414
+ // vitest
415
+ "vitest.workspace.ts",
416
+ // #region docker
417
+ "Dockerfile",
418
+ ".dockerignore"
419
+ // #endregion
420
+ ];
421
+ if (!raw) {
422
+ list.push(".github", "LICENSE", "renovate.json", "SECURITY.md", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "netlify.toml");
423
+ }
424
+ return list;
425
+ }
426
+
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
+ // src/lib.ts
461
+ var queue = new PQueue({ concurrency: 1 });
462
+ var __filename2 = fileURLToPath(import.meta.url);
463
+ var __dirname2 = path.dirname(__filename2);
464
+ var assetsDir = path.join(__dirname2, "../assets");
465
+ var templatesDir = path.join(__dirname2, "../templates");
466
+ var cwd = process.cwd();
467
+ function isWorkspace(version2) {
468
+ if (typeof version2 === "string") {
469
+ return version2.startsWith("workspace:");
470
+ }
471
+ return false;
472
+ }
473
+ function setPkgJson(sourcePkgJson, targetPkgJson) {
474
+ const packageManager = (0, import_get_value2.default)(sourcePkgJson, "packageManager", { default: "" });
475
+ const deps = (0, import_get_value2.default)(sourcePkgJson, "dependencies", { default: {} });
476
+ const devDeps = (0, import_get_value2.default)(sourcePkgJson, "devDependencies", { default: {} });
477
+ const targetDeps = (0, import_get_value2.default)(targetPkgJson, "dependencies", { default: {} });
478
+ const targetDevDeps = (0, import_get_value2.default)(targetPkgJson, "devDependencies", { default: {} });
479
+ (0, import_set_value.default)(targetPkgJson, "packageManager", packageManager);
480
+ Object.entries(deps).forEach((x) => {
481
+ if (!isWorkspace(targetDeps[x[0]])) {
482
+ (0, import_set_value.default)(targetPkgJson, `dependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
483
+ }
484
+ });
485
+ Object.entries(devDeps).forEach((x) => {
486
+ if (x[0] === name) {
487
+ (0, import_set_value.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, `^${version}`, { preservePaths: false });
488
+ } else {
489
+ if (!isWorkspace(targetDevDeps[x[0]])) {
490
+ (0, import_set_value.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
491
+ }
492
+ }
493
+ });
494
+ for (const [k, v] of scriptsEntries) {
495
+ (0, import_set_value.default)(targetPkgJson, `scripts.${k}`, v);
496
+ }
497
+ }
498
+ function confirmOverwrite(filename) {
499
+ return confirm({ message: `${pc.greenBright(filename)} \u6587\u4EF6\u5185\u5BB9\u53D1\u751F\u6539\u53D8,\u662F\u5426\u8986\u76D6?`, default: false });
500
+ }
501
+ async function upgradeMonorepo(opts) {
502
+ const { outDir = "", raw, interactive } = opts;
503
+ const absOutDir = path.isAbsolute(outDir) ? outDir : path.join(cwd, outDir);
504
+ const gitClient = new GitClient({
505
+ baseDir: cwd
506
+ });
507
+ const repoName = await gitClient.getRepoName();
508
+ let targets = getAssetTargets(raw);
509
+ if (interactive) {
510
+ targets = await checkbox({
511
+ message: "\u9009\u62E9\u4F60\u9700\u8981\u7684\u6587\u4EF6",
512
+ choices: targets.map((x) => {
513
+ return {
514
+ value: x,
515
+ checked: true
516
+ };
517
+ })
518
+ });
519
+ }
520
+ const regexpArr = targets.map((x) => {
521
+ return new RegExp(`^${escapeStringRegexp(x)}`);
522
+ });
523
+ for await (const file of klaw(assetsDir, {
524
+ filter(p) {
525
+ const str = path.relative(assetsDir, p);
526
+ return isMatch(str, regexpArr);
527
+ }
528
+ })) {
529
+ await queue.add(async () => {
530
+ if (file.stats.isFile()) {
531
+ const relPath = path.relative(assetsDir, file.path);
532
+ const targetPath = path.resolve(absOutDir, relPath);
533
+ const targetIsExisted = await fs.exists(targetPath);
534
+ async function overwriteOrCopy(target) {
535
+ let isOverwrite = true;
536
+ if (targetIsExisted) {
537
+ const src = await fs.readFile(file.path);
538
+ const dest = target ?? await fs.readFile(targetPath);
539
+ if (await isFileChanged(src, dest)) {
540
+ isOverwrite = await confirmOverwrite(relPath);
541
+ }
542
+ }
543
+ return isOverwrite;
544
+ }
545
+ if (relPath === "package.json") {
546
+ const sourcePath = file.path;
547
+ if (targetIsExisted) {
548
+ const sourcePkgJson = await fs.readJson(sourcePath);
549
+ const targetPkgJson = await fs.readJson(targetPath);
550
+ setPkgJson(sourcePkgJson, targetPkgJson);
551
+ const data = JSON.stringify(targetPkgJson, void 0, 2);
552
+ await fs.writeFile(targetPath, `${data}
553
+ `, "utf8");
554
+ logger.success(targetPath);
555
+ }
556
+ } else if (relPath === ".changeset/config.json" && repoName) {
557
+ const changesetJson = await fs.readJson(file.path);
558
+ (0, import_set_value.default)(changesetJson, "changelog.1.repo", repoName);
559
+ const data = JSON.stringify(changesetJson, void 0, 2);
560
+ if (await overwriteOrCopy(data)) {
561
+ await fs.ensureDir(path.dirname(targetPath));
562
+ await fs.writeFile(targetPath, `${data}
563
+ `, "utf8");
564
+ logger.success(targetPath);
565
+ }
566
+ } else {
567
+ if (await overwriteOrCopy()) {
568
+ await fs.copy(
569
+ file.path,
570
+ targetPath
571
+ );
572
+ logger.success(targetPath);
573
+ }
574
+ }
575
+ }
576
+ });
577
+ }
578
+ }
579
+ async function createNewProject(name2) {
580
+ const defaultTemplate = "bar";
581
+ const targetTemplate = name2 ?? defaultTemplate;
582
+ await fs.copy(path.join(templatesDir, defaultTemplate), path.join(cwd, targetTemplate));
583
+ logger.success(`${targetTemplate} \u9879\u76EE\u521B\u5EFA\u6210\u529F\uFF01`);
584
+ }
585
+
586
+ export {
587
+ __toESM,
588
+ name,
589
+ version,
590
+ init_esm_shims,
591
+ require_set_value,
592
+ logger,
593
+ GitClient,
594
+ setPkgJson,
595
+ upgradeMonorepo,
596
+ createNewProject
597
+ };
598
+ /*! Bundled license information:
599
+
600
+ isobject/index.js:
601
+ (*!
602
+ * isobject <https://github.com/jonschlinkert/isobject>
603
+ *
604
+ * Copyright (c) 2014-2017, Jon Schlinkert.
605
+ * Released under the MIT License.
606
+ *)
607
+
608
+ get-value/index.js:
609
+ (*!
610
+ * get-value <https://github.com/jonschlinkert/get-value>
611
+ *
612
+ * Copyright (c) 2014-2018, Jon Schlinkert.
613
+ * Released under the MIT License.
614
+ *)
615
+
616
+ is-primitive/index.js:
617
+ (*!
618
+ * is-primitive <https://github.com/jonschlinkert/is-primitive>
619
+ *
620
+ * Copyright (c) 2014-present, Jon Schlinkert.
621
+ * Released under the MIT License.
622
+ *)
623
+
624
+ is-plain-object/index.js:
625
+ (*!
626
+ * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
627
+ *
628
+ * Copyright (c) 2014-2017, Jon Schlinkert.
629
+ * Released under the MIT License.
630
+ *)
631
+
632
+ set-value/index.js:
633
+ (*!
634
+ * set-value <https://github.com/jonschlinkert/set-value>
635
+ *
636
+ * Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
637
+ * Released under the MIT License.
638
+ *)
639
+ */