@ariestools/toolchain 8.6.11 → 8.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/api-exposure/apiExposure.d.ts.map +1 -1
- package/dist/actions/api-exposure/config.d.ts.map +1 -1
- package/dist/actions/api-exposure/types.d.ts +3 -0
- package/dist/actions/api-exposure/types.d.ts.map +1 -1
- package/dist/actions/gitlint-fix.d.ts +2 -1
- package/dist/actions/gitlint-fix.d.ts.map +1 -1
- package/dist/actions/gitlint.d.ts +3 -1
- package/dist/actions/gitlint.d.ts.map +1 -1
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/lintlint.d.ts +1 -1
- package/dist/actions/lintlint.d.ts.map +1 -1
- package/dist/actions/node-lint.d.ts +1 -1
- package/dist/actions/node-lint.d.ts.map +1 -1
- package/dist/actions/package/compile/ApiExposureConfig.d.ts +9 -2
- package/dist/actions/package/compile/ApiExposureConfig.d.ts.map +1 -1
- package/dist/actions/package/compile/MonolithConfig.d.ts +23 -0
- package/dist/actions/package/compile/MonolithConfig.d.ts.map +1 -1
- package/dist/actions/package/compile/PublintConfig.d.ts +41 -0
- package/dist/actions/package/compile/PublintConfig.d.ts.map +1 -0
- package/dist/actions/package/compile/RuleLevelConfig.d.ts +7 -0
- package/dist/actions/package/compile/RuleLevelConfig.d.ts.map +1 -0
- package/dist/actions/package/compile/XyConfig.d.ts +29 -34
- package/dist/actions/package/compile/XyConfig.d.ts.map +1 -1
- package/dist/actions/package/compile/monolithCompileEntries.d.ts.map +1 -1
- package/dist/actions/package/compile/monolithCompileLayout.d.ts.map +1 -1
- package/dist/actions/package/index.d.ts +1 -0
- package/dist/actions/package/index.d.ts.map +1 -1
- package/dist/actions/package/publint.d.ts +3 -1
- package/dist/actions/package/publint.d.ts.map +1 -1
- package/dist/actions/package/publintRules.d.ts +10 -0
- package/dist/actions/package/publintRules.d.ts.map +1 -0
- package/dist/actions/package-lint.d.ts +2 -1
- package/dist/actions/package-lint.d.ts.map +1 -1
- package/dist/actions/packman/lint.d.ts +2 -1
- package/dist/actions/packman/lint.d.ts.map +1 -1
- package/dist/actions/publint.d.ts.map +1 -1
- package/dist/actions/ruleCatalog.d.ts +40 -0
- package/dist/actions/ruleCatalog.d.ts.map +1 -0
- package/dist/actions/ruleRunner.d.ts +60 -0
- package/dist/actions/ruleRunner.d.ts.map +1 -0
- package/dist/actions/skills/lint.d.ts +3 -1
- package/dist/actions/skills/lint.d.ts.map +1 -1
- package/dist/bin/package/build.mjs +218 -67
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +8 -4
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/publint.mjs +210 -63
- package/dist/bin/package/publint.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +8 -4
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/package/sync-layout.mjs +1 -1
- package/dist/bin/package/sync-layout.mjs.map +1 -1
- package/dist/bin/xy.mjs +1484 -315
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/lib/loadConfig.d.ts.map +1 -1
- package/dist/xy/common/checkCommand.d.ts.map +1 -1
- package/dist/xy/common/deadCommand.d.ts.map +1 -1
- package/dist/xy/common/gitlintCommand.d.ts.map +1 -1
- package/dist/xy/common/packmanCommand.d.ts.map +1 -1
- package/dist/xy/common/repo/lintCommand.d.ts.map +1 -1
- package/dist/xy/common/skills/index.d.ts.map +1 -1
- package/dist/xy/lint/apiExposureCommand.d.ts.map +1 -1
- package/dist/xy/lint/cycleCommand.d.ts.map +1 -1
- package/dist/xy/lint/deplintCommand.d.ts.map +1 -1
- package/dist/xy/lint/fixCommand.d.ts.map +1 -1
- package/dist/xy/lint/lint/runCommand.d.ts.map +1 -1
- package/dist/xy/lint/lintlintCommand.d.ts.map +1 -1
- package/dist/xy/lint/nodeLintCommand.d.ts.map +1 -1
- package/dist/xy/lint/publintCommand.d.ts.map +1 -1
- package/dist/xy/lint/relintCommand.d.ts.map +1 -1
- package/dist/xy/lint/republintCommand.d.ts.map +1 -1
- package/dist/xy/xy.d.ts +3 -10
- package/dist/xy/xy.d.ts.map +1 -1
- package/dist/xy/xyParseOptions.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { XyJsonDiagnostic } from '../lib/index.ts';
|
|
2
|
+
import type { RuleLevel } from './package/index.ts';
|
|
3
|
+
import type { ActionResult } from './result.ts';
|
|
4
|
+
export interface RuleRunnerConfig {
|
|
5
|
+
rules?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export interface RuleCheckContext {
|
|
8
|
+
fix: boolean;
|
|
9
|
+
isExplicit: boolean;
|
|
10
|
+
level: RuleLevel;
|
|
11
|
+
}
|
|
12
|
+
export interface RuleCheckDiagnostic extends XyJsonDiagnostic {
|
|
13
|
+
level?: Exclude<RuleLevel, 'off'>;
|
|
14
|
+
}
|
|
15
|
+
export interface RuleCheckOutcome {
|
|
16
|
+
diagnostics?: RuleCheckDiagnostic[];
|
|
17
|
+
fixedCount?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface RuleCheckDefinition<TContext = void> {
|
|
20
|
+
check: (context: TContext, rule: RuleCheckContext) => Promise<RuleCheckOutcome> | RuleCheckOutcome;
|
|
21
|
+
defaultLevel: RuleLevel;
|
|
22
|
+
description?: string;
|
|
23
|
+
id: string;
|
|
24
|
+
}
|
|
25
|
+
export interface RuleRunDiagnostic extends XyJsonDiagnostic {
|
|
26
|
+
level: Exclude<RuleLevel, 'off'>;
|
|
27
|
+
rule: string;
|
|
28
|
+
}
|
|
29
|
+
export interface RuleRunReport {
|
|
30
|
+
diagnostics: RuleRunDiagnostic[];
|
|
31
|
+
errorCount: number;
|
|
32
|
+
fixedCount: number;
|
|
33
|
+
warningCount: number;
|
|
34
|
+
}
|
|
35
|
+
export interface RuleRunResult extends ActionResult {
|
|
36
|
+
envelope: ActionResult['envelope'] & {
|
|
37
|
+
data: RuleRunReport;
|
|
38
|
+
errors?: RuleRunDiagnostic[];
|
|
39
|
+
warnings?: RuleRunDiagnostic[];
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface RuleRunnerReporter<TContext = unknown> {
|
|
43
|
+
diagnostic?: (diagnostic: RuleRunDiagnostic) => void;
|
|
44
|
+
fixed?: (rule: RuleCheckDefinition<TContext>, fixedCount: number) => void;
|
|
45
|
+
passed?: (rule: RuleCheckDefinition<TContext>) => void;
|
|
46
|
+
}
|
|
47
|
+
export interface RunRuleChecksParams<TContext = void> {
|
|
48
|
+
commandName: string;
|
|
49
|
+
config?: RuleRunnerConfig;
|
|
50
|
+
context: TContext;
|
|
51
|
+
fix?: boolean;
|
|
52
|
+
reporter?: RuleRunnerReporter<TContext>;
|
|
53
|
+
rules: RuleCheckDefinition<TContext>[];
|
|
54
|
+
strict?: boolean;
|
|
55
|
+
}
|
|
56
|
+
export declare function isRuleLevel(value: unknown): value is RuleLevel;
|
|
57
|
+
export declare function parseRuleLevelSetting(location: string, setting: unknown, defaultLevel: RuleLevel): RuleLevel;
|
|
58
|
+
export declare function defaultRuleReporter<TContext = unknown>(): RuleRunnerReporter<TContext>;
|
|
59
|
+
export declare function runRuleChecks<TContext = void>({ commandName, config, context, fix, reporter, rules, strict, }: RunRuleChecksParams<TContext>): Promise<RuleRunResult>;
|
|
60
|
+
//# sourceMappingURL=ruleRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruleRunner.d.ts","sourceRoot":"","sources":["../../src/actions/ruleRunner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAK/C,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC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skillRules.ts';
|
|
2
3
|
export interface SkillsLintOptions {
|
|
3
4
|
cwd?: string;
|
|
@@ -6,6 +7,7 @@ export interface SkillsLintOptions {
|
|
|
6
7
|
isOffline?: boolean;
|
|
7
8
|
isStrict?: boolean;
|
|
8
9
|
projectDirs?: string[];
|
|
10
|
+
strict?: boolean;
|
|
9
11
|
}
|
|
10
12
|
export interface OutdatedSkill {
|
|
11
13
|
latest?: string;
|
|
@@ -22,5 +24,5 @@ export interface SkillsLintResult {
|
|
|
22
24
|
unnecessary: XyoSkillName[];
|
|
23
25
|
warnings: number;
|
|
24
26
|
}
|
|
25
|
-
export declare const skillsLint: (options?: SkillsLintOptions) => Promise<
|
|
27
|
+
export declare const skillsLint: (options?: SkillsLintOptions) => Promise<EnvelopeReturn>;
|
|
26
28
|
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../../src/actions/skills/lint.ts"],"names":[],"mappings":"
|
|
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;AAgBxD,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;AA+ND,eAAO,MAAM,UAAU,GAAU,UAAS,iBAAsB,KAAG,OAAO,CAAC,cAAc,CAgExF,CAAA"}
|
|
@@ -9868,15 +9868,27 @@ function mergeRuleConfigs(target, source) {
|
|
|
9868
9868
|
};
|
|
9869
9869
|
return source;
|
|
9870
9870
|
}
|
|
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
|
+
]);
|
|
9871
9883
|
function mergeCommandConfig(rootCmd, workspaceCmd, commandName) {
|
|
9872
|
-
return deepMerge$1(rootCmd, workspaceCmd, { customMerge: (key) => (commandName
|
|
9884
|
+
return deepMerge$1(rootCmd, workspaceCmd, { customMerge: (key) => RULE_CONFIG_COMMANDS.has(commandName) && key === "rules" ? mergeRuleConfigs : void 0 });
|
|
9873
9885
|
}
|
|
9874
9886
|
/**
|
|
9875
9887
|
* Loads a command-specific config merged from root and workspace levels.
|
|
9876
9888
|
* The root config provides defaults; the workspace config extends/overrides.
|
|
9877
9889
|
* Arrays (e.g. `exclude`) are unioned and maps (e.g. `packages`) are merged
|
|
9878
9890
|
* via deepmerge, with workspace entries overriding root entries for the same key.
|
|
9879
|
-
*
|
|
9891
|
+
* Rule entries are replaced per rule id so tuple configs keep their
|
|
9880
9892
|
* ESLint-like shape instead of being concatenated as arrays.
|
|
9881
9893
|
*/
|
|
9882
9894
|
/**
|
|
@@ -13945,7 +13957,7 @@ function syncMonolithLayout(packageDir, config, options = {}) {
|
|
|
13945
13957
|
paths: buildTsconfigPaths(modules, config)
|
|
13946
13958
|
};
|
|
13947
13959
|
writeOrCheck(tsconfigPath, `${JSON.stringify(tsconfig, null, 2)}\n`);
|
|
13948
|
-
writeOrCheck(PATH.join(packageDir, "src/index.ts"), buildIndexTs(modules, config));
|
|
13960
|
+
if (!(config.index?.custom ?? false)) writeOrCheck(PATH.join(packageDir, "src/index.ts"), buildIndexTs(modules, config));
|
|
13949
13961
|
if (monolithHasModelBarrel(config)) writeOrCheck(PATH.join(packageDir, "src/model.ts"), buildModelTs(modules));
|
|
13950
13962
|
for (const mod of modules) {
|
|
13951
13963
|
if (!(mod.export ?? false)) continue;
|
|
@@ -14131,10 +14143,14 @@ function modulesPlatformEntries(mod, config, isExternal, modulesPlatform) {
|
|
|
14131
14143
|
};
|
|
14132
14144
|
return shims;
|
|
14133
14145
|
}
|
|
14146
|
+
/** Master barrel entry for a platform (`index.entries` override or `./index.ts`). */
|
|
14147
|
+
function masterBarrelEntry(config, platform) {
|
|
14148
|
+
return config.index?.entries?.[platform] ?? "./index.ts";
|
|
14149
|
+
}
|
|
14134
14150
|
function initialBarrelEntries(config, platforms, modulesPlatform, barrelPlatforms) {
|
|
14135
14151
|
const entries = {};
|
|
14136
|
-
for (const platform of platforms) entries[platform] = barrelPlatforms.has(platform) ? [
|
|
14137
|
-
entries[modulesPlatform] ??= barrelPlatforms.has(modulesPlatform) ? [
|
|
14152
|
+
for (const platform of platforms) entries[platform] = barrelPlatforms.has(platform) ? [masterBarrelEntry(config, platform)] : [];
|
|
14153
|
+
entries[modulesPlatform] ??= barrelPlatforms.has(modulesPlatform) ? [masterBarrelEntry(config, modulesPlatform)] : [];
|
|
14138
14154
|
if (monolithHasModelBarrel(config)) entries[modulesPlatform].push("./model.ts");
|
|
14139
14155
|
return entries;
|
|
14140
14156
|
}
|
|
@@ -14172,7 +14188,7 @@ function buildMonolithEntries(config) {
|
|
|
14172
14188
|
entries[modulesPlatform].push(...modulesPlatformEntries(mod, config, isExternal, modulesPlatform));
|
|
14173
14189
|
}
|
|
14174
14190
|
for (const [platform, platformEntryMap] of Object.entries(platformEntries)) {
|
|
14175
|
-
entries[platform] ??= barrelPlatforms.has(platform) ? [
|
|
14191
|
+
entries[platform] ??= barrelPlatforms.has(platform) ? [masterBarrelEntry(config, platform)] : [];
|
|
14176
14192
|
for (const [name, target] of Object.entries(platformEntryMap)) if (platform !== modulesPlatform || !exportedConditional.has(name)) entries[platform].push(platformShimEntry(platform, name, target, isExternal));
|
|
14177
14193
|
}
|
|
14178
14194
|
return entries;
|
|
@@ -14830,7 +14846,7 @@ const packageCompile = async (inConfig = {}, mode = {}) => {
|
|
|
14830
14846
|
return await packageCompileEsbuild(config, mode);
|
|
14831
14847
|
};
|
|
14832
14848
|
//#endregion
|
|
14833
|
-
//#region src/actions/package/compile/
|
|
14849
|
+
//#region src/actions/package/compile/PublintConfig.ts
|
|
14834
14850
|
const ALL_PUBLINT_CHECKS = [
|
|
14835
14851
|
"compileTargets",
|
|
14836
14852
|
"defaultExportOrder",
|
|
@@ -15733,6 +15749,96 @@ async function checkPlatform(pkgDir, pkg, shouldFix = false) {
|
|
|
15733
15749
|
return result;
|
|
15734
15750
|
}
|
|
15735
15751
|
//#endregion
|
|
15752
|
+
//#region src/actions/package/publintRules.ts
|
|
15753
|
+
const PUBLINT_RULE_LEVELS = /* @__PURE__ */ new Set([
|
|
15754
|
+
"error",
|
|
15755
|
+
"off",
|
|
15756
|
+
"warn"
|
|
15757
|
+
]);
|
|
15758
|
+
function defaultPublintLevel(check) {
|
|
15759
|
+
return check === "platform" || check === "publint" ? "error" : "warn";
|
|
15760
|
+
}
|
|
15761
|
+
function normalizePublintConfig$2(value) {
|
|
15762
|
+
if (typeof value === "object") return value;
|
|
15763
|
+
return {};
|
|
15764
|
+
}
|
|
15765
|
+
function isPublintCheckName(value) {
|
|
15766
|
+
return ALL_PUBLINT_CHECKS.includes(value);
|
|
15767
|
+
}
|
|
15768
|
+
function isRuleLevel(value) {
|
|
15769
|
+
return typeof value === "string" && PUBLINT_RULE_LEVELS.has(value);
|
|
15770
|
+
}
|
|
15771
|
+
function candidateRuleLevelValue(value) {
|
|
15772
|
+
if (Array.isArray(value) && value.length > 0) return value[0];
|
|
15773
|
+
if (typeof value === "object" && value !== null) {
|
|
15774
|
+
const record = value;
|
|
15775
|
+
return record.level ?? record.enabled;
|
|
15776
|
+
}
|
|
15777
|
+
return value;
|
|
15778
|
+
}
|
|
15779
|
+
function parseRuleLevel(location, value) {
|
|
15780
|
+
const candidate = candidateRuleLevelValue(value);
|
|
15781
|
+
if (candidate === true) return "warn";
|
|
15782
|
+
if (candidate === false) return "off";
|
|
15783
|
+
if (isRuleLevel(candidate)) return candidate;
|
|
15784
|
+
throw new TypeError(`${location} must be "error", "warn", "off", boolean, [level, options], or { level?, enabled? }`);
|
|
15785
|
+
}
|
|
15786
|
+
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
|
+
});
|
|
15791
|
+
}
|
|
15792
|
+
function defaultLevels() {
|
|
15793
|
+
return new Map(ALL_PUBLINT_CHECKS.map((check) => [check, defaultPublintLevel(check)]));
|
|
15794
|
+
}
|
|
15795
|
+
function setRuleLevel(levels, explicit, check, level) {
|
|
15796
|
+
levels.set(check, level);
|
|
15797
|
+
explicit.add(check);
|
|
15798
|
+
}
|
|
15799
|
+
function applyIncludedOnly(levels, explicit, include) {
|
|
15800
|
+
if (include.length === 0) return;
|
|
15801
|
+
const included = new Set(include);
|
|
15802
|
+
for (const check of ALL_PUBLINT_CHECKS) {
|
|
15803
|
+
if (included.has(check)) continue;
|
|
15804
|
+
setRuleLevel(levels, explicit, check, "off");
|
|
15805
|
+
}
|
|
15806
|
+
}
|
|
15807
|
+
function applyExcluded(levels, explicit, exclude) {
|
|
15808
|
+
for (const check of exclude) setRuleLevel(levels, explicit, check, "off");
|
|
15809
|
+
}
|
|
15810
|
+
function applyConfiguredRules(levels, explicit, rules) {
|
|
15811
|
+
for (const [check, setting] of Object.entries(rules ?? {})) {
|
|
15812
|
+
if (!isPublintCheckName(check)) throw new TypeError(`Unknown publint check "${check}" in commands.publint.rules`);
|
|
15813
|
+
setRuleLevel(levels, explicit, check, parseRuleLevel(`commands.publint.rules["${check}"]`, setting));
|
|
15814
|
+
}
|
|
15815
|
+
}
|
|
15816
|
+
function resolvePublintRules(value, cliExclude, cliInclude) {
|
|
15817
|
+
const config = normalizePublintConfig$2(value);
|
|
15818
|
+
const configExclude = normalizePublintRuleNames("commands.publint.exclude", config.exclude);
|
|
15819
|
+
const configInclude = normalizePublintRuleNames("commands.publint.include", config.include);
|
|
15820
|
+
const normalizedCliExclude = normalizePublintRuleNames("--exclude", cliExclude);
|
|
15821
|
+
const normalizedCliInclude = normalizePublintRuleNames("--include", cliInclude);
|
|
15822
|
+
const levels = defaultLevels();
|
|
15823
|
+
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
|
+
applyIncludedOnly(levels, explicit, configInclude);
|
|
15826
|
+
applyExcluded(levels, explicit, configExclude);
|
|
15827
|
+
applyConfiguredRules(levels, explicit, config.rules);
|
|
15828
|
+
applyIncludedOnly(levels, explicit, normalizedCliInclude);
|
|
15829
|
+
applyExcluded(levels, explicit, normalizedCliExclude);
|
|
15830
|
+
return {
|
|
15831
|
+
explicit,
|
|
15832
|
+
levels
|
|
15833
|
+
};
|
|
15834
|
+
}
|
|
15835
|
+
function cloneResolvedPublintRules(rules) {
|
|
15836
|
+
return {
|
|
15837
|
+
explicit: new Set(rules.explicit),
|
|
15838
|
+
levels: new Map(rules.levels)
|
|
15839
|
+
};
|
|
15840
|
+
}
|
|
15841
|
+
//#endregion
|
|
15736
15842
|
//#region ../../node_modules/.pnpm/@publint+pack@0.1.4/node_modules/@publint/pack/src/node/pack.js
|
|
15737
15843
|
/** @type {import('../index.d.ts').pack} */
|
|
15738
15844
|
async function pack(dir, opts) {
|
|
@@ -17850,9 +17956,6 @@ function normalizePublintConfig$1(value) {
|
|
|
17850
17956
|
if (typeof value === "object") return value;
|
|
17851
17957
|
return {};
|
|
17852
17958
|
}
|
|
17853
|
-
function mergeWorkspaceExclude(exclude, wsPublintConfig) {
|
|
17854
|
-
return /* @__PURE__ */ new Set([...exclude, ...wsPublintConfig.exclude ?? []]);
|
|
17855
|
-
}
|
|
17856
17959
|
const shouldRemoveSourceFromExports = (exports) => {
|
|
17857
17960
|
let isRemoved = false;
|
|
17858
17961
|
for (const [key, value] of Object.entries(exports)) if (key === "source") {
|
|
@@ -17908,6 +18011,15 @@ function mergeResults(target, source) {
|
|
|
17908
18011
|
target.warnings += source.warnings;
|
|
17909
18012
|
target.modified ||= source.modified;
|
|
17910
18013
|
}
|
|
18014
|
+
function mergeLeveledResult(target, source, check, rules) {
|
|
18015
|
+
const issueCount = source.errors + source.warnings;
|
|
18016
|
+
if (rules.explicit.has(check)) {
|
|
18017
|
+
const level = rules.levels.get(check) ?? defaultPublintLevel(check);
|
|
18018
|
+
if (level === "error") target.errors += issueCount;
|
|
18019
|
+
else if (level === "warn") target.warnings += issueCount;
|
|
18020
|
+
} else mergeResults(target, source);
|
|
18021
|
+
target.modified ||= source.modified;
|
|
18022
|
+
}
|
|
17911
18023
|
async function readPackageJson(pkgDir) {
|
|
17912
18024
|
return JSON.parse(await promises.readFile(PATH.join(pkgDir, "package.json"), "utf8"));
|
|
17913
18025
|
}
|
|
@@ -18034,21 +18146,21 @@ function checkRootTypes(pkg, shouldFix) {
|
|
|
18034
18146
|
result.warnings++;
|
|
18035
18147
|
return result;
|
|
18036
18148
|
}
|
|
18037
|
-
async function customPubLint(pkgDir, pkg, shouldFix = false,
|
|
18149
|
+
async function customPubLint(pkgDir, pkg, shouldFix = false, rules) {
|
|
18038
18150
|
const result = emptyCustomResult();
|
|
18039
|
-
if (
|
|
18040
|
-
if (
|
|
18041
|
-
if (
|
|
18042
|
-
if (
|
|
18043
|
-
if (
|
|
18044
|
-
if (
|
|
18045
|
-
if (
|
|
18046
|
-
if (
|
|
18047
|
-
if (
|
|
18048
|
-
if (
|
|
18049
|
-
if (
|
|
18050
|
-
if (
|
|
18051
|
-
if (
|
|
18151
|
+
if (rules.levels.get("files") !== "off") mergeLeveledResult(result, checkFiles(pkg, shouldFix), "files", rules);
|
|
18152
|
+
if (rules.levels.get("source") !== "off") mergeLeveledResult(result, checkExportsSource(pkg, shouldFix), "source", rules);
|
|
18153
|
+
if (rules.levels.get("rootSource") !== "off") mergeLeveledResult(result, checkRootSource(pkg, shouldFix), "rootSource", rules);
|
|
18154
|
+
if (rules.levels.get("main") !== "off") mergeLeveledResult(result, migrateFieldToExports(pkg, "main", "default", shouldFix), "main", rules);
|
|
18155
|
+
if (rules.levels.get("types") !== "off") mergeLeveledResult(result, migrateFieldToExports(pkg, "types", "types", shouldFix), "types", rules);
|
|
18156
|
+
if (rules.levels.get("module") !== "off") mergeLeveledResult(result, migrateFieldToExports(pkg, "module", "default", shouldFix), "module", rules);
|
|
18157
|
+
if (rules.levels.get("importToDefault") !== "off") mergeLeveledResult(result, checkImportToDefault(pkg, shouldFix), "importToDefault", rules);
|
|
18158
|
+
if (rules.levels.get("neutralToDefault") !== "off") mergeLeveledResult(result, checkNeutralToDefault(pkg, shouldFix, (message) => console.warn(chalk.yellow(message))), "neutralToDefault", rules);
|
|
18159
|
+
if (rules.levels.get("defaultExportOrder") !== "off") mergeLeveledResult(result, checkDefaultExportOrder(pkg, shouldFix, (message) => console.warn(chalk.yellow(message))), "defaultExportOrder", rules);
|
|
18160
|
+
if (rules.levels.get("rootTypes") !== "off") mergeLeveledResult(result, checkRootTypes(pkg, shouldFix), "rootTypes", rules);
|
|
18161
|
+
if (rules.levels.get("platform") !== "off") mergeLeveledResult(result, await checkPlatform(pkgDir, pkg, shouldFix), "platform", rules);
|
|
18162
|
+
if (rules.levels.get("sideEffects") !== "off") mergeLeveledResult(result, checkSideEffects(pkg), "sideEffects", rules);
|
|
18163
|
+
if (rules.levels.get("resolutions") !== "off") mergeLeveledResult(result, checkResolutions(pkg), "resolutions", rules);
|
|
18052
18164
|
return [
|
|
18053
18165
|
result.errors,
|
|
18054
18166
|
result.warnings,
|
|
@@ -18124,42 +18236,89 @@ async function runPublintLibrary(pkgDir, pkg, isStrict, shouldPack) {
|
|
|
18124
18236
|
warnings: messages.filter((message) => message.type !== "error").length
|
|
18125
18237
|
};
|
|
18126
18238
|
}
|
|
18127
|
-
|
|
18239
|
+
function applyEffectiveExcludes(pkg, exclude, rules) {
|
|
18240
|
+
const effectiveExclude = Boolean(pkg.private) ? /* @__PURE__ */ new Set([...exclude, ...PUBLISH_ONLY_CHECKS]) : exclude;
|
|
18241
|
+
for (const check of effectiveExclude) {
|
|
18242
|
+
rules.levels.set(check, "off");
|
|
18243
|
+
rules.explicit.add(check);
|
|
18244
|
+
}
|
|
18245
|
+
}
|
|
18246
|
+
async function runCustomPublintPass(pkgDir, pkg, shouldFix, rules) {
|
|
18247
|
+
const [errors, warnings, modified] = await customPubLint(pkgDir, pkg, shouldFix, rules);
|
|
18248
|
+
if (shouldFix && modified) {
|
|
18249
|
+
await writePackageJson(pkgDir, pkg);
|
|
18250
|
+
return {
|
|
18251
|
+
pkg: await readPackageJson(pkgDir),
|
|
18252
|
+
result: {
|
|
18253
|
+
errors,
|
|
18254
|
+
modified,
|
|
18255
|
+
warnings
|
|
18256
|
+
}
|
|
18257
|
+
};
|
|
18258
|
+
}
|
|
18259
|
+
return {
|
|
18260
|
+
pkg,
|
|
18261
|
+
result: {
|
|
18262
|
+
errors,
|
|
18263
|
+
modified,
|
|
18264
|
+
warnings
|
|
18265
|
+
}
|
|
18266
|
+
};
|
|
18267
|
+
}
|
|
18268
|
+
async function runLeveledPublintLibrary(pkgDir, pkg, isStrict, shouldPack, rules) {
|
|
18269
|
+
const level = rules.levels.get("publint");
|
|
18270
|
+
if (level === "off") return {
|
|
18271
|
+
errors: 0,
|
|
18272
|
+
warnings: 0
|
|
18273
|
+
};
|
|
18274
|
+
const library = await runPublintLibrary(pkgDir, pkg, isStrict, shouldPack);
|
|
18275
|
+
if (!rules.explicit.has("publint")) return library;
|
|
18276
|
+
const issueCount = library.errors + library.warnings;
|
|
18277
|
+
return level === "error" ? {
|
|
18278
|
+
errors: issueCount,
|
|
18279
|
+
warnings: 0
|
|
18280
|
+
} : {
|
|
18281
|
+
errors: 0,
|
|
18282
|
+
warnings: issueCount
|
|
18283
|
+
};
|
|
18284
|
+
}
|
|
18285
|
+
function runLeveledCompileTargets(pkgDir, shouldFix, rules) {
|
|
18286
|
+
const level = rules.levels.get("compileTargets");
|
|
18287
|
+
const raw = level === "off" ? {
|
|
18288
|
+
errors: 0,
|
|
18289
|
+
warnings: 0
|
|
18290
|
+
} : checkCompileTargets(pkgDir, shouldFix);
|
|
18291
|
+
if (!rules.explicit.has("compileTargets")) return raw;
|
|
18292
|
+
const issueCount = raw.errors + raw.warnings;
|
|
18293
|
+
return level === "error" ? {
|
|
18294
|
+
errors: issueCount,
|
|
18295
|
+
warnings: 0
|
|
18296
|
+
} : {
|
|
18297
|
+
errors: 0,
|
|
18298
|
+
warnings: issueCount
|
|
18299
|
+
};
|
|
18300
|
+
}
|
|
18301
|
+
const packagePublintDetailed = async ({ exclude = /* @__PURE__ */ new Set(), ruleLevels, shouldFix = false, shouldPack: shouldPackParam, pkgDir: pkgDirParam, isStrict = isStrictMode(), verbose: _verbose = false } = {}) => {
|
|
18128
18302
|
const pkgDir = PATH.resolve(pkgDirParam ?? INIT_CWD());
|
|
18129
18303
|
const wsPublintConfig = normalizePublintConfig$1(await loadWorkspaceCommandConfig(pkgDir, "publint"));
|
|
18130
|
-
const workspaceExclude = mergeWorkspaceExclude(exclude, wsPublintConfig);
|
|
18131
18304
|
const shouldPack = shouldPackParam ?? wsPublintConfig.pack ?? true;
|
|
18305
|
+
const resolvedRules = ruleLevels === void 0 ? resolvePublintRules(wsPublintConfig) : cloneResolvedPublintRules(ruleLevels);
|
|
18132
18306
|
let pkg = await readPackageJson(pkgDir);
|
|
18133
|
-
|
|
18307
|
+
applyEffectiveExcludes(pkg, exclude, resolvedRules);
|
|
18134
18308
|
console.log(chalk.green(`Publint: ${String(pkg.name)}${Boolean(pkg.private) ? chalk.gray(" (private)") : ""}`));
|
|
18135
18309
|
console.log(chalk.gray(pkgDir));
|
|
18136
|
-
let
|
|
18137
|
-
|
|
18138
|
-
|
|
18139
|
-
|
|
18140
|
-
|
|
18141
|
-
|
|
18142
|
-
|
|
18143
|
-
|
|
18144
|
-
|
|
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);
|
|
18310
|
+
let customResult = emptyCustomResult();
|
|
18311
|
+
if (shouldFix) {
|
|
18312
|
+
const customPass = await runCustomPublintPass(pkgDir, pkg, shouldFix, resolvedRules);
|
|
18313
|
+
customResult = customPass.result;
|
|
18314
|
+
pkg = customPass.pkg;
|
|
18315
|
+
}
|
|
18316
|
+
const library = await runLeveledPublintLibrary(pkgDir, pkg, isStrict, shouldPack, resolvedRules);
|
|
18317
|
+
if (!shouldFix) customResult = (await runCustomPublintPass(pkgDir, pkg, shouldFix, resolvedRules)).result;
|
|
18318
|
+
const compileTargets = runLeveledCompileTargets(pkgDir, shouldFix, resolvedRules);
|
|
18160
18319
|
return {
|
|
18161
|
-
errors:
|
|
18162
|
-
warnings:
|
|
18320
|
+
errors: library.errors + customResult.errors + compileTargets.errors,
|
|
18321
|
+
warnings: library.warnings + customResult.warnings + compileTargets.warnings
|
|
18163
18322
|
};
|
|
18164
18323
|
};
|
|
18165
18324
|
const packagePublint = async (params = {}) => {
|
|
@@ -18168,28 +18327,20 @@ const packagePublint = async (params = {}) => {
|
|
|
18168
18327
|
};
|
|
18169
18328
|
//#endregion
|
|
18170
18329
|
//#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
18330
|
function normalizePublintConfig(value) {
|
|
18185
18331
|
if (typeof value === "object") return value;
|
|
18186
18332
|
return {};
|
|
18187
18333
|
}
|
|
18334
|
+
function offChecks(rules) {
|
|
18335
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
18336
|
+
for (const [check, level] of rules.levels) if (level === "off") excluded.add(check);
|
|
18337
|
+
return excluded;
|
|
18338
|
+
}
|
|
18188
18339
|
async function loadPublintOptions() {
|
|
18189
18340
|
const config = await loadConfig();
|
|
18190
18341
|
const publintConfig = normalizePublintConfig(config.commands?.publint ?? config.publint);
|
|
18191
18342
|
return {
|
|
18192
|
-
exclude:
|
|
18343
|
+
exclude: offChecks(resolvePublintRules(publintConfig)),
|
|
18193
18344
|
pack: publintConfig.pack ?? true
|
|
18194
18345
|
};
|
|
18195
18346
|
}
|