@servicetitan/startup 35.0.0 → 35.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.
Files changed (33) hide show
  1. package/dist/cypress-config/index.d.ts +2 -0
  2. package/dist/cypress-config/index.d.ts.map +1 -0
  3. package/dist/cypress-config/index.js +20 -0
  4. package/dist/cypress-config/index.js.map +1 -0
  5. package/dist/cypress-config/webpack-config.d.ts +4 -0
  6. package/dist/cypress-config/webpack-config.d.ts.map +1 -0
  7. package/dist/cypress-config/webpack-config.js +76 -0
  8. package/dist/cypress-config/webpack-config.js.map +1 -0
  9. package/dist/storybook-config/swc.js +1 -1
  10. package/dist/storybook-config/swc.js.map +1 -1
  11. package/dist/utils/get-base-tsconfig.d.ts +2 -0
  12. package/dist/utils/get-base-tsconfig.d.ts.map +1 -0
  13. package/dist/utils/get-base-tsconfig.js +21 -0
  14. package/dist/utils/get-base-tsconfig.js.map +1 -0
  15. package/dist/utils/get-tsconfig-with-fallback.d.ts +6 -0
  16. package/dist/utils/get-tsconfig-with-fallback.d.ts.map +1 -0
  17. package/dist/utils/get-tsconfig-with-fallback.js +24 -0
  18. package/dist/utils/get-tsconfig-with-fallback.js.map +1 -0
  19. package/dist/utils/index.d.ts +2 -0
  20. package/dist/utils/index.d.ts.map +1 -1
  21. package/dist/utils/index.js +2 -0
  22. package/dist/utils/index.js.map +1 -1
  23. package/package.json +14 -12
  24. package/src/cypress-config/__tests__/webpack-config.test.ts +124 -0
  25. package/src/cypress-config/index.ts +1 -0
  26. package/src/cypress-config/webpack-config.ts +58 -0
  27. package/src/storybook-config/__tests__/swc.test.ts +11 -0
  28. package/src/storybook-config/swc.ts +2 -2
  29. package/src/utils/__tests__/get-tsconfig-with-fallback.test.ts +23 -0
  30. package/src/utils/__tests__/get-tsconfig.test.ts +4 -4
  31. package/src/utils/get-base-tsconfig.ts +5 -0
  32. package/src/utils/get-tsconfig-with-fallback.ts +12 -0
  33. package/src/utils/index.ts +2 -0
