@servicetitan/install 40.4.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
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "PnpmPackageManager", {
|
|
|
8
8
|
return PnpmPackageManager;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const
|
|
11
|
+
const _nodefs = /*#__PURE__*/ _interop_require_default(require("node:fs"));
|
|
12
12
|
const _utils = require("../utils");
|
|
13
13
|
const _packagemanager = require("./package-manager");
|
|
14
14
|
const _utils1 = require("./utils");
|
|
@@ -29,6 +29,7 @@ function _interop_require_default(obj) {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
const MIN_PNPM_VERSION_FOR_RELEASE_AGE = '10.16.0';
|
|
32
|
+
const MINUTES_PER_DAY = 24 * 60;
|
|
32
33
|
class PnpmPackageManager extends _packagemanager.PackageManager {
|
|
33
34
|
get rootWorkspacePackage() {
|
|
34
35
|
return '.';
|
|
@@ -49,6 +50,15 @@ class PnpmPackageManager extends _packagemanager.PackageManager {
|
|
|
49
50
|
const snapshot = (_this_getLockFile = this.getLockFile()) === null || _this_getLockFile === void 0 ? void 0 : (_this_getLockFile_snapshots = _this_getLockFile.snapshots) === null || _this_getLockFile_snapshots === void 0 ? void 0 : _this_getLockFile_snapshots[`${declaredBy}@${declaredByVersion}`];
|
|
50
51
|
return (_ref = snapshot === null || snapshot === void 0 ? void 0 : (_snapshot_dependencies = snapshot.dependencies) === null || _snapshot_dependencies === void 0 ? void 0 : _snapshot_dependencies[dependency]) !== null && _ref !== void 0 ? _ref : snapshot === null || snapshot === void 0 ? void 0 : (_snapshot_peerDependencies = snapshot.peerDependencies) === null || _snapshot_peerDependencies === void 0 ? void 0 : _snapshot_peerDependencies[dependency];
|
|
51
52
|
}
|
|
53
|
+
getRecommendedSettings(args) {
|
|
54
|
+
// npx is part of npm, so it reads npm's config even in pnpm projects
|
|
55
|
+
return [
|
|
56
|
+
...(0, _utils.toNpmConfigSettings)([
|
|
57
|
+
'yes=false'
|
|
58
|
+
]),
|
|
59
|
+
...this.getMinReleaseAgeSettings(args)
|
|
60
|
+
];
|
|
61
|
+
}
|
|
52
62
|
getResolvedVersion({ workspacePackage, dependency }) {
|
|
53
63
|
return this.resolveVersion(workspacePackage, dependency);
|
|
54
64
|
}
|
|
@@ -78,16 +88,65 @@ class PnpmPackageManager extends _packagemanager.PackageManager {
|
|
|
78
88
|
* missing the dep gets a clear error instead of silent `undefined`.
|
|
79
89
|
*/ const yaml = require('js-yaml');
|
|
80
90
|
try {
|
|
81
|
-
return yaml.load(
|
|
91
|
+
return yaml.load(_nodefs.default.readFileSync(lockFilePath, 'utf-8'));
|
|
82
92
|
} catch (unused) {
|
|
83
93
|
return undefined;
|
|
84
94
|
}
|
|
85
95
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
96
|
+
getMinReleaseAgeSettings(args) {
|
|
97
|
+
const resolved = (0, _utils1.resolveMinReleaseAge)(args.minReleaseAge);
|
|
98
|
+
if (!resolved) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
const version = (0, _utils.runCommand)(this.command, [
|
|
102
|
+
'--version'
|
|
103
|
+
]).trim();
|
|
104
|
+
if ((0, _utils.versionCompare)(version, MIN_PNPM_VERSION_FOR_RELEASE_AGE) < 0) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
return [
|
|
108
|
+
'project',
|
|
109
|
+
'global'
|
|
110
|
+
].flatMap((location)=>{
|
|
111
|
+
const getConfig = location === 'project' ? _utils.pnpmGetProjectConfig : _utils.pnpmGetGlobalConfig;
|
|
112
|
+
return [
|
|
113
|
+
{
|
|
114
|
+
description: `minimumReleaseAge in pnpm ${location} config`,
|
|
115
|
+
isSet: ()=>getConfig('minimumReleaseAge') !== undefined,
|
|
116
|
+
set: ()=>(0, _utils.pnpmSetConfig)(location, [
|
|
117
|
+
'minimumReleaseAge',
|
|
118
|
+
String(resolved.days * MINUTES_PER_DAY)
|
|
119
|
+
])
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
description: `minimumReleaseAgeExclude in pnpm ${location} config`,
|
|
123
|
+
isSet: ()=>getConfig('minimumReleaseAgeExclude') !== undefined,
|
|
124
|
+
set: ()=>(0, _utils.pnpmSetConfig)(location, [
|
|
125
|
+
'--json',
|
|
126
|
+
'minimumReleaseAgeExclude',
|
|
127
|
+
toJsonArg(resolved.exclude)
|
|
128
|
+
])
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Returns the version of a dependency that a workspace package resolves to. When the package
|
|
135
|
+
* doesn't declare the dependency itself, it resolves through the root's node_modules, so this
|
|
136
|
+
* falls back to the root workspace's dependencies. Packages outside the workspace get no
|
|
137
|
+
* fallback.
|
|
138
|
+
*/ resolveVersion(workspacePackage, dependency) {
|
|
139
|
+
var _findImporterEntry;
|
|
140
|
+
var _this_getLockFile;
|
|
141
|
+
if (workspacePackage === undefined) {
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
const importers = (_this_getLockFile = this.getLockFile()) === null || _this_getLockFile === void 0 ? void 0 : _this_getLockFile.importers;
|
|
145
|
+
const importer = importers === null || importers === void 0 ? void 0 : importers[workspacePackage];
|
|
146
|
+
if (!importer) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
const entry = (_findImporterEntry = findImporterEntry(importer, dependency)) !== null && _findImporterEntry !== void 0 ? _findImporterEntry : findImporterEntry(importers[this.rootWorkspacePackage], dependency);
|
|
91
150
|
return entry ? stripPeerDependencySuffix(entry.version) : undefined;
|
|
92
151
|
}
|
|
93
152
|
warnIfMinReleaseAgeNotConfigured(args) {
|
|
@@ -130,6 +189,20 @@ class PnpmPackageManager extends _packagemanager.PackageManager {
|
|
|
130
189
|
super(...args), _define_property(this, "command", 'pnpm'), _define_property(this, "lockFileName", 'pnpm-lock.yaml');
|
|
131
190
|
}
|
|
132
191
|
}
|
|
192
|
+
function findImporterEntry(importer, dependency) {
|
|
193
|
+
var _ref, _ref1;
|
|
194
|
+
var _importer_dependencies, _importer_devDependencies, _importer_optionalDependencies;
|
|
195
|
+
return (_ref = (_ref1 = importer === null || importer === void 0 ? void 0 : (_importer_dependencies = importer.dependencies) === null || _importer_dependencies === void 0 ? void 0 : _importer_dependencies[dependency]) !== null && _ref1 !== void 0 ? _ref1 : importer === null || importer === void 0 ? void 0 : (_importer_devDependencies = importer.devDependencies) === null || _importer_devDependencies === void 0 ? void 0 : _importer_devDependencies[dependency]) !== null && _ref !== void 0 ? _ref : importer === null || importer === void 0 ? void 0 : (_importer_optionalDependencies = importer.optionalDependencies) === null || _importer_optionalDependencies === void 0 ? void 0 : _importer_optionalDependencies[dependency];
|
|
196
|
+
}
|
|
197
|
+
function toJsonArg(value) {
|
|
198
|
+
const json = JSON.stringify(value);
|
|
199
|
+
if (process.platform !== 'win32') {
|
|
200
|
+
return json;
|
|
201
|
+
}
|
|
202
|
+
// On Windows, pnpm runs through a shell that strips unescaped double quotes
|
|
203
|
+
const escapedJson = json.replaceAll('"', String.raw`\"`);
|
|
204
|
+
return `"${escapedJson}"`;
|
|
205
|
+
}
|
|
133
206
|
function stripPeerDependencySuffix(version) {
|
|
134
207
|
// e.g., "1.2.3(react@18.2.0)(react-dom@18.2.0)" → "1.2.3"
|
|
135
208
|
return version.split('(')[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/package-manager/pnpm-package-manager.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport fs from 'fs';\nimport { isCI, runCommand, versionCompare } from '../utils';\nimport type { DeclaredVersionQuery, InstallArgs, ResolvedVersionQuery } from './package-manager';\nimport { PackageManager } from './package-manager';\nimport { resolveMinReleaseAge } from './utils';\n\nconst MIN_PNPM_VERSION_FOR_RELEASE_AGE = '10.16.0';\n\ninterface PnpmImporterEntry {\n specifier: string;\n version: string;\n}\n\ninterface PnpmImporter {\n dependencies?: Record<string, PnpmImporterEntry>;\n devDependencies?: Record<string, PnpmImporterEntry>;\n optionalDependencies?: Record<string, PnpmImporterEntry>;\n}\n\ninterface PnpmSnapshot {\n dependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n}\n\nexport interface PnpmLockFile {\n importers?: Record<string, PnpmImporter>;\n snapshots?: Record<string, PnpmSnapshot>;\n}\n\nexport class PnpmPackageManager extends PackageManager<PnpmLockFile> {\n readonly command = 'pnpm';\n readonly lockFileName = 'pnpm-lock.yaml';\n\n protected override get rootWorkspacePackage(): string {\n return '.';\n }\n\n clearCache() {\n runCommand(this.command, ['store', 'prune']);\n }\n\n getDeclaredVersion({\n workspacePackage,\n declaredBy,\n dependency,\n }: DeclaredVersionQuery): string | undefined {\n const declaredByVersion = this.resolveVersion(workspacePackage, declaredBy);\n if (!declaredByVersion) {\n return undefined;\n }\n const snapshot = this.getLockFile()?.snapshots?.[`${declaredBy}@${declaredByVersion}`];\n return snapshot?.dependencies?.[dependency] ?? snapshot?.peerDependencies?.[dependency];\n }\n\n getResolvedVersion({ workspacePackage, dependency }: ResolvedVersionQuery): string | undefined {\n return this.resolveVersion(workspacePackage, dependency);\n }\n\n installPackages(args: InstallArgs = {}, options?: Parameters<typeof runCommand>[2]) {\n this.warnIfMinReleaseAgeNotConfigured(args);\n\n try {\n runCommand(\n this.command,\n [\n 'install',\n ...(isCI() ? ['--frozen-lockfile'] : []),\n ...(args.fix ? ['--lockfile-only'] : []),\n ],\n options\n );\n } finally {\n this.reset();\n }\n }\n\n protected parseLockFile(): PnpmLockFile | undefined {\n const lockFilePath = this.getLockFilePath();\n if (!lockFilePath) {\n return undefined;\n }\n /*\n * js-yaml is an optional peer; let MODULE_NOT_FOUND surface so a caller\n * missing the dep gets a clear error instead of silent `undefined`.\n */\n const yaml = require('js-yaml');\n try {\n return yaml.load(fs.readFileSync(lockFilePath, 'utf-8'));\n } catch {\n return undefined;\n }\n }\n\n private resolveVersion(workspacePackage: string, dependency: string): string | undefined {\n const importer = this.getLockFile()?.importers?.[workspacePackage];\n const entry =\n importer?.dependencies?.[dependency] ??\n importer?.devDependencies?.[dependency] ??\n importer?.optionalDependencies?.[dependency];\n return entry ? stripPeerDependencySuffix(entry.version) : undefined;\n }\n\n private warnIfMinReleaseAgeNotConfigured(args: InstallArgs) {\n if (args.fix) {\n return;\n }\n\n if (!resolveMinReleaseAge(args.minReleaseAge)) {\n return;\n }\n\n const version = runCommand(this.command, ['--version']).trim();\n if (versionCompare(version, MIN_PNPM_VERSION_FOR_RELEASE_AGE) < 0) {\n console.warn(\n `WARNING: pnpm ${version} does not support minimum release age protection. Installing without it.`\n );\n return;\n }\n\n if (this.hasConfiguredMinReleaseAge()) {\n return;\n }\n\n console.warn(\n 'WARNING: this project does not enforce a minimum release age for pnpm installs. Configure minimumReleaseAge in pnpm-workspace.yaml.'\n );\n }\n\n /*\n * `pnpm config list --json` reports this key as `minimum-release-age` on\n * pnpm <11 and `minimumReleaseAge` on pnpm >=11, so both are checked.\n */\n private hasConfiguredMinReleaseAge(): boolean {\n try {\n const config = JSON.parse(runCommand(this.command, ['config', 'list', '--json']));\n const configuredAge = config.minimumReleaseAge ?? config['minimum-release-age'];\n return Number(configuredAge) > 0;\n } catch {\n return false;\n }\n }\n}\n\nfunction stripPeerDependencySuffix(version: string): string {\n // e.g., \"1.2.3(react@18.2.0)(react-dom@18.2.0)\" → \"1.2.3\"\n return version.split('(')[0];\n}\n"],"names":["PnpmPackageManager","MIN_PNPM_VERSION_FOR_RELEASE_AGE","PackageManager","rootWorkspacePackage","clearCache","runCommand","command","getDeclaredVersion","workspacePackage","declaredBy","dependency","snapshot","declaredByVersion","resolveVersion","undefined","getLockFile","snapshots","dependencies","peerDependencies","getResolvedVersion","installPackages","args","options","warnIfMinReleaseAgeNotConfigured","isCI","fix","reset","parseLockFile","lockFilePath","getLockFilePath","yaml","require","load","fs","readFileSync","importer","importers","entry","devDependencies","optionalDependencies","stripPeerDependencySuffix","version","resolveMinReleaseAge","minReleaseAge","trim","versionCompare","console","warn","hasConfiguredMinReleaseAge","config","JSON","parse","configuredAge","minimumReleaseAge","Number","lockFileName","split"],"mappings":"AAAA,6BAA6B;;;;+BA8BhBA;;;eAAAA;;;2DA7BE;uBACkC;gCAElB;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CACR;IAER;IAEA;;;KAGC,GACD,AAAQC,6BAAsC;QAC1C,IAAI;gBAEsBC;YADtB,MAAMA,SAASC,KAAKC,KAAK,CAAC9C,IAAAA,iBAAU,EAAC,IAAI,CAACC,OAAO,EAAE;gBAAC;gBAAU;gBAAQ;aAAS;YAC/E,MAAM8C,iBAAgBH,4BAAAA,OAAOI,iBAAiB,cAAxBJ,uCAAAA,4BAA4BA,MAAM,CAAC,sBAAsB;YAC/E,OAAOK,OAAOF,iBAAiB;QACnC,EAAE,eAAM;YACJ,OAAO;QACX;IACJ;;QA/GG,gBACH,uBAAS9C,WAAU,SACnB,uBAASiD,gBAAe;;AA8G5B;AAEA,SAASf,0BAA0BC,OAAe;IAC9C,0DAA0D;IAC1D,OAAOA,QAAQe,KAAK,CAAC,IAAI,CAAC,EAAE;AAChC"}
|
|
1
|
+
{"version":3,"sources":["../../src/package-manager/pnpm-package-manager.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport type * as Yaml from 'js-yaml';\nimport fs from 'node:fs';\nimport {\n isCI,\n pnpmGetGlobalConfig,\n pnpmGetProjectConfig,\n pnpmSetConfig,\n runCommand,\n Setting,\n toNpmConfigSettings,\n versionCompare,\n} from '../utils';\nimport type { DeclaredVersionQuery, InstallArgs, ResolvedVersionQuery } from './package-manager';\nimport { PackageManager } from './package-manager';\nimport { resolveMinReleaseAge } from './utils';\n\nconst MIN_PNPM_VERSION_FOR_RELEASE_AGE = '10.16.0';\nconst MINUTES_PER_DAY = 24 * 60;\n\ninterface PnpmImporterEntry {\n specifier: string;\n version: string;\n}\n\ninterface PnpmImporter {\n dependencies?: Record<string, PnpmImporterEntry>;\n devDependencies?: Record<string, PnpmImporterEntry>;\n optionalDependencies?: Record<string, PnpmImporterEntry>;\n}\n\ninterface PnpmSnapshot {\n dependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n}\n\nexport interface PnpmLockFile {\n importers?: Record<string, PnpmImporter>;\n snapshots?: Record<string, PnpmSnapshot>;\n}\n\nexport class PnpmPackageManager extends PackageManager<PnpmLockFile> {\n readonly command = 'pnpm';\n readonly lockFileName = 'pnpm-lock.yaml';\n\n protected override get rootWorkspacePackage(): string {\n return '.';\n }\n\n clearCache() {\n runCommand(this.command, ['store', 'prune']);\n }\n\n getDeclaredVersion({\n workspacePackage,\n declaredBy,\n dependency,\n }: DeclaredVersionQuery): string | undefined {\n const declaredByVersion = this.resolveVersion(workspacePackage, declaredBy);\n if (!declaredByVersion) {\n return undefined;\n }\n const snapshot = this.getLockFile()?.snapshots?.[`${declaredBy}@${declaredByVersion}`];\n return snapshot?.dependencies?.[dependency] ?? snapshot?.peerDependencies?.[dependency];\n }\n\n getRecommendedSettings(args: InstallArgs) {\n // npx is part of npm, so it reads npm's config even in pnpm projects\n return [...toNpmConfigSettings(['yes=false']), ...this.getMinReleaseAgeSettings(args)];\n }\n\n getResolvedVersion({ workspacePackage, dependency }: ResolvedVersionQuery): string | undefined {\n return this.resolveVersion(workspacePackage, dependency);\n }\n\n installPackages(args: InstallArgs = {}, options?: Parameters<typeof runCommand>[2]) {\n this.warnIfMinReleaseAgeNotConfigured(args);\n\n try {\n runCommand(\n this.command,\n [\n 'install',\n ...(isCI() ? ['--frozen-lockfile'] : []),\n ...(args.fix ? ['--lockfile-only'] : []),\n ],\n options\n );\n } finally {\n this.reset();\n }\n }\n\n protected parseLockFile(): PnpmLockFile | undefined {\n const lockFilePath = this.getLockFilePath();\n if (!lockFilePath) {\n return undefined;\n }\n /*\n * js-yaml is an optional peer; let MODULE_NOT_FOUND surface so a caller\n * missing the dep gets a clear error instead of silent `undefined`.\n */\n const yaml: typeof Yaml = require('js-yaml');\n try {\n return yaml.load(fs.readFileSync(lockFilePath, 'utf-8')) as PnpmLockFile;\n } catch {\n return undefined;\n }\n }\n\n private getMinReleaseAgeSettings(args: InstallArgs): Setting[] {\n const resolved = resolveMinReleaseAge(args.minReleaseAge);\n if (!resolved) {\n return [];\n }\n\n const version = runCommand(this.command, ['--version']).trim();\n if (versionCompare(version, MIN_PNPM_VERSION_FOR_RELEASE_AGE) < 0) {\n return [];\n }\n\n return (['project', 'global'] as const).flatMap(location => {\n const getConfig = location === 'project' ? pnpmGetProjectConfig : pnpmGetGlobalConfig;\n return [\n {\n description: `minimumReleaseAge in pnpm ${location} config`,\n isSet: () => getConfig('minimumReleaseAge') !== undefined,\n set: () =>\n pnpmSetConfig(location, [\n 'minimumReleaseAge',\n String(resolved.days * MINUTES_PER_DAY),\n ]),\n },\n {\n description: `minimumReleaseAgeExclude in pnpm ${location} config`,\n isSet: () => getConfig('minimumReleaseAgeExclude') !== undefined,\n set: () =>\n pnpmSetConfig(location, [\n '--json',\n 'minimumReleaseAgeExclude',\n toJsonArg(resolved.exclude),\n ]),\n },\n ];\n });\n }\n\n /**\n * Returns the version of a dependency that a workspace package resolves to. When the package\n * doesn't declare the dependency itself, it resolves through the root's node_modules, so this\n * falls back to the root workspace's dependencies. Packages outside the workspace get no\n * fallback.\n */\n private resolveVersion(\n workspacePackage: string | undefined,\n dependency: string\n ): string | undefined {\n if (workspacePackage === undefined) {\n return undefined;\n }\n const importers = this.getLockFile()?.importers;\n const importer = importers?.[workspacePackage];\n if (!importer) {\n return undefined;\n }\n const entry =\n findImporterEntry(importer, dependency) ??\n findImporterEntry(importers[this.rootWorkspacePackage], dependency);\n return entry ? stripPeerDependencySuffix(entry.version) : undefined;\n }\n\n private warnIfMinReleaseAgeNotConfigured(args: InstallArgs) {\n if (args.fix) {\n return;\n }\n\n if (!resolveMinReleaseAge(args.minReleaseAge)) {\n return;\n }\n\n const version = runCommand(this.command, ['--version']).trim();\n if (versionCompare(version, MIN_PNPM_VERSION_FOR_RELEASE_AGE) < 0) {\n console.warn(\n `WARNING: pnpm ${version} does not support minimum release age protection. Installing without it.`\n );\n return;\n }\n\n if (this.hasConfiguredMinReleaseAge()) {\n return;\n }\n\n console.warn(\n 'WARNING: this project does not enforce a minimum release age for pnpm installs. Configure minimumReleaseAge in pnpm-workspace.yaml.'\n );\n }\n\n /*\n * `pnpm config list --json` reports this key as `minimum-release-age` on\n * pnpm <11 and `minimumReleaseAge` on pnpm >=11, so both are checked.\n */\n private hasConfiguredMinReleaseAge(): boolean {\n try {\n const config = JSON.parse(runCommand(this.command, ['config', 'list', '--json']));\n const configuredAge = config.minimumReleaseAge ?? config['minimum-release-age'];\n return Number(configuredAge) > 0;\n } catch {\n return false;\n }\n }\n}\n\nfunction findImporterEntry(importer: PnpmImporter | undefined, dependency: string) {\n return (\n importer?.dependencies?.[dependency] ??\n importer?.devDependencies?.[dependency] ??\n importer?.optionalDependencies?.[dependency]\n );\n}\n\nfunction toJsonArg(value: unknown) {\n const json = JSON.stringify(value);\n if (process.platform !== 'win32') {\n return json;\n }\n\n // On Windows, pnpm runs through a shell that strips unescaped double quotes\n const escapedJson = json.replaceAll('\"', String.raw`\\\"`);\n return `\"${escapedJson}\"`;\n}\n\nfunction stripPeerDependencySuffix(version: string): string {\n // e.g., \"1.2.3(react@18.2.0)(react-dom@18.2.0)\" → \"1.2.3\"\n return version.split('(')[0];\n}\n"],"names":["PnpmPackageManager","MIN_PNPM_VERSION_FOR_RELEASE_AGE","MINUTES_PER_DAY","PackageManager","rootWorkspacePackage","clearCache","runCommand","command","getDeclaredVersion","workspacePackage","declaredBy","dependency","snapshot","declaredByVersion","resolveVersion","undefined","getLockFile","snapshots","dependencies","peerDependencies","getRecommendedSettings","args","toNpmConfigSettings","getMinReleaseAgeSettings","getResolvedVersion","installPackages","options","warnIfMinReleaseAgeNotConfigured","isCI","fix","reset","parseLockFile","lockFilePath","getLockFilePath","yaml","require","load","fs","readFileSync","resolved","resolveMinReleaseAge","minReleaseAge","version","trim","versionCompare","flatMap","location","getConfig","pnpmGetProjectConfig","pnpmGetGlobalConfig","description","isSet","set","pnpmSetConfig","String","days","toJsonArg","exclude","findImporterEntry","importers","importer","entry","stripPeerDependencySuffix","console","warn","hasConfiguredMinReleaseAge","config","JSON","parse","configuredAge","minimumReleaseAge","Number","lockFileName","devDependencies","optionalDependencies","value","json","stringify","process","platform","escapedJson","replaceAll","raw","split"],"mappings":"AAAA,6BAA6B;;;;+BAyChBA;;;eAAAA;;;+DAvCE;uBAUR;gCAEwB;wBACM;;;;;;;;;;;;;;;;;AAErC,MAAMC,mCAAmC;AACzC,MAAMC,kBAAkB,KAAK;AAuBtB,MAAMF,2BAA2BG,8BAAc;IAIlD,IAAuBC,uBAA+B;QAClD,OAAO;IACX;IAEAC,aAAa;QACTC,IAAAA,iBAAU,EAAC,IAAI,CAACC,OAAO,EAAE;YAAC;YAAS;SAAQ;IAC/C;IAEAC,mBAAmB,EACfC,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACS,EAAsB;;YAKxB,6BAAA,mBACVC,wBAAwCA;QAL/C,MAAMC,oBAAoB,IAAI,CAACC,cAAc,CAACL,kBAAkBC;QAChE,IAAI,CAACG,mBAAmB;YACpB,OAAOE;QACX;QACA,MAAMH,YAAW,oBAAA,IAAI,CAACI,WAAW,gBAAhB,yCAAA,8BAAA,kBAAoBC,SAAS,cAA7B,kDAAA,2BAA+B,CAAC,GAAGP,WAAW,CAAC,EAAEG,mBAAmB,CAAC;QACtF,eAAOD,qBAAAA,gCAAAA,yBAAAA,SAAUM,YAAY,cAAtBN,6CAAAA,sBAAwB,CAACD,WAAW,uCAAIC,qBAAAA,gCAAAA,6BAAAA,SAAUO,gBAAgB,cAA1BP,iDAAAA,0BAA4B,CAACD,WAAW;IAC3F;IAEAS,uBAAuBC,IAAiB,EAAE;QACtC,qEAAqE;QACrE,OAAO;eAAIC,IAAAA,0BAAmB,EAAC;gBAAC;aAAY;eAAM,IAAI,CAACC,wBAAwB,CAACF;SAAM;IAC1F;IAEAG,mBAAmB,EAAEf,gBAAgB,EAAEE,UAAU,EAAwB,EAAsB;QAC3F,OAAO,IAAI,CAACG,cAAc,CAACL,kBAAkBE;IACjD;IAEAc,gBAAgBJ,OAAoB,CAAC,CAAC,EAAEK,OAA0C,EAAE;QAChF,IAAI,CAACC,gCAAgC,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AACC,OAAO,EAAE;gBAAC;gBAAU;gBAAQ;aAAS;YAC/E,MAAM8D,iBAAgBH,4BAAAA,OAAOI,iBAAiB,cAAxBJ,uCAAAA,4BAA4BA,MAAM,CAAC,sBAAsB;YAC/E,OAAOK,OAAOF,iBAAiB;QACnC,EAAE,eAAM;YACJ,OAAO;QACX;IACJ;;QAxKG,gBACH,uBAAS9D,WAAU,SACnB,uBAASiE,gBAAe;;AAuK5B;AAEA,SAASd,kBAAkBE,QAAkC,EAAEjD,UAAkB;QAEzEiD;QAAAA,wBACAA,2BACAA;IAHJ,QACIA,gBAAAA,qBAAAA,gCAAAA,yBAAAA,SAAU1C,YAAY,cAAtB0C,6CAAAA,sBAAwB,CAACjD,WAAW,yCACpCiD,qBAAAA,gCAAAA,4BAAAA,SAAUa,eAAe,cAAzBb,gDAAAA,yBAA2B,CAACjD,WAAW,cADvCiD,kBAAAA,OAEAA,qBAAAA,gCAAAA,iCAAAA,SAAUc,oBAAoB,cAA9Bd,qDAAAA,8BAAgC,CAACjD,WAAW;AAEpD;AAEA,SAAS6C,UAAUmB,KAAc;IAC7B,MAAMC,OAAOT,KAAKU,SAAS,CAACF;IAC5B,IAAIG,QAAQC,QAAQ,KAAK,SAAS;QAC9B,OAAOH;IACX;IAEA,4EAA4E;IAC5E,MAAMI,cAAcJ,KAAKK,UAAU,CAAC,KAAK3B,OAAO4B,GAAG,CAAC,EAAE,CAAC;IACvD,OAAO,CAAC,CAAC,EAAEF,YAAY,CAAC,CAAC;AAC7B;AAEA,SAASlB,0BAA0BpB,OAAe;IAC9C,0DAA0D;IAC1D,OAAOA,QAAQyC,KAAK,CAAC,IAAI,CAAC,EAAE;AAChC"}
|
|
@@ -21,7 +21,7 @@ function withProjectAllowScripts(scripts, fn) {
|
|
|
21
21
|
if (!supportsProjectAllowScriptsConfig(getNpmVersion())) {
|
|
22
22
|
return fn();
|
|
23
23
|
}
|
|
24
|
-
const packageJsonPath = _path.default.join(
|
|
24
|
+
const packageJsonPath = _path.default.join((0, _utils.npmGetLocalPrefix)(), 'package.json');
|
|
25
25
|
const backupPath = `${packageJsonPath}.bak`;
|
|
26
26
|
const original = _fs.default.readFileSync(packageJsonPath, 'utf-8');
|
|
27
27
|
_fs.default.copyFileSync(packageJsonPath, backupPath);
|
|
@@ -38,11 +38,6 @@ function getNpmVersion() {
|
|
|
38
38
|
'--version'
|
|
39
39
|
]).trim();
|
|
40
40
|
}
|
|
41
|
-
function getNpmPrefix() {
|
|
42
|
-
return (0, _utils.runCommand)(NPM, [
|
|
43
|
-
'prefix'
|
|
44
|
-
]).trim();
|
|
45
|
-
}
|
|
46
41
|
function buildPackageJsonWithAllowScripts(original, scripts) {
|
|
47
42
|
const packageJson = JSON.parse(original);
|
|
48
43
|
const allowed = Object.fromEntries(scripts.map((name)=>[
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/package-manager/utils/with-project-allow-scripts.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { runCommand } from '../../utils';\n\nconst NPM = 'npm';\n\nexport function withProjectAllowScripts<T>(scripts: string[], fn: () => T): T {\n if (!supportsProjectAllowScriptsConfig(getNpmVersion())) {\n return fn();\n }\n\n const packageJsonPath = path.join(
|
|
1
|
+
{"version":3,"sources":["../../../src/package-manager/utils/with-project-allow-scripts.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { npmGetLocalPrefix, runCommand } from '../../utils';\n\nconst NPM = 'npm';\n\nexport function withProjectAllowScripts<T>(scripts: string[], fn: () => T): T {\n if (!supportsProjectAllowScriptsConfig(getNpmVersion())) {\n return fn();\n }\n\n const packageJsonPath = path.join(npmGetLocalPrefix(), 'package.json');\n const backupPath = `${packageJsonPath}.bak`;\n const original = fs.readFileSync(packageJsonPath, 'utf-8');\n fs.copyFileSync(packageJsonPath, backupPath);\n\n try {\n fs.writeFileSync(packageJsonPath, buildPackageJsonWithAllowScripts(original, scripts));\n return fn();\n } finally {\n fs.copyFileSync(backupPath, packageJsonPath);\n fs.rmSync(backupPath);\n }\n}\n\nfunction getNpmVersion(): string {\n return runCommand(NPM, ['--version']).trim();\n}\n\nfunction buildPackageJsonWithAllowScripts(original: string, scripts: string[]): string {\n const packageJson = JSON.parse(original);\n const allowed = Object.fromEntries(scripts.map(name => [name, true]));\n\n return JSON.stringify(\n { ...packageJson, allowScripts: { ...allowed, ...packageJson.allowScripts } },\n null,\n 2\n );\n}\n\nfunction supportsProjectAllowScriptsConfig(npmVersion: string): boolean {\n const [major, minor] = npmVersion.split('.').map(part => Number.parseInt(part, 10));\n if (!Number.isFinite(major)) {\n return false;\n }\n return major > 11 || (major === 11 && minor >= 16);\n}\n"],"names":["withProjectAllowScripts","NPM","scripts","fn","supportsProjectAllowScriptsConfig","getNpmVersion","packageJsonPath","path","join","npmGetLocalPrefix","backupPath","original","fs","readFileSync","copyFileSync","writeFileSync","buildPackageJsonWithAllowScripts","rmSync","runCommand","trim","packageJson","JSON","parse","allowed","Object","fromEntries","map","name","stringify","allowScripts","npmVersion","major","minor","split","part","Number","parseInt","isFinite"],"mappings":";;;;+BAMgBA;;;eAAAA;;;2DAND;6DACE;uBAC6B;;;;;;AAE9C,MAAMC,MAAM;AAEL,SAASD,wBAA2BE,OAAiB,EAAEC,EAAW;IACrE,IAAI,CAACC,kCAAkCC,kBAAkB;QACrD,OAAOF;IACX;IAEA,MAAMG,kBAAkBC,aAAI,CAACC,IAAI,CAACC,IAAAA,wBAAiB,KAAI;IACvD,MAAMC,aAAa,GAAGJ,gBAAgB,IAAI,CAAC;IAC3C,MAAMK,WAAWC,WAAE,CAACC,YAAY,CAACP,iBAAiB;IAClDM,WAAE,CAACE,YAAY,CAACR,iBAAiBI;IAEjC,IAAI;QACAE,WAAE,CAACG,aAAa,CAACT,iBAAiBU,iCAAiCL,UAAUT;QAC7E,OAAOC;IACX,SAAU;QACNS,WAAE,CAACE,YAAY,CAACJ,YAAYJ;QAC5BM,WAAE,CAACK,MAAM,CAACP;IACd;AACJ;AAEA,SAASL;IACL,OAAOa,IAAAA,iBAAU,EAACjB,KAAK;QAAC;KAAY,EAAEkB,IAAI;AAC9C;AAEA,SAASH,iCAAiCL,QAAgB,EAAET,OAAiB;IACzE,MAAMkB,cAAcC,KAAKC,KAAK,CAACX;IAC/B,MAAMY,UAAUC,OAAOC,WAAW,CAACvB,QAAQwB,GAAG,CAACC,CAAAA,OAAQ;YAACA;YAAM;SAAK;IAEnE,OAAON,KAAKO,SAAS,CACjB;QAAE,GAAGR,WAAW;QAAES,cAAc;YAAE,GAAGN,OAAO;YAAE,GAAGH,YAAYS,YAAY;QAAC;IAAE,GAC5E,MACA;AAER;AAEA,SAASzB,kCAAkC0B,UAAkB;IACzD,MAAM,CAACC,OAAOC,MAAM,GAAGF,WAAWG,KAAK,CAAC,KAAKP,GAAG,CAACQ,CAAAA,OAAQC,OAAOC,QAAQ,CAACF,MAAM;IAC/E,IAAI,CAACC,OAAOE,QAAQ,CAACN,QAAQ;QACzB,OAAO;IACX;IACA,OAAOA,QAAQ,MAAOA,UAAU,MAAMC,SAAS;AACnD"}
|
|
@@ -17,18 +17,18 @@ const AUDITED_SCRIPTS = [
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
name: 'cypress',
|
|
20
|
-
maximumVersion: '16.
|
|
20
|
+
maximumVersion: '16.4.0',
|
|
21
21
|
note: "Downloads Cypress's platform-specific test runner binary"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
name: 'msw',
|
|
25
|
-
maximumVersion: '3.0.
|
|
25
|
+
maximumVersion: '3.0.8',
|
|
26
26
|
note: 'No install script at all since 3.0.0; worker regeneration moved to the manual `msw init` CLI command instead of running automatically on install. Ceiling bumped anyway to prevent audit workflow from flagging old version'
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
name: 'nx',
|
|
30
|
-
maximumVersion: '24.0
|
|
31
|
-
note: 'Verifies native platform
|
|
30
|
+
maximumVersion: '24.1.0',
|
|
31
|
+
note: 'Verifies native platform and workspace trust, and updates the Nx Cloud client if the workspace uses Nx Cloud'
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
name: 'tree-sitter',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/audited-scripts.ts"],"sourcesContent":["export interface AuditedScript {\n name: string;\n action: 'allow' | 'ignore';\n maximumVersion?: string;\n note?: string;\n}\n\nexport const AUDITED_SCRIPTS: AuditedScript[] = [\n // Trusted to run their install scripts, up to the audited version.\n ...[\n {\n name: '@servicetitan/startup',\n note: 'Applies patch-package patches to installed dependencies',\n },\n {\n name: 'cypress',\n maximumVersion: '16.
|
|
1
|
+
{"version":3,"sources":["../../src/utils/audited-scripts.ts"],"sourcesContent":["export interface AuditedScript {\n name: string;\n action: 'allow' | 'ignore';\n maximumVersion?: string;\n note?: string;\n}\n\nexport const AUDITED_SCRIPTS: AuditedScript[] = [\n // Trusted to run their install scripts, up to the audited version.\n ...[\n {\n name: '@servicetitan/startup',\n note: 'Applies patch-package patches to installed dependencies',\n },\n {\n name: 'cypress',\n maximumVersion: '16.4.0',\n note: \"Downloads Cypress's platform-specific test runner binary\",\n },\n {\n name: 'msw',\n maximumVersion: '3.0.8',\n note: 'No install script at all since 3.0.0; worker regeneration moved to the manual `msw init` CLI command instead of running automatically on install. Ceiling bumped anyway to prevent audit workflow from flagging old version',\n },\n {\n name: 'nx',\n maximumVersion: '24.1.0',\n note: 'Verifies native platform and workspace trust, and updates the Nx Cloud client if the workspace uses Nx Cloud',\n },\n {\n name: 'tree-sitter',\n maximumVersion: '0.25.1',\n note: 'Installs a prebuilt native binary via node-gyp-build, compiling from source as a fallback',\n },\n ].map((entry: Omit<AuditedScript, 'action'>) => ({ ...entry, action: 'allow' as const })),\n\n // Have install scripts, but don't need them to function correctly.\n ...[\n {\n name: '@parcel/watcher',\n note: 'Installs platform-specific binary via optionalDependencies, install script is a legacy fallback',\n },\n {\n name: '@progress/kendo-licensing',\n note: 'Validates Kendo UI license key, not needed for functionality',\n },\n {\n name: '@scarf/scarf',\n note: 'Sends anonymous analytics/telemetry to Scarf, usage-tracking mechanism with no functional purpose',\n },\n {\n name: '@swc/core',\n note: 'Installs platform-specific binary via optionalDependencies, postinstall is a legacy fallback',\n },\n {\n name: '@tree-sitter-grammars/tree-sitter-yaml',\n note: 'Ships prebuilds for all supported targets via node-gyp-build, install script is a source-compile fallback',\n },\n {\n name: '@vaadin/vaadin-usage-statistics',\n note: \"Toggles Vaadin's development-time telemetry, no effect on functionality\",\n },\n {\n name: 'contentful',\n note: 'In 9.3.x, printed a message announcing that v10 was available, no functional purpose; no install script at all since 9.4.0',\n },\n {\n name: 'core-js-pure',\n note: 'Prints a donation/sponsorship banner to the console, no functional purpose',\n },\n {\n name: 'core-js',\n note: 'Prints a donation/sponsorship banner to the console, no functional purpose',\n },\n {\n name: 'es5-ext',\n note: 'Displays politically motivated message targeted at Russian developers, no effect on functionality',\n },\n {\n name: 'esbuild',\n note: 'Installs platform-specific binary via optionalDependencies, postinstall is a legacy fallback',\n },\n {\n name: 'tree-sitter-json',\n note: 'Ships prebuilds for all supported targets via node-gyp-build, install script is a source-compile fallback',\n },\n {\n name: 'unrs-resolver',\n note: 'Installs platform-specific binary via optionalDependencies, postinstall is a legacy fallback',\n },\n ].map((entry: Omit<AuditedScript, 'action'>) => ({ ...entry, action: 'ignore' as const })),\n];\n"],"names":["AUDITED_SCRIPTS","name","note","maximumVersion","map","entry","action"],"mappings":";;;;+BAOaA;;;eAAAA;;;AAAN,MAAMA,kBAAmC;IAC5C,mEAAmE;OAChE;QACC;YACIC,MAAM;YACNC,MAAM;QACV;QACA;YACID,MAAM;YACNE,gBAAgB;YAChBD,MAAM;QACV;QACA;YACID,MAAM;YACNE,gBAAgB;YAChBD,MAAM;QACV;QACA;YACID,MAAM;YACNE,gBAAgB;YAChBD,MAAM;QACV;QACA;YACID,MAAM;YACNE,gBAAgB;YAChBD,MAAM;QACV;KACH,CAACE,GAAG,CAAC,CAACC,QAA0C,CAAA;YAAE,GAAGA,KAAK;YAAEC,QAAQ;QAAiB,CAAA;IAEtF,mEAAmE;OAChE;QACC;YACIL,MAAM;YACNC,MAAM;QACV;QACA;YACID,MAAM;YACNC,MAAM;QACV;QACA;YACID,MAAM;YACNC,MAAM;QACV;QACA;YACID,MAAM;YACNC,MAAM;QACV;QACA;YACID,MAAM;YACNC,MAAM;QACV;QACA;YACID,MAAM;YACNC,MAAM;QACV;QACA;YACID,MAAM;YACNC,MAAM;QACV;QACA;YACID,MAAM;YACNC,MAAM;QACV;QACA;YACID,MAAM;YACNC,MAAM;QACV;QACA;YACID,MAAM;YACNC,MAAM;QACV;QACA;YACID,MAAM;YACNC,MAAM;QACV;QACA;YACID,MAAM;YACNC,MAAM;QACV;QACA;YACID,MAAM;YACNC,MAAM;QACV;KACH,CAACE,GAAG,CAAC,CAACC,QAA0C,CAAA;YAAE,GAAGA,KAAK;YAAEC,QAAQ;QAAkB,CAAA;CAC1F"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -8,7 +8,9 @@ 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';
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,qCAAqC,CAAC;AACpD,cAAc,eAAe,CAAC;AAC9B,cAAc,mCAAmC,CAAC;AAClD,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,MAAM,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kCAAkC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,qCAAqC,CAAC;AACpD,cAAc,eAAe,CAAC;AAC9B,cAAc,mCAAmC,CAAC;AAClD,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,MAAM,CAAC;AACrB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kCAAkC,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -12,6 +12,7 @@ _export_star(require("./get-workspace-root-package-json"), exports);
|
|
|
12
12
|
_export_star(require("./git"), exports);
|
|
13
13
|
_export_star(require("./npm"), exports);
|
|
14
14
|
_export_star(require("./os"), exports);
|
|
15
|
+
_export_star(require("./pnpm"), exports);
|
|
15
16
|
_export_star(require("./read-json"), exports);
|
|
16
17
|
_export_star(require("./version-compare"), exports);
|
|
17
18
|
_export_star(require("./warn-untrusted-install-scripts"), exports);
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './audited-scripts';\nexport * from './ci';\nexport * from './debug';\nexport * from './find-up';\nexport * from './get-packages-with-install-scripts';\nexport * from './get-version';\nexport * from './get-workspace-root-package-json';\nexport * from './git';\nexport * from './npm';\nexport * from './os';\nexport * from './read-json';\nexport * from './version-compare';\nexport * from './warn-untrusted-install-scripts';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './audited-scripts';\nexport * from './ci';\nexport * from './debug';\nexport * from './find-up';\nexport * from './get-packages-with-install-scripts';\nexport * from './get-version';\nexport * from './get-workspace-root-package-json';\nexport * from './git';\nexport * from './npm';\nexport * from './os';\nexport * from './pnpm';\nexport * from './read-json';\nexport type { Setting } from './setting';\nexport * from './version-compare';\nexport * from './warn-untrusted-install-scripts';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBAEA;qBACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/npm/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./npm-config"), exports);
|
|
6
|
+
_export_star(require("./npm-get-local-prefix"), exports);
|
|
7
|
+
_export_star(require("./npm-who-am-i"), exports);
|
|
8
|
+
function _export_star(from, to) {
|
|
9
|
+
Object.keys(from).forEach(function(k) {
|
|
10
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
11
|
+
Object.defineProperty(to, k, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function() {
|
|
14
|
+
return from[k];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return from;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/npm/index.ts"],"sourcesContent":["export * from './npm-config';\nexport * from './npm-get-local-prefix';\nexport * from './npm-who-am-i';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Setting } from '../setting';
|
|
2
|
+
export declare function npmGetUserConfig(key: string): string | undefined;
|
|
3
|
+
export declare function npmGetProjectConfig(key: string): string | undefined;
|
|
4
|
+
export declare function toNpmConfigSettings(settings: string[]): Setting[];
|
|
5
|
+
//# sourceMappingURL=npm-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm-config.d.ts","sourceRoot":"","sources":["../../../src/utils/npm/npm-config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAO1C,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,sBAE3C;AASD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,sBAY9C;AA+BD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAWjE"}
|
|
@@ -0,0 +1,112 @@
|
|
|
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 npmGetProjectConfig () {
|
|
13
|
+
return npmGetProjectConfig;
|
|
14
|
+
},
|
|
15
|
+
get npmGetUserConfig () {
|
|
16
|
+
return npmGetUserConfig;
|
|
17
|
+
},
|
|
18
|
+
get toNpmConfigSettings () {
|
|
19
|
+
return toNpmConfigSettings;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _nodeos = /*#__PURE__*/ _interop_require_default(require("node:os"));
|
|
23
|
+
const _findworkspaceroot = require("../find-workspace-root");
|
|
24
|
+
const _os = require("../os");
|
|
25
|
+
function _interop_require_default(obj) {
|
|
26
|
+
return obj && obj.__esModule ? obj : {
|
|
27
|
+
default: obj
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function npmGetUserConfig(key) {
|
|
31
|
+
return npmGetConfig(key, [
|
|
32
|
+
`--prefix=${getHomePrefix()}`
|
|
33
|
+
]);
|
|
34
|
+
}
|
|
35
|
+
function getHomePrefix() {
|
|
36
|
+
const home = _nodeos.default.homedir();
|
|
37
|
+
// On Windows, npm runs through a shell that splits unquoted arguments at spaces.
|
|
38
|
+
return process.platform === 'win32' ? `"${home}"` : home;
|
|
39
|
+
}
|
|
40
|
+
function npmGetProjectConfig(key) {
|
|
41
|
+
return npmGetConfig(key, [], {
|
|
42
|
+
// `npm config` fails in a workspace package
|
|
43
|
+
cwd: getProjectDir(),
|
|
44
|
+
env: {
|
|
45
|
+
// npm skips config files that don't exist
|
|
46
|
+
/* eslint-disable @typescript-eslint/naming-convention */ npm_config_globalconfig: (0, _os.getMissingConfigPath)(),
|
|
47
|
+
npm_config_userconfig: (0, _os.getMissingConfigPath)()
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function npmGetConfig(key, args, options = {}) {
|
|
52
|
+
const result = (0, _os.runCommand)('npm', [
|
|
53
|
+
'config',
|
|
54
|
+
'get',
|
|
55
|
+
key,
|
|
56
|
+
...args
|
|
57
|
+
], {
|
|
58
|
+
...options,
|
|
59
|
+
env: {
|
|
60
|
+
...options.env,
|
|
61
|
+
/*
|
|
62
|
+
* Environment variables override configuration files, for example
|
|
63
|
+
* when install itself runs via `npx --yes`.
|
|
64
|
+
*/ [`npm_config_${key.replaceAll('-', '_')}`]: undefined
|
|
65
|
+
},
|
|
66
|
+
stdio: [
|
|
67
|
+
'pipe',
|
|
68
|
+
'pipe',
|
|
69
|
+
'ignore'
|
|
70
|
+
]
|
|
71
|
+
}).trim();
|
|
72
|
+
// npm prints an empty string for unset array settings
|
|
73
|
+
return [
|
|
74
|
+
'',
|
|
75
|
+
'null',
|
|
76
|
+
'undefined'
|
|
77
|
+
].includes(result) ? undefined : result;
|
|
78
|
+
}
|
|
79
|
+
function getProjectDir() {
|
|
80
|
+
var _findWorkspaceRoot;
|
|
81
|
+
return (_findWorkspaceRoot = (0, _findworkspaceroot.findWorkspaceRoot)()) !== null && _findWorkspaceRoot !== void 0 ? _findWorkspaceRoot : process.cwd();
|
|
82
|
+
}
|
|
83
|
+
function npmHasConfig(key, location) {
|
|
84
|
+
const value = location === 'user' ? npmGetUserConfig(key) : npmGetProjectConfig(key);
|
|
85
|
+
return value !== undefined;
|
|
86
|
+
}
|
|
87
|
+
function toNpmConfigSettings(settings) {
|
|
88
|
+
return [
|
|
89
|
+
'project',
|
|
90
|
+
'user'
|
|
91
|
+
].flatMap((location)=>settings.map((setting)=>{
|
|
92
|
+
const [key] = setting.split('=');
|
|
93
|
+
return {
|
|
94
|
+
description: `${setting} in npm ${location} config`,
|
|
95
|
+
isSet: ()=>npmHasConfig(key, location),
|
|
96
|
+
set: ()=>npmSetConfig(setting, location)
|
|
97
|
+
};
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
function npmSetConfig(setting, location) {
|
|
101
|
+
(0, _os.runCommand)('npm', [
|
|
102
|
+
'config',
|
|
103
|
+
'set',
|
|
104
|
+
setting,
|
|
105
|
+
`--location=${location}`
|
|
106
|
+
], {
|
|
107
|
+
// `npm config` fails in a workspace package
|
|
108
|
+
cwd: getProjectDir()
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=npm-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/npm/npm-config.ts"],"sourcesContent":["import os from 'node:os';\nimport { findWorkspaceRoot } from '../find-workspace-root';\nimport { getMissingConfigPath, runCommand } from '../os';\nimport type { Setting } from '../setting';\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 return npmGetConfig(key, [`--prefix=${getHomePrefix()}`]);\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\nexport function npmGetProjectConfig(key: string) {\n return npmGetConfig(key, [], {\n // `npm config` fails in a workspace package\n cwd: getProjectDir(),\n env: {\n // npm skips config files that don't exist\n /* eslint-disable @typescript-eslint/naming-convention */\n npm_config_globalconfig: getMissingConfigPath(),\n npm_config_userconfig: getMissingConfigPath(),\n /* eslint-enable @typescript-eslint/naming-convention */\n },\n });\n}\n\nfunction npmGetConfig(key: string, args: string[], options: Parameters<typeof runCommand>[2] = {}) {\n const result = runCommand('npm', ['config', 'get', key, ...args], {\n ...options,\n env: {\n ...options.env,\n /*\n * Environment variables override configuration files, for example\n * when install itself runs via `npx --yes`.\n */\n [`npm_config_${key.replaceAll('-', '_')}`]: undefined,\n },\n stdio: ['pipe', 'pipe', 'ignore'],\n }).trim();\n\n // npm prints an empty string for unset array settings\n return ['', 'null', 'undefined'].includes(result) ? undefined : result;\n}\n\nfunction getProjectDir() {\n return findWorkspaceRoot() ?? process.cwd();\n}\n\ntype NpmConfigLocation = 'project' | 'user';\n\nfunction npmHasConfig(key: string, location: NpmConfigLocation) {\n const value = location === 'user' ? npmGetUserConfig(key) : npmGetProjectConfig(key);\n return value !== undefined;\n}\n\nexport function toNpmConfigSettings(settings: string[]): Setting[] {\n return (['project', 'user'] as const).flatMap(location =>\n settings.map(setting => {\n const [key] = setting.split('=');\n return {\n description: `${setting} in npm ${location} config`,\n isSet: () => npmHasConfig(key, location),\n set: () => npmSetConfig(setting, location),\n };\n })\n );\n}\n\nfunction npmSetConfig(setting: string, location: NpmConfigLocation) {\n runCommand('npm', ['config', 'set', setting, `--location=${location}`], {\n // `npm config` fails in a workspace package\n cwd: getProjectDir(),\n });\n}\n"],"names":["npmGetProjectConfig","npmGetUserConfig","toNpmConfigSettings","key","npmGetConfig","getHomePrefix","home","os","homedir","process","platform","cwd","getProjectDir","env","npm_config_globalconfig","getMissingConfigPath","npm_config_userconfig","args","options","result","runCommand","replaceAll","undefined","stdio","trim","includes","findWorkspaceRoot","npmHasConfig","location","value","settings","flatMap","map","setting","split","description","isSet","set","npmSetConfig"],"mappings":";;;;;;;;;;;QAqBgBA;eAAAA;;QAXAC;eAAAA;;QAsDAC;eAAAA;;;+DAhED;mCACmB;oBACe;;;;;;AAQ1C,SAASD,iBAAiBE,GAAW;IACxC,OAAOC,aAAaD,KAAK;QAAC,CAAC,SAAS,EAAEE,iBAAiB;KAAC;AAC5D;AAEA,SAASA;IACL,MAAMC,OAAOC,eAAE,CAACC,OAAO;IAEvB,iFAAiF;IACjF,OAAOC,QAAQC,QAAQ,KAAK,UAAU,CAAC,CAAC,EAAEJ,KAAK,CAAC,CAAC,GAAGA;AACxD;AAEO,SAASN,oBAAoBG,GAAW;IAC3C,OAAOC,aAAaD,KAAK,EAAE,EAAE;QACzB,4CAA4C;QAC5CQ,KAAKC;QACLC,KAAK;YACD,0CAA0C;YAC1C,uDAAuD,GACvDC,yBAAyBC,IAAAA,wBAAoB;YAC7CC,uBAAuBD,IAAAA,wBAAoB;QAE/C;IACJ;AACJ;AAEA,SAASX,aAAaD,GAAW,EAAEc,IAAc,EAAEC,UAA4C,CAAC,CAAC;IAC7F,MAAMC,SAASC,IAAAA,cAAU,EAAC,OAAO;QAAC;QAAU;QAAOjB;WAAQc;KAAK,EAAE;QAC9D,GAAGC,OAAO;QACVL,KAAK;YACD,GAAGK,QAAQL,GAAG;YACd;;;aAGC,GACD,CAAC,CAAC,WAAW,EAAEV,IAAIkB,UAAU,CAAC,KAAK,MAAM,CAAC,EAAEC;QAChD;QACAC,OAAO;YAAC;YAAQ;YAAQ;SAAS;IACrC,GAAGC,IAAI;IAEP,sDAAsD;IACtD,OAAO;QAAC;QAAI;QAAQ;KAAY,CAACC,QAAQ,CAACN,UAAUG,YAAYH;AACpE;AAEA,SAASP;QACEc;IAAP,QAAOA,qBAAAA,IAAAA,oCAAiB,iBAAjBA,gCAAAA,qBAAuBjB,QAAQE,GAAG;AAC7C;AAIA,SAASgB,aAAaxB,GAAW,EAAEyB,QAA2B;IAC1D,MAAMC,QAAQD,aAAa,SAAS3B,iBAAiBE,OAAOH,oBAAoBG;IAChF,OAAO0B,UAAUP;AACrB;AAEO,SAASpB,oBAAoB4B,QAAkB;IAClD,OAAO,AAAC;QAAC;QAAW;KAAO,CAAWC,OAAO,CAACH,CAAAA,WAC1CE,SAASE,GAAG,CAACC,CAAAA;YACT,MAAM,CAAC9B,IAAI,GAAG8B,QAAQC,KAAK,CAAC;YAC5B,OAAO;gBACHC,aAAa,GAAGF,QAAQ,QAAQ,EAAEL,SAAS,OAAO,CAAC;gBACnDQ,OAAO,IAAMT,aAAaxB,KAAKyB;gBAC/BS,KAAK,IAAMC,aAAaL,SAASL;YACrC;QACJ;AAER;AAEA,SAASU,aAAaL,OAAe,EAAEL,QAA2B;IAC9DR,IAAAA,cAAU,EAAC,OAAO;QAAC;QAAU;QAAOa;QAAS,CAAC,WAAW,EAAEL,UAAU;KAAC,EAAE;QACpE,4CAA4C;QAC5CjB,KAAKC;IACT;AACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RunCommandOptions } from '../os';
|
|
2
|
+
type NpmGetLocalPrefixOptions = Omit<RunCommandOptions, 'cwd'>;
|
|
3
|
+
/**
|
|
4
|
+
* Returns the project root npm resolves for the current directory, as printed by `npm prefix`:
|
|
5
|
+
* the nearest ancestor with package.json or node_modules, or the workspace root containing it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function npmGetLocalPrefix(options?: NpmGetLocalPrefixOptions): string;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=npm-get-local-prefix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm-get-local-prefix.d.ts","sourceRoot":"","sources":["../../../src/utils/npm/npm-get-local-prefix.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEtD,KAAK,wBAAwB,GAAG,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;AAK/D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,MAAM,CAE5E"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "npmGetLocalPrefix", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return npmGetLocalPrefix;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
+
const _findup = require("../find-up");
|
|
13
|
+
const _os = require("../os");
|
|
14
|
+
function _interop_require_default(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
// npm >=11.6 replaces secrets and UUIDs in everything it prints with this marker
|
|
20
|
+
const REDACTED = '***';
|
|
21
|
+
function npmGetLocalPrefix(options) {
|
|
22
|
+
return unredact((0, _os.runCommand)('npm', [
|
|
23
|
+
'prefix'
|
|
24
|
+
], options).trim());
|
|
25
|
+
}
|
|
26
|
+
/*
|
|
27
|
+
* npm redacts its output, so `npm prefix` prints *** in place of any UUID in the path.
|
|
28
|
+
* The prefix is always the current directory or one of its ancestors, so return the one
|
|
29
|
+
* that matches the output.
|
|
30
|
+
*/ function unredact(prefix) {
|
|
31
|
+
var _findUp;
|
|
32
|
+
if (!prefix.includes(REDACTED)) {
|
|
33
|
+
return prefix;
|
|
34
|
+
}
|
|
35
|
+
const expected = splitPath(prefix);
|
|
36
|
+
return (_findUp = (0, _findup.findUp)((directory)=>{
|
|
37
|
+
const actual = splitPath(directory);
|
|
38
|
+
const matches = actual.length === expected.length && actual.every((segment, i)=>matchesSegment(segment, expected[i]));
|
|
39
|
+
return matches ? directory : undefined;
|
|
40
|
+
})) !== null && _findUp !== void 0 ? _findUp : prefix;
|
|
41
|
+
}
|
|
42
|
+
function splitPath(value) {
|
|
43
|
+
// Windows paths are case-insensitive, and npm may print the drive letter in a different case
|
|
44
|
+
return (process.platform === 'win32' ? value.toLowerCase() : value).split(_path.default.sep);
|
|
45
|
+
}
|
|
46
|
+
// npm redacts a UUID even when it is only part of a segment, so *** stands for one or more characters
|
|
47
|
+
function matchesSegment(actual, expected) {
|
|
48
|
+
const index = expected.indexOf(REDACTED);
|
|
49
|
+
if (index === -1) {
|
|
50
|
+
return actual === expected;
|
|
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
|
+
}
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=npm-get-local-prefix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/npm/npm-get-local-prefix.ts"],"sourcesContent":["import path from 'path';\nimport { findUp } from '../find-up';\nimport { runCommand, RunCommandOptions } from '../os';\n\ntype NpmGetLocalPrefixOptions = Omit<RunCommandOptions, 'cwd'>;\n\n// npm >=11.6 replaces secrets and UUIDs in everything it prints with this marker\nconst REDACTED = '***';\n\n/**\n * Returns the project root npm resolves for the current directory, as printed by `npm prefix`:\n * the nearest ancestor with package.json or node_modules, or the workspace root containing it.\n */\nexport function npmGetLocalPrefix(options?: NpmGetLocalPrefixOptions): string {\n return unredact(runCommand('npm', ['prefix'], options).trim());\n}\n\n/*\n * npm redacts its output, so `npm prefix` prints *** in place of any UUID in the path.\n * The prefix is always the current directory or one of its ancestors, so return the one\n * that matches the output.\n */\nfunction unredact(prefix: string) {\n if (!prefix.includes(REDACTED)) {\n return prefix;\n }\n\n const expected = splitPath(prefix);\n return (\n findUp(directory => {\n const actual = splitPath(directory);\n const matches =\n actual.length === expected.length &&\n actual.every((segment, i) => matchesSegment(segment, expected[i]));\n return matches ? directory : undefined;\n }) ?? prefix\n );\n}\n\nfunction splitPath(value: string) {\n // Windows paths are case-insensitive, and npm may print the drive letter in a different case\n return (process.platform === 'win32' ? value.toLowerCase() : value).split(path.sep);\n}\n\n// npm redacts a UUID even when it is only part of a segment, so *** stands for one or more characters\nfunction matchesSegment(actual: string, expected: string) {\n const index = expected.indexOf(REDACTED);\n if (index === -1) {\n return actual === expected;\n }\n\n const head = expected.slice(0, index);\n const tail = expected.slice(index + REDACTED.length);\n if (!actual.startsWith(head)) {\n return false;\n }\n for (let end = head.length + 1; end <= actual.length; end++) {\n if (matchesSegment(actual.slice(end), tail)) {\n return true;\n }\n }\n return false;\n}\n"],"names":["npmGetLocalPrefix","REDACTED","options","unredact","runCommand","trim","prefix","findUp","includes","expected","splitPath","directory","actual","matches","length","every","segment","i","matchesSegment","undefined","value","process","platform","toLowerCase","split","path","sep","index","indexOf","head","slice","tail","startsWith","end"],"mappings":";;;;+BAagBA;;;eAAAA;;;6DAbC;wBACM;oBACuB;;;;;;AAI9C,iFAAiF;AACjF,MAAMC,WAAW;AAMV,SAASD,kBAAkBE,OAAkC;IAChE,OAAOC,SAASC,IAAAA,cAAU,EAAC,OAAO;QAAC;KAAS,EAAEF,SAASG,IAAI;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B,SAAS,CAAC,EAAE,QAAQ,EAAE,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,sBAcjE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "npmWhoAmI", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return npmWhoAmI;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _debug = require("../debug");
|
|
12
|
+
const _os = require("../os");
|
|
13
|
+
function npmWhoAmI({ registry } = {}) {
|
|
14
|
+
try {
|
|
15
|
+
const result = (0, _os.runCommand)('npm', [
|
|
16
|
+
'whoami',
|
|
17
|
+
...registry ? [
|
|
18
|
+
`--registry=${registry}`
|
|
19
|
+
] : []
|
|
20
|
+
], {
|
|
21
|
+
stdio: [
|
|
22
|
+
'pipe',
|
|
23
|
+
'pipe',
|
|
24
|
+
'ignore'
|
|
25
|
+
],
|
|
26
|
+
timeout: 10000
|
|
27
|
+
}).trim();
|
|
28
|
+
(0, _debug.debug)('install:whoami', {
|
|
29
|
+
result
|
|
30
|
+
});
|
|
31
|
+
return result.trim();
|
|
32
|
+
} catch (unused) {
|
|
33
|
+
// ignore
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=npm-who-am-i.js.map
|