@pnpm/global.commands 1100.0.1 → 1100.0.3

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/globalAdd.js CHANGED
@@ -8,6 +8,7 @@ import { isSubdir } from 'is-subdir';
8
8
  import { symlinkDir } from 'symlink-dir';
9
9
  import { checkGlobalBinConflicts } from './checkGlobalBinConflicts.js';
10
10
  import { installGlobalPackages } from './installGlobalPackages.js';
11
+ import { promptApproveGlobalBuilds } from './promptApproveGlobalBuilds.js';
11
12
  import { readInstalledPackages } from './readInstalledPackages.js';
12
13
  export async function handleGlobalAdd(opts, params, commands) {
13
14
  // Resolve relative path selectors to absolute paths before the working
@@ -56,22 +57,13 @@ export async function handleGlobalAdd(opts, params, commands) {
56
57
  allowBuilds: builds,
57
58
  });
58
59
  const ignoredBuilds = await installGlobalPackages(makeInstallOpts(installDir, allowBuilds), params);
59
- // If any packages had their builds skipped, prompt the user to approve them
60
- // (reuses the same interactive flow as `pnpm approve-builds`)
61
- if (ignoredBuilds?.size && process.stdin.isTTY) {
62
- await commands['approve-builds']({
63
- ...opts,
64
- modulesDir: path.join(installDir, 'node_modules'),
65
- dir: installDir,
66
- lockfileDir: installDir,
67
- rootProjectManifest: undefined,
68
- rootProjectManifestDir: installDir,
69
- workspaceDir: opts.globalPkgDir,
70
- global: false,
71
- pending: false,
72
- allowBuilds,
73
- }, [], commands);
74
- }
60
+ await promptApproveGlobalBuilds({
61
+ globalPkgDir: globalDir,
62
+ installDir,
63
+ ignoredBuilds,
64
+ allowBuilds,
65
+ inheritedOpts: opts,
66
+ }, commands);
75
67
  // Read resolved aliases from the installed package.json
76
68
  const pkgJson = readPackageJsonFromDirRawSync(installDir);
77
69
  const aliases = Object.keys(pkgJson.dependencies ?? {});
@@ -7,6 +7,7 @@ import { isSubdir } from 'is-subdir';
7
7
  import { symlinkDir } from 'symlink-dir';
8
8
  import { checkGlobalBinConflicts } from './checkGlobalBinConflicts.js';
9
9
  import { installGlobalPackages } from './installGlobalPackages.js';
10
+ import { promptApproveGlobalBuilds } from './promptApproveGlobalBuilds.js';
10
11
  import { readInstalledPackages } from './readInstalledPackages.js';
11
12
  export async function handleGlobalUpdate(opts, params, commands) {
12
13
  const globalDir = opts.globalPkgDir;
@@ -65,22 +66,13 @@ async function updateGlobalPackageGroup(opts, globalDir, globalBinDir, pkg, comm
65
66
  includeDirect: include,
66
67
  allowBuilds,
67
68
  }, depSpecs);
68
- // If any packages had their builds skipped, prompt the user to approve them
69
- // (reuses the same interactive flow as `pnpm approve-builds`)
70
- if (ignoredBuilds?.size && process.stdin.isTTY) {
71
- await commands['approve-builds']({
72
- ...opts,
73
- modulesDir: path.join(installDir, 'node_modules'),
74
- dir: installDir,
75
- lockfileDir: installDir,
76
- rootProjectManifest: undefined,
77
- rootProjectManifestDir: installDir,
78
- workspaceDir: opts.globalPkgDir,
79
- global: false,
80
- pending: false,
81
- allowBuilds,
82
- }, [], commands);
83
- }
69
+ await promptApproveGlobalBuilds({
70
+ globalPkgDir: globalDir,
71
+ installDir,
72
+ ignoredBuilds,
73
+ allowBuilds,
74
+ inheritedOpts: opts,
75
+ }, commands);
84
76
  // Check for bin name conflicts with other global packages
85
77
  const pkgs = await readInstalledPackages(installDir);
86
78
  let binsToSkip;
