@servicetitan/install 38.0.0 → 38.2.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.
Files changed (55) hide show
  1. package/dist/cli/install.js +5 -12
  2. package/dist/cli/install.js.map +1 -1
  3. package/dist/package-manager/get-package-manager.d.ts.map +1 -1
  4. package/dist/package-manager/get-package-manager.js +3 -29
  5. package/dist/package-manager/get-package-manager.js.map +1 -1
  6. package/dist/package-manager/npm-package-manager.d.ts.map +1 -1
  7. package/dist/package-manager/npm-package-manager.js +8 -9
  8. package/dist/package-manager/npm-package-manager.js.map +1 -1
  9. package/dist/package-manager/package-manager.js +4 -9
  10. package/dist/package-manager/package-manager.js.map +1 -1
  11. package/dist/package-manager/pnpm-package-manager.js +1 -3
  12. package/dist/package-manager/pnpm-package-manager.js.map +1 -1
  13. package/dist/package-manager/utils/index.d.ts +1 -1
  14. package/dist/package-manager/utils/index.d.ts.map +1 -1
  15. package/dist/package-manager/utils/index.js +1 -1
  16. package/dist/package-manager/utils/index.js.map +1 -1
  17. package/dist/package-manager/utils/log-allowed-scripts.d.ts +1 -1
  18. package/dist/package-manager/utils/log-allowed-scripts.d.ts.map +1 -1
  19. package/dist/package-manager/utils/log-allowed-scripts.js +6 -5
  20. package/dist/package-manager/utils/log-allowed-scripts.js.map +1 -1
  21. package/dist/package-manager/utils/resolve-allow-scripts.d.ts +1 -1
  22. package/dist/package-manager/utils/resolve-allow-scripts.d.ts.map +1 -1
  23. package/dist/package-manager/utils/resolve-allow-scripts.js +2 -2
  24. package/dist/package-manager/utils/resolve-allow-scripts.js.map +1 -1
  25. package/dist/package-manager/utils/uses-startup.d.ts +2 -0
  26. package/dist/package-manager/utils/uses-startup.d.ts.map +1 -0
  27. package/dist/package-manager/utils/uses-startup.js +20 -0
  28. package/dist/package-manager/utils/uses-startup.js.map +1 -0
  29. package/dist/utils/find-workspace-root.d.ts +2 -0
  30. package/dist/utils/find-workspace-root.d.ts.map +1 -0
  31. package/dist/utils/find-workspace-root.js +35 -0
  32. package/dist/utils/find-workspace-root.js.map +1 -0
  33. package/dist/utils/get-workspace-root-package-json.d.ts +10 -0
  34. package/dist/utils/get-workspace-root-package-json.d.ts.map +1 -0
  35. package/dist/utils/get-workspace-root-package-json.js +31 -0
  36. package/dist/utils/get-workspace-root-package-json.js.map +1 -0
  37. package/dist/utils/index.d.ts +1 -0
  38. package/dist/utils/index.d.ts.map +1 -1
  39. package/dist/utils/index.js +1 -0
  40. package/dist/utils/index.js.map +1 -1
  41. package/package.json +3 -3
  42. package/src/package-manager/get-package-manager.ts +2 -28
  43. package/src/package-manager/npm-package-manager.ts +8 -7
  44. package/src/package-manager/utils/index.ts +1 -1
  45. package/src/package-manager/utils/log-allowed-scripts.ts +8 -5
  46. package/src/package-manager/utils/resolve-allow-scripts.ts +2 -2
  47. package/src/package-manager/utils/uses-startup.ts +12 -0
  48. package/src/utils/find-workspace-root.ts +20 -0
  49. package/src/utils/get-workspace-root-package-json.ts +22 -0
  50. package/src/utils/index.ts +1 -0
  51. package/dist/package-manager/utils/should-ignore-scripts.d.ts +0 -3
  52. package/dist/package-manager/utils/should-ignore-scripts.d.ts.map +0 -1
  53. package/dist/package-manager/utils/should-ignore-scripts.js +0 -21
  54. package/dist/package-manager/utils/should-ignore-scripts.js.map +0 -1
  55. package/src/package-manager/utils/should-ignore-scripts.ts +0 -11
@@ -19,15 +19,12 @@ function _check_private_redeclaration(obj, privateCollection) {
19
19
  }
20
20
  }
21
21
  function _class_apply_descriptor_get(receiver, descriptor) {
22
- if (descriptor.get) {
23
- return descriptor.get.call(receiver);
24
- }
22
+ if (descriptor.get) return descriptor.get.call(receiver);
25
23
  return descriptor.value;
26
24
  }
27
25
  function _class_apply_descriptor_set(receiver, descriptor, value) {
28
- if (descriptor.set) {
29
- descriptor.set.call(receiver, value);
30
- } else {
26
+ if (descriptor.set) descriptor.set.call(receiver, value);
27
+ else {
31
28
  if (!descriptor.writable) {
32
29
  throw new TypeError("attempted to set read only private field");
33
30
  }
@@ -35,9 +32,7 @@ function _class_apply_descriptor_set(receiver, descriptor, value) {
35
32
  }
36
33
  }
37
34
  function _class_extract_field_descriptor(receiver, privateMap, action) {
38
- if (!privateMap.has(receiver)) {
39
- throw new TypeError("attempted to " + action + " private field on non-instance");
40
- }
35
+ if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
41
36
  return privateMap.get(receiver);
42
37
  }
43
38
  function _class_private_field_get(receiver, privateMap) {
@@ -61,9 +56,7 @@ function _define_property(obj, key, value) {
61
56
  configurable: true,
62
57
  writable: true
63
58
  });
64
- } else {
65
- obj[key] = value;
66
- }
59
+ } else obj[key] = value;
67
60
  return obj;
68
61
  }