@@ -0,0 +1,2 @@
1
+ export * from './webpack-config';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cypress-config/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _export_star(require("./webpack-config"), exports);
6
+ function _export_star(from, to) {
7
+ Object.keys(from).forEach(function(k) {
8
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
9
+ Object.defineProperty(to, k, {
10
+ enumerable: true,
11
+ get: function() {
12
+ return from[k];
13
+ }
14
+ });
15
+ }
16
+ });
17
+ return from;
18
+ }
19
+
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cypress-config/index.ts"],"sourcesContent":["export * from './webpack-config';\n"],"names":[],"mappings":";;;;qBAAc"}
@@ -0,0 +1,4 @@
1
+ import type { Configuration } from 'webpack';
2
+ import { Overrides } from '../webpack/configs';
3
+ export declare function webpackConfig(overrides?: Overrides): Configuration;
4
+ //# sourceMappingURL=webpack-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack-config.d.ts","sourceRoot":"","sources":["../../src/cypress-config/webpack-config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAK7C,OAAO,EAAW,SAAS,EAAe,MAAM,oBAAoB,CAAC;AAErE,wBAAgB,aAAa,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,aAAa,CAiBlE"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "webpackConfig", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return webpackConfig;
9
+ }
10
+ });
11
+ const _nodeutil = require("node:util");
12
+ const _webpackmerge = /*#__PURE__*/ _interop_require_default(require("webpack-merge"));
13
+ const _tasks = require("../cli/tasks");
14
+ const _utils = require("../cli/utils");
15
+ const _utils1 = require("../utils");
16
+ const _configs = require("../webpack/configs");
17
+ function _interop_require_default(obj) {
18
+ return obj && obj.__esModule ? obj : {
19
+ default: obj
20
+ };
21
+ }
22
+ function webpackConfig(overrides) {
23
+ var _ref;
24
+ const context = getContext();
25
+ const rules = getRules(context, overrides !== null && overrides !== void 0 ? overrides : {});
26
+ /* istanbul ignore next: debug only */ _utils1.log.debug('cypress-config:webpack-config', ()=>(0, _nodeutil.inspect)({
27
+ rules
28
+ }, {
29
+ depth: null
30
+ }));
31
+ const config = {
32
+ module: {
33
+ rules
34
+ },
35
+ resolve: {
36
+ extensions: [
37
+ '.ts',
38
+ '.tsx',
39
+ '.js',
40
+ '.jsx'
41
+ ]
42
+ }
43
+ };
44
+ return (0, _webpackmerge.default)(config, (_ref = overrides === null || overrides === void 0 ? void 0 : overrides.configuration) !== null && _ref !== void 0 ? _ref : {});
45
+ }
46
+ function getContext() {
47
+ return {
48
+ destination: '',
49
+ isProduction: false,
50
+ name: '',
51
+ packageData: {},
52
+ sharedDependencies: {},
53
+ source: ''
54
+ };
55
+ }
56
+ function getRules(context, overrides) {
57
+ const { rules } = (0, _configs.rulesConfig)(context, overrides);
58
+ return [
59
+ getSwcLoaderRule(),
60
+ ...rules
61
+ ];
62
+ }
63
+ function getSwcLoaderRule() {
64
+ const tsConfig = new _utils.TSConfig((0, _utils1.getTsConfigWithFallback)());
65
+ const swcOptions = (0, _tasks.getSwcOptions)(tsConfig);
66
+ return {
67
+ test: /\.tsx?$/,
68
+ exclude: /node_modules/,
69
+ use: {
70
+ loader: 'swc-loader',
71
+ options: swcOptions
72
+ }
73
+ };
74
+ }
75
+
76
+ //# sourceMappingURL=webpack-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cypress-config/webpack-config.ts"],"sourcesContent":["import { inspect } from 'node:util';\nimport type { Configuration } from 'webpack';\nimport merge from 'webpack-merge';\nimport { getSwcOptions } from '../cli/tasks';\nimport { TSConfig } from '../cli/utils';\nimport { getTsConfigWithFallback, log } from '../utils';\nimport { Context, Overrides, rulesConfig } from '../webpack/configs';\n\nexport function webpackConfig(overrides?: Overrides): Configuration {\n const context = getContext();\n const rules = getRules(context, overrides ?? {});\n\n /* istanbul ignore next: debug only */\n log.debug('cypress-config:webpack-config', () => inspect({ rules }, { depth: null }));\n\n const config: Configuration = {\n module: {\n rules,\n },\n resolve: {\n extensions: ['.ts', '.tsx', '.js', '.jsx'],\n },\n };\n\n return merge(config, overrides?.configuration ?? {});\n}\n\nfunction getContext(): Context {\n return {\n destination: '',\n isProduction: false,\n name: '',\n packageData: {} as any,\n sharedDependencies: {},\n source: '',\n };\n}\n\nfunction getRules(context: Context, overrides: Overrides) {\n const { rules } = rulesConfig(context, overrides);\n\n return [getSwcLoaderRule(), ...rules];\n}\n\nfunction getSwcLoaderRule() {\n const tsConfig = new TSConfig(getTsConfigWithFallback());\n\n const swcOptions = getSwcOptions(tsConfig);\n\n return {\n test: /\\.tsx?$/,\n exclude: /node_modules/,\n use: {\n loader: 'swc-loader',\n options: swcOptions,\n },\n };\n}\n"],"names":["webpackConfig","overrides","context","getContext","rules","getRules","log","debug","inspect","depth","config","module","resolve","extensions","merge","configuration","destination","isProduction","name","packageData","sharedDependencies","source","rulesConfig","getSwcLoaderRule","tsConfig","TSConfig","getTsConfigWithFallback","swcOptions","getSwcOptions","test","exclude","use","loader","options"],"mappings":";;;;+BAQgBA;;;eAAAA;;;0BARQ;qEAEN;uBACY;uBACL;wBACoB;yBACG;;;;;;AAEzC,SAASA,cAAcC,SAAqB;;IAC/C,MAAMC,UAAUC;IAChB,MAAMC,QAAQC,SAASH,SAASD,sBAAAA,uBAAAA,YAAa,CAAC;IAE9C,oCAAoC,GACpCK,WAAG,CAACC,KAAK,CAAC,iCAAiC,IAAMC,IAAAA,iBAAO,EAAC;YAAEJ;QAAM,GAAG;YAAEK,OAAO;QAAK;IAElF,MAAMC,SAAwB;QAC1BC,QAAQ;YACJP;QACJ;QACAQ,SAAS;YACLC,YAAY;gBAAC;gBAAO;gBAAQ;gBAAO;aAAO;QAC9C;IACJ;IAEA,OAAOC,IAAAA,qBAAK,EAACJ,gBAAQT,sBAAAA,gCAAAA,UAAWc,aAAa,uCAAI,CAAC;AACtD;AAEA,SAASZ;IACL,OAAO;QACHa,aAAa;QACbC,cAAc;QACdC,MAAM;QACNC,aAAa,CAAC;QACdC,oBAAoB,CAAC;QACrBC,QAAQ;IACZ;AACJ;AAEA,SAAShB,SAASH,OAAgB,EAAED,SAAoB;IACpD,MAAM,EAAEG,KAAK,EAAE,GAAGkB,IAAAA,oBAAW,EAACpB,SAASD;IAEvC,OAAO;QAACsB;WAAuBnB;KAAM;AACzC;AAEA,SAASmB;IACL,MAAMC,WAAW,IAAIC,eAAQ,CAACC,IAAAA,+BAAuB;IAErD,MAAMC,aAAaC,IAAAA,oBAAa,EAACJ;IAEjC,OAAO;QACHK,MAAM;QACNC,SAAS;QACTC,KAAK;YACDC,QAAQ;YACRC,SAASN;QACb;IACJ;AACJ"}
@@ -13,7 +13,7 @@ const _tasks = require("../cli/tasks");
13
13
  const _utils = require("../cli/utils");
