@servicetitan/startup 32.4.0 → 32.5.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 (65) hide show
  1. package/dist/cli/commands/init.d.ts +1 -1
  2. package/dist/cli/commands/init.d.ts.map +1 -1
  3. package/dist/cli/commands/init.js +6 -5
  4. package/dist/cli/commands/init.js.map +1 -1
  5. package/dist/cli/commands/install.d.ts +1 -4
  6. package/dist/cli/commands/install.d.ts.map +1 -1
  7. package/dist/cli/commands/install.js +12 -118
  8. package/dist/cli/commands/install.js.map +1 -1
  9. package/dist/cli/commands/mfe-list.d.ts.map +1 -1
  10. package/dist/cli/commands/mfe-list.js +2 -1
  11. package/dist/cli/commands/mfe-list.js.map +1 -1
  12. package/dist/cli/commands/review/rules/index.d.ts.map +1 -1
  13. package/dist/cli/commands/review/rules/index.js +2 -0
  14. package/dist/cli/commands/review/rules/index.js.map +1 -1
  15. package/dist/cli/commands/review/rules/no-deprecated-startup-install.d.ts +7 -0
  16. package/dist/cli/commands/review/rules/no-deprecated-startup-install.d.ts.map +1 -0
  17. package/dist/cli/commands/review/rules/no-deprecated-startup-install.js +38 -0
  18. package/dist/cli/commands/review/rules/no-deprecated-startup-install.js.map +1 -0
  19. package/dist/cli/commands/review/types.d.ts +1 -0
  20. package/dist/cli/commands/review/types.d.ts.map +1 -1
  21. package/dist/cli/commands/review/types.js.map +1 -1
  22. package/dist/cli/commands/upload-sourcemaps.d.ts.map +1 -1
  23. package/dist/cli/commands/upload-sourcemaps.js +2 -1
  24. package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
  25. package/dist/cli/utils/cli-git.d.ts +0 -9
  26. package/dist/cli/utils/cli-git.d.ts.map +1 -1
  27. package/dist/cli/utils/cli-git.js +0 -59
  28. package/dist/cli/utils/cli-git.js.map +1 -1
  29. package/dist/cli/utils/cli-npm.d.ts +0 -3
  30. package/dist/cli/utils/cli-npm.d.ts.map +1 -1
  31. package/dist/cli/utils/cli-npm.js +0 -22
  32. package/dist/cli/utils/cli-npm.js.map +1 -1
  33. package/dist/cli/utils/index.d.ts +0 -1
  34. package/dist/cli/utils/index.d.ts.map +1 -1
  35. package/dist/cli/utils/index.js +0 -1
  36. package/dist/cli/utils/index.js.map +1 -1
  37. package/dist/cli/utils/lerna-exec.d.ts.map +1 -1
  38. package/dist/cli/utils/lerna-exec.js +2 -2
  39. package/dist/cli/utils/lerna-exec.js.map +1 -1
  40. package/package.json +7 -8
  41. package/src/cli/commands/__tests__/init.test.ts +11 -14
  42. package/src/cli/commands/__tests__/install.test.ts +19 -224
  43. package/src/cli/commands/__tests__/mfe-list.test.ts +5 -4
  44. package/src/cli/commands/__tests__/upload-sourcemaps.test.ts +4 -7
  45. package/src/cli/commands/init.ts +6 -4
  46. package/src/cli/commands/install.ts +13 -116
  47. package/src/cli/commands/mfe-list.ts +2 -1
  48. package/src/cli/commands/review/rules/__tests__/no-deprecated-startup-install.test.ts +81 -0
  49. package/src/cli/commands/review/rules/index.ts +2 -0
  50. package/src/cli/commands/review/rules/no-deprecated-startup-install.ts +30 -0
  51. package/src/cli/commands/review/types.ts +1 -0
  52. package/src/cli/commands/upload-sourcemaps.ts +2 -1
  53. package/src/cli/utils/__tests__/cli-git.test.ts +4 -140
  54. package/src/cli/utils/__tests__/cli-npm.test.ts +0 -43
  55. package/src/cli/utils/__tests__/lerna-exec.test.ts +2 -2
  56. package/src/cli/utils/cli-git.ts +1 -52
  57. package/src/cli/utils/cli-npm.ts +0 -12
  58. package/src/cli/utils/index.ts +0 -1
  59. package/src/cli/utils/lerna-exec.ts +1 -1
  60. package/dist/cli/utils/is-ci.d.ts +0 -2
  61. package/dist/cli/utils/is-ci.d.ts.map +0 -1
  62. package/dist/cli/utils/is-ci.js +0 -15
  63. package/dist/cli/utils/is-ci.js.map +0 -1
  64. package/src/cli/utils/__tests__/is-ci.test.ts +0 -40
  65. package/src/cli/utils/is-ci.ts +0 -3