@@ -0,0 +1,24 @@
1
+ import type { CommandHandlerMap } from '@pnpm/cli.command';
2
+ import type { IgnoredBuilds } from '@pnpm/types';
3
+ export interface PromptApproveGlobalBuildsOptions {
4
+ globalPkgDir: string;
5
+ installDir: string;
6
+ ignoredBuilds: IgnoredBuilds | undefined;
7
+ allowBuilds: Record<string, string | boolean>;
8
+ /** Inherited config opts from the global add/update handler. */
9
+ inheritedOpts: object;
10
+ }
11
+ /**
12
+ * If the previous global install left builds awaiting approval, run the
13
+ * interactive `approve-builds` flow against the install directory.
14
+ *
15
+ * `settingsDir` points at the global packages directory so the resulting
16
+ * allowBuilds update lands in its pnpm-workspace.yaml. The
17
+ * workspace-context fields (`workspaceDir`, `allProjects`,
18
+ * `selectedProjectsGraph`, `workspacePackagePatterns`) are explicitly
19
+ * cleared so that the install run by approve-builds in GVS mode operates
20
+ * only on the install directory — otherwise it would treat the global
21
+ * packages dir as a workspace and discover sibling install directories as
22
+ * workspace projects.
23
+ */
24
+ export declare function promptApproveGlobalBuilds(opts: PromptApproveGlobalBuildsOptions, commands: CommandHandlerMap): Promise<void>;
@@ -0,0 +1,35 @@
1
+ import path from 'node:path';
2
+ /**
3
+ * If the previous global install left builds awaiting approval, run the
4
+ * interactive `approve-builds` flow against the install directory.
5
+ *
6
+ * `settingsDir` points at the global packages directory so the resulting
7
+ * allowBuilds update lands in its pnpm-workspace.yaml. The
8
+ * workspace-context fields (`workspaceDir`, `allProjects`,
9
+ * `selectedProjectsGraph`, `workspacePackagePatterns`) are explicitly
10
+ * cleared so that the install run by approve-builds in GVS mode operates
11
+ * only on the install directory — otherwise it would treat the global
12
+ * packages dir as a workspace and discover sibling install directories as
13
+ * workspace projects.
14
+ */
15
+ export async function promptApproveGlobalBuilds(opts, commands) {
16
+ if (!opts.ignoredBuilds?.size || !process.stdin.isTTY)
17
+ return;
18
+ await commands['approve-builds']({
19
+ ...opts.inheritedOpts,
20
+ workspaceDir: undefined,
21
+ allProjects: undefined,
22
+ selectedProjectsGraph: undefined,
23
+ workspacePackagePatterns: undefined,
24
+ modulesDir: path.join(opts.installDir, 'node_modules'),
25
+ dir: opts.installDir,
26
+ lockfileDir: opts.installDir,
27
+ rootProjectManifest: undefined,
28
+ rootProjectManifestDir: opts.installDir,
29
+ settingsDir: opts.globalPkgDir,
30
+ global: false,
31
+ pending: false,
32
+ allowBuilds: opts.allowBuilds,
33
+ }, [], commands);
34
+ }
35
+ //# sourceMappingURL=promptApproveGlobalBuilds.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/global.commands",
3
- "version": "1100.0.1",
3
+ "version": "1100.0.3",
4
4
  "description": "Global package command handlers for pnpm",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -28,22 +28,22 @@
28
28
  "@pnpm/util.lex-comparator": "^3.0.2",
29
29
  "is-subdir": "^2.0.0",
30
30
  "symlink-dir": "^10.0.1",
31
- "@pnpm/bins.resolver": "1100.0.1",
32
31
  "@pnpm/bins.remover": "1100.0.1",
33
- "@pnpm/bins.linker": "1100.0.1",
34
- "@pnpm/cli.command": "1100.0.0",
35
- "@pnpm/cli.utils": "1100.0.1",
32
+ "@pnpm/bins.resolver": "1100.0.1",
33
+ "@pnpm/error": "1100.0.0",
34
+ "@pnpm/cli.utils": "1101.0.0",
35
+ "@pnpm/bins.linker": "1100.0.2",
36
+ "@pnpm/config.reader": "1101.1.0",
37
+ "@pnpm/installing.deps-installer": "1100.0.3",
36
38
  "@pnpm/config.matcher": "1100.0.0",
37
- "@pnpm/config.reader": "1100.0.1",
39
+ "@pnpm/cli.command": "1100.0.0",
38
40
  "@pnpm/pkg-manifest.reader": "1100.0.1",
39
- "@pnpm/error": "1100.0.0",
40
41
  "@pnpm/global.packages": "1100.0.1",
41
42
  "@pnpm/types": "1101.0.0",
42
- "@pnpm/installing.deps-installer": "1100.0.1",
43
- "@pnpm/store.connection-manager": "1100.0.1"
43
+ "@pnpm/store.connection-manager": "1100.0.3"
44
44
  },
45
45
  "devDependencies": {
46
- "@pnpm/global.commands": "1100.0.1"
46
+ "@pnpm/global.commands": "1100.0.3"
47
47
  },
48
48
  "engines": {
49
49
  "node": ">=22.13"