@servicetitan/install 40.3.0 → 41.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/dist/cli/install.d.ts +1 -1
- package/dist/cli/install.d.ts.map +1 -1
- package/dist/cli/install.js +16 -20
- package/dist/cli/install.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/package-manager/npm-package-manager.d.ts +2 -0
- package/dist/package-manager/npm-package-manager.d.ts.map +1 -1
- package/dist/package-manager/npm-package-manager.js +36 -13
- package/dist/package-manager/npm-package-manager.js.map +1 -1
- package/dist/package-manager/package-manager.d.ts +8 -5
- package/dist/package-manager/package-manager.d.ts.map +1 -1
- package/dist/package-manager/package-manager.js +14 -5
- package/dist/package-manager/package-manager.js.map +1 -1
- package/dist/package-manager/pnpm-package-manager.d.ts +9 -1
- package/dist/package-manager/pnpm-package-manager.d.ts.map +1 -1
- package/dist/package-manager/pnpm-package-manager.js +80 -7
- package/dist/package-manager/pnpm-package-manager.js.map +1 -1
- package/dist/package-manager/utils/with-project-allow-scripts.js +1 -6
- package/dist/package-manager/utils/with-project-allow-scripts.js.map +1 -1
- package/dist/utils/audited-scripts.js +4 -4
- package/dist/utils/audited-scripts.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/npm/index.d.ts +4 -0
- package/dist/utils/npm/index.d.ts.map +1 -0
- package/dist/utils/npm/index.js +22 -0
- package/dist/utils/npm/index.js.map +1 -0
- package/dist/utils/npm/npm-config.d.ts +5 -0
- package/dist/utils/npm/npm-config.d.ts.map +1 -0
- package/dist/utils/npm/npm-config.js +112 -0
- package/dist/utils/npm/npm-config.js.map +1 -0
- package/dist/utils/npm/npm-get-local-prefix.d.ts +9 -0
- package/dist/utils/npm/npm-get-local-prefix.d.ts.map +1 -0
- package/dist/utils/npm/npm-get-local-prefix.js +65 -0
- package/dist/utils/npm/npm-get-local-prefix.js.map +1 -0
- package/dist/utils/npm/npm-who-am-i.d.ts +4 -0
- package/dist/utils/npm/npm-who-am-i.d.ts.map +1 -0
- package/dist/utils/npm/npm-who-am-i.js +37 -0
- package/dist/utils/npm/npm-who-am-i.js.map +1 -0
- package/dist/utils/os.d.ts +2 -2
- package/dist/utils/os.d.ts.map +1 -1
- package/dist/utils/os.js +22 -3
- package/dist/utils/os.js.map +1 -1
- package/dist/utils/pnpm.d.ts +5 -0
- package/dist/utils/pnpm.d.ts.map +1 -0
- package/dist/utils/pnpm.js +87 -0
- package/dist/utils/pnpm.js.map +1 -0
- package/dist/utils/setting.d.ts +6 -0
- package/dist/utils/setting.d.ts.map +1 -0
- package/dist/utils/setting.js +6 -0
- package/dist/utils/setting.js.map +1 -0
- package/package.json +2 -1
- package/src/cli/install.ts +12 -21
- package/src/index.ts +3 -0
- package/src/package-manager/npm-package-manager.ts +38 -19
- package/src/package-manager/package-manager.ts +22 -11
- package/src/package-manager/pnpm-package-manager.ts +96 -9
- package/src/package-manager/utils/with-project-allow-scripts.ts +2 -6
- package/src/utils/audited-scripts.ts +4 -4
- package/src/utils/index.ts +2 -0
- package/src/utils/npm/index.ts +3 -0
- package/src/utils/npm/npm-config.ts +83 -0
- package/src/utils/npm/npm-get-local-prefix.ts +63 -0
- package/src/utils/npm/npm-who-am-i.ts +18 -0
- package/src/utils/os.ts +12 -1
- package/src/utils/pnpm.ts +52 -0
- package/src/utils/setting.ts +5 -0
- package/dist/utils/npm.d.ts +0 -5
- package/dist/utils/npm.d.ts.map +0 -1
- package/dist/utils/npm.js +0 -77
- package/dist/utils/npm.js.map +0 -1
- package/src/utils/npm.ts +0 -44
package/src/utils/index.ts
CHANGED
|
@@ -8,6 +8,8 @@ export * from './get-workspace-root-package-json';
|
|
|
8
8
|
export * from './git';
|
|
9
9
|
export * from './npm';
|
|
10
10
|
export * from './os';
|
|
11
|
+
export * from './pnpm';
|
|
11
12
|
export * from './read-json';
|
|
13
|
+
export type { Setting } from './setting';
|
|
12
14
|
export * from './version-compare';
|
|
13
15
|
export * from './warn-untrusted-install-scripts';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import { findWorkspaceRoot } from '../find-workspace-root';
|
|
3
|
+
import { getMissingConfigPath, runCommand } from '../os';
|
|
4
|
+
import type { Setting } from '../setting';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Reads a setting as seen from the home directory, so project-level .npmrc files
|
|
8
|
+
* in the current directory do not affect the result. Returns undefined when the
|
|
9
|
+
* setting is unset.
|
|
10
|
+
*/
|
|
11
|
+
export function npmGetUserConfig(key: string) {
|
|
12
|
+
return npmGetConfig(key, [`--prefix=${getHomePrefix()}`]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getHomePrefix() {
|
|
16
|
+
const home = os.homedir();
|
|
17
|
+
|
|
18
|
+
// On Windows, npm runs through a shell that splits unquoted arguments at spaces.
|
|
19
|
+
return process.platform === 'win32' ? `"${home}"` : home;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function npmGetProjectConfig(key: string) {
|
|
23
|
+
return npmGetConfig(key, [], {
|
|
24
|
+
// `npm config` fails in a workspace package
|
|
25
|
+
cwd: getProjectDir(),
|
|
26
|
+
env: {
|
|
27
|
+
// npm skips config files that don't exist
|
|
28
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
29
|
+
npm_config_globalconfig: getMissingConfigPath(),
|
|
30
|
+
npm_config_userconfig: getMissingConfigPath(),
|
|
31
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function npmGetConfig(key: string, args: string[], options: Parameters<typeof runCommand>[2] = {}) {
|
|
37
|
+
const result = runCommand('npm', ['config', 'get', key, ...args], {
|
|
38
|
+
...options,
|
|
39
|
+
env: {
|
|
40
|
+
...options.env,
|
|
41
|
+
/*
|
|
42
|
+
* Environment variables override configuration files, for example
|
|
43
|
+
* when install itself runs via `npx --yes`.
|
|
44
|
+
*/
|
|
45
|
+
[`npm_config_${key.replaceAll('-', '_')}`]: undefined,
|
|
46
|
+
},
|
|
47
|
+
stdio: ['pipe', 'pipe', 'ignore'],
|
|
48
|
+
}).trim();
|
|
49
|
+
|
|
50
|
+
// npm prints an empty string for unset array settings
|
|
51
|
+
return ['', 'null', 'undefined'].includes(result) ? undefined : result;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getProjectDir() {
|
|
55
|
+
return findWorkspaceRoot() ?? process.cwd();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type NpmConfigLocation = 'project' | 'user';
|
|
59
|
+
|
|
60
|
+
function npmHasConfig(key: string, location: NpmConfigLocation) {
|
|
61
|
+
const value = location === 'user' ? npmGetUserConfig(key) : npmGetProjectConfig(key);
|
|
62
|
+
return value !== undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function toNpmConfigSettings(settings: string[]): Setting[] {
|
|
66
|
+
return (['project', 'user'] as const).flatMap(location =>
|
|
67
|
+
settings.map(setting => {
|
|
68
|
+
const [key] = setting.split('=');
|
|
69
|
+
return {
|
|
70
|
+
description: `${setting} in npm ${location} config`,
|
|
71
|
+
isSet: () => npmHasConfig(key, location),
|
|
72
|
+
set: () => npmSetConfig(setting, location),
|
|
73
|
+
};
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function npmSetConfig(setting: string, location: NpmConfigLocation) {
|
|
79
|
+
runCommand('npm', ['config', 'set', setting, `--location=${location}`], {
|
|
80
|
+
// `npm config` fails in a workspace package
|
|
81
|
+
cwd: getProjectDir(),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { findUp } from '../find-up';
|
|
3
|
+
import { runCommand, RunCommandOptions } from '../os';
|
|
4
|
+
|
|
5
|
+
type NpmGetLocalPrefixOptions = Omit<RunCommandOptions, 'cwd'>;
|
|
6
|
+
|
|
7
|
+
// npm >=11.6 replaces secrets and UUIDs in everything it prints with this marker
|
|
8
|
+
const REDACTED = '***';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Returns the project root npm resolves for the current directory, as printed by `npm prefix`:
|
|
12
|
+
* the nearest ancestor with package.json or node_modules, or the workspace root containing it.
|
|
13
|
+
*/
|
|
14
|
+
export function npmGetLocalPrefix(options?: NpmGetLocalPrefixOptions): string {
|
|
15
|
+
return unredact(runCommand('npm', ['prefix'], options).trim());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* npm redacts its output, so `npm prefix` prints *** in place of any UUID in the path.
|
|
20
|
+
* The prefix is always the current directory or one of its ancestors, so return the one
|
|
21
|
+
* that matches the output.
|
|
22
|
+
*/
|
|
23
|
+
function unredact(prefix: string) {
|
|
24
|
+
if (!prefix.includes(REDACTED)) {
|
|
25
|
+
return prefix;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const expected = splitPath(prefix);
|
|
29
|
+
return (
|
|
30
|
+
findUp(directory => {
|
|
31
|
+
const actual = splitPath(directory);
|
|
32
|
+
const matches =
|
|
33
|
+
actual.length === expected.length &&
|
|
34
|
+
actual.every((segment, i) => matchesSegment(segment, expected[i]));
|
|
35
|
+
return matches ? directory : undefined;
|
|
36
|
+
}) ?? prefix
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function splitPath(value: string) {
|
|
41
|
+
// Windows paths are case-insensitive, and npm may print the drive letter in a different case
|
|
42
|
+
return (process.platform === 'win32' ? value.toLowerCase() : value).split(path.sep);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// npm redacts a UUID even when it is only part of a segment, so *** stands for one or more characters
|
|
46
|
+
function matchesSegment(actual: string, expected: string) {
|
|
47
|
+
const index = expected.indexOf(REDACTED);
|
|
48
|
+
if (index === -1) {
|
|
49
|
+
return actual === expected;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const head = expected.slice(0, index);
|
|
53
|
+
const tail = expected.slice(index + REDACTED.length);
|
|
54
|
+
if (!actual.startsWith(head)) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
for (let end = head.length + 1; end <= actual.length; end++) {
|
|
58
|
+
if (matchesSegment(actual.slice(end), tail)) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { debug } from '../debug';
|
|
2
|
+
import { runCommand } from '../os';
|
|
3
|
+
|
|
4
|
+
export function npmWhoAmI({ registry }: { registry?: string } = {}) {
|
|
5
|
+
try {
|
|
6
|
+
const result = runCommand(
|
|
7
|
+
'npm',
|
|
8
|
+
['whoami', ...(registry ? [`--registry=${registry}`] : [])],
|
|
9
|
+
{ stdio: ['pipe', 'pipe', 'ignore'], timeout: 10000 }
|
|
10
|
+
).trim();
|
|
11
|
+
|
|
12
|
+
debug('install:whoami', { result });
|
|
13
|
+
|
|
14
|
+
return result.trim();
|
|
15
|
+
} catch {
|
|
16
|
+
// ignore
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/utils/os.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { execFileSync, ExecSyncOptionsWithBufferEncoding } from 'child_process';
|
|
2
|
+
import { randomBytes } from 'node:crypto';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
2
5
|
import { debug } from './debug';
|
|
3
6
|
|
|
4
|
-
type RunCommandOptions = ExecSyncOptionsWithBufferEncoding;
|
|
7
|
+
export type RunCommandOptions = ExecSyncOptionsWithBufferEncoding;
|
|
5
8
|
|
|
6
9
|
export function runCommand(command: string, args: string[], options: RunCommandOptions = {}) {
|
|
7
10
|
debug('install:run', { command, args, options });
|
|
@@ -22,3 +25,11 @@ function getWindowsOptions(command: string) {
|
|
|
22
25
|
return { shell: true };
|
|
23
26
|
}
|
|
24
27
|
}
|
|
28
|
+
|
|
29
|
+
export function getMissingConfigPath() {
|
|
30
|
+
return path.join(
|
|
31
|
+
os.tmpdir(),
|
|
32
|
+
'servicetitan-install-missing-config',
|
|
33
|
+
randomBytes(16).toString('hex')
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import { findWorkspaceRoot } from './find-workspace-root';
|
|
3
|
+
import { getMissingConfigPath, runCommand } from './os';
|
|
4
|
+
|
|
5
|
+
export type PnpmConfigLocation = 'project' | 'global';
|
|
6
|
+
|
|
7
|
+
export function pnpmGetProjectConfig(key: string): unknown {
|
|
8
|
+
return pnpmGetConfig(key, {
|
|
9
|
+
cwd: getWorkspaceDir(),
|
|
10
|
+
env: {
|
|
11
|
+
// pnpm skips config paths that don't exist
|
|
12
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
13
|
+
XDG_CONFIG_HOME: getMissingConfigPath(),
|
|
14
|
+
npm_config_globalconfig: getMissingConfigPath(),
|
|
15
|
+
npm_config_userconfig: getMissingConfigPath(),
|
|
16
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function pnpmGetGlobalConfig(key: string): unknown {
|
|
22
|
+
// Outside the project, so the project's config doesn't affect the result
|
|
23
|
+
return pnpmGetConfig(key, { cwd: os.homedir() });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function pnpmGetConfig(key: string, options: NonNullable<Parameters<typeof runCommand>[2]>) {
|
|
27
|
+
const envKey = key.replaceAll(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);
|
|
28
|
+
const result = runCommand('pnpm', ['config', 'get', '--json', key], {
|
|
29
|
+
...options,
|
|
30
|
+
env: {
|
|
31
|
+
...options.env,
|
|
32
|
+
// Environment variables override configuration files
|
|
33
|
+
[`npm_config_${envKey}`]: undefined,
|
|
34
|
+
[`pnpm_config_${envKey}`]: undefined,
|
|
35
|
+
},
|
|
36
|
+
stdio: ['pipe', 'pipe', 'ignore'],
|
|
37
|
+
}).trim();
|
|
38
|
+
|
|
39
|
+
// pnpm prints nothing for unset settings
|
|
40
|
+
return result ? JSON.parse(result) : undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function pnpmSetConfig(location: PnpmConfigLocation, args: string[]) {
|
|
44
|
+
runCommand('pnpm', ['config', 'set', `--location=${location}`, ...args], {
|
|
45
|
+
// In a workspace package, pnpm 11 writes project config to the package but reads it from the root
|
|
46
|
+
cwd: location === 'project' ? getWorkspaceDir() : undefined,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function getWorkspaceDir() {
|
|
51
|
+
return findWorkspaceRoot() ?? process.cwd();
|
|
52
|
+
}
|
package/dist/utils/npm.d.ts
DELETED
package/dist/utils/npm.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"npm.d.ts","sourceRoot":"","sources":["../../src/utils/npm.ts"],"names":[],"mappings":"AAIA,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,sBAcjE;AAOD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,sBAW3C"}
|
package/dist/utils/npm.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get npmGetUserConfig () {
|
|
13
|
-
return npmGetUserConfig;
|
|
14
|
-
},
|
|
15
|
-
get npmWhoAmI () {
|
|
16
|
-
return npmWhoAmI;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _os = /*#__PURE__*/ _interop_require_default(require("os"));
|
|
20
|
-
const _debug = require("./debug");
|
|
21
|
-
const _os1 = require("./os");
|
|
22
|
-
function _interop_require_default(obj) {
|
|
23
|
-
return obj && obj.__esModule ? obj : {
|
|
24
|
-
default: obj
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function npmWhoAmI({ registry } = {}) {
|
|
28
|
-
try {
|
|
29
|
-
const result = (0, _os1.runCommand)('npm', [
|
|
30
|
-
'whoami',
|
|
31
|
-
...registry ? [
|
|
32
|
-
`--registry=${registry}`
|
|
33
|
-
] : []
|
|
34
|
-
], {
|
|
35
|
-
stdio: [
|
|
36
|
-
'pipe',
|
|
37
|
-
'pipe',
|
|
38
|
-
'ignore'
|
|
39
|
-
],
|
|
40
|
-
timeout: 10000
|
|
41
|
-
}).trim();
|
|
42
|
-
(0, _debug.debug)('install:whoami', {
|
|
43
|
-
result
|
|
44
|
-
});
|
|
45
|
-
return result.trim();
|
|
46
|
-
} catch (unused) {
|
|
47
|
-
// ignore
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function npmGetUserConfig(key) {
|
|
51
|
-
const result = (0, _os1.runCommand)('npm', [
|
|
52
|
-
'config',
|
|
53
|
-
'get',
|
|
54
|
-
key,
|
|
55
|
-
`--prefix=${getHomePrefix()}`
|
|
56
|
-
], {
|
|
57
|
-
/*
|
|
58
|
-
* Environment variables override configuration files, for example
|
|
59
|
-
* when install itself runs via `npx --yes`.
|
|
60
|
-
*/ env: {
|
|
61
|
-
[`npm_config_${key.replace(/-/g, '_')}`]: undefined
|
|
62
|
-
},
|
|
63
|
-
stdio: [
|
|
64
|
-
'pipe',
|
|
65
|
-
'pipe',
|
|
66
|
-
'ignore'
|
|
67
|
-
]
|
|
68
|
-
}).trim();
|
|
69
|
-
return result === 'null' ? undefined : result;
|
|
70
|
-
}
|
|
71
|
-
function getHomePrefix() {
|
|
72
|
-
const home = _os.default.homedir();
|
|
73
|
-
// On Windows, npm runs through a shell that splits unquoted arguments at spaces.
|
|
74
|
-
return process.platform === 'win32' ? `"${home}"` : home;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//# sourceMappingURL=npm.js.map
|
package/dist/utils/npm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/npm.ts"],"sourcesContent":["import os from 'os';\nimport { debug } from './debug';\nimport { runCommand } from './os';\n\nexport function npmWhoAmI({ registry }: { registry?: string } = {}) {\n try {\n const result = runCommand(\n 'npm',\n ['whoami', ...(registry ? [`--registry=${registry}`] : [])],\n { stdio: ['pipe', 'pipe', 'ignore'], timeout: 10000 }\n ).trim();\n\n debug('install:whoami', { result });\n\n return result.trim();\n } catch {\n // ignore\n }\n}\n\n/*\n * Reads a setting as seen from the home directory, so project-level .npmrc files\n * in the current directory do not affect the result. Returns undefined when the\n * setting is unset.\n */\nexport function npmGetUserConfig(key: string) {\n const result = runCommand('npm', ['config', 'get', key, `--prefix=${getHomePrefix()}`], {\n /*\n * Environment variables override configuration files, for example\n * when install itself runs via `npx --yes`.\n */\n env: { [`npm_config_${key.replace(/-/g, '_')}`]: undefined },\n stdio: ['pipe', 'pipe', 'ignore'],\n }).trim();\n\n return result === 'null' ? undefined : result;\n}\n\nfunction getHomePrefix() {\n const home = os.homedir();\n\n // On Windows, npm runs through a shell that splits unquoted arguments at spaces.\n return process.platform === 'win32' ? `\"${home}\"` : home;\n}\n"],"names":["npmGetUserConfig","npmWhoAmI","registry","result","runCommand","stdio","timeout","trim","debug","key","getHomePrefix","env","replace","undefined","home","os","homedir","process","platform"],"mappings":";;;;;;;;;;;QAyBgBA;eAAAA;;QArBAC;eAAAA;;;2DAJD;uBACO;qBACK;;;;;;AAEpB,SAASA,UAAU,EAAEC,QAAQ,EAAyB,GAAG,CAAC,CAAC;IAC9D,IAAI;QACA,MAAMC,SAASC,IAAAA,eAAU,EACrB,OACA;YAAC;eAAcF,WAAW;gBAAC,CAAC,WAAW,EAAEA,UAAU;aAAC,GAAG,EAAE;SAAE,EAC3D;YAAEG,OAAO;gBAAC;gBAAQ;gBAAQ;aAAS;YAAEC,SAAS;QAAM,GACtDC,IAAI;QAENC,IAAAA,YAAK,EAAC,kBAAkB;YAAEL;QAAO;QAEjC,OAAOA,OAAOI,IAAI;IACtB,EAAE,eAAM;IACJ,SAAS;IACb;AACJ;AAOO,SAASP,iBAAiBS,GAAW;IACxC,MAAMN,SAASC,IAAAA,eAAU,EAAC,OAAO;QAAC;QAAU;QAAOK;QAAK,CAAC,SAAS,EAAEC,iBAAiB;KAAC,EAAE;QACpF;;;SAGC,GACDC,KAAK;YAAE,CAAC,CAAC,WAAW,EAAEF,IAAIG,OAAO,CAAC,MAAM,MAAM,CAAC,EAAEC;QAAU;QAC3DR,OAAO;YAAC;YAAQ;YAAQ;SAAS;IACrC,GAAGE,IAAI;IAEP,OAAOJ,WAAW,SAASU,YAAYV;AAC3C;AAEA,SAASO;IACL,MAAMI,OAAOC,WAAE,CAACC,OAAO;IAEvB,iFAAiF;IACjF,OAAOC,QAAQC,QAAQ,KAAK,UAAU,CAAC,CAAC,EAAEJ,KAAK,CAAC,CAAC,GAAGA;AACxD"}
|
package/src/utils/npm.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import os from 'os';
|
|
2
|
-
import { debug } from './debug';
|
|
3
|
-
import { runCommand } from './os';
|
|
4
|
-
|
|
5
|
-
export function npmWhoAmI({ registry }: { registry?: string } = {}) {
|
|
6
|
-
try {
|
|
7
|
-
const result = runCommand(
|
|
8
|
-
'npm',
|
|
9
|
-
['whoami', ...(registry ? [`--registry=${registry}`] : [])],
|
|
10
|
-
{ stdio: ['pipe', 'pipe', 'ignore'], timeout: 10000 }
|
|
11
|
-
).trim();
|
|
12
|
-
|
|
13
|
-
debug('install:whoami', { result });
|
|
14
|
-
|
|
15
|
-
return result.trim();
|
|
16
|
-
} catch {
|
|
17
|
-
// ignore
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/*
|
|
22
|
-
* Reads a setting as seen from the home directory, so project-level .npmrc files
|
|
23
|
-
* in the current directory do not affect the result. Returns undefined when the
|
|
24
|
-
* setting is unset.
|
|
25
|
-
*/
|
|
26
|
-
export function npmGetUserConfig(key: string) {
|
|
27
|
-
const result = runCommand('npm', ['config', 'get', key, `--prefix=${getHomePrefix()}`], {
|
|
28
|
-
/*
|
|
29
|
-
* Environment variables override configuration files, for example
|
|
30
|
-
* when install itself runs via `npx --yes`.
|
|
31
|
-
*/
|
|
32
|
-
env: { [`npm_config_${key.replace(/-/g, '_')}`]: undefined },
|
|
33
|
-
stdio: ['pipe', 'pipe', 'ignore'],
|
|
34
|
-
}).trim();
|
|
35
|
-
|
|
36
|
-
return result === 'null' ? undefined : result;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function getHomePrefix() {
|
|
40
|
-
const home = os.homedir();
|
|
41
|
-
|
|
42
|
-
// On Windows, npm runs through a shell that splits unquoted arguments at spaces.
|
|
43
|
-
return process.platform === 'win32' ? `"${home}"` : home;
|
|
44
|
-
}
|