@ariestools/toolchain 8.6.12 → 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/config.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.d.ts +2 -0
- package/dist/actions/gitlint.d.ts.map +1 -1
- package/dist/actions/lintlint.d.ts +31 -0
- package/dist/actions/lintlint.d.ts.map +1 -1
- package/dist/actions/node-lint.d.ts +7 -0
- package/dist/actions/node-lint.d.ts.map +1 -1
- package/dist/actions/package/compile/MonolithConfig.d.ts +23 -4
- package/dist/actions/package/compile/MonolithConfig.d.ts.map +1 -1
- package/dist/actions/package/compile/PublintConfig.d.ts +4 -2
- package/dist/actions/package/compile/PublintConfig.d.ts.map +1 -1
- package/dist/actions/package/compile/XyConfig.d.ts +18 -6
- 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/publintRules.d.ts +4 -1
- package/dist/actions/package/publintRules.d.ts.map +1 -1
- package/dist/actions/package-lint.d.ts.map +1 -1
- package/dist/actions/packman/lint.d.ts +14 -0
- package/dist/actions/packman/lint.d.ts.map +1 -1
- package/dist/actions/ruleCatalog.d.ts +4 -2
- package/dist/actions/ruleCatalog.d.ts.map +1 -1
- package/dist/actions/ruleRunner.d.ts +4 -1
- package/dist/actions/ruleRunner.d.ts.map +1 -1
- package/dist/actions/skills/lint.d.ts +13 -0
- package/dist/actions/skills/lint.d.ts.map +1 -1
- package/dist/bin/package/build.mjs +412 -55
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +249 -21
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/publint.mjs +163 -34
- package/dist/bin/package/publint.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +249 -21
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/package/sync-layout.mjs +47 -7
- package/dist/bin/package/sync-layout.mjs.map +1 -1
- package/dist/bin/xy.mjs +6942 -621
- 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/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/deprecatedCommand.d.ts +2 -0
- package/dist/xy/deprecatedCommand.d.ts.map +1 -0
- 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/package.json +5 -4
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { EnvelopeReturn } from '../../lib/index.ts';
|
|
2
|
+
import type { RuleCheckDefinition } from '../ruleRunner.ts';
|
|
3
|
+
import { type RepoProfile } from './detectProfile.ts';
|
|
2
4
|
import { type SkillTier, type XyoSkillName } from './skillRules.ts';
|
|
3
5
|
export interface SkillsLintOptions {
|
|
4
6
|
cwd?: string;
|
|
@@ -24,5 +26,16 @@ export interface SkillsLintResult {
|
|
|
24
26
|
unnecessary: XyoSkillName[];
|
|
25
27
|
warnings: number;
|
|
26
28
|
}
|
|
29
|
+
interface SkillsLintContext {
|
|
30
|
+
cwd: string;
|
|
31
|
+
duplicates: string[];
|
|
32
|
+
globalDir: string;
|
|
33
|
+
missing: XyoSkillName[];
|
|
34
|
+
outdated: OutdatedSkill[];
|
|
35
|
+
profile: RepoProfile;
|
|
36
|
+
unnecessary: XyoSkillName[];
|
|
37
|
+
}
|
|
38
|
+
export declare const SKILLS_LINT_RULES: RuleCheckDefinition<SkillsLintContext>[];
|
|
27
39
|
export declare const skillsLint: (options?: SkillsLintOptions) => Promise<EnvelopeReturn>;
|
|
40
|
+
export {};
|
|
28
41
|
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../../src/actions/skills/lint.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../../src/actions/skills/lint.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGxD,OAAO,KAAK,EACV,mBAAmB,EAGpB,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAMxE,OAAO,EAIL,KAAK,SAAS,EAEd,KAAK,YAAY,EAClB,MAAM,iBAAiB,CAAA;AAGxB,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,YAAY,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,QAAQ,EAAE,aAAa,EAAE,CAAA;IACzB,WAAW,EAAE,SAAS,CAAA;IACtB,WAAW,EAAE,YAAY,EAAE,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;CACjB;AAsCD,UAAU,iBAAiB;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,QAAQ,EAAE,aAAa,EAAE,CAAA;IACzB,OAAO,EAAE,WAAW,CAAA;IACpB,WAAW,EAAE,YAAY,EAAE,CAAA;CAC5B;AA4GD,eAAO,MAAM,iBAAiB,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,EAqDrE,CAAA;AAiBD,eAAO,MAAM,UAAU,GAAU,UAAS,iBAAsB,KAAG,OAAO,CAAC,cAAc,CAiExF,CAAA"}
|
|
@@ -9661,8 +9661,8 @@ var require_ExplorerSync = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
9661
9661
|
exports.ExplorerSync = ExplorerSync;
|
|
9662
9662
|
}));
|
|
9663
9663
|
//#endregion
|
|
9664
|
-
//#region
|
|
9665
|
-
var
|
|
9664
|
+
//#region ../../node_modules/.pnpm/cosmiconfig@9.0.2_typescript@6.0.3/node_modules/cosmiconfig/dist/index.js
|
|
9665
|
+
var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
9666
9666
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9667
9667
|
exports.defaultLoadersSync = exports.defaultLoaders = exports.globalConfigSearchPlacesSync = exports.globalConfigSearchPlaces = exports.getDefaultSearchPlacesSync = exports.getDefaultSearchPlaces = void 0;
|
|
9668
9668
|
exports.cosmiconfig = cosmiconfig;
|
|
@@ -9794,7 +9794,111 @@ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
9794
9794
|
clearCaches: explorer.clearCaches.bind(explorer)
|
|
9795
9795
|
};
|
|
9796
9796
|
}
|
|
9797
|
-
}))
|
|
9797
|
+
}));
|
|
9798
|
+
//#endregion
|
|
9799
|
+
//#region src/lib/ruleCommandRegistry.ts
|
|
9800
|
+
const RULE_COMMANDS = {
|
|
9801
|
+
apiExposure: {
|
|
9802
|
+
command: "api-exposure",
|
|
9803
|
+
configKey: "apiExposure",
|
|
9804
|
+
includeInRoot: true,
|
|
9805
|
+
title: "API Exposure Rules"
|
|
9806
|
+
},
|
|
9807
|
+
check: {
|
|
9808
|
+
command: "check",
|
|
9809
|
+
includeInRoot: true,
|
|
9810
|
+
title: "Check Rules"
|
|
9811
|
+
},
|
|
9812
|
+
cycle: {
|
|
9813
|
+
command: "cycle",
|
|
9814
|
+
includeInRoot: true,
|
|
9815
|
+
title: "Cycle Rules"
|
|
9816
|
+
},
|
|
9817
|
+
dead: {
|
|
9818
|
+
command: "dead",
|
|
9819
|
+
configKey: "dead",
|
|
9820
|
+
includeInRoot: true,
|
|
9821
|
+
title: "Dead Rules"
|
|
9822
|
+
},
|
|
9823
|
+
deplint: {
|
|
9824
|
+
command: "deplint",
|
|
9825
|
+
configKey: "deplint",
|
|
9826
|
+
includeInRoot: true,
|
|
9827
|
+
title: "Deplint Rules"
|
|
9828
|
+
},
|
|
9829
|
+
fix: {
|
|
9830
|
+
command: "fix",
|
|
9831
|
+
includeInRoot: false,
|
|
9832
|
+
title: "Fix Rules"
|
|
9833
|
+
},
|
|
9834
|
+
gitLint: {
|
|
9835
|
+
aliases: ["gitlint"],
|
|
9836
|
+
command: "git lint",
|
|
9837
|
+
configKey: "gitLint",
|
|
9838
|
+
includeInRoot: true,
|
|
9839
|
+
title: "Git Lint Rules"
|
|
9840
|
+
},
|
|
9841
|
+
lint: {
|
|
9842
|
+
aliases: ["relint"],
|
|
9843
|
+
command: "lint",
|
|
9844
|
+
includeInRoot: true,
|
|
9845
|
+
title: "Lint Rules"
|
|
9846
|
+
},
|
|
9847
|
+
lintLint: {
|
|
9848
|
+
aliases: ["lintlint"],
|
|
9849
|
+
command: "lint lint",
|
|
9850
|
+
configKey: "lintLint",
|
|
9851
|
+
includeInRoot: true,
|
|
9852
|
+
title: "Lint Lint Rules"
|
|
9853
|
+
},
|
|
9854
|
+
nodeLint: {
|
|
9855
|
+
aliases: ["node-lint"],
|
|
9856
|
+
command: "node lint",
|
|
9857
|
+
configKey: "nodeLint",
|
|
9858
|
+
includeInRoot: true,
|
|
9859
|
+
title: "Node Lint Rules"
|
|
9860
|
+
},
|
|
9861
|
+
packman: {
|
|
9862
|
+
command: "packman lint",
|
|
9863
|
+
configKey: "packman",
|
|
9864
|
+
includeInRoot: true,
|
|
9865
|
+
title: "Packman Lint Rules"
|
|
9866
|
+
},
|
|
9867
|
+
publint: {
|
|
9868
|
+
aliases: ["republint"],
|
|
9869
|
+
command: "publint",
|
|
9870
|
+
configKey: "publint",
|
|
9871
|
+
includeInRoot: true,
|
|
9872
|
+
title: "Publint Rules"
|
|
9873
|
+
},
|
|
9874
|
+
repoLint: {
|
|
9875
|
+
command: "repo lint",
|
|
9876
|
+
configKey: "repoLint",
|
|
9877
|
+
includeInRoot: true,
|
|
9878
|
+
title: "Repo Lint Rules"
|
|
9879
|
+
},
|
|
9880
|
+
skillsLint: {
|
|
9881
|
+
command: "skills lint",
|
|
9882
|
+
configKey: "skillsLint",
|
|
9883
|
+
includeInRoot: true,
|
|
9884
|
+
title: "Skills Lint Rules"
|
|
9885
|
+
}
|
|
9886
|
+
};
|
|
9887
|
+
const DEPRECATED_CONFIG_KEY_ALIASES = {
|
|
9888
|
+
gitLint: ["gitlint"],
|
|
9889
|
+
lintLint: ["lintlint"]
|
|
9890
|
+
};
|
|
9891
|
+
const CONFIG_ALIAS_TO_CANONICAL = new Map(Object.entries(DEPRECATED_CONFIG_KEY_ALIASES).flatMap(([canonical, aliases]) => aliases.map((alias) => [alias, canonical])));
|
|
9892
|
+
const RULE_CONFIG_COMMAND_KEYS = new Set(Object.values(RULE_COMMANDS).flatMap((command) => "configKey" in command ? [command.configKey] : []));
|
|
9893
|
+
function canonicalRuleConfigKey(commandName) {
|
|
9894
|
+
return CONFIG_ALIAS_TO_CANONICAL.get(commandName) ?? commandName;
|
|
9895
|
+
}
|
|
9896
|
+
function deprecatedRuleConfigAliases(configKey) {
|
|
9897
|
+
return Object.entries(DEPRECATED_CONFIG_KEY_ALIASES).find(([canonical]) => canonical === configKey)?.[1] ?? [];
|
|
9898
|
+
}
|
|
9899
|
+
//#endregion
|
|
9900
|
+
//#region src/lib/loadConfig.ts
|
|
9901
|
+
var import_dist = require_dist();
|
|
9798
9902
|
const configState = {
|
|
9799
9903
|
config: void 0,
|
|
9800
9904
|
rootConfigPath: void 0
|
|
@@ -9842,21 +9946,30 @@ async function loadWorkspaceConfig(workspaceDir) {
|
|
|
9842
9946
|
}
|
|
9843
9947
|
/** Deprecated top-level fields that should be under `commands`. */
|
|
9844
9948
|
const DEPRECATED_COMMAND_FIELDS = /* @__PURE__ */ new Set(["deplint", "publint"]);
|
|
9949
|
+
function warnOnce(key, message) {
|
|
9950
|
+
if (deprecationWarned.has(key)) return;
|
|
9951
|
+
deprecationWarned.add(key);
|
|
9952
|
+
console.warn(chalk.yellow(message));
|
|
9953
|
+
}
|
|
9845
9954
|
/**
|
|
9846
9955
|
* Resolves a command's config field from a config object.
|
|
9847
9956
|
* Prefers `commands.[name]` over top-level `[name]`.
|
|
9848
9957
|
* Warns once per config file when a deprecated top-level field is used.
|
|
9849
9958
|
*/
|
|
9850
9959
|
function resolveCommandField(cfg, commandName, configPath) {
|
|
9851
|
-
const
|
|
9852
|
-
|
|
9853
|
-
const
|
|
9854
|
-
if (
|
|
9855
|
-
|
|
9856
|
-
|
|
9857
|
-
|
|
9858
|
-
|
|
9859
|
-
|
|
9960
|
+
const configKey = canonicalRuleConfigKey(commandName);
|
|
9961
|
+
const commands = isRecord$1(cfg.commands) ? cfg.commands : void 0;
|
|
9962
|
+
const fromCommands = commands?.[configKey];
|
|
9963
|
+
if (isRecord$1(fromCommands)) return fromCommands;
|
|
9964
|
+
for (const alias of deprecatedRuleConfigAliases(configKey)) {
|
|
9965
|
+
const fromAlias = commands?.[alias];
|
|
9966
|
+
if (!isRecord$1(fromAlias)) continue;
|
|
9967
|
+
warnOnce(`${configPath ?? "unknown"}:commands.${alias}`, `[xy] Deprecated: "commands.${alias}" in ${configPath ?? "xy.config"} — use "commands.${configKey}"`);
|
|
9968
|
+
return fromAlias;
|
|
9969
|
+
}
|
|
9970
|
+
const fromTopLevel = cfg[configKey];
|
|
9971
|
+
if (fromTopLevel !== void 0 && typeof fromTopLevel === "object" && DEPRECATED_COMMAND_FIELDS.has(configKey)) {
|
|
9972
|
+
warnOnce(`${configPath ?? "unknown"}:${configKey}`, `[xy] Deprecated: top-level "${configKey}" in ${configPath ?? "xy.config"} — move to "commands.${configKey}"`);
|
|
9860
9973
|
return fromTopLevel;
|
|
9861
9974
|
}
|
|
9862
9975
|
return {};
|
|
@@ -9868,20 +9981,9 @@ function mergeRuleConfigs(target, source) {
|
|
|
9868
9981
|
};
|
|
9869
9982
|
return source;
|
|
9870
9983
|
}
|
|
9871
|
-
const RULE_CONFIG_COMMANDS = /* @__PURE__ */ new Set([
|
|
9872
|
-
"apiExposure",
|
|
9873
|
-
"dead",
|
|
9874
|
-
"deplint",
|
|
9875
|
-
"gitlint",
|
|
9876
|
-
"lintlint",
|
|
9877
|
-
"nodeLint",
|
|
9878
|
-
"packman",
|
|
9879
|
-
"publint",
|
|
9880
|
-
"repoLint",
|
|
9881
|
-
"skillsLint"
|
|
9882
|
-
]);
|
|
9883
9984
|
function mergeCommandConfig(rootCmd, workspaceCmd, commandName) {
|
|
9884
|
-
|
|
9985
|
+
const configKey = canonicalRuleConfigKey(commandName);
|
|
9986
|
+
return deepMerge$1(rootCmd, workspaceCmd, { customMerge: (key) => RULE_CONFIG_COMMAND_KEYS.has(configKey) && key === "rules" ? mergeRuleConfigs : void 0 });
|
|
9885
9987
|
}
|
|
9886
9988
|
/**
|
|
9887
9989
|
* Loads a command-specific config merged from root and workspace levels.
|
|
@@ -9904,8 +10006,9 @@ function isWorkspaceUnderRootConfig(workspaceDir) {
|
|
|
9904
10006
|
return relative === "" || !relative.startsWith("..") && !PATH.isAbsolute(relative);
|
|
9905
10007
|
}
|
|
9906
10008
|
async function loadWorkspaceCommandConfig(workspaceDir, commandName) {
|
|
10009
|
+
const configKey = canonicalRuleConfigKey(commandName);
|
|
9907
10010
|
const root = await loadConfig();
|
|
9908
|
-
return mergeCommandConfig(isWorkspaceUnderRootConfig(workspaceDir) ? resolveCommandField(root,
|
|
10011
|
+
return mergeCommandConfig(isWorkspaceUnderRootConfig(workspaceDir) ? resolveCommandField(root, configKey, configState.rootConfigPath) : {}, resolveCommandField(await loadWorkspaceConfig(workspaceDir), configKey, workspaceConfigCache.has(workspaceDir) ? workspaceDir : void 0), configKey);
|
|
9909
10012
|
}
|
|
9910
10013
|
//#endregion
|
|
9911
10014
|
//#region ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
|
|
@@ -13774,6 +13877,230 @@ const packageCompileEsbuild = async (config, mode = {}) => {
|
|
|
13774
13877
|
return nodeErrors + browserErrors + neutralErrors;
|
|
13775
13878
|
};
|
|
13776
13879
|
//#endregion
|
|
13880
|
+
//#region src/actions/package/compile/monolithReexport.ts
|
|
13881
|
+
function normalizeReexportTargets(value) {
|
|
13882
|
+
if (value === void 0) return [];
|
|
13883
|
+
return Array.isArray(value) ? value : [value];
|
|
13884
|
+
}
|
|
13885
|
+
/** Package-like specifier: not a hash alias and not a relative/absolute path. */
|
|
13886
|
+
function isPackageLikeSpecifier(spec) {
|
|
13887
|
+
return !spec.startsWith("#") && !spec.startsWith(".") && !spec.startsWith("/");
|
|
13888
|
+
}
|
|
13889
|
+
/** Configured `reexport` targets for a module, if any. */
|
|
13890
|
+
function moduleReexportTargets(mod) {
|
|
13891
|
+
return normalizeReexportTargets(mod.reexport);
|
|
13892
|
+
}
|
|
13893
|
+
function moduleHasReexport(mod) {
|
|
13894
|
+
return moduleReexportTargets(mod).length > 0;
|
|
13895
|
+
}
|
|
13896
|
+
/**
|
|
13897
|
+
* Master-barrel re-export targets for a module: explicit `barrelFrom`, else
|
|
13898
|
+
* `reexport`, else `#<name>`.
|
|
13899
|
+
*/
|
|
13900
|
+
function moduleBarrelTargets(mod) {
|
|
13901
|
+
const fromBarrel = normalizeReexportTargets(mod.barrelFrom);
|
|
13902
|
+
if (fromBarrel.length > 0) return fromBarrel;
|
|
13903
|
+
const fromReexport = moduleReexportTargets(mod);
|
|
13904
|
+
if (fromReexport.length > 0) return fromReexport;
|
|
13905
|
+
return [`#${mod.name}`];
|
|
13906
|
+
}
|
|
13907
|
+
/**
|
|
13908
|
+
* Subpath shim re-export targets: explicit `shimFrom`, else `reexport`, else
|
|
13909
|
+
* `#<name>`.
|
|
13910
|
+
*/
|
|
13911
|
+
function moduleShimTargets(mod) {
|
|
13912
|
+
const fromShim = normalizeReexportTargets(mod.shimFrom);
|
|
13913
|
+
if (fromShim.length > 0) return fromShim;
|
|
13914
|
+
const fromReexport = moduleReexportTargets(mod);
|
|
13915
|
+
if (fromReexport.length > 0) return fromReexport;
|
|
13916
|
+
return [`#${mod.name}`];
|
|
13917
|
+
}
|
|
13918
|
+
/** Builds a pure star-reexport TypeScript (or mjs) source body (no header). */
|
|
13919
|
+
function buildStarReexportLines(targets, options = {}) {
|
|
13920
|
+
const semi = options.semi === false ? "" : ";";
|
|
13921
|
+
return `${targets.map((target) => `export * from '${target}'${semi}`).join("\n")}\n`;
|
|
13922
|
+
}
|
|
13923
|
+
const starExportLineRe = /^export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?\s*$/;
|
|
13924
|
+
function isSkippableSourceLine(line) {
|
|
13925
|
+
if (line.length === 0) return true;
|
|
13926
|
+
if (line.startsWith("//")) return true;
|
|
13927
|
+
if (line.startsWith("/*") || line.startsWith("*") || line.startsWith("*/")) return true;
|
|
13928
|
+
return false;
|
|
13929
|
+
}
|
|
13930
|
+
/**
|
|
13931
|
+
* If `source` is only star re-exports (plus blank lines / `//` comments /
|
|
13932
|
+
* generated header), returns the targets in order. Otherwise `null`.
|
|
13933
|
+
*/
|
|
13934
|
+
function parsePureStarReexports(source) {
|
|
13935
|
+
const targets = [];
|
|
13936
|
+
for (const rawLine of source.split("\n")) {
|
|
13937
|
+
const line = rawLine.trim();
|
|
13938
|
+
if (isSkippableSourceLine(line)) continue;
|
|
13939
|
+
const match = starExportLineRe.exec(line);
|
|
13940
|
+
if (match === null) return null;
|
|
13941
|
+
targets.push(match[1]);
|
|
13942
|
+
}
|
|
13943
|
+
return targets.length > 0 ? targets : null;
|
|
13944
|
+
}
|
|
13945
|
+
function moduleIndexSourcePath(packageDir, moduleName) {
|
|
13946
|
+
return PATH.join(packageDir, "src", "modules", moduleName, "index.ts");
|
|
13947
|
+
}
|
|
13948
|
+
function hashModuleParts(spec) {
|
|
13949
|
+
const [modName, sub] = spec.slice(1).split("/", 2);
|
|
13950
|
+
return {
|
|
13951
|
+
modName,
|
|
13952
|
+
sub
|
|
13953
|
+
};
|
|
13954
|
+
}
|
|
13955
|
+
function resolveHashToModuleFile(packageDir, spec, config) {
|
|
13956
|
+
const { modName, sub } = hashModuleParts(spec);
|
|
13957
|
+
if (config.aliasImports?.[spec] !== void 0) {
|
|
13958
|
+
const alias = config.aliasImports[spec].replace(/^\.\//, "");
|
|
13959
|
+
return PATH.join(packageDir, alias);
|
|
13960
|
+
}
|
|
13961
|
+
if (sub === void 0) return moduleIndexSourcePath(packageDir, modName);
|
|
13962
|
+
if (sub === "model") return PATH.join(packageDir, "src", "modules", modName, "model.ts");
|
|
13963
|
+
return PATH.join(packageDir, "src", "modules", modName, `${sub}.ts`);
|
|
13964
|
+
}
|
|
13965
|
+
function expandNestedSource(file, packageDir, config, seen) {
|
|
13966
|
+
if (!fs.existsSync(file)) return null;
|
|
13967
|
+
const nested = parsePureStarReexports(fs.readFileSync(file, "utf8"));
|
|
13968
|
+
if (nested === null) return null;
|
|
13969
|
+
return expandToPackageReexportTargets(nested, packageDir, config, seen);
|
|
13970
|
+
}
|
|
13971
|
+
function expandHashTarget(target, packageDir, config, seen) {
|
|
13972
|
+
const { modName, sub } = hashModuleParts(target);
|
|
13973
|
+
const mod = config.modules.find((candidate) => candidate.name === modName);
|
|
13974
|
+
if (mod !== void 0 && moduleHasReexport(mod) && sub === void 0) return expandToPackageReexportTargets(moduleReexportTargets(mod), packageDir, config, seen);
|
|
13975
|
+
const file = resolveHashToModuleFile(packageDir, target, config);
|
|
13976
|
+
if (file === null) return null;
|
|
13977
|
+
return expandNestedSource(file, packageDir, config, seen);
|
|
13978
|
+
}
|
|
13979
|
+
function expandRelativeTarget(target, packageDir, config, seen) {
|
|
13980
|
+
const base = PATH.resolve(packageDir, "src", target.replace(/^\.\//, ""));
|
|
13981
|
+
const existing = [
|
|
13982
|
+
base,
|
|
13983
|
+
`${base}.ts`,
|
|
13984
|
+
`${base}.tsx`,
|
|
13985
|
+
PATH.join(base, "index.ts")
|
|
13986
|
+
].find((candidate) => fs.existsSync(candidate));
|
|
13987
|
+
if (existing === void 0) return null;
|
|
13988
|
+
return expandNestedSource(existing, packageDir, config, seen);
|
|
13989
|
+
}
|
|
13990
|
+
/**
|
|
13991
|
+
* Expands pure star-reexport targets until only package-like specifiers remain.
|
|
13992
|
+
* Returns `null` if any hop has local implementation or unreadable sources.
|
|
13993
|
+
*/
|
|
13994
|
+
function expandToPackageReexportTargets(targets, packageDir, config, seen = /* @__PURE__ */ new Set()) {
|
|
13995
|
+
const out = [];
|
|
13996
|
+
for (const target of targets) {
|
|
13997
|
+
if (seen.has(target)) continue;
|
|
13998
|
+
seen.add(target);
|
|
13999
|
+
if (isPackageLikeSpecifier(target)) {
|
|
14000
|
+
out.push(target);
|
|
14001
|
+
continue;
|
|
14002
|
+
}
|
|
14003
|
+
const expanded = target.startsWith("#") ? expandHashTarget(target, packageDir, config, seen) : target.startsWith(".") ? expandRelativeTarget(target, packageDir, config, seen) : null;
|
|
14004
|
+
if (expanded === null) return null;
|
|
14005
|
+
out.push(...expanded);
|
|
14006
|
+
}
|
|
14007
|
+
return out;
|
|
14008
|
+
}
|
|
14009
|
+
/**
|
|
14010
|
+
* Resolves pure package reexport targets for a module from config and/or source.
|
|
14011
|
+
*/
|
|
14012
|
+
function resolveModulePackageReexports(mod, packageDir, config) {
|
|
14013
|
+
if (moduleHasReexport(mod)) return expandToPackageReexportTargets(moduleReexportTargets(mod), packageDir, config);
|
|
14014
|
+
const file = moduleIndexSourcePath(packageDir, mod.name);
|
|
14015
|
+
if (!fs.existsSync(file)) return null;
|
|
14016
|
+
const targets = parsePureStarReexports(fs.readFileSync(file, "utf8"));
|
|
14017
|
+
if (targets === null) return null;
|
|
14018
|
+
return expandToPackageReexportTargets(targets, packageDir, config);
|
|
14019
|
+
}
|
|
14020
|
+
function walkMjs$1(dir, out = []) {
|
|
14021
|
+
if (!fs.existsSync(dir)) return out;
|
|
14022
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
14023
|
+
for (const entry of entries) {
|
|
14024
|
+
const fp = PATH.join(dir, entry.name);
|
|
14025
|
+
if (entry.isDirectory()) walkMjs$1(fp, out);
|
|
14026
|
+
else if (entry.name.endsWith(".mjs")) out.push(fp);
|
|
14027
|
+
}
|
|
14028
|
+
return out;
|
|
14029
|
+
}
|
|
14030
|
+
function writePureReexportMjs(filePath, targets) {
|
|
14031
|
+
fs.mkdirSync(PATH.dirname(filePath), { recursive: true });
|
|
14032
|
+
fs.writeFileSync(filePath, buildStarReexportLines(targets, { semi: true }));
|
|
14033
|
+
}
|
|
14034
|
+
function collectPackageTargetsByModule(packageDir, config) {
|
|
14035
|
+
const packageTargetsByModule = /* @__PURE__ */ new Map();
|
|
14036
|
+
for (const mod of config.modules) {
|
|
14037
|
+
if (!(mod.export ?? false) && !(mod.barrel ?? false)) continue;
|
|
14038
|
+
const targets = resolveModulePackageReexports(mod, packageDir, config);
|
|
14039
|
+
if (targets !== null && targets.length > 0) packageTargetsByModule.set(mod.name, targets);
|
|
14040
|
+
}
|
|
14041
|
+
return packageTargetsByModule;
|
|
14042
|
+
}
|
|
14043
|
+
function resolveBarrelModuleTargets(mod, packageDir, config, packageTargetsByModule) {
|
|
14044
|
+
const fromBarrel = normalizeReexportTargets(mod.barrelFrom);
|
|
14045
|
+
if (fromBarrel.length > 0) return expandToPackageReexportTargets(fromBarrel, packageDir, config);
|
|
14046
|
+
return packageTargetsByModule.get(mod.name) ?? null;
|
|
14047
|
+
}
|
|
14048
|
+
function resolveIndexPackageTargets(packageDir, config, packageTargetsByModule) {
|
|
14049
|
+
const barrelModules = config.modules.filter((mod) => mod.barrel ?? false).toSorted((a, b) => a.name.localeCompare(b.name));
|
|
14050
|
+
const indexTargets = [...config.barrelImports ?? []];
|
|
14051
|
+
for (const mod of barrelModules) {
|
|
14052
|
+
const moduleTargets = resolveBarrelModuleTargets(mod, packageDir, config, packageTargetsByModule);
|
|
14053
|
+
if (moduleTargets === null) return null;
|
|
14054
|
+
indexTargets.push(...moduleTargets);
|
|
14055
|
+
}
|
|
14056
|
+
return indexTargets;
|
|
14057
|
+
}
|
|
14058
|
+
function rewriteModuleReexportMjs(distDir, modulesPlatform, packageTargetsByModule) {
|
|
14059
|
+
let rewritten = 0;
|
|
14060
|
+
for (const [name, targets] of packageTargetsByModule) {
|
|
14061
|
+
const file = PATH.join(distDir, modulesPlatform, `${name}.mjs`);
|
|
14062
|
+
if (!fs.existsSync(file)) continue;
|
|
14063
|
+
writePureReexportMjs(file, targets);
|
|
14064
|
+
rewritten++;
|
|
14065
|
+
}
|
|
14066
|
+
return rewritten;
|
|
14067
|
+
}
|
|
14068
|
+
function rewriteIndexReexportMjs(distDir, platforms, indexTargets) {
|
|
14069
|
+
let rewritten = 0;
|
|
14070
|
+
for (const platform of platforms) {
|
|
14071
|
+
const file = PATH.join(distDir, platform, "index.mjs");
|
|
14072
|
+
if (!fs.existsSync(file)) continue;
|
|
14073
|
+
writePureReexportMjs(file, indexTargets);
|
|
14074
|
+
rewritten++;
|
|
14075
|
+
}
|
|
14076
|
+
for (const file of walkMjs$1(distDir)) {
|
|
14077
|
+
const base = PATH.basename(file);
|
|
14078
|
+
if (!base.startsWith("index") || !base.endsWith(".mjs") || base === "index.mjs") continue;
|
|
14079
|
+
writePureReexportMjs(file, indexTargets);
|
|
14080
|
+
rewritten++;
|
|
14081
|
+
}
|
|
14082
|
+
return rewritten;
|
|
14083
|
+
}
|
|
14084
|
+
/**
|
|
14085
|
+
* After esbuild, rewrite known pure package-facade entries to `export * from`
|
|
14086
|
+
* form. esbuild preserves star re-exports only on the entry file; multi-hop
|
|
14087
|
+
* `#module` chains become `__reExport` helpers that break Storybook/Vite
|
|
14088
|
+
* analysis. Returns the number of files rewritten.
|
|
14089
|
+
*/
|
|
14090
|
+
function flattenPurePackageReexportMjs(distDir, packageDir, config) {
|
|
14091
|
+
const modulesPlatform = config.modulesPlatform ?? "neutral";
|
|
14092
|
+
const platforms = config.platforms ?? [
|
|
14093
|
+
"neutral",
|
|
14094
|
+
"node",
|
|
14095
|
+
"browser"
|
|
14096
|
+
];
|
|
14097
|
+
const packageTargetsByModule = collectPackageTargetsByModule(packageDir, config);
|
|
14098
|
+
let rewritten = rewriteModuleReexportMjs(distDir, modulesPlatform, packageTargetsByModule);
|
|
14099
|
+
const indexTargets = resolveIndexPackageTargets(packageDir, config, packageTargetsByModule);
|
|
14100
|
+
if (indexTargets !== null && indexTargets.length > 0) rewritten += rewriteIndexReexportMjs(distDir, platforms, indexTargets);
|
|
14101
|
+
return rewritten;
|
|
14102
|
+
}
|
|
14103
|
+
//#endregion
|
|
13777
14104
|
//#region src/actions/package/compile/monolithCompileLayout.ts
|
|
13778
14105
|
/**
|
|
13779
14106
|
* Layout generation for `compile.mode: 'monolith'` — a 1:1 port of the
|
|
@@ -13880,10 +14207,7 @@ function buildIndexTs(modules, config) {
|
|
|
13880
14207
|
const hasConditional = Object.keys(config.conditionalImports ?? {}).length > 0;
|
|
13881
14208
|
const barrelModules = modules.filter((mod) => mod.barrel ?? false).toSorted((a, b) => a.name.localeCompare(b.name));
|
|
13882
14209
|
const lines = (config.barrelImports ?? []).map((spec) => `export * from '${spec}'`);
|
|
13883
|
-
for (const mod of barrelModules) {
|
|
13884
|
-
const target = mod.barrelFrom ?? `#${mod.name}`;
|
|
13885
|
-
lines.push(`export * from '${target}'`);
|
|
13886
|
-
}
|
|
14210
|
+
for (const mod of barrelModules) for (const target of moduleBarrelTargets(mod)) lines.push(`export * from '${target}'`);
|
|
13887
14211
|
return `${GENERATED_HEADER}${hasConditional ? "/* eslint-disable @typescript-eslint/ban-ts-comment -- conditional package imports */\n// @ts-nocheck\n" : ""}${lines.join("\n")}
|
|
13888
14212
|
`;
|
|
13889
14213
|
}
|
|
@@ -13893,9 +14217,11 @@ function buildModelTs(modules) {
|
|
|
13893
14217
|
`;
|
|
13894
14218
|
}
|
|
13895
14219
|
function buildModuleShim(mod) {
|
|
13896
|
-
|
|
13897
|
-
|
|
13898
|
-
|
|
14220
|
+
return `${GENERATED_HEADER}${buildStarReexportLines(moduleShimTargets(mod), { semi: false })}`;
|
|
14221
|
+
}
|
|
14222
|
+
/** Generated module body for facade modules with `reexport` targets. */
|
|
14223
|
+
function buildModuleReexportIndex(mod) {
|
|
14224
|
+
return `${GENERATED_HEADER}${buildStarReexportLines(moduleReexportTargets(mod), { semi: false })}`;
|
|
13899
14225
|
}
|
|
13900
14226
|
function buildModelShim(mod) {
|
|
13901
14227
|
return `${GENERATED_HEADER}export type * from '#${mod.name}/model'
|
|
@@ -13960,6 +14286,7 @@ function syncMonolithLayout(packageDir, config, options = {}) {
|
|
|
13960
14286
|
if (!(config.index?.custom ?? false)) writeOrCheck(PATH.join(packageDir, "src/index.ts"), buildIndexTs(modules, config));
|
|
13961
14287
|
if (monolithHasModelBarrel(config)) writeOrCheck(PATH.join(packageDir, "src/model.ts"), buildModelTs(modules));
|
|
13962
14288
|
for (const mod of modules) {
|
|
14289
|
+
if (moduleHasReexport(mod)) writeOrCheck(PATH.join(packageDir, "src", "modules", mod.name, "index.ts"), buildModuleReexportIndex(mod));
|
|
13963
14290
|
if (!(mod.export ?? false)) continue;
|
|
13964
14291
|
writeOrCheck(PATH.join(packageDir, `src/${mod.name}.ts`), buildModuleShim(mod));
|
|
13965
14292
|
if (mod.model ?? false) writeOrCheck(PATH.join(packageDir, `src/${mod.name}.model.ts`), buildModelShim(mod));
|
|
@@ -14122,15 +14449,14 @@ function moduleShimEntries(mod, isDirectIndex, isExternal) {
|
|
|
14122
14449
|
return shims;
|
|
14123
14450
|
}
|
|
14124
14451
|
/**
|
|
14125
|
-
*
|
|
14126
|
-
*
|
|
14127
|
-
*
|
|
14128
|
-
*
|
|
14129
|
-
* re-export its own output — compile the default source directly instead.
|
|
14452
|
+
* Prefer compiling `modules/<name>/index.ts` directly when star re-exports
|
|
14453
|
+
* must stay as `export * from` on the entry (esbuild lowers multi-hop stars
|
|
14454
|
+
* into `__reExport` helpers). Used for external linkage, facade `reexport`
|
|
14455
|
+
* modules, and pure package facades that would otherwise hop through shims.
|
|
14130
14456
|
*/
|
|
14131
14457
|
function modulesPlatformEntries(mod, config, isExternal, modulesPlatform) {
|
|
14132
14458
|
const conditional = config.conditionalImports?.[mod.name];
|
|
14133
|
-
let isDirectIndex = isExternal && conditional === void 0;
|
|
14459
|
+
let isDirectIndex = (isExternal || moduleHasReexport(mod)) && conditional === void 0;
|
|
14134
14460
|
let directIn = `./modules/${mod.name}/index.ts`;
|
|
14135
14461
|
if (isExternal && conditional?.distImports?.default === `./dist/${modulesPlatform}/${mod.name}.mjs`) {
|
|
14136
14462
|
isDirectIndex = true;
|
|
@@ -14168,12 +14494,14 @@ function platformShimEntry(platform, name, target, isExternal) {
|
|
|
14168
14494
|
* a conditional `#import` skip the modules-platform entry — the subpath
|
|
14169
14495
|
* shim already resolves the default condition.
|
|
14170
14496
|
*
|
|
14171
|
-
* With `moduleLinkage: 'external'`
|
|
14172
|
-
* the generated one-line shims and target the module files
|
|
14173
|
-
* `{in, out}` pairs: esbuild only preserves
|
|
14174
|
-
* when it appears in the entry file itself — routed
|
|
14175
|
-
* re-export
|
|
14176
|
-
* remain the tsc declaration sources for the same dist names.
|
|
14497
|
+
* With `moduleLinkage: 'external'` or module `reexport` facades, subpath
|
|
14498
|
+
* entries bypass the generated one-line shims and target the module files
|
|
14499
|
+
* directly via `{in, out}` pairs: esbuild only preserves
|
|
14500
|
+
* `export * from '…'` when it appears in the entry file itself — routed
|
|
14501
|
+
* through an intermediate re-export the star is lowered to `__reExport`
|
|
14502
|
+
* helpers. Shims remain the tsc declaration sources for the same dist names.
|
|
14503
|
+
* After esbuild, pure package-facade graphs are also flattened in
|
|
14504
|
+
* {@link flattenPurePackageReexportMjs} so multi-hop barrels stay clean.
|
|
14177
14505
|
*/
|
|
14178
14506
|
function buildMonolithEntries(config) {
|
|
14179
14507
|
const { conditionalImports = {}, modules, platformEntries = {} } = config;
|
|
@@ -14281,9 +14609,12 @@ const packageCompileMonolith = async (config, mode = {}) => {
|
|
|
14281
14609
|
if (!shouldEmit) return 0;
|
|
14282
14610
|
const compileResult = await packageCompileEsbuild(deriveEsbuildConfig(config, compile, monolith), { emitOnly: true });
|
|
14283
14611
|
if (compileResult !== 0) return compileResult;
|
|
14284
|
-
const
|
|
14612
|
+
const distDir = PATH.join(packageDir, "dist");
|
|
14613
|
+
const flattened = flattenPurePackageReexportMjs(distDir, packageDir, monolith);
|
|
14614
|
+
if (isVerbose && flattened > 0) console.log(chalk.gray(`monolith pure reexport flatten: ${flattened} files`));
|
|
14615
|
+
const rewritten = fixMonolithDeclarations(distDir, monolith);
|
|
14285
14616
|
if (isVerbose) console.log(chalk.gray(`monolith declaration fixups: ${rewritten} files`));
|
|
14286
|
-
const specifierProblems = verifyMonolithRuntimeSpecifiers(
|
|
14617
|
+
const specifierProblems = verifyMonolithRuntimeSpecifiers(distDir, monolith);
|
|
14287
14618
|
if (specifierProblems.length > 0) {
|
|
14288
14619
|
for (const problem of specifierProblems) console.error(chalk.red(problem));
|
|
14289
14620
|
return 1;
|
|
@@ -14865,6 +15196,10 @@ const ALL_PUBLINT_CHECKS = [
|
|
|
14865
15196
|
"source",
|
|
14866
15197
|
"types"
|
|
14867
15198
|
];
|
|
15199
|
+
function publintRuleId$1(check) {
|
|
15200
|
+
return `pub.${check}`;
|
|
15201
|
+
}
|
|
15202
|
+
ALL_PUBLINT_CHECKS.map(publintRuleId$1);
|
|
14868
15203
|
/** Checks that only apply to published (non-private) packages */
|
|
14869
15204
|
const PUBLISH_ONLY_CHECKS = [
|
|
14870
15205
|
"defaultExportOrder",
|
|
@@ -15755,9 +16090,19 @@ const PUBLINT_RULE_LEVELS = /* @__PURE__ */ new Set([
|
|
|
15755
16090
|
"off",
|
|
15756
16091
|
"warn"
|
|
15757
16092
|
]);
|
|
16093
|
+
const PUBLINT_RULE_PREFIX = "pub.";
|
|
16094
|
+
const deprecatedPublintRuleWarnings = /* @__PURE__ */ new Set();
|
|
15758
16095
|
function defaultPublintLevel(check) {
|
|
15759
16096
|
return check === "platform" || check === "publint" ? "error" : "warn";
|
|
15760
16097
|
}
|
|
16098
|
+
function publintRuleId(check) {
|
|
16099
|
+
return `${PUBLINT_RULE_PREFIX}${check}`;
|
|
16100
|
+
}
|
|
16101
|
+
function warnDeprecatedPublintRuleName(ruleName) {
|
|
16102
|
+
if (deprecatedPublintRuleWarnings.has(ruleName)) return;
|
|
16103
|
+
deprecatedPublintRuleWarnings.add(ruleName);
|
|
16104
|
+
console.warn(`Deprecated: commands.publint.rules["${ruleName}"] is deprecated; use commands.publint.rules["${publintRuleId(ruleName)}"] instead.`);
|
|
16105
|
+
}
|
|
15761
16106
|
function normalizePublintConfig$2(value) {
|
|
15762
16107
|
if (typeof value === "object") return value;
|
|
15763
16108
|
return {};
|
|
@@ -15765,6 +16110,11 @@ function normalizePublintConfig$2(value) {
|
|
|
15765
16110
|
function isPublintCheckName(value) {
|
|
15766
16111
|
return ALL_PUBLINT_CHECKS.includes(value);
|
|
15767
16112
|
}
|
|
16113
|
+
function normalizePublintRuleName(location, value) {
|
|
16114
|
+
const bareName = value.startsWith(PUBLINT_RULE_PREFIX) ? value.slice(4) : value;
|
|
16115
|
+
if (!isPublintCheckName(bareName)) throw new TypeError(`Unknown publint rule "${value}" in ${location}`);
|
|
16116
|
+
return bareName;
|
|
16117
|
+
}
|
|
15768
16118
|
function isRuleLevel(value) {
|
|
15769
16119
|
return typeof value === "string" && PUBLINT_RULE_LEVELS.has(value);
|
|
15770
16120
|
}
|
|
@@ -15784,10 +16134,7 @@ function parseRuleLevel(location, value) {
|
|
|
15784
16134
|
throw new TypeError(`${location} must be "error", "warn", "off", boolean, [level, options], or { level?, enabled? }`);
|
|
15785
16135
|
}
|
|
15786
16136
|
function normalizePublintRuleNames(location, values) {
|
|
15787
|
-
return (values ?? []).map((value) =>
|
|
15788
|
-
if (!isPublintCheckName(value)) throw new TypeError(`Unknown publint check "${value}" in ${location}`);
|
|
15789
|
-
return value;
|
|
15790
|
-
});
|
|
16137
|
+
return (values ?? []).map((value) => normalizePublintRuleName(location, value));
|
|
15791
16138
|
}
|
|
15792
16139
|
function defaultLevels() {
|
|
15793
16140
|
return new Map(ALL_PUBLINT_CHECKS.map((check) => [check, defaultPublintLevel(check)]));
|
|
@@ -15808,9 +16155,19 @@ function applyExcluded(levels, explicit, exclude) {
|
|
|
15808
16155
|
for (const check of exclude) setRuleLevel(levels, explicit, check, "off");
|
|
15809
16156
|
}
|
|
15810
16157
|
function applyConfiguredRules(levels, explicit, rules) {
|
|
15811
|
-
|
|
15812
|
-
|
|
15813
|
-
|
|
16158
|
+
const configuredRules = Object.entries(rules ?? {});
|
|
16159
|
+
const canonicalRuleIds = new Set(configuredRules.map(([ruleId]) => ruleId).filter((ruleId) => ruleId.startsWith(PUBLINT_RULE_PREFIX)));
|
|
16160
|
+
for (const [check, setting] of configuredRules) {
|
|
16161
|
+
if (check.startsWith(PUBLINT_RULE_PREFIX)) continue;
|
|
16162
|
+
const ruleName = normalizePublintRuleName("commands.publint.rules", check);
|
|
16163
|
+
if (canonicalRuleIds.has(publintRuleId(ruleName))) continue;
|
|
16164
|
+
warnDeprecatedPublintRuleName(ruleName);
|
|
16165
|
+
setRuleLevel(levels, explicit, ruleName, parseRuleLevel(`commands.publint.rules["${publintRuleId(ruleName)}"]`, setting));
|
|
16166
|
+
}
|
|
16167
|
+
for (const [ruleId, setting] of configuredRules) {
|
|
16168
|
+
if (!ruleId.startsWith(PUBLINT_RULE_PREFIX)) continue;
|
|
16169
|
+
const check = normalizePublintRuleName("commands.publint.rules", ruleId);
|
|
16170
|
+
setRuleLevel(levels, explicit, check, parseRuleLevel(`commands.publint.rules["${publintRuleId(check)}"]`, setting));
|
|
15814
16171
|
}
|
|
15815
16172
|
}
|
|
15816
16173
|
function resolvePublintRules(value, cliExclude, cliInclude) {
|
|
@@ -15819,9 +16176,9 @@ function resolvePublintRules(value, cliExclude, cliInclude) {
|
|
|
15819
16176
|
const configInclude = normalizePublintRuleNames("commands.publint.include", config.include);
|
|
15820
16177
|
const normalizedCliExclude = normalizePublintRuleNames("--exclude", cliExclude);
|
|
15821
16178
|
const normalizedCliInclude = normalizePublintRuleNames("--include", cliInclude);
|
|
16179
|
+
if ((configExclude.length > 0 || normalizedCliExclude.length > 0) && (configInclude.length > 0 || normalizedCliInclude.length > 0)) throw new TypeError("Publint: --include and --exclude cannot be used together");
|
|
15822
16180
|
const levels = defaultLevels();
|
|
15823
16181
|
const explicit = /* @__PURE__ */ new Set();
|
|
15824
|
-
if ((configExclude.length > 0 || normalizedCliExclude.length > 0) && (configInclude.length > 0 || normalizedCliInclude.length > 0)) throw new TypeError("Publint: --include and --exclude cannot be used together");
|
|
15825
16182
|
applyIncludedOnly(levels, explicit, configInclude);
|
|
15826
16183
|
applyExcluded(levels, explicit, configExclude);
|
|
15827
16184
|
applyConfiguredRules(levels, explicit, config.rules);
|