@pnpm/exec.prepare-package 1100.0.33 → 1100.0.34
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 +11 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +11 -13
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @pnpm/prepare-package
|
|
2
2
|
|
|
3
|
+
## 1100.0.34
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Enforce `allowBuilds` when a prepared git dependency is reused from the shared store, and use the lockfile's canonical git resolution ID in approval suggestions.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies:
|
|
10
|
+
- @pnpm/exec.lifecycle@1100.1.15
|
|
11
|
+
- @pnpm/pkg-manifest.reader@1100.0.18
|
|
12
|
+
- @pnpm/types@1102.1.0
|
|
13
|
+
|
|
3
14
|
## 1100.0.33
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AllowBuild } from '@pnpm/types';
|
|
1
|
+
import type { AllowBuild, PackageManifest } from '@pnpm/types';
|
|
2
2
|
export interface PreparePackageOptions {
|
|
3
3
|
allowBuild?: AllowBuild;
|
|
4
4
|
ignoreScripts?: boolean;
|
|
@@ -10,3 +10,4 @@ export declare function preparePackage(opts: PreparePackageOptions, gitRootDir:
|
|
|
10
10
|
shouldBeBuilt: boolean;
|
|
11
11
|
pkgDir: string;
|
|
12
12
|
}>;
|
|
13
|
+
export declare function assertPackageBuildIsAllowed(opts: Pick<PreparePackageOptions, 'allowBuild' | 'pkgResolutionId'>, manifest: Partial<PackageManifest>): void;
|
package/lib/index.js
CHANGED
|
@@ -22,19 +22,7 @@ export async function preparePackage(opts, gitRootDir, subDir) {
|
|
|
22
22
|
return { shouldBeBuilt: false, pkgDir };
|
|
23
23
|
if (opts.ignoreScripts)
|
|
24
24
|
return { shouldBeBuilt: true, pkgDir };
|
|
25
|
-
|
|
26
|
-
// If allowBuild is undefined or returns false, block the build.
|
|
27
|
-
// The depPath is synthesized from the resolution id rather than read from
|
|
28
|
-
// a lockfile; resolution ids of git and tarball artifacts are never
|
|
29
|
-
// semver-shaped, so the policy derives an untrusted package identity.
|
|
30
|
-
const depPath = `${manifest.name}@${opts.pkgResolutionId}`;
|
|
31
|
-
if (!opts.allowBuild?.(depPath)) {
|
|
32
|
-
throw new PnpmError('GIT_DEP_PREPARE_NOT_ALLOWED', `The git-hosted package "${manifest.name}@${manifest.version}" needs to execute build scripts but is not in the "allowBuilds" allowlist.`, {
|
|
33
|
-
hint: `Add the package to "allowBuilds" in your project's pnpm-workspace.yaml to allow it to run scripts. For example:
|
|
34
|
-
allowBuilds:
|
|
35
|
-
${depPath}: true`,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
25
|
+
assertPackageBuildIsAllowed(opts, manifest);
|
|
38
26
|
const pm = (await preferredPM(gitRootDir))?.name ?? 'npm';
|
|
39
27
|
const execOpts = {
|
|
40
28
|
depPath: `${manifest.name}@${manifest.version}`,
|
|
@@ -72,6 +60,16 @@ allowBuilds:
|
|
|
72
60
|
await rimraf(path.join(pkgDir, 'node_modules'));
|
|
73
61
|
return { shouldBeBuilt: true, pkgDir };
|
|
74
62
|
}
|
|
63
|
+
export function assertPackageBuildIsAllowed(opts, manifest) {
|
|
64
|
+
const depPath = `${manifest.name}@${opts.pkgResolutionId}`;
|
|
65
|
+
if (!opts.allowBuild?.(depPath)) {
|
|
66
|
+
throw new PnpmError('GIT_DEP_PREPARE_NOT_ALLOWED', `The git-hosted package "${manifest.name}@${manifest.version}" needs to execute build scripts but is not in the "allowBuilds" allowlist.`, {
|
|
67
|
+
hint: `Add the package to "allowBuilds" in your project's pnpm-workspace.yaml to allow it to run scripts. For example:
|
|
68
|
+
allowBuilds:
|
|
69
|
+
${depPath}: true`,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
75
73
|
function packageShouldBeBuilt(manifest, pkgDir) {
|
|
76
74
|
if (manifest.scripts == null)
|
|
77
75
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/exec.prepare-package",
|
|
3
|
-
"version": "1100.0.
|
|
3
|
+
"version": "1100.0.34",
|
|
4
4
|
"description": "Prepares a Git-hosted package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@pnpm/error": "1100.1.3",
|
|
31
|
-
"@pnpm/exec.lifecycle": "1100.1.
|
|
32
|
-
"@pnpm/pkg-manifest.reader": "1100.0.
|
|
33
|
-
"@pnpm/types": "1102.
|
|
31
|
+
"@pnpm/exec.lifecycle": "1100.1.15",
|
|
32
|
+
"@pnpm/pkg-manifest.reader": "1100.0.18",
|
|
33
|
+
"@pnpm/types": "1102.1.0",
|
|
34
34
|
"@zkochan/rimraf": "^4.0.0",
|
|
35
35
|
"execa": "npm:safe-execa@0.3.0",
|
|
36
36
|
"preferred-pm": "^5.0.0",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@jest/globals": "30.4.1",
|
|
41
|
-
"@pnpm/exec.prepare-package": "1100.0.
|
|
42
|
-
"@pnpm/prepare": "1100.0.
|
|
41
|
+
"@pnpm/exec.prepare-package": "1100.0.34",
|
|
42
|
+
"@pnpm/prepare": "1100.0.28",
|
|
43
43
|
"@pnpm/test-fixtures": "1100.0.1",
|
|
44
44
|
"@pnpm/test-ipc-server": "1100.0.0",
|
|
45
45
|
"@types/ramda": "0.32.0",
|