@servicetitan/install 38.1.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 (49) hide show
  1. package/dist/package-manager/get-package-manager.d.ts.map +1 -1
  2. package/dist/package-manager/get-package-manager.js +3 -29
  3. package/dist/package-manager/get-package-manager.js.map +1 -1
  4. package/dist/package-manager/npm-package-manager.d.ts.map +1 -1
  5. package/dist/package-manager/npm-package-manager.js +7 -6
  6. package/dist/package-manager/npm-package-manager.js.map +1 -1
  7. package/dist/package-manager/utils/index.d.ts +1 -1
  8. package/dist/package-manager/utils/index.d.ts.map +1 -1
  9. package/dist/package-manager/utils/index.js +1 -1
  10. package/dist/package-manager/utils/index.js.map +1 -1
  11. package/dist/package-manager/utils/log-allowed-scripts.d.ts +1 -1
  12. package/dist/package-manager/utils/log-allowed-scripts.d.ts.map +1 -1
  13. package/dist/package-manager/utils/log-allowed-scripts.js +6 -5
  14. package/dist/package-manager/utils/log-allowed-scripts.js.map +1 -1
  15. package/dist/package-manager/utils/resolve-allow-scripts.d.ts +1 -1
  16. package/dist/package-manager/utils/resolve-allow-scripts.d.ts.map +1 -1
  17. package/dist/package-manager/utils/resolve-allow-scripts.js +2 -2
  18. package/dist/package-manager/utils/resolve-allow-scripts.js.map +1 -1
  19. package/dist/package-manager/utils/uses-startup.d.ts +2 -0
  20. package/dist/package-manager/utils/uses-startup.d.ts.map +1 -0
  21. package/dist/package-manager/utils/uses-startup.js +20 -0
  22. package/dist/package-manager/utils/uses-startup.js.map +1 -0
  23. package/dist/utils/find-workspace-root.d.ts +2 -0
  24. package/dist/utils/find-workspace-root.d.ts.map +1 -0
  25. package/dist/utils/find-workspace-root.js +35 -0
  26. package/dist/utils/find-workspace-root.js.map +1 -0
  27. package/dist/utils/get-workspace-root-package-json.d.ts +10 -0
  28. package/dist/utils/get-workspace-root-package-json.d.ts.map +1 -0
  29. package/dist/utils/get-workspace-root-package-json.js +31 -0
  30. package/dist/utils/get-workspace-root-package-json.js.map +1 -0
  31. package/dist/utils/index.d.ts +1 -0
  32. package/dist/utils/index.d.ts.map +1 -1
  33. package/dist/utils/index.js +1 -0
  34. package/dist/utils/index.js.map +1 -1
  35. package/package.json +3 -3
  36. package/src/package-manager/get-package-manager.ts +2 -28
  37. package/src/package-manager/npm-package-manager.ts +8 -7
  38. package/src/package-manager/utils/index.ts +1 -1
  39. package/src/package-manager/utils/log-allowed-scripts.ts +8 -5
  40. package/src/package-manager/utils/resolve-allow-scripts.ts +2 -2
  41. package/src/package-manager/utils/uses-startup.ts +12 -0
  42. package/src/utils/find-workspace-root.ts +20 -0
  43. package/src/utils/get-workspace-root-package-json.ts +22 -0
  44. package/src/utils/index.ts +1 -0
  45. package/dist/package-manager/utils/should-ignore-scripts.d.ts +0 -3
  46. package/dist/package-manager/utils/should-ignore-scripts.d.ts.map +0 -1
  47. package/dist/package-manager/utils/should-ignore-scripts.js +0 -21
  48. package/dist/package-manager/utils/should-ignore-scripts.js.map +0 -1
  49. package/src/package-manager/utils/should-ignore-scripts.ts +0 -11
