@servicetitan/startup 31.6.0 → 32.0.1

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 (68) hide show
  1. package/dist/cli/commands/init.d.ts +2 -1
  2. package/dist/cli/commands/init.d.ts.map +1 -1
  3. package/dist/cli/commands/init.js +24 -43
  4. package/dist/cli/commands/init.js.map +1 -1
  5. package/dist/cli/commands/install.d.ts +4 -0
  6. package/dist/cli/commands/install.d.ts.map +1 -1
  7. package/dist/cli/commands/install.js +91 -3
  8. package/dist/cli/commands/install.js.map +1 -1
  9. package/dist/cli/commands/mfe-package-clean.d.ts.map +1 -1
  10. package/dist/cli/commands/mfe-package-clean.js +5 -7
  11. package/dist/cli/commands/mfe-package-clean.js.map +1 -1
  12. package/dist/cli/commands/mfe-package-publish.d.ts.map +1 -1
  13. package/dist/cli/commands/mfe-package-publish.js +11 -15
  14. package/dist/cli/commands/mfe-package-publish.js.map +1 -1
  15. package/dist/cli/commands/upload-sourcemaps.d.ts.map +1 -1
  16. package/dist/cli/commands/upload-sourcemaps.js +1 -1
  17. package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
  18. package/dist/cli/index.js +1 -2
  19. package/dist/cli/index.js.map +1 -1
  20. package/dist/cli/utils/cli-git.d.ts +11 -2
  21. package/dist/cli/utils/cli-git.d.ts.map +1 -1
  22. package/dist/cli/utils/cli-git.js +60 -4
  23. package/dist/cli/utils/cli-git.js.map +1 -1
  24. package/dist/cli/utils/cli-os.d.ts.map +1 -1
  25. package/dist/cli/utils/cli-os.js +3 -0
  26. package/dist/cli/utils/cli-os.js.map +1 -1
  27. package/dist/cli/utils/index.d.ts +6 -0
  28. package/dist/cli/utils/index.d.ts.map +1 -1
  29. package/dist/cli/utils/index.js +6 -0
  30. package/dist/cli/utils/index.js.map +1 -1
  31. package/dist/cli/utils/is-ci.d.ts +2 -0
  32. package/dist/cli/utils/is-ci.d.ts.map +1 -0
  33. package/dist/cli/utils/is-ci.js +15 -0
  34. package/dist/cli/utils/is-ci.js.map +1 -0
  35. package/dist/cli/utils/lerna-exec.d.ts.map +1 -1
  36. package/dist/cli/utils/lerna-exec.js +2 -1
  37. package/dist/cli/utils/lerna-exec.js.map +1 -1
  38. package/dist/utils/get-branch-configs.d.ts +1 -1
  39. package/dist/utils/get-branch-configs.d.ts.map +1 -1
  40. package/dist/utils/get-branch-configs.js +2 -2
  41. package/dist/utils/get-branch-configs.js.map +1 -1
  42. package/dist/utils/index.d.ts +1 -0
  43. package/dist/utils/index.d.ts.map +1 -1
  44. package/dist/utils/index.js +1 -0
  45. package/dist/utils/index.js.map +1 -1
  46. package/package.json +6 -6
  47. package/src/cli/commands/__tests__/init.test.ts +21 -87
  48. package/src/cli/commands/__tests__/install.test.ts +174 -12
  49. package/src/cli/commands/__tests__/mfe-package-clean.test.ts +3 -6
  50. package/src/cli/commands/__tests__/mfe-package-publish.test.ts +6 -8
  51. package/src/cli/commands/__tests__/upload-sourcemaps.test.ts +7 -3
  52. package/src/cli/commands/init.ts +17 -37
  53. package/src/cli/commands/install.ts +95 -6
  54. package/src/cli/commands/mfe-package-clean.ts +2 -4
  55. package/src/cli/commands/mfe-package-publish.ts +18 -6
  56. package/src/cli/commands/upload-sourcemaps.ts +2 -2
  57. package/src/cli/index.ts +1 -2
  58. package/src/cli/utils/__tests__/cli-git.test.ts +142 -6
  59. package/src/cli/utils/__tests__/eslint.test.ts +3 -2
  60. package/src/cli/utils/__tests__/is-ci.test.ts +40 -0
  61. package/src/cli/utils/__tests__/lerna-exec.test.ts +6 -3
  62. package/src/cli/utils/cli-git.ts +55 -5
  63. package/src/cli/utils/cli-os.ts +4 -1
  64. package/src/cli/utils/index.ts +6 -0
  65. package/src/cli/utils/is-ci.ts +3 -0
  66. package/src/cli/utils/lerna-exec.ts +2 -1
  67. package/src/utils/get-branch-configs.ts +1 -1
  68. package/src/utils/index.ts +1 -0
