@servicetitan/install 36.1.2-canary.8 → 36.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.
@@ -1 +1 @@
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"}
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"}
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "getPackageManager", {
9
9
  }
10
10
  });
11
11
  const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
+ const _utils = require("../utils");
12
14
  const _npmpackagemanager = require("./npm-package-manager");
13
15
  const _pnpmpackagemanager = require("./pnpm-package-manager");
14
16
  function _interop_require_default(obj) {
@@ -28,10 +30,25 @@ function getPackageManager() {
28
30
  }
29
31
  }
30
32
  function readPackageManagerName() {
31
- var _ref;
33
+ var _findWorkspaceRoot, _ref;
32
34
  var _packageJson_cli;
33
- const packageJson = JSON.parse(_fs.default.readFileSync('package.json', 'utf-8'));
34
- return (_ref = (_packageJson_cli = packageJson.cli) === null || _packageJson_cli === void 0 ? void 0 : _packageJson_cli.packageManager) !== null && _ref !== void 0 ? _ref : 'npm';
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
+ });
35
52
  }
36
53
 
37
54
  //# 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 { 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 packageJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'));\n return packageJson.cli?.packageManager ?? 'npm';\n}\n"],"names":["getPackageManager","name","readPackageManagerName","NpmPackageManager","PnpmPackageManager","Error","packageJson","JSON","parse","fs","readFileSync","cli","packageManager"],"mappings":";;;;+BAKgBA;;;eAAAA;;;2DALD;mCACmB;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;;QAEEI;IADP,MAAMA,cAAcC,KAAKC,KAAK,CAACC,WAAE,CAACC,YAAY,CAAC,gBAAgB;IAC/D,gBAAOJ,mBAAAA,YAAYK,GAAG,cAAfL,uCAAAA,iBAAiBM,cAAc,uCAAI;AAC9C"}
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"}
@@ -0,0 +1,2 @@
1
+ export declare function findUp<T>(callback: (directory: string) => T | undefined): NonNullable<T> | undefined;
2
+ //# sourceMappingURL=find-up.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-up.d.ts","sourceRoot":"","sources":["../../src/utils/find-up.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,CAAC,GAAG,SAAS,8BASvE"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "findUp", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return findUp;
9
+ }
10
+ });
11
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
12
+ function _interop_require_default(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
17
+ function findUp(callback) {
18
+ let directory = _path.default.resolve('./');
19
+ do {
20
+ const result = callback(directory);
21
+ if (result) {
22
+ return result;
23
+ }
24
+ directory = _path.default.resolve(_path.default.join(directory, '../'));
25
+ }while (_path.default.parse(directory).name)
26
+ }
27
+
28
+ //# sourceMappingURL=find-up.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/find-up.ts"],"sourcesContent":["import path from 'path';\n\nexport function findUp<T>(callback: (directory: string) => T | undefined) {\n let directory = path.resolve('./');\n do {\n const result = callback(directory);\n if (result) {\n return result;\n }\n directory = path.resolve(path.join(directory, '../'));\n } while (path.parse(directory).name);\n}\n"],"names":["findUp","callback","directory","path","resolve","result","join","parse","name"],"mappings":";;;;+BAEgBA;;;eAAAA;;;6DAFC;;;;;;AAEV,SAASA,OAAUC,QAA8C;IACpE,IAAIC,YAAYC,aAAI,CAACC,OAAO,CAAC;IAC7B,GAAG;QACC,MAAMC,SAASJ,SAASC;QACxB,IAAIG,QAAQ;YACR,OAAOA;QACX;QACAH,YAAYC,aAAI,CAACC,OAAO,CAACD,aAAI,CAACG,IAAI,CAACJ,WAAW;IAClD,QAASC,aAAI,CAACI,KAAK,CAACL,WAAWM,IAAI,CAAE;AACzC"}
@@ -1,5 +1,6 @@
1
1
  export * from './ci';
2
2
  export * from './debug';
3
+ export * from './find-up';
3
4
  export * from './get-packages-with-install-scripts';
4
5
  export * from './get-version';
5
6
  export * from './git';
@@ -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,qCAAqC,CAAC;AACpD,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,wBAAwB,CAAC;AACvC,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,OAAO,CAAC;AACtB,cAAc,wBAAwB,CAAC;AACvC,cAAc,OAAO,CAAC;AACtB,cAAc,MAAM,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,cAAc,kCAAkC,CAAC"}
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  _export_star(require("./ci"), exports);
6
6
  _export_star(require("./debug"), exports);
7
+ _export_star(require("./find-up"), exports);
7
8
  _export_star(require("./get-packages-with-install-scripts"), exports);
8
9
  _export_star(require("./get-version"), exports);
9
10
  _export_star(require("./git"), exports);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './ci';\nexport * from './debug';\nexport * from './get-packages-with-install-scripts';\nexport * from './get-version';\nexport * from './git';\nexport * from './has-lockfile-changed';\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 './git';\nexport * from './has-lockfile-changed';\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"}
@@ -1,2 +1,3 @@
1
1
  export declare function readJson(file: string): any;
2
+ export declare function readJsonSafe<T = any>(file: string): T | undefined;
2
3
  //# sourceMappingURL=read-json.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"read-json.d.ts","sourceRoot":"","sources":["../../src/utils/read-json.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,OAEpC"}
1
+ {"version":3,"file":"read-json.d.ts","sourceRoot":"","sources":["../../src/utils/read-json.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,OAEpC;AAED,wBAAgB,YAAY,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAMjE"}
@@ -2,10 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- Object.defineProperty(exports, "readJson", {
6
- enumerable: true,
7
- get: function() {
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get readJson () {
8
13
  return readJson;
14
+ },
15
+ get readJsonSafe () {
16
+ return readJsonSafe;
9
17
  }
10
18
  });
11
19
  const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
@@ -19,5 +27,12 @@ function readJson(file) {
19
27
  encoding: 'utf-8'
20
28
  }));
21
29
  }