69
62
  function _interop_require_default(obj) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/install.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport fs from 'fs';\nimport os from 'os';\nimport path from 'path';\nimport type { AllowScripts } from '../package-manager';\nimport { getPackageManager, PackageManager } from '../package-manager';\nimport { debug, getVersion, gitCloneRepo, isCI, npmWhoAmI, readJson, runCommand } from '../utils';\n\nconst REPO_NAME = 'frontend-dev-config';\nconst AUTH_TOKEN_KEY = '//registry.npmjs.org/:_authToken';\nconst AUTH_TOKEN_REGEX = /^\\/\\/registry\\.npmjs\\.org\\/:_authToken=\\s*(?<authToken>.+)/m;\nconst ENVIRONMENT_VARIABLE_REGEX = /\\${(?<environmentVariable>[^}]+)}/;\n\nexport interface Args {\n allowScripts?: AllowScripts;\n fix?: boolean;\n quiet?: boolean;\n token?: boolean;\n}\n\nexport class Install {\n args: Args;\n #packageManager: PackageManager | undefined;\n\n constructor(args: Args) {\n this.args = args;\n }\n\n execute() {\n this.log(`install cli v${getVersion()}`);\n\n const env = this.configureNpmToken();\n this.installPackages(env);\n }\n\n private configureNpmToken() {\n if (isCI() || this.args.fix || this.args.token === false) {\n return;\n }\n\n this.log('Configuring NPM token ...');\n\n if (this.args.token !== true) {\n if (npmWhoAmI() === 'st-team') {\n return;\n }\n }\n\n const token = this.fetchNpmToken();\n if (!token) {\n return;\n }\n\n runCommand('npm', ['config', 'set', `${AUTH_TOKEN_KEY}=${token}`]);\n\n if (!fs.existsSync('.npmrc')) {\n return;\n }\n\n const npmrc = fs.readFileSync('.npmrc', 'utf-8');\n const { authToken } = AUTH_TOKEN_REGEX.exec(npmrc)?.groups ?? {};\n debug({ authToken });\n if (!authToken) {\n return;\n }\n\n const { environmentVariable } = ENVIRONMENT_VARIABLE_REGEX.exec(authToken)?.groups ?? {};\n debug({ environmentVariable });\n if (environmentVariable) {\n return { [environmentVariable]: token };\n }\n\n runCommand('npm', ['config', 'delete', '--location=project', AUTH_TOKEN_KEY]);\n }\n\n private fetchNpmToken() {\n const tempDirPath = fs.mkdtempSync(path.join(os.tmpdir(), 'st-install-'));\n try {\n if (!gitCloneRepo({ destination: tempDirPath, name: REPO_NAME })) {\n throw new Error(`could not clone servicetitan/${REPO_NAME}`);\n }\n\n const npmJson = readJson(path.join(tempDirPath, '.npm.json'));\n debug('install:fetch-npm-token', { npmJson });\n\n if (!((npmJson && typeof npmJson === 'object') || Array.isArray(npmJson))) {\n throw new Error('.npm.json is not an object');\n }\n\n const { readOnlyToken: authToken } = npmJson;\n if (!authToken) {\n throw new Error('.npm.json does not contain auth token');\n }\n\n if (typeof authToken !== 'string') {\n throw new Error('.npm.json auth token is not a string');\n }\n\n return Buffer.from(authToken, 'base64').toString('utf-8');\n } catch (e) {\n console.warn(String(e));\n } finally {\n try {\n fs.rmSync(tempDirPath, { recursive: true, force: true });\n } catch {\n // ignore\n }\n }\n }\n\n private installPackages(env?: Record<string, string>) {\n if (this.args.token) {\n return;\n }\n\n this.log(`Running ${this.packageManager.command} install`);\n\n this.packageManager.installPackages(this.args, { env, stdio: 'inherit' });\n }\n\n private get packageManager() {\n return (this.#packageManager ??= getPackageManager());\n }\n\n private log(message: string) {\n if (!this.args.quiet) {\n console.log(message);\n }\n }\n}\n"],"names":["Install","REPO_NAME","AUTH_TOKEN_KEY","AUTH_TOKEN_REGEX","ENVIRONMENT_VARIABLE_REGEX","execute","log","getVersion","env","configureNpmToken","installPackages","isCI","args","fix","token","npmWhoAmI","fetchNpmToken","runCommand","fs","existsSync","npmrc","readFileSync","authToken","exec","groups","debug","environmentVariable","tempDirPath","mkdtempSync","path","join","os","tmpdir","gitCloneRepo","destination","name","Error","npmJson","readJson","Array","isArray","readOnlyToken","Buffer","from","toString","e","console","warn","String","rmSync","recursive","force","packageManager","command","stdio","getPackageManager","message","quiet"],"mappings":"AAAA,6BAA6B;;;;+BAoBhBA;;;eAAAA;;;2DAnBE;2DACA;6DACE;gCAEiC;uBACqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvF,MAAMC,YAAY;AAClB,MAAMC,iBAAiB;AACvB,MAAMC,mBAAmB;AACzB,MAAMC,6BAA6B;IAW/B;AAFG,MAAMJ;IAQTK,UAAU;QACN,IAAI,CAACC,GAAG,CAAC,CAAC,aAAa,EAAEC,IAAAA,iBAAU,KAAI;QAEvC,MAAMC,MAAM,IAAI,CAACC,iBAAiB;QAClC,IAAI,CAACC,eAAe,CAACF;IACzB;IAEQC,oBAAoB;;YAyBFN,wBAMUC;QA9BhC,IAAIO,IAAAA,WAAI,OAAM,IAAI,CAACC,IAAI,CAACC,GAAG,IAAI,IAAI,CAACD,IAAI,CAACE,KAAK,KAAK,OAAO;YACtD;QACJ;QAEA,IAAI,CAACR,GAAG,CAAC;QAET,IAAI,IAAI,CAACM,IAAI,CAACE,KAAK,KAAK,MAAM;YAC1B,IAAIC,IAAAA,gBAAS,QAAO,WAAW;gBAC3B;YACJ;QACJ;QAEA,MAAMD,QAAQ,IAAI,CAACE,aAAa;QAChC,IAAI,CAACF,OAAO;YACR;QACJ;QAEAG,IAAAA,iBAAU,EAAC,OAAO;YAAC;YAAU;YAAO,GAAGf,eAAe,CAAC,EAAEY,OAAO;SAAC;QAEjE,IAA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IAAI,OAAOd,cAAc,UAAU;gBAC/B,MAAM,IAAIc,MAAM;YACpB;YAEA,OAAOM,OAAOC,IAAI,CAACrB,WAAW,UAAUsB,QAAQ,CAAC;QACrD,EAAE,OAAOC,GAAG;YACRC,QAAQC,IAAI,CAACC,OAAOH;QACxB,SAAU;YACN,IAAI;gBACA3B,WAAE,CAAC+B,MAAM,CAACtB,aAAa;oBAAEuB,WAAW;oBAAMC,OAAO;gBAAK;YAC1D,EAAE,eAAM;YACJ,SAAS;YACb;QACJ;IACJ;IAEQzC,gBAAgBF,GAA4B,EAAE;QAClD,IAAI,IAAI,CAACI,IAAI,CAACE,KAAK,EAAE;YACjB;QACJ;QAEA,IAAI,CAACR,GAAG,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC8C,cAAc,CAACC,OAAO,CAAC,QAAQ,CAAC;QAEzD,IAAI,CAACD,cAAc,CAAC1C,eAAe,CAAC,IAAI,CAACE,IAAI,EAAE;YAAEJ;YAAK8C,OAAO;QAAU;IAC3E;IAEA,IAAYF,iBAAiB;;QACzB,sCAAa,uEAAL,IAAI,EAAC,iGAAoBG,IAAAA,iCAAiB;IACtD;IAEQjD,IAAIkD,OAAe,EAAE;QACzB,IAAI,CAAC,IAAI,CAAC5C,IAAI,CAAC6C,KAAK,EAAE;YAClBX,QAAQxC,GAAG,CAACkD;QAChB;IACJ;IAxGA,YAAY5C,IAAU,CAAE;QAHxBA,uBAAAA,QAAAA,KAAAA;QACA,gCAAA;;mBAAA,KAAA;;QAGI,IAAI,CAACA,IAAI,GAAGA;IAChB;AAuGJ"}
1
+ {"version":3,"sources":["../../src/cli/install.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport fs from 'fs';\nimport os from 'os';\nimport path from 'path';\nimport type { AllowScripts } from '../package-manager';\nimport { getPackageManager, PackageManager } from '../package-manager';\nimport { debug, getVersion, gitCloneRepo, isCI, npmWhoAmI, readJson, runCommand } from '../utils';\n\nconst REPO_NAME = 'frontend-dev-config';\nconst AUTH_TOKEN_KEY = '//registry.npmjs.org/:_authToken';\nconst AUTH_TOKEN_REGEX = /^\\/\\/registry\\.npmjs\\.org\\/:_authToken=\\s*(?<authToken>.+)/m;\nconst ENVIRONMENT_VARIABLE_REGEX = /\\${(?<environmentVariable>[^}]+)}/;\n\nexport interface Args {\n allowScripts?: AllowScripts;\n fix?: boolean;\n quiet?: boolean;\n token?: boolean;\n}\n\nexport class Install {\n args: Args;\n #packageManager: PackageManager | undefined;\n\n constructor(args: Args) {\n this.args = args;\n }\n\n execute() {\n this.log(`install cli v${getVersion()}`);\n\n const env = this.configureNpmToken();\n this.installPackages(env);\n }\n\n private configureNpmToken() {\n if (isCI() || this.args.fix || this.args.token === false) {\n return;\n }\n\n this.log('Configuring NPM token ...');\n\n if (this.args.token !== true) {\n if (npmWhoAmI() === 'st-team') {\n return;\n }\n }\n\n const token = this.fetchNpmToken();\n if (!token) {\n return;\n }\n\n runCommand('npm', ['config', 'set', `${AUTH_TOKEN_KEY}=${token}`]);\n\n if (!fs.existsSync('.npmrc')) {\n return;\n }\n\n const npmrc = fs.readFileSync('.npmrc', 'utf-8');\n const { authToken } = AUTH_TOKEN_REGEX.exec(npmrc)?.groups ?? {};\n debug({ authToken });\n if (!authToken) {\n return;\n }\n\n const { environmentVariable } = ENVIRONMENT_VARIABLE_REGEX.exec(authToken)?.groups ?? {};\n debug({ environmentVariable });\n if (environmentVariable) {\n return { [environmentVariable]: token };\n }\n\n runCommand('npm', ['config', 'delete', '--location=project', AUTH_TOKEN_KEY]);\n }\n\n private fetchNpmToken() {\n const tempDirPath = fs.mkdtempSync(path.join(os.tmpdir(), 'st-install-'));\n try {\n if (!gitCloneRepo({ destination: tempDirPath, name: REPO_NAME })) {\n throw new Error(`could not clone servicetitan/${REPO_NAME}`);\n }\n\n const npmJson = readJson(path.join(tempDirPath, '.npm.json'));\n debug('install:fetch-npm-token', { npmJson });\n\n if (!((npmJson && typeof npmJson === 'object') || Array.isArray(npmJson))) {\n throw new Error('.npm.json is not an object');\n }\n\n const { readOnlyToken: authToken } = npmJson;\n if (!authToken) {\n throw new Error('.npm.json does not contain auth token');\n }\n\n if (typeof authToken !== 'string') {\n throw new Error('.npm.json auth token is not a string');\n }\n\n return Buffer.from(authToken, 'base64').toString('utf-8');\n } catch (e) {\n console.warn(String(e));\n } finally {\n try {\n fs.rmSync(tempDirPath, { recursive: true, force: true });\n } catch {\n // ignore\n }\n }\n }\n\n private installPackages(env?: Record<string, string>) {\n if (this.args.token) {\n return;\n }\n\n this.log(`Running ${this.packageManager.command} install`);\n\n this.packageManager.installPackages(this.args, { env, stdio: 'inherit' });\n }\n\n private get packageManager() {\n return (this.#packageManager ??= getPackageManager());\n }\n\n private log(message: string) {\n if (!this.args.quiet) {\n console.log(message);\n }\n }\n}\n"],"names":["Install","REPO_NAME","AUTH_TOKEN_KEY","AUTH_TOKEN_REGEX","ENVIRONMENT_VARIABLE_REGEX","execute","log","getVersion","env","configureNpmToken","installPackages","isCI","args","fix","token","npmWhoAmI","fetchNpmToken","runCommand","fs","existsSync","npmrc","readFileSync","authToken","exec","groups","debug","environmentVariable","tempDirPath","mkdtempSync","path","join","os","tmpdir","gitCloneRepo","destination","name","Error","npmJson","readJson","Array","isArray","readOnlyToken","Buffer","from","toString","e","console","warn","String","rmSync","recursive","force","packageManager","command","stdio","getPackageManager","message","quiet"],"mappings":"AAAA,6BAA6B;;;;+BAoBhBA;;;eAAAA;;;2DAnBE;2DACA;6DACE;gCAEiC;uBACqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvF,MAAMC,YAAY;AAClB,MAAMC,iBAAiB;AACvB,MAAMC,mBAAmB;AACzB,MAAMC,6BAA6B;IAW/B;AAFG,MAAMJ;IAQTK,UAAU;QACN,IAAI,CAACC,GAAG,CAAC,CAAC,aAAa,EAAEC,IAAAA,iBAAU,KAAI;QAEvC,MAAMC,MAAM,IAAI,CAACC,iBAAiB;QAClC,IAAI,CAACC,eAAe,CA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zB,IAAI,CAAC,IAAI,CAAC5C,IAAI,CAAC6C,KAAK,EAAE;YAClBX,QAAQxC,GAAG,CAACkD;QAChB;IACJ;IAxGA,YAAY5C,IAAU,CAAE;QAHxBA,uBAAAA,QAAAA,KAAAA;QACA,gCAAA;;mBAAA,KAAA;;QAGI,IAAI,CAACA,IAAI,GAAGA;IAChB;AAuGJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-package-manager.d.ts","sourceRoot":"","sources":["../../src/package-manager/get-package-manager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,wBAAgB,iBAAiB,IAAI,cAAc,CAUlD"}
1
+ {"version":3,"file":"get-package-manager.d.ts","sourceRoot":"","sources":["../../src/package-manager/get-package-manager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,wBAAgB,iBAAiB,IAAI,cAAc,CAUlD"}
@@ -8,18 +8,13 @@ Object.defineProperty(exports, "getPackageManager", {
8
8
  return getPackageManager;
9
9
  }
10
10
  });
11
- const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
- const _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
11
  const _utils = require("../utils");
14
12
  const _npmpackagemanager = require("./npm-package-manager");
15
13
  const _pnpmpackagemanager = require("./pnpm-package-manager");
16
- function _interop_require_default(obj) {
17
- return obj && obj.__esModule ? obj : {
18
- default: obj
19
- };
20
- }
21
14
  function getPackageManager() {
22
- const name = readPackageManagerName();
15
+ var _ref;
16
+ var _getWorkspaceRootPackageJson_cli, _getWorkspaceRootPackageJson;
17
+ const name = (_ref = (_getWorkspaceRootPackageJson = (0, _utils.getWorkspaceRootPackageJson)()) === null || _getWorkspaceRootPackageJson === void 0 ? void 0 : (_getWorkspaceRootPackageJson_cli = _getWorkspaceRootPackageJson.cli) === null || _getWorkspaceRootPackageJson_cli === void 0 ? void 0 : _getWorkspaceRootPackageJson_cli.packageManager) !== null && _ref !== void 0 ? _ref : 'npm';
23
18
  switch(name){
24
19
  case 'npm':
25
20
  return new _npmpackagemanager.NpmPackageManager();
@@ -29,26 +24,5 @@ function getPackageManager() {
29
24
  throw new Error(`Unsupported package manager: ${name}`);
30
25
  }
31
26
  }
32
- function readPackageManagerName() {
33
- var _findWorkspaceRoot, _ref;
34
- var _packageJson_cli;
35
- const root = (_findWorkspaceRoot = findWorkspaceRoot()) !== null && _findWorkspaceRoot !== void 0 ? _findWorkspaceRoot : _path.default.resolve('./');
36
- const packageJson = (0, _utils.readJsonSafe)(_path.default.join(root, 'package.json'));
37
- return (_ref = packageJson === null || packageJson === void 0 ? void 0 : (_packageJson_cli = packageJson.cli) === null || _packageJson_cli === void 0 ? void 0 : _packageJson_cli.packageManager) !== null && _ref !== void 0 ? _ref : 'npm';
38
- }
39
- function findWorkspaceRoot() {
40
- return (0, _utils.findUp)((directory)=>{
41
- var _readJsonSafe, _readJsonSafe1;
42
- if ((_readJsonSafe = (0, _utils.readJsonSafe)(_path.default.join(directory, 'package.json'))) === null || _readJsonSafe === void 0 ? void 0 : _readJsonSafe.workspaces) {
43
- return directory;
44
- }
45
- if (_fs.default.existsSync(_path.default.join(directory, 'pnpm-workspace.yaml'))) {
46
- return directory;
47
- }
48
- if ((_readJsonSafe1 = (0, _utils.readJsonSafe)(_path.default.join(directory, 'lerna.json'))) === null || _readJsonSafe1 === void 0 ? void 0 : _readJsonSafe1.packages) {
49
- return directory;
50
- }
51
- });
52
- }
53
27
 
54
28
  //# sourceMappingURL=get-package-manager.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/package-manager/get-package-manager.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { findUp, readJsonSafe } from '../utils';\nimport { NpmPackageManager } from './npm-package-manager';\nimport type { PackageManager } from './package-manager';\nimport { PnpmPackageManager } from './pnpm-package-manager';\n\nexport function getPackageManager(): PackageManager {\n const name = readPackageManagerName();\n switch (name) {\n case 'npm':\n return new NpmPackageManager();\n case 'pnpm':\n return new PnpmPackageManager();\n default:\n throw new Error(`Unsupported package manager: ${name}`);\n }\n}\n\nfunction readPackageManagerName(): string {\n const root = findWorkspaceRoot() ?? path.resolve('./');\n const packageJson = readJsonSafe<{ cli?: { packageManager?: string } }>(\n path.join(root, 'package.json')\n );\n return packageJson?.cli?.packageManager ?? 'npm';\n}\n\nfunction findWorkspaceRoot(): string | undefined {\n return findUp(directory => {\n if (\n readJsonSafe<{ workspaces?: unknown }>(path.join(directory, 'package.json'))?.workspaces\n ) {\n return directory;\n }\n if (fs.existsSync(path.join(directory, 'pnpm-workspace.yaml'))) {\n return directory;\n }\n if (readJsonSafe<{ packages?: unknown }>(path.join(directory, 'lerna.json'))?.packages) {\n return directory;\n }\n });\n}\n"],"names":["getPackageManager","name","readPackageManagerName","NpmPackageManager","PnpmPackageManager","Error","findWorkspaceRoot","packageJson","root","path","resolve","readJsonSafe","join","cli","packageManager","findUp","directory","workspaces","fs","existsSync","packages"],"mappings":";;;;+BAOgBA;;;eAAAA;;;2DAPD;6DACE;uBACoB;mCACH;oCAEC;;;;;;AAE5B,SAASA;IACZ,MAAMC,OAAOC;IACb,OAAQD;QACJ,KAAK;YACD,OAAO,IAAIE,oCAAiB;QAChC,KAAK;YACD,OAAO,IAAIC,sCAAkB;QACjC;YACI,MAAM,IAAIC,MAAM,CAAC,6BAA6B,EAAEJ,MAAM;IAC9D;AACJ;AAEA,SAASC;QACQI;QAINC;IAJP,MAAMC,QAAOF,qBAAAA,iCAAAA,gCAAAA,qBAAuBG,aAAI,CAACC,OAAO,CAAC;IACjD,MAAMH,cAAcI,IAAAA,mBAAY,EAC5BF,aAAI,CAACG,IAAI,CAACJ,MAAM;IAEpB,eAAOD,wBAAAA,mCAAAA,mBAAAA,YAAaM,GAAG,cAAhBN,uCAAAA,iBAAkBO,cAAc,uCAAI;AAC/C;AAEA,SAASR;IACL,OAAOS,IAAAA,aAAM,EAACC,CAAAA;YAENL,eAOAA;QARJ,KACIA,gBAAAA,IAAAA,mBAAY,EAA2BF,aAAI,CAACG,IAAI,CAACI,WAAW,8BAA5DL,oCAAAA,cAA8EM,UAAU,EAC1F;YACE,OAAOD;QACX;QACA,IAAIE,WAAE,CAACC,UAAU,CAACV,aAAI,CAACG,IAAI,CAACI,WAAW,yBAAyB;YAC5D,OAAOA;QACX;QACA,KAAIL,iBAAAA,IAAAA,mBAAY,EAAyBF,aAAI,CAACG,IAAI,CAACI,WAAW,4BAA1DL,qCAAAA,eAA0ES,QAAQ,EAAE;YACpF,OAAOJ;QACX;IACJ;AACJ"}
1
+ {"version":3,"sources":["../../src/package-manager/get-package-manager.ts"],"sourcesContent":["import { getWorkspaceRootPackageJson } from '../utils';\nimport { NpmPackageManager } from './npm-package-manager';\nimport type { PackageManager } from './package-manager';\nimport { PnpmPackageManager } from './pnpm-package-manager';\n\nexport function getPackageManager(): PackageManager {\n const name = getWorkspaceRootPackageJson()?.cli?.packageManager ?? 'npm';\n switch (name) {\n case 'npm':\n return new NpmPackageManager();\n case 'pnpm':\n return new PnpmPackageManager();\n default:\n throw new Error(`Unsupported package manager: ${name}`);\n }\n}\n"],"names":["getPackageManager","getWorkspaceRootPackageJson","name","cli","packageManager","NpmPackageManager","PnpmPackageManager","Error"],"mappings":";;;;+BAKgBA;;;eAAAA;;;uBAL4B;mCACV;oCAEC;AAE5B,SAASA;;QACCC,kCAAAA;IAAb,MAAMC,gBAAOD,+BAAAA,IAAAA,kCAA2B,iBAA3BA,oDAAAA,mCAAAA,6BAA+BE,GAAG,cAAlCF,uDAAAA,iCAAoCG,cAAc,uCAAI;IACnE,OAAQF;QACJ,KAAK;YACD,OAAO,IAAIG,oCAAiB;QAChC,KAAK;YACD,OAAO,IAAIC,sCAAkB;QACjC;YACI,MAAM,IAAIC,MAAM,CAAC,6BAA6B,EAAEL,MAAM;IAC9D;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"npm-package-manager.d.ts","sourceRoot":"","sources":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20
  configurable: true,
21
21
  writable: true
22
22
  });
23
- } else {
24
- obj[key] = value;
25
- }
23
+ } else obj[key] = value;
26
24
  return obj;