14
14
  const _utils1 = require("../utils");
15
15
  function swc(config) {
16
- const tsConfig = new _utils.TSConfig((0, _utils1.getTsConfig)());
16
+ const tsConfig = new _utils.TSConfig((0, _utils1.getTsConfigWithFallback)());
17
17
  const swcOptions = (0, _tasks.getSwcOptions)(tsConfig);
18
18
  /*
19
19
  * We cannot set 'jsc.target' because Storybook always sets 'env'
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/storybook-config/swc.ts"],"sourcesContent":["import type { SwcOptions } from '@swc/cli';\nimport { inspect } from 'node:util';\nimport { getSwcOptions } from '../cli/tasks';\nimport { TSConfig } from '../cli/utils';\nimport { getTsConfig, log } from '../utils';\n\nexport function swc(config: SwcOptions) {\n const tsConfig = new TSConfig(getTsConfig());\n const swcOptions = getSwcOptions(tsConfig);\n\n /*\n * We cannot set 'jsc.target' because Storybook always sets 'env'\n * (see https://github.com/storybookjs/storybook/blob/24db05a0e4b499a99fb5a53b5a70fa894fa6a8c8/code/builders/builder-webpack5/src/presets/custom-webpack-preset.ts#L19)\n * and 'env' and 'jsc.target' cannot be used together\n */\n if (swcOptions.jsc.target) {\n delete swcOptions.jsc.target;\n }\n\n /* istanbul ignore next: debug only */\n log.debug('storybook-config:swc', () => inspect({ swcOptions }, { depth: null }));\n\n return { ...config, ...swcOptions };\n}\n"],"names":["swc","config","tsConfig","TSConfig","getTsConfig","swcOptions","getSwcOptions","jsc","target","log","debug","inspect","depth"],"mappings":";;;;+BAMgBA;;;eAAAA;;;0BALQ;uBACM;uBACL;wBACQ;AAE1B,SAASA,IAAIC,MAAkB;IAClC,MAAMC,WAAW,IAAIC,eAAQ,CAACC,IAAAA,mBAAW;IACzC,MAAMC,aAAaC,IAAAA,oBAAa,EAACJ;IAEjC;;;;KAIC,GACD,IAAIG,WAAWE,GAAG,CAACC,MAAM,EAAE;QACvB,OAAOH,WAAWE,GAAG,CAACC,MAAM;IAChC;IAEA,oCAAoC,GACpCC,WAAG,CAACC,KAAK,CAAC,wBAAwB,IAAMC,IAAAA,iBAAO,EAAC;YAAEN;QAAW,GAAG;YAAEO,OAAO;QAAK;IAE9E,OAAO;QAAE,GAAGX,MAAM;QAAE,GAAGI,UAAU;IAAC;AACtC"}
1
+ {"version":3,"sources":["../../src/storybook-config/swc.ts"],"sourcesContent":["import type { SwcOptions } from '@swc/cli';\nimport { inspect } from 'node:util';\nimport { getSwcOptions } from '../cli/tasks';\nimport { TSConfig } from '../cli/utils';\nimport { getTsConfigWithFallback, log } from '../utils';\n\nexport function swc(config: SwcOptions) {\n const tsConfig = new TSConfig(getTsConfigWithFallback());\n const swcOptions = getSwcOptions(tsConfig);\n\n /*\n * We cannot set 'jsc.target' because Storybook always sets 'env'\n * (see https://github.com/storybookjs/storybook/blob/24db05a0e4b499a99fb5a53b5a70fa894fa6a8c8/code/builders/builder-webpack5/src/presets/custom-webpack-preset.ts#L19)\n * and 'env' and 'jsc.target' cannot be used together\n */\n if (swcOptions.jsc.target) {\n delete swcOptions.jsc.target;\n }\n\n /* istanbul ignore next: debug only */\n log.debug('storybook-config:swc', () => inspect({ swcOptions }, { depth: null }));\n\n return { ...config, ...swcOptions };\n}\n"],"names":["swc","config","tsConfig","TSConfig","getTsConfigWithFallback","swcOptions","getSwcOptions","jsc","target","log","debug","inspect","depth"],"mappings":";;;;+BAMgBA;;;eAAAA;;;0BALQ;uBACM;uBACL;wBACoB;AAEtC,SAASA,IAAIC,MAAkB;IAClC,MAAMC,WAAW,IAAIC,eAAQ,CAACC,IAAAA,+BAAuB;IACrD,MAAMC,aAAaC,IAAAA,oBAAa,EAACJ;IAEjC;;;;KAIC,GACD,IAAIG,WAAWE,GAAG,CAACC,MAAM,EAAE;QACvB,OAAOH,WAAWE,GAAG,CAACC,MAAM;IAChC;IAEA,oCAAoC,GACpCC,WAAG,CAACC,KAAK,CAAC,wBAAwB,IAAMC,IAAAA,iBAAO,EAAC;YAAEN;QAAW,GAAG;YAAEO,OAAO;QAAK;IAE9E,OAAO;QAAE,GAAGX,MAAM;QAAE,GAAGI,UAAU;IAAC;AACtC"}
@@ -0,0 +1,2 @@
1
+ export declare function getBaseTsConfig(): string;
2
+ //# sourceMappingURL=get-base-tsconfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-base-tsconfig.d.ts","sourceRoot":"","sources":["../../src/utils/get-base-tsconfig.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,WAE9B"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getBaseTsConfig", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getBaseTsConfig;
9
+ }
10
+ });
11
+ const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
12
+ function _interop_require_default(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
17
+ function getBaseTsConfig() {
18
+ return _nodepath.default.resolve(__dirname, '../../tsconfig/base.json');
19
+ }
20
+
21
+ //# sourceMappingURL=get-base-tsconfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/get-base-tsconfig.ts"],"sourcesContent":["import path from 'node:path';\n\nexport function getBaseTsConfig() {\n return path.resolve(__dirname, '../../tsconfig/base.json');\n}\n"],"names":["getBaseTsConfig","path","resolve","__dirname"],"mappings":";;;;+BAEgBA;;;eAAAA;;;iEAFC;;;;;;AAEV,SAASA;IACZ,OAAOC,iBAAI,CAACC,OAAO,CAACC,WAAW;AACnC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the tsconfig file to use for builds, falling back to startup's base.json
3
+ * if no tsconfig is found at the given location.
4
+ */
5
+ export declare function getTsConfigWithFallback(location?: string): string;
6
+ //# sourceMappingURL=get-tsconfig-with-fallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-tsconfig-with-fallback.d.ts","sourceRoot":"","sources":["../../src/utils/get-tsconfig-with-fallback.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,SAAO,UAGtD"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getTsConfigWithFallback", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getTsConfigWithFallback;
9
+ }
10
+ });
11
+ const _nodefs = /*#__PURE__*/ _interop_require_default(require("node:fs"));
12
+ const _getbasetsconfig = require("./get-base-tsconfig");
13
+ const _gettsconfig = require("./get-tsconfig");
14
+ function _interop_require_default(obj) {
15
+ return obj && obj.__esModule ? obj : {
16
+ default: obj
17
+ };
18
+ }
19
+ function getTsConfigWithFallback(location = './') {
20
+ const config = (0, _gettsconfig.getTsConfig)(location);
21
+ return _nodefs.default.existsSync(config) ? config : (0, _getbasetsconfig.getBaseTsConfig)();
22
+ }
23
+
24
+ //# sourceMappingURL=get-tsconfig-with-fallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/get-tsconfig-with-fallback.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { getBaseTsConfig } from './get-base-tsconfig';\nimport { getTsConfig } from './get-tsconfig';\n\n/**\n * Returns the tsconfig file to use for builds, falling back to startup's base.json\n * if no tsconfig is found at the given location.\n */\nexport function getTsConfigWithFallback(location = './') {\n const config = getTsConfig(location);\n return fs.existsSync(config) ? config : getBaseTsConfig();\n}\n"],"names":["getTsConfigWithFallback","location","config","getTsConfig","fs","existsSync","getBaseTsConfig"],"mappings":";;;;+BAQgBA;;;eAAAA;;;+DARD;iCACiB;6BACJ;;;;;;AAMrB,SAASA,wBAAwBC,WAAW,IAAI;IACnD,MAAMC,SAASC,IAAAA,wBAAW,EAACF;IAC3B,OAAOG,eAAE,CAACC,UAAU,CAACH,UAAUA,SAASI,IAAAA,gCAAe;AAC3D"}
@@ -2,6 +2,7 @@ export * from './find-packages';
2
2
  export * from './find-up';
