repopo 0.10.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +113 -0
- package/README.md +76 -77
- package/THIRD-PARTY-LICENSES.txt +232 -14
- package/bin/dev.js +5 -1
- package/esm/adapters/fluidFramework.d.ts +13 -9
- package/esm/adapters/fluidFramework.d.ts.map +1 -1
- package/esm/adapters/fluidFramework.js +20 -43
- package/esm/adapters/fluidFramework.js.map +1 -1
- package/esm/api.d.ts +64 -1
- package/esm/api.d.ts.map +1 -1
- package/esm/api.js +17 -1
- package/esm/api.js.map +1 -1
- package/esm/baseCommand.d.ts +1 -1
- package/esm/baseCommand.d.ts.map +1 -1
- package/esm/baseCommand.js +7 -10
- package/esm/baseCommand.js.map +1 -1
- package/esm/commands/check-native.d.ts +25 -0
- package/esm/commands/check-native.d.ts.map +1 -0
- package/esm/commands/check-native.js +156 -0
- package/esm/commands/check-native.js.map +1 -0
- package/esm/commands/check.d.ts +7 -34
- package/esm/commands/check.d.ts.map +1 -1
- package/esm/commands/check.js +76 -265
- package/esm/commands/check.js.map +1 -1
- package/esm/commands/list.d.ts.map +1 -1
- package/esm/commands/list.js +6 -6
- package/esm/commands/list.js.map +1 -1
- package/esm/concurrency.d.ts +3 -0
- package/esm/concurrency.d.ts.map +1 -0
- package/esm/concurrency.js +8 -0
- package/esm/concurrency.js.map +1 -0
- package/esm/config.d.ts +5 -39
- package/esm/config.d.ts.map +1 -1
- package/esm/config.js +3 -7
- package/esm/config.js.map +1 -1
- package/esm/context.d.ts +20 -3
- package/esm/context.d.ts.map +1 -1
- package/esm/context.js +18 -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 -11
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +3 -14
- package/esm/index.js.map +1 -1
- package/esm/makePolicy.d.ts +26 -79
- package/esm/makePolicy.d.ts.map +1 -1
- package/esm/makePolicy.js +51 -95
- package/esm/makePolicy.js.map +1 -1
- package/esm/perf.d.ts +10 -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 +41 -0
- package/esm/policies/CargoLicenceValidated.d.ts.map +1 -0
- package/esm/policies/CargoLicenceValidated.js +47 -0
- package/esm/policies/CargoLicenceValidated.js.map +1 -0
- package/esm/policies/CargoLintsConfigured.d.ts +30 -0
- package/esm/policies/CargoLintsConfigured.d.ts.map +1 -0
- package/esm/policies/CargoLintsConfigured.js +65 -0
- package/esm/policies/CargoLintsConfigured.js.map +1 -0
- package/esm/policies/CargoLockPolicy.d.ts +34 -0
- package/esm/policies/CargoLockPolicy.d.ts.map +1 -0
- package/esm/policies/CargoLockPolicy.js +61 -0
- package/esm/policies/CargoLockPolicy.js.map +1 -0
- package/esm/policies/CargoTomlRequired.d.ts +34 -0
- package/esm/policies/CargoTomlRequired.d.ts.map +1 -0
- package/esm/policies/CargoTomlRequired.js +77 -0
- package/esm/policies/CargoTomlRequired.js.map +1 -0
- package/esm/policies/CargoTomlSorted.d.ts +20 -0
- package/esm/policies/CargoTomlSorted.d.ts.map +1 -0
- package/esm/policies/CargoTomlSorted.js +168 -0
- package/esm/policies/CargoTomlSorted.js.map +1 -0
- package/esm/policies/ConditionalScripts.d.ts +10 -8
- package/esm/policies/ConditionalScripts.d.ts.map +1 -1
- package/esm/policies/ConditionalScripts.js +27 -24
- 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 +18 -20
- package/esm/policies/ExactScripts.js.map +1 -1
- package/esm/policies/GleamDepVersions.d.ts +25 -0
- package/esm/policies/GleamDepVersions.d.ts.map +1 -0
- package/esm/policies/GleamDepVersions.js +67 -0
- package/esm/policies/GleamDepVersions.js.map +1 -0
- package/esm/policies/GleamDocExists.d.ts +24 -0
- package/esm/policies/GleamDocExists.d.ts.map +1 -0
- package/esm/policies/GleamDocExists.js +39 -0
- package/esm/policies/GleamDocExists.js.map +1 -0
- package/esm/policies/GleamInternalModulesConfigured.d.ts +21 -0
- package/esm/policies/GleamInternalModulesConfigured.d.ts.map +1 -0
- package/esm/policies/GleamInternalModulesConfigured.js +32 -0
- package/esm/policies/GleamInternalModulesConfigured.js.map +1 -0
- package/esm/policies/GleamLicenceConfigured.d.ts +29 -0
- package/esm/policies/GleamLicenceConfigured.d.ts.map +1 -0
- package/esm/policies/GleamLicenceConfigured.js +36 -0
- package/esm/policies/GleamLicenceConfigured.js.map +1 -0
- package/esm/policies/GleamManifestCommitted.d.ts +16 -0
- package/esm/policies/GleamManifestCommitted.d.ts.map +1 -0
- package/esm/policies/GleamManifestCommitted.js +27 -0
- package/esm/policies/GleamManifestCommitted.js.map +1 -0
- package/esm/policies/GleamMonorepoConsistency.d.ts +38 -0
- package/esm/policies/GleamMonorepoConsistency.d.ts.map +1 -0
- package/esm/policies/GleamMonorepoConsistency.js +74 -0
- package/esm/policies/GleamMonorepoConsistency.js.map +1 -0
- package/esm/policies/GleamNameRestrictions.d.ts +25 -0
- package/esm/policies/GleamNameRestrictions.d.ts.map +1 -0
- package/esm/policies/GleamNameRestrictions.js +44 -0
- package/esm/policies/GleamNameRestrictions.js.map +1 -0
- package/esm/policies/GleamNoPathDepsInPublished.d.ts +22 -0
- package/esm/policies/GleamNoPathDepsInPublished.d.ts.map +1 -0
- package/esm/policies/GleamNoPathDepsInPublished.js +43 -0
- package/esm/policies/GleamNoPathDepsInPublished.js.map +1 -0
- package/esm/policies/GleamPathDepsValid.d.ts +9 -0
- package/esm/policies/GleamPathDepsValid.d.ts.map +1 -0
- package/esm/policies/GleamPathDepsValid.js +59 -0
- package/esm/policies/GleamPathDepsValid.js.map +1 -0
- package/esm/policies/GleamProjectStructure.d.ts +32 -0
- package/esm/policies/GleamProjectStructure.d.ts.map +1 -0
- package/esm/policies/GleamProjectStructure.js +32 -0
- package/esm/policies/GleamProjectStructure.js.map +1 -0
- package/esm/policies/GleamSharedDependencyVersions.d.ts +37 -0
- package/esm/policies/GleamSharedDependencyVersions.d.ts.map +1 -0
- package/esm/policies/GleamSharedDependencyVersions.js +101 -0
- package/esm/policies/GleamSharedDependencyVersions.js.map +1 -0
- package/esm/policies/GleamTomlRequired.d.ts +30 -0
- package/esm/policies/GleamTomlRequired.d.ts.map +1 -0
- package/esm/policies/GleamTomlRequired.js +37 -0
- package/esm/policies/GleamTomlRequired.js.map +1 -0
- package/esm/policies/GleamTomlSorted.d.ts +20 -0
- package/esm/policies/GleamTomlSorted.d.ts.map +1 -0
- package/esm/policies/GleamTomlSorted.js +157 -0
- package/esm/policies/GleamTomlSorted.js.map +1 -0
- package/esm/policies/GleamVersionConstraint.d.ts +20 -0
- package/esm/policies/GleamVersionConstraint.d.ts.map +1 -0
- package/esm/policies/GleamVersionConstraint.js +68 -0
- package/esm/policies/GleamVersionConstraint.js.map +1 -0
- package/esm/policies/HtmlFileHeaders.d.ts +4 -2
- package/esm/policies/HtmlFileHeaders.d.ts.map +1 -1
- package/esm/policies/HtmlFileHeaders.js +2 -2
- package/esm/policies/HtmlFileHeaders.js.map +1 -1
- package/esm/policies/JsTsFileHeaders.d.ts +4 -2
- package/esm/policies/JsTsFileHeaders.d.ts.map +1 -1
- package/esm/policies/JsTsFileHeaders.js +1 -1
- package/esm/policies/JsTsFileHeaders.js.map +1 -1
- package/esm/policies/LicenseFileExists.d.ts +10 -4
- package/esm/policies/LicenseFileExists.d.ts.map +1 -1
- package/esm/policies/LicenseFileExists.js +27 -20
- package/esm/policies/LicenseFileExists.js.map +1 -1
- package/esm/policies/MutuallyExclusiveScripts.d.ts +8 -6
- package/esm/policies/MutuallyExclusiveScripts.d.ts.map +1 -1
- package/esm/policies/MutuallyExclusiveScripts.js +9 -13
- package/esm/policies/MutuallyExclusiveScripts.js.map +1 -1
- package/esm/policies/NoBuildDirectory.d.ts +15 -0
- package/esm/policies/NoBuildDirectory.d.ts.map +1 -0
- package/esm/policies/NoBuildDirectory.js +24 -0
- package/esm/policies/NoBuildDirectory.js.map +1 -0
- 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 +14 -0
- package/esm/policies/NoTargetArtifacts.d.ts.map +1 -0
- package/esm/policies/NoTargetArtifacts.js +37 -0
- package/esm/policies/NoTargetArtifacts.js.map +1 -0
- package/esm/policies/NoUnsafeWithoutJustification.d.ts +31 -0
- package/esm/policies/NoUnsafeWithoutJustification.d.ts.map +1 -0
- package/esm/policies/NoUnsafeWithoutJustification.js +79 -0
- package/esm/policies/NoUnsafeWithoutJustification.js.map +1 -0
- package/esm/policies/NoWildcardDependencies.d.ts +30 -0
- package/esm/policies/NoWildcardDependencies.d.ts.map +1 -0
- package/esm/policies/NoWildcardDependencies.js +83 -0
- package/esm/policies/NoWildcardDependencies.js.map +1 -0
- package/esm/policies/PackageAllowedScopes.d.ts +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 +38 -36
- 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 +18 -21
- 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 +29 -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 +51 -31
- 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 +32 -54
- 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 +34 -25
- 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 +24 -61
- 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 +42 -38
- 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 +17 -19
- package/esm/policies/PackageTestScripts.js.map +1 -1
- package/esm/policies/PublicApiDocumented.d.ts +21 -0
- package/esm/policies/PublicApiDocumented.d.ts.map +1 -0
- package/esm/policies/PublicApiDocumented.js +38 -0
- package/esm/policies/PublicApiDocumented.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 +27 -26
- package/esm/policies/RequiredScripts.js.map +1 -1
- package/esm/policies/RustDocExists.d.ts +24 -0
- package/esm/policies/RustDocExists.d.ts.map +1 -0
- package/esm/policies/RustDocExists.js +49 -0
- package/esm/policies/RustDocExists.js.map +1 -0
- package/esm/policies/RustToolchainExists.d.ts +27 -0
- package/esm/policies/RustToolchainExists.d.ts.map +1 -0
- package/esm/policies/RustToolchainExists.js +28 -0
- package/esm/policies/RustToolchainExists.js.map +1 -0
- package/esm/policies/RustfmtConfigExists.d.ts +27 -0
- package/esm/policies/RustfmtConfigExists.d.ts.map +1 -0
- package/esm/policies/RustfmtConfigExists.js +28 -0
- package/esm/policies/RustfmtConfigExists.js.map +1 -0
- 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 +29 -0
- package/esm/policies/SharedDependencyVersions.d.ts.map +1 -0
- package/esm/policies/SharedDependencyVersions.js +143 -0
- package/esm/policies/SharedDependencyVersions.js.map +1 -0
- package/esm/policies/WorkspaceInheritance.d.ts +31 -0
- package/esm/policies/WorkspaceInheritance.d.ts.map +1 -0
- package/esm/policies/WorkspaceInheritance.js +93 -0
- package/esm/policies/WorkspaceInheritance.js.map +1 -0
- package/esm/policies/WorkspaceMembersValid.d.ts +27 -0
- package/esm/policies/WorkspaceMembersValid.d.ts.map +1 -0
- package/esm/policies/WorkspaceMembersValid.js +87 -0
- package/esm/policies/WorkspaceMembersValid.js.map +1 -0
- package/esm/policies/constants.d.ts +8 -0
- package/esm/policies/constants.d.ts.map +1 -1
- package/esm/policies/constants.js +9 -1
- package/esm/policies/constants.js.map +1 -1
- package/esm/policies.d.ts +43 -5
- package/esm/policies.d.ts.map +1 -1
- package/esm/policies.js +63 -6
- package/esm/policies.js.map +1 -1
- package/esm/policy.d.ts +65 -269
- 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 +82 -0
- package/esm/policyDefiners/defineCargoPolicy.d.ts.map +1 -0
- package/esm/policyDefiners/defineCargoPolicy.js +42 -0
- package/esm/policyDefiners/defineCargoPolicy.js.map +1 -0
- package/esm/policyDefiners/defineFileHeaderPolicy.d.ts +27 -14
- package/esm/policyDefiners/defineFileHeaderPolicy.d.ts.map +1 -1
- package/esm/policyDefiners/defineFileHeaderPolicy.js +19 -39
- package/esm/policyDefiners/defineFileHeaderPolicy.js.map +1 -1
- package/esm/policyDefiners/defineGleamPolicy.d.ts +81 -0
- package/esm/policyDefiners/defineGleamPolicy.d.ts.map +1 -0
- package/esm/policyDefiners/defineGleamPolicy.js +42 -0
- package/esm/policyDefiners/defineGleamPolicy.js.map +1 -0
- 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 +66 -0
- package/esm/policyDefiners/spdxValidator.d.ts.map +1 -0
- package/esm/policyDefiners/spdxValidator.js +139 -0
- package/esm/policyDefiners/spdxValidator.js.map +1 -0
- package/esm/policyDefiners/tomlParser.d.ts +8 -0
- package/esm/policyDefiners/tomlParser.d.ts.map +1 -0
- package/esm/policyDefiners/tomlParser.js +17 -0
- package/esm/policyDefiners/tomlParser.js.map +1 -0
- package/esm/policyExecution.d.ts +19 -0
- package/esm/policyExecution.d.ts.map +1 -0
- package/esm/policyExecution.js +224 -0
- package/esm/policyExecution.js.map +1 -0
- package/esm/repositoryFiles.d.ts +4 -0
- package/esm/repositoryFiles.d.ts.map +1 -0
- package/esm/repositoryFiles.js +8 -0
- package/esm/repositoryFiles.js.map +1 -0
- package/esm/runner.d.ts +85 -0
- package/esm/runner.d.ts.map +1 -0
- package/esm/runner.js +189 -0
- package/esm/runner.js.map +1 -0
- 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 +117 -3
- package/package.json +66 -36
- package/scripts/benchmark.mjs +341 -0
- package/scripts/postinstall.mjs +154 -0
- package/sidecar/sidecar.mjs +399 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { resolve } from "pathe";
|
|
3
|
+
import { defineGleamPolicy, } from "../policyDefiners/defineGleamPolicy.js";
|
|
4
|
+
const DEFAULT_SORTED_SECTIONS = ["dependencies", "dev-dependencies"];
|
|
5
|
+
const SECTION_HEADER_REGEX = /^\[([^\]]+)\]\s*$/;
|
|
6
|
+
const KEY_VALUE_REGEX = /^(\S+)\s*=/;
|
|
7
|
+
function isSorted(keys) {
|
|
8
|
+
for (let i = 1; i < keys.length; i++) {
|
|
9
|
+
const prev = keys[i - 1];
|
|
10
|
+
const curr = keys[i];
|
|
11
|
+
if (prev !== undefined && curr !== undefined && curr < prev) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
function classifyLine(line) {
|
|
18
|
+
if (SECTION_HEADER_REGEX.test(line)) {
|
|
19
|
+
return "section";
|
|
20
|
+
}
|
|
21
|
+
if (line.trim() === "") {
|
|
22
|
+
return "blank";
|
|
23
|
+
}
|
|
24
|
+
if (line.trim().startsWith("#")) {
|
|
25
|
+
return "comment";
|
|
26
|
+
}
|
|
27
|
+
if (KEY_VALUE_REGEX.test(line)) {
|
|
28
|
+
return "key";
|
|
29
|
+
}
|
|
30
|
+
return "continuation";
|
|
31
|
+
}
|
|
32
|
+
function handleCommentLine(entryLine, currentEntry) {
|
|
33
|
+
if (currentEntry) {
|
|
34
|
+
currentEntry.lines.push(entryLine);
|
|
35
|
+
return currentEntry;
|
|
36
|
+
}
|
|
37
|
+
return { key: "", lines: [entryLine] };
|
|
38
|
+
}
|
|
39
|
+
function processKeyLine(entryLine, currentEntry, entries) {
|
|
40
|
+
if (currentEntry) {
|
|
41
|
+
entries.push(currentEntry);
|
|
42
|
+
}
|
|
43
|
+
const keyMatch = entryLine.match(KEY_VALUE_REGEX);
|
|
44
|
+
return { key: keyMatch?.[1] ?? "", lines: [entryLine] };
|
|
45
|
+
}
|
|
46
|
+
function collectSectionEntries(lines, startIndex) {
|
|
47
|
+
const entries = [];
|
|
48
|
+
let currentEntry;
|
|
49
|
+
let i = startIndex;
|
|
50
|
+
while (i < lines.length) {
|
|
51
|
+
const entryLine = lines[i] ?? "";
|
|
52
|
+
const kind = classifyLine(entryLine);
|
|
53
|
+
if (kind === "section") {
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
switch (kind) {
|
|
57
|
+
case "blank": {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
case "comment": {
|
|
61
|
+
currentEntry = handleCommentLine(entryLine, currentEntry);
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
case "key": {
|
|
65
|
+
currentEntry = processKeyLine(entryLine, currentEntry, entries);
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case "continuation": {
|
|
69
|
+
currentEntry?.lines.push(entryLine);
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
default: {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
i++;
|
|
77
|
+
}
|
|
78
|
+
if (currentEntry) {
|
|
79
|
+
entries.push(currentEntry);
|
|
80
|
+
}
|
|
81
|
+
return { entries, endIndex: i };
|
|
82
|
+
}
|
|
83
|
+
function sortTomlSections(content, sectionsToSort) {
|
|
84
|
+
const lines = content.split("\n");
|
|
85
|
+
const result = [];
|
|
86
|
+
let i = 0;
|
|
87
|
+
while (i < lines.length) {
|
|
88
|
+
const line = lines[i] ?? "";
|
|
89
|
+
const sectionMatch = line.match(SECTION_HEADER_REGEX);
|
|
90
|
+
if (sectionMatch && sectionsToSort.includes(sectionMatch[1] ?? "")) {
|
|
91
|
+
result.push(line);
|
|
92
|
+
i++;
|
|
93
|
+
const { entries, endIndex } = collectSectionEntries(lines, i);
|
|
94
|
+
entries.sort((a, b) => a.key.localeCompare(b.key));
|
|
95
|
+
for (const entry of entries) {
|
|
96
|
+
result.push(...entry.lines);
|
|
97
|
+
}
|
|
98
|
+
i = endIndex;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
result.push(line);
|
|
102
|
+
i++;
|
|
103
|
+
}
|
|
104
|
+
return result.join("\n");
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A policy that ensures dependency sections in gleam.toml are sorted alphabetically.
|
|
108
|
+
*
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
export const GleamTomlSorted = defineGleamPolicy({
|
|
112
|
+
name: "GleamTomlSorted",
|
|
113
|
+
description: "Ensures dependency sections in gleam.toml are sorted alphabetically.",
|
|
114
|
+
handler: async (toml, { file, root, resolve: shouldResolve, config }) => {
|
|
115
|
+
const sections = config?.sections ?? DEFAULT_SORTED_SECTIONS;
|
|
116
|
+
const unsortedSections = [];
|
|
117
|
+
for (const section of sections) {
|
|
118
|
+
const sectionData = toml[section];
|
|
119
|
+
if (sectionData !== undefined && !isSorted(Object.keys(sectionData))) {
|
|
120
|
+
unsortedSections.push(section);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (unsortedSections.length === 0) {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
if (shouldResolve) {
|
|
127
|
+
try {
|
|
128
|
+
const filePath = resolve(root, file);
|
|
129
|
+
const content = await readFile(filePath, "utf-8");
|
|
130
|
+
const sorted = sortTomlSections(content, unsortedSections);
|
|
131
|
+
await writeFile(filePath, sorted);
|
|
132
|
+
return [
|
|
133
|
+
{
|
|
134
|
+
message: `Unsorted sections: [${unsortedSections.join("], [")}]`,
|
|
135
|
+
fixStatus: "fixed",
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return [
|
|
141
|
+
{
|
|
142
|
+
message: `Unsorted sections: [${unsortedSections.join("], [")}]. Auto-fix failed.`,
|
|
143
|
+
fixStatus: "failed",
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return [
|
|
149
|
+
{
|
|
150
|
+
message: `Unsorted sections: [${unsortedSections.join("], [")}]`,
|
|
151
|
+
fixStatus: "available",
|
|
152
|
+
manualFix: "Sort the dependency keys alphabetically in the listed sections.",
|
|
153
|
+
},
|
|
154
|
+
];
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
//# sourceMappingURL=GleamTomlSorted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GleamTomlSorted.js","sourceRoot":"","sources":["../../src/policies/GleamTomlSorted.ts"],"names":[],"mappings":"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","sourcesContent":["import { readFile, writeFile } from \"node:fs/promises\";\nimport { resolve } from \"pathe\";\nimport type { FilePolicyDefinition } from \"../policy.js\";\nimport {\n\tdefineGleamPolicy,\n\ttype GleamToml,\n} from \"../policyDefiners/defineGleamPolicy.js\";\n\n/**\n * Configuration for the GleamTomlSorted policy.\n *\n * @public\n */\nexport interface GleamTomlSortedConfig {\n\t/**\n\t * Sections whose keys should be sorted alphabetically.\n\t * @defaultValue [\"dependencies\", \"dev-dependencies\"]\n\t */\n\tsections?: string[];\n}\n\nconst DEFAULT_SORTED_SECTIONS = [\"dependencies\", \"dev-dependencies\"];\n\nconst SECTION_HEADER_REGEX = /^\\[([^\\]]+)\\]\\s*$/;\nconst KEY_VALUE_REGEX = /^(\\S+)\\s*=/;\n\nfunction isSorted(keys: string[]): boolean {\n\tfor (let i = 1; i < keys.length; i++) {\n\t\tconst prev = keys[i - 1];\n\t\tconst curr = keys[i];\n\t\tif (prev !== undefined && curr !== undefined && curr < prev) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\ninterface TomlEntry {\n\tkey: string;\n\tlines: string[];\n}\n\nfunction classifyLine(\n\tline: string,\n): \"section\" | \"blank\" | \"comment\" | \"key\" | \"continuation\" {\n\tif (SECTION_HEADER_REGEX.test(line)) {\n\t\treturn \"section\";\n\t}\n\tif (line.trim() === \"\") {\n\t\treturn \"blank\";\n\t}\n\tif (line.trim().startsWith(\"#\")) {\n\t\treturn \"comment\";\n\t}\n\tif (KEY_VALUE_REGEX.test(line)) {\n\t\treturn \"key\";\n\t}\n\treturn \"continuation\";\n}\n\nfunction handleCommentLine(\n\tentryLine: string,\n\tcurrentEntry: TomlEntry | undefined,\n): TomlEntry {\n\tif (currentEntry) {\n\t\tcurrentEntry.lines.push(entryLine);\n\t\treturn currentEntry;\n\t}\n\treturn { key: \"\", lines: [entryLine] };\n}\n\nfunction processKeyLine(\n\tentryLine: string,\n\tcurrentEntry: TomlEntry | undefined,\n\tentries: TomlEntry[],\n): TomlEntry {\n\tif (currentEntry) {\n\t\tentries.push(currentEntry);\n\t}\n\tconst keyMatch = entryLine.match(KEY_VALUE_REGEX);\n\treturn { key: keyMatch?.[1] ?? \"\", lines: [entryLine] };\n}\n\nfunction collectSectionEntries(\n\tlines: string[],\n\tstartIndex: number,\n): {\n\tentries: TomlEntry[];\n\tendIndex: number;\n} {\n\tconst entries: TomlEntry[] = [];\n\tlet currentEntry: TomlEntry | undefined;\n\tlet i = startIndex;\n\n\twhile (i < lines.length) {\n\t\tconst entryLine = lines[i] ?? \"\";\n\t\tconst kind = classifyLine(entryLine);\n\n\t\tif (kind === \"section\") {\n\t\t\tbreak;\n\t\t}\n\n\t\tswitch (kind) {\n\t\t\tcase \"blank\": {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"comment\": {\n\t\t\t\tcurrentEntry = handleCommentLine(entryLine, currentEntry);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"key\": {\n\t\t\t\tcurrentEntry = processKeyLine(entryLine, currentEntry, entries);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"continuation\": {\n\t\t\t\tcurrentEntry?.lines.push(entryLine);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\ti++;\n\t}\n\tif (currentEntry) {\n\t\tentries.push(currentEntry);\n\t}\n\treturn { entries, endIndex: i };\n}\n\nfunction sortTomlSections(content: string, sectionsToSort: string[]): string {\n\tconst lines = content.split(\"\\n\");\n\tconst result: string[] = [];\n\tlet i = 0;\n\n\twhile (i < lines.length) {\n\t\tconst line = lines[i] ?? \"\";\n\t\tconst sectionMatch = line.match(SECTION_HEADER_REGEX);\n\n\t\tif (sectionMatch && sectionsToSort.includes(sectionMatch[1] ?? \"\")) {\n\t\t\tresult.push(line);\n\t\t\ti++;\n\t\t\tconst { entries, endIndex } = collectSectionEntries(lines, i);\n\t\t\tentries.sort((a, b) => a.key.localeCompare(b.key));\n\t\t\tfor (const entry of entries) {\n\t\t\t\tresult.push(...entry.lines);\n\t\t\t}\n\t\t\ti = endIndex;\n\t\t\tcontinue;\n\t\t}\n\n\t\tresult.push(line);\n\t\ti++;\n\t}\n\n\treturn result.join(\"\\n\");\n}\n\n/**\n * A policy that ensures dependency sections in gleam.toml are sorted alphabetically.\n *\n * @public\n */\nexport const GleamTomlSorted = defineGleamPolicy({\n\tname: \"GleamTomlSorted\",\n\tdescription:\n\t\t\"Ensures dependency sections in gleam.toml are sorted alphabetically.\",\n\thandler: async (\n\t\ttoml: GleamToml,\n\t\t{ file, root, resolve: shouldResolve, config },\n\t) => {\n\t\tconst sections = config?.sections ?? DEFAULT_SORTED_SECTIONS;\n\t\tconst unsortedSections: string[] = [];\n\n\t\tfor (const section of sections) {\n\t\t\tconst sectionData = toml[section] as Record<string, unknown> | undefined;\n\t\t\tif (sectionData !== undefined && !isSorted(Object.keys(sectionData))) {\n\t\t\t\tunsortedSections.push(section);\n\t\t\t}\n\t\t}\n\n\t\tif (unsortedSections.length === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tif (shouldResolve) {\n\t\t\ttry {\n\t\t\t\tconst filePath = resolve(root, file);\n\t\t\t\tconst content = await readFile(filePath, \"utf-8\");\n\t\t\t\tconst sorted = sortTomlSections(content, unsortedSections);\n\t\t\t\tawait writeFile(filePath, sorted);\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tmessage: `Unsorted sections: [${unsortedSections.join(\"], [\")}]`,\n\t\t\t\t\t\tfixStatus: \"fixed\",\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t} catch {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tmessage: `Unsorted sections: [${unsortedSections.join(\"], [\")}]. Auto-fix failed.`,\n\t\t\t\t\t\tfixStatus: \"failed\",\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\tmessage: `Unsorted sections: [${unsortedSections.join(\"], [\")}]`,\n\t\t\t\tfixStatus: \"available\",\n\t\t\t\tmanualFix:\n\t\t\t\t\t\"Sort the dependency keys alphabetically in the listed sections.\",\n\t\t\t},\n\t\t];\n\t},\n}) satisfies FilePolicyDefinition<GleamTomlSortedConfig>;\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FilePolicyDefinition } from "../policy.js";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for the GleamVersionConstraint policy.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface GleamVersionConstraintConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Minimum Gleam compiler version to require (e.g., "1.0.0").
|
|
10
|
+
* If set, the constraint must specify at least this version.
|
|
11
|
+
*/
|
|
12
|
+
minimumVersion?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A policy that ensures the Gleam compiler version constraint is set in gleam.toml.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare const GleamVersionConstraint: FilePolicyDefinition<GleamVersionConstraintConfig>;
|
|
20
|
+
//# sourceMappingURL=GleamVersionConstraint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GleamVersionConstraint.d.ts","sourceRoot":"","sources":["../../src/policies/GleamVersionConstraint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMzD;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAyCD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,oDA8B4B,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { defineGleamPolicy, } from "../policyDefiners/defineGleamPolicy.js";
|
|
2
|
+
const SEMVER_PREFIX_REGEX = /^[><=~^!\s]+/;
|
|
3
|
+
/**
|
|
4
|
+
* Parse a simple semver string into comparable parts.
|
|
5
|
+
*/
|
|
6
|
+
function parseSemver(version) {
|
|
7
|
+
const cleaned = version.replace(SEMVER_PREFIX_REGEX, "").trim();
|
|
8
|
+
const parts = cleaned.split(".");
|
|
9
|
+
if (parts.length < 2) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const major = Number.parseInt(parts[0] ?? "0", 10);
|
|
13
|
+
const minor = Number.parseInt(parts[1] ?? "0", 10);
|
|
14
|
+
const patch = Number.parseInt(parts[2] ?? "0", 10);
|
|
15
|
+
if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch)) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return [major, minor, patch];
|
|
19
|
+
}
|
|
20
|
+
function isVersionAtLeast(constraint, minimum) {
|
|
21
|
+
const constraintParts = parseSemver(constraint);
|
|
22
|
+
const minimumParts = parseSemver(minimum);
|
|
23
|
+
if (!(constraintParts && minimumParts)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
for (let i = 0; i < 3; i++) {
|
|
27
|
+
const c = constraintParts[i] ?? 0;
|
|
28
|
+
const m = minimumParts[i] ?? 0;
|
|
29
|
+
if (c > m) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if (c < m) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A policy that ensures the Gleam compiler version constraint is set in gleam.toml.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export const GleamVersionConstraint = defineGleamPolicy({
|
|
44
|
+
name: "GleamVersionConstraint",
|
|
45
|
+
description: "Ensures gleam.toml has a Gleam compiler version constraint to prevent incompatible builds.",
|
|
46
|
+
handler: async (toml, { config }) => {
|
|
47
|
+
const gleamVersion = toml.gleam;
|
|
48
|
+
if (gleamVersion === undefined || gleamVersion === "") {
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
message: "Missing gleam version constraint in gleam.toml.",
|
|
52
|
+
manualFix: 'Add gleam = ">= 1.0.0" (or appropriate version) to gleam.toml.',
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
if (config?.minimumVersion &&
|
|
57
|
+
!isVersionAtLeast(gleamVersion, config.minimumVersion)) {
|
|
58
|
+
return [
|
|
59
|
+
{
|
|
60
|
+
message: `Gleam version constraint "${gleamVersion}" is below minimum "${config.minimumVersion}".`,
|
|
61
|
+
manualFix: `Update to gleam = ">= ${config.minimumVersion}" or higher.`,
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
return [];
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=GleamVersionConstraint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GleamVersionConstraint.js","sourceRoot":"","sources":["../../src/policies/GleamVersionConstraint.ts"],"names":[],"mappings":"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","sourcesContent":["import type { FilePolicyDefinition } from \"../policy.js\";\nimport {\n\tdefineGleamPolicy,\n\ttype GleamToml,\n} from \"../policyDefiners/defineGleamPolicy.js\";\n\n/**\n * Configuration for the GleamVersionConstraint policy.\n *\n * @public\n */\nexport interface GleamVersionConstraintConfig {\n\t/**\n\t * Minimum Gleam compiler version to require (e.g., \"1.0.0\").\n\t * If set, the constraint must specify at least this version.\n\t */\n\tminimumVersion?: string;\n}\n\nconst SEMVER_PREFIX_REGEX = /^[><=~^!\\s]+/;\n\n/**\n * Parse a simple semver string into comparable parts.\n */\nfunction parseSemver(version: string): [number, number, number] | undefined {\n\tconst cleaned = version.replace(SEMVER_PREFIX_REGEX, \"\").trim();\n\tconst parts = cleaned.split(\".\");\n\tif (parts.length < 2) {\n\t\treturn undefined;\n\t}\n\tconst major = Number.parseInt(parts[0] ?? \"0\", 10);\n\tconst minor = Number.parseInt(parts[1] ?? \"0\", 10);\n\tconst patch = Number.parseInt(parts[2] ?? \"0\", 10);\n\tif (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch)) {\n\t\treturn undefined;\n\t}\n\treturn [major, minor, patch];\n}\n\nfunction isVersionAtLeast(constraint: string, minimum: string): boolean {\n\tconst constraintParts = parseSemver(constraint);\n\tconst minimumParts = parseSemver(minimum);\n\tif (!(constraintParts && minimumParts)) {\n\t\treturn false;\n\t}\n\tfor (let i = 0; i < 3; i++) {\n\t\tconst c = constraintParts[i] ?? 0;\n\t\tconst m = minimumParts[i] ?? 0;\n\t\tif (c > m) {\n\t\t\treturn true;\n\t\t}\n\t\tif (c < m) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * A policy that ensures the Gleam compiler version constraint is set in gleam.toml.\n *\n * @public\n */\nexport const GleamVersionConstraint = defineGleamPolicy({\n\tname: \"GleamVersionConstraint\",\n\tdescription:\n\t\t\"Ensures gleam.toml has a Gleam compiler version constraint to prevent incompatible builds.\",\n\thandler: async (toml: GleamToml, { config }) => {\n\t\tconst gleamVersion = toml.gleam as string | undefined;\n\n\t\tif (gleamVersion === undefined || gleamVersion === \"\") {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tmessage: \"Missing gleam version constraint in gleam.toml.\",\n\t\t\t\t\tmanualFix:\n\t\t\t\t\t\t'Add gleam = \">= 1.0.0\" (or appropriate version) to gleam.toml.',\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tif (\n\t\t\tconfig?.minimumVersion &&\n\t\t\t!isVersionAtLeast(gleamVersion, config.minimumVersion)\n\t\t) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tmessage: `Gleam version constraint \"${gleamVersion}\" is below minimum \"${config.minimumVersion}\".`,\n\t\t\t\t\tmanualFix: `Update to gleam = \">= ${config.minimumVersion}\" or higher.`,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\treturn [];\n\t},\n}) satisfies FilePolicyDefinition<GleamVersionConstraintConfig>;\n"]}
|
|
@@ -2,7 +2,9 @@ import { type FileHeaderPolicyConfig } from "../policyDefiners/defineFileHeaderP
|
|
|
2
2
|
/**
|
|
3
3
|
* A RepoPolicy that checks that HTML files have the configured header comment.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
5
|
+
* @public
|
|
6
6
|
*/
|
|
7
|
-
export declare const HtmlFileHeaders: import("../policy.js").
|
|
7
|
+
export declare const HtmlFileHeaders: import("../policy.js").FilePolicyDefinition<FileHeaderPolicyConfig> & {
|
|
8
|
+
requiresConfig: true;
|
|
9
|
+
};
|
|
8
10
|
//# sourceMappingURL=HtmlFileHeaders.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HtmlFileHeaders.d.ts","sourceRoot":"","sources":["../../src/policies/HtmlFileHeaders.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,sBAAsB,EAC3B,MAAM,6CAA6C,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"HtmlFileHeaders.d.ts","sourceRoot":"","sources":["../../src/policies/HtmlFileHeaders.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,sBAAsB,EAC3B,MAAM,6CAA6C,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,eAAe;;CAe1B,CAAC"}
|
|
@@ -3,13 +3,13 @@ import { defineFileHeaderPolicy, } from "../policyDefiners/defineFileHeaderPolic
|
|
|
3
3
|
/**
|
|
4
4
|
* A RepoPolicy that checks that HTML files have the configured header comment.
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
6
|
+
* @public
|
|
7
7
|
*/
|
|
8
8
|
export const HtmlFileHeaders = defineFileHeaderPolicy({
|
|
9
9
|
name: "HtmlFileHeaders",
|
|
10
10
|
description: "Ensures HTML files have the configured header comment.",
|
|
11
11
|
config: {
|
|
12
|
-
match: /(^|\/)[^/]+\.
|
|
12
|
+
match: /(^|\/)[^/]+\.html?$/i,
|
|
13
13
|
lineStart: /<!-- /, // Lines begin with '<!-- '
|
|
14
14
|
lineEnd: / -->\r?\n/, // Lines end with ' -->' followed by CRLF or LF
|
|
15
15
|
replacer: (content, { headerText }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HtmlFileHeaders.js","sourceRoot":"","sources":["../../src/policies/HtmlFileHeaders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EACN,sBAAsB,GAEtB,MAAM,6CAA6C,CAAC;AAErD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC;IACrD,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,wDAAwD;IACrE,MAAM,EAAE;QACP,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"HtmlFileHeaders.js","sourceRoot":"","sources":["../../src/policies/HtmlFileHeaders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EACN,sBAAsB,GAEtB,MAAM,6CAA6C,CAAC;AAErD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC;IACrD,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,wDAAwD;IACrE,MAAM,EAAE;QACP,KAAK,EAAE,sBAAsB;QAC7B,SAAS,EAAE,OAAO,EAAE,2BAA2B;QAC/C,OAAO,EAAE,WAAW,EAAE,+CAA+C;QACrE,QAAQ,EAAE,CACT,OAAe,EACf,EAAE,UAAU,EAA0B,EAC7B,EAAE;YACX,MAAM,UAAU,GAAG,QAAQ,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,OAAO,OAAO,CAAC,OAAO,OAAO,GAAG,OAAO,GAAG,OAAO,EAAE,CAAC;YAClH,OAAO,UAAU,CAAC;QACnB,CAAC;KACD;CACD,CAAC,CAAC","sourcesContent":["import { EOL as newline } from \"node:os\";\nimport {\n\tdefineFileHeaderPolicy,\n\ttype FileHeaderPolicyConfig,\n} from \"../policyDefiners/defineFileHeaderPolicy.js\";\n\n/**\n * A RepoPolicy that checks that HTML files have the configured header comment.\n *\n * @public\n */\nexport const HtmlFileHeaders = defineFileHeaderPolicy({\n\tname: \"HtmlFileHeaders\",\n\tdescription: \"Ensures HTML files have the configured header comment.\",\n\tconfig: {\n\t\tmatch: /(^|\\/)[^/]+\\.html?$/i,\n\t\tlineStart: /<!-- /, // Lines begin with '<!-- '\n\t\tlineEnd: / -->\\r?\\n/, // Lines end with ' -->' followed by CRLF or LF\n\t\treplacer: (\n\t\t\tcontent: string,\n\t\t\t{ headerText }: FileHeaderPolicyConfig,\n\t\t): string => {\n\t\t\tconst newContent = `<!-- ${headerText.replace(newline, ` -->${newline}<!-- `)} -->${newline}${newline}${content}`;\n\t\t\treturn newContent;\n\t\t},\n\t},\n});\n"]}
|
|
@@ -2,7 +2,9 @@ import { type FileHeaderPolicyConfig } from "../policyDefiners/defineFileHeaderP
|
|
|
2
2
|
/**
|
|
3
3
|
* A RepoPolicy that checks that JavaScript and TypeScript source files have the configured header comment
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
5
|
+
* @public
|
|
6
6
|
*/
|
|
7
|
-
export declare const JsTsFileHeaders: import("../policy.js").
|
|
7
|
+
export declare const JsTsFileHeaders: import("../policy.js").FilePolicyDefinition<FileHeaderPolicyConfig> & {
|
|
8
|
+
requiresConfig: true;
|
|
9
|
+
};
|
|
8
10
|
//# sourceMappingURL=JsTsFileHeaders.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsTsFileHeaders.d.ts","sourceRoot":"","sources":["../../src/policies/JsTsFileHeaders.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,sBAAsB,EAC3B,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"JsTsFileHeaders.d.ts","sourceRoot":"","sources":["../../src/policies/JsTsFileHeaders.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,sBAAsB,EAC3B,MAAM,6CAA6C,CAAC;AAerD;;;;GAIG;AACH,eAAO,MAAM,eAAe;;CAY1B,CAAC"}
|
|
@@ -11,7 +11,7 @@ const jsTsReplacer = (prevContent, { headerText }) => {
|
|
|
11
11
|
/**
|
|
12
12
|
* A RepoPolicy that checks that JavaScript and TypeScript source files have the configured header comment
|
|
13
13
|
*
|
|
14
|
-
* @
|
|
14
|
+
* @public
|
|
15
15
|
*/
|
|
16
16
|
export const JsTsFileHeaders = defineFileHeaderPolicy({
|
|
17
17
|
name: "JsTsFileHeaders",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsTsFileHeaders.js","sourceRoot":"","sources":["../../src/policies/JsTsFileHeaders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EACN,sBAAsB,GAEtB,MAAM,6CAA6C,CAAC;AAErD,MAAM,YAAY,GAAG,CACpB,WAAmB,EACnB,EAAE,UAAU,EAA0B,EAC7B,EAAE;IACX,qCAAqC;IACrC,MAAM,SAAS,GACd,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC;QAC3D,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC;IACtB,MAAM,UAAU,GAAG,MAAM,OAAO,MAAM,UAAU,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"JsTsFileHeaders.js","sourceRoot":"","sources":["../../src/policies/JsTsFileHeaders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EACN,sBAAsB,GAEtB,MAAM,6CAA6C,CAAC;AAErD,MAAM,YAAY,GAAG,CACpB,WAAmB,EACnB,EAAE,UAAU,EAA0B,EAC7B,EAAE;IACX,qCAAqC;IACrC,MAAM,SAAS,GACd,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC;QAC3D,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC;IACtB,MAAM,UAAU,GAAG,MAAM,OAAO,MAAM,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,OAAO,KAAK,CAAC,GAAG,OAAO,MAAM,SAAS,GAAG,WAAW,EAAE,CAAC;IAC5H,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC;IACrD,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACV,oFAAoF;IACrF,MAAM,EAAE;QACP,KAAK,EAAE,6BAA6B;QACpC,WAAW,EAAE,4BAA4B,EAAE,kDAAkD;QAC7F,SAAS,EAAE,MAAM,EAAE,qCAAqC;QACxD,OAAO,EAAE,OAAO,EAAE,uCAAuC;QACzD,SAAS,EAAE,iBAAiB,EAAE,0EAA0E;QACxG,QAAQ,EAAE,YAAY;KACtB;CACD,CAAC,CAAC","sourcesContent":["import { EOL as newline } from \"node:os\";\nimport {\n\tdefineFileHeaderPolicy,\n\ttype FileHeaderPolicyConfig,\n} from \"../policyDefiners/defineFileHeaderPolicy.js\";\n\nconst jsTsReplacer = (\n\tprevContent: string,\n\t{ headerText }: FileHeaderPolicyConfig,\n): string => {\n\t// prepend header to existing content\n\tconst separator =\n\t\tprevContent.startsWith(\"\\r\") || prevContent.startsWith(\"\\n\")\n\t\t\t? newline\n\t\t\t: newline + newline;\n\tconst newContent = `/*!${newline} * ${headerText.replace(newline, `${newline} * `)}${newline} */${separator}${prevContent}`;\n\treturn newContent;\n};\n\n/**\n * A RepoPolicy that checks that JavaScript and TypeScript source files have the configured header comment\n *\n * @public\n */\nexport const JsTsFileHeaders = defineFileHeaderPolicy({\n\tname: \"JsTsFileHeaders\",\n\tdescription:\n\t\t\"Ensures JavaScript and TypeScript source files have the configured header comment.\",\n\tconfig: {\n\t\tmatch: /(^|\\/)[^/]+\\.[mc]?[jt]sx?$/i,\n\t\theaderStart: /(#![^\\n]*\\r?\\n)?\\/\\*!\\r?\\n/, // Begins with optional hashbang followed by '/*!'\n\t\tlineStart: / \\* /, // Subsequent lines begins with ' * '\n\t\tlineEnd: /\\r?\\n/, // Subsequent lines end with CRLF or LF\n\t\theaderEnd: / \\*\\/\\r?\\n\\r?\\n/, // Header ends with ' */' on a line by itself, followed by another newline\n\t\treplacer: jsTsReplacer,\n\t},\n});\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { PolicyDefinition } from "../policy.js";
|
|
2
1
|
/**
|
|
3
2
|
* Policy settings for the LicenseFileExists repo policy.
|
|
4
3
|
*
|
|
5
|
-
* @
|
|
4
|
+
* @public
|
|
6
5
|
*/
|
|
7
6
|
export interface LicenseFileExistsSettings {
|
|
8
7
|
/**
|
|
@@ -14,7 +13,14 @@ export interface LicenseFileExistsSettings {
|
|
|
14
13
|
* A repo policy that checks that a LICENSE file exists in the repository root.
|
|
15
14
|
* This is essential for open source projects to clarify usage rights and obligations.
|
|
16
15
|
*
|
|
17
|
-
* @
|
|
16
|
+
* @public
|
|
18
17
|
*/
|
|
19
|
-
export declare const LicenseFileExists:
|
|
18
|
+
export declare const LicenseFileExists: {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
scope: "repository";
|
|
22
|
+
handler: ({ root, files, config }: import("../policy.js").RepositoryPolicyArgs<LicenseFileExistsSettings>) => Promise<{
|
|
23
|
+
message: string;
|
|
24
|
+
}[]>;
|
|
25
|
+
};
|
|
20
26
|
//# sourceMappingURL=LicenseFileExists.d.ts.map
|
|
@@ -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"]}
|
|
@@ -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"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Operation } from "effection";
|
|
2
|
+
import type { PolicyFinding } from "../policy.js";
|
|
3
|
+
/**
|
|
4
|
+
* A policy that prevents accidental commits of build directory contents.
|
|
5
|
+
* Applies to Gleam's `build/` output directory.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
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
|
+
};
|
|
15
|
+
//# sourceMappingURL=NoBuildDirectory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|