@xylabs/toolchain 7.10.1 → 7.10.3
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 +162 -30
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/package/compile/XyConfig.mjs.map +1 -1
- package/dist/actions/package/compile/index.mjs.map +1 -1
- package/dist/actions/package/index.mjs.map +1 -1
- package/dist/actions/package/publint.mjs.map +1 -1
- package/dist/actions/packman/index.mjs +270 -112
- package/dist/actions/packman/index.mjs.map +1 -1
- package/dist/actions/packman/lint.mjs +203 -36
- package/dist/actions/packman/lint.mjs.map +1 -1
- package/dist/actions/publint.mjs.map +1 -1
- package/dist/bin/package/publint.mjs.map +1 -1
- package/dist/bin/xy.mjs +164 -32
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +21 -2
- package/dist/index.mjs +250 -92
- package/dist/index.mjs.map +1 -1
- package/dist/lib/deprecationMigrate.mjs +81 -46
- package/dist/lib/deprecationMigrate.mjs.map +1 -1
- package/dist/lib/index.mjs +75 -49
- package/dist/lib/index.mjs.map +1 -1
- package/dist/xy/common/checkCommand.mjs.map +1 -1
- package/dist/xy/common/index.mjs +164 -32
- package/dist/xy/common/index.mjs.map +1 -1
- package/dist/xy/common/packmanCommand.mjs +272 -114
- package/dist/xy/common/packmanCommand.mjs.map +1 -1
- package/dist/xy/index.mjs +164 -32
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/lint/index.mjs.map +1 -1
- package/dist/xy/lint/publintCommand.mjs.map +1 -1
- package/dist/xy/xy.mjs +164 -32
- package/dist/xy/xy.mjs.map +1 -1
- package/package.json +3 -3
package/dist/xy/common/index.mjs
CHANGED
|
@@ -2872,7 +2872,7 @@ function packageLintMonorepo(fix = false) {
|
|
|
2872
2872
|
fix: () => fixInternalDepVersions(cwd, workspaces),
|
|
2873
2873
|
label: "Internal deps/devDeps use correct version ranges"
|
|
2874
2874
|
};
|
|
2875
|
-
const
|
|
2875
|
+
const checks = [
|
|
2876
2876
|
{
|
|
2877
2877
|
check: () => checkRootPrivate(pkg),
|
|
2878
2878
|
fix: fixRootPrivate,
|
|
@@ -2924,7 +2924,7 @@ function packageLintMonorepo(fix = false) {
|
|
|
2924
2924
|
label: "Internal peerDeps use semver ranges (not workspace: protocol)"
|
|
2925
2925
|
}
|
|
2926
2926
|
];
|
|
2927
|
-
const { errors, fixed } = runChecks(
|
|
2927
|
+
const { errors, fixed } = runChecks(checks, cwd, pkg, fix);
|
|
2928
2928
|
logSummary(errors, fixed);
|
|
2929
2929
|
if (fix && fixed > 0) {
|
|
2930
2930
|
runInstall();
|
|
@@ -3547,6 +3547,41 @@ import {
|
|
|
3547
3547
|
} from "fs";
|
|
3548
3548
|
import PATH20 from "path";
|
|
3549
3549
|
import chalk31 from "chalk";
|
|
3550
|
+
var DEFAULT_MINIMUM_RELEASE_AGE = 4320;
|
|
3551
|
+
var DEFAULT_RELEASE_AGE_EXCLUDES = ["'@xylabs/*'", "'@xyo-network/*'"];
|
|
3552
|
+
function resolvePackmanConfig(cfg) {
|
|
3553
|
+
return {
|
|
3554
|
+
minimumReleaseAge: cfg?.minimumReleaseAge ?? DEFAULT_MINIMUM_RELEASE_AGE,
|
|
3555
|
+
minimumReleaseAgeExclude: cfg?.minimumReleaseAgeExclude ?? DEFAULT_RELEASE_AGE_EXCLUDES
|
|
3556
|
+
};
|
|
3557
|
+
}
|
|
3558
|
+
function readPnpmWorkspaceYaml(cwd) {
|
|
3559
|
+
const wsPath = PATH20.join(cwd, "pnpm-workspace.yaml");
|
|
3560
|
+
if (!existsSync19(wsPath)) return void 0;
|
|
3561
|
+
return readFileSync20(wsPath, "utf8");
|
|
3562
|
+
}
|
|
3563
|
+
function writePnpmWorkspaceYaml(cwd, content) {
|
|
3564
|
+
writeFileSync15(PATH20.join(cwd, "pnpm-workspace.yaml"), content, "utf8");
|
|
3565
|
+
}
|
|
3566
|
+
function parseYamlListSection(content, sectionName) {
|
|
3567
|
+
const items = [];
|
|
3568
|
+
let inSection = false;
|
|
3569
|
+
for (const line of content.split("\n")) {
|
|
3570
|
+
if (new RegExp(String.raw`^${sectionName}\s*:`).test(line)) {
|
|
3571
|
+
inSection = true;
|
|
3572
|
+
continue;
|
|
3573
|
+
}
|
|
3574
|
+
if (inSection) {
|
|
3575
|
+
const match = /^\s+-\s+(.+)$/.exec(line);
|
|
3576
|
+
if (match) {
|
|
3577
|
+
items.push(match[1].trim());
|
|
3578
|
+
} else if (line.trim() && !/^\s/.test(line)) {
|
|
3579
|
+
break;
|
|
3580
|
+
}
|
|
3581
|
+
}
|
|
3582
|
+
}
|
|
3583
|
+
return items;
|
|
3584
|
+
}
|
|
3550
3585
|
function checkEnableScripts(cwd, verbose, silent) {
|
|
3551
3586
|
const yarnrcPath = PATH20.join(cwd, ".yarnrc.yml");
|
|
3552
3587
|
if (!existsSync19(yarnrcPath)) {
|
|
@@ -3554,8 +3589,7 @@ function checkEnableScripts(cwd, verbose, silent) {
|
|
|
3554
3589
|
return true;
|
|
3555
3590
|
}
|
|
3556
3591
|
const content = readFileSync20(yarnrcPath, "utf8");
|
|
3557
|
-
const
|
|
3558
|
-
for (const line of lines) {
|
|
3592
|
+
for (const line of content.split("\n")) {
|
|
3559
3593
|
const trimmed = line.trim();
|
|
3560
3594
|
if (/^enableScripts\s*:/.test(trimmed)) {
|
|
3561
3595
|
const value = trimmed.replace(/^enableScripts\s*:\s*/, "").trim();
|
|
@@ -3570,12 +3604,9 @@ function checkEnableScripts(cwd, verbose, silent) {
|
|
|
3570
3604
|
if (!silent) console.log(chalk31.red(" enableScripts is not set in .yarnrc.yml (expected false)"));
|
|
3571
3605
|
return false;
|
|
3572
3606
|
}
|
|
3573
|
-
function fixEnableScripts(cwd
|
|
3607
|
+
function fixEnableScripts(cwd) {
|
|
3574
3608
|
const yarnrcPath = PATH20.join(cwd, ".yarnrc.yml");
|
|
3575
|
-
if (!existsSync19(yarnrcPath))
|
|
3576
|
-
if (verbose) console.log(chalk31.gray(" No .yarnrc.yml found, skipping enableScripts fix"));
|
|
3577
|
-
return true;
|
|
3578
|
-
}
|
|
3609
|
+
if (!existsSync19(yarnrcPath)) return true;
|
|
3579
3610
|
const content = readFileSync20(yarnrcPath, "utf8");
|
|
3580
3611
|
const lines = content.split("\n");
|
|
3581
3612
|
let found = false;
|
|
@@ -3609,28 +3640,129 @@ function fixEnableScripts(cwd, verbose) {
|
|
|
3609
3640
|
console.log(chalk31.green(" Fixed: enableScripts set to false"));
|
|
3610
3641
|
return true;
|
|
3611
3642
|
}
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3643
|
+
function checkMinimumReleaseAge(cwd, config2, verbose, silent) {
|
|
3644
|
+
if (detectPackageManager() !== "pnpm") return true;
|
|
3645
|
+
const content = readPnpmWorkspaceYaml(cwd);
|
|
3646
|
+
if (!content) {
|
|
3647
|
+
if (!silent) console.log(chalk31.red(" No pnpm-workspace.yaml found"));
|
|
3648
|
+
return false;
|
|
3617
3649
|
}
|
|
3618
|
-
|
|
3619
|
-
|
|
3650
|
+
const { minimumReleaseAge } = config2;
|
|
3651
|
+
for (const line of content.split("\n")) {
|
|
3652
|
+
const match = /^minimumReleaseAge\s*:\s*(\d+)/.exec(line.trim());
|
|
3653
|
+
if (match) {
|
|
3654
|
+
const value = Number.parseInt(match[1], 10);
|
|
3655
|
+
if (value >= minimumReleaseAge) {
|
|
3656
|
+
if (verbose) console.log(chalk31.green(` minimumReleaseAge is ${value} (>= ${minimumReleaseAge})`));
|
|
3657
|
+
return true;
|
|
3658
|
+
}
|
|
3659
|
+
if (!silent) console.log(chalk31.red(` minimumReleaseAge is ${value} (expected >= ${minimumReleaseAge})`));
|
|
3660
|
+
return false;
|
|
3661
|
+
}
|
|
3662
|
+
}
|
|
3663
|
+
if (!silent) console.log(chalk31.red(` minimumReleaseAge is not set in pnpm-workspace.yaml (expected >= ${minimumReleaseAge})`));
|
|
3664
|
+
return false;
|
|
3665
|
+
}
|
|
3666
|
+
function fixMinimumReleaseAge(cwd, config2) {
|
|
3667
|
+
if (detectPackageManager() !== "pnpm") return true;
|
|
3668
|
+
const content = readPnpmWorkspaceYaml(cwd);
|
|
3669
|
+
if (!content) return false;
|
|
3670
|
+
const { minimumReleaseAge } = config2;
|
|
3671
|
+
const lines = content.split("\n");
|
|
3672
|
+
let found = false;
|
|
3673
|
+
const newLines = lines.map((line) => {
|
|
3674
|
+
if (/^minimumReleaseAge\s*:/.test(line)) {
|
|
3675
|
+
found = true;
|
|
3676
|
+
return `minimumReleaseAge: ${minimumReleaseAge}`;
|
|
3677
|
+
}
|
|
3678
|
+
return line;
|
|
3679
|
+
});
|
|
3680
|
+
if (!found) {
|
|
3681
|
+
const lastLine = newLines.at(-1);
|
|
3682
|
+
if (lastLine === "") {
|
|
3683
|
+
newLines.splice(-1, 0, `minimumReleaseAge: ${minimumReleaseAge}`);
|
|
3684
|
+
} else {
|
|
3685
|
+
newLines.push(`minimumReleaseAge: ${minimumReleaseAge}`);
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
writePnpmWorkspaceYaml(cwd, newLines.join("\n"));
|
|
3689
|
+
console.log(chalk31.green(` Fixed: minimumReleaseAge set to ${minimumReleaseAge}`));
|
|
3690
|
+
return true;
|
|
3691
|
+
}
|
|
3692
|
+
function checkMinimumReleaseAgeExclude(cwd, config2, verbose, silent) {
|
|
3693
|
+
if (detectPackageManager() !== "pnpm") return true;
|
|
3694
|
+
const content = readPnpmWorkspaceYaml(cwd);
|
|
3695
|
+
if (!content) {
|
|
3696
|
+
if (!silent) console.log(chalk31.red(" No pnpm-workspace.yaml found"));
|
|
3697
|
+
return false;
|
|
3698
|
+
}
|
|
3699
|
+
const excludes = parseYamlListSection(content, "minimumReleaseAgeExclude");
|
|
3700
|
+
const missing = config2.minimumReleaseAgeExclude.filter((scope) => !excludes.includes(scope));
|
|
3701
|
+
if (missing.length === 0) {
|
|
3702
|
+
if (verbose) console.log(chalk31.green(" minimumReleaseAgeExclude includes all required scopes"));
|
|
3703
|
+
return true;
|
|
3704
|
+
}
|
|
3705
|
+
if (!silent) console.log(chalk31.red(` minimumReleaseAgeExclude is missing: ${missing.join(", ")}`));
|
|
3706
|
+
return false;
|
|
3707
|
+
}
|
|
3708
|
+
function fixMinimumReleaseAgeExclude(cwd, config2) {
|
|
3709
|
+
if (detectPackageManager() !== "pnpm") return true;
|
|
3710
|
+
const content = readPnpmWorkspaceYaml(cwd);
|
|
3711
|
+
if (!content) return false;
|
|
3712
|
+
const existingExcludes = parseYamlListSection(content, "minimumReleaseAgeExclude");
|
|
3713
|
+
const toAdd = config2.minimumReleaseAgeExclude.filter((scope) => !existingExcludes.includes(scope));
|
|
3714
|
+
if (toAdd.length === 0) return true;
|
|
3715
|
+
const lines = content.split("\n");
|
|
3716
|
+
const sectionIndex = lines.findIndex((line) => /^minimumReleaseAgeExclude\s*:/.test(line));
|
|
3717
|
+
if (sectionIndex === -1) {
|
|
3718
|
+
const newSection = ["minimumReleaseAgeExclude:", ...config2.minimumReleaseAgeExclude.map((s) => ` - ${s}`)];
|
|
3719
|
+
const lastLine = lines.at(-1);
|
|
3720
|
+
if (lastLine === "") {
|
|
3721
|
+
lines.splice(-1, 0, ...newSection);
|
|
3722
|
+
} else {
|
|
3723
|
+
lines.push(...newSection);
|
|
3724
|
+
}
|
|
3725
|
+
} else {
|
|
3726
|
+
let insertAt = sectionIndex + 1;
|
|
3727
|
+
while (insertAt < lines.length && /^\s+-/.test(lines[insertAt])) {
|
|
3728
|
+
insertAt++;
|
|
3729
|
+
}
|
|
3730
|
+
for (const scope of toAdd) {
|
|
3731
|
+
lines.splice(insertAt, 0, ` - ${scope}`);
|
|
3732
|
+
insertAt++;
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3735
|
+
writePnpmWorkspaceYaml(cwd, lines.join("\n"));
|
|
3736
|
+
console.log(chalk31.green(` Fixed: added ${toAdd.join(", ")} to minimumReleaseAgeExclude`));
|
|
3737
|
+
return true;
|
|
3738
|
+
}
|
|
3739
|
+
async function packmanLint({ fix, verbose } = {}) {
|
|
3620
3740
|
const cwd = process.cwd();
|
|
3741
|
+
const rootConfig = await loadConfig();
|
|
3742
|
+
const packmanConfig = resolvePackmanConfig(rootConfig.commands ? rootConfig.commands.packman : void 0);
|
|
3621
3743
|
let failures = 0;
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3744
|
+
const enableScriptsPassed = checkEnableScripts(cwd, verbose, fix);
|
|
3745
|
+
if (!enableScriptsPassed) {
|
|
3746
|
+
if (fix) {
|
|
3747
|
+
if (!fixEnableScripts(cwd)) failures++;
|
|
3748
|
+
} else {
|
|
3749
|
+
failures++;
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
const agePassed = checkMinimumReleaseAge(cwd, packmanConfig, verbose, fix);
|
|
3753
|
+
if (!agePassed) {
|
|
3754
|
+
if (fix) {
|
|
3755
|
+
if (!fixMinimumReleaseAge(cwd, packmanConfig)) failures++;
|
|
3756
|
+
} else {
|
|
3757
|
+
failures++;
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
const excludePassed = checkMinimumReleaseAgeExclude(cwd, packmanConfig, verbose, fix);
|
|
3761
|
+
if (!excludePassed) {
|
|
3762
|
+
if (fix) {
|
|
3763
|
+
if (!fixMinimumReleaseAgeExclude(cwd, packmanConfig)) failures++;
|
|
3764
|
+
} else {
|
|
3765
|
+
failures++;
|
|
3634
3766
|
}
|
|
3635
3767
|
}
|
|
3636
3768
|
if (failures > 0) {
|
|
@@ -3895,14 +4027,14 @@ function lintPackages(cwd) {
|
|
|
3895
4027
|
function readmeLint({ config: config2, verbose }) {
|
|
3896
4028
|
const cwd = INIT_CWD();
|
|
3897
4029
|
console.log(chalk33.green("Readme Lint"));
|
|
3898
|
-
const
|
|
4030
|
+
const checks = [
|
|
3899
4031
|
lintTemplate(cwd),
|
|
3900
4032
|
lintLogoConfig(cwd, config2),
|
|
3901
4033
|
lintPackages(cwd)
|
|
3902
4034
|
];
|
|
3903
4035
|
let errorCount = 0;
|
|
3904
4036
|
let warningCount = 0;
|
|
3905
|
-
for (const { errors, warnings } of
|
|
4037
|
+
for (const { errors, warnings } of checks) {
|
|
3906
4038
|
for (const error of errors) {
|
|
3907
4039
|
console.log(chalk33.red(` \u2717 ${error}`));
|
|
3908
4040
|
errorCount++;
|
|
@@ -4446,8 +4578,8 @@ var lintCommand = {
|
|
|
4446
4578
|
type: "boolean"
|
|
4447
4579
|
});
|
|
4448
4580
|
},
|
|
4449
|
-
handler: (argv) => {
|
|
4450
|
-
process.exitCode = packmanLint({
|
|
4581
|
+
handler: async (argv) => {
|
|
4582
|
+
process.exitCode = await packmanLint({
|
|
4451
4583
|
fix: !!argv.fix,
|
|
4452
4584
|
verbose: !!argv.verbose
|
|
4453
4585
|
});
|