repopo 0.9.0 → 0.12.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 +81 -0
- package/README.md +41 -2
- package/THIRD-PARTY-LICENSES.txt +71 -11
- package/bin/dev.js +5 -1
- package/esm/baseCommand.d.ts +1 -1
- package/esm/baseCommand.d.ts.map +1 -1
- package/esm/baseCommand.js +6 -9
- package/esm/baseCommand.js.map +1 -1
- package/esm/commands/check-native.d.ts +25 -0
- package/esm/commands/check-native.d.ts.map +1 -0
- package/esm/commands/check-native.js +137 -0
- package/esm/commands/check-native.js.map +1 -0
- package/esm/commands/check.d.ts +8 -19
- package/esm/commands/check.d.ts.map +1 -1
- package/esm/commands/check.js +97 -169
- package/esm/commands/check.js.map +1 -1
- package/esm/commands/list.d.ts.map +1 -1
- package/esm/commands/list.js +5 -6
- package/esm/commands/list.js.map +1 -1
- package/esm/config.d.ts +19 -4
- package/esm/config.d.ts.map +1 -1
- package/esm/config.js +2 -3
- package/esm/config.js.map +1 -1
- package/esm/context.d.ts +13 -3
- package/esm/context.d.ts.map +1 -1
- package/esm/context.js +11 -1
- package/esm/context.js.map +1 -1
- package/esm/index.d.ts +7 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +9 -1
- package/esm/index.js.map +1 -1
- package/esm/makePolicy.d.ts +77 -8
- package/esm/makePolicy.d.ts.map +1 -1
- package/esm/makePolicy.js +108 -4
- package/esm/makePolicy.js.map +1 -1
- package/esm/perf.d.ts +7 -2
- package/esm/perf.d.ts.map +1 -1
- package/esm/perf.js.map +1 -1
- package/esm/policies/CargoLicenceValidated.d.ts +41 -0
- package/esm/policies/CargoLicenceValidated.d.ts.map +1 -0
- package/esm/policies/CargoLicenceValidated.js +45 -0
- package/esm/policies/CargoLicenceValidated.js.map +1 -0
- package/esm/policies/CargoLintsConfigured.d.ts +30 -0
- package/esm/policies/CargoLintsConfigured.d.ts.map +1 -0
- package/esm/policies/CargoLintsConfigured.js +61 -0
- package/esm/policies/CargoLintsConfigured.js.map +1 -0
- package/esm/policies/CargoLockPolicy.d.ts +34 -0
- package/esm/policies/CargoLockPolicy.d.ts.map +1 -0
- package/esm/policies/CargoLockPolicy.js +57 -0
- package/esm/policies/CargoLockPolicy.js.map +1 -0
- package/esm/policies/CargoTomlRequired.d.ts +34 -0
- package/esm/policies/CargoTomlRequired.d.ts.map +1 -0
- package/esm/policies/CargoTomlRequired.js +77 -0
- package/esm/policies/CargoTomlRequired.js.map +1 -0
- package/esm/policies/CargoTomlSorted.d.ts +20 -0
- package/esm/policies/CargoTomlSorted.d.ts.map +1 -0
- package/esm/policies/CargoTomlSorted.js +164 -0
- package/esm/policies/CargoTomlSorted.js.map +1 -0
- package/esm/policies/ConditionalScripts.d.ts +94 -0
- package/esm/policies/ConditionalScripts.d.ts.map +1 -0
- package/esm/policies/ConditionalScripts.js +145 -0
- package/esm/policies/ConditionalScripts.js.map +1 -0
- package/esm/policies/ExactScripts.d.ts +51 -0
- package/esm/policies/ExactScripts.d.ts.map +1 -0
- package/esm/policies/ExactScripts.js +108 -0
- package/esm/policies/ExactScripts.js.map +1 -0
- package/esm/policies/GleamDepVersions.d.ts +25 -0
- package/esm/policies/GleamDepVersions.d.ts.map +1 -0
- package/esm/policies/GleamDepVersions.js +67 -0
- package/esm/policies/GleamDepVersions.js.map +1 -0
- package/esm/policies/GleamDocExists.d.ts +24 -0
- package/esm/policies/GleamDocExists.d.ts.map +1 -0
- package/esm/policies/GleamDocExists.js +39 -0
- package/esm/policies/GleamDocExists.js.map +1 -0
- package/esm/policies/GleamInternalModulesConfigured.d.ts +21 -0
- package/esm/policies/GleamInternalModulesConfigured.d.ts.map +1 -0
- package/esm/policies/GleamInternalModulesConfigured.js +30 -0
- package/esm/policies/GleamInternalModulesConfigured.js.map +1 -0
- package/esm/policies/GleamLicenceConfigured.d.ts +29 -0
- package/esm/policies/GleamLicenceConfigured.d.ts.map +1 -0
- package/esm/policies/GleamLicenceConfigured.js +34 -0
- package/esm/policies/GleamLicenceConfigured.js.map +1 -0
- package/esm/policies/GleamManifestCommitted.d.ts +9 -0
- package/esm/policies/GleamManifestCommitted.d.ts.map +1 -0
- package/esm/policies/GleamManifestCommitted.js +26 -0
- package/esm/policies/GleamManifestCommitted.js.map +1 -0
- package/esm/policies/GleamMonorepoConsistency.d.ts +30 -0
- package/esm/policies/GleamMonorepoConsistency.d.ts.map +1 -0
- package/esm/policies/GleamMonorepoConsistency.js +74 -0
- package/esm/policies/GleamMonorepoConsistency.js.map +1 -0
- package/esm/policies/GleamNameRestrictions.d.ts +25 -0
- package/esm/policies/GleamNameRestrictions.d.ts.map +1 -0
- package/esm/policies/GleamNameRestrictions.js +44 -0
- package/esm/policies/GleamNameRestrictions.js.map +1 -0
- package/esm/policies/GleamNoPathDepsInPublished.d.ts +22 -0
- package/esm/policies/GleamNoPathDepsInPublished.d.ts.map +1 -0
- package/esm/policies/GleamNoPathDepsInPublished.js +43 -0
- package/esm/policies/GleamNoPathDepsInPublished.js.map +1 -0
- package/esm/policies/GleamPathDepsValid.d.ts +9 -0
- package/esm/policies/GleamPathDepsValid.d.ts.map +1 -0
- package/esm/policies/GleamPathDepsValid.js +59 -0
- package/esm/policies/GleamPathDepsValid.js.map +1 -0
- package/esm/policies/GleamProjectStructure.d.ts +25 -0
- package/esm/policies/GleamProjectStructure.d.ts.map +1 -0
- package/esm/policies/GleamProjectStructure.js +33 -0
- package/esm/policies/GleamProjectStructure.js.map +1 -0
- package/esm/policies/GleamSharedDependencyVersions.d.ts +29 -0
- package/esm/policies/GleamSharedDependencyVersions.d.ts.map +1 -0
- package/esm/policies/GleamSharedDependencyVersions.js +101 -0
- package/esm/policies/GleamSharedDependencyVersions.js.map +1 -0
- package/esm/policies/GleamTomlRequired.d.ts +30 -0
- package/esm/policies/GleamTomlRequired.d.ts.map +1 -0
- package/esm/policies/GleamTomlRequired.js +37 -0
- package/esm/policies/GleamTomlRequired.js.map +1 -0
- package/esm/policies/GleamTomlSorted.d.ts +20 -0
- package/esm/policies/GleamTomlSorted.d.ts.map +1 -0
- package/esm/policies/GleamTomlSorted.js +153 -0
- package/esm/policies/GleamTomlSorted.js.map +1 -0
- package/esm/policies/GleamVersionConstraint.d.ts +20 -0
- package/esm/policies/GleamVersionConstraint.d.ts.map +1 -0
- package/esm/policies/GleamVersionConstraint.js +64 -0
- package/esm/policies/GleamVersionConstraint.js.map +1 -0
- package/esm/policies/HtmlFileHeaders.d.ts +1 -1
- package/esm/policies/HtmlFileHeaders.d.ts.map +1 -1
- package/esm/policies/HtmlFileHeaders.js +1 -1
- package/esm/policies/HtmlFileHeaders.js.map +1 -1
- package/esm/policies/JsTsFileHeaders.d.ts +1 -1
- package/esm/policies/JsTsFileHeaders.d.ts.map +1 -1
- package/esm/policies/MutuallyExclusiveScripts.d.ts +46 -0
- package/esm/policies/MutuallyExclusiveScripts.d.ts.map +1 -0
- package/esm/policies/MutuallyExclusiveScripts.js +52 -0
- package/esm/policies/MutuallyExclusiveScripts.js.map +1 -0
- package/esm/policies/NoBuildDirectory.d.ts +9 -0
- package/esm/policies/NoBuildDirectory.d.ts.map +1 -0
- package/esm/policies/NoBuildDirectory.js +29 -0
- package/esm/policies/NoBuildDirectory.js.map +1 -0
- package/esm/policies/NoPrivateWorkspaceDependencies.d.ts +1 -1
- package/esm/policies/NoPrivateWorkspaceDependencies.d.ts.map +1 -1
- package/esm/policies/NoTargetArtifacts.d.ts +8 -0
- package/esm/policies/NoTargetArtifacts.d.ts.map +1 -0
- package/esm/policies/NoTargetArtifacts.js +42 -0
- package/esm/policies/NoTargetArtifacts.js.map +1 -0
- package/esm/policies/NoUnsafeWithoutJustification.d.ts +24 -0
- package/esm/policies/NoUnsafeWithoutJustification.d.ts.map +1 -0
- package/esm/policies/NoUnsafeWithoutJustification.js +80 -0
- package/esm/policies/NoUnsafeWithoutJustification.js.map +1 -0
- package/esm/policies/NoWildcardDependencies.d.ts +30 -0
- package/esm/policies/NoWildcardDependencies.d.ts.map +1 -0
- package/esm/policies/NoWildcardDependencies.js +83 -0
- package/esm/policies/NoWildcardDependencies.js.map +1 -0
- package/esm/policies/PackageAllowedScopes.d.ts +1 -1
- package/esm/policies/PackageAllowedScopes.d.ts.map +1 -1
- package/esm/policies/PackageEsmType.d.ts +1 -1
- package/esm/policies/PackageEsmType.d.ts.map +1 -1
- package/esm/policies/PackageEsmType.js +7 -5
- package/esm/policies/PackageEsmType.js.map +1 -1
- package/esm/policies/PackageFolderName.d.ts +1 -1
- package/esm/policies/PackageFolderName.d.ts.map +1 -1
- package/esm/policies/PackageJsonProperties.d.ts +1 -1
- package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
- package/esm/policies/PackageJsonProperties.js +12 -4
- package/esm/policies/PackageJsonProperties.js.map +1 -1
- package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts +1 -1
- package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
- package/esm/policies/PackageJsonRepoDirectoryProperty.js +3 -2
- package/esm/policies/PackageJsonRepoDirectoryProperty.js.map +1 -1
- package/esm/policies/PackageJsonSorted.d.ts +1 -1
- package/esm/policies/PackageJsonSorted.d.ts.map +1 -1
- package/esm/policies/PackageJsonSorted.js +42 -7
- package/esm/policies/PackageJsonSorted.js.map +1 -1
- package/esm/policies/PackageLicense.d.ts +1 -1
- package/esm/policies/PackageLicense.d.ts.map +1 -1
- package/esm/policies/PackageLicense.js +1 -2
- package/esm/policies/PackageLicense.js.map +1 -1
- package/esm/policies/PackagePrivateField.d.ts +1 -1
- package/esm/policies/PackagePrivateField.d.ts.map +1 -1
- package/esm/policies/PackagePrivateField.js +3 -2
- package/esm/policies/PackagePrivateField.js.map +1 -1
- package/esm/policies/PackageReadme.d.ts +1 -1
- package/esm/policies/PackageReadme.d.ts.map +1 -1
- package/esm/policies/PackageReadme.js +2 -2
- package/esm/policies/PackageReadme.js.map +1 -1
- package/esm/policies/PackageScripts.d.ts +1 -1
- package/esm/policies/PackageScripts.d.ts.map +1 -1
- package/esm/policies/PackageScripts.js +3 -2
- package/esm/policies/PackageScripts.js.map +1 -1
- package/esm/policies/PackageTestScripts.d.ts +1 -1
- package/esm/policies/PackageTestScripts.d.ts.map +1 -1
- package/esm/policies/PackageTestScripts.js +3 -3
- package/esm/policies/PackageTestScripts.js.map +1 -1
- package/esm/policies/PublicApiDocumented.d.ts +21 -0
- package/esm/policies/PublicApiDocumented.d.ts.map +1 -0
- package/esm/policies/PublicApiDocumented.js +36 -0
- package/esm/policies/PublicApiDocumented.js.map +1 -0
- package/esm/policies/RequiredScripts.d.ts +71 -0
- package/esm/policies/RequiredScripts.d.ts.map +1 -0
- package/esm/policies/RequiredScripts.js +121 -0
- package/esm/policies/RequiredScripts.js.map +1 -0
- package/esm/policies/RustDocExists.d.ts +24 -0
- package/esm/policies/RustDocExists.d.ts.map +1 -0
- package/esm/policies/RustDocExists.js +49 -0
- package/esm/policies/RustDocExists.js.map +1 -0
- package/esm/policies/RustToolchainExists.d.ts +20 -0
- package/esm/policies/RustToolchainExists.d.ts.map +1 -0
- package/esm/policies/RustToolchainExists.js +27 -0
- package/esm/policies/RustToolchainExists.js.map +1 -0
- package/esm/policies/RustfmtConfigExists.d.ts +20 -0
- package/esm/policies/RustfmtConfigExists.d.ts.map +1 -0
- package/esm/policies/RustfmtConfigExists.js +27 -0
- package/esm/policies/RustfmtConfigExists.js.map +1 -0
- package/esm/policies/ScriptContains.d.ts +64 -0
- package/esm/policies/ScriptContains.d.ts.map +1 -0
- package/esm/policies/ScriptContains.js +62 -0
- package/esm/policies/ScriptContains.js.map +1 -0
- package/esm/policies/SharedDependencyVersions.d.ts +24 -0
- package/esm/policies/SharedDependencyVersions.d.ts.map +1 -0
- package/esm/policies/SharedDependencyVersions.js +135 -0
- package/esm/policies/SharedDependencyVersions.js.map +1 -0
- package/esm/policies/WorkspaceInheritance.d.ts +24 -0
- package/esm/policies/WorkspaceInheritance.d.ts.map +1 -0
- package/esm/policies/WorkspaceInheritance.js +94 -0
- package/esm/policies/WorkspaceInheritance.js.map +1 -0
- package/esm/policies/WorkspaceMembersValid.d.ts +20 -0
- package/esm/policies/WorkspaceMembersValid.d.ts.map +1 -0
- package/esm/policies/WorkspaceMembersValid.js +88 -0
- package/esm/policies/WorkspaceMembersValid.js.map +1 -0
- package/esm/policies/constants.d.ts +8 -0
- package/esm/policies/constants.d.ts.map +1 -1
- package/esm/policies/constants.js +8 -0
- package/esm/policies/constants.js.map +1 -1
- package/esm/policies.d.ts +36 -1
- package/esm/policies.d.ts.map +1 -1
- package/esm/policies.js +68 -0
- package/esm/policies.js.map +1 -1
- package/esm/policy.d.ts +202 -84
- package/esm/policy.d.ts.map +1 -1
- package/esm/policy.js +103 -21
- package/esm/policy.js.map +1 -1
- package/esm/policyDefiners/defineCargoPolicy.d.ts +66 -0
- package/esm/policyDefiners/defineCargoPolicy.d.ts.map +1 -0
- package/esm/policyDefiners/defineCargoPolicy.js +60 -0
- package/esm/policyDefiners/defineCargoPolicy.js.map +1 -0
- package/esm/policyDefiners/defineFileHeaderPolicy.d.ts +7 -2
- package/esm/policyDefiners/defineFileHeaderPolicy.d.ts.map +1 -1
- package/esm/policyDefiners/defineFileHeaderPolicy.js +11 -7
- package/esm/policyDefiners/defineFileHeaderPolicy.js.map +1 -1
- package/esm/policyDefiners/defineGleamPolicy.d.ts +65 -0
- package/esm/policyDefiners/defineGleamPolicy.d.ts.map +1 -0
- package/esm/policyDefiners/defineGleamPolicy.js +59 -0
- package/esm/policyDefiners/defineGleamPolicy.js.map +1 -0
- package/esm/policyDefiners/definePackagePolicy.d.ts +18 -5
- package/esm/policyDefiners/definePackagePolicy.d.ts.map +1 -1
- package/esm/policyDefiners/definePackagePolicy.js +14 -4
- package/esm/policyDefiners/definePackagePolicy.js.map +1 -1
- package/esm/policyDefiners/spdxValidator.d.ts +74 -0
- package/esm/policyDefiners/spdxValidator.d.ts.map +1 -0
- package/esm/policyDefiners/spdxValidator.js +127 -0
- package/esm/policyDefiners/spdxValidator.js.map +1 -0
- package/esm/policyDefiners/tomlParser.d.ts +8 -0
- package/esm/policyDefiners/tomlParser.d.ts.map +1 -0
- package/esm/policyDefiners/tomlParser.js +17 -0
- package/esm/policyDefiners/tomlParser.js.map +1 -0
- package/esm/runner.d.ts +60 -0
- package/esm/runner.d.ts.map +1 -0
- package/esm/runner.js +174 -0
- package/esm/runner.js.map +1 -0
- package/esm/tsdoc-metadata.json +1 -1
- package/oclif.manifest.json +100 -3
- package/package.json +46 -31
- package/scripts/postinstall.mjs +154 -0
- package/sidecar/sidecar.mjs +468 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,86 @@
|
|
|
1
1
|
# repopo
|
|
2
2
|
|
|
3
|
+
## 0.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Distinguish duplicate configured policy instances in exclusions, diagnostics, results, and performance metrics. _[`#783`](https://github.com/tylerbutler/tools-monorepo/pull/783) [`da9f08b`](https://github.com/tylerbutler/tools-monorepo/commit/da9f08bbb90cad92f7419c474a43741eef5d3c2a) [@tylerbutler](https://github.com/tylerbutler)_
|
|
8
|
+
|
|
9
|
+
Duplicate instances must now set a unique `instanceId` in the `policy()` options.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Fix policy checks and automatic fixes: _[`#791`](https://github.com/tylerbutler/tools-monorepo/pull/791) [`9236dae`](https://github.com/tylerbutler/tools-monorepo/commit/9236dae487eef8d97c8c5974d3e58cf5338cac66) [@tylerbutler](https://github.com/tylerbutler)_
|
|
14
|
+
- Run same-file fixers in configuration order to prevent lost edits.
|
|
15
|
+
- Validate configured header text, avoid duplicate headers, and apply HTML headers to HTML files.
|
|
16
|
+
- Replace verbatim package.json arrays instead of appending entries.
|
|
17
|
+
- Check Cargo workspace members selected by globs and honor workspace exclusions.
|
|
18
|
+
- Preserve Git filenames that contain Unicode, tabs, or newlines in both engines.
|
|
19
|
+
- Preserve legacy fix results and apply default policies when a native configuration omits `policies`.
|
|
20
|
+
|
|
21
|
+
## 0.11.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Make policy and exclusion regular-expression matching deterministic for global and sticky flags. _[`#778`](https://github.com/tylerbutler/tools-monorepo/pull/778) [`b263d07`](https://github.com/tylerbutler/tools-monorepo/commit/b263d07c531baf032f5f8a75444971b91c55f2ab) [@tylerbutler](https://github.com/tylerbutler)_
|
|
26
|
+
- Isolate policy run results and performance statistics across sequential and concurrent `PolicyRunner` invocations. _[`#782`](https://github.com/tylerbutler/tools-monorepo/pull/782) [`bd06230`](https://github.com/tylerbutler/tools-monorepo/commit/bd06230247adf908155ce2a9e35ba0ed5aebac3c) [@tylerbutler](https://github.com/tylerbutler)_
|
|
27
|
+
- Load the optional `sort-package-json` peer dependency only when the package sorting policy runs, allowing Repopo to load without it while preserving sorting support when installed. _[`#780`](https://github.com/tylerbutler/tools-monorepo/pull/780) [`0972973`](https://github.com/tylerbutler/tools-monorepo/commit/0972973fa9df873d3dde101836adb9ff9196b8f8) [@tylerbutler](https://github.com/tylerbutler)_
|
|
28
|
+
- Resolve built-in policy filesystem operations from the repository root when policy file paths are repository-relative. _[`#784`](https://github.com/tylerbutler/tools-monorepo/pull/784) [`fe789fd`](https://github.com/tylerbutler/tools-monorepo/commit/fe789fd4cb33fcab19a63ad2f132b5d91c8a0c73) [@tylerbutler](https://github.com/tylerbutler)_
|
|
29
|
+
- Report unexpected policy execution errors for the affected file and continue checking remaining files. _[`#781`](https://github.com/tylerbutler/tools-monorepo/pull/781) [`32f5afe`](https://github.com/tylerbutler/tools-monorepo/commit/32f5afee62c6ba732650ca23f1669e0c2b2c73df) [@tylerbutler](https://github.com/tylerbutler)_
|
|
30
|
+
|
|
31
|
+
<details><summary>Updated 1 dependency</summary>
|
|
32
|
+
|
|
33
|
+
<small>
|
|
34
|
+
|
|
35
|
+
[`dd64d1d`](https://github.com/tylerbutler/tools-monorepo/commit/dd64d1da4f10d6793af9a270216b296edee884a6)
|
|
36
|
+
|
|
37
|
+
</small>
|
|
38
|
+
|
|
39
|
+
- `@tylerbu/cli-api@0.11.0`
|
|
40
|
+
|
|
41
|
+
</details>
|
|
42
|
+
|
|
43
|
+
## 0.11.0
|
|
44
|
+
|
|
45
|
+
### Minor Changes
|
|
46
|
+
|
|
47
|
+
- Add experimental `check-native` command powered by a Rust core engine for significantly faster policy checking (up to 1.5x faster than the standard `check` command). The Rust engine handles file enumeration, pattern matching, and orchestration while delegating policy evaluation to a Node.js sidecar, so all existing configs and third-party policies work without changes. _[`#623`](https://github.com/tylerbutler/tools-monorepo/pull/623) [`dd15dc9`](https://github.com/tylerbutler/tools-monorepo/commit/dd15dc98c5c2a69c2a6f022a2a0c985f2c26dcf4) [@tylerbutler](https://github.com/tylerbutler)_
|
|
48
|
+
|
|
49
|
+
Also adds a simplified `policy()` function for defining policies and new focused script policies (`RequiredScripts`, `ExactScripts`, `MutuallyExclusiveScripts`, `ConditionalScripts`, `ScriptContains`) that replace the monolithic `PackageScripts` policy with more granular, composable alternatives.
|
|
50
|
+
|
|
51
|
+
- Add `CargoLicenceValidated` policy that validates SPDX licence expressions in `Cargo.toml` files using the `spdx-correct` package. Includes a shared SPDX validator (`spdxValidator`) reused by both Cargo and Gleam licence policies. _[`#654`](https://github.com/tylerbutler/tools-monorepo/pull/654) [`9deb6dc`](https://github.com/tylerbutler/tools-monorepo/commit/9deb6dcce769bbb25fd067f9668cf6031f3d3bc7) [@tylerbutler](https://github.com/tylerbutler)_
|
|
52
|
+
- Extract `PolicyRunner` class from `CheckPolicy` command to fix SRP violation. The new class encapsulates all policy execution logic (file iteration, exclusion checking, policy matching, handler execution, resolution attempts) and returns structured `PolicyRunResults` instead of producing side effects. `PolicyRunner` has no OCLIF dependencies and can be used programmatically. The `CheckPolicy` command is now a thin CLI wrapper handling only flag parsing, file collection, and result formatting. _[`#672`](https://github.com/tylerbutler/tools-monorepo/pull/672) [`5f5bdf9`](https://github.com/tylerbutler/tools-monorepo/commit/5f5bdf90883177258ae6cd2284515f0465347d31) [@tylerbutler](https://github.com/tylerbutler)_
|
|
53
|
+
- Add 15 Gleam language policies for enforcing project conventions, structure, dependency management, documentation, and monorepo consistency. Includes `defineGleamPolicy` helper and shared TOML parser infrastructure. _[`#654`](https://github.com/tylerbutler/tools-monorepo/pull/654) [`9deb6dc`](https://github.com/tylerbutler/tools-monorepo/commit/9deb6dcce769bbb25fd067f9668cf6031f3d3bc7) [@tylerbutler](https://github.com/tylerbutler)_
|
|
54
|
+
- Add 14 new Rust/Cargo.toml policies for enforcing best practices in Rust projects: _[`#654`](https://github.com/tylerbutler/tools-monorepo/pull/654) [`9deb6dc`](https://github.com/tylerbutler/tools-monorepo/commit/9deb6dcce769bbb25fd067f9668cf6031f3d3bc7) [@tylerbutler](https://github.com/tylerbutler)_
|
|
55
|
+
- **Cargo.toml**: `CargoTomlRequired`, `CargoTomlSorted`, `CargoLintsConfigured`
|
|
56
|
+
- **Project structure**: `RustToolchainExists`, `RustfmtConfigExists`, `CargoLockPolicy`, `NoTargetArtifacts`
|
|
57
|
+
- **Security**: `NoWildcardDependencies`, `NoUnsafeWithoutJustification`
|
|
58
|
+
- **Documentation**: `PublicApiDocumented`, `RustDocExists`
|
|
59
|
+
- **Workspace**: `WorkspaceMembersValid`, `SharedDependencyVersions`, `WorkspaceInheritance`
|
|
60
|
+
|
|
61
|
+
Also adds `defineCargoPolicy` helper for creating Cargo.toml-targeted policies, and `smol-toml` as an optional peer dependency for TOML parsing.
|
|
62
|
+
|
|
63
|
+
## 0.10.0
|
|
64
|
+
|
|
65
|
+
### Minor Changes
|
|
66
|
+
|
|
67
|
+
- Add new `policy()` function as simplified API for defining repository policies, replacing the more complex `makePolicy`/`makePolicyDefinition` workflow. _[`#617`](https://github.com/tylerbutler/tools-monorepo/pull/617) [`becd406`](https://github.com/tylerbutler/tools-monorepo/commit/becd4064e1434b2384cda991f2d0702d91ed5ed9) [@tylerbutler](https://github.com/tylerbutler)_
|
|
68
|
+
|
|
69
|
+
New features:
|
|
70
|
+
- `policy()` function with multiple overload signatures for defining policies concisely
|
|
71
|
+
- `PolicyShape` interface for object-literal policy definitions
|
|
72
|
+
- `ConfiguredPolicy` and `PolicyError` types for the new API surface
|
|
73
|
+
- Five new script-focused policies: `RequiredScripts`, `ExactScripts`, `MutuallyExclusiveScripts`, `ConditionalScripts`, and `ScriptContains`
|
|
74
|
+
- `isPolicyError` type guard and `convertLegacyResult`/`convertToPolicyFailure` conversion utilities
|
|
75
|
+
|
|
76
|
+
Deprecations (old APIs still work but are marked `@deprecated`):
|
|
77
|
+
- `makePolicy` → use `policy()` instead
|
|
78
|
+
- `makePolicyDefinition` → use `PolicyShape` object literals instead
|
|
79
|
+
- `PolicyFailure` → use `PolicyError` instead
|
|
80
|
+
- `PolicyInstance` → use `ConfiguredPolicy` instead
|
|
81
|
+
- `PolicyStandaloneResolver` → use `PolicyResolver` instead
|
|
82
|
+
- `isPolicyFailure` → use `isPolicyError` instead
|
|
83
|
+
|
|
3
84
|
## 0.9.0
|
|
4
85
|
|
|
5
86
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -18,6 +18,12 @@ TypeScript configuration file is recommended.
|
|
|
18
18
|
|
|
19
19
|
The policy config must export a default object of the type `PolicyConfig`.
|
|
20
20
|
|
|
21
|
+
Omit `policies` to use the default policies with either `check` or `check-native`.
|
|
22
|
+
Set `policies: []` to disable them.
|
|
23
|
+
|
|
24
|
+
With `check --fix`, policies run in configuration order for each file so that one
|
|
25
|
+
fix does not overwrite another. Read-only checks can run policies concurrently.
|
|
26
|
+
|
|
21
27
|
## Excluding files from policy check
|
|
22
28
|
|
|
23
29
|
By default, all files in the repo are checked. You can exclude files completely from the policy check by configuring the
|
|
@@ -37,11 +43,13 @@ repopo includes the following policies. All of the included policies are enabled
|
|
|
37
43
|
|
|
38
44
|
## HtmlFileHeaders and JsTsFileHeaders
|
|
39
45
|
|
|
40
|
-
|
|
46
|
+
Use `HtmlFileHeaders` for `.html` and `.htm` files, and `JsTsFileHeaders` for
|
|
47
|
+
JavaScript and TypeScript files.
|
|
41
48
|
|
|
42
49
|
### Configuration
|
|
43
50
|
|
|
44
|
-
|
|
51
|
+
Pass `{ headerText: "Copyright Example" }` to `policy()` for either policy.
|
|
52
|
+
Checks compare the file header with that configured text; `--fix` adds a missing header.
|
|
45
53
|
|
|
46
54
|
## NoJsFileExtensions
|
|
47
55
|
|
|
@@ -57,6 +65,7 @@ The PackageJsonProperties policy is used to enforce fields in package.json files
|
|
|
57
65
|
### Configuration
|
|
58
66
|
|
|
59
67
|
The `verbatim` setting requires that all the configured fields in package.json match the values in the configuration.
|
|
68
|
+
Array values replace existing arrays rather than append to them. Unspecified object fields remain unchanged.
|
|
60
69
|
|
|
61
70
|
```ts
|
|
62
71
|
import type { PolicyConfig } from "@tylerbu/repopo";
|
|
@@ -97,6 +106,7 @@ Use `generatePackagePolicy` to generate policies for package.json files.
|
|
|
97
106
|
|
|
98
107
|
<!-- commands -->
|
|
99
108
|
* [`repopo check`](#repopo-check)
|
|
109
|
+
* [`repopo check-native`](#repopo-check-native)
|
|
100
110
|
* [`repopo list`](#repopo-list)
|
|
101
111
|
|
|
102
112
|
## `repopo check`
|
|
@@ -118,6 +128,35 @@ LOGGING FLAGS
|
|
|
118
128
|
|
|
119
129
|
_See code: [src/commands/check.ts](https://github.com/tylerbutler/tools-monorepo/blob/main/packages/repopo/src/commands/check.ts)_
|
|
120
130
|
|
|
131
|
+
## `repopo check-native`
|
|
132
|
+
|
|
133
|
+
Checks and applies policies using the Rust engine.
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
USAGE
|
|
137
|
+
$ repopo check-native [-f] [--stdin] [-v] [-q] [-c <value>] [--sidecar-path <value>] [--binary-path <value>]
|
|
138
|
+
[--runtime auto|node|bun]
|
|
139
|
+
|
|
140
|
+
FLAGS
|
|
141
|
+
-c, --config=<value> Path to the config file.
|
|
142
|
+
-f, --fix Fix errors if possible.
|
|
143
|
+
-q, --quiet Suppress all output except errors.
|
|
144
|
+
-v, --verbose Show verbose output including per-policy timing.
|
|
145
|
+
--binary-path=<value> [env: REPOPO_CORE_PATH] Path to the repopo-core Rust binary.
|
|
146
|
+
--runtime=<option> [env: REPOPO_RUNTIME] JS runtime for the sidecar process (auto, node, bun).
|
|
147
|
+
<options: auto|node|bun>
|
|
148
|
+
--sidecar-path=<value> [env: REPOPO_SIDECAR_PATH] Path to the Node.js sidecar script.
|
|
149
|
+
--stdin Read list of files from stdin.
|
|
150
|
+
|
|
151
|
+
DESCRIPTION
|
|
152
|
+
Checks and applies policies using the Rust engine.
|
|
153
|
+
|
|
154
|
+
Runs the Rust-based repopo-core engine with the Node.js sidecar. This provides the same policy checking as 'check' but
|
|
155
|
+
with Rust-based file enumeration, regex matching, and orchestration for better performance.
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
_See code: [src/commands/check-native.ts](https://github.com/tylerbutler/tools-monorepo/blob/main/packages/repopo/src/commands/check-native.ts)_
|
|
159
|
+
|
|
121
160
|
## `repopo list`
|
|
122
161
|
|
|
123
162
|
Lists the policies configured to run.
|
package/THIRD-PARTY-LICENSES.txt
CHANGED
|
@@ -3,7 +3,7 @@ https://www.npmjs.com/package/generate-license-file
|
|
|
3
3
|
|
|
4
4
|
The following npm package may be included in this product:
|
|
5
5
|
|
|
6
|
-
- jsonfile@6.2.
|
|
6
|
+
- jsonfile@6.2.1
|
|
7
7
|
|
|
8
8
|
This package contains the following license:
|
|
9
9
|
|
|
@@ -27,7 +27,7 @@ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHE
|
|
|
27
27
|
|
|
28
28
|
The following npm package may be included in this product:
|
|
29
29
|
|
|
30
|
-
- @rushstack/node-core-library@5.
|
|
30
|
+
- @rushstack/node-core-library@5.23.1
|
|
31
31
|
|
|
32
32
|
This package contains the following license:
|
|
33
33
|
|
|
@@ -60,7 +60,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
60
60
|
|
|
61
61
|
The following npm package may be included in this product:
|
|
62
62
|
|
|
63
|
-
- resolve-workspace-root@2.0.
|
|
63
|
+
- resolve-workspace-root@2.0.1
|
|
64
64
|
|
|
65
65
|
This package contains the following license:
|
|
66
66
|
|
|
@@ -90,7 +90,7 @@ Copyright (c) 2024-present Cedric van Putten <me@cedric.dev>
|
|
|
90
90
|
|
|
91
91
|
The following npm package may be included in this product:
|
|
92
92
|
|
|
93
|
-
- @fluid-tools/build-infrastructure@0.
|
|
93
|
+
- @fluid-tools/build-infrastructure@0.65.0
|
|
94
94
|
|
|
95
95
|
This package contains the following license:
|
|
96
96
|
|
|
@@ -144,8 +144,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
144
144
|
|
|
145
145
|
The following npm packages may be included in this product:
|
|
146
146
|
|
|
147
|
-
- effection@4.0.
|
|
148
|
-
- simple-git@3.
|
|
147
|
+
- effection@4.0.3
|
|
148
|
+
- simple-git@3.36.0
|
|
149
149
|
|
|
150
150
|
These packages each contain the following license:
|
|
151
151
|
|
|
@@ -155,8 +155,8 @@ MIT
|
|
|
155
155
|
|
|
156
156
|
The following npm packages may be included in this product:
|
|
157
157
|
|
|
158
|
-
- @oclif/core@4.
|
|
159
|
-
- @oclif/plugin-help@6.2.
|
|
158
|
+
- @oclif/core@4.11.14
|
|
159
|
+
- @oclif/plugin-help@6.2.53
|
|
160
160
|
|
|
161
161
|
These packages each contain the following license:
|
|
162
162
|
|
|
@@ -216,7 +216,37 @@ SOFTWARE.
|
|
|
216
216
|
|
|
217
217
|
The following npm package may be included in this product:
|
|
218
218
|
|
|
219
|
-
-
|
|
219
|
+
- lilconfig@3.1.3
|
|
220
|
+
|
|
221
|
+
This package contains the following license:
|
|
222
|
+
|
|
223
|
+
MIT License
|
|
224
|
+
|
|
225
|
+
Copyright (c) 2022 Anton Kastritskiy
|
|
226
|
+
|
|
227
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
228
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
229
|
+
in the Software without restriction, including without limitation the rights
|
|
230
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
231
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
232
|
+
furnished to do so, subject to the following conditions:
|
|
233
|
+
|
|
234
|
+
The above copyright notice and this permission notice shall be included in all
|
|
235
|
+
copies or substantial portions of the Software.
|
|
236
|
+
|
|
237
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
238
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
239
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
240
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
241
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
242
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
243
|
+
SOFTWARE.
|
|
244
|
+
|
|
245
|
+
-----------
|
|
246
|
+
|
|
247
|
+
The following npm package may be included in this product:
|
|
248
|
+
|
|
249
|
+
- tinyglobby@0.2.17
|
|
220
250
|
|
|
221
251
|
This package contains the following license:
|
|
222
252
|
|
|
@@ -246,7 +276,7 @@ SOFTWARE.
|
|
|
246
276
|
|
|
247
277
|
The following npm package may be included in this product:
|
|
248
278
|
|
|
249
|
-
- defu@6.1.
|
|
279
|
+
- defu@6.1.7
|
|
250
280
|
|
|
251
281
|
This package contains the following license:
|
|
252
282
|
|
|
@@ -411,7 +441,37 @@ DEALINGS IN THE SOFTWARE.
|
|
|
411
441
|
|
|
412
442
|
The following npm package may be included in this product:
|
|
413
443
|
|
|
414
|
-
-
|
|
444
|
+
- @tylerbu/lilconfig-loader-ts@0.1.3
|
|
445
|
+
|
|
446
|
+
This package contains the following license:
|
|
447
|
+
|
|
448
|
+
MIT License
|
|
449
|
+
|
|
450
|
+
Copyright (c) Tyler Butler <tyler@tylerbutler.com>
|
|
451
|
+
|
|
452
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
453
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
454
|
+
in the Software without restriction, including without limitation the rights
|
|
455
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
456
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
457
|
+
furnished to do so, subject to the following conditions:
|
|
458
|
+
|
|
459
|
+
The above copyright notice and this permission notice shall be included in all
|
|
460
|
+
copies or substantial portions of the Software.
|
|
461
|
+
|
|
462
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
463
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
464
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
465
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
466
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
467
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
468
|
+
SOFTWARE.
|
|
469
|
+
|
|
470
|
+
-----------
|
|
471
|
+
|
|
472
|
+
The following npm package may be included in this product:
|
|
473
|
+
|
|
474
|
+
- picomatch@4.0.5
|
|
415
475
|
|
|
416
476
|
This package contains the following license:
|
|
417
477
|
|
package/bin/dev.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
|
|
2
2
|
|
|
3
|
-
import { execute } from "@oclif/core";
|
|
3
|
+
import { execute, settings } from "@oclif/core";
|
|
4
|
+
|
|
5
|
+
if (process.argv[2]?.startsWith("snapshot:")) {
|
|
6
|
+
settings.enableAutoTranspile = false;
|
|
7
|
+
}
|
|
4
8
|
|
|
5
9
|
await execute({ development: true, dir: import.meta.url });
|
package/esm/baseCommand.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommandWithConfig, type CommandWithContext, type RequiresGit } from "@tylerbu/cli-api";
|
|
2
2
|
import { type SimpleGit } from "simple-git";
|
|
3
3
|
import { type RepopoConfig } from "./config.js";
|
|
4
|
-
import type
|
|
4
|
+
import { type RepopoCommandContext } from "./context.js";
|
|
5
5
|
/**
|
|
6
6
|
* This class is the base for all repopo commands. It contains common flags and config loading.
|
|
7
7
|
*/
|
package/esm/baseCommand.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseCommand.d.ts","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,YAAY,CAAC;AACvD,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"baseCommand.d.ts","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,YAAY,CAAC;AACvD,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAEN,KAAK,oBAAoB,EACzB,MAAM,cAAc,CAAC;AAKtB;;GAEG;AACH,8BAAsB,iBAAiB,CACrC,CAAC,SAAS,OAAO,iBAAiB,GAAG;IACpC,IAAI,EAAE,OAAO,iBAAiB,CAAC,IAAI,CAAC;IACpC,KAAK,EAAE,OAAO,iBAAiB,CAAC,KAAK,CAAC;CACtC,CAEF,SAAQ,iBAAiB,CAAC,CAAC,EAAE,YAAY,CACzC,YAAW,kBAAkB,CAAC,oBAAoB,CAAC,EAAE,WAAW;IAEhE,UAAmB,aAAa,eAAuB;IACvD,UAAmB,OAAO,oCAAyB;IAEnD,gBAAgC,KAAK;;MAE1B;IAEX,OAAO,CAAC,IAAI,CAAwB;IACpC,IAAW,GAAG,IAAI,SAAS,CAK1B;IAEqB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB3C,OAAO,CAAC,QAAQ,CAAmC;IAEtC,UAAU,IAAI,OAAO,CAAC,oBAAoB,CAAC;CAMxD"}
|
package/esm/baseCommand.js
CHANGED
|
@@ -3,7 +3,8 @@ import { createConsolaLogger } from "@tylerbu/cli-api/loggers/consola";
|
|
|
3
3
|
import { findGitRootSync } from "@tylerbu/fundamentals/git";
|
|
4
4
|
import { simpleGit } from "simple-git";
|
|
5
5
|
import { DefaultPolicyConfig } from "./config.js";
|
|
6
|
-
import {
|
|
6
|
+
import { createExcludedPolicyFileMap, } from "./context.js";
|
|
7
|
+
import { identifyPolicyInstances, makePolicy } from "./makePolicy.js";
|
|
7
8
|
import { newPerfStats } from "./perf.js";
|
|
8
9
|
import { DefaultPolicies } from "./policy.js";
|
|
9
10
|
/**
|
|
@@ -25,18 +26,14 @@ export class BaseRepopoCommand extends CommandWithConfig {
|
|
|
25
26
|
async init() {
|
|
26
27
|
await super.init();
|
|
27
28
|
const excludeFiles = this.commandConfig?.excludeFiles?.map((e) => new RegExp(e, "i")) ?? [];
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
const regexes = policy.excludeFiles?.map((e) => new RegExp(e, "i")) ?? [];
|
|
31
|
-
excludePoliciesForFiles.set(policy.name, regexes);
|
|
32
|
-
}
|
|
29
|
+
const policies = identifyPolicyInstances(this.commandConfig?.policies ??
|
|
30
|
+
DefaultPolicies.map((configuredPolicy) => makePolicy(configuredPolicy)));
|
|
33
31
|
const gitRoot = findGitRootSync();
|
|
34
32
|
this._git = simpleGit({ baseDir: gitRoot });
|
|
35
33
|
this._context = {
|
|
36
34
|
excludeFromAll: excludeFiles,
|
|
37
|
-
policies
|
|
38
|
-
|
|
39
|
-
excludePoliciesForFiles,
|
|
35
|
+
policies,
|
|
36
|
+
excludePoliciesForFiles: createExcludedPolicyFileMap(policies),
|
|
40
37
|
gitRoot,
|
|
41
38
|
perfStats: newPerfStats(),
|
|
42
39
|
};
|
package/esm/baseCommand.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseCommand.js","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,GAGjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAkB,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAqB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"baseCommand.js","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,GAGjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAkB,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAqB,MAAM,aAAa,CAAC;AACrE,OAAO,EACN,2BAA2B,GAE3B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBA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E,YAAY,EAAE;SACzB,CAAC;IACH,CAAC;IAEO,QAAQ,CAAmC;IAE5C,KAAK,CAAC,UAAU;QACtB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC","sourcesContent":["import {\n\tCommandWithConfig,\n\ttype CommandWithContext,\n\ttype RequiresGit,\n} from \"@tylerbu/cli-api\";\nimport { createConsolaLogger } from \"@tylerbu/cli-api/loggers/consola\";\nimport { findGitRootSync } from \"@tylerbu/fundamentals/git\";\nimport { type SimpleGit, simpleGit } from \"simple-git\";\nimport { DefaultPolicyConfig, type RepopoConfig } from \"./config.js\";\nimport {\n\tcreateExcludedPolicyFileMap,\n\ttype RepopoCommandContext,\n} from \"./context.js\";\nimport { identifyPolicyInstances, makePolicy } from \"./makePolicy.js\";\nimport { newPerfStats } from \"./perf.js\";\nimport { DefaultPolicies } from \"./policy.js\";\n\n/**\n * This class is the base for all repopo commands. It contains common flags and config loading.\n */\nexport abstract class BaseRepopoCommand<\n\t\tT extends typeof BaseRepopoCommand & {\n\t\t\targs: typeof CommandWithConfig.args;\n\t\t\tflags: typeof CommandWithConfig.flags;\n\t\t},\n\t>\n\textends CommandWithConfig<T, RepopoConfig>\n\timplements CommandWithContext<RepopoCommandContext>, RequiresGit\n{\n\tprotected override defaultConfig = DefaultPolicyConfig;\n\tprotected override _logger = createConsolaLogger();\n\n\tpublic static override readonly flags = {\n\t\t...CommandWithConfig.flags,\n\t} as const;\n\n\tprivate _git: SimpleGit | undefined;\n\tpublic get git(): SimpleGit {\n\t\tif (this._git === undefined) {\n\t\t\tthrow new Error(\"git property is undefined\");\n\t\t}\n\t\treturn this._git;\n\t}\n\n\tpublic override async init(): Promise<void> {\n\t\tawait super.init();\n\n\t\tconst excludeFiles: RegExp[] =\n\t\t\tthis.commandConfig?.excludeFiles?.map((e) => new RegExp(e, \"i\")) ?? [];\n\n\t\tconst policies = identifyPolicyInstances(\n\t\t\tthis.commandConfig?.policies ??\n\t\t\t\tDefaultPolicies.map((configuredPolicy) => makePolicy(configuredPolicy)),\n\t\t);\n\t\tconst gitRoot = findGitRootSync();\n\t\tthis._git = simpleGit({ baseDir: gitRoot });\n\t\tthis._context = {\n\t\t\texcludeFromAll: excludeFiles,\n\t\t\tpolicies,\n\t\t\texcludePoliciesForFiles: createExcludedPolicyFileMap(policies),\n\t\t\tgitRoot,\n\t\t\tperfStats: newPerfStats(),\n\t\t};\n\t}\n\n\tprivate _context: RepopoCommandContext | undefined;\n\n\tpublic async getContext(): Promise<RepopoCommandContext> {\n\t\tif (this._context === undefined) {\n\t\t\tthrow new Error(\"Context not initialized.\");\n\t\t}\n\t\treturn this._context;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
/**
|
|
3
|
+
* Runs the Rust-based repopo-core engine with the Node.js sidecar for
|
|
4
|
+
* policy handler execution. This command provides the same functionality
|
|
5
|
+
* as `check` but uses the Rust engine for file enumeration, regex matching,
|
|
6
|
+
* and orchestration.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CheckNative extends Command {
|
|
9
|
+
static readonly summary = "Checks and applies policies using the Rust engine.";
|
|
10
|
+
static readonly description: string;
|
|
11
|
+
static readonly flags: {
|
|
12
|
+
readonly fix: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
readonly stdin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
readonly verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
readonly quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
readonly config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
readonly "sidecar-path": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
readonly "binary-path": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
readonly runtime: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
};
|
|
21
|
+
run(): Promise<void>;
|
|
22
|
+
private resolveBinaryPath;
|
|
23
|
+
private resolveSidecarPath;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=check-native.d.ts.map
|
|
@@ -0,0 +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;AAK7C;;;;;GAKG;AACH,qBAAa,WAAY,SAAQ,OAAO;IACvC,gBAAgC,OAAO,wDACe;IAEtD,gBAAgC,WAAW,SAGoC;IAE/E,gBAAgC,KAAK;;;;;;;;;MA0C1B;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAqD1C,OAAO,CAAC,iBAAiB;IAiDzB,OAAO,CAAC,kBAAkB;CAQ1B"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { Command, Flags } from "@oclif/core";
|
|
5
|
+
import { dirname, resolve } from "pathe";
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
/**
|
|
8
|
+
* Runs the Rust-based repopo-core engine with the Node.js sidecar for
|
|
9
|
+
* policy handler execution. This command provides the same functionality
|
|
10
|
+
* as `check` but uses the Rust engine for file enumeration, regex matching,
|
|
11
|
+
* and orchestration.
|
|
12
|
+
*/
|
|
13
|
+
export class CheckNative extends Command {
|
|
14
|
+
static summary = "Checks and applies policies using the Rust engine.";
|
|
15
|
+
static description = "Runs the Rust-based repopo-core engine with the Node.js sidecar. " +
|
|
16
|
+
"This provides the same policy checking as 'check' but with Rust-based " +
|
|
17
|
+
"file enumeration, regex matching, and orchestration for better performance.";
|
|
18
|
+
static flags = {
|
|
19
|
+
fix: Flags.boolean({
|
|
20
|
+
aliases: ["resolve"],
|
|
21
|
+
description: "Fix errors if possible.",
|
|
22
|
+
required: false,
|
|
23
|
+
char: "f",
|
|
24
|
+
}),
|
|
25
|
+
stdin: Flags.boolean({
|
|
26
|
+
description: "Read list of files from stdin.",
|
|
27
|
+
required: false,
|
|
28
|
+
}),
|
|
29
|
+
verbose: Flags.boolean({
|
|
30
|
+
description: "Show verbose output including per-policy timing.",
|
|
31
|
+
required: false,
|
|
32
|
+
char: "v",
|
|
33
|
+
}),
|
|
34
|
+
quiet: Flags.boolean({
|
|
35
|
+
description: "Suppress all output except errors.",
|
|
36
|
+
required: false,
|
|
37
|
+
char: "q",
|
|
38
|
+
}),
|
|
39
|
+
config: Flags.string({
|
|
40
|
+
description: "Path to the config file.",
|
|
41
|
+
required: false,
|
|
42
|
+
char: "c",
|
|
43
|
+
}),
|
|
44
|
+
"sidecar-path": Flags.string({
|
|
45
|
+
description: "Path to the Node.js sidecar script.",
|
|
46
|
+
required: false,
|
|
47
|
+
env: "REPOPO_SIDECAR_PATH",
|
|
48
|
+
}),
|
|
49
|
+
"binary-path": Flags.string({
|
|
50
|
+
description: "Path to the repopo-core Rust binary.",
|
|
51
|
+
required: false,
|
|
52
|
+
env: "REPOPO_CORE_PATH",
|
|
53
|
+
}),
|
|
54
|
+
runtime: Flags.string({
|
|
55
|
+
description: "JS runtime for the sidecar process (auto, node, bun).",
|
|
56
|
+
required: false,
|
|
57
|
+
env: "REPOPO_RUNTIME",
|
|
58
|
+
options: ["auto", "node", "bun"],
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
61
|
+
async run() {
|
|
62
|
+
const { flags } = await this.parse(CheckNative);
|
|
63
|
+
const binaryPath = this.resolveBinaryPath(flags["binary-path"]);
|
|
64
|
+
const sidecarPath = this.resolveSidecarPath(flags["sidecar-path"]);
|
|
65
|
+
const args = ["check", "--sidecar-path", sidecarPath];
|
|
66
|
+
if (flags.fix) {
|
|
67
|
+
args.push("--fix");
|
|
68
|
+
}
|
|
69
|
+
if (flags.stdin) {
|
|
70
|
+
args.push("--stdin");
|
|
71
|
+
}
|
|
72
|
+
if (flags.verbose) {
|
|
73
|
+
args.push("--verbose");
|
|
74
|
+
}
|
|
75
|
+
if (flags.quiet) {
|
|
76
|
+
args.push("--quiet");
|
|
77
|
+
}
|
|
78
|
+
if (flags.config) {
|
|
79
|
+
args.push("--config", flags.config);
|
|
80
|
+
}
|
|
81
|
+
if (flags.runtime) {
|
|
82
|
+
args.push("--runtime", flags.runtime);
|
|
83
|
+
}
|
|
84
|
+
return new Promise((resolvePromise, reject) => {
|
|
85
|
+
const child = spawn(binaryPath, args, {
|
|
86
|
+
stdio: "inherit",
|
|
87
|
+
// biome-ignore lint/style/noProcessEnv: Need to pass parent environment to child process
|
|
88
|
+
env: { ...process.env },
|
|
89
|
+
});
|
|
90
|
+
child.on("error", (err) => {
|
|
91
|
+
reject(new Error(`Failed to spawn repopo-core: ${err.message}\n` +
|
|
92
|
+
`Binary path: ${binaryPath}\n` +
|
|
93
|
+
"Make sure the Rust binary has been built: cargo build --manifest-path crates/core/Cargo.toml"));
|
|
94
|
+
});
|
|
95
|
+
child.on("close", (code) => {
|
|
96
|
+
if (code !== 0) {
|
|
97
|
+
process.exitCode = code ?? 1;
|
|
98
|
+
}
|
|
99
|
+
resolvePromise();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
resolveBinaryPath(explicit) {
|
|
104
|
+
if (explicit) {
|
|
105
|
+
return explicit;
|
|
106
|
+
}
|
|
107
|
+
const packageRoot = resolve(__dirname, "..", "..");
|
|
108
|
+
const binaryName = process.platform === "win32" ? "repopo-core.exe" : "repopo-core";
|
|
109
|
+
// Check paths in priority order:
|
|
110
|
+
// 1. Postinstall-downloaded binary (npm install)
|
|
111
|
+
const nativePath = resolve(packageRoot, "native", binaryName);
|
|
112
|
+
if (existsSync(nativePath)) {
|
|
113
|
+
return nativePath;
|
|
114
|
+
}
|
|
115
|
+
// 2. Local release build (cargo build --release)
|
|
116
|
+
const releasePath = resolve(packageRoot, "crates", "core", "target", "release", binaryName);
|
|
117
|
+
if (existsSync(releasePath)) {
|
|
118
|
+
return releasePath;
|
|
119
|
+
}
|
|
120
|
+
// 3. Local debug build (cargo build)
|
|
121
|
+
const debugPath = resolve(packageRoot, "crates", "core", "target", "debug", binaryName);
|
|
122
|
+
if (existsSync(debugPath)) {
|
|
123
|
+
return debugPath;
|
|
124
|
+
}
|
|
125
|
+
throw new Error("repopo-core binary not found. Either:\n" +
|
|
126
|
+
" - Install the package (npm install repopo) to download pre-built binaries\n" +
|
|
127
|
+
" - Build from source: cargo build --manifest-path crates/core/Cargo.toml");
|
|
128
|
+
}
|
|
129
|
+
resolveSidecarPath(explicit) {
|
|
130
|
+
if (explicit) {
|
|
131
|
+
return explicit;
|
|
132
|
+
}
|
|
133
|
+
const packageRoot = resolve(__dirname, "..", "..");
|
|
134
|
+
return resolve(packageRoot, "sidecar", "sidecar.mjs");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=check-native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AAEzC,MAAM,SAAS,GAAG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,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\";\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 * policy handler execution. This command provides the same functionality\n * as `check` but uses the Rust engine for file enumeration, regex matching,\n * and orchestration.\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\"This provides the same policy checking as 'check' but with Rust-based \" +\n\t\t\"file enumeration, regex matching, and orchestration for better performance.\";\n\n\tpublic static override readonly flags = {\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\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\n\t\t\tchild.on(\"error\", (err) => {\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) => {\n\t\t\t\tif (code !== 0) {\n\t\t\t\t\tprocess.exitCode = code ?? 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
|
@@ -20,28 +20,17 @@ export declare class CheckPolicy<T extends typeof BaseRepopoCommand & {
|
|
|
20
20
|
};
|
|
21
21
|
run(): Promise<void>;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @param pathsToCheck - All paths that should be checked. Paths should be relative to the repository root.
|
|
26
|
-
* @param context - The context.
|
|
23
|
+
* Collects file paths to check from either stdin or git ls-files.
|
|
27
24
|
*/
|
|
28
|
-
private
|
|
25
|
+
private collectFilePaths;
|
|
29
26
|
/**
|
|
30
|
-
*
|
|
31
|
-
* routes the file to the appropriate handlers.
|
|
32
|
-
*
|
|
33
|
-
* @param relPath - A git repo-relative path to a file.
|
|
27
|
+
* Formats a single policy file result, logging messages and setting exit codes.
|
|
34
28
|
*/
|
|
35
|
-
private
|
|
36
|
-
private
|
|
37
|
-
private
|
|
38
|
-
private
|
|
39
|
-
private
|
|
40
|
-
private handlePolicyResult;
|
|
41
|
-
private handleFixResult;
|
|
42
|
-
private handleFailureResult;
|
|
43
|
-
private attemptResolution;
|
|
44
|
-
private logPolicyFailure;
|
|
29
|
+
private formatResult;
|
|
30
|
+
private formatFixResult;
|
|
31
|
+
private formatPolicyErrorFixResult;
|
|
32
|
+
private formatResolutionResult;
|
|
33
|
+
private formatPolicyFailure;
|
|
45
34
|
private logMessages;
|
|
46
35
|
}
|
|
47
36
|
//# sourceMappingURL=check.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AA+BtD;;;;;;;;GAQG;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,iEACwB;IAE/D,gBAAgC,KAAK;;;;MAY1B;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAiC1C;;OAEG;YACW,gBAAgB;IAmC9B;;OAEG;IACH,OAAO,CAAC,YAAY;IA6BpB,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,0BAA0B;IAsBlC,OAAO,CAAC,sBAAsB;IAqB9B,OAAO,CAAC,mBAAmB;IAgC3B,OAAO,CAAC,WAAW;CAOnB"}
|