@servicetitan/startup 29.0.0 → 30.1.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.
- package/bin/index.js +1 -1
- package/dist/cli/commands/convert-eslint-config.d.ts +21 -0
- package/dist/cli/commands/convert-eslint-config.d.ts.map +1 -0
- package/dist/cli/commands/convert-eslint-config.js +235 -0
- package/dist/cli/commands/convert-eslint-config.js.map +1 -0
- package/dist/cli/commands/get-command.d.ts.map +1 -1
- package/dist/cli/commands/get-command.js +6 -0
- package/dist/cli/commands/get-command.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +4 -3
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/lint.d.ts +1 -1
- package/dist/cli/commands/lint.js +2 -2
- package/dist/cli/commands/run-task.d.ts +13 -0
- package/dist/cli/commands/run-task.d.ts.map +1 -0
- package/dist/cli/commands/run-task.js +53 -0
- package/dist/cli/commands/run-task.js.map +1 -0
- package/dist/cli/index.js +13 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/tasks/cli-task.d.ts +16 -0
- package/dist/cli/tasks/cli-task.d.ts.map +1 -0
- package/dist/cli/tasks/cli-task.js +58 -0
- package/dist/cli/tasks/cli-task.js.map +1 -0
- package/dist/cli/tasks/swc-compile-package.d.ts +12 -0
- package/dist/cli/tasks/swc-compile-package.d.ts.map +1 -0
- package/dist/cli/tasks/swc-compile-package.js +66 -0
- package/dist/cli/tasks/swc-compile-package.js.map +1 -0
- package/dist/cli/tasks/task.d.ts +42 -0
- package/dist/cli/tasks/task.d.ts.map +1 -0
- package/dist/cli/tasks/task.js +113 -0
- package/dist/cli/tasks/task.js.map +1 -0
- package/dist/cli/tasks/tsc-compile-package.d.ts +12 -0
- package/dist/cli/tasks/tsc-compile-package.d.ts.map +1 -0
- package/dist/cli/tasks/tsc-compile-package.js +42 -0
- package/dist/cli/tasks/tsc-compile-package.js.map +1 -0
- package/dist/cli/tasks/tsc-compile.d.ts +16 -0
- package/dist/cli/tasks/tsc-compile.d.ts.map +1 -0
- package/dist/cli/tasks/tsc-compile.js +48 -0
- package/dist/cli/tasks/tsc-compile.js.map +1 -0
- package/dist/cli/utils/bundle.js +1 -1
- package/dist/cli/utils/bundle.js.map +1 -1
- package/dist/cli/utils/cli-os.js +2 -2
- package/dist/cli/utils/cli-os.js.map +1 -1
- package/dist/cli/utils/eslint.d.ts.map +1 -1
- package/dist/cli/utils/eslint.js +13 -12
- package/dist/cli/utils/eslint.js.map +1 -1
- package/dist/cli/utils/is-module-installed.js +1 -1
- package/dist/cli/utils/is-module-installed.js.map +1 -1
- package/dist/cli/utils/tsc.d.ts +3 -2
- package/dist/cli/utils/tsc.d.ts.map +1 -1
- package/dist/cli/utils/tsc.js +20 -16
- package/dist/cli/utils/tsc.js.map +1 -1
- package/dist/utils/get-configuration.d.ts +3 -1
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +2 -0
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/get-destination-folders.d.ts.map +1 -1
- package/dist/utils/get-destination-folders.js +9 -13
- package/dist/utils/get-destination-folders.js.map +1 -1
- package/dist/utils/get-folders.js +2 -2
- package/dist/utils/get-folders.js.map +1 -1
- package/dist/utils/log.d.ts +1 -0
- package/dist/utils/log.d.ts.map +1 -1
- package/dist/utils/log.js +3 -0
- package/dist/utils/log.js.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js +4 -6
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/ignore-plugin/check-resource.js +1 -1
- package/dist/webpack/configs/plugins/ignore-plugin/check-resource.js.map +1 -1
- package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts +1 -2
- package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/moment-locales-plugin.js +13 -7
- package/dist/webpack/configs/plugins/moment-locales-plugin.js.map +1 -1
- package/dist/webpack/utils/testing/normalize-errors.d.ts +1 -2
- package/dist/webpack/utils/testing/normalize-errors.d.ts.map +1 -1
- package/dist/webpack/utils/testing/normalize-errors.js.map +1 -1
- package/package.json +34 -21
- package/src/cli/commands/__tests__/convert-eslint-config.test.ts +455 -0
- package/src/cli/commands/__tests__/lint.test.ts +2 -2
- package/src/cli/commands/convert-eslint-config.ts +289 -0
- package/src/cli/commands/get-command.ts +6 -0
- package/src/cli/commands/init.ts +4 -3
- package/src/cli/commands/lint.ts +3 -3
- package/src/cli/commands/run-task.ts +41 -0
- package/src/cli/index.ts +16 -4
- package/src/cli/tasks/__tests__/cli-task.test.ts +115 -0
- package/src/cli/tasks/__tests__/swc-compile.test.ts +192 -0
- package/src/cli/tasks/__tests__/task.test.ts +88 -0
- package/src/cli/tasks/__tests__/tsc-compile-package.test.ts +72 -0
- package/src/cli/tasks/__tests__/tsc-compile.test.ts +156 -0
- package/src/cli/tasks/cli-task.ts +64 -0
- package/src/cli/tasks/swc-cli.d.ts +3 -0
- package/src/cli/tasks/swc-compile-package.ts +70 -0
- package/src/cli/tasks/task.ts +112 -0
- package/src/cli/tasks/tsc-compile-package.ts +47 -0
- package/src/cli/tasks/tsc-compile.ts +64 -0
- package/src/cli/utils/__tests__/assets-copy.test.ts +1 -1
- package/src/cli/utils/__tests__/bundle.test.ts +6 -1
- package/src/cli/utils/__tests__/cli-os.test.ts +2 -2
- package/src/cli/utils/__tests__/eslint.test.ts +37 -8
- package/src/cli/utils/__tests__/styles-copy.test.ts +1 -1
- package/src/cli/utils/__tests__/tsc.test.ts +34 -55
- package/src/cli/utils/bundle.ts +1 -1
- package/src/cli/utils/cli-os.ts +2 -2
- package/src/cli/utils/eslint.ts +16 -13
- package/src/cli/utils/is-module-installed.ts +1 -1
- package/src/cli/utils/tsc.ts +25 -20
- package/src/utils/__tests__/get-destination-folders.test.ts +1 -1
- package/src/utils/__tests__/get-folders.test.ts +6 -18
- package/src/utils/__tests__/log.test.ts +6 -0
- package/src/utils/get-configuration.ts +2 -0
- package/src/utils/get-destination-folders.ts +11 -17
- package/src/utils/get-folders.ts +2 -2
- package/src/utils/log.ts +4 -0
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +2 -2
- package/src/webpack/__tests__/create-webpack-config.test.ts +1 -1
- package/src/webpack/configs/plugins/assets-manifest-plugin.ts +3 -2
- package/src/webpack/configs/plugins/ignore-plugin/check-resource.ts +1 -1
- package/src/webpack/configs/plugins/moment-locales-plugin.ts +17 -4
- package/src/webpack/utils/testing/normalize-errors.ts +1 -3
|
@@ -15,15 +15,9 @@ describe('[Startup] utils:get-folders', () => {
|
|
|
15
15
|
'tsconfig.json': JSON.stringify({ compilerOptions: { ourDir: 'dist' } }),
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
getFolders();
|
|
22
|
-
} catch (e) {
|
|
23
|
-
error = e;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
expect(error).toBe('"compilerOptions.rootDir" must be defined in the "tsconfig.json"!');
|
|
18
|
+
expect(() => getFolders()).toThrow(
|
|
19
|
+
'"compilerOptions.rootDir" must be defined in the "tsconfig.json"!'
|
|
20
|
+
);
|
|
27
21
|
});
|
|
28
22
|
|
|
29
23
|
test('getFolders throws an exception if "compilerOptions.outDir" isn\'t defined', () => {
|
|
@@ -32,15 +26,9 @@ describe('[Startup] utils:get-folders', () => {
|
|
|
32
26
|
'tsconfig.json': JSON.stringify({ compilerOptions: { rootDir: 'src' } }),
|
|
33
27
|
});
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
getFolders();
|
|
39
|
-
} catch (e) {
|
|
40
|
-
error = e;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
expect(error).toBe('"compilerOptions.outDir" must be defined in the "tsconfig.json"!');
|
|
29
|
+
expect(() => getFolders()).toThrow(
|
|
30
|
+
'"compilerOptions.outDir" must be defined in the "tsconfig.json"!'
|
|
31
|
+
);
|
|
44
32
|
});
|
|
45
33
|
|
|
46
34
|
test('"compilerOptions.outDir" used as the destination', () => {
|
|
@@ -14,6 +14,12 @@ describe(`[startup] Utils`, () => {
|
|
|
14
14
|
stdoutSpy = jest.spyOn(process.stdout, 'write').mockImplementation(jest.fn());
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
+
test('text() writes default text', () => {
|
|
18
|
+
log.text(message);
|
|
19
|
+
|
|
20
|
+
expect(stdoutSpy).toHaveBeenCalledWith(`${chalk(message)}\n`);
|
|
21
|
+
});
|
|
22
|
+
|
|
17
23
|
test('info() writes cyan text', () => {
|
|
18
24
|
log.info(message);
|
|
19
25
|
|
|
@@ -58,6 +58,7 @@ export interface NodeConfiguration {
|
|
|
58
58
|
export enum CommandName {
|
|
59
59
|
'build' = 'build',
|
|
60
60
|
'bundle-package' = 'bundle-package',
|
|
61
|
+
'convert-eslint-config' = 'convert-eslint-config',
|
|
61
62
|
'eslint' = 'eslint',
|
|
62
63
|
'init' = 'init',
|
|
63
64
|
'install' = 'install',
|
|
@@ -70,6 +71,7 @@ export enum CommandName {
|
|
|
70
71
|
'start' = 'start',
|
|
71
72
|
'styles-check' = 'styles-check',
|
|
72
73
|
'test' = 'test',
|
|
74
|
+
'task' = 'task',
|
|
73
75
|
}
|
|
74
76
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
75
77
|
|
|
@@ -8,24 +8,18 @@ import { getPackages, readJson } from '.';
|
|
|
8
8
|
*/
|
|
9
9
|
export function getDestinationFolders() {
|
|
10
10
|
const packages = getPackages();
|
|
11
|
+
const cwd = process.cwd();
|
|
11
12
|
|
|
12
|
-
return packages
|
|
13
|
-
.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (!fs.existsSync(tsConfigPath)) {
|
|
17
|
-
return '';
|
|
18
|
-
}
|
|
19
|
-
|
|
13
|
+
return packages.reduce<string[]>((result, { location }) => {
|
|
14
|
+
const tsConfigPath = path.join(location, 'tsconfig.json');
|
|
15
|
+
if (fs.existsSync(tsConfigPath)) {
|
|
20
16
|
const { outDir } = readJson(tsConfigPath).compilerOptions ?? {};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
if (outDir) {
|
|
18
|
+
result.push(
|
|
19
|
+
path.join(path.relative(cwd, location), outDir, '/').replace(/\\/g, '/')
|
|
20
|
+
);
|
|
24
21
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.replace(/\\/g, '/');
|
|
29
|
-
})
|
|
30
|
-
.filter(path => !!path);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}, []);
|
|
31
25
|
}
|
package/src/utils/get-folders.ts
CHANGED
|
@@ -10,11 +10,11 @@ export function getFolders(location = './') {
|
|
|
10
10
|
readJson(path.join(location, 'tsconfig.json')).compilerOptions ?? {};
|
|
11
11
|
|
|
12
12
|
if (!rootDir) {
|
|
13
|
-
throw '"compilerOptions.rootDir" must be defined in the "tsconfig.json"!';
|
|
13
|
+
throw new Error('"compilerOptions.rootDir" must be defined in the "tsconfig.json"!');
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
if (!outDir) {
|
|
17
|
-
throw '"compilerOptions.outDir" must be defined in the "tsconfig.json"!';
|
|
17
|
+
throw new Error('"compilerOptions.outDir" must be defined in the "tsconfig.json"!');
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
return {
|
package/src/utils/log.ts
CHANGED
|
@@ -3,7 +3,7 @@ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
|
3
3
|
import { fs, vol } from 'memfs';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { DefinePlugin } from 'webpack';
|
|
6
|
-
import WebpackAssetsManifest from 'webpack-assets-manifest';
|
|
6
|
+
import { WebpackAssetsManifest } from 'webpack-assets-manifest';
|
|
7
7
|
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
|
8
8
|
|
|
9
9
|
import { webpackDevConfigFileName, webpackProdConfigFileName } from '../../cli/utils';
|
|
@@ -32,7 +32,7 @@ jest.mock('webpack', () => ({
|
|
|
32
32
|
...jest.requireActual('webpack'),
|
|
33
33
|
DefinePlugin: jest.fn(),
|
|
34
34
|
}));
|
|
35
|
-
jest.mock('webpack-assets-manifest', () => jest.fn());
|
|
35
|
+
jest.mock('webpack-assets-manifest', () => ({ WebpackAssetsManifest: jest.fn() }));
|
|
36
36
|
jest.mock('webpack-virtual-modules', () => jest.fn());
|
|
37
37
|
jest.mock('../../utils', () => ({
|
|
38
38
|
...jest.requireActual('../../utils'),
|
|
@@ -50,7 +50,7 @@ jest.mock('webpack', () => ({
|
|
|
50
50
|
IgnorePlugin: jest.fn(),
|
|
51
51
|
ProvidePlugin: jest.fn(),
|
|
52
52
|
}));
|
|
53
|
-
jest.mock('webpack-assets-manifest', () => jest.fn());
|
|
53
|
+
jest.mock('webpack-assets-manifest', () => ({ WebpackAssetsManifest: jest.fn() }));
|
|
54
54
|
jest.mock('webpack-bundle-analyzer', () => ({ BundleAnalyzerPlugin: jest.fn() }));
|
|
55
55
|
jest.mock('webpack-filter-warnings-plugin', () => jest.fn());
|
|
56
56
|
jest.mock('webpack-virtual-modules', () => jest.fn());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import WebpackAssetsManifest from 'webpack-assets-manifest';
|
|
1
|
+
import { WebpackAssetsManifest } from 'webpack-assets-manifest';
|
|
2
2
|
import { Context, Overrides } from '../types';
|
|
3
3
|
import { generateMetadata } from '../utils';
|
|
4
4
|
|
|
@@ -27,7 +27,8 @@ export function assetsManifestPlugin(context: Context, _: Overrides) {
|
|
|
27
27
|
js: getAssetsByType('js'),
|
|
28
28
|
};
|
|
29
29
|
},
|
|
30
|
-
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
31
|
+
done: async (_manifest: WebpackAssetsManifest) => {
|
|
31
32
|
generateMetadata(context);
|
|
32
33
|
},
|
|
33
34
|
});
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
import MomentLocalesPlugin from 'moment-locales-webpack-plugin';
|
|
2
1
|
import { Context, Overrides } from '../types';
|
|
3
2
|
|
|
3
|
+
const MomentLocalesPlugin: typeof import('moment-locales-webpack-plugin') | undefined =
|
|
4
|
+
isMomentInstalled() ? require('moment-locales-webpack-plugin') : undefined;
|
|
5
|
+
|
|
4
6
|
export function momentLocalesPlugin(_: Context, _overrides: Overrides) {
|
|
5
|
-
return
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
return (
|
|
8
|
+
MomentLocalesPlugin &&
|
|
9
|
+
new MomentLocalesPlugin({
|
|
10
|
+
localesToKeep: ['en-au', 'en-ca', 'en-gb'],
|
|
11
|
+
})
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function isMomentInstalled() {
|
|
16
|
+
try {
|
|
17
|
+
return !!require.resolve('moment');
|
|
18
|
+
} catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
8
21
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { WebpackError } from 'webpack';
|
|
2
|
-
|
|
3
1
|
function removeCWD(str: string) {
|
|
4
2
|
const isWin = process.platform === 'win32';
|
|
5
3
|
let cwd = process.cwd();
|
|
@@ -13,6 +11,6 @@ function removeCWD(str: string) {
|
|
|
13
11
|
return str.replace(new RegExp(cwd, 'g'), '');
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
export function normalizeErrors(errors:
|
|
14
|
+
export function normalizeErrors(errors: Error[]) {
|
|
17
15
|
return errors.map(error => removeCWD(error.message.split('\n').slice(0, 2).join('\n')));
|
|
18
16
|
}
|