repopo 0.12.0 → 0.13.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 +53 -0
- package/README.md +50 -90
- package/THIRD-PARTY-LICENSES.txt +169 -11
- package/bin/dev.js +0 -0
- package/esm/adapters/fluidFramework.d.ts +13 -9
- package/esm/adapters/fluidFramework.d.ts.map +1 -1
- package/esm/adapters/fluidFramework.js +20 -43
- package/esm/adapters/fluidFramework.js.map +1 -1
- package/esm/api.d.ts +64 -1
- package/esm/api.d.ts.map +1 -1
- package/esm/api.js +17 -1
- package/esm/api.js.map +1 -1
- package/esm/baseCommand.d.ts.map +1 -1
- package/esm/baseCommand.js +2 -2
- package/esm/baseCommand.js.map +1 -1
- package/esm/commands/check-native.d.ts +3 -3
- package/esm/commands/check-native.d.ts.map +1 -1
- package/esm/commands/check-native.js +26 -7
- package/esm/commands/check-native.js.map +1 -1
- package/esm/commands/check.d.ts +6 -21
- package/esm/commands/check.d.ts.map +1 -1
- package/esm/commands/check.js +73 -153
- package/esm/commands/check.js.map +1 -1
- package/esm/commands/list.d.ts.map +1 -1
- package/esm/commands/list.js +2 -1
- package/esm/commands/list.js.map +1 -1
- package/esm/concurrency.d.ts +3 -0
- package/esm/concurrency.d.ts.map +1 -0
- package/esm/concurrency.js +8 -0
- package/esm/concurrency.js.map +1 -0
- package/esm/config.d.ts +5 -39
- package/esm/config.d.ts.map +1 -1
- package/esm/config.js +3 -7
- package/esm/config.js.map +1 -1
- package/esm/context.d.ts +8 -1
- package/esm/context.d.ts.map +1 -1
- package/esm/context.js +8 -1
- package/esm/context.js.map +1 -1
- package/esm/executionContractError.d.ts +4 -0
- package/esm/executionContractError.d.ts.map +1 -0
- package/esm/executionContractError.js +4 -0
- package/esm/executionContractError.js.map +1 -0
- package/esm/fileCache.d.ts +12 -0
- package/esm/fileCache.d.ts.map +1 -0
- package/esm/fileCache.js +37 -0
- package/esm/fileCache.js.map +1 -0
- package/esm/filePaths.d.ts +2 -0
- package/esm/filePaths.d.ts.map +1 -0
- package/esm/filePaths.js +9 -0
- package/esm/filePaths.js.map +1 -0
- package/esm/generators.d.ts +0 -20
- package/esm/generators.d.ts.map +1 -1
- package/esm/generators.js.map +1 -1
- package/esm/index.d.ts +3 -16
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +3 -17
- package/esm/index.js.map +1 -1
- package/esm/makePolicy.d.ts +20 -100
- package/esm/makePolicy.d.ts.map +1 -1
- package/esm/makePolicy.js +44 -132
- package/esm/makePolicy.js.map +1 -1
- package/esm/perf.d.ts +5 -2
- package/esm/perf.d.ts.map +1 -1
- package/esm/perf.js +10 -9
- package/esm/perf.js.map +1 -1
- package/esm/policies/CargoLicenceValidated.d.ts +4 -4
- package/esm/policies/CargoLicenceValidated.d.ts.map +1 -1
- package/esm/policies/CargoLicenceValidated.js +9 -7
- package/esm/policies/CargoLicenceValidated.js.map +1 -1
- package/esm/policies/CargoLintsConfigured.d.ts +4 -4
- package/esm/policies/CargoLintsConfigured.d.ts.map +1 -1
- package/esm/policies/CargoLintsConfigured.js +19 -15
- package/esm/policies/CargoLintsConfigured.js.map +1 -1
- package/esm/policies/CargoLockPolicy.d.ts +4 -4
- package/esm/policies/CargoLockPolicy.d.ts.map +1 -1
- package/esm/policies/CargoLockPolicy.js +15 -11
- package/esm/policies/CargoLockPolicy.js.map +1 -1
- package/esm/policies/CargoTomlRequired.d.ts +5 -5
- package/esm/policies/CargoTomlRequired.d.ts.map +1 -1
- package/esm/policies/CargoTomlRequired.js +7 -7
- package/esm/policies/CargoTomlRequired.js.map +1 -1
- package/esm/policies/CargoTomlSorted.d.ts +4 -4
- package/esm/policies/CargoTomlSorted.d.ts.map +1 -1
- package/esm/policies/CargoTomlSorted.js +21 -17
- package/esm/policies/CargoTomlSorted.js.map +1 -1
- package/esm/policies/ConditionalScripts.d.ts +10 -8
- package/esm/policies/ConditionalScripts.d.ts.map +1 -1
- package/esm/policies/ConditionalScripts.js +24 -22
- package/esm/policies/ConditionalScripts.js.map +1 -1
- package/esm/policies/ExactScripts.d.ts +8 -6
- package/esm/policies/ExactScripts.d.ts.map +1 -1
- package/esm/policies/ExactScripts.js +15 -18
- package/esm/policies/ExactScripts.js.map +1 -1
- package/esm/policies/GleamDepVersions.d.ts +5 -5
- package/esm/policies/GleamDepVersions.d.ts.map +1 -1
- package/esm/policies/GleamDepVersions.js +5 -5
- package/esm/policies/GleamDepVersions.js.map +1 -1
- package/esm/policies/GleamDocExists.d.ts +4 -4
- package/esm/policies/GleamDocExists.d.ts.map +1 -1
- package/esm/policies/GleamDocExists.js +6 -6
- package/esm/policies/GleamDocExists.js.map +1 -1
- package/esm/policies/GleamInternalModulesConfigured.d.ts +4 -4
- package/esm/policies/GleamInternalModulesConfigured.d.ts.map +1 -1
- package/esm/policies/GleamInternalModulesConfigured.js +8 -6
- package/esm/policies/GleamInternalModulesConfigured.js.map +1 -1
- package/esm/policies/GleamLicenceConfigured.d.ts +4 -4
- package/esm/policies/GleamLicenceConfigured.d.ts.map +1 -1
- package/esm/policies/GleamLicenceConfigured.js +8 -6
- package/esm/policies/GleamLicenceConfigured.js.map +1 -1
- package/esm/policies/GleamManifestCommitted.d.ts +10 -3
- package/esm/policies/GleamManifestCommitted.d.ts.map +1 -1
- package/esm/policies/GleamManifestCommitted.js +10 -9
- package/esm/policies/GleamManifestCommitted.js.map +1 -1
- package/esm/policies/GleamMonorepoConsistency.d.ts +13 -5
- package/esm/policies/GleamMonorepoConsistency.d.ts.map +1 -1
- package/esm/policies/GleamMonorepoConsistency.js +10 -10
- package/esm/policies/GleamMonorepoConsistency.js.map +1 -1
- package/esm/policies/GleamNameRestrictions.d.ts +4 -4
- package/esm/policies/GleamNameRestrictions.d.ts.map +1 -1
- package/esm/policies/GleamNameRestrictions.js +6 -6
- package/esm/policies/GleamNameRestrictions.js.map +1 -1
- package/esm/policies/GleamNoPathDepsInPublished.d.ts +4 -4
- package/esm/policies/GleamNoPathDepsInPublished.d.ts.map +1 -1
- package/esm/policies/GleamNoPathDepsInPublished.js +6 -6
- package/esm/policies/GleamNoPathDepsInPublished.js.map +1 -1
- package/esm/policies/GleamPathDepsValid.d.ts +3 -3
- package/esm/policies/GleamPathDepsValid.d.ts.map +1 -1
- package/esm/policies/GleamPathDepsValid.js +5 -5
- package/esm/policies/GleamPathDepsValid.js.map +1 -1
- package/esm/policies/GleamProjectStructure.d.ts +11 -4
- package/esm/policies/GleamProjectStructure.d.ts.map +1 -1
- package/esm/policies/GleamProjectStructure.js +7 -8
- package/esm/policies/GleamProjectStructure.js.map +1 -1
- package/esm/policies/GleamSharedDependencyVersions.d.ts +12 -4
- package/esm/policies/GleamSharedDependencyVersions.d.ts.map +1 -1
- package/esm/policies/GleamSharedDependencyVersions.js +10 -10
- package/esm/policies/GleamSharedDependencyVersions.js.map +1 -1
- package/esm/policies/GleamTomlRequired.d.ts +4 -4
- package/esm/policies/GleamTomlRequired.d.ts.map +1 -1
- package/esm/policies/GleamTomlRequired.js +5 -5
- package/esm/policies/GleamTomlRequired.js.map +1 -1
- package/esm/policies/GleamTomlSorted.d.ts +4 -4
- package/esm/policies/GleamTomlSorted.d.ts.map +1 -1
- package/esm/policies/GleamTomlSorted.js +21 -17
- package/esm/policies/GleamTomlSorted.js.map +1 -1
- package/esm/policies/GleamVersionConstraint.d.ts +4 -4
- package/esm/policies/GleamVersionConstraint.d.ts.map +1 -1
- package/esm/policies/GleamVersionConstraint.js +14 -10
- package/esm/policies/GleamVersionConstraint.js.map +1 -1
- package/esm/policies/HtmlFileHeaders.d.ts +4 -2
- 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 +4 -2
- package/esm/policies/JsTsFileHeaders.d.ts.map +1 -1
- package/esm/policies/JsTsFileHeaders.js +1 -1
- package/esm/policies/JsTsFileHeaders.js.map +1 -1
- package/esm/policies/LicenseFileExists.d.ts +10 -4
- package/esm/policies/LicenseFileExists.d.ts.map +1 -1
- package/esm/policies/LicenseFileExists.js +27 -20
- package/esm/policies/LicenseFileExists.js.map +1 -1
- package/esm/policies/MutuallyExclusiveScripts.d.ts +8 -6
- package/esm/policies/MutuallyExclusiveScripts.d.ts.map +1 -1
- package/esm/policies/MutuallyExclusiveScripts.js +9 -13
- package/esm/policies/MutuallyExclusiveScripts.js.map +1 -1
- package/esm/policies/NoBuildDirectory.d.ts +9 -3
- package/esm/policies/NoBuildDirectory.d.ts.map +1 -1
- package/esm/policies/NoBuildDirectory.js +8 -13
- package/esm/policies/NoBuildDirectory.js.map +1 -1
- package/esm/policies/NoJsFileExtensions.d.ts +9 -3
- package/esm/policies/NoJsFileExtensions.d.ts.map +1 -1
- package/esm/policies/NoJsFileExtensions.js +9 -14
- package/esm/policies/NoJsFileExtensions.js.map +1 -1
- package/esm/policies/NoLargeBinaryFiles.d.ts +9 -4
- package/esm/policies/NoLargeBinaryFiles.d.ts.map +1 -1
- package/esm/policies/NoLargeBinaryFiles.js +10 -16
- package/esm/policies/NoLargeBinaryFiles.js.map +1 -1
- package/esm/policies/NoPrivateWorkspaceDependencies.d.ts +10 -6
- package/esm/policies/NoPrivateWorkspaceDependencies.d.ts.map +1 -1
- package/esm/policies/NoPrivateWorkspaceDependencies.js +12 -14
- package/esm/policies/NoPrivateWorkspaceDependencies.js.map +1 -1
- package/esm/policies/NoTargetArtifacts.d.ts +9 -3
- package/esm/policies/NoTargetArtifacts.d.ts.map +1 -1
- package/esm/policies/NoTargetArtifacts.js +9 -14
- package/esm/policies/NoTargetArtifacts.js.map +1 -1
- package/esm/policies/NoUnsafeWithoutJustification.d.ts +11 -4
- package/esm/policies/NoUnsafeWithoutJustification.d.ts.map +1 -1
- package/esm/policies/NoUnsafeWithoutJustification.js +8 -9
- package/esm/policies/NoUnsafeWithoutJustification.js.map +1 -1
- package/esm/policies/NoWildcardDependencies.d.ts +5 -5
- package/esm/policies/NoWildcardDependencies.d.ts.map +1 -1
- package/esm/policies/NoWildcardDependencies.js +6 -6
- package/esm/policies/NoWildcardDependencies.js.map +1 -1
- package/esm/policies/PackageAllowedScopes.d.ts +9 -5
- package/esm/policies/PackageAllowedScopes.d.ts.map +1 -1
- package/esm/policies/PackageAllowedScopes.js +15 -16
- package/esm/policies/PackageAllowedScopes.js.map +1 -1
- package/esm/policies/PackageEsmType.d.ts +7 -5
- package/esm/policies/PackageEsmType.d.ts.map +1 -1
- package/esm/policies/PackageEsmType.js +31 -31
- package/esm/policies/PackageEsmType.js.map +1 -1
- package/esm/policies/PackageFolderName.d.ts +8 -6
- package/esm/policies/PackageFolderName.d.ts.map +1 -1
- package/esm/policies/PackageFolderName.js +13 -16
- package/esm/policies/PackageFolderName.js.map +1 -1
- package/esm/policies/PackageJsonProperties.d.ts +5 -3
- package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
- package/esm/policies/PackageJsonProperties.js +6 -17
- package/esm/policies/PackageJsonProperties.js.map +1 -1
- package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts +2 -7
- package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
- package/esm/policies/PackageJsonRepoDirectoryProperty.js +28 -42
- package/esm/policies/PackageJsonRepoDirectoryProperty.js.map +1 -1
- package/esm/policies/PackageJsonSorted.d.ts +2 -2
- package/esm/policies/PackageJsonSorted.d.ts.map +1 -1
- package/esm/policies/PackageJsonSorted.js +15 -30
- package/esm/policies/PackageJsonSorted.js.map +1 -1
- package/esm/policies/PackageLicense.d.ts +4 -4
- package/esm/policies/PackageLicense.d.ts.map +1 -1
- package/esm/policies/PackageLicense.js +31 -52
- package/esm/policies/PackageLicense.js.map +1 -1
- package/esm/policies/PackagePrivateField.d.ts +12 -8
- package/esm/policies/PackagePrivateField.d.ts.map +1 -1
- package/esm/policies/PackagePrivateField.js +31 -23
- package/esm/policies/PackagePrivateField.js.map +1 -1
- package/esm/policies/PackageReadme.d.ts +6 -5
- package/esm/policies/PackageReadme.d.ts.map +1 -1
- package/esm/policies/PackageReadme.js +22 -59
- package/esm/policies/PackageReadme.js.map +1 -1
- package/esm/policies/PackageScripts.d.ts +26 -22
- package/esm/policies/PackageScripts.d.ts.map +1 -1
- package/esm/policies/PackageScripts.js +39 -36
- package/esm/policies/PackageScripts.js.map +1 -1
- package/esm/policies/PackageTestScripts.d.ts +10 -6
- package/esm/policies/PackageTestScripts.d.ts.map +1 -1
- package/esm/policies/PackageTestScripts.js +14 -16
- package/esm/policies/PackageTestScripts.js.map +1 -1
- package/esm/policies/PublicApiDocumented.d.ts +4 -4
- package/esm/policies/PublicApiDocumented.d.ts.map +1 -1
- package/esm/policies/PublicApiDocumented.js +10 -8
- package/esm/policies/PublicApiDocumented.js.map +1 -1
- package/esm/policies/RequiredGitignorePatterns.d.ts +11 -4
- package/esm/policies/RequiredGitignorePatterns.d.ts.map +1 -1
- package/esm/policies/RequiredGitignorePatterns.js +29 -36
- package/esm/policies/RequiredGitignorePatterns.js.map +1 -1
- package/esm/policies/RequiredScripts.d.ts +9 -7
- package/esm/policies/RequiredScripts.d.ts.map +1 -1
- package/esm/policies/RequiredScripts.js +24 -24
- package/esm/policies/RequiredScripts.js.map +1 -1
- package/esm/policies/RustDocExists.d.ts +4 -4
- package/esm/policies/RustDocExists.d.ts.map +1 -1
- package/esm/policies/RustDocExists.js +6 -6
- package/esm/policies/RustDocExists.js.map +1 -1
- package/esm/policies/RustToolchainExists.d.ts +11 -4
- package/esm/policies/RustToolchainExists.d.ts.map +1 -1
- package/esm/policies/RustToolchainExists.js +10 -9
- package/esm/policies/RustToolchainExists.js.map +1 -1
- package/esm/policies/RustfmtConfigExists.d.ts +11 -4
- package/esm/policies/RustfmtConfigExists.d.ts.map +1 -1
- package/esm/policies/RustfmtConfigExists.js +10 -9
- package/esm/policies/RustfmtConfigExists.js.map +1 -1
- package/esm/policies/ScriptContains.d.ts +9 -7
- package/esm/policies/ScriptContains.d.ts.map +1 -1
- package/esm/policies/ScriptContains.js +9 -13
- package/esm/policies/ScriptContains.js.map +1 -1
- package/esm/policies/SharedDependencyVersions.d.ts +9 -4
- package/esm/policies/SharedDependencyVersions.d.ts.map +1 -1
- package/esm/policies/SharedDependencyVersions.js +28 -20
- package/esm/policies/SharedDependencyVersions.js.map +1 -1
- package/esm/policies/WorkspaceInheritance.d.ts +11 -4
- package/esm/policies/WorkspaceInheritance.d.ts.map +1 -1
- package/esm/policies/WorkspaceInheritance.js +10 -11
- package/esm/policies/WorkspaceInheritance.js.map +1 -1
- package/esm/policies/WorkspaceMembersValid.d.ts +11 -4
- package/esm/policies/WorkspaceMembersValid.d.ts.map +1 -1
- package/esm/policies/WorkspaceMembersValid.js +10 -11
- package/esm/policies/WorkspaceMembersValid.js.map +1 -1
- package/esm/policies/constants.d.ts.map +1 -1
- package/esm/policies/constants.js +1 -1
- package/esm/policies/constants.js.map +1 -1
- package/esm/policies.d.ts +13 -5
- package/esm/policies.d.ts.map +1 -1
- package/esm/policies.js +12 -5
- package/esm/policies.js.map +1 -1
- package/esm/policy.d.ts +61 -289
- package/esm/policy.d.ts.map +1 -1
- package/esm/policy.js +1 -122
- package/esm/policy.js.map +1 -1
- package/esm/policyDefiners/defineCargoPolicy.d.ts +25 -9
- package/esm/policyDefiners/defineCargoPolicy.d.ts.map +1 -1
- package/esm/policyDefiners/defineCargoPolicy.js +10 -28
- package/esm/policyDefiners/defineCargoPolicy.js.map +1 -1
- package/esm/policyDefiners/defineFileHeaderPolicy.d.ts +27 -14
- package/esm/policyDefiners/defineFileHeaderPolicy.d.ts.map +1 -1
- package/esm/policyDefiners/defineFileHeaderPolicy.js +16 -35
- package/esm/policyDefiners/defineFileHeaderPolicy.js.map +1 -1
- package/esm/policyDefiners/defineGleamPolicy.d.ts +25 -9
- package/esm/policyDefiners/defineGleamPolicy.d.ts.map +1 -1
- package/esm/policyDefiners/defineGleamPolicy.js +10 -27
- package/esm/policyDefiners/defineGleamPolicy.js.map +1 -1
- package/esm/policyDefiners/definePackagePolicy.d.ts +24 -13
- package/esm/policyDefiners/definePackagePolicy.d.ts.map +1 -1
- package/esm/policyDefiners/definePackagePolicy.js +9 -32
- package/esm/policyDefiners/definePackagePolicy.js.map +1 -1
- package/esm/policyDefiners/spdxValidator.d.ts +4 -12
- package/esm/policyDefiners/spdxValidator.d.ts.map +1 -1
- package/esm/policyDefiners/spdxValidator.js +26 -14
- package/esm/policyDefiners/spdxValidator.js.map +1 -1
- package/esm/policyExecution.d.ts +19 -0
- package/esm/policyExecution.d.ts.map +1 -0
- package/esm/policyExecution.js +224 -0
- package/esm/policyExecution.js.map +1 -0
- package/esm/repositoryFiles.d.ts +4 -0
- package/esm/repositoryFiles.d.ts.map +1 -0
- package/esm/repositoryFiles.js +8 -0
- package/esm/repositoryFiles.js.map +1 -0
- package/esm/runner.d.ts +72 -47
- package/esm/runner.d.ts.map +1 -1
- package/esm/runner.js +153 -138
- package/esm/runner.js.map +1 -1
- package/esm/settlePolicyPromise.d.ts +4 -0
- package/esm/settlePolicyPromise.d.ts.map +1 -0
- package/esm/settlePolicyPromise.js +10 -0
- package/esm/settlePolicyPromise.js.map +1 -0
- package/esm/tsdoc-metadata.json +1 -1
- package/esm/utils/safePaths.d.ts +9 -0
- package/esm/utils/safePaths.d.ts.map +1 -0
- package/esm/utils/safePaths.js +40 -0
- package/esm/utils/safePaths.js.map +1 -0
- package/oclif.manifest.json +19 -2
- package/package.json +42 -27
- package/scripts/benchmark.mjs +341 -0
- package/sidecar/sidecar.mjs +348 -417
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import path from "pathe";
|
|
2
|
-
import { makePolicyDefinition } from "../makePolicy.js";
|
|
3
2
|
/**
|
|
4
3
|
* Converts a FluidFramework handler to a repopo PolicyDefinition.
|
|
5
4
|
*
|
|
@@ -19,56 +18,34 @@ function fromFluidHandler(fluidHandler, options) {
|
|
|
19
18
|
const absolutePath = path.join(root, file);
|
|
20
19
|
const errorMessage = await fluidHandler.handler(absolutePath, root);
|
|
21
20
|
if (errorMessage === undefined) {
|
|
22
|
-
return
|
|
21
|
+
return [];
|
|
23
22
|
}
|
|
24
23
|
// Check if resolver exists to determine if auto-fixable
|
|
25
24
|
const autoFixable = fluidHandler.resolver !== undefined;
|
|
26
25
|
// If resolve is requested and we have a resolver, try to fix
|
|
27
26
|
if (resolve && fluidHandler.resolver !== undefined) {
|
|
28
27
|
const resolveResult = await fluidHandler.resolver(absolutePath, root);
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
message: resolveResult.message ?? errorMessage,
|
|
31
|
+
fixStatus: resolveResult.resolved ? "fixed" : "failed",
|
|
32
|
+
},
|
|
33
|
+
];
|
|
36
34
|
}
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
message: errorMessage,
|
|
38
|
+
fixStatus: autoFixable ? "available" : undefined,
|
|
39
|
+
},
|
|
40
|
+
];
|
|
43
41
|
};
|
|
44
|
-
|
|
45
|
-
let resolver;
|
|
46
|
-
if (fluidHandler.resolver !== undefined) {
|
|
47
|
-
resolver = async ({ file, root }) => {
|
|
48
|
-
const absolutePath = path.join(root, file);
|
|
49
|
-
// First get the error message for context
|
|
50
|
-
const errorMessage = await fluidHandler.handler(absolutePath, root);
|
|
51
|
-
// biome-ignore lint/style/noNonNullAssertion: we checked this is defined above
|
|
52
|
-
const resolveResult = await fluidHandler.resolver(absolutePath, root);
|
|
53
|
-
return {
|
|
54
|
-
name: policyName,
|
|
55
|
-
file,
|
|
56
|
-
errorMessages: [
|
|
57
|
-
resolveResult.message ?? errorMessage ?? "Unknown error",
|
|
58
|
-
],
|
|
59
|
-
autoFixable: true,
|
|
60
|
-
resolved: resolveResult.resolved,
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
return makePolicyDefinition({
|
|
42
|
+
return {
|
|
65
43
|
name: policyName,
|
|
66
44
|
description: `FluidFramework policy: ${fluidHandler.name}`,
|
|
67
45
|
match: fluidHandler.match,
|
|
68
46
|
handler,
|
|
69
47
|
defaultConfig: undefined, // no config
|
|
70
|
-
|
|
71
|
-
});
|
|
48
|
+
};
|
|
72
49
|
}
|
|
73
50
|
/**
|
|
74
51
|
* Converts FluidFramework handlers to repopo PolicyDefinitions.
|
|
@@ -81,19 +58,19 @@ function fromFluidHandler(fluidHandler, options) {
|
|
|
81
58
|
* Key differences handled by this adapter:
|
|
82
59
|
*
|
|
83
60
|
* - **Handler signature**: Fluid uses `(file, root) => string | undefined`,
|
|
84
|
-
* repopo uses `(args) =>
|
|
61
|
+
* repopo uses `(args) => Promise<PolicyResult> | Operation<PolicyResult>`
|
|
85
62
|
*
|
|
86
63
|
* - **File paths**: Fluid passes absolute paths, repopo passes repo-relative paths.
|
|
87
64
|
* The adapter converts between the two.
|
|
88
65
|
*
|
|
89
66
|
* - **Return types**: Fluid returns `string | undefined` (error message or success),
|
|
90
|
-
* repopo returns `
|
|
67
|
+
* repopo returns `readonly PolicyFinding[]`
|
|
91
68
|
*
|
|
92
69
|
* For a single handler, wrap it in an array: `fromFluidHandlers([handler])`.
|
|
93
70
|
*
|
|
94
71
|
* @example
|
|
95
72
|
* ```typescript
|
|
96
|
-
* import { fromFluidHandlers, makePolicy } from "repopo";
|
|
73
|
+
* import { fromFluidHandlers, makePolicy, type RepopoConfig } from "repopo";
|
|
97
74
|
* import { copyrightFileHeaderHandlers, fluidCaseHandler } from "@fluidframework/build-tools";
|
|
98
75
|
*
|
|
99
76
|
* // Convert multiple handlers with a namespace prefix
|
|
@@ -106,7 +83,7 @@ function fromFluidHandler(fluidHandler, options) {
|
|
|
106
83
|
*
|
|
107
84
|
* const config: RepopoConfig = {
|
|
108
85
|
* policies: [
|
|
109
|
-
* ...FluidCopyrightPolicies.map(p => makePolicy(p)),
|
|
86
|
+
* ...FluidCopyrightPolicies.map((p) => makePolicy(p)),
|
|
110
87
|
* makePolicy(FluidCasePolicy),
|
|
111
88
|
* ],
|
|
112
89
|
* };
|
|
@@ -116,7 +93,7 @@ function fromFluidHandler(fluidHandler, options) {
|
|
|
116
93
|
* @param options - Optional configuration applied to all conversions.
|
|
117
94
|
* @returns An array of repopo PolicyDefinitions.
|
|
118
95
|
*
|
|
119
|
-
* @
|
|
96
|
+
* @public
|
|
120
97
|
*/
|
|
121
98
|
export function fromFluidHandlers(fluidHandlers, options) {
|
|
122
99
|
return fluidHandlers.map((h) => fromFluidHandler(h, options));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidFramework.js","sourceRoot":"","sources":["../../src/adapters/fluidFramework.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"fluidFramework.js","sourceRoot":"","sources":["../../src/adapters/fluidFramework.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,OAAO,CAAC;AAqEzB;;;;;;;;;;GAUG;AACH,SAAS,gBAAgB,CACxB,YAA0B,EAC1B,OAA6B;IAE7B,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC1C,MAAM,UAAU,GAAG,GAAG,UAAU,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;IAEvD,MAAM,OAAO,GAAkB,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAChE,uCAAuC;QACvC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE3C,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAEpE,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,EAAE,CAAC;QACX,CAAC;QAED,wDAAwD;QACxD,MAAM,WAAW,GAAG,YAAY,CAAC,QAAQ,KAAK,SAAS,CAAC;QAExD,6DAA6D;QAC7D,IAAI,OAAO,IAAI,YAAY,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACpD,MAAM,aAAa,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YAEtE,OAAO;gBACN;oBACC,OAAO,EAAE,aAAa,CAAC,OAAO,IAAI,YAAY;oBAC9C,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;iBACtD;aACD,CAAC;QACH,CAAC;QAED,OAAO;YACN;gBACC,OAAO,EAAE,YAAY;gBACrB,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;aAChD;SACD,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACN,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,0BAA0B,YAAY,CAAC,IAAI,EAAE;QAC1D,KAAK,EAAE,YAAY,CAAC,KAAK;QACzB,OAAO;QACP,aAAa,EAAE,SAAS,EAAE,YAAY;KACP,CAAC;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,UAAU,iBAAiB,CAChC,aAA6B,EAC7B,OAA6B;IAE7B,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["import path from \"pathe\";\nimport type { FilePolicyDefinition, PolicyHandler } from \"../policy.js\";\n\n/**\n * A FluidFramework build-tools policy handler interface.\n *\n * This interface matches the `Handler` interface from `@fluidframework/build-tools`.\n *\n * @public\n */\nexport interface FluidHandler {\n\t/**\n\t * The name of the handler, used for filtering and display.\n\t */\n\tname: string;\n\n\t/**\n\t * A regex pattern that determines which files this handler applies to.\n\t */\n\tmatch: RegExp;\n\n\t/**\n\t * The handler function that checks a file against the policy.\n\t *\n\t * @param file - Absolute path to the file.\n\t * @param root - Path to the repo root.\n\t * @returns `undefined` if the check passes, otherwise an error message string.\n\t */\n\thandler: (file: string, root: string) => Promise<string | undefined>;\n\n\t/**\n\t * Optional resolver function that attempts to fix policy violations.\n\t *\n\t * @param file - Absolute path to the file.\n\t * @param root - Path to the repo root.\n\t * @returns An object indicating whether the fix was successful.\n\t */\n\tresolver?: (\n\t\tfile: string,\n\t\troot: string,\n\t) =>\n\t\t| Promise<{\n\t\t\t\t/** Whether the violation was fixed. */\n\t\t\t\tresolved: boolean;\n\t\t\t\t/** Optional explanation of the fix result. */\n\t\t\t\tmessage?: string;\n\t\t }>\n\t\t| {\n\t\t\t\t/** Whether the violation was fixed. */\n\t\t\t\tresolved: boolean;\n\t\t\t\t/** Optional explanation of the fix result. */\n\t\t\t\tmessage?: string;\n\t\t };\n}\n\n/**\n * Options for converting FluidFramework handlers to repopo policies.\n *\n * @public\n */\nexport interface FluidAdapterOptions {\n\t/**\n\t * Optional prefix to add to policy names. Useful for namespacing Fluid policies.\n\t *\n\t * @example \"Fluid:\" would result in \"Fluid:my-handler-name\"\n\t */\n\tnamePrefix?: string;\n}\n\n/**\n * Converts a FluidFramework handler to a repopo PolicyDefinition.\n *\n * This is an internal function used by {@link fromFluidHandlers}.\n *\n * @param fluidHandler - A FluidFramework Handler object to convert.\n * @param options - Optional configuration for the conversion.\n * @returns A repopo PolicyDefinition that wraps the Fluid handler.\n *\n * @internal\n */\nfunction fromFluidHandler(\n\tfluidHandler: FluidHandler,\n\toptions?: FluidAdapterOptions,\n): FilePolicyDefinition {\n\tconst { namePrefix = \"\" } = options ?? {};\n\tconst policyName = `${namePrefix}${fluidHandler.name}`;\n\n\tconst handler: PolicyHandler = async ({ file, root, resolve }) => {\n\t\t// Fluid handlers expect absolute paths\n\t\tconst absolutePath = path.join(root, file);\n\n\t\tconst errorMessage = await fluidHandler.handler(absolutePath, root);\n\n\t\tif (errorMessage === undefined) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Check if resolver exists to determine if auto-fixable\n\t\tconst autoFixable = fluidHandler.resolver !== undefined;\n\n\t\t// If resolve is requested and we have a resolver, try to fix\n\t\tif (resolve && fluidHandler.resolver !== undefined) {\n\t\t\tconst resolveResult = await fluidHandler.resolver(absolutePath, root);\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tmessage: resolveResult.message ?? errorMessage,\n\t\t\t\t\tfixStatus: resolveResult.resolved ? \"fixed\" : \"failed\",\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tmessage: errorMessage,\n\t\t\t\tfixStatus: autoFixable ? \"available\" : undefined,\n\t\t\t},\n\t\t];\n\t};\n\n\treturn {\n\t\tname: policyName,\n\t\tdescription: `FluidFramework policy: ${fluidHandler.name}`,\n\t\tmatch: fluidHandler.match,\n\t\thandler,\n\t\tdefaultConfig: undefined, // no config\n\t} satisfies FilePolicyDefinition;\n}\n\n/**\n * Converts FluidFramework handlers to repopo PolicyDefinitions.\n *\n * This adapter bridges the gap between FluidFramework's build-tools policy system\n * and repopo's policy system, allowing you to reuse existing Fluid policies in repopo.\n *\n * @remarks\n *\n * Key differences handled by this adapter:\n *\n * - **Handler signature**: Fluid uses `(file, root) => string | undefined`,\n * repopo uses `(args) => Promise<PolicyResult> | Operation<PolicyResult>`\n *\n * - **File paths**: Fluid passes absolute paths, repopo passes repo-relative paths.\n * The adapter converts between the two.\n *\n * - **Return types**: Fluid returns `string | undefined` (error message or success),\n * repopo returns `readonly PolicyFinding[]`\n *\n * For a single handler, wrap it in an array: `fromFluidHandlers([handler])`.\n *\n * @example\n * ```typescript\n * import { fromFluidHandlers, makePolicy, type RepopoConfig } from \"repopo\";\n * import { copyrightFileHeaderHandlers, fluidCaseHandler } from \"@fluidframework/build-tools\";\n *\n * // Convert multiple handlers with a namespace prefix\n * const FluidCopyrightPolicies = fromFluidHandlers(copyrightFileHeaderHandlers, {\n * namePrefix: \"Fluid:\",\n * });\n *\n * // For a single handler, wrap it in an array\n * const [FluidCasePolicy] = fromFluidHandlers([fluidCaseHandler]);\n *\n * const config: RepopoConfig = {\n * policies: [\n * ...FluidCopyrightPolicies.map((p) => makePolicy(p)),\n * makePolicy(FluidCasePolicy),\n * ],\n * };\n * ```\n *\n * @param fluidHandlers - An array of FluidFramework Handler objects to convert.\n * @param options - Optional configuration applied to all conversions.\n * @returns An array of repopo PolicyDefinitions.\n *\n * @public\n */\nexport function fromFluidHandlers(\n\tfluidHandlers: FluidHandler[],\n\toptions?: FluidAdapterOptions,\n): FilePolicyDefinition[] {\n\treturn fluidHandlers.map((h) => fromFluidHandler(h, options));\n}\n"]}
|
package/esm/api.d.ts
CHANGED
|
@@ -1,2 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A tool for enforcing repository policies and standards across codebases.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Repopo provides a framework for defining and enforcing policies across repositories,
|
|
6
|
+
* such as file headers, package.json consistency, and other code standards.
|
|
7
|
+
* It can be used as a CLI tool or integrated into CI/CD pipelines.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
export { type FluidAdapterOptions, type FluidHandler, fromFluidHandlers, } from "./adapters/fluidFramework.js";
|
|
12
|
+
export type { RepopoConfig } from "./config.js";
|
|
13
|
+
export { makePolicy } from "./makePolicy.js";
|
|
14
|
+
export type { PolicyAction, PolicyHandlerPerfStats } from "./perf.js";
|
|
15
|
+
export type { CargoLicenceValidatedConfig } from "./policies/CargoLicenceValidated.js";
|
|
16
|
+
export type { CargoLintsConfiguredConfig } from "./policies/CargoLintsConfigured.js";
|
|
17
|
+
export type { CargoLockPolicyConfig } from "./policies/CargoLockPolicy.js";
|
|
18
|
+
export type { CargoTomlRequiredConfig } from "./policies/CargoTomlRequired.js";
|
|
19
|
+
export type { CargoTomlSortedConfig } from "./policies/CargoTomlSorted.js";
|
|
20
|
+
export type { ConditionalScriptEntry, ConditionalScriptRule, ConditionalScriptsConfig, } from "./policies/ConditionalScripts.js";
|
|
21
|
+
export type { ExactScriptsConfig } from "./policies/ExactScripts.js";
|
|
22
|
+
export type { GleamDepVersionsConfig } from "./policies/GleamDepVersions.js";
|
|
23
|
+
export type { GleamDocExistsConfig } from "./policies/GleamDocExists.js";
|
|
24
|
+
export type { GleamInternalModulesConfiguredConfig } from "./policies/GleamInternalModulesConfigured.js";
|
|
25
|
+
export type { GleamLicenceConfiguredConfig } from "./policies/GleamLicenceConfigured.js";
|
|
26
|
+
export type { GleamMonorepoConsistencyConfig } from "./policies/GleamMonorepoConsistency.js";
|
|
27
|
+
export type { GleamNameRestrictionsConfig } from "./policies/GleamNameRestrictions.js";
|
|
28
|
+
export type { GleamNoPathDepsInPublishedConfig } from "./policies/GleamNoPathDepsInPublished.js";
|
|
29
|
+
export type { GleamProjectStructureConfig } from "./policies/GleamProjectStructure.js";
|
|
30
|
+
export type { GleamSharedDependencyVersionsConfig } from "./policies/GleamSharedDependencyVersions.js";
|
|
31
|
+
export type { GleamTomlRequiredConfig } from "./policies/GleamTomlRequired.js";
|
|
32
|
+
export type { GleamTomlSortedConfig } from "./policies/GleamTomlSorted.js";
|
|
33
|
+
export type { GleamVersionConstraintConfig } from "./policies/GleamVersionConstraint.js";
|
|
34
|
+
export type { LicenseFileExistsSettings } from "./policies/LicenseFileExists.js";
|
|
35
|
+
export type { MutuallyExclusiveScriptsConfig } from "./policies/MutuallyExclusiveScripts.js";
|
|
36
|
+
export type { NoLargeBinaryFilesSettings } from "./policies/NoLargeBinaryFiles.js";
|
|
37
|
+
export type { NoPrivateWorkspaceDependenciesSettings } from "./policies/NoPrivateWorkspaceDependencies.js";
|
|
38
|
+
export type { NoUnsafeWithoutJustificationConfig } from "./policies/NoUnsafeWithoutJustification.js";
|
|
39
|
+
export type { NoWildcardDependenciesConfig } from "./policies/NoWildcardDependencies.js";
|
|
40
|
+
export type { PackageAllowedScopesConfig } from "./policies/PackageAllowedScopes.js";
|
|
41
|
+
export type { PackageEsmTypeConfig } from "./policies/PackageEsmType.js";
|
|
42
|
+
export type { PackageFolderNameConfig } from "./policies/PackageFolderName.js";
|
|
43
|
+
export type { PackageJsonPropertiesSettings } from "./policies/PackageJsonProperties.js";
|
|
44
|
+
export type { PackageLicenseSettings } from "./policies/PackageLicense.js";
|
|
45
|
+
export type { PackagePrivateFieldConfig } from "./policies/PackagePrivateField.js";
|
|
46
|
+
export type { PackageReadmeSettings } from "./policies/PackageReadme.js";
|
|
47
|
+
export type { PackageScriptsSettings, ScriptMustContainRule, } from "./policies/PackageScripts.js";
|
|
48
|
+
export type { PackageTestScriptsConfig } from "./policies/PackageTestScripts.js";
|
|
49
|
+
export type { PublicApiDocumentedConfig } from "./policies/PublicApiDocumented.js";
|
|
50
|
+
export type { RequiredGitignorePatternsSettings } from "./policies/RequiredGitignorePatterns.js";
|
|
51
|
+
export type { RequiredScriptEntry, RequiredScriptsConfig, } from "./policies/RequiredScripts.js";
|
|
52
|
+
export type { RustDocExistsConfig } from "./policies/RustDocExists.js";
|
|
53
|
+
export type { RustfmtConfigExistsConfig } from "./policies/RustfmtConfigExists.js";
|
|
54
|
+
export type { RustToolchainExistsConfig } from "./policies/RustToolchainExists.js";
|
|
55
|
+
export type { ScriptContainsConfig, ScriptContainsRule, } from "./policies/ScriptContains.js";
|
|
56
|
+
export type { SharedDependencyVersionsConfig } from "./policies/SharedDependencyVersions.js";
|
|
57
|
+
export type { WorkspaceInheritanceConfig } from "./policies/WorkspaceInheritance.js";
|
|
58
|
+
export type { WorkspaceMembersValidConfig } from "./policies/WorkspaceMembersValid.js";
|
|
59
|
+
export type { ConfiguredFilePolicy, ConfiguredPolicy, ConfiguredRepositoryPolicy, FilePolicyDefinition, IdentifiedPolicy, PolicyArgs, PolicyDefinition, PolicyFinding, PolicyHandler, PolicyInstanceId, PolicyName, PolicyOptions, PolicyResolver, PolicyResult, RepositoryPolicyArgs, RepositoryPolicyDefinition, RepositoryPolicyHandler, } from "./policy.js";
|
|
60
|
+
export { type CargoToml, type CargoTomlHandler, type DefineCargoPolicyArgs, defineCargoPolicy, } from "./policyDefiners/defineCargoPolicy.js";
|
|
61
|
+
export { type DefineFileHeaderPolicyArgs, defineFileHeaderPolicy, type FileHeaderGeneratorConfig, type FileHeaderPolicyConfig, } from "./policyDefiners/defineFileHeaderPolicy.js";
|
|
62
|
+
export { type DefineGleamPolicyArgs, defineGleamPolicy, type GleamToml, type GleamTomlHandler, } from "./policyDefiners/defineGleamPolicy.js";
|
|
63
|
+
export { type DefinePackagePolicyArgs, definePackagePolicy, type PackageJsonHandler, } from "./policyDefiners/definePackagePolicy.js";
|
|
64
|
+
export { type PolicyExecutionError, type PolicyRunFinding, PolicyRunner, type PolicyRunnerOptions, type PolicyRunResults, type PolicySkippedWork, type RepositoryInventory, runPolicies, } from "./runner.js";
|
|
2
65
|
//# 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":""}
|
|
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,MA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AAgB,EAChB,UAAU,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,iBAAiB,GACjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,KAAK,0BAA0B,EAC/B,sBAAsB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,GAC3B,MAAM,4CAA4C,CAAC;AACpD,OAAO,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,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
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A tool for enforcing repository policies and standards across codebases.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Repopo provides a framework for defining and enforcing policies across repositories,
|
|
6
|
+
* such as file headers, package.json consistency, and other code standards.
|
|
7
|
+
* It can be used as a CLI tool or integrated into CI/CD pipelines.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
export { fromFluidHandlers, } from "./adapters/fluidFramework.js";
|
|
12
|
+
export { makePolicy } from "./makePolicy.js";
|
|
13
|
+
export { defineCargoPolicy, } from "./policyDefiners/defineCargoPolicy.js";
|
|
14
|
+
export { defineFileHeaderPolicy, } from "./policyDefiners/defineFileHeaderPolicy.js";
|
|
15
|
+
export { defineGleamPolicy, } from "./policyDefiners/defineGleamPolicy.js";
|
|
16
|
+
export { definePackagePolicy, } from "./policyDefiners/definePackagePolicy.js";
|
|
17
|
+
export { PolicyRunner, runPolicies, } from "./runner.js";
|
|
2
18
|
//# 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":"","sourcesContent":[""]}
|
|
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;AA8E7C,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,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 { 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\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"]}
|
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,
|
|
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,EAGN,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,7 @@ 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 { createExcludedPolicyFileMap, } from "./context.js";
|
|
6
|
+
import { createExcludedPolicyFileMap, exclusionRegex, } from "./context.js";
|
|
7
7
|
import { identifyPolicyInstances, makePolicy } from "./makePolicy.js";
|
|
8
8
|
import { newPerfStats } from "./perf.js";
|
|
9
9
|
import { DefaultPolicies } from "./policy.js";
|
|
@@ -25,7 +25,7 @@ export class BaseRepopoCommand extends CommandWithConfig {
|
|
|
25
25
|
}
|
|
26
26
|
async init() {
|
|
27
27
|
await super.init();
|
|
28
|
-
const excludeFiles = this.commandConfig?.excludeFiles?.map(
|
|
28
|
+
const excludeFiles = this.commandConfig?.excludeFiles?.map(exclusionRegex) ?? [];
|
|
29
29
|
const policies = identifyPolicyInstances(this.commandConfig?.policies ??
|
|
30
30
|
DefaultPolicies.map((configuredPolicy) => makePolicy(configuredPolicy)));
|
|
31
31
|
const gitRoot = findGitRootSync();
|
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;AACrE,OAAO,EACN,2BAA2B,
|
|
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,EAC3B,cAAc,GAEd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;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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\texclusionRegex,\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(exclusionRegex) ?? [];\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"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Command } from "@oclif/core";
|
|
2
2
|
/**
|
|
3
3
|
* Runs the Rust-based repopo-core engine with the Node.js sidecar for
|
|
4
|
-
* policy
|
|
5
|
-
*
|
|
6
|
-
* and orchestration.
|
|
4
|
+
* per-policy execution. Rust owns matching, ordering, concurrency, exception
|
|
5
|
+
* boundaries, repository scheduling and aggregation.
|
|
7
6
|
*/
|
|
8
7
|
export declare class CheckNative extends Command {
|
|
9
8
|
static readonly summary = "Checks and applies policies using the Rust engine.";
|
|
10
9
|
static readonly description: string;
|
|
11
10
|
static readonly flags: {
|
|
11
|
+
readonly concurrency: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
readonly fix: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
13
|
readonly stdin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
14
|
readonly verbose: 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;AAM7C;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,OAAO;IACvC,gBAAgC,OAAO,wDACe;IAEtD,gBAAgC,WAAW,SAIsC;IAEjF,gBAAgC,KAAK;;;;;;;;;;MAgD1B;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAkE1C,OAAO,CAAC,iBAAiB;IAiDzB,OAAO,CAAC,kBAAkB;CAQ1B"}
|
|
@@ -3,19 +3,25 @@ import { existsSync } from "node:fs";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { Command, Flags } from "@oclif/core";
|
|
5
5
|
import { dirname, resolve } from "pathe";
|
|
6
|
+
import { DEFAULT_CONCURRENCY, validateConcurrency } from "../concurrency.js";
|
|
6
7
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
8
|
/**
|
|
8
9
|
* Runs the Rust-based repopo-core engine with the Node.js sidecar for
|
|
9
|
-
* policy
|
|
10
|
-
*
|
|
11
|
-
* and orchestration.
|
|
10
|
+
* per-policy execution. Rust owns matching, ordering, concurrency, exception
|
|
11
|
+
* boundaries, repository scheduling and aggregation.
|
|
12
12
|
*/
|
|
13
13
|
export class CheckNative extends Command {
|
|
14
14
|
static summary = "Checks and applies policies using the Rust engine.";
|
|
15
15
|
static description = "Runs the Rust-based repopo-core engine with the Node.js sidecar. " +
|
|
16
|
-
"
|
|
17
|
-
"
|
|
16
|
+
"Rust handles file matching, scheduling and reporting; the sidecar shares per-policy contracts with 'check'. " +
|
|
17
|
+
"Repository policies always run with the full repository inventory, including with --stdin. " +
|
|
18
|
+
"With --fix, repository policies can modify files outside the stdin selection.";
|
|
18
19
|
static flags = {
|
|
20
|
+
concurrency: Flags.integer({
|
|
21
|
+
description: "Maximum concurrent files in read-only checks. Fixes remain sequential.",
|
|
22
|
+
default: DEFAULT_CONCURRENCY,
|
|
23
|
+
parse: async (value) => validateConcurrency(Number(value)),
|
|
24
|
+
}),
|
|
19
25
|
fix: Flags.boolean({
|
|
20
26
|
aliases: ["resolve"],
|
|
21
27
|
description: "Fix errors if possible.",
|
|
@@ -63,6 +69,7 @@ export class CheckNative extends Command {
|
|
|
63
69
|
const binaryPath = this.resolveBinaryPath(flags["binary-path"]);
|
|
64
70
|
const sidecarPath = this.resolveSidecarPath(flags["sidecar-path"]);
|
|
65
71
|
const args = ["check", "--sidecar-path", sidecarPath];
|
|
72
|
+
args.push("--concurrency", String(flags.concurrency));
|
|
66
73
|
if (flags.fix) {
|
|
67
74
|
args.push("--fix");
|
|
68
75
|
}
|
|
@@ -87,14 +94,26 @@ export class CheckNative extends Command {
|
|
|
87
94
|
// biome-ignore lint/style/noProcessEnv: Need to pass parent environment to child process
|
|
88
95
|
env: { ...process.env },
|
|
89
96
|
});
|
|
97
|
+
const interrupt = () => child.kill("SIGINT");
|
|
98
|
+
const terminate = () => child.kill("SIGTERM");
|
|
99
|
+
const cleanup = () => {
|
|
100
|
+
process.removeListener("SIGINT", interrupt);
|
|
101
|
+
process.removeListener("SIGTERM", terminate);
|
|
102
|
+
};
|
|
103
|
+
process.on("SIGINT", interrupt);
|
|
104
|
+
process.on("SIGTERM", terminate);
|
|
90
105
|
child.on("error", (err) => {
|
|
106
|
+
cleanup();
|
|
91
107
|
reject(new Error(`Failed to spawn repopo-core: ${err.message}\n` +
|
|
92
108
|
`Binary path: ${binaryPath}\n` +
|
|
93
109
|
"Make sure the Rust binary has been built: cargo build --manifest-path crates/core/Cargo.toml"));
|
|
94
110
|
});
|
|
95
|
-
child.on("close", (code) => {
|
|
111
|
+
child.on("close", (code, signal) => {
|
|
112
|
+
cleanup();
|
|
96
113
|
if (code !== 0) {
|
|
97
|
-
process.exitCode =
|
|
114
|
+
process.exitCode =
|
|
115
|
+
code ??
|
|
116
|
+
(signal === "SIGINT" ? 130 : signal === "SIGTERM" ? 143 : 1);
|
|
98
117
|
}
|
|
99
118
|
resolvePromise();
|
|
100
119
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-native.js","sourceRoot":"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C,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,aAAa,CAAC;QAElE,iCAAiC;QACjC,iDAAiD;QACjD,MAAM,UAAU,GAAG,OAAO,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\";\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"]}
|
|
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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,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"]}
|
package/esm/commands/check.d.ts
CHANGED
|
@@ -1,36 +1,21 @@
|
|
|
1
1
|
import { BaseRepopoCommand } from "../baseCommand.js";
|
|
2
|
-
/**
|
|
3
|
-
* This tool enforces policies across the code base via a series of handler functions. The handler functions are
|
|
4
|
-
* associated with a regular expression, and all files matching that expression are passed to the handler function.
|
|
5
|
-
*
|
|
6
|
-
* By default, the list of files to check comes from `git ls-files. You can also pipe in file names from stdin. For
|
|
7
|
-
* example:
|
|
8
|
-
*
|
|
9
|
-
* `git ls-files -co --exclude-standard --full-name | repopo check --stdin --verbose`
|
|
10
|
-
*/
|
|
2
|
+
/** Check selected files and the complete repository inventory. */
|
|
11
3
|
export declare class CheckPolicy<T extends typeof BaseRepopoCommand & {
|
|
12
4
|
args: typeof CheckPolicy.args;
|
|
13
5
|
flags: typeof CheckPolicy.flags;
|
|
14
6
|
}> extends BaseRepopoCommand<T> {
|
|
15
7
|
static readonly summary = "Checks and applies policies to the files in the repository.";
|
|
8
|
+
static readonly description: string;
|
|
16
9
|
static readonly flags: {
|
|
17
10
|
readonly config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
readonly concurrency: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
12
|
readonly fix: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
13
|
readonly stdin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
14
|
};
|
|
21
15
|
run(): Promise<void>;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
16
|
+
private reportFinding;
|
|
17
|
+
private reportError;
|
|
25
18
|
private collectFilePaths;
|
|
26
|
-
|
|
27
|
-
* Formats a single policy file result, logging messages and setting exit codes.
|
|
28
|
-
*/
|
|
29
|
-
private formatResult;
|
|
30
|
-
private formatFixResult;
|
|
31
|
-
private formatPolicyErrorFixResult;
|
|
32
|
-
private formatResolutionResult;
|
|
33
|
-
private formatPolicyFailure;
|
|
34
|
-
private logMessages;
|
|
19
|
+
private collectRepositoryFiles;
|
|
35
20
|
}
|
|
36
21
|
//# 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":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAwBtD,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;;;;;MAkB1B;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAqC1C,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,WAAW;YAWL,gBAAgB;YAgBhB,sBAAsB;CAGpC"}
|