27
25
  }
28
26
  function _interop_require_default(obj) {
@@ -56,16 +54,17 @@ class NpmPackageManager extends _packagemanager.PackageManager {
56
54
  }
57
55
  installPackages(args = {}, options) {
58
56
  var _args_allowScripts;
59
- const allowScripts = (0, _utils1.resolveAllowScripts)((_args_allowScripts = args.allowScripts) !== null && _args_allowScripts !== void 0 ? _args_allowScripts : []);
57
+ const builtInAllowlist = (0, _utils1.usesStartup)() ? _utils1.DEFAULT_ALLOWED_SCRIPTS : [];
58
+ const allowScripts = (0, _utils1.resolveAllowScripts)((_args_allowScripts = args.allowScripts) !== null && _args_allowScripts !== void 0 ? _args_allowScripts : [], builtInAllowlist);
60
59
  if (!args.quiet) {
61
- (0, _utils1.logAllowedScripts)(allowScripts);
60
+ (0, _utils1.logAllowedScripts)(allowScripts, builtInAllowlist);
62
61
  }
63
62
  (0, _utils.runCommand)(this.command, [
64
63
  (0, _utils.isCI)() ? 'ci' : 'i',
65
64
  '--audit=false',
66
65
  '--fund=false',
67
66
  '--legacy-peer-deps',
68
- ...(0, _utils1.shouldIgnoreScripts)(allowScripts) ? [
67
+ ...allowScripts !== true ? [
69
68
  '--ignore-scripts'
70
69
  ] : [],
71
70
  ...args.fix ? [
@@ -78,10 +77,10 @@ class NpmPackageManager extends _packagemanager.PackageManager {
78
77
  return;
79
78
  }
80
79
  /*
81
- * Rebuild applies when allowScripts is an explicit list:
80
+ * Rebuild applies when allowScripts is a non-empty explicit list:
82
81
  * `true` means npm install already ran every script, `false`
83
82
  * means the user opted out.
84
- */ if (Array.isArray(allowScripts)) {
83
+ */ if (Array.isArray(allowScripts) && allowScripts.length > 0) {
85
84
  this.runRebuild(allowScripts);
86
85
  }
87
86
  /*
@@ -89,7 +88,7 @@ class NpmPackageManager extends _packagemanager.PackageManager {
89
88
  * scripts they should add to --allow-scripts. Skip when the user
90
89
  * explicitly opted out (`false`); they made an informed choice.
91
90
  */ if (allowScripts !== false) {
92
- (0, _utils.warnUntrustedInstallScripts)(Array.isArray(allowScripts) ? allowScripts : _utils1.DEFAULT_ALLOWED_SCRIPTS);
91
+ (0, _utils.warnUntrustedInstallScripts)(Array.isArray(allowScripts) ? allowScripts : builtInAllowlist);
93
92
  }
94
93
  /*
95
94
  * When allowScripts is `true`, npm already ran project postinstall.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/package-manager/npm-package-manager.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport fs from 'fs';\nimport { isCI, runCommand, warnUntrustedInstallScripts } from '../utils';\nimport type { DeclaredVersionQuery, InstallArgs, ResolvedVersionQuery } from './package-manager';\nimport { PackageManager } from './package-manager';\nimport {\n DEFAULT_ALLOWED_SCRIPTS,\n logAllowedScripts,\n resolveAllowScripts,\n shouldIgnoreScripts,\n} from './utils';\n\ninterface NpmLockFileEntry {\n version?: string;\n resolved?: string;\n link?: boolean;\n dependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n}\n\nexport interface NpmLockFile {\n packages?: Record<string, NpmLockFileEntry>;\n}\n\nexport class NpmPackageManager extends PackageManager<NpmLockFile> {\n readonly command = 'npm';\n readonly lockFileName = 'package-lock.json';\n\n clearCache() {\n runCommand(this.command, ['cache', 'clear', '--force']);\n }\n\n getDeclaredVersion({\n workspacePackage,\n declaredBy,\n dependency,\n }: DeclaredVersionQuery): string | undefined {\n const entry = this.findEntry({ workspacePackage, package: declaredBy });\n return entry?.dependencies?.[dependency] ?? entry?.peerDependencies?.[dependency];\n }\n\n getResolvedVersion({ workspacePackage, dependency }: ResolvedVersionQuery): string | undefined {\n return this.findEntry({ workspacePackage, package: dependency })?.version;\n }\n\n installPackages(args: InstallArgs = {}, options?: Parameters<typeof runCommand>[2]) {\n const allowScripts = resolveAllowScripts(args.allowScripts ?? []);\n\n if (!args.quiet) {\n logAllowedScripts(allowScripts);\n }\n\n runCommand(\n this.command,\n [\n isCI() ? 'ci' : 'i',\n '--audit=false',\n '--fund=false',\n '--legacy-peer-deps',\n ...(shouldIgnoreScripts(allowScripts) ? ['--ignore-scripts'] : []),\n ...(args.fix ? ['--package-lock-only', '--prefer-dedupe'] : []),\n ],\n options\n );\n\n try {\n if (args.fix) {\n return;\n }\n /*\n * Rebuild applies when allowScripts is an explicit list:\n * `true` means npm install already ran every script, `false`\n * means the user opted out.\n */\n if (Array.isArray(allowScripts)) {\n this.runRebuild(allowScripts);\n }\n /*\n * Warn against the effective allowlist so teams can see which\n * scripts they should add to --allow-scripts. Skip when the user\n * explicitly opted out (`false`); they made an informed choice.\n */\n if (allowScripts !== false) {\n warnUntrustedInstallScripts(\n Array.isArray(allowScripts) ? allowScripts : DEFAULT_ALLOWED_SCRIPTS\n );\n }\n /*\n * When allowScripts is `true`, npm already ran project postinstall.\n * In other cases, we run it manually. Note, `false` only ignores\n * package scripts, the project postinstall is always trusted.\n */\n if (allowScripts !== true) {\n this.runProjectPostinstall(options);\n }\n } finally {\n this.reset();\n }\n }\n\n protected parseLockFile(): NpmLockFile | undefined {\n const lockFilePath = this.getLockFilePath();\n if (!lockFilePath) {\n return undefined;\n }\n try {\n return JSON.parse(fs.readFileSync(lockFilePath, 'utf-8'));\n } catch {\n return undefined;\n }\n }\n\n /**\n * Looks up a lockfile entry for the given workspace package, falling back\n * to the hoisted root entry. `workspacePackage` is the package's relative\n * path from the repo root; the empty string `''` denotes the root\n * workspace package itself, matching npm's own lockfile key convention.\n * Follows link entries to the resolved workspace package, so callers see\n * the workspace package's own metadata rather than the symlink stub.\n */\n private findEntry({\n workspacePackage,\n package: packageName,\n }: {\n workspacePackage: string;\n package: string;\n }): NpmLockFileEntry | undefined {\n const packages = this.getLockFile()?.packages;\n const entry =\n packages?.[`${workspacePackage}/node_modules/${packageName}`] ??\n packages?.[`node_modules/${packageName}`];\n if (entry?.link && entry.resolved) {\n return packages?.[entry.resolved];\n }\n return entry;\n }\n\n private runRebuild(scripts: string[]) {\n try {\n runCommand(this.command, ['rebuild', ...scripts]);\n } catch {\n console.error(`Failed to run allowed scripts: ${scripts.join(', ')}`);\n process.exitCode = 1;\n }\n }\n\n private runProjectPostinstall(options?: Parameters<typeof runCommand>[2]) {\n try {\n runCommand(this.command, ['run', 'postinstall', '--if-present'], options);\n } catch {\n process.exitCode = 1;\n }\n }\n}\n"],"names":["NpmPackageManager","PackageManager","clearCache","runCommand","command","getDeclaredVersion","workspacePackage","declaredBy","dependency","entry","findEntry","package","dependencies","peerDependencies","getResolvedVersion","version","installPackages","args","options","allowScripts","resolveAllowScripts","quiet","logAllowedScripts","isCI","shouldIgnoreScripts","fix","Array","isArray","runRebuild","warnUntrustedInstallScripts","DEFAULT_ALLOWED_SCRIPTS","runProjectPostinstall","reset","parseLockFile","lockFilePath","getLockFilePath","undefined","JSON","parse","fs","readFileSync","packageName","packages","getLockFile","link","resolved","scripts","console","error","join","process","exitCode","lockFileName"],"mappings":"AAAA,6BAA6B;;;;+BAwBhBA;;;eAAAA;;;2DAvBE;uBAC+C;gCAE/B;wBAMxB;;;;;;;;;;;;;;;;;;;AAcA,MAAMA,0BAA0BC,8BAAc;IAIjDC,aAAa;QACTC,IAAAA,iBAAU,EAAC,IAAI,CAACC,OAAO,EAAE;YAAC;YAAS;YAAS;SAAU;IAC1D;IAEAC,mBAAmB,EACfC,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACS,EAAsB;;YAElCC,qBAAqCA;QAD5C,MAAMA,QAAQ,IAAI,CAACC,SAAS,CAAC;YAAEJ;YAAkBK,SAASJ;QAAW;QACrE,eAAOE,kBAAAA,6BAAAA,sBAAAA,MAAOG,YAAY,cAAnBH,0CAAAA,mBAAqB,CAACD,WAAW,uCAAIC,kBAAAA,6BAAAA,0BAAAA,MAAOI,gBAAgB,cAAvBJ,8CAAAA,uBAAyB,CAACD,WAAW;IACrF;IAEAM,mBAAmB,EAAER,gBAAgB,EAAEE,UAAU,EAAwB,EAAsB;YACpF;QAAP,QAAO,kBAAA,IAAI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,WAAW,EAIvB,EAAgC;;YACZ;QAAjB,MAAMC,YAAW,oBAAA,IAAI,CAACC,WAAW,gBAAhB,wCAAA,kBAAoBD,QAAQ;QAC7C,MAAMjC,gBACFiC,qBAAAA,+BAAAA,QAAU,CAAC,GAAGpC,iBAAiB,cAAc,EAAEmC,aAAa,CAAC,uCAC7DC,qBAAAA,+BAAAA,QAAU,CAAC,CAAC,aAAa,EAAED,aAAa,CAAC;QAC7C,IAAIhC,CAAAA,kBAAAA,4BAAAA,MAAOmC,IAAI,KAAInC,MAAMoC,QAAQ,EAAE;YAC/B,OAAOH,qBAAAA,+BAAAA,QAAU,CAACjC,MAAMoC,QAAQ,CAAC;QACrC;QACA,OAAOpC;IACX;IAEQmB,WAAWkB,OAAiB,EAAE;QAClC,IAAI;YACA3C,IAAAA,iBAAU,EAAC,IAAI,CAACC,OAAO,EAAE;gBAAC;mBAAc0C;aAAQ;QACpD,EAAE,eAAM;YACJC,QAAQC,KAAK,CAAC,CAAC,+BAA+B,EAAEF,QAAQG,IAAI,CAAC,OAAO;YACpEC,QAAQC,QAAQ,GAAG;QACvB;IACJ;IAEQpB,sBAAsBb,OAA0C,EAAE;QACtE,IAAI;YACAf,IAAAA,iBAAU,EAAC,IAAI,CAACC,OAAO,EAAE;gBAAC;gBAAO;gBAAe;aAAe,EAAEc;QACrE,EAAE,eAAM;YACJgC,QAAQC,QAAQ,GAAG;QACvB;IACJ;;QAhIG,gBACH,uBAAS/C,WAAU,QACnB,uBAASgD,gBAAe;;AA+H5B"}
1
+ {"version":3,"sources":["../../src/package-manager/npm-package-manager.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport fs from 'fs';\nimport { isCI, runCommand, warnUntrustedInstallScripts } from '../utils';\nimport type { DeclaredVersionQuery, InstallArgs, ResolvedVersionQuery } from './package-manager';\nimport { PackageManager } from './package-manager';\nimport {\n DEFAULT_ALLOWED_SCRIPTS,\n logAllowedScripts,\n resolveAllowScripts,\n usesStartup,\n} from './utils';\n\ninterface NpmLockFileEntry {\n version?: string;\n resolved?: string;\n link?: boolean;\n dependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n}\n\nexport interface NpmLockFile {\n packages?: Record<string, NpmLockFileEntry>;\n}\n\nexport class NpmPackageManager extends PackageManager<NpmLockFile> {\n readonly command = 'npm';\n readonly lockFileName = 'package-lock.json';\n\n clearCache() {\n runCommand(this.command, ['cache', 'clear', '--force']);\n }\n\n getDeclaredVersion({\n workspacePackage,\n declaredBy,\n dependency,\n }: DeclaredVersionQuery): string | undefined {\n const entry = this.findEntry({ workspacePackage, package: declaredBy });\n return entry?.dependencies?.[dependency] ?? entry?.peerDependencies?.[dependency];\n }\n\n getResolvedVersion({ workspacePackage, dependency }: ResolvedVersionQuery): string | undefined {\n return this.findEntry({ workspacePackage, package: dependency })?.version;\n }\n\n installPackages(args: InstallArgs = {}, options?: Parameters<typeof runCommand>[2]) {\n const builtInAllowlist = usesStartup() ? DEFAULT_ALLOWED_SCRIPTS : [];\n const allowScripts = resolveAllowScripts(args.allowScripts ?? [], builtInAllowlist);\n\n if (!args.quiet) {\n logAllowedScripts(allowScripts, builtInAllowlist);\n }\n\n runCommand(\n this.command,\n [\n isCI() ? 'ci' : 'i',\n '--audit=false',\n '--fund=false',\n '--legacy-peer-deps',\n ...(allowScripts !== true ? ['--ignore-scripts'] : []),\n ...(args.fix ? ['--package-lock-only', '--prefer-dedupe'] : []),\n ],\n options\n );\n\n try {\n if (args.fix) {\n return;\n }\n /*\n * Rebuild applies when allowScripts is a non-empty explicit list:\n * `true` means npm install already ran every script, `false`\n * means the user opted out.\n */\n if (Array.isArray(allowScripts) && allowScripts.length > 0) {\n this.runRebuild(allowScripts);\n }\n /*\n * Warn against the effective allowlist so teams can see which\n * scripts they should add to --allow-scripts. Skip when the user\n * explicitly opted out (`false`); they made an informed choice.\n */\n if (allowScripts !== false) {\n warnUntrustedInstallScripts(\n Array.isArray(allowScripts) ? allowScripts : builtInAllowlist\n );\n }\n /*\n * When allowScripts is `true`, npm already ran project postinstall.\n * In other cases, we run it manually. Note, `false` only ignores\n * package scripts, the project postinstall is always trusted.\n */\n if (allowScripts !== true) {\n this.runProjectPostinstall(options);\n }\n } finally {\n this.reset();\n }\n }\n\n protected parseLockFile(): NpmLockFile | undefined {\n const lockFilePath = this.getLockFilePath();\n if (!lockFilePath) {\n return undefined;\n }\n try {\n return JSON.parse(fs.readFileSync(lockFilePath, 'utf-8'));\n } catch {\n return undefined;\n }\n }\n\n /**\n * Looks up a lockfile entry for the given workspace package, falling back\n * to the hoisted root entry. `workspacePackage` is the package's relative\n * path from the repo root; the empty string `''` denotes the root\n * workspace package itself, matching npm's own lockfile key convention.\n * Follows link entries to the resolved workspace package, so callers see\n * the workspace package's own metadata rather than the symlink stub.\n */\n private findEntry({\n workspacePackage,\n package: packageName,\n }: {\n workspacePackage: string;\n package: string;\n }): NpmLockFileEntry | undefined {\n const packages = this.getLockFile()?.packages;\n const entry =\n packages?.[`${workspacePackage}/node_modules/${packageName}`] ??\n packages?.[`node_modules/${packageName}`];\n if (entry?.link && entry.resolved) {\n return packages?.[entry.resolved];\n }\n return entry;\n }\n\n private runRebuild(scripts: string[]) {\n try {\n runCommand(this.command, ['rebuild', ...scripts]);\n } catch {\n console.error(`Failed to run allowed scripts: ${scripts.join(', ')}`);\n process.exitCode = 1;\n }\n }\n\n private runProjectPostinstall(options?: Parameters<typeof runCommand>[2]) {\n try {\n runCommand(this.command, ['run', 'postinstall', '--if-present'], options);\n } catch {\n process.exitCode = 1;\n }\n }\n}\n"],"names":["NpmPackageManager","PackageManager","clearCache","runCommand","command","getDeclaredVersion","workspacePackage","declaredBy","dependency","entry","findEntry","package","dependencies","peerDependencies","getResolvedVersion","version","installPackages","args","options","builtInAllowlist","usesStartup","DEFAULT_ALLOWED_SCRIPTS","allowScripts","resolveAllowScripts","quiet","logAllowedScripts","isCI","fix","Array","isArray","length","runRebuild","warnUntrustedInstallScripts","runProjectPostinstall","reset","parseLockFile","lockFilePath","getLockFilePath","undefined","JSON","parse","fs","readFileSync","packageName","packages","getLockFile","link","resolved","scripts","console","error","join","process","exitCode","lockFileName"],"mappings":"AAAA,6BAA6B;;;;+BAwBhBA;;;eAAAA;;;2DAvBE;uBAC+C;gCAE/B;wBAMxB;;;;;;;;;;;;;;;;;AAcA,MAAMA,0BAA0BC,8BAAc;IAIjDC,aAAa;QACTC,IAAAA,iBAAU,EAAC,IAAI,CAACC,OAAO,EAAE;YAAC;YAAS;YAAS;SAAU;IAC1D;IAEAC,mBAAmB,EACfC,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACS,EAAsB;;YAElCC,qBAAqCA;QAD5C,MAAMA,QAAQ,IAAI,CAACC,SAAS,CAAC;YAAEJ;YAAkBK,SAASJ;QAAW;QACrE,eAAOE,kBAAAA,6BAAAA,sBAAAA,MAAOG,YAAY,cAAnBH,0CAAAA,mBAAqB,CAACD,WAAW,uCAAIC,kBAAAA,6BAAAA,0BAAAA,MAAOI,gBAAgB,cAAvBJ,8CAAAA,uBAAyB,CAACD,WAAW;IACrF;IAEAM,mBAAmB,EAAER,gBAAgB,EAAEE,UAAU,EAAwB,EAAsB;YACpF;QAAP,QAAO,kBAAA,IAAI,CAACE,SAAS,CAAC;YAAEJ;YAAkBK,SAASH;QAAW,gBAAvD,sCAAA,gBAA2DO,OAAO;IAC7E;IAEAC,gBAAgBC,OAAoB,CAAC,CAAC,EAAEC,OAA0C,EAAE;YAEvCD;QADzC,MAAME,mBAAmBC,IAAAA,mBAAW,MAAKC,+BAAuB,GAAG,EAAE;QACrE,MAAMC,eAAeC,IAAAA,2BAAmB,GAACN,qBAAAA,KAAKK,YAAY,cAAjBL,gCAAAA,qBAAqB,EAAE,EAAEE;QAElE,IAAI,CAACF,KAAKO,KAAK,EAAE;YACbC,IAAAA,yBAAiB,EAACH,cAAcH;QACpC;QAEAhB,IAAAA,iBAAU,EACN,IAAI,CAACC,OAAO,EACZ;YACIsB,IAAAA,WAAI,MAAK,OAAO;YAChB;YACA;YACA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Q,CAAC;QACrC;QACA,OAAOtC;IACX;IAEQsB,WAAWiB,OAAiB,EAAE;QAClC,IAAI;YACA7C,IAAAA,iBAAU,EAAC,IAAI,CAACC,OAAO,EAAE;gBAAC;mBAAc4C;aAAQ;QACpD,EAAE,eAAM;YACJC,QAAQC,KAAK,CAAC,CAAC,+BAA+B,EAAEF,QAAQG,IAAI,CAAC,OAAO;YACpEC,QAAQC,QAAQ,GAAG;QACvB;IACJ;IAEQpB,sBAAsBf,OAA0C,EAAE;QACtE,IAAI;YACAf,IAAAA,iBAAU,EAAC,IAAI,CAACC,OAAO,EAAE;gBAAC;gBAAO;gBAAe;aAAe,EAAEc;QACrE,EAAE,eAAM;YACJkC,QAAQC,QAAQ,GAAG;QACvB;IACJ;;QAjIG,gBACH,uBAASjD,WAAU,QACnB,uBAASkD,gBAAe;;AAgI5B"}
@@ -17,15 +17,12 @@ function _check_private_redeclaration(obj, privateCollection) {
17
17
  }
18
18
  }
19
19
  function _class_apply_descriptor_get(receiver, descriptor) {
20
- if (descriptor.get) {
21
- return descriptor.get.call(receiver);
22
- }
20
+ if (descriptor.get) return descriptor.get.call(receiver);
23
21
  return descriptor.value;
24
22
  }
25
23
  function _class_apply_descriptor_set(receiver, descriptor, value) {
26
- if (descriptor.set) {
27
- descriptor.set.call(receiver, value);
28
- } else {
24
+ if (descriptor.set) descriptor.set.call(receiver, value);
25
+ else {
29
26
  if (!descriptor.writable) {
30
27
  throw new TypeError("attempted to set read only private field");
31
28
  }
@@ -33,9 +30,7 @@ function _class_apply_descriptor_set(receiver, descriptor, value) {
33
30
  }
34
31
  }
35
32
  function _class_extract_field_descriptor(receiver, privateMap, action) {
36
- if (!privateMap.has(receiver)) {
37
- throw new TypeError("attempted to " + action + " private field on non-instance");
38
- }
33
+ if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
39
34
  return privateMap.get(receiver);
40
35
  }
41
36
  function _class_private_field_get(receiver, privateMap) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/package-manager/package-manager.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'node:path';\nimport { findUp, runCommand } from '../utils';\n\nexport type AllowScripts = true | false | string[];\n\nexport interface InstallArgs {\n allowScripts?: AllowScripts;\n fix?: boolean;\n quiet?: boolean;\n}\n\nexport interface DeclaredVersionQuery {\n workspacePackage: string;\n declaredBy: string;\n dependency: string;\n}\n\nexport interface ResolvedVersionQuery {\n workspacePackage: string;\n dependency: string;\n}\n\nexport abstract class PackageManager<LockFile = unknown> {\n abstract readonly command: string;\n abstract readonly lockFileName: string;\n\n #lockFile: LockFile | undefined;\n #lockFileLoaded = false;\n #lockFilePath: string | undefined;\n #lockFilePathLoaded = false;\n\n hasValidLockFile(): boolean {\n return this.getLockFile() !== undefined;\n }\n\n getLockFilePath(): string | undefined {\n if (!this.#lockFilePathLoaded) {\n this.#lockFilePath = findUp(directory => {\n const candidate = path.join(directory, this.lockFileName);\n return fs.existsSync(candidate) ? candidate : undefined;\n });\n this.#lockFilePathLoaded = true;\n }\n return this.#lockFilePath;\n }\n\n /**\n * Returns the lockfile key for a package given its absolute or\n * cwd-relative directory. Both npm and pnpm key their lockfile entries\n * by the package's path relative to the workspace root.\n */\n getWorkspacePackage(packageDir = process.cwd()): string {\n const lockFilePath = this.getLockFilePath();\n if (!lockFilePath) {\n return this.rootWorkspacePackage;\n }\n const relative = path\n .relative(path.dirname(lockFilePath), path.resolve(packageDir))\n .split(path.sep)\n .join('/');\n return relative === '' ? this.rootWorkspacePackage : relative;\n }\n\n protected getLockFile(): LockFile | undefined {\n if (!this.#lockFileLoaded) {\n this.#lockFile = this.parseLockFile();\n this.#lockFileLoaded = true;\n }\n return this.#lockFile;\n }\n\n protected reset() {\n this.#lockFile = undefined;\n this.#lockFileLoaded = false;\n this.#lockFilePath = undefined;\n this.#lockFilePathLoaded = false;\n }\n\n protected get rootWorkspacePackage(): string {\n return '';\n }\n\n abstract clearCache(): void;\n abstract getDeclaredVersion(query: DeclaredVersionQuery): string | undefined;\n abstract getResolvedVersion(query: ResolvedVersionQuery): string | undefined;\n abstract installPackages(args?: InstallArgs, options?: Parameters<typeof runCommand>[2]): void;\n\n protected abstract parseLockFile(): LockFile | undefined;\n}\n"],"names":["PackageManager","hasValidLockFile","getLockFile","undefined","getLockFilePath","findUp","directory","candidate","path","join","lockFileName","fs","existsSync","getWorkspacePackage","packageDir","process","cwd","lockFilePath","rootWorkspacePackage","relative","dirname","resolve","split","sep","parseLockFile","reset"],"mappings":";;;;+BAuBsBA;;;eAAAA;;;2DAvBP;iEACE;uBACkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAyB/B,yCACA,+CACA,6CACA;AAPG,MAAeA;IASlBC,mBAA4B;QACxB,OAAO,IAAI,CAACC,WAAW,OAAOC;IAClC;IAEAC,kBAAsC;QAClC,IAAI,0BAAC,IAAI,EAAC,sBAAqB;2CACtB,eAAgBC,IAAAA,aAAM,EAACC,CAAAA;gBACxB,MAAMC,YAAYC,iBAAI,CAACC,IAAI,CAACH,WAAW,IAAI,CAACI,YAAY;gBACxD,OAAOC,WAAE,CAACC,UAAU,CAACL,aAAaA,YAAYJ;YAClD;2CACK,qBAAsB;QAC/B;QACA,gCAAO,IAAI,EAAC;IAChB;IAEA;;;;KAIC,GACDU,oBAAoBC,aAAaC,QAAQC,GAAG,EAAE,EAAU;QACpD,MAAMC,eAAe,IAAI,CAACb,eAAe;QACzC,IAAI,CAACa,cAAc;YACf,OAAO,IAAI,CAACC,oBAAoB;QACpC;QACA,MAAMC,WAAWX,iBAAI,CAChBW,QAAQ,CAACX,iBAAI,CAACY,OAAO,CAACH,eAAeT,iBAAI,CAACa,OAAO,CAACP,aAClDQ,KAAK,CAACd,iBAAI,CAACe,GAAG,EACdd,IAAI,CAAC;QACV,OAAOU,aAAa,KAAK,IAAI,CAACD,oBAAoB,GAAGC;IACzD;IAEUjB,cAAoC;QAC1C,IAAI,0BAAC,IAAI,EAAC,kBAAiB;2CAClB,WAAY,IAAI,CAACsB,aAAa;2CAC9B,iBAAkB;QAC3B;QACA,gCAAO,IAAI,EAAC;IAChB;IAEUC,QAAQ;uCACT,WAAYtB;uCACZ,iBAAkB;uCAClB,eAAgBA;uCAChB,qBAAsB;IAC/B;IAEA,IAAce,uBAA+B;QACzC,OAAO;IACX;;QAtDA,gCAAA;;mBAAA,KAAA;;QACA,gCAAA;;mBAAkB;;QAClB,gCAAA;;mBAAA,KAAA;;QACA,gCAAA;;mBAAsB;;;AA2D1B"}
1
+ {"version":3,"sources":["../../src/package-manager/package-manager.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'node:path';\nimport { findUp, runCommand } from '../utils';\n\nexport type AllowScripts = true | false | string[];\n\nexport interface InstallArgs {\n allowScripts?: AllowScripts;\n fix?: boolean;\n quiet?: boolean;\n}\n\nexport interface DeclaredVersionQuery {\n workspacePackage: string;\n declaredBy: string;\n dependency: string;\n}\n\nexport interface ResolvedVersionQuery {\n workspacePackage: string;\n dependency: string;\n}\n\nexport abstract class PackageManager<LockFile = unknown> {\n abstract readonly command: string;\n abstract readonly lockFileName: string;\n\n #lockFile: LockFile | undefined;\n #lockFileLoaded = false;\n #lockFilePath: string | undefined;\n #lockFilePathLoaded = false;\n\n hasValidLockFile(): boolean {\n return this.getLockFile() !== undefined;\n }\n\n getLockFilePath(): string | undefined {\n if (!this.#lockFilePathLoaded) {\n this.#lockFilePath = findUp(directory => {\n const candidate = path.join(directory, this.lockFileName);\n return fs.existsSync(candidate) ? candidate : undefined;\n });\n this.#lockFilePathLoaded = true;\n }\n return this.#lockFilePath;\n }\n\n /**\n * Returns the lockfile key for a package given its absolute or\n * cwd-relative directory. Both npm and pnpm key their lockfile entries\n * by the package's path relative to the workspace root.\n */\n getWorkspacePackage(packageDir = process.cwd()): string {\n const lockFilePath = this.getLockFilePath();\n if (!lockFilePath) {\n return this.rootWorkspacePackage;\n }\n const relative = path\n .relative(path.dirname(lockFilePath), path.resolve(packageDir))\n .split(path.sep)\n .join('/');\n return relative === '' ? this.rootWorkspacePackage : relative;\n }\n\n protected getLockFile(): LockFile | undefined {\n if (!this.#lockFileLoaded) {\n this.#lockFile = this.parseLockFile();\n this.#lockFileLoaded = true;\n }\n return this.#lockFile;\n }\n\n protected reset() {\n this.#lockFile = undefined;\n this.#lockFileLoaded = false;\n this.#lockFilePath = undefined;\n this.#lockFilePathLoaded = false;\n }\n\n protected get rootWorkspacePackage(): string {\n return '';\n }\n\n abstract clearCache(): void;\n abstract getDeclaredVersion(query: DeclaredVersionQuery): string | undefined;\n abstract getResolvedVersion(query: ResolvedVersionQuery): string | undefined;\n abstract installPackages(args?: InstallArgs, options?: Parameters<typeof runCommand>[2]): void;\n\n protected abstract parseLockFile(): LockFile | undefined;\n}\n"],"names":["PackageManager","hasValidLockFile","getLockFile","undefined","getLockFilePath","findUp","directory","candidate","path","join","lockFileName","fs","existsSync","getWorkspacePackage","packageDir","process","cwd","lockFilePath","rootWorkspacePackage","relative","dirname","resolve","split","sep","parseLockFile","reset"],"mappings":";;;;+BAuBsBA;;;eAAAA;;;2DAvBP;iEACE;uBACkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAyB/B,yCACA,+CACA,6CACA;AAPG,MAAeA;IASlBC,mBAA4B;QACxB,OAAO,IAAI,CAACC,WAAW,OAAOC;IAClC;IAEAC,kBAAsC;QAClC,IAAI,0BAAC,IAAI,EAAC,sBAAqB;2CACtB,eAAgBC,IAAAA,aAAM,EAACC,CAAAA;gBACxB,MAAMC,YAAYC,iBAAI,CAACC,IAAI,CAACH,WAAW,IAAI,CAACI,YAAY;gBACxD,OAAOC,WAAE,CAACC,UAAU,CAACL,aAAaA,YAAYJ;YAClD;2CACK,qBAAsB;QAC/B;QACA,gCAAO,IAAI,EAAC;IAChB;IAEA;;;;KAIC,GACDU,oBAAoBC,aAAaC,QAAQC,GAAG,EAAE,EAAU;QACpD,MAAMC,eAAe,IAAI,CAACb,eAAe;QACzC,IAAI,CAACa,cAAc;YACf,OAAO,IAAI,CAACC,oBAAoB;QACpC;QACA,MAAMC,WAAWX,iBAAI,CAChBW,QAAQ,CAACX,iBAAI,CAACY,OAAO,CAACH,eAAeT,iBAAI,CAACa,OAAO,CAACP,aAClDQ,KAAK,CAACd,iBAAI,CAACe,GAAG,EACdd,IAAI,CAAC;QACV,OAAOU,aAAa,KAAK,IAAI,CAACD,oBAAoB,GAAGC;IACzD;IAEUjB,cAAoC;QAC1C,IAAI,0BAAC,IAAI,EAAC,kBAAiB;2CAClB,WAAY,IAAI,CAACsB,aAAa;2CAC9B,iBAAkB;QAC3B;QACA,gCAAO,IAAI,EAAC;IAChB;IAEUC,QAAQ;uCACT,WAAYtB;uCACZ,iBAAkB;uCAClB,eAAgBA;uCAChB,qBAAsB;IAC/B;IAEA,IAAce,uBAA+B;QACzC,OAAO;IACX;;QAtDA,gCAAA;;mBAAA,KAAA;;QACA,gCAAA;;mBAAkB;;QAClB,gCAAA;;mBAAA,KAAA;;QACA,gCAAA;;mBAAsB;;;AA2D1B"}
@@ -19,9 +19,7 @@ function _define_property(obj, key, value) {
19
19
  configurable: true,
20
20
  writable: true
21
21
  });
22
- } else {
23
- obj[key] = value;
24
- }
22
+ } else obj[key] = value;
25
23
  return obj;
26
24
  }
27
25
  function _interop_require_default(obj) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/package-manager/pnpm-package-manager.ts"],"sourcesContent":["import fs from 'fs';\nimport { isCI, runCommand } from '../utils';\nimport type { DeclaredVersionQuery, InstallArgs, ResolvedVersionQuery } from './package-manager';\nimport { PackageManager } from './package-manager';\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 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\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","PackageManager","rootWorkspacePackage","clearCache","runCommand","command","getDeclaredVersion","workspacePackage","declaredBy","dependency","snapshot","declaredByVersion","resolveVersion","undefined","getLockFile","snapshots","dependencies","peerDependencies","getResolvedVersion","installPackages","args","options","isCI","fix","reset","parseLockFile","lockFilePath","getLockFilePath","yaml","require","load","fs","readFileSync","importer","importers","entry","devDependencies","optionalDependencies","stripPeerDependencySuffix","version","lockFileName","split"],"mappings":";;;;+BA0BaA;;;eAAAA;;;2DA1BE;uBACkB;gCAEF;;;;;;;;;;;;;;;;;;;AAuBxB,MAAMA,2BAA2BC,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,mBAAmB,EAAEX,gBAAgB,EAAEE,UAAU,EAAwB,EAAsB;QAC3F,OAAO,IAAI,CAACG,cAAc,CAACL,kBAAkBE;IACjD;IAEAU,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E,KAAK,CAAC,IAAI,CAAC,EAAE;AAChC"}
1
+ {"version":3,"sources":["../../src/package-manager/pnpm-package-manager.ts"],"sourcesContent":["import fs from 'fs';\nimport { isCI, runCommand } from '../utils';\nimport type { DeclaredVersionQuery, InstallArgs, ResolvedVersionQuery } from './package-manager';\nimport { PackageManager } from './package-manager';\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 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\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","PackageManager","rootWorkspacePackage","clearCache","runCommand","command","getDeclaredVersion","workspacePackage","declaredBy","dependency","snapshot","declaredByVersion","resolveVersion","undefined","getLockFile","snapshots","dependencies","peerDependencies","getResolvedVersion","installPackages","args","options","isCI","fix","reset","parseLockFile","lockFilePath","getLockFilePath","yaml","require","load","fs","readFileSync","importer","importers","entry","devDependencies","optionalDependencies","stripPeerDependencySuffix","version","lockFileName","split"],"mappings":";;;;+BA0BaA;;;eAAAA;;;2DA1BE;uBACkB;gCAEF;;;;;;;;;;;;;;;;;AAuBxB,MAAMA,2BAA2BC,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,M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AAA,gCAAAA,yBAAAA,SAAUjB,YAAY,cAAtBiB,6CAAAA,sBAAwB,CAACxB,WAAW,yCACpCwB,qBAAAA,gCAAAA,4BAAAA,SAAUG,eAAe,cAAzBH,gDAAAA,yBAA2B,CAACxB,WAAW,cADvCwB,kBAAAA,OAEAA,qBAAAA,gCAAAA,iCAAAA,SAAUI,oBAAoB,cAA9BJ,qDAAAA,8BAAgC,CAACxB,WAAW;QAChD,OAAO0B,QAAQG,0BAA0BH,MAAMI,OAAO,IAAI1B;IAC9D;;QArEG,gBACH,uBAASR,WAAU,SACnB,uBAASmC,gBAAe;;AAoE5B;AAEA,SAASF,0BAA0BC,OAAe;IAC9C,0DAA0D;IAC1D,OAAOA,QAAQE,KAAK,CAAC,IAAI,CAAC,EAAE;AAChC"}
@@ -1,5 +1,5 @@
1
1
  export * from './log-allowed-scripts';
2
2
  export * from './parse-allow-scripts';
3
3
  export * from './resolve-allow-scripts';
4
- export * from './should-ignore-scripts';
4
+ export * from './uses-startup';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/package-manager/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/package-manager/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC"}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  _export_star(require("./log-allowed-scripts"), exports);
6
6
  _export_star(require("./parse-allow-scripts"), exports);
7
7
  _export_star(require("./resolve-allow-scripts"), exports);
8
- _export_star(require("./should-ignore-scripts"), exports);
8
+ _export_star(require("./uses-startup"), exports);
9
9
  function _export_star(from, to) {
10
10
  Object.keys(from).forEach(function(k) {
11
11
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/package-manager/utils/index.ts"],"sourcesContent":["export * from './log-allowed-scripts';\nexport * from './parse-allow-scripts';\nexport * from './resolve-allow-scripts';\nexport * from './should-ignore-scripts';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA"}
1
+ {"version":3,"sources":["../../../src/package-manager/utils/index.ts"],"sourcesContent":["export * from './log-allowed-scripts';\nexport * from './parse-allow-scripts';\nexport * from './resolve-allow-scripts';\nexport * from './uses-startup';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA"}
@@ -1,3 +1,3 @@
1
1
  import type { AllowScripts } from '../package-manager';
2
- export declare function logAllowedScripts(allowScripts: AllowScripts): void;
2
+ export declare function logAllowedScripts(allowScripts: AllowScripts, builtInAllowlist: string[]): void;
3
3
  //# sourceMappingURL=log-allowed-scripts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"log-allowed-scripts.d.ts","sourceRoot":"","sources":["../../../src/package-manager/utils/log-allowed-scripts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,YAAY,QAY3D"}
1
+ {"version":3,"file":"log-allowed-scripts.d.ts","sourceRoot":"","sources":["../../../src/package-manager/utils/log-allowed-scripts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAgBvF"}
@@ -8,8 +8,7 @@ Object.defineProperty(exports, "logAllowedScripts", {
8
8
  return logAllowedScripts;
9
9
  }
10
10
  });
11
- const _resolveallowscripts = require("./resolve-allow-scripts");
12
- function logAllowedScripts(allowScripts) {
11
+ function logAllowedScripts(allowScripts, builtInAllowlist) {
13
12
  if (allowScripts === true) {
14
13
  console.log('Allowing all install scripts');
15
14
  return;
@@ -17,10 +16,12 @@ function logAllowedScripts(allowScripts) {
17
16
  if (allowScripts === false) {
18
17
  return;
19
18
  }
20
- const extras = allowScripts.filter((s)=>!_resolveallowscripts.DEFAULT_ALLOWED_SCRIPTS.includes(s));
21
- if (extras.length) {
22
- console.log(`Allowing additional install scripts: ${extras.join(', ')}`);
19
+ const extras = allowScripts.filter((s)=>!builtInAllowlist.includes(s));
20
+ if (!extras.length) {
21
+ return;
23
22
  }
23
+ const label = builtInAllowlist.length ? 'Allowing additional install scripts' : 'Allowing install scripts';
24
+ console.log(`${label}: ${extras.join(', ')}`);
24
25
  }
25
26
 
26
27
  //# sourceMappingURL=log-allowed-scripts.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/package-manager/utils/log-allowed-scripts.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport type { AllowScripts } from '../package-manager';\nimport { DEFAULT_ALLOWED_SCRIPTS } from './resolve-allow-scripts';\n\nexport function logAllowedScripts(allowScripts: AllowScripts) {\n if (allowScripts === true) {\n console.log('Allowing all install scripts');\n return;\n }\n if (allowScripts === false) {\n return;\n }\n const extras = allowScripts.filter(s => !DEFAULT_ALLOWED_SCRIPTS.includes(s));\n if (extras.length) {\n console.log(`Allowing additional install scripts: ${extras.join(', ')}`);\n }\n}\n"],"names":["logAllowedScripts","allowScripts","console","log","extras","filter","s","DEFAULT_ALLOWED_SCRIPTS","includes","length","join"],"mappings":"AAAA,6BAA6B;;;;+BAIbA;;;eAAAA;;;qCAFwB;AAEjC,SAASA,kBAAkBC,YAA0B;IACxD,IAAIA,iBAAiB,MAAM;QACvBC,QAAQC,GAAG,CAAC;QACZ;IACJ;IACA,IAAIF,iBAAiB,OAAO;QACxB;IACJ;IACA,MAAMG,SAASH,aAAaI,MAAM,CAACC,CAAAA,IAAK,CAACC,4CAAuB,CAACC,QAAQ,CAACF;IAC1E,IAAIF,OAAOK,MAAM,EAAE;QACfP,QAAQC,GAAG,CAAC,CAAC,qCAAqC,EAAEC,OAAOM,IAAI,CAAC,OAAO;IAC3E;AACJ"}
1
+ {"version":3,"sources":["../../../src/package-manager/utils/log-allowed-scripts.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport type { AllowScripts } from '../package-manager';\n\nexport function logAllowedScripts(allowScripts: AllowScripts, builtInAllowlist: string[]) {\n if (allowScripts === true) {\n console.log('Allowing all install scripts');\n return;\n }\n if (allowScripts === false) {\n return;\n }\n const extras = allowScripts.filter(s => !builtInAllowlist.includes(s));\n if (!extras.length) {\n return;\n }\n const label = builtInAllowlist.length\n ? 'Allowing additional install scripts'\n : 'Allowing install scripts';\n console.log(`${label}: ${extras.join(', ')}`);\n}\n"],"names":["logAllowedScripts","allowScripts","builtInAllowlist","console","log","extras","filter","s","includes","length","label","join"],"mappings":"AAAA,6BAA6B;;;;+BAGbA;;;eAAAA;;;AAAT,SAASA,kBAAkBC,YAA0B,EAAEC,gBAA0B;IACpF,IAAID,iBAAiB,MAAM;QACvBE,QAAQC,GAAG,CAAC;QACZ;IACJ;IACA,IAAIH,iBAAiB,OAAO;QACxB;IACJ;IACA,MAAMI,SAASJ,aAAaK,MAAM,CAACC,CAAAA,IAAK,CAACL,iBAAiBM,QAAQ,CAACD;IACnE,IAAI,CAACF,OAAOI,MAAM,EAAE;QAChB;IACJ;IACA,MAAMC,QAAQR,iBAAiBO,MAAM,GAC/B,wCACA;IACNN,QAAQC,GAAG,CAAC,GAAGM,MAAM,EAAE,EAAEL,OAAOM,IAAI,CAAC,OAAO;AAChD"}
@@ -1,4 +1,4 @@
1
1
  import type { AllowScripts } from '../package-manager';
2
2
  export declare const DEFAULT_ALLOWED_SCRIPTS: string[];
3
- export declare function resolveAllowScripts(value: AllowScripts): AllowScripts;
3
+ export declare function resolveAllowScripts(value: AllowScripts, builtInAllowlist: string[]): AllowScripts;
4
4
  //# sourceMappingURL=resolve-allow-scripts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-allow-scripts.d.ts","sourceRoot":"","sources":["../../../src/package-manager/utils/resolve-allow-scripts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,eAAO,MAAM,uBAAuB,UAMnC,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CAKrE"}
1
+ {"version":3,"file":"resolve-allow-scripts.d.ts","sourceRoot":"","sources":["../../../src/package-manager/utils/resolve-allow-scripts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,eAAO,MAAM,uBAAuB,UAMnC,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,YAAY,CAKjG"}
@@ -24,12 +24,12 @@ const DEFAULT_ALLOWED_SCRIPTS = [
24
24
  'nx',
25
25
  'tree-sitter'
26
26
  ];
27
- function resolveAllowScripts(value) {
27
+ function resolveAllowScripts(value, builtInAllowlist) {
28
28
  if (value === true || value === false) {
29
29
  return value;
30
30
  }
31
31
  return [
32
- ...DEFAULT_ALLOWED_SCRIPTS,
32
+ ...builtInAllowlist,
33
33
  ...(0, _parseallowscripts.parseAllowScripts)(value)
34
34
  ];
35
35
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/package-manager/utils/resolve-allow-scripts.ts"],"sourcesContent":["import type { AllowScripts } from '../package-manager';\nimport { parseAllowScripts } from './parse-allow-scripts';\n\nexport const DEFAULT_ALLOWED_SCRIPTS = [\n '@servicetitan/startup',\n 'cypress',\n 'msw',\n 'nx',\n 'tree-sitter',\n];\n\nexport function resolveAllowScripts(value: AllowScripts): AllowScripts {\n if (value === true || value === false) {\n return value;\n }\n return [...DEFAULT_ALLOWED_SCRIPTS, ...parseAllowScripts(value)];\n}\n"],"names":["DEFAULT_ALLOWED_SCRIPTS","resolveAllowScripts","value","parseAllowScripts"],"mappings":";;;;;;;;;;;QAGaA;eAAAA;;QAQGC;eAAAA;;;mCAVkB;AAE3B,MAAMD,0BAA0B;IACnC;IACA;IACA;IACA;IACA;CACH;AAEM,SAASC,oBAAoBC,KAAmB;IACnD,IAAIA,UAAU,QAAQA,UAAU,OAAO;QACnC,OAAOA;IACX;IACA,OAAO;WAAIF;WAA4BG,IAAAA,oCAAiB,EAACD;KAAO;AACpE"}
1
+ {"version":3,"sources":["../../../src/package-manager/utils/resolve-allow-scripts.ts"],"sourcesContent":["import type { AllowScripts } from '../package-manager';\nimport { parseAllowScripts } from './parse-allow-scripts';\n\nexport const DEFAULT_ALLOWED_SCRIPTS = [\n '@servicetitan/startup',\n 'cypress',\n 'msw',\n 'nx',\n 'tree-sitter',\n];\n\nexport function resolveAllowScripts(value: AllowScripts, builtInAllowlist: string[]): AllowScripts {\n if (value === true || value === false) {\n return value;\n }\n return [...builtInAllowlist, ...parseAllowScripts(value)];\n}\n"],"names":["DEFAULT_ALLOWED_SCRIPTS","resolveAllowScripts","value","builtInAllowlist","parseAllowScripts"],"mappings":";;;;;;;;;;;QAGaA;eAAAA;;QAQGC;eAAAA;;;mCAVkB;AAE3B,MAAMD,0BAA0B;IACnC;IACA;IACA;IACA;IACA;CACH;AAEM,SAASC,oBAAoBC,KAAmB,EAAEC,gBAA0B;IAC/E,IAAID,UAAU,QAAQA,UAAU,OAAO;QACnC,OAAOA;IACX;IACA,OAAO;WAAIC;WAAqBC,IAAAA,oCAAiB,EAACF;KAAO;AAC7D"}
@@ -0,0 +1,2 @@
1
+ export declare function usesStartup(): boolean;
2
+ //# sourceMappingURL=uses-startup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uses-startup.d.ts","sourceRoot":"","sources":["../../../src/package-manager/utils/uses-startup.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,IAAI,OAAO,CAOrC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "usesStartup", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return usesStartup;
9
+ }
10
+ });
11
+ const _utils = require("../../utils");
12
+ const STARTUP_PACKAGE = '@servicetitan/startup';
13
+ function usesStartup() {
14
+ var _ref, _ref1;
15
+ var _packageJson_dependencies, _packageJson_devDependencies, _packageJson_peerDependencies;
16
+ const packageJson = (0, _utils.getWorkspaceRootPackageJson)();
17
+ return !!((_ref = (_ref1 = packageJson === null || packageJson === void 0 ? void 0 : (_packageJson_dependencies = packageJson.dependencies) === null || _packageJson_dependencies === void 0 ? void 0 : _packageJson_dependencies[STARTUP_PACKAGE]) !== null && _ref1 !== void 0 ? _ref1 : packageJson === null || packageJson === void 0 ? void 0 : (_packageJson_devDependencies = packageJson.devDependencies) === null || _packageJson_devDependencies === void 0 ? void 0 : _packageJson_devDependencies[STARTUP_PACKAGE]) !== null && _ref !== void 0 ? _ref : packageJson === null || packageJson === void 0 ? void 0 : (_packageJson_peerDependencies = packageJson.peerDependencies) === null || _packageJson_peerDependencies === void 0 ? void 0 : _packageJson_peerDependencies[STARTUP_PACKAGE]);
18
+ }
19
+
20
+ //# sourceMappingURL=uses-startup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/package-manager/utils/uses-startup.ts"],"sourcesContent":["import { getWorkspaceRootPackageJson } from '../../utils';\n\nconst STARTUP_PACKAGE = '@servicetitan/startup';\n\nexport function usesStartup(): boolean {\n const packageJson = getWorkspaceRootPackageJson();\n return !!(\n packageJson?.dependencies?.[STARTUP_PACKAGE] ??\n packageJson?.devDependencies?.[STARTUP_PACKAGE] ??\n packageJson?.peerDependencies?.[STARTUP_PACKAGE]\n );\n}\n"],"names":["usesStartup","STARTUP_PACKAGE","packageJson","getWorkspaceRootPackageJson","dependencies","devDependencies","peerDependencies"],"mappings":";;;;+BAIgBA;;;eAAAA;;;uBAJ4B;AAE5C,MAAMC,kBAAkB;AAEjB,SAASD;QAGRE;QAAAA,2BACAA,8BACAA;IAJJ,MAAMA,cAAcC,IAAAA,kCAA2B;IAC/C,OAAO,CAAC,GACJD,gBAAAA,wBAAAA,mCAAAA,4BAAAA,YAAaE,YAAY,cAAzBF,gDAAAA,yBAA2B,CAACD,gBAAgB,yCAC5CC,wBAAAA,mCAAAA,+BAAAA,YAAaG,eAAe,cAA5BH,mDAAAA,4BAA8B,CAACD,gBAAgB,cAD/CC,kBAAAA,OAEAA,wBAAAA,mCAAAA,gCAAAA,YAAaI,gBAAgB,cAA7BJ,oDAAAA,6BAA+B,CAACD,gBAAgB;AAExD"}
@@ -0,0 +1,2 @@
1
+ export declare function findWorkspaceRoot(): string | undefined;
2
+ //# sourceMappingURL=find-workspace-root.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-workspace-root.d.ts","sourceRoot":"","sources":["../../src/utils/find-workspace-root.ts"],"names":[],"mappings":"AAKA,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CActD"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "findWorkspaceRoot", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return findWorkspaceRoot;
9
+ }
10
+ });
11
+ const _nodefs = /*#__PURE__*/ _interop_require_default(require("node:fs"));
12
+ const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
13
+ const _findup = require("./find-up");
14
+ const _readjson = require("./read-json");
15
+ function _interop_require_default(obj) {
16
+ return obj && obj.__esModule ? obj : {
17
+ default: obj
18
+ };
19
+ }
20
+ function findWorkspaceRoot() {
21
+ return (0, _findup.findUp)((directory)=>{
22
+ var _readJsonSafe, _readJsonSafe1;
23
+ if ((_readJsonSafe = (0, _readjson.readJsonSafe)(_nodepath.default.join(directory, 'package.json'))) === null || _readJsonSafe === void 0 ? void 0 : _readJsonSafe.workspaces) {
24
+ return directory;
25
+ }
26
+ if (_nodefs.default.existsSync(_nodepath.default.join(directory, 'pnpm-workspace.yaml'))) {
27
+ return directory;
28
+ }
29
+ if ((_readJsonSafe1 = (0, _readjson.readJsonSafe)(_nodepath.default.join(directory, 'lerna.json'))) === null || _readJsonSafe1 === void 0 ? void 0 : _readJsonSafe1.packages) {
30
+ return directory;
31
+ }
32
+ });
33
+ }
34
+
35
+ //# sourceMappingURL=find-workspace-root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/find-workspace-root.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { findUp } from './find-up';\nimport { readJsonSafe } from './read-json';\n\nexport function findWorkspaceRoot(): string | undefined {\n return findUp(directory => {\n if (\n readJsonSafe<{ workspaces?: unknown }>(path.join(directory, 'package.json'))?.workspaces\n ) {\n return directory;\n }\n if (fs.existsSync(path.join(directory, 'pnpm-workspace.yaml'))) {\n return directory;\n }\n if (readJsonSafe<{ packages?: unknown }>(path.join(directory, 'lerna.json'))?.packages) {\n return directory;\n }\n });\n}\n"],"names":["findWorkspaceRoot","findUp","directory","readJsonSafe","path","join","workspaces","fs","existsSync","packages"],"mappings":";;;;+BAKgBA;;;eAAAA;;;+DALD;iEACE;wBACM;0BACM;;;;;;AAEtB,SAASA;IACZ,OAAOC,IAAAA,cAAM,EAACC,CAAAA;YAENC,eAOAA;QARJ,KACIA,gBAAAA,IAAAA,sBAAY,EAA2BC,iBAAI,CAACC,IAAI,CAACH,WAAW,8BAA5DC,oCAAAA,cAA8EG,UAAU,EAC1F;YACE,OAAOJ;QACX;QACA,IAAIK,eAAE,CAACC,UAAU,CAACJ,iBAAI,CAACC,IAAI,CAACH,WAAW,yBAAyB;YAC5D,OAAOA;QACX;QACA,KAAIC,iBAAAA,IAAAA,sBAAY,EAAyBC,iBAAI,CAACC,IAAI,CAACH,WAAW,4BAA1DC,qCAAAA,eAA0EM,QAAQ,EAAE;YACpF,OAAOP;QACX;IACJ;AACJ"}
@@ -0,0 +1,10 @@
1
+ export interface PackageJson {
2
+ cli?: {
3
+ packageManager?: string;
4
+ };
5
+ dependencies?: Record<string, string>;
6
+ devDependencies?: Record<string, string>;
7
+ peerDependencies?: Record<string, string>;
8
+ }
9
+ export declare function getWorkspaceRootPackageJson(): PackageJson | undefined;
10
+ //# sourceMappingURL=get-workspace-root-package-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-workspace-root-package-json.d.ts","sourceRoot":"","sources":["../../src/utils/get-workspace-root-package-json.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IACxB,GAAG,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C;AAKD,wBAAgB,2BAA2B,IAAI,WAAW,GAAG,SAAS,CAOrE"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getWorkspaceRootPackageJson", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getWorkspaceRootPackageJson;
9
+ }
10
+ });
11
+ const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
12
+ const _findworkspaceroot = require("./find-workspace-root");
13
+ const _readjson = require("./read-json");
14
+ function _interop_require_default(obj) {
15
+ return obj && obj.__esModule ? obj : {
16
+ default: obj
17
+ };
18
+ }
19
+ let rootPackageJson;
20
+ let rootPackageJsonLoaded = false;
21
+ function getWorkspaceRootPackageJson() {
22
+ if (!rootPackageJsonLoaded) {
23
+ var _findWorkspaceRoot;
24
+ const root = (_findWorkspaceRoot = (0, _findworkspaceroot.findWorkspaceRoot)()) !== null && _findWorkspaceRoot !== void 0 ? _findWorkspaceRoot : _nodepath.default.resolve('./');
25
+ rootPackageJson = (0, _readjson.readJsonSafe)(_nodepath.default.join(root, 'package.json'));
26
+ rootPackageJsonLoaded = true;
27
+ }
28
+ return rootPackageJson;
29
+ }
30
+
31
+ //# sourceMappingURL=get-workspace-root-package-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/get-workspace-root-package-json.ts"],"sourcesContent":["import path from 'node:path';\nimport { findWorkspaceRoot } from './find-workspace-root';\nimport { readJsonSafe } from './read-json';\n\nexport interface PackageJson {\n cli?: { packageManager?: string };\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n}\n\nlet rootPackageJson: PackageJson | undefined;\nlet rootPackageJsonLoaded = false;\n\nexport function getWorkspaceRootPackageJson(): PackageJson | undefined {\n if (!rootPackageJsonLoaded) {\n const root = findWorkspaceRoot() ?? path.resolve('./');\n rootPackageJson = readJsonSafe<PackageJson>(path.join(root, 'package.json'));\n rootPackageJsonLoaded = true;\n }\n return rootPackageJson;\n}\n"],"names":["getWorkspaceRootPackageJson","rootPackageJson","rootPackageJsonLoaded","findWorkspaceRoot","root","path","resolve","readJsonSafe","join"],"mappings":";;;;+BAcgBA;;;eAAAA;;;iEAdC;mCACiB;0BACL;;;;;;AAS7B,IAAIC;AACJ,IAAIC,wBAAwB;AAErB,SAASF;IACZ,IAAI,CAACE,uBAAuB;YACXC;QAAb,MAAMC,QAAOD,qBAAAA,IAAAA,oCAAiB,iBAAjBA,gCAAAA,qBAAuBE,iBAAI,CAACC,OAAO,CAAC;QACjDL,kBAAkBM,IAAAA,sBAAY,EAAcF,iBAAI,CAACG,IAAI,CAACJ,MAAM;QAC5DF,wBAAwB;IAC5B;IACA,OAAOD;AACX"}
@@ -3,6 +3,7 @@ export * from './debug';
3
3
  export * from './find-up';
4
4
  export * from './get-packages-with-install-scripts';
5
5
  export * from './get-version';
6
+ export * from './get-workspace-root-package-json';
6
7
  export * from './git';
7
8
  export * from './npm';
8
9
  export * from './os';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,qCAAqC,CAAC;AACpD,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,MAAM,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,cAAc,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,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,kCAAkC,CAAC"}
@@ -7,6 +7,7 @@ _export_star(require("./debug"), exports);
7
7
  _export_star(require("./find-up"), exports);
8
8
  _export_star(require("./get-packages-with-install-scripts"), exports);
9
9
  _export_star(require("./get-version"), exports);
10
+ _export_star(require("./get-workspace-root-package-json"), exports);
10
11
  _export_star(require("./git"), exports);
11
12
  _export_star(require("./npm"), exports);
12
13
  _export_star(require("./os"), exports);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './ci';\nexport * from './debug';\nexport * from './find-up';\nexport * from './get-packages-with-install-scripts';\nexport * from './get-version';\nexport * from './git';\nexport * from './npm';\nexport * from './os';\nexport * from './read-json';\nexport * from './warn-untrusted-install-scripts';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * 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 './warn-untrusted-install-scripts';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/install",
3
- "version": "38.0.0",
3
+ "version": "38.2.0",
4
4
  "description": "Lightweight wrapper around npm install that configures access to private packages",
5
5
  "homepage": "https://docs.st.dev/docs/frontend/uikit/install",
6
6
  "repository": {
@@ -30,7 +30,7 @@
30
30
  "webpack": false
31
31
  },
32
32
  "peerDependencies": {
33
- "js-yaml": "~4.2.0"
33
+ "js-yaml": "~5.2.2"
34
34
  },
35
35
  "peerDependenciesMeta": {
36
36
  "js-yaml": {
@@ -40,5 +40,5 @@
40
40
  "devDependencies": {
41
41
  "ts-node": "~10.9.2"
42
42
  },
43
- "gitHead": "a96a725030a0c422257567b1f06025bca8ca53b9"
43
+ "gitHead": "fd8cf00982a529371e44d76a0ca455dbbb42bae5"
44
44
  }
@@ -1,12 +1,10 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { findUp, readJsonSafe } from '../utils';
1
+ import { getWorkspaceRootPackageJson } from '../utils';
4
2
  import { NpmPackageManager } from './npm-package-manager';
5
3
  import type { PackageManager } from './package-manager';
6
4
  import { PnpmPackageManager } from './pnpm-package-manager';
7
5
 
8
6
  export function getPackageManager(): PackageManager {
9
- const name = readPackageManagerName();
7
+ const name = getWorkspaceRootPackageJson()?.cli?.packageManager ?? 'npm';
10
8
  switch (name) {
11
9
  case 'npm':
12
10
  return new NpmPackageManager();
@@ -16,27 +14,3 @@ export function getPackageManager(): PackageManager {
16
14
  throw new Error(`Unsupported package manager: ${name}`);
17
15
  }
18
16
  }
19
-
20
- function readPackageManagerName(): string {
21
- const root = findWorkspaceRoot() ?? path.resolve('./');
22
- const packageJson = readJsonSafe<{ cli?: { packageManager?: string } }>(
23
- path.join(root, 'package.json')
24
- );
25
- return packageJson?.cli?.packageManager ?? 'npm';
26
- }
27
-
28
- function findWorkspaceRoot(): string | undefined {
29
- return findUp(directory => {
30
- if (
31
- readJsonSafe<{ workspaces?: unknown }>(path.join(directory, 'package.json'))?.workspaces
32
- ) {
33
- return directory;
34
- }
35
- if (fs.existsSync(path.join(directory, 'pnpm-workspace.yaml'))) {
36
- return directory;
37
- }
38
- if (readJsonSafe<{ packages?: unknown }>(path.join(directory, 'lerna.json'))?.packages) {
39
- return directory;
40
- }
41
- });
42
- }
@@ -7,7 +7,7 @@ import {
7
7
  DEFAULT_ALLOWED_SCRIPTS,
8
8
  logAllowedScripts,
9
9
  resolveAllowScripts,
10
- shouldIgnoreScripts,
10
+ usesStartup,
11
11
  } from './utils';
12
12
 
13
13
  interface NpmLockFileEntry {
@@ -44,10 +44,11 @@ export class NpmPackageManager extends PackageManager<NpmLockFile> {
44
44
  }
45
45
 
46
46
  installPackages(args: InstallArgs = {}, options?: Parameters<typeof runCommand>[2]) {
47
- const allowScripts = resolveAllowScripts(args.allowScripts ?? []);
47
+ const builtInAllowlist = usesStartup() ? DEFAULT_ALLOWED_SCRIPTS : [];
48
+ const allowScripts = resolveAllowScripts(args.allowScripts ?? [], builtInAllowlist);
48
49
 
49
50
  if (!args.quiet) {
50
- logAllowedScripts(allowScripts);
51
+ logAllowedScripts(allowScripts, builtInAllowlist);
51
52
  }
52
53
 
53
54
  runCommand(
@@ -57,7 +58,7 @@ export class NpmPackageManager extends PackageManager<NpmLockFile> {
57
58
  '--audit=false',
58
59
  '--fund=false',
59
60
  '--legacy-peer-deps',
60
- ...(shouldIgnoreScripts(allowScripts) ? ['--ignore-scripts'] : []),
61
+ ...(allowScripts !== true ? ['--ignore-scripts'] : []),
61
62
  ...(args.fix ? ['--package-lock-only', '--prefer-dedupe'] : []),
62
63
  ],
63
64
  options
@@ -68,11 +69,11 @@ export class NpmPackageManager extends PackageManager<NpmLockFile> {
68
69
  return;
69
70
  }
70
71
  /*
71
- * Rebuild applies when allowScripts is an explicit list:
72
+ * Rebuild applies when allowScripts is a non-empty explicit list:
72
73
  * `true` means npm install already ran every script, `false`
73
74
  * means the user opted out.
74
75
  */
75
- if (Array.isArray(allowScripts)) {
76
+ if (Array.isArray(allowScripts) && allowScripts.length > 0) {
76
77
  this.runRebuild(allowScripts);
77
78
  }
78
79
  /*
@@ -82,7 +83,7 @@ export class NpmPackageManager extends PackageManager<NpmLockFile> {
82
83
  */
83
84
  if (allowScripts !== false) {
84
85
  warnUntrustedInstallScripts(
85
- Array.isArray(allowScripts) ? allowScripts : DEFAULT_ALLOWED_SCRIPTS
86
+ Array.isArray(allowScripts) ? allowScripts : builtInAllowlist
86
87
  );
87
88
  }
88
89
  /*
@@ -1,4 +1,4 @@
1
1
  export * from './log-allowed-scripts';
2
2
  export * from './parse-allow-scripts';
3
3
  export * from './resolve-allow-scripts';
4
- export * from './should-ignore-scripts';
4
+ export * from './uses-startup';
@@ -1,8 +1,7 @@
1
1
  /* eslint-disable no-console */
2
2
  import type { AllowScripts } from '../package-manager';
3
- import { DEFAULT_ALLOWED_SCRIPTS } from './resolve-allow-scripts';
4
3
 
5
- export function logAllowedScripts(allowScripts: AllowScripts) {
4
+ export function logAllowedScripts(allowScripts: AllowScripts, builtInAllowlist: string[]) {
6
5
  if (allowScripts === true) {
7
6
  console.log('Allowing all install scripts');
8
7
  return;
@@ -10,8 +9,12 @@ export function logAllowedScripts(allowScripts: AllowScripts) {
10
9
  if (allowScripts === false) {
11
10
  return;
12
11
  }
13
- const extras = allowScripts.filter(s => !DEFAULT_ALLOWED_SCRIPTS.includes(s));
14
- if (extras.length) {
15
- console.log(`Allowing additional install scripts: ${extras.join(', ')}`);
12
+ const extras = allowScripts.filter(s => !builtInAllowlist.includes(s));
13
+ if (!extras.length) {
14
+ return;
16
15
  }
16
+ const label = builtInAllowlist.length
17
+ ? 'Allowing additional install scripts'
18
+ : 'Allowing install scripts';
19
+ console.log(`${label}: ${extras.join(', ')}`);
17
20
  }
@@ -9,9 +9,9 @@ export const DEFAULT_ALLOWED_SCRIPTS = [
9
9
  'tree-sitter',
10
10
  ];
11
11
 
12
- export function resolveAllowScripts(value: AllowScripts): AllowScripts {
12
+ export function resolveAllowScripts(value: AllowScripts, builtInAllowlist: string[]): AllowScripts {
13
13
  if (value === true || value === false) {
14
14
  return value;
15
15
  }
16
- return [...DEFAULT_ALLOWED_SCRIPTS, ...parseAllowScripts(value)];
16
+ return [...builtInAllowlist, ...parseAllowScripts(value)];
17
17
  }
@@ -0,0 +1,12 @@
1
+ import { getWorkspaceRootPackageJson } from '../../utils';
2
+
3
+ const STARTUP_PACKAGE = '@servicetitan/startup';
4
+
5
+ export function usesStartup(): boolean {
6
+ const packageJson = getWorkspaceRootPackageJson();
7
+ return !!(
8
+ packageJson?.dependencies?.[STARTUP_PACKAGE] ??
9
+ packageJson?.devDependencies?.[STARTUP_PACKAGE] ??
10
+ packageJson?.peerDependencies?.[STARTUP_PACKAGE]
11
+ );
12
+ }
@@ -0,0 +1,20 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { findUp } from './find-up';
4
+ import { readJsonSafe } from './read-json';
5
+
6
+ export function findWorkspaceRoot(): string | undefined {
7
+ return findUp(directory => {
8
+ if (
9
+ readJsonSafe<{ workspaces?: unknown }>(path.join(directory, 'package.json'))?.workspaces
10
+ ) {
11
+ return directory;
12
+ }
13
+ if (fs.existsSync(path.join(directory, 'pnpm-workspace.yaml'))) {
14
+ return directory;
15
+ }
16
+ if (readJsonSafe<{ packages?: unknown }>(path.join(directory, 'lerna.json'))?.packages) {
17
+ return directory;
18
+ }
19
+ });
20
+ }
@@ -0,0 +1,22 @@
1
+ import path from 'node:path';
2
+ import { findWorkspaceRoot } from './find-workspace-root';
3
+ import { readJsonSafe } from './read-json';
4
+
5
+ export interface PackageJson {
6
+ cli?: { packageManager?: string };
7
+ dependencies?: Record<string, string>;
8
+ devDependencies?: Record<string, string>;
9
+ peerDependencies?: Record<string, string>;
10
+ }
11
+
12
+ let rootPackageJson: PackageJson | undefined;
13
+ let rootPackageJsonLoaded = false;
14
+
15
+ export function getWorkspaceRootPackageJson(): PackageJson | undefined {
16
+ if (!rootPackageJsonLoaded) {
17
+ const root = findWorkspaceRoot() ?? path.resolve('./');
18
+ rootPackageJson = readJsonSafe<PackageJson>(path.join(root, 'package.json'));
19
+ rootPackageJsonLoaded = true;
20
+ }
21
+ return rootPackageJson;
22
+ }
@@ -3,6 +3,7 @@ export * from './debug';
3
3
  export * from './find-up';
4
4
  export * from './get-packages-with-install-scripts';
5
5
  export * from './get-version';
6
+ export * from './get-workspace-root-package-json';
6
7
  export * from './git';
7
8
  export * from './npm';
8
9
  export * from './os';
@@ -1,3 +0,0 @@
1
- import type { AllowScripts } from '../package-manager';
2
- export declare function shouldIgnoreScripts(allowScripts: AllowScripts): boolean;
3
- //# sourceMappingURL=should-ignore-scripts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"should-ignore-scripts.d.ts","sourceRoot":"","sources":["../../../src/package-manager/utils/should-ignore-scripts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAQvE"}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "shouldIgnoreScripts", {
6
- enumerable: true,
7
- get: function() {
8
- return shouldIgnoreScripts;
9
- }
10
- });
11
- function shouldIgnoreScripts(allowScripts) {
12
- if (allowScripts === true) {
13
- return false;
14
- }
15
- if (allowScripts === false) {
16
- return true;
17
- }
18
- return allowScripts.length > 0;
19
- }
20
-
21
- //# sourceMappingURL=should-ignore-scripts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/package-manager/utils/should-ignore-scripts.ts"],"sourcesContent":["import type { AllowScripts } from '../package-manager';\n\nexport function shouldIgnoreScripts(allowScripts: AllowScripts): boolean {\n if (allowScripts === true) {\n return false;\n }\n if (allowScripts === false) {\n return true;\n }\n return allowScripts.length > 0;\n}\n"],"names":["shouldIgnoreScripts","allowScripts","length"],"mappings":";;;;+BAEgBA;;;eAAAA;;;AAAT,SAASA,oBAAoBC,YAA0B;IAC1D,IAAIA,iBAAiB,MAAM;QACvB,OAAO;IACX;IACA,IAAIA,iBAAiB,OAAO;QACxB,OAAO;IACX;IACA,OAAOA,aAAaC,MAAM,GAAG;AACjC"}
@@ -1,11 +0,0 @@
1
- import type { AllowScripts } from '../package-manager';
2
-
3
- export function shouldIgnoreScripts(allowScripts: AllowScripts): boolean {
4
- if (allowScripts === true) {
5
- return false;
6
- }
7
- if (allowScripts === false) {
8
- return true;
9
- }
10
- return allowScripts.length > 0;
11
- }