@icebreakers/monorepo 0.1.2 → 0.1.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.
- package/assets/netlify.toml +11 -0
- package/assets/package.json +8 -12
- package/assets/tsconfig.json +1 -0
- package/dist/{chunk-LKAY3H44.js → chunk-FGKUZK2R.js} +120 -35
- package/dist/cli.cjs +132 -40
- package/dist/cli.js +12 -5
- package/dist/index.cjs +122 -36
- package/dist/index.js +1 -1
- package/package.json +6 -3
package/assets/package.json
CHANGED
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"version": "0.0.0",
|
|
5
5
|
"private": true,
|
|
6
|
-
"
|
|
7
|
-
"apps/*",
|
|
8
|
-
"packages/*"
|
|
9
|
-
],
|
|
10
|
-
"packageManager": "pnpm@9.7.1",
|
|
6
|
+
"packageManager": "pnpm@9.8.0",
|
|
11
7
|
"engines": {
|
|
12
8
|
"node": ">=20.0.0"
|
|
13
9
|
},
|
|
@@ -30,33 +26,33 @@
|
|
|
30
26
|
"@commitlint/config-conventional": "^19.2.2",
|
|
31
27
|
"@commitlint/prompt-cli": "^19.4.0",
|
|
32
28
|
"@commitlint/types": "^19.0.3",
|
|
33
|
-
"@icebreakers/eslint-config": "^0.3.
|
|
29
|
+
"@icebreakers/eslint-config": "^0.3.23",
|
|
34
30
|
"@types/fs-extra": "^11.0.4",
|
|
35
31
|
"@types/get-value": "^3.0.5",
|
|
36
32
|
"@types/klaw": "^3.0.6",
|
|
37
33
|
"@types/lint-staged": "^13.3.0",
|
|
38
34
|
"@types/lodash": "^4.17.7",
|
|
39
35
|
"@types/lodash-es": "^4.17.12",
|
|
40
|
-
"@types/node": "^22.
|
|
36
|
+
"@types/node": "^22.5.0",
|
|
41
37
|
"@types/set-value": "^4.0.3",
|
|
42
38
|
"@vitest/coverage-v8": "^2.0.5",
|
|
43
39
|
"ci-info": "^4.0.0",
|
|
44
40
|
"defu": "^6.1.4",
|
|
45
|
-
"eslint": "^9.9.
|
|
41
|
+
"eslint": "^9.9.1",
|
|
46
42
|
"fs-extra": "^11.2.0",
|
|
47
43
|
"get-value": "^3.0.1",
|
|
48
|
-
"husky": "^9.1.
|
|
44
|
+
"husky": "^9.1.5",
|
|
49
45
|
"klaw": "^4.1.0",
|
|
50
46
|
"lint-staged": "^15.2.8",
|
|
51
47
|
"lodash": "^4.17.21",
|
|
52
48
|
"lodash-es": "^4.17.21",
|
|
53
49
|
"only-allow": "^1.2.1",
|
|
54
50
|
"pathe": "^1.1.2",
|
|
55
|
-
"pkg-types": "^1.
|
|
51
|
+
"pkg-types": "^1.2.0",
|
|
56
52
|
"set-value": "^4.1.0",
|
|
57
|
-
"tslib": "^2.
|
|
53
|
+
"tslib": "^2.7.0",
|
|
58
54
|
"tsup": "^8.2.4",
|
|
59
|
-
"tsx": "^4.
|
|
55
|
+
"tsx": "^4.18.0",
|
|
60
56
|
"turbo": "^2.0.14",
|
|
61
57
|
"typescript": "^5.5.4",
|
|
62
58
|
"unbuild": "^2.0.0",
|
package/assets/tsconfig.json
CHANGED
|
@@ -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.2.4_jiti@1.21.6_postcss@8.4.41_tsx@4.
|
|
30
|
+
// ../../node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.41_tsx@4.18.0_typescript@5.5.4_yaml@2.5.0/node_modules/tsup/assets/esm_shims.js
|
|
31
31
|
var init_esm_shims = __esm({
|
|
32
|
-
"../../node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.41_tsx@4.
|
|
32
|
+
"../../node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.41_tsx@4.18.0_typescript@5.5.4_yaml@2.5.0/node_modules/tsup/assets/esm_shims.js"() {
|
|
33
33
|
"use strict";
|
|
34
34
|
}
|
|
35
35
|
});
|
|
@@ -310,10 +310,32 @@ init_esm_shims();
|
|
|
310
310
|
init_esm_shims();
|
|
311
311
|
var import_get_value2 = __toESM(require_get_value(), 1);
|
|
312
312
|
var import_set_value = __toESM(require_set_value(), 1);
|
|
313
|
+
import { fileURLToPath } from "node:url";
|
|
313
314
|
import process from "node:process";
|
|
314
315
|
import path from "pathe";
|
|
315
316
|
import fs from "fs-extra";
|
|
316
317
|
import klaw from "klaw";
|
|
318
|
+
import PQueue from "p-queue";
|
|
319
|
+
import checkbox from "@inquirer/checkbox";
|
|
320
|
+
|
|
321
|
+
// src/logger.ts
|
|
322
|
+
init_esm_shims();
|
|
323
|
+
import { createConsola } from "consola";
|
|
324
|
+
var logger = createConsola();
|
|
325
|
+
|
|
326
|
+
// src/utils.ts
|
|
327
|
+
init_esm_shims();
|
|
328
|
+
function escapeStringRegexp(str) {
|
|
329
|
+
return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
330
|
+
}
|
|
331
|
+
function isMatch(str, arr) {
|
|
332
|
+
for (const reg of arr) {
|
|
333
|
+
if (reg.test(str)) {
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
317
339
|
|
|
318
340
|
// src/git.ts
|
|
319
341
|
init_esm_shims();
|
|
@@ -338,56 +360,119 @@ var GitClient = class {
|
|
|
338
360
|
}
|
|
339
361
|
};
|
|
340
362
|
|
|
363
|
+
// src/targets.ts
|
|
364
|
+
init_esm_shims();
|
|
365
|
+
function getTargets(raw) {
|
|
366
|
+
const list = [
|
|
367
|
+
".changeset",
|
|
368
|
+
".husky",
|
|
369
|
+
".vscode",
|
|
370
|
+
".editorconfig",
|
|
371
|
+
".gitattributes",
|
|
372
|
+
".gitignore",
|
|
373
|
+
".npmrc",
|
|
374
|
+
"commitlint.config.ts",
|
|
375
|
+
"eslint.config.js",
|
|
376
|
+
"lint-staged.config.js",
|
|
377
|
+
"package.json",
|
|
378
|
+
// pnpm
|
|
379
|
+
"pnpm-workspace.yaml",
|
|
380
|
+
// base tsconfig
|
|
381
|
+
"tsconfig.json",
|
|
382
|
+
// turbo
|
|
383
|
+
"turbo.json",
|
|
384
|
+
// vitest
|
|
385
|
+
"vitest.workspace.ts",
|
|
386
|
+
// #region docker
|
|
387
|
+
"Dockerfile",
|
|
388
|
+
".dockerignore"
|
|
389
|
+
// #endregion
|
|
390
|
+
];
|
|
391
|
+
if (!raw) {
|
|
392
|
+
list.push(".github", "LICENSE", "renovate.json", "SECURITY.md", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "netlify.toml");
|
|
393
|
+
}
|
|
394
|
+
return list;
|
|
395
|
+
}
|
|
396
|
+
|
|
341
397
|
// src/lib.ts
|
|
342
|
-
var
|
|
398
|
+
var queue = new PQueue({ concurrency: 1 });
|
|
399
|
+
var __filename2 = fileURLToPath(import.meta.url);
|
|
400
|
+
var __dirname2 = path.dirname(__filename2);
|
|
401
|
+
var assetsDir = path.join(__dirname2, "../assets");
|
|
343
402
|
var cwd = process.cwd();
|
|
344
403
|
async function main(opts) {
|
|
345
|
-
const { outDir = "" } = opts;
|
|
404
|
+
const { outDir = "", raw, interactive } = opts;
|
|
346
405
|
const absOutDir = path.isAbsolute(outDir) ? outDir : path.join(cwd, outDir);
|
|
347
406
|
const gitClient = new GitClient({
|
|
348
407
|
baseDir: cwd
|
|
349
408
|
});
|
|
350
409
|
const repoName = await gitClient.getRepoName();
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
410
|
+
let targets = getTargets(raw);
|
|
411
|
+
if (interactive) {
|
|
412
|
+
targets = await checkbox({
|
|
413
|
+
message: "\u9009\u62E9\u4F60\u9700\u8981\u7684\u6587\u4EF6",
|
|
414
|
+
choices: targets.map((x) => {
|
|
415
|
+
return {
|
|
416
|
+
value: x,
|
|
417
|
+
checked: true
|
|
418
|
+
};
|
|
419
|
+
})
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
const regexpArr = targets.map((x) => {
|
|
423
|
+
return new RegExp(`^${escapeStringRegexp(x)}`);
|
|
424
|
+
});
|
|
425
|
+
for await (const file of klaw(assetsDir, {
|
|
426
|
+
filter(p) {
|
|
427
|
+
const str = path.relative(assetsDir, p);
|
|
428
|
+
return isMatch(str, regexpArr);
|
|
429
|
+
}
|
|
430
|
+
})) {
|
|
431
|
+
await queue.add(async () => {
|
|
432
|
+
if (file.stats.isFile()) {
|
|
433
|
+
const relPath = path.relative(assetsDir, file.path);
|
|
434
|
+
const targetPath = path.resolve(absOutDir, relPath);
|
|
435
|
+
if (relPath === "package.json") {
|
|
436
|
+
const sourcePath = file.path;
|
|
437
|
+
if (await fs.exists(targetPath) && await fs.exists(sourcePath)) {
|
|
438
|
+
const sourcePkgJson = await fs.readJson(sourcePath);
|
|
439
|
+
const targetPkgJson = await fs.readJson(targetPath);
|
|
440
|
+
const deps = (0, import_get_value2.default)(sourcePkgJson, "dependencies", { default: {} });
|
|
441
|
+
const devDeps = (0, import_get_value2.default)(sourcePkgJson, "devDependencies", { default: {} });
|
|
442
|
+
Object.entries(deps).forEach((x) => {
|
|
443
|
+
(0, import_set_value.default)(targetPkgJson, `dependencies.${x[0]}`, x[1], { preservePaths: false });
|
|
444
|
+
});
|
|
445
|
+
Object.entries(devDeps).forEach((x) => {
|
|
446
|
+
(0, import_set_value.default)(targetPkgJson, `devDependencies.${x[0]}`, x[1], { preservePaths: false });
|
|
447
|
+
});
|
|
448
|
+
await fs.writeJson(targetPath, targetPkgJson, {
|
|
449
|
+
spaces: 2
|
|
450
|
+
});
|
|
451
|
+
logger.success(targetPath);
|
|
452
|
+
}
|
|
453
|
+
} else if (relPath === ".changeset/config.json" && repoName && await fs.exists(file.path)) {
|
|
454
|
+
const changesetJson = await fs.readJson(file.path);
|
|
455
|
+
(0, import_set_value.default)(changesetJson, "changelog.1.repo", repoName);
|
|
456
|
+
await fs.ensureDir(path.dirname(targetPath));
|
|
457
|
+
await fs.writeJson(targetPath, changesetJson, {
|
|
369
458
|
spaces: 2
|
|
370
459
|
});
|
|
460
|
+
logger.success(targetPath);
|
|
461
|
+
} else {
|
|
462
|
+
await fs.copy(
|
|
463
|
+
file.path,
|
|
464
|
+
targetPath
|
|
465
|
+
);
|
|
466
|
+
logger.success(targetPath);
|
|
371
467
|
}
|
|
372
|
-
} else if (relPath === ".changeset/config.json" && repoName && await fs.exists(file.path)) {
|
|
373
|
-
const changesetJson = await fs.readJson(file.path);
|
|
374
|
-
(0, import_set_value.default)(changesetJson, "changelog.1.repo", repoName);
|
|
375
|
-
await fs.ensureDir(path.dirname(targetPath));
|
|
376
|
-
await fs.writeJson(targetPath, changesetJson, {
|
|
377
|
-
spaces: 2
|
|
378
|
-
});
|
|
379
|
-
} else {
|
|
380
|
-
await fs.copy(
|
|
381
|
-
file.path,
|
|
382
|
-
path.resolve(absOutDir, relPath)
|
|
383
|
-
);
|
|
384
468
|
}
|
|
385
|
-
}
|
|
469
|
+
});
|
|
386
470
|
}
|
|
387
471
|
}
|
|
388
472
|
|
|
389
473
|
export {
|
|
390
474
|
init_esm_shims,
|
|
475
|
+
logger,
|
|
391
476
|
main
|
|
392
477
|
};
|
|
393
478
|
/*! Bundled license information:
|
package/dist/cli.cjs
CHANGED
|
@@ -28,10 +28,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
mod
|
|
29
29
|
));
|
|
30
30
|
|
|
31
|
-
// ../../node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.41_tsx@4.
|
|
31
|
+
// ../../node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.41_tsx@4.18.0_typescript@5.5.4_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js
|
|
32
|
+
var getImportMetaUrl, importMetaUrl;
|
|
32
33
|
var init_cjs_shims = __esm({
|
|
33
|
-
"../../node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.41_tsx@4.
|
|
34
|
+
"../../node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.41_tsx@4.18.0_typescript@5.5.4_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js"() {
|
|
34
35
|
"use strict";
|
|
36
|
+
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
37
|
+
importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
35
38
|
}
|
|
36
39
|
});
|
|
37
40
|
|
|
@@ -306,20 +309,45 @@ var require_set_value = __commonJS({
|
|
|
306
309
|
|
|
307
310
|
// src/cli.ts
|
|
308
311
|
init_cjs_shims();
|
|
312
|
+
|
|
313
|
+
// src/program.ts
|
|
314
|
+
init_cjs_shims();
|
|
309
315
|
var import_commander = require("commander");
|
|
310
316
|
|
|
311
317
|
// package.json
|
|
312
318
|
var name = "@icebreakers/monorepo";
|
|
313
|
-
var version = "0.1.
|
|
319
|
+
var version = "0.1.4";
|
|
320
|
+
|
|
321
|
+
// src/logger.ts
|
|
322
|
+
init_cjs_shims();
|
|
323
|
+
var import_consola = require("consola");
|
|
324
|
+
var logger = (0, import_consola.createConsola)();
|
|
314
325
|
|
|
315
326
|
// src/lib.ts
|
|
316
327
|
init_cjs_shims();
|
|
328
|
+
var import_node_url = require("url");
|
|
317
329
|
var import_node_process = __toESM(require("process"), 1);
|
|
318
330
|
var import_pathe = __toESM(require("pathe"), 1);
|
|
319
331
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
320
332
|
var import_get_value2 = __toESM(require_get_value(), 1);
|
|
321
333
|
var import_set_value = __toESM(require_set_value(), 1);
|
|
322
334
|
var import_klaw = __toESM(require("klaw"), 1);
|
|
335
|
+
var import_p_queue = __toESM(require("p-queue"), 1);
|
|
336
|
+
var import_checkbox = __toESM(require("@inquirer/checkbox"), 1);
|
|
337
|
+
|
|
338
|
+
// src/utils.ts
|
|
339
|
+
init_cjs_shims();
|
|
340
|
+
function escapeStringRegexp(str) {
|
|
341
|
+
return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
342
|
+
}
|
|
343
|
+
function isMatch(str, arr) {
|
|
344
|
+
for (const reg of arr) {
|
|
345
|
+
if (reg.test(str)) {
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
323
351
|
|
|
324
352
|
// src/git.ts
|
|
325
353
|
init_cjs_shims();
|
|
@@ -344,62 +372,126 @@ var GitClient = class {
|
|
|
344
372
|
}
|
|
345
373
|
};
|
|
346
374
|
|
|
375
|
+
// src/targets.ts
|
|
376
|
+
init_cjs_shims();
|
|
377
|
+
function getTargets(raw) {
|
|
378
|
+
const list = [
|
|
379
|
+
".changeset",
|
|
380
|
+
".husky",
|
|
381
|
+
".vscode",
|
|
382
|
+
".editorconfig",
|
|
383
|
+
".gitattributes",
|
|
384
|
+
".gitignore",
|
|
385
|
+
".npmrc",
|
|
386
|
+
"commitlint.config.ts",
|
|
387
|
+
"eslint.config.js",
|
|
388
|
+
"lint-staged.config.js",
|
|
389
|
+
"package.json",
|
|
390
|
+
// pnpm
|
|
391
|
+
"pnpm-workspace.yaml",
|
|
392
|
+
// base tsconfig
|
|
393
|
+
"tsconfig.json",
|
|
394
|
+
// turbo
|
|
395
|
+
"turbo.json",
|
|
396
|
+
// vitest
|
|
397
|
+
"vitest.workspace.ts",
|
|
398
|
+
// #region docker
|
|
399
|
+
"Dockerfile",
|
|
400
|
+
".dockerignore"
|
|
401
|
+
// #endregion
|
|
402
|
+
];
|
|
403
|
+
if (!raw) {
|
|
404
|
+
list.push(".github", "LICENSE", "renovate.json", "SECURITY.md", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "netlify.toml");
|
|
405
|
+
}
|
|
406
|
+
return list;
|
|
407
|
+
}
|
|
408
|
+
|
|
347
409
|
// src/lib.ts
|
|
348
|
-
var
|
|
349
|
-
var
|
|
410
|
+
var queue = new import_p_queue.default({ concurrency: 1 });
|
|
411
|
+
var __filename2 = (0, import_node_url.fileURLToPath)(importMetaUrl);
|
|
412
|
+
var __dirname = import_pathe.default.dirname(__filename2);
|
|
413
|
+
var assetsDir = import_pathe.default.join(__dirname, "../assets");
|
|
350
414
|
var cwd = import_node_process.default.cwd();
|
|
351
415
|
async function main(opts) {
|
|
352
|
-
const { outDir = "" } = opts;
|
|
416
|
+
const { outDir = "", raw, interactive } = opts;
|
|
353
417
|
const absOutDir = import_pathe.default.isAbsolute(outDir) ? outDir : import_pathe.default.join(cwd, outDir);
|
|
354
418
|
const gitClient = new GitClient({
|
|
355
419
|
baseDir: cwd
|
|
356
420
|
});
|
|
357
421
|
const repoName = await gitClient.getRepoName();
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
422
|
+
let targets = getTargets(raw);
|
|
423
|
+
if (interactive) {
|
|
424
|
+
targets = await (0, import_checkbox.default)({
|
|
425
|
+
message: "\u9009\u62E9\u4F60\u9700\u8981\u7684\u6587\u4EF6",
|
|
426
|
+
choices: targets.map((x) => {
|
|
427
|
+
return {
|
|
428
|
+
value: x,
|
|
429
|
+
checked: true
|
|
430
|
+
};
|
|
431
|
+
})
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
const regexpArr = targets.map((x) => {
|
|
435
|
+
return new RegExp(`^${escapeStringRegexp(x)}`);
|
|
436
|
+
});
|
|
437
|
+
for await (const file of (0, import_klaw.default)(assetsDir, {
|
|
438
|
+
filter(p) {
|
|
439
|
+
const str = import_pathe.default.relative(assetsDir, p);
|
|
440
|
+
return isMatch(str, regexpArr);
|
|
441
|
+
}
|
|
442
|
+
})) {
|
|
443
|
+
await queue.add(async () => {
|
|
444
|
+
if (file.stats.isFile()) {
|
|
445
|
+
const relPath = import_pathe.default.relative(assetsDir, file.path);
|
|
446
|
+
const targetPath = import_pathe.default.resolve(absOutDir, relPath);
|
|
447
|
+
if (relPath === "package.json") {
|
|
448
|
+
const sourcePath = file.path;
|
|
449
|
+
if (await import_fs_extra.default.exists(targetPath) && await import_fs_extra.default.exists(sourcePath)) {
|
|
450
|
+
const sourcePkgJson = await import_fs_extra.default.readJson(sourcePath);
|
|
451
|
+
const targetPkgJson = await import_fs_extra.default.readJson(targetPath);
|
|
452
|
+
const deps = (0, import_get_value2.default)(sourcePkgJson, "dependencies", { default: {} });
|
|
453
|
+
const devDeps = (0, import_get_value2.default)(sourcePkgJson, "devDependencies", { default: {} });
|
|
454
|
+
Object.entries(deps).forEach((x) => {
|
|
455
|
+
(0, import_set_value.default)(targetPkgJson, `dependencies.${x[0]}`, x[1], { preservePaths: false });
|
|
456
|
+
});
|
|
457
|
+
Object.entries(devDeps).forEach((x) => {
|
|
458
|
+
(0, import_set_value.default)(targetPkgJson, `devDependencies.${x[0]}`, x[1], { preservePaths: false });
|
|
459
|
+
});
|
|
460
|
+
await import_fs_extra.default.writeJson(targetPath, targetPkgJson, {
|
|
461
|
+
spaces: 2
|
|
462
|
+
});
|
|
463
|
+
logger.success(targetPath);
|
|
464
|
+
}
|
|
465
|
+
} else if (relPath === ".changeset/config.json" && repoName && await import_fs_extra.default.exists(file.path)) {
|
|
466
|
+
const changesetJson = await import_fs_extra.default.readJson(file.path);
|
|
467
|
+
(0, import_set_value.default)(changesetJson, "changelog.1.repo", repoName);
|
|
468
|
+
await import_fs_extra.default.ensureDir(import_pathe.default.dirname(targetPath));
|
|
469
|
+
await import_fs_extra.default.writeJson(targetPath, changesetJson, {
|
|
376
470
|
spaces: 2
|
|
377
471
|
});
|
|
472
|
+
logger.success(targetPath);
|
|
473
|
+
} else {
|
|
474
|
+
await import_fs_extra.default.copy(
|
|
475
|
+
file.path,
|
|
476
|
+
targetPath
|
|
477
|
+
);
|
|
478
|
+
logger.success(targetPath);
|
|
378
479
|
}
|
|
379
|
-
} else if (relPath === ".changeset/config.json" && repoName && await import_fs_extra.default.exists(file.path)) {
|
|
380
|
-
const changesetJson = await import_fs_extra.default.readJson(file.path);
|
|
381
|
-
(0, import_set_value.default)(changesetJson, "changelog.1.repo", repoName);
|
|
382
|
-
await import_fs_extra.default.ensureDir(import_pathe.default.dirname(targetPath));
|
|
383
|
-
await import_fs_extra.default.writeJson(targetPath, changesetJson, {
|
|
384
|
-
spaces: 2
|
|
385
|
-
});
|
|
386
|
-
} else {
|
|
387
|
-
await import_fs_extra.default.copy(
|
|
388
|
-
file.path,
|
|
389
|
-
import_pathe.default.resolve(absOutDir, relPath)
|
|
390
|
-
);
|
|
391
480
|
}
|
|
392
|
-
}
|
|
481
|
+
});
|
|
393
482
|
}
|
|
394
483
|
}
|
|
395
484
|
|
|
396
|
-
// src/
|
|
485
|
+
// src/program.ts
|
|
397
486
|
import_commander.program.name(name).version(version);
|
|
398
487
|
import_commander.program.option("-i,--interactive").option("--raw", "raw mode").option("--outDir <dir>", "Output directory").action(async (opts) => {
|
|
399
488
|
await main(opts);
|
|
400
|
-
|
|
489
|
+
logger.success("upgrade @icebreakers/monorepo ok!");
|
|
401
490
|
});
|
|
402
|
-
import_commander.program
|
|
491
|
+
var program_default = import_commander.program;
|
|
492
|
+
|
|
493
|
+
// src/cli.ts
|
|
494
|
+
program_default.parse();
|
|
403
495
|
/*! Bundled license information:
|
|
404
496
|
|
|
405
497
|
isobject/index.js:
|
package/dist/cli.js
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
2
|
init_esm_shims,
|
|
3
|
+
logger,
|
|
3
4
|
main
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FGKUZK2R.js";
|
|
5
6
|
|
|
6
7
|
// src/cli.ts
|
|
7
8
|
init_esm_shims();
|
|
9
|
+
|
|
10
|
+
// src/program.ts
|
|
11
|
+
init_esm_shims();
|
|
8
12
|
import { program } from "commander";
|
|
9
13
|
|
|
10
14
|
// package.json
|
|
11
15
|
var name = "@icebreakers/monorepo";
|
|
12
|
-
var version = "0.1.
|
|
16
|
+
var version = "0.1.4";
|
|
13
17
|
|
|
14
|
-
// src/
|
|
18
|
+
// src/program.ts
|
|
15
19
|
program.name(name).version(version);
|
|
16
20
|
program.option("-i,--interactive").option("--raw", "raw mode").option("--outDir <dir>", "Output directory").action(async (opts) => {
|
|
17
21
|
await main(opts);
|
|
18
|
-
|
|
22
|
+
logger.success("upgrade @icebreakers/monorepo ok!");
|
|
19
23
|
});
|
|
20
|
-
program
|
|
24
|
+
var program_default = program;
|
|
25
|
+
|
|
26
|
+
// src/cli.ts
|
|
27
|
+
program_default.parse();
|
package/dist/index.cjs
CHANGED
|
@@ -33,10 +33,13 @@ 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.2.4_jiti@1.21.6_postcss@8.4.41_tsx@4.
|
|
36
|
+
// ../../node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.41_tsx@4.18.0_typescript@5.5.4_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js
|
|
37
|
+
var getImportMetaUrl, importMetaUrl;
|
|
37
38
|
var init_cjs_shims = __esm({
|
|
38
|
-
"../../node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.41_tsx@4.
|
|
39
|
+
"../../node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.41_tsx@4.18.0_typescript@5.5.4_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js"() {
|
|
39
40
|
"use strict";
|
|
41
|
+
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
42
|
+
importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
40
43
|
}
|
|
41
44
|
});
|
|
42
45
|
|
|
@@ -319,12 +322,34 @@ init_cjs_shims();
|
|
|
319
322
|
|
|
320
323
|
// src/lib.ts
|
|
321
324
|
init_cjs_shims();
|
|
325
|
+
var import_node_url = require("url");
|
|
322
326
|
var import_node_process = __toESM(require("process"), 1);
|
|
323
327
|
var import_pathe = __toESM(require("pathe"), 1);
|
|
324
328
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
325
329
|
var import_get_value2 = __toESM(require_get_value(), 1);
|
|
326
330
|
var import_set_value = __toESM(require_set_value(), 1);
|
|
327
331
|
var import_klaw = __toESM(require("klaw"), 1);
|
|
332
|
+
var import_p_queue = __toESM(require("p-queue"), 1);
|
|
333
|
+
var import_checkbox = __toESM(require("@inquirer/checkbox"), 1);
|
|
334
|
+
|
|
335
|
+
// src/logger.ts
|
|
336
|
+
init_cjs_shims();
|
|
337
|
+
var import_consola = require("consola");
|
|
338
|
+
var logger = (0, import_consola.createConsola)();
|
|
339
|
+
|
|
340
|
+
// src/utils.ts
|
|
341
|
+
init_cjs_shims();
|
|
342
|
+
function escapeStringRegexp(str) {
|
|
343
|
+
return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
344
|
+
}
|
|
345
|
+
function isMatch(str, arr) {
|
|
346
|
+
for (const reg of arr) {
|
|
347
|
+
if (reg.test(str)) {
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
328
353
|
|
|
329
354
|
// src/git.ts
|
|
330
355
|
init_cjs_shims();
|
|
@@ -349,52 +374,113 @@ var GitClient = class {
|
|
|
349
374
|
}
|
|
350
375
|
};
|
|
351
376
|
|
|
377
|
+
// src/targets.ts
|
|
378
|
+
init_cjs_shims();
|
|
379
|
+
function getTargets(raw) {
|
|
380
|
+
const list = [
|
|
381
|
+
".changeset",
|
|
382
|
+
".husky",
|
|
383
|
+
".vscode",
|
|
384
|
+
".editorconfig",
|
|
385
|
+
".gitattributes",
|
|
386
|
+
".gitignore",
|
|
387
|
+
".npmrc",
|
|
388
|
+
"commitlint.config.ts",
|
|
389
|
+
"eslint.config.js",
|
|
390
|
+
"lint-staged.config.js",
|
|
391
|
+
"package.json",
|
|
392
|
+
// pnpm
|
|
393
|
+
"pnpm-workspace.yaml",
|
|
394
|
+
// base tsconfig
|
|
395
|
+
"tsconfig.json",
|
|
396
|
+
// turbo
|
|
397
|
+
"turbo.json",
|
|
398
|
+
// vitest
|
|
399
|
+
"vitest.workspace.ts",
|
|
400
|
+
// #region docker
|
|
401
|
+
"Dockerfile",
|
|
402
|
+
".dockerignore"
|
|
403
|
+
// #endregion
|
|
404
|
+
];
|
|
405
|
+
if (!raw) {
|
|
406
|
+
list.push(".github", "LICENSE", "renovate.json", "SECURITY.md", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "netlify.toml");
|
|
407
|
+
}
|
|
408
|
+
return list;
|
|
409
|
+
}
|
|
410
|
+
|
|
352
411
|
// src/lib.ts
|
|
353
|
-
var
|
|
354
|
-
var
|
|
412
|
+
var queue = new import_p_queue.default({ concurrency: 1 });
|
|
413
|
+
var __filename2 = (0, import_node_url.fileURLToPath)(importMetaUrl);
|
|
414
|
+
var __dirname = import_pathe.default.dirname(__filename2);
|
|
415
|
+
var assetsDir = import_pathe.default.join(__dirname, "../assets");
|
|
355
416
|
var cwd = import_node_process.default.cwd();
|
|
356
417
|
async function main(opts) {
|
|
357
|
-
const { outDir = "" } = opts;
|
|
418
|
+
const { outDir = "", raw, interactive } = opts;
|
|
358
419
|
const absOutDir = import_pathe.default.isAbsolute(outDir) ? outDir : import_pathe.default.join(cwd, outDir);
|
|
359
420
|
const gitClient = new GitClient({
|
|
360
421
|
baseDir: cwd
|
|
361
422
|
});
|
|
362
423
|
const repoName = await gitClient.getRepoName();
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
424
|
+
let targets = getTargets(raw);
|
|
425
|
+
if (interactive) {
|
|
426
|
+
targets = await (0, import_checkbox.default)({
|
|
427
|
+
message: "\u9009\u62E9\u4F60\u9700\u8981\u7684\u6587\u4EF6",
|
|
428
|
+
choices: targets.map((x) => {
|
|
429
|
+
return {
|
|
430
|
+
value: x,
|
|
431
|
+
checked: true
|
|
432
|
+
};
|
|
433
|
+
})
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
const regexpArr = targets.map((x) => {
|
|
437
|
+
return new RegExp(`^${escapeStringRegexp(x)}`);
|
|
438
|
+
});
|
|
439
|
+
for await (const file of (0, import_klaw.default)(assetsDir, {
|
|
440
|
+
filter(p) {
|
|
441
|
+
const str = import_pathe.default.relative(assetsDir, p);
|
|
442
|
+
return isMatch(str, regexpArr);
|
|
443
|
+
}
|
|
444
|
+
})) {
|
|
445
|
+
await queue.add(async () => {
|
|
446
|
+
if (file.stats.isFile()) {
|
|
447
|
+
const relPath = import_pathe.default.relative(assetsDir, file.path);
|
|
448
|
+
const targetPath = import_pathe.default.resolve(absOutDir, relPath);
|
|
449
|
+
if (relPath === "package.json") {
|
|
450
|
+
const sourcePath = file.path;
|
|
451
|
+
if (await import_fs_extra.default.exists(targetPath) && await import_fs_extra.default.exists(sourcePath)) {
|
|
452
|
+
const sourcePkgJson = await import_fs_extra.default.readJson(sourcePath);
|
|
453
|
+
const targetPkgJson = await import_fs_extra.default.readJson(targetPath);
|
|
454
|
+
const deps = (0, import_get_value2.default)(sourcePkgJson, "dependencies", { default: {} });
|
|
455
|
+
const devDeps = (0, import_get_value2.default)(sourcePkgJson, "devDependencies", { default: {} });
|
|
456
|
+
Object.entries(deps).forEach((x) => {
|
|
457
|
+
(0, import_set_value.default)(targetPkgJson, `dependencies.${x[0]}`, x[1], { preservePaths: false });
|
|
458
|
+
});
|
|
459
|
+
Object.entries(devDeps).forEach((x) => {
|
|
460
|
+
(0, import_set_value.default)(targetPkgJson, `devDependencies.${x[0]}`, x[1], { preservePaths: false });
|
|
461
|
+
});
|
|
462
|
+
await import_fs_extra.default.writeJson(targetPath, targetPkgJson, {
|
|
463
|
+
spaces: 2
|
|
464
|
+
});
|
|
465
|
+
logger.success(targetPath);
|
|
466
|
+
}
|
|
467
|
+
} else if (relPath === ".changeset/config.json" && repoName && await import_fs_extra.default.exists(file.path)) {
|
|
468
|
+
const changesetJson = await import_fs_extra.default.readJson(file.path);
|
|
469
|
+
(0, import_set_value.default)(changesetJson, "changelog.1.repo", repoName);
|
|
470
|
+
await import_fs_extra.default.ensureDir(import_pathe.default.dirname(targetPath));
|
|
471
|
+
await import_fs_extra.default.writeJson(targetPath, changesetJson, {
|
|
381
472
|
spaces: 2
|
|
382
473
|
});
|
|
474
|
+
logger.success(targetPath);
|
|
475
|
+
} else {
|
|
476
|
+
await import_fs_extra.default.copy(
|
|
477
|
+
file.path,
|
|
478
|
+
targetPath
|
|
479
|
+
);
|
|
480
|
+
logger.success(targetPath);
|
|
383
481
|
}
|
|
384
|
-
} else if (relPath === ".changeset/config.json" && repoName && await import_fs_extra.default.exists(file.path)) {
|
|
385
|
-
const changesetJson = await import_fs_extra.default.readJson(file.path);
|
|
386
|
-
(0, import_set_value.default)(changesetJson, "changelog.1.repo", repoName);
|
|
387
|
-
await import_fs_extra.default.ensureDir(import_pathe.default.dirname(targetPath));
|
|
388
|
-
await import_fs_extra.default.writeJson(targetPath, changesetJson, {
|
|
389
|
-
spaces: 2
|
|
390
|
-
});
|
|
391
|
-
} else {
|
|
392
|
-
await import_fs_extra.default.copy(
|
|
393
|
-
file.path,
|
|
394
|
-
import_pathe.default.resolve(absOutDir, relPath)
|
|
395
|
-
);
|
|
396
482
|
}
|
|
397
|
-
}
|
|
483
|
+
});
|
|
398
484
|
}
|
|
399
485
|
}
|
|
400
486
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icebreakers/monorepo",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "0.1.4",
|
|
5
|
+
"description": "icebreaker's monorepo config generator",
|
|
6
6
|
"author": "sonofmagic",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/sonofmagic/monorepo-template",
|
|
@@ -24,10 +24,13 @@
|
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
+
"@inquirer/checkbox": "^2.4.7",
|
|
27
28
|
"commander": "^12.1.0",
|
|
29
|
+
"consola": "^3.2.3",
|
|
28
30
|
"fs-extra": "^11.2.0",
|
|
29
|
-
"git-url-parse": "^
|
|
31
|
+
"git-url-parse": "^15.0.0",
|
|
30
32
|
"klaw": "^4.1.0",
|
|
33
|
+
"p-queue": "^8.0.1",
|
|
31
34
|
"pathe": "^1.1.2",
|
|
32
35
|
"simple-git": "^3.25.0"
|
|
33
36
|
},
|