@xylabs/ts-scripts-yarn3 7.4.26 → 7.4.28
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/index.mjs +333 -88
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/lintlint.mjs +230 -0
- package/dist/actions/lintlint.mjs.map +1 -0
- package/dist/actions/retest.mjs +27 -5
- package/dist/actions/retest.mjs.map +1 -1
- package/dist/actions/test.mjs +23 -4
- package/dist/actions/test.mjs.map +1 -1
- package/dist/bin/xy.mjs +331 -61
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +15 -3
- package/dist/index.mjs +387 -116
- package/dist/index.mjs.map +1 -1
- package/dist/xy/common/index.mjs +36 -13
- package/dist/xy/common/index.mjs.map +1 -1
- package/dist/xy/common/retestCommand.mjs +34 -9
- package/dist/xy/common/retestCommand.mjs.map +1 -1
- package/dist/xy/common/testCommand.mjs +30 -8
- package/dist/xy/common/testCommand.mjs.map +1 -1
- package/dist/xy/index.mjs +331 -61
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/lint/index.mjs +285 -38
- package/dist/xy/lint/index.mjs.map +1 -1
- package/dist/xy/lint/lintlintCommand.mjs +250 -0
- package/dist/xy/lint/lintlintCommand.mjs.map +1 -0
- package/dist/xy/xy.mjs +331 -61
- 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 chalk44 from "chalk";
|
|
3
3
|
|
|
4
4
|
// src/actions/build.ts
|
|
5
5
|
import chalk10 from "chalk";
|
|
@@ -2449,14 +2449,241 @@ var license = async (pkg) => {
|
|
|
2449
2449
|
)).reduce((prev, value) => prev || value, 0);
|
|
2450
2450
|
};
|
|
2451
2451
|
|
|
2452
|
+
// src/actions/lintlint.ts
|
|
2453
|
+
import { readFileSync as readFileSync14, writeFileSync as writeFileSync6 } from "fs";
|
|
2454
|
+
import PATH10 from "path";
|
|
2455
|
+
import chalk31 from "chalk";
|
|
2456
|
+
import { findUp } from "find-up";
|
|
2457
|
+
function parseRuleValue(value) {
|
|
2458
|
+
if (typeof value === "string") {
|
|
2459
|
+
return { level: value };
|
|
2460
|
+
}
|
|
2461
|
+
if (typeof value === "number") {
|
|
2462
|
+
return { level: String(value) };
|
|
2463
|
+
}
|
|
2464
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
2465
|
+
return {
|
|
2466
|
+
level: String(value[0]),
|
|
2467
|
+
options: value.length > 1 ? value.slice(1) : void 0
|
|
2468
|
+
};
|
|
2469
|
+
}
|
|
2470
|
+
return void 0;
|
|
2471
|
+
}
|
|
2472
|
+
function normalizeLevel(level) {
|
|
2473
|
+
if (level === "0" || level === "off") return "off";
|
|
2474
|
+
if (level === "1" || level === "warn") return "warn";
|
|
2475
|
+
if (level === "2" || level === "error") return "error";
|
|
2476
|
+
return level;
|
|
2477
|
+
}
|
|
2478
|
+
function rulesMatch(a, b) {
|
|
2479
|
+
if (normalizeLevel(a.level) !== normalizeLevel(b.level)) return false;
|
|
2480
|
+
return JSON.stringify(a.options) === JSON.stringify(b.options);
|
|
2481
|
+
}
|
|
2482
|
+
function formatRule(entry) {
|
|
2483
|
+
if (entry.options) {
|
|
2484
|
+
return JSON.stringify([entry.level, ...entry.options]);
|
|
2485
|
+
}
|
|
2486
|
+
return JSON.stringify([entry.level]);
|
|
2487
|
+
}
|
|
2488
|
+
function mergeRulesFromBlocks(blocks) {
|
|
2489
|
+
const merged = /* @__PURE__ */ new Map();
|
|
2490
|
+
for (const block of blocks) {
|
|
2491
|
+
if (!block.rules) continue;
|
|
2492
|
+
for (const [name, value] of Object.entries(block.rules)) {
|
|
2493
|
+
const parsed = parseRuleValue(value);
|
|
2494
|
+
if (parsed) merged.set(name, parsed);
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
return merged;
|
|
2498
|
+
}
|
|
2499
|
+
function detectSharedPackage(source) {
|
|
2500
|
+
if (source.includes("@xylabs/eslint-config-react-flat")) return "@xylabs/eslint-config-react-flat";
|
|
2501
|
+
if (source.includes("@xylabs/eslint-config-flat")) return "@xylabs/eslint-config-flat";
|
|
2502
|
+
return void 0;
|
|
2503
|
+
}
|
|
2504
|
+
function extractLocalRuleBlocks(source) {
|
|
2505
|
+
const blocks = [];
|
|
2506
|
+
const ruleBlockRegex = /\{\s*(?:files\s*:\s*\[.*?\]\s*,\s*)?rules\s*:\s*\{([^}]*(?:\{[^}]*\}[^}]*)*)\}/g;
|
|
2507
|
+
let match;
|
|
2508
|
+
while ((match = ruleBlockRegex.exec(source)) !== null) {
|
|
2509
|
+
blocks.push(match[1]);
|
|
2510
|
+
}
|
|
2511
|
+
return blocks;
|
|
2512
|
+
}
|
|
2513
|
+
function extractRulesFromSourceBlocks(blocks) {
|
|
2514
|
+
const rules2 = /* @__PURE__ */ new Map();
|
|
2515
|
+
for (const block of blocks) {
|
|
2516
|
+
const ruleRegex = /['"]([^'"]+)['"]\s*:\s*(\[[\s\S]*?\](?=\s*,|\s*$))/gm;
|
|
2517
|
+
let match;
|
|
2518
|
+
while ((match = ruleRegex.exec(block)) !== null) {
|
|
2519
|
+
rules2.set(match[1], match[2]);
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
return rules2;
|
|
2523
|
+
}
|
|
2524
|
+
async function resolveSharedConfig(configDir, sharedPkg) {
|
|
2525
|
+
try {
|
|
2526
|
+
const sharedModule = await import(sharedPkg);
|
|
2527
|
+
const config2 = sharedModule.config ?? sharedModule.default;
|
|
2528
|
+
if (Array.isArray(config2)) return config2;
|
|
2529
|
+
return [];
|
|
2530
|
+
} catch {
|
|
2531
|
+
const distPath = PATH10.resolve(configDir, "node_modules", sharedPkg, "dist", "node", "index.mjs");
|
|
2532
|
+
try {
|
|
2533
|
+
const sharedModule = await import(distPath);
|
|
2534
|
+
const config2 = sharedModule.config ?? sharedModule.default;
|
|
2535
|
+
if (Array.isArray(config2)) return config2;
|
|
2536
|
+
} catch {
|
|
2537
|
+
const neutralPath = PATH10.resolve(configDir, "node_modules", sharedPkg, "dist", "neutral", "index.mjs");
|
|
2538
|
+
const sharedModule = await import(neutralPath);
|
|
2539
|
+
const config2 = sharedModule.config ?? sharedModule.default;
|
|
2540
|
+
if (Array.isArray(config2)) return config2;
|
|
2541
|
+
}
|
|
2542
|
+
return [];
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
async function loadSharedRules(configDir, sharedPkg, verbose) {
|
|
2546
|
+
const sharedBlocks = await resolveSharedConfig(configDir, sharedPkg);
|
|
2547
|
+
const sharedRules = mergeRulesFromBlocks(sharedBlocks);
|
|
2548
|
+
if (verbose) {
|
|
2549
|
+
console.log(chalk31.gray(`Shared config defines ${sharedRules.size} rules`));
|
|
2550
|
+
}
|
|
2551
|
+
if (sharedRules.size === 0) {
|
|
2552
|
+
console.error(chalk31.red("Could not load rules from shared config. Is it installed and built?"));
|
|
2553
|
+
return void 0;
|
|
2554
|
+
}
|
|
2555
|
+
return sharedRules;
|
|
2556
|
+
}
|
|
2557
|
+
async function loadLocalRules(eslintConfigPath, source, verbose) {
|
|
2558
|
+
const localModule = await import(eslintConfigPath);
|
|
2559
|
+
const localConfig = localModule.default ?? localModule;
|
|
2560
|
+
const localBlocks = Array.isArray(localConfig) ? localConfig : [localConfig];
|
|
2561
|
+
const resolved = mergeRulesFromBlocks(localBlocks);
|
|
2562
|
+
const localRuleBlocks = extractLocalRuleBlocks(source);
|
|
2563
|
+
const explicit = extractRulesFromSourceBlocks(localRuleBlocks);
|
|
2564
|
+
if (verbose) {
|
|
2565
|
+
console.log(chalk31.gray(`Local config has ${explicit.size} explicit rule setting(s)`));
|
|
2566
|
+
}
|
|
2567
|
+
return { explicit, resolved };
|
|
2568
|
+
}
|
|
2569
|
+
function compareRules(explicitRuleNames, allResolvedRules, sharedRules) {
|
|
2570
|
+
const redundant = [];
|
|
2571
|
+
const overrides = [];
|
|
2572
|
+
const additions = [];
|
|
2573
|
+
for (const ruleName of explicitRuleNames.keys()) {
|
|
2574
|
+
const resolvedEntry = allResolvedRules.get(ruleName);
|
|
2575
|
+
const sharedEntry = sharedRules.get(ruleName);
|
|
2576
|
+
if (!resolvedEntry) continue;
|
|
2577
|
+
if (!sharedEntry) {
|
|
2578
|
+
additions.push({ local: resolvedEntry, rule: ruleName });
|
|
2579
|
+
} else if (rulesMatch(resolvedEntry, sharedEntry)) {
|
|
2580
|
+
redundant.push({
|
|
2581
|
+
local: resolvedEntry,
|
|
2582
|
+
rule: ruleName,
|
|
2583
|
+
shared: sharedEntry
|
|
2584
|
+
});
|
|
2585
|
+
} else {
|
|
2586
|
+
overrides.push({
|
|
2587
|
+
local: resolvedEntry,
|
|
2588
|
+
rule: ruleName,
|
|
2589
|
+
shared: sharedEntry
|
|
2590
|
+
});
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
return {
|
|
2594
|
+
additions,
|
|
2595
|
+
overrides,
|
|
2596
|
+
redundant
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
function reportResults({
|
|
2600
|
+
additions,
|
|
2601
|
+
overrides,
|
|
2602
|
+
redundant
|
|
2603
|
+
}, verbose) {
|
|
2604
|
+
if (redundant.length > 0) {
|
|
2605
|
+
console.log(chalk31.yellow(`
|
|
2606
|
+
${redundant.length} redundant rule(s) (same as shared config \u2014 can be removed):`));
|
|
2607
|
+
for (const { rule, local } of redundant) {
|
|
2608
|
+
console.log(chalk31.yellow(` ${rule}: ${formatRule(local)}`));
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
if (overrides.length > 0) {
|
|
2612
|
+
console.log(chalk31.cyan(`
|
|
2613
|
+
${overrides.length} rule override(s) (different from shared config):`));
|
|
2614
|
+
for (const {
|
|
2615
|
+
rule,
|
|
2616
|
+
local,
|
|
2617
|
+
shared
|
|
2618
|
+
} of overrides) {
|
|
2619
|
+
console.log(chalk31.cyan(` ${rule}:`));
|
|
2620
|
+
console.log(chalk31.gray(` shared: ${formatRule(shared)}`));
|
|
2621
|
+
console.log(chalk31.white(` local: ${formatRule(local)}`));
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2624
|
+
if (additions.length > 0 && verbose) {
|
|
2625
|
+
console.log(chalk31.gray(`
|
|
2626
|
+
${additions.length} local addition(s) (not in shared config):`));
|
|
2627
|
+
for (const { rule, local } of additions) {
|
|
2628
|
+
console.log(chalk31.gray(` ${rule}: ${formatRule(local)}`));
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
if (redundant.length === 0 && overrides.length === 0) {
|
|
2632
|
+
console.log(chalk31.green("No redundant or overridden rules found"));
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
function fixRedundantRules(eslintConfigPath, source, redundant) {
|
|
2636
|
+
let updated = source;
|
|
2637
|
+
for (const { rule } of redundant) {
|
|
2638
|
+
const escaped = rule.replaceAll("/", String.raw`\/`);
|
|
2639
|
+
const pattern = new RegExp(String.raw`[ \t]*['"]${escaped}['"]\s*:\s*\[[^\]]*\],?[ \t]*\n?`, "g");
|
|
2640
|
+
updated = updated.replace(pattern, "");
|
|
2641
|
+
}
|
|
2642
|
+
updated = updated.replaceAll(/\n{3,}/g, "\n\n");
|
|
2643
|
+
if (updated !== source) {
|
|
2644
|
+
writeFileSync6(eslintConfigPath, updated, "utf8");
|
|
2645
|
+
console.log(chalk31.green(`
|
|
2646
|
+
Fixed: removed ${redundant.length} redundant rule(s)`));
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
async function lintlint({ fix: fix2, verbose } = {}) {
|
|
2650
|
+
const eslintConfigPath = await findUp("eslint.config.mjs");
|
|
2651
|
+
if (!eslintConfigPath) {
|
|
2652
|
+
console.error(chalk31.red("No eslint.config.mjs found"));
|
|
2653
|
+
return 1;
|
|
2654
|
+
}
|
|
2655
|
+
const configDir = PATH10.dirname(eslintConfigPath);
|
|
2656
|
+
if (verbose) {
|
|
2657
|
+
console.log(chalk31.gray(`Found config: ${eslintConfigPath}`));
|
|
2658
|
+
}
|
|
2659
|
+
const source = readFileSync14(eslintConfigPath, "utf8");
|
|
2660
|
+
const sharedPkg = detectSharedPackage(source);
|
|
2661
|
+
if (!sharedPkg) {
|
|
2662
|
+
console.log(chalk31.yellow("No @xylabs/eslint-config-flat or @xylabs/eslint-config-react-flat imports found"));
|
|
2663
|
+
return 0;
|
|
2664
|
+
}
|
|
2665
|
+
if (verbose) {
|
|
2666
|
+
console.log(chalk31.gray(`Shared package: ${sharedPkg}`));
|
|
2667
|
+
}
|
|
2668
|
+
const sharedRules = await loadSharedRules(configDir, sharedPkg, !!verbose);
|
|
2669
|
+
if (!sharedRules) return 1;
|
|
2670
|
+
const { explicit, resolved } = await loadLocalRules(eslintConfigPath, source, !!verbose);
|
|
2671
|
+
const results = compareRules(explicit, resolved, sharedRules);
|
|
2672
|
+
reportResults(results, !!verbose);
|
|
2673
|
+
if (results.redundant.length > 0 && fix2) {
|
|
2674
|
+
fixRedundantRules(eslintConfigPath, source, results.redundant);
|
|
2675
|
+
}
|
|
2676
|
+
return results.redundant.length > 0 && !fix2 ? 1 : 0;
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2452
2679
|
// src/actions/npmignore-gen.ts
|
|
2453
2680
|
var filename = ".npmignore";
|
|
2454
2681
|
var npmignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
2455
2682
|
|
|
2456
2683
|
// src/actions/package-lint.ts
|
|
2457
|
-
import { readFileSync as
|
|
2458
|
-
import
|
|
2459
|
-
import
|
|
2684
|
+
import { readFileSync as readFileSync15, writeFileSync as writeFileSync7 } from "fs";
|
|
2685
|
+
import PATH11 from "path";
|
|
2686
|
+
import chalk32 from "chalk";
|
|
2460
2687
|
import picomatch from "picomatch";
|
|
2461
2688
|
function emptyResult() {
|
|
2462
2689
|
return {
|
|
@@ -2466,12 +2693,12 @@ function emptyResult() {
|
|
|
2466
2693
|
};
|
|
2467
2694
|
}
|
|
2468
2695
|
function readRootPackageJson(cwd) {
|
|
2469
|
-
const raw =
|
|
2696
|
+
const raw = readFileSync15(PATH11.resolve(cwd, "package.json"), "utf8");
|
|
2470
2697
|
return JSON.parse(raw);
|
|
2471
2698
|
}
|
|
2472
2699
|
function writeRootPackageJson(cwd, pkg) {
|
|
2473
|
-
const path8 =
|
|
2474
|
-
|
|
2700
|
+
const path8 = PATH11.resolve(cwd, "package.json");
|
|
2701
|
+
writeFileSync7(path8, `${JSON.stringify(pkg, null, 2)}
|
|
2475
2702
|
`, "utf8");
|
|
2476
2703
|
}
|
|
2477
2704
|
function isMonorepo(pkg) {
|
|
@@ -2498,7 +2725,7 @@ function checkRootPrivate(pkg) {
|
|
|
2498
2725
|
function fixRootPrivate(cwd, pkg) {
|
|
2499
2726
|
pkg.private = true;
|
|
2500
2727
|
writeRootPackageJson(cwd, pkg);
|
|
2501
|
-
console.log(
|
|
2728
|
+
console.log(chalk32.green(' \u2714 Fixed: set "private": true in root package.json'));
|
|
2502
2729
|
}
|
|
2503
2730
|
function checkNoPublishConfigOnPrivate(pkg) {
|
|
2504
2731
|
const result = emptyResult();
|
|
@@ -2510,7 +2737,7 @@ function checkNoPublishConfigOnPrivate(pkg) {
|
|
|
2510
2737
|
function fixNoPublishConfigOnPrivate(cwd, pkg) {
|
|
2511
2738
|
delete pkg.publishConfig;
|
|
2512
2739
|
writeRootPackageJson(cwd, pkg);
|
|
2513
|
-
console.log(
|
|
2740
|
+
console.log(chalk32.green(" \u2714 Fixed: removed publishConfig from private root package.json"));
|
|
2514
2741
|
}
|
|
2515
2742
|
function checkDiscoverable(pkg, workspaces) {
|
|
2516
2743
|
const result = emptyResult();
|
|
@@ -2529,22 +2756,22 @@ function logResults(label, result, fix2) {
|
|
|
2529
2756
|
let errors = 0;
|
|
2530
2757
|
let fixed = 0;
|
|
2531
2758
|
for (const error of result.errors) {
|
|
2532
|
-
console.log(
|
|
2759
|
+
console.log(chalk32.red(` \u2717 ${error}`));
|
|
2533
2760
|
errors++;
|
|
2534
2761
|
}
|
|
2535
2762
|
for (const fixable of result.fixable) {
|
|
2536
2763
|
if (fix2) {
|
|
2537
2764
|
fixed++;
|
|
2538
2765
|
} else {
|
|
2539
|
-
console.log(
|
|
2766
|
+
console.log(chalk32.red(` \u2717 ${fixable} (fixable)`));
|
|
2540
2767
|
errors++;
|
|
2541
2768
|
}
|
|
2542
2769
|
}
|
|
2543
2770
|
for (const warning of result.warnings) {
|
|
2544
|
-
console.log(
|
|
2771
|
+
console.log(chalk32.yellow(` \u26A0 ${warning}`));
|
|
2545
2772
|
}
|
|
2546
2773
|
if (errors === 0 && fixed === 0 && result.warnings.length === 0) {
|
|
2547
|
-
console.log(
|
|
2774
|
+
console.log(chalk32.green(` \u2713 ${label}`));
|
|
2548
2775
|
}
|
|
2549
2776
|
return { errors, fixed };
|
|
2550
2777
|
}
|
|
@@ -2564,14 +2791,14 @@ function runChecks(entries, cwd, pkg, fix2) {
|
|
|
2564
2791
|
}
|
|
2565
2792
|
function logSummary(errors, fixed) {
|
|
2566
2793
|
if (fixed > 0) {
|
|
2567
|
-
console.log(
|
|
2794
|
+
console.log(chalk32.green(`
|
|
2568
2795
|
Fixed ${fixed} issue(s)`));
|
|
2569
2796
|
}
|
|
2570
2797
|
if (errors > 0) {
|
|
2571
|
-
console.log(
|
|
2798
|
+
console.log(chalk32.red(`
|
|
2572
2799
|
${errors} error(s) found`));
|
|
2573
2800
|
} else if (fixed === 0) {
|
|
2574
|
-
console.log(
|
|
2801
|
+
console.log(chalk32.green("\n All checks passed"));
|
|
2575
2802
|
}
|
|
2576
2803
|
}
|
|
2577
2804
|
function packageLintMonorepo(fix2 = false) {
|
|
@@ -2580,14 +2807,14 @@ function packageLintMonorepo(fix2 = false) {
|
|
|
2580
2807
|
try {
|
|
2581
2808
|
pkg = readRootPackageJson(cwd);
|
|
2582
2809
|
} catch {
|
|
2583
|
-
console.error(
|
|
2810
|
+
console.error(chalk32.red("Could not read package.json"));
|
|
2584
2811
|
return 1;
|
|
2585
2812
|
}
|
|
2586
2813
|
if (!isMonorepo(pkg)) {
|
|
2587
|
-
console.log(
|
|
2814
|
+
console.log(chalk32.gray("Not a monorepo \u2014 skipping package-lint checks"));
|
|
2588
2815
|
return 0;
|
|
2589
2816
|
}
|
|
2590
|
-
console.log(
|
|
2817
|
+
console.log(chalk32.green("Package Lint"));
|
|
2591
2818
|
const workspaces = yarnWorkspaces();
|
|
2592
2819
|
const checks = [
|
|
2593
2820
|
{
|
|
@@ -2661,7 +2888,7 @@ var rebuild = ({ target }) => {
|
|
|
2661
2888
|
};
|
|
2662
2889
|
|
|
2663
2890
|
// src/actions/recompile.ts
|
|
2664
|
-
import
|
|
2891
|
+
import chalk33 from "chalk";
|
|
2665
2892
|
var recompile = async ({
|
|
2666
2893
|
verbose,
|
|
2667
2894
|
target,
|
|
@@ -2697,7 +2924,7 @@ var recompileAll = async ({
|
|
|
2697
2924
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
2698
2925
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
2699
2926
|
if (jobs) {
|
|
2700
|
-
console.log(
|
|
2927
|
+
console.log(chalk33.blue(`Jobs set to [${jobs}]`));
|
|
2701
2928
|
}
|
|
2702
2929
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
2703
2930
|
[
|
|
@@ -2728,7 +2955,7 @@ var recompileAll = async ({
|
|
|
2728
2955
|
]
|
|
2729
2956
|
]);
|
|
2730
2957
|
console.log(
|
|
2731
|
-
`${
|
|
2958
|
+
`${chalk33.gray("Recompiled in")} [${chalk33.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk33.gray("seconds")}`
|
|
2732
2959
|
);
|
|
2733
2960
|
return result;
|
|
2734
2961
|
};
|
|
@@ -2759,13 +2986,13 @@ var reinstall = () => {
|
|
|
2759
2986
|
};
|
|
2760
2987
|
|
|
2761
2988
|
// src/actions/relint.ts
|
|
2762
|
-
import
|
|
2989
|
+
import chalk34 from "chalk";
|
|
2763
2990
|
var relintPackage = ({
|
|
2764
2991
|
pkg,
|
|
2765
2992
|
fix: fix2,
|
|
2766
2993
|
verbose
|
|
2767
2994
|
}) => {
|
|
2768
|
-
console.log(
|
|
2995
|
+
console.log(chalk34.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
2769
2996
|
const start = Date.now();
|
|
2770
2997
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
2771
2998
|
["yarn", [
|
|
@@ -2775,7 +3002,7 @@ var relintPackage = ({
|
|
|
2775
3002
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
2776
3003
|
]]
|
|
2777
3004
|
]);
|
|
2778
|
-
console.log(
|
|
3005
|
+
console.log(chalk34.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk34.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk34.gray("seconds")}`));
|
|
2779
3006
|
return result;
|
|
2780
3007
|
};
|
|
2781
3008
|
var relint = ({
|
|
@@ -2795,21 +3022,31 @@ var relint = ({
|
|
|
2795
3022
|
});
|
|
2796
3023
|
};
|
|
2797
3024
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
2798
|
-
console.log(
|
|
3025
|
+
console.log(chalk34.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
2799
3026
|
const start = Date.now();
|
|
2800
3027
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
2801
3028
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
2802
3029
|
["yarn", ["eslint", ...fixOptions]]
|
|
2803
3030
|
]);
|
|
2804
|
-
console.log(
|
|
3031
|
+
console.log(chalk34.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk34.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk34.gray("seconds")}`));
|
|
2805
3032
|
return result;
|
|
2806
3033
|
};
|
|
2807
3034
|
|
|
2808
3035
|
// src/actions/retest.ts
|
|
2809
|
-
|
|
2810
|
-
return
|
|
3036
|
+
function isWorkspace(target) {
|
|
3037
|
+
return yarnWorkspaces().some((ws) => ws.name === target);
|
|
3038
|
+
}
|
|
3039
|
+
var retest = ({ target } = {}) => {
|
|
3040
|
+
if (target && isWorkspace(target)) {
|
|
3041
|
+
return runSteps(`Re-Test [${target}]`, [
|
|
3042
|
+
["yarn", ["workspace", target, "run", "vitest", "--clearCache"]],
|
|
3043
|
+
["yarn", ["workspace", target, "run", "vitest", "."]]
|
|
3044
|
+
]);
|
|
3045
|
+
}
|
|
3046
|
+
const path8 = target ?? ".";
|
|
3047
|
+
return runSteps("Re-Test", [
|
|
2811
3048
|
["yarn", ["vitest", "--clearCache"]],
|
|
2812
|
-
["yarn", ["vitest",
|
|
3049
|
+
["yarn", ["vitest", path8]]
|
|
2813
3050
|
]);
|
|
2814
3051
|
};
|
|
2815
3052
|
|
|
@@ -2819,17 +3056,24 @@ var sonar = () => {
|
|
|
2819
3056
|
};
|
|
2820
3057
|
|
|
2821
3058
|
// src/actions/statics.ts
|
|
2822
|
-
import
|
|
3059
|
+
import chalk35 from "chalk";
|
|
2823
3060
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
2824
3061
|
var statics = () => {
|
|
2825
|
-
console.log(
|
|
3062
|
+
console.log(chalk35.green("Check Required Static Dependencies"));
|
|
2826
3063
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
2827
3064
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
2828
3065
|
};
|
|
2829
3066
|
|
|
2830
3067
|
// src/actions/test.ts
|
|
2831
|
-
|
|
2832
|
-
return
|
|
3068
|
+
function isWorkspace2(target) {
|
|
3069
|
+
return yarnWorkspaces().some((ws) => ws.name === target);
|
|
3070
|
+
}
|
|
3071
|
+
var test = ({ target } = {}) => {
|
|
3072
|
+
if (target && isWorkspace2(target)) {
|
|
3073
|
+
return runSteps(`Test [${target}]`, [["yarn", ["workspace", target, "run", "vitest", "."]]]);
|
|
3074
|
+
}
|
|
3075
|
+
const path8 = target ?? ".";
|
|
3076
|
+
return runSteps("Test", [["yarn", ["vitest", path8]]]);
|
|
2833
3077
|
};
|
|
2834
3078
|
|
|
2835
3079
|
// src/actions/up.ts
|
|
@@ -3221,21 +3465,27 @@ var readmeCommand = {
|
|
|
3221
3465
|
|
|
3222
3466
|
// src/xy/common/retestCommand.ts
|
|
3223
3467
|
var retestCommand = {
|
|
3224
|
-
command: "retest",
|
|
3225
|
-
describe: "Re-Test - Run
|
|
3468
|
+
command: "retest [target]",
|
|
3469
|
+
describe: "Re-Test - Run Vitest Tests with cleaned cache",
|
|
3470
|
+
builder: (yargs2) => {
|
|
3471
|
+
return yargs2.positional("target", { describe: "Package name or file/folder path to test" });
|
|
3472
|
+
},
|
|
3226
3473
|
handler: (argv) => {
|
|
3227
|
-
if (argv.verbose) console.log(
|
|
3228
|
-
process.exitCode = retest();
|
|
3474
|
+
if (argv.verbose) console.log(`Re-Testing: ${argv.target ?? "all"}`);
|
|
3475
|
+
process.exitCode = retest({ target: argv.target });
|
|
3229
3476
|
}
|
|
3230
3477
|
};
|
|
3231
3478
|
|
|
3232
3479
|
// src/xy/common/testCommand.ts
|
|
3233
3480
|
var testCommand = {
|
|
3234
|
-
command: "test",
|
|
3235
|
-
describe: "Test - Run
|
|
3481
|
+
command: "test [target]",
|
|
3482
|
+
describe: "Test - Run Vitest Tests",
|
|
3483
|
+
builder: (yargs2) => {
|
|
3484
|
+
return yargs2.positional("target", { describe: "Package name or file/folder path to test" });
|
|
3485
|
+
},
|
|
3236
3486
|
handler: (argv) => {
|
|
3237
|
-
if (argv.verbose) console.log(
|
|
3238
|
-
process.exitCode = test();
|
|
3487
|
+
if (argv.verbose) console.log(`Testing: ${argv.target ?? "all"}`);
|
|
3488
|
+
process.exitCode = test({ target: argv.target });
|
|
3239
3489
|
}
|
|
3240
3490
|
};
|
|
3241
3491
|
|
|
@@ -3403,7 +3653,7 @@ var xyInstallCommands = (args) => {
|
|
|
3403
3653
|
};
|
|
3404
3654
|
|
|
3405
3655
|
// src/xy/lint/cycleCommand.ts
|
|
3406
|
-
import
|
|
3656
|
+
import chalk36 from "chalk";
|
|
3407
3657
|
var cycleCommand = {
|
|
3408
3658
|
command: "cycle [package]",
|
|
3409
3659
|
describe: "Cycle - Check for dependency cycles",
|
|
@@ -3414,12 +3664,12 @@ var cycleCommand = {
|
|
|
3414
3664
|
const start = Date.now();
|
|
3415
3665
|
if (argv.verbose) console.log("Cycle");
|
|
3416
3666
|
process.exitCode = await cycle({ pkg: argv.package });
|
|
3417
|
-
console.log(
|
|
3667
|
+
console.log(chalk36.blue(`Finished in ${Date.now() - start}ms`));
|
|
3418
3668
|
}
|
|
3419
3669
|
};
|
|
3420
3670
|
|
|
3421
3671
|
// src/xy/lint/deplintCommand.ts
|
|
3422
|
-
import
|
|
3672
|
+
import chalk37 from "chalk";
|
|
3423
3673
|
var deplintCommand = {
|
|
3424
3674
|
command: "deplint [package]",
|
|
3425
3675
|
describe: "Deplint - Run Deplint",
|
|
@@ -3457,12 +3707,12 @@ var deplintCommand = {
|
|
|
3457
3707
|
peerDeps: !!argv.peerDeps,
|
|
3458
3708
|
verbose: !!argv.verbose
|
|
3459
3709
|
});
|
|
3460
|
-
console.log(
|
|
3710
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
3461
3711
|
}
|
|
3462
3712
|
};
|
|
3463
3713
|
|
|
3464
3714
|
// src/xy/lint/fixCommand.ts
|
|
3465
|
-
import
|
|
3715
|
+
import chalk38 from "chalk";
|
|
3466
3716
|
var fixCommand = {
|
|
3467
3717
|
command: "fix [package]",
|
|
3468
3718
|
describe: "Fix - Run Eslint w/fix",
|
|
@@ -3473,12 +3723,12 @@ var fixCommand = {
|
|
|
3473
3723
|
const start = Date.now();
|
|
3474
3724
|
if (argv.verbose) console.log("Fix");
|
|
3475
3725
|
process.exitCode = fix();
|
|
3476
|
-
console.log(
|
|
3726
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
3477
3727
|
}
|
|
3478
3728
|
};
|
|
3479
3729
|
|
|
3480
3730
|
// src/xy/lint/knipCommand.ts
|
|
3481
|
-
import
|
|
3731
|
+
import chalk39 from "chalk";
|
|
3482
3732
|
var knipCommand = {
|
|
3483
3733
|
command: "knip",
|
|
3484
3734
|
describe: "Knip - Run Knip",
|
|
@@ -3489,12 +3739,12 @@ var knipCommand = {
|
|
|
3489
3739
|
if (argv.verbose) console.log("Knip");
|
|
3490
3740
|
const start = Date.now();
|
|
3491
3741
|
process.exitCode = knip();
|
|
3492
|
-
console.log(
|
|
3742
|
+
console.log(chalk39.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
3493
3743
|
}
|
|
3494
3744
|
};
|
|
3495
3745
|
|
|
3496
3746
|
// src/xy/lint/lintCommand.ts
|
|
3497
|
-
import
|
|
3747
|
+
import chalk40 from "chalk";
|
|
3498
3748
|
var lintCommand = {
|
|
3499
3749
|
command: "lint [package]",
|
|
3500
3750
|
describe: "Lint - Run Eslint",
|
|
@@ -3523,7 +3773,27 @@ var lintCommand = {
|
|
|
3523
3773
|
cache: argv.cache,
|
|
3524
3774
|
verbose: !!argv.verbose
|
|
3525
3775
|
});
|
|
3526
|
-
console.log(
|
|
3776
|
+
console.log(chalk40.blue(`Finished in ${Date.now() - start}ms`));
|
|
3777
|
+
}
|
|
3778
|
+
};
|
|
3779
|
+
|
|
3780
|
+
// src/xy/lint/lintlintCommand.ts
|
|
3781
|
+
var lintlintCommand = {
|
|
3782
|
+
command: "lintlint",
|
|
3783
|
+
describe: "Lint Lint - Check for redundant or overridden ESLint rules vs shared config",
|
|
3784
|
+
builder: (yargs2) => {
|
|
3785
|
+
return yargs2.option("fix", {
|
|
3786
|
+
default: false,
|
|
3787
|
+
description: "Remove redundant rules from local config",
|
|
3788
|
+
type: "boolean"
|
|
3789
|
+
});
|
|
3790
|
+
},
|
|
3791
|
+
handler: async (argv) => {
|
|
3792
|
+
if (argv.verbose) console.log("Lint Lint");
|
|
3793
|
+
process.exitCode = await lintlint({
|
|
3794
|
+
fix: argv.fix,
|
|
3795
|
+
verbose: !!argv.verbose
|
|
3796
|
+
});
|
|
3527
3797
|
}
|
|
3528
3798
|
};
|
|
3529
3799
|
|
|
@@ -3545,7 +3815,7 @@ var packageLintCommand = {
|
|
|
3545
3815
|
};
|
|
3546
3816
|
|
|
3547
3817
|
// src/xy/lint/publintCommand.ts
|
|
3548
|
-
import
|
|
3818
|
+
import chalk41 from "chalk";
|
|
3549
3819
|
var publintCommand = {
|
|
3550
3820
|
command: "publint [package]",
|
|
3551
3821
|
describe: "Publint - Run Publint",
|
|
@@ -3556,12 +3826,12 @@ var publintCommand = {
|
|
|
3556
3826
|
if (argv.verbose) console.log("Publint");
|
|
3557
3827
|
const start = Date.now();
|
|
3558
3828
|
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
3559
|
-
console.log(
|
|
3829
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3560
3830
|
}
|
|
3561
3831
|
};
|
|
3562
3832
|
|
|
3563
3833
|
// src/xy/lint/relintCommand.ts
|
|
3564
|
-
import
|
|
3834
|
+
import chalk42 from "chalk";
|
|
3565
3835
|
var relintCommand = {
|
|
3566
3836
|
command: "relint [package]",
|
|
3567
3837
|
describe: "Relint - Clean & Lint",
|
|
@@ -3572,12 +3842,12 @@ var relintCommand = {
|
|
|
3572
3842
|
if (argv.verbose) console.log("Relinting");
|
|
3573
3843
|
const start = Date.now();
|
|
3574
3844
|
process.exitCode = relint();
|
|
3575
|
-
console.log(
|
|
3845
|
+
console.log(chalk42.blue(`Finished in ${Date.now() - start}ms`));
|
|
3576
3846
|
}
|
|
3577
3847
|
};
|
|
3578
3848
|
|
|
3579
3849
|
// src/xy/lint/sonarCommand.ts
|
|
3580
|
-
import
|
|
3850
|
+
import chalk43 from "chalk";
|
|
3581
3851
|
var sonarCommand = {
|
|
3582
3852
|
command: "sonar",
|
|
3583
3853
|
describe: "Sonar - Run Sonar Check",
|
|
@@ -3588,13 +3858,13 @@ var sonarCommand = {
|
|
|
3588
3858
|
const start = Date.now();
|
|
3589
3859
|
if (argv.verbose) console.log("Sonar Check");
|
|
3590
3860
|
process.exitCode = sonar();
|
|
3591
|
-
console.log(
|
|
3861
|
+
console.log(chalk43.blue(`Finished in ${Date.now() - start}ms`));
|
|
3592
3862
|
}
|
|
3593
3863
|
};
|
|
3594
3864
|
|
|
3595
3865
|
// src/xy/lint/index.ts
|
|
3596
3866
|
var xyLintCommands = (args) => {
|
|
3597
|
-
return args.command(cycleCommand).command(lintCommand).command(deplintCommand).command(fixCommand).command(relintCommand).command(publintCommand).command(knipCommand).command(packageLintCommand).command(sonarCommand);
|
|
3867
|
+
return args.command(cycleCommand).command(lintCommand).command(lintlintCommand).command(deplintCommand).command(fixCommand).command(relintCommand).command(publintCommand).command(knipCommand).command(packageLintCommand).command(sonarCommand);
|
|
3598
3868
|
};
|
|
3599
3869
|
|
|
3600
3870
|
// src/xy/xyParseOptions.ts
|
|
@@ -3636,8 +3906,8 @@ var xyParseOptions = () => {
|
|
|
3636
3906
|
var xy = async () => {
|
|
3637
3907
|
const options = xyParseOptions();
|
|
3638
3908
|
return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
|
|
3639
|
-
console.error(
|
|
3640
|
-
console.log(
|
|
3909
|
+
console.error(chalk44.yellow(`Command not found [${chalk44.magenta(process.argv[2])}]`));
|
|
3910
|
+
console.log(chalk44.gray("Try 'yarn xy --help' for list of commands"));
|
|
3641
3911
|
}).version().help().argv;
|
|
3642
3912
|
};
|
|
3643
3913
|
export {
|