@@ -45,6 +45,7 @@ export interface Package {
45
45
  name: string;
46
46
  peerDependencies?: Record<string, string>;
47
47
  private?: boolean;
48
+ scripts?: Record<string, string>;
48
49
  sideEffects?: any;
49
50
  workspaces?: string[];
50
51
  }
@@ -1,7 +1,8 @@
1
+ import { isCI } from '@servicetitan/install';
1
2
  import path from 'path';
2
3
  import { execSync } from 'child_process';
3
4
  import { getTsConfig, isWebComponent, log, logErrors, readJson } from '../../utils';
4
- import { isCI, TSConfig } from '../utils';
5
+ import { TSConfig } from '../utils';
5
6
  import { Command, CommandArgs } from './types';
6
7
 
7
8
  interface Args extends CommandArgs {
@@ -1,15 +1,12 @@
1
- import { runCommand, runCommandOutput } from '../cli-os';
1
+ import { runCommandOutput } from '../cli-os';
2
2
 
3
- import { gitCloneRepo, gitGetBranch, gitGetCommitHash, gitIsReachable } from '../cli-git';
4
- import { isCI } from '../is-ci';
3
+ import { gitGetBranch, gitGetCommitHash } from '../cli-git';
5
4
 
6
- jest.mock('../is-ci', () => ({ isCI: jest.fn() }));
7
- jest.mock('../cli-os', () => ({ runCommand: jest.fn(), runCommandOutput: jest.fn() }));
5
+ jest.mock('../cli-os', () => ({ runCommandOutput: jest.fn() }));
8
6
 
9
7
  describe('[startup] Cli Utils (Git)', () => {
10
8
  beforeEach(() => {
11
- jest.resetAllMocks();
12
- jest.mocked(isCI).mockReturnValue(false);
9
+ jest.clearAllMocks();
13
10
  });
14
11
 
15
12
  function itRunsCommand(subject: Function, command: string) {
@@ -30,137 +27,4 @@ describe('[startup] Cli Utils (Git)', () => {
30
27
  describe(gitGetCommitHash.name, () => {
31
28
  itRunsCommand(gitGetCommitHash, 'git rev-parse --short HEAD');
32
29
  });
33
-
34
- describe(gitCloneRepo.name, () => {
35
- const destination = 'foo';
36
- const name = '{name}';
37
-
38
- const webUrl = `https://github.com/servicetitan/${name}.git`;
39
- const sshUrl = `git@github.com:servicetitan/${name}.git`;
40
-
41
- let params: Parameters<typeof gitCloneRepo>[0];
42
-
43
- beforeEach(() => (params = { destination, name }));
44
-
45
- const subject = () => gitCloneRepo(params);
46
-
47
- function itReturns(value: boolean) {
48
- test(`it returns ${value}`, async () => {
49
- expect(await subject()).toBe(value);
50
- });
51
- }
52
-
53
- test(`clones ${sshUrl} to destination directory`, async () => {
54
- await subject();
55
-
56
- expect(runCommand).toHaveBeenCalledWith(
57
- `git clone -q ${sshUrl} ${destination}`,
58
- expect.anything()
59
- );
60
- });
61
-
62
- itReturns(true);
63
-
64
- describe(`when cloning ${sshUrl} fails`, () => {
65
- beforeEach(() => jest.mocked(runCommand).mockRejectedValueOnce('Nope!'));
66
-
67
- test(`clones ${webUrl} to destination directory`, async () => {
68
- await subject();
69
-
70
- expect(runCommand).toHaveBeenCalledWith(`git clone -q ${webUrl} ${destination}`, {
71
- quiet: true,
72
- // eslint-disable-next-line @typescript-eslint/naming-convention
73
- env: expect.objectContaining({ GIT_TERMINAL_PROMPT: '0' }),
74
- });
75
- });
76
-
77
- itReturns(true);
78
-
79
- describe(`when cloning ${webUrl} also fails`, () => {
80
- beforeEach(() => {
81
- jest.mocked(runCommand).mockRejectedValue('Nope!');
82
- });
83
-
84
- itReturns(false);
85
- });
86
- });
87
-
88
- describe('when running in CI environment with GITHUB_TOKEN', () => {
89
- const originalEnv = process.env;
90
- const token = 'foo-bar';
91
-
92
- beforeEach(() => {
93
- jest.mocked(isCI).mockReturnValue(true);
94
- process.env.GITHUB_TOKEN = token;
95
- });
96
- afterEach(() => (process.env = originalEnv));
97
-
98
- test(`clones ${webUrl} with token to destination directory`, async () => {
99
- await subject();
100
-
101
- const urlWithToken = webUrl.replace('github.com', `oauth2:${token}@github.com`);
102
- expect(runCommand).toHaveBeenCalledWith(
103
- `git clone -q ${urlWithToken} ${destination}`,
104
- expect.anything()
105
- );
106
- });
107
- });
108
- });
109
-
110
- describe(gitIsReachable.name, () => {
111
- const name = '{name}';
112
-
113
- let params: Parameters<typeof gitIsReachable>[0];
114
-
115
- beforeEach(() => (params = { name }));
116
-
117
- const subject = () => gitIsReachable(params);
118
-
119
- function itReturns(value: boolean) {
120
- test(`it returns ${value}`, () => {
121
- expect(subject()).toBe(value);
122
- });
123
- }
124
-
125
- const webUrl = `https://github.com/servicetitan/${name}.git`;
126
- const sshUrl = `git@github.com:servicetitan/${name}.git`;
127
-
128
- test(`checks if ${sshUrl} is reachable`, () => {
129
- subject();
130
-
131
- expect(runCommandOutput).toHaveBeenCalledWith(`git ls-remote -qt ${sshUrl}`, {
132
- quiet: true,
133
- });
134
- });
135
-
136
- itReturns(true);
137
-
138
- describe(`when ${sshUrl} is not reachable`, () => {
139
- beforeEach(() => {
140
- jest.mocked(runCommandOutput).mockImplementationOnce(() => {
141
- throw new Error('Oops!');
142
- });
143
- });
144
-
145
- test(`checks if ${webUrl} is reachable`, () => {
146
- subject();
147
-
148
- expect(runCommandOutput).toHaveBeenCalledWith(`git ls-remote -qt ${webUrl}`, {
149
- quiet: true,
150
- });
151
- });
152
-
153
- itReturns(true);
154
-
155
- describe(`when ${webUrl} is also unreachable`, () => {
156
- beforeEach(() =>
157
- jest.mocked(runCommandOutput).mockImplementation(() => {
158
- throw new Error('Oops');
159
- })
160
- );
161
-
162
- itReturns(false);
163
- });
164
- });
165
- });
166
30
  });
@@ -8,7 +8,6 @@ import {
8
8
  npmTagVersion,
9
9
  npmUnpublish,
10
10
  npmView,
11
- npmWhoAmI,
12
11
  } from '../cli-npm';
13
12
 
14
13
  jest.mock('../cli-os', () => ({
@@ -249,46 +248,4 @@ describe('[startup] Cli Utils (Npm)', () => {
249
248
  });
250
249
  });
251
250
  });
252
-
253
- describe(npmWhoAmI.name, () => {
254
- const username = 'Foo\n';
255
- let args: Parameters<typeof npmWhoAmI>[0];
256
-
257
- beforeEach(() => {
258
- args = undefined;
259
- jest.mocked(runCommandOutput).mockReturnValue(username);
260
- });
261
-
262
- const subject = () => npmWhoAmI(args);
263
-
264
- itRunsCommandOutput(subject, 'npm whoami', {
265
- quiet: true,
266
- stdio: ['pipe', 'pipe', 'ignore'],
267
- timeout: 10000,
268
- });
269
-
270
- test('returns trimmed username ', () => {
271
- expect(subject()).toEqual(username.trim());
272
- });
273
-
274
- describe('with registry', () => {
275
- beforeEach(() => (args = { registry: '{registry}' }));
276
-
277
- itRunsCommandOutput(subject, 'npm whoami --registry={registry}', expect.anything());
278
- });
279
-
280
- describe('when command fails', () => {
281
- const error = new Error('Oops');
282
-
283
- beforeEach(() => {
284
- jest.mocked(runCommandOutput).mockImplementation(() => {
285
- throw error;
286
- });
287
- });
288
-
289
- test('ignores error and returns undefined', () => {
290
- expect(subject()).toBeUndefined();
291
- });
292
- });
293
- });
294
251
  });
@@ -1,12 +1,12 @@
1
+ import { isCI } from '@servicetitan/install';
1
2
  import execa from 'execa';
2
3
 
3
4
  import { log } from '../../../utils';
4
- import { isCI } from '../is-ci';
5
5
  import { maybeCreateGitFolder } from '../maybe-create-git-folder';
6
6
  import { lernaExec } from '../lerna-exec';
7
7
 
8
+ jest.mock('@servicetitan/install');
8
9
  jest.mock('execa');
9
- jest.mock('../is-ci', () => ({ isCI: jest.fn() }));
10
10
  jest.mock('../maybe-create-git-folder', () => ({ maybeCreateGitFolder: jest.fn() }));
11
11
 
12
12
  const AVAILABLE_PARALLELISM = 2;
@@ -1,6 +1,4 @@
1
- import { log } from '../../utils';
2
- import { runCommand, runCommandOutput } from './cli-os';
3
- import { isCI } from './is-ci';
1
+ import { runCommandOutput } from './cli-os';
4
2
 
5
3
  export function gitGetBranch(): string {
6
4
  return runCommandOutput('git rev-parse --abbrev-ref HEAD').trim();
@@ -9,52 +7,3 @@ export function gitGetBranch(): string {
9
7
  export function gitGetCommitHash(): string {
10
8
  return runCommandOutput('git rev-parse --short HEAD').trim();
11
9
  }
12
-
13
- interface Repo {
14
- owner?: string;
15
- name: string;
16
- }
17
-
18
- export async function gitCloneRepo(params: Repo & { destination: string }) {
19
- const { destination, name, owner = 'servicetitan' } = params;
20
- const gitUrls = getGitUrls({ owner, name });
21
-
22
- for (const url of gitUrls) {
23
- try {
24
- const command = `git clone -q ${url} ${destination}`;
25
- log.debug('git:clone-repo', `running ${command}`);
26
-
27
- // eslint-disable-next-line no-await-in-loop
28
- await runCommand(command, {
29
- quiet: true,
30
- // eslint-disable-next-line @typescript-eslint/naming-convention
31
- env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
32
- });
33
- return true;
34
- } catch {
35
- // ignore error
36
- }
37
- }
38
-
39
- return false;
40
- }
41
-
42
- export function gitIsReachable({ owner = 'servicetitan', name }: Repo) {
43
- return getGitUrls({ owner, name }).some(url => {
44
- try {
45
- runCommandOutput(`git ls-remote -qt ${url}`, { quiet: true });
46
- return true;
47
- } catch {
48
- return false;
49
- }
50
- });
51
- }
52
-
53
- function getGitUrls({ owner, name }: Repo) {
54
- const webUrl = `https://github.com/${owner}/${name}.git`;
55
- const sshUrl = `git@github.com:${owner}/${name}.git`;
56
-
57
- return isCI() && !!process.env.GITHUB_TOKEN
58
- ? [webUrl.replace('github.com', `oauth2:${process.env.GITHUB_TOKEN}@github.com`)]
59
- : [sshUrl, webUrl];
60
- }
@@ -95,15 +95,3 @@ export function npmView({ packageName, registry }: { packageName: string; regist
95
95
  // ignore
96
96
  }
97
97
  }
98
-
99
- export function npmWhoAmI({ registry }: { registry?: string } = {}) {
100
- try {
101
- return runCommandOutput(['npm', 'whoami', registry ? `--registry=${registry}` : ''], {
102
- quiet: true,
103
- stdio: ['pipe', 'pipe', 'ignore'],
104
- timeout: NPM_TIMEOUT,
105
- }).trim();
106
- } catch {
107
- // ignore
108
- }
109
- }
@@ -9,7 +9,6 @@ export * from './compile-sass';
9
9
  export * from './copy-files';
10
10
  export * from './eslint';
11
11
  export * from './get-module-type';
12
- export * from './is-ci';
13
12
  export * from './is-module-installed';
14
13
  export * from './is-tty';
15
14
  export * from './lerna-exec';
@@ -1,8 +1,8 @@
1
+ import { isCI } from '@servicetitan/install';
1
2
  import execa, { StdioOption } from 'execa';
2
3
  import os from 'node:os';
3
4
 
4
5
  import { log } from '../../utils';
5
- import { isCI } from './is-ci';
6
6
  import { maybeCreateGitFolder } from './maybe-create-git-folder';
7
7
 
8
8
  interface Args {
@@ -1,2 +0,0 @@
1
- export declare function isCI(): boolean;
2
- //# sourceMappingURL=is-ci.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-ci.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/is-ci.ts"],"names":[],"mappings":"AAAA,wBAAgB,IAAI,YAEnB"}
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "isCI", {
6
- enumerable: true,
7
- get: function() {
8
- return isCI;
9
- }
10
- });
11
- function isCI() {
12
- return !!process.env.CI || !!process.env.TEAMCITY_VERSION;
13
- }
14
-
15
- //# sourceMappingURL=is-ci.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/cli/utils/is-ci.ts"],"sourcesContent":["export function isCI() {\n return !!process.env.CI || !!process.env.TEAMCITY_VERSION;\n}\n"],"names":["isCI","process","env","CI","TEAMCITY_VERSION"],"mappings":";;;;+BAAgBA;;;eAAAA;;;AAAT,SAASA;IACZ,OAAO,CAAC,CAACC,QAAQC,GAAG,CAACC,EAAE,IAAI,CAAC,CAACF,QAAQC,GAAG,CAACE,gBAAgB;AAC7D"}
@@ -1,40 +0,0 @@
1
- import { isCI } from '../is-ci';
2
-
3
- describe(`[startup] Utils ${isCI.name}`, () => {
4
- const originalCI = process.env.CI;
5
-
6
- beforeAll(() => delete process.env.CI);
7
- afterAll(() => (process.env.CI = originalCI));
8
-
9
- const subject = () => isCI();
10
-
11
- function itReturns(value: boolean) {
12
- test(`returns ${value}`, () => {
13
- expect(subject()).toBe(value);
14
- });
15
- }
16
-
17
- itReturns(false);
18
-
19
- describe.each([
20
- { value: '', result: false },
21
- { value: '1', result: true },
22
- ])('when process.env.CI is "$value"', ({ value, result }) => {
23
- beforeEach(() => (process.env.CI = value));
24
-
25
- afterEach(() => delete process.env.CI);
26
-
27
- itReturns(result);
28
- });
29
-
30
- describe.each([
31
- { value: '', result: false },
32
- { value: '1', result: true },
33
- ])('when process.env.TEAMCITY_VERSION is "$value"', ({ value, result }) => {
34
- beforeEach(() => (process.env.TEAMCITY_VERSION = value));
35
-
36
- afterEach(() => delete process.env.TEAMCITY_VERSION);
37
-
38
- itReturns(result);
39
- });
40
- });
@@ -1,3 +0,0 @@
1
- export function isCI() {
2
- return !!process.env.CI || !!process.env.TEAMCITY_VERSION;
3
- }