3
3
  export * from './format-duration';
4
4
  export * from './format-relative-date';
5
+ export * from './get-base-tsconfig';
5
6
  export * from './get-branch-configs';
6
7
  export * from './get-configuration';
7
8
  export * from './get-destination-folders';
@@ -12,6 +13,7 @@ export * from './get-package-name';
12
13
  export * from './get-packages';
13
14
  export * from './get-startup-version';
14
15
  export * from './get-tsconfig';
16
+ export * from './get-tsconfig-with-fallback';
15
17
  export * from './load-shared-dependencies';
16
18
  export * from './log';
17
19
  export * from './log-errors';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -6,6 +6,7 @@ _export_star(require("./find-packages"), exports);
6
6
  _export_star(require("./find-up"), exports);
7
7
  _export_star(require("./format-duration"), exports);
8
8
  _export_star(require("./format-relative-date"), exports);
9
+ _export_star(require("./get-base-tsconfig"), exports);
9
10
  _export_star(require("./get-branch-configs"), exports);
10
11
  _export_star(require("./get-configuration"), exports);
11
12
  _export_star(require("./get-destination-folders"), exports);
@@ -16,6 +17,7 @@ _export_star(require("./get-package-name"), exports);
16
17
  _export_star(require("./get-packages"), exports);
