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