repopo 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/README.md +57 -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 +66 -1
- package/esm/api.d.ts.map +1 -1
- package/esm/api.js +18 -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 +5 -3
- package/esm/commands/check-native.d.ts.map +1 -1
- package/esm/commands/check-native.js +35 -7
- package/esm/commands/check-native.js.map +1 -1
- package/esm/commands/check.d.ts +8 -21
- package/esm/commands/check.d.ts.map +1 -1
- package/esm/commands/check.js +98 -154
- package/esm/commands/check.js.map +1 -1
- package/esm/commands/list.d.ts.map +1 -1
- package/esm/commands/list.js +1 -0
- 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 +10 -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 +10 -1
- package/esm/context.d.ts.map +1 -1
- package/esm/context.js +19 -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 +46 -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/MaxChangedFiles.d.ts +17 -0
- package/esm/policies/MaxChangedFiles.d.ts.map +1 -0
- package/esm/policies/MaxChangedFiles.js +22 -0
- package/esm/policies/MaxChangedFiles.js.map +1 -0
- package/esm/policies/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/RequireCompanionChanges.d.ts +16 -0
- package/esm/policies/RequireCompanionChanges.d.ts.map +1 -0
- package/esm/policies/RequireCompanionChanges.js +42 -0
- package/esm/policies/RequireCompanionChanges.js.map +1 -0
- package/esm/policies/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 +15 -5
- package/esm/policies.d.ts.map +1 -1
- package/esm/policies.js +14 -5
- package/esm/policies.js.map +1 -1
- package/esm/policy.d.ts +67 -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 +20 -0
- package/esm/policyExecution.d.ts.map +1 -0
- package/esm/policyExecution.js +234 -0
- package/esm/policyExecution.js.map +1 -0
- package/esm/repositoryChanges.d.ts +26 -0
- package/esm/repositoryChanges.d.ts.map +1 -0
- package/esm/repositoryChanges.js +172 -0
- package/esm/repositoryChanges.js.map +1 -0
- package/esm/repositoryFiles.d.ts +6 -0
- package/esm/repositoryFiles.d.ts.map +1 -0
- package/esm/repositoryFiles.js +11 -0
- package/esm/repositoryFiles.js.map +1 -0
- package/esm/runner.d.ts +73 -47
- package/esm/runner.d.ts.map +1 -1
- package/esm/runner.js +158 -144
- 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 +57 -2
- package/package.json +42 -27
- package/scripts/benchmark.mjs +341 -0
- package/sidecar/sidecar.mjs +388 -417
|
@@ -61,31 +61,32 @@ async function fixMissingScripts(json, file, missingWithDefaults, existingScript
|
|
|
61
61
|
*
|
|
62
62
|
* @example
|
|
63
63
|
* ```typescript
|
|
64
|
-
* import {
|
|
64
|
+
* import { makePolicy } from "repopo";
|
|
65
65
|
* import { RequiredScripts } from "repopo/policies";
|
|
66
66
|
*
|
|
67
|
-
*
|
|
67
|
+
* makePolicy(RequiredScripts, { config: {
|
|
68
68
|
* scripts: [
|
|
69
69
|
* "test", // Must exist, no auto-fix
|
|
70
70
|
* { lint: "biome lint ." }, // Must exist, auto-fix adds default if missing
|
|
71
71
|
* { clean: "rimraf dist esm" }, // Must exist, auto-fix adds default if missing
|
|
72
72
|
* ],
|
|
73
|
-
* })
|
|
73
|
+
* } })
|
|
74
74
|
* ```
|
|
75
75
|
*
|
|
76
|
-
* @
|
|
76
|
+
* @public
|
|
77
77
|
*/
|
|
78
78
|
export const RequiredScripts = definePackagePolicy({
|
|
79
|
+
requiresConfig: true,
|
|
79
80
|
name: POLICY_NAME,
|
|
80
81
|
description: "Validates that required scripts exist in package.json.",
|
|
81
82
|
handler: async (json, { file, root, resolve, config }) => {
|
|
82
83
|
if (config === undefined || config.scripts.length === 0) {
|
|
83
|
-
return
|
|
84
|
+
return [];
|
|
84
85
|
}
|
|
85
86
|
const scripts = json.scripts ?? {};
|
|
86
87
|
const validation = validateRequiredScripts(scripts, config.scripts);
|
|
87
88
|
if (validation.missingScripts.length === 0) {
|
|
88
|
-
return
|
|
89
|
+
return [];
|
|
89
90
|
}
|
|
90
91
|
const hasAutoFixableErrors = validation.missingWithDefaults.length > 0;
|
|
91
92
|
if (resolve && hasAutoFixableErrors) {
|
|
@@ -93,29 +94,28 @@ export const RequiredScripts = definePackagePolicy({
|
|
|
93
94
|
const fixedScripts = await fixMissingScripts(json, resolvePath(root, file), validation.missingWithDefaults, scripts);
|
|
94
95
|
// Check if there are still missing scripts (those without defaults)
|
|
95
96
|
const stillMissing = validation.missingScripts.filter((name) => !fixedScripts.includes(name));
|
|
96
|
-
return
|
|
97
|
-
name
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
};
|
|
97
|
+
return [
|
|
98
|
+
...fixedScripts.map((name) => ({
|
|
99
|
+
message: `Fixed scripts: ${name}`,
|
|
100
|
+
fixStatus: "fixed",
|
|
101
|
+
})),
|
|
102
|
+
...stillMissing.map((name) => ({
|
|
103
|
+
message: `Still missing: ${name}`,
|
|
104
|
+
})),
|
|
105
|
+
];
|
|
106
106
|
}
|
|
107
107
|
catch {
|
|
108
108
|
// Fall through to return regular failure
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
return {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
};
|
|
111
|
+
return validation.missingScripts.map((name) => ({
|
|
112
|
+
message: `Missing required scripts:\n\t${name}`,
|
|
113
|
+
fixStatus: validation.missingWithDefaults.some((entry) => entry.name === name)
|
|
114
|
+
? resolve
|
|
115
|
+
? "failed"
|
|
116
|
+
: "available"
|
|
117
|
+
: undefined,
|
|
118
|
+
}));
|
|
119
119
|
},
|
|
120
120
|
});
|
|
121
121
|
//# sourceMappingURL=RequiredScripts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequiredScripts.js","sourceRoot":"","sources":["../../src/policies/RequiredScripts.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AA+C/E,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAOtC;;GAEG;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\nimport { resolve as resolvePath } from \"pathe\";\nimport type { PackageJson } from \"type-fest\";\nimport { definePackagePolicy } from \"../policyDefiners/definePackagePolicy.js\";\n\n/**\n * A required script entry. Can be either:\n * - A string (script name only, no default value)\n * - An object with a single key-value pair (script name → default value for auto-fix)\n *\n * @example\n * ```typescript\n * // Script must exist, no auto-fix available\n * \"test\"\n *\n * // Script must exist, auto-fix will add this value if missing\n * { lint: \"biome lint .\" }\n * ```\n *\n * @alpha\n */\nexport type RequiredScriptEntry = string | Record<string, string>;\n\n/**\n * Configuration for the RequiredScripts policy.\n *\n * @alpha\n */\nexport interface RequiredScriptsConfig {\n\t/**\n\t * Scripts that must be present in package.json.\n\t *\n\t * @remarks\n\t * Each entry can be:\n\t * - A string: Script must exist, no auto-fix available, content not validated\n\t * - An object `{ scriptName: \"default value\" }`: Script must exist, auto-fix adds the\n\t * default value if missing, but existing scripts with different content still pass\n\t *\n\t * @example\n\t * ```typescript\n\t * scripts: [\n\t * \"test\", // Must exist, no auto-fix\n\t * { lint: \"biome lint .\" }, // Must exist, auto-fix available\n\t * { clean: \"rimraf dist esm\" }, // Must exist, auto-fix available\n\t * ]\n\t * ```\n\t */\n\tscripts: RequiredScriptEntry[];\n}\n\nconst POLICY_NAME = \"RequiredScripts\";\n\ninterface ParsedEntry {\n\tname: string;\n\tdefaultValue?: string;\n}\n\n/**\n * Extracts script name and optional default value from a RequiredScriptEntry.\n */\nfunction parseRequiredEntry(entry: RequiredScriptEntry): ParsedEntry {\n\tif (typeof entry === \"string\") {\n\t\treturn { name: entry };\n\t}\n\tconst keys = Object.keys(entry);\n\tif (keys.length !== 1) {\n\t\tthrow new Error(\n\t\t\t`Invalid required script entry: expected single key-value pair, got ${keys.length} keys`,\n\t\t);\n\t}\n\t// biome-ignore lint/style/noNonNullAssertion: we verified length is 1\n\tconst name = keys[0]!;\n\tconst defaultValue = entry[name];\n\treturn defaultValue !== undefined ? { name, defaultValue } : { name };\n}\n\ninterface ValidationResult {\n\tmissingScripts: string[];\n\tmissingWithDefaults: Array<{ name: string; defaultValue: string }>;\n}\n\nfunction validateRequiredScripts(\n\tscripts: Record<string, string | undefined>,\n\trequiredEntries: RequiredScriptEntry[],\n): ValidationResult {\n\tconst missingScripts: string[] = [];\n\tconst missingWithDefaults: Array<{ name: string; defaultValue: string }> = [];\n\n\tfor (const entry of requiredEntries) {\n\t\tconst { name, defaultValue } = parseRequiredEntry(entry);\n\t\tif (!Object.hasOwn(scripts, name)) {\n\t\t\tmissingScripts.push(name);\n\t\t\tif (defaultValue !== undefined) {\n\t\t\t\tmissingWithDefaults.push({ name, defaultValue });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { missingScripts, missingWithDefaults };\n}\n\nasync function fixMissingScripts(\n\tjson: PackageJson,\n\tfile: string,\n\tmissingWithDefaults: Array<{ name: string; defaultValue: string }>,\n\texistingScripts: Record<string, string | undefined>,\n): Promise<string[]> {\n\tconst updatedScripts: Record<string, string> = {};\n\n\t// Copy existing scripts\n\tfor (const [key, value] of Object.entries(existingScripts)) {\n\t\tif (value !== undefined) {\n\t\t\tupdatedScripts[key] = value;\n\t\t}\n\t}\n\n\t// Add missing scripts with defaults\n\tconst fixedScripts: string[] = [];\n\tfor (const { name, defaultValue } of missingWithDefaults) {\n\t\tupdatedScripts[name] = defaultValue;\n\t\tfixedScripts.push(name);\n\t}\n\n\tawait jsonfile.writeFile(\n\t\tfile,\n\t\t{ ...json, scripts: updatedScripts },\n\t\t{ spaces: 2 },\n\t);\n\n\treturn fixedScripts;\n}\n\n/**\n * A policy that validates required scripts exist in package.json.\n *\n * @remarks\n * Use this policy when you want to ensure specific scripts are present.\n * Scripts can be specified with optional default values that enable auto-fix.\n *\n * Note: This policy only checks for script presence. It does NOT validate\n * the script's content. Use ExactScripts for content validation.\n *\n * @example\n * ```typescript\n * import { policy } from \"repopo\";\n * import { RequiredScripts } from \"repopo/policies\";\n *\n * policy(RequiredScripts, {\n * scripts: [\n * \"test\", // Must exist, no auto-fix\n * { lint: \"biome lint .\" }, // Must exist, auto-fix adds default if missing\n * { clean: \"rimraf dist esm\" }, // Must exist, auto-fix adds default if missing\n * ],\n * })\n * ```\n *\n * @alpha\n */\nexport const RequiredScripts = definePackagePolicy<\n\tPackageJson,\n\tRequiredScriptsConfig | undefined\n>({\n\tname: POLICY_NAME,\n\tdescription: \"Validates that required scripts exist in package.json.\",\n\thandler: async (json, { file, root, resolve, config }) => {\n\t\tif (config === undefined || config.scripts.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst scripts = json.scripts ?? {};\n\t\tconst validation = validateRequiredScripts(scripts, config.scripts);\n\n\t\tif (validation.missingScripts.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst hasAutoFixableErrors = validation.missingWithDefaults.length > 0;\n\n\t\tif (resolve && hasAutoFixableErrors) {\n\t\t\ttry {\n\t\t\t\tconst fixedScripts = await fixMissingScripts(\n\t\t\t\t\tjson,\n\t\t\t\t\tresolvePath(root, file),\n\t\t\t\t\tvalidation.missingWithDefaults,\n\t\t\t\t\tscripts,\n\t\t\t\t);\n\n\t\t\t\t// Check if there are still missing scripts (those without defaults)\n\t\t\t\tconst stillMissing = validation.missingScripts.filter(\n\t\t\t\t\t(name) => !fixedScripts.includes(name),\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\tname: POLICY_NAME,\n\t\t\t\t\tfile,\n\t\t\t\t\tresolved: stillMissing.length === 0,\n\t\t\t\t\terrorMessages:\n\t\t\t\t\t\tstillMissing.length > 0\n\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t`Fixed scripts: ${fixedScripts.join(\", \")}. Still missing: ${stillMissing.join(\", \")}`,\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t: [`Fixed scripts: ${fixedScripts.join(\", \")}`],\n\t\t\t\t};\n\t\t\t} catch {\n\t\t\t\t// Fall through to return regular failure\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tname: POLICY_NAME,\n\t\t\tfile,\n\t\t\tautoFixable: hasAutoFixableErrors,\n\t\t\terrorMessages: [\n\t\t\t\t`Missing required scripts:\\n\\t${validation.missingScripts.join(\"\\n\\t\")}`,\n\t\t\t],\n\t\t};\n\t},\n});\n"]}
|
|
1
|
+
{"version":3,"file":"RequiredScripts.js","sourceRoot":"","sources":["../../src/policies/RequiredScripts.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AA+C/E,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAOtC;;GAEG;AACH,SAAS,kBAAkB,CAAC,KAA0B;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACxB,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACd,sEAAsE,IAAI,CAAC,MAAM,OAAO,CACxF,CAAC;IACH,CAAC;IACD,sEAAsE;IACtE,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC;IACtB,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;AACvE,CAAC;AAUD,SAAS,uBAAuB,CAC/B,OAA2C,EAC3C,eAAsC;IAEtC,MAAM,cAAc,GAAa,EAAE,CAAC;IACpC,MAAM,mBAAmB,GAGpB,EAAE,CAAC;IACR,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;QACrC,MAAM,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C,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;wBAC9B,OAAO,EAAE,kBAAkB,IAAI,EAAE;qBACjC,CAAC,CAAC;iBACH,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACR,yCAAyC;YAC1C,CAAC;QACF,CAAC;QACD,OAAO,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC/C,OAAO,EAAE,gCAAgC,IAAI,EAAE;YAC/C,SAAS,EAAE,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAC7C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAC9B;gBACA,CAAC,CAAC,OAAO;oBACR,CAAC,CAAC,QAAQ;oBACV,CAAC,CAAC,WAAW;gBACd,CAAC,CAAC,SAAS;SACZ,CAAC,CAAC,CAAC;IACL,CAAC;CACD,CAAC,CAAC","sourcesContent":["import jsonfile from \"jsonfile\";\nimport { resolve as resolvePath } from \"pathe\";\nimport type { PackageJson } from \"type-fest\";\nimport { definePackagePolicy } from \"../policyDefiners/definePackagePolicy.js\";\n\n/**\n * A required script entry. Can be either:\n * - A string (script name only, no default value)\n * - An object with a single key-value pair (script name → default value for auto-fix)\n *\n * @example\n * ```typescript\n * // Script must exist, no auto-fix available\n * \"test\"\n *\n * // Script must exist, auto-fix will add this value if missing\n * { lint: \"biome lint .\" }\n * ```\n *\n * @public\n */\nexport type RequiredScriptEntry = string | Record<string, string>;\n\n/**\n * Configuration for the RequiredScripts policy.\n *\n * @public\n */\nexport interface RequiredScriptsConfig {\n\t/**\n\t * Scripts that must be present in package.json.\n\t *\n\t * @remarks\n\t * Each entry can be:\n\t * - A string: Script must exist, no auto-fix available, content not validated\n\t * - An object `{ scriptName: \"default value\" }`: Script must exist, auto-fix adds the\n\t * default value if missing, but existing scripts with different content still pass\n\t *\n\t * @example\n\t * ```typescript\n\t * scripts: [\n\t * \"test\", // Must exist, no auto-fix\n\t * { lint: \"biome lint .\" }, // Must exist, auto-fix available\n\t * { clean: \"rimraf dist esm\" }, // Must exist, auto-fix available\n\t * ]\n\t * ```\n\t */\n\tscripts: RequiredScriptEntry[];\n}\n\nconst POLICY_NAME = \"RequiredScripts\";\n\ninterface ParsedEntry {\n\tname: string;\n\tdefaultValue?: string;\n}\n\n/**\n * Extracts script name and optional default value from a RequiredScriptEntry.\n */\nfunction parseRequiredEntry(entry: RequiredScriptEntry): ParsedEntry {\n\tif (typeof entry === \"string\") {\n\t\treturn { name: entry };\n\t}\n\tconst keys = Object.keys(entry);\n\tif (keys.length !== 1) {\n\t\tthrow new Error(\n\t\t\t`Invalid required script entry: expected single key-value pair, got ${keys.length} keys`,\n\t\t);\n\t}\n\t// biome-ignore lint/style/noNonNullAssertion: we verified length is 1\n\tconst name = keys[0]!;\n\tconst defaultValue = entry[name];\n\treturn defaultValue !== undefined ? { name, defaultValue } : { name };\n}\n\ninterface ValidationResult {\n\tmissingScripts: string[];\n\tmissingWithDefaults: Array<{\n\t\tname: string;\n\t\tdefaultValue: string;\n\t}>;\n}\n\nfunction validateRequiredScripts(\n\tscripts: Record<string, string | undefined>,\n\trequiredEntries: RequiredScriptEntry[],\n): ValidationResult {\n\tconst missingScripts: string[] = [];\n\tconst missingWithDefaults: Array<{\n\t\tname: string;\n\t\tdefaultValue: string;\n\t}> = [];\n\tfor (const entry of requiredEntries) {\n\t\tconst { name, defaultValue } = parseRequiredEntry(entry);\n\t\tif (!Object.hasOwn(scripts, name)) {\n\t\t\tmissingScripts.push(name);\n\t\t\tif (defaultValue !== undefined) {\n\t\t\t\tmissingWithDefaults.push({ name, defaultValue });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { missingScripts, missingWithDefaults };\n}\n\nasync function fixMissingScripts(\n\tjson: PackageJson,\n\tfile: string,\n\tmissingWithDefaults: Array<{\n\t\tname: string;\n\t\tdefaultValue: string;\n\t}>,\n\texistingScripts: Record<string, string | undefined>,\n): Promise<string[]> {\n\tconst updatedScripts: Record<string, string> = {};\n\n\t// Copy existing scripts\n\tfor (const [key, value] of Object.entries(existingScripts)) {\n\t\tif (value !== undefined) {\n\t\t\tupdatedScripts[key] = value;\n\t\t}\n\t}\n\n\t// Add missing scripts with defaults\n\tconst fixedScripts: string[] = [];\n\tfor (const { name, defaultValue } of missingWithDefaults) {\n\t\tupdatedScripts[name] = defaultValue;\n\t\tfixedScripts.push(name);\n\t}\n\n\tawait jsonfile.writeFile(\n\t\tfile,\n\t\t{ ...json, scripts: updatedScripts },\n\t\t{ spaces: 2 },\n\t);\n\n\treturn fixedScripts;\n}\n\n/**\n * A policy that validates required scripts exist in package.json.\n *\n * @remarks\n * Use this policy when you want to ensure specific scripts are present.\n * Scripts can be specified with optional default values that enable auto-fix.\n *\n * Note: This policy only checks for script presence. It does NOT validate\n * the script's content. Use ExactScripts for content validation.\n *\n * @example\n * ```typescript\n * import { makePolicy } from \"repopo\";\n * import { RequiredScripts } from \"repopo/policies\";\n *\n * makePolicy(RequiredScripts, { config: {\n * scripts: [\n * \"test\", // Must exist, no auto-fix\n * { lint: \"biome lint .\" }, // Must exist, auto-fix adds default if missing\n * { clean: \"rimraf dist esm\" }, // Must exist, auto-fix adds default if missing\n * ],\n * } })\n * ```\n *\n * @public\n */\nexport const RequiredScripts = definePackagePolicy<\n\tPackageJson,\n\tRequiredScriptsConfig | undefined\n>({\n\trequiresConfig: true,\n\tname: POLICY_NAME,\n\tdescription: \"Validates that required scripts exist in package.json.\",\n\thandler: async (json, { file, root, resolve, config }) => {\n\t\tif (config === undefined || config.scripts.length === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst scripts = json.scripts ?? {};\n\t\tconst validation = validateRequiredScripts(scripts, config.scripts);\n\n\t\tif (validation.missingScripts.length === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst hasAutoFixableErrors = validation.missingWithDefaults.length > 0;\n\n\t\tif (resolve && hasAutoFixableErrors) {\n\t\t\ttry {\n\t\t\t\tconst fixedScripts = await fixMissingScripts(\n\t\t\t\t\tjson,\n\t\t\t\t\tresolvePath(root, file),\n\t\t\t\t\tvalidation.missingWithDefaults,\n\t\t\t\t\tscripts,\n\t\t\t\t);\n\n\t\t\t\t// Check if there are still missing scripts (those without defaults)\n\t\t\t\tconst stillMissing = validation.missingScripts.filter(\n\t\t\t\t\t(name) => !fixedScripts.includes(name),\n\t\t\t\t);\n\t\t\t\treturn [\n\t\t\t\t\t...fixedScripts.map((name) => ({\n\t\t\t\t\t\tmessage: `Fixed scripts: ${name}`,\n\t\t\t\t\t\tfixStatus: \"fixed\" as const,\n\t\t\t\t\t})),\n\t\t\t\t\t...stillMissing.map((name) => ({\n\t\t\t\t\t\tmessage: `Still missing: ${name}`,\n\t\t\t\t\t})),\n\t\t\t\t];\n\t\t\t} catch {\n\t\t\t\t// Fall through to return regular failure\n\t\t\t}\n\t\t}\n\t\treturn validation.missingScripts.map((name) => ({\n\t\t\tmessage: `Missing required scripts:\\n\\t${name}`,\n\t\t\tfixStatus: validation.missingWithDefaults.some(\n\t\t\t\t(entry) => entry.name === name,\n\t\t\t)\n\t\t\t\t? resolve\n\t\t\t\t\t? \"failed\"\n\t\t\t\t\t: \"available\"\n\t\t\t\t: undefined,\n\t\t}));\n\t},\n});\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FilePolicyDefinition } from "../policy.js";
|
|
2
2
|
/**
|
|
3
3
|
* Configuration for the RustDocExists policy.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
5
|
+
* @public
|
|
6
6
|
*/
|
|
7
7
|
export interface RustDocExistsConfig {
|
|
8
8
|
/**
|
|
@@ -18,7 +18,7 @@ export interface RustDocExistsConfig {
|
|
|
18
18
|
/**
|
|
19
19
|
* A policy that validates documentation files exist for Rust crates.
|
|
20
20
|
*
|
|
21
|
-
* @
|
|
21
|
+
* @public
|
|
22
22
|
*/
|
|
23
|
-
export declare const RustDocExists:
|
|
23
|
+
export declare const RustDocExists: FilePolicyDefinition<RustDocExistsConfig>;
|
|
24
24
|
//# sourceMappingURL=RustDocExists.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RustDocExists.d.ts","sourceRoot":"","sources":["../../src/policies/RustDocExists.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"RustDocExists.d.ts","sourceRoot":"","sources":["../../src/policies/RustDocExists.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMzD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAID;;;;GAIG;AACH,eAAO,MAAM,aAAa,2CAkD4B,CAAC"}
|
|
@@ -5,7 +5,7 @@ const DEFAULT_REQUIRED = ["README.md"];
|
|
|
5
5
|
/**
|
|
6
6
|
* A policy that validates documentation files exist for Rust crates.
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
8
|
+
* @public
|
|
9
9
|
*/
|
|
10
10
|
export const RustDocExists = defineCargoPolicy({
|
|
11
11
|
name: "RustDocExists",
|
|
@@ -13,7 +13,7 @@ export const RustDocExists = defineCargoPolicy({
|
|
|
13
13
|
handler: async (toml, { file, root, config }) => {
|
|
14
14
|
// Skip workspace root
|
|
15
15
|
if (toml.workspace !== undefined && toml.package === undefined) {
|
|
16
|
-
return
|
|
16
|
+
return [];
|
|
17
17
|
}
|
|
18
18
|
const dir = path.dirname(path.resolve(root, file));
|
|
19
19
|
const required = config?.required ?? DEFAULT_REQUIRED;
|
|
@@ -38,12 +38,12 @@ export const RustDocExists = defineCargoPolicy({
|
|
|
38
38
|
errors.push(`Missing recommended documentation: ${missingRecommended.join(", ")}`);
|
|
39
39
|
}
|
|
40
40
|
if (errors.length > 0) {
|
|
41
|
-
return {
|
|
42
|
-
|
|
41
|
+
return errors.map((message) => ({
|
|
42
|
+
message,
|
|
43
43
|
manualFix: "Create the missing documentation files alongside Cargo.toml.",
|
|
44
|
-
};
|
|
44
|
+
}));
|
|
45
45
|
}
|
|
46
|
-
return
|
|
46
|
+
return [];
|
|
47
47
|
},
|
|
48
48
|
});
|
|
49
49
|
//# sourceMappingURL=RustDocExists.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RustDocExists.js","sourceRoot":"","sources":["../../src/policies/RustDocExists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,OAAO,CAAC;AAEzB,OAAO,EAEN,iBAAiB,GACjB,MAAM,wCAAwC,CAAC;AAoBhD,MAAM,gBAAgB,GAAG,CAAC,WAAW,CAAC,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"RustDocExists.js","sourceRoot":"","sources":["../../src/policies/RustDocExists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,OAAO,CAAC;AAEzB,OAAO,EAEN,iBAAiB,GACjB,MAAM,wCAAwC,CAAC;AAoBhD,MAAM,gBAAgB,GAAG,CAAC,WAAW,CAAC,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;IAC9C,IAAI,EAAE,eAAe;IACrB,WAAW,EACV,6EAA6E;IAC9E,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;QAC1D,sBAAsB;QACtB,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAChE,OAAO,EAAE,CAAC;QACX,CAAC;QAED,MA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,OAAO;gBACP,SAAS,EACR,8DAA8D;aAC/D,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD,CAAqD,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport path from \"pathe\";\nimport type { FilePolicyDefinition } from \"../policy.js\";\nimport {\n\ttype CargoToml,\n\tdefineCargoPolicy,\n} from \"../policyDefiners/defineCargoPolicy.js\";\n\n/**\n * Configuration for the RustDocExists policy.\n *\n * @public\n */\nexport interface RustDocExistsConfig {\n\t/**\n\t * Files that must exist alongside the Cargo.toml.\n\t * @defaultValue [\"README.md\"]\n\t */\n\trequired?: string[];\n\n\t/**\n\t * Files that are recommended but not required. Missing ones produce warnings.\n\t */\n\trecommended?: string[];\n}\n\nconst DEFAULT_REQUIRED = [\"README.md\"];\n\n/**\n * A policy that validates documentation files exist for Rust crates.\n *\n * @public\n */\nexport const RustDocExists = defineCargoPolicy({\n\tname: \"RustDocExists\",\n\tdescription:\n\t\t\"Validates that documentation files (README.md, etc.) exist for Rust crates.\",\n\thandler: async (toml: CargoToml, { file, root, config }) => {\n\t\t// Skip workspace root\n\t\tif (toml.workspace !== undefined && toml.package === undefined) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst dir = path.dirname(path.resolve(root, file));\n\t\tconst required = config?.required ?? DEFAULT_REQUIRED;\n\t\tconst recommended = config?.recommended ?? [];\n\n\t\tconst missingRequired: string[] = [];\n\t\tconst missingRecommended: string[] = [];\n\n\t\tfor (const fileName of required) {\n\t\t\tif (!existsSync(path.join(dir, fileName))) {\n\t\t\t\tmissingRequired.push(fileName);\n\t\t\t}\n\t\t}\n\n\t\tfor (const fileName of recommended) {\n\t\t\tif (!existsSync(path.join(dir, fileName))) {\n\t\t\t\tmissingRecommended.push(fileName);\n\t\t\t}\n\t\t}\n\n\t\tconst errors: string[] = [];\n\t\tif (missingRequired.length > 0) {\n\t\t\terrors.push(\n\t\t\t\t`Missing required documentation: ${missingRequired.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t\tif (missingRecommended.length > 0) {\n\t\t\terrors.push(\n\t\t\t\t`Missing recommended documentation: ${missingRecommended.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\tif (errors.length > 0) {\n\t\t\treturn errors.map((message) => ({\n\t\t\t\tmessage,\n\t\t\t\tmanualFix:\n\t\t\t\t\t\"Create the missing documentation files alongside Cargo.toml.\",\n\t\t\t}));\n\t\t}\n\t\treturn [];\n\t},\n}) satisfies FilePolicyDefinition<RustDocExistsConfig>;\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { PolicyDefinition } from "../policy.js";
|
|
2
1
|
/**
|
|
3
2
|
* Configuration for the RustToolchainExists policy.
|
|
4
3
|
*
|
|
5
|
-
* @
|
|
4
|
+
* @public
|
|
6
5
|
*/
|
|
7
6
|
export interface RustToolchainExistsConfig {
|
|
8
7
|
/**
|
|
@@ -14,7 +13,15 @@ export interface RustToolchainExistsConfig {
|
|
|
14
13
|
/**
|
|
15
14
|
* A policy that requires a rust-toolchain.toml file for reproducible Rust builds.
|
|
16
15
|
*
|
|
17
|
-
* @
|
|
16
|
+
* @public
|
|
18
17
|
*/
|
|
19
|
-
export declare const RustToolchainExists:
|
|
18
|
+
export declare const RustToolchainExists: {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
match: RegExp;
|
|
22
|
+
handler: ({ root, config }: import("../policy.js").PolicyArgs<RustToolchainExistsConfig>) => Promise<{
|
|
23
|
+
message: string;
|
|
24
|
+
manualFix: string;
|
|
25
|
+
}[]>;
|
|
26
|
+
};
|
|
20
27
|
//# sourceMappingURL=RustToolchainExists.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RustToolchainExists.d.ts","sourceRoot":"","sources":["../../src/policies/RustToolchainExists.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"RustToolchainExists.d.ts","sourceRoot":"","sources":["../../src/policies/RustToolchainExists.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACzC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAID;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;CAuB2B,CAAC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import path from "pathe";
|
|
3
|
-
import { makePolicyDefinition } from "../makePolicy.js";
|
|
4
3
|
const DEFAULT_NAMES = ["rust-toolchain.toml", "rust-toolchain"];
|
|
5
4
|
/**
|
|
6
5
|
* A policy that requires a rust-toolchain.toml file for reproducible Rust builds.
|
|
7
6
|
*
|
|
8
|
-
* @
|
|
7
|
+
* @public
|
|
9
8
|
*/
|
|
10
|
-
export const RustToolchainExists =
|
|
9
|
+
export const RustToolchainExists = {
|
|
11
10
|
name: "RustToolchainExists",
|
|
12
11
|
description: "Ensures a rust-toolchain.toml file exists for reproducible Rust builds.",
|
|
13
12
|
// Trigger on Cargo.toml to check once per project
|
|
@@ -16,12 +15,14 @@ export const RustToolchainExists = makePolicyDefinition({
|
|
|
16
15
|
const names = config?.acceptedNames ?? DEFAULT_NAMES;
|
|
17
16
|
const hasToolchain = names.some((name) => existsSync(path.join(root, name)));
|
|
18
17
|
if (hasToolchain) {
|
|
19
|
-
return
|
|
18
|
+
return [];
|
|
20
19
|
}
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
message: `No rust-toolchain file found. Expected one of: ${names.join(", ")}`,
|
|
23
|
+
manualFix: "Create a rust-toolchain.toml file specifying the Rust toolchain version.",
|
|
24
|
+
},
|
|
25
|
+
];
|
|
25
26
|
},
|
|
26
|
-
}
|
|
27
|
+
};
|
|
27
28
|
//# sourceMappingURL=RustToolchainExists.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RustToolchainExists.js","sourceRoot":"","sources":["../../src/policies/RustToolchainExists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"RustToolchainExists.js","sourceRoot":"","sources":["../../src/policies/RustToolchainExists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,OAAO,CAAC;AAezB,MAAM,aAAa,GAAG,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,CAAC;AAEhE;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAClC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EACV,yEAAyE;IAC1E,kDAAkD;IAClD,KAAK,EAAE,eAAe;IACtB,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;QACnC,MAAM,KAAK,GAAG,MAAM,EAAE,aAAa,IAAI,aAAa,CAAC;QACrD,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CACxC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CACjC,CAAC;QAEF,IAAI,YAAY,EAAE,CAAC;YAClB,OAAO,EAAE,CAAC;QACX,CAAC;QACD,OAAO;YACN;gBACC,OAAO,EAAE,kDAAkD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBAC7E,SAAS,EACR,0EAA0E;aAC3E;SACD,CAAC;IACH,CAAC;CACyD,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport path from \"pathe\";\nimport type { FilePolicyDefinition } from \"../policy.js\";\n/**\n * Configuration for the RustToolchainExists policy.\n *\n * @public\n */\nexport interface RustToolchainExistsConfig {\n\t/**\n\t * Accepted file names for the toolchain file.\n\t * @defaultValue [\"rust-toolchain.toml\", \"rust-toolchain\"]\n\t */\n\tacceptedNames?: string[];\n}\n\nconst DEFAULT_NAMES = [\"rust-toolchain.toml\", \"rust-toolchain\"];\n\n/**\n * A policy that requires a rust-toolchain.toml file for reproducible Rust builds.\n *\n * @public\n */\nexport const RustToolchainExists = {\n\tname: \"RustToolchainExists\",\n\tdescription:\n\t\t\"Ensures a rust-toolchain.toml file exists for reproducible Rust builds.\",\n\t// Trigger on Cargo.toml to check once per project\n\tmatch: /^Cargo\\.toml$/,\n\thandler: async ({ root, config }) => {\n\t\tconst names = config?.acceptedNames ?? DEFAULT_NAMES;\n\t\tconst hasToolchain = names.some((name) =>\n\t\t\texistsSync(path.join(root, name)),\n\t\t);\n\n\t\tif (hasToolchain) {\n\t\t\treturn [];\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\tmessage: `No rust-toolchain file found. Expected one of: ${names.join(\", \")}`,\n\t\t\t\tmanualFix:\n\t\t\t\t\t\"Create a rust-toolchain.toml file specifying the Rust toolchain version.\",\n\t\t\t},\n\t\t];\n\t},\n} satisfies FilePolicyDefinition<RustToolchainExistsConfig>;\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { PolicyDefinition } from "../policy.js";
|
|
2
1
|
/**
|
|
3
2
|
* Configuration for the RustfmtConfigExists policy.
|
|
4
3
|
*
|
|
5
|
-
* @
|
|
4
|
+
* @public
|
|
6
5
|
*/
|
|
7
6
|
export interface RustfmtConfigExistsConfig {
|
|
8
7
|
/**
|
|
@@ -14,7 +13,15 @@ export interface RustfmtConfigExistsConfig {
|
|
|
14
13
|
/**
|
|
15
14
|
* A policy that requires a rustfmt.toml file for consistent Rust formatting.
|
|
16
15
|
*
|
|
17
|
-
* @
|
|
16
|
+
* @public
|
|
18
17
|
*/
|
|
19
|
-
export declare const RustfmtConfigExists:
|
|
18
|
+
export declare const RustfmtConfigExists: {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
match: RegExp;
|
|
22
|
+
handler: ({ root, config }: import("../policy.js").PolicyArgs<RustfmtConfigExistsConfig>) => Promise<{
|
|
23
|
+
message: string;
|
|
24
|
+
manualFix: string;
|
|
25
|
+
}[]>;
|
|
26
|
+
};
|
|
20
27
|
//# sourceMappingURL=RustfmtConfigExists.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RustfmtConfigExists.d.ts","sourceRoot":"","sources":["../../src/policies/RustfmtConfigExists.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"RustfmtConfigExists.d.ts","sourceRoot":"","sources":["../../src/policies/RustfmtConfigExists.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACzC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAID;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;CAoB2B,CAAC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import path from "pathe";
|
|
3
|
-
import { makePolicyDefinition } from "../makePolicy.js";
|
|
4
3
|
const DEFAULT_NAMES = ["rustfmt.toml", ".rustfmt.toml"];
|
|
5
4
|
/**
|
|
6
5
|
* A policy that requires a rustfmt.toml file for consistent Rust formatting.
|
|
7
6
|
*
|
|
8
|
-
* @
|
|
7
|
+
* @public
|
|
9
8
|
*/
|
|
10
|
-
export const RustfmtConfigExists =
|
|
9
|
+
export const RustfmtConfigExists = {
|
|
11
10
|
name: "RustfmtConfigExists",
|
|
12
11
|
description: "Ensures a rustfmt.toml file exists for consistent Rust formatting.",
|
|
13
12
|
// Trigger on Cargo.toml to check once per project
|
|
@@ -16,12 +15,14 @@ export const RustfmtConfigExists = makePolicyDefinition({
|
|
|
16
15
|
const names = config?.acceptedNames ?? DEFAULT_NAMES;
|
|
17
16
|
const hasConfig = names.some((name) => existsSync(path.join(root, name)));
|
|
18
17
|
if (hasConfig) {
|
|
19
|
-
return
|
|
18
|
+
return [];
|
|
20
19
|
}
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
message: `No rustfmt config found. Expected one of: ${names.join(", ")}`,
|
|
23
|
+
manualFix: "Create a rustfmt.toml file to configure Rust formatting.",
|
|
24
|
+
},
|
|
25
|
+
];
|
|
25
26
|
},
|
|
26
|
-
}
|
|
27
|
+
};
|
|
27
28
|
//# sourceMappingURL=RustfmtConfigExists.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RustfmtConfigExists.js","sourceRoot":"","sources":["../../src/policies/RustfmtConfigExists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"RustfmtConfigExists.js","sourceRoot":"","sources":["../../src/policies/RustfmtConfigExists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,OAAO,CAAC;AAezB,MAAM,aAAa,GAAG,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAClC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EACV,oEAAoE;IACrE,kDAAkD;IAClD,KAAK,EAAE,eAAe;IACtB,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;QACnC,MAAM,KAAK,GAAG,MAAM,EAAE,aAAa,IAAI,aAAa,CAAC;QACrD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAE1E,IAAI,SAAS,EAAE,CAAC;YACf,OAAO,EAAE,CAAC;QACX,CAAC;QACD,OAAO;YACN;gBACC,OAAO,EAAE,6CAA6C,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBACxE,SAAS,EAAE,0DAA0D;aACrE;SACD,CAAC;IACH,CAAC;CACyD,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport path from \"pathe\";\nimport type { FilePolicyDefinition } from \"../policy.js\";\n/**\n * Configuration for the RustfmtConfigExists policy.\n *\n * @public\n */\nexport interface RustfmtConfigExistsConfig {\n\t/**\n\t * Accepted file names for the rustfmt config.\n\t * @defaultValue [\"rustfmt.toml\", \".rustfmt.toml\"]\n\t */\n\tacceptedNames?: string[];\n}\n\nconst DEFAULT_NAMES = [\"rustfmt.toml\", \".rustfmt.toml\"];\n\n/**\n * A policy that requires a rustfmt.toml file for consistent Rust formatting.\n *\n * @public\n */\nexport const RustfmtConfigExists = {\n\tname: \"RustfmtConfigExists\",\n\tdescription:\n\t\t\"Ensures a rustfmt.toml file exists for consistent Rust formatting.\",\n\t// Trigger on Cargo.toml to check once per project\n\tmatch: /^Cargo\\.toml$/,\n\thandler: async ({ root, config }) => {\n\t\tconst names = config?.acceptedNames ?? DEFAULT_NAMES;\n\t\tconst hasConfig = names.some((name) => existsSync(path.join(root, name)));\n\n\t\tif (hasConfig) {\n\t\t\treturn [];\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\tmessage: `No rustfmt config found. Expected one of: ${names.join(\", \")}`,\n\t\t\t\tmanualFix: \"Create a rustfmt.toml file to configure Rust formatting.\",\n\t\t\t},\n\t\t];\n\t},\n} satisfies FilePolicyDefinition<RustfmtConfigExistsConfig>;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration for validating that a script's body contains required substrings.
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
4
|
+
* @public
|
|
5
5
|
*/
|
|
6
6
|
export interface ScriptContainsRule {
|
|
7
7
|
/**
|
|
@@ -17,7 +17,7 @@ export interface ScriptContainsRule {
|
|
|
17
17
|
/**
|
|
18
18
|
* Configuration for the ScriptContains policy.
|
|
19
19
|
*
|
|
20
|
-
* @
|
|
20
|
+
* @public
|
|
21
21
|
*/
|
|
22
22
|
export interface ScriptContainsConfig {
|
|
23
23
|
/**
|
|
@@ -46,19 +46,21 @@ export interface ScriptContainsConfig {
|
|
|
46
46
|
*
|
|
47
47
|
* @example
|
|
48
48
|
* ```typescript
|
|
49
|
-
* import {
|
|
49
|
+
* import { makePolicy } from "repopo";
|
|
50
50
|
* import { ScriptContains } from "repopo/policies";
|
|
51
51
|
*
|
|
52
|
-
*
|
|
52
|
+
* makePolicy(ScriptContains, { config: {
|
|
53
53
|
* rules: [
|
|
54
54
|
* { script: "clean", mustContain: ["rimraf"] },
|
|
55
55
|
* { script: "build", mustContain: ["tsc"] },
|
|
56
56
|
* { script: "test", mustContain: ["vitest", "run"] },
|
|
57
57
|
* ],
|
|
58
|
-
* })
|
|
58
|
+
* } })
|
|
59
59
|
* ```
|
|
60
60
|
*
|
|
61
|
-
* @
|
|
61
|
+
* @public
|
|
62
62
|
*/
|
|
63
|
-
export declare const ScriptContains: import("../policy.js").
|
|
63
|
+
export declare const ScriptContains: import("../policy.js").FilePolicyDefinition<ScriptContainsConfig | undefined> & {
|
|
64
|
+
requiresConfig: true;
|
|
65
|
+
};
|
|
64
66
|
//# sourceMappingURL=ScriptContains.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptContains.d.ts","sourceRoot":"","sources":["../../src/policies/ScriptContains.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;;;;;;;;OAUG;IACH,KAAK,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"ScriptContains.d.ts","sourceRoot":"","sources":["../../src/policies/ScriptContains.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;;;;;;;;OAUG;IACH,KAAK,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,cAAc;;CAsCzB,CAAC"}
|
|
@@ -13,26 +13,27 @@ const POLICY_NAME = "ScriptContains";
|
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* ```typescript
|
|
16
|
-
* import {
|
|
16
|
+
* import { makePolicy } from "repopo";
|
|
17
17
|
* import { ScriptContains } from "repopo/policies";
|
|
18
18
|
*
|
|
19
|
-
*
|
|
19
|
+
* makePolicy(ScriptContains, { config: {
|
|
20
20
|
* rules: [
|
|
21
21
|
* { script: "clean", mustContain: ["rimraf"] },
|
|
22
22
|
* { script: "build", mustContain: ["tsc"] },
|
|
23
23
|
* { script: "test", mustContain: ["vitest", "run"] },
|
|
24
24
|
* ],
|
|
25
|
-
* })
|
|
25
|
+
* } })
|
|
26
26
|
* ```
|
|
27
27
|
*
|
|
28
|
-
* @
|
|
28
|
+
* @public
|
|
29
29
|
*/
|
|
30
30
|
export const ScriptContains = definePackagePolicy({
|
|
31
|
+
requiresConfig: true,
|
|
31
32
|
name: POLICY_NAME,
|
|
32
33
|
description: "Validates that script bodies contain required substrings.",
|
|
33
|
-
handler: async (json, {
|
|
34
|
+
handler: async (json, { config }) => {
|
|
34
35
|
if (config === undefined || config.rules.length === 0) {
|
|
35
|
-
return
|
|
36
|
+
return [];
|
|
36
37
|
}
|
|
37
38
|
const scripts = json.scripts ?? {};
|
|
38
39
|
const errors = [];
|
|
@@ -49,14 +50,9 @@ export const ScriptContains = definePackagePolicy({
|
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
if (errors.length === 0) {
|
|
52
|
-
return
|
|
53
|
+
return [];
|
|
53
54
|
}
|
|
54
|
-
return {
|
|
55
|
-
name: POLICY_NAME,
|
|
56
|
-
file,
|
|
57
|
-
autoFixable: false,
|
|
58
|
-
errorMessages: errors,
|
|
59
|
-
};
|
|
55
|
+
return errors.map((message) => ({ message }));
|
|
60
56
|
},
|
|
61
57
|
});
|
|
62
58
|
//# sourceMappingURL=ScriptContains.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptContains.js","sourceRoot":"","sources":["../../src/policies/ScriptContains.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAwC/E,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAG/C;IACD,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,2DAA2D;IACxE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"ScriptContains.js","sourceRoot":"","sources":["../../src/policies/ScriptContains.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAwC/E,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAG/C;IACD,cAAc,EAAE,IAAI;IACpB,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,2DAA2D;IACxE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QACnC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvD,OAAO,EAAE,CAAC;QACX,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QACnC,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjC,qCAAqC;YACrC,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBACzC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACxC,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;oBACpC,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAChD,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAC9C,CAAC;oBAEF,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAClC,MAAM,CAAC,IAAI,CACV,WAAW,IAAI,CAAC,MAAM,mBAAmB,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACvE,CAAC;oBACH,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,EAAE,CAAC;QACX,CAAC;QACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;CACD,CAAC,CAAC","sourcesContent":["import type { PackageJson } from \"type-fest\";\nimport { definePackagePolicy } from \"../policyDefiners/definePackagePolicy.js\";\n\n/**\n * Configuration for validating that a script's body contains required substrings.\n *\n * @public\n */\nexport interface ScriptContainsRule {\n\t/**\n\t * The name of the script to validate.\n\t */\n\tscript: string;\n\n\t/**\n\t * Substrings that must appear in the script body.\n\t * All substrings must be present for the script to pass validation.\n\t */\n\tmustContain: string[];\n}\n\n/**\n * Configuration for the ScriptContains policy.\n *\n * @public\n */\nexport interface ScriptContainsConfig {\n\t/**\n\t * Rules for validating script body content.\n\t *\n\t * @example\n\t * ```typescript\n\t * rules: [\n\t * { script: \"clean\", mustContain: [\"rimraf\"] },\n\t * { script: \"build\", mustContain: [\"tsc\"] },\n\t * ]\n\t * ```\n\t */\n\trules: ScriptContainsRule[];\n}\n\nconst POLICY_NAME = \"ScriptContains\";\n\n/**\n * A policy that validates script bodies contain required substrings.\n *\n * @remarks\n * Use this policy to ensure specific scripts contain required commands or patterns\n * without requiring an exact match. For example, requiring that the \"clean\" script\n * uses \"rimraf\" or that \"build\" includes \"tsc\".\n *\n * The policy only validates scripts that exist. If a script doesn't exist,\n * it's not an error (use RequiredScripts for that).\n *\n * @example\n * ```typescript\n * import { makePolicy } from \"repopo\";\n * import { ScriptContains } from \"repopo/policies\";\n *\n * makePolicy(ScriptContains, { config: {\n * rules: [\n * { script: \"clean\", mustContain: [\"rimraf\"] },\n * { script: \"build\", mustContain: [\"tsc\"] },\n * { script: \"test\", mustContain: [\"vitest\", \"run\"] },\n * ],\n * } })\n * ```\n *\n * @public\n */\nexport const ScriptContains = definePackagePolicy<\n\tPackageJson,\n\tScriptContainsConfig | undefined\n>({\n\trequiresConfig: true,\n\tname: POLICY_NAME,\n\tdescription: \"Validates that script bodies contain required substrings.\",\n\thandler: async (json, { config }) => {\n\t\tif (config === undefined || config.rules.length === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst scripts = json.scripts ?? {};\n\t\tconst errors: string[] = [];\n\n\t\tfor (const rule of config.rules) {\n\t\t\t// Only validate if the script exists\n\t\t\tif (Object.hasOwn(scripts, rule.script)) {\n\t\t\t\tconst scriptBody = scripts[rule.script];\n\t\t\t\tif (typeof scriptBody === \"string\") {\n\t\t\t\t\tconst missingSubstrings = rule.mustContain.filter(\n\t\t\t\t\t\t(substring) => !scriptBody.includes(substring),\n\t\t\t\t\t);\n\n\t\t\t\t\tif (missingSubstrings.length > 0) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t`Script \"${rule.script}\" must contain: ${missingSubstrings.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (errors.length === 0) {\n\t\t\treturn [];\n\t\t}\n\t\treturn errors.map((message) => ({ message }));\n\t},\n});\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PolicyFinding } from "../policy.js";
|
|
2
2
|
/**
|
|
3
3
|
* Configuration for the SharedDependencyVersions policy.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
5
|
+
* @public
|
|
6
6
|
*/
|
|
7
7
|
export interface SharedDependencyVersionsConfig {
|
|
8
8
|
/**
|
|
@@ -18,7 +18,12 @@ export interface SharedDependencyVersionsConfig {
|
|
|
18
18
|
/**
|
|
19
19
|
* A policy that detects dependency version mismatches across Cargo workspace members.
|
|
20
20
|
*
|
|
21
|
-
* @
|
|
21
|
+
* @public
|
|
22
22
|
*/
|
|
23
|
-
export declare const SharedDependencyVersions:
|
|
23
|
+
export declare const SharedDependencyVersions: {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
scope: "repository";
|
|
27
|
+
handler: ({ files, root, config }: import("../policy.js").RepositoryPolicyArgs<SharedDependencyVersionsConfig>) => Promise<PolicyFinding[]>;
|
|
28
|
+
};
|
|
24
29
|
//# sourceMappingURL=SharedDependencyVersions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedDependencyVersions.d.ts","sourceRoot":"","sources":["../../src/policies/SharedDependencyVersions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SharedDependencyVersions.d.ts","sourceRoot":"","sources":["../../src/policies/SharedDependencyVersions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAA8B,MAAM,cAAc,CAAC;AAG9E;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B;AAsHD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;;;CA0DiC,CAAC"}
|