17
18
  _export_star(require("./get-startup-version"), exports);
18
19
  _export_star(require("./get-tsconfig"), exports);
20
+ _export_star(require("./get-tsconfig-with-fallback"), exports);
19
21
  _export_star(require("./load-shared-dependencies"), exports);
20
22
  _export_star(require("./log"), exports);
21
23
  _export_star(require("./log-errors"), exports);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './find-packages';\nexport * from './find-up';\nexport * from './format-duration';\nexport * from './format-relative-date';\nexport * from './get-branch-configs';\nexport * from './get-configuration';\nexport * from './get-destination-folders';\nexport * from './get-folders';\nexport * from './get-jest-config';\nexport * from './get-package-data';\nexport * from './get-package-name';\nexport * from './get-packages';\nexport * from './get-startup-version';\nexport * from './get-tsconfig';\nexport * from './load-shared-dependencies';\nexport * from './log';\nexport * from './log-errors';\nexport * from './omit';\nexport * from './pick';\nexport * from './prettify';\nexport * from './read-json';\nexport * from './to-array';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './find-packages';\nexport * from './find-up';\nexport * from './format-duration';\nexport * from './format-relative-date';\nexport * from './get-base-tsconfig';\nexport * from './get-branch-configs';\nexport * from './get-configuration';\nexport * from './get-destination-folders';\nexport * from './get-folders';\nexport * from './get-jest-config';\nexport * from './get-package-data';\nexport * from './get-package-name';\nexport * from './get-packages';\nexport * from './get-startup-version';\nexport * from './get-tsconfig';\nexport * from './get-tsconfig-with-fallback';\nexport * from './load-shared-dependencies';\nexport * from './log';\nexport * from './log-errors';\nexport * from './omit';\nexport * from './pick';\nexport * from './prettify';\nexport * from './read-json';\nexport * from './to-array';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/startup",
3
- "version": "35.0.0",
3
+ "version": "35.1.0",
4
4
  "description": "CLI to create multi-package Lerna projects with TypeScript and React",
5
5
  "homepage": "https://docs.st.dev/docs/frontend/uikit/startup",
6
6
  "repository": {
@@ -20,6 +20,7 @@
20
20
  "default": "./dist/index.js",
21
21
  "types": "./dist/index.d.ts"
22
22
  },
23
+ "./cypress-config": "./dist/cypress-config/index.js",
23
24
  "./jest-preset": "./jest/jest-preset.js",
24
25
  "./jest-resolver": "./dist/jest/resolver.js",
25
26
  "./jest-svg-transformer": "./dist/jest/svg-transformer.js",
@@ -56,16 +57,16 @@
56
57
  "@jest/core": "~30.3.0",
57
58
  "@jest/types": "~30.3.0",
58
59
  "@jsdevtools/coverage-istanbul-loader": "^3.0.5",
59
- "@servicetitan/eslint-config": "35.0.0",
60
- "@servicetitan/install": "35.0.0",
61
- "@servicetitan/startup-utils": "35.0.0",
62
- "@servicetitan/stylelint-config": "35.0.0",
60
+ "@servicetitan/eslint-config": "35.1.0",
61
+ "@servicetitan/install": "35.1.0",
62
+ "@servicetitan/startup-utils": "35.1.0",
63
+ "@servicetitan/stylelint-config": "35.1.0",
63
64
  "@svgr/webpack": "^8.1.0",
64
65
  "@swc/cli": "^0.5.0",
65
66
  "@swc/core": "1.15.18",
66
67
  "@types/debug": "^4.1.12",
67
68
  "@types/jest": "~30.0.0",
68
- "@vitest/coverage-v8": "^4.0.18",
69
+ "@vitest/coverage-v8": "^4.1.0",
69
70
  "chalk": "~4.1.2",
70
71
  "cli-table3": "^0.6.5",
71
72
  "cpx2": "8.0.0",
@@ -87,31 +88,32 @@
87
88
  "json5": "^2.2.3",
88
89
  "lerna": "~9.0.5",
89
90
  "less": "~4.5.1",
90
- "less-loader": "~12.3.1",
91
+ "less-loader": "~12.3.2",
91
92
  "less-plugin-npm-import": "~2.1.0",
92
93
  "lodash.kebabcase": "^4.1.1",
93
94
  "lodash.memoize": "^4.1.2",
94
95
  "memfs": "~4.56.11",
