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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LicenseFileExists.d.ts","sourceRoot":"","sources":["../../src/policies/LicenseFileExists.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LicenseFileExists.d.ts","sourceRoot":"","sources":["../../src/policies/LicenseFileExists.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACzC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAgBD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;;;;;;;CAoCmC,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stat } from "node:fs/promises";
|
|
2
2
|
import path from "pathe";
|
|
3
|
-
import { makePolicyDefinition } from "../makePolicy.js";
|
|
4
3
|
/**
|
|
5
4
|
* Default license file names to check for.
|
|
6
5
|
*/
|
|
@@ -18,29 +17,37 @@ const DEFAULT_LICENSE_NAMES = [
|
|
|
18
17
|
* A repo policy that checks that a LICENSE file exists in the repository root.
|
|
19
18
|
* This is essential for open source projects to clarify usage rights and obligations.
|
|
20
19
|
*
|
|
21
|
-
* @
|
|
20
|
+
* @public
|
|
22
21
|
*/
|
|
23
|
-
export const LicenseFileExists =
|
|
22
|
+
export const LicenseFileExists = {
|
|
24
23
|
name: "LicenseFileExists",
|
|
25
24
|
description: "Ensures a LICENSE file exists in the repository root for open source projects.",
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
handler: async ({ root, config }) => {
|
|
25
|
+
scope: "repository",
|
|
26
|
+
handler: async ({ root, files, config }) => {
|
|
29
27
|
const acceptedNames = config?.acceptedNames ?? DEFAULT_LICENSE_NAMES;
|
|
30
28
|
// Check if any of the accepted license files exist in the root
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
for (const name of acceptedNames) {
|
|
30
|
+
if (!files.includes(name)) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
if ((await stat(path.join(root, name))).isFile()) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (!(error instanceof Error &&
|
|
40
|
+
"code" in error &&
|
|
41
|
+
error.code === "ENOENT")) {
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
34
45
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
`No LICENSE file found in repository root. Expected one of: ${acceptedNames.join(", ")}`,
|
|
41
|
-
],
|
|
42
|
-
};
|
|
43
|
-
return result;
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
message: `No LICENSE file found in repository root. Expected one of: ${acceptedNames.join(", ")}`,
|
|
49
|
+
},
|
|
50
|
+
];
|
|
44
51
|
},
|
|
45
|
-
}
|
|
52
|
+
};
|
|
46
53
|
//# sourceMappingURL=LicenseFileExists.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LicenseFileExists.js","sourceRoot":"","sources":["../../src/policies/LicenseFileExists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"LicenseFileExists.js","sourceRoot":"","sources":["../../src/policies/LicenseFileExists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,IAAI,MAAM,OAAO,CAAC;AAezB;;GAEG;AACH,MAAM,qBAAqB,GAAG;IAC7B,SAAS;IACT,aAAa;IACb,YAAY;IACZ,aAAa;IACb,SAAS;IACT,aAAa;IACb,YAAY;IACZ,aAAa;CACb,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EACV,gFAAgF;IACjF,KAAK,EAAE,YAAY;IACnB,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;QAC1C,MAAM,aAAa,GAAG,MAAM,EAAE,aAAa,IAAI,qBAAqB,CAAC;QAErE,+DAA+D;QAC/D,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;YAClC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3B,SAAS;YACV,CAAC;YACD,IAAI,CAAC;gBACJ,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;oBAClD,OAAO,EAAE,CAAC;gBACX,CAAC;YACF,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACzB,IACC,CAAC,CACA,KAAK,YAAY,KAAK;oBACtB,MAAM,IAAI,KAAK;oBACf,KAAK,CAAC,IAAI,KAAK,QAAQ,CACvB,EACA,CAAC;oBACF,MAAM,KAAK,CAAC;gBACb,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO;YACN;gBACC,OAAO,EAAE,8DAA8D,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;aACjG;SACD,CAAC;IACH,CAAC;CAC+D,CAAC","sourcesContent":["import { stat } from \"node:fs/promises\";\nimport path from \"pathe\";\nimport type { RepositoryPolicyDefinition } from \"../policy.js\";\n\n/**\n * Policy settings for the LicenseFileExists repo policy.\n *\n * @public\n */\nexport interface LicenseFileExistsSettings {\n\t/**\n\t * Array of acceptable license file names. Defaults to common variations.\n\t */\n\tacceptedNames?: string[];\n}\n\n/**\n * Default license file names to check for.\n */\nconst DEFAULT_LICENSE_NAMES = [\n\t\"LICENSE\",\n\t\"LICENSE.txt\",\n\t\"LICENSE.md\",\n\t\"LICENSE.rst\",\n\t\"LICENCE\",\n\t\"LICENCE.txt\",\n\t\"LICENCE.md\",\n\t\"LICENCE.rst\",\n];\n\n/**\n * A repo policy that checks that a LICENSE file exists in the repository root.\n * This is essential for open source projects to clarify usage rights and obligations.\n *\n * @public\n */\nexport const LicenseFileExists = {\n\tname: \"LicenseFileExists\",\n\tdescription:\n\t\t\"Ensures a LICENSE file exists in the repository root for open source projects.\",\n\tscope: \"repository\",\n\thandler: async ({ root, files, config }) => {\n\t\tconst acceptedNames = config?.acceptedNames ?? DEFAULT_LICENSE_NAMES;\n\n\t\t// Check if any of the accepted license files exist in the root\n\t\tfor (const name of acceptedNames) {\n\t\t\tif (!files.includes(name)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif ((await stat(path.join(root, name))).isFile()) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t} catch (error: unknown) {\n\t\t\t\tif (\n\t\t\t\t\t!(\n\t\t\t\t\t\terror instanceof Error &&\n\t\t\t\t\t\t\"code\" in error &&\n\t\t\t\t\t\terror.code === \"ENOENT\"\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthrow error;\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: `No LICENSE file found in repository root. Expected one of: ${acceptedNames.join(\", \")}`,\n\t\t\t},\n\t\t];\n\t},\n} satisfies RepositoryPolicyDefinition<LicenseFileExistsSettings>;\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Configuration for the changed-file limit. @public */
|
|
2
|
+
export interface MaxChangedFilesConfig {
|
|
3
|
+
/** Maximum number of eligible changed files; must be a nonnegative integer. */
|
|
4
|
+
maxFiles: number;
|
|
5
|
+
}
|
|
6
|
+
/** Limit the number of files in the selected change set. @public */
|
|
7
|
+
export declare const MaxChangedFiles: {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
scope: "changes";
|
|
11
|
+
requiresConfig: true;
|
|
12
|
+
handler: ({ entries, config }: import("../policy.js").RepositoryPolicyArgs<MaxChangedFilesConfig>) => Promise<{
|
|
13
|
+
message: string;
|
|
14
|
+
manualFix: string;
|
|
15
|
+
}[]>;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=MaxChangedFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaxChangedFiles.d.ts","sourceRoot":"","sources":["../../src/policies/MaxChangedFiles.ts"],"names":[],"mappings":"AAEA,wDAAwD;AACxD,MAAM,WAAW,qBAAqB;IACrC,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,oEAAoE;AACpE,eAAO,MAAM,eAAe;;;;;;;;;CAwBiC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Limit the number of files in the selected change set. @public */
|
|
2
|
+
export const MaxChangedFiles = {
|
|
3
|
+
name: "MaxChangedFiles",
|
|
4
|
+
description: "Limits the number of changed files in a change set.",
|
|
5
|
+
scope: "changes",
|
|
6
|
+
requiresConfig: true,
|
|
7
|
+
handler: async ({ entries, config }) => {
|
|
8
|
+
if (!(config && Number.isInteger(config.maxFiles)) || config.maxFiles < 0) {
|
|
9
|
+
throw new TypeError("MaxChangedFiles requires maxFiles to be a nonnegative integer.");
|
|
10
|
+
}
|
|
11
|
+
const count = entries.filter((entry) => entry.status !== "unchanged").length;
|
|
12
|
+
return count > config.maxFiles
|
|
13
|
+
? [
|
|
14
|
+
{
|
|
15
|
+
message: `Change set contains ${count} changed files; maximum allowed is ${config.maxFiles}.`,
|
|
16
|
+
manualFix: "Reduce the number of changed files or split the change into smaller change sets.",
|
|
17
|
+
},
|
|
18
|
+
]
|
|
19
|
+
: [];
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=MaxChangedFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaxChangedFiles.js","sourceRoot":"","sources":["../../src/policies/MaxChangedFiles.ts"],"names":[],"mappings":"AAQA,oEAAoE;AACpE,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,qDAAqD;IAClE,KAAK,EAAE,SAAS;IAChB,cAAc,EAAE,IAAI;IACpB,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;QACtC,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;YAC3E,MAAM,IAAI,SAAS,CAClB,gEAAgE,CAChE,CAAC;QACH,CAAC;QACD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAC3B,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,WAAW,CACvC,CAAC,MAAM,CAAC;QACT,OAAO,KAAK,GAAG,MAAM,CAAC,QAAQ;YAC7B,CAAC,CAAC;gBACA;oBACC,OAAO,EAAE,uBAAuB,KAAK,sCAAsC,MAAM,CAAC,QAAQ,GAAG;oBAC7F,SAAS,EACR,kFAAkF;iBACnF;aACD;YACF,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CAC2D,CAAC","sourcesContent":["import type { RepositoryPolicyDefinition } from \"../policy.js\";\n\n/** Configuration for the changed-file limit. @public */\nexport interface MaxChangedFilesConfig {\n\t/** Maximum number of eligible changed files; must be a nonnegative integer. */\n\tmaxFiles: number;\n}\n\n/** Limit the number of files in the selected change set. @public */\nexport const MaxChangedFiles = {\n\tname: \"MaxChangedFiles\",\n\tdescription: \"Limits the number of changed files in a change set.\",\n\tscope: \"changes\",\n\trequiresConfig: true,\n\thandler: async ({ entries, config }) => {\n\t\tif (!(config && Number.isInteger(config.maxFiles)) || config.maxFiles < 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"MaxChangedFiles requires maxFiles to be a nonnegative integer.\",\n\t\t\t);\n\t\t}\n\t\tconst count = entries.filter(\n\t\t\t(entry) => entry.status !== \"unchanged\",\n\t\t).length;\n\t\treturn count > config.maxFiles\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tmessage: `Change set contains ${count} changed files; maximum allowed is ${config.maxFiles}.`,\n\t\t\t\t\t\tmanualFix:\n\t\t\t\t\t\t\t\"Reduce the number of changed files or split the change into smaller change sets.\",\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: [];\n\t},\n} satisfies RepositoryPolicyDefinition<MaxChangedFilesConfig>;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration for the MutuallyExclusiveScripts policy.
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
4
|
+
* @public
|
|
5
5
|
*/
|
|
6
6
|
export interface MutuallyExclusiveScriptsConfig {
|
|
7
7
|
/**
|
|
@@ -29,18 +29,20 @@ export interface MutuallyExclusiveScriptsConfig {
|
|
|
29
29
|
*
|
|
30
30
|
* @example
|
|
31
31
|
* ```typescript
|
|
32
|
-
* import {
|
|
32
|
+
* import { makePolicy } from "repopo";
|
|
33
33
|
* import { MutuallyExclusiveScripts } from "repopo/policies";
|
|
34
34
|
*
|
|
35
|
-
*
|
|
35
|
+
* makePolicy(MutuallyExclusiveScripts, { config: {
|
|
36
36
|
* groups: [
|
|
37
37
|
* ["lint:eslint", "lint:biome"],
|
|
38
38
|
* ["test:jest", "test:vitest"],
|
|
39
39
|
* ],
|
|
40
|
-
* })
|
|
40
|
+
* } })
|
|
41
41
|
* ```
|
|
42
42
|
*
|
|
43
|
-
* @
|
|
43
|
+
* @public
|
|
44
44
|
*/
|
|
45
|
-
export declare const MutuallyExclusiveScripts: import("../policy.js").
|
|
45
|
+
export declare const MutuallyExclusiveScripts: import("../policy.js").FilePolicyDefinition<MutuallyExclusiveScriptsConfig | undefined> & {
|
|
46
|
+
requiresConfig: true;
|
|
47
|
+
};
|
|
46
48
|
//# sourceMappingURL=MutuallyExclusiveScripts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutuallyExclusiveScripts.d.ts","sourceRoot":"","sources":["../../src/policies/MutuallyExclusiveScripts.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;;;;;;;;;;;OAYG;IACH,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CACnB;AAID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,wBAAwB,
|
|
1
|
+
{"version":3,"file":"MutuallyExclusiveScripts.d.ts","sourceRoot":"","sources":["../../src/policies/MutuallyExclusiveScripts.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;;;;;;;;;;;OAYG;IACH,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CACnB;AAID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,wBAAwB;;CAiCnC,CAAC"}
|
|
@@ -10,25 +10,26 @@ const POLICY_NAME = "MutuallyExclusiveScripts";
|
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```typescript
|
|
13
|
-
* import {
|
|
13
|
+
* import { makePolicy } from "repopo";
|
|
14
14
|
* import { MutuallyExclusiveScripts } from "repopo/policies";
|
|
15
15
|
*
|
|
16
|
-
*
|
|
16
|
+
* makePolicy(MutuallyExclusiveScripts, { config: {
|
|
17
17
|
* groups: [
|
|
18
18
|
* ["lint:eslint", "lint:biome"],
|
|
19
19
|
* ["test:jest", "test:vitest"],
|
|
20
20
|
* ],
|
|
21
|
-
* })
|
|
21
|
+
* } })
|
|
22
22
|
* ```
|
|
23
23
|
*
|
|
24
|
-
* @
|
|
24
|
+
* @public
|
|
25
25
|
*/
|
|
26
26
|
export const MutuallyExclusiveScripts = definePackagePolicy({
|
|
27
|
+
requiresConfig: true,
|
|
27
28
|
name: POLICY_NAME,
|
|
28
29
|
description: "Validates that at most one script from each exclusive group exists in package.json.",
|
|
29
|
-
handler: async (json, {
|
|
30
|
+
handler: async (json, { config }) => {
|
|
30
31
|
if (config === undefined || config.groups.length === 0) {
|
|
31
|
-
return
|
|
32
|
+
return [];
|
|
32
33
|
}
|
|
33
34
|
const scripts = json.scripts ?? {};
|
|
34
35
|
const errors = [];
|
|
@@ -39,14 +40,9 @@ export const MutuallyExclusiveScripts = definePackagePolicy({
|
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
if (errors.length === 0) {
|
|
42
|
-
return
|
|
43
|
+
return [];
|
|
43
44
|
}
|
|
44
|
-
return {
|
|
45
|
-
name: POLICY_NAME,
|
|
46
|
-
file,
|
|
47
|
-
autoFixable: false,
|
|
48
|
-
errorMessages: errors,
|
|
49
|
-
};
|
|
45
|
+
return errors.map((message) => ({ message }));
|
|
50
46
|
},
|
|
51
47
|
});
|
|
52
48
|
//# sourceMappingURL=MutuallyExclusiveScripts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutuallyExclusiveScripts.js","sourceRoot":"","sources":["../../src/policies/MutuallyExclusiveScripts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAwB/E,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAGzD;IACD,IAAI,EAAE,WAAW;IACjB,WAAW,EACV,qFAAqF;IACtF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"MutuallyExclusiveScripts.js","sourceRoot":"","sources":["../../src/policies/MutuallyExclusiveScripts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAwB/E,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAGzD;IACD,cAAc,EAAE,IAAI;IACpB,IAAI,EAAE,WAAW;IACjB,WAAW,EACV,qFAAqF;IACtF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QACnC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxD,OAAO,EAAE,CAAC;QACX,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QACnC,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAClD,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAClC,CAAC;YAEF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC/B,MAAM,CAAC,IAAI,CACV,6CAA6C,cAAc,CAAC,MAAM,KAAK,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAClG,CAAC;YACH,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 the MutuallyExclusiveScripts policy.\n *\n * @public\n */\nexport interface MutuallyExclusiveScriptsConfig {\n\t/**\n\t * List of mutually exclusive script groups. Each group is an array of script names\n\t * where at most one script from the group can be present.\n\t *\n\t * Packages can have zero scripts from the group (all optional), but cannot have\n\t * multiple scripts from the same group.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Allow \"test:unit\" OR \"test:vitest\" OR neither, but not both\n\t * groups: [[\"test:unit\", \"test:vitest\"]]\n\t * ```\n\t */\n\tgroups: string[][];\n}\n\nconst POLICY_NAME = \"MutuallyExclusiveScripts\";\n\n/**\n * A policy that validates mutually exclusive script groups in package.json.\n *\n * @remarks\n * Use this policy when you want to enforce that only one script from a group\n * can exist in a package. This is useful for ensuring that packages don't have\n * conflicting scripts (e.g., both \"lint:eslint\" and \"lint:biome\").\n *\n * @example\n * ```typescript\n * import { makePolicy } from \"repopo\";\n * import { MutuallyExclusiveScripts } from \"repopo/policies\";\n *\n * makePolicy(MutuallyExclusiveScripts, { config: {\n * groups: [\n * [\"lint:eslint\", \"lint:biome\"],\n * [\"test:jest\", \"test:vitest\"],\n * ],\n * } })\n * ```\n *\n * @public\n */\nexport const MutuallyExclusiveScripts = definePackagePolicy<\n\tPackageJson,\n\tMutuallyExclusiveScriptsConfig | undefined\n>({\n\trequiresConfig: true,\n\tname: POLICY_NAME,\n\tdescription:\n\t\t\"Validates that at most one script from each exclusive group exists in package.json.\",\n\thandler: async (json, { config }) => {\n\t\tif (config === undefined || config.groups.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 group of config.groups) {\n\t\t\tconst presentScripts = group.filter((scriptName) =>\n\t\t\t\tObject.hasOwn(scripts, scriptName),\n\t\t\t);\n\n\t\t\tif (presentScripts.length > 1) {\n\t\t\t\terrors.push(\n\t\t\t\t\t`Scripts are mutually exclusive, but found ${presentScripts.length}: ${presentScripts.join(\", \")}`,\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,9 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Operation } from "effection";
|
|
2
|
+
import type { PolicyFinding } from "../policy.js";
|
|
2
3
|
/**
|
|
3
4
|
* A policy that prevents accidental commits of build directory contents.
|
|
4
5
|
* Applies to Gleam's `build/` output directory.
|
|
5
6
|
*
|
|
6
|
-
* @
|
|
7
|
+
* @public
|
|
7
8
|
*/
|
|
8
|
-
export declare const NoBuildDirectory:
|
|
9
|
+
export declare const NoBuildDirectory: {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
match: RegExp;
|
|
13
|
+
handler: ({ file }: import("../policy.js").PolicyArgs<void>) => Operation<PolicyFinding[]>;
|
|
14
|
+
};
|
|
9
15
|
//# sourceMappingURL=NoBuildDirectory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoBuildDirectory.d.ts","sourceRoot":"","sources":["../../src/policies/NoBuildDirectory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NoBuildDirectory.d.ts","sourceRoot":"","sources":["../../src/policies/NoBuildDirectory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAwB,aAAa,EAAE,MAAM,cAAc,CAAC;AAOxE;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;oEAKG,SAAS,CAAC,aAAa,EAAE,CAAC;CAS1B,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { makePolicyDefinition } from "../makePolicy.js";
|
|
2
1
|
/**
|
|
3
2
|
* Build output extensions and directory patterns that should not be committed.
|
|
4
3
|
*/
|
|
@@ -7,23 +6,19 @@ const BUILD_DIR_REGEX = /(?:^|\/)(build)\//;
|
|
|
7
6
|
* A policy that prevents accidental commits of build directory contents.
|
|
8
7
|
* Applies to Gleam's `build/` output directory.
|
|
9
8
|
*
|
|
10
|
-
* @
|
|
9
|
+
* @public
|
|
11
10
|
*/
|
|
12
|
-
export const NoBuildDirectory =
|
|
11
|
+
export const NoBuildDirectory = {
|
|
13
12
|
name: "NoBuildDirectory",
|
|
14
13
|
description: "Prevents accidental commits of build directory contents (Gleam build/ output).",
|
|
15
14
|
match: BUILD_DIR_REGEX,
|
|
16
|
-
// biome-ignore lint/correctness/useYield: no yield needed
|
|
17
15
|
handler: function* ({ file }) {
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
errorMessages: [
|
|
23
|
-
`Build artifact detected in build/ directory: ${file}. The build/ directory should be in .gitignore.`,
|
|
24
|
-
],
|
|
16
|
+
return [
|
|
17
|
+
`Build artifact detected in build/ directory: ${file}. The build/ directory should be in .gitignore.`,
|
|
18
|
+
].map((message) => ({
|
|
19
|
+
message,
|
|
25
20
|
manualFix: "Remove the build/ directory from source control and add it to .gitignore.",
|
|
26
|
-
};
|
|
21
|
+
}));
|
|
27
22
|
},
|
|
28
|
-
}
|
|
23
|
+
};
|
|
29
24
|
//# sourceMappingURL=NoBuildDirectory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoBuildDirectory.js","sourceRoot":"","sources":["../../src/policies/NoBuildDirectory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NoBuildDirectory.js","sourceRoot":"","sources":["../../src/policies/NoBuildDirectory.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACV,gFAAgF;IACjF,KAAK,EAAE,eAAe;IACtB,OAAO,EAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE;QAC3B,OAAO;YACN,gDAAgD,IAAI,iDAAiD;SACrG,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACnB,OAAO;YACP,SAAS,EACR,2EAA2E;SAC5E,CAAC,CAAC,CAAC;IACL,CAAC;CAC8B,CAAC","sourcesContent":["import type { Operation } from \"effection\";\nimport type { FilePolicyDefinition, PolicyFinding } from \"../policy.js\";\n\n/**\n * Build output extensions and directory patterns that should not be committed.\n */\nconst BUILD_DIR_REGEX = /(?:^|\\/)(build)\\//;\n\n/**\n * A policy that prevents accidental commits of build directory contents.\n * Applies to Gleam's `build/` output directory.\n *\n * @public\n */\nexport const NoBuildDirectory = {\n\tname: \"NoBuildDirectory\",\n\tdescription:\n\t\t\"Prevents accidental commits of build directory contents (Gleam build/ output).\",\n\tmatch: BUILD_DIR_REGEX,\n\thandler: function* ({ file }): Operation<PolicyFinding[]> {\n\t\treturn [\n\t\t\t`Build artifact detected in build/ directory: ${file}. The build/ directory should be in .gitignore.`,\n\t\t].map((message) => ({\n\t\t\tmessage,\n\t\t\tmanualFix:\n\t\t\t\t\"Remove the build/ directory from source control and add it to .gitignore.\",\n\t\t}));\n\t},\n} satisfies FilePolicyDefinition;\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Operation } from "effection";
|
|
2
|
+
import type { PolicyFinding } from "../policy.js";
|
|
2
3
|
/**
|
|
3
4
|
* A repo policy that checks for JavaScript source files that just use the .js file extension. Such files may be
|
|
4
5
|
* interpreted by node as either CommonJS or ESM based on the `type` field in the nearest package.json file. This
|
|
@@ -6,7 +7,12 @@ import type { PolicyDefinition } from "../policy.js";
|
|
|
6
7
|
* is processed by node. Using explicit file extensions reduces ambiguity and ensures a CJS file isn't suddenly treated
|
|
7
8
|
* like an ESM file.
|
|
8
9
|
*
|
|
9
|
-
* @
|
|
10
|
+
* @public
|
|
10
11
|
*/
|
|
11
|
-
export declare const NoJsFileExtensions:
|
|
12
|
+
export declare const NoJsFileExtensions: {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
match: RegExp;
|
|
16
|
+
handler: () => Operation<PolicyFinding[]>;
|
|
17
|
+
};
|
|
12
18
|
//# sourceMappingURL=NoJsFileExtensions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoJsFileExtensions.d.ts","sourceRoot":"","sources":["../../src/policies/NoJsFileExtensions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NoJsFileExtensions.d.ts","sourceRoot":"","sources":["../../src/policies/NoJsFileExtensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAwB,aAAa,EAAE,MAAM,cAAc,CAAC;AACxE;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB;;;;mBAKP,SAAS,CAAC,aAAa,EAAE,CAAC;CAQlB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { makePolicyDefinition } from "../makePolicy.js";
|
|
2
1
|
/**
|
|
3
2
|
* A repo policy that checks for JavaScript source files that just use the .js file extension. Such files may be
|
|
4
3
|
* interpreted by node as either CommonJS or ESM based on the `type` field in the nearest package.json file. This
|
|
@@ -6,23 +5,19 @@ import { makePolicyDefinition } from "../makePolicy.js";
|
|
|
6
5
|
* is processed by node. Using explicit file extensions reduces ambiguity and ensures a CJS file isn't suddenly treated
|
|
7
6
|
* like an ESM file.
|
|
8
7
|
*
|
|
9
|
-
* @
|
|
8
|
+
* @public
|
|
10
9
|
*/
|
|
11
|
-
export const NoJsFileExtensions =
|
|
10
|
+
export const NoJsFileExtensions = {
|
|
12
11
|
name: "NoJsFileExtensions",
|
|
13
12
|
description: "Prevents ambiguous .js files by requiring explicit .mjs or .cjs extensions based on module format.",
|
|
14
13
|
match: /(^|\/)[^/]+\.js$/i,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
autoFixable: false,
|
|
21
|
-
errorMessages: [
|
|
22
|
-
"JavaScript files should have a .cjs or .mjs file extension based on the module format of the file.",
|
|
23
|
-
],
|
|
14
|
+
handler: function* () {
|
|
15
|
+
return [
|
|
16
|
+
"JavaScript files should have a .cjs or .mjs file extension based on the module format of the file.",
|
|
17
|
+
].map((message) => ({
|
|
18
|
+
message,
|
|
24
19
|
manualFix: "Rename the file to have a .cjs or .mjs file extension.",
|
|
25
|
-
};
|
|
20
|
+
}));
|
|
26
21
|
},
|
|
27
|
-
}
|
|
22
|
+
};
|
|
28
23
|
//# sourceMappingURL=NoJsFileExtensions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoJsFileExtensions.js","sourceRoot":"","sources":["../../src/policies/NoJsFileExtensions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NoJsFileExtensions.js","sourceRoot":"","sources":["../../src/policies/NoJsFileExtensions.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EACV,oGAAoG;IACrG,KAAK,EAAE,mBAAmB;IAC1B,OAAO,EAAE,QAAQ,CAAC;QACjB,OAAO;YACN,oGAAoG;SACpG,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACnB,OAAO;YACP,SAAS,EAAE,wDAAwD;SACnE,CAAC,CAAC,CAAC;IACL,CAAC;CAC8B,CAAC","sourcesContent":["import type { Operation } from \"effection\";\nimport type { FilePolicyDefinition, PolicyFinding } from \"../policy.js\";\n/**\n * A repo policy that checks for JavaScript source files that just use the .js file extension. Such files may be\n * interpreted by node as either CommonJS or ESM based on the `type` field in the nearest package.json file. This\n * can create unexpected behavior for JS files; changing the package.json nearest to one will change how the JS\n * is processed by node. Using explicit file extensions reduces ambiguity and ensures a CJS file isn't suddenly treated\n * like an ESM file.\n *\n * @public\n */\nexport const NoJsFileExtensions = {\n\tname: \"NoJsFileExtensions\",\n\tdescription:\n\t\t\"Prevents ambiguous .js files by requiring explicit .mjs or .cjs extensions based on module format.\",\n\tmatch: /(^|\\/)[^/]+\\.js$/i,\n\thandler: function* (): Operation<PolicyFinding[]> {\n\t\treturn [\n\t\t\t\"JavaScript files should have a .cjs or .mjs file extension based on the module format of the file.\",\n\t\t].map((message) => ({\n\t\t\tmessage,\n\t\t\tmanualFix: \"Rename the file to have a .cjs or .mjs file extension.\",\n\t\t}));\n\t},\n} satisfies FilePolicyDefinition;\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PolicyFinding } from "../policy.js";
|
|
2
2
|
/**
|
|
3
3
|
* Policy settings for the NoLargeBinaryFiles repo policy.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
5
|
+
* @public
|
|
6
6
|
*/
|
|
7
7
|
export interface NoLargeBinaryFilesSettings {
|
|
8
8
|
/**
|
|
@@ -24,7 +24,12 @@ export interface NoLargeBinaryFilesSettings {
|
|
|
24
24
|
* A repo policy that prevents large binary files from being committed to the repository.
|
|
25
25
|
* Large files can bloat the repository and slow down clones. Consider using Git LFS for large assets.
|
|
26
26
|
*
|
|
27
|
-
* @
|
|
27
|
+
* @public
|
|
28
28
|
*/
|
|
29
|
-
export declare const NoLargeBinaryFiles:
|
|
29
|
+
export declare const NoLargeBinaryFiles: {
|
|
30
|
+
name: string;
|
|
31
|
+
description: string;
|
|
32
|
+
match: RegExp;
|
|
33
|
+
handler: ({ file, root, config }: import("../policy.js").PolicyArgs<NoLargeBinaryFilesSettings>) => Promise<PolicyFinding[]>;
|
|
34
|
+
};
|
|
30
35
|
//# sourceMappingURL=NoLargeBinaryFiles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoLargeBinaryFiles.d.ts","sourceRoot":"","sources":["../../src/policies/NoLargeBinaryFiles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NoLargeBinaryFiles.d.ts","sourceRoot":"","sources":["../../src/policies/NoLargeBinaryFiles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAwB,aAAa,EAAE,MAAM,cAAc,CAAC;AACxE;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE7B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AA2FD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;CAsC6B,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { statSync } from "node:fs";
|
|
2
2
|
import path from "pathe";
|
|
3
|
-
import { makePolicyDefinition } from "../makePolicy.js";
|
|
4
3
|
/**
|
|
5
4
|
* Default maximum file size (10MB in bytes).
|
|
6
5
|
*/
|
|
@@ -80,9 +79,9 @@ function formatBytes(bytes) {
|
|
|
80
79
|
* A repo policy that prevents large binary files from being committed to the repository.
|
|
81
80
|
* Large files can bloat the repository and slow down clones. Consider using Git LFS for large assets.
|
|
82
81
|
*
|
|
83
|
-
* @
|
|
82
|
+
* @public
|
|
84
83
|
*/
|
|
85
|
-
export const NoLargeBinaryFiles =
|
|
84
|
+
export const NoLargeBinaryFiles = {
|
|
86
85
|
name: "NoLargeBinaryFiles",
|
|
87
86
|
description: "Prevents large binary files from being committed to avoid repository bloat; consider using Git LFS for large assets.",
|
|
88
87
|
// Match all files
|
|
@@ -93,32 +92,27 @@ export const NoLargeBinaryFiles = makePolicyDefinition({
|
|
|
93
92
|
const excludePatterns = config?.excludePatterns ?? [];
|
|
94
93
|
// Skip excluded files
|
|
95
94
|
if (isExcluded(file, excludePatterns, excludeExtensions)) {
|
|
96
|
-
return
|
|
95
|
+
return [];
|
|
97
96
|
}
|
|
98
97
|
try {
|
|
99
98
|
const filePath = path.resolve(root, file);
|
|
100
99
|
const stats = statSync(filePath);
|
|
101
100
|
// Skip directories
|
|
102
101
|
if (stats.isDirectory()) {
|
|
103
|
-
return
|
|
102
|
+
return [];
|
|
104
103
|
}
|
|
105
104
|
if (stats.size > maxSizeBytes) {
|
|
106
|
-
const result =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
autoFixable: false,
|
|
110
|
-
errorMessages: [
|
|
111
|
-
`File is too large: ${formatBytes(stats.size)} (max: ${formatBytes(maxSizeBytes)}). Consider using Git LFS or removing the file.`,
|
|
112
|
-
],
|
|
113
|
-
};
|
|
105
|
+
const result = [
|
|
106
|
+
`File is too large: ${formatBytes(stats.size)} (max: ${formatBytes(maxSizeBytes)}). Consider using Git LFS or removing the file.`,
|
|
107
|
+
].map((message) => ({ message }));
|
|
114
108
|
return result;
|
|
115
109
|
}
|
|
116
|
-
return
|
|
110
|
+
return [];
|
|
117
111
|
}
|
|
118
112
|
catch (_error) {
|
|
119
113
|
// File doesn't exist or can't be accessed, skip it
|
|
120
|
-
return
|
|
114
|
+
return [];
|
|
121
115
|
}
|
|
122
116
|
},
|
|
123
|
-
}
|
|
117
|
+
};
|
|
124
118
|
//# sourceMappingURL=NoLargeBinaryFiles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoLargeBinaryFiles.js","sourceRoot":"","sources":["../../src/policies/NoLargeBinaryFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,IAAI,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"NoLargeBinaryFiles.js","sourceRoot":"","sources":["../../src/policies/NoLargeBinaryFiles.ts"],"names":[],"mappings":"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","sourcesContent":["import { statSync } from \"node:fs\";\nimport path from \"pathe\";\nimport type { FilePolicyDefinition, PolicyFinding } from \"../policy.js\";\n/**\n * Policy settings for the NoLargeBinaryFiles repo policy.\n *\n * @public\n */\nexport interface NoLargeBinaryFilesSettings {\n\t/**\n\t * Maximum file size in bytes. Defaults to 10MB.\n\t */\n\tmaxSizeBytes?: number;\n\n\t/**\n\t * File extensions to exclude from size checking.\n\t * Useful for known large files that should be allowed.\n\t */\n\texcludeExtensions?: string[];\n\n\t/**\n\t * File patterns to exclude from size checking.\n\t * Uses glob-style patterns.\n\t */\n\texcludePatterns?: string[];\n}\n\n/**\n * Default maximum file size (10MB in bytes).\n */\nconst DEFAULT_MAX_SIZE = 10 * 1024 * 1024;\n\n/**\n * Default file extensions that are typically safe to exclude from size limits.\n */\nconst DEFAULT_EXCLUDE_EXTENSIONS = [\n\t\".md\",\n\t\".txt\",\n\t\".json\",\n\t\".js\",\n\t\".ts\",\n\t\".jsx\",\n\t\".tsx\",\n\t\".css\",\n\t\".scss\",\n\t\".sass\",\n\t\".less\",\n\t\".html\",\n\t\".xml\",\n\t\".yml\",\n\t\".yaml\",\n\t\".toml\",\n\t\".ini\",\n\t\".conf\",\n\t\".config\",\n];\n\n/**\n * Convert a glob pattern to a regex pattern by escaping special characters\n * and converting * to .* for wildcard matching.\n */\nfunction globToRegex(pattern: string): RegExp {\n\t// Escape all regex special characters except *\n\tconst escaped = pattern.replace(/[.+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t// Convert * to .* for wildcard matching\n\tconst regexPattern = escaped.replace(/\\*/g, \".*\");\n\treturn new RegExp(`^${regexPattern}$`);\n}\n\n/**\n * Check if a file matches any of the exclude patterns.\n */\nfunction isExcluded(\n\tfilePath: string,\n\texcludePatterns: string[],\n\texcludeExtensions: string[],\n): boolean {\n\tconst ext = path.extname(filePath).toLowerCase();\n\n\t// Check extensions\n\tif (excludeExtensions.includes(ext)) {\n\t\treturn true;\n\t}\n\n\t// Check patterns (simple glob-like matching)\n\tfor (const pattern of excludePatterns) {\n\t\tif (pattern.includes(\"*\")) {\n\t\t\tconst regex = globToRegex(pattern);\n\t\t\tif (regex.test(filePath)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (filePath.includes(pattern)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Format bytes in a human-readable format.\n */\nfunction formatBytes(bytes: number): string {\n\tif (bytes === 0) {\n\t\treturn \"0 B\";\n\t}\n\tconst k = 1024;\n\tconst sizes = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\"];\n\tconst i = Math.min(\n\t\tMath.floor(Math.log(bytes) / Math.log(k)),\n\t\tsizes.length - 1,\n\t);\n\tconst formatted = (bytes / k ** i).toFixed(1);\n\treturn `${formatted} ${sizes[i]}`;\n}\n\n/**\n * A repo policy that prevents large binary files from being committed to the repository.\n * Large files can bloat the repository and slow down clones. Consider using Git LFS for large assets.\n *\n * @public\n */\nexport const NoLargeBinaryFiles = {\n\tname: \"NoLargeBinaryFiles\",\n\tdescription:\n\t\t\"Prevents large binary files from being committed to avoid repository bloat; consider using Git LFS for large assets.\",\n\t// Match all files\n\tmatch: /.*/,\n\thandler: async ({ file, root, config }) => {\n\t\tconst maxSizeBytes = config?.maxSizeBytes ?? DEFAULT_MAX_SIZE;\n\t\tconst excludeExtensions =\n\t\t\tconfig?.excludeExtensions ?? DEFAULT_EXCLUDE_EXTENSIONS;\n\t\tconst excludePatterns = config?.excludePatterns ?? [];\n\n\t\t// Skip excluded files\n\t\tif (isExcluded(file, excludePatterns, excludeExtensions)) {\n\t\t\treturn [];\n\t\t}\n\n\t\ttry {\n\t\t\tconst filePath = path.resolve(root, file);\n\t\t\tconst stats = statSync(filePath);\n\n\t\t\t// Skip directories\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (stats.size > maxSizeBytes) {\n\t\t\t\tconst result: PolicyFinding[] = [\n\t\t\t\t\t`File is too large: ${formatBytes(stats.size)} (max: ${formatBytes(maxSizeBytes)}). Consider using Git LFS or removing the file.`,\n\t\t\t\t].map((message) => ({ message }));\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\treturn [];\n\t\t} catch (_error: unknown) {\n\t\t\t// File doesn't exist or can't be accessed, skip it\n\t\t\treturn [];\n\t\t}\n\t},\n} satisfies FilePolicyDefinition<NoLargeBinaryFilesSettings>;\n"]}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration for the NoPrivateWorkspaceDependencies policy.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
3
5
|
*/
|
|
4
6
|
export interface NoPrivateWorkspaceDependenciesSettings {
|
|
5
7
|
/**
|
|
6
8
|
* Whether to check devDependencies in addition to dependencies.
|
|
7
|
-
* @
|
|
9
|
+
* @defaultValue false
|
|
8
10
|
*/
|
|
9
11
|
checkDevDependencies?: boolean;
|
|
10
12
|
}
|
|
@@ -21,17 +23,19 @@ export interface NoPrivateWorkspaceDependenciesSettings {
|
|
|
21
23
|
* @example
|
|
22
24
|
* ```typescript
|
|
23
25
|
* // In repopo.config.ts
|
|
26
|
+
* import { makePolicy } from "repopo";
|
|
24
27
|
* import { NoPrivateWorkspaceDependencies } from "repopo/policies";
|
|
25
28
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* });
|
|
29
|
+
* // Only check production dependencies (default)
|
|
30
|
+
* makePolicy(NoPrivateWorkspaceDependencies);
|
|
29
31
|
*
|
|
30
32
|
* // Or check both dependencies and devDependencies
|
|
31
33
|
* makePolicy(NoPrivateWorkspaceDependencies, {
|
|
32
|
-
* checkDevDependencies: true,
|
|
34
|
+
* config: { checkDevDependencies: true },
|
|
33
35
|
* });
|
|
34
36
|
* ```
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
35
39
|
*/
|
|
36
|
-
export declare const NoPrivateWorkspaceDependencies: import("../policy.js").
|
|
40
|
+
export declare const NoPrivateWorkspaceDependencies: import("../policy.js").FilePolicyDefinition<NoPrivateWorkspaceDependenciesSettings | undefined>;
|
|
37
41
|
//# sourceMappingURL=NoPrivateWorkspaceDependencies.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoPrivateWorkspaceDependencies.d.ts","sourceRoot":"","sources":["../../src/policies/NoPrivateWorkspaceDependencies.ts"],"names":[],"mappings":"AAYA
|
|
1
|
+
{"version":3,"file":"NoPrivateWorkspaceDependencies.d.ts","sourceRoot":"","sources":["../../src/policies/NoPrivateWorkspaceDependencies.ts"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,MAAM,WAAW,sCAAsC;IACtD;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAC/B;AA6ED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,8BAA8B,iGAoEzC,CAAC"}
|