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":"GleamProjectStructure.d.ts","sourceRoot":"","sources":["../../src/policies/GleamProjectStructure.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"GleamProjectStructure.d.ts","sourceRoot":"","sources":["../../src/policies/GleamProjectStructure.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC3C;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;CA6B2B,CAAC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import path from "pathe";
|
|
3
|
-
import { makePolicyDefinition } from "../makePolicy.js";
|
|
4
3
|
/**
|
|
5
4
|
* A policy that validates standard Gleam project structure.
|
|
6
5
|
*
|
|
7
|
-
* @
|
|
6
|
+
* @public
|
|
8
7
|
*/
|
|
9
|
-
export const GleamProjectStructure =
|
|
8
|
+
export const GleamProjectStructure = {
|
|
10
9
|
name: "GleamProjectStructure",
|
|
11
10
|
description: "Validates that Gleam projects have the standard directory structure (src/, test/).",
|
|
12
11
|
match: /gleam\.toml$/,
|
|
@@ -22,12 +21,12 @@ export const GleamProjectStructure = makePolicyDefinition({
|
|
|
22
21
|
errors.push("Missing test/ directory.");
|
|
23
22
|
}
|
|
24
23
|
if (errors.length > 0) {
|
|
25
|
-
return {
|
|
26
|
-
|
|
24
|
+
return errors.map((message) => ({
|
|
25
|
+
message,
|
|
27
26
|
manualFix: "Create the missing directories in your Gleam project.",
|
|
28
|
-
};
|
|
27
|
+
}));
|
|
29
28
|
}
|
|
30
|
-
return
|
|
29
|
+
return [];
|
|
31
30
|
},
|
|
32
|
-
}
|
|
31
|
+
};
|
|
33
32
|
//# sourceMappingURL=GleamProjectStructure.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GleamProjectStructure.js","sourceRoot":"","sources":["../../src/policies/GleamProjectStructure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"GleamProjectStructure.js","sourceRoot":"","sources":["../../src/policies/GleamProjectStructure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,OAAO,CAAC;AAqBzB;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EACV,oFAAoF;IACrF,KAAK,EAAE,cAAc;IACrB,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;QACzC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QACnD,MAAM,UAAU,GAAG,MAAM,EAAE,aAAa,IAAI,IAAI,CAAC;QACjD,MAAM,WAAW,GAAG,MAAM,EAAE,cAAc,IAAI,KAAK,CAAC;QACpD,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,IAAI,UAAU,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;YACtD,MAAM,CAAC,IAAI,CACV,qFAAqF,CACrF,CAAC;QACH,CAAC;QAED,IAAI,WAAW,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;YACxD,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACzC,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;gBAC/B,OAAO;gBACP,SAAS,EAAE,uDAAuD;aAClE,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CAC2D,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport path from \"pathe\";\nimport type { FilePolicyDefinition } from \"../policy.js\";\n/**\n * Configuration for the GleamProjectStructure policy.\n *\n * @public\n */\nexport interface GleamProjectStructureConfig {\n\t/**\n\t * If true, require the src/ directory to exist.\n\t * @defaultValue true\n\t */\n\trequireSrcDir?: boolean;\n\n\t/**\n\t * If true, require the test/ directory to exist.\n\t * @defaultValue false\n\t */\n\trequireTestDir?: boolean;\n}\n\n/**\n * A policy that validates standard Gleam project structure.\n *\n * @public\n */\nexport const GleamProjectStructure = {\n\tname: \"GleamProjectStructure\",\n\tdescription:\n\t\t\"Validates that Gleam projects have the standard directory structure (src/, test/).\",\n\tmatch: /gleam\\.toml$/,\n\thandler: async ({ file, root, config }) => {\n\t\tconst dir = path.dirname(path.resolve(root, file));\n\t\tconst requireSrc = config?.requireSrcDir ?? true;\n\t\tconst requireTest = config?.requireTestDir ?? false;\n\t\tconst errors: string[] = [];\n\n\t\tif (requireSrc && !existsSync(path.join(dir, \"src\"))) {\n\t\t\terrors.push(\n\t\t\t\t\"Missing src/ directory. Gleam projects require a src/ directory for source modules.\",\n\t\t\t);\n\t\t}\n\n\t\tif (requireTest && !existsSync(path.join(dir, \"test\"))) {\n\t\t\terrors.push(\"Missing test/ directory.\");\n\t\t}\n\n\t\tif (errors.length > 0) {\n\t\t\treturn errors.map((message) => ({\n\t\t\t\tmessage,\n\t\t\t\tmanualFix: \"Create the missing directories in your Gleam project.\",\n\t\t\t}));\n\t\t}\n\t\treturn [];\n\t},\n} satisfies FilePolicyDefinition<GleamProjectStructureConfig>;\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { PolicyDefinition } from "../policy.js";
|
|
2
1
|
/**
|
|
3
2
|
* Configuration for the GleamSharedDependencyVersions policy.
|
|
4
3
|
*
|
|
5
|
-
* @
|
|
4
|
+
* @public
|
|
6
5
|
*/
|
|
7
6
|
export interface GleamSharedDependencyVersionsConfig {
|
|
8
7
|
/**
|
|
@@ -23,7 +22,16 @@ export interface GleamSharedDependencyVersionsConfig {
|
|
|
23
22
|
/**
|
|
24
23
|
* A policy that detects dependency version mismatches across Gleam packages in a monorepo.
|
|
25
24
|
*
|
|
26
|
-
* @
|
|
25
|
+
* @public
|
|
27
26
|
*/
|
|
28
|
-
export declare const GleamSharedDependencyVersions:
|
|
27
|
+
export declare const GleamSharedDependencyVersions: {
|
|
28
|
+
name: string;
|
|
29
|
+
requiresConfig: true;
|
|
30
|
+
description: string;
|
|
31
|
+
match: RegExp;
|
|
32
|
+
handler: ({ root, config }: import("../policy.js").PolicyArgs<GleamSharedDependencyVersionsConfig>) => Promise<{
|
|
33
|
+
message: string;
|
|
34
|
+
manualFix: string;
|
|
35
|
+
}[]>;
|
|
36
|
+
};
|
|
29
37
|
//# sourceMappingURL=GleamSharedDependencyVersions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GleamSharedDependencyVersions.d.ts","sourceRoot":"","sources":["../../src/policies/GleamSharedDependencyVersions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GleamSharedDependencyVersions.d.ts","sourceRoot":"","sources":["../../src/policies/GleamSharedDependencyVersions.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,WAAW,mCAAmC;IACnD;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AA2DD;;;;GAIG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;CAqD2B,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import path from "pathe";
|
|
3
|
-
import { makePolicyDefinition } from "../makePolicy.js";
|
|
4
3
|
import { parseToml } from "../policyDefiners/tomlParser.js";
|
|
5
4
|
function extractVersion(dep) {
|
|
6
5
|
if (typeof dep === "string") {
|
|
@@ -50,20 +49,21 @@ function recordDependency(allDeps, depName, version, pkgPath) {
|
|
|
50
49
|
/**
|
|
51
50
|
* A policy that detects dependency version mismatches across Gleam packages in a monorepo.
|
|
52
51
|
*
|
|
53
|
-
* @
|
|
52
|
+
* @public
|
|
54
53
|
*/
|
|
55
|
-
export const GleamSharedDependencyVersions =
|
|
54
|
+
export const GleamSharedDependencyVersions = {
|
|
56
55
|
name: "GleamSharedDependencyVersions",
|
|
56
|
+
requiresConfig: true,
|
|
57
57
|
description: "Detects dependency version mismatches across Gleam packages in a monorepo.",
|
|
58
58
|
match: /^gleam\.toml$/,
|
|
59
59
|
handler: async ({ root, config }) => {
|
|
60
60
|
const packagePaths = config?.packages;
|
|
61
61
|
if (!packagePaths || packagePaths.length < 2) {
|
|
62
|
-
return
|
|
62
|
+
return [];
|
|
63
63
|
}
|
|
64
64
|
const detectMismatches = config?.detectMismatches ?? true;
|
|
65
65
|
if (!detectMismatches) {
|
|
66
|
-
return
|
|
66
|
+
return [];
|
|
67
67
|
}
|
|
68
68
|
const includeDev = config?.includeDev ?? false;
|
|
69
69
|
const allDeps = new Map();
|
|
@@ -90,12 +90,12 @@ export const GleamSharedDependencyVersions = makePolicyDefinition({
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
if (errors.length > 0) {
|
|
93
|
-
return {
|
|
94
|
-
|
|
93
|
+
return errors.map((message) => ({
|
|
94
|
+
message,
|
|
95
95
|
manualFix: "Align dependency versions across all Gleam packages in the monorepo.",
|
|
96
|
-
};
|
|
96
|
+
}));
|
|
97
97
|
}
|
|
98
|
-
return
|
|
98
|
+
return [];
|
|
99
99
|
},
|
|
100
|
-
}
|
|
100
|
+
};
|
|
101
101
|
//# sourceMappingURL=GleamSharedDependencyVersions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GleamSharedDependencyVersions.js","sourceRoot":"","sources":["../../src/policies/GleamSharedDependencyVersions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"GleamSharedDependencyVersions.js","sourceRoot":"","sources":["../../src/policies/GleamSharedDependencyVersions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,OAAO,CAAC;AAEzB,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AA0B5D,SAAS,cAAc,CAAC,GAAY;IACnC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,GAAG,CAAC;IACZ,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,GAA8B,CAAC;QAC9C,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YACxC,OAAO,MAAM,CAAC,OAAO,CAAC;QACvB,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,SAAS,WAAW,CACnB,IAA6B,EAC7B,UAAmB;IAEnB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;IACvC,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,CAAC;IAClC,IAAI,UAAU,EAAE,CAAC;QAChB,QAAQ,CAAC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AAC,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;qBACvC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,QAAQ,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;qBACtD,IAAI,CAAC,IAAI,CAAC,CAAC;gBACb,MAAM,CAAC,IAAI,CAAC,yBAAyB,GAAG,MAAM,OAAO,EAAE,CAAC,CAAC;YAC1D,CAAC;QACF,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;gBAC/B,OAAO;gBACP,SAAS,EACR,sEAAsE;aACvE,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACmE,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport path from \"pathe\";\nimport type { FilePolicyDefinition } from \"../policy.js\";\nimport { parseToml } from \"../policyDefiners/tomlParser.js\";\n\n/**\n * Configuration for the GleamSharedDependencyVersions policy.\n *\n * @public\n */\nexport interface GleamSharedDependencyVersionsConfig {\n\t/**\n\t * If true, detect version mismatches across packages.\n\t * @defaultValue true\n\t */\n\tdetectMismatches?: boolean;\n\n\t/**\n\t * If true, also check dev-dependencies for mismatches.\n\t * @defaultValue false\n\t */\n\tincludeDev?: boolean;\n\n\t/**\n\t * Paths to gleam.toml files to compare (relative to repo root).\n\t */\n\tpackages?: string[];\n}\n\nfunction extractVersion(dep: unknown): string | undefined {\n\tif (typeof dep === \"string\") {\n\t\treturn dep;\n\t}\n\tif (typeof dep === \"object\" && dep !== null) {\n\t\tconst record = dep as Record<string, unknown>;\n\t\tif (typeof record.version === \"string\") {\n\t\t\treturn record.version;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction collectDeps(\n\ttoml: Record<string, unknown>,\n\tincludeDev: boolean,\n): Map<string, string> {\n\tconst deps = new Map<string, string>();\n\tconst sections = [\"dependencies\"];\n\tif (includeDev) {\n\t\tsections.push(\"dev-dependencies\");\n\t}\n\n\tfor (const section of sections) {\n\t\tconst sectionDeps = toml[section] as Record<string, unknown> | undefined;\n\t\tif (!sectionDeps) {\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const [name, value] of Object.entries(sectionDeps)) {\n\t\t\tconst version = extractVersion(value);\n\t\t\tif (version) {\n\t\t\t\tdeps.set(name, version);\n\t\t\t}\n\t\t}\n\t}\n\treturn deps;\n}\n\nfunction recordDependency(\n\tallDeps: Map<string, Map<string, string[]>>,\n\tdepName: string,\n\tversion: string,\n\tpkgPath: string,\n): void {\n\tif (!allDeps.has(depName)) {\n\t\tallDeps.set(depName, new Map());\n\t}\n\tconst versionMap = allDeps.get(depName);\n\tif (versionMap === undefined) {\n\t\treturn;\n\t}\n\tif (!versionMap.has(version)) {\n\t\tversionMap.set(version, []);\n\t}\n\tversionMap.get(version)?.push(pkgPath);\n}\n\n/**\n * A policy that detects dependency version mismatches across Gleam packages in a monorepo.\n *\n * @public\n */\nexport const GleamSharedDependencyVersions = {\n\tname: \"GleamSharedDependencyVersions\",\n\trequiresConfig: true,\n\tdescription:\n\t\t\"Detects dependency version mismatches across Gleam packages in a monorepo.\",\n\tmatch: /^gleam\\.toml$/,\n\thandler: async ({ root, config }) => {\n\t\tconst packagePaths = config?.packages;\n\t\tif (!packagePaths || packagePaths.length < 2) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst detectMismatches = config?.detectMismatches ?? true;\n\t\tif (!detectMismatches) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst includeDev = config?.includeDev ?? false;\n\t\tconst allDeps = new Map<string, Map<string, string[]>>();\n\n\t\tfor (const pkgPath of packagePaths) {\n\t\t\ttry {\n\t\t\t\tconst content = await readFile(path.resolve(root, pkgPath), \"utf-8\");\n\t\t\t\tconst toml = await parseToml(content);\n\t\t\t\tconst deps = collectDeps(toml, includeDev);\n\n\t\t\t\tfor (const [name, version] of deps) {\n\t\t\t\t\trecordDependency(allDeps, name, version, pkgPath);\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Package might not exist\n\t\t\t}\n\t\t}\n\n\t\tconst errors: string[] = [];\n\t\tfor (const [dep, versionMap] of allDeps) {\n\t\t\tif (versionMap.size > 1) {\n\t\t\t\tconst details = [...versionMap.entries()]\n\t\t\t\t\t.map(([ver, pkgs]) => `\"${ver}\" in ${pkgs.join(\", \")}`)\n\t\t\t\t\t.join(\"; \");\n\t\t\t\terrors.push(`Version mismatch for \"${dep}\": ${details}`);\n\t\t\t}\n\t\t}\n\n\t\tif (errors.length > 0) {\n\t\t\treturn errors.map((message) => ({\n\t\t\t\tmessage,\n\t\t\t\tmanualFix:\n\t\t\t\t\t\"Align dependency versions across all Gleam packages in the monorepo.\",\n\t\t\t}));\n\t\t}\n\t\treturn [];\n\t},\n} satisfies FilePolicyDefinition<GleamSharedDependencyVersionsConfig>;\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FilePolicyDefinition } from "../policy.js";
|
|
2
2
|
/**
|
|
3
3
|
* Configuration for the GleamTomlRequired policy.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
5
|
+
* @public
|
|
6
6
|
*/
|
|
7
7
|
export interface GleamTomlRequiredConfig {
|
|
8
8
|
/**
|
|
@@ -24,7 +24,7 @@ export interface GleamTomlRequiredConfig {
|
|
|
24
24
|
/**
|
|
25
25
|
* A policy that enforces required fields exist in gleam.toml.
|
|
26
26
|
*
|
|
27
|
-
* @
|
|
27
|
+
* @public
|
|
28
28
|
*/
|
|
29
|
-
export declare const GleamTomlRequired:
|
|
29
|
+
export declare const GleamTomlRequired: FilePolicyDefinition<GleamTomlRequiredConfig>;
|
|
30
30
|
//# sourceMappingURL=GleamTomlRequired.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GleamTomlRequired.d.ts","sourceRoot":"","sources":["../../src/policies/GleamTomlRequired.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"GleamTomlRequired.d.ts","sourceRoot":"","sources":["../../src/policies/GleamTomlRequired.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMzD;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAcD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,+CA4B4B,CAAC"}
|
|
@@ -12,7 +12,7 @@ function checkRequiredFields(toml, fields) {
|
|
|
12
12
|
/**
|
|
13
13
|
* A policy that enforces required fields exist in gleam.toml.
|
|
14
14
|
*
|
|
15
|
-
* @
|
|
15
|
+
* @public
|
|
16
16
|
*/
|
|
17
17
|
export const GleamTomlRequired = defineGleamPolicy({
|
|
18
18
|
name: "GleamTomlRequired",
|
|
@@ -26,12 +26,12 @@ export const GleamTomlRequired = defineGleamPolicy({
|
|
|
26
26
|
errors.push("Missing [repository] section in gleam.toml.");
|
|
27
27
|
}
|
|
28
28
|
if (errors.length > 0) {
|
|
29
|
-
return {
|
|
30
|
-
|
|
29
|
+
return errors.map((message) => ({
|
|
30
|
+
message,
|
|
31
31
|
manualFix: "Add the missing fields to your gleam.toml file.",
|
|
32
|
-
};
|
|
32
|
+
}));
|
|
33
33
|
}
|
|
34
|
-
return
|
|
34
|
+
return [];
|
|
35
35
|
},
|
|
36
36
|
});
|
|
37
37
|
//# sourceMappingURL=GleamTomlRequired.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GleamTomlRequired.js","sourceRoot":"","sources":["../../src/policies/GleamTomlRequired.ts"],"names":[],"mappings":"AACA,OAAO,EACN,iBAAiB,GAEjB,MAAM,wCAAwC,CAAC;AA2BhD,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEpD,SAAS,mBAAmB,CAAC,IAAe,EAAE,MAAgB;IAC7D,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC5B,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;YACrD,MAAM,CAAC,IAAI,CAAC,2BAA2B,KAAK,EAAE,CAAC,CAAC;QACjD,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"GleamTomlRequired.js","sourceRoot":"","sources":["../../src/policies/GleamTomlRequired.ts"],"names":[],"mappings":"AACA,OAAO,EACN,iBAAiB,GAEjB,MAAM,wCAAwC,CAAC;AA2BhD,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEpD,SAAS,mBAAmB,CAAC,IAAe,EAAE,MAAgB;IAC7D,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC5B,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;YACrD,MAAM,CAAC,IAAI,CAAC,2BAA2B,KAAK,EAAE,CAAC,CAAC;QACjD,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;IAClD,IAAI,EAAE,mBAAmB;IACzB,WAAW,EACV,oFAAoF;IACrF,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QAC9C,MAAM,MAAM,GAAG,mBAAmB,CACjC,IAAI,EACJ,MAAM,EAAE,QAAQ,IAAI,uBAAuB,CAC3C,CAAC;QAEF,IAAI,MAAM,EAAE,mBAAmB,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7D,MAAM,CAAC,IAAI,CACV,yEAAyE,CACzE,CAAC;QACH,CAAC;QAED,IAAI,MAAM,EAAE,iBAAiB,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YAChE,MAAM,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;QAC5D,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;gBAC/B,OAAO;gBACP,SAAS,EAAE,iDAAiD;aAC5D,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD,CAAyD,CAAC","sourcesContent":["import type { FilePolicyDefinition } from \"../policy.js\";\nimport {\n\tdefineGleamPolicy,\n\ttype GleamToml,\n} from \"../policyDefiners/defineGleamPolicy.js\";\n\n/**\n * Configuration for the GleamTomlRequired policy.\n *\n * @public\n */\nexport interface GleamTomlRequiredConfig {\n\t/**\n\t * Top-level fields that must exist in gleam.toml.\n\t * @defaultValue [\"name\", \"version\"]\n\t */\n\trequired?: string[];\n\n\t/**\n\t * If true, require the `gleam` compiler version constraint.\n\t * @defaultValue false\n\t */\n\trequireGleamVersion?: boolean;\n\n\t/**\n\t * If true, require the `[repository]` section.\n\t * @defaultValue false\n\t */\n\trequireRepository?: boolean;\n}\n\nconst DEFAULT_REQUIRED_FIELDS = [\"name\", \"version\"];\n\nfunction checkRequiredFields(toml: GleamToml, fields: string[]): string[] {\n\tconst errors: string[] = [];\n\tfor (const field of fields) {\n\t\tif (toml[field] === undefined || toml[field] === \"\") {\n\t\t\terrors.push(`Missing required field: ${field}`);\n\t\t}\n\t}\n\treturn errors;\n}\n\n/**\n * A policy that enforces required fields exist in gleam.toml.\n *\n * @public\n */\nexport const GleamTomlRequired = defineGleamPolicy({\n\tname: \"GleamTomlRequired\",\n\tdescription:\n\t\t\"Ensures gleam.toml files contain required fields for proper project configuration.\",\n\thandler: async (toml: GleamToml, { config }) => {\n\t\tconst errors = checkRequiredFields(\n\t\t\ttoml,\n\t\t\tconfig?.required ?? DEFAULT_REQUIRED_FIELDS,\n\t\t);\n\n\t\tif (config?.requireGleamVersion && toml.gleam === undefined) {\n\t\t\terrors.push(\n\t\t\t\t'Missing gleam version constraint. Add gleam = \">= x.y.z\" to gleam.toml.',\n\t\t\t);\n\t\t}\n\n\t\tif (config?.requireRepository && toml.repository === undefined) {\n\t\t\terrors.push(\"Missing [repository] section in gleam.toml.\");\n\t\t}\n\n\t\tif (errors.length > 0) {\n\t\t\treturn errors.map((message) => ({\n\t\t\t\tmessage,\n\t\t\t\tmanualFix: \"Add the missing fields to your gleam.toml file.\",\n\t\t\t}));\n\t\t}\n\t\treturn [];\n\t},\n}) satisfies FilePolicyDefinition<GleamTomlRequiredConfig>;\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FilePolicyDefinition } from "../policy.js";
|
|
2
2
|
/**
|
|
3
3
|
* Configuration for the GleamTomlSorted policy.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
5
|
+
* @public
|
|
6
6
|
*/
|
|
7
7
|
export interface GleamTomlSortedConfig {
|
|
8
8
|
/**
|
|
@@ -14,7 +14,7 @@ export interface GleamTomlSortedConfig {
|
|
|
14
14
|
/**
|
|
15
15
|
* A policy that ensures dependency sections in gleam.toml are sorted alphabetically.
|
|
16
16
|
*
|
|
17
|
-
* @
|
|
17
|
+
* @public
|
|
18
18
|
*/
|
|
19
|
-
export declare const GleamTomlSorted:
|
|
19
|
+
export declare const GleamTomlSorted: FilePolicyDefinition<GleamTomlSortedConfig>;
|
|
20
20
|
//# sourceMappingURL=GleamTomlSorted.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GleamTomlSorted.d.ts","sourceRoot":"","sources":["../../src/policies/GleamTomlSorted.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"GleamTomlSorted.d.ts","sourceRoot":"","sources":["../../src/policies/GleamTomlSorted.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMzD;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AA2ID;;;;GAIG;AACH,eAAO,MAAM,eAAe,6CAoD4B,CAAC"}
|
|
@@ -106,7 +106,7 @@ function sortTomlSections(content, sectionsToSort) {
|
|
|
106
106
|
/**
|
|
107
107
|
* A policy that ensures dependency sections in gleam.toml are sorted alphabetically.
|
|
108
108
|
*
|
|
109
|
-
* @
|
|
109
|
+
* @public
|
|
110
110
|
*/
|
|
111
111
|
export const GleamTomlSorted = defineGleamPolicy({
|
|
112
112
|
name: "GleamTomlSorted",
|
|
@@ -121,7 +121,7 @@ export const GleamTomlSorted = defineGleamPolicy({
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
if (unsortedSections.length === 0) {
|
|
124
|
-
return
|
|
124
|
+
return [];
|
|
125
125
|
}
|
|
126
126
|
if (shouldResolve) {
|
|
127
127
|
try {
|
|
@@ -129,25 +129,29 @@ export const GleamTomlSorted = defineGleamPolicy({
|
|
|
129
129
|
const content = await readFile(filePath, "utf-8");
|
|
130
130
|
const sorted = sortTomlSections(content, unsortedSections);
|
|
131
131
|
await writeFile(filePath, sorted);
|
|
132
|
-
return
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
return [
|
|
133
|
+
{
|
|
134
|
+
message: `Unsorted sections: [${unsortedSections.join("], [")}]`,
|
|
135
|
+
fixStatus: "fixed",
|
|
136
|
+
},
|
|
137
|
+
];
|
|
137
138
|
}
|
|
138
139
|
catch {
|
|
139
|
-
return
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
return [
|
|
141
|
+
{
|
|
142
|
+
message: `Unsorted sections: [${unsortedSections.join("], [")}]. Auto-fix failed.`,
|
|
143
|
+
fixStatus: "failed",
|
|
144
|
+
},
|
|
145
|
+
];
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
|
-
return
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
+
];
|
|
151
155
|
},
|
|
152
156
|
});
|
|
153
157
|
//# sourceMappingURL=GleamTomlSorted.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GleamTomlSorted.js","sourceRoot":"","sources":["../../src/policies/GleamTomlSorted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EACN,iBAAiB,GAEjB,MAAM,wCAAwC,CAAC;AAehD,MAAM,uBAAuB,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;AAErE,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AACjD,MAAM,eAAe,GAAG,YAAY,CAAC;AAErC,SAAS,QAAQ,CAAC,IAAc;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC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AC,qBAAqB;oBAChF,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,KAAK;iBACZ,CAAC;YACH,CAAC;QACF,CAAC;QAED,OAAO;YACN,KAAK,EAAE,uBAAuB,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG;YAC9D,OAAO,EAAE,IAAI;YACb,SAAS,EACR,iEAAiE;SAClE,CAAC;IACH,CAAC;CACD,CAAC,CAAC","sourcesContent":["import { readFile, writeFile } from \"node:fs/promises\";\nimport { resolve } from \"pathe\";\nimport type { PolicyShape } from \"../policy.js\";\nimport {\n\tdefineGleamPolicy,\n\ttype GleamToml,\n} from \"../policyDefiners/defineGleamPolicy.js\";\n\n/**\n * Configuration for the GleamTomlSorted policy.\n *\n * @alpha\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): { entries: TomlEntry[]; endIndex: number } {\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 * @alpha\n */\nexport const GleamTomlSorted: PolicyShape<GleamTomlSortedConfig> =\n\tdefineGleamPolicy({\n\t\tname: \"GleamTomlSorted\",\n\t\tdescription:\n\t\t\t\"Ensures dependency sections in gleam.toml are sorted alphabetically.\",\n\t\thandler: async (\n\t\t\ttoml: GleamToml,\n\t\t\t{ file, root, resolve: shouldResolve, config },\n\t\t) => {\n\t\t\tconst sections = config?.sections ?? DEFAULT_SORTED_SECTIONS;\n\t\t\tconst unsortedSections: string[] = [];\n\n\t\t\tfor (const section of sections) {\n\t\t\t\tconst sectionData = toml[section] as\n\t\t\t\t\t| Record<string, unknown>\n\t\t\t\t\t| undefined;\n\t\t\t\tif (sectionData !== undefined && !isSorted(Object.keys(sectionData))) {\n\t\t\t\t\tunsortedSections.push(section);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (unsortedSections.length === 0) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (shouldResolve) {\n\t\t\t\ttry {\n\t\t\t\t\tconst filePath = resolve(root, file);\n\t\t\t\t\tconst content = await readFile(filePath, \"utf-8\");\n\t\t\t\t\tconst sorted = sortTomlSections(content, unsortedSections);\n\t\t\t\t\tawait writeFile(filePath, sorted);\n\t\t\t\t\treturn {\n\t\t\t\t\t\terror: `Unsorted sections: [${unsortedSections.join(\"], [\")}]`,\n\t\t\t\t\t\tfixable: true,\n\t\t\t\t\t\tfixed: true,\n\t\t\t\t\t};\n\t\t\t\t} catch {\n\t\t\t\t\treturn {\n\t\t\t\t\t\terror: `Unsorted sections: [${unsortedSections.join(\"], [\")}]. Auto-fix failed.`,\n\t\t\t\t\t\tfixable: true,\n\t\t\t\t\t\tfixed: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\terror: `Unsorted sections: [${unsortedSections.join(\"], [\")}]`,\n\t\t\t\tfixable: true,\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"]}
|
|
1
|
+
{"version":3,"file":"GleamTomlSorted.js","sourceRoot":"","sources":["../../src/policies/GleamTomlSorted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EACN,iBAAiB,GAEjB,MAAM,wCAAwC,CAAC;AAehD,MAAM,uBAAuB,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;AAErE,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AACjD,MAAM,eAAe,GAAG,YAAY,CAAC;AAErC,SAAS,QAAQ,CAAC,IAAc;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACrB,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,GAAG,IAA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,CAAC;CACD,CAAuD,CAAC","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"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FilePolicyDefinition } from "../policy.js";
|
|
2
2
|
/**
|
|
3
3
|
* Configuration for the GleamVersionConstraint policy.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
5
|
+
* @public
|
|
6
6
|
*/
|
|
7
7
|
export interface GleamVersionConstraintConfig {
|
|
8
8
|
/**
|
|
@@ -14,7 +14,7 @@ export interface GleamVersionConstraintConfig {
|
|
|
14
14
|
/**
|
|
15
15
|
* A policy that ensures the Gleam compiler version constraint is set in gleam.toml.
|
|
16
16
|
*
|
|
17
|
-
* @
|
|
17
|
+
* @public
|
|
18
18
|
*/
|
|
19
|
-
export declare const GleamVersionConstraint:
|
|
19
|
+
export declare const GleamVersionConstraint: FilePolicyDefinition<GleamVersionConstraintConfig>;
|
|
20
20
|
//# sourceMappingURL=GleamVersionConstraint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GleamVersionConstraint.d.ts","sourceRoot":"","sources":["../../src/policies/GleamVersionConstraint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
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"}
|
|
@@ -38,7 +38,7 @@ function isVersionAtLeast(constraint, minimum) {
|
|
|
38
38
|
/**
|
|
39
39
|
* A policy that ensures the Gleam compiler version constraint is set in gleam.toml.
|
|
40
40
|
*
|
|
41
|
-
* @
|
|
41
|
+
* @public
|
|
42
42
|
*/
|
|
43
43
|
export const GleamVersionConstraint = defineGleamPolicy({
|
|
44
44
|
name: "GleamVersionConstraint",
|
|
@@ -46,19 +46,23 @@ export const GleamVersionConstraint = defineGleamPolicy({
|
|
|
46
46
|
handler: async (toml, { config }) => {
|
|
47
47
|
const gleamVersion = toml.gleam;
|
|
48
48
|
if (gleamVersion === undefined || gleamVersion === "") {
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
+
];
|
|
53
55
|
}
|
|
54
56
|
if (config?.minimumVersion &&
|
|
55
57
|
!isVersionAtLeast(gleamVersion, config.minimumVersion)) {
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
+
];
|
|
60
64
|
}
|
|
61
|
-
return
|
|
65
|
+
return [];
|
|
62
66
|
},
|
|
63
67
|
});
|
|
64
68
|
//# sourceMappingURL=GleamVersionConstraint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GleamVersionConstraint.js","sourceRoot":"","sources":["../../src/policies/GleamVersionConstraint.ts"],"names":[],"mappings":"AACA,OAAO,EACN,iBAAiB,GAEjB,MAAM,wCAAwC,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ACN;oBACC,OAAO,EAAE,iDAAiD;oBAC1D,SAAS,EACR,gEAAgE;iBACjE;aACD,CAAC;QACH,CAAC;QAED,IACC,MAAM,EAAE,cAAc;YACtB,CAAC,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,cAAc,CAAC,EACrD,CAAC;YACF,OAAO;gBACN;oBACC,OAAO,EAAE,6BAA6B,YAAY,uBAAuB,MAAM,CAAC,cAAc,IAAI;oBAClG,SAAS,EAAE,yBAAyB,MAAM,CAAC,cAAc,cAAc;iBACvE;aACD,CAAC;QACH,CAAC;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD,CAA8D,CAAC","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,7 +3,7 @@ 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",
|
|
@@ -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,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,
|
|
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
|