95
- "mini-css-extract-plugin": "~2.10.0",
96
+ "mini-css-extract-plugin": "~2.10.1",
96
97
  "moment-locales-webpack-plugin": "~1.2.0",
97
98
  "multimatch": "~8.0.0",
98
99
  "patch-package": "^8.0.1",
99
100
  "portfinder": "~1.0.38",
100
101
  "postcss": "~8.5.8",
101
102
  "prettier": "~3.8.1",
102
- "sass": "~1.97.3",
103
+ "sass": "~1.98.0",
103
104
  "sass-loader": "~16.0.7",
104
105
  "semver": "~7.7.4",
105
106
  "source-map-loader": "~5.0.0",
106
107
  "style-loader": "~4.0.0",
107
108
  "stylelint": "~16.26.1",
109
+ "swc-loader": "^0.2.7",
108
110
  "terminal-link": "^5.0.0",
109
- "terser-webpack-plugin": "^5.3.16",
111
+ "terser-webpack-plugin": "^5.4.0",
110
112
  "ts-jest": "29.4.6",
111
113
  "ts-node": "~10.9.2",
112
114
  "typed-css-modules": "~0.9.1",
113
115
  "typescript": "5.9.3",
114
- "vitest": "^4.0.18",
116
+ "vitest": "^4.1.0",
115
117
  "webpack": "~5.105.4",
116
118
  "webpack-assets-manifest": "~6.5.1",
117
119
  "webpack-bundle-analyzer": "^5.2.0",
@@ -144,5 +146,5 @@
144
146
  "cli": {
145
147
  "webpack": false
146
148
  },
147
- "gitHead": "3a5f2e6cad93c4e898091fb3d51310ccb26a91ee"
149
+ "gitHead": "f1d49b43f27789cf5cd4bea3e065cd9e33bf5876"
148
150
  }
