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