@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.
Files changed (103) hide show
  1. package/dist/actions/api-exposure/apiExposure.d.ts.map +1 -1
  2. package/dist/actions/api-exposure/config.d.ts.map +1 -1
  3. package/dist/actions/api-exposure/types.d.ts +3 -0
  4. package/dist/actions/api-exposure/types.d.ts.map +1 -1
  5. package/dist/actions/deplint/packageJsonEditor.d.ts +1 -1
  6. package/dist/actions/deplint/ruleConfig.d.ts.map +1 -1
  7. package/dist/actions/deplint/types.d.ts +1 -1
  8. package/dist/actions/gitlint-fix.d.ts +2 -1
  9. package/dist/actions/gitlint-fix.d.ts.map +1 -1
  10. package/dist/actions/gitlint.d.ts +5 -1
  11. package/dist/actions/gitlint.d.ts.map +1 -1
  12. package/dist/actions/index.d.ts +2 -0
  13. package/dist/actions/index.d.ts.map +1 -1
  14. package/dist/actions/lintlint.d.ts +32 -1
  15. package/dist/actions/lintlint.d.ts.map +1 -1
  16. package/dist/actions/node-lint.d.ts +8 -1
  17. package/dist/actions/node-lint.d.ts.map +1 -1
  18. package/dist/actions/package/compile/ApiExposureConfig.d.ts +9 -2
  19. package/dist/actions/package/compile/ApiExposureConfig.d.ts.map +1 -1
  20. package/dist/actions/package/compile/MonolithConfig.d.ts +46 -4
  21. package/dist/actions/package/compile/MonolithConfig.d.ts.map +1 -1
  22. package/dist/actions/package/compile/PublintConfig.d.ts +43 -0
  23. package/dist/actions/package/compile/PublintConfig.d.ts.map +1 -0
  24. package/dist/actions/package/compile/RuleLevelConfig.d.ts +7 -0
  25. package/dist/actions/package/compile/RuleLevelConfig.d.ts.map +1 -0
  26. package/dist/actions/package/compile/XyConfig.d.ts +45 -38
  27. package/dist/actions/package/compile/XyConfig.d.ts.map +1 -1
  28. package/dist/actions/package/compile/index.d.ts +1 -0
  29. package/dist/actions/package/compile/index.d.ts.map +1 -1
  30. package/dist/actions/package/compile/monolithCompileEntries.d.ts +8 -6
  31. package/dist/actions/package/compile/monolithCompileEntries.d.ts.map +1 -1
  32. package/dist/actions/package/compile/monolithCompileLayout.d.ts +2 -0
  33. package/dist/actions/package/compile/monolithCompileLayout.d.ts.map +1 -1
  34. package/dist/actions/package/compile/monolithReexport.d.ts +45 -0
  35. package/dist/actions/package/compile/monolithReexport.d.ts.map +1 -0
  36. package/dist/actions/package/compile/packageCompileMonolith.d.ts.map +1 -1
  37. package/dist/actions/package/index.d.ts +1 -0
  38. package/dist/actions/package/index.d.ts.map +1 -1
  39. package/dist/actions/package/publint.d.ts +3 -1
  40. package/dist/actions/package/publint.d.ts.map +1 -1
  41. package/dist/actions/package/publintRules.d.ts +13 -0
  42. package/dist/actions/package/publintRules.d.ts.map +1 -0
  43. package/dist/actions/package-lint.d.ts +2 -1
  44. package/dist/actions/package-lint.d.ts.map +1 -1
  45. package/dist/actions/packman/lint.d.ts +16 -1
  46. package/dist/actions/packman/lint.d.ts.map +1 -1
  47. package/dist/actions/publint.d.ts.map +1 -1
  48. package/dist/actions/ruleCatalog.d.ts +42 -0
  49. package/dist/actions/ruleCatalog.d.ts.map +1 -0
  50. package/dist/actions/ruleRunner.d.ts +63 -0
  51. package/dist/actions/ruleRunner.d.ts.map +1 -0
  52. package/dist/actions/skills/lint.d.ts +16 -1
  53. package/dist/actions/skills/lint.d.ts.map +1 -1
  54. package/dist/bin/package/build.mjs +609 -101
  55. package/dist/bin/package/build.mjs.map +1 -1
  56. package/dist/bin/package/compile.mjs +257 -25
  57. package/dist/bin/package/compile.mjs.map +1 -1
  58. package/dist/bin/package/publint.mjs +352 -76
  59. package/dist/bin/package/publint.mjs.map +1 -1
  60. package/dist/bin/package/recompile.mjs +257 -25
  61. package/dist/bin/package/recompile.mjs.map +1 -1
  62. package/dist/bin/package/sync-layout.mjs +48 -8
  63. package/dist/bin/package/sync-layout.mjs.map +1 -1
  64. package/dist/bin/xy.mjs +8326 -836
  65. package/dist/bin/xy.mjs.map +1 -1
  66. package/dist/lib/index.d.ts +1 -0
  67. package/dist/lib/index.d.ts.map +1 -1
  68. package/dist/lib/loadConfig.d.ts +1 -0
  69. package/dist/lib/loadConfig.d.ts.map +1 -1
  70. package/dist/lib/ruleCommandRegistry.d.ts +100 -0
  71. package/dist/lib/ruleCommandRegistry.d.ts.map +1 -0
  72. package/dist/xy/common/checkCommand.d.ts.map +1 -1
  73. package/dist/xy/common/deadCommand.d.ts.map +1 -1
  74. package/dist/xy/common/gitCommand.d.ts +3 -0
  75. package/dist/xy/common/gitCommand.d.ts.map +1 -0
  76. package/dist/xy/common/gitlintCommand.d.ts +2 -0
  77. package/dist/xy/common/gitlintCommand.d.ts.map +1 -1
  78. package/dist/xy/common/index.d.ts.map +1 -1
  79. package/dist/xy/common/packmanCommand.d.ts.map +1 -1
  80. package/dist/xy/common/repo/lintCommand.d.ts.map +1 -1
  81. package/dist/xy/common/skills/index.d.ts.map +1 -1
  82. package/dist/xy/deprecatedCommand.d.ts +2 -0
  83. package/dist/xy/deprecatedCommand.d.ts.map +1 -0
  84. package/dist/xy/lint/apiExposureCommand.d.ts.map +1 -1
  85. package/dist/xy/lint/cycleCommand.d.ts.map +1 -1
  86. package/dist/xy/lint/deplintCommand.d.ts.map +1 -1
  87. package/dist/xy/lint/fixCommand.d.ts.map +1 -1
  88. package/dist/xy/lint/index.d.ts.map +1 -1
  89. package/dist/xy/lint/lint/index.d.ts.map +1 -1
  90. package/dist/xy/lint/lint/runCommand.d.ts.map +1 -1
  91. package/dist/xy/lint/lintlintCommand.d.ts +2 -0
  92. package/dist/xy/lint/lintlintCommand.d.ts.map +1 -1
  93. package/dist/xy/lint/nodeCommand.d.ts +3 -0
  94. package/dist/xy/lint/nodeCommand.d.ts.map +1 -0
  95. package/dist/xy/lint/nodeLintCommand.d.ts +2 -0
  96. package/dist/xy/lint/nodeLintCommand.d.ts.map +1 -1
  97. package/dist/xy/lint/publintCommand.d.ts.map +1 -1
  98. package/dist/xy/lint/relintCommand.d.ts.map +1 -1
  99. package/dist/xy/lint/republintCommand.d.ts.map +1 -1
  100. package/dist/xy/xy.d.ts +3 -10
  101. package/dist/xy/xy.d.ts.map +1 -1
  102. package/dist/xy/xyParseOptions.d.ts.map +1 -1
  103. package/package.json +5 -4