@@ -0,0 +1,124 @@
1
+ import { fs, vol } from 'memfs';
2
+ import { getSwcOptions } from '../../cli/tasks';
3
+ import { TSConfig } from '../../cli/utils';
4
+ import { getBaseTsConfig } from '../../utils';
5
+ import { Overrides, rulesConfig } from '../../webpack/configs';
6
+ import { webpackConfig } from '../webpack-config';
7
+
8
+ jest.mock('fs', () => fs);
9
+ jest.mock('../../webpack/configs');
10
+ jest.mock('../../cli/tasks');
11
+
12
+ describe(`[startup/cypress-config] ${webpackConfig.name}`, () => {
13
+ const mockRules: any[] = [
14
+ { test: /\.css$/, use: ['css-loader'] },
15
+ { test: /\.module\.less$/, use: ['style-loader', 'less-loader'] },
16
+ ];
17
+ const mockSwcOptions: any = { jsc: 'foobar' };
18
+ const mockTsConfig = { compilerOptions: { target: 'es2020' } };
19
+ const mockFallbackTsConfig = { compilerOptions: { target: 'es2018' } };
20
+ const fallbackConfig = getBaseTsConfig();
21
+
22
+ let overrides: Overrides | undefined;
23
+
24
+ beforeEach(() => {
25
+ jest.clearAllMocks();
26
+ jest.mocked(rulesConfig).mockReturnValue({ rules: mockRules });
27
+ jest.mocked(getSwcOptions).mockReturnValue(mockSwcOptions);
28
+ vol.fromJSON({
29
+ 'tsconfig.json': JSON.stringify(mockTsConfig),
30
+ [fallbackConfig]: JSON.stringify(mockFallbackTsConfig),
31
+ });
32
+ overrides = undefined;
33
+ });
34
+
35
+ afterEach(() => vol.reset());
36
+
37
+ const subject = () => webpackConfig(overrides);
38
+
39
+ test('gets rules with non-production context', () => {
40
+ subject();
41
+
42
+ expect(rulesConfig).toHaveBeenCalledWith(
43
+ expect.objectContaining({ isProduction: false }),
44
+ expect.anything()
45
+ );
46
+ });
47
+
48
+ test('includes all rules from rulesConfig', () => {
49
+ const result = subject();
50
+
51
+ for (const rule of mockRules) {
52
+ expect(result.module!.rules).toContainEqual(rule);
53
+ }
54
+ });
55
+
56
+ test('adds swc-loader rule for TypeScript files', () => {
57
+ const result = subject();
58
+
59
+ expect(result.module!.rules).toContainEqual(
60
+ expect.objectContaining({
61
+ test: /\.tsx?$/,
62
+ exclude: /node_modules/,
63
+ use: { loader: 'swc-loader', options: mockSwcOptions },
64
+ })
65
+ );
66
+ });
67
+
68
+ test('passes tsconfig content to getSwcOptions', () => {
69
+ subject();
70
+
71
+ const tsConfigArg = jest.mocked(getSwcOptions).mock.calls[0][0];
72
+ expect(tsConfigArg).toStrictEqual(new TSConfig('tsconfig.json'));
73
+ });
74
+
75
+ describe('when no tsconfig is found', () => {
76
+ beforeEach(() => fs.rmSync('tsconfig.json'));
77
+
78
+ test('gets default swc config from base.json', () => {
79
+ subject();
80
+
81
+ const tsConfigArg = jest.mocked(getSwcOptions).mock.calls[0][0];
82
+ expect(tsConfigArg).toStrictEqual(new TSConfig(fallbackConfig));
83
+ });
84
+ });
85
+
86
+ test('includes resolve extensions for TypeScript and JavaScript', () => {
87
+ expect(subject().resolve!.extensions).toEqual(['.ts', '.tsx', '.js', '.jsx']);
88
+ });
89
+
90
+ describe('with overrides', () => {
91
+ beforeEach(() => (overrides = { plugins: { MiniCssExtractPlugin: {} } }));
92
+
93
+ test('passes overrides through to rulesConfig', () => {
94
+ subject();
95
+
96
+ expect(rulesConfig).toHaveBeenCalledWith(expect.anything(), overrides);
97
+ });
98
+
99
+ describe('with configuration overrides', () => {
100
+ beforeEach(
101
+ () =>
102
+ (overrides = {
103
+ configuration: {
104
+ devtool: 'eval-source-map',
105
+ resolve: {
106
+ alias: {
107
+ '@': '/src',
108
+ },
109
+ },
110
+ },
111
+ })
112
+ );
113
+
114
+ test('merges configuration overrides into result', () => {
115
+ const result = subject();
116
+
117
+ expect(result.devtool).toBe(overrides!.configuration!.devtool);
118
+ expect(result.resolve?.alias).toEqual(overrides!.configuration!.resolve!.alias);
119
+ expect(result.resolve?.extensions).toEqual(['.ts', '.tsx', '.js', '.jsx']);
120
+ expect(result.module?.rules).toBeDefined();
121
+ });
122
+ });
123
+ });
124
+ });
@@ -0,0 +1 @@
1
+ export * from './webpack-config';
@@ -0,0 +1,58 @@
1
+ import { inspect } from 'node:util';
2
+ import type { Configuration } from 'webpack';
3
+ import merge from 'webpack-merge';
4
+ import { getSwcOptions } from '../cli/tasks';
5
+ import { TSConfig } from '../cli/utils';
6
+ import { getTsConfigWithFallback, log } from '../utils';
7
+ import { Context, Overrides, rulesConfig } from '../webpack/configs';
8
+
9
+ export function webpackConfig(overrides?: Overrides): Configuration {
10
+ const context = getContext();
11
+ const rules = getRules(context, overrides ?? {});
12
+
13
+ /* istanbul ignore next: debug only */
14
+ log.debug('cypress-config:webpack-config', () => inspect({ rules }, { depth: null }));
15
+
16
+ const config: Configuration = {
17
+ module: {
18
+ rules,
19
+ },
20
+ resolve: {
21
+ extensions: ['.ts', '.tsx', '.js', '.jsx'],
22
+ },
23
+ };
24
+
25
+ return merge(config, overrides?.configuration ?? {});
26
+ }
27
+
28
+ function getContext(): Context {
29
+ return {
30
+ destination: '',
31
+ isProduction: false,
32
+ name: '',
33
+ packageData: {} as any,
34
+ sharedDependencies: {},
35
+ source: '',
36
+ };
37
+ }
38
+
39
+ function getRules(context: Context, overrides: Overrides) {
40
+ const { rules } = rulesConfig(context, overrides);
41
+
42
+ return [getSwcLoaderRule(), ...rules];
43
+ }
44
+
45
+ function getSwcLoaderRule() {
46
+ const tsConfig = new TSConfig(getTsConfigWithFallback());
47
+
48
+ const swcOptions = getSwcOptions(tsConfig);
49
+
50
+ return {
51
+ test: /\.tsx?$/,
52
+ exclude: /node_modules/,
53
+ use: {
54
+ loader: 'swc-loader',
55
+ options: swcOptions,
56
+ },
57
+ };
58
+ }
@@ -2,16 +2,19 @@ import { SwcOptions } from '@swc/cli';
2
2
  import { fs, vol } from 'memfs';
3
3
  import { getSwcOptions } from '../../cli/tasks';
4
4
  import { TSConfig } from '../../cli/utils';
5
+ import { getBaseTsConfig } from '../../utils';
5
6
  import { swc } from '../swc';
6
7
 
7
8
  jest.mock('fs', () => fs);
8
9
 
9
10
  describe(`[startup/storybook-config] ${swc.name}`, () => {
11
+ const baseJsonPath = getBaseTsConfig();
10
12
  const config: SwcOptions = { env: { bugfixes: true } };
11
13
  let tsConfig: TSConfig;
12
14
 
13
15
  function setTsConfig(config: Record<string, any> = {}) {
14
16
  return vol.fromJSON({
17
+ [baseJsonPath]: JSON.stringify({ compilerOptions: { sourceMap: true } }),
15
18
  'tsconfig.json': JSON.stringify(config),
16
19
  });
17
20
  }
@@ -34,4 +37,12 @@ describe(`[startup/storybook-config] ${swc.name}`, () => {
34
37
  expect(subject().jsc.target).toBeUndefined();
35
38
  });
36
39
  });
