@servicetitan/startup 32.2.0 → 32.3.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.
- package/dist/cli/commands/build.d.ts +36 -7
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +35 -10
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-package.d.ts +9 -10
- package/dist/cli/commands/bundle-package.d.ts.map +1 -1
- package/dist/cli/commands/bundle-package.js +6 -22
- package/dist/cli/commands/bundle-package.js.map +1 -1
- package/dist/cli/commands/clean.d.ts +2 -2
- package/dist/cli/commands/clean.d.ts.map +1 -1
- package/dist/cli/commands/clean.js +16 -4
- package/dist/cli/commands/clean.js.map +1 -1
- package/dist/cli/commands/convert-eslint-config.d.ts +2 -2
- package/dist/cli/commands/convert-eslint-config.d.ts.map +1 -1
- package/dist/cli/commands/convert-eslint-config.js +3 -4
- package/dist/cli/commands/convert-eslint-config.js.map +1 -1
- package/dist/cli/commands/eslint.d.ts +3 -5
- package/dist/cli/commands/eslint.d.ts.map +1 -1
- package/dist/cli/commands/eslint.js +2 -18
- package/dist/cli/commands/eslint.js.map +1 -1
- package/dist/cli/commands/get-command.d.ts.map +1 -1
- package/dist/cli/commands/get-command.js +2 -0
- package/dist/cli/commands/get-command.js.map +1 -1
- package/dist/cli/commands/index.d.ts +0 -1
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +0 -1
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/init.d.ts +10 -6
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +9 -8
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/install.d.ts +21 -7
- package/dist/cli/commands/install.d.ts.map +1 -1
- package/dist/cli/commands/install.js +33 -11
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/kendo-ui-license.d.ts +3 -3
- package/dist/cli/commands/kendo-ui-license.d.ts.map +1 -1
- package/dist/cli/commands/kendo-ui-license.js +17 -5
- package/dist/cli/commands/kendo-ui-license.js.map +1 -1
- package/dist/cli/commands/lint.d.ts +31 -12
- package/dist/cli/commands/lint.d.ts.map +1 -1
- package/dist/cli/commands/lint.js +34 -13
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/mfe-list.d.ts +46 -0
- package/dist/cli/commands/mfe-list.d.ts.map +1 -0
- package/dist/cli/commands/mfe-list.js +200 -0
- package/dist/cli/commands/mfe-list.js.map +1 -0
- package/dist/cli/commands/mfe-package-clean.d.ts +29 -5
- package/dist/cli/commands/mfe-package-clean.d.ts.map +1 -1
- package/dist/cli/commands/mfe-package-clean.js +28 -5
- package/dist/cli/commands/mfe-package-clean.js.map +1 -1
- package/dist/cli/commands/mfe-package-publish.d.ts +37 -5
- package/dist/cli/commands/mfe-package-publish.d.ts.map +1 -1
- package/dist/cli/commands/mfe-package-publish.js +36 -5
- package/dist/cli/commands/mfe-package-publish.js.map +1 -1
- package/dist/cli/commands/mfe-publish.d.ts +17 -4
- package/dist/cli/commands/mfe-publish.d.ts.map +1 -1
- package/dist/cli/commands/mfe-publish.js +37 -7
- package/dist/cli/commands/mfe-publish.js.map +1 -1
- package/dist/cli/commands/prepare-package.d.ts +3 -5
- package/dist/cli/commands/prepare-package.d.ts.map +1 -1
- package/dist/cli/commands/prepare-package.js +2 -18
- package/dist/cli/commands/prepare-package.js.map +1 -1
- package/dist/cli/commands/review/review.d.ts +14 -6
- package/dist/cli/commands/review/review.d.ts.map +1 -1
- package/dist/cli/commands/review/review.js +27 -23
- package/dist/cli/commands/review/review.js.map +1 -1
- package/dist/cli/commands/run-task.d.ts +10 -6
- package/dist/cli/commands/run-task.d.ts.map +1 -1
- package/dist/cli/commands/run-task.js +16 -13
- package/dist/cli/commands/run-task.js.map +1 -1
- package/dist/cli/commands/start.d.ts +28 -7
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +27 -10
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/styles-check.d.ts +2 -2
- package/dist/cli/commands/styles-check.d.ts.map +1 -1
- package/dist/cli/commands/styles-check.js +2 -1
- package/dist/cli/commands/styles-check.js.map +1 -1
- package/dist/cli/commands/test/tests.d.ts +14 -5
- package/dist/cli/commands/test/tests.d.ts.map +1 -1
- package/dist/cli/commands/test/tests.js +26 -13
- package/dist/cli/commands/test/tests.js.map +1 -1
- package/dist/cli/commands/types.d.ts +13 -4
- package/dist/cli/commands/types.d.ts.map +1 -1
- package/dist/cli/commands/types.js +28 -0
- package/dist/cli/commands/types.js.map +1 -1
- package/dist/cli/commands/upload-sourcemaps.d.ts +3 -5
- package/dist/cli/commands/upload-sourcemaps.d.ts.map +1 -1
- package/dist/cli/commands/upload-sourcemaps.js +5 -20
- package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
- package/dist/cli/index.js +47 -39
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/tasks/swc-compile-package.d.ts +2 -2
- package/dist/cli/tasks/swc-compile-package.d.ts.map +1 -1
- package/dist/cli/tasks/swc-compile-package.js.map +1 -1
- package/dist/cli/tasks/tsc-compile-package.d.ts +2 -2
- package/dist/cli/tasks/tsc-compile-package.d.ts.map +1 -1
- package/dist/cli/tasks/tsc-compile-package.js +1 -1
- package/dist/cli/tasks/tsc-compile-package.js.map +1 -1
- package/dist/cli/tasks/tsc-compile.d.ts +2 -2
- package/dist/cli/tasks/tsc-compile.d.ts.map +1 -1
- package/dist/cli/tasks/tsc-compile.js.map +1 -1
- package/dist/cli/utils/bundle.js +1 -1
- package/dist/cli/utils/bundle.js.map +1 -1
- package/dist/cli/utils/cli-npm.d.ts +14 -0
- package/dist/cli/utils/cli-npm.d.ts.map +1 -1
- package/dist/cli/utils/cli-npm.js +44 -0
- package/dist/cli/utils/cli-npm.js.map +1 -1
- package/dist/cli/utils/cli-os.d.ts +2 -2
- package/dist/cli/utils/cli-os.d.ts.map +1 -1
- package/dist/cli/utils/cli-os.js +13 -9
- package/dist/cli/utils/cli-os.js.map +1 -1
- package/dist/cli/utils/eslint.d.ts +2 -1
- package/dist/cli/utils/eslint.d.ts.map +1 -1
- package/dist/cli/utils/eslint.js.map +1 -1
- package/dist/cli/utils/index.d.ts +1 -0
- package/dist/cli/utils/index.d.ts.map +1 -1
- package/dist/cli/utils/index.js +1 -0
- package/dist/cli/utils/index.js.map +1 -1
- package/dist/cli/utils/is-tty.d.ts +2 -0
- package/dist/cli/utils/is-tty.d.ts.map +1 -0
- package/dist/cli/utils/is-tty.js +15 -0
- package/dist/cli/utils/is-tty.js.map +1 -0
- package/dist/cli/utils/lerna-exec.d.ts.map +1 -1
- package/dist/cli/utils/lerna-exec.js +2 -0
- package/dist/cli/utils/lerna-exec.js.map +1 -1
- package/dist/cli/utils/maybe-create-git-folder.d.ts +2 -3
- package/dist/cli/utils/maybe-create-git-folder.d.ts.map +1 -1
- package/dist/cli/utils/maybe-create-git-folder.js +4 -9
- package/dist/cli/utils/maybe-create-git-folder.js.map +1 -1
- package/dist/cli/utils/process-tree.d.ts.map +1 -1
- package/dist/cli/utils/process-tree.js +2 -2
- package/dist/cli/utils/process-tree.js.map +1 -1
- package/dist/cli/utils/set-node-options.d.ts.map +1 -1
- package/dist/cli/utils/set-node-options.js +2 -1
- package/dist/cli/utils/set-node-options.js.map +1 -1
- package/dist/utils/find-packages.d.ts +1 -0
- package/dist/utils/find-packages.d.ts.map +1 -1
- package/dist/utils/find-packages.js.map +1 -1
- package/dist/utils/format-relative-date.d.ts +2 -0
- package/dist/utils/format-relative-date.d.ts.map +1 -0
- package/dist/utils/format-relative-date.js +60 -0
- package/dist/utils/format-relative-date.js.map +1 -0
- package/dist/utils/get-configuration.d.ts +1 -0
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +1 -0
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/get-packages.d.ts +3 -5
- package/dist/utils/get-packages.d.ts.map +1 -1
- package/dist/utils/get-packages.js +1 -4
- package/dist/utils/get-packages.js.map +1 -1
- package/dist/utils/get-startup-version.d.ts.map +1 -1
- package/dist/utils/get-startup-version.js +1 -1
- package/dist/utils/get-startup-version.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/webpack/configs/loaders/style-loader.d.ts +1 -1
- package/dist/webpack/configs/loaders/style-loader.d.ts.map +1 -1
- package/dist/webpack/configs/loaders/style-loader.js +2 -2
- package/dist/webpack/configs/loaders/style-loader.js.map +1 -1
- package/dist/webpack/configs/optimization-config.js +5 -5
- package/dist/webpack/configs/optimization-config.js.map +1 -1
- package/dist/webpack/configs/output-config.d.ts.map +1 -1
- package/dist/webpack/configs/output-config.js +14 -7
- package/dist/webpack/configs/output-config.js.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js +10 -3
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js.map +1 -1
- package/package.json +9 -8
- package/src/cli/commands/__tests__/build.test.ts +1 -1
- package/src/cli/commands/__tests__/bundle-package.test.ts +22 -2
- package/src/cli/commands/__tests__/install.test.ts +42 -4
- package/src/cli/commands/__tests__/lint.test.ts +1 -1
- package/src/cli/commands/__tests__/mfe-list.test.ts +394 -0
- package/src/cli/commands/__tests__/mfe-publish.test.ts +25 -0
- package/src/cli/commands/__tests__/start.test.ts +1 -1
- package/src/cli/commands/build.ts +14 -10
- package/src/cli/commands/bundle-package.ts +19 -13
- package/src/cli/commands/clean.ts +2 -4
- package/src/cli/commands/convert-eslint-config.ts +3 -5
- package/src/cli/commands/eslint.ts +3 -5
- package/src/cli/commands/get-command.ts +2 -0
- package/src/cli/commands/index.ts +0 -1
- package/src/cli/commands/init.ts +7 -8
- package/src/cli/commands/install.ts +24 -11
- package/src/cli/commands/kendo-ui-license.ts +4 -6
- package/src/cli/commands/lint.ts +19 -19
- package/src/cli/commands/mfe-list.ts +173 -0
- package/src/cli/commands/mfe-package-clean.ts +25 -4
- package/src/cli/commands/mfe-package-publish.ts +33 -4
- package/src/cli/commands/mfe-publish.ts +37 -6
- package/src/cli/commands/prepare-package.ts +3 -5
- package/src/cli/commands/review/review.ts +9 -9
- package/src/cli/commands/run-task.ts +15 -11
- package/src/cli/commands/start.ts +12 -10
- package/src/cli/commands/styles-check.ts +2 -2
- package/src/cli/commands/test/__tests__/tests.test.ts +1 -1
- package/src/cli/commands/test/tests.ts +20 -10
- package/src/cli/commands/types.ts +14 -4
- package/src/cli/commands/upload-sourcemaps.ts +3 -5
- package/src/cli/index.ts +59 -37
- package/src/cli/tasks/swc-compile-package.ts +2 -2
- package/src/cli/tasks/tsc-compile-package.ts +4 -3
- package/src/cli/tasks/tsc-compile.ts +2 -2
- package/src/cli/utils/__tests__/bundle.test.ts +13 -0
- package/src/cli/utils/__tests__/cli-npm.test.ts +89 -0
- package/src/cli/utils/__tests__/is-tty.test.ts +17 -0
- package/src/cli/utils/__tests__/lerna-exec.test.ts +7 -0
- package/src/cli/utils/__tests__/maybe-create-git-folder.test.ts +11 -32
- package/src/cli/utils/__tests__/set-node-options.test.ts +10 -10
- package/src/cli/utils/bundle.ts +1 -1
- package/src/cli/utils/cli-npm.ts +34 -0
- package/src/cli/utils/cli-os.ts +12 -25
- package/src/cli/utils/eslint.ts +2 -1
- package/src/cli/utils/index.ts +1 -0
- package/src/cli/utils/is-tty.ts +3 -0
- package/src/cli/utils/lerna-exec.ts +3 -0
- package/src/cli/utils/maybe-create-git-folder.ts +5 -12
- package/src/cli/utils/process-tree.ts +4 -2
- package/src/cli/utils/set-node-options.ts +2 -1
- package/src/utils/__tests__/format-relative-date.test.ts +61 -0
- package/src/utils/__tests__/get-packages.test.ts +3 -0
- package/src/utils/find-packages.ts +1 -0
- package/src/utils/format-relative-date.ts +33 -0
- package/src/utils/get-configuration.ts +1 -0
- package/src/utils/get-packages.ts +3 -9
- package/src/utils/get-startup-version.ts +1 -3
- package/src/utils/index.ts +1 -0
- package/src/webpack/__mocks__/style-rules.ts +3 -3
- package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +6 -14
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +52 -29
- package/src/webpack/configs/loaders/style-loader.ts +5 -2
- package/src/webpack/configs/optimization-config.ts +5 -5
- package/src/webpack/configs/output-config.ts +10 -5
- package/src/webpack/configs/plugins/assets-manifest-plugin.ts +11 -4
- package/dist/cli/commands/get-user-commands.d.ts +0 -7
- package/dist/cli/commands/get-user-commands.d.ts.map +0 -1
- package/dist/cli/commands/get-user-commands.js +0 -27
- package/dist/cli/commands/get-user-commands.js.map +0 -1
- package/src/cli/commands/__tests__/get-user-commands.test.ts +0 -27
- package/src/cli/commands/get-user-commands.ts +0 -19
|
@@ -1,57 +1,36 @@
|
|
|
1
1
|
import { fs, vol } from 'memfs';
|
|
2
2
|
|
|
3
3
|
import { maybeCreateGitFolder } from '../maybe-create-git-folder';
|
|
4
|
-
import { Init } from '../../commands/init';
|
|
5
|
-
import { Start } from '../../commands/start';
|
|
6
4
|
|
|
7
5
|
jest.mock('fs', () => fs);
|
|
8
6
|
|
|
9
7
|
describe(`[startup] Utils`, () => {
|
|
10
8
|
describe(`${maybeCreateGitFolder.name}`, () => {
|
|
11
|
-
let command: Parameters<typeof maybeCreateGitFolder>[0];
|
|
12
9
|
const mkdirSpy = jest.spyOn(fs, 'mkdirSync').mockImplementation(jest.fn());
|
|
13
10
|
|
|
14
11
|
beforeEach(() => {
|
|
15
|
-
|
|
16
|
-
vol.fromJSON({});
|
|
12
|
+
jest.clearAllMocks();
|
|
13
|
+
vol.fromJSON({ 'lerna.json': '' });
|
|
17
14
|
});
|
|
18
15
|
|
|
19
16
|
afterEach(() => vol.reset);
|
|
20
17
|
|
|
21
|
-
const subject = () => maybeCreateGitFolder(
|
|
18
|
+
const subject = () => maybeCreateGitFolder();
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
subject();
|
|
20
|
+
test('creates .git folder', () => {
|
|
21
|
+
subject();
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
23
|
+
expect(mkdirSpy).toHaveBeenCalledWith('.git', { recursive: true });
|
|
24
|
+
});
|
|
30
25
|
|
|
31
|
-
describe('when
|
|
32
|
-
beforeEach(() =>
|
|
33
|
-
Object.defineProperty(process, 'platform', { value: 'win32' });
|
|
34
|
-
});
|
|
26
|
+
describe('when directory does not contain lerna.json', () => {
|
|
27
|
+
beforeEach(() => fs.rmSync('lerna.json'));
|
|
35
28
|
|
|
36
|
-
test('
|
|
29
|
+
test('does not create .git folder', () => {
|
|
37
30
|
subject();
|
|
38
31
|
|
|
39
|
-
expect(mkdirSpy).
|
|
32
|
+
expect(mkdirSpy).not.toHaveBeenCalled();
|
|
40
33
|
});
|
|
41
|
-
|
|
42
|
-
describe('when command is Init', () => {
|
|
43
|
-
beforeEach(() => (command = Init));
|
|
44
|
-
|
|
45
|
-
itDoesNotCreateGitFolder();
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('when not running on Windows', () => {
|
|
50
|
-
beforeEach(() => {
|
|
51
|
-
Object.defineProperty(process, 'platform', { value: 'linux' });
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
itDoesNotCreateGitFolder();
|
|
55
34
|
});
|
|
56
35
|
});
|
|
57
36
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import os from 'os';
|
|
2
2
|
import { getConfigurationSafe } from '../../../utils';
|
|
3
|
-
import { Command } from '../../commands';
|
|
3
|
+
import { Command } from '../../commands/types';
|
|
4
4
|
|
|
5
5
|
import { setNodeOptions } from '../set-node-options';
|
|
6
6
|
|
|
@@ -13,15 +13,11 @@ jest.mock('../../../utils', () => ({
|
|
|
13
13
|
getConfigurationSafe: jest.fn(() => ({})),
|
|
14
14
|
}));
|
|
15
15
|
|
|
16
|
-
class MockCommand
|
|
17
|
-
get greedy() {
|
|
16
|
+
class MockCommand extends Command {
|
|
17
|
+
static get greedy() {
|
|
18
18
|
return true;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
description() {
|
|
22
|
-
return 'mock command';
|
|
23
|
-
}
|
|
24
|
-
|
|
25
21
|
async execute() {
|
|
26
22
|
return Promise.resolve();
|
|
27
23
|
}
|
|
@@ -33,12 +29,16 @@ describe(`[startup] utils:${setNodeOptions.name}`, () => {
|
|
|
33
29
|
const originalNodeOptions = process.env.NODE_OPTIONS;
|
|
34
30
|
const maxOldSpaceSize = `--max_old_space_size=${DEFAULT_SIZE}`;
|
|
35
31
|
const commandName: any = 'mock';
|
|
36
|
-
const command = new MockCommand();
|
|
32
|
+
const command = new MockCommand({});
|
|
33
|
+
let greedy: boolean;
|
|
37
34
|
|
|
38
35
|
beforeEach(() => {
|
|
36
|
+
greedy = true;
|
|
39
37
|
delete process.env.NODE_OPTIONS;
|
|
40
38
|
(os.totalmem as jest.Mock).mockReturnValue(16384 * MB);
|
|
41
|
-
jest.spyOn(command, 'greedy', 'get').
|
|
39
|
+
jest.spyOn(command.constructor as typeof Command, 'greedy', 'get').mockImplementation(
|
|
40
|
+
() => greedy
|
|
41
|
+
);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
afterAll(() => (process.env.NODE_OPTIONS = originalNodeOptions));
|
|
@@ -52,7 +52,7 @@ describe(`[startup] utils:${setNodeOptions.name}`, () => {
|
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
describe('when the command is not greedy', () => {
|
|
55
|
-
beforeEach(() =>
|
|
55
|
+
beforeEach(() => (greedy = false));
|
|
56
56
|
|
|
57
57
|
test('returns false and does not set NODE_OPTIONS', () => {
|
|
58
58
|
expect(subject()).toBe(false);
|
package/src/cli/utils/bundle.ts
CHANGED
|
@@ -52,7 +52,7 @@ export async function bundle(options: Options = {}) {
|
|
|
52
52
|
|
|
53
53
|
log.info(`Bundling ${emitExposedDependencies ? 'exposed dependencies' : 'package'}...`);
|
|
54
54
|
|
|
55
|
-
const mode = watch ? 'development' : 'production';
|
|
55
|
+
const mode = watch || useWatchConfig ? 'development' : 'production';
|
|
56
56
|
const fallback = watch || useWatchConfig ? webpackDevConfigFileName : webpackProdConfigFileName;
|
|
57
57
|
const customConfig = readWebpackConfig({ ...options, fallback });
|
|
58
58
|
const webpackOptions = getWebpackOptions(options, customConfig);
|
package/src/cli/utils/cli-npm.ts
CHANGED
|
@@ -73,3 +73,37 @@ export async function npmTagVersion({
|
|
|
73
73
|
}add ${packageName}@${packageVersion} ${tag}`
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
export interface NPMPackageInfo {
|
|
78
|
+
'name': string;
|
|
79
|
+
'version': string;
|
|
80
|
+
'dist-tags'?: Record<string, string>;
|
|
81
|
+
'time'?: Record<string, string>;
|
|
82
|
+
'versions'?: string[];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function npmView({ packageName, registry }: { packageName: string; registry?: string }) {
|
|
86
|
+
try {
|
|
87
|
+
const result = runCommandOutput(
|
|
88
|
+
['npm', 'view', '--json', registry ? `--registry=${registry}` : '', packageName],
|
|
89
|
+
{ quiet: true, timeout: NPM_TIMEOUT }
|
|
90
|
+
);
|
|
91
|
+
if (result) {
|
|
92
|
+
return JSON.parse(result) as NPMPackageInfo;
|
|
93
|
+
}
|
|
94
|
+
} catch {
|
|
95
|
+
// ignore
|
|
96
|
+
}
|
|
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
|
+
}
|
package/src/cli/utils/cli-os.ts
CHANGED
|
@@ -8,25 +8,19 @@ import { log } from '../../utils';
|
|
|
8
8
|
|
|
9
9
|
type RunCommandOptions = SpawnOptionsWithoutStdio & { quiet?: boolean };
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export async function runCommand(
|
|
12
12
|
command: string | (string | false)[],
|
|
13
13
|
{ quiet, ...spawnOptions }: RunCommandOptions = {}
|
|
14
|
-
)
|
|
15
|
-
return new Promise((resolve, reject) => {
|
|
14
|
+
) {
|
|
15
|
+
return new Promise<void>((resolve, reject) => {
|
|
16
16
|
const commandArray: string[] = Array.isArray(command)
|
|
17
|
-
? command
|
|
18
|
-
.filter(c => !!c)
|
|
19
|
-
.map(c => c.toString())
|
|
20
|
-
.join(' ')
|
|
21
|
-
.split(' ')
|
|
17
|
+
? command.reduce((acc, el) => (el ? [...acc, ...el.toString().split(' ')] : acc), [])
|
|
22
18
|
: command.split(' ');
|
|
23
19
|
const fullCommand = commandArray.join(' ');
|
|
24
|
-
|
|
25
20
|
const commandName = commandArray.shift();
|
|
26
21
|
|
|
27
22
|
if (!commandName) {
|
|
28
23
|
reject(new Error('invalid command'));
|
|
29
|
-
|
|
30
24
|
return;
|
|
31
25
|
}
|
|
32
26
|
|
|
@@ -57,26 +51,19 @@ export const runCommand = (
|
|
|
57
51
|
reject(e);
|
|
58
52
|
});
|
|
59
53
|
});
|
|
60
|
-
}
|
|
54
|
+
}
|
|
61
55
|
|
|
62
56
|
type RunCommandOutputOptions = ExecSyncOptionsWithBufferEncoding & { quiet?: boolean };
|
|
63
57
|
|
|
64
|
-
export
|
|
58
|
+
export function runCommandOutput(
|
|
65
59
|
command: string | (string | false)[],
|
|
66
60
|
{ quiet, ...execSyncOptions }: RunCommandOutputOptions = {}
|
|
67
|
-
)
|
|
68
|
-
const
|
|
69
|
-
? command
|
|
70
|
-
|
|
71
|
-
.map(c => c.toString())
|
|
72
|
-
.join(' ')
|
|
73
|
-
.split(' ')
|
|
74
|
-
: command.split(' ');
|
|
75
|
-
const fullCommand = commandArray.join(' ');
|
|
76
|
-
|
|
77
|
-
const commandName = commandArray.shift();
|
|
61
|
+
) {
|
|
62
|
+
const fullCommand = Array.isArray(command)
|
|
63
|
+
? command.reduce((acc, el) => (el ? [...acc, el.toString()] : acc), []).join(' ')
|
|
64
|
+
: command;
|
|
78
65
|
|
|
79
|
-
if (!
|
|
66
|
+
if (!fullCommand) {
|
|
80
67
|
throw new Error();
|
|
81
68
|
}
|
|
82
69
|
|
|
@@ -91,4 +78,4 @@ export const runCommandOutput = (
|
|
|
91
78
|
}
|
|
92
79
|
|
|
93
80
|
return result;
|
|
94
|
-
}
|
|
81
|
+
}
|
package/src/cli/utils/eslint.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ESLint } from 'eslint';
|
|
2
2
|
|
|
3
3
|
import { getDestinationFolders, getESLintConfiguration, log } from '../../utils';
|
|
4
|
+
import { CommandArgs } from '../commands';
|
|
4
5
|
|
|
5
|
-
interface Args {
|
|
6
|
+
interface Args extends CommandArgs {
|
|
6
7
|
fix?: boolean;
|
|
7
8
|
paths: string[];
|
|
8
9
|
}
|
package/src/cli/utils/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './eslint';
|
|
|
11
11
|
export * from './get-module-type';
|
|
12
12
|
export * from './is-ci';
|
|
13
13
|
export * from './is-module-installed';
|
|
14
|
+
export * from './is-tty';
|
|
14
15
|
export * from './lerna-exec';
|
|
15
16
|
export * from './maybe-create-git-folder';
|
|
16
17
|
export * from './pipe-stdout';
|
|
@@ -3,6 +3,7 @@ import os from 'node:os';
|
|
|
3
3
|
|
|
4
4
|
import { log } from '../../utils';
|
|
5
5
|
import { isCI } from './is-ci';
|
|
6
|
+
import { maybeCreateGitFolder } from './maybe-create-git-folder';
|
|
6
7
|
|
|
7
8
|
interface Args {
|
|
8
9
|
'bail'?: boolean;
|
|
@@ -15,6 +16,8 @@ interface Args {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export function lernaExec(args: Args) {
|
|
19
|
+
maybeCreateGitFolder();
|
|
20
|
+
|
|
18
21
|
const lernaArguments = [
|
|
19
22
|
'exec',
|
|
20
23
|
...getOptions(args),
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
|
|
3
|
-
import { Init } from '../commands/init';
|
|
4
|
-
import { Command, Newable } from '../commands/types';
|
|
2
|
+
import { log } from '../../utils';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* Create empty .git folder to workaround issue where Lerna does not
|
|
8
|
-
* detect workspace packages
|
|
6
|
+
* detect workspace packages. The empty .git folder
|
|
9
7
|
* causes nx to use the git-hasher when building the project graph.
|
|
10
8
|
* Note this gets fixed (e.g., https://github.com/nrwl/nx/issues/8601) but
|
|
11
9
|
* keeps reappearing (e.g., https://github.com/nrwl/nx/issues/9584 and
|
|
12
10
|
* https://github.com/nrwl/nx/issues/18094)
|
|
13
11
|
*/
|
|
14
|
-
export function maybeCreateGitFolder(
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
if (command === Init) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (!fs.existsSync('.git')) {
|
|
12
|
+
export function maybeCreateGitFolder() {
|
|
13
|
+
if (!fs.existsSync('.git') && fs.existsSync('lerna.json')) {
|
|
14
|
+
log.debug('maybe-create-git-folder', 'creating .git folder');
|
|
22
15
|
/*
|
|
23
16
|
* Using {recursive: true} to ignore if directory exists. This happens
|
|
24
17
|
* when parallel process creates the directory after we've checked
|
|
@@ -42,7 +42,7 @@ export class ProcessTree<T extends Record<any, any> = never> {
|
|
|
42
42
|
const entry = this.#entries.get(item)!;
|
|
43
43
|
|
|
44
44
|
const handlerResult = Promise.all(
|
|
45
|
-
entry.dependsOn.map(item => this.#entries.get(item)!.onComplete)
|
|
45
|
+
entry.dependsOn.map(item => this.#entries.get(item)!.onComplete).filter(el => !!el)
|
|
46
46
|
).then(() => ({ result: entry.handler() }));
|
|
47
47
|
|
|
48
48
|
entry.process = handlerResult.then(({ result }) =>
|
|
@@ -52,6 +52,8 @@ export class ProcessTree<T extends Record<any, any> = never> {
|
|
|
52
52
|
isHandlerResultObject(result) ? (result.onComplete ?? result.process) : result
|
|
53
53
|
);
|
|
54
54
|
});
|
|
55
|
-
return Promise.all(
|
|
55
|
+
return Promise.all(
|
|
56
|
+
[...this.#entries.values()].map(item => item.process).filter(el => !!el)
|
|
57
|
+
);
|
|
56
58
|
}
|
|
57
59
|
}
|
|
@@ -25,7 +25,8 @@ export function setNodeOptions(commandName: CommandName, command: Command) {
|
|
|
25
25
|
}, oldNodeOptions)
|
|
26
26
|
.trim();
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const greedy = (command.constructor as typeof Command).greedy;
|
|
29
|
+
const newNodeOptions = ensureMaxOldSpaceSize(mergedOptions, greedy);
|
|
29
30
|
if (newNodeOptions !== oldNodeOptions) {
|
|
30
31
|
process.env.NODE_OPTIONS = newNodeOptions;
|
|
31
32
|
return true;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { formatRelativeDate } from '../format-relative-date';
|
|
2
|
+
|
|
3
|
+
describe('[startup] Utils', () => {
|
|
4
|
+
describe(formatRelativeDate.name, () => {
|
|
5
|
+
beforeAll(() => {
|
|
6
|
+
jest.useFakeTimers();
|
|
7
|
+
jest.setSystemTime(new Date(2025, 0, 1));
|
|
8
|
+
});
|
|
9
|
+
afterAll(() => jest.useRealTimers());
|
|
10
|
+
|
|
11
|
+
type DateUnit = 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years';
|
|
12
|
+
|
|
13
|
+
function adjustDate(when: Date, amount: number, by: DateUnit) {
|
|
14
|
+
const result = new Date(when);
|
|
15
|
+
if (by === 'seconds') {
|
|
16
|
+
result.setSeconds(when.getSeconds() + amount);
|
|
17
|
+
} else if (by === 'minutes') {
|
|
18
|
+
result.setMinutes(when.getMinutes() + amount);
|
|
19
|
+
} else if (by === 'hours') {
|
|
20
|
+
result.setHours(when.getHours() + amount);
|
|
21
|
+
} else if (by === 'days') {
|
|
22
|
+
result.setDate(when.getDate() + amount);
|
|
23
|
+
} else if (by === 'months') {
|
|
24
|
+
result.setMonth(when.getMonth() + amount);
|
|
25
|
+
} else if (by === 'years') {
|
|
26
|
+
result.setFullYear(when.getFullYear() + amount);
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
test.each<{
|
|
32
|
+
delta: [number, DateUnit];
|
|
33
|
+
expected: string;
|
|
34
|
+
}>([
|
|
35
|
+
{ delta: [0, 'seconds'], expected: 'in 0 seconds' },
|
|
36
|
+
{ delta: [1, 'seconds'], expected: 'in 1 second' },
|
|
37
|
+
{ delta: [-2, 'seconds'], expected: '2 seconds ago' },
|
|
38
|
+
{ delta: [1, 'minutes'], expected: 'in 1 minute' },
|
|
39
|
+
{ delta: [-2, 'minutes'], expected: '2 minutes ago' },
|
|
40
|
+
{ delta: [1, 'hours'], expected: 'in 1 hour' },
|
|
41
|
+
{ delta: [-2, 'hours'], expected: '2 hours ago' },
|
|
42
|
+
{ delta: [1, 'days'], expected: 'in 1 day' },
|
|
43
|
+
{ delta: [-2, 'days'], expected: '2 days ago' },
|
|
44
|
+
{ delta: [1, 'months'], expected: 'in 1 month' },
|
|
45
|
+
{ delta: [-2, 'months'], expected: '2 months ago' },
|
|
46
|
+
{ delta: [1, 'years'], expected: 'in 1 year' },
|
|
47
|
+
{ delta: [-2, 'years'], expected: '2 years ago' },
|
|
48
|
+
])(
|
|
49
|
+
`with $delta.0 $delta.1 from now, returns "$expected"`,
|
|
50
|
+
({ delta: [amount, unit], expected }) => {
|
|
51
|
+
const now = new Date();
|
|
52
|
+
const from = adjustDate(now, amount, unit);
|
|
53
|
+
expect(formatRelativeDate(from, now)).toBe(expected);
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
test('with no "to", returns time relative to now', () => {
|
|
58
|
+
expect(formatRelativeDate(Date.now() - 61 * 1000)).toEqual('1 minute ago');
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -73,6 +73,7 @@ describe('[startup] Utils', () => {
|
|
|
73
73
|
private: false,
|
|
74
74
|
location: path.resolve('./legacy/bar'),
|
|
75
75
|
type: PackageType.Legacy,
|
|
76
|
+
cli: { legacy: true },
|
|
76
77
|
},
|
|
77
78
|
{
|
|
78
79
|
name: 'baz',
|
|
@@ -80,6 +81,7 @@ describe('[startup] Utils', () => {
|
|
|
80
81
|
private: false,
|
|
81
82
|
location: path.resolve('./examples/baz'),
|
|
82
83
|
type: PackageType.TSC,
|
|
84
|
+
cli: { webpack: false },
|
|
83
85
|
},
|
|
84
86
|
{
|
|
85
87
|
name: 'qux',
|
|
@@ -87,6 +89,7 @@ describe('[startup] Utils', () => {
|
|
|
87
89
|
private: false,
|
|
88
90
|
location: path.resolve('./examples/qux'),
|
|
89
91
|
type: PackageType.TSC,
|
|
92
|
+
cli: { webpack: false },
|
|
90
93
|
},
|
|
91
94
|
]);
|
|
92
95
|
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const SECOND = 1000;
|
|
2
|
+
const MINUTE = 60 * SECOND;
|
|
3
|
+
const HOUR = MINUTE * 60;
|
|
4
|
+
const DAY = HOUR * 24;
|
|
5
|
+
const MONTH = DAY * 30;
|
|
6
|
+
const YEAR = DAY * 365;
|
|
7
|
+
|
|
8
|
+
const table: { threshold: number; divisor: number; unit: Intl.RelativeTimeFormatUnit }[] = [
|
|
9
|
+
{ threshold: MINUTE, divisor: SECOND, unit: 'seconds' },
|
|
10
|
+
{ threshold: HOUR, divisor: MINUTE, unit: 'minutes' },
|
|
11
|
+
{ threshold: DAY, divisor: HOUR, unit: 'hours' },
|
|
12
|
+
{ threshold: MONTH, divisor: DAY, unit: 'days' },
|
|
13
|
+
{ threshold: YEAR, divisor: MONTH, unit: 'months' },
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
export function formatRelativeDate(
|
|
17
|
+
from: Date | string | number,
|
|
18
|
+
to?: Date | string | number,
|
|
19
|
+
locale?: string
|
|
20
|
+
) {
|
|
21
|
+
const dateFrom = new Date(from);
|
|
22
|
+
const dateTo = to ? new Date(to) : new Date();
|
|
23
|
+
const delta = dateFrom.getTime() - dateTo.getTime();
|
|
24
|
+
const absoluteDelta = Math.abs(delta);
|
|
25
|
+
const { divisor, unit } = table.find(({ threshold }) => absoluteDelta < threshold) ?? {
|
|
26
|
+
divisor: YEAR,
|
|
27
|
+
unit: 'years',
|
|
28
|
+
};
|
|
29
|
+
return new Intl.RelativeTimeFormat(locale, {
|
|
30
|
+
style: 'long',
|
|
31
|
+
numeric: 'always',
|
|
32
|
+
}).format(Math.round(delta / divisor), unit);
|
|
33
|
+
}
|
|
@@ -71,6 +71,7 @@ export enum CommandName {
|
|
|
71
71
|
'install' = 'install',
|
|
72
72
|
'kendo-ui-license' = 'kendo-ui-license',
|
|
73
73
|
'lint' = 'lint',
|
|
74
|
+
'mfe-list' = 'mfe-list',
|
|
74
75
|
'mfe-package-clean' = 'mfe-package-clean',
|
|
75
76
|
'mfe-package-publish' = 'mfe-package-publish',
|
|
76
77
|
'mfe-publish' = 'mfe-publish',
|
|
@@ -9,12 +9,9 @@ export enum PackageType {
|
|
|
9
9
|
Legacy,
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export interface Package {
|
|
13
|
-
name: string;
|
|
14
|
-
type: PackageType;
|
|
15
|
-
version: string;
|
|
12
|
+
export interface Package extends ProjectPackage {
|
|
16
13
|
private: boolean;
|
|
17
|
-
|
|
14
|
+
type: PackageType;
|
|
18
15
|
}
|
|
19
16
|
|
|
20
17
|
interface GetPackagesOptions {
|
|
@@ -113,12 +110,9 @@ function filterPackages(packages: ProjectPackage[], options: GetPackagesOptions)
|
|
|
113
110
|
|
|
114
111
|
function withMetadata(packages: ProjectPackage[]): Package[] {
|
|
115
112
|
return packages.map(pkg => {
|
|
116
|
-
const { name, version, location } = pkg;
|
|
117
113
|
return {
|
|
118
|
-
|
|
119
|
-
version,
|
|
114
|
+
...pkg,
|
|
120
115
|
private: pkg.private ?? false,
|
|
121
|
-
location,
|
|
122
116
|
type: getPackageType(pkg),
|
|
123
117
|
};
|
|
124
118
|
});
|
|
@@ -2,7 +2,5 @@ import path from 'path';
|
|
|
2
2
|
import { readJson } from './read-json';
|
|
3
3
|
|
|
4
4
|
export function getStartupVersion() {
|
|
5
|
-
return readJson(
|
|
6
|
-
path.join(path.dirname(require.resolve('@servicetitan/startup')), '../package.json')
|
|
7
|
-
).version;
|
|
5
|
+
return readJson(path.join(__dirname, '../../package.json')).version;
|
|
8
6
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -81,7 +81,7 @@ export const styleRules: Record<string, StyleRule> = {
|
|
|
81
81
|
},
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
export const
|
|
84
|
+
export const miniCssPluginStyleRules = Object.entries(styleRules).reduce(
|
|
85
85
|
(result, [key, rule]) => {
|
|
86
86
|
result[key] = { ...rule, use: rule.use?.map(transformStyleLoader) };
|
|
87
87
|
return result;
|
|
@@ -89,7 +89,7 @@ export const webComponentStyleRules = Object.entries(styleRules).reduce(
|
|
|
89
89
|
{} as typeof styleRules
|
|
90
90
|
);
|
|
91
91
|
|
|
92
|
-
export const productionStyleRules = Object.entries(
|
|
92
|
+
export const productionStyleRules = Object.entries(miniCssPluginStyleRules).reduce(
|
|
93
93
|
(result, [key, rule]) => {
|
|
94
94
|
if (key === '.css') {
|
|
95
95
|
result[key] = { ...rule, exclude: /\.module.css$/ }; // production doesn't use callback?!
|
|
@@ -98,7 +98,7 @@ export const productionStyleRules = Object.entries(webComponentStyleRules).reduc
|
|
|
98
98
|
}
|
|
99
99
|
return result;
|
|
100
100
|
},
|
|
101
|
-
{} as typeof
|
|
101
|
+
{} as typeof miniCssPluginStyleRules
|
|
102
102
|
);
|
|
103
103
|
|
|
104
104
|
/**
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
log,
|
|
21
21
|
pick,
|
|
22
22
|
} from '../../utils';
|
|
23
|
-
import {
|
|
23
|
+
import { miniCssPluginStyleRules } from '../__mocks__';
|
|
24
24
|
import { getLaunchDarklySdkVersion } from '../configs/utils/get-launchdarkly-sdk-version';
|
|
25
25
|
import { getModuleEntryPath } from '../utils';
|
|
26
26
|
|
|
@@ -218,7 +218,7 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
218
218
|
);
|
|
219
219
|
});
|
|
220
220
|
|
|
221
|
-
Object.entries(
|
|
221
|
+
Object.entries(miniCssPluginStyleRules).forEach(([extension, rule]) => {
|
|
222
222
|
test(`configures "${extension}" rules`, () => {
|
|
223
223
|
expect(subject().module?.rules).toContainEqual(rule);
|
|
224
224
|
});
|
|
@@ -226,12 +226,8 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
226
226
|
});
|
|
227
227
|
});
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
test('configures "output.clean" to keep shared dependencies', () => {
|
|
233
|
-
expect(subject().output?.clean).toEqual({ keep: /shared/ });
|
|
234
|
-
});
|
|
229
|
+
test('configures "output.clean" to keep shared dependencies', () => {
|
|
230
|
+
expect(subject().output?.clean).toEqual({ keep: /shared/ });
|
|
235
231
|
});
|
|
236
232
|
|
|
237
233
|
describe('with bundled exposed dependencies', () => {
|
|
@@ -408,12 +404,8 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
408
404
|
expect(HtmlWebpackPlugin).not.toHaveBeenCalled();
|
|
409
405
|
});
|
|
410
406
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
test('configures "output.clean" to true', () => {
|
|
415
|
-
expect(subject().output?.clean).toBe(true);
|
|
416
|
-
});
|
|
407
|
+
test('configures "output.clean" to true', () => {
|
|
408
|
+
expect(subject().output?.clean).toBe(true);
|
|
417
409
|
});
|
|
418
410
|
});
|
|
419
411
|
});
|