@@ -9661,8 +9661,8 @@ var require_ExplorerSync = /* @__PURE__ */ __commonJSMin(((exports) => {
9661
9661
  exports.ExplorerSync = ExplorerSync;
9662
9662
  }));
9663
9663
  //#endregion
9664
- //#region src/lib/loadConfig.ts
9665
- var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
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 fromCommands = cfg.commands?.[commandName];
9852
- if (fromCommands !== void 0 && typeof fromCommands === "object") return fromCommands;
9853
- const fromTopLevel = cfg[commandName];
9854
- if (fromTopLevel !== void 0 && typeof fromTopLevel === "object" && DEPRECATED_COMMAND_FIELDS.has(commandName)) {
9855
- const key = `${configPath ?? "unknown"}:${commandName}`;
9856
- if (!deprecationWarned.has(key)) {
9857
- deprecationWarned.add(key);
9858
- console.warn(chalk.yellow(`[xy] Deprecated: top-level "${commandName}" in ${configPath ?? "xy.config"} — move to "commands.${commandName}"`));
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 {};
@@ -9869,14 +9982,15 @@ function mergeRuleConfigs(target, source) {
9869
9982
  return source;
9870
9983
  }
9871
9984
  function mergeCommandConfig(rootCmd, workspaceCmd, commandName) {
9872
- return deepMerge$1(rootCmd, workspaceCmd, { customMerge: (key) => (commandName === "deplint" || commandName === "dead") && key === "rules" ? mergeRuleConfigs : void 0 });
9985
+ const configKey = canonicalRuleConfigKey(commandName);
9986
+ return deepMerge$1(rootCmd, workspaceCmd, { customMerge: (key) => RULE_CONFIG_COMMAND_KEYS.has(configKey) && key === "rules" ? mergeRuleConfigs : void 0 });
9873
9987
  }
9874
9988
  /**
9875
9989
  * Loads a command-specific config merged from root and workspace levels.
9876
9990
  * The root config provides defaults; the workspace config extends/overrides.
9877
9991
  * Arrays (e.g. `exclude`) are unioned and maps (e.g. `packages`) are merged
9878
9992
  * via deepmerge, with workspace entries overriding root entries for the same key.
9879
- * Deplint rule entries are replaced per rule id so tuple configs keep their
9993
+ * Rule entries are replaced per rule id so tuple configs keep their
9880
9994
  * ESLint-like shape instead of being concatenated as arrays.
9881
9995
  */
9882
9996
  /**
@@ -9892,8 +10006,9 @@ function isWorkspaceUnderRootConfig(workspaceDir) {
9892
10006
  return relative === "" || !relative.startsWith("..") && !PATH.isAbsolute(relative);
9893
10007
  }
9894
10008
  async function loadWorkspaceCommandConfig(workspaceDir, commandName) {
10009
+ const configKey = canonicalRuleConfigKey(commandName);
9895
10010
  const root = await loadConfig();
9896
- return mergeCommandConfig(isWorkspaceUnderRootConfig(workspaceDir) ? resolveCommandField(root, commandName, configState.rootConfigPath) : {}, resolveCommandField(await loadWorkspaceConfig(workspaceDir), commandName, workspaceConfigCache.has(workspaceDir) ? workspaceDir : void 0), commandName);
10011
+ return mergeCommandConfig(isWorkspaceUnderRootConfig(workspaceDir) ? resolveCommandField(root, configKey, configState.rootConfigPath) : {}, resolveCommandField(await loadWorkspaceConfig(workspaceDir), configKey, workspaceConfigCache.has(workspaceDir) ? workspaceDir : void 0), configKey);
9897
10012
  }
9898
10013
  //#endregion
9899
10014
  //#region ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
@@ -13762,6 +13877,230 @@ const packageCompileEsbuild = async (config, mode = {}) => {
13762
13877
  return nodeErrors + browserErrors + neutralErrors;
13763
13878
  };
13764
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
13765
14104
  //#region src/actions/package/compile/monolithCompileLayout.ts
13766
14105
  /**
13767
14106
  * Layout generation for `compile.mode: 'monolith'` — a 1:1 port of the
@@ -13868,10 +14207,7 @@ function buildIndexTs(modules, config) {
13868
14207
  const hasConditional = Object.keys(config.conditionalImports ?? {}).length > 0;
13869
14208
  const barrelModules = modules.filter((mod) => mod.barrel ?? false).toSorted((a, b) => a.name.localeCompare(b.name));
13870
14209
  const lines = (config.barrelImports ?? []).map((spec) => `export * from '${spec}'`);
13871
- for (const mod of barrelModules) {
13872
- const target = mod.barrelFrom ?? `#${mod.name}`;
13873
- lines.push(`export * from '${target}'`);
13874
- }
14210
+ for (const mod of barrelModules) for (const target of moduleBarrelTargets(mod)) lines.push(`export * from '${target}'`);
13875
14211
  return `${GENERATED_HEADER}${hasConditional ? "/* eslint-disable @typescript-eslint/ban-ts-comment -- conditional package imports */\n// @ts-nocheck\n" : ""}${lines.join("\n")}
13876
14212
  `;
13877
14213
  }
@@ -13881,9 +14217,11 @@ function buildModelTs(modules) {
13881
14217
  `;
13882
14218
  }
13883
14219
  function buildModuleShim(mod) {
13884
- const target = mod.shimFrom ?? `#${mod.name}`;
13885
- return `${GENERATED_HEADER}export * from '${target}'
13886
- `;
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 })}`;
13887
14225
  }
13888
14226
  function buildModelShim(mod) {
13889
14227
  return `${GENERATED_HEADER}export type * from '#${mod.name}/model'