40
+
41
+ describe('when no tsconfig is found', () => {
42
+ beforeEach(() => fs.rmSync('tsconfig.json'));
43
+
44
+ test('gets default swc config from base.json', () => {
45
+ expect(subject()).toEqual({ ...config, ...getSwcOptions(new TSConfig(baseJsonPath)) });
46
+ });
47
+ });
37
48
  });
@@ -2,10 +2,10 @@ import type { SwcOptions } from '@swc/cli';
2
2
  import { inspect } from 'node:util';
3
3
  import { getSwcOptions } from '../cli/tasks';
4
4
  import { TSConfig } from '../cli/utils';
5
- import { getTsConfig, log } from '../utils';
5
+ import { getTsConfigWithFallback, log } from '../utils';
6
6
 
7
7
  export function swc(config: SwcOptions) {
8
- const tsConfig = new TSConfig(getTsConfig());
8
+ const tsConfig = new TSConfig(getTsConfigWithFallback());
9
9
  const swcOptions = getSwcOptions(tsConfig);
10
10
 
11
11
  /*
@@ -0,0 +1,23 @@
1
+ import { fs, vol } from 'memfs';
2
+ import { getBaseTsConfig } from '../get-base-tsconfig';
3
+ import { getTsConfigWithFallback } from '../get-tsconfig-with-fallback';
4
+
5
+ jest.mock('fs', () => fs);
6
+
7
+ describe(`[startup] Utils`, () => {
8
+ describe(`${getTsConfigWithFallback.name}`, () => {
9
+ afterEach(() => vol.reset());
10
+
11
+ test('returns base.json', () => {
12
+ expect(getTsConfigWithFallback()).toBe(getBaseTsConfig());
13
+ });
14
+
15
+ describe('when tsconfig exists', () => {
16
+ beforeEach(() => vol.fromJSON({ 'tsconfig.json': JSON.stringify({}) }));
17
+
18
+ test('returns tsconfig', () => {
19
+ expect(getTsConfigWithFallback()).toBe('tsconfig.json');
20
+ });
21
+ });
22
+ });
23
+ });
@@ -1,5 +1,5 @@
1
1
  import { fs, vol } from 'memfs';
2
- import path from 'path';
2
+ import path from 'node:path';
3
3
  import { getTsConfig } from '../get-tsconfig';
4
4
 
5
5
  jest.mock('fs', () => fs);
@@ -36,9 +36,9 @@ describe(`[startup] Utils`, () => {
36
36
  });
37
37
 
38
38
  describe(`when ${buildConfig} is present`, () => {
39
- beforeEach(() => {
40
- vol.fromJSON({ [`packages/foo/${buildConfig}`]: JSON.stringify({}) });
41
- });
39
+ beforeEach(() =>
40
+ vol.fromJSON({ [`packages/foo/${buildConfig}`]: JSON.stringify({}) })
41
+ );
42
42
 
43
43
  test(`returns {location}/${buildConfig}`, () => {
44
44
  expect(subject()).toBe(path.join(location!, buildConfig));
@@ -0,0 +1,5 @@
1
+ import path from 'node:path';
2
+
3
+ export function getBaseTsConfig() {
4
+ return path.resolve(__dirname, '../../tsconfig/base.json');
5
+ }
@@ -0,0 +1,12 @@
1
+ import fs from 'node:fs';
2
+ import { getBaseTsConfig } from './get-base-tsconfig';
3
+ import { getTsConfig } from './get-tsconfig';
4
+
5
+ /**
6
+ * Returns the tsconfig file to use for builds, falling back to startup's base.json
7
+ * if no tsconfig is found at the given location.
8
+ */
9
+ export function getTsConfigWithFallback(location = './') {
10
+ const config = getTsConfig(location);
11
+ return fs.existsSync(config) ? config : getBaseTsConfig();
12
+ }
@@ -2,6 +2,7 @@ export * from './find-packages';
2
2
  export * from './find-up';
3
3
  export * from './format-duration';
4
4
  export * from './format-relative-date';
5
+ export * from './get-base-tsconfig';
5
6
  export * from './get-branch-configs';
6
7
  export * from './get-configuration';
7
8
  export * from './get-destination-folders';
@@ -12,6 +13,7 @@ export * from './get-package-name';
12
13
  export * from './get-packages';
13
14
  export * from './get-startup-version';
14
15
  export * from './get-tsconfig';
16
+ export * from './get-tsconfig-with-fallback';
15
17
  export * from './load-shared-dependencies';
16
18
  export * from './log';
17
19
  export * from './log-errors';