@webpieces/code-rules 0.4.926 → 0.4.928
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/package.json +6 -6
- package/src/api-lib-source-rule.d.ts +1 -1
- package/src/api-lib-source-rule.js +1 -3
- package/src/api-lib-source-rule.js.map +1 -1
- package/src/code-policy-composition.js +10 -1
- package/src/code-policy-composition.js.map +1 -1
- package/src/code-rules-bootstrap.js +1 -1
- package/src/code-rules-bootstrap.js.map +1 -1
- package/src/code-rules-engine.d.ts +3 -1
- package/src/code-rules-engine.js +13 -4
- package/src/code-rules-engine.js.map +1 -1
- package/src/configs/api-lib-spelling-configs.d.ts +2 -4
- package/src/configs/api-lib-spelling-configs.js +2 -8
- package/src/configs/api-lib-spelling-configs.js.map +1 -1
- package/src/configs/no-client-creation-config.d.ts +0 -1
- package/src/configs/no-client-creation-config.js +1 -4
- package/src/configs/no-client-creation-config.js.map +1 -1
- package/src/configs/no-state-paths-config.js +0 -1
- package/src/configs/no-state-paths-config.js.map +1 -1
- package/src/configs/no-utility-types-config.d.ts +1 -2
- package/src/configs/no-utility-types-config.js +1 -4
- package/src/configs/no-utility-types-config.js.map +1 -1
- package/src/configs/required-type-suffix-config.d.ts +1 -2
- package/src/configs/required-type-suffix-config.js +1 -4
- package/src/configs/required-type-suffix-config.js.map +1 -1
- package/src/configs/rule-configs.d.ts +0 -5
- package/src/configs/rule-configs.js +13 -44
- package/src/configs/rule-configs.js.map +1 -1
- package/src/configs/tag-truth-configs.d.ts +4 -2
- package/src/configs/tag-truth-configs.js +4 -4
- package/src/configs/tag-truth-configs.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +7 -2
- package/src/index.js.map +1 -1
- package/src/rule-dispatch.d.ts +30 -0
- package/src/rule-dispatch.js +49 -0
- package/src/rule-dispatch.js.map +1 -0
- package/src/rule-migrations.d.ts +17 -0
- package/src/rule-migrations.js +40 -0
- package/src/rule-migrations.js.map +1 -0
- package/src/rule-pack.js +2 -1
- package/src/rule-pack.js.map +1 -1
- package/src/scan-scope.js +4 -1
- package/src/scan-scope.js.map +1 -1
- package/src/tag-rule.js +1 -14
- package/src/tag-rule.js.map +1 -1
- package/src/validate-catch-error-pattern.js +1 -17
- package/src/validate-catch-error-pattern.js.map +1 -1
- package/src/validate-dtos.js +1 -18
- package/src/validate-dtos.js.map +1 -1
- package/src/validate-ensure-we-are-secure.js +3 -0
- package/src/validate-ensure-we-are-secure.js.map +1 -1
- package/src/validate-framework-packages.js +3 -1
- package/src/validate-framework-packages.js.map +1 -1
- package/src/validate-inject-annotation-not-needed-for-concrete-class.d.ts +1 -1
- package/src/validate-inject-annotation-not-needed-for-concrete-class.js +10 -25
- package/src/validate-inject-annotation-not-needed-for-concrete-class.js.map +1 -1
- package/src/validate-match-rules.d.ts +0 -1
- package/src/validate-match-rules.js +1 -12
- package/src/validate-match-rules.js.map +1 -1
- package/src/validate-modified-files.d.ts +0 -7
- package/src/validate-modified-files.js +8 -22
- package/src/validate-modified-files.js.map +1 -1
- package/src/validate-modified-methods.js +2 -6
- package/src/validate-modified-methods.js.map +1 -1
- package/src/validate-new-methods.js +2 -6
- package/src/validate-new-methods.js.map +1 -1
- package/src/validate-no-any-unknown.js +1 -18
- package/src/validate-no-any-unknown.js.map +1 -1
- package/src/validate-no-client-creation-outside-server-or-client.d.ts +2 -3
- package/src/validate-no-client-creation-outside-server-or-client.js +4 -18
- package/src/validate-no-client-creation-outside-server-or-client.js.map +1 -1
- package/src/validate-no-custom-css.d.ts +0 -1
- package/src/validate-no-custom-css.js +1 -12
- package/src/validate-no-custom-css.js.map +1 -1
- package/src/validate-no-destructure.d.ts +3 -3
- package/src/validate-no-destructure.js +11 -31
- package/src/validate-no-destructure.js.map +1 -1
- package/src/validate-no-direct-api-resolver.js +1 -18
- package/src/validate-no-direct-api-resolver.js.map +1 -1
- package/src/validate-no-function-outside-class.d.ts +3 -3
- package/src/validate-no-function-outside-class.js +11 -25
- package/src/validate-no-function-outside-class.js.map +1 -1
- package/src/validate-no-implicit-any.js +1 -14
- package/src/validate-no-implicit-any.js.map +1 -1
- package/src/validate-no-inline-types.js +1 -18
- package/src/validate-no-inline-types.js.map +1 -1
- package/src/validate-no-process-exit-outside-main.js +1 -12
- package/src/validate-no-process-exit-outside-main.js.map +1 -1
- package/src/validate-no-state-paths-in-templates.d.ts +0 -1
- package/src/validate-no-state-paths-in-templates.js +1 -12
- package/src/validate-no-state-paths-in-templates.js.map +1 -1
- package/src/validate-no-symbol-di-tokens.d.ts +2 -2
- package/src/validate-no-symbol-di-tokens.js +9 -65
- package/src/validate-no-symbol-di-tokens.js.map +1 -1
- package/src/validate-no-unmanaged-exceptions.js +1 -17
- package/src/validate-no-unmanaged-exceptions.js.map +1 -1
- package/src/validate-prisma-converters.js +1 -18
- package/src/validate-prisma-converters.js.map +1 -1
- package/src/validate-return-types.js +1 -18
- package/src/validate-return-types.js.map +1 -1
- package/src/resolve-mode.d.ts +0 -2
- package/src/resolve-mode.js +0 -11
- package/src/resolve-mode.js.map +0 -1
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/index.ts"],"names":[],"mappings":";;;;;;AAAA,mDAAiE;AAAxD,+GAAA,aAAa,OAAA;AAEtB,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,uEAAoE;AAA3D,kIAAA,sBAAsB,OAAA;AAC/B,yEAA0F;AAAjF,oIAAA,uBAAuB,OAAA;AAAE,+HAAA,kBAAkB,OAAA;AACpD,+DAAuD;AAA9C,qHAAA,aAAa,OAAA;AACtB,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,iEAAqE;AAA5D,mIAAA,0BAA0B,OAAA;AACnC,uEAA2E;AAAlE,yIAAA,6BAA6B,OAAA;AACtC,+EAA4E;AAAnE,0IAAA,0BAA0B,OAAA;AACnC,uFAAoF;AAA3E,kJAA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B,OAAA;AAAE,oHAAA,oBAAoB,OAAA;AAAE,kHAAA,kBAAkB,OAAA;AAAE,uHAAA,uBAAuB,OAAA;AAAE,0HAAA,0BAA0B,OAAA;AAAE,kHAAA,kBAAkB,OAAA;AAAE,mHAAA,mBAAmB,OAAA;AAAE,wHAAA,wBAAwB,OAAA;AAAE,qHAAA,qBAAqB,OAAA;AAAE,mHAAA,mBAAmB,OAAA;AAAE,2HAAA,2BAA2B,OAAA;AAAE,uHAAA,uBAAuB,OAAA;AAAE,kIAAA,kCAAkC,OAAA;AAAE,iHAAA,iBAAiB,OAAA;AAAE,sHAAA,sBAAsB,OAAA;AAAE,8HAAA,8BAA8B,OAAA;AAAE,4HAAA,4BAA4B,OAAA;AAAE,+IAAA,+CAA+C,OAAA;AAAE,kHAAA,kBAAkB,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,uHAAA,uBAAuB,OAAA;AAEppB,iFAA8H;AAArH,uIAAA,0BAA0B,OAAA;AAAE,wJAAA,2CAA2C,OAAA;AAEhF,yEAA2I;AAAlI,8HAAA,qBAAqB,OAAA;AAAE,2IAAA,kCAAkC,OAAA;AAAE,sIAAA,6BAA6B,OAAA;AACjG,+EAAiH;AAAxG,wIAAA,4BAA4B,OAAA;AAAE,yIAAA,6BAA6B,OAAA;AACpE,6EAAiF;AAAxE,uIAAA,4BAA4B,OAAA;AACrC,qFAA0G;AAAjG,sIAAA,uBAAuB,OAAA;AAAE,uIAAA,wBAAwB,OAAA;AAC1D,iEAA2I;AAAlI,uHAAA,kBAAkB,OAAA;AAAE,4HAAA,uBAAuB,OAAA;AAAE,2HAAA,sBAAsB,OAAA;AAAE,4HAAA,uBAAuB,OAAA","sourcesContent":["export { CodeValidator, ExecutorResult } from './code-validator';\n\nexport { NoAnyUnknownValidator } from './validate-no-any-unknown';\nexport { NoImplicitAnyValidator } from './validate-no-implicit-any';\nexport { MaxMethodLinesValidator, runModifiedMethods } from './validate-modified-methods';\nexport { runNewMethods } from './validate-new-methods';\nexport { MaxFileLinesValidator } from './validate-modified-files';\nexport { RequireReturnTypeValidator } from './validate-return-types';\nexport { NoInlineTypeLiteralsValidator } from './validate-no-inline-types';\nexport { CatchErrorPatternValidator } from './validate-catch-error-pattern';\nexport { NoUnmanagedExceptionsValidator } from './validate-no-unmanaged-exceptions';\nexport { NoDestructureValidator } from './validate-no-destructure';\nexport { NoDirectApiResolverValidator } from './validate-no-direct-api-resolver';\nexport { NoSymbolDiTokensValidator } from './validate-no-symbol-di-tokens';\nexport { NoClientCreationOutsideServerOrClientValidator } from './validate-no-client-creation-outside-server-or-client';\nexport {\n NoStatePathsInTemplatesValidator,\n StatePathHit,\n StatePathViolation,\n} from './validate-no-state-paths-in-templates';\nexport { ProjectRoleResolver } from './project-role-resolver';\nexport { NoProcessExitOutsideMainValidator } from './validate-no-process-exit-outside-main';\nexport { NoFunctionOutsideClassValidator } from './validate-no-function-outside-class';\nexport {\n InjectAnnotationNotNeededForConcreteClassValidator,\n findRedundantInjectInSource,\n} from './validate-inject-annotation-not-needed-for-concrete-class';\nexport { FrameworkTagValidator } from './validate-framework-tag';\nexport { RoleTagValidator } from './validate-role-tag';\nexport {\n EnsureWeAreSecureValidator,\n SecurityContractViolation,\n auditSecurityContracts,\n findDirectlyChangedProjectRoots,\n} from './validate-ensure-we-are-secure';\nexport { ApiLibFile, ApiLibSite } from './api-lib-source-rule';\nexport { NoInlineImportInApiLibValidator, InlineImportScanner } from './validate-no-inline-import-in-api-lib';\nexport { OneEnumSpellingInApiLibValidator, EnumSpellingScanner } from './validate-one-enum-spelling-in-api-lib';\nexport { NoUtilityTypesInApiLibValidator, UtilityTypeScanner } from './validate-no-utility-types-in-api-lib';\nexport {\n RequiredTypeSuffixValidator,\n ExportedTypeScanner,\n SuffixEntryPicker,\n SuffixRename,\n GoverningGlob,\n} from './validate-required-type-suffix';\nexport { ApiLibEnumIndex } from './api-lib-enum-index';\nexport { ProjectScanTargets, ScannedProject } from './project-scan-targets';\nexport {\n FrameworkTsconfigValidator,\n FrameworkTsconfigAudit,\n RuntimeCompilerOptions,\n TsconfigRuntimeViolation,\n frameworkTsconfigError,\n} from './validate-framework-tsconfig';\nexport {\n FrameworkPackagesValidator,\n FrameworkPackagesAudit,\n FrameworkPackageViolation,\n frameworkPackagesError,\n} from './validate-framework-packages';\nexport { EnumText } from './api-lib-enum-text';\nexport { PrismaValidateDtosValidator } from './validate-dtos';\nexport { PrismaConverterValidator } from './validate-prisma-converters';\nexport { default as validateCode } from './validate-code';\nexport { CodeRulesBootstrap } from './code-rules-bootstrap';\nexport { CodeRulesRunRequest, RuleSelection, RunRequestParser } from './code-rules-run-request';\nexport { ScanScope, GateScanScope, ScanRestriction, ProjectCatalog, ProjectEntry, RecordedSite } from './scan-scope';\n// Where code-rules applies the framework-owned path exclusions to every rule it composes (#1253).\nexport { ExclusionScopedPolicy, GlobalExcludePaths, RuleExclusionsFactory } from './rule-dispatch';\n\nexport { ReactNativeCompatibility } from './react-native-compatibility';\n\nexport { METHOD_LIMIT_MODES, RETURN_TYPE_MODES, INLINE_TYPE_MODES, PROJECT_MODES, PRISMA_DTOS_MODES, PRISMA_CONVERTER_MODES, DIRECT_API_RESOLVER_MODES, MaxMethodLinesConfig, MaxFileLinesConfig, RequireReturnTypeConfig, NoInlineTypeLiteralsConfig, NoAnyUnknownConfig, NoImplicitAnyConfig, PrismaValidateDtosConfig, PrismaConverterConfig, NoDestructureConfig, NoUnmanagedExceptionsConfig, CatchErrorPatternConfig, AngularNoDirectApiInResolverConfig, NoCustomCssConfig, NoSymbolDiTokensConfig, NoProcessExitOutsideMainConfig, NoFunctionOutsideClassConfig, InjectAnnotationNotNeededForConcreteClassConfig, FrameworkTagConfig, RoleTagConfig, EnsureWeAreSecureConfig } from './configs/rule-configs';\nexport type { MethodLimitMode, ReturnTypeMode, InlineTypeMode, ProjectMode, PrismaValidateDtosMode, PrismaConverterMode, DirectApiResolverMode } from './configs/rule-configs';\nexport { CLIENT_CREATION_SEVERITIES, NoClientCreationOutsideServerOrClientConfig } from './configs/no-client-creation-config';\nexport type { ClientCreationSeverity } from './configs/no-client-creation-config';\nexport { DEFAULT_TEMPLATE_DIRS, DEFAULT_BANNED_STATE_PATH_PREFIXES, NoStatePathsInTemplatesConfig } from './configs/no-state-paths-config';\nexport { NoInlineImportInApiLibConfig, OneEnumSpellingInApiLibConfig } from './configs/api-lib-spelling-configs';\nexport { NoUtilityTypesInApiLibConfig } from './configs/no-utility-types-config';\nexport { RequiredTypeSuffixEntry, RequiredTypeSuffixConfig } from './configs/required-type-suffix-config';\nexport { PROJECT_SCAN_MODES, FrameworkTsconfigConfig, FrameworkPackagesEntry, FrameworkPackagesConfig } from './configs/tag-truth-configs';\nexport type { ProjectScanMode } from './configs/tag-truth-configs';\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseRuleConfig, BuildPolicy, BuildPolicyResult } from '@webpieces/rules-sdk';
|
|
2
|
+
import { RuleFileExclusions } from '@webpieces/rules-config';
|
|
3
|
+
/**
|
|
4
|
+
* The repo's top-level `excludePaths` (webpieces.config.json), bound at the composition root from the
|
|
5
|
+
* runtime request — the globs NO rule judges, in the build as in the hooks (#1253). Data-only.
|
|
6
|
+
*/
|
|
7
|
+
export declare class GlobalExcludePaths {
|
|
8
|
+
readonly paths: readonly string[];
|
|
9
|
+
constructor(paths: readonly string[]);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Where code-rules APPLIES the framework-owned path exclusions (#1253): every validator the runtime
|
|
13
|
+
* composes is wrapped in this, so its `run` happens inside a {@link RuleFileScope} carrying the global
|
|
14
|
+
* list plus the rule's own `excludePaths`, and every file listing it asks DiffScope / ScanScope for has
|
|
15
|
+
* those files removed. The validator carries no exclusion code, so a rule added to CODE_POLICIES later
|
|
16
|
+
* is covered by construction. The skip check stays where it was — `shouldRun()` — and is delegated.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ExclusionScopedPolicy implements BuildPolicy {
|
|
19
|
+
private readonly inner;
|
|
20
|
+
readonly exclusions: RuleFileExclusions;
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly configKey: string;
|
|
23
|
+
constructor(inner: BuildPolicy, exclusions: RuleFileExclusions);
|
|
24
|
+
shouldRun(): boolean;
|
|
25
|
+
run(workspaceRoot: string): Promise<BuildPolicyResult>;
|
|
26
|
+
}
|
|
27
|
+
/** Builds the exclusions of one rule run from the global list and the rule's validated config. */
|
|
28
|
+
export declare class RuleExclusionsFactory {
|
|
29
|
+
forRule(ruleName: string, global: GlobalExcludePaths, config: BaseRuleConfig): RuleFileExclusions;
|
|
30
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RuleExclusionsFactory = exports.ExclusionScopedPolicy = exports.GlobalExcludePaths = void 0;
|
|
4
|
+
const rules_config_1 = require("@webpieces/rules-config");
|
|
5
|
+
/**
|
|
6
|
+
* The repo's top-level `excludePaths` (webpieces.config.json), bound at the composition root from the
|
|
7
|
+
* runtime request — the globs NO rule judges, in the build as in the hooks (#1253). Data-only.
|
|
8
|
+
*/
|
|
9
|
+
class GlobalExcludePaths {
|
|
10
|
+
paths;
|
|
11
|
+
constructor(paths) {
|
|
12
|
+
this.paths = paths;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.GlobalExcludePaths = GlobalExcludePaths;
|
|
16
|
+
/**
|
|
17
|
+
* Where code-rules APPLIES the framework-owned path exclusions (#1253): every validator the runtime
|
|
18
|
+
* composes is wrapped in this, so its `run` happens inside a {@link RuleFileScope} carrying the global
|
|
19
|
+
* list plus the rule's own `excludePaths`, and every file listing it asks DiffScope / ScanScope for has
|
|
20
|
+
* those files removed. The validator carries no exclusion code, so a rule added to CODE_POLICIES later
|
|
21
|
+
* is covered by construction. The skip check stays where it was — `shouldRun()` — and is delegated.
|
|
22
|
+
*/
|
|
23
|
+
class ExclusionScopedPolicy {
|
|
24
|
+
inner;
|
|
25
|
+
exclusions;
|
|
26
|
+
name;
|
|
27
|
+
configKey;
|
|
28
|
+
constructor(inner, exclusions) {
|
|
29
|
+
this.inner = inner;
|
|
30
|
+
this.exclusions = exclusions;
|
|
31
|
+
this.name = inner.name;
|
|
32
|
+
this.configKey = inner.configKey;
|
|
33
|
+
}
|
|
34
|
+
shouldRun() {
|
|
35
|
+
return this.inner.shouldRun();
|
|
36
|
+
}
|
|
37
|
+
async run(workspaceRoot) {
|
|
38
|
+
return new rules_config_1.RuleFileScope().runWithin(this.exclusions, () => this.inner.run(workspaceRoot));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.ExclusionScopedPolicy = ExclusionScopedPolicy;
|
|
42
|
+
/** Builds the exclusions of one rule run from the global list and the rule's validated config. */
|
|
43
|
+
class RuleExclusionsFactory {
|
|
44
|
+
forRule(ruleName, global, config) {
|
|
45
|
+
return new rules_config_1.RuleFileExclusions(ruleName, global.paths, config.excludePaths ?? []);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.RuleExclusionsFactory = RuleExclusionsFactory;
|
|
49
|
+
//# sourceMappingURL=rule-dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-dispatch.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/rule-dispatch.ts"],"names":[],"mappings":";;;AACA,0DAA4E;AAE5E;;;GAGG;AACH,MAAa,kBAAkB;IACN;IAArB,YAAqB,KAAwB;QAAxB,UAAK,GAAL,KAAK,CAAmB;IAAG,CAAC;CACpD;AAFD,gDAEC;AAED;;;;;;GAMG;AACH,MAAa,qBAAqB;IAKT;IACR;IALJ,IAAI,CAAS;IACb,SAAS,CAAS;IAE3B,YACqB,KAAkB,EAC1B,UAA8B;QADtB,UAAK,GAAL,KAAK,CAAa;QAC1B,eAAU,GAAV,UAAU,CAAoB;QAEvC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IACrC,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,aAAqB;QAC3B,OAAO,IAAI,4BAAa,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/F,CAAC;CACJ;AAnBD,sDAmBC;AAED,kGAAkG;AAClG,MAAa,qBAAqB;IAC9B,OAAO,CAAC,QAAgB,EAAE,MAA0B,EAAE,MAAsB;QACxE,OAAO,IAAI,iCAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;IACrF,CAAC;CACJ;AAJD,sDAIC","sourcesContent":["import { BaseRuleConfig, BuildPolicy, BuildPolicyResult } from '@webpieces/rules-sdk';\nimport { RuleFileExclusions, RuleFileScope } from '@webpieces/rules-config';\n\n/**\n * The repo's top-level `excludePaths` (webpieces.config.json), bound at the composition root from the\n * runtime request — the globs NO rule judges, in the build as in the hooks (#1253). Data-only.\n */\nexport class GlobalExcludePaths {\n constructor(readonly paths: readonly string[]) {}\n}\n\n/**\n * Where code-rules APPLIES the framework-owned path exclusions (#1253): every validator the runtime\n * composes is wrapped in this, so its `run` happens inside a {@link RuleFileScope} carrying the global\n * list plus the rule's own `excludePaths`, and every file listing it asks DiffScope / ScanScope for has\n * those files removed. The validator carries no exclusion code, so a rule added to CODE_POLICIES later\n * is covered by construction. The skip check stays where it was — `shouldRun()` — and is delegated.\n */\nexport class ExclusionScopedPolicy implements BuildPolicy {\n readonly name: string;\n readonly configKey: string;\n\n constructor(\n private readonly inner: BuildPolicy,\n readonly exclusions: RuleFileExclusions,\n ) {\n this.name = inner.name;\n this.configKey = inner.configKey;\n }\n\n shouldRun(): boolean {\n return this.inner.shouldRun();\n }\n\n async run(workspaceRoot: string): Promise<BuildPolicyResult> {\n return new RuleFileScope().runWithin(this.exclusions, () => this.inner.run(workspaceRoot));\n }\n}\n\n/** Builds the exclusions of one rule run from the global list and the rule's validated config. */\nexport class RuleExclusionsFactory {\n forRule(ruleName: string, global: GlobalExcludePaths, config: BaseRuleConfig): RuleFileExclusions {\n return new RuleFileExclusions(ruleName, global.paths, config.excludePaths ?? []);\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RetiredConfigKey } from '@webpieces/rules-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* The rules whose own `allowedPaths` meant "do not judge these files" (#1253). That field is gone: the
|
|
4
|
+
* framework-owned `excludePaths`, which EVERY rule accepts and the dispatcher applies, replaced it.
|
|
5
|
+
* There is no alias — the old key fails the config load with this instruction.
|
|
6
|
+
*/
|
|
7
|
+
export declare const RENAMED_ALLOWED_PATHS_RULES: readonly string[];
|
|
8
|
+
/**
|
|
9
|
+
* The exact edit for one retired `<rule>.allowedPaths` (#1253). Generic over the rule id, so the
|
|
10
|
+
* sentence is written once for all ten rules.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AllowedPathsMigration {
|
|
13
|
+
instruction(ruleId: string): string;
|
|
14
|
+
retired(ruleId: string): RetiredConfigKey;
|
|
15
|
+
}
|
|
16
|
+
/** Rejected obsolete code-rules fields, each with its exact repair instruction. */
|
|
17
|
+
export declare const ruleMigrations: readonly RetiredConfigKey[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ruleMigrations = exports.AllowedPathsMigration = exports.RENAMED_ALLOWED_PATHS_RULES = void 0;
|
|
4
|
+
const rules_sdk_1 = require("@webpieces/rules-sdk");
|
|
5
|
+
/**
|
|
6
|
+
* The rules whose own `allowedPaths` meant "do not judge these files" (#1253). That field is gone: the
|
|
7
|
+
* framework-owned `excludePaths`, which EVERY rule accepts and the dispatcher applies, replaced it.
|
|
8
|
+
* There is no alias — the old key fails the config load with this instruction.
|
|
9
|
+
*/
|
|
10
|
+
exports.RENAMED_ALLOWED_PATHS_RULES = [
|
|
11
|
+
'max-file-lines',
|
|
12
|
+
'no-destructure',
|
|
13
|
+
'no-symbol-di-tokens',
|
|
14
|
+
'no-function-outside-class',
|
|
15
|
+
'inject-annotation-not-needed-for-concrete-class',
|
|
16
|
+
'no-client-creation-outside-server-or-client',
|
|
17
|
+
'one-enum-spelling-in-api-lib',
|
|
18
|
+
'no-inline-import-in-api-lib',
|
|
19
|
+
'no-utility-types-in-api-lib',
|
|
20
|
+
'required-type-suffix',
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* The exact edit for one retired `<rule>.allowedPaths` (#1253). Generic over the rule id, so the
|
|
24
|
+
* sentence is written once for all ten rules.
|
|
25
|
+
*/
|
|
26
|
+
class AllowedPathsMigration {
|
|
27
|
+
instruction(ruleId) {
|
|
28
|
+
return (`"allowedPaths" was renamed to "excludePaths" — a framework field every rule now accepts (#1253). ` +
|
|
29
|
+
`Rename the key inside the "${ruleId}" entry and keep its globs; they are matched against the ` +
|
|
30
|
+
`workspace-relative path ("**" any depth, "*" one segment), so write a tree as "dir/**". To exclude ` +
|
|
31
|
+
`a path from EVERY rule instead, list it in the top-level "excludePaths" of webpieces.config.json.`);
|
|
32
|
+
}
|
|
33
|
+
retired(ruleId) {
|
|
34
|
+
return new rules_sdk_1.RetiredConfigKey('field', `${ruleId}.allowedPaths`, `${ruleId}.excludePaths`, this.instruction(ruleId), `[${ruleId}]`, false);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.AllowedPathsMigration = AllowedPathsMigration;
|
|
38
|
+
/** Rejected obsolete code-rules fields, each with its exact repair instruction. */
|
|
39
|
+
exports.ruleMigrations = exports.RENAMED_ALLOWED_PATHS_RULES.map((ruleId) => new AllowedPathsMigration().retired(ruleId));
|
|
40
|
+
//# sourceMappingURL=rule-migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-migrations.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/rule-migrations.ts"],"names":[],"mappings":";;;AAAA,oDAAwD;AAExD;;;;GAIG;AACU,QAAA,2BAA2B,GAAsB;IAC1D,gBAAgB;IAChB,gBAAgB;IAChB,qBAAqB;IACrB,2BAA2B;IAC3B,iDAAiD;IACjD,6CAA6C;IAC7C,8BAA8B;IAC9B,6BAA6B;IAC7B,6BAA6B;IAC7B,sBAAsB;CACzB,CAAC;AAEF;;;GAGG;AACH,MAAa,qBAAqB;IAC9B,WAAW,CAAC,MAAc;QACtB,OAAO,CACH,mGAAmG;YACnG,8BAA8B,MAAM,2DAA2D;YAC/F,qGAAqG;YACrG,mGAAmG,CACtG,CAAC;IACN,CAAC;IAED,OAAO,CAAC,MAAc;QAClB,OAAO,IAAI,4BAAgB,CACvB,OAAO,EACP,GAAG,MAAM,eAAe,EACxB,GAAG,MAAM,eAAe,EACxB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EACxB,IAAI,MAAM,GAAG,EACb,KAAK,CACR,CAAC;IACN,CAAC;CACJ;AApBD,sDAoBC;AAED,mFAAmF;AACtE,QAAA,cAAc,GAAgC,mCAA2B,CAAC,GAAG,CACtF,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,qBAAqB,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAClE,CAAC","sourcesContent":["import { RetiredConfigKey } from '@webpieces/rules-sdk';\n\n/**\n * The rules whose own `allowedPaths` meant \"do not judge these files\" (#1253). That field is gone: the\n * framework-owned `excludePaths`, which EVERY rule accepts and the dispatcher applies, replaced it.\n * There is no alias — the old key fails the config load with this instruction.\n */\nexport const RENAMED_ALLOWED_PATHS_RULES: readonly string[] = [\n 'max-file-lines',\n 'no-destructure',\n 'no-symbol-di-tokens',\n 'no-function-outside-class',\n 'inject-annotation-not-needed-for-concrete-class',\n 'no-client-creation-outside-server-or-client',\n 'one-enum-spelling-in-api-lib',\n 'no-inline-import-in-api-lib',\n 'no-utility-types-in-api-lib',\n 'required-type-suffix',\n];\n\n/**\n * The exact edit for one retired `<rule>.allowedPaths` (#1253). Generic over the rule id, so the\n * sentence is written once for all ten rules.\n */\nexport class AllowedPathsMigration {\n instruction(ruleId: string): string {\n return (\n `\"allowedPaths\" was renamed to \"excludePaths\" — a framework field every rule now accepts (#1253). ` +\n `Rename the key inside the \"${ruleId}\" entry and keep its globs; they are matched against the ` +\n `workspace-relative path (\"**\" any depth, \"*\" one segment), so write a tree as \"dir/**\". To exclude ` +\n `a path from EVERY rule instead, list it in the top-level \"excludePaths\" of webpieces.config.json.`\n );\n }\n\n retired(ruleId: string): RetiredConfigKey {\n return new RetiredConfigKey(\n 'field',\n `${ruleId}.allowedPaths`,\n `${ruleId}.excludePaths`,\n this.instruction(ruleId),\n `[${ruleId}]`,\n false,\n );\n }\n}\n\n/** Rejected obsolete code-rules fields, each with its exact repair instruction. */\nexport const ruleMigrations: readonly RetiredConfigKey[] = RENAMED_ALLOWED_PATHS_RULES.map(\n (ruleId: string) => new AllowedPathsMigration().retired(ruleId),\n);\n"]}
|
package/src/rule-pack.js
CHANGED
|
@@ -5,7 +5,8 @@ const rule_help_1 = require("./rule-help");
|
|
|
5
5
|
const rule_settings_1 = require("./rule-settings");
|
|
6
6
|
const rules_sdk_1 = require("@webpieces/rules-sdk");
|
|
7
7
|
const code_policy_registry_1 = require("./code-policy-registry");
|
|
8
|
+
const rule_migrations_1 = require("./rule-migrations");
|
|
8
9
|
const package_json_1 = require("../package.json");
|
|
9
10
|
/** The code owner publishes the same definitions its composition root binds. */
|
|
10
|
-
exports.rulePackManifest = new rules_sdk_1.RulePackManifest('@webpieces/code-rules', package_json_1.version, rules_sdk_1.RULE_PACK_API_VERSION, code_policy_registry_1.CODE_POLICIES.map((binding) => new rules_sdk_1.OwnedRuleDefinition(binding.ruleId, binding.schema, rules_sdk_1.RULE_SCHEMA_API_VERSION, rule_settings_1.optionalTuning[binding.ruleId], rule_settings_1.recommendedSeeds[binding.ruleId], 'rules', rule_help_1.ruleHelp[binding.ruleId])), code_policy_registry_1.CODE_POLICIES.map((binding) => new rules_sdk_1.RuleContribution(binding.ruleId, '@webpieces/code-rules', 'build', '@webpieces/code-rules/rule-runtime')),
|
|
11
|
+
exports.rulePackManifest = new rules_sdk_1.RulePackManifest('@webpieces/code-rules', package_json_1.version, rules_sdk_1.RULE_PACK_API_VERSION, code_policy_registry_1.CODE_POLICIES.map((binding) => new rules_sdk_1.OwnedRuleDefinition(binding.ruleId, binding.schema, rules_sdk_1.RULE_SCHEMA_API_VERSION, rule_settings_1.optionalTuning[binding.ruleId], rule_settings_1.recommendedSeeds[binding.ruleId], 'rules', rule_help_1.ruleHelp[binding.ruleId])), code_policy_registry_1.CODE_POLICIES.map((binding) => new rules_sdk_1.RuleContribution(binding.ruleId, '@webpieces/code-rules', 'build', '@webpieces/code-rules/rule-runtime')), rule_migrations_1.ruleMigrations, []);
|
|
11
12
|
//# sourceMappingURL=rule-pack.js.map
|
package/src/rule-pack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-pack.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/rule-pack.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AACvC,mDAAmE;AACnE,oDAM8B;AAC9B,iEAAmE;AACnE,kDAA0C;AAE1C,gFAAgF;AACnE,QAAA,gBAAgB,GAAG,IAAI,4BAAgB,CAChD,uBAAuB,EACvB,sBAAO,EACP,iCAAqB,EACrB,oCAAa,CAAC,GAAG,CACb,CAAC,OAAmB,EAAE,EAAE,CACpB,IAAI,+BAAmB,CACnB,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,MAAM,EACd,mCAAuB,EACvB,8BAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAC9B,gCAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,EAChC,OAAO,EACP,oBAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAC3B,CACR,EACD,oCAAa,CAAC,GAAG,CACb,CAAC,OAAmB,EAAE,EAAE,CACpB,IAAI,4BAAgB,CAChB,OAAO,CAAC,MAAM,EACd,uBAAuB,EACvB,OAAO,EACP,oCAAoC,CACvC,CACR,EACD,
|
|
1
|
+
{"version":3,"file":"rule-pack.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/rule-pack.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AACvC,mDAAmE;AACnE,oDAM8B;AAC9B,iEAAmE;AACnE,uDAAmD;AACnD,kDAA0C;AAE1C,gFAAgF;AACnE,QAAA,gBAAgB,GAAG,IAAI,4BAAgB,CAChD,uBAAuB,EACvB,sBAAO,EACP,iCAAqB,EACrB,oCAAa,CAAC,GAAG,CACb,CAAC,OAAmB,EAAE,EAAE,CACpB,IAAI,+BAAmB,CACnB,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,MAAM,EACd,mCAAuB,EACvB,8BAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAC9B,gCAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,EAChC,OAAO,EACP,oBAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAC3B,CACR,EACD,oCAAa,CAAC,GAAG,CACb,CAAC,OAAmB,EAAE,EAAE,CACpB,IAAI,4BAAgB,CAChB,OAAO,CAAC,MAAM,EACd,uBAAuB,EACvB,OAAO,EACP,oCAAoC,CACvC,CACR,EACD,gCAAc,EACd,EAAE,CACL,CAAC","sourcesContent":["import { ruleHelp } from './rule-help';\nimport { optionalTuning, recommendedSeeds } from './rule-settings';\nimport {\n OwnedRuleDefinition,\n RuleContribution,\n RulePackManifest,\n RULE_PACK_API_VERSION,\n RULE_SCHEMA_API_VERSION,\n} from '@webpieces/rules-sdk';\nimport { CODE_POLICIES, CodePolicy } from './code-policy-registry';\nimport { ruleMigrations } from './rule-migrations';\nimport { version } from '../package.json';\n\n/** The code owner publishes the same definitions its composition root binds. */\nexport const rulePackManifest = new RulePackManifest(\n '@webpieces/code-rules',\n version,\n RULE_PACK_API_VERSION,\n CODE_POLICIES.map(\n (binding: CodePolicy) =>\n new OwnedRuleDefinition(\n binding.ruleId,\n binding.schema,\n RULE_SCHEMA_API_VERSION,\n optionalTuning[binding.ruleId],\n recommendedSeeds[binding.ruleId],\n 'rules',\n ruleHelp[binding.ruleId],\n ),\n ),\n CODE_POLICIES.map(\n (binding: CodePolicy) =>\n new RuleContribution(\n binding.ruleId,\n '@webpieces/code-rules',\n 'build',\n '@webpieces/code-rules/rule-runtime',\n ),\n ),\n ruleMigrations,\n [],\n);\n"]}
|
package/src/scan-scope.js
CHANGED
|
@@ -67,7 +67,10 @@ let ProjectCatalog = class ProjectCatalog {
|
|
|
67
67
|
return best;
|
|
68
68
|
}
|
|
69
69
|
load(workspaceRoot) {
|
|
70
|
-
|
|
70
|
+
// OUTSIDE any rule run's path exclusions (#1253): the catalog is cached across rules, so one rule's
|
|
71
|
+
// excludePaths must never hide a project from the next. Excluded FILES are dropped by their listing.
|
|
72
|
+
const listed = new rules_config_1.RuleFileScope().outside(() => this.diffScope.getAllFiles(workspaceRoot, { tsOnly: false }));
|
|
73
|
+
const jsons = listed
|
|
71
74
|
.filter((f) => f === 'project.json' || f.endsWith('/project.json'));
|
|
72
75
|
return jsons.map((rel) => {
|
|
73
76
|
const dir = path.posix.dirname(rel) === '.' ? '' : path.posix.dirname(rel);
|
package/src/scan-scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-scope.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/scan-scope.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;AAEH,+CAAyB;AACzB,mDAA6B;AAC7B,0DAAyE;AAEzE,8DAA0D;AAC1D,iEAA6D;AAC7D,yCAA2D;AAE3D,oGAAoG;AACpG,MAAa,YAA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,SAAS,CAAC,CAAC,CAAC;IACpF,CAAC;CACJ;AALD,sCAKC","sourcesContent":["/**\n * Which FILES a diff-scoped code rule judges, for every mode it offers — and the one place the per-run\n * `--projects` restriction of the debug run (#1027) is applied.\n *\n * NEW_AND_MODIFIED_CODE — the changed files (the rule then keeps only sites on changed lines)\n * NEW_AND_MODIFIED_FILES — the changed files, whole\n * MODIFIED_PROJECTS — every in-scope file of every project the diff touches, whole, plus the\n * changed files themselves (so it is never narrower than NEW_AND_MODIFIED_FILES)\n * RUN_EVERY_TIME — every in-scope file in the repo, whole, every run\n *\n * The two whole-scope modes are NEW_AND_MODIFIED_FILES over a bigger file set — the rule's own detection,\n * disable handling and failure text are untouched, which is what lets a debug run print exactly what the\n * gate would print. A rule asks {@link ScanScope.files} instead of `getChangedFiles`, and asks\n * {@link ScanScope.isLineScoped} instead of comparing its mode to NEW_AND_MODIFIED_CODE.\n *\n * Every rule that reads its files here also reports its sites through {@link ScanScope.recordSites}, so\n * the debug run can print a count per project without parsing any rule's output.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { ChangedFilesOptions, DiffScope } from \"@webpieces/rules-config\";\nimport { ModifiedCodeMode } from '@webpieces/rules-sdk';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { injectable, bindingScopeValues } from 'inversify';\n\n/** One nx project: its name and its directory (repo-relative, '/'-separated, no trailing slash). */\nexport class ProjectEntry {\n constructor(\n readonly name: string,\n readonly dir: string,\n ) {}\n}\n\n/** The only field of a project.json this catalog reads. */\ntype RawProjectName = { name?: string };\n\n/**\n * The repo's nx projects, found from the `project.json` files git knows about (tracked or untracked,\n * never ignored), and the owner lookup every whole-scope mode and `--projects` filter uses: a file\n * belongs to the DEEPEST project directory containing it.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ProjectCatalog {\n private cachedRoot: string | undefined;\n private cached: ProjectEntry[] = [];\n\n constructor(private readonly diffScope: DiffScope) {}\n\n all(workspaceRoot: string): ProjectEntry[] {\n if (this.cachedRoot !== workspaceRoot) {\n this.cached = this.load(workspaceRoot);\n this.cachedRoot = workspaceRoot;\n }\n return this.cached;\n }\n\n /** The project owning `relFile`, or undefined when no project directory contains it. */\n ownerOf(workspaceRoot: string, relFile: string): ProjectEntry | undefined {\n const file = relFile.split(path.sep).join('/');\n let best: ProjectEntry | undefined;\n for (const project of this.all(workspaceRoot)) {\n const inside = project.dir === '' || file.startsWith(`${project.dir}/`);\n if (inside && (best === undefined || project.dir.length > best.dir.length)) best = project;\n }\n return best;\n }\n\n private load(workspaceRoot: string): ProjectEntry[] {\n const jsons = this.diffScope.getAllFiles(workspaceRoot, { tsOnly: false })\n .filter((f: string) => f === 'project.json' || f.endsWith('/project.json'));\n return jsons.map((rel: string) => {\n const dir = path.posix.dirname(rel) === '.' ? '' : path.posix.dirname(rel);\n return new ProjectEntry(this.readName(path.join(workspaceRoot, rel)) ?? path.posix.basename(dir), dir);\n });\n }\n\n private readName(fullPath: string): string | undefined {\n // webpieces-disable no-unmanaged-exceptions -- add the exact project.json path while preserving the parse/read failure as cause\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const parsed = JSON.parse(fs.readFileSync(fullPath, 'utf-8')) as RawProjectName;\n return typeof parsed.name === 'string' && parsed.name.length > 0 ? parsed.name : undefined;\n } catch (err: unknown) {\n const error = toError(err);\n throw new InformAiError(`Cannot read nx project identity from ${fullPath} — fix project.json and retry.`, {\n cause: error,\n });\n }\n }\n}\n\n/**\n * The per-run project restriction. Bound at the composition root: `undefined` for every normal run (the\n * gate), the `--projects` names for a debug run. Data-only.\n */\nexport class ScanRestriction {\n constructor(readonly projectNames: readonly string[] | undefined) {}\n}\n\n/** One recorded violating site: which rule, which file. Data-only. */\nexport class RecordedSite {\n constructor(\n readonly ruleName: string,\n readonly relFile: string,\n ) {}\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class ScanScope {\n private readonly sites: RecordedSite[] = [];\n\n constructor(\n private readonly diffScope: DiffScope,\n private readonly catalog: ProjectCatalog,\n private readonly restriction: ScanRestriction,\n ) {}\n\n /** True when the rule keeps only sites on changed lines; every other active mode judges whole files. */\n isLineScoped(mode: ModifiedCodeMode): boolean {\n return mode === 'NEW_AND_MODIFIED_CODE';\n }\n\n /**\n * The files a rule in `mode` judges, restricted to the debug run's `--projects` when there is one.\n * `opts` is passed through to the git listing (`tsOnly: false` for a rule that reads templates/CSS).\n */\n files(workspaceRoot: string, mode: ModifiedCodeMode, base: string, head: string | undefined, opts?: ChangedFilesOptions): string[] {\n return this.restrict(workspaceRoot, this.unrestricted(workspaceRoot, mode, base, head, opts));\n }\n\n /** Record every violating site a rule found, for the debug run's per-project count. */\n recordSites(ruleName: string, relFiles: readonly string[]): void {\n for (const relFile of relFiles) this.sites.push(new RecordedSite(ruleName, relFile));\n }\n\n /** Sites recorded so far, counted per owning project name (`(no project)` for a file outside one). */\n countsByProject(workspaceRoot: string): Map<string, number> {\n const counts = new Map<string, number>();\n for (const site of this.sites) {\n const name = this.catalog.ownerOf(workspaceRoot, site.relFile)?.name ?? '(no project)';\n counts.set(name, (counts.get(name) ?? 0) + 1);\n }\n return counts;\n }\n\n private unrestricted(workspaceRoot: string, mode: ModifiedCodeMode, base: string, head: string | undefined, opts?: ChangedFilesOptions): string[] {\n if (mode === 'RUN_EVERY_TIME') return this.diffScope.getAllFiles(workspaceRoot, opts);\n const changed = this.diffScope.getChangedFiles(workspaceRoot, base, head, opts);\n if (mode !== 'MODIFIED_PROJECTS') return changed;\n // A project is TOUCHED by any changed file it owns — not only the files this rule reads — so a\n // project.json or README edit counts, exactly as nx affected would see it.\n const touched = new Set<string>();\n for (const f of this.diffScope.getChangedFiles(workspaceRoot, base, head, { tsOnly: false })) {\n const owner = this.catalog.ownerOf(workspaceRoot, f);\n if (owner !== undefined) touched.add(owner.dir);\n }\n const inTouched = this.diffScope.getAllFiles(workspaceRoot, opts).filter((f: string) => {\n const owner = this.catalog.ownerOf(workspaceRoot, f);\n return owner !== undefined && touched.has(owner.dir);\n });\n return Array.from(new Set([...changed, ...inTouched]));\n }\n\n private restrict(workspaceRoot: string, files: string[]): string[] {\n const names = this.restriction.projectNames;\n if (names === undefined) return files;\n const wanted = new Set(names);\n return files.filter((f: string) => {\n const owner = this.catalog.ownerOf(workspaceRoot, f);\n return owner !== undefined && wanted.has(owner.name);\n });\n }\n}\n\n/**\n * The gate's {@link ScanScope} — the diff, no project restriction — for a caller that builds a validator\n * outside the DI container: the single-rule nx executors (`validate-no-any-unknown` and friends) and specs.\n */\nexport class GateScanScope extends ScanScope {\n constructor() {\n const diffScope = new DiffScope();\n super(diffScope, new ProjectCatalog(diffScope), new ScanRestriction(undefined));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scan-scope.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/scan-scope.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;AAEH,+CAAyB;AACzB,mDAA6B;AAC7B,0DAAwF;AAExF,8DAA0D;AAC1D,iEAA6D;AAC7D,yCAA2D;AAE3D,oGAAoG;AACpG,MAAa,YAAY;IAER;IACA;IAFb,YACa,IAAY,EACZ,GAAW;QADX,SAAI,GAAJ,IAAI,CAAQ;QACZ,QAAG,GAAH,GAAG,CAAQ;IACrB,CAAC;CACP;AALD,oCAKC;AAKD;;;;GAIG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IAIM;IAHrB,UAAU,CAAqB;IAC/B,MAAM,GAAmB,EAAE,CAAC;IAEpC,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAErD,GAAG,CAAC,aAAqB;QACrB,IAAI,IAAI,CAAC,UAAU,KAAK,aAAa,EAAE,CAAC;YACpC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACvC,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC;QACpC,CAAC;QACD,OAAO,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C;IAC3D,CAAC;IAEO,QAAQ,CAAC,aAAqB,EAAE,KAAe;QACnD,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC;QAC5C,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QACtC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAC9B,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAS,EAAE,EAAE;YAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;YACrD,OAAO,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AAhEY,8BAAS;oBAAT,SAAS;IADrB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAKL,wBAAS;QACX,cAAc;QACV,eAAe;GANxC,SAAS,CAgErB;AAED;;;GAGG;AACH,MAAa,aAAc,SAAQ,SAAS;IACxC;QACI,MAAM,SAAS,GAAG,IAAI,wBAAS,EAAE,CAAC;QAClC,KAAK,CAAC,SAAS,EAAE,IAAI,cAAc,CAAC,SAAS,CAAC,EAAE,IAAI,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;IACpF,CAAC;CACJ;AALD,sCAKC","sourcesContent":["/**\n * Which FILES a diff-scoped code rule judges, for every mode it offers — and the one place the per-run\n * `--projects` restriction of the debug run (#1027) is applied.\n *\n * NEW_AND_MODIFIED_CODE — the changed files (the rule then keeps only sites on changed lines)\n * NEW_AND_MODIFIED_FILES — the changed files, whole\n * MODIFIED_PROJECTS — every in-scope file of every project the diff touches, whole, plus the\n * changed files themselves (so it is never narrower than NEW_AND_MODIFIED_FILES)\n * RUN_EVERY_TIME — every in-scope file in the repo, whole, every run\n *\n * The two whole-scope modes are NEW_AND_MODIFIED_FILES over a bigger file set — the rule's own detection,\n * disable handling and failure text are untouched, which is what lets a debug run print exactly what the\n * gate would print. A rule asks {@link ScanScope.files} instead of `getChangedFiles`, and asks\n * {@link ScanScope.isLineScoped} instead of comparing its mode to NEW_AND_MODIFIED_CODE.\n *\n * Every rule that reads its files here also reports its sites through {@link ScanScope.recordSites}, so\n * the debug run can print a count per project without parsing any rule's output.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { ChangedFilesOptions, DiffScope, RuleFileScope } from \"@webpieces/rules-config\";\nimport { ModifiedCodeMode } from '@webpieces/rules-sdk';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { injectable, bindingScopeValues } from 'inversify';\n\n/** One nx project: its name and its directory (repo-relative, '/'-separated, no trailing slash). */\nexport class ProjectEntry {\n constructor(\n readonly name: string,\n readonly dir: string,\n ) {}\n}\n\n/** The only field of a project.json this catalog reads. */\ntype RawProjectName = { name?: string };\n\n/**\n * The repo's nx projects, found from the `project.json` files git knows about (tracked or untracked,\n * never ignored), and the owner lookup every whole-scope mode and `--projects` filter uses: a file\n * belongs to the DEEPEST project directory containing it.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ProjectCatalog {\n private cachedRoot: string | undefined;\n private cached: ProjectEntry[] = [];\n\n constructor(private readonly diffScope: DiffScope) {}\n\n all(workspaceRoot: string): ProjectEntry[] {\n if (this.cachedRoot !== workspaceRoot) {\n this.cached = this.load(workspaceRoot);\n this.cachedRoot = workspaceRoot;\n }\n return this.cached;\n }\n\n /** The project owning `relFile`, or undefined when no project directory contains it. */\n ownerOf(workspaceRoot: string, relFile: string): ProjectEntry | undefined {\n const file = relFile.split(path.sep).join('/');\n let best: ProjectEntry | undefined;\n for (const project of this.all(workspaceRoot)) {\n const inside = project.dir === '' || file.startsWith(`${project.dir}/`);\n if (inside && (best === undefined || project.dir.length > best.dir.length)) best = project;\n }\n return best;\n }\n\n private load(workspaceRoot: string): ProjectEntry[] {\n // OUTSIDE any rule run's path exclusions (#1253): the catalog is cached across rules, so one rule's\n // excludePaths must never hide a project from the next. Excluded FILES are dropped by their listing.\n const listed = new RuleFileScope().outside(() => this.diffScope.getAllFiles(workspaceRoot, { tsOnly: false }));\n const jsons = listed\n .filter((f: string) => f === 'project.json' || f.endsWith('/project.json'));\n return jsons.map((rel: string) => {\n const dir = path.posix.dirname(rel) === '.' ? '' : path.posix.dirname(rel);\n return new ProjectEntry(this.readName(path.join(workspaceRoot, rel)) ?? path.posix.basename(dir), dir);\n });\n }\n\n private readName(fullPath: string): string | undefined {\n // webpieces-disable no-unmanaged-exceptions -- add the exact project.json path while preserving the parse/read failure as cause\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const parsed = JSON.parse(fs.readFileSync(fullPath, 'utf-8')) as RawProjectName;\n return typeof parsed.name === 'string' && parsed.name.length > 0 ? parsed.name : undefined;\n } catch (err: unknown) {\n const error = toError(err);\n throw new InformAiError(`Cannot read nx project identity from ${fullPath} — fix project.json and retry.`, {\n cause: error,\n });\n }\n }\n}\n\n/**\n * The per-run project restriction. Bound at the composition root: `undefined` for every normal run (the\n * gate), the `--projects` names for a debug run. Data-only.\n */\nexport class ScanRestriction {\n constructor(readonly projectNames: readonly string[] | undefined) {}\n}\n\n/** One recorded violating site: which rule, which file. Data-only. */\nexport class RecordedSite {\n constructor(\n readonly ruleName: string,\n readonly relFile: string,\n ) {}\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class ScanScope {\n private readonly sites: RecordedSite[] = [];\n\n constructor(\n private readonly diffScope: DiffScope,\n private readonly catalog: ProjectCatalog,\n private readonly restriction: ScanRestriction,\n ) {}\n\n /** True when the rule keeps only sites on changed lines; every other active mode judges whole files. */\n isLineScoped(mode: ModifiedCodeMode): boolean {\n return mode === 'NEW_AND_MODIFIED_CODE';\n }\n\n /**\n * The files a rule in `mode` judges, restricted to the debug run's `--projects` when there is one.\n * `opts` is passed through to the git listing (`tsOnly: false` for a rule that reads templates/CSS).\n */\n files(workspaceRoot: string, mode: ModifiedCodeMode, base: string, head: string | undefined, opts?: ChangedFilesOptions): string[] {\n return this.restrict(workspaceRoot, this.unrestricted(workspaceRoot, mode, base, head, opts));\n }\n\n /** Record every violating site a rule found, for the debug run's per-project count. */\n recordSites(ruleName: string, relFiles: readonly string[]): void {\n for (const relFile of relFiles) this.sites.push(new RecordedSite(ruleName, relFile));\n }\n\n /** Sites recorded so far, counted per owning project name (`(no project)` for a file outside one). */\n countsByProject(workspaceRoot: string): Map<string, number> {\n const counts = new Map<string, number>();\n for (const site of this.sites) {\n const name = this.catalog.ownerOf(workspaceRoot, site.relFile)?.name ?? '(no project)';\n counts.set(name, (counts.get(name) ?? 0) + 1);\n }\n return counts;\n }\n\n private unrestricted(workspaceRoot: string, mode: ModifiedCodeMode, base: string, head: string | undefined, opts?: ChangedFilesOptions): string[] {\n if (mode === 'RUN_EVERY_TIME') return this.diffScope.getAllFiles(workspaceRoot, opts);\n const changed = this.diffScope.getChangedFiles(workspaceRoot, base, head, opts);\n if (mode !== 'MODIFIED_PROJECTS') return changed;\n // A project is TOUCHED by any changed file it owns — not only the files this rule reads — so a\n // project.json or README edit counts, exactly as nx affected would see it.\n const touched = new Set<string>();\n for (const f of this.diffScope.getChangedFiles(workspaceRoot, base, head, { tsOnly: false })) {\n const owner = this.catalog.ownerOf(workspaceRoot, f);\n if (owner !== undefined) touched.add(owner.dir);\n }\n const inTouched = this.diffScope.getAllFiles(workspaceRoot, opts).filter((f: string) => {\n const owner = this.catalog.ownerOf(workspaceRoot, f);\n return owner !== undefined && touched.has(owner.dir);\n });\n return Array.from(new Set([...changed, ...inTouched]));\n }\n\n private restrict(workspaceRoot: string, files: string[]): string[] {\n const names = this.restriction.projectNames;\n if (names === undefined) return files;\n const wanted = new Set(names);\n return files.filter((f: string) => {\n const owner = this.catalog.ownerOf(workspaceRoot, f);\n return owner !== undefined && wanted.has(owner.name);\n });\n }\n}\n\n/**\n * The gate's {@link ScanScope} — the diff, no project restriction — for a caller that builds a validator\n * outside the DI container: the single-rule nx executors (`validate-no-any-unknown` and friends) and specs.\n */\nexport class GateScanScope extends ScanScope {\n constructor() {\n const diffScope = new DiffScope();\n super(diffScope, new ProjectCatalog(diffScope), new ScanRestriction(undefined));\n }\n}\n"]}
|
package/src/tag-rule.js
CHANGED
|
@@ -17,7 +17,6 @@ const fs = tslib_1.__importStar(require("fs"));
|
|
|
17
17
|
const path = tslib_1.__importStar(require("path"));
|
|
18
18
|
const rules_config_1 = require("@webpieces/rules-config");
|
|
19
19
|
const to_error_1 = require("@webpieces/tooling-common/to-error");
|
|
20
|
-
const resolve_mode_1 = require("./resolve-mode");
|
|
21
20
|
/** A project (identified by its project.json) missing the required tag. */
|
|
22
21
|
class MissingTagProject {
|
|
23
22
|
name;
|
|
@@ -182,21 +181,9 @@ function findProjectsWithInvalidTagValues(workspaceRoot, changedFiles, tagPrefix
|
|
|
182
181
|
}
|
|
183
182
|
return invalid;
|
|
184
183
|
}
|
|
185
|
-
function resolveMode(normalMode, epoch, branchPattern, ruleName) {
|
|
186
|
-
if (normalMode === 'OFF') {
|
|
187
|
-
return normalMode;
|
|
188
|
-
}
|
|
189
|
-
const skip = (0, resolve_mode_1.shouldSkipRule)(epoch, branchPattern);
|
|
190
|
-
if (skip.skip) {
|
|
191
|
-
console.log(`\n⏭️ Skipping ${ruleName} validation (${skip.reason})`);
|
|
192
|
-
console.log('');
|
|
193
|
-
return 'OFF';
|
|
194
|
-
}
|
|
195
|
-
return normalMode;
|
|
196
|
-
}
|
|
197
184
|
/** Run a concrete tag rule (framework-tag / role-tag) against the git diff. */
|
|
198
185
|
async function runTagValidator(options, workspaceRoot, spec) {
|
|
199
|
-
const mode =
|
|
186
|
+
const mode = options.mode ?? 'OFF';
|
|
200
187
|
const knownTypes = options.knownTypes && options.knownTypes.length > 0 ? options.knownTypes : spec.defaultKnownTypes;
|
|
201
188
|
if (mode === 'OFF') {
|
|
202
189
|
console.log(`\n⏭️ Skipping ${spec.ruleName} validation (mode: OFF)`);
|
package/src/tag-rule.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag-rule.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/tag-rule.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAgJH,wDAcC;AASD,4EAiBC;AAqBD,0CAgEC;;AA3QD,+CAAyB;AACzB,mDAA6B;AAC7B,0DAAsE;AAEtE,iEAA6D;AAE7D,iDAAgD;AAEhD,2EAA2E;AAC3E,MAAa,iBAAiB;IAEN;IACA;IAFpB,YACoB,IAAY,EACZ,eAAuB;QADvB,SAAI,GAAJ,IAAI,CAAQ;QACZ,oBAAe,GAAf,eAAe,CAAQ;IACxC,CAAC;CACP;AALD,8CAKC;AAED;;;;GAIG;AACH,MAAa,iBAAiB;IAEN;IACA;IACA;IAHpB,YACoB,IAAY,EACZ,eAAuB,EACvB,SAAmB;QAFnB,SAAI,GAAJ,IAAI,CAAQ;QACZ,oBAAe,GAAf,eAAe,CAAQ;QACvB,cAAS,GAAT,SAAS,CAAU;IACpC,CAAC;CACP;AAND,8CAMC;AASD,qFAAqF;AACrF,MAAa,WAAW;IAGA;IAEA;IAEA;IAEA;IAEA;IAMA;IAEA;IAlBpB;IACI,gDAAgD;IAChC,SAAiB;IACjC,iFAAiF;IACjE,QAAgB;IAChC,uEAAuE;IACvD,SAAiB;IACjC,8DAA8D;IAC9C,iBAA2B;IAC3C,+DAA+D;IAC/C,MAAwF;IACxG;;;;OAIG;IACa,iBAA0B,KAAK;IAC/C,kFAAkF;IAClE,sBAAkD,IAAI;QAhBtD,cAAS,GAAT,SAAS,CAAQ;QAEjB,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,cAAS,GAAT,SAAS,CAAQ;QAEjB,sBAAiB,GAAjB,iBAAiB,CAAU;QAE3B,WAAM,GAAN,MAAM,CAAkF;QAMxF,mBAAc,GAAd,cAAc,CAAiB;QAE/B,wBAAmB,GAAnB,mB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E,KAAK,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * Shared \"every modified project must carry a `<prefix>` nx tag\" rule engine.\n *\n * Both `framework-tag` (prefix `framework:`) and `role-tag` (prefix `role:`) are\n * the same rule with different prefix/known-values/messages, so the\n * project-walking + diff-scoping + mode logic lives here once and each concrete\n * rule supplies only a {@link TagRuleSpec}.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { detectBase, getChangedFiles } from \"@webpieces/rules-config\";\nimport { ProjectMode } from \"./configs/rule-configs\";\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { ExecutorResult } from './code-validator';\nimport { shouldSkipRule } from './resolve-mode';\n\n/** A project (identified by its project.json) missing the required tag. */\nexport class MissingTagProject {\n constructor(\n public readonly name: string,\n public readonly projectJsonPath: string\n ) {}\n}\n\n/**\n * A project carrying one or more `<prefix>` tag VALUES outside the known set\n * (e.g. `framework:all`). `role-tag` never uses this — only rules that opt into\n * value validation via {@link TagRuleSpec.validateValues}.\n */\nexport class InvalidTagProject {\n constructor(\n public readonly name: string,\n public readonly projectJsonPath: string,\n public readonly badValues: string[]\n ) {}\n}\n\n/** Print the invalid-value report for projects carrying out-of-set tag values. */\nexport type ReportInvalidValues = (\n invalid: InvalidTagProject[],\n knownTypes: string[],\n mode: ProjectMode\n) => void;\n\n/** The knobs and messages that make a concrete tag rule out of the shared engine. */\nexport class TagRuleSpec {\n constructor(\n /** Tag prefix, e.g. `framework:` or `role:`. */\n public readonly tagPrefix: string,\n /** Rule id, e.g. `framework-tag` / `role-tag` (used in skip/validating logs). */\n public readonly ruleName: string,\n /** Human label for the \"Validating X\" banner, e.g. `Framework Tag`. */\n public readonly ruleLabel: string,\n /** Default allowed values when config.knownTypes is empty. */\n public readonly defaultKnownTypes: string[],\n /** Print the violation report for the missing-tag projects. */\n public readonly report: (untagged: MissingTagProject[], knownTypes: string[], mode: ProjectMode) => void,\n /**\n * When true, ALSO validate that every `<prefix>` tag value is in the\n * known set (framework-tag opts in to reject `framework:all` and typos;\n * role-tag leaves this false so its single-value behavior is unchanged).\n */\n public readonly validateValues: boolean = false,\n /** Report for out-of-set values; required when {@link validateValues} is true. */\n public readonly reportInvalidValues: ReportInvalidValues | null = null\n ) {}\n}\n\n/** The config fields the shared engine reads (shared by every tag rule config). */\nexport interface TagRuleConfig {\n mode?: ProjectMode;\n knownTypes?: string[];\n turnOffRuleUntilEpoch?: number;\n turnOffRuleWhileOnBranch?: string | null;\n}\n\ntype RawProjectJson = { name?: string; tags?: string[] };\n\nclass ProjectJson {\n constructor(\n public readonly name: string | null,\n public readonly tags: string[]\n ) {}\n}\n\n/**\n * Parse `name` + `tags` from a project.json. Returns an empty ProjectJson when\n * unreadable/unparseable — config validation owns malformed-json reporting; this\n * rule just nudges for a tag and must never crash the build.\n */\nfunction readProjectJson(projectJsonPath: string, workspaceRoot: string): ProjectJson {\n const fullPath = path.join(workspaceRoot, projectJsonPath);\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const parsed: RawProjectJson = JSON.parse(fs.readFileSync(fullPath, 'utf-8'));\n const name = typeof parsed.name === 'string' && parsed.name.length > 0 ? parsed.name : null;\n const tags = Array.isArray(parsed.tags) ? parsed.tags.filter((tag: string) => typeof tag === 'string') : [];\n return new ProjectJson(name, tags);\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — malformed project.json is not this rule's concern\n return new ProjectJson(null, []);\n }\n}\n\n/**\n * Walk up from a changed file to the nearest ancestor directory containing a\n * project.json (the file's owning nx project). Returns the repo-relative\n * project.json path, or null when the file belongs to no project.\n */\nfunction findOwningProjectJson(changedFile: string, workspaceRoot: string): string | null {\n let dir = path.dirname(changedFile);\n while (true) {\n const candidate = path.join(dir, 'project.json');\n if (fs.existsSync(path.join(workspaceRoot, candidate))) {\n return candidate;\n }\n const parent = path.dirname(dir);\n if (parent === dir || dir === '.' || dir === '') {\n return null;\n }\n dir = parent;\n }\n}\n\nfunction hasTag(tags: string[], tagPrefix: string): boolean {\n return tags.some((tag: string) => tag.startsWith(tagPrefix) && tag.slice(tagPrefix.length).trim().length > 0);\n}\n\n/** The non-empty values of every `<tagPrefix>` tag on a project (the env/role set). */\nfunction tagValues(tags: string[], tagPrefix: string): string[] {\n return tags\n .filter((tag: string) => tag.startsWith(tagPrefix))\n .map((tag: string) => tag.slice(tagPrefix.length).trim())\n .filter((value: string) => value.length > 0);\n}\n\n/** The distinct owning project.json paths of a set of changed files. */\nfunction collectOwningProjectJsons(workspaceRoot: string, changedFiles: string[]): string[] {\n const projectJsonPaths = new Set<string>();\n for (const file of changedFiles) {\n const owning = findOwningProjectJson(file, workspaceRoot);\n if (owning !== null) {\n projectJsonPaths.add(owning);\n }\n }\n return Array.from(projectJsonPaths).sort();\n}\n\n/** Every owning project of a changed file that is missing a `<tagPrefix>` tag. */\nexport function findProjectsMissingTag(\n workspaceRoot: string,\n changedFiles: string[],\n tagPrefix: string\n): MissingTagProject[] {\n const missing: MissingTagProject[] = [];\n for (const projectJsonPath of collectOwningProjectJsons(workspaceRoot, changedFiles)) {\n const projectJson = readProjectJson(projectJsonPath, workspaceRoot);\n if (!hasTag(projectJson.tags, tagPrefix)) {\n const name = projectJson.name ?? path.dirname(projectJsonPath);\n missing.push(new MissingTagProject(name, projectJsonPath));\n }\n }\n return missing;\n}\n\n/**\n * Every owning project of a changed file that carries one or more `<tagPrefix>`\n * tag VALUES outside `knownTypes`. Multiple values per project are allowed (an\n * env set) — this only flags values not in the known set (e.g. `framework:all`\n * or a typo). Projects with no `<tagPrefix>` tag are skipped here (the\n * missing-tag scan owns that case).\n */\nexport function findProjectsWithInvalidTagValues(\n workspaceRoot: string,\n changedFiles: string[],\n tagPrefix: string,\n knownTypes: string[]\n): InvalidTagProject[] {\n const known = new Set(knownTypes);\n const invalid: InvalidTagProject[] = [];\n for (const projectJsonPath of collectOwningProjectJsons(workspaceRoot, changedFiles)) {\n const projectJson = readProjectJson(projectJsonPath, workspaceRoot);\n const badValues = tagValues(projectJson.tags, tagPrefix).filter((value: string) => !known.has(value));\n if (badValues.length > 0) {\n const name = projectJson.name ?? path.dirname(projectJsonPath);\n invalid.push(new InvalidTagProject(name, projectJsonPath, badValues));\n }\n }\n return invalid;\n}\n\nfunction resolveMode(\n normalMode: ProjectMode,\n epoch: number | undefined,\n branchPattern: string | undefined,\n ruleName: string\n): ProjectMode {\n if (normalMode === 'OFF') {\n return normalMode;\n }\n const skip = shouldSkipRule(epoch, branchPattern);\n if (skip.skip) {\n console.log(`\\n⏭️ Skipping ${ruleName} validation (${skip.reason})`);\n console.log('');\n return 'OFF';\n }\n return normalMode;\n}\n\n/** Run a concrete tag rule (framework-tag / role-tag) against the git diff. */\nexport async function runTagValidator(\n options: TagRuleConfig,\n workspaceRoot: string,\n spec: TagRuleSpec\n): Promise<ExecutorResult> {\n const mode: ProjectMode = resolveMode(\n options.mode ?? 'OFF',\n options.turnOffRuleUntilEpoch,\n (options.turnOffRuleWhileOnBranch ?? undefined),\n spec.ruleName\n );\n const knownTypes = options.knownTypes && options.knownTypes.length > 0 ? options.knownTypes : spec.defaultKnownTypes;\n\n if (mode === 'OFF') {\n console.log(`\\n⏭️ Skipping ${spec.ruleName} validation (mode: OFF)`);\n console.log('');\n return { success: true };\n }\n\n console.log(`\\n📏 Validating ${spec.ruleLabel}\\n`);\n console.log(` Mode: ${mode}`);\n\n let base = process.env['NX_BASE'];\n const head = process.env['NX_HEAD'];\n\n if (!base) {\n base = detectBase(workspaceRoot) ?? undefined;\n if (!base) {\n console.log(`\\n⏭️ Skipping ${spec.ruleName} validation (could not detect base branch)`);\n console.log('');\n return { success: true };\n }\n }\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);\n console.log('');\n\n // Project-level rule: ANY changed file (not just .ts) makes its owning\n // project require a tag, so include non-code files too.\n const changedFiles = getChangedFiles(workspaceRoot, base, head, { tsOnly: false });\n if (changedFiles.length === 0) {\n console.log('✅ No changed files in any project');\n return { success: true };\n }\n\n const missing = findProjectsMissingTag(workspaceRoot, changedFiles, spec.tagPrefix);\n const invalid =\n spec.validateValues && spec.reportInvalidValues !== null\n ? findProjectsWithInvalidTagValues(workspaceRoot, changedFiles, spec.tagPrefix, knownTypes)\n : [];\n\n if (missing.length === 0 && invalid.length === 0) {\n console.log(`✅ Every modified project declares a valid ${spec.tagPrefix.replace(/:$/, '')} tag`);\n return { success: true };\n }\n\n if (missing.length > 0) {\n spec.report(missing, knownTypes, mode);\n }\n if (invalid.length > 0 && spec.reportInvalidValues !== null) {\n spec.reportInvalidValues(invalid, knownTypes, mode);\n }\n return { success: false };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tag-rule.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/tag-rule.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AA+IH,wDAcC;AASD,4EAiBC;AAGD,0CA2DC;;AAnPD,+CAAyB;AACzB,mDAA6B;AAC7B,0DAAsE;AAEtE,iEAA6D;AAG7D,2EAA2E;AAC3E,MAAa,iBAAiB;IAEN;IACA;IAFpB,YACoB,IAAY,EACZ,eAAuB;QADvB,SAAI,GAAJ,IAAI,CAAQ;QACZ,oBAAe,GAAf,eAAe,CAAQ;IACxC,CAAC;CACP;AALD,8CAKC;AAED;;;;GAIG;AACH,MAAa,iBAAiB;IAEN;IACA;IACA;IAHpB,YACoB,IAAY,EACZ,eAAuB,EACvB,SAAmB;QAFnB,SAAI,GAAJ,IAAI,CAAQ;QACZ,oBAAe,GAAf,eAAe,CAAQ;QACvB,cAAS,GAAT,SAAS,CAAU;IACpC,CAAC;CACP;AAND,8CAMC;AASD,qFAAqF;AACrF,MAAa,WAAW;IAGA;IAEA;IAEA;IAEA;IAEA;IAMA;IAEA;IAlBpB;IACI,gDAAgD;IAChC,SAAiB;IACjC,iFAAiF;IACjE,QAAgB;IAChC,uEAAuE;IACvD,SAAiB;IACjC,8DAA8D;IAC9C,iBAA2B;IAC3C,+DAA+D;IAC/C,MAAwF;IACxG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EAAE,CAAC;IAC7B,CAAC;IAED,MAAM,OAAO,GAAG,sBAAsB,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACpF,MAAM,OAAO,GACT,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,mBAAmB,KAAK,IAAI;QACpD,CAAC,CAAC,gCAAgC,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC;QAC3F,CAAC,CAAC,EAAE,CAAC;IAEb,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,6CAA6C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;QACjG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,mBAAmB,KAAK,IAAI,EAAE,CAAC;QAC1D,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * Shared \"every modified project must carry a `<prefix>` nx tag\" rule engine.\n *\n * Both `framework-tag` (prefix `framework:`) and `role-tag` (prefix `role:`) are\n * the same rule with different prefix/known-values/messages, so the\n * project-walking + diff-scoping + mode logic lives here once and each concrete\n * rule supplies only a {@link TagRuleSpec}.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { detectBase, getChangedFiles } from \"@webpieces/rules-config\";\nimport { ProjectMode } from \"./configs/rule-configs\";\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { ExecutorResult } from './code-validator';\n\n/** A project (identified by its project.json) missing the required tag. */\nexport class MissingTagProject {\n constructor(\n public readonly name: string,\n public readonly projectJsonPath: string\n ) {}\n}\n\n/**\n * A project carrying one or more `<prefix>` tag VALUES outside the known set\n * (e.g. `framework:all`). `role-tag` never uses this — only rules that opt into\n * value validation via {@link TagRuleSpec.validateValues}.\n */\nexport class InvalidTagProject {\n constructor(\n public readonly name: string,\n public readonly projectJsonPath: string,\n public readonly badValues: string[]\n ) {}\n}\n\n/** Print the invalid-value report for projects carrying out-of-set tag values. */\nexport type ReportInvalidValues = (\n invalid: InvalidTagProject[],\n knownTypes: string[],\n mode: ProjectMode\n) => void;\n\n/** The knobs and messages that make a concrete tag rule out of the shared engine. */\nexport class TagRuleSpec {\n constructor(\n /** Tag prefix, e.g. `framework:` or `role:`. */\n public readonly tagPrefix: string,\n /** Rule id, e.g. `framework-tag` / `role-tag` (used in skip/validating logs). */\n public readonly ruleName: string,\n /** Human label for the \"Validating X\" banner, e.g. `Framework Tag`. */\n public readonly ruleLabel: string,\n /** Default allowed values when config.knownTypes is empty. */\n public readonly defaultKnownTypes: string[],\n /** Print the violation report for the missing-tag projects. */\n public readonly report: (untagged: MissingTagProject[], knownTypes: string[], mode: ProjectMode) => void,\n /**\n * When true, ALSO validate that every `<prefix>` tag value is in the\n * known set (framework-tag opts in to reject `framework:all` and typos;\n * role-tag leaves this false so its single-value behavior is unchanged).\n */\n public readonly validateValues: boolean = false,\n /** Report for out-of-set values; required when {@link validateValues} is true. */\n public readonly reportInvalidValues: ReportInvalidValues | null = null\n ) {}\n}\n\n/** The config fields the shared engine reads (shared by every tag rule config). */\nexport interface TagRuleConfig {\n mode?: ProjectMode;\n knownTypes?: string[];\n turnOffRuleUntilEpoch?: number;\n turnOffRuleWhileOnBranch?: string | null;\n}\n\ntype RawProjectJson = { name?: string; tags?: string[] };\n\nclass ProjectJson {\n constructor(\n public readonly name: string | null,\n public readonly tags: string[]\n ) {}\n}\n\n/**\n * Parse `name` + `tags` from a project.json. Returns an empty ProjectJson when\n * unreadable/unparseable — config validation owns malformed-json reporting; this\n * rule just nudges for a tag and must never crash the build.\n */\nfunction readProjectJson(projectJsonPath: string, workspaceRoot: string): ProjectJson {\n const fullPath = path.join(workspaceRoot, projectJsonPath);\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const parsed: RawProjectJson = JSON.parse(fs.readFileSync(fullPath, 'utf-8'));\n const name = typeof parsed.name === 'string' && parsed.name.length > 0 ? parsed.name : null;\n const tags = Array.isArray(parsed.tags) ? parsed.tags.filter((tag: string) => typeof tag === 'string') : [];\n return new ProjectJson(name, tags);\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — malformed project.json is not this rule's concern\n return new ProjectJson(null, []);\n }\n}\n\n/**\n * Walk up from a changed file to the nearest ancestor directory containing a\n * project.json (the file's owning nx project). Returns the repo-relative\n * project.json path, or null when the file belongs to no project.\n */\nfunction findOwningProjectJson(changedFile: string, workspaceRoot: string): string | null {\n let dir = path.dirname(changedFile);\n while (true) {\n const candidate = path.join(dir, 'project.json');\n if (fs.existsSync(path.join(workspaceRoot, candidate))) {\n return candidate;\n }\n const parent = path.dirname(dir);\n if (parent === dir || dir === '.' || dir === '') {\n return null;\n }\n dir = parent;\n }\n}\n\nfunction hasTag(tags: string[], tagPrefix: string): boolean {\n return tags.some((tag: string) => tag.startsWith(tagPrefix) && tag.slice(tagPrefix.length).trim().length > 0);\n}\n\n/** The non-empty values of every `<tagPrefix>` tag on a project (the env/role set). */\nfunction tagValues(tags: string[], tagPrefix: string): string[] {\n return tags\n .filter((tag: string) => tag.startsWith(tagPrefix))\n .map((tag: string) => tag.slice(tagPrefix.length).trim())\n .filter((value: string) => value.length > 0);\n}\n\n/** The distinct owning project.json paths of a set of changed files. */\nfunction collectOwningProjectJsons(workspaceRoot: string, changedFiles: string[]): string[] {\n const projectJsonPaths = new Set<string>();\n for (const file of changedFiles) {\n const owning = findOwningProjectJson(file, workspaceRoot);\n if (owning !== null) {\n projectJsonPaths.add(owning);\n }\n }\n return Array.from(projectJsonPaths).sort();\n}\n\n/** Every owning project of a changed file that is missing a `<tagPrefix>` tag. */\nexport function findProjectsMissingTag(\n workspaceRoot: string,\n changedFiles: string[],\n tagPrefix: string\n): MissingTagProject[] {\n const missing: MissingTagProject[] = [];\n for (const projectJsonPath of collectOwningProjectJsons(workspaceRoot, changedFiles)) {\n const projectJson = readProjectJson(projectJsonPath, workspaceRoot);\n if (!hasTag(projectJson.tags, tagPrefix)) {\n const name = projectJson.name ?? path.dirname(projectJsonPath);\n missing.push(new MissingTagProject(name, projectJsonPath));\n }\n }\n return missing;\n}\n\n/**\n * Every owning project of a changed file that carries one or more `<tagPrefix>`\n * tag VALUES outside `knownTypes`. Multiple values per project are allowed (an\n * env set) — this only flags values not in the known set (e.g. `framework:all`\n * or a typo). Projects with no `<tagPrefix>` tag are skipped here (the\n * missing-tag scan owns that case).\n */\nexport function findProjectsWithInvalidTagValues(\n workspaceRoot: string,\n changedFiles: string[],\n tagPrefix: string,\n knownTypes: string[]\n): InvalidTagProject[] {\n const known = new Set(knownTypes);\n const invalid: InvalidTagProject[] = [];\n for (const projectJsonPath of collectOwningProjectJsons(workspaceRoot, changedFiles)) {\n const projectJson = readProjectJson(projectJsonPath, workspaceRoot);\n const badValues = tagValues(projectJson.tags, tagPrefix).filter((value: string) => !known.has(value));\n if (badValues.length > 0) {\n const name = projectJson.name ?? path.dirname(projectJsonPath);\n invalid.push(new InvalidTagProject(name, projectJsonPath, badValues));\n }\n }\n return invalid;\n}\n\n/** Run a concrete tag rule (framework-tag / role-tag) against the git diff. */\nexport async function runTagValidator(\n options: TagRuleConfig,\n workspaceRoot: string,\n spec: TagRuleSpec\n): Promise<ExecutorResult> {\n const mode: ProjectMode = options.mode ?? 'OFF';\n const knownTypes = options.knownTypes && options.knownTypes.length > 0 ? options.knownTypes : spec.defaultKnownTypes;\n\n if (mode === 'OFF') {\n console.log(`\\n⏭️ Skipping ${spec.ruleName} validation (mode: OFF)`);\n console.log('');\n return { success: true };\n }\n\n console.log(`\\n📏 Validating ${spec.ruleLabel}\\n`);\n console.log(` Mode: ${mode}`);\n\n let base = process.env['NX_BASE'];\n const head = process.env['NX_HEAD'];\n\n if (!base) {\n base = detectBase(workspaceRoot) ?? undefined;\n if (!base) {\n console.log(`\\n⏭️ Skipping ${spec.ruleName} validation (could not detect base branch)`);\n console.log('');\n return { success: true };\n }\n }\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);\n console.log('');\n\n // Project-level rule: ANY changed file (not just .ts) makes its owning\n // project require a tag, so include non-code files too.\n const changedFiles = getChangedFiles(workspaceRoot, base, head, { tsOnly: false });\n if (changedFiles.length === 0) {\n console.log('✅ No changed files in any project');\n return { success: true };\n }\n\n const missing = findProjectsMissingTag(workspaceRoot, changedFiles, spec.tagPrefix);\n const invalid =\n spec.validateValues && spec.reportInvalidValues !== null\n ? findProjectsWithInvalidTagValues(workspaceRoot, changedFiles, spec.tagPrefix, knownTypes)\n : [];\n\n if (missing.length === 0 && invalid.length === 0) {\n console.log(`✅ Every modified project declares a valid ${spec.tagPrefix.replace(/:$/, '')} tag`);\n return { success: true };\n }\n\n if (missing.length > 0) {\n spec.report(missing, knownTypes, mode);\n }\n if (invalid.length > 0 && spec.reportInvalidValues !== null) {\n spec.reportInvalidValues(invalid, knownTypes, mode);\n }\n return { success: false };\n}\n"]}
|
|
@@ -46,7 +46,6 @@ const rules_config_1 = require("@webpieces/rules-config");
|
|
|
46
46
|
const rule_configs_1 = require("./configs/rule-configs");
|
|
47
47
|
const code_validator_1 = require("./code-validator");
|
|
48
48
|
const inversify_1 = require("inversify");
|
|
49
|
-
const resolve_mode_1 = require("./resolve-mode");
|
|
50
49
|
const scan_scope_1 = require("./scan-scope");
|
|
51
50
|
/**
|
|
52
51
|
* Check if a line contains a disable comment for catch-error-pattern.
|
|
@@ -317,23 +316,8 @@ function reportViolations(violations, mode, disableAllowed) {
|
|
|
317
316
|
console.error(` Current mode: ${mode}`);
|
|
318
317
|
console.error('');
|
|
319
318
|
}
|
|
320
|
-
/**
|
|
321
|
-
* Resolve mode considering turnOffRuleUntilEpoch override.
|
|
322
|
-
*/
|
|
323
|
-
function resolveMode(normalMode, epoch, branchPattern) {
|
|
324
|
-
if (normalMode === 'OFF') {
|
|
325
|
-
return normalMode;
|
|
326
|
-
}
|
|
327
|
-
const skip = (0, resolve_mode_1.shouldSkipRule)(epoch, branchPattern);
|
|
328
|
-
if (skip.skip) {
|
|
329
|
-
console.log(`\n\u23ed\ufe0f Skipping catch-error-pattern validation (${skip.reason})`);
|
|
330
|
-
console.log('');
|
|
331
|
-
return 'OFF';
|
|
332
|
-
}
|
|
333
|
-
return normalMode;
|
|
334
|
-
}
|
|
335
319
|
async function runValidatorImpl(scan, options, workspaceRoot) {
|
|
336
|
-
const mode =
|
|
320
|
+
const mode = options.mode ?? 'OFF';
|
|
337
321
|
const disableAllowed = options.disableAllowed ?? true;
|
|
338
322
|
if (mode === 'OFF') {
|
|
339
323
|
console.log('\n\u23ed\ufe0f Skipping catch-error-pattern validation (mode: OFF)');
|