@ariestools/toolchain 8.6.11 → 8.7.0
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/deplint/packageJsonEditor.d.ts +1 -1
- package/dist/actions/deplint/ruleConfig.d.ts.map +1 -1
- package/dist/actions/deplint/types.d.ts +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 +5 -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 +32 -1
- package/dist/actions/lintlint.d.ts.map +1 -1
- package/dist/actions/node-lint.d.ts +8 -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 +46 -4
- package/dist/actions/package/compile/MonolithConfig.d.ts.map +1 -1
- package/dist/actions/package/compile/PublintConfig.d.ts +43 -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 +45 -38
- package/dist/actions/package/compile/XyConfig.d.ts.map +1 -1
- package/dist/actions/package/compile/index.d.ts +1 -0
- package/dist/actions/package/compile/index.d.ts.map +1 -1
- package/dist/actions/package/compile/monolithCompileEntries.d.ts +8 -6
- package/dist/actions/package/compile/monolithCompileEntries.d.ts.map +1 -1
- package/dist/actions/package/compile/monolithCompileLayout.d.ts +2 -0
- package/dist/actions/package/compile/monolithCompileLayout.d.ts.map +1 -1
- package/dist/actions/package/compile/monolithReexport.d.ts +45 -0
- package/dist/actions/package/compile/monolithReexport.d.ts.map +1 -0
- package/dist/actions/package/compile/packageCompileMonolith.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 +13 -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 +16 -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 +42 -0
- package/dist/actions/ruleCatalog.d.ts.map +1 -0
- package/dist/actions/ruleRunner.d.ts +63 -0
- package/dist/actions/ruleRunner.d.ts.map +1 -0
- package/dist/actions/skills/lint.d.ts +16 -1
- package/dist/actions/skills/lint.d.ts.map +1 -1
- package/dist/bin/package/build.mjs +609 -101
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +257 -25
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/publint.mjs +352 -76
- package/dist/bin/package/publint.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +257 -25
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/package/sync-layout.mjs +48 -8
- package/dist/bin/package/sync-layout.mjs.map +1 -1
- package/dist/bin/xy.mjs +8326 -836
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/loadConfig.d.ts +1 -0
- package/dist/lib/loadConfig.d.ts.map +1 -1
- package/dist/lib/ruleCommandRegistry.d.ts +100 -0
- package/dist/lib/ruleCommandRegistry.d.ts.map +1 -0
- package/dist/xy/common/checkCommand.d.ts.map +1 -1
- package/dist/xy/common/deadCommand.d.ts.map +1 -1
- package/dist/xy/common/gitCommand.d.ts +3 -0
- package/dist/xy/common/gitCommand.d.ts.map +1 -0
- package/dist/xy/common/gitlintCommand.d.ts +2 -0
- package/dist/xy/common/gitlintCommand.d.ts.map +1 -1
- package/dist/xy/common/index.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/deprecatedCommand.d.ts +2 -0
- package/dist/xy/deprecatedCommand.d.ts.map +1 -0
- 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/index.d.ts.map +1 -1
- package/dist/xy/lint/lint/index.d.ts.map +1 -1
- package/dist/xy/lint/lint/runCommand.d.ts.map +1 -1
- package/dist/xy/lint/lintlintCommand.d.ts +2 -0
- package/dist/xy/lint/lintlintCommand.d.ts.map +1 -1
- package/dist/xy/lint/nodeCommand.d.ts +3 -0
- package/dist/xy/lint/nodeCommand.d.ts.map +1 -0
- package/dist/xy/lint/nodeLintCommand.d.ts +2 -0
- 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 +5 -4
|
@@ -9174,8 +9174,8 @@ var require_ExplorerSync = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
9174
9174
|
exports.ExplorerSync = ExplorerSync;
|
|
9175
9175
|
}));
|
|
9176
9176
|
//#endregion
|
|
9177
|
-
//#region
|
|
9178
|
-
var
|
|
9177
|
+
//#region ../../node_modules/.pnpm/cosmiconfig@9.0.2_typescript@6.0.3/node_modules/cosmiconfig/dist/index.js
|
|
9178
|
+
var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
9179
9179
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9180
9180
|
exports.defaultLoadersSync = exports.defaultLoaders = exports.globalConfigSearchPlacesSync = exports.globalConfigSearchPlaces = exports.getDefaultSearchPlacesSync = exports.getDefaultSearchPlaces = void 0;
|
|
9181
9181
|
exports.cosmiconfig = cosmiconfig;
|
|
@@ -9307,7 +9307,111 @@ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
9307
9307
|
clearCaches: explorer.clearCaches.bind(explorer)
|
|
9308
9308
|
};
|
|
9309
9309
|
}
|
|
9310
|
-
}))
|
|
9310
|
+
}));
|
|
9311
|
+
//#endregion
|
|
9312
|
+
//#region src/lib/ruleCommandRegistry.ts
|
|
9313
|
+
const RULE_COMMANDS = {
|
|
9314
|
+
apiExposure: {
|
|
9315
|
+
command: "api-exposure",
|
|
9316
|
+
configKey: "apiExposure",
|
|
9317
|
+
includeInRoot: true,
|
|
9318
|
+
title: "API Exposure Rules"
|
|
9319
|
+
},
|
|
9320
|
+
check: {
|
|
9321
|
+
command: "check",
|
|
9322
|
+
includeInRoot: true,
|
|
9323
|
+
title: "Check Rules"
|
|
9324
|
+
},
|
|
9325
|
+
cycle: {
|
|
9326
|
+
command: "cycle",
|
|
9327
|
+
includeInRoot: true,
|
|
9328
|
+
title: "Cycle Rules"
|
|
9329
|
+
},
|
|
9330
|
+
dead: {
|
|
9331
|
+
command: "dead",
|
|
9332
|
+
configKey: "dead",
|
|
9333
|
+
includeInRoot: true,
|
|
9334
|
+
title: "Dead Rules"
|
|
9335
|
+
},
|
|
9336
|
+
deplint: {
|
|
9337
|
+
command: "deplint",
|
|
9338
|
+
configKey: "deplint",
|
|
9339
|
+
includeInRoot: true,
|
|
9340
|
+
title: "Deplint Rules"
|
|
9341
|
+
},
|
|
9342
|
+
fix: {
|
|
9343
|
+
command: "fix",
|
|
9344
|
+
includeInRoot: false,
|
|
9345
|
+
title: "Fix Rules"
|
|
9346
|
+
},
|
|
9347
|
+
gitLint: {
|
|
9348
|
+
aliases: ["gitlint"],
|
|
9349
|
+
command: "git lint",
|
|
9350
|
+
configKey: "gitLint",
|
|
9351
|
+
includeInRoot: true,
|
|
9352
|
+
title: "Git Lint Rules"
|
|
9353
|
+
},
|
|
9354
|
+
lint: {
|
|
9355
|
+
aliases: ["relint"],
|
|
9356
|
+
command: "lint",
|
|
9357
|
+
includeInRoot: true,
|
|
9358
|
+
title: "Lint Rules"
|
|
9359
|
+
},
|
|
9360
|
+
lintLint: {
|
|
9361
|
+
aliases: ["lintlint"],
|
|
9362
|
+
command: "lint lint",
|
|
9363
|
+
configKey: "lintLint",
|
|
9364
|
+
includeInRoot: true,
|
|
9365
|
+
title: "Lint Lint Rules"
|
|
9366
|
+
},
|
|
9367
|
+
nodeLint: {
|
|
9368
|
+
aliases: ["node-lint"],
|
|
9369
|
+
command: "node lint",
|
|
9370
|
+
configKey: "nodeLint",
|
|
9371
|
+
includeInRoot: true,
|
|
9372
|
+
title: "Node Lint Rules"
|
|
9373
|
+
},
|
|
9374
|
+
packman: {
|
|
9375
|
+
command: "packman lint",
|
|
9376
|
+
configKey: "packman",
|
|
9377
|
+
includeInRoot: true,
|
|
9378
|
+
title: "Packman Lint Rules"
|
|
9379
|
+
},
|
|
9380
|
+
publint: {
|
|
9381
|
+
aliases: ["republint"],
|
|
9382
|
+
command: "publint",
|
|
9383
|
+
configKey: "publint",
|
|
9384
|
+
includeInRoot: true,
|
|
9385
|
+
title: "Publint Rules"
|
|
9386
|
+
},
|
|
9387
|
+
repoLint: {
|
|
9388
|
+
command: "repo lint",
|
|
9389
|
+
configKey: "repoLint",
|
|
9390
|
+
includeInRoot: true,
|
|
9391
|
+
title: "Repo Lint Rules"
|
|
9392
|
+
},
|
|
9393
|
+
skillsLint: {
|
|
9394
|
+
command: "skills lint",
|
|
9395
|
+
configKey: "skillsLint",
|
|
9396
|
+
includeInRoot: true,
|
|
9397
|
+
title: "Skills Lint Rules"
|
|
9398
|
+
}
|
|
9399
|
+
};
|
|
9400
|
+
const DEPRECATED_CONFIG_KEY_ALIASES = {
|
|
9401
|
+
gitLint: ["gitlint"],
|
|
9402
|
+
lintLint: ["lintlint"]
|
|
9403
|
+
};
|
|
9404
|
+
const CONFIG_ALIAS_TO_CANONICAL = new Map(Object.entries(DEPRECATED_CONFIG_KEY_ALIASES).flatMap(([canonical, aliases]) => aliases.map((alias) => [alias, canonical])));
|
|
9405
|
+
const RULE_CONFIG_COMMAND_KEYS = new Set(Object.values(RULE_COMMANDS).flatMap((command) => "configKey" in command ? [command.configKey] : []));
|
|
9406
|
+
function canonicalRuleConfigKey(commandName) {
|
|
9407
|
+
return CONFIG_ALIAS_TO_CANONICAL.get(commandName) ?? commandName;
|
|
9408
|
+
}
|
|
9409
|
+
function deprecatedRuleConfigAliases(configKey) {
|
|
9410
|
+
return Object.entries(DEPRECATED_CONFIG_KEY_ALIASES).find(([canonical]) => canonical === configKey)?.[1] ?? [];
|
|
9411
|
+
}
|
|
9412
|
+
//#endregion
|
|
9413
|
+
//#region src/lib/loadConfig.ts
|
|
9414
|
+
var import_dist = require_dist();
|
|
9311
9415
|
const configState = {
|
|
9312
9416
|
config: void 0,
|
|
9313
9417
|
rootConfigPath: void 0
|
|
@@ -9355,21 +9459,30 @@ async function loadWorkspaceConfig(workspaceDir) {
|
|
|
9355
9459
|
}
|
|
9356
9460
|
/** Deprecated top-level fields that should be under `commands`. */
|
|
9357
9461
|
const DEPRECATED_COMMAND_FIELDS = /* @__PURE__ */ new Set(["deplint", "publint"]);
|
|
9462
|
+
function warnOnce(key, message) {
|
|
9463
|
+
if (deprecationWarned.has(key)) return;
|
|
9464
|
+
deprecationWarned.add(key);
|
|
9465
|
+
console.warn(chalk.yellow(message));
|
|
9466
|
+
}
|
|
9358
9467
|
/**
|
|
9359
9468
|
* Resolves a command's config field from a config object.
|
|
9360
9469
|
* Prefers `commands.[name]` over top-level `[name]`.
|
|
9361
9470
|
* Warns once per config file when a deprecated top-level field is used.
|
|
9362
9471
|
*/
|
|
9363
9472
|
function resolveCommandField(cfg, commandName, configPath) {
|
|
9364
|
-
const
|
|
9365
|
-
|
|
9366
|
-
const
|
|
9367
|
-
if (
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9473
|
+
const configKey = canonicalRuleConfigKey(commandName);
|
|
9474
|
+
const commands = isRecord$1(cfg.commands) ? cfg.commands : void 0;
|
|
9475
|
+
const fromCommands = commands?.[configKey];
|
|
9476
|
+
if (isRecord$1(fromCommands)) return fromCommands;
|
|
9477
|
+
for (const alias of deprecatedRuleConfigAliases(configKey)) {
|
|
9478
|
+
const fromAlias = commands?.[alias];
|
|
9479
|
+
if (!isRecord$1(fromAlias)) continue;
|
|
9480
|
+
warnOnce(`${configPath ?? "unknown"}:commands.${alias}`, `[xy] Deprecated: "commands.${alias}" in ${configPath ?? "xy.config"} — use "commands.${configKey}"`);
|
|
9481
|
+
return fromAlias;
|
|
9482
|
+
}
|
|
9483
|
+
const fromTopLevel = cfg[configKey];
|
|
9484
|
+
if (fromTopLevel !== void 0 && typeof fromTopLevel === "object" && DEPRECATED_COMMAND_FIELDS.has(configKey)) {
|
|
9485
|
+
warnOnce(`${configPath ?? "unknown"}:${configKey}`, `[xy] Deprecated: top-level "${configKey}" in ${configPath ?? "xy.config"} — move to "commands.${configKey}"`);
|
|
9373
9486
|
return fromTopLevel;
|
|
9374
9487
|
}
|
|
9375
9488
|
return {};
|
|
@@ -9382,14 +9495,15 @@ function mergeRuleConfigs(target, source) {
|
|
|
9382
9495
|
return source;
|
|
9383
9496
|
}
|
|
9384
9497
|
function mergeCommandConfig(rootCmd, workspaceCmd, commandName) {
|
|
9385
|
-
|
|
9498
|
+
const configKey = canonicalRuleConfigKey(commandName);
|
|
9499
|
+
return deepMerge(rootCmd, workspaceCmd, { customMerge: (key) => RULE_CONFIG_COMMAND_KEYS.has(configKey) && key === "rules" ? mergeRuleConfigs : void 0 });
|
|
9386
9500
|
}
|
|
9387
9501
|
/**
|
|
9388
9502
|
* Loads a command-specific config merged from root and workspace levels.
|
|
9389
9503
|
* The root config provides defaults; the workspace config extends/overrides.
|
|
9390
9504
|
* Arrays (e.g. `exclude`) are unioned and maps (e.g. `packages`) are merged
|
|
9391
9505
|
* via deepmerge, with workspace entries overriding root entries for the same key.
|
|
9392
|
-
*
|
|
9506
|
+
* Rule entries are replaced per rule id so tuple configs keep their
|
|
9393
9507
|
* ESLint-like shape instead of being concatenated as arrays.
|
|
9394
9508
|
*/
|
|
9395
9509
|
/**
|
|
@@ -9405,8 +9519,9 @@ function isWorkspaceUnderRootConfig(workspaceDir) {
|
|
|
9405
9519
|
return relative === "" || !relative.startsWith("..") && !PATH.isAbsolute(relative);
|
|
9406
9520
|
}
|
|
9407
9521
|
async function loadWorkspaceCommandConfig(workspaceDir, commandName) {
|
|
9522
|
+
const configKey = canonicalRuleConfigKey(commandName);
|
|
9408
9523
|
const root = await loadConfig();
|
|
9409
|
-
return mergeCommandConfig(isWorkspaceUnderRootConfig(workspaceDir) ? resolveCommandField(root,
|
|
9524
|
+
return mergeCommandConfig(isWorkspaceUnderRootConfig(workspaceDir) ? resolveCommandField(root, configKey, configState.rootConfigPath) : {}, resolveCommandField(await loadWorkspaceConfig(workspaceDir), configKey, workspaceConfigCache.has(workspaceDir) ? workspaceDir : void 0), configKey);
|
|
9410
9525
|
}
|
|
9411
9526
|
//#endregion
|
|
9412
9527
|
//#region src/lib/reporting/xyReporter.ts
|
|
@@ -10291,7 +10406,7 @@ const resolveCompilePlatforms = (compile) => {
|
|
|
10291
10406
|
};
|
|
10292
10407
|
};
|
|
10293
10408
|
//#endregion
|
|
10294
|
-
//#region src/actions/package/compile/
|
|
10409
|
+
//#region src/actions/package/compile/PublintConfig.ts
|
|
10295
10410
|
const ALL_PUBLINT_CHECKS = [
|
|
10296
10411
|
"compileTargets",
|
|
10297
10412
|
"defaultExportOrder",
|
|
@@ -10310,6 +10425,10 @@ const ALL_PUBLINT_CHECKS = [
|
|
|
10310
10425
|
"source",
|
|
10311
10426
|
"types"
|
|
10312
10427
|
];
|
|
10428
|
+
function publintRuleId$1(check) {
|
|
10429
|
+
return `pub.${check}`;
|
|
10430
|
+
}
|
|
10431
|
+
ALL_PUBLINT_CHECKS.map(publintRuleId$1);
|
|
10313
10432
|
/** Checks that only apply to published (non-private) packages */
|
|
10314
10433
|
const PUBLISH_ONLY_CHECKS = [
|
|
10315
10434
|
"defaultExportOrder",
|
|
@@ -11194,6 +11313,118 @@ async function checkPlatform(pkgDir, pkg, shouldFix = false) {
|
|
|
11194
11313
|
return result;
|
|
11195
11314
|
}
|
|
11196
11315
|
//#endregion
|
|
11316
|
+
//#region src/actions/package/publintRules.ts
|
|
11317
|
+
const PUBLINT_RULE_LEVELS = /* @__PURE__ */ new Set([
|
|
11318
|
+
"error",
|
|
11319
|
+
"off",
|
|
11320
|
+
"warn"
|
|
11321
|
+
]);
|
|
11322
|
+
const PUBLINT_RULE_PREFIX = "pub.";
|
|
11323
|
+
const deprecatedPublintRuleWarnings = /* @__PURE__ */ new Set();
|
|
11324
|
+
function defaultPublintLevel(check) {
|
|
11325
|
+
return check === "platform" || check === "publint" ? "error" : "warn";
|
|
11326
|
+
}
|
|
11327
|
+
function publintRuleId(check) {
|
|
11328
|
+
return `${PUBLINT_RULE_PREFIX}${check}`;
|
|
11329
|
+
}
|
|
11330
|
+
function warnDeprecatedPublintRuleName(ruleName) {
|
|
11331
|
+
if (deprecatedPublintRuleWarnings.has(ruleName)) return;
|
|
11332
|
+
deprecatedPublintRuleWarnings.add(ruleName);
|
|
11333
|
+
console.warn(`Deprecated: commands.publint.rules["${ruleName}"] is deprecated; use commands.publint.rules["${publintRuleId(ruleName)}"] instead.`);
|
|
11334
|
+
}
|
|
11335
|
+
function normalizePublintConfig$2(value) {
|
|
11336
|
+
if (typeof value === "object") return value;
|
|
11337
|
+
return {};
|
|
11338
|
+
}
|
|
11339
|
+
function isPublintCheckName(value) {
|
|
11340
|
+
return ALL_PUBLINT_CHECKS.includes(value);
|
|
11341
|
+
}
|
|
11342
|
+
function normalizePublintRuleName(location, value) {
|
|
11343
|
+
const bareName = value.startsWith(PUBLINT_RULE_PREFIX) ? value.slice(4) : value;
|
|
11344
|
+
if (!isPublintCheckName(bareName)) throw new TypeError(`Unknown publint rule "${value}" in ${location}`);
|
|
11345
|
+
return bareName;
|
|
11346
|
+
}
|
|
11347
|
+
function isRuleLevel(value) {
|
|
11348
|
+
return typeof value === "string" && PUBLINT_RULE_LEVELS.has(value);
|
|
11349
|
+
}
|
|
11350
|
+
function candidateRuleLevelValue(value) {
|
|
11351
|
+
if (Array.isArray(value) && value.length > 0) return value[0];
|
|
11352
|
+
if (typeof value === "object" && value !== null) {
|
|
11353
|
+
const record = value;
|
|
11354
|
+
return record.level ?? record.enabled;
|
|
11355
|
+
}
|
|
11356
|
+
return value;
|
|
11357
|
+
}
|
|
11358
|
+
function parseRuleLevel(location, value) {
|
|
11359
|
+
const candidate = candidateRuleLevelValue(value);
|
|
11360
|
+
if (candidate === true) return "warn";
|
|
11361
|
+
if (candidate === false) return "off";
|
|
11362
|
+
if (isRuleLevel(candidate)) return candidate;
|
|
11363
|
+
throw new TypeError(`${location} must be "error", "warn", "off", boolean, [level, options], or { level?, enabled? }`);
|
|
11364
|
+
}
|
|
11365
|
+
function normalizePublintRuleNames(location, values) {
|
|
11366
|
+
return (values ?? []).map((value) => normalizePublintRuleName(location, value));
|
|
11367
|
+
}
|
|
11368
|
+
function defaultLevels() {
|
|
11369
|
+
return new Map(ALL_PUBLINT_CHECKS.map((check) => [check, defaultPublintLevel(check)]));
|
|
11370
|
+
}
|
|
11371
|
+
function setRuleLevel(levels, explicit, check, level) {
|
|
11372
|
+
levels.set(check, level);
|
|
11373
|
+
explicit.add(check);
|
|
11374
|
+
}
|
|
11375
|
+
function applyIncludedOnly(levels, explicit, include) {
|
|
11376
|
+
if (include.length === 0) return;
|
|
11377
|
+
const included = new Set(include);
|
|
11378
|
+
for (const check of ALL_PUBLINT_CHECKS) {
|
|
11379
|
+
if (included.has(check)) continue;
|
|
11380
|
+
setRuleLevel(levels, explicit, check, "off");
|
|
11381
|
+
}
|
|
11382
|
+
}
|
|
11383
|
+
function applyExcluded(levels, explicit, exclude) {
|
|
11384
|
+
for (const check of exclude) setRuleLevel(levels, explicit, check, "off");
|
|
11385
|
+
}
|
|
11386
|
+
function applyConfiguredRules(levels, explicit, rules) {
|
|
11387
|
+
const configuredRules = Object.entries(rules ?? {});
|
|
11388
|
+
const canonicalRuleIds = new Set(configuredRules.map(([ruleId]) => ruleId).filter((ruleId) => ruleId.startsWith(PUBLINT_RULE_PREFIX)));
|
|
11389
|
+
for (const [check, setting] of configuredRules) {
|
|
11390
|
+
if (check.startsWith(PUBLINT_RULE_PREFIX)) continue;
|
|
11391
|
+
const ruleName = normalizePublintRuleName("commands.publint.rules", check);
|
|
11392
|
+
if (canonicalRuleIds.has(publintRuleId(ruleName))) continue;
|
|
11393
|
+
warnDeprecatedPublintRuleName(ruleName);
|
|
11394
|
+
setRuleLevel(levels, explicit, ruleName, parseRuleLevel(`commands.publint.rules["${publintRuleId(ruleName)}"]`, setting));
|
|
11395
|
+
}
|
|
11396
|
+
for (const [ruleId, setting] of configuredRules) {
|
|
11397
|
+
if (!ruleId.startsWith(PUBLINT_RULE_PREFIX)) continue;
|
|
11398
|
+
const check = normalizePublintRuleName("commands.publint.rules", ruleId);
|
|
11399
|
+
setRuleLevel(levels, explicit, check, parseRuleLevel(`commands.publint.rules["${publintRuleId(check)}"]`, setting));
|
|
11400
|
+
}
|
|
11401
|
+
}
|
|
11402
|
+
function resolvePublintRules(value, cliExclude, cliInclude) {
|
|
11403
|
+
const config = normalizePublintConfig$2(value);
|
|
11404
|
+
const configExclude = normalizePublintRuleNames("commands.publint.exclude", config.exclude);
|
|
11405
|
+
const configInclude = normalizePublintRuleNames("commands.publint.include", config.include);
|
|
11406
|
+
const normalizedCliExclude = normalizePublintRuleNames("--exclude", cliExclude);
|
|
11407
|
+
const normalizedCliInclude = normalizePublintRuleNames("--include", cliInclude);
|
|
11408
|
+
if ((configExclude.length > 0 || normalizedCliExclude.length > 0) && (configInclude.length > 0 || normalizedCliInclude.length > 0)) throw new TypeError("Publint: --include and --exclude cannot be used together");
|
|
11409
|
+
const levels = defaultLevels();
|
|
11410
|
+
const explicit = /* @__PURE__ */ new Set();
|
|
11411
|
+
applyIncludedOnly(levels, explicit, configInclude);
|
|
11412
|
+
applyExcluded(levels, explicit, configExclude);
|
|
11413
|
+
applyConfiguredRules(levels, explicit, config.rules);
|
|
11414
|
+
applyIncludedOnly(levels, explicit, normalizedCliInclude);
|
|
11415
|
+
applyExcluded(levels, explicit, normalizedCliExclude);
|
|
11416
|
+
return {
|
|
11417
|
+
explicit,
|
|
11418
|
+
levels
|
|
11419
|
+
};
|
|
11420
|
+
}
|
|
11421
|
+
function cloneResolvedPublintRules(rules) {
|
|
11422
|
+
return {
|
|
11423
|
+
explicit: new Set(rules.explicit),
|
|
11424
|
+
levels: new Map(rules.levels)
|
|
11425
|
+
};
|
|
11426
|
+
}
|
|
11427
|
+
//#endregion
|
|
11197
11428
|
//#region ../../node_modules/.pnpm/@publint+pack@0.1.4/node_modules/@publint/pack/src/node/pack.js
|
|
11198
11429
|
/** @type {import('../index.d.ts').pack} */
|
|
11199
11430
|
async function pack(dir, opts) {
|
|
@@ -13311,9 +13542,6 @@ function normalizePublintConfig$1(value) {
|
|
|
13311
13542
|
if (typeof value === "object") return value;
|
|
13312
13543
|
return {};
|
|
13313
13544
|
}
|
|
13314
|
-
function mergeWorkspaceExclude(exclude, wsPublintConfig) {
|
|
13315
|
-
return /* @__PURE__ */ new Set([...exclude, ...wsPublintConfig.exclude ?? []]);
|
|
13316
|
-
}
|
|
13317
13545
|
const shouldRemoveSourceFromExports = (exports) => {
|
|
13318
13546
|
let isRemoved = false;
|
|
13319
13547
|
for (const [key, value] of Object.entries(exports)) if (key === "source") {
|
|
@@ -13369,6 +13597,15 @@ function mergeResults(target, source) {
|
|
|
13369
13597
|
target.warnings += source.warnings;
|
|
13370
13598
|
target.modified ||= source.modified;
|
|
13371
13599
|
}
|
|
13600
|
+
function mergeLeveledResult(target, source, check, rules) {
|
|
13601
|
+
const issueCount = source.errors + source.warnings;
|
|
13602
|
+
if (rules.explicit.has(check)) {
|
|
13603
|
+
const level = rules.levels.get(check) ?? defaultPublintLevel(check);
|
|
13604
|
+
if (level === "error") target.errors += issueCount;
|
|
13605
|
+
else if (level === "warn") target.warnings += issueCount;
|
|
13606
|
+
} else mergeResults(target, source);
|
|
13607
|
+
target.modified ||= source.modified;
|
|
13608
|
+
}
|
|
13372
13609
|
async function readPackageJson(pkgDir) {
|
|
13373
13610
|
return JSON.parse(await promises.readFile(PATH.join(pkgDir, "package.json"), "utf8"));
|
|
13374
13611
|
}
|
|
@@ -13495,21 +13732,21 @@ function checkRootTypes(pkg, shouldFix) {
|
|
|
13495
13732
|
result.warnings++;
|
|
13496
13733
|
return result;
|
|
13497
13734
|
}
|
|
13498
|
-
async function customPubLint(pkgDir, pkg, shouldFix = false,
|
|
13735
|
+
async function customPubLint(pkgDir, pkg, shouldFix = false, rules) {
|
|
13499
13736
|
const result = emptyCustomResult();
|
|
13500
|
-
if (
|
|
13501
|
-
if (
|
|
13502
|
-
if (
|
|
13503
|
-
if (
|
|
13504
|
-
if (
|
|
13505
|
-
if (
|
|
13506
|
-
if (
|
|
13507
|
-
if (
|
|
13508
|
-
if (
|
|
13509
|
-
if (
|
|
13510
|
-
if (
|
|
13511
|
-
if (
|
|
13512
|
-
if (
|
|
13737
|
+
if (rules.levels.get("files") !== "off") mergeLeveledResult(result, checkFiles(pkg, shouldFix), "files", rules);
|
|
13738
|
+
if (rules.levels.get("source") !== "off") mergeLeveledResult(result, checkExportsSource(pkg, shouldFix), "source", rules);
|
|
13739
|
+
if (rules.levels.get("rootSource") !== "off") mergeLeveledResult(result, checkRootSource(pkg, shouldFix), "rootSource", rules);
|
|
13740
|
+
if (rules.levels.get("main") !== "off") mergeLeveledResult(result, migrateFieldToExports(pkg, "main", "default", shouldFix), "main", rules);
|
|
13741
|
+
if (rules.levels.get("types") !== "off") mergeLeveledResult(result, migrateFieldToExports(pkg, "types", "types", shouldFix), "types", rules);
|
|
13742
|
+
if (rules.levels.get("module") !== "off") mergeLeveledResult(result, migrateFieldToExports(pkg, "module", "default", shouldFix), "module", rules);
|
|
13743
|
+
if (rules.levels.get("importToDefault") !== "off") mergeLeveledResult(result, checkImportToDefault(pkg, shouldFix), "importToDefault", rules);
|
|
13744
|
+
if (rules.levels.get("neutralToDefault") !== "off") mergeLeveledResult(result, checkNeutralToDefault(pkg, shouldFix, (message) => console.warn(chalk.yellow(message))), "neutralToDefault", rules);
|
|
13745
|
+
if (rules.levels.get("defaultExportOrder") !== "off") mergeLeveledResult(result, checkDefaultExportOrder(pkg, shouldFix, (message) => console.warn(chalk.yellow(message))), "defaultExportOrder", rules);
|
|
13746
|
+
if (rules.levels.get("rootTypes") !== "off") mergeLeveledResult(result, checkRootTypes(pkg, shouldFix), "rootTypes", rules);
|
|
13747
|
+
if (rules.levels.get("platform") !== "off") mergeLeveledResult(result, await checkPlatform(pkgDir, pkg, shouldFix), "platform", rules);
|
|
13748
|
+
if (rules.levels.get("sideEffects") !== "off") mergeLeveledResult(result, checkSideEffects(pkg), "sideEffects", rules);
|
|
13749
|
+
if (rules.levels.get("resolutions") !== "off") mergeLeveledResult(result, checkResolutions(pkg), "resolutions", rules);
|
|
13513
13750
|
return [
|
|
13514
13751
|
result.errors,
|
|
13515
13752
|
result.warnings,
|
|
@@ -13585,42 +13822,89 @@ async function runPublintLibrary(pkgDir, pkg, isStrict, shouldPack) {
|
|
|
13585
13822
|
warnings: messages.filter((message) => message.type !== "error").length
|
|
13586
13823
|
};
|
|
13587
13824
|
}
|
|
13588
|
-
|
|
13825
|
+
function applyEffectiveExcludes(pkg, exclude, rules) {
|
|
13826
|
+
const effectiveExclude = Boolean(pkg.private) ? /* @__PURE__ */ new Set([...exclude, ...PUBLISH_ONLY_CHECKS]) : exclude;
|
|
13827
|
+
for (const check of effectiveExclude) {
|
|
13828
|
+
rules.levels.set(check, "off");
|
|
13829
|
+
rules.explicit.add(check);
|
|
13830
|
+
}
|
|
13831
|
+
}
|
|
13832
|
+
async function runCustomPublintPass(pkgDir, pkg, shouldFix, rules) {
|
|
13833
|
+
const [errors, warnings, modified] = await customPubLint(pkgDir, pkg, shouldFix, rules);
|
|
13834
|
+
if (shouldFix && modified) {
|
|
13835
|
+
await writePackageJson(pkgDir, pkg);
|
|
13836
|
+
return {
|
|
13837
|
+
pkg: await readPackageJson(pkgDir),
|
|
13838
|
+
result: {
|
|
13839
|
+
errors,
|
|
13840
|
+
modified,
|
|
13841
|
+
warnings
|
|
13842
|
+
}
|
|
13843
|
+
};
|
|
13844
|
+
}
|
|
13845
|
+
return {
|
|
13846
|
+
pkg,
|
|
13847
|
+
result: {
|
|
13848
|
+
errors,
|
|
13849
|
+
modified,
|
|
13850
|
+
warnings
|
|
13851
|
+
}
|
|
13852
|
+
};
|
|
13853
|
+
}
|
|
13854
|
+
async function runLeveledPublintLibrary(pkgDir, pkg, isStrict, shouldPack, rules) {
|
|
13855
|
+
const level = rules.levels.get("publint");
|
|
13856
|
+
if (level === "off") return {
|
|
13857
|
+
errors: 0,
|
|
13858
|
+
warnings: 0
|
|
13859
|
+
};
|
|
13860
|
+
const library = await runPublintLibrary(pkgDir, pkg, isStrict, shouldPack);
|
|
13861
|
+
if (!rules.explicit.has("publint")) return library;
|
|
13862
|
+
const issueCount = library.errors + library.warnings;
|
|
13863
|
+
return level === "error" ? {
|
|
13864
|
+
errors: issueCount,
|
|
13865
|
+
warnings: 0
|
|
13866
|
+
} : {
|
|
13867
|
+
errors: 0,
|
|
13868
|
+
warnings: issueCount
|
|
13869
|
+
};
|
|
13870
|
+
}
|
|
13871
|
+
function runLeveledCompileTargets(pkgDir, shouldFix, rules) {
|
|
13872
|
+
const level = rules.levels.get("compileTargets");
|
|
13873
|
+
const raw = level === "off" ? {
|
|
13874
|
+
errors: 0,
|
|
13875
|
+
warnings: 0
|
|
13876
|
+
} : checkCompileTargets(pkgDir, shouldFix);
|
|
13877
|
+
if (!rules.explicit.has("compileTargets")) return raw;
|
|
13878
|
+
const issueCount = raw.errors + raw.warnings;
|
|
13879
|
+
return level === "error" ? {
|
|
13880
|
+
errors: issueCount,
|
|
13881
|
+
warnings: 0
|
|
13882
|
+
} : {
|
|
13883
|
+
errors: 0,
|
|
13884
|
+
warnings: issueCount
|
|
13885
|
+
};
|
|
13886
|
+
}
|
|
13887
|
+
const packagePublintDetailed = async ({ exclude = /* @__PURE__ */ new Set(), ruleLevels, shouldFix = false, shouldPack: shouldPackParam, pkgDir: pkgDirParam, isStrict = isStrictMode(), verbose: _verbose = false } = {}) => {
|
|
13589
13888
|
const pkgDir = PATH.resolve(pkgDirParam ?? INIT_CWD());
|
|
13590
13889
|
const wsPublintConfig = normalizePublintConfig$1(await loadWorkspaceCommandConfig(pkgDir, "publint"));
|
|
13591
|
-
const workspaceExclude = mergeWorkspaceExclude(exclude, wsPublintConfig);
|
|
13592
13890
|
const shouldPack = shouldPackParam ?? wsPublintConfig.pack ?? true;
|
|
13891
|
+
const resolvedRules = ruleLevels === void 0 ? resolvePublintRules(wsPublintConfig) : cloneResolvedPublintRules(ruleLevels);
|
|
13593
13892
|
let pkg = await readPackageJson(pkgDir);
|
|
13594
|
-
|
|
13893
|
+
applyEffectiveExcludes(pkg, exclude, resolvedRules);
|
|
13595
13894
|
console.log(chalk.green(`Publint: ${String(pkg.name)}${Boolean(pkg.private) ? chalk.gray(" (private)") : ""}`));
|
|
13596
13895
|
console.log(chalk.gray(pkgDir));
|
|
13597
|
-
let
|
|
13598
|
-
|
|
13599
|
-
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
await writePackageJson(pkgDir, pkg);
|
|
13607
|
-
pkg = await readPackageJson(pkgDir);
|
|
13608
|
-
}
|
|
13609
|
-
};
|
|
13610
|
-
if (shouldFix) await runCustomChecks();
|
|
13611
|
-
if (!effectiveExclude.has("publint")) {
|
|
13612
|
-
const library = await runPublintLibrary(pkgDir, pkg, isStrict, shouldPack);
|
|
13613
|
-
libraryErrors = library.errors;
|
|
13614
|
-
libraryWarnings = library.warnings;
|
|
13615
|
-
}
|
|
13616
|
-
if (!shouldFix) await runCustomChecks();
|
|
13617
|
-
const compileTargets = effectiveExclude.has("compileTargets") ? {
|
|
13618
|
-
errors: 0,
|
|
13619
|
-
warnings: 0
|
|
13620
|
-
} : checkCompileTargets(pkgDir, shouldFix);
|
|
13896
|
+
let customResult = emptyCustomResult();
|
|
13897
|
+
if (shouldFix) {
|
|
13898
|
+
const customPass = await runCustomPublintPass(pkgDir, pkg, shouldFix, resolvedRules);
|
|
13899
|
+
customResult = customPass.result;
|
|
13900
|
+
pkg = customPass.pkg;
|
|
13901
|
+
}
|
|
13902
|
+
const library = await runLeveledPublintLibrary(pkgDir, pkg, isStrict, shouldPack, resolvedRules);
|
|
13903
|
+
if (!shouldFix) customResult = (await runCustomPublintPass(pkgDir, pkg, shouldFix, resolvedRules)).result;
|
|
13904
|
+
const compileTargets = runLeveledCompileTargets(pkgDir, shouldFix, resolvedRules);
|
|
13621
13905
|
return {
|
|
13622
|
-
errors:
|
|
13623
|
-
warnings:
|
|
13906
|
+
errors: library.errors + customResult.errors + compileTargets.errors,
|
|
13907
|
+
warnings: library.warnings + customResult.warnings + compileTargets.warnings
|
|
13624
13908
|
};
|
|
13625
13909
|
};
|
|
13626
13910
|
const packagePublint = async (params = {}) => {
|
|
@@ -13629,28 +13913,20 @@ const packagePublint = async (params = {}) => {
|
|
|
13629
13913
|
};
|
|
13630
13914
|
//#endregion
|
|
13631
13915
|
//#region src/actions/publint.ts
|
|
13632
|
-
function resolveExclude(publintConfig, cliExclude, cliInclude) {
|
|
13633
|
-
const hasExclude = (publintConfig.exclude?.length ?? 0) > 0 || (cliExclude?.length ?? 0) > 0;
|
|
13634
|
-
const hasInclude = (publintConfig.include?.length ?? 0) > 0 || (cliInclude?.length ?? 0) > 0;
|
|
13635
|
-
if (hasExclude && hasInclude) {
|
|
13636
|
-
console.error(chalk.red("Publint: --include and --exclude cannot be used together"));
|
|
13637
|
-
return;
|
|
13638
|
-
}
|
|
13639
|
-
if (hasInclude) {
|
|
13640
|
-
const include = /* @__PURE__ */ new Set([...publintConfig.include ?? [], ...cliInclude ?? []]);
|
|
13641
|
-
return new Set(ALL_PUBLINT_CHECKS.filter((c) => !include.has(c)));
|
|
13642
|
-
}
|
|
13643
|
-
return /* @__PURE__ */ new Set([...publintConfig.exclude ?? [], ...cliExclude ?? []]);
|
|
13644
|
-
}
|
|
13645
13916
|
function normalizePublintConfig(value) {
|
|
13646
13917
|
if (typeof value === "object") return value;
|
|
13647
13918
|
return {};
|
|
13648
13919
|
}
|
|
13920
|
+
function offChecks(rules) {
|
|
13921
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
13922
|
+
for (const [check, level] of rules.levels) if (level === "off") excluded.add(check);
|
|
13923
|
+
return excluded;
|
|
13924
|
+
}
|
|
13649
13925
|
async function loadPublintOptions() {
|
|
13650
13926
|
const config = await loadConfig();
|
|
13651
13927
|
const publintConfig = normalizePublintConfig(config.commands?.publint ?? config.publint);
|
|
13652
13928
|
return {
|
|
13653
|
-
exclude:
|
|
13929
|
+
exclude: offChecks(resolvePublintRules(publintConfig)),
|
|
13654
13930
|
pack: publintConfig.pack ?? true
|
|
13655
13931
|
};
|
|
13656
13932
|
}
|