@pnpm/building.commands 1000.0.0-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/LICENSE +22 -0
- package/lib/build/index.d.ts +3 -0
- package/lib/build/index.js +4 -0
- package/lib/build/rebuild.d.ts +16 -0
- package/lib/build/rebuild.js +90 -0
- package/lib/build/recursive.d.ts +10 -0
- package/lib/build/recursive.js +115 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +3 -0
- package/lib/policy/approveBuilds.d.ts +11 -0
- package/lib/policy/approveBuilds.js +140 -0
- package/lib/policy/getAutomaticallyIgnoredBuilds.d.ts +8 -0
- package/lib/policy/getAutomaticallyIgnoredBuilds.js +27 -0
- package/lib/policy/ignoredBuilds.d.ts +7 -0
- package/lib/policy/ignoredBuilds.js +48 -0
- package/lib/policy/index.d.ts +4 -0
- package/lib/policy/index.js +4 -0
- package/package.json +83 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
|
|
4
|
+
Copyright (c) 2016-2026 Zoltan Kochan and other contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Config } from '@pnpm/config.reader';
|
|
2
|
+
import type { LogBase } from '@pnpm/logger';
|
|
3
|
+
import { type CreateStoreControllerOptions } from '@pnpm/store.connection-manager';
|
|
4
|
+
export declare function rcOptionsTypes(): Record<string, unknown>;
|
|
5
|
+
export declare function cliOptionsTypes(): Record<string, unknown>;
|
|
6
|
+
export declare const commandNames: string[];
|
|
7
|
+
export declare function help(): string;
|
|
8
|
+
export type RebuildCommandOpts = Pick<Config, 'allProjects' | 'dir' | 'engineStrict' | 'hooks' | 'lockfileDir' | 'nodeLinker' | 'rawLocalConfig' | 'rootProjectManifest' | 'rootProjectManifestDir' | 'registries' | 'scriptShell' | 'selectedProjectsGraph' | 'sideEffectsCache' | 'sideEffectsCacheReadonly' | 'scriptsPrependNodePath' | 'shellEmulator' | 'workspaceDir'> & CreateStoreControllerOptions & {
|
|
9
|
+
recursive?: boolean;
|
|
10
|
+
reporter?: (logObj: LogBase) => void;
|
|
11
|
+
pending: boolean;
|
|
12
|
+
skipIfHasSideEffectsCache?: boolean;
|
|
13
|
+
neverBuiltDependencies?: string[];
|
|
14
|
+
allowBuilds?: Record<string, boolean | string>;
|
|
15
|
+
};
|
|
16
|
+
export declare function handler(opts: RebuildCommandOpts, params: string[]): Promise<void>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { buildProjects, buildSelectedPkgs, } from '@pnpm/building.after-install';
|
|
2
|
+
import { FILTERING, UNIVERSAL_OPTIONS } from '@pnpm/cli.common-cli-options-help';
|
|
3
|
+
import { docsUrl, readProjectManifestOnly } from '@pnpm/cli.utils';
|
|
4
|
+
import { types as allTypes } from '@pnpm/config.reader';
|
|
5
|
+
import { createStoreController, } from '@pnpm/store.connection-manager';
|
|
6
|
+
import { pick } from 'ramda';
|
|
7
|
+
import { renderHelp } from 'render-help';
|
|
8
|
+
import { recursiveRebuild } from './recursive.js';
|
|
9
|
+
export function rcOptionsTypes() {
|
|
10
|
+
return {
|
|
11
|
+
...pick([
|
|
12
|
+
'npm-path',
|
|
13
|
+
'reporter',
|
|
14
|
+
'scripts-prepend-node-path',
|
|
15
|
+
'unsafe-perm',
|
|
16
|
+
'store-dir',
|
|
17
|
+
], allTypes),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function cliOptionsTypes() {
|
|
21
|
+
return {
|
|
22
|
+
...rcOptionsTypes(),
|
|
23
|
+
pending: Boolean,
|
|
24
|
+
recursive: Boolean,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export const commandNames = ['rebuild', 'rb'];
|
|
28
|
+
export function help() {
|
|
29
|
+
return renderHelp({
|
|
30
|
+
aliases: ['rb'],
|
|
31
|
+
description: 'Rebuild a package.',
|
|
32
|
+
descriptionLists: [
|
|
33
|
+
{
|
|
34
|
+
title: 'Options',
|
|
35
|
+
list: [
|
|
36
|
+
{
|
|
37
|
+
description: 'Rebuild every package found in subdirectories \
|
|
38
|
+
or every workspace package, when executed inside a workspace. \
|
|
39
|
+
For options that may be used with `-r`, see "pnpm help recursive"',
|
|
40
|
+
name: '--recursive',
|
|
41
|
+
shortAlias: '-r',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
description: 'Rebuild packages that were not build during installation. Packages are not build when installing with the --ignore-scripts flag',
|
|
45
|
+
name: '--pending',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
description: 'The directory in which all the packages are saved on the disk',
|
|
49
|
+
name: '--store-dir <dir>',
|
|
50
|
+
},
|
|
51
|
+
...UNIVERSAL_OPTIONS,
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
FILTERING,
|
|
55
|
+
],
|
|
56
|
+
url: docsUrl('rebuild'),
|
|
57
|
+
usages: ['pnpm rebuild [<pkg> ...]'],
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export async function handler(opts, params) {
|
|
61
|
+
if (opts.recursive && (opts.allProjects != null) && (opts.selectedProjectsGraph != null) && opts.workspaceDir) {
|
|
62
|
+
await recursiveRebuild(opts.allProjects, params, { ...opts, selectedProjectsGraph: opts.selectedProjectsGraph, workspaceDir: opts.workspaceDir });
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const store = await createStoreController(opts);
|
|
66
|
+
const rebuildOpts = Object.assign(opts, {
|
|
67
|
+
sideEffectsCacheRead: opts.sideEffectsCache ?? opts.sideEffectsCacheReadonly,
|
|
68
|
+
sideEffectsCacheWrite: opts.sideEffectsCache,
|
|
69
|
+
storeController: store.ctrl,
|
|
70
|
+
storeDir: store.dir,
|
|
71
|
+
});
|
|
72
|
+
if (params.length === 0) {
|
|
73
|
+
await buildProjects([
|
|
74
|
+
{
|
|
75
|
+
buildIndex: 0,
|
|
76
|
+
manifest: await readProjectManifestOnly(rebuildOpts.dir, opts),
|
|
77
|
+
rootDir: rebuildOpts.dir,
|
|
78
|
+
},
|
|
79
|
+
], rebuildOpts);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
await buildSelectedPkgs([
|
|
83
|
+
{
|
|
84
|
+
buildIndex: 0,
|
|
85
|
+
manifest: await readProjectManifestOnly(rebuildOpts.dir, opts),
|
|
86
|
+
rootDir: rebuildOpts.dir,
|
|
87
|
+
},
|
|
88
|
+
], params, rebuildOpts);
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=rebuild.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Config } from '@pnpm/config.reader';
|
|
2
|
+
import { type CreateStoreControllerOptions } from '@pnpm/store.connection-manager';
|
|
3
|
+
import type { Project } from '@pnpm/types';
|
|
4
|
+
type RecursiveRebuildOpts = CreateStoreControllerOptions & Pick<Config, 'hoistPattern' | 'hooks' | 'ignorePnpmfile' | 'ignoreScripts' | 'lockfileDir' | 'lockfileOnly' | 'nodeLinker' | 'packageConfigs' | 'rawLocalConfig' | 'registries' | 'rootProjectManifest' | 'rootProjectManifestDir' | 'sharedWorkspaceLockfile'> & {
|
|
5
|
+
pending?: boolean;
|
|
6
|
+
} & Partial<Pick<Config, 'bail' | 'sort' | 'workspaceConcurrency'>>;
|
|
7
|
+
export declare function recursiveRebuild(allProjects: Project[], params: string[], opts: RecursiveRebuildOpts & {
|
|
8
|
+
ignoredPackages?: Set<string>;
|
|
9
|
+
} & Required<Pick<Config, 'selectedProjectsGraph' | 'workspaceDir'>>): Promise<void>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import util from 'node:util';
|
|
3
|
+
import { buildProjects as rebuildAll, buildSelectedPkgs } from '@pnpm/building.after-install';
|
|
4
|
+
import { throwOnCommandFail, } from '@pnpm/cli.utils';
|
|
5
|
+
import { createProjectConfigRecord, getWorkspaceConcurrency, } from '@pnpm/config.reader';
|
|
6
|
+
import { logger } from '@pnpm/logger';
|
|
7
|
+
import { createStoreController } from '@pnpm/store.connection-manager';
|
|
8
|
+
import { sortProjects } from '@pnpm/workspace.projects-sorter';
|
|
9
|
+
import pLimit from 'p-limit';
|
|
10
|
+
export async function recursiveRebuild(allProjects, params, opts) {
|
|
11
|
+
if (allProjects.length === 0) {
|
|
12
|
+
// It might make sense to throw an exception in this case
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const pkgs = Object.values(opts.selectedProjectsGraph).map((wsPkg) => wsPkg.package);
|
|
16
|
+
if (pkgs.length === 0) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const manifestsByPath = {};
|
|
20
|
+
for (const { rootDir, manifest, writeProjectManifest } of pkgs) {
|
|
21
|
+
manifestsByPath[rootDir] = { manifest, writeProjectManifest };
|
|
22
|
+
}
|
|
23
|
+
const throwOnFail = throwOnCommandFail.bind(null, 'pnpm recursive rebuild');
|
|
24
|
+
const chunks = opts.sort !== false
|
|
25
|
+
? sortProjects(opts.selectedProjectsGraph)
|
|
26
|
+
: [Object.keys(opts.selectedProjectsGraph).sort()];
|
|
27
|
+
const store = await createStoreController(opts);
|
|
28
|
+
const rebuildOpts = Object.assign(opts, {
|
|
29
|
+
ownLifecycleHooksStdio: 'pipe',
|
|
30
|
+
pruneLockfileImporters: ((opts.ignoredPackages == null) || opts.ignoredPackages.size === 0) &&
|
|
31
|
+
pkgs.length === allProjects.length,
|
|
32
|
+
storeController: store.ctrl,
|
|
33
|
+
storeDir: store.dir,
|
|
34
|
+
});
|
|
35
|
+
const result = {};
|
|
36
|
+
const projectConfigRecord = createProjectConfigRecord(opts) ?? {};
|
|
37
|
+
async function getImporters() {
|
|
38
|
+
const importers = [];
|
|
39
|
+
await Promise.all(chunks.map(async (prefixes, buildIndex) => {
|
|
40
|
+
if (opts.ignoredPackages != null) {
|
|
41
|
+
prefixes = prefixes.filter((prefix) => !opts.ignoredPackages.has(prefix));
|
|
42
|
+
}
|
|
43
|
+
return Promise.all(prefixes.map(async (prefix) => {
|
|
44
|
+
importers.push({
|
|
45
|
+
buildIndex,
|
|
46
|
+
manifest: manifestsByPath[prefix].manifest,
|
|
47
|
+
rootDir: prefix,
|
|
48
|
+
});
|
|
49
|
+
}));
|
|
50
|
+
}));
|
|
51
|
+
return importers;
|
|
52
|
+
}
|
|
53
|
+
const rebuild = (params.length === 0
|
|
54
|
+
? rebuildAll
|
|
55
|
+
: (importers, opts) => buildSelectedPkgs(importers, params, opts) // eslint-disable-line
|
|
56
|
+
);
|
|
57
|
+
if (opts.lockfileDir) {
|
|
58
|
+
const importers = await getImporters();
|
|
59
|
+
await rebuild(importers, {
|
|
60
|
+
...rebuildOpts,
|
|
61
|
+
pending: opts.pending === true,
|
|
62
|
+
});
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const limitRebuild = pLimit(getWorkspaceConcurrency(opts.workspaceConcurrency));
|
|
66
|
+
for (const chunk of chunks) {
|
|
67
|
+
// eslint-disable-next-line no-await-in-loop
|
|
68
|
+
await Promise.all(chunk.map(async (rootDir) => limitRebuild(async () => {
|
|
69
|
+
try {
|
|
70
|
+
if (opts.ignoredPackages?.has(rootDir)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
result[rootDir] = { status: 'running' };
|
|
74
|
+
const { manifest } = opts.selectedProjectsGraph[rootDir].package;
|
|
75
|
+
const localConfig = manifest.name ? projectConfigRecord[manifest.name] : undefined;
|
|
76
|
+
await rebuild([
|
|
77
|
+
{
|
|
78
|
+
buildIndex: 0,
|
|
79
|
+
manifest: manifestsByPath[rootDir].manifest,
|
|
80
|
+
rootDir,
|
|
81
|
+
},
|
|
82
|
+
], {
|
|
83
|
+
...rebuildOpts,
|
|
84
|
+
...localConfig,
|
|
85
|
+
dir: rootDir,
|
|
86
|
+
pending: opts.pending === true,
|
|
87
|
+
rawConfig: {
|
|
88
|
+
...rebuildOpts.rawConfig,
|
|
89
|
+
...localConfig,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
result[rootDir].status = 'passed';
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
assert(util.types.isNativeError(err));
|
|
96
|
+
const errWithPrefix = Object.assign(err, {
|
|
97
|
+
prefix: rootDir,
|
|
98
|
+
});
|
|
99
|
+
logger.info(errWithPrefix);
|
|
100
|
+
if (!opts.bail) {
|
|
101
|
+
result[rootDir] = {
|
|
102
|
+
status: 'failure',
|
|
103
|
+
error: errWithPrefix,
|
|
104
|
+
message: err.message,
|
|
105
|
+
prefix: rootDir,
|
|
106
|
+
};
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
throw err;
|
|
110
|
+
}
|
|
111
|
+
})));
|
|
112
|
+
}
|
|
113
|
+
throwOnFail(result);
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=recursive.js.map
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type RebuildCommandOpts } from '@pnpm/building.commands';
|
|
2
|
+
import type { Config } from '@pnpm/config.reader';
|
|
3
|
+
export type ApproveBuildsCommandOpts = Pick<Config, 'modulesDir' | 'dir' | 'rootProjectManifest' | 'rootProjectManifestDir' | 'allowBuilds'> & {
|
|
4
|
+
all?: boolean;
|
|
5
|
+
global?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const commandNames: string[];
|
|
8
|
+
export declare function help(): string;
|
|
9
|
+
export declare function cliOptionsTypes(): Record<string, unknown>;
|
|
10
|
+
export declare function rcOptionsTypes(): Record<string, unknown>;
|
|
11
|
+
export declare function handler(opts: ApproveBuildsCommandOpts & RebuildCommandOpts): Promise<void>;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { rebuild } from '@pnpm/building.commands';
|
|
2
|
+
import { writeSettings } from '@pnpm/config.writer';
|
|
3
|
+
import { PnpmError } from '@pnpm/error';
|
|
4
|
+
import { writeModulesManifest } from '@pnpm/installing.modules-yaml';
|
|
5
|
+
import { globalInfo } from '@pnpm/logger';
|
|
6
|
+
import { lexCompare } from '@pnpm/util.lex-comparator';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import enquirer from 'enquirer';
|
|
9
|
+
import { renderHelp } from 'render-help';
|
|
10
|
+
import { getAutomaticallyIgnoredBuilds } from './getAutomaticallyIgnoredBuilds.js';
|
|
11
|
+
export const commandNames = ['approve-builds'];
|
|
12
|
+
export function help() {
|
|
13
|
+
return renderHelp({
|
|
14
|
+
description: 'Approve dependencies for running scripts during installation',
|
|
15
|
+
usages: [],
|
|
16
|
+
descriptionLists: [
|
|
17
|
+
{
|
|
18
|
+
title: 'Options',
|
|
19
|
+
list: [
|
|
20
|
+
{
|
|
21
|
+
description: 'Approve all pending dependencies without interactive prompts',
|
|
22
|
+
name: '--all',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export function cliOptionsTypes() {
|
|
30
|
+
return {
|
|
31
|
+
all: Boolean,
|
|
32
|
+
global: Boolean,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function rcOptionsTypes() {
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
export async function handler(opts) {
|
|
39
|
+
if (opts.global) {
|
|
40
|
+
throw new PnpmError('APPROVE_BUILDS_NOT_SUPPORTED_WITH_GLOBAL', '"approve-builds" is not supported with global packages', {
|
|
41
|
+
hint: 'Use --allow-build when installing globally, e.g. "pnpm add -g --allow-build=<pkg> <pkg>". ' +
|
|
42
|
+
'pnpm will also prompt to allow builds interactively during global install.',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const { automaticallyIgnoredBuilds, modulesDir, modulesManifest, } = await getAutomaticallyIgnoredBuilds(opts);
|
|
46
|
+
if (!automaticallyIgnoredBuilds?.length) {
|
|
47
|
+
globalInfo('There are no packages awaiting approval');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
let buildPackages = [];
|
|
51
|
+
if (opts.all) {
|
|
52
|
+
buildPackages = sortUniqueStrings([...automaticallyIgnoredBuilds]);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const { result } = await enquirer.prompt({
|
|
56
|
+
choices: sortUniqueStrings([...automaticallyIgnoredBuilds]),
|
|
57
|
+
indicator(state, choice) {
|
|
58
|
+
return ` ${choice.enabled ? '●' : '○'}`;
|
|
59
|
+
},
|
|
60
|
+
message: 'Choose which packages to build ' +
|
|
61
|
+
`(Press ${chalk.cyan('<space>')} to select, ` +
|
|
62
|
+
`${chalk.cyan('<a>')} to toggle all, ` +
|
|
63
|
+
`${chalk.cyan('<i>')} to invert selection)`,
|
|
64
|
+
name: 'result',
|
|
65
|
+
pointer: '❯',
|
|
66
|
+
result() {
|
|
67
|
+
return this.selected;
|
|
68
|
+
},
|
|
69
|
+
styles: {
|
|
70
|
+
dark: chalk.reset,
|
|
71
|
+
em: chalk.bgBlack.whiteBright,
|
|
72
|
+
success: chalk.reset,
|
|
73
|
+
},
|
|
74
|
+
type: 'multiselect',
|
|
75
|
+
// For Vim users (related: https://github.com/enquirer/enquirer/pull/163)
|
|
76
|
+
j() {
|
|
77
|
+
return this.down();
|
|
78
|
+
},
|
|
79
|
+
k() {
|
|
80
|
+
return this.up();
|
|
81
|
+
},
|
|
82
|
+
cancel() {
|
|
83
|
+
// By default, canceling the prompt via Ctrl+c throws an empty string.
|
|
84
|
+
// The custom cancel function prevents that behavior.
|
|
85
|
+
// Otherwise, pnpm CLI would print an error and confuse users.
|
|
86
|
+
// See related issue: https://github.com/enquirer/enquirer/issues/225
|
|
87
|
+
process.exit(0);
|
|
88
|
+
},
|
|
89
|
+
}); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
90
|
+
buildPackages = result.map(({ value }) => value);
|
|
91
|
+
}
|
|
92
|
+
const ignoredPackages = automaticallyIgnoredBuilds.filter((automaticallyIgnoredBuild) => !buildPackages.includes(automaticallyIgnoredBuild));
|
|
93
|
+
const allowBuilds = { ...opts.allowBuilds };
|
|
94
|
+
if (ignoredPackages.length) {
|
|
95
|
+
for (const pkg of ignoredPackages) {
|
|
96
|
+
allowBuilds[pkg] = false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (buildPackages.length) {
|
|
100
|
+
for (const pkg of buildPackages) {
|
|
101
|
+
allowBuilds[pkg] = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!opts.all) {
|
|
105
|
+
if (buildPackages.length) {
|
|
106
|
+
const confirmed = await enquirer.prompt({
|
|
107
|
+
type: 'confirm',
|
|
108
|
+
name: 'build',
|
|
109
|
+
message: `The next packages will now be built: ${buildPackages.join(', ')}.
|
|
110
|
+
Do you approve?`,
|
|
111
|
+
initial: false,
|
|
112
|
+
});
|
|
113
|
+
if (!confirmed.build) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
globalInfo('All packages were added to allowBuilds with value false.');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
await writeSettings({
|
|
122
|
+
...opts,
|
|
123
|
+
workspaceDir: opts.workspaceDir ?? opts.rootProjectManifestDir,
|
|
124
|
+
updatedSettings: { allowBuilds },
|
|
125
|
+
});
|
|
126
|
+
if (buildPackages.length) {
|
|
127
|
+
return rebuild.handler({
|
|
128
|
+
...opts,
|
|
129
|
+
allowBuilds,
|
|
130
|
+
}, buildPackages);
|
|
131
|
+
}
|
|
132
|
+
else if (modulesManifest) {
|
|
133
|
+
delete modulesManifest.ignoredBuilds;
|
|
134
|
+
await writeModulesManifest(modulesDir, modulesManifest);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function sortUniqueStrings(array) {
|
|
138
|
+
return Array.from(new Set(array)).sort(lexCompare);
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=approveBuilds.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Modules } from '@pnpm/installing.modules-yaml';
|
|
2
|
+
import type { IgnoredBuildsCommandOpts } from './ignoredBuilds.js';
|
|
3
|
+
export interface GetAutomaticallyIgnoredBuildsResult {
|
|
4
|
+
automaticallyIgnoredBuilds: string[] | null;
|
|
5
|
+
modulesDir: string;
|
|
6
|
+
modulesManifest: Modules | null;
|
|
7
|
+
}
|
|
8
|
+
export declare function getAutomaticallyIgnoredBuilds(opts: IgnoredBuildsCommandOpts): Promise<GetAutomaticallyIgnoredBuildsResult>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { parse } from '@pnpm/deps.path';
|
|
3
|
+
import { readModulesManifest } from '@pnpm/installing.modules-yaml';
|
|
4
|
+
export async function getAutomaticallyIgnoredBuilds(opts) {
|
|
5
|
+
const modulesDir = getModulesDir(opts);
|
|
6
|
+
const modulesManifest = await readModulesManifest(modulesDir);
|
|
7
|
+
let automaticallyIgnoredBuilds;
|
|
8
|
+
if (modulesManifest?.ignoredBuilds) {
|
|
9
|
+
const ignoredPkgNames = new Set();
|
|
10
|
+
for (const depPath of modulesManifest.ignoredBuilds) {
|
|
11
|
+
ignoredPkgNames.add(parse(depPath).name ?? depPath);
|
|
12
|
+
}
|
|
13
|
+
automaticallyIgnoredBuilds = Array.from(ignoredPkgNames);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
automaticallyIgnoredBuilds = null;
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
automaticallyIgnoredBuilds,
|
|
20
|
+
modulesDir,
|
|
21
|
+
modulesManifest,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function getModulesDir(opts) {
|
|
25
|
+
return opts.modulesDir ?? path.join(opts.lockfileDir ?? opts.dir, 'node_modules');
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=getAutomaticallyIgnoredBuilds.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Config } from '@pnpm/config.reader';
|
|
2
|
+
export type IgnoredBuildsCommandOpts = Pick<Config, 'modulesDir' | 'dir' | 'allowBuilds' | 'lockfileDir'>;
|
|
3
|
+
export declare const commandNames: string[];
|
|
4
|
+
export declare function help(): string;
|
|
5
|
+
export declare function cliOptionsTypes(): Record<string, unknown>;
|
|
6
|
+
export declare function rcOptionsTypes(): Record<string, unknown>;
|
|
7
|
+
export declare function handler(opts: IgnoredBuildsCommandOpts): Promise<string>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { renderHelp } from 'render-help';
|
|
2
|
+
import { getAutomaticallyIgnoredBuilds } from './getAutomaticallyIgnoredBuilds.js';
|
|
3
|
+
export const commandNames = ['ignored-builds'];
|
|
4
|
+
export function help() {
|
|
5
|
+
return renderHelp({
|
|
6
|
+
description: 'Print the list of packages with blocked build scripts',
|
|
7
|
+
usages: [],
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export function cliOptionsTypes() {
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
export function rcOptionsTypes() {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
export async function handler(opts) {
|
|
17
|
+
const disallowedBuilds = opts.allowBuilds
|
|
18
|
+
? Object.entries(opts.allowBuilds)
|
|
19
|
+
.filter(([, value]) => value === false)
|
|
20
|
+
.map(([pkg]) => pkg)
|
|
21
|
+
: [];
|
|
22
|
+
let { automaticallyIgnoredBuilds } = await getAutomaticallyIgnoredBuilds(opts);
|
|
23
|
+
if (automaticallyIgnoredBuilds) {
|
|
24
|
+
automaticallyIgnoredBuilds = automaticallyIgnoredBuilds
|
|
25
|
+
.filter((automaticallyIgnoredBuild) => !disallowedBuilds.includes(automaticallyIgnoredBuild));
|
|
26
|
+
}
|
|
27
|
+
let output = 'Automatically ignored builds during installation:\n';
|
|
28
|
+
if (automaticallyIgnoredBuilds == null) {
|
|
29
|
+
output += ' Cannot identify as no node_modules found';
|
|
30
|
+
}
|
|
31
|
+
else if (automaticallyIgnoredBuilds.length === 0) {
|
|
32
|
+
output += ' None';
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
output += ` ${automaticallyIgnoredBuilds.join('\n ')}
|
|
36
|
+
hint: To allow the execution of build scripts for a package, add its name to "allowBuilds" and set to "true", then run "pnpm rebuild".
|
|
37
|
+
hint: For example:
|
|
38
|
+
hint: allowBuilds:
|
|
39
|
+
hint: esbuild: true
|
|
40
|
+
hint: If you don't want to build a package, set it to "false" instead.`;
|
|
41
|
+
}
|
|
42
|
+
output += '\n';
|
|
43
|
+
if (disallowedBuilds.length) {
|
|
44
|
+
output += `\nExplicitly ignored package builds (via allowBuilds):\n ${disallowedBuilds.join('\n ')}\n`;
|
|
45
|
+
}
|
|
46
|
+
return output;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=ignoredBuilds.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pnpm/building.commands",
|
|
3
|
+
"version": "1000.0.0-0",
|
|
4
|
+
"description": "Commands for rebuilding and managing dependency builds",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pnpm",
|
|
7
|
+
"pnpm11",
|
|
8
|
+
"rebuild"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"funding": "https://opencollective.com/pnpm",
|
|
12
|
+
"repository": "https://github.com/pnpm/pnpm/tree/main/building/commands",
|
|
13
|
+
"homepage": "https://github.com/pnpm/pnpm/tree/main/building/commands#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/pnpm/pnpm/issues"
|
|
16
|
+
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "lib/index.js",
|
|
19
|
+
"types": "lib/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./lib/index.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"lib",
|
|
25
|
+
"!*.map"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@pnpm/util.lex-comparator": "^3.0.2",
|
|
29
|
+
"chalk": "^5.6.0",
|
|
30
|
+
"enquirer": "^2.4.1",
|
|
31
|
+
"p-limit": "^7.1.0",
|
|
32
|
+
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
33
|
+
"render-help": "^2.0.0",
|
|
34
|
+
"@pnpm/building.after-install": "1000.0.0-0",
|
|
35
|
+
"@pnpm/cli.common-cli-options-help": "1000.0.1",
|
|
36
|
+
"@pnpm/config.writer": "1000.0.14",
|
|
37
|
+
"@pnpm/config.reader": "1004.4.2",
|
|
38
|
+
"@pnpm/deps.path": "1001.1.3",
|
|
39
|
+
"@pnpm/prepare-temp-dir": "1000.0.0",
|
|
40
|
+
"@pnpm/error": "1000.0.5",
|
|
41
|
+
"@pnpm/installing.modules-yaml": "1000.3.6",
|
|
42
|
+
"@pnpm/cli.utils": "1001.2.8",
|
|
43
|
+
"@pnpm/store.connection-manager": "1002.2.4",
|
|
44
|
+
"@pnpm/types": "1000.9.0",
|
|
45
|
+
"@pnpm/workspace.projects-sorter": "1000.0.11"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@pnpm/logger": ">=1001.0.0 <1002.0.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@jest/globals": "30.0.5",
|
|
52
|
+
"@pnpm/registry-mock": "5.2.4",
|
|
53
|
+
"@types/ramda": "0.29.12",
|
|
54
|
+
"execa": "npm:safe-execa@0.3.0",
|
|
55
|
+
"load-json-file": "^7.0.1",
|
|
56
|
+
"read-yaml-file": "^3.0.0",
|
|
57
|
+
"write-package": "7.2.0",
|
|
58
|
+
"write-yaml-file": "^6.0.0",
|
|
59
|
+
"@pnpm/assert-project": "1000.0.4",
|
|
60
|
+
"@pnpm/constants": "1001.3.1",
|
|
61
|
+
"@pnpm/building.commands": "1000.0.0-0",
|
|
62
|
+
"@pnpm/logger": "1001.0.1",
|
|
63
|
+
"@pnpm/prepare": "1000.0.4",
|
|
64
|
+
"@pnpm/store.cafs": "1000.0.19",
|
|
65
|
+
"@pnpm/crypto.object-hasher": "1000.1.0",
|
|
66
|
+
"@pnpm/store.index": "1000.0.0-0",
|
|
67
|
+
"@pnpm/test-ipc-server": "1000.0.0",
|
|
68
|
+
"@pnpm/test-fixtures": "1000.0.0",
|
|
69
|
+
"@pnpm/workspace.projects-filter": "1000.0.43"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=22.13"
|
|
73
|
+
},
|
|
74
|
+
"jest": {
|
|
75
|
+
"preset": "@pnpm/jest-config/with-registry"
|
|
76
|
+
},
|
|
77
|
+
"scripts": {
|
|
78
|
+
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
79
|
+
"_test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest",
|
|
80
|
+
"test": "pnpm run compile && pnpm run _test",
|
|
81
|
+
"compile": "tsgo --build && pnpm run lint --fix"
|
|
82
|
+
}
|
|
83
|
+
}
|