@@ -13945,9 +14283,10 @@ function syncMonolithLayout(packageDir, config, options = {}) {
13945
14283
  paths: buildTsconfigPaths(modules, config)
13946
14284
  };
13947
14285
  writeOrCheck(tsconfigPath, `${JSON.stringify(tsconfig, null, 2)}\n`);
13948
- writeOrCheck(PATH.join(packageDir, "src/index.ts"), buildIndexTs(modules, config));
14286
+ if (!(config.index?.custom ?? false)) writeOrCheck(PATH.join(packageDir, "src/index.ts"), buildIndexTs(modules, config));
13949
14287
  if (monolithHasModelBarrel(config)) writeOrCheck(PATH.join(packageDir, "src/model.ts"), buildModelTs(modules));
13950
14288
  for (const mod of modules) {
14289
+ if (moduleHasReexport(mod)) writeOrCheck(PATH.join(packageDir, "src", "modules", mod.name, "index.ts"), buildModuleReexportIndex(mod));
13951
14290
  if (!(mod.export ?? false)) continue;
13952
14291
  writeOrCheck(PATH.join(packageDir, `src/${mod.name}.ts`), buildModuleShim(mod));
13953
14292
  if (mod.model ?? false) writeOrCheck(PATH.join(packageDir, `src/${mod.name}.model.ts`), buildModelShim(mod));
@@ -14110,15 +14449,14 @@ function moduleShimEntries(mod, isDirectIndex, isExternal) {
14110
14449
  return shims;
14111
14450
  }
14112
14451
  /**
14113
- * Modules-platform entries for one exported module. Conditional modules
14114
- * normally keep the shim entry in external mode: the shim's retained `#`
14115
- * re-export funnels through distImports. But when the conditional's default
14116
- * condition targets the modules-platform file itself, that shim would
14117
- * 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.
14118
14456
  */
14119
14457
  function modulesPlatformEntries(mod, config, isExternal, modulesPlatform) {
14120
14458
  const conditional = config.conditionalImports?.[mod.name];
14121
- let isDirectIndex = isExternal && conditional === void 0;
14459
+ let isDirectIndex = (isExternal || moduleHasReexport(mod)) && conditional === void 0;
14122
14460
  let directIn = `./modules/${mod.name}/index.ts`;
14123
14461
  if (isExternal && conditional?.distImports?.default === `./dist/${modulesPlatform}/${mod.name}.mjs`) {
14124
14462
  isDirectIndex = true;
@@ -14131,10 +14469,14 @@ function modulesPlatformEntries(mod, config, isExternal, modulesPlatform) {
14131
14469
  };
14132
14470
  return shims;
14133
14471
  }
14472
+ /** Master barrel entry for a platform (`index.entries` override or `./index.ts`). */
14473
+ function masterBarrelEntry(config, platform) {
14474
+ return config.index?.entries?.[platform] ?? "./index.ts";
14475
+ }
14134
14476
  function initialBarrelEntries(config, platforms, modulesPlatform, barrelPlatforms) {
14135
14477
  const entries = {};
14136
- for (const platform of platforms) entries[platform] = barrelPlatforms.has(platform) ? ["./index.ts"] : [];
14137
- entries[modulesPlatform] ??= barrelPlatforms.has(modulesPlatform) ? ["./index.ts"] : [];
14478
+ for (const platform of platforms) entries[platform] = barrelPlatforms.has(platform) ? [masterBarrelEntry(config, platform)] : [];
14479
+ entries[modulesPlatform] ??= barrelPlatforms.has(modulesPlatform) ? [masterBarrelEntry(config, modulesPlatform)] : [];
14138
14480
  if (monolithHasModelBarrel(config)) entries[modulesPlatform].push("./model.ts");
14139
14481
  return entries;
14140
14482
  }
@@ -14152,12 +14494,14 @@ function platformShimEntry(platform, name, target, isExternal) {
14152
14494
  * a conditional `#import` skip the modules-platform entry — the subpath
14153
14495
  * shim already resolves the default condition.
14154
14496
  *
14155
- * With `moduleLinkage: 'external'` the subpath and platform entries bypass
14156
- * the generated one-line shims and target the module files directly via
14157
- * `{in, out}` pairs: esbuild only preserves `export * from '#external'`
14158
- * when it appears in the entry file itself — routed through an intermediate
14159
- * re-export file the star export is silently lost in ESM output. The shims
14160
- * 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.
14161
14505
  */
14162
14506
  function buildMonolithEntries(config) {
14163
14507
  const { conditionalImports = {}, modules, platformEntries = {} } = config;
@@ -14172,7 +14516,7 @@ function buildMonolithEntries(config) {
14172
14516
  entries[modulesPlatform].push(...modulesPlatformEntries(mod, config, isExternal, modulesPlatform));
14173
14517
  }
14174
14518
  for (const [platform, platformEntryMap] of Object.entries(platformEntries)) {
14175
- entries[platform] ??= barrelPlatforms.has(platform) ? ["./index.ts"] : [];
14519
+ entries[platform] ??= barrelPlatforms.has(platform) ? [masterBarrelEntry(config, platform)] : [];
14176
14520
  for (const [name, target] of Object.entries(platformEntryMap)) if (platform !== modulesPlatform || !exportedConditional.has(name)) entries[platform].push(platformShimEntry(platform, name, target, isExternal));
14177
14521
  }
14178
14522
  return entries;
@@ -14265,9 +14609,12 @@ const packageCompileMonolith = async (config, mode = {}) => {
14265
14609
  if (!shouldEmit) return 0;
14266
14610
  const compileResult = await packageCompileEsbuild(deriveEsbuildConfig(config, compile, monolith), { emitOnly: true });
14267
14611
  if (compileResult !== 0) return compileResult;
14268
- const rewritten = fixMonolithDeclarations(PATH.join(packageDir, "dist"), monolith);
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);
14269
14616
  if (isVerbose) console.log(chalk.gray(`monolith declaration fixups: ${rewritten} files`));
14270
- const specifierProblems = verifyMonolithRuntimeSpecifiers(PATH.join(packageDir, "dist"), monolith);
14617
+ const specifierProblems = verifyMonolithRuntimeSpecifiers(distDir, monolith);
14271
14618
  if (specifierProblems.length > 0) {
14272
14619
  for (const problem of specifierProblems) console.error(chalk.red(problem));
14273
14620
  return 1;
@@ -14830,7 +15177,7 @@ const packageCompile = async (inConfig = {}, mode = {}) => {
14830
15177
  return await packageCompileEsbuild(config, mode);
14831
15178
  };
14832
15179
  //#endregion
14833
- //#region src/actions/package/compile/XyConfig.ts
15180
+ //#region src/actions/package/compile/PublintConfig.ts
14834
15181
  const ALL_PUBLINT_CHECKS = [
14835
15182
  "compileTargets",
14836
15183
  "defaultExportOrder",
@@ -14849,6 +15196,10 @@ const ALL_PUBLINT_CHECKS = [
14849
15196
  "source",
14850
15197
  "types"
14851
15198
  ];
15199
+ function publintRuleId$1(check) {
15200
+ return `pub.${check}`;
15201
+ }
15202
+ ALL_PUBLINT_CHECKS.map(publintRuleId$1);
14852
15203
  /** Checks that only apply to published (non-private) packages */
14853
15204
  const PUBLISH_ONLY_CHECKS = [
14854
15205
  "defaultExportOrder",
@@ -15733,6 +16084,118 @@ async function checkPlatform(pkgDir, pkg, shouldFix = false) {
15733
16084
  return result;
15734
16085
  }
15735
16086
  //#endregion
16087
+ //#region src/actions/package/publintRules.ts
16088
+ const PUBLINT_RULE_LEVELS = /* @__PURE__ */ new Set([
16089
+ "error",
16090
+ "off",
16091
+ "warn"
16092
+ ]);
16093
+ const PUBLINT_RULE_PREFIX = "pub.";
16094
+ const deprecatedPublintRuleWarnings = /* @__PURE__ */ new Set();
16095
+ function defaultPublintLevel(check) {
16096
+ return check === "platform" || check === "publint" ? "error" : "warn";
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
+ }
16106
+ function normalizePublintConfig$2(value) {
16107
+ if (typeof value === "object") return value;
16108
+ return {};
16109
+ }
16110
+ function isPublintCheckName(value) {
16111
+ return ALL_PUBLINT_CHECKS.includes(value);
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
+ }
16118
+ function isRuleLevel(value) {
16119
+ return typeof value === "string" && PUBLINT_RULE_LEVELS.has(value);
16120
+ }
16121
+ function candidateRuleLevelValue(value) {
16122
+ if (Array.isArray(value) && value.length > 0) return value[0];
16123
+ if (typeof value === "object" && value !== null) {
16124
+ const record = value;
16125
+ return record.level ?? record.enabled;
16126
+ }
16127
+ return value;
16128
+ }
16129
+ function parseRuleLevel(location, value) {
16130
+ const candidate = candidateRuleLevelValue(value);
16131
+ if (candidate === true) return "warn";
16132
+ if (candidate === false) return "off";
16133
+ if (isRuleLevel(candidate)) return candidate;
16134
+ throw new TypeError(`${location} must be "error", "warn", "off", boolean, [level, options], or { level?, enabled? }`);
16135
+ }
16136
+ function normalizePublintRuleNames(location, values) {
16137
+ return (values ?? []).map((value) => normalizePublintRuleName(location, value));
16138
+ }
16139
+ function defaultLevels() {
16140
+ return new Map(ALL_PUBLINT_CHECKS.map((check) => [check, defaultPublintLevel(check)]));
16141
+ }
16142
+ function setRuleLevel(levels, explicit, check, level) {
16143
+ levels.set(check, level);
16144
+ explicit.add(check);
16145
+ }
16146
+ function applyIncludedOnly(levels, explicit, include) {
16147
+ if (include.length === 0) return;
16148
+ const included = new Set(include);
16149
+ for (const check of ALL_PUBLINT_CHECKS) {
16150
+ if (included.has(check)) continue;
16151
+ setRuleLevel(levels, explicit, check, "off");
16152
+ }
16153
+ }
16154
+ function applyExcluded(levels, explicit, exclude) {
16155
+ for (const check of exclude) setRuleLevel(levels, explicit, check, "off");
16156
+ }
16157
+ function applyConfiguredRules(levels, explicit, rules) {
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));
16171
+ }
16172
+ }
16173
+ function resolvePublintRules(value, cliExclude, cliInclude) {
16174
+ const config = normalizePublintConfig$2(value);
16175
+ const configExclude = normalizePublintRuleNames("commands.publint.exclude", config.exclude);
16176
+ const configInclude = normalizePublintRuleNames("commands.publint.include", config.include);
16177
+ const normalizedCliExclude = normalizePublintRuleNames("--exclude", cliExclude);
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");
16180
+ const levels = defaultLevels();
16181
+ const explicit = /* @__PURE__ */ new Set();
16182
+ applyIncludedOnly(levels, explicit, configInclude);
16183
+ applyExcluded(levels, explicit, configExclude);
16184
+ applyConfiguredRules(levels, explicit, config.rules);
16185
+ applyIncludedOnly(levels, explicit, normalizedCliInclude);
16186
+ applyExcluded(levels, explicit, normalizedCliExclude);
16187
+ return {
16188
+ explicit,
16189
+ levels
16190
+ };
16191
+ }
16192
+ function cloneResolvedPublintRules(rules) {
16193
+ return {
16194
+ explicit: new Set(rules.explicit),
16195
+ levels: new Map(rules.levels)
16196
+ };
16197
+ }
16198
+ //#endregion
15736
16199
  //#region ../../node_modules/.pnpm/@publint+pack@0.1.4/node_modules/@publint/pack/src/node/pack.js
15737
16200
  /** @type {import('../index.d.ts').pack} */
15738
16201
  async function pack(dir, opts) {
@@ -17850,9 +18313,6 @@ function normalizePublintConfig$1(value) {
17850
18313
  if (typeof value === "object") return value;
17851
18314
  return {};
17852
18315
  }
17853
- function mergeWorkspaceExclude(exclude, wsPublintConfig) {
17854
- return /* @__PURE__ */ new Set([...exclude, ...wsPublintConfig.exclude ?? []]);
17855
- }
17856
18316
  const shouldRemoveSourceFromExports = (exports) => {
17857
18317
  let isRemoved = false;
17858
18318
  for (const [key, value] of Object.entries(exports)) if (key === "source") {
@@ -17908,6 +18368,15 @@ function mergeResults(target, source) {
17908
18368
  target.warnings += source.warnings;
17909
18369
  target.modified ||= source.modified;
17910
18370
  }
18371
+ function mergeLeveledResult(target, source, check, rules) {
18372
+ const issueCount = source.errors + source.warnings;
18373
+ if (rules.explicit.has(check)) {
18374
+ const level = rules.levels.get(check) ?? defaultPublintLevel(check);
18375
+ if (level === "error") target.errors += issueCount;
18376
+ else if (level === "warn") target.warnings += issueCount;
18377
+ } else mergeResults(target, source);
18378
+ target.modified ||= source.modified;
18379
+ }
17911
18380
  async function readPackageJson(pkgDir) {
17912
18381
  return JSON.parse(await promises.readFile(PATH.join(pkgDir, "package.json"), "utf8"));
17913
18382
  }
@@ -18034,21 +18503,21 @@ function checkRootTypes(pkg, shouldFix) {
18034
18503
  result.warnings++;
18035
18504
  return result;
18036
18505
  }
18037
- async function customPubLint(pkgDir, pkg, shouldFix = false, exclude = /* @__PURE__ */ new Set()) {
18506
+ async function customPubLint(pkgDir, pkg, shouldFix = false, rules) {
18038
18507
  const result = emptyCustomResult();
18039
- if (!exclude.has("files")) mergeResults(result, checkFiles(pkg, shouldFix));
18040
- if (!exclude.has("source")) mergeResults(result, checkExportsSource(pkg, shouldFix));
18041
- if (!exclude.has("rootSource")) mergeResults(result, checkRootSource(pkg, shouldFix));
18042
- if (!exclude.has("main")) mergeResults(result, migrateFieldToExports(pkg, "main", "default", shouldFix));
18043
- if (!exclude.has("types")) mergeResults(result, migrateFieldToExports(pkg, "types", "types", shouldFix));
18044
- if (!exclude.has("module")) mergeResults(result, migrateFieldToExports(pkg, "module", "default", shouldFix));
18045
- if (!exclude.has("importToDefault")) mergeResults(result, checkImportToDefault(pkg, shouldFix));
18046
- if (!exclude.has("neutralToDefault")) mergeResults(result, checkNeutralToDefault(pkg, shouldFix, (message) => console.warn(chalk.yellow(message))));
18047
- if (!exclude.has("defaultExportOrder")) mergeResults(result, checkDefaultExportOrder(pkg, shouldFix, (message) => console.warn(chalk.yellow(message))));
18048
- if (!exclude.has("rootTypes")) mergeResults(result, checkRootTypes(pkg, shouldFix));
18049
- if (!exclude.has("platform")) mergeResults(result, await checkPlatform(pkgDir, pkg, shouldFix));
18050
- if (!exclude.has("sideEffects")) mergeResults(result, checkSideEffects(pkg));
18051
- if (!exclude.has("resolutions")) mergeResults(result, checkResolutions(pkg));
18508
+ if (rules.levels.get("files") !== "off") mergeLeveledResult(result, checkFiles(pkg, shouldFix), "files", rules);
18509
+ if (rules.levels.get("source") !== "off") mergeLeveledResult(result, checkExportsSource(pkg, shouldFix), "source", rules);
18510
+ if (rules.levels.get("rootSource") !== "off") mergeLeveledResult(result, checkRootSource(pkg, shouldFix), "rootSource", rules);
18511
+ if (rules.levels.get("main") !== "off") mergeLeveledResult(result, migrateFieldToExports(pkg, "main", "default", shouldFix), "main", rules);
18512
+ if (rules.levels.get("types") !== "off") mergeLeveledResult(result, migrateFieldToExports(pkg, "types", "types", shouldFix), "types", rules);
18513
+ if (rules.levels.get("module") !== "off") mergeLeveledResult(result, migrateFieldToExports(pkg, "module", "default", shouldFix), "module", rules);
18514
+ if (rules.levels.get("importToDefault") !== "off") mergeLeveledResult(result, checkImportToDefault(pkg, shouldFix), "importToDefault", rules);
18515
+ if (rules.levels.get("neutralToDefault") !== "off") mergeLeveledResult(result, checkNeutralToDefault(pkg, shouldFix, (message) => console.warn(chalk.yellow(message))), "neutralToDefault", rules);
18516
+ if (rules.levels.get("defaultExportOrder") !== "off") mergeLeveledResult(result, checkDefaultExportOrder(pkg, shouldFix, (message) => console.warn(chalk.yellow(message))), "defaultExportOrder", rules);
18517
+ if (rules.levels.get("rootTypes") !== "off") mergeLeveledResult(result, checkRootTypes(pkg, shouldFix), "rootTypes", rules);
18518
+ if (rules.levels.get("platform") !== "off") mergeLeveledResult(result, await checkPlatform(pkgDir, pkg, shouldFix), "platform", rules);
18519
+ if (rules.levels.get("sideEffects") !== "off") mergeLeveledResult(result, checkSideEffects(pkg), "sideEffects", rules);
18520
+ if (rules.levels.get("resolutions") !== "off") mergeLeveledResult(result, checkResolutions(pkg), "resolutions", rules);
18052
18521
  return [
18053
18522
  result.errors,
18054
18523
  result.warnings,
@@ -18124,42 +18593,89 @@ async function runPublintLibrary(pkgDir, pkg, isStrict, shouldPack) {
18124
18593
  warnings: messages.filter((message) => message.type !== "error").length
18125
18594
  };
18126
18595
  }
18127
- const packagePublintDetailed = async ({ exclude = /* @__PURE__ */ new Set(), shouldFix = false, shouldPack: shouldPackParam, pkgDir: pkgDirParam, isStrict = isStrictMode(), verbose: _verbose = false } = {}) => {
18596
+ function applyEffectiveExcludes(pkg, exclude, rules) {
18597
+ const effectiveExclude = Boolean(pkg.private) ? /* @__PURE__ */ new Set([...exclude, ...PUBLISH_ONLY_CHECKS]) : exclude;
18598
+ for (const check of effectiveExclude) {
18599
+ rules.levels.set(check, "off");
18600
+ rules.explicit.add(check);
18601
+ }
18602
+ }
18603
+ async function runCustomPublintPass(pkgDir, pkg, shouldFix, rules) {
18604
+ const [errors, warnings, modified] = await customPubLint(pkgDir, pkg, shouldFix, rules);
18605
+ if (shouldFix && modified) {
18606
+ await writePackageJson(pkgDir, pkg);
18607
+ return {
18608
+ pkg: await readPackageJson(pkgDir),
18609
+ result: {
18610
+ errors,
18611
+ modified,
18612
+ warnings
18613
+ }
18614
+ };
18615
+ }
18616
+ return {
18617
+ pkg,
18618
+ result: {
18619
+ errors,
18620
+ modified,
18621
+ warnings
18622
+ }
18623
+ };
18624
+ }
18625
+ async function runLeveledPublintLibrary(pkgDir, pkg, isStrict, shouldPack, rules) {
18626
+ const level = rules.levels.get("publint");
18627
+ if (level === "off") return {
18628
+ errors: 0,
18629
+ warnings: 0
18630
+ };
18631
+ const library = await runPublintLibrary(pkgDir, pkg, isStrict, shouldPack);
18632
+ if (!rules.explicit.has("publint")) return library;
18633
+ const issueCount = library.errors + library.warnings;
18634
+ return level === "error" ? {
18635
+ errors: issueCount,
18636
+ warnings: 0
18637
+ } : {
18638
+ errors: 0,
18639
+ warnings: issueCount
18640
+ };
18641
+ }
18642
+ function runLeveledCompileTargets(pkgDir, shouldFix, rules) {
18643
+ const level = rules.levels.get("compileTargets");
18644
+ const raw = level === "off" ? {
18645
+ errors: 0,
18646
+ warnings: 0
18647
+ } : checkCompileTargets(pkgDir, shouldFix);
18648
+ if (!rules.explicit.has("compileTargets")) return raw;
18649
+ const issueCount = raw.errors + raw.warnings;
18650
+ return level === "error" ? {
18651
+ errors: issueCount,
18652
+ warnings: 0
18653
+ } : {
18654
+ errors: 0,
18655
+ warnings: issueCount
18656
+ };
18657
+ }
18658
+ const packagePublintDetailed = async ({ exclude = /* @__PURE__ */ new Set(), ruleLevels, shouldFix = false, shouldPack: shouldPackParam, pkgDir: pkgDirParam, isStrict = isStrictMode(), verbose: _verbose = false } = {}) => {
18128
18659
  const pkgDir = PATH.resolve(pkgDirParam ?? INIT_CWD());
18129
18660
  const wsPublintConfig = normalizePublintConfig$1(await loadWorkspaceCommandConfig(pkgDir, "publint"));
18130
- const workspaceExclude = mergeWorkspaceExclude(exclude, wsPublintConfig);
18131
18661
  const shouldPack = shouldPackParam ?? wsPublintConfig.pack ?? true;
18662
+ const resolvedRules = ruleLevels === void 0 ? resolvePublintRules(wsPublintConfig) : cloneResolvedPublintRules(ruleLevels);
18132
18663
  let pkg = await readPackageJson(pkgDir);
18133
- const effectiveExclude = Boolean(pkg.private) ? /* @__PURE__ */ new Set([...workspaceExclude, ...PUBLISH_ONLY_CHECKS]) : workspaceExclude;
18664
+ applyEffectiveExcludes(pkg, exclude, resolvedRules);
18134
18665
  console.log(chalk.green(`Publint: ${String(pkg.name)}${Boolean(pkg.private) ? chalk.gray(" (private)") : ""}`));
18135
18666
  console.log(chalk.gray(pkgDir));
18136
- let errorCount = 0;
18137
- let warningCount = 0;
18138
- let libraryErrors = 0;
18139
- let libraryWarnings = 0;
18140
- const runCustomChecks = async () => {
18141
- const [customErrors, customWarnings, isModified] = await customPubLint(pkgDir, pkg, shouldFix, effectiveExclude);
18142
- errorCount += customErrors;
18143
- warningCount += customWarnings;
18144
- if (shouldFix && isModified) {
18145
- await writePackageJson(pkgDir, pkg);
18146
- pkg = await readPackageJson(pkgDir);
18147
- }
18148
- };
18149
- if (shouldFix) await runCustomChecks();
18150
- if (!effectiveExclude.has("publint")) {
18151
- const library = await runPublintLibrary(pkgDir, pkg, isStrict, shouldPack);
18152
- libraryErrors = library.errors;
18153
- libraryWarnings = library.warnings;
18154
- }
18155
- if (!shouldFix) await runCustomChecks();
18156
- const compileTargets = effectiveExclude.has("compileTargets") ? {
18157
- errors: 0,
18158
- warnings: 0
18159
- } : checkCompileTargets(pkgDir, shouldFix);
18667
+ let customResult = emptyCustomResult();
18668
+ if (shouldFix) {
18669
+ const customPass = await runCustomPublintPass(pkgDir, pkg, shouldFix, resolvedRules);
18670
+ customResult = customPass.result;
18671
+ pkg = customPass.pkg;
18672
+ }
18673
+ const library = await runLeveledPublintLibrary(pkgDir, pkg, isStrict, shouldPack, resolvedRules);
18674
+ if (!shouldFix) customResult = (await runCustomPublintPass(pkgDir, pkg, shouldFix, resolvedRules)).result;
18675
+ const compileTargets = runLeveledCompileTargets(pkgDir, shouldFix, resolvedRules);
18160
18676
  return {
18161
- errors: libraryErrors + errorCount + compileTargets.errors,
18162
- warnings: libraryWarnings + warningCount + compileTargets.warnings
18677
+ errors: library.errors + customResult.errors + compileTargets.errors,
18678
+ warnings: library.warnings + customResult.warnings + compileTargets.warnings
18163
18679
  };
18164
18680
  };
18165
18681
  const packagePublint = async (params = {}) => {
@@ -18168,28 +18684,20 @@ const packagePublint = async (params = {}) => {
18168
18684
  };
18169
18685
  //#endregion
18170
18686
  //#region src/actions/publint.ts
18171
- function resolveExclude(publintConfig, cliExclude, cliInclude) {
18172
- const hasExclude = (publintConfig.exclude?.length ?? 0) > 0 || (cliExclude?.length ?? 0) > 0;
18173
- const hasInclude = (publintConfig.include?.length ?? 0) > 0 || (cliInclude?.length ?? 0) > 0;
18174
- if (hasExclude && hasInclude) {
18175
- console.error(chalk.red("Publint: --include and --exclude cannot be used together"));
18176
- return;
18177
- }
18178
- if (hasInclude) {
18179
- const include = /* @__PURE__ */ new Set([...publintConfig.include ?? [], ...cliInclude ?? []]);
18180
- return new Set(ALL_PUBLINT_CHECKS.filter((c) => !include.has(c)));
18181
- }
18182
- return /* @__PURE__ */ new Set([...publintConfig.exclude ?? [], ...cliExclude ?? []]);
18183
- }
18184
18687
  function normalizePublintConfig(value) {
18185
18688
  if (typeof value === "object") return value;
18186
18689
  return {};
18187
18690
  }
18691
+ function offChecks(rules) {
18692
+ const excluded = /* @__PURE__ */ new Set();
18693
+ for (const [check, level] of rules.levels) if (level === "off") excluded.add(check);
18694
+ return excluded;
18695
+ }
18188
18696
  async function loadPublintOptions() {
18189
18697
  const config = await loadConfig();
18190
18698
  const publintConfig = normalizePublintConfig(config.commands?.publint ?? config.publint);
18191
18699
  return {
18192
- exclude: resolveExclude(publintConfig) ?? /* @__PURE__ */ new Set(),
18700
+ exclude: offChecks(resolvePublintRules(publintConfig)),
18193
18701
  pack: publintConfig.pack ?? true
18194
18702
  };
18195
18703
  }