@ariestools/toolchain 8.6.11 → 8.6.12
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/api-exposure/apiExposure.d.ts.map +1 -1
- package/dist/actions/api-exposure/config.d.ts.map +1 -1
- package/dist/actions/api-exposure/types.d.ts +3 -0
- package/dist/actions/api-exposure/types.d.ts.map +1 -1
- package/dist/actions/gitlint-fix.d.ts +2 -1
- package/dist/actions/gitlint-fix.d.ts.map +1 -1
- package/dist/actions/gitlint.d.ts +3 -1
- package/dist/actions/gitlint.d.ts.map +1 -1
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/lintlint.d.ts +1 -1
- package/dist/actions/lintlint.d.ts.map +1 -1
- package/dist/actions/node-lint.d.ts +1 -1
- package/dist/actions/node-lint.d.ts.map +1 -1
- package/dist/actions/package/compile/ApiExposureConfig.d.ts +9 -2
- package/dist/actions/package/compile/ApiExposureConfig.d.ts.map +1 -1
- package/dist/actions/package/compile/MonolithConfig.d.ts +23 -0
- package/dist/actions/package/compile/MonolithConfig.d.ts.map +1 -1
- package/dist/actions/package/compile/PublintConfig.d.ts +41 -0
- package/dist/actions/package/compile/PublintConfig.d.ts.map +1 -0
- package/dist/actions/package/compile/RuleLevelConfig.d.ts +7 -0
- package/dist/actions/package/compile/RuleLevelConfig.d.ts.map +1 -0
- package/dist/actions/package/compile/XyConfig.d.ts +29 -34
- package/dist/actions/package/compile/XyConfig.d.ts.map +1 -1
- package/dist/actions/package/compile/monolithCompileEntries.d.ts.map +1 -1
- package/dist/actions/package/compile/monolithCompileLayout.d.ts.map +1 -1
- package/dist/actions/package/index.d.ts +1 -0
- package/dist/actions/package/index.d.ts.map +1 -1
- package/dist/actions/package/publint.d.ts +3 -1
- package/dist/actions/package/publint.d.ts.map +1 -1
- package/dist/actions/package/publintRules.d.ts +10 -0
- package/dist/actions/package/publintRules.d.ts.map +1 -0
- package/dist/actions/package-lint.d.ts +2 -1
- package/dist/actions/package-lint.d.ts.map +1 -1
- package/dist/actions/packman/lint.d.ts +2 -1
- package/dist/actions/packman/lint.d.ts.map +1 -1
- package/dist/actions/publint.d.ts.map +1 -1
- package/dist/actions/ruleCatalog.d.ts +40 -0
- package/dist/actions/ruleCatalog.d.ts.map +1 -0
- package/dist/actions/ruleRunner.d.ts +60 -0
- package/dist/actions/ruleRunner.d.ts.map +1 -0
- package/dist/actions/skills/lint.d.ts +3 -1
- package/dist/actions/skills/lint.d.ts.map +1 -1
- package/dist/bin/package/build.mjs +218 -67
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +8 -4
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/publint.mjs +210 -63
- package/dist/bin/package/publint.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +8 -4
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/package/sync-layout.mjs +1 -1
- package/dist/bin/package/sync-layout.mjs.map +1 -1
- package/dist/bin/xy.mjs +1484 -315
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/lib/loadConfig.d.ts.map +1 -1
- package/dist/xy/common/checkCommand.d.ts.map +1 -1
- package/dist/xy/common/deadCommand.d.ts.map +1 -1
- package/dist/xy/common/gitlintCommand.d.ts.map +1 -1
- package/dist/xy/common/packmanCommand.d.ts.map +1 -1
- package/dist/xy/common/repo/lintCommand.d.ts.map +1 -1
- package/dist/xy/common/skills/index.d.ts.map +1 -1
- package/dist/xy/lint/apiExposureCommand.d.ts.map +1 -1
- package/dist/xy/lint/cycleCommand.d.ts.map +1 -1
- package/dist/xy/lint/deplintCommand.d.ts.map +1 -1
- package/dist/xy/lint/fixCommand.d.ts.map +1 -1
- package/dist/xy/lint/lint/runCommand.d.ts.map +1 -1
- package/dist/xy/lint/lintlintCommand.d.ts.map +1 -1
- package/dist/xy/lint/nodeLintCommand.d.ts.map +1 -1
- package/dist/xy/lint/publintCommand.d.ts.map +1 -1
- package/dist/xy/lint/relintCommand.d.ts.map +1 -1
- package/dist/xy/lint/republintCommand.d.ts.map +1 -1
- package/dist/xy/xy.d.ts +3 -10
- package/dist/xy/xy.d.ts.map +1 -1
- package/dist/xy/xyParseOptions.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/bin/xy.mjs
CHANGED
|
@@ -11584,15 +11584,27 @@ function mergeRuleConfigs(target, source) {
|
|
|
11584
11584
|
};
|
|
11585
11585
|
return source;
|
|
11586
11586
|
}
|
|
11587
|
+
const RULE_CONFIG_COMMANDS = /* @__PURE__ */ new Set([
|
|
11588
|
+
"apiExposure",
|
|
11589
|
+
"dead",
|
|
11590
|
+
"deplint",
|
|
11591
|
+
"gitlint",
|
|
11592
|
+
"lintlint",
|
|
11593
|
+
"nodeLint",
|
|
11594
|
+
"packman",
|
|
11595
|
+
"publint",
|
|
11596
|
+
"repoLint",
|
|
11597
|
+
"skillsLint"
|
|
11598
|
+
]);
|
|
11587
11599
|
function mergeCommandConfig(rootCmd, workspaceCmd, commandName) {
|
|
11588
|
-
return deepMerge(rootCmd, workspaceCmd, { customMerge: (key) => (commandName
|
|
11600
|
+
return deepMerge(rootCmd, workspaceCmd, { customMerge: (key) => RULE_CONFIG_COMMANDS.has(commandName) && key === "rules" ? mergeRuleConfigs : void 0 });
|
|
11589
11601
|
}
|
|
11590
11602
|
/**
|
|
11591
11603
|
* Loads a command-specific config merged from root and workspace levels.
|
|
11592
11604
|
* The root config provides defaults; the workspace config extends/overrides.
|
|
11593
11605
|
* Arrays (e.g. `exclude`) are unioned and maps (e.g. `packages`) are merged
|
|
11594
11606
|
* via deepmerge, with workspace entries overriding root entries for the same key.
|
|
11595
|
-
*
|
|
11607
|
+
* Rule entries are replaced per rule id so tuple configs keep their
|
|
11596
11608
|
* ESLint-like shape instead of being concatenated as arrays.
|
|
11597
11609
|
*/
|
|
11598
11610
|
/**
|
|
@@ -23087,35 +23099,63 @@ const DEFAULT_AEI_THRESHOLDS = {
|
|
|
23087
23099
|
probablyPeerMax: 179,
|
|
23088
23100
|
reviewMax: 119
|
|
23089
23101
|
};
|
|
23102
|
+
const RULE_LEVELS$1 = /* @__PURE__ */ new Set([
|
|
23103
|
+
"error",
|
|
23104
|
+
"off",
|
|
23105
|
+
"warn"
|
|
23106
|
+
]);
|
|
23090
23107
|
function isRecord$5(value) {
|
|
23091
23108
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23092
23109
|
}
|
|
23093
23110
|
function isValidWeight(value) {
|
|
23094
23111
|
return value === "infinite" || typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
23095
23112
|
}
|
|
23113
|
+
function isRuleLevel$4(value) {
|
|
23114
|
+
return typeof value === "string" && RULE_LEVELS$1.has(value);
|
|
23115
|
+
}
|
|
23116
|
+
function parseWeight(location, weight) {
|
|
23117
|
+
if (!isValidWeight(weight)) throw new TypeError(`${location} must be a non-negative finite number or "infinite"`);
|
|
23118
|
+
return weight;
|
|
23119
|
+
}
|
|
23120
|
+
function parseTupleRuleSetting(location, setting) {
|
|
23121
|
+
if (setting.length !== 2) throw new TypeError(`${location} tuple must be [level, options]`);
|
|
23122
|
+
const [level, options] = setting;
|
|
23123
|
+
if (!isRuleLevel$4(level)) throw new TypeError(`${location} level must be "error", "warn", or "off"`);
|
|
23124
|
+
if (!isRecord$5(options)) throw new TypeError(`${location} options must be an object`);
|
|
23125
|
+
return {
|
|
23126
|
+
enabled: level !== "off",
|
|
23127
|
+
level,
|
|
23128
|
+
weight: options.weight === void 0 ? void 0 : parseWeight(`${location}.weight`, options.weight)
|
|
23129
|
+
};
|
|
23130
|
+
}
|
|
23131
|
+
function parseObjectRuleSetting(location, setting) {
|
|
23132
|
+
for (const key of Object.keys(setting)) if (![
|
|
23133
|
+
"enabled",
|
|
23134
|
+
"level",
|
|
23135
|
+
"weight"
|
|
23136
|
+
].includes(key)) throw new TypeError(`${location} has unknown option "${key}"`);
|
|
23137
|
+
if (setting.enabled !== void 0 && typeof setting.enabled !== "boolean") throw new TypeError(`${location}.enabled must be a boolean`);
|
|
23138
|
+
if (setting.level !== void 0 && !isRuleLevel$4(setting.level)) throw new TypeError(`${location}.level must be "error", "warn", or "off"`);
|
|
23139
|
+
const level = setting.level;
|
|
23140
|
+
return {
|
|
23141
|
+
enabled: level === void 0 ? setting.enabled : level !== "off",
|
|
23142
|
+
level,
|
|
23143
|
+
weight: setting.weight === void 0 ? void 0 : parseWeight(`${location}.weight`, setting.weight)
|
|
23144
|
+
};
|
|
23145
|
+
}
|
|
23096
23146
|
function parseRuleSetting(location, setting) {
|
|
23097
23147
|
if (typeof setting === "boolean") return { enabled: setting };
|
|
23098
|
-
if (setting
|
|
23099
|
-
|
|
23100
|
-
|
|
23101
|
-
|
|
23102
|
-
|
|
23103
|
-
|
|
23104
|
-
|
|
23105
|
-
|
|
23106
|
-
|
|
23107
|
-
|
|
23108
|
-
|
|
23109
|
-
if (typeof setting.enabled !== "boolean") throw new TypeError(`${location}.enabled must be a boolean`);
|
|
23110
|
-
parsed.enabled = setting.enabled;
|
|
23111
|
-
}
|
|
23112
|
-
if (setting.weight !== void 0) {
|
|
23113
|
-
if (!isValidWeight(setting.weight)) throw new TypeError(`${location}.weight must be a non-negative finite number or "infinite"`);
|
|
23114
|
-
parsed.weight = setting.weight;
|
|
23115
|
-
}
|
|
23116
|
-
return parsed;
|
|
23117
|
-
}
|
|
23118
|
-
throw new TypeError(`${location} must be a boolean, number, "infinite", or { enabled?, weight? } object`);
|
|
23148
|
+
if (isRuleLevel$4(setting)) return {
|
|
23149
|
+
enabled: setting !== "off",
|
|
23150
|
+
level: setting
|
|
23151
|
+
};
|
|
23152
|
+
if (setting === "infinite" || typeof setting === "number") return {
|
|
23153
|
+
enabled: true,
|
|
23154
|
+
weight: parseWeight(location, setting)
|
|
23155
|
+
};
|
|
23156
|
+
if (Array.isArray(setting)) return parseTupleRuleSetting(location, setting);
|
|
23157
|
+
if (isRecord$5(setting)) return parseObjectRuleSetting(location, setting);
|
|
23158
|
+
throw new TypeError(`${location} must be a boolean, rule level, number, "infinite", [level, options], or { enabled?, level?, weight? } object`);
|
|
23119
23159
|
}
|
|
23120
23160
|
function validateRuleIds(location, rules) {
|
|
23121
23161
|
const unknown = Object.keys(rules).filter((ruleId) => !AEI_RULE_IDS.has(ruleId));
|
|
@@ -23140,6 +23180,7 @@ function applySetting(rule, parsed) {
|
|
|
23140
23180
|
return {
|
|
23141
23181
|
...rule,
|
|
23142
23182
|
enabled: parsed.enabled ?? rule.enabled,
|
|
23183
|
+
level: parsed.level ?? (parsed.enabled === false ? "off" : rule.level),
|
|
23143
23184
|
weight: parsed.weight ?? rule.weight
|
|
23144
23185
|
};
|
|
23145
23186
|
}
|
|
@@ -23175,6 +23216,7 @@ function normalizeApiExposureConfig(config) {
|
|
|
23175
23216
|
const base = {
|
|
23176
23217
|
...definition,
|
|
23177
23218
|
enabled: definition.defaultEnabled ?? true,
|
|
23219
|
+
level: definition.defaultEnabled === false ? "off" : "warn",
|
|
23178
23220
|
weight: definition.defaultWeight
|
|
23179
23221
|
};
|
|
23180
23222
|
const setting = globalRuleSettings[definition.id];
|
|
@@ -23219,6 +23261,7 @@ function resolveFindings(raw, config) {
|
|
|
23219
23261
|
findings.push({
|
|
23220
23262
|
...rawFinding,
|
|
23221
23263
|
infinite: rule.weight === "infinite",
|
|
23264
|
+
level: rule.level,
|
|
23222
23265
|
weight: rule.weight === "infinite" ? 0 : rule.weight
|
|
23223
23266
|
});
|
|
23224
23267
|
}
|
|
@@ -24209,10 +24252,13 @@ const apiExposure = async ({ dep, failOn, format, minBand, pkg, verbose, workspa
|
|
|
24209
24252
|
results.push(result);
|
|
24210
24253
|
}
|
|
24211
24254
|
const allAssessments = results.flatMap((result) => result.assessments);
|
|
24212
|
-
const
|
|
24255
|
+
const warningAssessments = new Set(allAssessments.filter((assessment) => assessment.recommendation === "review"));
|
|
24213
24256
|
const mismatches = allAssessments.filter((assessment) => isMismatch(assessment));
|
|
24214
24257
|
const confidence = (band) => Math.abs(bandIndex(band) - bandIndex("review"));
|
|
24215
24258
|
const failingMismatches = failOn === void 0 ? [] : mismatches.filter((assessment) => confidence(assessment.recommendation) >= confidence(failOn));
|
|
24259
|
+
for (const assessment of mismatches) warningAssessments.add(assessment);
|
|
24260
|
+
const errorAssessments = /* @__PURE__ */ new Set([...failingMismatches, ...allAssessments.filter((assessment) => (assessment.recommendation === "review" || isMismatch(assessment)) && assessment.findings.some((finding) => finding.level === "error"))]);
|
|
24261
|
+
for (const assessment of errorAssessments) warningAssessments.delete(assessment);
|
|
24216
24262
|
if (!isJsonMode() && effectiveFormat === "human") {
|
|
24217
24263
|
renderHumanApiExposure(results, {
|
|
24218
24264
|
minBand,
|
|
@@ -24223,10 +24269,10 @@ const apiExposure = async ({ dep, failOn, format, minBand, pkg, verbose, workspa
|
|
|
24223
24269
|
return {
|
|
24224
24270
|
envelope: {
|
|
24225
24271
|
data: results,
|
|
24226
|
-
errorCount:
|
|
24227
|
-
warningCount:
|
|
24272
|
+
errorCount: errorAssessments.size,
|
|
24273
|
+
warningCount: warningAssessments.size
|
|
24228
24274
|
},
|
|
24229
|
-
exitCode:
|
|
24275
|
+
exitCode: errorAssessments.size
|
|
24230
24276
|
};
|
|
24231
24277
|
};
|
|
24232
24278
|
//#endregion
|
|
@@ -27472,7 +27518,7 @@ const BUILT_IN_RULE_OPTION_KEYS = {
|
|
|
27472
27518
|
function isRecord$4(value) {
|
|
27473
27519
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27474
27520
|
}
|
|
27475
|
-
function isRuleLevel$
|
|
27521
|
+
function isRuleLevel$3(value) {
|
|
27476
27522
|
return typeof value === "string" && VALID_RULE_LEVELS$1.has(value);
|
|
27477
27523
|
}
|
|
27478
27524
|
function severityFromLevel$1(level) {
|
|
@@ -27483,7 +27529,7 @@ function formatRuleConfigLocation$1(ruleId) {
|
|
|
27483
27529
|
}
|
|
27484
27530
|
function parseRuleConfig$1(ruleId, value) {
|
|
27485
27531
|
if (typeof value === "string") {
|
|
27486
|
-
if (!isRuleLevel$
|
|
27532
|
+
if (!isRuleLevel$3(value)) throw new TypeError(`${formatRuleConfigLocation$1(ruleId)} must be one of "off", "warn", or "error"`);
|
|
27487
27533
|
return {
|
|
27488
27534
|
level: value,
|
|
27489
27535
|
options: {}
|
|
@@ -27492,7 +27538,7 @@ function parseRuleConfig$1(ruleId, value) {
|
|
|
27492
27538
|
if (Array.isArray(value)) {
|
|
27493
27539
|
if (value.length !== 2) throw new TypeError(`${formatRuleConfigLocation$1(ruleId)} tuple must be [level, options]`);
|
|
27494
27540
|
const level = value[0];
|
|
27495
|
-
if (!isRuleLevel$
|
|
27541
|
+
if (!isRuleLevel$3(level)) throw new TypeError(`${formatRuleConfigLocation$1(ruleId)} level must be one of "off", "warn", or "error"`);
|
|
27496
27542
|
const options = value[1];
|
|
27497
27543
|
if (!isRecord$4(options)) throw new TypeError(`${formatRuleConfigLocation$1(ruleId)} options must be an object`);
|
|
27498
27544
|
return {
|
|
@@ -31026,7 +31072,7 @@ const resolveCompilePlatforms = (compile) => {
|
|
|
31026
31072
|
};
|
|
31027
31073
|
};
|
|
31028
31074
|
//#endregion
|
|
31029
|
-
//#region src/actions/package/compile/
|
|
31075
|
+
//#region src/actions/package/compile/PublintConfig.ts
|
|
31030
31076
|
const ALL_PUBLINT_CHECKS = [
|
|
31031
31077
|
"compileTargets",
|
|
31032
31078
|
"defaultExportOrder",
|
|
@@ -31931,6 +31977,99 @@ async function checkPlatform(pkgDir, pkg, shouldFix = false) {
|
|
|
31931
31977
|
return result;
|
|
31932
31978
|
}
|
|
31933
31979
|
//#endregion
|
|
31980
|
+
//#region src/actions/package/publintRules.ts
|
|
31981
|
+
const PUBLINT_RULE_LEVELS = /* @__PURE__ */ new Set([
|
|
31982
|
+
"error",
|
|
31983
|
+
"off",
|
|
31984
|
+
"warn"
|
|
31985
|
+
]);
|
|
31986
|
+
function defaultPublintLevel(check) {
|
|
31987
|
+
return check === "platform" || check === "publint" ? "error" : "warn";
|
|
31988
|
+
}
|
|
31989
|
+
function normalizePublintConfig$2(value) {
|
|
31990
|
+
if (typeof value === "object") return value;
|
|
31991
|
+
return {};
|
|
31992
|
+
}
|
|
31993
|
+
function isPublintCheckName(value) {
|
|
31994
|
+
return ALL_PUBLINT_CHECKS.includes(value);
|
|
31995
|
+
}
|
|
31996
|
+
function isRuleLevel$2(value) {
|
|
31997
|
+
return typeof value === "string" && PUBLINT_RULE_LEVELS.has(value);
|
|
31998
|
+
}
|
|
31999
|
+
function candidateRuleLevelValue(value) {
|
|
32000
|
+
if (Array.isArray(value) && value.length > 0) return value[0];
|
|
32001
|
+
if (typeof value === "object" && value !== null) {
|
|
32002
|
+
const record = value;
|
|
32003
|
+
return record.level ?? record.enabled;
|
|
32004
|
+
}
|
|
32005
|
+
return value;
|
|
32006
|
+
}
|
|
32007
|
+
function parseRuleLevel(location, value) {
|
|
32008
|
+
const candidate = candidateRuleLevelValue(value);
|
|
32009
|
+
if (candidate === true) return "warn";
|
|
32010
|
+
if (candidate === false) return "off";
|
|
32011
|
+
if (isRuleLevel$2(candidate)) return candidate;
|
|
32012
|
+
throw new TypeError(`${location} must be "error", "warn", "off", boolean, [level, options], or { level?, enabled? }`);
|
|
32013
|
+
}
|
|
32014
|
+
function normalizePublintRuleNames(location, values) {
|
|
32015
|
+
return (values ?? []).map((value) => {
|
|
32016
|
+
if (!isPublintCheckName(value)) throw new TypeError(`Unknown publint check "${value}" in ${location}`);
|
|
32017
|
+
return value;
|
|
32018
|
+
});
|
|
32019
|
+
}
|
|
32020
|
+
function defaultLevels() {
|
|
32021
|
+
return new Map(ALL_PUBLINT_CHECKS.map((check) => [check, defaultPublintLevel(check)]));
|
|
32022
|
+
}
|
|
32023
|
+
function setRuleLevel(levels, explicit, check, level) {
|
|
32024
|
+
levels.set(check, level);
|
|
32025
|
+
explicit.add(check);
|
|
32026
|
+
}
|
|
32027
|
+
function applyIncludedOnly(levels, explicit, include) {
|
|
32028
|
+
if (include.length === 0) return;
|
|
32029
|
+
const included = new Set(include);
|
|
32030
|
+
for (const check of ALL_PUBLINT_CHECKS) {
|
|
32031
|
+
if (included.has(check)) continue;
|
|
32032
|
+
setRuleLevel(levels, explicit, check, "off");
|
|
32033
|
+
}
|
|
32034
|
+
}
|
|
32035
|
+
function applyExcluded(levels, explicit, exclude) {
|
|
32036
|
+
for (const check of exclude) setRuleLevel(levels, explicit, check, "off");
|
|
32037
|
+
}
|
|
32038
|
+
function applyConfiguredRules(levels, explicit, rules) {
|
|
32039
|
+
for (const [check, setting] of Object.entries(rules ?? {})) {
|
|
32040
|
+
if (!isPublintCheckName(check)) throw new TypeError(`Unknown publint check "${check}" in commands.publint.rules`);
|
|
32041
|
+
setRuleLevel(levels, explicit, check, parseRuleLevel(`commands.publint.rules["${check}"]`, setting));
|
|
32042
|
+
}
|
|
32043
|
+
}
|
|
32044
|
+
function resolvePublintRules(value, cliExclude, cliInclude) {
|
|
32045
|
+
const config = normalizePublintConfig$2(value);
|
|
32046
|
+
const configExclude = normalizePublintRuleNames("commands.publint.exclude", config.exclude);
|
|
32047
|
+
const configInclude = normalizePublintRuleNames("commands.publint.include", config.include);
|
|
32048
|
+
const normalizedCliExclude = normalizePublintRuleNames("--exclude", cliExclude);
|
|
32049
|
+
const normalizedCliInclude = normalizePublintRuleNames("--include", cliInclude);
|
|
32050
|
+
const levels = defaultLevels();
|
|
32051
|
+
const explicit = /* @__PURE__ */ new Set();
|
|
32052
|
+
if ((configExclude.length > 0 || normalizedCliExclude.length > 0) && (configInclude.length > 0 || normalizedCliInclude.length > 0)) throw new TypeError("Publint: --include and --exclude cannot be used together");
|
|
32053
|
+
applyIncludedOnly(levels, explicit, configInclude);
|
|
32054
|
+
applyExcluded(levels, explicit, configExclude);
|
|
32055
|
+
applyConfiguredRules(levels, explicit, config.rules);
|
|
32056
|
+
applyIncludedOnly(levels, explicit, normalizedCliInclude);
|
|
32057
|
+
applyExcluded(levels, explicit, normalizedCliExclude);
|
|
32058
|
+
return {
|
|
32059
|
+
explicit,
|
|
32060
|
+
levels
|
|
32061
|
+
};
|
|
32062
|
+
}
|
|
32063
|
+
function resolvePublintRuleLevels(value, cliExclude, cliInclude) {
|
|
32064
|
+
return resolvePublintRules(value, cliExclude, cliInclude).levels;
|
|
32065
|
+
}
|
|
32066
|
+
function cloneResolvedPublintRules(rules) {
|
|
32067
|
+
return {
|
|
32068
|
+
explicit: new Set(rules.explicit),
|
|
32069
|
+
levels: new Map(rules.levels)
|
|
32070
|
+
};
|
|
32071
|
+
}
|
|
32072
|
+
//#endregion
|
|
31934
32073
|
//#region ../../node_modules/.pnpm/@publint+pack@0.1.4/node_modules/@publint/pack/src/node/pack.js
|
|
31935
32074
|
/** @type {import('../index.d.ts').pack} */
|
|
31936
32075
|
async function pack(dir, opts) {
|
|
@@ -34048,9 +34187,6 @@ function normalizePublintConfig$1(value) {
|
|
|
34048
34187
|
if (typeof value === "object") return value;
|
|
34049
34188
|
return {};
|
|
34050
34189
|
}
|
|
34051
|
-
function mergeWorkspaceExclude(exclude, wsPublintConfig) {
|
|
34052
|
-
return /* @__PURE__ */ new Set([...exclude, ...wsPublintConfig.exclude ?? []]);
|
|
34053
|
-
}
|
|
34054
34190
|
const shouldRemoveSourceFromExports = (exports) => {
|
|
34055
34191
|
let isRemoved = false;
|
|
34056
34192
|
for (const [key, value] of Object.entries(exports)) if (key === "source") {
|
|
@@ -34106,6 +34242,15 @@ function mergeResults(target, source) {
|
|
|
34106
34242
|
target.warnings += source.warnings;
|
|
34107
34243
|
target.modified ||= source.modified;
|
|
34108
34244
|
}
|
|
34245
|
+
function mergeLeveledResult(target, source, check, rules) {
|
|
34246
|
+
const issueCount = source.errors + source.warnings;
|
|
34247
|
+
if (rules.explicit.has(check)) {
|
|
34248
|
+
const level = rules.levels.get(check) ?? defaultPublintLevel(check);
|
|
34249
|
+
if (level === "error") target.errors += issueCount;
|
|
34250
|
+
else if (level === "warn") target.warnings += issueCount;
|
|
34251
|
+
} else mergeResults(target, source);
|
|
34252
|
+
target.modified ||= source.modified;
|
|
34253
|
+
}
|
|
34109
34254
|
async function readPackageJson$3(pkgDir) {
|
|
34110
34255
|
return JSON.parse(await promises.readFile(PATH.join(pkgDir, "package.json"), "utf8"));
|
|
34111
34256
|
}
|
|
@@ -34232,21 +34377,21 @@ function checkRootTypes(pkg, shouldFix) {
|
|
|
34232
34377
|
result.warnings++;
|
|
34233
34378
|
return result;
|
|
34234
34379
|
}
|
|
34235
|
-
async function customPubLint(pkgDir, pkg, shouldFix = false,
|
|
34380
|
+
async function customPubLint(pkgDir, pkg, shouldFix = false, rules) {
|
|
34236
34381
|
const result = emptyCustomResult();
|
|
34237
|
-
if (
|
|
34238
|
-
if (
|
|
34239
|
-
if (
|
|
34240
|
-
if (
|
|
34241
|
-
if (
|
|
34242
|
-
if (
|
|
34243
|
-
if (
|
|
34244
|
-
if (
|
|
34245
|
-
if (
|
|
34246
|
-
if (
|
|
34247
|
-
if (
|
|
34248
|
-
if (
|
|
34249
|
-
if (
|
|
34382
|
+
if (rules.levels.get("files") !== "off") mergeLeveledResult(result, checkFiles(pkg, shouldFix), "files", rules);
|
|
34383
|
+
if (rules.levels.get("source") !== "off") mergeLeveledResult(result, checkExportsSource(pkg, shouldFix), "source", rules);
|
|
34384
|
+
if (rules.levels.get("rootSource") !== "off") mergeLeveledResult(result, checkRootSource(pkg, shouldFix), "rootSource", rules);
|
|
34385
|
+
if (rules.levels.get("main") !== "off") mergeLeveledResult(result, migrateFieldToExports(pkg, "main", "default", shouldFix), "main", rules);
|
|
34386
|
+
if (rules.levels.get("types") !== "off") mergeLeveledResult(result, migrateFieldToExports(pkg, "types", "types", shouldFix), "types", rules);
|
|
34387
|
+
if (rules.levels.get("module") !== "off") mergeLeveledResult(result, migrateFieldToExports(pkg, "module", "default", shouldFix), "module", rules);
|
|
34388
|
+
if (rules.levels.get("importToDefault") !== "off") mergeLeveledResult(result, checkImportToDefault(pkg, shouldFix), "importToDefault", rules);
|
|
34389
|
+
if (rules.levels.get("neutralToDefault") !== "off") mergeLeveledResult(result, checkNeutralToDefault(pkg, shouldFix, (message) => console.warn(chalk.yellow(message))), "neutralToDefault", rules);
|
|
34390
|
+
if (rules.levels.get("defaultExportOrder") !== "off") mergeLeveledResult(result, checkDefaultExportOrder(pkg, shouldFix, (message) => console.warn(chalk.yellow(message))), "defaultExportOrder", rules);
|
|
34391
|
+
if (rules.levels.get("rootTypes") !== "off") mergeLeveledResult(result, checkRootTypes(pkg, shouldFix), "rootTypes", rules);
|
|
34392
|
+
if (rules.levels.get("platform") !== "off") mergeLeveledResult(result, await checkPlatform(pkgDir, pkg, shouldFix), "platform", rules);
|
|
34393
|
+
if (rules.levels.get("sideEffects") !== "off") mergeLeveledResult(result, checkSideEffects(pkg), "sideEffects", rules);
|
|
34394
|
+
if (rules.levels.get("resolutions") !== "off") mergeLeveledResult(result, checkResolutions(pkg), "resolutions", rules);
|
|
34250
34395
|
return [
|
|
34251
34396
|
result.errors,
|
|
34252
34397
|
result.warnings,
|
|
@@ -34322,42 +34467,89 @@ async function runPublintLibrary(pkgDir, pkg, isStrict, shouldPack) {
|
|
|
34322
34467
|
warnings: messages.filter((message) => message.type !== "error").length
|
|
34323
34468
|
};
|
|
34324
34469
|
}
|
|
34325
|
-
|
|
34470
|
+
function applyEffectiveExcludes(pkg, exclude, rules) {
|
|
34471
|
+
const effectiveExclude = Boolean(pkg.private) ? /* @__PURE__ */ new Set([...exclude, ...PUBLISH_ONLY_CHECKS]) : exclude;
|
|
34472
|
+
for (const check of effectiveExclude) {
|
|
34473
|
+
rules.levels.set(check, "off");
|
|
34474
|
+
rules.explicit.add(check);
|
|
34475
|
+
}
|
|
34476
|
+
}
|
|
34477
|
+
async function runCustomPublintPass(pkgDir, pkg, shouldFix, rules) {
|
|
34478
|
+
const [errors, warnings, modified] = await customPubLint(pkgDir, pkg, shouldFix, rules);
|
|
34479
|
+
if (shouldFix && modified) {
|
|
34480
|
+
await writePackageJson$1(pkgDir, pkg);
|
|
34481
|
+
return {
|
|
34482
|
+
pkg: await readPackageJson$3(pkgDir),
|
|
34483
|
+
result: {
|
|
34484
|
+
errors,
|
|
34485
|
+
modified,
|
|
34486
|
+
warnings
|
|
34487
|
+
}
|
|
34488
|
+
};
|
|
34489
|
+
}
|
|
34490
|
+
return {
|
|
34491
|
+
pkg,
|
|
34492
|
+
result: {
|
|
34493
|
+
errors,
|
|
34494
|
+
modified,
|
|
34495
|
+
warnings
|
|
34496
|
+
}
|
|
34497
|
+
};
|
|
34498
|
+
}
|
|
34499
|
+
async function runLeveledPublintLibrary(pkgDir, pkg, isStrict, shouldPack, rules) {
|
|
34500
|
+
const level = rules.levels.get("publint");
|
|
34501
|
+
if (level === "off") return {
|
|
34502
|
+
errors: 0,
|
|
34503
|
+
warnings: 0
|
|
34504
|
+
};
|
|
34505
|
+
const library = await runPublintLibrary(pkgDir, pkg, isStrict, shouldPack);
|
|
34506
|
+
if (!rules.explicit.has("publint")) return library;
|
|
34507
|
+
const issueCount = library.errors + library.warnings;
|
|
34508
|
+
return level === "error" ? {
|
|
34509
|
+
errors: issueCount,
|
|
34510
|
+
warnings: 0
|
|
34511
|
+
} : {
|
|
34512
|
+
errors: 0,
|
|
34513
|
+
warnings: issueCount
|
|
34514
|
+
};
|
|
34515
|
+
}
|
|
34516
|
+
function runLeveledCompileTargets(pkgDir, shouldFix, rules) {
|
|
34517
|
+
const level = rules.levels.get("compileTargets");
|
|
34518
|
+
const raw = level === "off" ? {
|
|
34519
|
+
errors: 0,
|
|
34520
|
+
warnings: 0
|
|
34521
|
+
} : checkCompileTargets(pkgDir, shouldFix);
|
|
34522
|
+
if (!rules.explicit.has("compileTargets")) return raw;
|
|
34523
|
+
const issueCount = raw.errors + raw.warnings;
|
|
34524
|
+
return level === "error" ? {
|
|
34525
|
+
errors: issueCount,
|
|
34526
|
+
warnings: 0
|
|
34527
|
+
} : {
|
|
34528
|
+
errors: 0,
|
|
34529
|
+
warnings: issueCount
|
|
34530
|
+
};
|
|
34531
|
+
}
|
|
34532
|
+
const packagePublintDetailed = async ({ exclude = /* @__PURE__ */ new Set(), ruleLevels, shouldFix = false, shouldPack: shouldPackParam, pkgDir: pkgDirParam, isStrict = isStrictMode(), verbose: _verbose = false } = {}) => {
|
|
34326
34533
|
const pkgDir = PATH.resolve(pkgDirParam ?? INIT_CWD());
|
|
34327
34534
|
const wsPublintConfig = normalizePublintConfig$1(await loadWorkspaceCommandConfig(pkgDir, "publint"));
|
|
34328
|
-
const workspaceExclude = mergeWorkspaceExclude(exclude, wsPublintConfig);
|
|
34329
34535
|
const shouldPack = shouldPackParam ?? wsPublintConfig.pack ?? true;
|
|
34536
|
+
const resolvedRules = ruleLevels === void 0 ? resolvePublintRules(wsPublintConfig) : cloneResolvedPublintRules(ruleLevels);
|
|
34330
34537
|
let pkg = await readPackageJson$3(pkgDir);
|
|
34331
|
-
|
|
34538
|
+
applyEffectiveExcludes(pkg, exclude, resolvedRules);
|
|
34332
34539
|
console.log(chalk.green(`Publint: ${String(pkg.name)}${Boolean(pkg.private) ? chalk.gray(" (private)") : ""}`));
|
|
34333
34540
|
console.log(chalk.gray(pkgDir));
|
|
34334
|
-
let
|
|
34335
|
-
|
|
34336
|
-
|
|
34337
|
-
|
|
34338
|
-
|
|
34339
|
-
|
|
34340
|
-
|
|
34341
|
-
|
|
34342
|
-
|
|
34343
|
-
await writePackageJson$1(pkgDir, pkg);
|
|
34344
|
-
pkg = await readPackageJson$3(pkgDir);
|
|
34345
|
-
}
|
|
34346
|
-
};
|
|
34347
|
-
if (shouldFix) await runCustomChecks();
|
|
34348
|
-
if (!effectiveExclude.has("publint")) {
|
|
34349
|
-
const library = await runPublintLibrary(pkgDir, pkg, isStrict, shouldPack);
|
|
34350
|
-
libraryErrors = library.errors;
|
|
34351
|
-
libraryWarnings = library.warnings;
|
|
34352
|
-
}
|
|
34353
|
-
if (!shouldFix) await runCustomChecks();
|
|
34354
|
-
const compileTargets = effectiveExclude.has("compileTargets") ? {
|
|
34355
|
-
errors: 0,
|
|
34356
|
-
warnings: 0
|
|
34357
|
-
} : checkCompileTargets(pkgDir, shouldFix);
|
|
34541
|
+
let customResult = emptyCustomResult();
|
|
34542
|
+
if (shouldFix) {
|
|
34543
|
+
const customPass = await runCustomPublintPass(pkgDir, pkg, shouldFix, resolvedRules);
|
|
34544
|
+
customResult = customPass.result;
|
|
34545
|
+
pkg = customPass.pkg;
|
|
34546
|
+
}
|
|
34547
|
+
const library = await runLeveledPublintLibrary(pkgDir, pkg, isStrict, shouldPack, resolvedRules);
|
|
34548
|
+
if (!shouldFix) customResult = (await runCustomPublintPass(pkgDir, pkg, shouldFix, resolvedRules)).result;
|
|
34549
|
+
const compileTargets = runLeveledCompileTargets(pkgDir, shouldFix, resolvedRules);
|
|
34358
34550
|
return {
|
|
34359
|
-
errors:
|
|
34360
|
-
warnings:
|
|
34551
|
+
errors: library.errors + customResult.errors + compileTargets.errors,
|
|
34552
|
+
warnings: library.warnings + customResult.warnings + compileTargets.warnings
|
|
34361
34553
|
};
|
|
34362
34554
|
};
|
|
34363
34555
|
//#endregion
|
|
@@ -34648,18 +34840,13 @@ function publintOptionsHash({ cliExclude, cliInclude, fix, pack }) {
|
|
|
34648
34840
|
strict: isStrictMode()
|
|
34649
34841
|
};
|
|
34650
34842
|
}
|
|
34651
|
-
function
|
|
34652
|
-
|
|
34653
|
-
|
|
34654
|
-
|
|
34655
|
-
console.error(chalk.red(
|
|
34843
|
+
function resolveRulesOrReport(publintConfig, cliExclude, cliInclude) {
|
|
34844
|
+
try {
|
|
34845
|
+
return resolvePublintRules(publintConfig, cliExclude, cliInclude);
|
|
34846
|
+
} catch (ex) {
|
|
34847
|
+
console.error(chalk.red(ex instanceof Error ? ex.message : String(ex)));
|
|
34656
34848
|
return;
|
|
34657
34849
|
}
|
|
34658
|
-
if (hasInclude) {
|
|
34659
|
-
const include = /* @__PURE__ */ new Set([...publintConfig.include ?? [], ...cliInclude ?? []]);
|
|
34660
|
-
return new Set(ALL_PUBLINT_CHECKS.filter((c) => !include.has(c)));
|
|
34661
|
-
}
|
|
34662
|
-
return /* @__PURE__ */ new Set([...publintConfig.exclude ?? [], ...cliExclude ?? []]);
|
|
34663
34850
|
}
|
|
34664
34851
|
function normalizePublintConfig(value) {
|
|
34665
34852
|
if (typeof value === "object") return value;
|
|
@@ -34668,6 +34855,11 @@ function normalizePublintConfig(value) {
|
|
|
34668
34855
|
function shouldRunWorkspaceCheck(exclude, check) {
|
|
34669
34856
|
return WORKSPACE_PUBLINT_CHECKS.includes(check) && !exclude.has(check);
|
|
34670
34857
|
}
|
|
34858
|
+
function offChecks(rules) {
|
|
34859
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
34860
|
+
for (const [check, level] of rules.levels) if (level === "off") excluded.add(check);
|
|
34861
|
+
return excluded;
|
|
34862
|
+
}
|
|
34671
34863
|
const publint = async ({ cliExclude, cliInclude, fix, incremental, jobs, pack, verbose, pkg, workspaces }) => {
|
|
34672
34864
|
if (pkg === void 0 && shouldUseIncremental$1(incremental)) return await publintIncremental({
|
|
34673
34865
|
cliExclude,
|
|
@@ -34708,10 +34900,11 @@ const publintSingle = async ({ cliExclude, cliInclude, fix, pack, pkg, verbose }
|
|
|
34708
34900
|
return resultFromExitCode(1);
|
|
34709
34901
|
}
|
|
34710
34902
|
const wsPublintConfig = normalizePublintConfig(await loadWorkspaceCommandConfig(workspace.location, "publint"));
|
|
34711
|
-
const
|
|
34712
|
-
if (!
|
|
34903
|
+
const resolvedRules = resolveRulesOrReport(wsPublintConfig, cliExclude, cliInclude);
|
|
34904
|
+
if (!resolvedRules) return resultFromExitCode(1);
|
|
34713
34905
|
const result = await packagePublintDetailed({
|
|
34714
|
-
exclude,
|
|
34906
|
+
exclude: offChecks(resolvedRules),
|
|
34907
|
+
ruleLevels: resolvedRules,
|
|
34715
34908
|
shouldFix: fix,
|
|
34716
34909
|
shouldPack: pack ?? wsPublintConfig.pack ?? true,
|
|
34717
34910
|
pkgDir: workspace.location,
|
|
@@ -34724,6 +34917,68 @@ const publintSingle = async ({ cliExclude, cliInclude, fix, pack, pkg, verbose }
|
|
|
34724
34917
|
warningCount: result.warnings
|
|
34725
34918
|
});
|
|
34726
34919
|
};
|
|
34920
|
+
async function runWorkspacePublint({ cliExclude, cliInclude, fix, pack, verbose, ws }) {
|
|
34921
|
+
const output = [];
|
|
34922
|
+
let captured = {
|
|
34923
|
+
errors: 0,
|
|
34924
|
+
output,
|
|
34925
|
+
warnings: 0
|
|
34926
|
+
};
|
|
34927
|
+
await outputStorage.run(output, async () => {
|
|
34928
|
+
try {
|
|
34929
|
+
const wsPublintConfig = normalizePublintConfig(await loadWorkspaceCommandConfig(ws.location, "publint"));
|
|
34930
|
+
const resolvedRules = resolvePublintRules(wsPublintConfig, cliExclude, cliInclude);
|
|
34931
|
+
const shouldPack = pack ?? wsPublintConfig.pack ?? true;
|
|
34932
|
+
const result = await packagePublintDetailed({
|
|
34933
|
+
exclude: offChecks(resolvedRules),
|
|
34934
|
+
ruleLevels: resolvedRules,
|
|
34935
|
+
shouldFix: fix,
|
|
34936
|
+
shouldPack,
|
|
34937
|
+
pkgDir: ws.location,
|
|
34938
|
+
verbose
|
|
34939
|
+
});
|
|
34940
|
+
captured = {
|
|
34941
|
+
errors: result.errors,
|
|
34942
|
+
output,
|
|
34943
|
+
warnings: result.warnings
|
|
34944
|
+
};
|
|
34945
|
+
} catch (ex) {
|
|
34946
|
+
output.push(chalk.red(`Publint failed for ${ws.name}: ${ex.message}\n`));
|
|
34947
|
+
captured = {
|
|
34948
|
+
errors: 1,
|
|
34949
|
+
output,
|
|
34950
|
+
warnings: 0
|
|
34951
|
+
};
|
|
34952
|
+
}
|
|
34953
|
+
});
|
|
34954
|
+
return captured;
|
|
34955
|
+
}
|
|
34956
|
+
async function runPeerDependencyPublint({ cliExclude, cliInclude, fix, workspaces }) {
|
|
34957
|
+
const rootConfig = await loadConfig();
|
|
34958
|
+
const rootRules = resolveRulesOrReport(normalizePublintConfig(rootConfig.commands?.publint ?? rootConfig.publint), cliExclude, cliInclude);
|
|
34959
|
+
if (!rootRules || !shouldRunWorkspaceCheck(offChecks(rootRules), "peerDeps")) return {
|
|
34960
|
+
errors: rootRules ? 0 : 1,
|
|
34961
|
+
warnings: 0
|
|
34962
|
+
};
|
|
34963
|
+
const cwd = INIT_CWD();
|
|
34964
|
+
const peerResult = checkInternalPeerVersions(cwd, workspaces);
|
|
34965
|
+
const fixableCount = peerResult.fixable.length;
|
|
34966
|
+
if (fixableCount > 0 && (fix ?? false)) {
|
|
34967
|
+
fixInternalPeerVersions(cwd, workspaces);
|
|
34968
|
+
shouldRunInstall();
|
|
34969
|
+
} else if (fixableCount > 0) {
|
|
34970
|
+
const isPeerError = rootRules.levels.get("peerDeps") === "error" || isStrictMode();
|
|
34971
|
+
for (const msg of peerResult.fixable) console.log(isPeerError ? chalk.red(` ✗ ${msg} (fixable)`) : chalk.yellow(` ⚠ ${msg} (fixable)`));
|
|
34972
|
+
return {
|
|
34973
|
+
errors: peerResult.errors.length + (isPeerError ? fixableCount : 0),
|
|
34974
|
+
warnings: isPeerError ? 0 : fixableCount
|
|
34975
|
+
};
|
|
34976
|
+
}
|
|
34977
|
+
return {
|
|
34978
|
+
errors: peerResult.errors.length,
|
|
34979
|
+
warnings: 0
|
|
34980
|
+
};
|
|
34981
|
+
}
|
|
34727
34982
|
async function publintIncremental({ cliExclude, cliInclude, fix, jobs, pack, verbose, workspaces: targetWorkspaces }) {
|
|
34728
34983
|
const pm = getPackageManager();
|
|
34729
34984
|
const allWorkspaces = targetWorkspaces ?? pm.listWorkspaces();
|
|
@@ -34784,30 +35039,13 @@ const publintAll = async ({ cliExclude, cliInclude, fix, jobs, pack, verbose, wo
|
|
|
34784
35039
|
i,
|
|
34785
35040
|
ws
|
|
34786
35041
|
})), concurrency, async ({ i, ws }) => {
|
|
34787
|
-
|
|
34788
|
-
|
|
34789
|
-
|
|
34790
|
-
|
|
34791
|
-
|
|
34792
|
-
|
|
34793
|
-
|
|
34794
|
-
shouldPack: pack ?? wsPublintConfig.pack ?? true,
|
|
34795
|
-
pkgDir: ws.location,
|
|
34796
|
-
verbose
|
|
34797
|
-
});
|
|
34798
|
-
results[i] = {
|
|
34799
|
-
errors: result.errors,
|
|
34800
|
-
output,
|
|
34801
|
-
warnings: result.warnings
|
|
34802
|
-
};
|
|
34803
|
-
} catch (ex) {
|
|
34804
|
-
output.push(chalk.red(`Publint failed for ${ws.name}: ${ex.message}\n`));
|
|
34805
|
-
results[i] = {
|
|
34806
|
-
errors: 1,
|
|
34807
|
-
output,
|
|
34808
|
-
warnings: 0
|
|
34809
|
-
};
|
|
34810
|
-
}
|
|
35042
|
+
results[i] = await runWorkspacePublint({
|
|
35043
|
+
cliExclude,
|
|
35044
|
+
cliInclude,
|
|
35045
|
+
fix,
|
|
35046
|
+
pack,
|
|
35047
|
+
verbose,
|
|
35048
|
+
ws
|
|
34811
35049
|
});
|
|
34812
35050
|
});
|
|
34813
35051
|
let totalErrors = 0;
|
|
@@ -34817,19 +35055,14 @@ const publintAll = async ({ cliExclude, cliInclude, fix, jobs, pack, verbose, wo
|
|
|
34817
35055
|
totalErrors += errors;
|
|
34818
35056
|
totalWarnings += warnings;
|
|
34819
35057
|
}
|
|
34820
|
-
|
|
34821
|
-
|
|
34822
|
-
|
|
34823
|
-
|
|
34824
|
-
|
|
34825
|
-
|
|
34826
|
-
|
|
34827
|
-
|
|
34828
|
-
for (const msg of peerResult.fixable) console.log(isStrict ? chalk.red(` ✗ ${msg} (fixable)`) : chalk.yellow(` ⚠ ${msg} (fixable)`));
|
|
34829
|
-
totalWarnings += peerResult.fixable.length;
|
|
34830
|
-
}
|
|
34831
|
-
totalErrors += peerResult.errors.length;
|
|
34832
|
-
}
|
|
35058
|
+
const peerResult = await runPeerDependencyPublint({
|
|
35059
|
+
cliExclude,
|
|
35060
|
+
cliInclude,
|
|
35061
|
+
fix,
|
|
35062
|
+
workspaces
|
|
35063
|
+
});
|
|
35064
|
+
totalErrors += peerResult.errors;
|
|
35065
|
+
totalWarnings += peerResult.warnings;
|
|
34833
35066
|
logPublintSummary(workspaces.length, totalErrors, totalWarnings, performance.now() - start);
|
|
34834
35067
|
return actionResult({
|
|
34835
35068
|
errorCount: totalErrors,
|
|
@@ -36124,7 +36357,7 @@ const VALID_RULE_LEVELS = /* @__PURE__ */ new Set([
|
|
|
36124
36357
|
function isRecord$2(value) {
|
|
36125
36358
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36126
36359
|
}
|
|
36127
|
-
function isRuleLevel(value) {
|
|
36360
|
+
function isRuleLevel$1(value) {
|
|
36128
36361
|
return typeof value === "string" && VALID_RULE_LEVELS.has(value);
|
|
36129
36362
|
}
|
|
36130
36363
|
function severityFromLevel(level) {
|
|
@@ -36135,7 +36368,7 @@ function formatRuleConfigLocation(ruleId) {
|
|
|
36135
36368
|
}
|
|
36136
36369
|
function parseRuleConfig(ruleId, value) {
|
|
36137
36370
|
if (typeof value === "string") {
|
|
36138
|
-
if (!isRuleLevel(value)) throw new TypeError(`${formatRuleConfigLocation(ruleId)} must be one of "off", "warn", or "error"`);
|
|
36371
|
+
if (!isRuleLevel$1(value)) throw new TypeError(`${formatRuleConfigLocation(ruleId)} must be one of "off", "warn", or "error"`);
|
|
36139
36372
|
return {
|
|
36140
36373
|
level: value,
|
|
36141
36374
|
options: {}
|
|
@@ -36144,7 +36377,7 @@ function parseRuleConfig(ruleId, value) {
|
|
|
36144
36377
|
if (Array.isArray(value)) {
|
|
36145
36378
|
if (value.length !== 2) throw new TypeError(`${formatRuleConfigLocation(ruleId)} tuple must be [level, options]`);
|
|
36146
36379
|
const level = value[0];
|
|
36147
|
-
if (!isRuleLevel(level)) throw new TypeError(`${formatRuleConfigLocation(ruleId)} level must be one of "off", "warn", or "error"`);
|
|
36380
|
+
if (!isRuleLevel$1(level)) throw new TypeError(`${formatRuleConfigLocation(ruleId)} level must be one of "off", "warn", or "error"`);
|
|
36148
36381
|
const options = value[1];
|
|
36149
36382
|
if (!isRecord$2(options)) throw new TypeError(`${formatRuleConfigLocation(ruleId)} options must be an object`);
|
|
36150
36383
|
return {
|
|
@@ -37298,45 +37531,189 @@ function gitignore() {
|
|
|
37298
37531
|
}
|
|
37299
37532
|
}
|
|
37300
37533
|
//#endregion
|
|
37534
|
+
//#region src/actions/ruleRunner.ts
|
|
37535
|
+
const RULE_LEVELS = /* @__PURE__ */ new Set([
|
|
37536
|
+
"error",
|
|
37537
|
+
"off",
|
|
37538
|
+
"warn"
|
|
37539
|
+
]);
|
|
37540
|
+
function isRuleLevel(value) {
|
|
37541
|
+
return typeof value === "string" && RULE_LEVELS.has(value);
|
|
37542
|
+
}
|
|
37543
|
+
function parseRuleLevelSetting(location, setting, defaultLevel) {
|
|
37544
|
+
if (setting === void 0) return defaultLevel;
|
|
37545
|
+
if (typeof setting === "boolean") return setting ? "warn" : "off";
|
|
37546
|
+
if (isRuleLevel(setting)) return setting;
|
|
37547
|
+
if (Array.isArray(setting) && setting.length > 0) {
|
|
37548
|
+
const [level] = setting;
|
|
37549
|
+
if (isRuleLevel(level)) return level;
|
|
37550
|
+
}
|
|
37551
|
+
if (typeof setting === "object" && setting !== null && !Array.isArray(setting)) {
|
|
37552
|
+
const record = setting;
|
|
37553
|
+
if (record.level !== void 0) {
|
|
37554
|
+
if (!isRuleLevel(record.level)) throw new TypeError(`${location}.level must be "error", "warn", or "off"`);
|
|
37555
|
+
return record.level;
|
|
37556
|
+
}
|
|
37557
|
+
if (record.enabled !== void 0) {
|
|
37558
|
+
if (typeof record.enabled !== "boolean") throw new TypeError(`${location}.enabled must be a boolean`);
|
|
37559
|
+
return record.enabled ? defaultLevel : "off";
|
|
37560
|
+
}
|
|
37561
|
+
}
|
|
37562
|
+
throw new TypeError(`${location} must be a rule level, boolean, [level, options], or { level?, enabled? } object`);
|
|
37563
|
+
}
|
|
37564
|
+
function validateConfiguredRuleIds(commandName, rules, config) {
|
|
37565
|
+
const known = new Set(rules.map((rule) => rule.id));
|
|
37566
|
+
const unknown = Object.keys(config?.rules ?? {}).filter((id) => !known.has(id));
|
|
37567
|
+
if (unknown.length > 0) throw new TypeError(`Unknown ${commandName} rule ${unknown.map((id) => `"${id}"`).join(", ")}`);
|
|
37568
|
+
}
|
|
37569
|
+
function diagnosticsForRule(rule, level, isExplicit, diagnostics) {
|
|
37570
|
+
return (diagnostics ?? []).map((diagnostic) => ({
|
|
37571
|
+
...diagnostic,
|
|
37572
|
+
level: isExplicit ? level : diagnostic.level ?? level,
|
|
37573
|
+
rule: diagnostic.rule ?? rule.id
|
|
37574
|
+
}));
|
|
37575
|
+
}
|
|
37576
|
+
function resolveRuleLevel(commandName, rule, config) {
|
|
37577
|
+
const setting = config?.rules?.[rule.id];
|
|
37578
|
+
return {
|
|
37579
|
+
isExplicit: setting !== void 0,
|
|
37580
|
+
level: parseRuleLevelSetting(`${commandName}.rules["${rule.id}"]`, setting, rule.defaultLevel)
|
|
37581
|
+
};
|
|
37582
|
+
}
|
|
37583
|
+
function buildRunResult(report, strict) {
|
|
37584
|
+
const errors = report.diagnostics.filter((diagnostic) => diagnostic.level === "error");
|
|
37585
|
+
const warnings = report.diagnostics.filter((diagnostic) => diagnostic.level === "warn");
|
|
37586
|
+
const exitCode = report.errorCount > 0 || strict && report.warningCount > 0 ? 1 : 0;
|
|
37587
|
+
const result = actionResult({
|
|
37588
|
+
errorCount: report.errorCount,
|
|
37589
|
+
exitCode,
|
|
37590
|
+
warningCount: report.warningCount
|
|
37591
|
+
});
|
|
37592
|
+
if (typeof result === "number") return {
|
|
37593
|
+
envelope: {
|
|
37594
|
+
data: report,
|
|
37595
|
+
errorCount: 0,
|
|
37596
|
+
warningCount: 0
|
|
37597
|
+
},
|
|
37598
|
+
exitCode: 0
|
|
37599
|
+
};
|
|
37600
|
+
return {
|
|
37601
|
+
envelope: {
|
|
37602
|
+
...result.envelope,
|
|
37603
|
+
data: report,
|
|
37604
|
+
errors,
|
|
37605
|
+
warnings
|
|
37606
|
+
},
|
|
37607
|
+
exitCode: result.exitCode
|
|
37608
|
+
};
|
|
37609
|
+
}
|
|
37610
|
+
function recordRuleOutcome(report, rule, diagnostics, fixedCount, reporter) {
|
|
37611
|
+
report.fixedCount += fixedCount;
|
|
37612
|
+
for (const diagnostic of diagnostics) {
|
|
37613
|
+
report.diagnostics.push(diagnostic);
|
|
37614
|
+
if (diagnostic.level === "error") report.errorCount += 1;
|
|
37615
|
+
else report.warningCount += 1;
|
|
37616
|
+
reporter?.diagnostic?.(diagnostic);
|
|
37617
|
+
}
|
|
37618
|
+
if (fixedCount > 0) reporter?.fixed?.(rule, fixedCount);
|
|
37619
|
+
if (diagnostics.length === 0 && fixedCount === 0) reporter?.passed?.(rule);
|
|
37620
|
+
}
|
|
37621
|
+
async function runRuleChecks({ commandName, config, context, fix = false, reporter, rules, strict = isStrictMode() }) {
|
|
37622
|
+
validateConfiguredRuleIds(commandName, rules, config);
|
|
37623
|
+
const report = {
|
|
37624
|
+
diagnostics: [],
|
|
37625
|
+
errorCount: 0,
|
|
37626
|
+
fixedCount: 0,
|
|
37627
|
+
warningCount: 0
|
|
37628
|
+
};
|
|
37629
|
+
for (const rule of rules) {
|
|
37630
|
+
const { isExplicit, level } = resolveRuleLevel(commandName, rule, config);
|
|
37631
|
+
if (level === "off") continue;
|
|
37632
|
+
const outcome = await rule.check(context, {
|
|
37633
|
+
fix,
|
|
37634
|
+
isExplicit,
|
|
37635
|
+
level
|
|
37636
|
+
});
|
|
37637
|
+
recordRuleOutcome(report, rule, diagnosticsForRule(rule, level, isExplicit, outcome.diagnostics), outcome.fixedCount ?? 0, reporter);
|
|
37638
|
+
}
|
|
37639
|
+
return buildRunResult(report, strict);
|
|
37640
|
+
}
|
|
37641
|
+
//#endregion
|
|
37301
37642
|
//#region src/actions/gitlint.ts
|
|
37302
|
-
|
|
37303
|
-
|
|
37304
|
-
|
|
37305
|
-
|
|
37306
|
-
|
|
37307
|
-
|
|
37308
|
-
|
|
37309
|
-
|
|
37310
|
-
|
|
37311
|
-
|
|
37312
|
-
|
|
37313
|
-
|
|
37314
|
-
|
|
37315
|
-
|
|
37316
|
-
|
|
37643
|
+
const GITLINT_RULES$1 = [
|
|
37644
|
+
{
|
|
37645
|
+
check: (_context, { fix }) => {
|
|
37646
|
+
if (getGitConfigBool("core.ignorecase") !== true) return {};
|
|
37647
|
+
if (fix) {
|
|
37648
|
+
setGitConfig("core.ignorecase", "false");
|
|
37649
|
+
return { fixedCount: 1 };
|
|
37650
|
+
}
|
|
37651
|
+
return { diagnostics: [{ message: "Please set core.ignorecase to FALSE in .git/config file [run xy gitlint --fix]" }] };
|
|
37652
|
+
},
|
|
37653
|
+
defaultLevel: "warn",
|
|
37654
|
+
description: "core.ignorecase must be false",
|
|
37655
|
+
id: "git.core.ignorecase"
|
|
37656
|
+
},
|
|
37657
|
+
{
|
|
37658
|
+
check: (_context, { fix }) => {
|
|
37659
|
+
if (getGitConfigBool("core.autocrlf") === false) return {};
|
|
37660
|
+
if (fix) {
|
|
37661
|
+
setGitConfig("core.autocrlf", "false");
|
|
37662
|
+
return { fixedCount: 1 };
|
|
37663
|
+
}
|
|
37664
|
+
return { diagnostics: [{ message: "Please set core.autocrlf to FALSE in .git/config file [run xy gitlint --fix]" }] };
|
|
37665
|
+
},
|
|
37666
|
+
defaultLevel: "warn",
|
|
37667
|
+
description: "core.autocrlf must be false",
|
|
37668
|
+
id: "git.core.autocrlf"
|
|
37669
|
+
},
|
|
37670
|
+
{
|
|
37671
|
+
check: (_context, { fix }) => {
|
|
37672
|
+
if (getGitConfig("core.eol") === "lf") return {};
|
|
37673
|
+
if (fix) {
|
|
37674
|
+
setGitConfig("core.eol", "lf");
|
|
37675
|
+
return { fixedCount: 1 };
|
|
37676
|
+
}
|
|
37677
|
+
return { diagnostics: [{ message: "Please set core.eol to \"lf\" in .git/config file [run xy gitlint --fix]" }] };
|
|
37678
|
+
},
|
|
37679
|
+
defaultLevel: "warn",
|
|
37680
|
+
description: "core.eol must be lf",
|
|
37681
|
+
id: "git.core.eol"
|
|
37682
|
+
}
|
|
37683
|
+
];
|
|
37684
|
+
function logGitlintDiagnostic(diagnostic) {
|
|
37685
|
+
const color = diagnostic.level === "error" ? chalk.red : chalk.yellow;
|
|
37686
|
+
console.warn(color(`${diagnostic.level === "error" ? "Error" : "Warning"}: ${diagnostic.message}`));
|
|
37687
|
+
}
|
|
37688
|
+
async function runGitlint(fix = false) {
|
|
37689
|
+
console.log(`\nGitlint${fix ? " Fix" : ""} Start [${process.cwd()}]\n`);
|
|
37690
|
+
const result = await runRuleChecks({
|
|
37691
|
+
commandName: "gitlint",
|
|
37692
|
+
config: await loadWorkspaceCommandConfig(process.cwd(), "gitlint"),
|
|
37693
|
+
context: void 0,
|
|
37694
|
+
fix,
|
|
37695
|
+
reporter: {
|
|
37696
|
+
diagnostic: logGitlintDiagnostic,
|
|
37697
|
+
fixed: (rule) => console.warn(chalk.yellow(`\nGitlint Fix: Updated ${rule.id.replace(/^git\./, "")}\n`))
|
|
37698
|
+
},
|
|
37699
|
+
rules: GITLINT_RULES$1
|
|
37700
|
+
});
|
|
37701
|
+
const valid = GITLINT_RULES$1.length - result.envelope.data.diagnostics.length - result.envelope.data.fixedCount;
|
|
37317
37702
|
const resultMessages = [];
|
|
37318
37703
|
if (valid > 0) resultMessages.push(chalk.green(`Passed: ${valid}`));
|
|
37319
|
-
if (
|
|
37704
|
+
if (result.envelope.warningCount > 0) resultMessages.push(chalk.yellow(`Warnings: ${result.envelope.warningCount}`));
|
|
37705
|
+
if (result.envelope.errorCount > 0) resultMessages.push(chalk.red(`Errors: ${result.envelope.errorCount}`));
|
|
37706
|
+
if (result.envelope.data.fixedCount > 0) resultMessages.push(chalk.green(`Fixed: ${result.envelope.data.fixedCount}`));
|
|
37320
37707
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]\n`);
|
|
37321
|
-
return
|
|
37708
|
+
return result;
|
|
37709
|
+
}
|
|
37710
|
+
function gitlint() {
|
|
37711
|
+
return runGitlint(false);
|
|
37322
37712
|
}
|
|
37323
37713
|
//#endregion
|
|
37324
37714
|
//#region src/actions/gitlint-fix.ts
|
|
37325
37715
|
function gitlintFix() {
|
|
37326
|
-
|
|
37327
|
-
if (getGitConfigBool("core.ignorecase") === true) {
|
|
37328
|
-
setGitConfig("core.ignorecase", "false");
|
|
37329
|
-
console.warn(chalk.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
37330
|
-
}
|
|
37331
|
-
if (getGitConfigBool("core.autocrlf") !== false) {
|
|
37332
|
-
setGitConfig("core.autocrlf", "false");
|
|
37333
|
-
console.warn(chalk.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
37334
|
-
}
|
|
37335
|
-
if (getGitConfig("core.eol") !== "lf") {
|
|
37336
|
-
setGitConfig("core.eol", "lf");
|
|
37337
|
-
console.warn(chalk.yellow("\nGitlint Fix: Updated core.eol to be \"lf\"\n"));
|
|
37338
|
-
}
|
|
37339
|
-
return 0;
|
|
37716
|
+
return runGitlint(true);
|
|
37340
37717
|
}
|
|
37341
37718
|
//#endregion
|
|
37342
37719
|
//#region src/actions/install.ts
|
|
@@ -37637,25 +38014,6 @@ function compareRules(explicitRuleNames, allResolvedRules, sharedRules) {
|
|
|
37637
38014
|
redundant
|
|
37638
38015
|
};
|
|
37639
38016
|
}
|
|
37640
|
-
function reportResults({ additions, overrides, redundant }, isVerbose) {
|
|
37641
|
-
if (redundant.length > 0) {
|
|
37642
|
-
console.log(chalk.yellow(`\n${redundant.length} redundant rule(s) (same as shared config — can be removed):`));
|
|
37643
|
-
for (const { rule, local } of redundant) console.log(chalk.yellow(` ${rule}: ${formatRule(local)}`));
|
|
37644
|
-
}
|
|
37645
|
-
if (overrides.length > 0) {
|
|
37646
|
-
console.log(chalk.cyan(`\n${overrides.length} rule override(s) (different from shared config):`));
|
|
37647
|
-
for (const { rule, local, shared } of overrides) {
|
|
37648
|
-
console.log(chalk.cyan(` ${rule}:`));
|
|
37649
|
-
console.log(chalk.gray(` shared: ${formatRule(shared)}`));
|
|
37650
|
-
console.log(chalk.white(` local: ${formatRule(local)}`));
|
|
37651
|
-
}
|
|
37652
|
-
}
|
|
37653
|
-
if (additions.length > 0 && isVerbose) {
|
|
37654
|
-
console.log(chalk.gray(`\n${additions.length} local addition(s) (not in shared config):`));
|
|
37655
|
-
for (const { rule, local } of additions) console.log(chalk.gray(` ${rule}: ${formatRule(local)}`));
|
|
37656
|
-
}
|
|
37657
|
-
if (redundant.length === 0 && overrides.length === 0) console.log(chalk.green("No redundant or overridden rules found"));
|
|
37658
|
-
}
|
|
37659
38017
|
function fixRedundantRules(eslintConfigPath, redundant) {
|
|
37660
38018
|
let updated = readFileSync(eslintConfigPath, "utf8");
|
|
37661
38019
|
const original = updated;
|
|
@@ -37691,29 +38049,97 @@ function fixConfigMismatch(eslintConfigPath, configDir, source, sharedPkg, expec
|
|
|
37691
38049
|
console.log(chalk.green(`Updated package.json: ${sharedPkg} → ${expectedPkg}`));
|
|
37692
38050
|
shouldRunInstall(configDir);
|
|
37693
38051
|
}
|
|
37694
|
-
function
|
|
38052
|
+
function detectConfigVariantMismatch(configDir, sharedPkg, isVerbose) {
|
|
37695
38053
|
const hasReact = isReactInMonorepo(configDir, isVerbose);
|
|
37696
38054
|
const expectedPkg = hasReact ? "@ariestools/eslint-config-react-flat" : "@ariestools/eslint-config-flat";
|
|
37697
|
-
if (sharedPkg === expectedPkg) return
|
|
37698
|
-
|
|
37699
|
-
|
|
37700
|
-
|
|
37701
|
-
|
|
38055
|
+
if (sharedPkg === expectedPkg) return void 0;
|
|
38056
|
+
return {
|
|
38057
|
+
expectedPkg,
|
|
38058
|
+
hasReact
|
|
38059
|
+
};
|
|
37702
38060
|
}
|
|
37703
|
-
function
|
|
37704
|
-
|
|
37705
|
-
|
|
38061
|
+
function logConfigVariantMismatch(sharedPkg, mismatch) {
|
|
38062
|
+
console.log(chalk.yellow(`\nConfig mismatch: using ${sharedPkg} but ${mismatch.hasReact ? "React packages detected" : "no React packages found"}`));
|
|
38063
|
+
console.log(chalk.yellow(` Expected: ${mismatch.expectedPkg}`));
|
|
37706
38064
|
}
|
|
38065
|
+
function lintlintDiagnostics(ruleId, messages) {
|
|
38066
|
+
return messages.map((message) => ({
|
|
38067
|
+
message,
|
|
38068
|
+
rule: ruleId
|
|
38069
|
+
}));
|
|
38070
|
+
}
|
|
38071
|
+
function logLintlintDiagnostic(diagnostic) {
|
|
38072
|
+
const color = diagnostic.level === "error" ? chalk.red : chalk.yellow;
|
|
38073
|
+
const marker = diagnostic.level === "error" ? "✗" : "⚠";
|
|
38074
|
+
console.log(color(` ${marker} ${diagnostic.message}`));
|
|
38075
|
+
}
|
|
38076
|
+
function logAdditions({ additions }, isVerbose) {
|
|
38077
|
+
if (additions.length === 0 || !isVerbose) return;
|
|
38078
|
+
console.log(chalk.gray(`\n${additions.length} local addition(s) (not in shared config):`));
|
|
38079
|
+
for (const { rule, local } of additions) console.log(chalk.gray(` ${rule}: ${formatRule(local)}`));
|
|
38080
|
+
}
|
|
38081
|
+
const LINTLINT_RULES$1 = [
|
|
38082
|
+
{
|
|
38083
|
+
check: ({ configDir, eslintConfigPath, mismatch, sharedPkg, source }, { fix }) => {
|
|
38084
|
+
if (mismatch === void 0) return {};
|
|
38085
|
+
logConfigVariantMismatch(sharedPkg, mismatch);
|
|
38086
|
+
if (fix) {
|
|
38087
|
+
fixConfigMismatch(eslintConfigPath, configDir, source, sharedPkg, mismatch.expectedPkg);
|
|
38088
|
+
return { fixedCount: 1 };
|
|
38089
|
+
}
|
|
38090
|
+
return { diagnostics: lintlintDiagnostics("lintlint.config-package", [`ESLint config uses ${sharedPkg}; expected ${mismatch.expectedPkg}`]) };
|
|
38091
|
+
},
|
|
38092
|
+
defaultLevel: "warn",
|
|
38093
|
+
description: "ESLint config package matches the repo profile",
|
|
38094
|
+
id: "lintlint.config-package"
|
|
38095
|
+
},
|
|
38096
|
+
{
|
|
38097
|
+
check: ({ eslintConfigPath, results }, { fix }) => {
|
|
38098
|
+
if (results.redundant.length === 0) return {};
|
|
38099
|
+
if (fix) {
|
|
38100
|
+
fixRedundantRules(eslintConfigPath, results.redundant);
|
|
38101
|
+
return { fixedCount: results.redundant.length };
|
|
38102
|
+
}
|
|
38103
|
+
return { diagnostics: lintlintDiagnostics("lintlint.redundant-rule", results.redundant.map(({ local, rule }) => `${rule}: ${formatRule(local)} is redundant with the shared config`)) };
|
|
38104
|
+
},
|
|
38105
|
+
defaultLevel: "warn",
|
|
38106
|
+
description: "Local ESLint rules do not redundantly repeat the shared config",
|
|
38107
|
+
id: "lintlint.redundant-rule"
|
|
38108
|
+
},
|
|
38109
|
+
{
|
|
38110
|
+
check: ({ results }) => ({ diagnostics: lintlintDiagnostics("lintlint.rule-override", results.overrides.map(({ local, rule, shared }) => `${rule}: local ${formatRule(local)} overrides shared ${formatRule(shared)}`)) }),
|
|
38111
|
+
defaultLevel: "warn",
|
|
38112
|
+
description: "Local ESLint rule overrides are reported for review",
|
|
38113
|
+
id: "lintlint.rule-override"
|
|
38114
|
+
}
|
|
38115
|
+
];
|
|
37707
38116
|
async function runLintlintChecks(eslintConfigPath, configDir, source, sharedPkg, shouldFix, isVerbose) {
|
|
37708
|
-
const
|
|
37709
|
-
const currentSource = hasMismatch && shouldFix ? readFileSync(eslintConfigPath, "utf8") : source;
|
|
38117
|
+
const mismatch = detectConfigVariantMismatch(configDir, sharedPkg, isVerbose);
|
|
37710
38118
|
const sharedRules = await loadSharedRules(configDir, sharedPkg, isVerbose);
|
|
37711
38119
|
if (sharedRules === void 0) return 1;
|
|
37712
|
-
const { explicit, resolved } = await loadLocalRules(eslintConfigPath,
|
|
38120
|
+
const { explicit, resolved } = await loadLocalRules(eslintConfigPath, source, isVerbose);
|
|
37713
38121
|
const results = compareRules(explicit, resolved, sharedRules);
|
|
37714
|
-
|
|
37715
|
-
|
|
37716
|
-
|
|
38122
|
+
logAdditions(results, isVerbose);
|
|
38123
|
+
const result = await runRuleChecks({
|
|
38124
|
+
commandName: "lintlint",
|
|
38125
|
+
config: await loadWorkspaceCommandConfig(configDir, "lintlint"),
|
|
38126
|
+
context: {
|
|
38127
|
+
configDir,
|
|
38128
|
+
eslintConfigPath,
|
|
38129
|
+
isVerbose,
|
|
38130
|
+
mismatch,
|
|
38131
|
+
results,
|
|
38132
|
+
sharedPkg,
|
|
38133
|
+
source
|
|
38134
|
+
},
|
|
38135
|
+
fix: shouldFix,
|
|
38136
|
+
reporter: { diagnostic: logLintlintDiagnostic },
|
|
38137
|
+
rules: LINTLINT_RULES$1,
|
|
38138
|
+
strict: isStrictMode()
|
|
38139
|
+
});
|
|
38140
|
+
if (shouldFix && result.envelope.data.fixedCount > 0) formatConfigFile(eslintConfigPath);
|
|
38141
|
+
if (result.envelope.data.diagnostics.length === 0 && result.envelope.data.fixedCount === 0) console.log(chalk.green("No redundant or overridden rules found"));
|
|
38142
|
+
return result;
|
|
37717
38143
|
}
|
|
37718
38144
|
async function lintlint({ shouldFix, isVerbose } = {}) {
|
|
37719
38145
|
const isFixEnabled = shouldFix === true;
|
|
@@ -37826,7 +38252,44 @@ function checkPackageEngines(cwd, location, shouldFix) {
|
|
|
37826
38252
|
rule: "engines-node-portable"
|
|
37827
38253
|
}];
|
|
37828
38254
|
}
|
|
37829
|
-
function
|
|
38255
|
+
function withRuleId(diagnostics, rule) {
|
|
38256
|
+
return diagnostics.map((diagnostic) => ({
|
|
38257
|
+
...diagnostic,
|
|
38258
|
+
rule
|
|
38259
|
+
}));
|
|
38260
|
+
}
|
|
38261
|
+
const NODE_LINT_RULES$1 = [
|
|
38262
|
+
{
|
|
38263
|
+
check: ({ cwd }, { fix }) => ({ diagnostics: withRuleId(checkVoltaNodeVersion(cwd, fix), "node.volta-node-latest") }),
|
|
38264
|
+
defaultLevel: "warn",
|
|
38265
|
+
description: "Root volta.node tracks the latest stable Node version",
|
|
38266
|
+
id: "node.volta-node-latest"
|
|
38267
|
+
},
|
|
38268
|
+
{
|
|
38269
|
+
check: ({ cwd, locations, verbose }, { fix }) => ({ diagnostics: withRuleId(locations.flatMap((location) => {
|
|
38270
|
+
if (verbose) console.log(chalk.gray(` checking ${location}`));
|
|
38271
|
+
return checkPackageEngines(cwd, location, fix).filter((diagnostic) => diagnostic.rule === "engines-node-range");
|
|
38272
|
+
}), "node.engines-node-range") }),
|
|
38273
|
+
defaultLevel: "warn",
|
|
38274
|
+
description: "Node-exporting packages declare a sufficiently modern engines.node range",
|
|
38275
|
+
id: "node.engines-node-range"
|
|
38276
|
+
},
|
|
38277
|
+
{
|
|
38278
|
+
check: ({ cwd, locations, verbose }, { fix }) => ({ diagnostics: withRuleId(locations.flatMap((location) => {
|
|
38279
|
+
if (verbose) console.log(chalk.gray(` checking ${location}`));
|
|
38280
|
+
return checkPackageEngines(cwd, location, fix).filter((diagnostic) => diagnostic.rule === "engines-node-portable");
|
|
38281
|
+
}), "node.engines-node-portable") }),
|
|
38282
|
+
defaultLevel: "warn",
|
|
38283
|
+
description: "Browser/neutral packages do not declare engines.node",
|
|
38284
|
+
id: "node.engines-node-portable"
|
|
38285
|
+
}
|
|
38286
|
+
];
|
|
38287
|
+
function logNodeDiagnostic(diagnostic) {
|
|
38288
|
+
const color = diagnostic.level === "error" ? chalk.red : chalk.yellow;
|
|
38289
|
+
const marker = diagnostic.level === "error" ? "✗" : "⚠";
|
|
38290
|
+
console.log(color(` ${marker} ${diagnostic.message} (fixable)`));
|
|
38291
|
+
}
|
|
38292
|
+
async function nodeLint(options = {}) {
|
|
37830
38293
|
const { shouldFix: isFix = false, verbose: isVerbose = false } = options;
|
|
37831
38294
|
const cwd = INIT_CWD();
|
|
37832
38295
|
if (!readPackageJson$1(PATH.resolve(cwd, "package.json"))) {
|
|
@@ -37836,19 +38299,20 @@ function nodeLint(options = {}) {
|
|
|
37836
38299
|
console.log(chalk.green("Node Lint"));
|
|
37837
38300
|
const workspaces = getPackageManager().listWorkspaces();
|
|
37838
38301
|
const locations = workspaces.length > 0 ? workspaces.map((ws) => ws.location) : ["."];
|
|
37839
|
-
const
|
|
37840
|
-
|
|
37841
|
-
|
|
37842
|
-
|
|
37843
|
-
|
|
37844
|
-
|
|
37845
|
-
|
|
37846
|
-
envelope: {
|
|
37847
|
-
warningCount: warnings.length,
|
|
37848
|
-
warnings
|
|
38302
|
+
const result = await runRuleChecks({
|
|
38303
|
+
commandName: "nodeLint",
|
|
38304
|
+
config: await loadWorkspaceCommandConfig(cwd, "nodeLint"),
|
|
38305
|
+
context: {
|
|
38306
|
+
cwd,
|
|
38307
|
+
locations,
|
|
38308
|
+
verbose: isVerbose
|
|
37849
38309
|
},
|
|
37850
|
-
|
|
37851
|
-
|
|
38310
|
+
fix: isFix,
|
|
38311
|
+
reporter: { diagnostic: logNodeDiagnostic },
|
|
38312
|
+
rules: NODE_LINT_RULES$1
|
|
38313
|
+
});
|
|
38314
|
+
if (result.envelope.data.diagnostics.length === 0) console.log(chalk.green(" ✓ All node-lint checks passed"));
|
|
38315
|
+
return result;
|
|
37852
38316
|
}
|
|
37853
38317
|
//#endregion
|
|
37854
38318
|
//#region src/actions/npmignore-gen.ts
|
|
@@ -38453,53 +38917,72 @@ function checkWorkspaceGlobCoverage(pkg, cwd, pm, workspaces) {
|
|
|
38453
38917
|
}
|
|
38454
38918
|
return result;
|
|
38455
38919
|
}
|
|
38456
|
-
function
|
|
38457
|
-
|
|
38458
|
-
|
|
38459
|
-
|
|
38460
|
-
|
|
38461
|
-
|
|
38462
|
-
|
|
38463
|
-
|
|
38464
|
-
|
|
38465
|
-
|
|
38466
|
-
|
|
38467
|
-
|
|
38468
|
-
|
|
38469
|
-
|
|
38470
|
-
|
|
38471
|
-
|
|
38472
|
-
|
|
38473
|
-
|
|
38920
|
+
function lintResultDiagnostics(ruleId, result) {
|
|
38921
|
+
return [
|
|
38922
|
+
...result.errors.map((message) => ({
|
|
38923
|
+
level: "error",
|
|
38924
|
+
message,
|
|
38925
|
+
rule: ruleId
|
|
38926
|
+
})),
|
|
38927
|
+
...result.fixable.map((message) => ({
|
|
38928
|
+
level: "error",
|
|
38929
|
+
message: `${message} (fixable)`,
|
|
38930
|
+
rule: ruleId
|
|
38931
|
+
})),
|
|
38932
|
+
...result.warnings.map((message) => ({
|
|
38933
|
+
level: "warn",
|
|
38934
|
+
message,
|
|
38935
|
+
rule: ruleId
|
|
38936
|
+
}))
|
|
38937
|
+
];
|
|
38474
38938
|
}
|
|
38475
|
-
function
|
|
38476
|
-
let totalErrors = 0;
|
|
38477
|
-
let totalFixed = 0;
|
|
38478
|
-
for (const entry of entries) {
|
|
38479
|
-
const result = entry.check();
|
|
38480
|
-
const log = logResults(entry.label, result, shouldFix);
|
|
38481
|
-
if (shouldFix && entry.shouldFix && result.fixable.length > 0) entry.shouldFix(cwd, pkg);
|
|
38482
|
-
totalErrors += log.errors;
|
|
38483
|
-
totalFixed += log.fixed;
|
|
38484
|
-
}
|
|
38939
|
+
function checkEntryToRule(entry, shouldFix) {
|
|
38485
38940
|
return {
|
|
38486
|
-
|
|
38487
|
-
|
|
38941
|
+
check: ({ cwd, pkg }) => {
|
|
38942
|
+
const result = entry.check();
|
|
38943
|
+
const nonFixableDiagnostics = lintResultDiagnostics(entry.id, {
|
|
38944
|
+
errors: result.errors,
|
|
38945
|
+
fixable: shouldFix && entry.shouldFix ? [] : result.fixable,
|
|
38946
|
+
warnings: result.warnings
|
|
38947
|
+
});
|
|
38948
|
+
if (shouldFix && entry.shouldFix && result.fixable.length > 0) {
|
|
38949
|
+
entry.shouldFix(cwd, pkg);
|
|
38950
|
+
return {
|
|
38951
|
+
diagnostics: nonFixableDiagnostics,
|
|
38952
|
+
fixedCount: result.fixable.length
|
|
38953
|
+
};
|
|
38954
|
+
}
|
|
38955
|
+
return { diagnostics: nonFixableDiagnostics };
|
|
38956
|
+
},
|
|
38957
|
+
defaultLevel: entry.level ?? "error",
|
|
38958
|
+
description: entry.label,
|
|
38959
|
+
id: entry.id
|
|
38488
38960
|
};
|
|
38489
38961
|
}
|
|
38962
|
+
function logRuleDiagnostic(diagnostic) {
|
|
38963
|
+
const color = diagnostic.level === "error" ? chalk.red : chalk.yellow;
|
|
38964
|
+
const marker = diagnostic.level === "error" ? "✗" : "⚠";
|
|
38965
|
+
console.log(color(` ${marker} ${diagnostic.message}`));
|
|
38966
|
+
}
|
|
38967
|
+
function logRulePassed(rule) {
|
|
38968
|
+
console.log(chalk.green(` ✓ ${rule.description ?? rule.id}`));
|
|
38969
|
+
}
|
|
38970
|
+
function logRuleFixed(rule, fixedCount) {
|
|
38971
|
+
console.log(chalk.green(` ✔ Fixed ${fixedCount} issue(s): ${rule.description ?? rule.id}`));
|
|
38972
|
+
}
|
|
38490
38973
|
function logSummary(errors, fixed) {
|
|
38491
38974
|
if (fixed > 0) console.log(chalk.green(`\n Fixed ${fixed} issue(s)`));
|
|
38492
38975
|
if (errors > 0) console.log(chalk.red(`\n ${errors} error(s) found`));
|
|
38493
38976
|
else if (fixed === 0) console.log(chalk.green("\n All checks passed"));
|
|
38494
38977
|
}
|
|
38495
|
-
function packageLintMonorepo(shouldFix = false) {
|
|
38978
|
+
async function packageLintMonorepo(shouldFix = false) {
|
|
38496
38979
|
const cwd = INIT_CWD();
|
|
38497
38980
|
let pkg;
|
|
38498
38981
|
try {
|
|
38499
38982
|
pkg = readRootPackageJson(cwd);
|
|
38500
38983
|
} catch {
|
|
38501
38984
|
console.error(chalk.red("Could not read package.json"));
|
|
38502
|
-
return 1;
|
|
38985
|
+
return resultFromExitCode(1);
|
|
38503
38986
|
}
|
|
38504
38987
|
if (!isMonorepo(pkg, cwd)) {
|
|
38505
38988
|
console.log(chalk.gray("Not a monorepo — skipping repo lint checks"));
|
|
@@ -38508,90 +38991,123 @@ function packageLintMonorepo(shouldFix = false) {
|
|
|
38508
38991
|
console.log(chalk.green("Repo Lint"));
|
|
38509
38992
|
const pm = detectPackageManager$1();
|
|
38510
38993
|
const workspaces = getPackageManager().listWorkspaces();
|
|
38511
|
-
const
|
|
38994
|
+
const checks = [
|
|
38512
38995
|
{
|
|
38513
38996
|
check: () => checkRootPrivate(pkg),
|
|
38997
|
+
id: "repo.root-private",
|
|
38514
38998
|
shouldFix: fixRootPrivate,
|
|
38515
38999
|
label: "Root package is private"
|
|
38516
39000
|
},
|
|
38517
39001
|
{
|
|
38518
39002
|
check: () => checkNoPublishConfigOnPrivate(pkg),
|
|
39003
|
+
id: "repo.no-private-publish-config",
|
|
38519
39004
|
shouldFix: fixNoPublishConfigOnPrivate,
|
|
38520
39005
|
label: "No publishConfig on private root"
|
|
38521
39006
|
},
|
|
38522
39007
|
{
|
|
38523
39008
|
check: () => checkPackagesFolder(workspaces),
|
|
39009
|
+
id: "repo.packages-folder",
|
|
38524
39010
|
label: "All packages are in packages/ folder"
|
|
38525
39011
|
},
|
|
38526
39012
|
{
|
|
38527
39013
|
check: () => checkSpecFileLayout(cwd, workspaces),
|
|
39014
|
+
id: "repo.spec-layout",
|
|
38528
39015
|
label: "Spec files live in a spec/ folder"
|
|
38529
39016
|
},
|
|
38530
39017
|
{
|
|
38531
39018
|
check: () => checkWorkspacesFieldPlacement(cwd, pm, workspaces),
|
|
39019
|
+
id: "repo.workspaces-field-placement",
|
|
38532
39020
|
shouldFix: () => fixWorkspacesFieldPlacement(cwd, pm, workspaces),
|
|
38533
39021
|
label: pm === "pnpm" ? "No workspaces field in package.json (use pnpm-workspace.yaml)" : "Workspaces field only in root package.json"
|
|
38534
39022
|
},
|
|
38535
39023
|
{
|
|
38536
39024
|
check: () => checkWorkspaceGlobCoverage(pkg, cwd, pm, workspaces),
|
|
39025
|
+
id: "repo.workspace-glob-coverage",
|
|
38537
39026
|
label: "Workspace globs cover all packages"
|
|
38538
39027
|
},
|
|
38539
39028
|
{
|
|
38540
39029
|
check: () => checkNoPackageManagerInWorkspaces(cwd, workspaces),
|
|
39030
|
+
id: "repo.no-package-manager-in-workspaces",
|
|
38541
39031
|
shouldFix: () => fixNoPackageManagerInWorkspaces(cwd, pkg, workspaces),
|
|
38542
39032
|
label: "No packageManager in workspace packages"
|
|
38543
39033
|
},
|
|
38544
39034
|
{
|
|
38545
39035
|
check: () => checkVoltaOnlyInRoot(cwd, workspaces),
|
|
39036
|
+
id: "repo.volta-only-root",
|
|
38546
39037
|
shouldFix: () => fixVoltaOnlyInRoot(cwd, pkg, workspaces),
|
|
38547
39038
|
label: "Volta only in root package.json"
|
|
38548
39039
|
},
|
|
38549
39040
|
{
|
|
38550
39041
|
check: () => checkEnginesOnlyInNonTerminal(cwd, workspaces),
|
|
39042
|
+
id: "repo.engines-non-terminal",
|
|
38551
39043
|
shouldFix: () => fixEnginesOnlyInNonTerminal(cwd, pkg, workspaces),
|
|
38552
39044
|
label: "Engines only in non-terminal (library) packages"
|
|
38553
39045
|
},
|
|
38554
39046
|
{
|
|
38555
39047
|
check: () => checkVersionsIncludeLts(cwd, workspaces),
|
|
39048
|
+
id: "repo.engines-lts",
|
|
38556
39049
|
label: "Engine/volta versions include latest LTS"
|
|
38557
39050
|
},
|
|
38558
39051
|
{
|
|
38559
39052
|
check: () => checkVersionConsistency(cwd, pkg, workspaces),
|
|
39053
|
+
id: "repo.version-consistency",
|
|
38560
39054
|
shouldFix: () => fixVersionConsistency(cwd, pkg, writeRootPackageJson, workspaces),
|
|
38561
39055
|
label: "Consistent versions across packages"
|
|
38562
39056
|
},
|
|
38563
39057
|
pm === "pnpm" ? {
|
|
38564
39058
|
check: () => checkWorkspaceProtocol(cwd, workspaces),
|
|
39059
|
+
id: "repo.internal-dependency-ranges",
|
|
38565
39060
|
shouldFix: () => fixWorkspaceProtocol(cwd, workspaces),
|
|
38566
39061
|
label: "Internal deps/devDeps use workspace: protocol"
|
|
38567
39062
|
} : {
|
|
38568
39063
|
check: () => checkInternalDepVersions(cwd, workspaces),
|
|
39064
|
+
id: "repo.internal-dependency-ranges",
|
|
38569
39065
|
shouldFix: () => fixInternalDepVersions(cwd, workspaces),
|
|
38570
39066
|
label: "Internal deps/devDeps use correct version ranges"
|
|
38571
39067
|
},
|
|
38572
39068
|
{
|
|
38573
39069
|
check: () => checkInternalPeerVersions(cwd, workspaces),
|
|
39070
|
+
id: "repo.internal-peer-ranges",
|
|
38574
39071
|
shouldFix: () => fixInternalPeerVersions(cwd, workspaces),
|
|
38575
39072
|
label: "Internal peerDeps use publishable ranges"
|
|
38576
39073
|
},
|
|
38577
39074
|
{
|
|
38578
39075
|
check: () => checkPnpmReleaseAgeExcludes(cwd, pm, workspaces),
|
|
39076
|
+
id: "repo.pnpm-release-age-excludes",
|
|
38579
39077
|
shouldFix: () => fixPnpmReleaseAgeExcludes(cwd, workspaces),
|
|
38580
39078
|
label: "pnpm-workspace.yaml minimumReleaseAgeExclude matches imported scoped packages"
|
|
38581
39079
|
},
|
|
38582
39080
|
{
|
|
38583
39081
|
check: () => checkPnpmMinimumReleaseAge(cwd, pm),
|
|
39082
|
+
id: "repo.pnpm-minimum-release-age",
|
|
38584
39083
|
shouldFix: () => fixPnpmMinimumReleaseAge(cwd),
|
|
38585
39084
|
label: "pnpm-workspace.yaml sets minimumReleaseAge"
|
|
38586
39085
|
},
|
|
38587
39086
|
...pm === "pnpm" ? [{
|
|
38588
39087
|
check: () => checkPnpmDependencyOverrides(cwd, pm, pkg),
|
|
38589
|
-
|
|
39088
|
+
id: "repo.pnpm-no-overrides",
|
|
39089
|
+
label: "No pnpm dependency overrides configured",
|
|
39090
|
+
level: "warn"
|
|
38590
39091
|
}] : []
|
|
38591
|
-
]
|
|
38592
|
-
|
|
38593
|
-
|
|
38594
|
-
|
|
39092
|
+
];
|
|
39093
|
+
const result = await runRuleChecks({
|
|
39094
|
+
commandName: "repoLint",
|
|
39095
|
+
config: await loadWorkspaceCommandConfig(cwd, "repoLint"),
|
|
39096
|
+
context: {
|
|
39097
|
+
cwd,
|
|
39098
|
+
pkg
|
|
39099
|
+
},
|
|
39100
|
+
fix: shouldFix,
|
|
39101
|
+
reporter: {
|
|
39102
|
+
diagnostic: logRuleDiagnostic,
|
|
39103
|
+
fixed: logRuleFixed,
|
|
39104
|
+
passed: logRulePassed
|
|
39105
|
+
},
|
|
39106
|
+
rules: checks.map((entry) => checkEntryToRule(entry, shouldFix))
|
|
39107
|
+
});
|
|
39108
|
+
logSummary(result.envelope.errorCount, result.envelope.data.fixedCount);
|
|
39109
|
+
if (shouldFix && result.envelope.data.fixedCount > 0) shouldRunInstall();
|
|
39110
|
+
return result;
|
|
38595
39111
|
}
|
|
38596
39112
|
//#endregion
|
|
38597
39113
|
//#region src/actions/packman/rewriteScripts.ts
|
|
@@ -39302,7 +39818,7 @@ async function convert({ target, verbose }) {
|
|
|
39302
39818
|
const result = await runTargetConversion(target, cwd, workspacePaths);
|
|
39303
39819
|
if (result !== 0) return result;
|
|
39304
39820
|
console.log(chalk.green("\nRunning repo lint --fix..."));
|
|
39305
|
-
packageLintMonorepo(true);
|
|
39821
|
+
await packageLintMonorepo(true);
|
|
39306
39822
|
return result;
|
|
39307
39823
|
}
|
|
39308
39824
|
//#endregion
|
|
@@ -39578,24 +40094,59 @@ function shouldFixVerifyDepsBeforeRun(cwd) {
|
|
|
39578
40094
|
console.log(chalk.green(` Fixed: verifyDepsBeforeRun set to ${DEFAULT_VERIFY_DEPS_BEFORE_RUN}`));
|
|
39579
40095
|
return true;
|
|
39580
40096
|
}
|
|
39581
|
-
function
|
|
39582
|
-
|
|
39583
|
-
if (fix ?? false) return shouldApplyFix() ? 0 : 1;
|
|
39584
|
-
return 1;
|
|
39585
|
-
}
|
|
39586
|
-
function runYarnLintChecks(cwd, fix, isVerbose) {
|
|
39587
|
-
return recordCheckFailure(shouldCheckEnableScripts(cwd, isVerbose, fix), fix, () => shouldFixEnableScripts(cwd));
|
|
40097
|
+
function packmanDiagnostic(message) {
|
|
40098
|
+
return { diagnostics: [{ message }] };
|
|
39588
40099
|
}
|
|
39589
|
-
|
|
39590
|
-
|
|
39591
|
-
|
|
39592
|
-
|
|
39593
|
-
|
|
39594
|
-
|
|
39595
|
-
|
|
39596
|
-
|
|
39597
|
-
|
|
39598
|
-
|
|
40100
|
+
const PACKMAN_RULES$1 = [
|
|
40101
|
+
{
|
|
40102
|
+
check: ({ cwd, isVerbose, pm }, { fix }) => {
|
|
40103
|
+
if (pm !== "yarn") return {};
|
|
40104
|
+
if (shouldCheckEnableScripts(cwd, isVerbose, true)) return {};
|
|
40105
|
+
if (fix && shouldFixEnableScripts(cwd)) return { fixedCount: 1 };
|
|
40106
|
+
return packmanDiagnostic("Yarn enableScripts must be false");
|
|
40107
|
+
},
|
|
40108
|
+
defaultLevel: "error",
|
|
40109
|
+
description: "Yarn enableScripts must be false",
|
|
40110
|
+
id: "packman.yarn.enableScripts"
|
|
40111
|
+
},
|
|
40112
|
+
{
|
|
40113
|
+
check: ({ config, cwd, isVerbose, pm }, { fix }) => {
|
|
40114
|
+
if (pm !== "pnpm") return {};
|
|
40115
|
+
if (shouldCheckMinimumReleaseAge(cwd, config, isVerbose, true)) return {};
|
|
40116
|
+
if (fix && shouldFixMinimumReleaseAge(cwd, config)) return { fixedCount: 1 };
|
|
40117
|
+
return packmanDiagnostic("pnpm minimumReleaseAge must meet the configured floor");
|
|
40118
|
+
},
|
|
40119
|
+
defaultLevel: "error",
|
|
40120
|
+
description: "pnpm minimumReleaseAge must meet the configured floor",
|
|
40121
|
+
id: "packman.pnpm.minimumReleaseAge"
|
|
40122
|
+
},
|
|
40123
|
+
{
|
|
40124
|
+
check: ({ config, cwd, isVerbose, pm }, { fix }) => {
|
|
40125
|
+
if (pm !== "pnpm") return {};
|
|
40126
|
+
if (shouldCheckMinimumReleaseAgeExclude(cwd, config, isVerbose, true)) return {};
|
|
40127
|
+
if (fix && shouldFixMinimumReleaseAgeExclude(cwd, config)) return { fixedCount: 1 };
|
|
40128
|
+
return packmanDiagnostic("pnpm minimumReleaseAgeExclude must match imported package scopes");
|
|
40129
|
+
},
|
|
40130
|
+
defaultLevel: "error",
|
|
40131
|
+
description: "pnpm minimumReleaseAgeExclude must match imported package scopes",
|
|
40132
|
+
id: "packman.pnpm.minimumReleaseAgeExclude"
|
|
40133
|
+
},
|
|
40134
|
+
{
|
|
40135
|
+
check: ({ cwd, isVerbose, pm }, { fix }) => {
|
|
40136
|
+
if (pm !== "pnpm") return {};
|
|
40137
|
+
if (shouldCheckVerifyDepsBeforeRun(cwd, isVerbose, true)) return {};
|
|
40138
|
+
if (fix && shouldFixVerifyDepsBeforeRun(cwd)) return { fixedCount: 1 };
|
|
40139
|
+
return packmanDiagnostic(`pnpm verifyDepsBeforeRun must be configured as ${DEFAULT_VERIFY_DEPS_BEFORE_RUN}`);
|
|
40140
|
+
},
|
|
40141
|
+
defaultLevel: "error",
|
|
40142
|
+
description: "pnpm verifyDepsBeforeRun must be configured",
|
|
40143
|
+
id: "packman.pnpm.verifyDepsBeforeRun"
|
|
40144
|
+
}
|
|
40145
|
+
];
|
|
40146
|
+
function logPackmanDiagnostic(diagnostic) {
|
|
40147
|
+
const color = diagnostic.level === "error" ? chalk.red : chalk.yellow;
|
|
40148
|
+
const marker = diagnostic.level === "error" ? "✗" : "⚠";
|
|
40149
|
+
console.log(color(` ${marker} ${diagnostic.message}`));
|
|
39599
40150
|
}
|
|
39600
40151
|
async function packmanLint({ fix, isVerbose } = {}) {
|
|
39601
40152
|
const cwd = process.cwd();
|
|
@@ -39604,17 +40155,26 @@ async function packmanLint({ fix, isVerbose } = {}) {
|
|
|
39604
40155
|
console.log(chalk.green(`packman lint: no manager-specific checks are currently required for ${pm}`));
|
|
39605
40156
|
return 0;
|
|
39606
40157
|
}
|
|
39607
|
-
|
|
39608
|
-
|
|
39609
|
-
|
|
39610
|
-
|
|
39611
|
-
|
|
39612
|
-
|
|
39613
|
-
|
|
39614
|
-
|
|
40158
|
+
const packmanConfig = await loadWorkspaceCommandConfig(cwd, "packman");
|
|
40159
|
+
const result = await runRuleChecks({
|
|
40160
|
+
commandName: "packman",
|
|
40161
|
+
config: packmanConfig,
|
|
40162
|
+
context: {
|
|
40163
|
+
config: resolvePackmanConfig(packmanConfig),
|
|
40164
|
+
cwd,
|
|
40165
|
+
isVerbose,
|
|
40166
|
+
pm
|
|
40167
|
+
},
|
|
40168
|
+
fix,
|
|
40169
|
+
reporter: { diagnostic: logPackmanDiagnostic },
|
|
40170
|
+
rules: PACKMAN_RULES$1,
|
|
40171
|
+
strict: isStrictMode()
|
|
40172
|
+
});
|
|
40173
|
+
if (result.exitCode > 0) {
|
|
40174
|
+
console.log(chalk.red(`\npackman lint: ${result.exitCode} check(s) failed`));
|
|
39615
40175
|
if (!(fix ?? false)) console.log(chalk.yellow("Run with --fix to auto-fix issues"));
|
|
39616
40176
|
} else console.log(chalk.green("\npackman lint: all checks hasPassed"));
|
|
39617
|
-
return
|
|
40177
|
+
return result;
|
|
39618
40178
|
}
|
|
39619
40179
|
//#endregion
|
|
39620
40180
|
//#region src/actions/publish.ts
|
|
@@ -39990,6 +40550,410 @@ const retest = ({ target } = {}) => {
|
|
|
39990
40550
|
return runSteps("Re-Test", [["vitest", ["--clearCache"]], ["vitest", [target ?? "."]]]);
|
|
39991
40551
|
};
|
|
39992
40552
|
//#endregion
|
|
40553
|
+
//#region src/actions/ruleCatalog.ts
|
|
40554
|
+
const levelColor = {
|
|
40555
|
+
error: "red",
|
|
40556
|
+
off: "gray",
|
|
40557
|
+
warn: "yellow"
|
|
40558
|
+
};
|
|
40559
|
+
const GITLINT_RULES = [
|
|
40560
|
+
{
|
|
40561
|
+
command: "gitlint",
|
|
40562
|
+
defaultLevel: "warn",
|
|
40563
|
+
description: "core.ignorecase must be false",
|
|
40564
|
+
id: "git.core.ignorecase"
|
|
40565
|
+
},
|
|
40566
|
+
{
|
|
40567
|
+
command: "gitlint",
|
|
40568
|
+
defaultLevel: "warn",
|
|
40569
|
+
description: "core.autocrlf must be false",
|
|
40570
|
+
id: "git.core.autocrlf"
|
|
40571
|
+
},
|
|
40572
|
+
{
|
|
40573
|
+
command: "gitlint",
|
|
40574
|
+
defaultLevel: "warn",
|
|
40575
|
+
description: "core.eol must be lf",
|
|
40576
|
+
id: "git.core.eol"
|
|
40577
|
+
}
|
|
40578
|
+
];
|
|
40579
|
+
const PACKMAN_RULES = [
|
|
40580
|
+
{
|
|
40581
|
+
command: "packman lint",
|
|
40582
|
+
defaultLevel: "error",
|
|
40583
|
+
description: "Yarn enableScripts must be false",
|
|
40584
|
+
id: "packman.yarn.enableScripts"
|
|
40585
|
+
},
|
|
40586
|
+
{
|
|
40587
|
+
command: "packman lint",
|
|
40588
|
+
defaultLevel: "error",
|
|
40589
|
+
description: "pnpm minimumReleaseAge must meet the configured floor",
|
|
40590
|
+
id: "packman.pnpm.minimumReleaseAge"
|
|
40591
|
+
},
|
|
40592
|
+
{
|
|
40593
|
+
command: "packman lint",
|
|
40594
|
+
defaultLevel: "error",
|
|
40595
|
+
description: "pnpm minimumReleaseAgeExclude must match imported package scopes",
|
|
40596
|
+
id: "packman.pnpm.minimumReleaseAgeExclude"
|
|
40597
|
+
},
|
|
40598
|
+
{
|
|
40599
|
+
command: "packman lint",
|
|
40600
|
+
defaultLevel: "error",
|
|
40601
|
+
description: "pnpm verifyDepsBeforeRun must be configured",
|
|
40602
|
+
id: "packman.pnpm.verifyDepsBeforeRun"
|
|
40603
|
+
}
|
|
40604
|
+
];
|
|
40605
|
+
const REPO_LINT_RULES = [
|
|
40606
|
+
[
|
|
40607
|
+
"repo.root-private",
|
|
40608
|
+
"Root package is private",
|
|
40609
|
+
"error"
|
|
40610
|
+
],
|
|
40611
|
+
[
|
|
40612
|
+
"repo.no-private-publish-config",
|
|
40613
|
+
"Private root has no publishConfig",
|
|
40614
|
+
"error"
|
|
40615
|
+
],
|
|
40616
|
+
[
|
|
40617
|
+
"repo.packages-folder",
|
|
40618
|
+
"Workspace packages live under packages/",
|
|
40619
|
+
"error"
|
|
40620
|
+
],
|
|
40621
|
+
[
|
|
40622
|
+
"repo.spec-layout",
|
|
40623
|
+
"Spec files live in spec/ folders",
|
|
40624
|
+
"error"
|
|
40625
|
+
],
|
|
40626
|
+
[
|
|
40627
|
+
"repo.workspaces-field-placement",
|
|
40628
|
+
"Workspace fields are declared in the package-manager-specific location",
|
|
40629
|
+
"error"
|
|
40630
|
+
],
|
|
40631
|
+
[
|
|
40632
|
+
"repo.workspace-glob-coverage",
|
|
40633
|
+
"Workspace globs cover every package",
|
|
40634
|
+
"error"
|
|
40635
|
+
],
|
|
40636
|
+
[
|
|
40637
|
+
"repo.no-package-manager-in-workspaces",
|
|
40638
|
+
"Only the root package declares packageManager",
|
|
40639
|
+
"error"
|
|
40640
|
+
],
|
|
40641
|
+
[
|
|
40642
|
+
"repo.volta-only-root",
|
|
40643
|
+
"Only the root package declares volta",
|
|
40644
|
+
"error"
|
|
40645
|
+
],
|
|
40646
|
+
[
|
|
40647
|
+
"repo.engines-non-terminal",
|
|
40648
|
+
"Only non-terminal packages declare engines",
|
|
40649
|
+
"error"
|
|
40650
|
+
],
|
|
40651
|
+
[
|
|
40652
|
+
"repo.engines-lts",
|
|
40653
|
+
"Engine and volta versions include latest LTS",
|
|
40654
|
+
"error"
|
|
40655
|
+
],
|
|
40656
|
+
[
|
|
40657
|
+
"repo.version-consistency",
|
|
40658
|
+
"Workspace versions are consistent",
|
|
40659
|
+
"error"
|
|
40660
|
+
],
|
|
40661
|
+
[
|
|
40662
|
+
"repo.internal-dependency-ranges",
|
|
40663
|
+
"Internal dependencies use the expected workspace/version protocol",
|
|
40664
|
+
"error"
|
|
40665
|
+
],
|
|
40666
|
+
[
|
|
40667
|
+
"repo.internal-peer-ranges",
|
|
40668
|
+
"Internal peerDependencies use publishable ranges",
|
|
40669
|
+
"error"
|
|
40670
|
+
],
|
|
40671
|
+
[
|
|
40672
|
+
"repo.pnpm-release-age-excludes",
|
|
40673
|
+
"pnpm minimumReleaseAgeExclude matches imported scopes",
|
|
40674
|
+
"error"
|
|
40675
|
+
],
|
|
40676
|
+
[
|
|
40677
|
+
"repo.pnpm-minimum-release-age",
|
|
40678
|
+
"pnpm minimumReleaseAge is configured",
|
|
40679
|
+
"error"
|
|
40680
|
+
],
|
|
40681
|
+
[
|
|
40682
|
+
"repo.pnpm-no-overrides",
|
|
40683
|
+
"pnpm dependency overrides are not configured",
|
|
40684
|
+
"warn"
|
|
40685
|
+
]
|
|
40686
|
+
].map(([id, description, defaultLevel]) => ({
|
|
40687
|
+
command: "repo lint",
|
|
40688
|
+
defaultLevel,
|
|
40689
|
+
description,
|
|
40690
|
+
id
|
|
40691
|
+
}));
|
|
40692
|
+
const NODE_LINT_RULES = [
|
|
40693
|
+
{
|
|
40694
|
+
command: "node-lint",
|
|
40695
|
+
defaultLevel: "warn",
|
|
40696
|
+
description: "Root volta.node tracks the latest stable Node version",
|
|
40697
|
+
id: "node.volta-node-latest"
|
|
40698
|
+
},
|
|
40699
|
+
{
|
|
40700
|
+
command: "node-lint",
|
|
40701
|
+
defaultLevel: "warn",
|
|
40702
|
+
description: "Node-exporting packages declare a sufficiently modern engines.node range",
|
|
40703
|
+
id: "node.engines-node-range"
|
|
40704
|
+
},
|
|
40705
|
+
{
|
|
40706
|
+
command: "node-lint",
|
|
40707
|
+
defaultLevel: "warn",
|
|
40708
|
+
description: "Browser/neutral packages do not declare engines.node",
|
|
40709
|
+
id: "node.engines-node-portable"
|
|
40710
|
+
}
|
|
40711
|
+
];
|
|
40712
|
+
const LINTLINT_RULES = [
|
|
40713
|
+
{
|
|
40714
|
+
command: "lintlint",
|
|
40715
|
+
defaultLevel: "warn",
|
|
40716
|
+
description: "ESLint config package matches the repo profile",
|
|
40717
|
+
id: "lintlint.config-package"
|
|
40718
|
+
},
|
|
40719
|
+
{
|
|
40720
|
+
command: "lintlint",
|
|
40721
|
+
defaultLevel: "warn",
|
|
40722
|
+
description: "Local ESLint rules do not redundantly repeat the shared config",
|
|
40723
|
+
id: "lintlint.redundant-rule"
|
|
40724
|
+
},
|
|
40725
|
+
{
|
|
40726
|
+
command: "lintlint",
|
|
40727
|
+
defaultLevel: "warn",
|
|
40728
|
+
description: "Local ESLint rule overrides are reported for review",
|
|
40729
|
+
id: "lintlint.rule-override"
|
|
40730
|
+
}
|
|
40731
|
+
];
|
|
40732
|
+
const SKILLS_LINT_RULES$1 = [
|
|
40733
|
+
{
|
|
40734
|
+
command: "skills lint",
|
|
40735
|
+
defaultLevel: "error",
|
|
40736
|
+
description: "Required skills for the detected repo profile are installed",
|
|
40737
|
+
id: "skills.required-installed"
|
|
40738
|
+
},
|
|
40739
|
+
{
|
|
40740
|
+
command: "skills lint",
|
|
40741
|
+
defaultLevel: "error",
|
|
40742
|
+
description: "Installed required skills are up to date",
|
|
40743
|
+
id: "skills.required-current"
|
|
40744
|
+
},
|
|
40745
|
+
{
|
|
40746
|
+
command: "skills lint",
|
|
40747
|
+
defaultLevel: "warn",
|
|
40748
|
+
description: "Installed skills are required or optional for the detected repo profile",
|
|
40749
|
+
id: "skills.unnecessary"
|
|
40750
|
+
},
|
|
40751
|
+
{
|
|
40752
|
+
command: "skills lint",
|
|
40753
|
+
defaultLevel: "warn",
|
|
40754
|
+
description: "Project-local skills are not duplicated globally",
|
|
40755
|
+
id: "skills.duplicate-install"
|
|
40756
|
+
}
|
|
40757
|
+
];
|
|
40758
|
+
function severityToLevel(severity, enabled = true) {
|
|
40759
|
+
if (!enabled) return "off";
|
|
40760
|
+
return severity === "error" ? "error" : "warn";
|
|
40761
|
+
}
|
|
40762
|
+
async function loadCommandConfig(commandName, pkg) {
|
|
40763
|
+
if (pkg !== void 0 && pkg.length > 0) {
|
|
40764
|
+
const workspace = getPackageManager().findWorkspace(pkg);
|
|
40765
|
+
if (workspace === void 0) throw new Error(`Workspace not found: ${pkg}`);
|
|
40766
|
+
return loadWorkspaceCommandConfig(workspace.location, commandName);
|
|
40767
|
+
}
|
|
40768
|
+
return loadWorkspaceCommandConfig(process.cwd(), commandName);
|
|
40769
|
+
}
|
|
40770
|
+
function sortRules(rules) {
|
|
40771
|
+
return rules.toSorted((left, right) => {
|
|
40772
|
+
const command = left.command.localeCompare(right.command);
|
|
40773
|
+
return command === 0 ? left.id.localeCompare(right.id) : command;
|
|
40774
|
+
});
|
|
40775
|
+
}
|
|
40776
|
+
function staticCatalog(definitions, config) {
|
|
40777
|
+
const ruleSettings = config?.rules ?? {};
|
|
40778
|
+
const known = new Set(definitions.map((rule) => rule.id));
|
|
40779
|
+
const unknown = Object.keys(ruleSettings).filter((id) => !known.has(id));
|
|
40780
|
+
if (unknown.length > 0) throw new TypeError(`Unknown rule ${unknown.map((id) => `"${id}"`).join(", ")}`);
|
|
40781
|
+
return definitions.map((rule) => ({
|
|
40782
|
+
command: rule.command,
|
|
40783
|
+
description: rule.description,
|
|
40784
|
+
id: rule.id,
|
|
40785
|
+
level: parseRuleLevelSetting(`${rule.command}.rules["${rule.id}"]`, ruleSettings[rule.id], rule.defaultLevel)
|
|
40786
|
+
}));
|
|
40787
|
+
}
|
|
40788
|
+
function commandPrefix(prefix, rules) {
|
|
40789
|
+
return rules.map((rule) => ({
|
|
40790
|
+
...rule,
|
|
40791
|
+
command: `${prefix} ${rule.command}`
|
|
40792
|
+
}));
|
|
40793
|
+
}
|
|
40794
|
+
async function getDeplintRuleCatalog(pkg) {
|
|
40795
|
+
return sortRules((await loadDeplintRules(await loadCommandConfig("deplint", pkg))).map((rule) => ({
|
|
40796
|
+
command: "deplint",
|
|
40797
|
+
description: rule.meta.description,
|
|
40798
|
+
id: rule.id,
|
|
40799
|
+
level: severityToLevel(rule.meta.severity, rule.enabled !== false)
|
|
40800
|
+
})));
|
|
40801
|
+
}
|
|
40802
|
+
async function getDeadRuleCatalog(pkg, options) {
|
|
40803
|
+
return sortRules(loadDeadRules(await loadCommandConfig("dead", pkg), { deprecated: options?.deprecated === true }).map((rule) => ({
|
|
40804
|
+
command: "dead",
|
|
40805
|
+
description: rule.meta.description,
|
|
40806
|
+
id: rule.id,
|
|
40807
|
+
level: severityToLevel(rule.meta.severity, rule.enabled)
|
|
40808
|
+
})));
|
|
40809
|
+
}
|
|
40810
|
+
async function getPublintRuleCatalog(command = "publint", pkg) {
|
|
40811
|
+
const levels = resolvePublintRuleLevels(await loadCommandConfig("publint", pkg));
|
|
40812
|
+
return ALL_PUBLINT_CHECKS.map((check) => ({
|
|
40813
|
+
command,
|
|
40814
|
+
id: check,
|
|
40815
|
+
level: levels.get(check) ?? "warn"
|
|
40816
|
+
}));
|
|
40817
|
+
}
|
|
40818
|
+
async function getApiExposureRuleCatalog(pkg) {
|
|
40819
|
+
const config = normalizeApiExposureConfig(await loadCommandConfig("apiExposure", pkg));
|
|
40820
|
+
const byId = new Map(config.rules.map((rule) => [rule.id, rule]));
|
|
40821
|
+
return AEI_RULES.map((rule) => {
|
|
40822
|
+
const resolved = byId.get(rule.id);
|
|
40823
|
+
return {
|
|
40824
|
+
command: "api-exposure",
|
|
40825
|
+
description: rule.description,
|
|
40826
|
+
id: rule.id,
|
|
40827
|
+
level: resolved?.level ?? "warn",
|
|
40828
|
+
weight: resolved?.weight ?? rule.defaultWeight
|
|
40829
|
+
};
|
|
40830
|
+
});
|
|
40831
|
+
}
|
|
40832
|
+
async function getGitlintRuleCatalog() {
|
|
40833
|
+
return staticCatalog(GITLINT_RULES, await loadCommandConfig("gitlint"));
|
|
40834
|
+
}
|
|
40835
|
+
async function getPackmanRuleCatalog() {
|
|
40836
|
+
return staticCatalog(PACKMAN_RULES, await loadCommandConfig("packman"));
|
|
40837
|
+
}
|
|
40838
|
+
async function getRepoLintRuleCatalog() {
|
|
40839
|
+
return staticCatalog(REPO_LINT_RULES, await loadCommandConfig("repoLint"));
|
|
40840
|
+
}
|
|
40841
|
+
async function getNodeLintRuleCatalog() {
|
|
40842
|
+
return staticCatalog(NODE_LINT_RULES, await loadCommandConfig("nodeLint"));
|
|
40843
|
+
}
|
|
40844
|
+
async function getLintlintRuleCatalog() {
|
|
40845
|
+
return staticCatalog(LINTLINT_RULES, await loadCommandConfig("lintlint"));
|
|
40846
|
+
}
|
|
40847
|
+
async function getSkillsLintRuleCatalog() {
|
|
40848
|
+
return staticCatalog(SKILLS_LINT_RULES$1, await loadCommandConfig("skillsLint"));
|
|
40849
|
+
}
|
|
40850
|
+
function parseEslintRuleLevel(setting) {
|
|
40851
|
+
let current = setting;
|
|
40852
|
+
while (Array.isArray(current) && current.length > 0) current = current[0];
|
|
40853
|
+
if (current === "error" || current === 2) return "error";
|
|
40854
|
+
if (current === "warn" || current === 1) return "warn";
|
|
40855
|
+
return "off";
|
|
40856
|
+
}
|
|
40857
|
+
function mergeEslintRules(configs) {
|
|
40858
|
+
const rules = /* @__PURE__ */ new Map();
|
|
40859
|
+
for (const config of configs) {
|
|
40860
|
+
if (config.rules === void 0) continue;
|
|
40861
|
+
for (const [id, setting] of Object.entries(config.rules)) rules.set(id, setting);
|
|
40862
|
+
}
|
|
40863
|
+
return rules;
|
|
40864
|
+
}
|
|
40865
|
+
async function getEslintRuleCatalog(command = "lint") {
|
|
40866
|
+
const configPath = await findUp(["eslint.config.ts", "eslint.config.mjs"]);
|
|
40867
|
+
if (configPath === void 0) return [];
|
|
40868
|
+
const module = await import(pathToFileURL(configPath).href);
|
|
40869
|
+
return mergeEslintRules(Array.isArray(module.default) ? module.default : []).entries().map(([id, setting]) => ({
|
|
40870
|
+
command,
|
|
40871
|
+
id,
|
|
40872
|
+
level: parseEslintRuleLevel(setting),
|
|
40873
|
+
source: configPath
|
|
40874
|
+
})).toArray().toSorted((left, right) => left.id.localeCompare(right.id));
|
|
40875
|
+
}
|
|
40876
|
+
function getCycleRuleCatalog(depth = 25) {
|
|
40877
|
+
return [{
|
|
40878
|
+
command: "cycle",
|
|
40879
|
+
description: `ESLint import cycle rule with maxDepth ${depth}`,
|
|
40880
|
+
id: "import-x/no-cycle",
|
|
40881
|
+
level: "warn"
|
|
40882
|
+
}];
|
|
40883
|
+
}
|
|
40884
|
+
async function getDirectRuleCatalog() {
|
|
40885
|
+
return sortRules([...(await Promise.all([
|
|
40886
|
+
getApiExposureRuleCatalog(),
|
|
40887
|
+
getDeadRuleCatalog(),
|
|
40888
|
+
getDeplintRuleCatalog(),
|
|
40889
|
+
getGitlintRuleCatalog(),
|
|
40890
|
+
getPackmanRuleCatalog(),
|
|
40891
|
+
getPublintRuleCatalog(),
|
|
40892
|
+
getPublintRuleCatalog("republint"),
|
|
40893
|
+
getRepoLintRuleCatalog(),
|
|
40894
|
+
getNodeLintRuleCatalog(),
|
|
40895
|
+
getLintlintRuleCatalog(),
|
|
40896
|
+
getSkillsLintRuleCatalog(),
|
|
40897
|
+
getEslintRuleCatalog("lint"),
|
|
40898
|
+
getEslintRuleCatalog("relint")
|
|
40899
|
+
])).flat(), ...getCycleRuleCatalog()]);
|
|
40900
|
+
}
|
|
40901
|
+
async function getCheckRuleCatalog() {
|
|
40902
|
+
return sortRules(commandPrefix("check", (await Promise.all([
|
|
40903
|
+
getGitlintRuleCatalog(),
|
|
40904
|
+
getPackmanRuleCatalog(),
|
|
40905
|
+
getPublintRuleCatalog(),
|
|
40906
|
+
getRepoLintRuleCatalog(),
|
|
40907
|
+
getLintlintRuleCatalog(),
|
|
40908
|
+
getSkillsLintRuleCatalog()
|
|
40909
|
+
])).flat()));
|
|
40910
|
+
}
|
|
40911
|
+
async function getFixRuleCatalog() {
|
|
40912
|
+
return sortRules(commandPrefix("fix", (await Promise.all([
|
|
40913
|
+
getGitlintRuleCatalog(),
|
|
40914
|
+
getDeplintRuleCatalog(),
|
|
40915
|
+
getRepoLintRuleCatalog(),
|
|
40916
|
+
getPublintRuleCatalog(),
|
|
40917
|
+
getEslintRuleCatalog("lint")
|
|
40918
|
+
])).flat()));
|
|
40919
|
+
}
|
|
40920
|
+
async function getMasterRuleCatalog() {
|
|
40921
|
+
const direct = await getDirectRuleCatalog();
|
|
40922
|
+
const aggregates = await Promise.all([getCheckRuleCatalog(), getFixRuleCatalog()]);
|
|
40923
|
+
return sortRules([...direct, ...aggregates.flat()]);
|
|
40924
|
+
}
|
|
40925
|
+
function renderRule(rule) {
|
|
40926
|
+
const level = chalk[levelColor[rule.level]](rule.level.padEnd(5));
|
|
40927
|
+
const weight = rule.weight === void 0 ? "" : chalk.gray(` weight=${String(rule.weight)}`);
|
|
40928
|
+
const description = rule.description === void 0 ? "" : chalk.gray(` ${rule.description}`);
|
|
40929
|
+
console.log(` ${level} ${chalk.cyan(rule.id)}${weight}${description}`);
|
|
40930
|
+
}
|
|
40931
|
+
function renderRuleCatalog(rules, title = "Rules") {
|
|
40932
|
+
console.log(chalk.bold(title));
|
|
40933
|
+
let currentCommand;
|
|
40934
|
+
const sortedRules = sortRules([...rules]);
|
|
40935
|
+
for (const rule of sortedRules) {
|
|
40936
|
+
if (rule.command !== currentCommand) {
|
|
40937
|
+
currentCommand = rule.command;
|
|
40938
|
+
console.log();
|
|
40939
|
+
console.log(chalk.green(currentCommand));
|
|
40940
|
+
}
|
|
40941
|
+
renderRule(rule);
|
|
40942
|
+
}
|
|
40943
|
+
}
|
|
40944
|
+
function ruleCatalogResult(rules, title) {
|
|
40945
|
+
const sorted = sortRules(rules);
|
|
40946
|
+
if (!isJsonMode()) renderRuleCatalog(sorted, title);
|
|
40947
|
+
return {
|
|
40948
|
+
envelope: {
|
|
40949
|
+
data: sorted,
|
|
40950
|
+
errorCount: 0,
|
|
40951
|
+
warningCount: 0
|
|
40952
|
+
},
|
|
40953
|
+
exitCode: 0
|
|
40954
|
+
};
|
|
40955
|
+
}
|
|
40956
|
+
//#endregion
|
|
39993
40957
|
//#region src/actions/secure.ts
|
|
39994
40958
|
const secure = async ({ jobs = 16, pkg, verbose = false } = {}) => {
|
|
39995
40959
|
return await runSecurityAudit(getPackageManager(), {
|
|
@@ -40429,15 +41393,13 @@ const missingSkillReason = (profile, skillName) => {
|
|
|
40429
41393
|
return "required for repo profile";
|
|
40430
41394
|
};
|
|
40431
41395
|
const checkRequiredSkills = (required, installed, latestVersions, profile, isOffline) => {
|
|
41396
|
+
const current = [];
|
|
40432
41397
|
const missing = [];
|
|
40433
41398
|
const outdated = [];
|
|
40434
|
-
let errors = 0;
|
|
40435
41399
|
for (const skillName of required) {
|
|
40436
41400
|
const installedSkill = installed.get(skillName);
|
|
40437
41401
|
if (installedSkill == null) {
|
|
40438
41402
|
missing.push(skillName);
|
|
40439
|
-
errors += 1;
|
|
40440
|
-
logError(`${skillName} — missing (${missingSkillReason(profile, skillName)})`);
|
|
40441
41403
|
continue;
|
|
40442
41404
|
}
|
|
40443
41405
|
const installedVersion = installedSkill.version;
|
|
@@ -40448,15 +41410,16 @@ const checkRequiredSkills = (required, installed, latestVersions, profile, isOff
|
|
|
40448
41410
|
name: skillName,
|
|
40449
41411
|
version: installedVersion
|
|
40450
41412
|
});
|
|
40451
|
-
errors += 1;
|
|
40452
|
-
logError(`${skillName} v${installedVersion ?? "unknown"} — outdated (latest ${latestVersion ?? "unknown"})`);
|
|
40453
41413
|
continue;
|
|
40454
41414
|
}
|
|
40455
|
-
|
|
40456
|
-
|
|
41415
|
+
current.push({
|
|
41416
|
+
name: skillName,
|
|
41417
|
+
version: installedVersion
|
|
41418
|
+
});
|
|
40457
41419
|
}
|
|
40458
41420
|
return {
|
|
40459
|
-
|
|
41421
|
+
current,
|
|
41422
|
+
errors: missing.length + outdated.length,
|
|
40460
41423
|
missing,
|
|
40461
41424
|
outdated
|
|
40462
41425
|
};
|
|
@@ -40480,18 +41443,15 @@ const collectSkillNamesToCheck = (required, installed) => {
|
|
|
40480
41443
|
for (const name of installed.keys()) if (isXyoSkillName(name)) names.add(name);
|
|
40481
41444
|
return [...names];
|
|
40482
41445
|
};
|
|
40483
|
-
const
|
|
40484
|
-
let warnings = 0;
|
|
41446
|
+
const collectUnnecessarySkills = (profile, installed) => {
|
|
40485
41447
|
const installedNames = installed.keys().toArray();
|
|
40486
|
-
|
|
40487
|
-
|
|
40488
|
-
|
|
40489
|
-
|
|
40490
|
-
|
|
40491
|
-
|
|
40492
|
-
|
|
40493
|
-
}
|
|
40494
|
-
return warnings;
|
|
41448
|
+
return unnecessarySkillsForTier(profile.tier, installedNames);
|
|
41449
|
+
};
|
|
41450
|
+
const skillDiagnostics = (rule, messages) => {
|
|
41451
|
+
return messages.map((message) => ({
|
|
41452
|
+
message,
|
|
41453
|
+
rule
|
|
41454
|
+
}));
|
|
40495
41455
|
};
|
|
40496
41456
|
const installMissingSkills = async (missing) => {
|
|
40497
41457
|
console.log();
|
|
@@ -40503,17 +41463,54 @@ const installMissingSkills = async (missing) => {
|
|
|
40503
41463
|
console.log(chalk.green("Missing skills installed. Re-run `xy skills lint` to verify versions."));
|
|
40504
41464
|
return 0;
|
|
40505
41465
|
};
|
|
40506
|
-
const
|
|
40507
|
-
|
|
40508
|
-
|
|
40509
|
-
|
|
40510
|
-
|
|
41466
|
+
const SKILLS_LINT_RULES = [
|
|
41467
|
+
{
|
|
41468
|
+
check: async ({ missing, profile }, { fix }) => {
|
|
41469
|
+
if (missing.length === 0) return {};
|
|
41470
|
+
if (fix) {
|
|
41471
|
+
if (await installMissingSkills(missing) === 0) return { fixedCount: missing.length };
|
|
41472
|
+
}
|
|
41473
|
+
return { diagnostics: skillDiagnostics("skills.required-installed", missing.map((skillName) => `${skillName} — missing (${missingSkillReason(profile, skillName)})`)) };
|
|
41474
|
+
},
|
|
41475
|
+
defaultLevel: "error",
|
|
41476
|
+
description: "Required skills for the detected repo profile are installed",
|
|
41477
|
+
id: "skills.required-installed"
|
|
41478
|
+
},
|
|
41479
|
+
{
|
|
41480
|
+
check: ({ outdated }) => ({ diagnostics: skillDiagnostics("skills.required-current", outdated.map((skill) => `${skill.name} v${skill.version ?? "unknown"} — outdated (latest ${skill.latest ?? "unknown"})`)) }),
|
|
41481
|
+
defaultLevel: "error",
|
|
41482
|
+
description: "Installed required skills are up to date",
|
|
41483
|
+
id: "skills.required-current"
|
|
41484
|
+
},
|
|
41485
|
+
{
|
|
41486
|
+
check: ({ unnecessary }) => ({ diagnostics: skillDiagnostics("skills.unnecessary", unnecessary.map((skillName) => `${skillName} — installed but not required for this repo profile`)) }),
|
|
41487
|
+
defaultLevel: "warn",
|
|
41488
|
+
description: "Installed skills are required or optional for the detected repo profile",
|
|
41489
|
+
id: "skills.unnecessary"
|
|
41490
|
+
},
|
|
41491
|
+
{
|
|
41492
|
+
check: ({ duplicates }) => ({ diagnostics: skillDiagnostics("skills.duplicate-install", duplicates.map((name) => `${name} — also installed globally (duplicate)`)) }),
|
|
41493
|
+
defaultLevel: "warn",
|
|
41494
|
+
description: "Project-local skills are not duplicated globally",
|
|
41495
|
+
id: "skills.duplicate-install"
|
|
41496
|
+
}
|
|
41497
|
+
];
|
|
41498
|
+
function logSkillsDiagnostic(diagnostic) {
|
|
41499
|
+
if (diagnostic.level === "error") logError(diagnostic.message);
|
|
41500
|
+
else logWarning(diagnostic.message);
|
|
41501
|
+
}
|
|
41502
|
+
function logCurrentRequiredSkills(requiredCheck) {
|
|
41503
|
+
for (const skill of requiredCheck.current) {
|
|
41504
|
+
const versionSuffix = skill.version == null ? "" : ` v${skill.version}`;
|
|
41505
|
+
logOk(`${skill.name}${versionSuffix}`);
|
|
41506
|
+
}
|
|
41507
|
+
}
|
|
40511
41508
|
const skillsLint = async (options = {}) => {
|
|
40512
41509
|
const cwd = options.cwd ?? INIT_CWD();
|
|
40513
41510
|
const projectDirs = options.projectDirs ?? [...PROJECT_SKILL_DIRS];
|
|
40514
41511
|
const globalDir = options.globalDir ?? DEFAULT_GLOBAL_DIR;
|
|
40515
41512
|
const isOffline = options.isOffline === true;
|
|
40516
|
-
const isStrict = options.isStrict === true;
|
|
41513
|
+
const isStrict = options.isStrict === true || options.strict === true;
|
|
40517
41514
|
const profile = detectRepoProfile(cwd);
|
|
40518
41515
|
const required = requiredSkillsForTier(profile.tier);
|
|
40519
41516
|
const optional = optionalSkillsForTier(profile.tier);
|
|
@@ -40521,21 +41518,41 @@ const skillsLint = async (options = {}) => {
|
|
|
40521
41518
|
logProfileHeader(profile);
|
|
40522
41519
|
const latestVersions = isOffline ? /* @__PURE__ */ new Map() : await fetchLatestSkillVersions(collectSkillNamesToCheck(required, installed));
|
|
40523
41520
|
const requiredCheck = checkRequiredSkills(required, installed, latestVersions, profile, isOffline);
|
|
40524
|
-
|
|
41521
|
+
logCurrentRequiredSkills(requiredCheck);
|
|
41522
|
+
const unnecessary = collectUnnecessarySkills(profile, installed);
|
|
41523
|
+
const duplicates = findDuplicateSkills(cwd, globalDir);
|
|
41524
|
+
const result = await runRuleChecks({
|
|
41525
|
+
commandName: "skillsLint",
|
|
41526
|
+
config: await loadWorkspaceCommandConfig(cwd, "skillsLint"),
|
|
41527
|
+
context: {
|
|
41528
|
+
cwd,
|
|
41529
|
+
duplicates,
|
|
41530
|
+
globalDir,
|
|
41531
|
+
missing: requiredCheck.missing,
|
|
41532
|
+
outdated: requiredCheck.outdated,
|
|
41533
|
+
profile,
|
|
41534
|
+
unnecessary
|
|
41535
|
+
},
|
|
41536
|
+
fix: options.fix === true,
|
|
41537
|
+
reporter: { diagnostic: logSkillsDiagnostic },
|
|
41538
|
+
rules: SKILLS_LINT_RULES,
|
|
41539
|
+
strict: isStrict
|
|
41540
|
+
});
|
|
40525
41541
|
logOptionalSkills(profile.tier, optional, installed);
|
|
40526
41542
|
console.log();
|
|
40527
|
-
if (
|
|
41543
|
+
if (result.envelope.data.diagnostics.length === 0 && result.envelope.data.fixedCount === 0) {
|
|
40528
41544
|
console.log(chalk.green("All required skills are installed and up to date."));
|
|
40529
|
-
return
|
|
41545
|
+
return result;
|
|
40530
41546
|
}
|
|
40531
|
-
|
|
41547
|
+
const hasMissingDiagnostic = result.envelope.data.diagnostics.some((diagnostic) => diagnostic.rule === "skills.required-installed");
|
|
41548
|
+
const hasOutdatedDiagnostic = result.envelope.data.diagnostics.some((diagnostic) => diagnostic.rule === "skills.required-current");
|
|
41549
|
+
if (hasMissingDiagnostic || hasOutdatedDiagnostic) {
|
|
40532
41550
|
const hints = [];
|
|
40533
|
-
if (
|
|
40534
|
-
if (
|
|
41551
|
+
if (hasMissingDiagnostic) hints.push("run `xy skills lint --fix` to install missing required skills");
|
|
41552
|
+
if (hasOutdatedDiagnostic) hints.push("run `xy skills updo` to update outdated skills");
|
|
40535
41553
|
console.log(chalk.yellow(`${hints.join(", or ")}.`));
|
|
40536
41554
|
}
|
|
40537
|
-
|
|
40538
|
-
return resolveLintExitCode(requiredCheck, warnings, isStrict);
|
|
41555
|
+
return result;
|
|
40539
41556
|
};
|
|
40540
41557
|
//#endregion
|
|
40541
41558
|
//#region src/actions/skills/updo.ts
|
|
@@ -41324,6 +42341,10 @@ const checkCommand = {
|
|
|
41324
42341
|
default: false,
|
|
41325
42342
|
description: "Auto-fix fixable issues",
|
|
41326
42343
|
type: "boolean"
|
|
42344
|
+
}).option("rules", {
|
|
42345
|
+
default: false,
|
|
42346
|
+
description: "List rules covered by the check command",
|
|
42347
|
+
type: "boolean"
|
|
41327
42348
|
});
|
|
41328
42349
|
},
|
|
41329
42350
|
handler: async (argv) => {
|
|
@@ -41331,6 +42352,10 @@ const checkCommand = {
|
|
|
41331
42352
|
const isFix = !!Boolean(argv.fix);
|
|
41332
42353
|
const jobs = argv.jobs;
|
|
41333
42354
|
if (isVerbose) console.log("Check");
|
|
42355
|
+
if (argv.rules === true) {
|
|
42356
|
+
await withEnvelope("check rules", async () => ruleCatalogResult(await getCheckRuleCatalog(), "Check Rules"));
|
|
42357
|
+
return;
|
|
42358
|
+
}
|
|
41334
42359
|
await withEnvelope("check", async () => {
|
|
41335
42360
|
let errors = 0;
|
|
41336
42361
|
let exitCode = 0;
|
|
@@ -41341,8 +42366,8 @@ const checkCommand = {
|
|
|
41341
42366
|
exitCode += resultExitCode(result);
|
|
41342
42367
|
};
|
|
41343
42368
|
console.log(chalk.blue("\n— gitlint —"));
|
|
41344
|
-
if (isFix) addResult(gitlintFix());
|
|
41345
|
-
else addResult(gitlint());
|
|
42369
|
+
if (isFix) addResult(await gitlintFix());
|
|
42370
|
+
else addResult(await gitlint());
|
|
41346
42371
|
console.log(chalk.blue("\n— packman lint —"));
|
|
41347
42372
|
addResult(await packmanLint({
|
|
41348
42373
|
fix: isFix,
|
|
@@ -41355,7 +42380,7 @@ const checkCommand = {
|
|
|
41355
42380
|
verbose: isVerbose
|
|
41356
42381
|
}));
|
|
41357
42382
|
console.log(chalk.blue("\n— repo lint —"));
|
|
41358
|
-
addResult(packageLintMonorepo(isFix));
|
|
42383
|
+
addResult(await packageLintMonorepo(isFix));
|
|
41359
42384
|
console.log(chalk.blue("\n— lintlint —"));
|
|
41360
42385
|
addResult(await lintlint({
|
|
41361
42386
|
shouldFix: isFix,
|
|
@@ -41401,6 +42426,10 @@ const deadCommand = {
|
|
|
41401
42426
|
default: false,
|
|
41402
42427
|
description: "Remove dead declarations instead of deprecating them",
|
|
41403
42428
|
type: "boolean"
|
|
42429
|
+
}).option("rules", {
|
|
42430
|
+
default: false,
|
|
42431
|
+
description: "List supported dead-code rules and their effective levels",
|
|
42432
|
+
type: "boolean"
|
|
41404
42433
|
});
|
|
41405
42434
|
},
|
|
41406
42435
|
command: "dead [package]",
|
|
@@ -41408,11 +42437,16 @@ const deadCommand = {
|
|
|
41408
42437
|
handler: async (argv) => {
|
|
41409
42438
|
if (Boolean(argv.verbose)) console.log("Dead");
|
|
41410
42439
|
const isFixRemove = argv["fix-remove"] === true;
|
|
42440
|
+
const pkg = argv.package;
|
|
42441
|
+
if (argv.rules === true) {
|
|
42442
|
+
await withEnvelope("dead rules", async () => ruleCatalogResult(await getDeadRuleCatalog(pkg, { deprecated: argv.deprecated === true }), "Dead Rules"));
|
|
42443
|
+
return;
|
|
42444
|
+
}
|
|
41411
42445
|
await withEnvelope("dead", () => dead({
|
|
41412
42446
|
fix: argv.fix === true || isFixRemove,
|
|
41413
42447
|
deprecated: argv.deprecated === true,
|
|
41414
42448
|
format: argv.format,
|
|
41415
|
-
pkg
|
|
42449
|
+
pkg,
|
|
41416
42450
|
remove: isFixRemove,
|
|
41417
42451
|
verbose: argv.verbose,
|
|
41418
42452
|
workspace: argv.workspace
|
|
@@ -41437,12 +42471,20 @@ const gitlintCommand = {
|
|
|
41437
42471
|
default: false,
|
|
41438
42472
|
description: "Auto-fix git config issues",
|
|
41439
42473
|
type: "boolean"
|
|
42474
|
+
}).option("rules", {
|
|
42475
|
+
default: false,
|
|
42476
|
+
description: "List supported gitlint rules and their effective levels",
|
|
42477
|
+
type: "boolean"
|
|
41440
42478
|
});
|
|
41441
42479
|
},
|
|
41442
42480
|
command: "gitlint",
|
|
41443
42481
|
describe: "Gitlint - Lint your git config",
|
|
41444
42482
|
handler: async (argv) => {
|
|
41445
42483
|
if (Boolean(argv.verbose)) console.log("Gitlint");
|
|
42484
|
+
if (argv.rules === true) {
|
|
42485
|
+
await withEnvelope("gitlint rules", async () => ruleCatalogResult(await getGitlintRuleCatalog(), "Gitlint Rules"));
|
|
42486
|
+
return;
|
|
42487
|
+
}
|
|
41446
42488
|
await withEnvelope("gitlint", () => {
|
|
41447
42489
|
if (Boolean(argv.fix)) return gitlintFix();
|
|
41448
42490
|
return gitlint();
|
|
@@ -41542,9 +42584,17 @@ const lintCommand$2 = {
|
|
|
41542
42584
|
default: false,
|
|
41543
42585
|
description: "Auto-fix configuration issues",
|
|
41544
42586
|
type: "boolean"
|
|
42587
|
+
}).option("rules", {
|
|
42588
|
+
default: false,
|
|
42589
|
+
description: "List supported packman lint rules and their effective levels",
|
|
42590
|
+
type: "boolean"
|
|
41545
42591
|
});
|
|
41546
42592
|
},
|
|
41547
42593
|
handler: async (argv) => {
|
|
42594
|
+
if (argv.rules === true) {
|
|
42595
|
+
await withEnvelope("packman lint rules", async () => ruleCatalogResult(await getPackmanRuleCatalog(), "Packman Lint Rules"));
|
|
42596
|
+
return;
|
|
42597
|
+
}
|
|
41548
42598
|
await withEnvelope("packman lint", () => packmanLint({
|
|
41549
42599
|
fix: !!Boolean(argv.fix),
|
|
41550
42600
|
isVerbose: !!Boolean(argv.verbose)
|
|
@@ -41632,10 +42682,18 @@ const lintCommand$1 = {
|
|
|
41632
42682
|
default: false,
|
|
41633
42683
|
description: "Auto-fix fixable issues",
|
|
41634
42684
|
type: "boolean"
|
|
42685
|
+
}).option("rules", {
|
|
42686
|
+
default: false,
|
|
42687
|
+
description: "List supported repo lint rules and their effective levels",
|
|
42688
|
+
type: "boolean"
|
|
41635
42689
|
});
|
|
41636
42690
|
},
|
|
41637
42691
|
handler: async (argv) => {
|
|
41638
42692
|
if (Boolean(argv.verbose)) console.log("Repo Lint");
|
|
42693
|
+
if (argv.rules === true) {
|
|
42694
|
+
await withEnvelope("repo lint rules", async () => ruleCatalogResult(await getRepoLintRuleCatalog(), "Repo Lint Rules"));
|
|
42695
|
+
return;
|
|
42696
|
+
}
|
|
41639
42697
|
await withEnvelope("repo lint", () => packageLintMonorepo(!!Boolean(argv.fix)));
|
|
41640
42698
|
}
|
|
41641
42699
|
};
|
|
@@ -41706,6 +42764,7 @@ Options:
|
|
|
41706
42764
|
const LINT_FLAGS = /* @__PURE__ */ new Set([
|
|
41707
42765
|
"--fix",
|
|
41708
42766
|
"--offline",
|
|
42767
|
+
"--rules",
|
|
41709
42768
|
"--strict"
|
|
41710
42769
|
]);
|
|
41711
42770
|
const parseLintArgs = (args) => {
|
|
@@ -41733,6 +42792,7 @@ Checks:
|
|
|
41733
42792
|
Options:
|
|
41734
42793
|
--fix Install missing required skills (project scope)
|
|
41735
42794
|
--offline Skip upstream version checks
|
|
42795
|
+
--rules List supported skills lint rules and their effective levels
|
|
41736
42796
|
--strict Fail on warnings (duplicates, unnecessary skills)
|
|
41737
42797
|
-h, --help Show this help
|
|
41738
42798
|
`);
|
|
@@ -41768,6 +42828,7 @@ const runSkillsTail = (tail) => {
|
|
|
41768
42828
|
}
|
|
41769
42829
|
if (subcommand === "defaults") return skillsDefaults(args);
|
|
41770
42830
|
if (subcommand === "lint") {
|
|
42831
|
+
if (args.includes("--rules")) return getSkillsLintRuleCatalog().then((rules) => ruleCatalogResult(rules, "Skills Lint Rules"));
|
|
41771
42832
|
const lintArgs = args.filter((arg) => !LINT_FLAGS.has(arg) && !HELP_FLAGS.has(arg));
|
|
41772
42833
|
if (lintArgs.length > 0) {
|
|
41773
42834
|
console.error(`Unknown arguments for skills lint: ${lintArgs.join(", ")}`);
|
|
@@ -42295,17 +43356,26 @@ const apiExposureCommand = {
|
|
|
42295
43356
|
choices: ["human", "json"],
|
|
42296
43357
|
description: "Output format (deprecated: prefer the global --json flag)",
|
|
42297
43358
|
type: "string"
|
|
43359
|
+
}).option("rules", {
|
|
43360
|
+
default: false,
|
|
43361
|
+
description: "List supported API Exposure rules and their effective levels",
|
|
43362
|
+
type: "boolean"
|
|
42298
43363
|
});
|
|
42299
43364
|
},
|
|
42300
43365
|
handler: async (argv) => {
|
|
42301
43366
|
if (Boolean(argv.verbose)) console.log("API Exposure");
|
|
43367
|
+
const pkg = typeof argv.package === "string" ? argv.package : void 0;
|
|
43368
|
+
if (argv.rules === true) {
|
|
43369
|
+
await withEnvelope("api-exposure rules", async () => ruleCatalogResult(await getApiExposureRuleCatalog(pkg), "API Exposure Rules"));
|
|
43370
|
+
return;
|
|
43371
|
+
}
|
|
42302
43372
|
const dep = argv.dep?.flatMap((value) => value.split(",")).map((value) => value.trim()).filter(Boolean);
|
|
42303
43373
|
await withEnvelope("api-exposure", () => apiExposure({
|
|
42304
43374
|
dep,
|
|
42305
43375
|
failOn: argv.failOn,
|
|
42306
43376
|
format: argv.format,
|
|
42307
43377
|
minBand: argv.minBand,
|
|
42308
|
-
pkg
|
|
43378
|
+
pkg,
|
|
42309
43379
|
verbose: !!Boolean(argv.verbose)
|
|
42310
43380
|
}));
|
|
42311
43381
|
}
|
|
@@ -42325,6 +43395,10 @@ const cycleCommand = {
|
|
|
42325
43395
|
default: 25,
|
|
42326
43396
|
description: "Maximum import depth for import-x/no-cycle",
|
|
42327
43397
|
type: "number"
|
|
43398
|
+
}).option("rules", {
|
|
43399
|
+
default: false,
|
|
43400
|
+
description: "List cycle lint rules and their effective levels",
|
|
43401
|
+
type: "boolean"
|
|
42328
43402
|
}).check((argv) => {
|
|
42329
43403
|
const depth = argv.depth;
|
|
42330
43404
|
if (!Number.isSafeInteger(depth) || depth < 1) throw new Error("--depth must be a positive integer");
|
|
@@ -42333,6 +43407,10 @@ const cycleCommand = {
|
|
|
42333
43407
|
},
|
|
42334
43408
|
handler: async (argv) => {
|
|
42335
43409
|
if (Boolean(argv.verbose)) console.log("Cycle");
|
|
43410
|
+
if (argv.rules === true) {
|
|
43411
|
+
await withEnvelope("cycle rules", async () => ruleCatalogResult(getCycleRuleCatalog(argv.depth), "Cycle Rules"));
|
|
43412
|
+
return;
|
|
43413
|
+
}
|
|
42336
43414
|
await withEnvelope("cycle", () => cycle({
|
|
42337
43415
|
cache: argv.cache,
|
|
42338
43416
|
depth: argv.depth,
|
|
@@ -42380,10 +43458,19 @@ const deplintCommand = {
|
|
|
42380
43458
|
choices: ["human", "json"],
|
|
42381
43459
|
description: "Output format (deprecated: prefer the global --json flag)",
|
|
42382
43460
|
type: "string"
|
|
43461
|
+
}).option("rules", {
|
|
43462
|
+
default: false,
|
|
43463
|
+
description: "List supported deplint rules and their effective levels",
|
|
43464
|
+
type: "boolean"
|
|
42383
43465
|
});
|
|
42384
43466
|
},
|
|
42385
43467
|
handler: async (argv) => {
|
|
42386
43468
|
if (Boolean(argv.verbose)) console.log("Deplint");
|
|
43469
|
+
const pkg = typeof argv.package === "string" ? argv.package : void 0;
|
|
43470
|
+
if (argv.rules === true) {
|
|
43471
|
+
await withEnvelope("deplint rules", async () => ruleCatalogResult(await getDeplintRuleCatalog(pkg), "Deplint Rules"));
|
|
43472
|
+
return;
|
|
43473
|
+
}
|
|
42387
43474
|
const cliExclude = argv.exclude?.flatMap((v) => v.split(",")).map((v) => v.trim()).filter(Boolean);
|
|
42388
43475
|
await withEnvelope("deplint", () => deplint({
|
|
42389
43476
|
classifier: argv.classifier,
|
|
@@ -42394,7 +43481,7 @@ const deplintCommand = {
|
|
|
42394
43481
|
format: argv.format,
|
|
42395
43482
|
jobs: argv.jobs,
|
|
42396
43483
|
peerDeps: !!Boolean(argv.peerDeps),
|
|
42397
|
-
pkg
|
|
43484
|
+
pkg,
|
|
42398
43485
|
verbose: !!Boolean(argv.verbose)
|
|
42399
43486
|
}));
|
|
42400
43487
|
}
|
|
@@ -42403,12 +43490,20 @@ const deplintCommand = {
|
|
|
42403
43490
|
//#region src/xy/lint/fixCommand.ts
|
|
42404
43491
|
const fixCommand = {
|
|
42405
43492
|
builder: (yargs) => {
|
|
42406
|
-
return packagePositionalParam(yargs)
|
|
43493
|
+
return packagePositionalParam(yargs).option("rules", {
|
|
43494
|
+
default: false,
|
|
43495
|
+
description: "List rules covered by the fix command",
|
|
43496
|
+
type: "boolean"
|
|
43497
|
+
});
|
|
42407
43498
|
},
|
|
42408
43499
|
command: "fix [package]",
|
|
42409
43500
|
describe: "Fix - Run standard auto-fix tools",
|
|
42410
43501
|
handler: async (argv) => {
|
|
42411
43502
|
if (Boolean(argv.verbose)) console.log("Fix");
|
|
43503
|
+
if (argv.rules === true) {
|
|
43504
|
+
await withEnvelope("fix rules", async () => ruleCatalogResult(await getFixRuleCatalog(), "Fix Rules"));
|
|
43505
|
+
return;
|
|
43506
|
+
}
|
|
42412
43507
|
await withEnvelope("fix", () => fix({
|
|
42413
43508
|
jobs: argv.jobs,
|
|
42414
43509
|
pkg: argv.package,
|
|
@@ -42484,12 +43579,20 @@ const runCommand = {
|
|
|
42484
43579
|
default: false,
|
|
42485
43580
|
description: "Project lint results across XY ESLint tier presets (runs ESLint at tier 4)",
|
|
42486
43581
|
type: "boolean"
|
|
43582
|
+
}).option("rules", {
|
|
43583
|
+
default: false,
|
|
43584
|
+
description: "List effective ESLint rules for this project",
|
|
43585
|
+
type: "boolean"
|
|
42487
43586
|
});
|
|
42488
43587
|
},
|
|
42489
43588
|
command: "run [package]",
|
|
42490
43589
|
describe: "Run ESLint",
|
|
42491
43590
|
handler: async (argv) => {
|
|
42492
43591
|
if (Boolean(argv.verbose)) console.log(Boolean(argv.analyze) ? "Lint analyze" : "Lint");
|
|
43592
|
+
if (argv.rules === true) {
|
|
43593
|
+
await withEnvelope("lint rules", async () => ruleCatalogResult(await getEslintRuleCatalog("lint"), "Lint Rules"));
|
|
43594
|
+
return;
|
|
43595
|
+
}
|
|
42493
43596
|
await withEnvelope("lint", () => lint({
|
|
42494
43597
|
analyze: argv.analyze,
|
|
42495
43598
|
cache: argv.cache,
|
|
@@ -42531,10 +43634,18 @@ const lintlintCommand = {
|
|
|
42531
43634
|
default: false,
|
|
42532
43635
|
description: "Remove redundant rules from local config",
|
|
42533
43636
|
type: "boolean"
|
|
43637
|
+
}).option("rules", {
|
|
43638
|
+
default: false,
|
|
43639
|
+
description: "List supported lintlint rules and their effective levels",
|
|
43640
|
+
type: "boolean"
|
|
42534
43641
|
});
|
|
42535
43642
|
},
|
|
42536
43643
|
handler: async (argv) => {
|
|
42537
43644
|
if (Boolean(argv.verbose)) console.log("Lint Lint");
|
|
43645
|
+
if (argv.rules === true) {
|
|
43646
|
+
await withEnvelope("lintlint rules", async () => ruleCatalogResult(await getLintlintRuleCatalog(), "Lintlint Rules"));
|
|
43647
|
+
return;
|
|
43648
|
+
}
|
|
42538
43649
|
await withEnvelope("lintlint", () => lintlint({
|
|
42539
43650
|
shouldFix: argv.fix,
|
|
42540
43651
|
isVerbose: !!Boolean(argv.verbose)
|
|
@@ -42552,10 +43663,18 @@ const nodeLintCommand = {
|
|
|
42552
43663
|
default: false,
|
|
42553
43664
|
description: "Fix issues: update volta.node, set engines.node on node packages, remove engines.node from browser/neutral packages",
|
|
42554
43665
|
type: "boolean"
|
|
43666
|
+
}).option("rules", {
|
|
43667
|
+
default: false,
|
|
43668
|
+
description: "List supported node-lint rules and their effective levels",
|
|
43669
|
+
type: "boolean"
|
|
42555
43670
|
});
|
|
42556
43671
|
},
|
|
42557
43672
|
handler: async (argv) => {
|
|
42558
43673
|
if (Boolean(argv.verbose)) console.log("Node Lint");
|
|
43674
|
+
if (argv.rules === true) {
|
|
43675
|
+
await withEnvelope("node-lint rules", async () => ruleCatalogResult(await getNodeLintRuleCatalog(), "Node Lint Rules"));
|
|
43676
|
+
return;
|
|
43677
|
+
}
|
|
42559
43678
|
await withEnvelope("node-lint", () => nodeLint({
|
|
42560
43679
|
shouldFix: !!Boolean(argv.fix),
|
|
42561
43680
|
verbose: !!Boolean(argv.verbose)
|
|
@@ -42583,10 +43702,19 @@ const publintCommand = {
|
|
|
42583
43702
|
}).option("pack", {
|
|
42584
43703
|
description: "Run pack before publint to verify published files (default: true)",
|
|
42585
43704
|
type: "boolean"
|
|
43705
|
+
}).option("rules", {
|
|
43706
|
+
default: false,
|
|
43707
|
+
description: "List supported publint checks and their effective levels",
|
|
43708
|
+
type: "boolean"
|
|
42586
43709
|
});
|
|
42587
43710
|
},
|
|
42588
43711
|
handler: async (argv) => {
|
|
42589
43712
|
if (Boolean(argv.verbose)) console.log("Publint");
|
|
43713
|
+
const pkg = argv.package;
|
|
43714
|
+
if (argv.rules === true) {
|
|
43715
|
+
await withEnvelope("publint rules", async () => ruleCatalogResult(await getPublintRuleCatalog("publint", pkg), "Publint Rules"));
|
|
43716
|
+
return;
|
|
43717
|
+
}
|
|
42590
43718
|
const parseList = (raw) => raw?.split(",").map((v) => v.trim()).filter(Boolean);
|
|
42591
43719
|
await withEnvelope("publint", async () => {
|
|
42592
43720
|
return await publint({
|
|
@@ -42596,7 +43724,7 @@ const publintCommand = {
|
|
|
42596
43724
|
incremental: argv.incremental !== false,
|
|
42597
43725
|
jobs: argv.jobs,
|
|
42598
43726
|
pack: argv.pack,
|
|
42599
|
-
pkg
|
|
43727
|
+
pkg,
|
|
42600
43728
|
verbose: !!Boolean(argv.verbose)
|
|
42601
43729
|
});
|
|
42602
43730
|
});
|
|
@@ -42618,10 +43746,18 @@ const relintCommand = {
|
|
|
42618
43746
|
default: false,
|
|
42619
43747
|
description: "Use the previous all-packages relint runner",
|
|
42620
43748
|
type: "boolean"
|
|
43749
|
+
}).option("rules", {
|
|
43750
|
+
default: false,
|
|
43751
|
+
description: "List effective ESLint rules for this project",
|
|
43752
|
+
type: "boolean"
|
|
42621
43753
|
});
|
|
42622
43754
|
},
|
|
42623
43755
|
handler: async (argv) => {
|
|
42624
43756
|
if (Boolean(argv.verbose)) console.log("Relinting");
|
|
43757
|
+
if (argv.rules === true) {
|
|
43758
|
+
await withEnvelope("relint rules", async () => ruleCatalogResult(await getEslintRuleCatalog("relint"), "Relint Rules"));
|
|
43759
|
+
return;
|
|
43760
|
+
}
|
|
42625
43761
|
await withEnvelope("relint", () => relint({
|
|
42626
43762
|
jobs: argv.jobs,
|
|
42627
43763
|
pkg: argv.package,
|
|
@@ -42651,10 +43787,19 @@ const republintCommand = {
|
|
|
42651
43787
|
}).option("pack", {
|
|
42652
43788
|
description: "Run pack before publint to verify published files (default: true)",
|
|
42653
43789
|
type: "boolean"
|
|
43790
|
+
}).option("rules", {
|
|
43791
|
+
default: false,
|
|
43792
|
+
description: "List supported republint checks and their effective levels",
|
|
43793
|
+
type: "boolean"
|
|
42654
43794
|
});
|
|
42655
43795
|
},
|
|
42656
43796
|
handler: async (argv) => {
|
|
42657
43797
|
if (Boolean(argv.verbose)) console.log("Republint");
|
|
43798
|
+
const pkg = argv.package;
|
|
43799
|
+
if (argv.rules === true) {
|
|
43800
|
+
await withEnvelope("republint rules", async () => ruleCatalogResult(await getPublintRuleCatalog("republint", pkg), "Republint Rules"));
|
|
43801
|
+
return;
|
|
43802
|
+
}
|
|
42658
43803
|
const parseList = (raw) => raw?.split(",").map((v) => v.trim()).filter(Boolean);
|
|
42659
43804
|
await withEnvelope("republint", async () => {
|
|
42660
43805
|
return await republint({
|
|
@@ -42663,7 +43808,7 @@ const republintCommand = {
|
|
|
42663
43808
|
fix: !!Boolean(argv.fix),
|
|
42664
43809
|
jobs: argv.jobs,
|
|
42665
43810
|
pack: argv.pack,
|
|
42666
|
-
pkg
|
|
43811
|
+
pkg,
|
|
42667
43812
|
verbose: !!Boolean(argv.verbose)
|
|
42668
43813
|
});
|
|
42669
43814
|
});
|
|
@@ -47906,6 +49051,10 @@ const xyParseOptions = () => {
|
|
|
47906
49051
|
default: false,
|
|
47907
49052
|
description: "Emit machine-readable JSON to stdout; suppress decorative output",
|
|
47908
49053
|
type: "boolean"
|
|
49054
|
+
}).option("rules", {
|
|
49055
|
+
default: false,
|
|
49056
|
+
description: "List supported rules and their effective levels",
|
|
49057
|
+
type: "boolean"
|
|
47909
49058
|
}).option("no-defer", {
|
|
47910
49059
|
default: false,
|
|
47911
49060
|
description: "Do not defer to local package.json script of the same name",
|
|
@@ -47924,9 +49073,29 @@ function registerPackageManagers() {
|
|
|
47924
49073
|
registerPackageManager(new YarnPackageManager());
|
|
47925
49074
|
registerPackageManager(new PnpmPackageManager());
|
|
47926
49075
|
}
|
|
49076
|
+
function isTruthyLongFlag(arg, flag) {
|
|
49077
|
+
return arg === flag || arg === `${flag}=true`;
|
|
49078
|
+
}
|
|
49079
|
+
function isRootRulesRequest(raw = process.argv.slice(2)) {
|
|
49080
|
+
if (raw.every((arg) => !isTruthyLongFlag(arg, "--rules"))) return false;
|
|
49081
|
+
for (let i = 0; i < raw.length; i++) {
|
|
49082
|
+
const arg = raw[i];
|
|
49083
|
+
if (arg === "--jobs" || arg === "-j") {
|
|
49084
|
+
i++;
|
|
49085
|
+
continue;
|
|
49086
|
+
}
|
|
49087
|
+
if (!arg.startsWith("-")) return false;
|
|
49088
|
+
}
|
|
49089
|
+
return true;
|
|
49090
|
+
}
|
|
47927
49091
|
const xyBase = async (plugins) => {
|
|
47928
49092
|
registerPackageManagers();
|
|
47929
49093
|
warnIfUnsupportedPackageManager();
|
|
49094
|
+
if (isRootRulesRequest()) {
|
|
49095
|
+
if (process.argv.some((arg) => isTruthyLongFlag(arg, "--json"))) setJsonMode(true);
|
|
49096
|
+
await withEnvelope("rules", async () => ruleCatalogResult(await getMasterRuleCatalog(), "XY Rules"));
|
|
49097
|
+
return;
|
|
49098
|
+
}
|
|
47930
49099
|
let args = xyBuildCommands(xyCommonCommands(xyLintCommands(xyParseOptions())));
|
|
47931
49100
|
if (plugins) args = plugins(args);
|
|
47932
49101
|
return await args.demandCommand(1).command("*", "", () => {
|