@icebreakers/monorepo 0.4.0 → 0.4.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.
- package/dist/{chunk-GSEOTDU7.js → chunk-XBY6UJ4D.js} +32 -29
- package/dist/cli.cjs +33 -30
- package/dist/cli.js +2 -2
- package/dist/index.cjs +32 -29
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -314,7 +314,7 @@ import process from "node:process";
|
|
|
314
314
|
import { fileURLToPath } from "node:url";
|
|
315
315
|
import checkbox from "@inquirer/checkbox";
|
|
316
316
|
import confirm from "@inquirer/confirm";
|
|
317
|
-
import
|
|
317
|
+
import fs from "fs-extra";
|
|
318
318
|
import klaw from "klaw";
|
|
319
319
|
import PQueue from "p-queue";
|
|
320
320
|
import path from "pathe";
|
|
@@ -378,13 +378,12 @@ var logger = createConsola();
|
|
|
378
378
|
// src/md5.ts
|
|
379
379
|
init_esm_shims();
|
|
380
380
|
import crypto from "node:crypto";
|
|
381
|
-
import fs from "fs-extra";
|
|
382
381
|
function getFileHash(data) {
|
|
383
382
|
const hashSum = crypto.createHash("md5");
|
|
384
383
|
hashSum.update(data);
|
|
385
384
|
return hashSum.digest("hex");
|
|
386
385
|
}
|
|
387
|
-
function
|
|
386
|
+
function isFileChanged(src, dest) {
|
|
388
387
|
try {
|
|
389
388
|
const currentHash = getFileHash(src);
|
|
390
389
|
const previousHash = getFileHash(dest);
|
|
@@ -394,9 +393,6 @@ function hasFileBufferChanged(src, dest) {
|
|
|
394
393
|
return false;
|
|
395
394
|
}
|
|
396
395
|
}
|
|
397
|
-
async function hasFileChanged(src, dest) {
|
|
398
|
-
return hasFileBufferChanged(await fs.readFile(src), await fs.readFile(dest));
|
|
399
|
-
}
|
|
400
396
|
|
|
401
397
|
// src/targets.ts
|
|
402
398
|
init_esm_shims();
|
|
@@ -500,7 +496,7 @@ async function main(opts) {
|
|
|
500
496
|
const removeDirs = ["scripts/monorepo"];
|
|
501
497
|
for (const dir of removeDirs) {
|
|
502
498
|
if (targets.includes(dir)) {
|
|
503
|
-
await
|
|
499
|
+
await fs.remove(path.resolve(absOutDir, dir));
|
|
504
500
|
}
|
|
505
501
|
}
|
|
506
502
|
const regexpArr = targets.map((x) => {
|
|
@@ -516,35 +512,42 @@ async function main(opts) {
|
|
|
516
512
|
if (file.stats.isFile()) {
|
|
517
513
|
const relPath = path.relative(assetsDir, file.path);
|
|
518
514
|
const targetPath = path.resolve(absOutDir, relPath);
|
|
515
|
+
const targetIsExisted = await fs.exists(targetPath);
|
|
516
|
+
async function overwriteOrCopy(target) {
|
|
517
|
+
let isOverwrite = true;
|
|
518
|
+
if (targetIsExisted) {
|
|
519
|
+
const src = await fs.readFile(file.path);
|
|
520
|
+
const dest = target ?? await fs.readFile(targetPath);
|
|
521
|
+
if (await isFileChanged(src, dest)) {
|
|
522
|
+
isOverwrite = await confirmOverwrite(relPath);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return isOverwrite;
|
|
526
|
+
}
|
|
519
527
|
if (relPath === "package.json") {
|
|
520
528
|
const sourcePath = file.path;
|
|
521
|
-
if (
|
|
522
|
-
const sourcePkgJson = await
|
|
523
|
-
const targetPkgJson = await
|
|
529
|
+
if (targetIsExisted) {
|
|
530
|
+
const sourcePkgJson = await fs.readJson(sourcePath);
|
|
531
|
+
const targetPkgJson = await fs.readJson(targetPath);
|
|
524
532
|
setPkgJson(sourcePkgJson, targetPkgJson);
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
533
|
+
const data = JSON.stringify(targetPkgJson, void 0, 2);
|
|
534
|
+
await fs.writeFile(targetPath, `${data}
|
|
535
|
+
`, "utf8");
|
|
528
536
|
logger.success(targetPath);
|
|
529
537
|
}
|
|
530
|
-
} else if (relPath === ".changeset/config.json" && repoName
|
|
531
|
-
const changesetJson = await
|
|
538
|
+
} else if (relPath === ".changeset/config.json" && repoName) {
|
|
539
|
+
const changesetJson = await fs.readJson(file.path);
|
|
532
540
|
(0, import_set_value.default)(changesetJson, "changelog.1.repo", repoName);
|
|
533
|
-
|
|
534
|
-
await
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
let isOverwrite = true;
|
|
540
|
-
const targetIsExisted = await fs2.exists(targetPath);
|
|
541
|
-
if (targetIsExisted) {
|
|
542
|
-
if (await hasFileChanged(file.path, targetPath)) {
|
|
543
|
-
isOverwrite = await confirmOverwrite(relPath);
|
|
544
|
-
}
|
|
541
|
+
const data = JSON.stringify(changesetJson, void 0, 2);
|
|
542
|
+
if (await overwriteOrCopy(data)) {
|
|
543
|
+
await fs.ensureDir(path.dirname(targetPath));
|
|
544
|
+
await fs.writeFile(targetPath, `${data}
|
|
545
|
+
`, "utf8");
|
|
546
|
+
logger.success(targetPath);
|
|
545
547
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
+
} else {
|
|
549
|
+
if (await overwriteOrCopy()) {
|
|
550
|
+
await fs.copy(
|
|
548
551
|
file.path,
|
|
549
552
|
targetPath
|
|
550
553
|
);
|
package/dist/cli.cjs
CHANGED
|
@@ -316,7 +316,7 @@ var import_commander = require("commander");
|
|
|
316
316
|
|
|
317
317
|
// package.json
|
|
318
318
|
var name = "@icebreakers/monorepo";
|
|
319
|
-
var version = "0.4.
|
|
319
|
+
var version = "0.4.2";
|
|
320
320
|
|
|
321
321
|
// src/lib.ts
|
|
322
322
|
init_cjs_shims();
|
|
@@ -324,7 +324,7 @@ var import_node_process = __toESM(require("process"), 1);
|
|
|
324
324
|
var import_node_url = require("url");
|
|
325
325
|
var import_checkbox = __toESM(require("@inquirer/checkbox"), 1);
|
|
326
326
|
var import_confirm = __toESM(require("@inquirer/confirm"), 1);
|
|
327
|
-
var
|
|
327
|
+
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
328
328
|
var import_get_value2 = __toESM(require_get_value(), 1);
|
|
329
329
|
var import_klaw = __toESM(require("klaw"), 1);
|
|
330
330
|
var import_p_queue = __toESM(require("p-queue"), 1);
|
|
@@ -390,13 +390,12 @@ var logger = (0, import_consola.createConsola)();
|
|
|
390
390
|
// src/md5.ts
|
|
391
391
|
init_cjs_shims();
|
|
392
392
|
var import_node_crypto = __toESM(require("crypto"), 1);
|
|
393
|
-
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
394
393
|
function getFileHash(data) {
|
|
395
394
|
const hashSum = import_node_crypto.default.createHash("md5");
|
|
396
395
|
hashSum.update(data);
|
|
397
396
|
return hashSum.digest("hex");
|
|
398
397
|
}
|
|
399
|
-
function
|
|
398
|
+
function isFileChanged(src, dest) {
|
|
400
399
|
try {
|
|
401
400
|
const currentHash = getFileHash(src);
|
|
402
401
|
const previousHash = getFileHash(dest);
|
|
@@ -406,9 +405,6 @@ function hasFileBufferChanged(src, dest) {
|
|
|
406
405
|
return false;
|
|
407
406
|
}
|
|
408
407
|
}
|
|
409
|
-
async function hasFileChanged(src, dest) {
|
|
410
|
-
return hasFileBufferChanged(await import_fs_extra.default.readFile(src), await import_fs_extra.default.readFile(dest));
|
|
411
|
-
}
|
|
412
408
|
|
|
413
409
|
// src/targets.ts
|
|
414
410
|
init_cjs_shims();
|
|
@@ -512,7 +508,7 @@ async function main(opts) {
|
|
|
512
508
|
const removeDirs = ["scripts/monorepo"];
|
|
513
509
|
for (const dir of removeDirs) {
|
|
514
510
|
if (targets.includes(dir)) {
|
|
515
|
-
await
|
|
511
|
+
await import_fs_extra.default.remove(import_pathe.default.resolve(absOutDir, dir));
|
|
516
512
|
}
|
|
517
513
|
}
|
|
518
514
|
const regexpArr = targets.map((x) => {
|
|
@@ -528,35 +524,42 @@ async function main(opts) {
|
|
|
528
524
|
if (file.stats.isFile()) {
|
|
529
525
|
const relPath = import_pathe.default.relative(assetsDir, file.path);
|
|
530
526
|
const targetPath = import_pathe.default.resolve(absOutDir, relPath);
|
|
527
|
+
const targetIsExisted = await import_fs_extra.default.exists(targetPath);
|
|
528
|
+
async function overwriteOrCopy(target) {
|
|
529
|
+
let isOverwrite = true;
|
|
530
|
+
if (targetIsExisted) {
|
|
531
|
+
const src = await import_fs_extra.default.readFile(file.path);
|
|
532
|
+
const dest = target ?? await import_fs_extra.default.readFile(targetPath);
|
|
533
|
+
if (await isFileChanged(src, dest)) {
|
|
534
|
+
isOverwrite = await confirmOverwrite(relPath);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return isOverwrite;
|
|
538
|
+
}
|
|
531
539
|
if (relPath === "package.json") {
|
|
532
540
|
const sourcePath = file.path;
|
|
533
|
-
if (
|
|
534
|
-
const sourcePkgJson = await
|
|
535
|
-
const targetPkgJson = await
|
|
541
|
+
if (targetIsExisted) {
|
|
542
|
+
const sourcePkgJson = await import_fs_extra.default.readJson(sourcePath);
|
|
543
|
+
const targetPkgJson = await import_fs_extra.default.readJson(targetPath);
|
|
536
544
|
setPkgJson(sourcePkgJson, targetPkgJson);
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
545
|
+
const data = JSON.stringify(targetPkgJson, void 0, 2);
|
|
546
|
+
await import_fs_extra.default.writeFile(targetPath, `${data}
|
|
547
|
+
`, "utf8");
|
|
540
548
|
logger.success(targetPath);
|
|
541
549
|
}
|
|
542
|
-
} else if (relPath === ".changeset/config.json" && repoName
|
|
543
|
-
const changesetJson = await
|
|
550
|
+
} else if (relPath === ".changeset/config.json" && repoName) {
|
|
551
|
+
const changesetJson = await import_fs_extra.default.readJson(file.path);
|
|
544
552
|
(0, import_set_value.default)(changesetJson, "changelog.1.repo", repoName);
|
|
545
|
-
|
|
546
|
-
await
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
let isOverwrite = true;
|
|
552
|
-
const targetIsExisted = await import_fs_extra2.default.exists(targetPath);
|
|
553
|
-
if (targetIsExisted) {
|
|
554
|
-
if (await hasFileChanged(file.path, targetPath)) {
|
|
555
|
-
isOverwrite = await confirmOverwrite(relPath);
|
|
556
|
-
}
|
|
553
|
+
const data = JSON.stringify(changesetJson, void 0, 2);
|
|
554
|
+
if (await overwriteOrCopy(data)) {
|
|
555
|
+
await import_fs_extra.default.ensureDir(import_pathe.default.dirname(targetPath));
|
|
556
|
+
await import_fs_extra.default.writeFile(targetPath, `${data}
|
|
557
|
+
`, "utf8");
|
|
558
|
+
logger.success(targetPath);
|
|
557
559
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
+
} else {
|
|
561
|
+
if (await overwriteOrCopy()) {
|
|
562
|
+
await import_fs_extra.default.copy(
|
|
560
563
|
file.path,
|
|
561
564
|
targetPath
|
|
562
565
|
);
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
init_esm_shims,
|
|
3
3
|
logger,
|
|
4
4
|
main
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-XBY6UJ4D.js";
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
8
8
|
init_esm_shims();
|
|
@@ -13,7 +13,7 @@ import { program } from "commander";
|
|
|
13
13
|
|
|
14
14
|
// package.json
|
|
15
15
|
var name = "@icebreakers/monorepo";
|
|
16
|
-
var version = "0.4.
|
|
16
|
+
var version = "0.4.2";
|
|
17
17
|
|
|
18
18
|
// src/program.ts
|
|
19
19
|
program.name(name).version(version);
|
package/dist/index.cjs
CHANGED
|
@@ -327,7 +327,7 @@ var import_node_process = __toESM(require("process"), 1);
|
|
|
327
327
|
var import_node_url = require("url");
|
|
328
328
|
var import_checkbox = __toESM(require("@inquirer/checkbox"), 1);
|
|
329
329
|
var import_confirm = __toESM(require("@inquirer/confirm"), 1);
|
|
330
|
-
var
|
|
330
|
+
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
331
331
|
var import_get_value2 = __toESM(require_get_value(), 1);
|
|
332
332
|
var import_klaw = __toESM(require("klaw"), 1);
|
|
333
333
|
var import_p_queue = __toESM(require("p-queue"), 1);
|
|
@@ -393,13 +393,12 @@ var logger = (0, import_consola.createConsola)();
|
|
|
393
393
|
// src/md5.ts
|
|
394
394
|
init_cjs_shims();
|
|
395
395
|
var import_node_crypto = __toESM(require("crypto"), 1);
|
|
396
|
-
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
397
396
|
function getFileHash(data) {
|
|
398
397
|
const hashSum = import_node_crypto.default.createHash("md5");
|
|
399
398
|
hashSum.update(data);
|
|
400
399
|
return hashSum.digest("hex");
|
|
401
400
|
}
|
|
402
|
-
function
|
|
401
|
+
function isFileChanged(src, dest) {
|
|
403
402
|
try {
|
|
404
403
|
const currentHash = getFileHash(src);
|
|
405
404
|
const previousHash = getFileHash(dest);
|
|
@@ -409,9 +408,6 @@ function hasFileBufferChanged(src, dest) {
|
|
|
409
408
|
return false;
|
|
410
409
|
}
|
|
411
410
|
}
|
|
412
|
-
async function hasFileChanged(src, dest) {
|
|
413
|
-
return hasFileBufferChanged(await import_fs_extra.default.readFile(src), await import_fs_extra.default.readFile(dest));
|
|
414
|
-
}
|
|
415
411
|
|
|
416
412
|
// src/targets.ts
|
|
417
413
|
init_cjs_shims();
|
|
@@ -515,7 +511,7 @@ async function main(opts) {
|
|
|
515
511
|
const removeDirs = ["scripts/monorepo"];
|
|
516
512
|
for (const dir of removeDirs) {
|
|
517
513
|
if (targets.includes(dir)) {
|
|
518
|
-
await
|
|
514
|
+
await import_fs_extra.default.remove(import_pathe.default.resolve(absOutDir, dir));
|
|
519
515
|
}
|
|
520
516
|
}
|
|
521
517
|
const regexpArr = targets.map((x) => {
|
|
@@ -531,35 +527,42 @@ async function main(opts) {
|
|
|
531
527
|
if (file.stats.isFile()) {
|
|
532
528
|
const relPath = import_pathe.default.relative(assetsDir, file.path);
|
|
533
529
|
const targetPath = import_pathe.default.resolve(absOutDir, relPath);
|
|
530
|
+
const targetIsExisted = await import_fs_extra.default.exists(targetPath);
|
|
531
|
+
async function overwriteOrCopy(target) {
|
|
532
|
+
let isOverwrite = true;
|
|
533
|
+
if (targetIsExisted) {
|
|
534
|
+
const src = await import_fs_extra.default.readFile(file.path);
|
|
535
|
+
const dest = target ?? await import_fs_extra.default.readFile(targetPath);
|
|
536
|
+
if (await isFileChanged(src, dest)) {
|
|
537
|
+
isOverwrite = await confirmOverwrite(relPath);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return isOverwrite;
|
|
541
|
+
}
|
|
534
542
|
if (relPath === "package.json") {
|
|
535
543
|
const sourcePath = file.path;
|
|
536
|
-
if (
|
|
537
|
-
const sourcePkgJson = await
|
|
538
|
-
const targetPkgJson = await
|
|
544
|
+
if (targetIsExisted) {
|
|
545
|
+
const sourcePkgJson = await import_fs_extra.default.readJson(sourcePath);
|
|
546
|
+
const targetPkgJson = await import_fs_extra.default.readJson(targetPath);
|
|
539
547
|
setPkgJson(sourcePkgJson, targetPkgJson);
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
548
|
+
const data = JSON.stringify(targetPkgJson, void 0, 2);
|
|
549
|
+
await import_fs_extra.default.writeFile(targetPath, `${data}
|
|
550
|
+
`, "utf8");
|
|
543
551
|
logger.success(targetPath);
|
|
544
552
|
}
|
|
545
|
-
} else if (relPath === ".changeset/config.json" && repoName
|
|
546
|
-
const changesetJson = await
|
|
553
|
+
} else if (relPath === ".changeset/config.json" && repoName) {
|
|
554
|
+
const changesetJson = await import_fs_extra.default.readJson(file.path);
|
|
547
555
|
(0, import_set_value.default)(changesetJson, "changelog.1.repo", repoName);
|
|
548
|
-
|
|
549
|
-
await
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
let isOverwrite = true;
|
|
555
|
-
const targetIsExisted = await import_fs_extra2.default.exists(targetPath);
|
|
556
|
-
if (targetIsExisted) {
|
|
557
|
-
if (await hasFileChanged(file.path, targetPath)) {
|
|
558
|
-
isOverwrite = await confirmOverwrite(relPath);
|
|
559
|
-
}
|
|
556
|
+
const data = JSON.stringify(changesetJson, void 0, 2);
|
|
557
|
+
if (await overwriteOrCopy(data)) {
|
|
558
|
+
await import_fs_extra.default.ensureDir(import_pathe.default.dirname(targetPath));
|
|
559
|
+
await import_fs_extra.default.writeFile(targetPath, `${data}
|
|
560
|
+
`, "utf8");
|
|
561
|
+
logger.success(targetPath);
|
|
560
562
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
+
} else {
|
|
564
|
+
if (await overwriteOrCopy()) {
|
|
565
|
+
await import_fs_extra.default.copy(
|
|
563
566
|
file.path,
|
|
564
567
|
targetPath
|
|
565
568
|
);
|
package/dist/index.js
CHANGED