@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/index.mjs
CHANGED
|
@@ -2524,18 +2524,245 @@ var license = async (pkg) => {
|
|
|
2524
2524
|
)).reduce((prev, value) => prev || value, 0);
|
|
2525
2525
|
};
|
|
2526
2526
|
|
|
2527
|
+
// src/actions/lintlint.ts
|
|
2528
|
+
import { readFileSync as readFileSync16, writeFileSync as writeFileSync6 } from "fs";
|
|
2529
|
+
import PATH10 from "path";
|
|
2530
|
+
import chalk32 from "chalk";
|
|
2531
|
+
import { findUp } from "find-up";
|
|
2532
|
+
function parseRuleValue(value) {
|
|
2533
|
+
if (typeof value === "string") {
|
|
2534
|
+
return { level: value };
|
|
2535
|
+
}
|
|
2536
|
+
if (typeof value === "number") {
|
|
2537
|
+
return { level: String(value) };
|
|
2538
|
+
}
|
|
2539
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
2540
|
+
return {
|
|
2541
|
+
level: String(value[0]),
|
|
2542
|
+
options: value.length > 1 ? value.slice(1) : void 0
|
|
2543
|
+
};
|
|
2544
|
+
}
|
|
2545
|
+
return void 0;
|
|
2546
|
+
}
|
|
2547
|
+
function normalizeLevel(level) {
|
|
2548
|
+
if (level === "0" || level === "off") return "off";
|
|
2549
|
+
if (level === "1" || level === "warn") return "warn";
|
|
2550
|
+
if (level === "2" || level === "error") return "error";
|
|
2551
|
+
return level;
|
|
2552
|
+
}
|
|
2553
|
+
function rulesMatch(a, b) {
|
|
2554
|
+
if (normalizeLevel(a.level) !== normalizeLevel(b.level)) return false;
|
|
2555
|
+
return JSON.stringify(a.options) === JSON.stringify(b.options);
|
|
2556
|
+
}
|
|
2557
|
+
function formatRule(entry) {
|
|
2558
|
+
if (entry.options) {
|
|
2559
|
+
return JSON.stringify([entry.level, ...entry.options]);
|
|
2560
|
+
}
|
|
2561
|
+
return JSON.stringify([entry.level]);
|
|
2562
|
+
}
|
|
2563
|
+
function mergeRulesFromBlocks(blocks) {
|
|
2564
|
+
const merged = /* @__PURE__ */ new Map();
|
|
2565
|
+
for (const block of blocks) {
|
|
2566
|
+
if (!block.rules) continue;
|
|
2567
|
+
for (const [name, value] of Object.entries(block.rules)) {
|
|
2568
|
+
const parsed = parseRuleValue(value);
|
|
2569
|
+
if (parsed) merged.set(name, parsed);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
return merged;
|
|
2573
|
+
}
|
|
2574
|
+
function detectSharedPackage(source) {
|
|
2575
|
+
if (source.includes("@xylabs/eslint-config-react-flat")) return "@xylabs/eslint-config-react-flat";
|
|
2576
|
+
if (source.includes("@xylabs/eslint-config-flat")) return "@xylabs/eslint-config-flat";
|
|
2577
|
+
return void 0;
|
|
2578
|
+
}
|
|
2579
|
+
function extractLocalRuleBlocks(source) {
|
|
2580
|
+
const blocks = [];
|
|
2581
|
+
const ruleBlockRegex = /\{\s*(?:files\s*:\s*\[.*?\]\s*,\s*)?rules\s*:\s*\{([^}]*(?:\{[^}]*\}[^}]*)*)\}/g;
|
|
2582
|
+
let match;
|
|
2583
|
+
while ((match = ruleBlockRegex.exec(source)) !== null) {
|
|
2584
|
+
blocks.push(match[1]);
|
|
2585
|
+
}
|
|
2586
|
+
return blocks;
|
|
2587
|
+
}
|
|
2588
|
+
function extractRulesFromSourceBlocks(blocks) {
|
|
2589
|
+
const rules2 = /* @__PURE__ */ new Map();
|
|
2590
|
+
for (const block of blocks) {
|
|
2591
|
+
const ruleRegex = /['"]([^'"]+)['"]\s*:\s*(\[[\s\S]*?\](?=\s*,|\s*$))/gm;
|
|
2592
|
+
let match;
|
|
2593
|
+
while ((match = ruleRegex.exec(block)) !== null) {
|
|
2594
|
+
rules2.set(match[1], match[2]);
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
return rules2;
|
|
2598
|
+
}
|
|
2599
|
+
async function resolveSharedConfig(configDir, sharedPkg) {
|
|
2600
|
+
try {
|
|
2601
|
+
const sharedModule = await import(sharedPkg);
|
|
2602
|
+
const config2 = sharedModule.config ?? sharedModule.default;
|
|
2603
|
+
if (Array.isArray(config2)) return config2;
|
|
2604
|
+
return [];
|
|
2605
|
+
} catch {
|
|
2606
|
+
const distPath = PATH10.resolve(configDir, "node_modules", sharedPkg, "dist", "node", "index.mjs");
|
|
2607
|
+
try {
|
|
2608
|
+
const sharedModule = await import(distPath);
|
|
2609
|
+
const config2 = sharedModule.config ?? sharedModule.default;
|
|
2610
|
+
if (Array.isArray(config2)) return config2;
|
|
2611
|
+
} catch {
|
|
2612
|
+
const neutralPath = PATH10.resolve(configDir, "node_modules", sharedPkg, "dist", "neutral", "index.mjs");
|
|
2613
|
+
const sharedModule = await import(neutralPath);
|
|
2614
|
+
const config2 = sharedModule.config ?? sharedModule.default;
|
|
2615
|
+
if (Array.isArray(config2)) return config2;
|
|
2616
|
+
}
|
|
2617
|
+
return [];
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
async function loadSharedRules(configDir, sharedPkg, verbose) {
|
|
2621
|
+
const sharedBlocks = await resolveSharedConfig(configDir, sharedPkg);
|
|
2622
|
+
const sharedRules = mergeRulesFromBlocks(sharedBlocks);
|
|
2623
|
+
if (verbose) {
|
|
2624
|
+
console.log(chalk32.gray(`Shared config defines ${sharedRules.size} rules`));
|
|
2625
|
+
}
|
|
2626
|
+
if (sharedRules.size === 0) {
|
|
2627
|
+
console.error(chalk32.red("Could not load rules from shared config. Is it installed and built?"));
|
|
2628
|
+
return void 0;
|
|
2629
|
+
}
|
|
2630
|
+
return sharedRules;
|
|
2631
|
+
}
|
|
2632
|
+
async function loadLocalRules(eslintConfigPath, source, verbose) {
|
|
2633
|
+
const localModule = await import(eslintConfigPath);
|
|
2634
|
+
const localConfig = localModule.default ?? localModule;
|
|
2635
|
+
const localBlocks = Array.isArray(localConfig) ? localConfig : [localConfig];
|
|
2636
|
+
const resolved = mergeRulesFromBlocks(localBlocks);
|
|
2637
|
+
const localRuleBlocks = extractLocalRuleBlocks(source);
|
|
2638
|
+
const explicit = extractRulesFromSourceBlocks(localRuleBlocks);
|
|
2639
|
+
if (verbose) {
|
|
2640
|
+
console.log(chalk32.gray(`Local config has ${explicit.size} explicit rule setting(s)`));
|
|
2641
|
+
}
|
|
2642
|
+
return { explicit, resolved };
|
|
2643
|
+
}
|
|
2644
|
+
function compareRules(explicitRuleNames, allResolvedRules, sharedRules) {
|
|
2645
|
+
const redundant = [];
|
|
2646
|
+
const overrides = [];
|
|
2647
|
+
const additions = [];
|
|
2648
|
+
for (const ruleName of explicitRuleNames.keys()) {
|
|
2649
|
+
const resolvedEntry = allResolvedRules.get(ruleName);
|
|
2650
|
+
const sharedEntry = sharedRules.get(ruleName);
|
|
2651
|
+
if (!resolvedEntry) continue;
|
|
2652
|
+
if (!sharedEntry) {
|
|
2653
|
+
additions.push({ local: resolvedEntry, rule: ruleName });
|
|
2654
|
+
} else if (rulesMatch(resolvedEntry, sharedEntry)) {
|
|
2655
|
+
redundant.push({
|
|
2656
|
+
local: resolvedEntry,
|
|
2657
|
+
rule: ruleName,
|
|
2658
|
+
shared: sharedEntry
|
|
2659
|
+
});
|
|
2660
|
+
} else {
|
|
2661
|
+
overrides.push({
|
|
2662
|
+
local: resolvedEntry,
|
|
2663
|
+
rule: ruleName,
|
|
2664
|
+
shared: sharedEntry
|
|
2665
|
+
});
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
return {
|
|
2669
|
+
additions,
|
|
2670
|
+
overrides,
|
|
2671
|
+
redundant
|
|
2672
|
+
};
|
|
2673
|
+
}
|
|
2674
|
+
function reportResults({
|
|
2675
|
+
additions,
|
|
2676
|
+
overrides,
|
|
2677
|
+
redundant
|
|
2678
|
+
}, verbose) {
|
|
2679
|
+
if (redundant.length > 0) {
|
|
2680
|
+
console.log(chalk32.yellow(`
|
|
2681
|
+
${redundant.length} redundant rule(s) (same as shared config \u2014 can be removed):`));
|
|
2682
|
+
for (const { rule, local } of redundant) {
|
|
2683
|
+
console.log(chalk32.yellow(` ${rule}: ${formatRule(local)}`));
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
if (overrides.length > 0) {
|
|
2687
|
+
console.log(chalk32.cyan(`
|
|
2688
|
+
${overrides.length} rule override(s) (different from shared config):`));
|
|
2689
|
+
for (const {
|
|
2690
|
+
rule,
|
|
2691
|
+
local,
|
|
2692
|
+
shared
|
|
2693
|
+
} of overrides) {
|
|
2694
|
+
console.log(chalk32.cyan(` ${rule}:`));
|
|
2695
|
+
console.log(chalk32.gray(` shared: ${formatRule(shared)}`));
|
|
2696
|
+
console.log(chalk32.white(` local: ${formatRule(local)}`));
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
if (additions.length > 0 && verbose) {
|
|
2700
|
+
console.log(chalk32.gray(`
|
|
2701
|
+
${additions.length} local addition(s) (not in shared config):`));
|
|
2702
|
+
for (const { rule, local } of additions) {
|
|
2703
|
+
console.log(chalk32.gray(` ${rule}: ${formatRule(local)}`));
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
if (redundant.length === 0 && overrides.length === 0) {
|
|
2707
|
+
console.log(chalk32.green("No redundant or overridden rules found"));
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
function fixRedundantRules(eslintConfigPath, source, redundant) {
|
|
2711
|
+
let updated = source;
|
|
2712
|
+
for (const { rule } of redundant) {
|
|
2713
|
+
const escaped = rule.replaceAll("/", String.raw`\/`);
|
|
2714
|
+
const pattern = new RegExp(String.raw`[ \t]*['"]${escaped}['"]\s*:\s*\[[^\]]*\],?[ \t]*\n?`, "g");
|
|
2715
|
+
updated = updated.replace(pattern, "");
|
|
2716
|
+
}
|
|
2717
|
+
updated = updated.replaceAll(/\n{3,}/g, "\n\n");
|
|
2718
|
+
if (updated !== source) {
|
|
2719
|
+
writeFileSync6(eslintConfigPath, updated, "utf8");
|
|
2720
|
+
console.log(chalk32.green(`
|
|
2721
|
+
Fixed: removed ${redundant.length} redundant rule(s)`));
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
async function lintlint({ fix: fix2, verbose } = {}) {
|
|
2725
|
+
const eslintConfigPath = await findUp("eslint.config.mjs");
|
|
2726
|
+
if (!eslintConfigPath) {
|
|
2727
|
+
console.error(chalk32.red("No eslint.config.mjs found"));
|
|
2728
|
+
return 1;
|
|
2729
|
+
}
|
|
2730
|
+
const configDir = PATH10.dirname(eslintConfigPath);
|
|
2731
|
+
if (verbose) {
|
|
2732
|
+
console.log(chalk32.gray(`Found config: ${eslintConfigPath}`));
|
|
2733
|
+
}
|
|
2734
|
+
const source = readFileSync16(eslintConfigPath, "utf8");
|
|
2735
|
+
const sharedPkg = detectSharedPackage(source);
|
|
2736
|
+
if (!sharedPkg) {
|
|
2737
|
+
console.log(chalk32.yellow("No @xylabs/eslint-config-flat or @xylabs/eslint-config-react-flat imports found"));
|
|
2738
|
+
return 0;
|
|
2739
|
+
}
|
|
2740
|
+
if (verbose) {
|
|
2741
|
+
console.log(chalk32.gray(`Shared package: ${sharedPkg}`));
|
|
2742
|
+
}
|
|
2743
|
+
const sharedRules = await loadSharedRules(configDir, sharedPkg, !!verbose);
|
|
2744
|
+
if (!sharedRules) return 1;
|
|
2745
|
+
const { explicit, resolved } = await loadLocalRules(eslintConfigPath, source, !!verbose);
|
|
2746
|
+
const results = compareRules(explicit, resolved, sharedRules);
|
|
2747
|
+
reportResults(results, !!verbose);
|
|
2748
|
+
if (results.redundant.length > 0 && fix2) {
|
|
2749
|
+
fixRedundantRules(eslintConfigPath, source, results.redundant);
|
|
2750
|
+
}
|
|
2751
|
+
return results.redundant.length > 0 && !fix2 ? 1 : 0;
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2527
2754
|
// src/actions/npmignore-gen.ts
|
|
2528
2755
|
var filename = ".npmignore";
|
|
2529
2756
|
var npmignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
2530
2757
|
|
|
2531
2758
|
// src/actions/package/clean-outputs.ts
|
|
2532
2759
|
import path8 from "path";
|
|
2533
|
-
import
|
|
2760
|
+
import chalk33 from "chalk";
|
|
2534
2761
|
var packageCleanOutputs = () => {
|
|
2535
2762
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
2536
2763
|
const pkgName = process.env.npm_package_name;
|
|
2537
2764
|
const folders = [path8.join(pkg, "dist"), path8.join(pkg, "build"), path8.join(pkg, "docs")];
|
|
2538
|
-
console.log(
|
|
2765
|
+
console.log(chalk33.green(`Cleaning Outputs [${pkgName}]`));
|
|
2539
2766
|
for (let folder of folders) {
|
|
2540
2767
|
deleteGlob(folder);
|
|
2541
2768
|
}
|
|
@@ -2544,11 +2771,11 @@ var packageCleanOutputs = () => {
|
|
|
2544
2771
|
|
|
2545
2772
|
// src/actions/package/clean-typescript.ts
|
|
2546
2773
|
import path9 from "path";
|
|
2547
|
-
import
|
|
2774
|
+
import chalk34 from "chalk";
|
|
2548
2775
|
var packageCleanTypescript = () => {
|
|
2549
2776
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
2550
2777
|
const pkgName = process.env.npm_package_name;
|
|
2551
|
-
console.log(
|
|
2778
|
+
console.log(chalk34.green(`Cleaning Typescript [${pkgName}]`));
|
|
2552
2779
|
const files = [path9.join(pkg, "*.tsbuildinfo"), path9.join(pkg, ".tsconfig.*"), path9.join(pkg, ".eslintcache")];
|
|
2553
2780
|
for (let file of files) {
|
|
2554
2781
|
deleteGlob(file);
|
|
@@ -2562,26 +2789,26 @@ var packageClean = async () => {
|
|
|
2562
2789
|
};
|
|
2563
2790
|
|
|
2564
2791
|
// src/actions/package/compile/compile.ts
|
|
2565
|
-
import
|
|
2792
|
+
import chalk39 from "chalk";
|
|
2566
2793
|
|
|
2567
2794
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
2568
|
-
import
|
|
2795
|
+
import chalk38 from "chalk";
|
|
2569
2796
|
import { build as build2, defineConfig } from "tsup";
|
|
2570
2797
|
|
|
2571
2798
|
// src/actions/package/compile/inputs.ts
|
|
2572
|
-
import
|
|
2799
|
+
import chalk35 from "chalk";
|
|
2573
2800
|
import { glob as glob2 } from "glob";
|
|
2574
2801
|
var getAllInputs = (srcDir, verbose = false) => {
|
|
2575
2802
|
return [...glob2.sync(`${srcDir}/**/*.ts`, { posix: true }).map((file) => {
|
|
2576
2803
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
2577
2804
|
if (verbose) {
|
|
2578
|
-
console.log(
|
|
2805
|
+
console.log(chalk35.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
2579
2806
|
}
|
|
2580
2807
|
return result;
|
|
2581
2808
|
}), ...glob2.sync(`${srcDir}/**/*.tsx`, { posix: true }).map((file) => {
|
|
2582
2809
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
2583
2810
|
if (verbose) {
|
|
2584
|
-
console.log(
|
|
2811
|
+
console.log(chalk35.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
2585
2812
|
}
|
|
2586
2813
|
return result;
|
|
2587
2814
|
})];
|
|
@@ -2643,7 +2870,7 @@ function deepMergeObjects(objects) {
|
|
|
2643
2870
|
|
|
2644
2871
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
2645
2872
|
import { cwd as cwd2 } from "process";
|
|
2646
|
-
import
|
|
2873
|
+
import chalk36 from "chalk";
|
|
2647
2874
|
import { createProgramFromConfig } from "tsc-prog";
|
|
2648
2875
|
import ts3, {
|
|
2649
2876
|
DiagnosticCategory,
|
|
@@ -2665,7 +2892,7 @@ var getCompilerOptions = (options = {}, fileName = "tsconfig.json") => {
|
|
|
2665
2892
|
var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", compilerOptionsParam, verbose = false) => {
|
|
2666
2893
|
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
2667
2894
|
if (verbose) {
|
|
2668
|
-
console.log(
|
|
2895
|
+
console.log(chalk36.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2669
2896
|
}
|
|
2670
2897
|
const configFilePath = ts3.findConfigFile(
|
|
2671
2898
|
"./",
|
|
@@ -2688,10 +2915,10 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
2688
2915
|
emitDeclarationOnly: true,
|
|
2689
2916
|
noEmit: false
|
|
2690
2917
|
};
|
|
2691
|
-
console.log(
|
|
2918
|
+
console.log(chalk36.cyan(`Validating Files: ${entries.length}`));
|
|
2692
2919
|
if (verbose) {
|
|
2693
2920
|
for (const entry of entries) {
|
|
2694
|
-
console.log(
|
|
2921
|
+
console.log(chalk36.grey(`Validating: ${entry}`));
|
|
2695
2922
|
}
|
|
2696
2923
|
}
|
|
2697
2924
|
try {
|
|
@@ -2727,7 +2954,7 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
2727
2954
|
return 0;
|
|
2728
2955
|
} finally {
|
|
2729
2956
|
if (verbose) {
|
|
2730
|
-
console.log(
|
|
2957
|
+
console.log(chalk36.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2731
2958
|
}
|
|
2732
2959
|
}
|
|
2733
2960
|
};
|
|
@@ -2735,7 +2962,7 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
2735
2962
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
2736
2963
|
import path10 from "path";
|
|
2737
2964
|
import { cwd as cwd3 } from "process";
|
|
2738
|
-
import
|
|
2965
|
+
import chalk37 from "chalk";
|
|
2739
2966
|
import { rollup } from "rollup";
|
|
2740
2967
|
import dts from "rollup-plugin-dts";
|
|
2741
2968
|
import nodeExternals from "rollup-plugin-node-externals";
|
|
@@ -2760,8 +2987,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
2760
2987
|
if (ignoredWarningCodes.has(warning.code ?? "")) {
|
|
2761
2988
|
return;
|
|
2762
2989
|
}
|
|
2763
|
-
console.warn(
|
|
2764
|
-
console.warn(
|
|
2990
|
+
console.warn(chalk37.yellow(`[${warning.code}] ${warning.message}`));
|
|
2991
|
+
console.warn(chalk37.gray(inputPath));
|
|
2765
2992
|
warn(warning);
|
|
2766
2993
|
}
|
|
2767
2994
|
});
|
|
@@ -2771,8 +2998,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
2771
2998
|
});
|
|
2772
2999
|
} catch (ex) {
|
|
2773
3000
|
const error = ex;
|
|
2774
|
-
console.warn(
|
|
2775
|
-
console.warn(
|
|
3001
|
+
console.warn(chalk37.red(error));
|
|
3002
|
+
console.warn(chalk37.gray(inputPath));
|
|
2776
3003
|
}
|
|
2777
3004
|
if (verbose) {
|
|
2778
3005
|
console.log(`Bundled declarations written to ${outputPath}`);
|
|
@@ -2780,7 +3007,7 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
2780
3007
|
}
|
|
2781
3008
|
var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build", verbose = false) => {
|
|
2782
3009
|
if (verbose) {
|
|
2783
|
-
console.log(
|
|
3010
|
+
console.log(chalk37.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2784
3011
|
console.log(`Entries: ${entries.join(", ")}`);
|
|
2785
3012
|
}
|
|
2786
3013
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
@@ -2804,7 +3031,7 @@ var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build",
|
|
|
2804
3031
|
await bundleDts(`${srcRoot}/${entryTypeName}`, `${outDir}/${entryTypeName}`, platform, { compilerOptions }, verbose);
|
|
2805
3032
|
}));
|
|
2806
3033
|
if (verbose) {
|
|
2807
|
-
console.log(
|
|
3034
|
+
console.log(chalk37.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2808
3035
|
}
|
|
2809
3036
|
return 0;
|
|
2810
3037
|
};
|
|
@@ -2816,15 +3043,15 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
2816
3043
|
console.log(`compileFolder [${srcDir}, ${options?.outDir}]`);
|
|
2817
3044
|
}
|
|
2818
3045
|
if (entries.length === 0) {
|
|
2819
|
-
console.warn(
|
|
3046
|
+
console.warn(chalk38.yellow(`No entries found in ${srcDir} to compile`));
|
|
2820
3047
|
return 0;
|
|
2821
3048
|
}
|
|
2822
3049
|
if (verbose) {
|
|
2823
|
-
console.log(
|
|
3050
|
+
console.log(chalk38.gray(`buildDir [${buildDir}]`));
|
|
2824
3051
|
}
|
|
2825
3052
|
const validationResult = packageCompileTsc(options?.platform ?? "neutral", entries, srcDir, buildDir, void 0, verbose);
|
|
2826
3053
|
if (validationResult !== 0) {
|
|
2827
|
-
console.error(
|
|
3054
|
+
console.error(chalk38.red(`Compile:Validation had ${validationResult} errors`));
|
|
2828
3055
|
return validationResult;
|
|
2829
3056
|
}
|
|
2830
3057
|
const optionsParams = tsupOptions([{
|
|
@@ -2849,12 +3076,12 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
2849
3076
|
})
|
|
2850
3077
|
)).flat();
|
|
2851
3078
|
if (verbose) {
|
|
2852
|
-
console.log(
|
|
2853
|
-
console.log(
|
|
3079
|
+
console.log(chalk38.cyan(`TSUP:build:start [${srcDir}]`));
|
|
3080
|
+
console.log(chalk38.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
|
|
2854
3081
|
}
|
|
2855
3082
|
await Promise.all(optionsList.map((options2) => build2(options2)));
|
|
2856
3083
|
if (verbose) {
|
|
2857
|
-
console.log(
|
|
3084
|
+
console.log(chalk38.cyan(`TSUP:build:stop [${srcDir}]`));
|
|
2858
3085
|
}
|
|
2859
3086
|
if (bundleTypes) {
|
|
2860
3087
|
await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", buildDir, verbose);
|
|
@@ -2965,14 +3192,14 @@ var packageCompileTsup = async (config2) => {
|
|
|
2965
3192
|
// src/actions/package/compile/compile.ts
|
|
2966
3193
|
var packageCompile = async (inConfig = {}) => {
|
|
2967
3194
|
const pkg = process.env.INIT_CWD;
|
|
2968
|
-
console.log(
|
|
3195
|
+
console.log(chalk39.green(`Compiling ${pkg}`));
|
|
2969
3196
|
const config2 = await loadConfig(inConfig);
|
|
2970
3197
|
return await packageCompileTsup(config2);
|
|
2971
3198
|
};
|
|
2972
3199
|
|
|
2973
3200
|
// src/actions/package/copy-assets.ts
|
|
2974
3201
|
import path11 from "path/posix";
|
|
2975
|
-
import
|
|
3202
|
+
import chalk40 from "chalk";
|
|
2976
3203
|
import cpy2 from "cpy";
|
|
2977
3204
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
2978
3205
|
try {
|
|
@@ -2985,7 +3212,7 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
2985
3212
|
}
|
|
2986
3213
|
);
|
|
2987
3214
|
if (values.length > 0) {
|
|
2988
|
-
console.log(
|
|
3215
|
+
console.log(chalk40.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
2989
3216
|
}
|
|
2990
3217
|
for (const value of values) {
|
|
2991
3218
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -3052,7 +3279,7 @@ var packageCycle = async () => {
|
|
|
3052
3279
|
// src/actions/package/gen-docs.ts
|
|
3053
3280
|
import { existsSync as existsSync10 } from "fs";
|
|
3054
3281
|
import path12 from "path";
|
|
3055
|
-
import
|
|
3282
|
+
import chalk41 from "chalk";
|
|
3056
3283
|
import {
|
|
3057
3284
|
Application,
|
|
3058
3285
|
ArgumentsReader,
|
|
@@ -3156,7 +3383,7 @@ var runTypeDoc = async (app) => {
|
|
|
3156
3383
|
return ExitCodes.OutputError;
|
|
3157
3384
|
}
|
|
3158
3385
|
}
|
|
3159
|
-
console.log(
|
|
3386
|
+
console.log(chalk41.green(`${pkgName} - Ok`));
|
|
3160
3387
|
return ExitCodes.Ok;
|
|
3161
3388
|
};
|
|
3162
3389
|
|
|
@@ -3165,30 +3392,30 @@ import { readdirSync as readdirSync6 } from "fs";
|
|
|
3165
3392
|
import path13 from "path";
|
|
3166
3393
|
import { cwd as cwd4 } from "process";
|
|
3167
3394
|
import { pathToFileURL } from "url";
|
|
3168
|
-
import
|
|
3395
|
+
import chalk42 from "chalk";
|
|
3169
3396
|
import { ESLint } from "eslint";
|
|
3170
|
-
import { findUp } from "find-up";
|
|
3397
|
+
import { findUp as findUp2 } from "find-up";
|
|
3171
3398
|
import picomatch from "picomatch";
|
|
3172
3399
|
var dumpMessages = (lintResults) => {
|
|
3173
3400
|
const colors = ["white", "yellow", "red"];
|
|
3174
3401
|
const severity = ["none", "warning", "error"];
|
|
3175
3402
|
for (const lintResult of lintResults) {
|
|
3176
3403
|
if (lintResult.messages.length > 0) {
|
|
3177
|
-
console.log(
|
|
3404
|
+
console.log(chalk42.gray(`
|
|
3178
3405
|
${lintResult.filePath}`));
|
|
3179
3406
|
for (const message of lintResult.messages) {
|
|
3180
3407
|
console.log(
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3408
|
+
chalk42.gray(` ${message.line}:${message.column}`),
|
|
3409
|
+
chalk42[colors[message.severity]](` ${severity[message.severity]}`),
|
|
3410
|
+
chalk42.white(` ${message.message}`),
|
|
3411
|
+
chalk42.gray(` ${message.ruleId}`)
|
|
3185
3412
|
);
|
|
3186
3413
|
}
|
|
3187
3414
|
}
|
|
3188
3415
|
}
|
|
3189
3416
|
};
|
|
3190
3417
|
async function getRootESLintConfig() {
|
|
3191
|
-
const configPath = await
|
|
3418
|
+
const configPath = await findUp2("eslint.config.mjs");
|
|
3192
3419
|
if (configPath === void 0) {
|
|
3193
3420
|
throw new Error("eslint.config.mjs not found in the monorepo");
|
|
3194
3421
|
}
|
|
@@ -3219,10 +3446,10 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
3219
3446
|
cache
|
|
3220
3447
|
});
|
|
3221
3448
|
const files = getFiles(cwd4(), ignoreFolders);
|
|
3222
|
-
console.log(
|
|
3449
|
+
console.log(chalk42.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
3223
3450
|
if (verbose) {
|
|
3224
3451
|
for (const file of files) {
|
|
3225
|
-
console.log(
|
|
3452
|
+
console.log(chalk42.gray(` ${file}`));
|
|
3226
3453
|
}
|
|
3227
3454
|
}
|
|
3228
3455
|
const lintResults = await engine.lintFiles(files);
|
|
@@ -3233,32 +3460,32 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
3233
3460
|
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
3234
3461
|
const lintTime = Date.now() - start;
|
|
3235
3462
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
3236
|
-
console.log(
|
|
3463
|
+
console.log(chalk42.white(`Linted ${chalk42[filesCountColor](files.length)} files in ${chalk42[lintTimeColor](lintTime)}ms`));
|
|
3237
3464
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
3238
3465
|
};
|
|
3239
3466
|
|
|
3240
3467
|
// src/actions/package/publint.ts
|
|
3241
3468
|
import { promises as fs10 } from "fs";
|
|
3242
|
-
import
|
|
3469
|
+
import chalk43 from "chalk";
|
|
3243
3470
|
import sortPackageJson from "sort-package-json";
|
|
3244
3471
|
var customPubLint = (pkg) => {
|
|
3245
3472
|
let errorCount = 0;
|
|
3246
3473
|
let warningCount = 0;
|
|
3247
3474
|
if (pkg.files === void 0) {
|
|
3248
|
-
console.warn(
|
|
3475
|
+
console.warn(chalk43.yellow('Publint [custom]: "files" field is missing'));
|
|
3249
3476
|
warningCount++;
|
|
3250
3477
|
}
|
|
3251
3478
|
if (pkg.main !== void 0) {
|
|
3252
|
-
console.warn(
|
|
3479
|
+
console.warn(chalk43.yellow('Publint [custom]: "main" field is deprecated, use "exports" instead'));
|
|
3253
3480
|
warningCount++;
|
|
3254
3481
|
}
|
|
3255
3482
|
if (pkg.sideEffects !== false) {
|
|
3256
|
-
console.warn(
|
|
3483
|
+
console.warn(chalk43.yellow('Publint [custom]: "sideEffects" field should be set to false'));
|
|
3257
3484
|
warningCount++;
|
|
3258
3485
|
}
|
|
3259
3486
|
if (pkg.resolutions !== void 0) {
|
|
3260
|
-
console.warn(
|
|
3261
|
-
console.warn(
|
|
3487
|
+
console.warn(chalk43.yellow('Publint [custom]: "resolutions" in use'));
|
|
3488
|
+
console.warn(chalk43.gray(JSON.stringify(pkg.resolutions, null, 2)));
|
|
3262
3489
|
warningCount++;
|
|
3263
3490
|
}
|
|
3264
3491
|
return [errorCount, warningCount];
|
|
@@ -3268,8 +3495,8 @@ var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
|
3268
3495
|
const sortedPkg = sortPackageJson(await fs10.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
3269
3496
|
await fs10.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
3270
3497
|
const pkg = JSON.parse(await fs10.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
3271
|
-
console.log(
|
|
3272
|
-
console.log(
|
|
3498
|
+
console.log(chalk43.green(`Publint: ${pkg.name}`));
|
|
3499
|
+
console.log(chalk43.gray(pkgDir));
|
|
3273
3500
|
const { publint: publint2 } = await import("publint");
|
|
3274
3501
|
const { messages } = await publint2({
|
|
3275
3502
|
level: "suggestion",
|
|
@@ -3280,22 +3507,22 @@ var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
|
3280
3507
|
for (const message of messages) {
|
|
3281
3508
|
switch (message.type) {
|
|
3282
3509
|
case "error": {
|
|
3283
|
-
console.error(
|
|
3510
|
+
console.error(chalk43.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
3284
3511
|
break;
|
|
3285
3512
|
}
|
|
3286
3513
|
case "warning": {
|
|
3287
|
-
console.warn(
|
|
3514
|
+
console.warn(chalk43.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
3288
3515
|
break;
|
|
3289
3516
|
}
|
|
3290
3517
|
default: {
|
|
3291
|
-
console.log(
|
|
3518
|
+
console.log(chalk43.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
3292
3519
|
break;
|
|
3293
3520
|
}
|
|
3294
3521
|
}
|
|
3295
3522
|
}
|
|
3296
3523
|
const [errorCount, warningCount] = customPubLint(pkg);
|
|
3297
3524
|
if (verbose) {
|
|
3298
|
-
console.log(
|
|
3525
|
+
console.log(chalk43.gray(`Publint [Finish]: ${pkgDir} [${messages.length + errorCount + warningCount} messages]`));
|
|
3299
3526
|
}
|
|
3300
3527
|
return messages.filter((message) => message.type === "error").length + errorCount;
|
|
3301
3528
|
};
|
|
@@ -3306,9 +3533,9 @@ var packageRecompile = async () => {
|
|
|
3306
3533
|
};
|
|
3307
3534
|
|
|
3308
3535
|
// src/actions/package-lint.ts
|
|
3309
|
-
import { readFileSync as
|
|
3310
|
-
import
|
|
3311
|
-
import
|
|
3536
|
+
import { readFileSync as readFileSync17, writeFileSync as writeFileSync7 } from "fs";
|
|
3537
|
+
import PATH11 from "path";
|
|
3538
|
+
import chalk44 from "chalk";
|
|
3312
3539
|
import picomatch2 from "picomatch";
|
|
3313
3540
|
function emptyResult() {
|
|
3314
3541
|
return {
|
|
@@ -3318,12 +3545,12 @@ function emptyResult() {
|
|
|
3318
3545
|
};
|
|
3319
3546
|
}
|
|
3320
3547
|
function readRootPackageJson(cwd5) {
|
|
3321
|
-
const raw =
|
|
3548
|
+
const raw = readFileSync17(PATH11.resolve(cwd5, "package.json"), "utf8");
|
|
3322
3549
|
return JSON.parse(raw);
|
|
3323
3550
|
}
|
|
3324
3551
|
function writeRootPackageJson(cwd5, pkg) {
|
|
3325
|
-
const path14 =
|
|
3326
|
-
|
|
3552
|
+
const path14 = PATH11.resolve(cwd5, "package.json");
|
|
3553
|
+
writeFileSync7(path14, `${JSON.stringify(pkg, null, 2)}
|
|
3327
3554
|
`, "utf8");
|
|
3328
3555
|
}
|
|
3329
3556
|
function isMonorepo(pkg) {
|
|
@@ -3350,7 +3577,7 @@ function checkRootPrivate(pkg) {
|
|
|
3350
3577
|
function fixRootPrivate(cwd5, pkg) {
|
|
3351
3578
|
pkg.private = true;
|
|
3352
3579
|
writeRootPackageJson(cwd5, pkg);
|
|
3353
|
-
console.log(
|
|
3580
|
+
console.log(chalk44.green(' \u2714 Fixed: set "private": true in root package.json'));
|
|
3354
3581
|
}
|
|
3355
3582
|
function checkNoPublishConfigOnPrivate(pkg) {
|
|
3356
3583
|
const result = emptyResult();
|
|
@@ -3362,7 +3589,7 @@ function checkNoPublishConfigOnPrivate(pkg) {
|
|
|
3362
3589
|
function fixNoPublishConfigOnPrivate(cwd5, pkg) {
|
|
3363
3590
|
delete pkg.publishConfig;
|
|
3364
3591
|
writeRootPackageJson(cwd5, pkg);
|
|
3365
|
-
console.log(
|
|
3592
|
+
console.log(chalk44.green(" \u2714 Fixed: removed publishConfig from private root package.json"));
|
|
3366
3593
|
}
|
|
3367
3594
|
function checkDiscoverable(pkg, workspaces) {
|
|
3368
3595
|
const result = emptyResult();
|
|
@@ -3381,22 +3608,22 @@ function logResults(label, result, fix2) {
|
|
|
3381
3608
|
let errors = 0;
|
|
3382
3609
|
let fixed = 0;
|
|
3383
3610
|
for (const error of result.errors) {
|
|
3384
|
-
console.log(
|
|
3611
|
+
console.log(chalk44.red(` \u2717 ${error}`));
|
|
3385
3612
|
errors++;
|
|
3386
3613
|
}
|
|
3387
3614
|
for (const fixable of result.fixable) {
|
|
3388
3615
|
if (fix2) {
|
|
3389
3616
|
fixed++;
|
|
3390
3617
|
} else {
|
|
3391
|
-
console.log(
|
|
3618
|
+
console.log(chalk44.red(` \u2717 ${fixable} (fixable)`));
|
|
3392
3619
|
errors++;
|
|
3393
3620
|
}
|
|
3394
3621
|
}
|
|
3395
3622
|
for (const warning of result.warnings) {
|
|
3396
|
-
console.log(
|
|
3623
|
+
console.log(chalk44.yellow(` \u26A0 ${warning}`));
|
|
3397
3624
|
}
|
|
3398
3625
|
if (errors === 0 && fixed === 0 && result.warnings.length === 0) {
|
|
3399
|
-
console.log(
|
|
3626
|
+
console.log(chalk44.green(` \u2713 ${label}`));
|
|
3400
3627
|
}
|
|
3401
3628
|
return { errors, fixed };
|
|
3402
3629
|
}
|
|
@@ -3416,14 +3643,14 @@ function runChecks(entries, cwd5, pkg, fix2) {
|
|
|
3416
3643
|
}
|
|
3417
3644
|
function logSummary(errors, fixed) {
|
|
3418
3645
|
if (fixed > 0) {
|
|
3419
|
-
console.log(
|
|
3646
|
+
console.log(chalk44.green(`
|
|
3420
3647
|
Fixed ${fixed} issue(s)`));
|
|
3421
3648
|
}
|
|
3422
3649
|
if (errors > 0) {
|
|
3423
|
-
console.log(
|
|
3650
|
+
console.log(chalk44.red(`
|
|
3424
3651
|
${errors} error(s) found`));
|
|
3425
3652
|
} else if (fixed === 0) {
|
|
3426
|
-
console.log(
|
|
3653
|
+
console.log(chalk44.green("\n All checks passed"));
|
|
3427
3654
|
}
|
|
3428
3655
|
}
|
|
3429
3656
|
function packageLintMonorepo(fix2 = false) {
|
|
@@ -3432,14 +3659,14 @@ function packageLintMonorepo(fix2 = false) {
|
|
|
3432
3659
|
try {
|
|
3433
3660
|
pkg = readRootPackageJson(cwd5);
|
|
3434
3661
|
} catch {
|
|
3435
|
-
console.error(
|
|
3662
|
+
console.error(chalk44.red("Could not read package.json"));
|
|
3436
3663
|
return 1;
|
|
3437
3664
|
}
|
|
3438
3665
|
if (!isMonorepo(pkg)) {
|
|
3439
|
-
console.log(
|
|
3666
|
+
console.log(chalk44.gray("Not a monorepo \u2014 skipping package-lint checks"));
|
|
3440
3667
|
return 0;
|
|
3441
3668
|
}
|
|
3442
|
-
console.log(
|
|
3669
|
+
console.log(chalk44.green("Package Lint"));
|
|
3443
3670
|
const workspaces = yarnWorkspaces();
|
|
3444
3671
|
const checks = [
|
|
3445
3672
|
{
|
|
@@ -3513,7 +3740,7 @@ var rebuild = ({ target }) => {
|
|
|
3513
3740
|
};
|
|
3514
3741
|
|
|
3515
3742
|
// src/actions/recompile.ts
|
|
3516
|
-
import
|
|
3743
|
+
import chalk45 from "chalk";
|
|
3517
3744
|
var recompile = async ({
|
|
3518
3745
|
verbose,
|
|
3519
3746
|
target,
|
|
@@ -3549,7 +3776,7 @@ var recompileAll = async ({
|
|
|
3549
3776
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
3550
3777
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
3551
3778
|
if (jobs) {
|
|
3552
|
-
console.log(
|
|
3779
|
+
console.log(chalk45.blue(`Jobs set to [${jobs}]`));
|
|
3553
3780
|
}
|
|
3554
3781
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
3555
3782
|
[
|
|
@@ -3580,7 +3807,7 @@ var recompileAll = async ({
|
|
|
3580
3807
|
]
|
|
3581
3808
|
]);
|
|
3582
3809
|
console.log(
|
|
3583
|
-
`${
|
|
3810
|
+
`${chalk45.gray("Recompiled in")} [${chalk45.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk45.gray("seconds")}`
|
|
3584
3811
|
);
|
|
3585
3812
|
return result;
|
|
3586
3813
|
};
|
|
@@ -3611,13 +3838,13 @@ var reinstall = () => {
|
|
|
3611
3838
|
};
|
|
3612
3839
|
|
|
3613
3840
|
// src/actions/relint.ts
|
|
3614
|
-
import
|
|
3841
|
+
import chalk46 from "chalk";
|
|
3615
3842
|
var relintPackage = ({
|
|
3616
3843
|
pkg,
|
|
3617
3844
|
fix: fix2,
|
|
3618
3845
|
verbose
|
|
3619
3846
|
}) => {
|
|
3620
|
-
console.log(
|
|
3847
|
+
console.log(chalk46.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
3621
3848
|
const start = Date.now();
|
|
3622
3849
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
3623
3850
|
["yarn", [
|
|
@@ -3627,7 +3854,7 @@ var relintPackage = ({
|
|
|
3627
3854
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
3628
3855
|
]]
|
|
3629
3856
|
]);
|
|
3630
|
-
console.log(
|
|
3857
|
+
console.log(chalk46.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk46.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk46.gray("seconds")}`));
|
|
3631
3858
|
return result;
|
|
3632
3859
|
};
|
|
3633
3860
|
var relint = ({
|
|
@@ -3647,21 +3874,31 @@ var relint = ({
|
|
|
3647
3874
|
});
|
|
3648
3875
|
};
|
|
3649
3876
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
3650
|
-
console.log(
|
|
3877
|
+
console.log(chalk46.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
3651
3878
|
const start = Date.now();
|
|
3652
3879
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
3653
3880
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
3654
3881
|
["yarn", ["eslint", ...fixOptions]]
|
|
3655
3882
|
]);
|
|
3656
|
-
console.log(
|
|
3883
|
+
console.log(chalk46.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk46.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk46.gray("seconds")}`));
|
|
3657
3884
|
return result;
|
|
3658
3885
|
};
|
|
3659
3886
|
|
|
3660
3887
|
// src/actions/retest.ts
|
|
3661
|
-
|
|
3662
|
-
return
|
|
3888
|
+
function isWorkspace(target) {
|
|
3889
|
+
return yarnWorkspaces().some((ws) => ws.name === target);
|
|
3890
|
+
}
|
|
3891
|
+
var retest = ({ target } = {}) => {
|
|
3892
|
+
if (target && isWorkspace(target)) {
|
|
3893
|
+
return runSteps(`Re-Test [${target}]`, [
|
|
3894
|
+
["yarn", ["workspace", target, "run", "vitest", "--clearCache"]],
|
|
3895
|
+
["yarn", ["workspace", target, "run", "vitest", "."]]
|
|
3896
|
+
]);
|
|
3897
|
+
}
|
|
3898
|
+
const path14 = target ?? ".";
|
|
3899
|
+
return runSteps("Re-Test", [
|
|
3663
3900
|
["yarn", ["vitest", "--clearCache"]],
|
|
3664
|
-
["yarn", ["vitest",
|
|
3901
|
+
["yarn", ["vitest", path14]]
|
|
3665
3902
|
]);
|
|
3666
3903
|
};
|
|
3667
3904
|
|
|
@@ -3671,17 +3908,24 @@ var sonar = () => {
|
|
|
3671
3908
|
};
|
|
3672
3909
|
|
|
3673
3910
|
// src/actions/statics.ts
|
|
3674
|
-
import
|
|
3911
|
+
import chalk47 from "chalk";
|
|
3675
3912
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
3676
3913
|
var statics = () => {
|
|
3677
|
-
console.log(
|
|
3914
|
+
console.log(chalk47.green("Check Required Static Dependencies"));
|
|
3678
3915
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
3679
3916
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
3680
3917
|
};
|
|
3681
3918
|
|
|
3682
3919
|
// src/actions/test.ts
|
|
3683
|
-
|
|
3684
|
-
return
|
|
3920
|
+
function isWorkspace2(target) {
|
|
3921
|
+
return yarnWorkspaces().some((ws) => ws.name === target);
|
|
3922
|
+
}
|
|
3923
|
+
var test = ({ target } = {}) => {
|
|
3924
|
+
if (target && isWorkspace2(target)) {
|
|
3925
|
+
return runSteps(`Test [${target}]`, [["yarn", ["workspace", target, "run", "vitest", "."]]]);
|
|
3926
|
+
}
|
|
3927
|
+
const path14 = target ?? ".";
|
|
3928
|
+
return runSteps("Test", [["yarn", ["vitest", path14]]]);
|
|
3685
3929
|
};
|
|
3686
3930
|
|
|
3687
3931
|
// src/actions/up.ts
|
|
@@ -4081,21 +4325,27 @@ var readmeCommand = {
|
|
|
4081
4325
|
|
|
4082
4326
|
// src/xy/common/retestCommand.ts
|
|
4083
4327
|
var retestCommand = {
|
|
4084
|
-
command: "retest",
|
|
4085
|
-
describe: "Re-Test - Run
|
|
4328
|
+
command: "retest [target]",
|
|
4329
|
+
describe: "Re-Test - Run Vitest Tests with cleaned cache",
|
|
4330
|
+
builder: (yargs2) => {
|
|
4331
|
+
return yargs2.positional("target", { describe: "Package name or file/folder path to test" });
|
|
4332
|
+
},
|
|
4086
4333
|
handler: (argv) => {
|
|
4087
|
-
if (argv.verbose) console.log(
|
|
4088
|
-
process.exitCode = retest();
|
|
4334
|
+
if (argv.verbose) console.log(`Re-Testing: ${argv.target ?? "all"}`);
|
|
4335
|
+
process.exitCode = retest({ target: argv.target });
|
|
4089
4336
|
}
|
|
4090
4337
|
};
|
|
4091
4338
|
|
|
4092
4339
|
// src/xy/common/testCommand.ts
|
|
4093
4340
|
var testCommand = {
|
|
4094
|
-
command: "test",
|
|
4095
|
-
describe: "Test - Run
|
|
4341
|
+
command: "test [target]",
|
|
4342
|
+
describe: "Test - Run Vitest Tests",
|
|
4343
|
+
builder: (yargs2) => {
|
|
4344
|
+
return yargs2.positional("target", { describe: "Package name or file/folder path to test" });
|
|
4345
|
+
},
|
|
4096
4346
|
handler: (argv) => {
|
|
4097
|
-
if (argv.verbose) console.log(
|
|
4098
|
-
process.exitCode = test();
|
|
4347
|
+
if (argv.verbose) console.log(`Testing: ${argv.target ?? "all"}`);
|
|
4348
|
+
process.exitCode = test({ target: argv.target });
|
|
4099
4349
|
}
|
|
4100
4350
|
};
|
|
4101
4351
|
|
|
@@ -4263,7 +4513,7 @@ var xyInstallCommands = (args) => {
|
|
|
4263
4513
|
};
|
|
4264
4514
|
|
|
4265
4515
|
// src/xy/lint/cycleCommand.ts
|
|
4266
|
-
import
|
|
4516
|
+
import chalk48 from "chalk";
|
|
4267
4517
|
var cycleCommand = {
|
|
4268
4518
|
command: "cycle [package]",
|
|
4269
4519
|
describe: "Cycle - Check for dependency cycles",
|
|
@@ -4274,12 +4524,12 @@ var cycleCommand = {
|
|
|
4274
4524
|
const start = Date.now();
|
|
4275
4525
|
if (argv.verbose) console.log("Cycle");
|
|
4276
4526
|
process.exitCode = await cycle({ pkg: argv.package });
|
|
4277
|
-
console.log(
|
|
4527
|
+
console.log(chalk48.blue(`Finished in ${Date.now() - start}ms`));
|
|
4278
4528
|
}
|
|
4279
4529
|
};
|
|
4280
4530
|
|
|
4281
4531
|
// src/xy/lint/deplintCommand.ts
|
|
4282
|
-
import
|
|
4532
|
+
import chalk49 from "chalk";
|
|
4283
4533
|
var deplintCommand = {
|
|
4284
4534
|
command: "deplint [package]",
|
|
4285
4535
|
describe: "Deplint - Run Deplint",
|
|
@@ -4317,12 +4567,12 @@ var deplintCommand = {
|
|
|
4317
4567
|
peerDeps: !!argv.peerDeps,
|
|
4318
4568
|
verbose: !!argv.verbose
|
|
4319
4569
|
});
|
|
4320
|
-
console.log(
|
|
4570
|
+
console.log(chalk49.blue(`Finished in ${Date.now() - start}ms`));
|
|
4321
4571
|
}
|
|
4322
4572
|
};
|
|
4323
4573
|
|
|
4324
4574
|
// src/xy/lint/fixCommand.ts
|
|
4325
|
-
import
|
|
4575
|
+
import chalk50 from "chalk";
|
|
4326
4576
|
var fixCommand = {
|
|
4327
4577
|
command: "fix [package]",
|
|
4328
4578
|
describe: "Fix - Run Eslint w/fix",
|
|
@@ -4333,12 +4583,12 @@ var fixCommand = {
|
|
|
4333
4583
|
const start = Date.now();
|
|
4334
4584
|
if (argv.verbose) console.log("Fix");
|
|
4335
4585
|
process.exitCode = fix();
|
|
4336
|
-
console.log(
|
|
4586
|
+
console.log(chalk50.blue(`Finished in ${Date.now() - start}ms`));
|
|
4337
4587
|
}
|
|
4338
4588
|
};
|
|
4339
4589
|
|
|
4340
4590
|
// src/xy/lint/knipCommand.ts
|
|
4341
|
-
import
|
|
4591
|
+
import chalk51 from "chalk";
|
|
4342
4592
|
var knipCommand = {
|
|
4343
4593
|
command: "knip",
|
|
4344
4594
|
describe: "Knip - Run Knip",
|
|
@@ -4349,12 +4599,12 @@ var knipCommand = {
|
|
|
4349
4599
|
if (argv.verbose) console.log("Knip");
|
|
4350
4600
|
const start = Date.now();
|
|
4351
4601
|
process.exitCode = knip();
|
|
4352
|
-
console.log(
|
|
4602
|
+
console.log(chalk51.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
4353
4603
|
}
|
|
4354
4604
|
};
|
|
4355
4605
|
|
|
4356
4606
|
// src/xy/lint/lintCommand.ts
|
|
4357
|
-
import
|
|
4607
|
+
import chalk52 from "chalk";
|
|
4358
4608
|
var lintCommand = {
|
|
4359
4609
|
command: "lint [package]",
|
|
4360
4610
|
describe: "Lint - Run Eslint",
|
|
@@ -4383,7 +4633,27 @@ var lintCommand = {
|
|
|
4383
4633
|
cache: argv.cache,
|
|
4384
4634
|
verbose: !!argv.verbose
|
|
4385
4635
|
});
|
|
4386
|
-
console.log(
|
|
4636
|
+
console.log(chalk52.blue(`Finished in ${Date.now() - start}ms`));
|
|
4637
|
+
}
|
|
4638
|
+
};
|
|
4639
|
+
|
|
4640
|
+
// src/xy/lint/lintlintCommand.ts
|
|
4641
|
+
var lintlintCommand = {
|
|
4642
|
+
command: "lintlint",
|
|
4643
|
+
describe: "Lint Lint - Check for redundant or overridden ESLint rules vs shared config",
|
|
4644
|
+
builder: (yargs2) => {
|
|
4645
|
+
return yargs2.option("fix", {
|
|
4646
|
+
default: false,
|
|
4647
|
+
description: "Remove redundant rules from local config",
|
|
4648
|
+
type: "boolean"
|
|
4649
|
+
});
|
|
4650
|
+
},
|
|
4651
|
+
handler: async (argv) => {
|
|
4652
|
+
if (argv.verbose) console.log("Lint Lint");
|
|
4653
|
+
process.exitCode = await lintlint({
|
|
4654
|
+
fix: argv.fix,
|
|
4655
|
+
verbose: !!argv.verbose
|
|
4656
|
+
});
|
|
4387
4657
|
}
|
|
4388
4658
|
};
|
|
4389
4659
|
|
|
@@ -4405,7 +4675,7 @@ var packageLintCommand = {
|
|
|
4405
4675
|
};
|
|
4406
4676
|
|
|
4407
4677
|
// src/xy/lint/publintCommand.ts
|
|
4408
|
-
import
|
|
4678
|
+
import chalk53 from "chalk";
|
|
4409
4679
|
var publintCommand = {
|
|
4410
4680
|
command: "publint [package]",
|
|
4411
4681
|
describe: "Publint - Run Publint",
|
|
@@ -4416,12 +4686,12 @@ var publintCommand = {
|
|
|
4416
4686
|
if (argv.verbose) console.log("Publint");
|
|
4417
4687
|
const start = Date.now();
|
|
4418
4688
|
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
4419
|
-
console.log(
|
|
4689
|
+
console.log(chalk53.blue(`Finished in ${Date.now() - start}ms`));
|
|
4420
4690
|
}
|
|
4421
4691
|
};
|
|
4422
4692
|
|
|
4423
4693
|
// src/xy/lint/relintCommand.ts
|
|
4424
|
-
import
|
|
4694
|
+
import chalk54 from "chalk";
|
|
4425
4695
|
var relintCommand = {
|
|
4426
4696
|
command: "relint [package]",
|
|
4427
4697
|
describe: "Relint - Clean & Lint",
|
|
@@ -4432,12 +4702,12 @@ var relintCommand = {
|
|
|
4432
4702
|
if (argv.verbose) console.log("Relinting");
|
|
4433
4703
|
const start = Date.now();
|
|
4434
4704
|
process.exitCode = relint();
|
|
4435
|
-
console.log(
|
|
4705
|
+
console.log(chalk54.blue(`Finished in ${Date.now() - start}ms`));
|
|
4436
4706
|
}
|
|
4437
4707
|
};
|
|
4438
4708
|
|
|
4439
4709
|
// src/xy/lint/sonarCommand.ts
|
|
4440
|
-
import
|
|
4710
|
+
import chalk55 from "chalk";
|
|
4441
4711
|
var sonarCommand = {
|
|
4442
4712
|
command: "sonar",
|
|
4443
4713
|
describe: "Sonar - Run Sonar Check",
|
|
@@ -4448,17 +4718,17 @@ var sonarCommand = {
|
|
|
4448
4718
|
const start = Date.now();
|
|
4449
4719
|
if (argv.verbose) console.log("Sonar Check");
|
|
4450
4720
|
process.exitCode = sonar();
|
|
4451
|
-
console.log(
|
|
4721
|
+
console.log(chalk55.blue(`Finished in ${Date.now() - start}ms`));
|
|
4452
4722
|
}
|
|
4453
4723
|
};
|
|
4454
4724
|
|
|
4455
4725
|
// src/xy/lint/index.ts
|
|
4456
4726
|
var xyLintCommands = (args) => {
|
|
4457
|
-
return args.command(cycleCommand).command(lintCommand).command(deplintCommand).command(fixCommand).command(relintCommand).command(publintCommand).command(knipCommand).command(packageLintCommand).command(sonarCommand);
|
|
4727
|
+
return args.command(cycleCommand).command(lintCommand).command(lintlintCommand).command(deplintCommand).command(fixCommand).command(relintCommand).command(publintCommand).command(knipCommand).command(packageLintCommand).command(sonarCommand);
|
|
4458
4728
|
};
|
|
4459
4729
|
|
|
4460
4730
|
// src/xy/xy.ts
|
|
4461
|
-
import
|
|
4731
|
+
import chalk56 from "chalk";
|
|
4462
4732
|
|
|
4463
4733
|
// src/xy/xyParseOptions.ts
|
|
4464
4734
|
import yargs from "yargs";
|
|
@@ -4499,8 +4769,8 @@ var xyParseOptions = () => {
|
|
|
4499
4769
|
var xy = async () => {
|
|
4500
4770
|
const options = xyParseOptions();
|
|
4501
4771
|
return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
|
|
4502
|
-
console.error(
|
|
4503
|
-
console.log(
|
|
4772
|
+
console.error(chalk56.yellow(`Command not found [${chalk56.magenta(process.argv[2])}]`));
|
|
4773
|
+
console.log(chalk56.gray("Try 'yarn xy --help' for list of commands"));
|
|
4504
4774
|
}).version().help().argv;
|
|
4505
4775
|
};
|
|
4506
4776
|
export {
|
|
@@ -4568,6 +4838,7 @@ export {
|
|
|
4568
4838
|
lint,
|
|
4569
4839
|
lintAllPackages,
|
|
4570
4840
|
lintPackage,
|
|
4841
|
+
lintlint,
|
|
4571
4842
|
loadConfig,
|
|
4572
4843
|
loadPackageConfig,
|
|
4573
4844
|
multiLineToJSONArray,
|