@pnpm/building.commands 1000.0.0-0 → 1100.0.1
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/lib/build/rebuild.d.ts +3 -3
- package/lib/build/rebuild.js +2 -1
- package/lib/build/recursive.d.ts +3 -3
- package/lib/build/recursive.js +0 -4
- package/lib/index.d.ts +1 -2
- package/lib/policy/approveBuilds.d.ts +6 -4
- package/lib/policy/approveBuilds.js +76 -13
- package/package.json +33 -30
package/lib/build/rebuild.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { type Config } from '@pnpm/config.reader';
|
|
1
|
+
import { type Config, type ConfigContext } from '@pnpm/config.reader';
|
|
2
2
|
import type { LogBase } from '@pnpm/logger';
|
|
3
3
|
import { type CreateStoreControllerOptions } from '@pnpm/store.connection-manager';
|
|
4
4
|
export declare function rcOptionsTypes(): Record<string, unknown>;
|
|
5
5
|
export declare function cliOptionsTypes(): Record<string, unknown>;
|
|
6
6
|
export declare const commandNames: string[];
|
|
7
|
+
export declare const overridableByScript = true;
|
|
7
8
|
export declare function help(): string;
|
|
8
|
-
export type RebuildCommandOpts = Pick<Config, '
|
|
9
|
+
export type RebuildCommandOpts = Pick<Config, 'dir' | 'engineStrict' | 'lockfileDir' | 'nodeLinker' | 'registries' | 'scriptShell' | 'sideEffectsCache' | 'sideEffectsCacheReadonly' | 'scriptsPrependNodePath' | 'shellEmulator' | 'workspaceDir'> & Pick<ConfigContext, 'allProjects' | 'hooks' | 'rootProjectManifest' | 'rootProjectManifestDir' | 'selectedProjectsGraph'> & CreateStoreControllerOptions & {
|
|
9
10
|
recursive?: boolean;
|
|
10
11
|
reporter?: (logObj: LogBase) => void;
|
|
11
12
|
pending: boolean;
|
|
12
13
|
skipIfHasSideEffectsCache?: boolean;
|
|
13
|
-
neverBuiltDependencies?: string[];
|
|
14
14
|
allowBuilds?: Record<string, boolean | string>;
|
|
15
15
|
};
|
|
16
16
|
export declare function handler(opts: RebuildCommandOpts, params: string[]): Promise<void>;
|
package/lib/build/rebuild.js
CHANGED
|
@@ -25,6 +25,7 @@ export function cliOptionsTypes() {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
export const commandNames = ['rebuild', 'rb'];
|
|
28
|
+
export const overridableByScript = true;
|
|
28
29
|
export function help() {
|
|
29
30
|
return renderHelp({
|
|
30
31
|
aliases: ['rb'],
|
|
@@ -41,7 +42,7 @@ For options that may be used with `-r`, see "pnpm help recursive"',
|
|
|
41
42
|
shortAlias: '-r',
|
|
42
43
|
},
|
|
43
44
|
{
|
|
44
|
-
description: 'Rebuild packages that were not
|
|
45
|
+
description: 'Rebuild packages that were not built during installation. Packages are not built when installing with the --ignore-scripts flag',
|
|
45
46
|
name: '--pending',
|
|
46
47
|
},
|
|
47
48
|
{
|
package/lib/build/recursive.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type Config } from '@pnpm/config.reader';
|
|
1
|
+
import { type Config, type ConfigContext } from '@pnpm/config.reader';
|
|
2
2
|
import { type CreateStoreControllerOptions } from '@pnpm/store.connection-manager';
|
|
3
3
|
import type { Project } from '@pnpm/types';
|
|
4
|
-
type RecursiveRebuildOpts = CreateStoreControllerOptions & Pick<Config, 'hoistPattern' | '
|
|
4
|
+
type RecursiveRebuildOpts = CreateStoreControllerOptions & Pick<Config, 'hoistPattern' | 'ignorePnpmfile' | 'ignoreScripts' | 'lockfileDir' | 'lockfileOnly' | 'nodeLinker' | 'packageConfigs' | 'registries' | 'sharedWorkspaceLockfile'> & Pick<ConfigContext, 'hooks' | 'rootProjectManifest' | 'rootProjectManifestDir'> & {
|
|
5
5
|
pending?: boolean;
|
|
6
6
|
} & Partial<Pick<Config, 'bail' | 'sort' | 'workspaceConcurrency'>>;
|
|
7
7
|
export declare function recursiveRebuild(allProjects: Project[], params: string[], opts: RecursiveRebuildOpts & {
|
|
8
8
|
ignoredPackages?: Set<string>;
|
|
9
|
-
} & Required<Pick<
|
|
9
|
+
} & Required<Pick<ConfigContext, 'selectedProjectsGraph'>> & Required<Pick<Config, 'workspaceDir'>>): Promise<void>;
|
|
10
10
|
export {};
|
package/lib/build/recursive.js
CHANGED
|
@@ -84,10 +84,6 @@ export async function recursiveRebuild(allProjects, params, opts) {
|
|
|
84
84
|
...localConfig,
|
|
85
85
|
dir: rootDir,
|
|
86
86
|
pending: opts.pending === true,
|
|
87
|
-
rawConfig: {
|
|
88
|
-
...rebuildOpts.rawConfig,
|
|
89
|
-
...localConfig,
|
|
90
|
-
},
|
|
91
87
|
});
|
|
92
88
|
result[rootDir].status = 'passed';
|
|
93
89
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { rebuild } from './build/index.js';
|
|
2
|
-
export type { RebuildCommandOpts } from './build/rebuild.js';
|
|
1
|
+
export { rebuild, type RebuildCommandOpts } from './build/index.js';
|
|
3
2
|
export type { ApproveBuildsCommandOpts } from './policy/approveBuilds.js';
|
|
4
3
|
export { approveBuilds, ignoredBuilds } from './policy/index.js';
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Config } from '@pnpm/config.reader';
|
|
3
|
-
|
|
1
|
+
import type { CommandHandlerMap } from '@pnpm/cli.command';
|
|
2
|
+
import type { Config, ConfigContext } from '@pnpm/config.reader';
|
|
3
|
+
import { type RebuildCommandOpts } from '../build/index.js';
|
|
4
|
+
export type ApproveBuildsCommandOpts = Pick<Config, 'modulesDir' | 'dir' | 'allowBuilds' | 'enableGlobalVirtualStore'> & Pick<ConfigContext, 'rootProjectManifest' | 'rootProjectManifestDir'> & {
|
|
4
5
|
all?: boolean;
|
|
5
6
|
global?: boolean;
|
|
6
7
|
};
|
|
7
8
|
export declare const commandNames: string[];
|
|
9
|
+
export declare const recursiveByDefault = true;
|
|
8
10
|
export declare function help(): string;
|
|
9
11
|
export declare function cliOptionsTypes(): Record<string, unknown>;
|
|
10
12
|
export declare function rcOptionsTypes(): Record<string, unknown>;
|
|
11
|
-
export declare function handler(opts: ApproveBuildsCommandOpts & RebuildCommandOpts): Promise<void>;
|
|
13
|
+
export declare function handler(opts: ApproveBuildsCommandOpts & RebuildCommandOpts, params?: string[], commands?: CommandHandlerMap): Promise<void>;
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import { rebuild } from '@pnpm/building.commands';
|
|
2
1
|
import { writeSettings } from '@pnpm/config.writer';
|
|
2
|
+
import { parse } from '@pnpm/deps.path';
|
|
3
3
|
import { PnpmError } from '@pnpm/error';
|
|
4
|
+
import { install } from '@pnpm/installing.commands';
|
|
4
5
|
import { writeModulesManifest } from '@pnpm/installing.modules-yaml';
|
|
5
6
|
import { globalInfo } from '@pnpm/logger';
|
|
6
7
|
import { lexCompare } from '@pnpm/util.lex-comparator';
|
|
7
8
|
import chalk from 'chalk';
|
|
8
9
|
import enquirer from 'enquirer';
|
|
9
10
|
import { renderHelp } from 'render-help';
|
|
11
|
+
import { rebuild } from '../build/index.js';
|
|
10
12
|
import { getAutomaticallyIgnoredBuilds } from './getAutomaticallyIgnoredBuilds.js';
|
|
11
13
|
export const commandNames = ['approve-builds'];
|
|
14
|
+
export const recursiveByDefault = true;
|
|
12
15
|
export function help() {
|
|
13
16
|
return renderHelp({
|
|
14
17
|
description: 'Approve dependencies for running scripts during installation',
|
|
15
|
-
usages: [
|
|
18
|
+
usages: [
|
|
19
|
+
'pnpm approve-builds',
|
|
20
|
+
'pnpm approve-builds [<pkg> ...] [!<pkg> ...]',
|
|
21
|
+
],
|
|
16
22
|
descriptionLists: [
|
|
17
23
|
{
|
|
18
24
|
title: 'Options',
|
|
@@ -35,20 +41,48 @@ export function cliOptionsTypes() {
|
|
|
35
41
|
export function rcOptionsTypes() {
|
|
36
42
|
return {};
|
|
37
43
|
}
|
|
38
|
-
export async function handler(opts) {
|
|
44
|
+
export async function handler(opts, params = [], commands) {
|
|
39
45
|
if (opts.global) {
|
|
40
46
|
throw new PnpmError('APPROVE_BUILDS_NOT_SUPPORTED_WITH_GLOBAL', '"approve-builds" is not supported with global packages', {
|
|
41
47
|
hint: 'Use --allow-build when installing globally, e.g. "pnpm add -g --allow-build=<pkg> <pkg>". ' +
|
|
42
48
|
'pnpm will also prompt to allow builds interactively during global install.',
|
|
43
49
|
});
|
|
44
50
|
}
|
|
51
|
+
if (opts.all && params.length) {
|
|
52
|
+
throw new PnpmError('APPROVE_BUILDS_ALL_WITH_ARGS', 'Cannot use --all with positional arguments');
|
|
53
|
+
}
|
|
45
54
|
const { automaticallyIgnoredBuilds, modulesDir, modulesManifest, } = await getAutomaticallyIgnoredBuilds(opts);
|
|
46
55
|
if (!automaticallyIgnoredBuilds?.length) {
|
|
47
56
|
globalInfo('There are no packages awaiting approval');
|
|
48
57
|
return;
|
|
49
58
|
}
|
|
59
|
+
const denied = [];
|
|
60
|
+
const approved = [];
|
|
61
|
+
const unknown = [];
|
|
62
|
+
for (const p of params) {
|
|
63
|
+
const name = p.startsWith('!') ? p.slice(1) : p;
|
|
64
|
+
if (!automaticallyIgnoredBuilds.includes(name)) {
|
|
65
|
+
unknown.push(name);
|
|
66
|
+
}
|
|
67
|
+
else if (p.startsWith('!')) {
|
|
68
|
+
denied.push(name);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
approved.push(name);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (unknown.length) {
|
|
75
|
+
throw new PnpmError('APPROVE_BUILDS_UNKNOWN_PACKAGES', `The following packages are not awaiting approval: ${unknown.join(', ')}`);
|
|
76
|
+
}
|
|
77
|
+
const contradictions = approved.filter((p) => denied.includes(p));
|
|
78
|
+
if (contradictions.length) {
|
|
79
|
+
throw new PnpmError('APPROVE_BUILDS_CONTRADICTING_ARGS', `The following packages are both approved and denied: ${contradictions.join(', ')}`);
|
|
80
|
+
}
|
|
50
81
|
let buildPackages = [];
|
|
51
|
-
if (
|
|
82
|
+
if (params.length) {
|
|
83
|
+
buildPackages = sortUniqueStrings([...approved]);
|
|
84
|
+
}
|
|
85
|
+
else if (opts.all) {
|
|
52
86
|
buildPackages = sortUniqueStrings([...automaticallyIgnoredBuilds]);
|
|
53
87
|
}
|
|
54
88
|
else {
|
|
@@ -89,19 +123,25 @@ export async function handler(opts) {
|
|
|
89
123
|
}); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
90
124
|
buildPackages = result.map(({ value }) => value);
|
|
91
125
|
}
|
|
92
|
-
const ignoredPackages = automaticallyIgnoredBuilds.filter((automaticallyIgnoredBuild) => !buildPackages.includes(automaticallyIgnoredBuild));
|
|
93
126
|
const allowBuilds = { ...opts.allowBuilds };
|
|
94
|
-
if (
|
|
95
|
-
for (const pkg of
|
|
127
|
+
if (params.length) {
|
|
128
|
+
for (const pkg of approved) {
|
|
129
|
+
allowBuilds[pkg] = true;
|
|
130
|
+
}
|
|
131
|
+
for (const pkg of denied) {
|
|
96
132
|
allowBuilds[pkg] = false;
|
|
97
133
|
}
|
|
98
134
|
}
|
|
99
|
-
|
|
135
|
+
else {
|
|
136
|
+
const ignoredPackages = automaticallyIgnoredBuilds.filter((automaticallyIgnoredBuild) => !buildPackages.includes(automaticallyIgnoredBuild));
|
|
137
|
+
for (const pkg of ignoredPackages) {
|
|
138
|
+
allowBuilds[pkg] = false;
|
|
139
|
+
}
|
|
100
140
|
for (const pkg of buildPackages) {
|
|
101
141
|
allowBuilds[pkg] = true;
|
|
102
142
|
}
|
|
103
143
|
}
|
|
104
|
-
if (!opts.all) {
|
|
144
|
+
if (!opts.all && !params.length) {
|
|
105
145
|
if (buildPackages.length) {
|
|
106
146
|
const confirmed = await enquirer.prompt({
|
|
107
147
|
type: 'confirm',
|
|
@@ -123,16 +163,39 @@ Do you approve?`,
|
|
|
123
163
|
workspaceDir: opts.workspaceDir ?? opts.rootProjectManifestDir,
|
|
124
164
|
updatedSettings: { allowBuilds },
|
|
125
165
|
});
|
|
166
|
+
if (modulesManifest?.ignoredBuilds) {
|
|
167
|
+
if (params.length) {
|
|
168
|
+
const decided = new Set([...approved, ...denied]);
|
|
169
|
+
for (const depPath of Array.from(modulesManifest.ignoredBuilds)) {
|
|
170
|
+
const name = parse(depPath).name ?? depPath;
|
|
171
|
+
if (decided.has(name)) {
|
|
172
|
+
modulesManifest.ignoredBuilds.delete(depPath);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (!modulesManifest.ignoredBuilds.size) {
|
|
176
|
+
delete modulesManifest.ignoredBuilds;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
delete modulesManifest.ignoredBuilds;
|
|
181
|
+
}
|
|
182
|
+
await writeModulesManifest(modulesDir, modulesManifest);
|
|
183
|
+
}
|
|
126
184
|
if (buildPackages.length) {
|
|
185
|
+
if (opts.enableGlobalVirtualStore) {
|
|
186
|
+
await install.handler({
|
|
187
|
+
...opts,
|
|
188
|
+
allowBuilds,
|
|
189
|
+
frozenLockfile: true,
|
|
190
|
+
optimisticRepeatInstall: false,
|
|
191
|
+
}, [], commands); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
127
194
|
return rebuild.handler({
|
|
128
195
|
...opts,
|
|
129
196
|
allowBuilds,
|
|
130
197
|
}, buildPackages);
|
|
131
198
|
}
|
|
132
|
-
else if (modulesManifest) {
|
|
133
|
-
delete modulesManifest.ignoredBuilds;
|
|
134
|
-
await writeModulesManifest(modulesDir, modulesManifest);
|
|
135
|
-
}
|
|
136
199
|
}
|
|
137
200
|
function sortUniqueStrings(array) {
|
|
138
201
|
return Array.from(new Set(array)).sort(lexCompare);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/building.commands",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1100.0.1",
|
|
4
4
|
"description": "Commands for rebuilding and managing dependency builds",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -31,42 +31,45 @@
|
|
|
31
31
|
"p-limit": "^7.1.0",
|
|
32
32
|
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
33
33
|
"render-help": "^2.0.0",
|
|
34
|
-
"@pnpm/building.after-install": "
|
|
35
|
-
"@pnpm/cli.
|
|
36
|
-
"@pnpm/
|
|
37
|
-
"@pnpm/
|
|
38
|
-
"@pnpm/
|
|
39
|
-
"@pnpm/
|
|
40
|
-
"@pnpm/
|
|
41
|
-
"@pnpm/
|
|
42
|
-
"@pnpm/
|
|
43
|
-
"@pnpm/store.connection-manager": "
|
|
44
|
-
"@pnpm/
|
|
45
|
-
"@pnpm/workspace.projects-sorter": "
|
|
34
|
+
"@pnpm/building.after-install": "1100.0.1",
|
|
35
|
+
"@pnpm/cli.command": "1100.0.0",
|
|
36
|
+
"@pnpm/cli.common-cli-options-help": "1100.0.0",
|
|
37
|
+
"@pnpm/cli.utils": "1100.0.1",
|
|
38
|
+
"@pnpm/config.reader": "1100.0.1",
|
|
39
|
+
"@pnpm/config.writer": "1100.0.1",
|
|
40
|
+
"@pnpm/installing.commands": "1100.0.1",
|
|
41
|
+
"@pnpm/error": "1100.0.0",
|
|
42
|
+
"@pnpm/installing.modules-yaml": "1100.0.1",
|
|
43
|
+
"@pnpm/store.connection-manager": "1100.0.1",
|
|
44
|
+
"@pnpm/prepare-temp-dir": "1100.0.0",
|
|
45
|
+
"@pnpm/workspace.projects-sorter": "1100.0.1",
|
|
46
|
+
"@pnpm/deps.path": "1100.0.1",
|
|
47
|
+
"@pnpm/types": "1101.0.0"
|
|
46
48
|
},
|
|
47
49
|
"peerDependencies": {
|
|
48
50
|
"@pnpm/logger": ">=1001.0.0 <1002.0.0"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
|
-
"@jest/globals": "30.0
|
|
52
|
-
"@pnpm/registry-mock": "
|
|
53
|
-
"@types/ramda": "0.
|
|
53
|
+
"@jest/globals": "30.3.0",
|
|
54
|
+
"@pnpm/registry-mock": "6.0.0",
|
|
55
|
+
"@types/ramda": "0.31.1",
|
|
54
56
|
"execa": "npm:safe-execa@0.3.0",
|
|
55
57
|
"load-json-file": "^7.0.1",
|
|
56
58
|
"read-yaml-file": "^3.0.0",
|
|
57
59
|
"write-package": "7.2.0",
|
|
58
60
|
"write-yaml-file": "^6.0.0",
|
|
59
|
-
"@pnpm/
|
|
60
|
-
"@pnpm/constants": "
|
|
61
|
-
"@pnpm/
|
|
62
|
-
"@pnpm/
|
|
63
|
-
"@pnpm/
|
|
64
|
-
"@pnpm/
|
|
65
|
-
"@pnpm/
|
|
66
|
-
"@pnpm/
|
|
67
|
-
"@pnpm/
|
|
68
|
-
"@pnpm/
|
|
69
|
-
"@pnpm/workspace.projects-filter": "
|
|
61
|
+
"@pnpm/building.commands": "1100.0.1",
|
|
62
|
+
"@pnpm/constants": "1100.0.0",
|
|
63
|
+
"@pnpm/crypto.object-hasher": "1100.0.0",
|
|
64
|
+
"@pnpm/assert-project": "1100.0.1",
|
|
65
|
+
"@pnpm/logger": "1100.0.0",
|
|
66
|
+
"@pnpm/prepare": "1100.0.1",
|
|
67
|
+
"@pnpm/store.index": "1100.0.0",
|
|
68
|
+
"@pnpm/test-fixtures": "1100.0.0",
|
|
69
|
+
"@pnpm/store.cafs": "1100.0.1",
|
|
70
|
+
"@pnpm/testing.command-defaults": "1100.0.0",
|
|
71
|
+
"@pnpm/workspace.projects-filter": "1100.0.1",
|
|
72
|
+
"@pnpm/test-ipc-server": "1100.0.0"
|
|
70
73
|
},
|
|
71
74
|
"engines": {
|
|
72
75
|
"node": ">=22.13"
|
|
@@ -76,8 +79,8 @@
|
|
|
76
79
|
},
|
|
77
80
|
"scripts": {
|
|
78
81
|
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
+
"test": "pn compile && pn --filter=pnpm compile && pn .test",
|
|
83
|
+
"compile": "tsgo --build && pn lint --fix",
|
|
84
|
+
".test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest"
|
|
82
85
|
}
|
|
83
86
|
}
|