@@ -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":["../../src/package-manager/npm-package-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAQ,UAAU,EAA+B,MAAM,UAAU,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQnD,UAAU,gBAAgB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC/C;AAED,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC9D,QAAQ,CAAC,OAAO,SAAS;IACzB,QAAQ,CAAC,YAAY,uBAAuB;IAE5C,UAAU;IAIV,kBAAkB,CAAC,EACf,gBAAgB,EAChB,UAAU,EACV,UAAU,GACb,EAA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EAAE,oBAAoB,GAAG,MAAM,GAAG,SAAS;IAK5C,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,UAAU,EAAE,EAAE,oBAAoB,GAAG,MAAM,GAAG,SAAS;IAI9F,eAAe,CAAC,IAAI,GAAE,WAAgB,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;IAwDlF,SAAS,CAAC,aAAa,IAAI,WAAW,GAAG,SAAS;IAYlD;;;;;;;OAOG;IACH,OAAO,CAAC,SAAS;IAiBjB,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,qBAAqB;CAOhC"}
@@ -54,16 +54,17 @@ class NpmPackageManager extends _packagemanager.PackageManager {
54
54
  }
55
55
  installPackages(args = {}, options) {
56
56
  var _args_allowScripts;
57
- 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);
58
59
  if (!args.quiet) {
59
- (0, _utils1.logAllowedScripts)(allowScripts);
60
+ (0, _utils1.logAllowedScripts)(allowScripts, builtInAllowlist);
60
61
  }
61
62
  (0, _utils.runCommand)(this.command, [
62
63
  (0, _utils.isCI)() ? 'ci' : 'i',
63
64
  '--audit=false',
64
65
  '--fund=false',
65
66
  '--legacy-peer-deps',
66
- ...(0, _utils1.shouldIgnoreScripts)(allowScripts) ? [
67
+ ...allowScripts !== true ? [
67
68
  '--ignore-scripts'
68
69
  ] : [],
69
70
  ...args.fix ? [
@@ -76,10 +77,10 @@ class NpmPackageManager extends _packagemanager.PackageManager {
76
77
  return;
77
78
  }
78
79
  /*
79
- * Rebuild applies when allowScripts is an explicit list:
80
+ * Rebuild applies when allowScripts is a non-empty explicit list:
80
81
  * `true` means npm install already ran every script, `false`
81
82
  * means the user opted out.
82
- */ if (Array.isArray(allowScripts)) {
83
+ */ if (Array.isArray(allowScripts) && allowScripts.length > 0) {
83
84
  this.runRebuild(allowScripts);
84
85
  }
85
86
  /*
@@ -87,7 +88,7 @@ class NpmPackageManager extends _packagemanager.PackageManager {
87
88
  * scripts they should add to --allow-scripts. Skip when the user
88
89
  * explicitly opted out (`false`); they made an informed choice.
89
90
  */ if (allowScripts !== false) {
90
- (0, _utils.warnUntrustedInstallScripts)(Array.isArray(allowScripts) ? allowScripts : _utils1.DEFAULT_ALLOWED_SCRIPTS);
91
+ (0, _utils.warnUntrustedInstallScripts)(Array.isArray(allowScripts) ? allowScripts : builtInAllowlist);
91
92
  }
92
93
  /*
93
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;QAA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":["../../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,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+BAAAA,QAAU,CAAC,GAAGtC,iBAAiB,cAAc,EAAEqC,aAAa,CAAC,uCAC7DC,qBAAAA,+BAAAA,QAAU,CAAC,CAAC,aAAa,EAAED,aAAa,CAAC;QAC7C,IAAIlC,CAAAA,kBAAAA,4BAAAA,MAAOqC,IAAI,KAAIrC,MAAMsC,QAAQ,EAAE;YAC/B,OAAOH,qBAAAA,+BAAAA,QAAU,CAACnC,MAAMsC,QAAQ,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"}
@@ -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.1.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": "~5.2.1"
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": "e8c601a26ad49ca0d6b0b84a9f530f3242d53c7f"
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
- }