30
+ function readJsonSafe(file) {
31
+ try {
32
+ return readJson(file);
33
+ } catch (unused) {
34
+ return undefined;
35
+ }
36
+ }
22
37
 
23
38
  //# sourceMappingURL=read-json.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/read-json.ts"],"sourcesContent":["import fs from 'fs';\n\nexport function readJson(file: string) {\n return JSON.parse(fs.readFileSync(file, { encoding: 'utf-8' }));\n}\n"],"names":["readJson","file","JSON","parse","fs","readFileSync","encoding"],"mappings":";;;;+BAEgBA;;;eAAAA;;;2DAFD;;;;;;AAER,SAASA,SAASC,IAAY;IACjC,OAAOC,KAAKC,KAAK,CAACC,WAAE,CAACC,YAAY,CAACJ,MAAM;QAAEK,UAAU;IAAQ;AAChE"}
1
+ {"version":3,"sources":["../../src/utils/read-json.ts"],"sourcesContent":["import fs from 'fs';\n\nexport function readJson(file: string) {\n return JSON.parse(fs.readFileSync(file, { encoding: 'utf-8' }));\n}\n\nexport function readJsonSafe<T = any>(file: string): T | undefined {\n try {\n return readJson(file);\n } catch {\n return undefined;\n }\n}\n"],"names":["readJson","readJsonSafe","file","JSON","parse","fs","readFileSync","encoding","undefined"],"mappings":";;;;;;;;;;;QAEgBA;eAAAA;;QAIAC;eAAAA;;;2DAND;;;;;;AAER,SAASD,SAASE,IAAY;IACjC,OAAOC,KAAKC,KAAK,CAACC,WAAE,CAACC,YAAY,CAACJ,MAAM;QAAEK,UAAU;IAAQ;AAChE;AAEO,SAASN,aAAsBC,IAAY;IAC9C,IAAI;QACA,OAAOF,SAASE;IACpB,EAAE,eAAM;QACJ,OAAOM;IACX;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/install",
3
- "version": "36.1.2-canary.8",
3
+ "version": "36.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": {
@@ -39,5 +39,6 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "ts-node": "~10.9.2"
42
- }
42
+ },
43
+ "gitHead": "87254b2caf60b20eb46c33b40ffb4dd05ad3e0f7"
43
44
  }
@@ -1,4 +1,6 @@
1
1
  import fs from 'fs';
2
+ import path from 'path';
3
+ import { findUp, readJsonSafe } from '../utils';
2
4
  import { NpmPackageManager } from './npm-package-manager';
3
5
  import type { PackageManager } from './package-manager';
4
6
  import { PnpmPackageManager } from './pnpm-package-manager';
@@ -16,6 +18,25 @@ export function getPackageManager(): PackageManager {
16
18
  }
17
19
 
18
20
  function readPackageManagerName(): string {
19
- const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
20
- return packageJson.cli?.packageManager ?? 'npm';
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
+ });
21
42
  }
@@ -0,0 +1,12 @@
1
+ import path from 'path';
2
+
3
+ export function findUp<T>(callback: (directory: string) => T | undefined) {
4
+ let directory = path.resolve('./');
5
+ do {
6
+ const result = callback(directory);
7
+ if (result) {
8
+ return result;
9
+ }
10
+ directory = path.resolve(path.join(directory, '../'));
11
+ } while (path.parse(directory).name);
12
+ }
@@ -1,5 +1,6 @@
1
1
  export * from './ci';
2
2
  export * from './debug';
3
+ export * from './find-up';
3
4
  export * from './get-packages-with-install-scripts';
4
5
  export * from './get-version';
5
6
  export * from './git';
@@ -3,3 +3,11 @@ import fs from 'fs';
3
3
  export function readJson(file: string) {
4
4
  return JSON.parse(fs.readFileSync(file, { encoding: 'utf-8' }));
5
5
  }
6
+
7
+ export function readJsonSafe<T = any>(file: string): T | undefined {
8
+ try {
9
+ return readJson(file);
10
+ } catch {
11
+ return undefined;
12
+ }
13
+ }