@@ -1,12 +1,21 @@
1
1
  import { execSync } from 'child_process';
2
- import { log, logErrors, getStartupVersion } from '../../utils';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import os from 'os';
5
+ import { log, logErrors, getStartupVersion, readJsonSafe } from '../../utils';
3
6
  import { Command } from './types';
7
+ import { gitCloneRepo, isCI } from '../utils';
4
8
 
5
9
  interface Args {
6
10
  quiet?: boolean;
7
11
  fix?: boolean;
12
+ token?: boolean;
8
13
  }
9
14
 
15
+ const REPO_NAME = 'frontend-dev-config';
16
+ const AUTH_TOKEN_KEY = '//registry.npmjs.org/:_authToken';
17
+ const AUTH_TOKEN_REGEX = /^\/\/registry\.npmjs\.org\/:_authToken=\s*\${([^}]+)}/m;
18
+
10
19
  export class Install implements Command {
11
20
  constructor(private readonly args?: Args) {}
12
21
 
@@ -16,12 +25,92 @@ export class Install implements Command {
16
25
 
17
26
  @logErrors
18
27
  async execute() {
28
+ if (!this.args?.quiet) {
29
+ log.info(`startup cli v${getStartupVersion()}`);
30
+ }
31
+
32
+ const env = await this.configureNpmToken();
33
+ this.installPackages(env);
34
+
35
+ return Promise.resolve(); // stops "async method has no 'await' expression" lint error
36
+ }
37
+
38
+ private async configureNpmToken() {
39
+ if (isCI() || this.args?.fix || this.args?.token === false) {
40
+ return;
41
+ }
42
+
43
+ if (!this.args?.quiet) {
44
+ log.info('Configuring NPM token ...');
45
+ }
46
+
47
+ const token = await this.fetchNpmToken();
48
+ if (!token) {
49
+ return;
50
+ }
51
+
52
+ execSync(`npm config set "${AUTH_TOKEN_KEY}"="${token}"`);
53
+
54
+ if (!fs.existsSync('.npmrc')) {
55
+ return;
56
+ }
57
+
58
+ const npmrc = fs.readFileSync('.npmrc', 'utf-8');
59
+ const match = AUTH_TOKEN_REGEX.exec(npmrc);
60
+ if (match) {
61
+ return { [match[1]]: token };
62
+ }
63
+
64
+ execSync(`npm config delete --location=project "${AUTH_TOKEN_KEY}"`);
65
+ }
66
+
67
+ private async fetchNpmToken() {
68
+ const tempDirPath = fs.mkdtempSync(path.join(os.tmpdir(), 'st-install-'));
69
+ try {
70
+ if (!(await gitCloneRepo({ destination: tempDirPath, name: REPO_NAME }))) {
71
+ throw new Error(`could not clone servicetitan/${REPO_NAME}`);
72
+ }
73
+
74
+ const npmJson = readJsonSafe(path.join(tempDirPath, '.npm.json'));
75
+
76
+ /* istanbul ignore next: debug only */
77
+ log.debug('install:fetch-token', () => JSON.stringify(npmJson, null, 2));
78
+
79
+ if (!((npmJson && typeof npmJson === 'object') || Array.isArray(npmJson))) {
80
+ throw new Error('.npm.json is not an object');
81
+ }
82
+
83
+ const { readOnlyToken: authToken } = npmJson;
84
+ if (!authToken) {
85
+ throw new Error('.npm.json does not contain auth token');
86
+ }
87
+
88
+ if (typeof authToken !== 'string') {
89
+ throw new Error('.npm.json auth token is not a string');
90
+ }
91
+
92
+ return Buffer.from(authToken, 'base64').toString('utf-8');
93
+ } catch (e) {
94
+ log.warning(String(e));
95
+ } finally {
96
+ try {
97
+ fs.rmSync(tempDirPath, { recursive: true, force: true });
98
+ } catch {
99
+ // ignore
100
+ }
101
+ }
102
+ }
103
+
104
+ private installPackages(env?: Record<string, string>) {
105
+ /* istanbul ignore next: debug only */
106
+ log.debug('install:install-packages', () => JSON.stringify({ env }));
107
+
19
108
  /**
20
109
  * Note, if these are changed, update bootstrap.js to match
21
110
  * @see {@link file://./../../../../../bootstrap.js}
22
111
  */
23
112
  const npmArguments = [
24
- process.env.CI ? 'ci' : 'i',
113
+ isCI() ? 'ci' : 'i',
25
114
  '--audit=false',
26
115
  '--fund=false',
27
116
  '--legacy-peer-deps',
@@ -29,12 +118,12 @@ export class Install implements Command {
29
118
  ].join(' ');
30
119
 
31
120
  if (!this.args?.quiet) {
32
- log.info(`startup cli v${getStartupVersion()}`);
33
121
  log.info(`Running npm ${npmArguments} ...`);
34
122
  }
35
123
 
36
- execSync(`npm ${npmArguments}`, { stdio: 'inherit' });
37
-
38
- return Promise.resolve(); // stops "async method has no 'await' expression" lint error
124
+ execSync(`npm ${npmArguments}`, {
125
+ ...(env ? { env: { ...process.env, ...env } } : {}),
126
+ stdio: 'inherit',
127
+ });
39
128
  }
40
129
  }
@@ -1,7 +1,5 @@
1
- import { isWebComponent, log, logErrors, readJson } from '../../utils';
2
- import { getBranchesConfigs } from '../../utils/get-branch-configs';
3
- import { gitGetBranch } from '../utils/cli-git';
4
- import { Version, npmGetPackageVersionsDetails, npmUnpublish } from '../utils/cli-npm';
1
+ import { getBranchesConfigs, isWebComponent, log, logErrors, readJson } from '../../utils';
2
+ import { gitGetBranch, npmGetPackageVersionsDetails, npmUnpublish, Version } from '../utils';
5
3
  import { Command } from './types';
6
4
 
7
5
  export interface Args {
@@ -1,12 +1,24 @@
1
1
  import path from 'path';
2
2
  import fs from 'fs';
3
- import { getFolders, isWebComponent, log, logErrors, readJson } from '../../utils';
4
- import { getBranchesConfigs } from '../../utils/get-branch-configs';
3
+ import {
4
+ getBranchesConfigs,
5
+ getFolders,
6
+ isWebComponent,
7
+ log,
8
+ logErrors,
9
+ readJson,
10
+ } from '../../utils';
5
11
  import { EntryPoint, EntryPoints, Metadata } from '../../webpack/configs';
6
- import { gitGetBranch, gitGetCommitHash } from '../utils/cli-git';
7
- import { npmGetPackageVersions, npmPackageSet, npmPublish, npmTagVersion } from '../utils/cli-npm';
8
- import { runCommand } from '../utils/cli-os';
9
- import { getDefaultBuildVersion } from '../utils/publish';
12
+ import {
13
+ getDefaultBuildVersion,
14
+ gitGetBranch,
15
+ gitGetCommitHash,
16
+ npmGetPackageVersions,
17
+ npmPackageSet,
18
+ npmPublish,
19
+ npmTagVersion,
20
+ runCommand,
21
+ } from '../utils';
10
22
  import { Command } from './types';
11
23
 
12
24
  export interface Args {
@@ -1,8 +1,8 @@
1
1
  import path from 'path';
2
2
  import { execSync } from 'child_process';
3
3
  import { getTsConfig, isWebComponent, log, logErrors, readJson } from '../../utils';
4
+ import { isCI, TSConfig } from '../utils';
4
5
  import { Command } from './types';
5
- import { TSConfig } from '../utils';
6
6
 
7
7
  interface Args {
8
8
  dry?: boolean;
@@ -35,7 +35,7 @@ export class UploadSourcemaps implements Command {
35
35
  private checkArgs() {
36
36
  if (!process.env.DATADOG_API_KEY) {
37
37
  const message = 'DATADOG_API_KEY environment variable is not set';
38
- if (!process.env.CI) {
38
+ if (!isCI()) {
39
39
  throw new Error(message);
40
40
  }
41
41
  log.warning(`${message}; skipping sourcemaps`);
package/src/cli/index.ts CHANGED
@@ -3,8 +3,7 @@ import path from 'path';
3
3
  import { argv, Arguments } from 'yargs';
4
4
  import { CommandName, getStartupVersion, log } from '../utils';
5
5
  import { getCommand, getUserCommands } from './commands';
6
- import { setNodeOptions } from './utils';
7
- import { maybeCreateGitFolder } from './utils/maybe-create-git-folder';
6
+ import { maybeCreateGitFolder, setNodeOptions } from './utils';
8
7
 
9
8
  const argvSync = argv as Arguments;
10
9
  const name = argvSync._[0]?.toString() as CommandName;
@@ -1,11 +1,16 @@
1
- import { runCommandOutput } from '../cli-os';
1
+ import { runCommand, runCommandOutput } from '../cli-os';
2
2
 
3
- import { gitGetBranch, gitGetCommitHash } from '../cli-git';
3
+ import { gitCloneRepo, gitGetBranch, gitGetCommitHash, gitIsReachable } from '../cli-git';
4
+ import { isCI } from '../is-ci';
4
5
 
5
- jest.mock('../cli-os', () => ({ runCommandOutput: jest.fn() }));
6
+ jest.mock('../is-ci', () => ({ isCI: jest.fn() }));
7
+ jest.mock('../cli-os', () => ({ runCommand: jest.fn(), runCommandOutput: jest.fn() }));
6
8
 
7
9
  describe('[startup] Cli Utils (Git)', () => {
8
- beforeEach(() => jest.resetAllMocks());
10
+ beforeEach(() => {
11
+ jest.resetAllMocks();
12
+ jest.mocked(isCI).mockReturnValue(false);
13
+ });
9
14
 
10
15
  function itRunsCommand(subject: Function, command: string) {
11
16
  test(`runs "${command}"`, () => {
@@ -18,11 +23,142 @@ describe('[startup] Cli Utils (Git)', () => {
18
23
  });
19
24
  }
20
25
 
21
- describe(`${gitGetBranch.name}`, () => {
26
+ describe(gitGetBranch.name, () => {
22
27
  itRunsCommand(gitGetBranch, 'git rev-parse --abbrev-ref HEAD');
23
28
  });
24
29
 
25
- describe(`${gitGetCommitHash.name}`, () => {
30
+ describe(gitGetCommitHash.name, () => {
26
31
  itRunsCommand(gitGetCommitHash, 'git rev-parse --short HEAD');
27
32
  });
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 ${webUrl} to destination directory`, async () => {
54
+ await subject();
55
+
56
+ expect(runCommand).toHaveBeenCalledWith(`git clone -q ${webUrl} ${destination}`, {
57
+ quiet: true,
58
+ });
59
+ });
60
+
61
+ itReturns(true);
62
+
63
+ describe(`when cloning ${webUrl} fails`, () => {
64
+ beforeEach(() => jest.mocked(runCommand).mockRejectedValueOnce('Nope!'));
65
+
66
+ test(`clones ${sshUrl} to destination directory`, async () => {
67
+ await subject();
68
+
69
+ expect(runCommand).toHaveBeenCalledWith(
70
+ `git clone -q ${sshUrl} ${destination}`,
71
+ expect.anything()
72
+ );
73
+ });
74
+
75
+ itReturns(true);
76
+
77
+ describe(`when cloning ${sshUrl} also fails`, () => {
78
+ beforeEach(() => {
79
+ jest.mocked(runCommand).mockRejectedValue('Nope!');
80
+ });
81
+
82
+ itReturns(false);
83
+ });
84
+ });
85
+
86
+ describe('when running in CI environment with GITHUB_TOKEN', () => {
87
+ const originalEnv = process.env;
88
+ const token = 'foo-bar';
89
+
90
+ beforeEach(() => {
91
+ jest.mocked(isCI).mockReturnValue(true);
92
+ process.env.GITHUB_TOKEN = token;
93
+ });
94
+ afterEach(() => (process.env = originalEnv));
95
+
96
+ test(`adds token to ${webUrl}`, async () => {
97
+ await subject();
98
+
99
+ const urlWithToken = webUrl.replace('github.com', `oauth2:${token}@github.com`);
100
+ expect(runCommand).toHaveBeenCalledWith(
101
+ `git clone -q ${urlWithToken} ${destination}`,
102
+ expect.anything()
103
+ );
104
+ });
105
+ });
106
+ });
107
+
108
+ describe(gitIsReachable.name, () => {
109
+ const name = '{name}';
110
+
111
+ let params: Parameters<typeof gitIsReachable>[0];
112
+
113
+ beforeEach(() => (params = { name }));
114
+
115
+ const subject = () => gitIsReachable(params);
116
+
117
+ function itReturns(value: boolean) {
118
+ test(`it returns ${value}`, () => {
119
+ expect(subject()).toBe(value);
120
+ });
121
+ }
122
+
123
+ const webUrl = `https://github.com/servicetitan/${name}.git`;
124
+ const sshUrl = `git@github.com:servicetitan/${name}.git`;
125
+
126
+ test(`checks if ${webUrl} is reachable`, () => {
127
+ subject();
128
+
129
+ expect(runCommandOutput).toHaveBeenCalledWith(`git ls-remote -qt ${webUrl}`, {
130
+ quiet: true,
131
+ });
132
+ });
133
+
134
+ itReturns(true);
135
+
136
+ describe(`when ${webUrl} is not reachable`, () => {
137
+ beforeEach(() => {
138
+ jest.mocked(runCommandOutput).mockImplementationOnce(() => {
139
+ throw new Error('Oops!');
140
+ });
141
+ });
142
+
143
+ test(`checks if ${sshUrl} is reachable`, () => {
144
+ subject();
145
+
146
+ expect(runCommandOutput).toHaveBeenCalledWith(`git ls-remote -qt ${sshUrl}`, {
147
+ quiet: true,
148
+ });
149
+ });
150
+
151
+ itReturns(true);
152
+
153
+ describe(`when ${sshUrl} is also unreachable`, () => {
154
+ beforeEach(() =>
155
+ jest.mocked(runCommandOutput).mockImplementation(() => {
156
+ throw new Error('Oops');
157
+ })
158
+ );
159
+
160
+ itReturns(false);
161
+ });
162
+ });
163
+ });
28
164
  });
@@ -1,12 +1,13 @@
1
1
  import { fs, vol } from 'memfs';
2
2
  import { ESLint } from 'eslint';
3
3
 
4
+ import { getDestinationFolders } from '../../../utils';
4
5
  import { eslint } from '../eslint';
5
- import { getDestinationFolders } from '../../../utils/get-destination-folders';
6
6
 
7
7
  jest.mock('fs', () => fs);
8
8
  jest.mock('eslint');
9
- jest.mock('../../../utils/get-destination-folders', () => ({
9
+ jest.mock('../../../utils', () => ({
10
+ ...jest.requireActual('../../../utils'),
10
11
  getDestinationFolders: jest.fn(),
11
12
  }));
12
13
 
@@ -0,0 +1,40 @@
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,9 +1,11 @@
1
1
  import execa from 'execa';
2
2
 
3
3
  import { log } from '../../../utils';
4
+ import { isCI } from '../is-ci';
4
5
  import { lernaExec } from '../lerna-exec';
5
6
 
6
7
  jest.mock('execa');
8
+ jest.mock('../is-ci', () => ({ isCI: jest.fn() }));
7
9
 
8
10
  const AVAILABLE_PARALLELISM = 2;
9
11
 
@@ -17,9 +19,9 @@ describe(`${lernaExec.name}`, () => {
17
19
 
18
20
  beforeEach(() => {
19
21
  jest.clearAllMocks();
22
+ jest.mocked(isCI).mockReturnValue(false);
20
23
  jest.spyOn(log, 'info').mockImplementation(jest.fn()); // suppress log output
21
24
  args = { cmd: 'foo' };
22
- delete process.env.CI;
23
25
  });
24
26
 
25
27
  const subject = () => lernaExec(args);
@@ -60,10 +62,11 @@ describe(`${lernaExec.name}`, () => {
60
62
  itRunsLernaExec(option);
61
63
  });
62
64
 
63
- describe('when process.env.CI=true', () => {
65
+ describe('when in CI environment', () => {
64
66
  beforeEach(() => {
65
- process.env.CI = 'true';
67
+ jest.mocked(isCI).mockReturnValue(true);
66
68
  });
69
+
67
70
  describe.each([
68
71
  { arg: { parallel: true }, option: `--concurrency=${AVAILABLE_PARALLELISM}` },
69
72
  { arg: { parallel: 10 }, option: '--concurrency=10' },
@@ -1,9 +1,59 @@
1
- import { runCommandOutput } from './cli-os';
1
+ import { log } from '../../utils';
2
+ import { runCommand, runCommandOutput } from './cli-os';
3
+ import { isCI } from './is-ci';
2
4
 
3
- export const gitGetBranch = (): string => {
5
+ export function gitGetBranch(): string {
4
6
  return runCommandOutput('git rev-parse --abbrev-ref HEAD').trim();
5
- };
7
+ }
6
8
 
7
- export const gitGetCommitHash = (): string => {
9
+ export function gitGetCommitHash(): string {
8
10
  return runCommandOutput('git rev-parse --short HEAD').trim();
9
- };
11
+ }
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, { quiet: true });
29
+ return true;
30
+ } catch {
31
+ // ignore error
32
+ }
33
+ }
34
+
35
+ return false;
36
+ }
37
+
38
+ export function gitIsReachable({ owner = 'servicetitan', name }: Repo) {
39
+ return getGitUrls({ owner, name }).some(url => {
40
+ try {
41
+ runCommandOutput(`git ls-remote -qt ${url}`, { quiet: true });
42
+ return true;
43
+ } catch {
44
+ return false;
45
+ }
46
+ });
47
+ }
48
+
49
+ function getGitUrls({ owner, name }: Repo) {
50
+ const webUrl = `https://github.com/${owner}/${name}.git`;
51
+ const sshUrl = `git@github.com:${owner}/${name}.git`;
52
+
53
+ const urls = [webUrl, sshUrl];
54
+ if (isCI() && !!process.env.GITHUB_TOKEN) {
55
+ urls.unshift(webUrl.replace('github.com', `oauth2:${process.env.GITHUB_TOKEN}@github.com`));
56
+ }
57
+
58
+ return urls;
59
+ }
@@ -42,7 +42,7 @@ export const runCommand = (
42
42
  proc.stdout.pipe(process.stdout);
43
43
  proc.stderr.pipe(process.stderr);
44
44
 
45
- proc.on('exit', function (code: any) {
45
+ proc.on('exit', function (code) {
46
46
  if (!quiet) {
47
47
  log.info(`command finished with code ${code}`, fullCommand);
48
48
  }
@@ -53,6 +53,9 @@ export const runCommand = (
53
53
  resolve();
54
54
  }
55
55
  });
56
+ proc.on('error', function (e) {
57
+ reject(e);
58
+ });
56
59
  });
57
60
  };
58
61
 
@@ -1,15 +1,21 @@
1
1
  export * from './bundle';
2
2
  export * from './check-args';
3
+ export * from './cli-git';
4
+ export * from './cli-npm';
5
+ export * from './cli-os';
3
6
  export * from './compile';
4
7
  export * from './compile-less';
5
8
  export * from './compile-sass';
6
9
  export * from './copy-files';
7
10
  export * from './eslint';
8
11
  export * from './get-module-type';
12
+ export * from './is-ci';
9
13
  export * from './is-module-installed';
10
14
  export * from './lerna-exec';
15
+ export * from './maybe-create-git-folder';
11
16
  export * from './pipe-stdout';
12
17
  export * from './process-tree';
18
+ export * from './publish';
13
19
  export * from './set-node-options';
14
20
  export * from './ts-config';
15
21
  export * from './type-check';
@@ -0,0 +1,3 @@
1
+ export function isCI() {
2
+ return !!process.env.CI || !!process.env.TEAMCITY_VERSION;
3
+ }
@@ -2,6 +2,7 @@ import execa, { StdioOption } from 'execa';
2
2
  import os from 'node:os';
3
3
 
4
4
  import { log } from '../../utils';
5
+ import { isCI } from './is-ci';
5
6
 
6
7
  interface Args {
7
8
  'bail'?: boolean;
@@ -37,7 +38,7 @@ function getOptions(args: Args) {
37
38
  result.push('--no-bail');
38
39
  }
39
40
  if (args.parallel === true) {
40
- result.push(process.env.CI ? `--concurrency=${os.availableParallelism()}` : '--parallel');
41
+ result.push(isCI() ? `--concurrency=${os.availableParallelism()}` : '--parallel');
41
42
  } else if (typeof args.parallel === 'number') {
42
43
  result.push(`--concurrency=${args.parallel}`);
43
44
  }
@@ -1,4 +1,4 @@
1
- import { getWebComponentBranchConfigs, WebComponentBranchConfigs } from './index';
1
+ import { getWebComponentBranchConfigs, WebComponentBranchConfigs } from './get-configuration';
2
2
 
3
3
  function getDefaultConfigs(): Record<string, WebComponentBranchConfigs> {
4
4
  return {
@@ -1,6 +1,7 @@
1
1
  export * from './find-packages';
2
2
  export * from './find-up';
3
3
  export * from './format-duration';
4
+ export * from './get-branch-configs';
4
5
  export * from './get-configuration';
5
6
  export * from './get-destination-folders';
6
7
  export * from './get-folders';