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