repopo 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +13 -6
- package/esm/api.d.ts +2 -0
- package/esm/api.d.ts.map +1 -1
- package/esm/api.js +1 -0
- package/esm/api.js.map +1 -1
- package/esm/commands/check-native.d.ts +2 -0
- package/esm/commands/check-native.d.ts.map +1 -1
- package/esm/commands/check-native.js +9 -0
- package/esm/commands/check-native.js.map +1 -1
- package/esm/commands/check.d.ts +2 -0
- package/esm/commands/check.d.ts.map +1 -1
- package/esm/commands/check.js +26 -2
- package/esm/commands/check.js.map +1 -1
- package/esm/commands/list.d.ts.map +1 -1
- package/esm/commands/list.js +1 -1
- package/esm/commands/list.js.map +1 -1
- package/esm/config.d.ts +5 -0
- package/esm/config.d.ts.map +1 -1
- package/esm/config.js.map +1 -1
- package/esm/context.d.ts +2 -0
- package/esm/context.d.ts.map +1 -1
- package/esm/context.js +11 -0
- package/esm/context.js.map +1 -1
- package/esm/makePolicy.d.ts.map +1 -1
- package/esm/makePolicy.js +3 -1
- package/esm/makePolicy.js.map +1 -1
- package/esm/policies/MaxChangedFiles.d.ts +17 -0
- package/esm/policies/MaxChangedFiles.d.ts.map +1 -0
- package/esm/policies/MaxChangedFiles.js +22 -0
- package/esm/policies/MaxChangedFiles.js.map +1 -0
- package/esm/policies/RequireCompanionChanges.d.ts +16 -0
- package/esm/policies/RequireCompanionChanges.d.ts.map +1 -0
- package/esm/policies/RequireCompanionChanges.js +42 -0
- package/esm/policies/RequireCompanionChanges.js.map +1 -0
- package/esm/policies.d.ts +2 -0
- package/esm/policies.d.ts.map +1 -1
- package/esm/policies.js +2 -0
- package/esm/policies.js.map +1 -1
- package/esm/policy.d.ts +9 -3
- package/esm/policy.d.ts.map +1 -1
- package/esm/policy.js.map +1 -1
- package/esm/policyExecution.d.ts +4 -3
- package/esm/policyExecution.d.ts.map +1 -1
- package/esm/policyExecution.js +13 -3
- package/esm/policyExecution.js.map +1 -1
- package/esm/repositoryChanges.d.ts +26 -0
- package/esm/repositoryChanges.d.ts.map +1 -0
- package/esm/repositoryChanges.js +172 -0
- package/esm/repositoryChanges.js.map +1 -0
- package/esm/repositoryFiles.d.ts +2 -0
- package/esm/repositoryFiles.d.ts.map +1 -1
- package/esm/repositoryFiles.js +6 -3
- package/esm/repositoryFiles.js.map +1 -1
- package/esm/runner.d.ts +5 -4
- package/esm/runner.d.ts.map +1 -1
- package/esm/runner.js +26 -27
- package/esm/runner.js.map +1 -1
- package/oclif.manifest.json +39 -1
- package/package.json +1 -1
- package/sidecar/sidecar.mjs +48 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# repopo
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add a full repository inventory annotated with added, modified, deleted, renamed, type-changed, or unchanged status. Support PR, local, and staged comparisons with explicit base overrides and shared TypeScript/native behavior. _[`#828`](https://github.com/tylerbutler/tools-monorepo/pull/828) [`ddf0db2`](https://github.com/tylerbutler/tools-monorepo/commit/ddf0db26c2c92c56df8954e5f81692da4a06ec13) [@tylerbutler](https://github.com/tylerbutler)_
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Use `RequireCompanionChanges` to require related path updates, such as documentation changes alongside source changes. Existing file selection and full repository inventory retain their behavior.
|
|
11
|
+
|
|
12
|
+
Configure comparisons with `changes: { mode?, base? }`. The CLI uses its explicit base override first, then CI's target, then the configured base.
|
|
13
|
+
|
|
14
|
+
Use `scope: "changes"` to request change statuses without making ordinary repository policies depend on Git comparison history. Both scopes accept one optional `match` regex that filters the handler's inventory, including either rename endpoint.
|
|
15
|
+
- Add the opt-in `MaxChangedFiles` policy with required configuration `{ maxFiles: number }`. Report a violation when the eligible changed-file count exceeds the nonnegative integer limit; exactly the limit passes. _[`#829`](https://github.com/tylerbutler/tools-monorepo/pull/829) [`f02fd0a`](https://github.com/tylerbutler/tools-monorepo/commit/f02fd0ac44020272d197289215aabb561e5307e2) [@tylerbutler](https://github.com/tylerbutler)_
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Count additions, modifications, deletions, type changes, and renames once per change record. Honor global and per-policy exclusions, and use the existing PR/local/staged change snapshot independently of stdin selection. Findings include the count, limit, and guidance to reduce or split the change.
|
|
19
|
+
|
|
3
20
|
## 0.13.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -66,12 +66,16 @@ Checks and applies policies to the files in the repository.
|
|
|
66
66
|
|
|
67
67
|
```
|
|
68
68
|
USAGE
|
|
69
|
-
$ repopo check [-v | --quiet] [--
|
|
69
|
+
$ repopo check [-v | --quiet] [--change-mode pr|local|staged] [--change-base <value>] [--concurrency
|
|
70
|
+
<value>] [-f] [--stdin]
|
|
70
71
|
|
|
71
72
|
FLAGS
|
|
72
|
-
-f, --fix
|
|
73
|
-
--
|
|
74
|
-
--
|
|
73
|
+
-f, --fix Fix errors if possible.
|
|
74
|
+
--change-base=<value> Override the PR change context base ref.
|
|
75
|
+
--change-mode=<option> Change context: pr (default), local, or staged. Does not select file-policy paths.
|
|
76
|
+
<options: pr|local|staged>
|
|
77
|
+
--concurrency=<value> [default: 8] Maximum concurrent files in read-only checks. Fixes remain sequential.
|
|
78
|
+
--stdin Read list of files from stdin.
|
|
75
79
|
|
|
76
80
|
LOGGING FLAGS
|
|
77
81
|
-v, --verbose Enable verbose logging.
|
|
@@ -92,8 +96,8 @@ Checks and applies policies using the Rust engine.
|
|
|
92
96
|
|
|
93
97
|
```
|
|
94
98
|
USAGE
|
|
95
|
-
$ repopo check-native [--
|
|
96
|
-
[--binary-path <value>] [--runtime auto|node|bun]
|
|
99
|
+
$ repopo check-native [--change-mode pr|local|staged] [--change-base <value>] [--concurrency <value>] [-f]
|
|
100
|
+
[--stdin] [-v] [-q] [-c <value>] [--sidecar-path <value>] [--binary-path <value>] [--runtime auto|node|bun]
|
|
97
101
|
|
|
98
102
|
FLAGS
|
|
99
103
|
-c, --config=<value> Path to the config file.
|
|
@@ -101,6 +105,9 @@ FLAGS
|
|
|
101
105
|
-q, --quiet Suppress all output except errors.
|
|
102
106
|
-v, --verbose Show verbose output including per-policy timing.
|
|
103
107
|
--binary-path=<value> [env: REPOPO_CORE_PATH] Path to the repopo-core Rust binary.
|
|
108
|
+
--change-base=<value> Override the PR change context base ref.
|
|
109
|
+
--change-mode=<option> Change context: pr (default), local, or staged. Does not select file-policy paths.
|
|
110
|
+
<options: pr|local|staged>
|
|
104
111
|
--concurrency=<value> [default: 8] Maximum concurrent files in read-only checks. Fixes remain sequential.
|
|
105
112
|
--runtime=<option> [env: REPOPO_RUNTIME] JS runtime for the sidecar process (auto, node, bun).
|
|
106
113
|
<options: auto|node|bun>
|
package/esm/api.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export type { GleamTomlRequiredConfig } from "./policies/GleamTomlRequired.js";
|
|
|
32
32
|
export type { GleamTomlSortedConfig } from "./policies/GleamTomlSorted.js";
|
|
33
33
|
export type { GleamVersionConstraintConfig } from "./policies/GleamVersionConstraint.js";
|
|
34
34
|
export type { LicenseFileExistsSettings } from "./policies/LicenseFileExists.js";
|
|
35
|
+
export type { MaxChangedFilesConfig } from "./policies/MaxChangedFiles.js";
|
|
35
36
|
export type { MutuallyExclusiveScriptsConfig } from "./policies/MutuallyExclusiveScripts.js";
|
|
36
37
|
export type { NoLargeBinaryFilesSettings } from "./policies/NoLargeBinaryFiles.js";
|
|
37
38
|
export type { NoPrivateWorkspaceDependenciesSettings } from "./policies/NoPrivateWorkspaceDependencies.js";
|
|
@@ -61,5 +62,6 @@ export { type CargoToml, type CargoTomlHandler, type DefineCargoPolicyArgs, defi
|
|
|
61
62
|
export { type DefineFileHeaderPolicyArgs, defineFileHeaderPolicy, type FileHeaderGeneratorConfig, type FileHeaderPolicyConfig, } from "./policyDefiners/defineFileHeaderPolicy.js";
|
|
62
63
|
export { type DefineGleamPolicyArgs, defineGleamPolicy, type GleamToml, type GleamTomlHandler, } from "./policyDefiners/defineGleamPolicy.js";
|
|
63
64
|
export { type DefinePackagePolicyArgs, definePackagePolicy, type PackageJsonHandler, } from "./policyDefiners/definePackagePolicy.js";
|
|
65
|
+
export { collectRepositoryInventory, type RepositoryFile, } from "./repositoryChanges.js";
|
|
64
66
|
export { type PolicyExecutionError, type PolicyRunFinding, PolicyRunner, type PolicyRunnerOptions, type PolicyRunResults, type PolicySkippedWork, type RepositoryInventory, runPolicies, } from "./runner.js";
|
|
65
67
|
//# sourceMappingURL=api.d.ts.map
|
package/esm/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACtE,YAAY,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AACvF,YAAY,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,YAAY,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,YAAY,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC/E,YAAY,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,YAAY,EACX,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GACxB,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,YAAY,EAAE,sBAAsB,EAAE,MAA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EACN,KAAK,qBAAqB,EAC1B,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,gBAAgB,GACrB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,KAAK,uBAAuB,EAC5B,mBAAmB,EACnB,KAAK,kBAAkB,GACvB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACN,0BAA0B,EAC1B,KAAK,cAAc,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,WAAW,GACX,MAAM,aAAa,CAAC"}
|
package/esm/api.js
CHANGED
|
@@ -14,5 +14,6 @@ export { defineCargoPolicy, } from "./policyDefiners/defineCargoPolicy.js";
|
|
|
14
14
|
export { defineFileHeaderPolicy, } from "./policyDefiners/defineFileHeaderPolicy.js";
|
|
15
15
|
export { defineGleamPolicy, } from "./policyDefiners/defineGleamPolicy.js";
|
|
16
16
|
export { definePackagePolicy, } from "./policyDefiners/definePackagePolicy.js";
|
|
17
|
+
export { collectRepositoryInventory, } from "./repositoryChanges.js";
|
|
17
18
|
export { PolicyRunner, runPolicies, } from "./runner.js";
|
|
18
19
|
//# sourceMappingURL=api.js.map
|
package/esm/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAGN,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAGN,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA+E7C,OAAO,EAIN,iBAAiB,GACjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEN,sBAAsB,GAGtB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAEN,iBAAiB,GAGjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEN,mBAAmB,GAEnB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACN,0BAA0B,GAE1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGN,YAAY,EAKZ,WAAW,GACX,MAAM,aAAa,CAAC","sourcesContent":["/**\n * A tool for enforcing repository policies and standards across codebases.\n *\n * @remarks\n * Repopo provides a framework for defining and enforcing policies across repositories,\n * such as file headers, package.json consistency, and other code standards.\n * It can be used as a CLI tool or integrated into CI/CD pipelines.\n *\n * @packageDocumentation\n */\n\nexport {\n\ttype FluidAdapterOptions,\n\ttype FluidHandler,\n\tfromFluidHandlers,\n} from \"./adapters/fluidFramework.js\";\nexport type { RepopoConfig } from \"./config.js\";\nexport { makePolicy } from \"./makePolicy.js\";\nexport type { PolicyAction, PolicyHandlerPerfStats } from \"./perf.js\";\nexport type { CargoLicenceValidatedConfig } from \"./policies/CargoLicenceValidated.js\";\nexport type { CargoLintsConfiguredConfig } from \"./policies/CargoLintsConfigured.js\";\nexport type { CargoLockPolicyConfig } from \"./policies/CargoLockPolicy.js\";\nexport type { CargoTomlRequiredConfig } from \"./policies/CargoTomlRequired.js\";\nexport type { CargoTomlSortedConfig } from \"./policies/CargoTomlSorted.js\";\nexport type {\n\tConditionalScriptEntry,\n\tConditionalScriptRule,\n\tConditionalScriptsConfig,\n} from \"./policies/ConditionalScripts.js\";\nexport type { ExactScriptsConfig } from \"./policies/ExactScripts.js\";\nexport type { GleamDepVersionsConfig } from \"./policies/GleamDepVersions.js\";\nexport type { GleamDocExistsConfig } from \"./policies/GleamDocExists.js\";\nexport type { GleamInternalModulesConfiguredConfig } from \"./policies/GleamInternalModulesConfigured.js\";\nexport type { GleamLicenceConfiguredConfig } from \"./policies/GleamLicenceConfigured.js\";\nexport type { GleamMonorepoConsistencyConfig } from \"./policies/GleamMonorepoConsistency.js\";\nexport type { GleamNameRestrictionsConfig } from \"./policies/GleamNameRestrictions.js\";\nexport type { GleamNoPathDepsInPublishedConfig } from \"./policies/GleamNoPathDepsInPublished.js\";\nexport type { GleamProjectStructureConfig } from \"./policies/GleamProjectStructure.js\";\nexport type { GleamSharedDependencyVersionsConfig } from \"./policies/GleamSharedDependencyVersions.js\";\nexport type { GleamTomlRequiredConfig } from \"./policies/GleamTomlRequired.js\";\nexport type { GleamTomlSortedConfig } from \"./policies/GleamTomlSorted.js\";\nexport type { GleamVersionConstraintConfig } from \"./policies/GleamVersionConstraint.js\";\nexport type { LicenseFileExistsSettings } from \"./policies/LicenseFileExists.js\";\nexport type { MaxChangedFilesConfig } from \"./policies/MaxChangedFiles.js\";\nexport type { MutuallyExclusiveScriptsConfig } from \"./policies/MutuallyExclusiveScripts.js\";\nexport type { NoLargeBinaryFilesSettings } from \"./policies/NoLargeBinaryFiles.js\";\nexport type { NoPrivateWorkspaceDependenciesSettings } from \"./policies/NoPrivateWorkspaceDependencies.js\";\nexport type { NoUnsafeWithoutJustificationConfig } from \"./policies/NoUnsafeWithoutJustification.js\";\nexport type { NoWildcardDependenciesConfig } from \"./policies/NoWildcardDependencies.js\";\nexport type { PackageAllowedScopesConfig } from \"./policies/PackageAllowedScopes.js\";\nexport type { PackageEsmTypeConfig } from \"./policies/PackageEsmType.js\";\nexport type { PackageFolderNameConfig } from \"./policies/PackageFolderName.js\";\nexport type { PackageJsonPropertiesSettings } from \"./policies/PackageJsonProperties.js\";\nexport type { PackageLicenseSettings } from \"./policies/PackageLicense.js\";\nexport type { PackagePrivateFieldConfig } from \"./policies/PackagePrivateField.js\";\nexport type { PackageReadmeSettings } from \"./policies/PackageReadme.js\";\nexport type {\n\tPackageScriptsSettings,\n\tScriptMustContainRule,\n} from \"./policies/PackageScripts.js\";\nexport type { PackageTestScriptsConfig } from \"./policies/PackageTestScripts.js\";\nexport type { PublicApiDocumentedConfig } from \"./policies/PublicApiDocumented.js\";\nexport type { RequiredGitignorePatternsSettings } from \"./policies/RequiredGitignorePatterns.js\";\nexport type {\n\tRequiredScriptEntry,\n\tRequiredScriptsConfig,\n} from \"./policies/RequiredScripts.js\";\nexport type { RustDocExistsConfig } from \"./policies/RustDocExists.js\";\nexport type { RustfmtConfigExistsConfig } from \"./policies/RustfmtConfigExists.js\";\nexport type { RustToolchainExistsConfig } from \"./policies/RustToolchainExists.js\";\nexport type {\n\tScriptContainsConfig,\n\tScriptContainsRule,\n} from \"./policies/ScriptContains.js\";\nexport type { SharedDependencyVersionsConfig } from \"./policies/SharedDependencyVersions.js\";\nexport type { WorkspaceInheritanceConfig } from \"./policies/WorkspaceInheritance.js\";\nexport type { WorkspaceMembersValidConfig } from \"./policies/WorkspaceMembersValid.js\";\nexport type {\n\tConfiguredFilePolicy,\n\tConfiguredPolicy,\n\tConfiguredRepositoryPolicy,\n\tFilePolicyDefinition,\n\tIdentifiedPolicy,\n\tPolicyArgs,\n\tPolicyDefinition,\n\tPolicyFinding,\n\tPolicyHandler,\n\tPolicyInstanceId,\n\tPolicyName,\n\tPolicyOptions,\n\tPolicyResolver,\n\tPolicyResult,\n\tRepositoryPolicyArgs,\n\tRepositoryPolicyDefinition,\n\tRepositoryPolicyHandler,\n} from \"./policy.js\";\nexport {\n\ttype CargoToml,\n\ttype CargoTomlHandler,\n\ttype DefineCargoPolicyArgs,\n\tdefineCargoPolicy,\n} from \"./policyDefiners/defineCargoPolicy.js\";\nexport {\n\ttype DefineFileHeaderPolicyArgs,\n\tdefineFileHeaderPolicy,\n\ttype FileHeaderGeneratorConfig,\n\ttype FileHeaderPolicyConfig,\n} from \"./policyDefiners/defineFileHeaderPolicy.js\";\nexport {\n\ttype DefineGleamPolicyArgs,\n\tdefineGleamPolicy,\n\ttype GleamToml,\n\ttype GleamTomlHandler,\n} from \"./policyDefiners/defineGleamPolicy.js\";\nexport {\n\ttype DefinePackagePolicyArgs,\n\tdefinePackagePolicy,\n\ttype PackageJsonHandler,\n} from \"./policyDefiners/definePackagePolicy.js\";\nexport {\n\tcollectRepositoryInventory,\n\ttype RepositoryFile,\n} from \"./repositoryChanges.js\";\nexport {\n\ttype PolicyExecutionError,\n\ttype PolicyRunFinding,\n\tPolicyRunner,\n\ttype PolicyRunnerOptions,\n\ttype PolicyRunResults,\n\ttype PolicySkippedWork,\n\ttype RepositoryInventory,\n\trunPolicies,\n} from \"./runner.js\";\n"]}
|
|
@@ -8,6 +8,8 @@ export declare class CheckNative extends Command {
|
|
|
8
8
|
static readonly summary = "Checks and applies policies using the Rust engine.";
|
|
9
9
|
static readonly description: string;
|
|
10
10
|
static readonly flags: {
|
|
11
|
+
readonly "change-mode": import("@oclif/core/interfaces").OptionFlag<"pr" | "local" | "staged" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
readonly "change-base": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
13
|
readonly concurrency: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
14
|
readonly fix: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
15
|
readonly stdin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-native.d.ts","sourceRoot":"","sources":["../../src/commands/check-native.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"check-native.d.ts","sourceRoot":"","sources":["../../src/commands/check-native.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAO7C;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,OAAO;IACvC,gBAAgC,OAAO,wDACe;IAEtD,gBAAgC,WAAW,SAIsC;IAEjF,gBAAgC,KAAK;;;;;;;;;;;;MAkD1B;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAwE1C,OAAO,CAAC,iBAAiB;IAiDzB,OAAO,CAAC,kBAAkB;CAQ1B"}
|
|
@@ -4,6 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
import { Command, Flags } from "@oclif/core";
|
|
5
5
|
import { dirname, resolve } from "pathe";
|
|
6
6
|
import { DEFAULT_CONCURRENCY, validateConcurrency } from "../concurrency.js";
|
|
7
|
+
import { CheckPolicy } from "./check.js";
|
|
7
8
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
9
|
/**
|
|
9
10
|
* Runs the Rust-based repopo-core engine with the Node.js sidecar for
|
|
@@ -17,6 +18,8 @@ export class CheckNative extends Command {
|
|
|
17
18
|
"Repository policies always run with the full repository inventory, including with --stdin. " +
|
|
18
19
|
"With --fix, repository policies can modify files outside the stdin selection.";
|
|
19
20
|
static flags = {
|
|
21
|
+
"change-mode": CheckPolicy.flags["change-mode"],
|
|
22
|
+
"change-base": CheckPolicy.flags["change-base"],
|
|
20
23
|
concurrency: Flags.integer({
|
|
21
24
|
description: "Maximum concurrent files in read-only checks. Fixes remain sequential.",
|
|
22
25
|
default: DEFAULT_CONCURRENCY,
|
|
@@ -69,6 +72,12 @@ export class CheckNative extends Command {
|
|
|
69
72
|
const binaryPath = this.resolveBinaryPath(flags["binary-path"]);
|
|
70
73
|
const sidecarPath = this.resolveSidecarPath(flags["sidecar-path"]);
|
|
71
74
|
const args = ["check", "--sidecar-path", sidecarPath];
|
|
75
|
+
if (flags["change-mode"] !== undefined) {
|
|
76
|
+
args.push("--change-mode", flags["change-mode"]);
|
|
77
|
+
}
|
|
78
|
+
if (flags["change-base"] !== undefined) {
|
|
79
|
+
args.push("--change-base", flags["change-base"]);
|
|
80
|
+
}
|
|
72
81
|
args.push("--concurrency", String(flags.concurrency));
|
|
73
82
|
if (flags.fix) {
|
|
74
83
|
args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CAAC,WAAW,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC9D,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC5B,OAAO,UAAU,CAAC;QACnB,CAAC;QAED,iDAAiD;QACjD,MAAM,WAAW,GAAG,OAAO,CAC1B,WAAW,EACX,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAU,CACV,CAAC;QACF,IAAI,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YAC7B,OAAO,WAAW,CAAC;QACpB,CAAC;QAED,qCAAqC;QACrC,MAAM,SAAS,GAAG,OAAO,CACxB,WAAW,EACX,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,OAAO,EACP,UAAU,CACV,CAAC;QACF,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,MAAM,IAAI,KAAK,CACd,yCAAyC;YACxC,+EAA+E;YAC/E,2EAA2E,CAC5E,CAAC;IACH,CAAC;IAEO,kBAAkB,CAAC,QAAiB;QAC3C,IAAI,QAAQ,EAAE,CAAC;YACd,OAAO,QAAQ,CAAC;QACjB,CAAC;QAED,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACnD,OAAO,OAAO,CAAC,WAAW,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;IACvD,CAAC","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { Command, Flags } from \"@oclif/core\";\nimport { dirname, resolve } from \"pathe\";\nimport { DEFAULT_CONCURRENCY, validateConcurrency } from \"../concurrency.js\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\n/**\n * Runs the Rust-based repopo-core engine with the Node.js sidecar for\n * per-policy execution. Rust owns matching, ordering, concurrency, exception\n * boundaries, repository scheduling and aggregation.\n */\nexport class CheckNative extends Command {\n\tpublic static override readonly summary =\n\t\t\"Checks and applies policies using the Rust engine.\";\n\n\tpublic static override readonly description =\n\t\t\"Runs the Rust-based repopo-core engine with the Node.js sidecar. \" +\n\t\t\"Rust handles file matching, scheduling and reporting; the sidecar shares per-policy contracts with 'check'. \" +\n\t\t\"Repository policies always run with the full repository inventory, including with --stdin. \" +\n\t\t\"With --fix, repository policies can modify files outside the stdin selection.\";\n\n\tpublic static override readonly flags = {\n\t\tconcurrency: Flags.integer({\n\t\t\tdescription:\n\t\t\t\t\"Maximum concurrent files in read-only checks. Fixes remain sequential.\",\n\t\t\tdefault: DEFAULT_CONCURRENCY,\n\t\t\tparse: async (value) => validateConcurrency(Number(value)),\n\t\t}),\n\t\tfix: Flags.boolean({\n\t\t\taliases: [\"resolve\"],\n\t\t\tdescription: \"Fix errors if possible.\",\n\t\t\trequired: false,\n\t\t\tchar: \"f\",\n\t\t}),\n\t\tstdin: Flags.boolean({\n\t\t\tdescription: \"Read list of files from stdin.\",\n\t\t\trequired: false,\n\t\t}),\n\t\tverbose: Flags.boolean({\n\t\t\tdescription: \"Show verbose output including per-policy timing.\",\n\t\t\trequired: false,\n\t\t\tchar: \"v\",\n\t\t}),\n\t\tquiet: Flags.boolean({\n\t\t\tdescription: \"Suppress all output except errors.\",\n\t\t\trequired: false,\n\t\t\tchar: \"q\",\n\t\t}),\n\t\tconfig: Flags.string({\n\t\t\tdescription: \"Path to the config file.\",\n\t\t\trequired: false,\n\t\t\tchar: \"c\",\n\t\t}),\n\t\t\"sidecar-path\": Flags.string({\n\t\t\tdescription: \"Path to the Node.js sidecar script.\",\n\t\t\trequired: false,\n\t\t\tenv: \"REPOPO_SIDECAR_PATH\",\n\t\t}),\n\t\t\"binary-path\": Flags.string({\n\t\t\tdescription: \"Path to the repopo-core Rust binary.\",\n\t\t\trequired: false,\n\t\t\tenv: \"REPOPO_CORE_PATH\",\n\t\t}),\n\t\truntime: Flags.string({\n\t\t\tdescription: \"JS runtime for the sidecar process (auto, node, bun).\",\n\t\t\trequired: false,\n\t\t\tenv: \"REPOPO_RUNTIME\",\n\t\t\toptions: [\"auto\", \"node\", \"bun\"],\n\t\t}),\n\t} as const;\n\n\tpublic override async run(): Promise<void> {\n\t\tconst { flags } = await this.parse(CheckNative);\n\n\t\tconst binaryPath = this.resolveBinaryPath(flags[\"binary-path\"]);\n\t\tconst sidecarPath = this.resolveSidecarPath(flags[\"sidecar-path\"]);\n\n\t\tconst args: string[] = [\"check\", \"--sidecar-path\", sidecarPath];\n\t\targs.push(\"--concurrency\", String(flags.concurrency));\n\n\t\tif (flags.fix) {\n\t\t\targs.push(\"--fix\");\n\t\t}\n\t\tif (flags.stdin) {\n\t\t\targs.push(\"--stdin\");\n\t\t}\n\t\tif (flags.verbose) {\n\t\t\targs.push(\"--verbose\");\n\t\t}\n\t\tif (flags.quiet) {\n\t\t\targs.push(\"--quiet\");\n\t\t}\n\t\tif (flags.config) {\n\t\t\targs.push(\"--config\", flags.config);\n\t\t}\n\t\tif (flags.runtime) {\n\t\t\targs.push(\"--runtime\", flags.runtime);\n\t\t}\n\n\t\treturn new Promise<void>((resolvePromise, reject) => {\n\t\t\tconst child = spawn(binaryPath, args, {\n\t\t\t\tstdio: \"inherit\",\n\t\t\t\t// biome-ignore lint/style/noProcessEnv: Need to pass parent environment to child process\n\t\t\t\tenv: { ...process.env },\n\t\t\t});\n\t\t\tconst interrupt = () => child.kill(\"SIGINT\");\n\t\t\tconst terminate = () => child.kill(\"SIGTERM\");\n\t\t\tconst cleanup = () => {\n\t\t\t\tprocess.removeListener(\"SIGINT\", interrupt);\n\t\t\t\tprocess.removeListener(\"SIGTERM\", terminate);\n\t\t\t};\n\t\t\tprocess.on(\"SIGINT\", interrupt);\n\t\t\tprocess.on(\"SIGTERM\", terminate);\n\n\t\t\tchild.on(\"error\", (err) => {\n\t\t\t\tcleanup();\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\n\t\t\t\t\t\t`Failed to spawn repopo-core: ${err.message}\\n` +\n\t\t\t\t\t\t\t`Binary path: ${binaryPath}\\n` +\n\t\t\t\t\t\t\t\"Make sure the Rust binary has been built: cargo build --manifest-path crates/core/Cargo.toml\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tchild.on(\"close\", (code, signal) => {\n\t\t\t\tcleanup();\n\t\t\t\tif (code !== 0) {\n\t\t\t\t\tprocess.exitCode =\n\t\t\t\t\t\tcode ??\n\t\t\t\t\t\t(signal === \"SIGINT\" ? 130 : signal === \"SIGTERM\" ? 143 : 1);\n\t\t\t\t}\n\t\t\t\tresolvePromise();\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate resolveBinaryPath(explicit?: string): string {\n\t\tif (explicit) {\n\t\t\treturn explicit;\n\t\t}\n\n\t\tconst packageRoot = resolve(__dirname, \"..\", \"..\");\n\t\tconst binaryName =\n\t\t\tprocess.platform === \"win32\" ? \"repopo-core.exe\" : \"repopo-core\";\n\n\t\t// Check paths in priority order:\n\t\t// 1. Postinstall-downloaded binary (npm install)\n\t\tconst nativePath = resolve(packageRoot, \"native\", binaryName);\n\t\tif (existsSync(nativePath)) {\n\t\t\treturn nativePath;\n\t\t}\n\n\t\t// 2. Local release build (cargo build --release)\n\t\tconst releasePath = resolve(\n\t\t\tpackageRoot,\n\t\t\t\"crates\",\n\t\t\t\"core\",\n\t\t\t\"target\",\n\t\t\t\"release\",\n\t\t\tbinaryName,\n\t\t);\n\t\tif (existsSync(releasePath)) {\n\t\t\treturn releasePath;\n\t\t}\n\n\t\t// 3. Local debug build (cargo build)\n\t\tconst debugPath = resolve(\n\t\t\tpackageRoot,\n\t\t\t\"crates\",\n\t\t\t\"core\",\n\t\t\t\"target\",\n\t\t\t\"debug\",\n\t\t\tbinaryName,\n\t\t);\n\t\tif (existsSync(debugPath)) {\n\t\t\treturn debugPath;\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t\"repopo-core binary not found. Either:\\n\" +\n\t\t\t\t\" - Install the package (npm install repopo) to download pre-built binaries\\n\" +\n\t\t\t\t\" - Build from source: cargo build --manifest-path crates/core/Cargo.toml\",\n\t\t);\n\t}\n\n\tprivate resolveSidecarPath(explicit?: string): string {\n\t\tif (explicit) {\n\t\t\treturn explicit;\n\t\t}\n\n\t\tconst packageRoot = resolve(__dirname, \"..\", \"..\");\n\t\treturn resolve(packageRoot, \"sidecar\", \"sidecar.mjs\");\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"check-native.js","sourceRoot":"","sources":["../../src/commands/check-native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,OAAO;IAChC,MAAM,CAAmB,OAAO,GACtC,oDAAoD,CAAC;IAE/C,MAAM,CAAmB,WAAW,GAC1C,mEAAmE;QACnE,8GAA8G;QAC9G,6FAA6F;QAC7F,+EAA+E,CAAC;IAE1E,MAAM,CAAmB,KAAK,GAAG;QACvC,aAAa,EAAE,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC;QAC/C,aAAa,EAAE,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC;QAC/C,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC;YAC1B,WAAW,EACV,wEAAwE;YACzE,OAAO,EAAE,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AAM,IAAI,KAAK,CACd,yCAAyC;YACxC,+EAA+E;YAC/E,2EAA2E,CAC5E,CAAC;IACH,CAAC;IAEO,kBAAkB,CAAC,QAAiB;QAC3C,IAAI,QAAQ,EAAE,CAAC;YACd,OAAO,QAAQ,CAAC;QACjB,CAAC;QAED,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACnD,OAAO,OAAO,CAAC,WAAW,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;IACvD,CAAC","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { Command, Flags } from \"@oclif/core\";\nimport { dirname, resolve } from \"pathe\";\nimport { DEFAULT_CONCURRENCY, validateConcurrency } from \"../concurrency.js\";\nimport { CheckPolicy } from \"./check.js\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\n/**\n * Runs the Rust-based repopo-core engine with the Node.js sidecar for\n * per-policy execution. Rust owns matching, ordering, concurrency, exception\n * boundaries, repository scheduling and aggregation.\n */\nexport class CheckNative extends Command {\n\tpublic static override readonly summary =\n\t\t\"Checks and applies policies using the Rust engine.\";\n\n\tpublic static override readonly description =\n\t\t\"Runs the Rust-based repopo-core engine with the Node.js sidecar. \" +\n\t\t\"Rust handles file matching, scheduling and reporting; the sidecar shares per-policy contracts with 'check'. \" +\n\t\t\"Repository policies always run with the full repository inventory, including with --stdin. \" +\n\t\t\"With --fix, repository policies can modify files outside the stdin selection.\";\n\n\tpublic static override readonly flags = {\n\t\t\"change-mode\": CheckPolicy.flags[\"change-mode\"],\n\t\t\"change-base\": CheckPolicy.flags[\"change-base\"],\n\t\tconcurrency: Flags.integer({\n\t\t\tdescription:\n\t\t\t\t\"Maximum concurrent files in read-only checks. Fixes remain sequential.\",\n\t\t\tdefault: DEFAULT_CONCURRENCY,\n\t\t\tparse: async (value) => validateConcurrency(Number(value)),\n\t\t}),\n\t\tfix: Flags.boolean({\n\t\t\taliases: [\"resolve\"],\n\t\t\tdescription: \"Fix errors if possible.\",\n\t\t\trequired: false,\n\t\t\tchar: \"f\",\n\t\t}),\n\t\tstdin: Flags.boolean({\n\t\t\tdescription: \"Read list of files from stdin.\",\n\t\t\trequired: false,\n\t\t}),\n\t\tverbose: Flags.boolean({\n\t\t\tdescription: \"Show verbose output including per-policy timing.\",\n\t\t\trequired: false,\n\t\t\tchar: \"v\",\n\t\t}),\n\t\tquiet: Flags.boolean({\n\t\t\tdescription: \"Suppress all output except errors.\",\n\t\t\trequired: false,\n\t\t\tchar: \"q\",\n\t\t}),\n\t\tconfig: Flags.string({\n\t\t\tdescription: \"Path to the config file.\",\n\t\t\trequired: false,\n\t\t\tchar: \"c\",\n\t\t}),\n\t\t\"sidecar-path\": Flags.string({\n\t\t\tdescription: \"Path to the Node.js sidecar script.\",\n\t\t\trequired: false,\n\t\t\tenv: \"REPOPO_SIDECAR_PATH\",\n\t\t}),\n\t\t\"binary-path\": Flags.string({\n\t\t\tdescription: \"Path to the repopo-core Rust binary.\",\n\t\t\trequired: false,\n\t\t\tenv: \"REPOPO_CORE_PATH\",\n\t\t}),\n\t\truntime: Flags.string({\n\t\t\tdescription: \"JS runtime for the sidecar process (auto, node, bun).\",\n\t\t\trequired: false,\n\t\t\tenv: \"REPOPO_RUNTIME\",\n\t\t\toptions: [\"auto\", \"node\", \"bun\"],\n\t\t}),\n\t} as const;\n\n\tpublic override async run(): Promise<void> {\n\t\tconst { flags } = await this.parse(CheckNative);\n\n\t\tconst binaryPath = this.resolveBinaryPath(flags[\"binary-path\"]);\n\t\tconst sidecarPath = this.resolveSidecarPath(flags[\"sidecar-path\"]);\n\n\t\tconst args: string[] = [\"check\", \"--sidecar-path\", sidecarPath];\n\t\tif (flags[\"change-mode\"] !== undefined) {\n\t\t\targs.push(\"--change-mode\", flags[\"change-mode\"]);\n\t\t}\n\t\tif (flags[\"change-base\"] !== undefined) {\n\t\t\targs.push(\"--change-base\", flags[\"change-base\"]);\n\t\t}\n\t\targs.push(\"--concurrency\", String(flags.concurrency));\n\n\t\tif (flags.fix) {\n\t\t\targs.push(\"--fix\");\n\t\t}\n\t\tif (flags.stdin) {\n\t\t\targs.push(\"--stdin\");\n\t\t}\n\t\tif (flags.verbose) {\n\t\t\targs.push(\"--verbose\");\n\t\t}\n\t\tif (flags.quiet) {\n\t\t\targs.push(\"--quiet\");\n\t\t}\n\t\tif (flags.config) {\n\t\t\targs.push(\"--config\", flags.config);\n\t\t}\n\t\tif (flags.runtime) {\n\t\t\targs.push(\"--runtime\", flags.runtime);\n\t\t}\n\n\t\treturn new Promise<void>((resolvePromise, reject) => {\n\t\t\tconst child = spawn(binaryPath, args, {\n\t\t\t\tstdio: \"inherit\",\n\t\t\t\t// biome-ignore lint/style/noProcessEnv: Need to pass parent environment to child process\n\t\t\t\tenv: { ...process.env },\n\t\t\t});\n\t\t\tconst interrupt = () => child.kill(\"SIGINT\");\n\t\t\tconst terminate = () => child.kill(\"SIGTERM\");\n\t\t\tconst cleanup = () => {\n\t\t\t\tprocess.removeListener(\"SIGINT\", interrupt);\n\t\t\t\tprocess.removeListener(\"SIGTERM\", terminate);\n\t\t\t};\n\t\t\tprocess.on(\"SIGINT\", interrupt);\n\t\t\tprocess.on(\"SIGTERM\", terminate);\n\n\t\t\tchild.on(\"error\", (err) => {\n\t\t\t\tcleanup();\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\n\t\t\t\t\t\t`Failed to spawn repopo-core: ${err.message}\\n` +\n\t\t\t\t\t\t\t`Binary path: ${binaryPath}\\n` +\n\t\t\t\t\t\t\t\"Make sure the Rust binary has been built: cargo build --manifest-path crates/core/Cargo.toml\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tchild.on(\"close\", (code, signal) => {\n\t\t\t\tcleanup();\n\t\t\t\tif (code !== 0) {\n\t\t\t\t\tprocess.exitCode =\n\t\t\t\t\t\tcode ??\n\t\t\t\t\t\t(signal === \"SIGINT\" ? 130 : signal === \"SIGTERM\" ? 143 : 1);\n\t\t\t\t}\n\t\t\t\tresolvePromise();\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate resolveBinaryPath(explicit?: string): string {\n\t\tif (explicit) {\n\t\t\treturn explicit;\n\t\t}\n\n\t\tconst packageRoot = resolve(__dirname, \"..\", \"..\");\n\t\tconst binaryName =\n\t\t\tprocess.platform === \"win32\" ? \"repopo-core.exe\" : \"repopo-core\";\n\n\t\t// Check paths in priority order:\n\t\t// 1. Postinstall-downloaded binary (npm install)\n\t\tconst nativePath = resolve(packageRoot, \"native\", binaryName);\n\t\tif (existsSync(nativePath)) {\n\t\t\treturn nativePath;\n\t\t}\n\n\t\t// 2. Local release build (cargo build --release)\n\t\tconst releasePath = resolve(\n\t\t\tpackageRoot,\n\t\t\t\"crates\",\n\t\t\t\"core\",\n\t\t\t\"target\",\n\t\t\t\"release\",\n\t\t\tbinaryName,\n\t\t);\n\t\tif (existsSync(releasePath)) {\n\t\t\treturn releasePath;\n\t\t}\n\n\t\t// 3. Local debug build (cargo build)\n\t\tconst debugPath = resolve(\n\t\t\tpackageRoot,\n\t\t\t\"crates\",\n\t\t\t\"core\",\n\t\t\t\"target\",\n\t\t\t\"debug\",\n\t\t\tbinaryName,\n\t\t);\n\t\tif (existsSync(debugPath)) {\n\t\t\treturn debugPath;\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t\"repopo-core binary not found. Either:\\n\" +\n\t\t\t\t\" - Install the package (npm install repopo) to download pre-built binaries\\n\" +\n\t\t\t\t\" - Build from source: cargo build --manifest-path crates/core/Cargo.toml\",\n\t\t);\n\t}\n\n\tprivate resolveSidecarPath(explicit?: string): string {\n\t\tif (explicit) {\n\t\t\treturn explicit;\n\t\t}\n\n\t\tconst packageRoot = resolve(__dirname, \"..\", \"..\");\n\t\treturn resolve(packageRoot, \"sidecar\", \"sidecar.mjs\");\n\t}\n}\n"]}
|
package/esm/commands/check.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export declare class CheckPolicy<T extends typeof BaseRepopoCommand & {
|
|
|
8
8
|
static readonly description: string;
|
|
9
9
|
static readonly flags: {
|
|
10
10
|
readonly config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
readonly "change-mode": import("@oclif/core/interfaces").OptionFlag<"pr" | "local" | "staged" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
readonly "change-base": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
13
|
readonly concurrency: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
14
|
readonly fix: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
15
|
readonly stdin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AA6BtD,kEAAkE;AAClE,qBAAa,WAAW,CACvB,CAAC,SAAS,OAAO,iBAAiB,GAAG;IACpC,IAAI,EAAE,OAAO,WAAW,CAAC,IAAI,CAAC;IAC9B,KAAK,EAAE,OAAO,WAAW,CAAC,KAAK,CAAC;CAChC,CACA,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAC7B,gBAAgC,OAAO,iEACwB;IAE/D,gBAAgC,WAAW,SAE8D;IAEzG,gBAAgC,KAAK;;;;;;;MA0B1B;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAwD1C,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,WAAW;YAWL,gBAAgB;YAgBhB,sBAAsB;CAGpC"}
|
package/esm/commands/check.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import process from "node:process";
|
|
1
|
+
import process, { env } from "node:process";
|
|
2
2
|
import { Flags } from "@oclif/core";
|
|
3
3
|
import { BaseRepopoCommand } from "../baseCommand.js";
|
|
4
4
|
import { DEFAULT_CONCURRENCY, validateConcurrency } from "../concurrency.js";
|
|
5
5
|
import { parseFilePaths } from "../filePaths.js";
|
|
6
6
|
import { logStats } from "../perf.js";
|
|
7
|
+
import { annotateInventory, collectRepositoryInventory, validateChangeOptions, } from "../repositoryChanges.js";
|
|
7
8
|
import { readRepositoryFiles } from "../repositoryFiles.js";
|
|
8
9
|
import { runPolicies, } from "../runner.js";
|
|
9
10
|
import { normalizeRepoRelativeFilePath } from "../utils/safePaths.js";
|
|
@@ -24,6 +25,13 @@ export class CheckPolicy extends BaseRepopoCommand {
|
|
|
24
25
|
static description = "File policies check selected files. Repository policies always run with the full repository file inventory, " +
|
|
25
26
|
"including with --stdin. With --fix, repository policies can modify files outside the stdin selection.";
|
|
26
27
|
static flags = {
|
|
28
|
+
"change-mode": Flags.option({
|
|
29
|
+
description: "Change context: pr (default), local, or staged. Does not select file-policy paths.",
|
|
30
|
+
options: ["pr", "local", "staged"],
|
|
31
|
+
})(),
|
|
32
|
+
"change-base": Flags.string({
|
|
33
|
+
description: "Override the PR change context base ref.",
|
|
34
|
+
}),
|
|
27
35
|
concurrency: Flags.integer({
|
|
28
36
|
description: "Maximum concurrent files in read-only checks. Fixes remain sequential.",
|
|
29
37
|
default: DEFAULT_CONCURRENCY,
|
|
@@ -47,6 +55,22 @@ export class CheckPolicy extends BaseRepopoCommand {
|
|
|
47
55
|
}
|
|
48
56
|
const context = await this.getContext();
|
|
49
57
|
const files = await this.collectFilePaths(context.gitRoot);
|
|
58
|
+
const mode = this.flags["change-mode"] ?? this.commandConfig?.changes?.mode;
|
|
59
|
+
const changeOptions = {
|
|
60
|
+
mode,
|
|
61
|
+
base: this.flags["change-base"] ??
|
|
62
|
+
((mode ?? "pr") === "pr"
|
|
63
|
+
? env.GITHUB_BASE_REF ||
|
|
64
|
+
env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME ||
|
|
65
|
+
this.commandConfig?.changes?.base
|
|
66
|
+
: undefined),
|
|
67
|
+
};
|
|
68
|
+
validateChangeOptions(changeOptions);
|
|
69
|
+
const inventory = context.policies.some((policy) => policy.scope === "changes") ||
|
|
70
|
+
this.flags["change-mode"] !== undefined ||
|
|
71
|
+
this.flags["change-base"] !== undefined
|
|
72
|
+
? await collectRepositoryInventory(context.gitRoot, changeOptions)
|
|
73
|
+
: [];
|
|
50
74
|
this.verbose(`${context.policies.length} policies loaded.`);
|
|
51
75
|
for (const policy of context.policies) {
|
|
52
76
|
this.verbose(policy.instanceId);
|
|
@@ -55,7 +79,7 @@ export class CheckPolicy extends BaseRepopoCommand {
|
|
|
55
79
|
policies: context.policies,
|
|
56
80
|
root: context.gitRoot,
|
|
57
81
|
files,
|
|
58
|
-
inventory: () => this.collectRepositoryFiles(),
|
|
82
|
+
inventory: async () => annotateInventory(await this.collectRepositoryFiles(), inventory),
|
|
59
83
|
exclude: context.excludeFromAll,
|
|
60
84
|
fix: this.flags.fix,
|
|
61
85
|
concurrency: this.flags.concurrency,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,m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C,KAAK,KAAK,KAAK,CAAC,QAAQ,KAAK,QAAQ,KAAK,KAAK,CAAC,OAAO,EAAE,CAClG,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAAC,OAAe;QAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK;YAC7B,CAAC,CAAC,cAAc,CAAC,MAAM,SAAS,EAAE,CAAC;YACnC,CAAC,CAAC,MAAM,IAAI,CAAC,sBAAsB,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC7B,IAAI,CAAC;gBACJ,OAAO,6BAA6B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACzD,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACzB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,MAAM,IAAI,KAAK,CAAC,sBAAsB,QAAQ,MAAM,OAAO,EAAE,EAAE;oBAC9D,KAAK,EAAE,KAAK;iBACZ,CAAC,CAAC;YACJ,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,sBAAsB;QACnC,OAAO,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC","sourcesContent":["import process from \"node:process\";\nimport { Flags } from \"@oclif/core\";\nimport { BaseRepopoCommand } from \"../baseCommand.js\";\nimport { DEFAULT_CONCURRENCY, validateConcurrency } from \"../concurrency.js\";\nimport { parseFilePaths } from \"../filePaths.js\";\nimport { logStats } from \"../perf.js\";\nimport { readRepositoryFiles } from \"../repositoryFiles.js\";\nimport {\n\ttype PolicyExecutionError,\n\ttype PolicyRunFinding,\n\trunPolicies,\n} from \"../runner.js\";\nimport { normalizeRepoRelativeFilePath } from \"../utils/safePaths.js\";\n\nasync function readStdin(): Promise<string> {\n\tif (process.stdin.isTTY) {\n\t\treturn \"\";\n\t}\n\tprocess.stdin.setEncoding(\"utf8\");\n\tlet data = \"\";\n\tfor await (const chunk of process.stdin) {\n\t\tdata += chunk;\n\t}\n\treturn data;\n}\n\n/** Check selected files and the complete repository inventory. */\nexport class CheckPolicy<\n\tT extends typeof BaseRepopoCommand & {\n\t\targs: typeof CheckPolicy.args;\n\t\tflags: typeof CheckPolicy.flags;\n\t},\n> extends BaseRepopoCommand<T> {\n\tpublic static override readonly summary =\n\t\t\"Checks and applies policies to the files in the repository.\";\n\n\tpublic static override readonly description =\n\t\t\"File policies check selected files. Repository policies always run with the full repository file inventory, \" +\n\t\t\"including with --stdin. With --fix, repository policies can modify files outside the stdin selection.\";\n\n\tpublic static override readonly flags = {\n\t\tconcurrency: Flags.integer({\n\t\t\tdescription:\n\t\t\t\t\"Maximum concurrent files in read-only checks. Fixes remain sequential.\",\n\t\t\tdefault: DEFAULT_CONCURRENCY,\n\t\t\tparse: async (value) => validateConcurrency(Number(value)),\n\t\t}),\n\t\tfix: Flags.boolean({\n\t\t\taliases: [\"resolve\"],\n\t\t\tdescription: \"Fix errors if possible.\",\n\t\t\trequired: false,\n\t\t\tchar: \"f\",\n\t\t}),\n\t\tstdin: Flags.boolean({\n\t\t\tdescription: \"Read list of files from stdin.\",\n\t\t\trequired: false,\n\t\t}),\n\t\t...BaseRepopoCommand.flags,\n\t} as const;\n\n\tpublic override async run(): Promise<void> {\n\t\tif (this.flags.fix) {\n\t\t\tthis.info(\"Resolving errors if possible.\");\n\t\t}\n\t\tconst context = await this.getContext();\n\t\tconst files = await this.collectFilePaths(context.gitRoot);\n\t\tthis.verbose(`${context.policies.length} policies loaded.`);\n\t\tfor (const policy of context.policies) {\n\t\t\tthis.verbose(policy.instanceId);\n\t\t}\n\t\tconst results = await runPolicies({\n\t\t\tpolicies: context.policies,\n\t\t\troot: context.gitRoot,\n\t\t\tfiles,\n\t\t\tinventory: () => this.collectRepositoryFiles(),\n\t\t\texclude: context.excludeFromAll,\n\t\t\tfix: this.flags.fix,\n\t\t\tconcurrency: this.flags.concurrency,\n\t\t});\n\t\tfor (const finding of results.findings) {\n\t\t\tthis.reportFinding(finding);\n\t\t}\n\t\tfor (const error of results.errors) {\n\t\t\tthis.reportError(error);\n\t\t}\n\n\t\tfor (const skipped of results.skipped) {\n\t\t\tthis.verbose(\n\t\t\t\t`Skipped ${skipped.policyId}: ${skipped.scope === \"file\" ? skipped.file : \"repository\"} (${skipped.reason})`,\n\t\t\t);\n\t\t}\n\n\t\tif (!this.flags.quiet) {\n\t\t\tlogStats(results.perfStats, this.logger);\n\t\t}\n\t}\n\n\tprivate reportFinding(finding: PolicyRunFinding): void {\n\t\tconst location =\n\t\t\tfinding.scope === \"file\"\n\t\t\t\t? finding.file\n\t\t\t\t: finding.files?.join(\", \") || \"repository\";\n\t\tconst message = `${finding.policyId}: ${location}: ${finding.message}`;\n\t\tif (finding.fixStatus === \"fixed\") {\n\t\t\tthis.info(`Resolved ${message}`);\n\t\t\treturn;\n\t\t}\n\t\tprocess.exitCode = 1;\n\t\tthis.warning(message);\n\t\tif (finding.manualFix) {\n\t\t\tthis.warning(`Manual fix: ${finding.manualFix}`);\n\t\t}\n\t}\n\n\tprivate reportError(error: PolicyExecutionError): void {\n\t\tprocess.exitCode = 1;\n\t\tconst location =\n\t\t\terror.scope === \"file\"\n\t\t\t\t? error.file\n\t\t\t\t: error.files.join(\", \") || \"repository\";\n\t\tthis.warning(\n\t\t\t`Execution error (${error.kind}, ${error.phase}) ${error.policyId}: ${location}: ${error.message}`,\n\t\t);\n\t}\n\n\tprivate async collectFilePaths(gitRoot: string): Promise<string[]> {\n\t\tconst paths = this.flags.stdin\n\t\t\t? parseFilePaths(await readStdin())\n\t\t\t: await this.collectRepositoryFiles();\n\t\treturn paths.map((filePath) => {\n\t\t\ttry {\n\t\t\t\treturn normalizeRepoRelativeFilePath(gitRoot, filePath);\n\t\t\t} catch (error: unknown) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow new Error(`Invalid file path '${filePath}': ${message}`, {\n\t\t\t\t\tcause: error,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate async collectRepositoryFiles(): Promise<string[]> {\n\t\treturn readRepositoryFiles(this.git);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EACN,iBAAiB,EACjB,0BAA0B,EAC1B,qBAAqB,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAGN,WAAW,GACX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAEtE,KAAK,UAAU,SAAS;IACvB,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QACzC,IAAI,IAAI,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,kEAAkE;AAClE,MAAM,OAAO,WAKX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D,KAAK,EAAE,KAAK;iBACZ,CAAC,CAAC;YACJ,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,sBAAsB;QACnC,OAAO,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC","sourcesContent":["import process, { env } from \"node:process\";\nimport { Flags } from \"@oclif/core\";\nimport { BaseRepopoCommand } from \"../baseCommand.js\";\nimport { DEFAULT_CONCURRENCY, validateConcurrency } from \"../concurrency.js\";\nimport { parseFilePaths } from \"../filePaths.js\";\nimport { logStats } from \"../perf.js\";\nimport {\n\tannotateInventory,\n\tcollectRepositoryInventory,\n\tvalidateChangeOptions,\n} from \"../repositoryChanges.js\";\nimport { readRepositoryFiles } from \"../repositoryFiles.js\";\nimport {\n\ttype PolicyExecutionError,\n\ttype PolicyRunFinding,\n\trunPolicies,\n} from \"../runner.js\";\nimport { normalizeRepoRelativeFilePath } from \"../utils/safePaths.js\";\n\nasync function readStdin(): Promise<string> {\n\tif (process.stdin.isTTY) {\n\t\treturn \"\";\n\t}\n\tprocess.stdin.setEncoding(\"utf8\");\n\tlet data = \"\";\n\tfor await (const chunk of process.stdin) {\n\t\tdata += chunk;\n\t}\n\treturn data;\n}\n\n/** Check selected files and the complete repository inventory. */\nexport class CheckPolicy<\n\tT extends typeof BaseRepopoCommand & {\n\t\targs: typeof CheckPolicy.args;\n\t\tflags: typeof CheckPolicy.flags;\n\t},\n> extends BaseRepopoCommand<T> {\n\tpublic static override readonly summary =\n\t\t\"Checks and applies policies to the files in the repository.\";\n\n\tpublic static override readonly description =\n\t\t\"File policies check selected files. Repository policies always run with the full repository file inventory, \" +\n\t\t\"including with --stdin. With --fix, repository policies can modify files outside the stdin selection.\";\n\n\tpublic static override readonly flags = {\n\t\t\"change-mode\": Flags.option({\n\t\t\tdescription:\n\t\t\t\t\"Change context: pr (default), local, or staged. Does not select file-policy paths.\",\n\t\t\toptions: [\"pr\", \"local\", \"staged\"] as const,\n\t\t})(),\n\t\t\"change-base\": Flags.string({\n\t\t\tdescription: \"Override the PR change context base ref.\",\n\t\t}),\n\t\tconcurrency: Flags.integer({\n\t\t\tdescription:\n\t\t\t\t\"Maximum concurrent files in read-only checks. Fixes remain sequential.\",\n\t\t\tdefault: DEFAULT_CONCURRENCY,\n\t\t\tparse: async (value) => validateConcurrency(Number(value)),\n\t\t}),\n\t\tfix: Flags.boolean({\n\t\t\taliases: [\"resolve\"],\n\t\t\tdescription: \"Fix errors if possible.\",\n\t\t\trequired: false,\n\t\t\tchar: \"f\",\n\t\t}),\n\t\tstdin: Flags.boolean({\n\t\t\tdescription: \"Read list of files from stdin.\",\n\t\t\trequired: false,\n\t\t}),\n\t\t...BaseRepopoCommand.flags,\n\t} as const;\n\n\tpublic override async run(): Promise<void> {\n\t\tif (this.flags.fix) {\n\t\t\tthis.info(\"Resolving errors if possible.\");\n\t\t}\n\t\tconst context = await this.getContext();\n\t\tconst files = await this.collectFilePaths(context.gitRoot);\n\t\tconst mode = this.flags[\"change-mode\"] ?? this.commandConfig?.changes?.mode;\n\t\tconst changeOptions = {\n\t\t\tmode,\n\t\t\tbase:\n\t\t\t\tthis.flags[\"change-base\"] ??\n\t\t\t\t((mode ?? \"pr\") === \"pr\"\n\t\t\t\t\t? env.GITHUB_BASE_REF ||\n\t\t\t\t\t\tenv.CI_MERGE_REQUEST_TARGET_BRANCH_NAME ||\n\t\t\t\t\t\tthis.commandConfig?.changes?.base\n\t\t\t\t\t: undefined),\n\t\t};\n\t\tvalidateChangeOptions(changeOptions);\n\t\tconst inventory =\n\t\t\tcontext.policies.some((policy) => policy.scope === \"changes\") ||\n\t\t\tthis.flags[\"change-mode\"] !== undefined ||\n\t\t\tthis.flags[\"change-base\"] !== undefined\n\t\t\t\t? await collectRepositoryInventory(context.gitRoot, changeOptions)\n\t\t\t\t: [];\n\t\tthis.verbose(`${context.policies.length} policies loaded.`);\n\t\tfor (const policy of context.policies) {\n\t\t\tthis.verbose(policy.instanceId);\n\t\t}\n\t\tconst results = await runPolicies({\n\t\t\tpolicies: context.policies,\n\t\t\troot: context.gitRoot,\n\t\t\tfiles,\n\t\t\tinventory: async () =>\n\t\t\t\tannotateInventory(await this.collectRepositoryFiles(), inventory),\n\t\t\texclude: context.excludeFromAll,\n\t\t\tfix: this.flags.fix,\n\t\t\tconcurrency: this.flags.concurrency,\n\t\t});\n\t\tfor (const finding of results.findings) {\n\t\t\tthis.reportFinding(finding);\n\t\t}\n\t\tfor (const error of results.errors) {\n\t\t\tthis.reportError(error);\n\t\t}\n\n\t\tfor (const skipped of results.skipped) {\n\t\t\tthis.verbose(\n\t\t\t\t`Skipped ${skipped.policyId}: ${skipped.scope === \"file\" ? skipped.file : \"repository\"} (${skipped.reason})`,\n\t\t\t);\n\t\t}\n\n\t\tif (!this.flags.quiet) {\n\t\t\tlogStats(results.perfStats, this.logger);\n\t\t}\n\t}\n\n\tprivate reportFinding(finding: PolicyRunFinding): void {\n\t\tconst location =\n\t\t\tfinding.scope === \"file\"\n\t\t\t\t? finding.file\n\t\t\t\t: finding.files?.join(\", \") || \"repository\";\n\t\tconst message = `${finding.policyId}: ${location}: ${finding.message}`;\n\t\tif (finding.fixStatus === \"fixed\") {\n\t\t\tthis.info(`Resolved ${message}`);\n\t\t\treturn;\n\t\t}\n\t\tprocess.exitCode = 1;\n\t\tthis.warning(message);\n\t\tif (finding.manualFix) {\n\t\t\tthis.warning(`Manual fix: ${finding.manualFix}`);\n\t\t}\n\t}\n\n\tprivate reportError(error: PolicyExecutionError): void {\n\t\tprocess.exitCode = 1;\n\t\tconst location =\n\t\t\terror.scope === \"file\"\n\t\t\t\t? error.file\n\t\t\t\t: error.files.join(\", \") || \"repository\";\n\t\tthis.warning(\n\t\t\t`Execution error (${error.kind}, ${error.phase}) ${error.policyId}: ${location}: ${error.message}`,\n\t\t);\n\t}\n\n\tprivate async collectFilePaths(gitRoot: string): Promise<string[]> {\n\t\tconst paths = this.flags.stdin\n\t\t\t? parseFilePaths(await readStdin())\n\t\t\t: await this.collectRepositoryFiles();\n\t\treturn paths.map((filePath) => {\n\t\t\ttry {\n\t\t\t\treturn normalizeRepoRelativeFilePath(gitRoot, filePath);\n\t\t\t} catch (error: unknown) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow new Error(`Invalid file path '${filePath}': ${message}`, {\n\t\t\t\t\tcause: error,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate async collectRepositoryFiles(): Promise<string[]> {\n\t\treturn readRepositoryFiles(this.git);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,qBAAa,WAAW,CACvB,CAAC,SAAS,OAAO,iBAAiB,GAAG;IACpC,IAAI,EAAE,OAAO,WAAW,CAAC,IAAI,CAAC;IAC9B,KAAK,EAAE,OAAO,WAAW,CAAC,KAAK,CAAC;CAChC,CACA,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAC7B,gBAAgC,OAAO,2CACE;IAEnB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,qBAAa,WAAW,CACvB,CAAC,SAAS,OAAO,iBAAiB,GAAG;IACpC,IAAI,EAAE,OAAO,WAAW,CAAC,IAAI,CAAC;IAC9B,KAAK,EAAE,OAAO,WAAW,CAAC,KAAK,CAAC;CAChC,CACA,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAC7B,gBAAgC,OAAO,2CACE;IAEnB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAW1C"}
|
package/esm/commands/list.js
CHANGED
|
@@ -11,7 +11,7 @@ export class ListCommand extends BaseRepopoCommand {
|
|
|
11
11
|
this.log(configuredPolicy.instanceId);
|
|
12
12
|
this.log(` ${configuredPolicy.description}`);
|
|
13
13
|
this.log(` scope: ${configuredPolicy.scope ?? "file"}`);
|
|
14
|
-
this.log(` resolver: ${configuredPolicy.
|
|
14
|
+
this.log(` resolver: ${configuredPolicy.resolver !== undefined}\n`);
|
|
15
15
|
}
|
|
16
16
|
this.log(`${policies.length} TOTAL POLICY HANDLERS`);
|
|
17
17
|
}
|
package/esm/commands/list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,WAKX,SAAQ,iBAAoB;IACtB,MAAM,CAAmB,OAAO,GACtC,uCAAuC,CAAC;IAEzB,KAAK,CAAC,GAAG;QACxB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QAC7C,8BAA8B;QAC9B,KAAK,MAAM,gBAAgB,IAAI,QAAQ,EAAE,CAAC;YACzC,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;YACtC,IAAI,CAAC,GAAG,CAAC,KAAK,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAC;YAC9C,IAAI,CAAC,GAAG,CAAC,YAAY,gBAAgB,CAAC,KAAK,IAAI,MAAM,EAAE,CAAC,CAAC;YACzD,IAAI,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,WAKX,SAAQ,iBAAoB;IACtB,MAAM,CAAmB,OAAO,GACtC,uCAAuC,CAAC;IAEzB,KAAK,CAAC,GAAG;QACxB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QAC7C,8BAA8B;QAC9B,KAAK,MAAM,gBAAgB,IAAI,QAAQ,EAAE,CAAC;YACzC,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;YACtC,IAAI,CAAC,GAAG,CAAC,KAAK,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAC;YAC9C,IAAI,CAAC,GAAG,CAAC,YAAY,gBAAgB,CAAC,KAAK,IAAI,MAAM,EAAE,CAAC,CAAC;YACzD,IAAI,CAAC,GAAG,CAAC,eAAe,gBAAgB,CAAC,QAAQ,KAAK,SAAS,IAAI,CAAC,CAAC;QACtE,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,wBAAwB,CAAC,CAAC;IACtD,CAAC","sourcesContent":["import { BaseRepopoCommand } from \"../baseCommand.js\";\n\n/**\n * This command lists all the policies configured to run.\n */\nexport class ListCommand<\n\tT extends typeof BaseRepopoCommand & {\n\t\targs: typeof ListCommand.args;\n\t\tflags: typeof ListCommand.flags;\n\t},\n> extends BaseRepopoCommand<T> {\n\tpublic static override readonly summary =\n\t\t\"Lists the policies configured to run.\";\n\n\tpublic override async run(): Promise<void> {\n\t\tconst { policies } = await this.getContext();\n\t\t// list the handlers then exit\n\t\tfor (const configuredPolicy of policies) {\n\t\t\tthis.log(configuredPolicy.instanceId);\n\t\t\tthis.log(` ${configuredPolicy.description}`);\n\t\t\tthis.log(` scope: ${configuredPolicy.scope ?? \"file\"}`);\n\t\t\tthis.log(` resolver: ${configuredPolicy.resolver !== undefined}\\n`);\n\t\t}\n\t\tthis.log(`${policies.length} TOTAL POLICY HANDLERS`);\n\t}\n}\n"]}
|
package/esm/config.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ export interface RepopoConfig {
|
|
|
4
4
|
policies?: ConfiguredPolicy[];
|
|
5
5
|
/** Repo-relative regex exclusions. Strings are case-insensitive. */
|
|
6
6
|
excludeFiles?: (string | RegExp)[];
|
|
7
|
+
/** Git comparison defaults; CLI base overrides CI, which overrides this base. */
|
|
8
|
+
changes?: {
|
|
9
|
+
mode?: "pr" | "local" | "staged" | undefined;
|
|
10
|
+
base?: string | undefined;
|
|
11
|
+
} | undefined;
|
|
7
12
|
}
|
|
8
13
|
/** The default configuration when no config file is found. @alpha */
|
|
9
14
|
export declare const DefaultPolicyConfig: RepopoConfig;
|
package/esm/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAErE,oDAAoD;AACpD,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC9B,oEAAoE;IACpE,YAAY,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAErE,oDAAoD;AACpD,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC9B,oEAAoE;IACpE,YAAY,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACnC,iFAAiF;IACjF,OAAO,CAAC,EACL;QACA,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;QAC7C,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KACzB,GACD,SAAS,CAAC;CACb;AAED,qEAAqE;AACrE,eAAO,MAAM,mBAAmB,EAAE,YAGjC,CAAC"}
|
package/esm/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAyB,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAyB,eAAe,EAAE,MAAM,aAAa,CAAC;AAgBrE,qEAAqE;AACrE,MAAM,CAAC,MAAM,mBAAmB,GAAiB;IAChD,QAAQ,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACrE,YAAY,EAAE,EAAE;CAChB,CAAC","sourcesContent":["import { makePolicy } from \"./makePolicy.js\";\nimport { type ConfiguredPolicy, DefaultPolicies } from \"./policy.js\";\n\n/** Repository-wide policy configuration. @public */\nexport interface RepopoConfig {\n\tpolicies?: ConfiguredPolicy[];\n\t/** Repo-relative regex exclusions. Strings are case-insensitive. */\n\texcludeFiles?: (string | RegExp)[];\n\t/** Git comparison defaults; CLI base overrides CI, which overrides this base. */\n\tchanges?:\n\t\t| {\n\t\t\t\tmode?: \"pr\" | \"local\" | \"staged\" | undefined;\n\t\t\t\tbase?: string | undefined;\n\t\t }\n\t\t| undefined;\n}\n\n/** The default configuration when no config file is found. @alpha */\nexport const DefaultPolicyConfig: RepopoConfig = {\n\tpolicies: DefaultPolicies.map((definition) => makePolicy(definition)),\n\texcludeFiles: [],\n};\n"]}
|
package/esm/context.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export type ExcludedPolicyFileMap = Map<PolicyInstanceId, RegExp[]>;
|
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
14
|
export declare function exclusionRegex(pattern: string | RegExp): RegExp;
|
|
15
|
+
/** Match without leaking global/sticky regex state between paths. @internal */
|
|
16
|
+
export declare function matchesPath(regex: RegExp, file: string): boolean;
|
|
15
17
|
/**
|
|
16
18
|
* Creates the per-instance exclusion map used by policy runners.
|
|
17
19
|
*
|
package/esm/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,GAAG,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC,CAAC;AAEpE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAC1C,QAAQ,EAAE,gBAAgB,EAAE,GAC1B,qBAAqB,CAOvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;IAEzB;;OAEG;IACH,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAE7B;;OAEG;IACH,uBAAuB,EAAE,qBAAqB,CAAC;IAE/C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,sBAAsB,CAAC;CAClC"}
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,GAAG,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC,CAAC;AAEpE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAE/D;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAQhE;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAC1C,QAAQ,EAAE,gBAAgB,EAAE,GAC1B,qBAAqB,CAOvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;IAEzB;;OAEG;IACH,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAE7B;;OAEG;IACH,uBAAuB,EAAE,qBAAqB,CAAC;IAE/C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,sBAAsB,CAAC;CAClC"}
|
package/esm/context.js
CHANGED
|
@@ -5,6 +5,17 @@
|
|
|
5
5
|
export function exclusionRegex(pattern) {
|
|
6
6
|
return typeof pattern === "string" ? new RegExp(pattern, "i") : pattern;
|
|
7
7
|
}
|
|
8
|
+
/** Match without leaking global/sticky regex state between paths. @internal */
|
|
9
|
+
export function matchesPath(regex, file) {
|
|
10
|
+
const index = regex.lastIndex;
|
|
11
|
+
try {
|
|
12
|
+
regex.lastIndex = 0;
|
|
13
|
+
return regex.test(file);
|
|
14
|
+
}
|
|
15
|
+
finally {
|
|
16
|
+
regex.lastIndex = index;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
8
19
|
/**
|
|
9
20
|
* Creates the per-instance exclusion map used by policy runners.
|
|
10
21
|
*
|
package/esm/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,OAAwB;IACtD,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACzE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAC1C,QAA4B;IAE5B,OAAO,IAAI,GAAG,CACb,QAAQ,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC;QAClC,gBAAgB,CAAC,UAAU;QAC3B,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE;KACnD,CAAC,CACF,CAAC;AACH,CAAC","sourcesContent":["import type { PolicyHandlerPerfStats } from \"./perf.js\";\nimport type { IdentifiedPolicy, PolicyInstanceId } from \"./policy.js\";\n\n/**\n * A map of policy instance IDs to file-path regexes that should be excluded from those policies.\n * Paths are relative to the repository root.\n *\n * @public\n */\nexport type ExcludedPolicyFileMap = Map<PolicyInstanceId, RegExp[]>;\n\n/**\n * Preserve explicit regex flags; string exclusions remain case-insensitive.\n * @internal\n */\nexport function exclusionRegex(pattern: string | RegExp): RegExp {\n\treturn typeof pattern === \"string\" ? new RegExp(pattern, \"i\") : pattern;\n}\n\n/**\n * Creates the per-instance exclusion map used by policy runners.\n *\n * @internal\n */\nexport function createExcludedPolicyFileMap(\n\tpolicies: IdentifiedPolicy[],\n): ExcludedPolicyFileMap {\n\treturn new Map(\n\t\tpolicies.map((configuredPolicy) => [\n\t\t\tconfiguredPolicy.instanceId,\n\t\t\tconfiguredPolicy.exclude?.map(exclusionRegex) ?? [],\n\t\t]),\n\t);\n}\n\n/**\n * Contextual data available to all Repopo commands.\n */\nexport interface RepopoCommandContext {\n\t/**\n\t * A list of regular expressions used to exclude files from all handlers.\n\t */\n\texcludeFromAll: RegExp[];\n\n\t/**\n\t * A list of handlers to apply to selected files.\n\t */\n\tpolicies: IdentifiedPolicy[];\n\n\t/**\n\t * A per-handler list of regular expressions used to exclude files from specific handlers.\n\t */\n\texcludePoliciesForFiles: ExcludedPolicyFileMap;\n\n\t/**\n\t * Path to the root of the git repo.\n\t */\n\tgitRoot: string;\n\n\t/**\n\t * Stores performance data for each handler. Used to collect and display performance stats.\n\t */\n\tperfStats: PolicyHandlerPerfStats;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,OAAwB;IACtD,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACzE,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,IAAY;IACtD,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC;IAC9B,IAAI,CAAC;QACJ,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;QACpB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;YAAS,CAAC;QACV,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAC1C,QAA4B;IAE5B,OAAO,IAAI,GAAG,CACb,QAAQ,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC;QAClC,gBAAgB,CAAC,UAAU;QAC3B,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE;KACnD,CAAC,CACF,CAAC;AACH,CAAC","sourcesContent":["import type { PolicyHandlerPerfStats } from \"./perf.js\";\nimport type { IdentifiedPolicy, PolicyInstanceId } from \"./policy.js\";\n\n/**\n * A map of policy instance IDs to file-path regexes that should be excluded from those policies.\n * Paths are relative to the repository root.\n *\n * @public\n */\nexport type ExcludedPolicyFileMap = Map<PolicyInstanceId, RegExp[]>;\n\n/**\n * Preserve explicit regex flags; string exclusions remain case-insensitive.\n * @internal\n */\nexport function exclusionRegex(pattern: string | RegExp): RegExp {\n\treturn typeof pattern === \"string\" ? new RegExp(pattern, \"i\") : pattern;\n}\n\n/** Match without leaking global/sticky regex state between paths. @internal */\nexport function matchesPath(regex: RegExp, file: string): boolean {\n\tconst index = regex.lastIndex;\n\ttry {\n\t\tregex.lastIndex = 0;\n\t\treturn regex.test(file);\n\t} finally {\n\t\tregex.lastIndex = index;\n\t}\n}\n\n/**\n * Creates the per-instance exclusion map used by policy runners.\n *\n * @internal\n */\nexport function createExcludedPolicyFileMap(\n\tpolicies: IdentifiedPolicy[],\n): ExcludedPolicyFileMap {\n\treturn new Map(\n\t\tpolicies.map((configuredPolicy) => [\n\t\t\tconfiguredPolicy.instanceId,\n\t\t\tconfiguredPolicy.exclude?.map(exclusionRegex) ?? [],\n\t\t]),\n\t);\n}\n\n/**\n * Contextual data available to all Repopo commands.\n */\nexport interface RepopoCommandContext {\n\t/**\n\t * A list of regular expressions used to exclude files from all handlers.\n\t */\n\texcludeFromAll: RegExp[];\n\n\t/**\n\t * A list of handlers to apply to selected files.\n\t */\n\tpolicies: IdentifiedPolicy[];\n\n\t/**\n\t * A per-handler list of regular expressions used to exclude files from specific handlers.\n\t */\n\texcludePoliciesForFiles: ExcludedPolicyFileMap;\n\n\t/**\n\t * Path to the root of the git repo.\n\t */\n\tgitRoot: string;\n\n\t/**\n\t * Stores performance data for each handler. Used to collect and display performance stats.\n\t */\n\tperfStats: PolicyHandlerPerfStats;\n}\n"]}
|
package/esm/makePolicy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makePolicy.d.ts","sourceRoot":"","sources":["../src/makePolicy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,oBAAoB,EACpB,gBAAgB,EAChB,0BAA0B,EAC1B,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,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,CAAC,CAAC,GACvB,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,CAAC,SAAS,0BAA0B,CAAC,OAAO,CAAC,EACvE,UAAU,EAAE,CAAC,EACb,GAAG,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GACvB,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,uFAAuF;AACvF,wBAAgB,UAAU,CAAC,CAAC,SAAS,gBAAgB,CAAC,OAAO,CAAC,EAC7D,UAAU,EAAE,CAAC,EACb,GAAG,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GACvB,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAyDjC,mEAAmE;AACnE,wBAAgB,uBAAuB,CACtC,CAAC,SAAS;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,UAAU,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAA;CAAE,EACxE,QAAQ,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG;IAAE,UAAU,EAAE,gBAAgB,CAAA;CAAE,CAAC,EAAE,CA6BlE"}
|
package/esm/makePolicy.js
CHANGED
|
@@ -9,7 +9,9 @@ export function makePolicy(definition, options, ...extra) {
|
|
|
9
9
|
Object.keys(options).some((key) => !["config", "exclude", "instanceId"].includes(key))))) {
|
|
10
10
|
throw new TypeError(guidance);
|
|
11
11
|
}
|
|
12
|
-
if (definition.scope
|
|
12
|
+
if (definition.scope !== undefined &&
|
|
13
|
+
definition.scope !== "file" &&
|
|
14
|
+
definition.resolver !== undefined) {
|
|
13
15
|
throw new TypeError("Repository policies support inline fixes only; remove resolver.");
|
|
14
16
|
}
|
|
15
17
|
if (options?.exclude !== undefined &&
|
package/esm/makePolicy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makePolicy.js","sourceRoot":"","sources":["../src/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,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACrB,OAAO,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { exclusionRegex } from \"./context.js\";\nimport type {\n\tConfiguredFilePolicy,\n\tConfiguredPolicy,\n\tConfiguredRepositoryPolicy,\n\tDefinedConfig,\n\tFilePolicyDefinition,\n\tPolicyDefinition,\n\tPolicyInstanceId,\n\tPolicyName,\n\tPolicyOptions,\n\tRepositoryPolicyDefinition,\n} from \"./policy.js\";\n\ntype ConfigOf<D> = D extends PolicyDefinition<infer C> ? C : never;\ntype RequiredConfigDefinitions<D> = D extends { requiresConfig: true }\n\t? D extends { defaultConfig: infer Default }\n\t\t? undefined extends Default\n\t\t\t? D\n\t\t\t: never\n\t\t: D\n\t: never;\ntype OptionsFor<D> = [RequiredConfigDefinitions<D>] extends [never]\n\t? [options?: PolicyOptions<ConfigOf<D>>]\n\t: [\n\t\t\toptions: PolicyOptions<ConfigOf<D>> & {\n\t\t\t\tconfig: DefinedConfig<ConfigOf<RequiredConfigDefinitions<D>>>;\n\t\t\t},\n\t\t];\n\n/** Configure a file definition using a single options object. @public */\nexport function makePolicy<D extends FilePolicyDefinition<unknown>>(\n\tdefinition: D,\n\t...options: OptionsFor<D>\n): ConfiguredFilePolicy<ConfigOf<D>>;\n/** Configure a repository definition using a single options object. @public */\nexport function makePolicy<D extends RepositoryPolicyDefinition<unknown>>(\n\tdefinition: D,\n\t...options: OptionsFor<D>\n): ConfiguredRepositoryPolicy<ConfigOf<D>>;\n/** Configure a common-union definition without losing scope discrimination. @public */\nexport function makePolicy<D extends PolicyDefinition<unknown>>(\n\tdefinition: D,\n\t...options: OptionsFor<D>\n): ConfiguredPolicy<ConfigOf<D>>;\nexport function makePolicy(\n\tdefinition: PolicyDefinition<unknown>,\n\toptions?: PolicyOptions<unknown>,\n\t...extra: unknown[]\n): ConfiguredPolicy<unknown> {\n\tconst guidance =\n\t\t\"Use makePolicy(definition, { config, exclude, instanceId }); positional config, third arguments and excludeFiles are no longer supported.\";\n\tif (\n\t\textra.length > 0 ||\n\t\t(options !== undefined &&\n\t\t\t(typeof options !== \"object\" ||\n\t\t\t\toptions === null ||\n\t\t\t\tArray.isArray(options) ||\n\t\t\t\tObject.keys(options).some(\n\t\t\t\t\t(key) => ![\"config\", \"exclude\", \"instanceId\"].includes(key),\n\t\t\t\t)))\n\t) {\n\t\tthrow new TypeError(guidance);\n\t}\n\tif (\n\t\tdefinition.scope !== undefined &&\n\t\tdefinition.scope !== \"file\" &&\n\t\tdefinition.resolver !== undefined\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"Repository policies support inline fixes only; remove resolver.\",\n\t\t);\n\t}\n\tif (\n\t\toptions?.exclude !== undefined &&\n\t\t!(\n\t\t\tArray.isArray(options.exclude) &&\n\t\t\toptions.exclude.every(\n\t\t\t\t(value) => typeof value === \"string\" || value instanceof RegExp,\n\t\t\t)\n\t\t)\n\t) {\n\t\tthrow new TypeError(guidance);\n\t}\n\tif (\n\t\toptions?.instanceId !== undefined &&\n\t\t(typeof options.instanceId !== \"string\" || options.instanceId.length === 0)\n\t) {\n\t\tthrow new TypeError(\"instanceId must be a nonempty string.\");\n\t}\n\toptions?.exclude?.forEach(exclusionRegex);\n\tconst config =\n\t\toptions?.config === undefined ? definition.defaultConfig : options.config;\n\tif (definition.requiresConfig && config === undefined) {\n\t\tthrow new TypeError(\n\t\t\t`Policy '${definition.name}' requires config. ${guidance}`,\n\t\t);\n\t}\n\treturn { ...definition, ...options, config };\n}\n\n/** Assign stable IDs, rejecting ambiguous duplicates. @internal */\nexport function identifyPolicyInstances<\n\tT extends { name: PolicyName; instanceId?: PolicyInstanceId | undefined },\n>(policies: readonly T[]): (T & { instanceId: PolicyInstanceId })[] {\n\tconst names = new Map<string, number>();\n\tconst ids = new Set<string>();\n\tfor (const policy of policies) {\n\t\tnames.set(policy.name, (names.get(policy.name) ?? 0) + 1);\n\t\tif (policy.instanceId !== undefined) {\n\t\t\tif (ids.has(policy.instanceId)) {\n\t\t\t\tthrow new Error(`Duplicate policy instance ID: ${policy.instanceId}`);\n\t\t\t}\n\t\t\tids.add(policy.instanceId);\n\t\t}\n\t}\n\treturn policies.map((policy) => {\n\t\tif (policy.instanceId !== undefined) {\n\t\t\treturn { ...policy, instanceId: policy.instanceId };\n\t\t}\n\t\tif ((names.get(policy.name) ?? 0) > 1) {\n\t\t\tthrow new Error(\n\t\t\t\t`Policy '${policy.name}' is configured multiple times. Set a unique instanceId for each instance.`,\n\t\t\t);\n\t\t}\n\t\tif (ids.has(policy.name)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Policy instance ID '${policy.name}' conflicts with another configured policy. Set an explicit unique instanceId.`,\n\t\t\t);\n\t\t}\n\t\tids.add(policy.name);\n\t\treturn { ...policy, instanceId: policy.name };\n\t});\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Configuration for the changed-file limit. @public */
|
|
2
|
+
export interface MaxChangedFilesConfig {
|
|
3
|
+
/** Maximum number of eligible changed files; must be a nonnegative integer. */
|
|
4
|
+
maxFiles: number;
|
|
5
|
+
}
|
|
6
|
+
/** Limit the number of files in the selected change set. @public */
|
|
7
|
+
export declare const MaxChangedFiles: {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
scope: "changes";
|
|
11
|
+
requiresConfig: true;
|
|
12
|
+
handler: ({ entries, config }: import("../policy.js").RepositoryPolicyArgs<MaxChangedFilesConfig>) => Promise<{
|
|
13
|
+
message: string;
|
|
14
|
+
manualFix: string;
|
|
15
|
+
}[]>;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=MaxChangedFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaxChangedFiles.d.ts","sourceRoot":"","sources":["../../src/policies/MaxChangedFiles.ts"],"names":[],"mappings":"AAEA,wDAAwD;AACxD,MAAM,WAAW,qBAAqB;IACrC,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,oEAAoE;AACpE,eAAO,MAAM,eAAe;;;;;;;;;CAwBiC,CAAC"}
|