repopo 0.10.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +113 -0
- package/README.md +76 -77
- package/THIRD-PARTY-LICENSES.txt +232 -14
- package/bin/dev.js +5 -1
- package/esm/adapters/fluidFramework.d.ts +13 -9
- package/esm/adapters/fluidFramework.d.ts.map +1 -1
- package/esm/adapters/fluidFramework.js +20 -43
- package/esm/adapters/fluidFramework.js.map +1 -1
- package/esm/api.d.ts +64 -1
- package/esm/api.d.ts.map +1 -1
- package/esm/api.js +17 -1
- package/esm/api.js.map +1 -1
- package/esm/baseCommand.d.ts +1 -1
- package/esm/baseCommand.d.ts.map +1 -1
- package/esm/baseCommand.js +7 -10
- package/esm/baseCommand.js.map +1 -1
- package/esm/commands/check-native.d.ts +25 -0
- package/esm/commands/check-native.d.ts.map +1 -0
- package/esm/commands/check-native.js +156 -0
- package/esm/commands/check-native.js.map +1 -0
- package/esm/commands/check.d.ts +7 -34
- package/esm/commands/check.d.ts.map +1 -1
- package/esm/commands/check.js +76 -265
- package/esm/commands/check.js.map +1 -1
- package/esm/commands/list.d.ts.map +1 -1
- package/esm/commands/list.js +6 -6
- package/esm/commands/list.js.map +1 -1
- package/esm/concurrency.d.ts +3 -0
- package/esm/concurrency.d.ts.map +1 -0
- package/esm/concurrency.js +8 -0
- package/esm/concurrency.js.map +1 -0
- package/esm/config.d.ts +5 -39
- package/esm/config.d.ts.map +1 -1
- package/esm/config.js +3 -7
- package/esm/config.js.map +1 -1
- package/esm/context.d.ts +20 -3
- package/esm/context.d.ts.map +1 -1
- package/esm/context.js +18 -1
- package/esm/context.js.map +1 -1
- package/esm/executionContractError.d.ts +4 -0
- package/esm/executionContractError.d.ts.map +1 -0
- package/esm/executionContractError.js +4 -0
- package/esm/executionContractError.js.map +1 -0
- package/esm/fileCache.d.ts +12 -0
- package/esm/fileCache.d.ts.map +1 -0
- package/esm/fileCache.js +37 -0
- package/esm/fileCache.js.map +1 -0
- package/esm/filePaths.d.ts +2 -0
- package/esm/filePaths.d.ts.map +1 -0
- package/esm/filePaths.js +9 -0
- package/esm/filePaths.js.map +1 -0
- package/esm/generators.d.ts +0 -20
- package/esm/generators.d.ts.map +1 -1
- package/esm/generators.js.map +1 -1
- package/esm/index.d.ts +3 -11
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +3 -14
- package/esm/index.js.map +1 -1
- package/esm/makePolicy.d.ts +26 -79
- package/esm/makePolicy.d.ts.map +1 -1
- package/esm/makePolicy.js +51 -95
- package/esm/makePolicy.js.map +1 -1
- package/esm/perf.d.ts +10 -2
- package/esm/perf.d.ts.map +1 -1
- package/esm/perf.js +10 -9
- package/esm/perf.js.map +1 -1
- package/esm/policies/CargoLicenceValidated.d.ts +41 -0
- package/esm/policies/CargoLicenceValidated.d.ts.map +1 -0
- package/esm/policies/CargoLicenceValidated.js +47 -0
- package/esm/policies/CargoLicenceValidated.js.map +1 -0
- package/esm/policies/CargoLintsConfigured.d.ts +30 -0
- package/esm/policies/CargoLintsConfigured.d.ts.map +1 -0
- package/esm/policies/CargoLintsConfigured.js +65 -0
- package/esm/policies/CargoLintsConfigured.js.map +1 -0
- package/esm/policies/CargoLockPolicy.d.ts +34 -0
- package/esm/policies/CargoLockPolicy.d.ts.map +1 -0
- package/esm/policies/CargoLockPolicy.js +61 -0
- package/esm/policies/CargoLockPolicy.js.map +1 -0
- package/esm/policies/CargoTomlRequired.d.ts +34 -0
- package/esm/policies/CargoTomlRequired.d.ts.map +1 -0
- package/esm/policies/CargoTomlRequired.js +77 -0
- package/esm/policies/CargoTomlRequired.js.map +1 -0
- package/esm/policies/CargoTomlSorted.d.ts +20 -0
- package/esm/policies/CargoTomlSorted.d.ts.map +1 -0
- package/esm/policies/CargoTomlSorted.js +168 -0
- package/esm/policies/CargoTomlSorted.js.map +1 -0
- package/esm/policies/ConditionalScripts.d.ts +10 -8
- package/esm/policies/ConditionalScripts.d.ts.map +1 -1
- package/esm/policies/ConditionalScripts.js +27 -24
- package/esm/policies/ConditionalScripts.js.map +1 -1
- package/esm/policies/ExactScripts.d.ts +8 -6
- package/esm/policies/ExactScripts.d.ts.map +1 -1
- package/esm/policies/ExactScripts.js +18 -20
- package/esm/policies/ExactScripts.js.map +1 -1
- package/esm/policies/GleamDepVersions.d.ts +25 -0
- package/esm/policies/GleamDepVersions.d.ts.map +1 -0
- package/esm/policies/GleamDepVersions.js +67 -0
- package/esm/policies/GleamDepVersions.js.map +1 -0
- package/esm/policies/GleamDocExists.d.ts +24 -0
- package/esm/policies/GleamDocExists.d.ts.map +1 -0
- package/esm/policies/GleamDocExists.js +39 -0
- package/esm/policies/GleamDocExists.js.map +1 -0
- package/esm/policies/GleamInternalModulesConfigured.d.ts +21 -0
- package/esm/policies/GleamInternalModulesConfigured.d.ts.map +1 -0
- package/esm/policies/GleamInternalModulesConfigured.js +32 -0
- package/esm/policies/GleamInternalModulesConfigured.js.map +1 -0
- package/esm/policies/GleamLicenceConfigured.d.ts +29 -0
- package/esm/policies/GleamLicenceConfigured.d.ts.map +1 -0
- package/esm/policies/GleamLicenceConfigured.js +36 -0
- package/esm/policies/GleamLicenceConfigured.js.map +1 -0
- package/esm/policies/GleamManifestCommitted.d.ts +16 -0
- package/esm/policies/GleamManifestCommitted.d.ts.map +1 -0
- package/esm/policies/GleamManifestCommitted.js +27 -0
- package/esm/policies/GleamManifestCommitted.js.map +1 -0
- package/esm/policies/GleamMonorepoConsistency.d.ts +38 -0
- package/esm/policies/GleamMonorepoConsistency.d.ts.map +1 -0
- package/esm/policies/GleamMonorepoConsistency.js +74 -0
- package/esm/policies/GleamMonorepoConsistency.js.map +1 -0
- package/esm/policies/GleamNameRestrictions.d.ts +25 -0
- package/esm/policies/GleamNameRestrictions.d.ts.map +1 -0
- package/esm/policies/GleamNameRestrictions.js +44 -0
- package/esm/policies/GleamNameRestrictions.js.map +1 -0
- package/esm/policies/GleamNoPathDepsInPublished.d.ts +22 -0
- package/esm/policies/GleamNoPathDepsInPublished.d.ts.map +1 -0
- package/esm/policies/GleamNoPathDepsInPublished.js +43 -0
- package/esm/policies/GleamNoPathDepsInPublished.js.map +1 -0
- package/esm/policies/GleamPathDepsValid.d.ts +9 -0
- package/esm/policies/GleamPathDepsValid.d.ts.map +1 -0
- package/esm/policies/GleamPathDepsValid.js +59 -0
- package/esm/policies/GleamPathDepsValid.js.map +1 -0
- package/esm/policies/GleamProjectStructure.d.ts +32 -0
- package/esm/policies/GleamProjectStructure.d.ts.map +1 -0
- package/esm/policies/GleamProjectStructure.js +32 -0
- package/esm/policies/GleamProjectStructure.js.map +1 -0
- package/esm/policies/GleamSharedDependencyVersions.d.ts +37 -0
- package/esm/policies/GleamSharedDependencyVersions.d.ts.map +1 -0
- package/esm/policies/GleamSharedDependencyVersions.js +101 -0
- package/esm/policies/GleamSharedDependencyVersions.js.map +1 -0
- package/esm/policies/GleamTomlRequired.d.ts +30 -0
- package/esm/policies/GleamTomlRequired.d.ts.map +1 -0
- package/esm/policies/GleamTomlRequired.js +37 -0
- package/esm/policies/GleamTomlRequired.js.map +1 -0
- package/esm/policies/GleamTomlSorted.d.ts +20 -0
- package/esm/policies/GleamTomlSorted.d.ts.map +1 -0
- package/esm/policies/GleamTomlSorted.js +157 -0
- package/esm/policies/GleamTomlSorted.js.map +1 -0
- package/esm/policies/GleamVersionConstraint.d.ts +20 -0
- package/esm/policies/GleamVersionConstraint.d.ts.map +1 -0
- package/esm/policies/GleamVersionConstraint.js +68 -0
- package/esm/policies/GleamVersionConstraint.js.map +1 -0
- package/esm/policies/HtmlFileHeaders.d.ts +4 -2
- package/esm/policies/HtmlFileHeaders.d.ts.map +1 -1
- package/esm/policies/HtmlFileHeaders.js +2 -2
- package/esm/policies/HtmlFileHeaders.js.map +1 -1
- package/esm/policies/JsTsFileHeaders.d.ts +4 -2
- package/esm/policies/JsTsFileHeaders.d.ts.map +1 -1
- package/esm/policies/JsTsFileHeaders.js +1 -1
- package/esm/policies/JsTsFileHeaders.js.map +1 -1
- package/esm/policies/LicenseFileExists.d.ts +10 -4
- package/esm/policies/LicenseFileExists.d.ts.map +1 -1
- package/esm/policies/LicenseFileExists.js +27 -20
- package/esm/policies/LicenseFileExists.js.map +1 -1
- package/esm/policies/MutuallyExclusiveScripts.d.ts +8 -6
- package/esm/policies/MutuallyExclusiveScripts.d.ts.map +1 -1
- package/esm/policies/MutuallyExclusiveScripts.js +9 -13
- package/esm/policies/MutuallyExclusiveScripts.js.map +1 -1
- package/esm/policies/NoBuildDirectory.d.ts +15 -0
- package/esm/policies/NoBuildDirectory.d.ts.map +1 -0
- package/esm/policies/NoBuildDirectory.js +24 -0
- package/esm/policies/NoBuildDirectory.js.map +1 -0
- package/esm/policies/NoJsFileExtensions.d.ts +9 -3
- package/esm/policies/NoJsFileExtensions.d.ts.map +1 -1
- package/esm/policies/NoJsFileExtensions.js +9 -14
- package/esm/policies/NoJsFileExtensions.js.map +1 -1
- package/esm/policies/NoLargeBinaryFiles.d.ts +9 -4
- package/esm/policies/NoLargeBinaryFiles.d.ts.map +1 -1
- package/esm/policies/NoLargeBinaryFiles.js +10 -16
- package/esm/policies/NoLargeBinaryFiles.js.map +1 -1
- package/esm/policies/NoPrivateWorkspaceDependencies.d.ts +10 -6
- package/esm/policies/NoPrivateWorkspaceDependencies.d.ts.map +1 -1
- package/esm/policies/NoPrivateWorkspaceDependencies.js +12 -14
- package/esm/policies/NoPrivateWorkspaceDependencies.js.map +1 -1
- package/esm/policies/NoTargetArtifacts.d.ts +14 -0
- package/esm/policies/NoTargetArtifacts.d.ts.map +1 -0
- package/esm/policies/NoTargetArtifacts.js +37 -0
- package/esm/policies/NoTargetArtifacts.js.map +1 -0
- package/esm/policies/NoUnsafeWithoutJustification.d.ts +31 -0
- package/esm/policies/NoUnsafeWithoutJustification.d.ts.map +1 -0
- package/esm/policies/NoUnsafeWithoutJustification.js +79 -0
- package/esm/policies/NoUnsafeWithoutJustification.js.map +1 -0
- package/esm/policies/NoWildcardDependencies.d.ts +30 -0
- package/esm/policies/NoWildcardDependencies.d.ts.map +1 -0
- package/esm/policies/NoWildcardDependencies.js +83 -0
- package/esm/policies/NoWildcardDependencies.js.map +1 -0
- package/esm/policies/PackageAllowedScopes.d.ts +9 -5
- package/esm/policies/PackageAllowedScopes.d.ts.map +1 -1
- package/esm/policies/PackageAllowedScopes.js +15 -16
- package/esm/policies/PackageAllowedScopes.js.map +1 -1
- package/esm/policies/PackageEsmType.d.ts +7 -5
- package/esm/policies/PackageEsmType.d.ts.map +1 -1
- package/esm/policies/PackageEsmType.js +38 -36
- package/esm/policies/PackageEsmType.js.map +1 -1
- package/esm/policies/PackageFolderName.d.ts +8 -6
- package/esm/policies/PackageFolderName.d.ts.map +1 -1
- package/esm/policies/PackageFolderName.js +13 -16
- package/esm/policies/PackageFolderName.js.map +1 -1
- package/esm/policies/PackageJsonProperties.d.ts +5 -3
- package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
- package/esm/policies/PackageJsonProperties.js +18 -21
- package/esm/policies/PackageJsonProperties.js.map +1 -1
- package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts +2 -7
- package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
- package/esm/policies/PackageJsonRepoDirectoryProperty.js +29 -42
- package/esm/policies/PackageJsonRepoDirectoryProperty.js.map +1 -1
- package/esm/policies/PackageJsonSorted.d.ts +2 -2
- package/esm/policies/PackageJsonSorted.d.ts.map +1 -1
- package/esm/policies/PackageJsonSorted.js +51 -31
- package/esm/policies/PackageJsonSorted.js.map +1 -1
- package/esm/policies/PackageLicense.d.ts +4 -4
- package/esm/policies/PackageLicense.d.ts.map +1 -1
- package/esm/policies/PackageLicense.js +32 -54
- package/esm/policies/PackageLicense.js.map +1 -1
- package/esm/policies/PackagePrivateField.d.ts +12 -8
- package/esm/policies/PackagePrivateField.d.ts.map +1 -1
- package/esm/policies/PackagePrivateField.js +34 -25
- package/esm/policies/PackagePrivateField.js.map +1 -1
- package/esm/policies/PackageReadme.d.ts +6 -5
- package/esm/policies/PackageReadme.d.ts.map +1 -1
- package/esm/policies/PackageReadme.js +24 -61
- package/esm/policies/PackageReadme.js.map +1 -1
- package/esm/policies/PackageScripts.d.ts +26 -22
- package/esm/policies/PackageScripts.d.ts.map +1 -1
- package/esm/policies/PackageScripts.js +42 -38
- package/esm/policies/PackageScripts.js.map +1 -1
- package/esm/policies/PackageTestScripts.d.ts +10 -6
- package/esm/policies/PackageTestScripts.d.ts.map +1 -1
- package/esm/policies/PackageTestScripts.js +17 -19
- package/esm/policies/PackageTestScripts.js.map +1 -1
- package/esm/policies/PublicApiDocumented.d.ts +21 -0
- package/esm/policies/PublicApiDocumented.d.ts.map +1 -0
- package/esm/policies/PublicApiDocumented.js +38 -0
- package/esm/policies/PublicApiDocumented.js.map +1 -0
- package/esm/policies/RequiredGitignorePatterns.d.ts +11 -4
- package/esm/policies/RequiredGitignorePatterns.d.ts.map +1 -1
- package/esm/policies/RequiredGitignorePatterns.js +29 -36
- package/esm/policies/RequiredGitignorePatterns.js.map +1 -1
- package/esm/policies/RequiredScripts.d.ts +9 -7
- package/esm/policies/RequiredScripts.d.ts.map +1 -1
- package/esm/policies/RequiredScripts.js +27 -26
- package/esm/policies/RequiredScripts.js.map +1 -1
- package/esm/policies/RustDocExists.d.ts +24 -0
- package/esm/policies/RustDocExists.d.ts.map +1 -0
- package/esm/policies/RustDocExists.js +49 -0
- package/esm/policies/RustDocExists.js.map +1 -0
- package/esm/policies/RustToolchainExists.d.ts +27 -0
- package/esm/policies/RustToolchainExists.d.ts.map +1 -0
- package/esm/policies/RustToolchainExists.js +28 -0
- package/esm/policies/RustToolchainExists.js.map +1 -0
- package/esm/policies/RustfmtConfigExists.d.ts +27 -0
- package/esm/policies/RustfmtConfigExists.d.ts.map +1 -0
- package/esm/policies/RustfmtConfigExists.js +28 -0
- package/esm/policies/RustfmtConfigExists.js.map +1 -0
- package/esm/policies/ScriptContains.d.ts +9 -7
- package/esm/policies/ScriptContains.d.ts.map +1 -1
- package/esm/policies/ScriptContains.js +9 -13
- package/esm/policies/ScriptContains.js.map +1 -1
- package/esm/policies/SharedDependencyVersions.d.ts +29 -0
- package/esm/policies/SharedDependencyVersions.d.ts.map +1 -0
- package/esm/policies/SharedDependencyVersions.js +143 -0
- package/esm/policies/SharedDependencyVersions.js.map +1 -0
- package/esm/policies/WorkspaceInheritance.d.ts +31 -0
- package/esm/policies/WorkspaceInheritance.d.ts.map +1 -0
- package/esm/policies/WorkspaceInheritance.js +93 -0
- package/esm/policies/WorkspaceInheritance.js.map +1 -0
- package/esm/policies/WorkspaceMembersValid.d.ts +27 -0
- package/esm/policies/WorkspaceMembersValid.d.ts.map +1 -0
- package/esm/policies/WorkspaceMembersValid.js +87 -0
- package/esm/policies/WorkspaceMembersValid.js.map +1 -0
- package/esm/policies/constants.d.ts +8 -0
- package/esm/policies/constants.d.ts.map +1 -1
- package/esm/policies/constants.js +9 -1
- package/esm/policies/constants.js.map +1 -1
- package/esm/policies.d.ts +43 -5
- package/esm/policies.d.ts.map +1 -1
- package/esm/policies.js +63 -6
- package/esm/policies.js.map +1 -1
- package/esm/policy.d.ts +65 -269
- package/esm/policy.d.ts.map +1 -1
- package/esm/policy.js +1 -122
- package/esm/policy.js.map +1 -1
- package/esm/policyDefiners/defineCargoPolicy.d.ts +82 -0
- package/esm/policyDefiners/defineCargoPolicy.d.ts.map +1 -0
- package/esm/policyDefiners/defineCargoPolicy.js +42 -0
- package/esm/policyDefiners/defineCargoPolicy.js.map +1 -0
- package/esm/policyDefiners/defineFileHeaderPolicy.d.ts +27 -14
- package/esm/policyDefiners/defineFileHeaderPolicy.d.ts.map +1 -1
- package/esm/policyDefiners/defineFileHeaderPolicy.js +19 -39
- package/esm/policyDefiners/defineFileHeaderPolicy.js.map +1 -1
- package/esm/policyDefiners/defineGleamPolicy.d.ts +81 -0
- package/esm/policyDefiners/defineGleamPolicy.d.ts.map +1 -0
- package/esm/policyDefiners/defineGleamPolicy.js +42 -0
- package/esm/policyDefiners/defineGleamPolicy.js.map +1 -0
- package/esm/policyDefiners/definePackagePolicy.d.ts +24 -13
- package/esm/policyDefiners/definePackagePolicy.d.ts.map +1 -1
- package/esm/policyDefiners/definePackagePolicy.js +9 -32
- package/esm/policyDefiners/definePackagePolicy.js.map +1 -1
- package/esm/policyDefiners/spdxValidator.d.ts +66 -0
- package/esm/policyDefiners/spdxValidator.d.ts.map +1 -0
- package/esm/policyDefiners/spdxValidator.js +139 -0
- package/esm/policyDefiners/spdxValidator.js.map +1 -0
- package/esm/policyDefiners/tomlParser.d.ts +8 -0
- package/esm/policyDefiners/tomlParser.d.ts.map +1 -0
- package/esm/policyDefiners/tomlParser.js +17 -0
- package/esm/policyDefiners/tomlParser.js.map +1 -0
- package/esm/policyExecution.d.ts +19 -0
- package/esm/policyExecution.d.ts.map +1 -0
- package/esm/policyExecution.js +224 -0
- package/esm/policyExecution.js.map +1 -0
- package/esm/repositoryFiles.d.ts +4 -0
- package/esm/repositoryFiles.d.ts.map +1 -0
- package/esm/repositoryFiles.js +8 -0
- package/esm/repositoryFiles.js.map +1 -0
- package/esm/runner.d.ts +85 -0
- package/esm/runner.d.ts.map +1 -0
- package/esm/runner.js +189 -0
- package/esm/runner.js.map +1 -0
- package/esm/settlePolicyPromise.d.ts +4 -0
- package/esm/settlePolicyPromise.d.ts.map +1 -0
- package/esm/settlePolicyPromise.js +10 -0
- package/esm/settlePolicyPromise.js.map +1 -0
- package/esm/tsdoc-metadata.json +1 -1
- package/esm/utils/safePaths.d.ts +9 -0
- package/esm/utils/safePaths.d.ts.map +1 -0
- package/esm/utils/safePaths.js +40 -0
- package/esm/utils/safePaths.js.map +1 -0
- package/oclif.manifest.json +117 -3
- package/package.json +66 -36
- package/scripts/benchmark.mjs +341 -0
- package/scripts/postinstall.mjs +154 -0
- package/sidecar/sidecar.mjs +399 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { randomInt } from "node:crypto";
|
|
3
|
+
import { access, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import { arch, cpus, platform, release, tmpdir } from "node:os";
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
+
import { parseArgs } from "node:util";
|
|
7
|
+
import { dirname, join, resolve } from "pathe";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Measure through process exit, including startup and stdin transfer.
|
|
11
|
+
* @param {string[]} command
|
|
12
|
+
* @param {string} cwd
|
|
13
|
+
* @param {string} [input]
|
|
14
|
+
* @returns {Promise<{milliseconds: number, stdout: string}>}
|
|
15
|
+
*/
|
|
16
|
+
export async function measure(command, cwd, input = "") {
|
|
17
|
+
const start = performance.now();
|
|
18
|
+
return new Promise((resolvePromise, reject) => {
|
|
19
|
+
const child = spawn(command[0], command.slice(1), { cwd });
|
|
20
|
+
let stdout = "";
|
|
21
|
+
let stderr = "";
|
|
22
|
+
child.stdout.setEncoding("utf8").on("data", (data) => {
|
|
23
|
+
stdout += data;
|
|
24
|
+
});
|
|
25
|
+
child.stderr.setEncoding("utf8").on("data", (data) => {
|
|
26
|
+
stderr += data;
|
|
27
|
+
});
|
|
28
|
+
child.on("error", reject);
|
|
29
|
+
// A process that exits early may close stdin before consuming the snapshot.
|
|
30
|
+
child.stdin.on("error", (error) => {
|
|
31
|
+
if (error.code !== "EPIPE") {
|
|
32
|
+
reject(error);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
child.on("close", (code, signal) => {
|
|
36
|
+
if (code !== 0) {
|
|
37
|
+
reject(
|
|
38
|
+
new Error(
|
|
39
|
+
`${JSON.stringify(command)} exited with ${signal ?? code}\n${stdout}${stderr}`,
|
|
40
|
+
),
|
|
41
|
+
);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
resolvePromise({ milliseconds: performance.now() - start, stdout });
|
|
45
|
+
});
|
|
46
|
+
child.stdin.end(input);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Each round runs every case once, in shuffled order, without concurrency.
|
|
52
|
+
* @param {{scenario: string, engine: string, command: string[], input: string}[]} cases
|
|
53
|
+
* @param {{cwd: string, warmup: number, runs: number}} options
|
|
54
|
+
*/
|
|
55
|
+
export async function runRounds(cases, { cwd, warmup, runs }) {
|
|
56
|
+
const samples = [];
|
|
57
|
+
for (let round = -warmup; round < runs; round++) {
|
|
58
|
+
const ordered = [...cases];
|
|
59
|
+
for (let i = ordered.length - 1; i > 0; i--) {
|
|
60
|
+
const j = randomInt(i + 1);
|
|
61
|
+
[ordered[i], ordered[j]] = [ordered[j], ordered[i]];
|
|
62
|
+
}
|
|
63
|
+
for (const [order, entry] of ordered.entries()) {
|
|
64
|
+
const { milliseconds } = await measure(entry.command, cwd, entry.input);
|
|
65
|
+
if (round >= 0) {
|
|
66
|
+
samples.push({
|
|
67
|
+
scenario: entry.scenario,
|
|
68
|
+
engine: entry.engine,
|
|
69
|
+
round,
|
|
70
|
+
order,
|
|
71
|
+
milliseconds,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
console.log(
|
|
76
|
+
`${round < 0 ? "Warmup" : "Timed"} round ${round < 0 ? round + warmup + 1 : round + 1} complete`,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return samples;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** @param {number[]} values */
|
|
83
|
+
export function summarize(values) {
|
|
84
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
85
|
+
if (sorted.length === 0) {
|
|
86
|
+
throw new Error("Cannot summarize an empty sample.");
|
|
87
|
+
}
|
|
88
|
+
const quantile = (fraction) => {
|
|
89
|
+
const index = (sorted.length - 1) * fraction;
|
|
90
|
+
const lower = Math.floor(index);
|
|
91
|
+
return (
|
|
92
|
+
sorted[lower] +
|
|
93
|
+
(sorted[Math.ceil(index)] - sorted[lower]) * (index - lower)
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
const mean = values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
97
|
+
return {
|
|
98
|
+
median: quantile(0.5),
|
|
99
|
+
mean,
|
|
100
|
+
stddev:
|
|
101
|
+
values.length < 2
|
|
102
|
+
? 0
|
|
103
|
+
: Math.sqrt(
|
|
104
|
+
values.reduce((sum, value) => sum + (value - mean) ** 2, 0) /
|
|
105
|
+
(values.length - 1),
|
|
106
|
+
),
|
|
107
|
+
p25: quantile(0.25),
|
|
108
|
+
p75: quantile(0.75),
|
|
109
|
+
min: sorted[0],
|
|
110
|
+
max: sorted.at(-1),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function main() {
|
|
115
|
+
const { values } = parseArgs({
|
|
116
|
+
options: {
|
|
117
|
+
quick: { type: "boolean" },
|
|
118
|
+
runs: { type: "string" },
|
|
119
|
+
warmup: { type: "string" },
|
|
120
|
+
json: { type: "string" },
|
|
121
|
+
scenario: { type: "string", multiple: true },
|
|
122
|
+
help: { type: "boolean" },
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
if (values.help) {
|
|
126
|
+
console.log(
|
|
127
|
+
"Usage: benchmark.sh [--quick] [--runs N] [--warmup N] [--json PATH] [--scenario NAME ...]",
|
|
128
|
+
);
|
|
129
|
+
console.log(
|
|
130
|
+
"Scenarios: startup, empty, inventory-stdin, inventory-git, config, matching, noop, real-stdin, real-git",
|
|
131
|
+
);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const runs = Number(values.runs ?? (values.quick ? 3 : 10));
|
|
135
|
+
const warmup = Number(values.warmup ?? (values.quick ? 1 : 3));
|
|
136
|
+
if (
|
|
137
|
+
!Number.isInteger(runs) ||
|
|
138
|
+
runs < 1 ||
|
|
139
|
+
!Number.isInteger(warmup) ||
|
|
140
|
+
warmup < 0
|
|
141
|
+
) {
|
|
142
|
+
throw new Error(
|
|
143
|
+
"--runs must be a positive integer; --warmup must be a non-negative integer.",
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
147
|
+
const cwd = resolve(packageRoot, "../..");
|
|
148
|
+
const cli = join(packageRoot, "bin/run.js");
|
|
149
|
+
const binary = join(
|
|
150
|
+
packageRoot,
|
|
151
|
+
"crates/core/target/release",
|
|
152
|
+
platform() === "win32" ? "repopo-core.exe" : "repopo-core",
|
|
153
|
+
);
|
|
154
|
+
await access(join(packageRoot, "esm/commands/check.js"));
|
|
155
|
+
try {
|
|
156
|
+
await access(binary);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
throw new Error(
|
|
159
|
+
"Build the release engine first: cargo build --release --manifest-path packages/repopo/crates/core/Cargo.toml",
|
|
160
|
+
{ cause: error },
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
let bunVersion = null;
|
|
164
|
+
try {
|
|
165
|
+
bunVersion = (await measure(["bun", "--version"], cwd)).stdout.trim();
|
|
166
|
+
} catch (error) {
|
|
167
|
+
if (error.code !== "ENOENT") {
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
170
|
+
console.log("Bun not found; skipping Bun variants.");
|
|
171
|
+
}
|
|
172
|
+
const inventory = (
|
|
173
|
+
await measure(
|
|
174
|
+
["git", "ls-files", "-co", "-z", "--exclude-standard", "--full-name"],
|
|
175
|
+
cwd,
|
|
176
|
+
)
|
|
177
|
+
).stdout;
|
|
178
|
+
const files = inventory.split("\0").filter(Boolean);
|
|
179
|
+
if (files.some((file) => /[\r\n]/.test(file))) {
|
|
180
|
+
throw new Error(
|
|
181
|
+
"The stdin benchmark cannot represent filenames containing newlines.",
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
const snapshot = `${files.join("\n")}\n`;
|
|
185
|
+
const directory = await mkdtemp(join(tmpdir(), "repopo-benchmark-"));
|
|
186
|
+
try {
|
|
187
|
+
const empty = join(directory, "empty.mjs");
|
|
188
|
+
const miss = join(directory, "miss.mjs");
|
|
189
|
+
const noop = join(directory, "noop.mjs");
|
|
190
|
+
await writeFile(empty, "export default { policies: [] };\n");
|
|
191
|
+
for (const [path, pattern] of [
|
|
192
|
+
[miss, "/^$/"],
|
|
193
|
+
[noop, "/./"],
|
|
194
|
+
]) {
|
|
195
|
+
await writeFile(
|
|
196
|
+
path,
|
|
197
|
+
`
|
|
198
|
+
import { policy } from ${JSON.stringify(pathToFileURL(join(packageRoot, "esm/makePolicy.js")).href)};
|
|
199
|
+
export default { policies: Array.from({ length: 20 }, (_, i) => policy({
|
|
200
|
+
name: "Benchmark" + i,
|
|
201
|
+
description: "Synthetic benchmark policy",
|
|
202
|
+
match: ${pattern},
|
|
203
|
+
handler: async () => true,
|
|
204
|
+
})) };
|
|
205
|
+
`,
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
const scenarios = [
|
|
209
|
+
{ name: "startup", args: null, input: "" },
|
|
210
|
+
{ name: "empty", args: ["--config", empty, "--stdin"], input: "" },
|
|
211
|
+
{
|
|
212
|
+
name: "inventory-stdin",
|
|
213
|
+
args: ["--config", empty, "--stdin"],
|
|
214
|
+
input: snapshot,
|
|
215
|
+
},
|
|
216
|
+
{ name: "inventory-git", args: ["--config", empty], input: "" },
|
|
217
|
+
{ name: "config", args: ["--config", miss, "--stdin"], input: "" },
|
|
218
|
+
{
|
|
219
|
+
name: "matching",
|
|
220
|
+
args: ["--config", miss, "--stdin"],
|
|
221
|
+
input: snapshot,
|
|
222
|
+
},
|
|
223
|
+
{ name: "noop", args: ["--config", noop, "--stdin"], input: snapshot },
|
|
224
|
+
{ name: "real-stdin", args: ["--stdin"], input: snapshot },
|
|
225
|
+
{ name: "real-git", args: [], input: "" },
|
|
226
|
+
];
|
|
227
|
+
for (const name of values.scenario ?? []) {
|
|
228
|
+
if (!scenarios.some((scenario) => scenario.name === name)) {
|
|
229
|
+
throw new Error(`Unknown scenario: ${name}`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const engines = [
|
|
233
|
+
{ name: "typescript", prefix: [process.execPath, cli], args: ["check"] },
|
|
234
|
+
...["node", ...(bunVersion ? ["bun"] : [])].flatMap((runtime) => [
|
|
235
|
+
{
|
|
236
|
+
name: `core-${runtime}`,
|
|
237
|
+
prefix: [binary],
|
|
238
|
+
args: [
|
|
239
|
+
"check",
|
|
240
|
+
"--sidecar-path",
|
|
241
|
+
join(packageRoot, "sidecar/sidecar.mjs"),
|
|
242
|
+
"--runtime",
|
|
243
|
+
runtime,
|
|
244
|
+
],
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: `cli-${runtime}`,
|
|
248
|
+
prefix: [process.execPath, cli],
|
|
249
|
+
args: ["check-native", "--binary-path", binary, "--runtime", runtime],
|
|
250
|
+
},
|
|
251
|
+
]),
|
|
252
|
+
];
|
|
253
|
+
const cases = scenarios
|
|
254
|
+
.filter(
|
|
255
|
+
(scenario) =>
|
|
256
|
+
!values.scenario || values.scenario.includes(scenario.name),
|
|
257
|
+
)
|
|
258
|
+
.flatMap((scenario) =>
|
|
259
|
+
engines.map((engine) => ({
|
|
260
|
+
scenario: scenario.name,
|
|
261
|
+
engine: engine.name,
|
|
262
|
+
command: [
|
|
263
|
+
...engine.prefix,
|
|
264
|
+
...(scenario.args === null
|
|
265
|
+
? ["--help"]
|
|
266
|
+
: [...engine.args, "--quiet", ...scenario.args]),
|
|
267
|
+
],
|
|
268
|
+
input: scenario.input,
|
|
269
|
+
})),
|
|
270
|
+
);
|
|
271
|
+
console.log(
|
|
272
|
+
`${files.length} files; ${cases.length} cases; ${warmup} warmups + ${runs} timed rounds. Any nonzero exit aborts.`,
|
|
273
|
+
);
|
|
274
|
+
const samples = await runRounds(cases, { cwd, runs, warmup });
|
|
275
|
+
const results = cases.map((entry) => ({
|
|
276
|
+
scenario: entry.scenario,
|
|
277
|
+
engine: entry.engine,
|
|
278
|
+
...summarize(
|
|
279
|
+
samples
|
|
280
|
+
.filter(
|
|
281
|
+
(sample) =>
|
|
282
|
+
sample.scenario === entry.scenario &&
|
|
283
|
+
sample.engine === entry.engine,
|
|
284
|
+
)
|
|
285
|
+
.map((sample) => sample.milliseconds),
|
|
286
|
+
),
|
|
287
|
+
}));
|
|
288
|
+
console.table(
|
|
289
|
+
results.map(({ scenario, engine, median, mean, stddev, p25, p75 }) => ({
|
|
290
|
+
scenario,
|
|
291
|
+
engine,
|
|
292
|
+
"median ms": median.toFixed(1),
|
|
293
|
+
"mean ms": mean.toFixed(1),
|
|
294
|
+
"sd ms": stddev.toFixed(1),
|
|
295
|
+
"p25 ms": p25.toFixed(1),
|
|
296
|
+
"p75 ms": p75.toFixed(1),
|
|
297
|
+
})),
|
|
298
|
+
);
|
|
299
|
+
if (values.json) {
|
|
300
|
+
await writeFile(
|
|
301
|
+
resolve(values.json),
|
|
302
|
+
`${JSON.stringify(
|
|
303
|
+
{
|
|
304
|
+
metadata: {
|
|
305
|
+
timestamp: new Date().toISOString(),
|
|
306
|
+
cwd,
|
|
307
|
+
node: process.version,
|
|
308
|
+
bun: bunVersion,
|
|
309
|
+
platform: platform(),
|
|
310
|
+
release: release(),
|
|
311
|
+
arch: arch(),
|
|
312
|
+
cpu: cpus()[0]?.model,
|
|
313
|
+
files: files.length,
|
|
314
|
+
syntheticPolicies: 20,
|
|
315
|
+
runs,
|
|
316
|
+
warmup,
|
|
317
|
+
units: "milliseconds",
|
|
318
|
+
},
|
|
319
|
+
cases,
|
|
320
|
+
samples,
|
|
321
|
+
results,
|
|
322
|
+
},
|
|
323
|
+
null,
|
|
324
|
+
2,
|
|
325
|
+
)}\n`,
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
} finally {
|
|
329
|
+
await rm(directory, { recursive: true, force: true });
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (
|
|
334
|
+
process.argv[1] &&
|
|
335
|
+
resolve(process.argv[1]) === fileURLToPath(import.meta.url)
|
|
336
|
+
) {
|
|
337
|
+
main().catch((error) => {
|
|
338
|
+
console.error(error);
|
|
339
|
+
process.exitCode = 1;
|
|
340
|
+
});
|
|
341
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Postinstall script for repopo - downloads pre-built repopo-core binary.
|
|
3
|
+
*
|
|
4
|
+
* This script uses only Node.js built-ins (no workspace dependencies).
|
|
5
|
+
* It gracefully handles all errors — a missing binary is not fatal since
|
|
6
|
+
* the Rust engine is optional.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { execFileSync } from "node:child_process";
|
|
10
|
+
import { createHash } from "node:crypto";
|
|
11
|
+
import {
|
|
12
|
+
chmodSync,
|
|
13
|
+
createWriteStream,
|
|
14
|
+
existsSync,
|
|
15
|
+
mkdirSync,
|
|
16
|
+
unlinkSync,
|
|
17
|
+
} from "node:fs";
|
|
18
|
+
import { readFile } from "node:fs/promises";
|
|
19
|
+
import { dirname, join } from "node:path";
|
|
20
|
+
import { pipeline } from "node:stream/promises";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
|
|
23
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
24
|
+
const packageRoot = join(__dirname, "..");
|
|
25
|
+
|
|
26
|
+
// Skip in source checkout (development)
|
|
27
|
+
if (existsSync(join(packageRoot, "crates", "core", "Cargo.toml"))) {
|
|
28
|
+
console.log("repopo: source checkout detected, skipping binary download.");
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Skip if explicitly disabled
|
|
33
|
+
// biome-ignore lint/style/noProcessEnv: Postinstall environment check
|
|
34
|
+
if (process.env.REPOPO_SKIP_POSTINSTALL === "1") {
|
|
35
|
+
console.log("repopo: REPOPO_SKIP_POSTINSTALL=1, skipping binary download.");
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const PLATFORM_MAP = {
|
|
40
|
+
"linux-x64": "repopo-core-linux-x64",
|
|
41
|
+
"linux-arm64": "repopo-core-linux-arm64",
|
|
42
|
+
"darwin-x64": "repopo-core-darwin-x64",
|
|
43
|
+
"darwin-arm64": "repopo-core-darwin-arm64",
|
|
44
|
+
"win32-x64": "repopo-core-win32-x64",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const platformKey = `${process.platform}-${process.arch}`;
|
|
48
|
+
const assetName = PLATFORM_MAP[platformKey];
|
|
49
|
+
|
|
50
|
+
if (!assetName) {
|
|
51
|
+
console.warn(
|
|
52
|
+
`repopo: unsupported platform ${platformKey}, skipping binary download.`,
|
|
53
|
+
);
|
|
54
|
+
process.exit(0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
const pkg = JSON.parse(
|
|
59
|
+
await readFile(join(packageRoot, "package.json"), "utf-8"),
|
|
60
|
+
);
|
|
61
|
+
const version = pkg.version;
|
|
62
|
+
const isWindows = process.platform === "win32";
|
|
63
|
+
const ext = isWindows ? ".zip" : ".tar.gz";
|
|
64
|
+
const binaryName = isWindows ? "repopo-core.exe" : "repopo-core";
|
|
65
|
+
const baseUrl = `https://github.com/tylerbutler/tools-monorepo/releases/download/repopo-core-v${version}`;
|
|
66
|
+
const archiveUrl = `${baseUrl}/${assetName}${ext}`;
|
|
67
|
+
const checksumUrl = `${archiveUrl}.sha256`;
|
|
68
|
+
|
|
69
|
+
const nativeDir = join(packageRoot, "native");
|
|
70
|
+
const binaryDest = join(nativeDir, binaryName);
|
|
71
|
+
|
|
72
|
+
// Skip if binary already exists
|
|
73
|
+
if (existsSync(binaryDest)) {
|
|
74
|
+
console.log("repopo: binary already exists, skipping download.");
|
|
75
|
+
process.exit(0);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
mkdirSync(nativeDir, { recursive: true });
|
|
79
|
+
|
|
80
|
+
console.log(`repopo: downloading ${assetName}${ext}...`);
|
|
81
|
+
|
|
82
|
+
// Download checksum
|
|
83
|
+
const checksumText = await fetchText(checksumUrl);
|
|
84
|
+
const expectedHash = checksumText.trim().split(/\s+/)[0];
|
|
85
|
+
|
|
86
|
+
// Download archive
|
|
87
|
+
const archivePath = join(nativeDir, `${assetName}${ext}`);
|
|
88
|
+
await downloadFile(archiveUrl, archivePath);
|
|
89
|
+
|
|
90
|
+
// Verify checksum
|
|
91
|
+
const fileBuffer = await readFile(archivePath);
|
|
92
|
+
const actualHash = createHash("sha256").update(fileBuffer).digest("hex");
|
|
93
|
+
|
|
94
|
+
if (actualHash !== expectedHash) {
|
|
95
|
+
unlinkSync(archivePath);
|
|
96
|
+
throw new Error(
|
|
97
|
+
`Checksum mismatch: expected ${expectedHash}, got ${actualHash}`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Extract — uses execFileSync with explicit argument arrays to avoid shell injection
|
|
102
|
+
if (isWindows) {
|
|
103
|
+
execFileSync(
|
|
104
|
+
"powershell",
|
|
105
|
+
[
|
|
106
|
+
"-Command",
|
|
107
|
+
`Expand-Archive -Path '${archivePath}' -DestinationPath '${nativeDir}' -Force`,
|
|
108
|
+
],
|
|
109
|
+
{ stdio: "pipe" },
|
|
110
|
+
);
|
|
111
|
+
} else {
|
|
112
|
+
execFileSync("tar", ["xzf", archivePath, "-C", nativeDir], {
|
|
113
|
+
stdio: "pipe",
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Clean up archive
|
|
118
|
+
unlinkSync(archivePath);
|
|
119
|
+
|
|
120
|
+
// Set executable permission (non-Windows)
|
|
121
|
+
if (!isWindows) {
|
|
122
|
+
chmodSync(binaryDest, 0o755);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
console.log("repopo: binary installed successfully.");
|
|
126
|
+
} catch (err) {
|
|
127
|
+
console.warn(
|
|
128
|
+
`repopo: failed to download binary (${err.message}). The Rust engine will be unavailable.`,
|
|
129
|
+
);
|
|
130
|
+
process.exit(0);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Fetch text content from a URL using Node.js built-in fetch.
|
|
135
|
+
*/
|
|
136
|
+
async function fetchText(url) {
|
|
137
|
+
const res = await fetch(url);
|
|
138
|
+
if (!res.ok) {
|
|
139
|
+
throw new Error(`HTTP ${res.status} fetching ${url}`);
|
|
140
|
+
}
|
|
141
|
+
return res.text();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Download a file from a URL to a local path using Node.js built-in fetch.
|
|
146
|
+
*/
|
|
147
|
+
async function downloadFile(url, dest) {
|
|
148
|
+
const res = await fetch(url);
|
|
149
|
+
if (!res.ok) {
|
|
150
|
+
throw new Error(`HTTP ${res.status} fetching ${url}`);
|
|
151
|
+
}
|
|
152
|
+
const fileStream = createWriteStream(dest);
|
|
153
|
+
await pipeline(res.body, fileStream);
|
|
154
|
+
}
|