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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageFolderName.js","sourceRoot":"","sources":["../../src/policies/PackageFolderName.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,OAAO,CAAC;AACzB,OAAO,SAAS,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAgE3D;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,KAAa,EAAE,WAAqB;IAC7D,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;GAMG;AACH,SAAS,qBAAqB,CAC7B,WAAmB,EACnB,WAAqB;IAErB,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAE9D,gEAAgE;IAChE,IAAI,KAAK,KAAK,SAAS,IAAI,gBAAgB,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,CAAC;QACjE,OAAO,YAAY,CAAC;IACrB,CAAC;IAED,8EAA8E;IAC9E,OAAO,WAAW,CAAC;AACpB,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"PackageFolderName.js","sourceRoot":"","sources":["../../src/policies/PackageFolderName.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,OAAO,CAAC;AACzB,OAAO,SAAS,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAgE3D;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,KAAa,EAAE,WAAqB;IAC7D,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;GAMG;AACH,SAAS,qBAAqB,CAC7B,WAAmB,EACnB,WAAqB;IAErB,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAE9D,gEAAgE;IAChE,IAAI,KAAK,KAAK,SAAS,IAAI,gBAAgB,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,CAAC;QACjE,OAAO,YAAY,CAAC;IACrB,CAAC;IAED,8EAA8E;IAC9E,OAAO,WAAW,CAAC;AACpB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAGlD;IACD,IAAI,EAAE,mBAAmB;IACzB,WAAW,EACV,iFAAiF;IAClF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;QACzC,2DAA2D;QAC3D,MAAM,eAAe,GAAG,MAAM,IAAI,EAAE,CAAC;QAErC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC;QAE9B,+BAA+B;QAC/B,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC/B,OAAO,EAAE,CAAC;QACX,CAAC;QAED,8CAA8C;QAC9C,IAAI,WAAW,KAAK,MAAM,EAAE,CAAC;YAC5B,OAAO,EAAE,CAAC;QACX,CAAC;QAED,oCAAoC;QACpC,IAAI,eAAe,CAAC,eAAe,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAC5D,OAAO,EAAE,CAAC;QACX,CAAC;QAED,yDAAyD;QACzD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAErD,+BAA+B;QAC/B,MAAM,kBAAkB,GAAG,qBAAqB,CAC/C,WAAW,EACX,eAAe,CAAC,WAAW,IAAI,EAAE,CACjC,CAAC;QAEF,uCAAuC;QACvC,IAAI,UAAU,KAAK,kBAAkB,EAAE,CAAC;YACvC,OAAO,EAAE,CAAC;QACX,CAAC;QAED,iCAAiC;QACjC,MAAM,UAAU,GAAoB;YACnC,mBAAmB,UAAU,kCAAkC,WAAW,6BAA6B,kBAAkB,GAAG;SAC5H,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QAClC,OAAO,UAAU,CAAC;IACnB,CAAC;CACD,CAAC,CAAC","sourcesContent":["import path from \"pathe\";\nimport picomatch from \"picomatch\";\nimport type { PackageJson } from \"type-fest\";\nimport type { PolicyFinding } from \"../policy.js\";\nimport { definePackagePolicy } from \"../policyDefiners/definePackagePolicy.js\";\nimport { parsePackageName } from \"../utils/packageName.js\";\n\n/**\n * Configuration for the PackageFolderName policy.\n *\n * This policy ensures that package folder names match their package names,\n * promoting consistency and making packages easier to find in the file system.\n *\n * @example\n * ```typescript\n * const config: PackageFolderNameConfig = {\n * // Strip all scopes when matching folder names\n * stripScopes: [\"@*\"],\n * // Or strip specific scopes\n * stripScopes: [\"@myorg\", \"@internal\"],\n * // These packages are exempt from the check\n * excludePackages: [\"@myorg/special-name\"],\n * };\n * ```\n *\n * @public\n */\nexport interface PackageFolderNameConfig {\n\t/**\n\t * A list of npm scope patterns to strip when comparing folder names to package names.\n\t *\n\t * For scoped packages like `@myorg/my-package`, if `@myorg` matches a pattern in this list,\n\t * the policy will expect the folder to be named `my-package` (not `@myorg/my-package`).\n\t *\n\t * @remarks\n\t *\n\t * Supports glob patterns:\n\t * - `@*` - matches all scopes\n\t * - `@myorg` - matches exactly `@myorg`\n\t * - `@my*` - matches scopes starting with `@my`\n\t *\n\t * @example\n\t * ```typescript\n\t * // Strip all scopes - @anything/my-package → folder \"my-package\"\n\t * stripScopes: [\"@*\"]\n\t *\n\t * // Strip specific scopes only\n\t * stripScopes: [\"@myorg\", \"@internal\"]\n\t *\n\t * // Strip scopes matching a pattern\n\t * stripScopes: [\"@fluid*\"]\n\t * ```\n\t */\n\tstripScopes?: string[];\n\n\t/**\n\t * A list of package names that are exempt from folder name matching.\n\t *\n\t * Use this for packages that intentionally have different folder names,\n\t * such as legacy packages or packages with special naming requirements.\n\t *\n\t * @example\n\t * ```typescript\n\t * excludePackages: [\"@myorg/cli\", \"legacy-package\"]\n\t * ```\n\t */\n\texcludePackages?: string[];\n}\n\n/**\n * Check if a scope should be stripped based on the patterns.\n *\n * @param scope - The scope to check (e.g., `@myorg`)\n * @param stripScopes - List of scope patterns to match (supports glob patterns via picomatch)\n * @returns `true` if the scope matches any pattern\n */\nfunction shouldStripScope(scope: string, stripScopes: string[]): boolean {\n\tif (stripScopes.length === 0) {\n\t\treturn false;\n\t}\n\n\treturn picomatch.isMatch(scope, stripScopes);\n}\n\n/**\n * Get the expected folder name from a package name.\n *\n * @param packageName - The package name (e.g., `@myorg/my-package`)\n * @param stripScopes - Scope patterns to strip from the package name\n * @returns The expected folder name\n */\nfunction getExpectedFolderName(\n\tpackageName: string,\n\tstripScopes: string[],\n): string {\n\tconst { scope, unscopedName } = parsePackageName(packageName);\n\n\t// Check if the package is scoped and should have scope stripped\n\tif (scope !== undefined && shouldStripScope(scope, stripScopes)) {\n\t\treturn unscopedName;\n\t}\n\n\t// Return full package name for unscoped packages or scopes not in stripScopes\n\treturn packageName;\n}\n\n/**\n * A policy that ensures package folder names match package names.\n *\n * This policy helps maintain a consistent and predictable file structure\n * in monorepos by ensuring that folder names correspond to package names.\n * This makes it easier to locate packages in the file system.\n *\n * @remarks\n *\n * The policy compares the immediate parent folder name of the package.json\n * against the package name. For scoped packages, the scope can optionally\n * be stripped based on the `stripScopes` configuration.\n *\n * For example:\n * - `packages/my-lib/package.json` with name `my-lib` ✓\n * - `packages/my-lib/package.json` with name `@myorg/my-lib` ✓ (if `@myorg` is in `stripScopes`)\n * - `packages/wrong-name/package.json` with name `my-lib` ✗\n *\n * @example\n * ```typescript\n * import { makePolicy } from \"repopo\";\n * import { PackageFolderName } from \"repopo/policies\";\n *\n * const config: RepopoConfig = {\n * policies: [\n * makePolicy(PackageFolderName, {\n * config: {\n * stripScopes: [\"@myorg\", \"@internal\"],\n * excludePackages: [\"@myorg/special-case\"],\n * },\n * }),\n * ],\n * };\n * ```\n *\n * @public\n */\nexport const PackageFolderName = definePackagePolicy<\n\tPackageJson,\n\tPackageFolderNameConfig | undefined\n>({\n\tname: \"PackageFolderName\",\n\tdescription:\n\t\t\"Ensures package folder names match package names for consistent file structure.\",\n\thandler: async (json, { file, config }) => {\n\t\t// If no config provided, use defaults (check all packages)\n\t\tconst effectiveConfig = config ?? {};\n\n\t\tconst packageName = json.name;\n\n\t\t// Skip packages without a name\n\t\tif (packageName === undefined) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Skip the root package (common in monorepos)\n\t\tif (packageName === \"root\") {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Skip explicitly excluded packages\n\t\tif (effectiveConfig.excludePackages?.includes(packageName)) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Get the folder name (parent directory of package.json)\n\t\tconst folderName = path.basename(path.dirname(file));\n\n\t\t// Get the expected folder name\n\t\tconst expectedFolderName = getExpectedFolderName(\n\t\t\tpackageName,\n\t\t\teffectiveConfig.stripScopes ?? [],\n\t\t);\n\n\t\t// Compare folder name to expected name\n\t\tif (folderName === expectedFolderName) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Mismatch - build error message\n\t\tconst failResult: PolicyFinding[] = [\n\t\t\t`Package folder \"${folderName}\" does not match package name \"${packageName}\". Expected folder name: \"${expectedFolderName}\"`,\n\t\t].map((message) => ({ message }));\n\t\treturn failResult;\n\t},\n});\n"]}
|
|
@@ -2,7 +2,7 @@ import type { PackageJson } from "type-fest";
|
|
|
2
2
|
/**
|
|
3
3
|
* Policy settings for the PackageJsonProperties repo policy.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
5
|
+
* @public
|
|
6
6
|
*/
|
|
7
7
|
export interface PackageJsonPropertiesSettings {
|
|
8
8
|
/**
|
|
@@ -13,7 +13,9 @@ export interface PackageJsonPropertiesSettings {
|
|
|
13
13
|
/**
|
|
14
14
|
* A RepoPolicy that checks that package.json properties in packages match expected values.
|
|
15
15
|
*
|
|
16
|
-
* @
|
|
16
|
+
* @public
|
|
17
17
|
*/
|
|
18
|
-
export declare const PackageJsonProperties: import("../policy.js").
|
|
18
|
+
export declare const PackageJsonProperties: import("../policy.js").FilePolicyDefinition<PackageJsonPropertiesSettings> & {
|
|
19
|
+
requiresConfig: true;
|
|
20
|
+
};
|
|
19
21
|
//# sourceMappingURL=PackageJsonProperties.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageJsonProperties.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonProperties.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PackageJsonProperties.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonProperties.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAa7C;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC7C;;OAEG;IACH,QAAQ,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;CAoChC,CAAC"}
|
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createDefu } from "defu";
|
|
2
2
|
import { call } from "effection";
|
|
3
3
|
import jsonfile from "jsonfile";
|
|
4
4
|
import diff from "microdiff";
|
|
5
|
+
import { resolve as resolvePath } from "pathe";
|
|
5
6
|
import { definePackagePolicy } from "../policyDefiners/definePackagePolicy.js";
|
|
6
7
|
const { writeFile: writeJson } = jsonfile;
|
|
8
|
+
const mergeProperties = createDefu((object, key, value) => {
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
object[key] = value;
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
});
|
|
7
15
|
/**
|
|
8
16
|
* A RepoPolicy that checks that package.json properties in packages match expected values.
|
|
9
17
|
*
|
|
10
|
-
* @
|
|
18
|
+
* @public
|
|
11
19
|
*/
|
|
12
20
|
export const PackageJsonProperties = definePackagePolicy({
|
|
13
21
|
name: "PackageJsonProperties",
|
|
14
22
|
description: "Ensures package.json files contain required properties with correct values.",
|
|
15
|
-
|
|
23
|
+
requiresConfig: true,
|
|
24
|
+
handler: function* (json, { file, root, config, resolve }) {
|
|
16
25
|
if (config === undefined) {
|
|
17
|
-
|
|
26
|
+
throw new TypeError("PackageJsonProperties requires config.");
|
|
18
27
|
}
|
|
19
28
|
const { verbatim } = config;
|
|
20
|
-
const
|
|
21
|
-
name: PackageJsonProperties.name,
|
|
22
|
-
file,
|
|
23
|
-
autoFixable: true,
|
|
24
|
-
errorMessages: [],
|
|
25
|
-
};
|
|
26
|
-
const merged = defu(verbatim, json);
|
|
29
|
+
const merged = mergeProperties(verbatim, json);
|
|
27
30
|
const result = diff(merged, json);
|
|
28
31
|
const messages = [];
|
|
29
32
|
for (const diffResult of result) {
|
|
@@ -31,19 +34,13 @@ export const PackageJsonProperties = definePackagePolicy({
|
|
|
31
34
|
}
|
|
32
35
|
if (messages.length > 0) {
|
|
33
36
|
if (resolve) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
resolved: false,
|
|
37
|
-
};
|
|
38
|
-
yield* call(() => writeJson(file, merged, { spaces: "\t" }));
|
|
39
|
-
fixResult.resolved = true;
|
|
40
|
-
return fixResult;
|
|
37
|
+
yield* call(() => writeJson(resolvePath(root, file), merged, { spaces: "\t" }));
|
|
38
|
+
return messages.map((message) => ({ message, fixStatus: "fixed" }));
|
|
41
39
|
}
|
|
42
40
|
// There were errors, and we're not resolving them, so return a fail result
|
|
43
|
-
|
|
44
|
-
return failResult;
|
|
41
|
+
return messages.map((message) => ({ message, fixStatus: "available" }));
|
|
45
42
|
}
|
|
46
|
-
return
|
|
43
|
+
return [];
|
|
47
44
|
},
|
|
48
45
|
});
|
|
49
46
|
//# sourceMappingURL=PackageJsonProperties.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageJsonProperties.js","sourceRoot":"","sources":["../../src/policies/PackageJsonProperties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"PackageJsonProperties.js","sourceRoot":"","sources":["../../src/policies/PackageJsonProperties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE/E,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;AAE1C,MAAM,eAAe,GAAG,UAAU,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;IACzD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC,CAAC,CAAC;AAcH;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAGtD;IACD,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EACV,6EAA6E;IAC9E,cAAc,EAAE,IAAI;IACpB,OAAO,EAAE,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QACxD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC,CAAC;QAC/D,CAAC;QACD,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;QAC5B,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAElC,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,KAAK,MAAM,UAAU,IAAI,MAAM,EAAE,CAAC;YACjC,QAAQ,CAAC,IAAI,CACZ,2CAA2C,UAAU,CAAC,IAAI,IAAI,CAC9D,CAAC;QACH,CAAC;QAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,IAAI,OAAO,EAAE,CAAC;gBACb,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAChB,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAC5D,CAAC;gBACF,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;YACrE,CAAC;YAED,2EAA2E;YAC3E,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;QACzE,CAAC;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD,CAAC,CAAC","sourcesContent":["import { createDefu } from \"defu\";\nimport { call } from \"effection\";\nimport jsonfile from \"jsonfile\";\nimport diff from \"microdiff\";\nimport { resolve as resolvePath } from \"pathe\";\nimport type { PackageJson } from \"type-fest\";\nimport { definePackagePolicy } from \"../policyDefiners/definePackagePolicy.js\";\n\nconst { writeFile: writeJson } = jsonfile;\n\nconst mergeProperties = createDefu((object, key, value) => {\n\tif (Array.isArray(value)) {\n\t\tobject[key] = value;\n\t\treturn true;\n\t}\n\treturn false;\n});\n\n/**\n * Policy settings for the PackageJsonProperties repo policy.\n *\n * @public\n */\nexport interface PackageJsonPropertiesSettings {\n\t/**\n\t * Sets a package.json property to the value provided. The value will be used verbatim.\n\t */\n\tverbatim: PackageJson;\n}\n\n/**\n * A RepoPolicy that checks that package.json properties in packages match expected values.\n *\n * @public\n */\nexport const PackageJsonProperties = definePackagePolicy<\n\tPackageJson,\n\tPackageJsonPropertiesSettings\n>({\n\tname: \"PackageJsonProperties\",\n\tdescription:\n\t\t\"Ensures package.json files contain required properties with correct values.\",\n\trequiresConfig: true,\n\thandler: function* (json, { file, root, config, resolve }) {\n\t\tif (config === undefined) {\n\t\t\tthrow new TypeError(\"PackageJsonProperties requires config.\");\n\t\t}\n\t\tconst { verbatim } = config;\n\t\tconst merged = mergeProperties(verbatim, json);\n\t\tconst result = diff(merged, json);\n\n\t\tconst messages: string[] = [];\n\t\tfor (const diffResult of result) {\n\t\t\tmessages.push(\n\t\t\t\t`Incorrect package.json field value for '${diffResult.path}'.`,\n\t\t\t);\n\t\t}\n\n\t\tif (messages.length > 0) {\n\t\t\tif (resolve) {\n\t\t\t\tyield* call(() =>\n\t\t\t\t\twriteJson(resolvePath(root, file), merged, { spaces: \"\\t\" }),\n\t\t\t\t);\n\t\t\t\treturn messages.map((message) => ({ message, fixStatus: \"fixed\" }));\n\t\t\t}\n\n\t\t\t// There were errors, and we're not resolving them, so return a fail result\n\t\t\treturn messages.map((message) => ({ message, fixStatus: \"available\" }));\n\t\t}\n\t\treturn [];\n\t},\n});\n"]}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
* field is a string instead of an object the package will be ignored.
|
|
4
|
-
*
|
|
5
|
-
* @alpha
|
|
6
|
-
*/
|
|
7
|
-
export declare const PackageJsonRepoDirectoryProperty: import("../policy.js").PolicyShape<undefined>;
|
|
1
|
+
/** Ensures repository.directory matches each package's repository-relative directory. @public */
|
|
2
|
+
export declare const PackageJsonRepoDirectoryProperty: import("../policy.js").FilePolicyDefinition<void>;
|
|
8
3
|
//# sourceMappingURL=PackageJsonRepoDirectoryProperty.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageJsonRepoDirectoryProperty.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonRepoDirectoryProperty.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PackageJsonRepoDirectoryProperty.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonRepoDirectoryProperty.ts"],"names":[],"mappings":"AAKA,iGAAiG;AACjG,eAAO,MAAM,gCAAgC,mDAqC3C,CAAC"}
|
|
@@ -2,54 +2,41 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import { updatePackageJsonFile } from "@fluid-tools/build-infrastructure";
|
|
3
3
|
import path from "pathe";
|
|
4
4
|
import { definePackagePolicy } from "../policyDefiners/definePackagePolicy.js";
|
|
5
|
-
/**
|
|
6
|
-
* A RepoPolicy that checks that the repository.directory property in package.json is set correctly. If the repository
|
|
7
|
-
* field is a string instead of an object the package will be ignored.
|
|
8
|
-
*
|
|
9
|
-
* @alpha
|
|
10
|
-
*/
|
|
5
|
+
/** Ensures repository.directory matches each package's repository-relative directory. @public */
|
|
11
6
|
export const PackageJsonRepoDirectoryProperty = definePackagePolicy({
|
|
12
7
|
name: "PackageJsonRepoDirectoryProperty",
|
|
13
8
|
description: "Ensures the repository.directory property in package.json is set correctly for monorepo packages.",
|
|
14
|
-
handler:
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (resolve) {
|
|
31
|
-
try {
|
|
32
|
-
updatePackageJsonFile(file, (pkgJson) => {
|
|
33
|
-
assert(typeof pkgJson.repository === "object");
|
|
34
|
-
if (relativePkgDir === undefined) {
|
|
35
|
-
delete pkgJson.repository.directory;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
pkgJson.repository.directory = relativePkgDir;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
fixResult.resolved = true;
|
|
9
|
+
handler: async (json, { file, root, resolve }) => {
|
|
10
|
+
const packageJsonPath = path.resolve(root, file);
|
|
11
|
+
const directory = path.relative(root, path.dirname(packageJsonPath)) || undefined;
|
|
12
|
+
if (typeof json.repository !== "object" ||
|
|
13
|
+
json.repository.directory === directory) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const message = `repository.directory value is wrong. Expected '${directory}', got '${json.repository.directory}'`;
|
|
17
|
+
if (!resolve) {
|
|
18
|
+
return [{ message, fixStatus: "available" }];
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
updatePackageJsonFile(packageJsonPath, (pkg) => {
|
|
22
|
+
assert(typeof pkg.repository === "object");
|
|
23
|
+
if (directory === undefined) {
|
|
24
|
+
delete pkg.repository.directory;
|
|
42
25
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
fixResult.errorMessages.push(`${error.message}\n${error.stack}`);
|
|
26
|
+
else {
|
|
27
|
+
pkg.repository.directory = directory;
|
|
46
28
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
message: `${message}: ${error instanceof Error ? error.message : String(error)}`,
|
|
35
|
+
fixStatus: "failed",
|
|
36
|
+
},
|
|
37
|
+
];
|
|
51
38
|
}
|
|
52
|
-
return
|
|
39
|
+
return [{ message, fixStatus: "fixed" }];
|
|
53
40
|
},
|
|
54
41
|
});
|
|
55
42
|
//# sourceMappingURL=PackageJsonRepoDirectoryProperty.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageJsonRepoDirectoryProperty.js","sourceRoot":"","sources":["../../src/policies/PackageJsonRepoDirectoryProperty.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,IAAI,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PackageJsonRepoDirectoryProperty.js","sourceRoot":"","sources":["../../src/policies/PackageJsonRepoDirectoryProperty.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,IAAI,MAAM,OAAO,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE/E,iGAAiG;AACjG,MAAM,CAAC,MAAM,gCAAgC,GAAG,mBAAmB,CAAC;IACnE,IAAI,EAAE,kCAAkC;IACxC,WAAW,EACV,mGAAmG;IACpG,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAChD,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACjD,MAAM,SAAS,GACd,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,IAAI,SAAS,CAAC;QACjE,IACC,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ;YACnC,IAAI,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EACtC,CAAC;YACF,OAAO,EAAE,CAAC;QACX,CAAC;QACD,MAAM,OAAO,GAAG,kDAAkD,SAAS,WAAW,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,CAAC;QACnH,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,OAAO,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC;YACJ,qBAAqB,CAAC,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE;gBAC9C,MAAM,CAAC,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC;gBAC3C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;oBAC7B,OAAO,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;gBACjC,CAAC;qBAAM,CAAC;oBACP,GAAG,CAAC,UAAU,CAAC,SAAS,GAAG,SAAS,CAAC;gBACtC,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACzB,OAAO;gBACN;oBACC,OAAO,EAAE,GAAG,OAAO,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;oBAChF,SAAS,EAAE,QAAQ;iBACnB;aACD,CAAC;QACH,CAAC;QACD,OAAO,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1C,CAAC;CACD,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { updatePackageJsonFile } from \"@fluid-tools/build-infrastructure\";\nimport path from \"pathe\";\nimport { definePackagePolicy } from \"../policyDefiners/definePackagePolicy.js\";\n\n/** Ensures repository.directory matches each package's repository-relative directory. @public */\nexport const PackageJsonRepoDirectoryProperty = definePackagePolicy({\n\tname: \"PackageJsonRepoDirectoryProperty\",\n\tdescription:\n\t\t\"Ensures the repository.directory property in package.json is set correctly for monorepo packages.\",\n\thandler: async (json, { file, root, resolve }) => {\n\t\tconst packageJsonPath = path.resolve(root, file);\n\t\tconst directory =\n\t\t\tpath.relative(root, path.dirname(packageJsonPath)) || undefined;\n\t\tif (\n\t\t\ttypeof json.repository !== \"object\" ||\n\t\t\tjson.repository.directory === directory\n\t\t) {\n\t\t\treturn [];\n\t\t}\n\t\tconst message = `repository.directory value is wrong. Expected '${directory}', got '${json.repository.directory}'`;\n\t\tif (!resolve) {\n\t\t\treturn [{ message, fixStatus: \"available\" }];\n\t\t}\n\t\ttry {\n\t\t\tupdatePackageJsonFile(packageJsonPath, (pkg) => {\n\t\t\t\tassert(typeof pkg.repository === \"object\");\n\t\t\t\tif (directory === undefined) {\n\t\t\t\t\tdelete pkg.repository.directory;\n\t\t\t\t} else {\n\t\t\t\t\tpkg.repository.directory = directory;\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error: unknown) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tmessage: `${message}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t\tfixStatus: \"failed\",\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\treturn [{ message, fixStatus: \"fixed\" }];\n\t},\n});\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A repo policy that checks if package.json files in the repo are sorted using sort-package-json.
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
4
|
+
* @public
|
|
5
5
|
*/
|
|
6
|
-
export declare const PackageJsonSorted: import("../policy.js").
|
|
6
|
+
export declare const PackageJsonSorted: import("../policy.js").FilePolicyDefinition<void>;
|
|
7
7
|
//# sourceMappingURL=PackageJsonSorted.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageJsonSorted.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonSorted.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PackageJsonSorted.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonSorted.ts"],"names":[],"mappings":"AAwCA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,mDA6C5B,CAAC"}
|
|
@@ -1,56 +1,76 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { call } from "effection";
|
|
1
|
+
import jsonfile from "jsonfile";
|
|
3
2
|
import { resolve as resolvePath } from "pathe";
|
|
4
|
-
import { sortPackageJson } from "sort-package-json";
|
|
5
3
|
import { definePackagePolicy } from "../policyDefiners/definePackagePolicy.js";
|
|
4
|
+
import { detectIndentation } from "../utils/indentation.js";
|
|
5
|
+
const { writeFile: writeJson } = jsonfile;
|
|
6
|
+
const missingDependencyMessage = "PackageJsonSorted requires the optional peer dependency sort-package-json. Install it to enable this policy.";
|
|
7
|
+
function isMissingSortPackageJsonError(error) {
|
|
8
|
+
if (error instanceof Error &&
|
|
9
|
+
"code" in error &&
|
|
10
|
+
error.code === "ERR_MODULE_NOT_FOUND" &&
|
|
11
|
+
error.message.includes("sort-package-json")) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return (typeof error === "object" &&
|
|
15
|
+
error !== null &&
|
|
16
|
+
"cause" in error &&
|
|
17
|
+
isMissingSortPackageJsonError(error.cause));
|
|
18
|
+
}
|
|
19
|
+
async function loadSortPackageJson() {
|
|
20
|
+
try {
|
|
21
|
+
const { sortPackageJson } = await import("sort-package-json");
|
|
22
|
+
return sortPackageJson;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (isMissingSortPackageJsonError(error)) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
6
31
|
/**
|
|
7
32
|
* A repo policy that checks if package.json files in the repo are sorted using sort-package-json.
|
|
8
33
|
*
|
|
9
|
-
* @
|
|
34
|
+
* @public
|
|
10
35
|
*/
|
|
11
36
|
export const PackageJsonSorted = definePackagePolicy({
|
|
12
37
|
name: "PackageJsonSorted",
|
|
13
38
|
description: "Ensures package.json files are sorted consistently using sort-package-json.",
|
|
14
|
-
handler:
|
|
39
|
+
handler: async (json, { file, root, resolve }) => {
|
|
40
|
+
const sortPackageJson = await loadSortPackageJson();
|
|
41
|
+
if (sortPackageJson === undefined) {
|
|
42
|
+
const result = [missingDependencyMessage].map((message) => ({ message }));
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
15
45
|
const sortedJson = sortPackageJson(json);
|
|
16
46
|
const isSorted = JSON.stringify(sortedJson) === JSON.stringify(json);
|
|
17
47
|
if (isSorted) {
|
|
18
|
-
return
|
|
48
|
+
return [];
|
|
19
49
|
}
|
|
20
50
|
if (resolve) {
|
|
21
51
|
try {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})
|
|
25
|
-
const result =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
resolved: true,
|
|
29
|
-
errorMessages: [],
|
|
30
|
-
};
|
|
52
|
+
const packageJsonPath = resolvePath(root, file);
|
|
53
|
+
const indent = await detectIndentation(packageJsonPath);
|
|
54
|
+
await writeJson(packageJsonPath, sortedJson, { spaces: indent });
|
|
55
|
+
const result = [
|
|
56
|
+
{ message: "package.json is not sorted.", fixStatus: "fixed" },
|
|
57
|
+
];
|
|
31
58
|
return result;
|
|
32
59
|
}
|
|
33
60
|
catch (error) {
|
|
34
|
-
const result =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
error.message,
|
|
41
|
-
error.stack ?? "",
|
|
42
|
-
],
|
|
43
|
-
};
|
|
61
|
+
const result = [
|
|
62
|
+
{
|
|
63
|
+
message: error instanceof Error ? error.message : String(error),
|
|
64
|
+
fixStatus: "failed",
|
|
65
|
+
},
|
|
66
|
+
];
|
|
44
67
|
return result;
|
|
45
68
|
}
|
|
46
69
|
}
|
|
47
70
|
else {
|
|
48
|
-
const result =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
autoFixable: true,
|
|
52
|
-
errorMessages: [],
|
|
53
|
-
};
|
|
71
|
+
const result = [
|
|
72
|
+
{ message: "package.json is not sorted.", fixStatus: "available" },
|
|
73
|
+
];
|
|
54
74
|
return result;
|
|
55
75
|
}
|
|
56
76
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageJsonSorted.js","sourceRoot":"","sources":["../../src/policies/PackageJsonSorted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"PackageJsonSorted.js","sourceRoot":"","sources":["../../src/policies/PackageJsonSorted.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;AAC1C,MAAM,wBAAwB,GAC7B,8GAA8G,CAAC;AAEhH,SAAS,6BAA6B,CAAC,KAAc;IACpD,IACC,KAAK,YAAY,KAAK;QACtB,MAAM,IAAI,KAAK;QACf,KAAK,CAAC,IAAI,KAAK,sBAAsB;QACrC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAC1C,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAO,IAAI,KAAK;QAChB,6BAA6B,CAAC,KAAK,CAAC,KAAK,CAAC,CAC1C,CAAC;AACH,CAAC;AAED,KAAK,UAAU,mBAAmB;IACjC,IAAI,CAAC;QACJ,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAC9D,OAAO,eAAe,CAAC;IACxB,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACzB,IAAI,6BAA6B,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1C,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;IACpD,IAAI,EAAE,mBAAmB;IACzB,WAAW,EACV,6EAA6E;IAC9E,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAChD,MAAM,eAAe,GAAG,MAAM,mBAAmB,EAAE,CAAC;QACpD,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YACnC,MAAM,MAAM,GAAoB,CAAC,wBAAwB,CAAC,CAAC,GAAG,CAC7D,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAC1B,CAAC;YACF,OAAO,MAAM,CAAC;QACf,CAAC;QAED,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAErE,IAAI,QAAQ,EAAE,CAAC;YACd,OAAO,EAAE,CAAC;QACX,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACb,IAAI,CAAC;gBACJ,MAAM,eAAe,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAChD,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,eAAe,CAAC,CAAC;gBACxD,MAAM,SAAS,CAAC,eAAe,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;gBACjE,MAAM,MAAM,GAAoB;oBAC/B,EAAE,OAAO,EAAE,6BAA6B,EAAE,SAAS,EAAE,OAAO,EAAE;iBAC9D,CAAC;gBACF,OAAO,MAAM,CAAC;YACf,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACzB,MAAM,MAAM,GAAoB;oBAC/B;wBACC,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;wBAC/D,SAAS,EAAE,QAAQ;qBACnB;iBACD,CAAC;gBACF,OAAO,MAAM,CAAC;YACf,CAAC;QACF,CAAC;aAAM,CAAC;YACP,MAAM,MAAM,GAAoB;gBAC/B,EAAE,OAAO,EAAE,6BAA6B,EAAE,SAAS,EAAE,WAAW,EAAE;aAClE,CAAC;YACF,OAAO,MAAM,CAAC;QACf,CAAC;IACF,CAAC;CACD,CAAC,CAAC","sourcesContent":["import jsonfile from \"jsonfile\";\nimport { resolve as resolvePath } from \"pathe\";\nimport type { PolicyFinding } from \"../policy.js\";\nimport { definePackagePolicy } from \"../policyDefiners/definePackagePolicy.js\";\nimport { detectIndentation } from \"../utils/indentation.js\";\n\nconst { writeFile: writeJson } = jsonfile;\nconst missingDependencyMessage =\n\t\"PackageJsonSorted requires the optional peer dependency sort-package-json. Install it to enable this policy.\";\n\nfunction isMissingSortPackageJsonError(error: unknown): boolean {\n\tif (\n\t\terror instanceof Error &&\n\t\t\"code\" in error &&\n\t\terror.code === \"ERR_MODULE_NOT_FOUND\" &&\n\t\terror.message.includes(\"sort-package-json\")\n\t) {\n\t\treturn true;\n\t}\n\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t\"cause\" in error &&\n\t\tisMissingSortPackageJsonError(error.cause)\n\t);\n}\n\nasync function loadSortPackageJson() {\n\ttry {\n\t\tconst { sortPackageJson } = await import(\"sort-package-json\");\n\t\treturn sortPackageJson;\n\t} catch (error: unknown) {\n\t\tif (isMissingSortPackageJsonError(error)) {\n\t\t\treturn undefined;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/**\n * A repo policy that checks if package.json files in the repo are sorted using sort-package-json.\n *\n * @public\n */\nexport const PackageJsonSorted = definePackagePolicy({\n\tname: \"PackageJsonSorted\",\n\tdescription:\n\t\t\"Ensures package.json files are sorted consistently using sort-package-json.\",\n\thandler: async (json, { file, root, resolve }) => {\n\t\tconst sortPackageJson = await loadSortPackageJson();\n\t\tif (sortPackageJson === undefined) {\n\t\t\tconst result: PolicyFinding[] = [missingDependencyMessage].map(\n\t\t\t\t(message) => ({ message }),\n\t\t\t);\n\t\t\treturn result;\n\t\t}\n\n\t\tconst sortedJson = sortPackageJson(json);\n\t\tconst isSorted = JSON.stringify(sortedJson) === JSON.stringify(json);\n\n\t\tif (isSorted) {\n\t\t\treturn [];\n\t\t}\n\n\t\tif (resolve) {\n\t\t\ttry {\n\t\t\t\tconst packageJsonPath = resolvePath(root, file);\n\t\t\t\tconst indent = await detectIndentation(packageJsonPath);\n\t\t\t\tawait writeJson(packageJsonPath, sortedJson, { spaces: indent });\n\t\t\t\tconst result: PolicyFinding[] = [\n\t\t\t\t\t{ message: \"package.json is not sorted.\", fixStatus: \"fixed\" },\n\t\t\t\t];\n\t\t\t\treturn result;\n\t\t\t} catch (error: unknown) {\n\t\t\t\tconst result: PolicyFinding[] = [\n\t\t\t\t\t{\n\t\t\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\tfixStatus: \"failed\",\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t\treturn result;\n\t\t\t}\n\t\t} else {\n\t\t\tconst result: PolicyFinding[] = [\n\t\t\t\t{ message: \"package.json is not sorted.\", fixStatus: \"available\" },\n\t\t\t];\n\t\t\treturn result;\n\t\t}\n\t},\n});\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Policy settings for the PackageLicense repo policy.
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
4
|
+
* @public
|
|
5
5
|
*/
|
|
6
6
|
export interface PackageLicenseSettings {
|
|
7
7
|
/**
|
|
@@ -50,12 +50,12 @@ export interface PackageLicenseSettings {
|
|
|
50
50
|
* makePolicy(PackageLicense),
|
|
51
51
|
*
|
|
52
52
|
* // Or require LICENSE for all packages including private
|
|
53
|
-
* makePolicy(PackageLicense, { skipPrivate: false }),
|
|
53
|
+
* // makePolicy(PackageLicense, { config: { skipPrivate: false } }),
|
|
54
54
|
* ],
|
|
55
55
|
* };
|
|
56
56
|
* ```
|
|
57
57
|
*
|
|
58
|
-
* @
|
|
58
|
+
* @public
|
|
59
59
|
*/
|
|
60
|
-
export declare const PackageLicense: import("../policy.js").
|
|
60
|
+
export declare const PackageLicense: import("../policy.js").FilePolicyDefinition<PackageLicenseSettings | undefined>;
|
|
61
61
|
//# sourceMappingURL=PackageLicense.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageLicense.d.ts","sourceRoot":"","sources":["../../src/policies/PackageLicense.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;
|
|
1
|
+
{"version":3,"file":"PackageLicense.d.ts","sourceRoot":"","sources":["../../src/policies/PackageLicense.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAkCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,cAAc,iFA6EzB,CAAC"}
|
|
@@ -6,35 +6,23 @@ const DEFAULT_LICENSE_FILE_NAME = "LICENSE";
|
|
|
6
6
|
const POLICY_NAME = "PackageLicense";
|
|
7
7
|
/**
|
|
8
8
|
* Copies the root LICENSE file to the package directory.
|
|
9
|
-
* @returns
|
|
9
|
+
* @returns Findings that record whether the license was fixed.
|
|
10
10
|
*/
|
|
11
|
-
async function copyLicenseFile(rootLicensePath, packageLicensePath,
|
|
11
|
+
async function copyLicenseFile(rootLicensePath, packageLicensePath, _policyName, _file, packageName, licenseFileName, isCreate) {
|
|
12
12
|
try {
|
|
13
13
|
await copyFile(rootLicensePath, packageLicensePath);
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
errorMessages: [
|
|
20
|
-
isCreate
|
|
21
|
-
? `Created ${licenseFileName} file for package "${packageName}"`
|
|
22
|
-
: `Updated ${licenseFileName} file for package "${packageName}" to match root`,
|
|
23
|
-
],
|
|
24
|
-
};
|
|
14
|
+
return [
|
|
15
|
+
isCreate
|
|
16
|
+
? `Created ${licenseFileName} file for package "${packageName}"`
|
|
17
|
+
: `Updated ${licenseFileName} file for package "${packageName}" to match root`,
|
|
18
|
+
].map((message) => ({ message, fixStatus: "fixed" }));
|
|
25
19
|
}
|
|
26
20
|
catch {
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
errorMessages: [
|
|
33
|
-
isCreate
|
|
34
|
-
? `Failed to copy ${licenseFileName} to package "${packageName}"`
|
|
35
|
-
: `Failed to update ${licenseFileName} for package "${packageName}"`,
|
|
36
|
-
],
|
|
37
|
-
};
|
|
21
|
+
return [
|
|
22
|
+
isCreate
|
|
23
|
+
? `Failed to copy ${licenseFileName} to package "${packageName}"`
|
|
24
|
+
: `Failed to update ${licenseFileName} for package "${packageName}"`,
|
|
25
|
+
].map((message) => ({ message, fixStatus: "failed" }));
|
|
38
26
|
}
|
|
39
27
|
}
|
|
40
28
|
/**
|
|
@@ -64,12 +52,12 @@ async function copyLicenseFile(rootLicensePath, packageLicensePath, policyName,
|
|
|
64
52
|
* makePolicy(PackageLicense),
|
|
65
53
|
*
|
|
66
54
|
* // Or require LICENSE for all packages including private
|
|
67
|
-
* makePolicy(PackageLicense, { skipPrivate: false }),
|
|
55
|
+
* // makePolicy(PackageLicense, { config: { skipPrivate: false } }),
|
|
68
56
|
* ],
|
|
69
57
|
* };
|
|
70
58
|
* ```
|
|
71
59
|
*
|
|
72
|
-
* @
|
|
60
|
+
* @public
|
|
73
61
|
*/
|
|
74
62
|
export const PackageLicense = definePackagePolicy({
|
|
75
63
|
name: "PackageLicense",
|
|
@@ -79,37 +67,29 @@ export const PackageLicense = definePackagePolicy({
|
|
|
79
67
|
const licenseFileName = config?.licenseFileName ?? DEFAULT_LICENSE_FILE_NAME;
|
|
80
68
|
// Skip private packages if configured to do so
|
|
81
69
|
if (skipPrivate && json.private === true) {
|
|
82
|
-
return
|
|
70
|
+
return [];
|
|
83
71
|
}
|
|
84
72
|
const packageName = json.name ?? "unknown";
|
|
85
|
-
|
|
86
|
-
const packageDir = path.dirname(file);
|
|
73
|
+
const packageDir = path.dirname(path.resolve(root, file));
|
|
87
74
|
const packageLicensePath = path.join(packageDir, licenseFileName);
|
|
88
75
|
const rootLicensePath = path.join(root, licenseFileName);
|
|
89
76
|
// Check if root LICENSE exists
|
|
90
77
|
if (!existsSync(rootLicensePath)) {
|
|
91
|
-
return
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
autoFixable: false,
|
|
95
|
-
errorMessages: [
|
|
96
|
-
`Cannot validate package LICENSE: root ${licenseFileName} file not found`,
|
|
97
|
-
],
|
|
98
|
-
};
|
|
78
|
+
return [
|
|
79
|
+
`Cannot validate package LICENSE: root ${licenseFileName} file not found`,
|
|
80
|
+
].map((message) => ({ message }));
|
|
99
81
|
}
|
|
100
82
|
// Check if package LICENSE exists
|
|
101
83
|
if (!existsSync(packageLicensePath)) {
|
|
102
84
|
if (resolve) {
|
|
103
85
|
return await copyLicenseFile(rootLicensePath, packageLicensePath, POLICY_NAME, file, packageName, licenseFileName, true);
|
|
104
86
|
}
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
],
|
|
112
|
-
};
|
|
87
|
+
return [
|
|
88
|
+
`${licenseFileName} file missing for package "${packageName}"`,
|
|
89
|
+
].map((message) => ({
|
|
90
|
+
message,
|
|
91
|
+
fixStatus: "available",
|
|
92
|
+
}));
|
|
113
93
|
}
|
|
114
94
|
// Compare package LICENSE with root LICENSE
|
|
115
95
|
const [packageLicenseContent, rootLicenseContent] = await Promise.all([
|
|
@@ -120,16 +100,14 @@ export const PackageLicense = definePackagePolicy({
|
|
|
120
100
|
if (resolve) {
|
|
121
101
|
return await copyLicenseFile(rootLicensePath, packageLicensePath, POLICY_NAME, file, packageName, licenseFileName, false);
|
|
122
102
|
}
|
|
123
|
-
return
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
],
|
|
130
|
-
};
|
|
103
|
+
return [
|
|
104
|
+
`${licenseFileName} file in package "${packageName}" doesn't match root ${licenseFileName}`,
|
|
105
|
+
].map((message) => ({
|
|
106
|
+
message,
|
|
107
|
+
fixStatus: "available",
|
|
108
|
+
}));
|
|
131
109
|
}
|
|
132
|
-
return
|
|
110
|
+
return [];
|
|
133
111
|
},
|
|
134
112
|
});
|
|
135
113
|
//# sourceMappingURL=PackageLicense.js.map
|