@xylabs/toolchain 7.10.1 → 7.10.2
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 +164 -32
- package/dist/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/index.mjs
CHANGED
|
@@ -6241,7 +6241,7 @@ function packageLintMonorepo(fix2 = false) {
|
|
|
6241
6241
|
fix: () => fixInternalDepVersions(cwd, workspaces),
|
|
6242
6242
|
label: "Internal deps/devDeps use correct version ranges"
|
|
6243
6243
|
};
|
|
6244
|
-
const
|
|
6244
|
+
const checks = [
|
|
6245
6245
|
{
|
|
6246
6246
|
check: () => checkRootPrivate(pkg),
|
|
6247
6247
|
fix: fixRootPrivate,
|
|
@@ -6293,7 +6293,7 @@ function packageLintMonorepo(fix2 = false) {
|
|
|
6293
6293
|
label: "Internal peerDeps use semver ranges (not workspace: protocol)"
|
|
6294
6294
|
}
|
|
6295
6295
|
];
|
|
6296
|
-
const { errors, fixed } = runChecks(
|
|
6296
|
+
const { errors, fixed } = runChecks(checks, cwd, pkg, fix2);
|
|
6297
6297
|
logSummary(errors, fixed);
|
|
6298
6298
|
if (fix2 && fixed > 0) {
|
|
6299
6299
|
runInstall();
|
|
@@ -6916,6 +6916,41 @@ import {
|
|
|
6916
6916
|
} from "fs";
|
|
6917
6917
|
import PATH25 from "path";
|
|
6918
6918
|
import chalk53 from "chalk";
|
|
6919
|
+
var DEFAULT_MINIMUM_RELEASE_AGE = 4320;
|
|
6920
|
+
var DEFAULT_RELEASE_AGE_EXCLUDES = ["'@xylabs/*'", "'@xyo-network/*'"];
|
|
6921
|
+
function resolvePackmanConfig(cfg) {
|
|
6922
|
+
return {
|
|
6923
|
+
minimumReleaseAge: cfg?.minimumReleaseAge ?? DEFAULT_MINIMUM_RELEASE_AGE,
|
|
6924
|
+
minimumReleaseAgeExclude: cfg?.minimumReleaseAgeExclude ?? DEFAULT_RELEASE_AGE_EXCLUDES
|
|
6925
|
+
};
|
|
6926
|
+
}
|
|
6927
|
+
function readPnpmWorkspaceYaml(cwd) {
|
|
6928
|
+
const wsPath = PATH25.join(cwd, "pnpm-workspace.yaml");
|
|
6929
|
+
if (!existsSync20(wsPath)) return void 0;
|
|
6930
|
+
return readFileSync27(wsPath, "utf8");
|
|
6931
|
+
}
|
|
6932
|
+
function writePnpmWorkspaceYaml(cwd, content) {
|
|
6933
|
+
writeFileSync16(PATH25.join(cwd, "pnpm-workspace.yaml"), content, "utf8");
|
|
6934
|
+
}
|
|
6935
|
+
function parseYamlListSection(content, sectionName) {
|
|
6936
|
+
const items = [];
|
|
6937
|
+
let inSection = false;
|
|
6938
|
+
for (const line of content.split("\n")) {
|
|
6939
|
+
if (new RegExp(String.raw`^${sectionName}\s*:`).test(line)) {
|
|
6940
|
+
inSection = true;
|
|
6941
|
+
continue;
|
|
6942
|
+
}
|
|
6943
|
+
if (inSection) {
|
|
6944
|
+
const match = /^\s+-\s+(.+)$/.exec(line);
|
|
6945
|
+
if (match) {
|
|
6946
|
+
items.push(match[1].trim());
|
|
6947
|
+
} else if (line.trim() && !/^\s/.test(line)) {
|
|
6948
|
+
break;
|
|
6949
|
+
}
|
|
6950
|
+
}
|
|
6951
|
+
}
|
|
6952
|
+
return items;
|
|
6953
|
+
}
|
|
6919
6954
|
function checkEnableScripts(cwd, verbose, silent) {
|
|
6920
6955
|
const yarnrcPath = PATH25.join(cwd, ".yarnrc.yml");
|
|
6921
6956
|
if (!existsSync20(yarnrcPath)) {
|
|
@@ -6923,8 +6958,7 @@ function checkEnableScripts(cwd, verbose, silent) {
|
|
|
6923
6958
|
return true;
|
|
6924
6959
|
}
|
|
6925
6960
|
const content = readFileSync27(yarnrcPath, "utf8");
|
|
6926
|
-
const
|
|
6927
|
-
for (const line of lines) {
|
|
6961
|
+
for (const line of content.split("\n")) {
|
|
6928
6962
|
const trimmed = line.trim();
|
|
6929
6963
|
if (/^enableScripts\s*:/.test(trimmed)) {
|
|
6930
6964
|
const value = trimmed.replace(/^enableScripts\s*:\s*/, "").trim();
|
|
@@ -6939,12 +6973,9 @@ function checkEnableScripts(cwd, verbose, silent) {
|
|
|
6939
6973
|
if (!silent) console.log(chalk53.red(" enableScripts is not set in .yarnrc.yml (expected false)"));
|
|
6940
6974
|
return false;
|
|
6941
6975
|
}
|
|
6942
|
-
function fixEnableScripts(cwd
|
|
6976
|
+
function fixEnableScripts(cwd) {
|
|
6943
6977
|
const yarnrcPath = PATH25.join(cwd, ".yarnrc.yml");
|
|
6944
|
-
if (!existsSync20(yarnrcPath))
|
|
6945
|
-
if (verbose) console.log(chalk53.gray(" No .yarnrc.yml found, skipping enableScripts fix"));
|
|
6946
|
-
return true;
|
|
6947
|
-
}
|
|
6978
|
+
if (!existsSync20(yarnrcPath)) return true;
|
|
6948
6979
|
const content = readFileSync27(yarnrcPath, "utf8");
|
|
6949
6980
|
const lines = content.split("\n");
|
|
6950
6981
|
let found = false;
|
|
@@ -6978,28 +7009,129 @@ function fixEnableScripts(cwd, verbose) {
|
|
|
6978
7009
|
console.log(chalk53.green(" Fixed: enableScripts set to false"));
|
|
6979
7010
|
return true;
|
|
6980
7011
|
}
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
7012
|
+
function checkMinimumReleaseAge(cwd, config2, verbose, silent) {
|
|
7013
|
+
if (detectPackageManager() !== "pnpm") return true;
|
|
7014
|
+
const content = readPnpmWorkspaceYaml(cwd);
|
|
7015
|
+
if (!content) {
|
|
7016
|
+
if (!silent) console.log(chalk53.red(" No pnpm-workspace.yaml found"));
|
|
7017
|
+
return false;
|
|
6986
7018
|
}
|
|
6987
|
-
|
|
6988
|
-
|
|
7019
|
+
const { minimumReleaseAge } = config2;
|
|
7020
|
+
for (const line of content.split("\n")) {
|
|
7021
|
+
const match = /^minimumReleaseAge\s*:\s*(\d+)/.exec(line.trim());
|
|
7022
|
+
if (match) {
|
|
7023
|
+
const value = Number.parseInt(match[1], 10);
|
|
7024
|
+
if (value >= minimumReleaseAge) {
|
|
7025
|
+
if (verbose) console.log(chalk53.green(` minimumReleaseAge is ${value} (>= ${minimumReleaseAge})`));
|
|
7026
|
+
return true;
|
|
7027
|
+
}
|
|
7028
|
+
if (!silent) console.log(chalk53.red(` minimumReleaseAge is ${value} (expected >= ${minimumReleaseAge})`));
|
|
7029
|
+
return false;
|
|
7030
|
+
}
|
|
7031
|
+
}
|
|
7032
|
+
if (!silent) console.log(chalk53.red(` minimumReleaseAge is not set in pnpm-workspace.yaml (expected >= ${minimumReleaseAge})`));
|
|
7033
|
+
return false;
|
|
7034
|
+
}
|
|
7035
|
+
function fixMinimumReleaseAge(cwd, config2) {
|
|
7036
|
+
if (detectPackageManager() !== "pnpm") return true;
|
|
7037
|
+
const content = readPnpmWorkspaceYaml(cwd);
|
|
7038
|
+
if (!content) return false;
|
|
7039
|
+
const { minimumReleaseAge } = config2;
|
|
7040
|
+
const lines = content.split("\n");
|
|
7041
|
+
let found = false;
|
|
7042
|
+
const newLines = lines.map((line) => {
|
|
7043
|
+
if (/^minimumReleaseAge\s*:/.test(line)) {
|
|
7044
|
+
found = true;
|
|
7045
|
+
return `minimumReleaseAge: ${minimumReleaseAge}`;
|
|
7046
|
+
}
|
|
7047
|
+
return line;
|
|
7048
|
+
});
|
|
7049
|
+
if (!found) {
|
|
7050
|
+
const lastLine = newLines.at(-1);
|
|
7051
|
+
if (lastLine === "") {
|
|
7052
|
+
newLines.splice(-1, 0, `minimumReleaseAge: ${minimumReleaseAge}`);
|
|
7053
|
+
} else {
|
|
7054
|
+
newLines.push(`minimumReleaseAge: ${minimumReleaseAge}`);
|
|
7055
|
+
}
|
|
7056
|
+
}
|
|
7057
|
+
writePnpmWorkspaceYaml(cwd, newLines.join("\n"));
|
|
7058
|
+
console.log(chalk53.green(` Fixed: minimumReleaseAge set to ${minimumReleaseAge}`));
|
|
7059
|
+
return true;
|
|
7060
|
+
}
|
|
7061
|
+
function checkMinimumReleaseAgeExclude(cwd, config2, verbose, silent) {
|
|
7062
|
+
if (detectPackageManager() !== "pnpm") return true;
|
|
7063
|
+
const content = readPnpmWorkspaceYaml(cwd);
|
|
7064
|
+
if (!content) {
|
|
7065
|
+
if (!silent) console.log(chalk53.red(" No pnpm-workspace.yaml found"));
|
|
7066
|
+
return false;
|
|
7067
|
+
}
|
|
7068
|
+
const excludes = parseYamlListSection(content, "minimumReleaseAgeExclude");
|
|
7069
|
+
const missing = config2.minimumReleaseAgeExclude.filter((scope) => !excludes.includes(scope));
|
|
7070
|
+
if (missing.length === 0) {
|
|
7071
|
+
if (verbose) console.log(chalk53.green(" minimumReleaseAgeExclude includes all required scopes"));
|
|
7072
|
+
return true;
|
|
7073
|
+
}
|
|
7074
|
+
if (!silent) console.log(chalk53.red(` minimumReleaseAgeExclude is missing: ${missing.join(", ")}`));
|
|
7075
|
+
return false;
|
|
7076
|
+
}
|
|
7077
|
+
function fixMinimumReleaseAgeExclude(cwd, config2) {
|
|
7078
|
+
if (detectPackageManager() !== "pnpm") return true;
|
|
7079
|
+
const content = readPnpmWorkspaceYaml(cwd);
|
|
7080
|
+
if (!content) return false;
|
|
7081
|
+
const existingExcludes = parseYamlListSection(content, "minimumReleaseAgeExclude");
|
|
7082
|
+
const toAdd = config2.minimumReleaseAgeExclude.filter((scope) => !existingExcludes.includes(scope));
|
|
7083
|
+
if (toAdd.length === 0) return true;
|
|
7084
|
+
const lines = content.split("\n");
|
|
7085
|
+
const sectionIndex = lines.findIndex((line) => /^minimumReleaseAgeExclude\s*:/.test(line));
|
|
7086
|
+
if (sectionIndex === -1) {
|
|
7087
|
+
const newSection = ["minimumReleaseAgeExclude:", ...config2.minimumReleaseAgeExclude.map((s) => ` - ${s}`)];
|
|
7088
|
+
const lastLine = lines.at(-1);
|
|
7089
|
+
if (lastLine === "") {
|
|
7090
|
+
lines.splice(-1, 0, ...newSection);
|
|
7091
|
+
} else {
|
|
7092
|
+
lines.push(...newSection);
|
|
7093
|
+
}
|
|
7094
|
+
} else {
|
|
7095
|
+
let insertAt = sectionIndex + 1;
|
|
7096
|
+
while (insertAt < lines.length && /^\s+-/.test(lines[insertAt])) {
|
|
7097
|
+
insertAt++;
|
|
7098
|
+
}
|
|
7099
|
+
for (const scope of toAdd) {
|
|
7100
|
+
lines.splice(insertAt, 0, ` - ${scope}`);
|
|
7101
|
+
insertAt++;
|
|
7102
|
+
}
|
|
7103
|
+
}
|
|
7104
|
+
writePnpmWorkspaceYaml(cwd, lines.join("\n"));
|
|
7105
|
+
console.log(chalk53.green(` Fixed: added ${toAdd.join(", ")} to minimumReleaseAgeExclude`));
|
|
7106
|
+
return true;
|
|
7107
|
+
}
|
|
7108
|
+
async function packmanLint({ fix: fix2, verbose } = {}) {
|
|
6989
7109
|
const cwd = process.cwd();
|
|
7110
|
+
const rootConfig = await loadConfig();
|
|
7111
|
+
const packmanConfig = resolvePackmanConfig(rootConfig.commands ? rootConfig.commands.packman : void 0);
|
|
6990
7112
|
let failures = 0;
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7113
|
+
const enableScriptsPassed = checkEnableScripts(cwd, verbose, fix2);
|
|
7114
|
+
if (!enableScriptsPassed) {
|
|
7115
|
+
if (fix2) {
|
|
7116
|
+
if (!fixEnableScripts(cwd)) failures++;
|
|
7117
|
+
} else {
|
|
7118
|
+
failures++;
|
|
7119
|
+
}
|
|
7120
|
+
}
|
|
7121
|
+
const agePassed = checkMinimumReleaseAge(cwd, packmanConfig, verbose, fix2);
|
|
7122
|
+
if (!agePassed) {
|
|
7123
|
+
if (fix2) {
|
|
7124
|
+
if (!fixMinimumReleaseAge(cwd, packmanConfig)) failures++;
|
|
7125
|
+
} else {
|
|
7126
|
+
failures++;
|
|
7127
|
+
}
|
|
7128
|
+
}
|
|
7129
|
+
const excludePassed = checkMinimumReleaseAgeExclude(cwd, packmanConfig, verbose, fix2);
|
|
7130
|
+
if (!excludePassed) {
|
|
7131
|
+
if (fix2) {
|
|
7132
|
+
if (!fixMinimumReleaseAgeExclude(cwd, packmanConfig)) failures++;
|
|
7133
|
+
} else {
|
|
7134
|
+
failures++;
|
|
7003
7135
|
}
|
|
7004
7136
|
}
|
|
7005
7137
|
if (failures > 0) {
|
|
@@ -7271,14 +7403,14 @@ function lintPackages(cwd) {
|
|
|
7271
7403
|
function readmeLint({ config: config2, verbose }) {
|
|
7272
7404
|
const cwd = INIT_CWD();
|
|
7273
7405
|
console.log(chalk55.green("Readme Lint"));
|
|
7274
|
-
const
|
|
7406
|
+
const checks = [
|
|
7275
7407
|
lintTemplate(cwd),
|
|
7276
7408
|
lintLogoConfig(cwd, config2),
|
|
7277
7409
|
lintPackages(cwd)
|
|
7278
7410
|
];
|
|
7279
7411
|
let errorCount = 0;
|
|
7280
7412
|
let warningCount = 0;
|
|
7281
|
-
for (const { errors, warnings } of
|
|
7413
|
+
for (const { errors, warnings } of checks) {
|
|
7282
7414
|
for (const error of errors) {
|
|
7283
7415
|
console.log(chalk55.red(` \u2717 ${error}`));
|
|
7284
7416
|
errorCount++;
|
|
@@ -8103,8 +8235,8 @@ var lintCommand = {
|
|
|
8103
8235
|
type: "boolean"
|
|
8104
8236
|
});
|
|
8105
8237
|
},
|
|
8106
|
-
handler: (argv) => {
|
|
8107
|
-
process.exitCode = packmanLint({
|
|
8238
|
+
handler: async (argv) => {
|
|
8239
|
+
process.exitCode = await packmanLint({
|
|
8108
8240
|
fix: !!argv.fix,
|
|
8109
8241
|
verbose: !!argv.verbose
|
|
8110
8242
|
});
|