@xylabs/ts-scripts-common 7.5.2 → 7.5.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/dist/actions/deplint/checkPackage/checkPackage.mjs +52 -5
- package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +17 -2
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +15 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +15 -1
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +41 -1
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/index.mjs +52 -5
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
- package/dist/actions/deplint/deplint.mjs +43 -5
- package/dist/actions/deplint/deplint.mjs.map +1 -1
- package/dist/actions/deplint/implicitDevDependencies.mjs +25 -0
- package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/index.mjs +43 -5
- package/dist/actions/deplint/index.mjs.map +1 -1
- package/dist/actions/deplint/tsScriptsAliases.mjs +20 -0
- package/dist/actions/deplint/tsScriptsAliases.mjs.map +1 -0
- package/dist/actions/index.mjs +195 -98
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/packman/convert.mjs +142 -83
- package/dist/actions/packman/convert.mjs.map +1 -1
- package/dist/actions/packman/convertToPnpm.mjs +94 -36
- package/dist/actions/packman/convertToPnpm.mjs.map +1 -1
- package/dist/actions/packman/convertToYarn.mjs +95 -37
- package/dist/actions/packman/convertToYarn.mjs.map +1 -1
- package/dist/actions/packman/index.mjs +142 -83
- package/dist/actions/packman/index.mjs.map +1 -1
- package/dist/actions/packman/rewriteSourceImports.mjs +60 -0
- package/dist/actions/packman/rewriteSourceImports.mjs.map +1 -0
- package/dist/bin/xy.mjs +212 -115
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.mjs +214 -117
- package/dist/index.mjs.map +1 -1
- package/dist/xy/common/index.mjs +142 -83
- package/dist/xy/common/index.mjs.map +1 -1
- package/dist/xy/common/packmanCommand.mjs +142 -83
- package/dist/xy/common/packmanCommand.mjs.map +1 -1
- package/dist/xy/index.mjs +212 -115
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/lint/deplintCommand.mjs +43 -5
- package/dist/xy/lint/deplintCommand.mjs.map +1 -1
- package/dist/xy/lint/index.mjs +43 -5
- package/dist/xy/lint/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +212 -115
- package/dist/xy/xy.mjs.map +1 -1
- package/package.json +2 -2
package/dist/xy/xy.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/xy/xy.ts
|
|
2
|
-
import
|
|
2
|
+
import chalk46 from "chalk";
|
|
3
3
|
|
|
4
4
|
// src/actions/build.ts
|
|
5
5
|
import chalk9 from "chalk";
|
|
@@ -1387,6 +1387,24 @@ function getExternalImportsFromFiles({
|
|
|
1387
1387
|
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
1388
1388
|
import { builtinModules } from "module";
|
|
1389
1389
|
import chalk18 from "chalk";
|
|
1390
|
+
|
|
1391
|
+
// src/actions/deplint/tsScriptsAliases.ts
|
|
1392
|
+
var VARIANT_MAP = {
|
|
1393
|
+
"@xylabs/ts-scripts-yarn3": "@xylabs/ts-scripts-pnpm",
|
|
1394
|
+
"@xylabs/ts-scripts-pnpm": "@xylabs/ts-scripts-yarn3",
|
|
1395
|
+
"@xylabs/ts-scripts-react-yarn3": "@xylabs/ts-scripts-react-pnpm",
|
|
1396
|
+
"@xylabs/ts-scripts-react-pnpm": "@xylabs/ts-scripts-react-yarn3"
|
|
1397
|
+
};
|
|
1398
|
+
function isSatisfiedByTsScriptsVariant(imp, allDeps) {
|
|
1399
|
+
const variant = VARIANT_MAP[imp];
|
|
1400
|
+
return variant !== void 0 && allDeps.includes(variant);
|
|
1401
|
+
}
|
|
1402
|
+
function isUsedViaTsScriptsVariant(dep, imports) {
|
|
1403
|
+
const variant = VARIANT_MAP[dep];
|
|
1404
|
+
return variant !== void 0 && imports.includes(variant);
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
1390
1408
|
function isRuntimeImportListed(imp, name, dependencies, peerDependencies) {
|
|
1391
1409
|
return dependencies.includes(imp) || imp === name || peerDependencies.includes(imp) || builtinModules.includes(imp);
|
|
1392
1410
|
}
|
|
@@ -1409,14 +1427,15 @@ function getUnlistedDependencies({ name, location }, {
|
|
|
1409
1427
|
distImportPaths
|
|
1410
1428
|
}) {
|
|
1411
1429
|
let unlistedDependencies = 0;
|
|
1430
|
+
const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
|
|
1412
1431
|
for (const imp of externalDistImports) {
|
|
1413
|
-
if (!isRuntimeImportListed(imp, name, dependencies, peerDependencies)) {
|
|
1432
|
+
if (!isRuntimeImportListed(imp, name, dependencies, peerDependencies) && !isSatisfiedByTsScriptsVariant(imp, allDeps)) {
|
|
1414
1433
|
unlistedDependencies++;
|
|
1415
1434
|
logMissing(name, imp, distImportPaths);
|
|
1416
1435
|
}
|
|
1417
1436
|
}
|
|
1418
1437
|
for (const imp of externalDistTypeImports) {
|
|
1419
|
-
if (!isTypeImportListed(imp, name, dependencies, devDependencies, peerDependencies)) {
|
|
1438
|
+
if (!isTypeImportListed(imp, name, dependencies, devDependencies, peerDependencies) && !isSatisfiedByTsScriptsVariant(imp, allDeps)) {
|
|
1420
1439
|
unlistedDependencies++;
|
|
1421
1440
|
logMissing(name, imp, distImportPaths);
|
|
1422
1441
|
}
|
|
@@ -1443,7 +1462,7 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
1443
1462
|
}) {
|
|
1444
1463
|
let unlistedDevDependencies = 0;
|
|
1445
1464
|
for (const imp of externalAllImports) {
|
|
1446
|
-
if (!distImports.includes(imp) && imp !== name && !dependencies.includes(imp) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`) && !builtinModules2.includes(imp)) {
|
|
1465
|
+
if (!distImports.includes(imp) && imp !== name && !dependencies.includes(imp) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`) && !builtinModules2.includes(imp) && !isSatisfiedByTsScriptsVariant(imp, [...dependencies, ...devDependencies, ...peerDependencies])) {
|
|
1447
1466
|
unlistedDevDependencies++;
|
|
1448
1467
|
console.log(`[${chalk19.blue(name)}] Missing devDependency in package.json: ${chalk19.red(imp)}`);
|
|
1449
1468
|
if (allImportPaths[imp]) {
|
|
@@ -1469,7 +1488,7 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
1469
1488
|
let unusedDependencies = 0;
|
|
1470
1489
|
for (const dep of dependencies) {
|
|
1471
1490
|
if (exclude?.has(dep)) continue;
|
|
1472
|
-
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1491
|
+
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, "")) && !isUsedViaTsScriptsVariant(dep, [...externalDistImports, ...externalDistTypeImports])) {
|
|
1473
1492
|
unusedDependencies++;
|
|
1474
1493
|
if (externalAllImports.includes(dep)) {
|
|
1475
1494
|
console.log(`[${chalk20.blue(name)}] dependency should be devDependency in package.json: ${chalk20.red(dep)}`);
|
|
@@ -1699,6 +1718,8 @@ function hasImportPlugin({ location, allDependencies }) {
|
|
|
1699
1718
|
return false;
|
|
1700
1719
|
}
|
|
1701
1720
|
var hasVitest = ({ allDependencies }) => allDependencies.includes("vitest");
|
|
1721
|
+
var isYarnRepo = () => detectPackageManager() === "yarn";
|
|
1722
|
+
var isPnpmRepo = () => detectPackageManager() === "pnpm";
|
|
1702
1723
|
var rules = [
|
|
1703
1724
|
{
|
|
1704
1725
|
package: "typescript",
|
|
@@ -1715,6 +1736,22 @@ var rules = [
|
|
|
1715
1736
|
{
|
|
1716
1737
|
package: "@vitest/coverage-v8",
|
|
1717
1738
|
isNeeded: hasVitest
|
|
1739
|
+
},
|
|
1740
|
+
{
|
|
1741
|
+
package: "@xylabs/ts-scripts-yarn3",
|
|
1742
|
+
isNeeded: isYarnRepo
|
|
1743
|
+
},
|
|
1744
|
+
{
|
|
1745
|
+
package: "@xylabs/ts-scripts-react-yarn3",
|
|
1746
|
+
isNeeded: isYarnRepo
|
|
1747
|
+
},
|
|
1748
|
+
{
|
|
1749
|
+
package: "@xylabs/ts-scripts-pnpm",
|
|
1750
|
+
isNeeded: isPnpmRepo
|
|
1751
|
+
},
|
|
1752
|
+
{
|
|
1753
|
+
package: "@xylabs/ts-scripts-react-pnpm",
|
|
1754
|
+
isNeeded: isPnpmRepo
|
|
1718
1755
|
}
|
|
1719
1756
|
];
|
|
1720
1757
|
function getImplicitDevDependencies(context) {
|
|
@@ -1748,7 +1785,8 @@ function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs,
|
|
|
1748
1785
|
const baseName = dep.replace(/^@types\//, "");
|
|
1749
1786
|
return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
|
|
1750
1787
|
}
|
|
1751
|
-
|
|
1788
|
+
if (allImports.has(dep)) return true;
|
|
1789
|
+
return isUsedViaTsScriptsVariant(dep, [...allImports]);
|
|
1752
1790
|
}
|
|
1753
1791
|
function getUnusedDevDependencies({ name, location }, {
|
|
1754
1792
|
devDependencies,
|
|
@@ -2586,24 +2624,24 @@ function packageLintMonorepo(fix2 = false) {
|
|
|
2586
2624
|
|
|
2587
2625
|
// src/actions/packman/convert.ts
|
|
2588
2626
|
import {
|
|
2589
|
-
existsSync as
|
|
2627
|
+
existsSync as existsSync14,
|
|
2590
2628
|
readdirSync as readdirSync6,
|
|
2591
|
-
readFileSync as
|
|
2629
|
+
readFileSync as readFileSync15,
|
|
2592
2630
|
statSync as statSync3
|
|
2593
2631
|
} from "fs";
|
|
2594
2632
|
import PATH15 from "path";
|
|
2595
|
-
import
|
|
2633
|
+
import chalk35 from "chalk";
|
|
2596
2634
|
|
|
2597
2635
|
// src/actions/packman/convertToPnpm.ts
|
|
2598
2636
|
import {
|
|
2599
|
-
existsSync as
|
|
2637
|
+
existsSync as existsSync12,
|
|
2600
2638
|
mkdirSync as mkdirSync5,
|
|
2601
|
-
readFileSync as
|
|
2639
|
+
readFileSync as readFileSync13,
|
|
2602
2640
|
rmSync as rmSync3,
|
|
2603
|
-
writeFileSync as
|
|
2641
|
+
writeFileSync as writeFileSync10
|
|
2604
2642
|
} from "fs";
|
|
2605
2643
|
import PATH13 from "path";
|
|
2606
|
-
import
|
|
2644
|
+
import chalk33 from "chalk";
|
|
2607
2645
|
|
|
2608
2646
|
// src/actions/packman/rewriteScripts.ts
|
|
2609
2647
|
function rewriteYarnToPnpm(script) {
|
|
@@ -2653,14 +2691,71 @@ function rewriteScriptsInPackageJson(pkg, direction) {
|
|
|
2653
2691
|
return { ...pkg, scripts: rewritten };
|
|
2654
2692
|
}
|
|
2655
2693
|
|
|
2656
|
-
// src/actions/packman/
|
|
2694
|
+
// src/actions/packman/rewriteSourceImports.ts
|
|
2657
2695
|
import {
|
|
2658
2696
|
existsSync as existsSync10,
|
|
2659
2697
|
readFileSync as readFileSync11,
|
|
2660
2698
|
writeFileSync as writeFileSync8
|
|
2661
2699
|
} from "fs";
|
|
2662
|
-
import PATH12 from "path";
|
|
2663
2700
|
import chalk31 from "chalk";
|
|
2701
|
+
import { globSync as globSync3 } from "glob";
|
|
2702
|
+
var IMPORT_SWAP_MAP = {
|
|
2703
|
+
"yarn-to-pnpm": [
|
|
2704
|
+
["@xylabs/ts-scripts-yarn3", "@xylabs/ts-scripts-pnpm"],
|
|
2705
|
+
["@xylabs/ts-scripts-react-yarn3", "@xylabs/ts-scripts-react-pnpm"]
|
|
2706
|
+
],
|
|
2707
|
+
"pnpm-to-yarn": [
|
|
2708
|
+
["@xylabs/ts-scripts-pnpm", "@xylabs/ts-scripts-yarn3"],
|
|
2709
|
+
["@xylabs/ts-scripts-react-pnpm", "@xylabs/ts-scripts-react-yarn3"]
|
|
2710
|
+
]
|
|
2711
|
+
};
|
|
2712
|
+
var SOURCE_GLOBS = [
|
|
2713
|
+
"**/*.ts",
|
|
2714
|
+
"**/*.tsx",
|
|
2715
|
+
"**/*.mts",
|
|
2716
|
+
"**/*.cts",
|
|
2717
|
+
"**/*.js",
|
|
2718
|
+
"**/*.mjs"
|
|
2719
|
+
];
|
|
2720
|
+
var IGNORE_PATTERNS = [
|
|
2721
|
+
"**/node_modules/**",
|
|
2722
|
+
"**/dist/**",
|
|
2723
|
+
"**/build/**",
|
|
2724
|
+
"**/.yarn/**"
|
|
2725
|
+
];
|
|
2726
|
+
function rewriteSourceImports(cwd, direction) {
|
|
2727
|
+
const swaps = IMPORT_SWAP_MAP[direction];
|
|
2728
|
+
const files = globSync3(SOURCE_GLOBS, {
|
|
2729
|
+
cwd,
|
|
2730
|
+
absolute: true,
|
|
2731
|
+
ignore: IGNORE_PATTERNS
|
|
2732
|
+
});
|
|
2733
|
+
let count = 0;
|
|
2734
|
+
for (const file of files) {
|
|
2735
|
+
if (!existsSync10(file)) continue;
|
|
2736
|
+
const original = readFileSync11(file, "utf8");
|
|
2737
|
+
let content = original;
|
|
2738
|
+
for (const [from, to] of swaps) {
|
|
2739
|
+
content = content.replaceAll(from, to);
|
|
2740
|
+
}
|
|
2741
|
+
if (content !== original) {
|
|
2742
|
+
writeFileSync8(file, content, "utf8");
|
|
2743
|
+
count++;
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
if (count > 0) {
|
|
2747
|
+
console.log(chalk31.green(` Rewrote ts-scripts imports in ${count} source file(s)`));
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
// src/actions/packman/swapTsScriptsDependency.ts
|
|
2752
|
+
import {
|
|
2753
|
+
existsSync as existsSync11,
|
|
2754
|
+
readFileSync as readFileSync12,
|
|
2755
|
+
writeFileSync as writeFileSync9
|
|
2756
|
+
} from "fs";
|
|
2757
|
+
import PATH12 from "path";
|
|
2758
|
+
import chalk32 from "chalk";
|
|
2664
2759
|
var SWAP_MAP = {
|
|
2665
2760
|
"yarn-to-pnpm": [
|
|
2666
2761
|
["@xylabs/ts-scripts-yarn3", "@xylabs/ts-scripts-pnpm"]
|
|
@@ -2670,8 +2765,8 @@ var SWAP_MAP = {
|
|
|
2670
2765
|
]
|
|
2671
2766
|
};
|
|
2672
2767
|
function swapInPackageJson(pkgPath, direction) {
|
|
2673
|
-
if (!
|
|
2674
|
-
const raw =
|
|
2768
|
+
if (!existsSync11(pkgPath)) return false;
|
|
2769
|
+
const raw = readFileSync12(pkgPath, "utf8");
|
|
2675
2770
|
const pkg = JSON.parse(raw);
|
|
2676
2771
|
let changed = false;
|
|
2677
2772
|
for (const depField of ["dependencies", "devDependencies"]) {
|
|
@@ -2686,7 +2781,7 @@ function swapInPackageJson(pkgPath, direction) {
|
|
|
2686
2781
|
}
|
|
2687
2782
|
}
|
|
2688
2783
|
if (changed) {
|
|
2689
|
-
|
|
2784
|
+
writeFileSync9(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
|
|
2690
2785
|
}
|
|
2691
2786
|
return changed;
|
|
2692
2787
|
}
|
|
@@ -2703,7 +2798,7 @@ function swapTsScriptsDependency(cwd, workspacePackageJsonPaths, direction) {
|
|
|
2703
2798
|
}
|
|
2704
2799
|
if (count > 0) {
|
|
2705
2800
|
const target = direction === "yarn-to-pnpm" ? "@xylabs/ts-scripts-pnpm" : "@xylabs/ts-scripts-yarn3";
|
|
2706
|
-
console.log(
|
|
2801
|
+
console.log(chalk32.green(` Swapped ts-scripts dependency to ${target} in ${count} package(s)`));
|
|
2707
2802
|
}
|
|
2708
2803
|
}
|
|
2709
2804
|
|
|
@@ -2714,13 +2809,13 @@ function createPnpmWorkspaceYaml(cwd, workspacePatterns) {
|
|
|
2714
2809
|
for (const pattern of workspacePatterns) {
|
|
2715
2810
|
lines.push(` - '${pattern}'`);
|
|
2716
2811
|
}
|
|
2717
|
-
|
|
2718
|
-
console.log(
|
|
2812
|
+
writeFileSync10(PATH13.join(cwd, "pnpm-workspace.yaml"), lines.join("\n") + "\n", "utf8");
|
|
2813
|
+
console.log(chalk33.green(" Created pnpm-workspace.yaml"));
|
|
2719
2814
|
}
|
|
2720
2815
|
function readPnpmWorkspacePatterns(cwd) {
|
|
2721
2816
|
const wsPath = PATH13.join(cwd, "pnpm-workspace.yaml");
|
|
2722
|
-
if (!
|
|
2723
|
-
const content =
|
|
2817
|
+
if (!existsSync12(wsPath)) return [];
|
|
2818
|
+
const content = readFileSync13(wsPath, "utf8");
|
|
2724
2819
|
const patterns = [];
|
|
2725
2820
|
const lines = content.split("\n");
|
|
2726
2821
|
let inPackages = false;
|
|
@@ -2740,19 +2835,19 @@ function readPnpmWorkspacePatterns(cwd) {
|
|
|
2740
2835
|
}
|
|
2741
2836
|
function updateRootPackageJson(cwd) {
|
|
2742
2837
|
const pkgPath = PATH13.join(cwd, "package.json");
|
|
2743
|
-
const pkg = JSON.parse(
|
|
2838
|
+
const pkg = JSON.parse(readFileSync13(pkgPath, "utf8"));
|
|
2744
2839
|
const workspacePatterns = pkg.workspaces ?? readPnpmWorkspacePatterns(cwd);
|
|
2745
2840
|
delete pkg.workspaces;
|
|
2746
2841
|
pkg.packageManager = `pnpm@${PNPM_VERSION}`;
|
|
2747
2842
|
const updated = rewriteScriptsInPackageJson(pkg, "yarn-to-pnpm");
|
|
2748
|
-
|
|
2749
|
-
console.log(
|
|
2843
|
+
writeFileSync10(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
2844
|
+
console.log(chalk33.green(" Updated root package.json"));
|
|
2750
2845
|
return workspacePatterns;
|
|
2751
2846
|
}
|
|
2752
2847
|
function updateGitignore(cwd) {
|
|
2753
2848
|
const gitignorePath = PATH13.join(cwd, ".gitignore");
|
|
2754
|
-
if (!
|
|
2755
|
-
let content =
|
|
2849
|
+
if (!existsSync12(gitignorePath)) return;
|
|
2850
|
+
let content = readFileSync13(gitignorePath, "utf8");
|
|
2756
2851
|
const yarnLines = [
|
|
2757
2852
|
".pnp.*",
|
|
2758
2853
|
".pnp",
|
|
@@ -2767,64 +2862,65 @@ function updateGitignore(cwd) {
|
|
|
2767
2862
|
content = content.replaceAll(new RegExp(String.raw`^${line.replaceAll(".", String.raw`\.`).replaceAll("*", String.raw`\*`).replaceAll("!", String.raw`\!`)}\s*$`, "gm"), "");
|
|
2768
2863
|
}
|
|
2769
2864
|
content = content.replaceAll(/\n{3,}/g, "\n\n");
|
|
2770
|
-
|
|
2771
|
-
console.log(
|
|
2865
|
+
writeFileSync10(gitignorePath, content, "utf8");
|
|
2866
|
+
console.log(chalk33.green(" Updated .gitignore"));
|
|
2772
2867
|
}
|
|
2773
2868
|
function deleteYarnArtifacts(cwd) {
|
|
2774
2869
|
const yarnLock = PATH13.join(cwd, "yarn.lock");
|
|
2775
2870
|
const yarnrc = PATH13.join(cwd, ".yarnrc.yml");
|
|
2776
2871
|
const yarnDir = PATH13.join(cwd, ".yarn");
|
|
2777
|
-
if (
|
|
2872
|
+
if (existsSync12(yarnLock)) {
|
|
2778
2873
|
rmSync3(yarnLock);
|
|
2779
|
-
console.log(
|
|
2874
|
+
console.log(chalk33.gray(" Deleted yarn.lock"));
|
|
2780
2875
|
}
|
|
2781
|
-
if (
|
|
2876
|
+
if (existsSync12(yarnrc)) {
|
|
2782
2877
|
rmSync3(yarnrc);
|
|
2783
|
-
console.log(
|
|
2878
|
+
console.log(chalk33.gray(" Deleted .yarnrc.yml"));
|
|
2784
2879
|
}
|
|
2785
|
-
if (
|
|
2880
|
+
if (existsSync12(yarnDir)) {
|
|
2786
2881
|
rmSync3(yarnDir, { force: true, recursive: true });
|
|
2787
|
-
console.log(
|
|
2882
|
+
console.log(chalk33.gray(" Deleted .yarn/"));
|
|
2788
2883
|
}
|
|
2789
2884
|
}
|
|
2790
2885
|
function createNpmrc(cwd) {
|
|
2791
2886
|
const npmrcPath = PATH13.join(cwd, ".npmrc");
|
|
2792
|
-
if (
|
|
2887
|
+
if (existsSync12(npmrcPath)) return;
|
|
2793
2888
|
mkdirSync5(PATH13.dirname(npmrcPath), { recursive: true });
|
|
2794
|
-
|
|
2795
|
-
console.log(
|
|
2889
|
+
writeFileSync10(npmrcPath, "", "utf8");
|
|
2890
|
+
console.log(chalk33.green(" Created .npmrc"));
|
|
2796
2891
|
}
|
|
2797
2892
|
function convertToPnpm(cwd, workspacePackageJsonPaths) {
|
|
2798
|
-
console.log(
|
|
2893
|
+
console.log(chalk33.blue("\nConverting to pnpm...\n"));
|
|
2799
2894
|
const workspacePatterns = updateRootPackageJson(cwd);
|
|
2800
2895
|
createPnpmWorkspaceYaml(cwd, workspacePatterns);
|
|
2801
2896
|
for (const pkgPath of workspacePackageJsonPaths) {
|
|
2802
2897
|
const fullPath = PATH13.resolve(cwd, pkgPath, "package.json");
|
|
2803
|
-
if (!
|
|
2804
|
-
const pkg = JSON.parse(
|
|
2898
|
+
if (!existsSync12(fullPath)) continue;
|
|
2899
|
+
const pkg = JSON.parse(readFileSync13(fullPath, "utf8"));
|
|
2805
2900
|
const updated = rewriteScriptsInPackageJson(pkg, "yarn-to-pnpm");
|
|
2806
2901
|
if (JSON.stringify(pkg) !== JSON.stringify(updated)) {
|
|
2807
|
-
|
|
2902
|
+
writeFileSync10(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
2808
2903
|
}
|
|
2809
2904
|
}
|
|
2810
|
-
console.log(
|
|
2905
|
+
console.log(chalk33.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
|
|
2811
2906
|
updateGitignore(cwd);
|
|
2812
2907
|
createNpmrc(cwd);
|
|
2813
2908
|
swapTsScriptsDependency(cwd, workspacePackageJsonPaths, "yarn-to-pnpm");
|
|
2909
|
+
rewriteSourceImports(cwd, "yarn-to-pnpm");
|
|
2814
2910
|
deleteYarnArtifacts(cwd);
|
|
2815
|
-
console.log(
|
|
2911
|
+
console.log(chalk33.blue("\nConversion complete. Run `pnpm install` to generate pnpm-lock.yaml.\n"));
|
|
2816
2912
|
return 0;
|
|
2817
2913
|
}
|
|
2818
2914
|
|
|
2819
2915
|
// src/actions/packman/convertToYarn.ts
|
|
2820
2916
|
import {
|
|
2821
|
-
existsSync as
|
|
2822
|
-
readFileSync as
|
|
2917
|
+
existsSync as existsSync13,
|
|
2918
|
+
readFileSync as readFileSync14,
|
|
2823
2919
|
rmSync as rmSync4,
|
|
2824
|
-
writeFileSync as
|
|
2920
|
+
writeFileSync as writeFileSync11
|
|
2825
2921
|
} from "fs";
|
|
2826
2922
|
import PATH14 from "path";
|
|
2827
|
-
import
|
|
2923
|
+
import chalk34 from "chalk";
|
|
2828
2924
|
var YARN_VERSION = "4.13.0";
|
|
2829
2925
|
var YARNRC_TEMPLATE = `compressionLevel: mixed
|
|
2830
2926
|
|
|
@@ -2847,8 +2943,8 @@ var YARN_GITIGNORE_ENTRIES = `
|
|
|
2847
2943
|
`;
|
|
2848
2944
|
function readPnpmWorkspacePatterns2(cwd) {
|
|
2849
2945
|
const wsPath = PATH14.join(cwd, "pnpm-workspace.yaml");
|
|
2850
|
-
if (!
|
|
2851
|
-
const content =
|
|
2946
|
+
if (!existsSync13(wsPath)) return [];
|
|
2947
|
+
const content = readFileSync14(wsPath, "utf8");
|
|
2852
2948
|
const patterns = [];
|
|
2853
2949
|
const lines = content.split("\n");
|
|
2854
2950
|
let inPackages = false;
|
|
@@ -2868,102 +2964,103 @@ function readPnpmWorkspacePatterns2(cwd) {
|
|
|
2868
2964
|
}
|
|
2869
2965
|
function updateRootPackageJson2(cwd, workspacePatterns) {
|
|
2870
2966
|
const pkgPath = PATH14.join(cwd, "package.json");
|
|
2871
|
-
const pkg = JSON.parse(
|
|
2967
|
+
const pkg = JSON.parse(readFileSync14(pkgPath, "utf8"));
|
|
2872
2968
|
pkg.workspaces = workspacePatterns;
|
|
2873
2969
|
pkg.packageManager = `yarn@${YARN_VERSION}`;
|
|
2874
2970
|
const updated = rewriteScriptsInPackageJson(pkg, "pnpm-to-yarn");
|
|
2875
|
-
|
|
2876
|
-
console.log(
|
|
2971
|
+
writeFileSync11(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
2972
|
+
console.log(chalk34.green(" Updated root package.json"));
|
|
2877
2973
|
}
|
|
2878
2974
|
function updateGitignore2(cwd) {
|
|
2879
2975
|
const gitignorePath = PATH14.join(cwd, ".gitignore");
|
|
2880
|
-
let content =
|
|
2976
|
+
let content = existsSync13(gitignorePath) ? readFileSync14(gitignorePath, "utf8") : "";
|
|
2881
2977
|
if (!content.includes(".yarn/*")) {
|
|
2882
2978
|
content = content.trimEnd() + "\n" + YARN_GITIGNORE_ENTRIES;
|
|
2883
2979
|
}
|
|
2884
|
-
|
|
2885
|
-
console.log(
|
|
2980
|
+
writeFileSync11(gitignorePath, content, "utf8");
|
|
2981
|
+
console.log(chalk34.green(" Updated .gitignore"));
|
|
2886
2982
|
}
|
|
2887
2983
|
function deletePnpmArtifacts(cwd) {
|
|
2888
2984
|
const lockfile = PATH14.join(cwd, "pnpm-lock.yaml");
|
|
2889
2985
|
const workspaceYaml = PATH14.join(cwd, "pnpm-workspace.yaml");
|
|
2890
2986
|
const npmrc = PATH14.join(cwd, ".npmrc");
|
|
2891
|
-
if (
|
|
2987
|
+
if (existsSync13(lockfile)) {
|
|
2892
2988
|
rmSync4(lockfile);
|
|
2893
|
-
console.log(
|
|
2989
|
+
console.log(chalk34.gray(" Deleted pnpm-lock.yaml"));
|
|
2894
2990
|
}
|
|
2895
|
-
if (
|
|
2991
|
+
if (existsSync13(workspaceYaml)) {
|
|
2896
2992
|
rmSync4(workspaceYaml);
|
|
2897
|
-
console.log(
|
|
2993
|
+
console.log(chalk34.gray(" Deleted pnpm-workspace.yaml"));
|
|
2898
2994
|
}
|
|
2899
|
-
if (
|
|
2900
|
-
const content =
|
|
2995
|
+
if (existsSync13(npmrc)) {
|
|
2996
|
+
const content = readFileSync14(npmrc, "utf8");
|
|
2901
2997
|
if (content.trim() === "" || content.includes("shamefully-hoist") || content.includes("node-linker")) {
|
|
2902
2998
|
rmSync4(npmrc);
|
|
2903
|
-
console.log(
|
|
2999
|
+
console.log(chalk34.gray(" Deleted .npmrc"));
|
|
2904
3000
|
}
|
|
2905
3001
|
}
|
|
2906
3002
|
}
|
|
2907
3003
|
function createYarnrc(cwd) {
|
|
2908
3004
|
const yarnrcPath = PATH14.join(cwd, ".yarnrc.yml");
|
|
2909
|
-
if (
|
|
2910
|
-
|
|
2911
|
-
console.log(
|
|
3005
|
+
if (existsSync13(yarnrcPath)) return;
|
|
3006
|
+
writeFileSync11(yarnrcPath, YARNRC_TEMPLATE, "utf8");
|
|
3007
|
+
console.log(chalk34.green(" Created .yarnrc.yml"));
|
|
2912
3008
|
}
|
|
2913
3009
|
function readWorkspacePatternsFromPackageJson(cwd) {
|
|
2914
3010
|
const pkgPath = PATH14.join(cwd, "package.json");
|
|
2915
|
-
if (!
|
|
2916
|
-
const pkg = JSON.parse(
|
|
3011
|
+
if (!existsSync13(pkgPath)) return [];
|
|
3012
|
+
const pkg = JSON.parse(readFileSync14(pkgPath, "utf8"));
|
|
2917
3013
|
return pkg.workspaces ?? [];
|
|
2918
3014
|
}
|
|
2919
3015
|
function convertToYarn(cwd, workspacePackageJsonPaths) {
|
|
2920
|
-
console.log(
|
|
3016
|
+
console.log(chalk34.blue("\nConverting to yarn...\n"));
|
|
2921
3017
|
const workspacePatterns = readPnpmWorkspacePatterns2(cwd);
|
|
2922
3018
|
if (workspacePatterns.length === 0) {
|
|
2923
3019
|
const fromPkg = readWorkspacePatternsFromPackageJson(cwd);
|
|
2924
3020
|
if (fromPkg.length > 0) {
|
|
2925
3021
|
workspacePatterns.push(...fromPkg);
|
|
2926
3022
|
} else {
|
|
2927
|
-
console.warn(
|
|
3023
|
+
console.warn(chalk34.yellow(" No workspace patterns found"));
|
|
2928
3024
|
}
|
|
2929
3025
|
}
|
|
2930
3026
|
updateRootPackageJson2(cwd, workspacePatterns);
|
|
2931
3027
|
for (const pkgPath of workspacePackageJsonPaths) {
|
|
2932
3028
|
const fullPath = PATH14.resolve(cwd, pkgPath, "package.json");
|
|
2933
|
-
if (!
|
|
2934
|
-
const pkg = JSON.parse(
|
|
3029
|
+
if (!existsSync13(fullPath)) continue;
|
|
3030
|
+
const pkg = JSON.parse(readFileSync14(fullPath, "utf8"));
|
|
2935
3031
|
const updated = rewriteScriptsInPackageJson(pkg, "pnpm-to-yarn");
|
|
2936
3032
|
if (JSON.stringify(pkg) !== JSON.stringify(updated)) {
|
|
2937
|
-
|
|
3033
|
+
writeFileSync11(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
2938
3034
|
}
|
|
2939
3035
|
}
|
|
2940
|
-
console.log(
|
|
3036
|
+
console.log(chalk34.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
|
|
2941
3037
|
updateGitignore2(cwd);
|
|
2942
3038
|
createYarnrc(cwd);
|
|
2943
3039
|
swapTsScriptsDependency(cwd, workspacePackageJsonPaths, "pnpm-to-yarn");
|
|
3040
|
+
rewriteSourceImports(cwd, "pnpm-to-yarn");
|
|
2944
3041
|
deletePnpmArtifacts(cwd);
|
|
2945
|
-
console.log(
|
|
3042
|
+
console.log(chalk34.blue("\nConversion complete. Run `corepack enable yarn && yarn set version stable && yarn install` to finish setup.\n"));
|
|
2946
3043
|
return 0;
|
|
2947
3044
|
}
|
|
2948
3045
|
|
|
2949
3046
|
// src/actions/packman/convert.ts
|
|
2950
3047
|
function detectCurrentPM(cwd) {
|
|
2951
|
-
if (
|
|
3048
|
+
if (existsSync14(PATH15.join(cwd, "pnpm-lock.yaml")) || existsSync14(PATH15.join(cwd, "pnpm-workspace.yaml"))) {
|
|
2952
3049
|
return "pnpm";
|
|
2953
3050
|
}
|
|
2954
|
-
if (
|
|
3051
|
+
if (existsSync14(PATH15.join(cwd, "yarn.lock")) || existsSync14(PATH15.join(cwd, ".yarnrc.yml"))) {
|
|
2955
3052
|
return "yarn";
|
|
2956
3053
|
}
|
|
2957
3054
|
return "unknown";
|
|
2958
3055
|
}
|
|
2959
3056
|
function findWorkspacePackagePaths(cwd) {
|
|
2960
3057
|
const pkgPath = PATH15.join(cwd, "package.json");
|
|
2961
|
-
const pkg = JSON.parse(
|
|
3058
|
+
const pkg = JSON.parse(readFileSync15(pkgPath, "utf8"));
|
|
2962
3059
|
let patterns = pkg.workspaces ?? [];
|
|
2963
3060
|
if (patterns.length === 0) {
|
|
2964
3061
|
const wsPath = PATH15.join(cwd, "pnpm-workspace.yaml");
|
|
2965
|
-
if (
|
|
2966
|
-
const content =
|
|
3062
|
+
if (existsSync14(wsPath)) {
|
|
3063
|
+
const content = readFileSync15(wsPath, "utf8");
|
|
2967
3064
|
const lines = content.split("\n");
|
|
2968
3065
|
let inPackages = false;
|
|
2969
3066
|
for (const line of lines) {
|
|
@@ -2994,14 +3091,14 @@ function resolveWorkspaceGlob(cwd, pattern) {
|
|
|
2994
3091
|
function walkGlob(basePath, parts, currentPath) {
|
|
2995
3092
|
if (parts.length === 0) {
|
|
2996
3093
|
const fullPath = PATH15.join(basePath, currentPath);
|
|
2997
|
-
if (
|
|
3094
|
+
if (existsSync14(PATH15.join(fullPath, "package.json"))) {
|
|
2998
3095
|
return [currentPath];
|
|
2999
3096
|
}
|
|
3000
3097
|
return [];
|
|
3001
3098
|
}
|
|
3002
3099
|
const [part, ...rest] = parts;
|
|
3003
3100
|
const dirPath = PATH15.join(basePath, currentPath);
|
|
3004
|
-
if (!
|
|
3101
|
+
if (!existsSync14(dirPath) || !statSync3(dirPath).isDirectory()) {
|
|
3005
3102
|
return [];
|
|
3006
3103
|
}
|
|
3007
3104
|
if (part === "*" || part === "**") {
|
|
@@ -3029,25 +3126,25 @@ function walkGlob(basePath, parts, currentPath) {
|
|
|
3029
3126
|
function convert({ target, verbose }) {
|
|
3030
3127
|
const validTargets = ["pnpm", "yarn"];
|
|
3031
3128
|
if (!validTargets.includes(target)) {
|
|
3032
|
-
console.error(
|
|
3129
|
+
console.error(chalk35.red(`Invalid target "${target}". Must be one of: ${validTargets.join(", ")}`));
|
|
3033
3130
|
return 1;
|
|
3034
3131
|
}
|
|
3035
3132
|
const cwd = process.cwd();
|
|
3036
3133
|
const currentPM = detectCurrentPM(cwd);
|
|
3037
3134
|
if (verbose) {
|
|
3038
|
-
console.log(
|
|
3039
|
-
console.log(
|
|
3135
|
+
console.log(chalk35.gray(`Current package manager: ${currentPM}`));
|
|
3136
|
+
console.log(chalk35.gray(`Target package manager: ${target}`));
|
|
3040
3137
|
}
|
|
3041
3138
|
if (currentPM === target) {
|
|
3042
|
-
console.log(
|
|
3139
|
+
console.log(chalk35.yellow(`Already using ${target}. Re-applying conversion to fix any incomplete steps...`));
|
|
3043
3140
|
}
|
|
3044
3141
|
if (currentPM === "unknown") {
|
|
3045
|
-
console.error(
|
|
3142
|
+
console.error(chalk35.red("Could not detect current package manager. No yarn.lock or pnpm-lock.yaml found."));
|
|
3046
3143
|
return 1;
|
|
3047
3144
|
}
|
|
3048
3145
|
const workspacePaths = findWorkspacePackagePaths(cwd);
|
|
3049
3146
|
if (verbose) {
|
|
3050
|
-
console.log(
|
|
3147
|
+
console.log(chalk35.gray(`Found ${workspacePaths.length} workspace packages`));
|
|
3051
3148
|
}
|
|
3052
3149
|
if (target === "pnpm") {
|
|
3053
3150
|
return convertToPnpm(cwd, workspacePaths);
|
|
@@ -3105,7 +3202,7 @@ var rebuild = ({ target }) => {
|
|
|
3105
3202
|
};
|
|
3106
3203
|
|
|
3107
3204
|
// src/actions/recompile.ts
|
|
3108
|
-
import
|
|
3205
|
+
import chalk36 from "chalk";
|
|
3109
3206
|
var recompile = async ({
|
|
3110
3207
|
verbose,
|
|
3111
3208
|
target,
|
|
@@ -3140,7 +3237,7 @@ var recompileAll = async ({
|
|
|
3140
3237
|
const start = Date.now();
|
|
3141
3238
|
const targetOptions = target ? ["-t", target] : [];
|
|
3142
3239
|
if (jobs) {
|
|
3143
|
-
console.log(
|
|
3240
|
+
console.log(chalk36.blue(`Jobs set to [${jobs}]`));
|
|
3144
3241
|
}
|
|
3145
3242
|
const foreachOptions = {
|
|
3146
3243
|
incremental,
|
|
@@ -3153,25 +3250,25 @@ var recompileAll = async ({
|
|
|
3153
3250
|
pm.foreachWorkspace("package-compile", targetOptions, foreachOptions)
|
|
3154
3251
|
]);
|
|
3155
3252
|
console.log(
|
|
3156
|
-
`${
|
|
3253
|
+
`${chalk36.gray("Recompiled in")} [${chalk36.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk36.gray("seconds")}`
|
|
3157
3254
|
);
|
|
3158
3255
|
return result;
|
|
3159
3256
|
};
|
|
3160
3257
|
|
|
3161
3258
|
// src/actions/relint.ts
|
|
3162
|
-
import
|
|
3259
|
+
import chalk37 from "chalk";
|
|
3163
3260
|
var relintPackage = ({
|
|
3164
3261
|
pkg,
|
|
3165
3262
|
fix: fix2,
|
|
3166
3263
|
verbose
|
|
3167
3264
|
}) => {
|
|
3168
|
-
console.log(
|
|
3265
|
+
console.log(chalk37.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
3169
3266
|
const start = Date.now();
|
|
3170
3267
|
const pm = getPackageManager();
|
|
3171
3268
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
3172
3269
|
pm.runInWorkspace(pkg, fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint")
|
|
3173
3270
|
]);
|
|
3174
|
-
console.log(
|
|
3271
|
+
console.log(chalk37.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk37.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk37.gray("seconds")}`));
|
|
3175
3272
|
return result;
|
|
3176
3273
|
};
|
|
3177
3274
|
var relint = ({
|
|
@@ -3191,13 +3288,13 @@ var relint = ({
|
|
|
3191
3288
|
});
|
|
3192
3289
|
};
|
|
3193
3290
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
3194
|
-
console.log(
|
|
3291
|
+
console.log(chalk37.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
3195
3292
|
const start = Date.now();
|
|
3196
3293
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
3197
3294
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
3198
3295
|
["eslint", fixOptions]
|
|
3199
3296
|
]);
|
|
3200
|
-
console.log(
|
|
3297
|
+
console.log(chalk37.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk37.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk37.gray("seconds")}`));
|
|
3201
3298
|
return result;
|
|
3202
3299
|
};
|
|
3203
3300
|
|
|
@@ -3641,7 +3738,7 @@ var xyCommonCommands = (args) => {
|
|
|
3641
3738
|
};
|
|
3642
3739
|
|
|
3643
3740
|
// src/xy/lint/cycleCommand.ts
|
|
3644
|
-
import
|
|
3741
|
+
import chalk38 from "chalk";
|
|
3645
3742
|
var cycleCommand = {
|
|
3646
3743
|
command: "cycle [package]",
|
|
3647
3744
|
describe: "Cycle - Check for dependency cycles",
|
|
@@ -3652,12 +3749,12 @@ var cycleCommand = {
|
|
|
3652
3749
|
const start = Date.now();
|
|
3653
3750
|
if (argv.verbose) console.log("Cycle");
|
|
3654
3751
|
process.exitCode = await cycle({ pkg: argv.package });
|
|
3655
|
-
console.log(
|
|
3752
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
3656
3753
|
}
|
|
3657
3754
|
};
|
|
3658
3755
|
|
|
3659
3756
|
// src/xy/lint/deplintCommand.ts
|
|
3660
|
-
import
|
|
3757
|
+
import chalk39 from "chalk";
|
|
3661
3758
|
var deplintCommand = {
|
|
3662
3759
|
command: "deplint [package]",
|
|
3663
3760
|
describe: "Deplint - Run Deplint",
|
|
@@ -3695,12 +3792,12 @@ var deplintCommand = {
|
|
|
3695
3792
|
peerDeps: !!argv.peerDeps,
|
|
3696
3793
|
verbose: !!argv.verbose
|
|
3697
3794
|
});
|
|
3698
|
-
console.log(
|
|
3795
|
+
console.log(chalk39.blue(`Finished in ${Date.now() - start}ms`));
|
|
3699
3796
|
}
|
|
3700
3797
|
};
|
|
3701
3798
|
|
|
3702
3799
|
// src/xy/lint/fixCommand.ts
|
|
3703
|
-
import
|
|
3800
|
+
import chalk40 from "chalk";
|
|
3704
3801
|
var fixCommand = {
|
|
3705
3802
|
command: "fix [package]",
|
|
3706
3803
|
describe: "Fix - Run Eslint w/fix",
|
|
@@ -3711,12 +3808,12 @@ var fixCommand = {
|
|
|
3711
3808
|
const start = Date.now();
|
|
3712
3809
|
if (argv.verbose) console.log("Fix");
|
|
3713
3810
|
process.exitCode = fix();
|
|
3714
|
-
console.log(
|
|
3811
|
+
console.log(chalk40.blue(`Finished in ${Date.now() - start}ms`));
|
|
3715
3812
|
}
|
|
3716
3813
|
};
|
|
3717
3814
|
|
|
3718
3815
|
// src/xy/lint/knipCommand.ts
|
|
3719
|
-
import
|
|
3816
|
+
import chalk41 from "chalk";
|
|
3720
3817
|
var knipCommand = {
|
|
3721
3818
|
command: "knip",
|
|
3722
3819
|
describe: "Knip - Run Knip",
|
|
@@ -3727,12 +3824,12 @@ var knipCommand = {
|
|
|
3727
3824
|
if (argv.verbose) console.log("Knip");
|
|
3728
3825
|
const start = Date.now();
|
|
3729
3826
|
process.exitCode = knip();
|
|
3730
|
-
console.log(
|
|
3827
|
+
console.log(chalk41.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
3731
3828
|
}
|
|
3732
3829
|
};
|
|
3733
3830
|
|
|
3734
3831
|
// src/xy/lint/lintCommand.ts
|
|
3735
|
-
import
|
|
3832
|
+
import chalk42 from "chalk";
|
|
3736
3833
|
var lintCommand = {
|
|
3737
3834
|
command: "lint [package]",
|
|
3738
3835
|
describe: "Lint - Run Eslint",
|
|
@@ -3761,7 +3858,7 @@ var lintCommand = {
|
|
|
3761
3858
|
cache: argv.cache,
|
|
3762
3859
|
verbose: !!argv.verbose
|
|
3763
3860
|
});
|
|
3764
|
-
console.log(
|
|
3861
|
+
console.log(chalk42.blue(`Finished in ${Date.now() - start}ms`));
|
|
3765
3862
|
}
|
|
3766
3863
|
};
|
|
3767
3864
|
|
|
@@ -3803,7 +3900,7 @@ var packageLintCommand = {
|
|
|
3803
3900
|
};
|
|
3804
3901
|
|
|
3805
3902
|
// src/xy/lint/publintCommand.ts
|
|
3806
|
-
import
|
|
3903
|
+
import chalk43 from "chalk";
|
|
3807
3904
|
var publintCommand = {
|
|
3808
3905
|
command: "publint [package]",
|
|
3809
3906
|
describe: "Publint - Run Publint",
|
|
@@ -3814,12 +3911,12 @@ var publintCommand = {
|
|
|
3814
3911
|
if (argv.verbose) console.log("Publint");
|
|
3815
3912
|
const start = Date.now();
|
|
3816
3913
|
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
3817
|
-
console.log(
|
|
3914
|
+
console.log(chalk43.blue(`Finished in ${Date.now() - start}ms`));
|
|
3818
3915
|
}
|
|
3819
3916
|
};
|
|
3820
3917
|
|
|
3821
3918
|
// src/xy/lint/relintCommand.ts
|
|
3822
|
-
import
|
|
3919
|
+
import chalk44 from "chalk";
|
|
3823
3920
|
var relintCommand = {
|
|
3824
3921
|
command: "relint [package]",
|
|
3825
3922
|
describe: "Relint - Clean & Lint",
|
|
@@ -3830,12 +3927,12 @@ var relintCommand = {
|
|
|
3830
3927
|
if (argv.verbose) console.log("Relinting");
|
|
3831
3928
|
const start = Date.now();
|
|
3832
3929
|
process.exitCode = relint();
|
|
3833
|
-
console.log(
|
|
3930
|
+
console.log(chalk44.blue(`Finished in ${Date.now() - start}ms`));
|
|
3834
3931
|
}
|
|
3835
3932
|
};
|
|
3836
3933
|
|
|
3837
3934
|
// src/xy/lint/sonarCommand.ts
|
|
3838
|
-
import
|
|
3935
|
+
import chalk45 from "chalk";
|
|
3839
3936
|
var sonarCommand = {
|
|
3840
3937
|
command: "sonar",
|
|
3841
3938
|
describe: "Sonar - Run Sonar Check",
|
|
@@ -3846,7 +3943,7 @@ var sonarCommand = {
|
|
|
3846
3943
|
const start = Date.now();
|
|
3847
3944
|
if (argv.verbose) console.log("Sonar Check");
|
|
3848
3945
|
process.exitCode = sonar();
|
|
3849
|
-
console.log(
|
|
3946
|
+
console.log(chalk45.blue(`Finished in ${Date.now() - start}ms`));
|
|
3850
3947
|
}
|
|
3851
3948
|
};
|
|
3852
3949
|
|
|
@@ -3896,8 +3993,8 @@ var xyBase = async (plugins) => {
|
|
|
3896
3993
|
let args = xyBuildCommands(xyCommonCommands(xyLintCommands(options)));
|
|
3897
3994
|
if (plugins) args = plugins(args);
|
|
3898
3995
|
return await args.demandCommand(1).command("*", "", () => {
|
|
3899
|
-
console.error(
|
|
3900
|
-
console.log(
|
|
3996
|
+
console.error(chalk46.yellow(`Command not found [${chalk46.magenta(process.argv[2])}]`));
|
|
3997
|
+
console.log(chalk46.gray("Try 'xy --help' for list of commands"));
|
|
3901
3998
|
}).version().help().argv;
|
|
3902
3999
|
};
|
|
3903
4000
|
export {
|