@servicetitan/startup 31.5.1 → 32.0.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 (199) hide show
  1. package/dist/cli/commands/build.d.ts +1 -1
  2. package/dist/cli/commands/build.d.ts.map +1 -1
  3. package/dist/cli/commands/build.js.map +1 -1
  4. package/dist/cli/commands/bundle-package.d.ts +1 -1
  5. package/dist/cli/commands/bundle-package.d.ts.map +1 -1
  6. package/dist/cli/commands/bundle-package.js.map +1 -1
  7. package/dist/cli/commands/eslint.d.ts +1 -1
  8. package/dist/cli/commands/eslint.d.ts.map +1 -1
  9. package/dist/cli/commands/eslint.js.map +1 -1
  10. package/dist/cli/commands/get-command.js +2 -2
  11. package/dist/cli/commands/get-command.js.map +1 -1
  12. package/dist/cli/commands/index.d.ts +1 -1
  13. package/dist/cli/commands/index.d.ts.map +1 -1
  14. package/dist/cli/commands/index.js +1 -1
  15. package/dist/cli/commands/index.js.map +1 -1
  16. package/dist/cli/commands/init.d.ts +3 -2
  17. package/dist/cli/commands/init.d.ts.map +1 -1
  18. package/dist/cli/commands/init.js +24 -43
  19. package/dist/cli/commands/init.js.map +1 -1
  20. package/dist/cli/commands/install.d.ts +4 -0
  21. package/dist/cli/commands/install.d.ts.map +1 -1
  22. package/dist/cli/commands/install.js +91 -3
  23. package/dist/cli/commands/install.js.map +1 -1
  24. package/dist/cli/commands/lint.d.ts +1 -1
  25. package/dist/cli/commands/lint.d.ts.map +1 -1
  26. package/dist/cli/commands/lint.js.map +1 -1
  27. package/dist/cli/commands/mfe-package-clean.d.ts.map +1 -1
  28. package/dist/cli/commands/mfe-package-clean.js +5 -7
  29. package/dist/cli/commands/mfe-package-clean.js.map +1 -1
  30. package/dist/cli/commands/mfe-package-publish.d.ts.map +1 -1
  31. package/dist/cli/commands/mfe-package-publish.js +11 -15
  32. package/dist/cli/commands/mfe-package-publish.js.map +1 -1
  33. package/dist/cli/commands/mfe-publish.d.ts +1 -1
  34. package/dist/cli/commands/mfe-publish.d.ts.map +1 -1
  35. package/dist/cli/commands/mfe-publish.js.map +1 -1
  36. package/dist/cli/commands/prepare-package.d.ts +1 -1
  37. package/dist/cli/commands/prepare-package.d.ts.map +1 -1
  38. package/dist/cli/commands/prepare-package.js.map +1 -1
  39. package/dist/cli/commands/review/rules/index.d.ts.map +1 -1
  40. package/dist/cli/commands/review/rules/index.js +4 -0
  41. package/dist/cli/commands/review/rules/index.js.map +1 -1
  42. package/dist/cli/commands/review/rules/require-all-react-dependencies.d.ts +14 -0
  43. package/dist/cli/commands/review/rules/require-all-react-dependencies.d.ts.map +1 -0
  44. package/dist/cli/commands/review/rules/require-all-react-dependencies.js +64 -0
  45. package/dist/cli/commands/review/rules/require-all-react-dependencies.js.map +1 -0
  46. package/dist/cli/commands/review/rules/require-one-react-version.d.ts +5 -0
  47. package/dist/cli/commands/review/rules/require-one-react-version.d.ts.map +1 -0
  48. package/dist/cli/commands/review/rules/require-one-react-version.js +25 -0
  49. package/dist/cli/commands/review/rules/require-one-react-version.js.map +1 -0
  50. package/dist/cli/commands/review/rules/require-one-uikit-version.d.ts.map +1 -1
  51. package/dist/cli/commands/review/rules/require-one-uikit-version.js +1 -0
  52. package/dist/cli/commands/review/rules/require-one-uikit-version.js.map +1 -1
  53. package/dist/cli/commands/review/utils/format-depends-on.d.ts +1 -0
  54. package/dist/cli/commands/review/utils/format-depends-on.d.ts.map +1 -1
  55. package/dist/cli/commands/review/utils/format-depends-on.js +15 -8
  56. package/dist/cli/commands/review/utils/format-depends-on.js.map +1 -1
  57. package/dist/cli/commands/review/utils/set-version.d.ts +2 -1
  58. package/dist/cli/commands/review/utils/set-version.d.ts.map +1 -1
  59. package/dist/cli/commands/review/utils/set-version.js +4 -2
  60. package/dist/cli/commands/review/utils/set-version.js.map +1 -1
  61. package/dist/cli/commands/start.d.ts +1 -1
  62. package/dist/cli/commands/start.d.ts.map +1 -1
  63. package/dist/cli/commands/start.js.map +1 -1
  64. package/dist/cli/commands/test/index.d.ts +2 -0
  65. package/dist/cli/commands/test/index.d.ts.map +1 -0
  66. package/dist/cli/commands/test/index.js +20 -0
  67. package/dist/cli/commands/test/index.js.map +1 -0
  68. package/dist/cli/commands/test/runners/index.d.ts +3 -0
  69. package/dist/cli/commands/test/runners/index.d.ts.map +1 -0
  70. package/dist/cli/commands/test/runners/index.js +21 -0
  71. package/dist/cli/commands/test/runners/index.js.map +1 -0
  72. package/dist/cli/commands/test/runners/jest.d.ts +7 -0
  73. package/dist/cli/commands/test/runners/jest.d.ts.map +1 -0
  74. package/dist/cli/commands/test/runners/jest.js +43 -0
  75. package/dist/cli/commands/test/runners/jest.js.map +1 -0
  76. package/dist/cli/commands/test/runners/vitest.d.ts +4 -0
  77. package/dist/cli/commands/test/runners/vitest.d.ts.map +1 -0
  78. package/dist/cli/commands/test/runners/vitest.js +86 -0
  79. package/dist/cli/commands/test/runners/vitest.js.map +1 -0
  80. package/dist/cli/commands/test/tests.d.ts +18 -0
  81. package/dist/cli/commands/test/tests.d.ts.map +1 -0
  82. package/dist/cli/commands/{tests.js → test/tests.js} +10 -9
  83. package/dist/cli/commands/test/tests.js.map +1 -0
  84. package/dist/cli/commands/upload-sourcemaps.d.ts.map +1 -1
  85. package/dist/cli/commands/upload-sourcemaps.js +1 -1
  86. package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
  87. package/dist/cli/index.js +1 -2
  88. package/dist/cli/index.js.map +1 -1
  89. package/dist/cli/utils/bundle.d.ts.map +1 -1
  90. package/dist/cli/utils/bundle.js +7 -4
  91. package/dist/cli/utils/bundle.js.map +1 -1
  92. package/dist/cli/utils/cli-git.d.ts +11 -2
  93. package/dist/cli/utils/cli-git.d.ts.map +1 -1
  94. package/dist/cli/utils/cli-git.js +60 -4
  95. package/dist/cli/utils/cli-git.js.map +1 -1
  96. package/dist/cli/utils/index.d.ts +6 -0
  97. package/dist/cli/utils/index.d.ts.map +1 -1
  98. package/dist/cli/utils/index.js +6 -0
  99. package/dist/cli/utils/index.js.map +1 -1
  100. package/dist/cli/utils/is-ci.d.ts +2 -0
  101. package/dist/cli/utils/is-ci.d.ts.map +1 -0
  102. package/dist/cli/utils/is-ci.js +15 -0
  103. package/dist/cli/utils/is-ci.js.map +1 -0
  104. package/dist/cli/utils/lerna-exec.d.ts.map +1 -1
  105. package/dist/cli/utils/lerna-exec.js +2 -1
  106. package/dist/cli/utils/lerna-exec.js.map +1 -1
  107. package/dist/cli/utils/set-node-options.d.ts.map +1 -1
  108. package/dist/cli/utils/set-node-options.js.map +1 -1
  109. package/dist/index.d.ts +0 -1
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +0 -1
  112. package/dist/index.js.map +1 -1
  113. package/dist/utils/get-branch-configs.d.ts +1 -1
  114. package/dist/utils/get-branch-configs.d.ts.map +1 -1
  115. package/dist/utils/get-branch-configs.js +2 -2
  116. package/dist/utils/get-branch-configs.js.map +1 -1
  117. package/dist/utils/get-configuration.d.ts +8 -2
  118. package/dist/utils/get-configuration.d.ts.map +1 -1
  119. package/dist/utils/get-configuration.js +10 -2
  120. package/dist/utils/get-configuration.js.map +1 -1
  121. package/dist/utils/get-jest-config.d.ts +1 -7
  122. package/dist/utils/get-jest-config.d.ts.map +1 -1
  123. package/dist/utils/get-jest-config.js +49 -58
  124. package/dist/utils/get-jest-config.js.map +1 -1
  125. package/dist/utils/index.d.ts +1 -0
  126. package/dist/utils/index.d.ts.map +1 -1
  127. package/dist/utils/index.js +1 -0
  128. package/dist/utils/index.js.map +1 -1
  129. package/dist/webpack/utils/testing/get-compiler.js.map +1 -1
  130. package/package.json +16 -14
  131. package/src/cli/commands/__tests__/init.test.ts +21 -87
  132. package/src/cli/commands/__tests__/install.test.ts +174 -12
  133. package/src/cli/commands/__tests__/mfe-package-clean.test.ts +3 -6
  134. package/src/cli/commands/__tests__/mfe-package-publish.test.ts +6 -8
  135. package/src/cli/commands/__tests__/upload-sourcemaps.test.ts +7 -3
  136. package/src/cli/commands/build.ts +1 -1
  137. package/src/cli/commands/bundle-package.ts +1 -1
  138. package/src/cli/commands/eslint.ts +1 -1
  139. package/src/cli/commands/get-command.ts +1 -1
  140. package/src/cli/commands/index.ts +1 -1
  141. package/src/cli/commands/init.ts +18 -38
  142. package/src/cli/commands/install.ts +95 -6
  143. package/src/cli/commands/lint.ts +1 -1
  144. package/src/cli/commands/mfe-package-clean.ts +2 -4
  145. package/src/cli/commands/mfe-package-publish.ts +18 -6
  146. package/src/cli/commands/mfe-publish.ts +1 -1
  147. package/src/cli/commands/prepare-package.ts +1 -1
  148. package/src/cli/commands/review/rules/__tests__/require-all-react-dependencies.test.ts +132 -0
  149. package/src/cli/commands/review/rules/__tests__/require-one-package-version.test.ts +0 -1
  150. package/src/cli/commands/review/rules/__tests__/require-one-react-version.test.ts +22 -0
  151. package/src/cli/commands/review/rules/__tests__/{require-one-uikit-version.ts → require-one-uikit-version.test.ts} +1 -0
  152. package/src/cli/commands/review/rules/index.ts +4 -0
  153. package/src/cli/commands/review/rules/require-all-react-dependencies.ts +53 -0
  154. package/src/cli/commands/review/rules/require-one-react-version.ts +9 -0
  155. package/src/cli/commands/review/rules/require-one-uikit-version.ts +1 -0
  156. package/src/cli/commands/review/utils/__tests__/set-version.test.ts +18 -8
  157. package/src/cli/commands/review/utils/format-depends-on.ts +8 -5
  158. package/src/cli/commands/review/utils/set-version.ts +10 -2
  159. package/src/cli/commands/start.ts +1 -1
  160. package/src/cli/commands/test/__tests__/tests.test.ts +78 -0
  161. package/src/cli/commands/test/index.ts +1 -0
  162. package/src/cli/commands/{__tests__/tests.test.ts → test/runners/__tests__/jest.test.ts} +10 -13
  163. package/src/cli/commands/test/runners/__tests__/vitest.test.ts +150 -0
  164. package/src/cli/commands/test/runners/index.ts +2 -0
  165. package/src/cli/commands/{tests.ts → test/runners/jest.ts} +5 -16
  166. package/src/cli/commands/test/runners/vitest.ts +70 -0
  167. package/src/cli/commands/test/tests.ts +34 -0
  168. package/src/cli/commands/upload-sourcemaps.ts +2 -2
  169. package/src/cli/index.ts +1 -2
  170. package/src/cli/utils/__tests__/bundle.test.ts +1 -1
  171. package/src/cli/utils/__tests__/cli-git.test.ts +142 -6
  172. package/src/cli/utils/__tests__/eslint.test.ts +3 -2
  173. package/src/cli/utils/__tests__/is-ci.test.ts +40 -0
  174. package/src/cli/utils/__tests__/lerna-exec.test.ts +6 -3
  175. package/src/cli/utils/bundle.ts +8 -3
  176. package/src/cli/utils/cli-git.ts +55 -5
  177. package/src/cli/utils/index.ts +6 -0
  178. package/src/cli/utils/is-ci.ts +3 -0
  179. package/src/cli/utils/lerna-exec.ts +2 -1
  180. package/src/cli/utils/set-node-options.ts +2 -2
  181. package/src/index.ts +0 -1
  182. package/src/utils/__tests__/get-configuration.test.ts +48 -11
  183. package/src/utils/__tests__/get-jest-config.test.ts +35 -61
  184. package/src/utils/get-branch-configs.ts +1 -1
  185. package/src/utils/get-configuration.ts +14 -3
  186. package/src/utils/get-jest-config.ts +39 -47
  187. package/src/utils/index.ts +1 -0
  188. package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +1 -1
  189. package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +1 -1
  190. package/src/webpack/__tests__/create-webpack-config.test.ts +1 -1
  191. package/src/webpack/utils/testing/get-compiler.ts +1 -1
  192. package/dist/cli/commands/tests.d.ts +0 -13
  193. package/dist/cli/commands/tests.d.ts.map +0 -1
  194. package/dist/cli/commands/tests.js.map +0 -1
  195. package/dist/jest/index.d.ts +0 -2
  196. package/dist/jest/index.d.ts.map +0 -1
  197. package/dist/jest/index.js +0 -16
  198. package/dist/jest/index.js.map +0 -1
  199. package/src/jest/index.ts +0 -5
@@ -2,17 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get getJestConfig () {
13
- return getJestConfig;
14
- },
15
- get getJestConfigCLI () {
5
+ Object.defineProperty(exports, "getJestConfigCLI", {
6
+ enumerable: true,
7
+ get: function() {
16
8
  return getJestConfigCLI;
17
9
  }
18
10
  });
@@ -25,29 +17,13 @@ function _interop_require_default(obj) {
25
17
  default: obj
26
18
  };
27
19
  }
28
- const getJestConfigBase = ({ coveragePathIgnorePatterns = [], setupFiles = [], testPathIgnorePatterns = [] })=>{
20
+ function getDefaultJestConfiguration({ coveragePathIgnorePatterns = [], setupFiles = [], testPathIgnorePatterns = [] }) {
29
21
  const moduleNameMapper = {
30
- '\\.(css|scss|less|png|svg|jpg|jpeg|gif|woff|woff2|eot|ttf|otf)$': 'identity-obj-proxy'
22
+ '\\.(css|scss|less|png|svg|svg\\?\\w+|jpg|jpeg|gif|woff|woff2|eot|ttf|otf)$': 'identity-obj-proxy'
31
23
  };
32
24
  return {
33
- verbose: true,
34
- testEnvironment: 'jsdom',
35
- testRunner: 'jest-circus/runner',
36
- transformIgnorePatterns: [
37
- 'node_modules/(?!(@servicetitan|@react-hook|nanoid|axios)/)'
38
- ],
39
- modulePathIgnorePatterns: [
40
- '<rootDir>/.*/__mocks__'
41
- ],
42
- moduleNameMapper,
43
- testPathIgnorePatterns: [
44
- '\\.yalc',
45
- ...(0, _getdestinationfolders.getDestinationFolders)(),
46
- ...(0, _toarray.toArray)(testPathIgnorePatterns)
47
- ],
48
- setupFiles: [
49
- _path.default.join(__dirname, '../../jest/setup.js'),
50
- ...(0, _toarray.toArray)(setupFiles)
25
+ collectCoverageFrom: [
26
+ '**/*.{ts,tsx}'
51
27
  ],
52
28
  coveragePathIgnorePatterns: [
53
29
  '^.+\\.d\\.ts$',
@@ -60,40 +36,55 @@ const getJestConfigBase = ({ coveragePathIgnorePatterns = [], setupFiles = [], t
60
36
  'cobertura',
61
37
  'lcov'
62
38
  ],
63
- collectCoverageFrom: [
64
- '**/*.{ts,tsx}'
39
+ moduleNameMapper,
40
+ modulePathIgnorePatterns: [
41
+ '<rootDir>/.*/__mocks__'
42
+ ],
43
+ preset: _path.default.join(__dirname, '../../jest'),
44
+ setupFiles: [
45
+ _path.default.join(__dirname, '../../jest/setup.js'),
46
+ ...(0, _toarray.toArray)(setupFiles)
47
+ ],
48
+ testEnvironment: 'jsdom',
49
+ testPathIgnorePatterns: [
50
+ '\\.yalc',
51
+ ...(0, _getdestinationfolders.getDestinationFolders)(),
52
+ ...(0, _toarray.toArray)(testPathIgnorePatterns)
65
53
  ],
66
- preset: _path.default.join(__dirname, '../../jest')
54
+ testRunner: 'jest-circus/runner',
55
+ transformIgnorePatterns: [
56
+ 'node_modules/(?!(@servicetitan|@react-hook|nanoid|axios)/)'
57
+ ],
58
+ verbose: true
67
59
  };
68
- };
69
- const getJestConfig = ()=>{
70
- const { coveragePathIgnorePatterns, setupFiles, testPathIgnorePatterns, ...config } = (0, _getconfiguration.getJestConfiguration)();
71
- return {
72
- ...getJestConfigBase({
60
+ }
61
+ function getJestConfigCLI(args) {
62
+ const { coveragePathIgnorePatterns, setupFiles, testPathIgnorePatterns, ...config } = {
63
+ ...(0, _getconfiguration.getJestConfiguration)(),
64
+ ...args
65
+ };
66
+ return stringifyForCLI({
67
+ ...getDefaultJestConfiguration({
73
68
  coveragePathIgnorePatterns,
74
69
  setupFiles,
75
70
  testPathIgnorePatterns
76
71
  }),
77
72
  ...config
78
- };
79
- };
80
- const getJestConfigCLI = (args)=>{
81
- const { coveragePathIgnorePatterns, setupFiles, testPathIgnorePatterns, globals, ...config } = {
82
- ...(0, _getconfiguration.getJestConfiguration)(),
83
- ...args
84
- };
85
- const { collectCoverageFrom, moduleNameMapper, ...rest } = getJestConfigBase({
86
- coveragePathIgnorePatterns,
87
- setupFiles,
88
- testPathIgnorePatterns
89
73
  });
90
- return {
91
- collectCoverageFrom: JSON.stringify(collectCoverageFrom),
92
- globals: JSON.stringify(globals),
93
- moduleNameMapper: JSON.stringify(moduleNameMapper),
94
- ...rest,
95
- ...config
96
- };
97
- };
74
+ }
75
+ function stringifyForCLI(config) {
76
+ return [
77
+ 'collectCoverageFrom',
78
+ 'globals',
79
+ 'moduleNameMapper',
80
+ 'transform'
81
+ ].reduce((result, key)=>{
82
+ const value = result[key];
83
+ if (value && typeof value !== 'string') {
84
+ result[key] = JSON.stringify(result[key]);
85
+ }
86
+ return result;
87
+ }, config);
88
+ }
98
89
 
99
90
  //# sourceMappingURL=get-jest-config.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/get-jest-config.ts"],"sourcesContent":["import path from 'path';\nimport { Config } from '@jest/types';\nimport { JestConfiguration, getJestConfiguration } from './get-configuration';\nimport { getDestinationFolders } from './get-destination-folders';\nimport { toArray } from './to-array';\n\nconst getJestConfigBase = ({\n coveragePathIgnorePatterns = [],\n setupFiles = [],\n testPathIgnorePatterns = [],\n}: {\n coveragePathIgnorePatterns?: string[];\n setupFiles?: string[];\n testPathIgnorePatterns?: string[];\n}) => {\n const moduleNameMapper = {\n '\\\\.(css|scss|less|png|svg|jpg|jpeg|gif|woff|woff2|eot|ttf|otf)$': 'identity-obj-proxy',\n };\n\n return {\n verbose: true,\n testEnvironment: 'jsdom',\n testRunner: 'jest-circus/runner',\n transformIgnorePatterns: ['node_modules/(?!(@servicetitan|@react-hook|nanoid|axios)/)'],\n modulePathIgnorePatterns: ['<rootDir>/.*/__mocks__'],\n moduleNameMapper,\n testPathIgnorePatterns: [\n '\\\\.yalc',\n ...getDestinationFolders(),\n ...toArray(testPathIgnorePatterns),\n ],\n setupFiles: [path.join(__dirname, '../../jest/setup.js'), ...toArray(setupFiles)],\n coveragePathIgnorePatterns: ['^.+\\\\.d\\\\.ts$', ...coveragePathIgnorePatterns],\n coverageReporters: ['html-spa', 'text', 'json', 'cobertura', 'lcov'],\n collectCoverageFrom: ['**/*.{ts,tsx}'],\n preset: path.join(__dirname, '../../jest'),\n };\n};\n\n/**\n * Get Jest clean config for running tests. This config could be used to export Jest configuration into the\n * Jest config files.\n */\nexport const getJestConfig = (): JestConfiguration => {\n const { coveragePathIgnorePatterns, setupFiles, testPathIgnorePatterns, ...config } =\n getJestConfiguration() as Record<string, any>;\n return {\n ...getJestConfigBase({\n coveragePathIgnorePatterns,\n setupFiles,\n testPathIgnorePatterns,\n }),\n ...config,\n };\n};\n\n/**\n * Get Jest config for running it using jest CLI (see jest runCLI function)\n */\nexport const getJestConfigCLI = (args: Config.Argv): Config.Argv => {\n const { coveragePathIgnorePatterns, setupFiles, testPathIgnorePatterns, globals, ...config } = {\n ...getJestConfiguration(),\n ...args,\n };\n\n const { collectCoverageFrom, moduleNameMapper, ...rest } = getJestConfigBase({\n coveragePathIgnorePatterns,\n setupFiles,\n testPathIgnorePatterns,\n });\n\n return {\n collectCoverageFrom: JSON.stringify(collectCoverageFrom),\n globals: JSON.stringify(globals),\n moduleNameMapper: JSON.stringify(moduleNameMapper),\n ...rest,\n ...config,\n };\n};\n"],"names":["getJestConfig","getJestConfigCLI","getJestConfigBase","coveragePathIgnorePatterns","setupFiles","testPathIgnorePatterns","moduleNameMapper","verbose","testEnvironment","testRunner","transformIgnorePatterns","modulePathIgnorePatterns","getDestinationFolders","toArray","path","join","__dirname","coverageReporters","collectCoverageFrom","preset","config","getJestConfiguration","args","globals","rest","JSON","stringify"],"mappings":";;;;;;;;;;;QA2CaA;eAAAA;;QAgBAC;eAAAA;;;6DA3DI;kCAEuC;uCAClB;yBACd;;;;;;AAExB,MAAMC,oBAAoB,CAAC,EACvBC,6BAA6B,EAAE,EAC/BC,aAAa,EAAE,EACfC,yBAAyB,EAAE,EAK9B;IACG,MAAMC,mBAAmB;QACrB,mEAAmE;IACvE;IAEA,OAAO;QACHC,SAAS;QACTC,iBAAiB;QACjBC,YAAY;QACZC,yBAAyB;YAAC;SAA6D;QACvFC,0BAA0B;YAAC;SAAyB;QACpDL;QACAD,wBAAwB;YACpB;eACGO,IAAAA,4CAAqB;eACrBC,IAAAA,gBAAO,EAACR;SACd;QACDD,YAAY;YAACU,aAAI,CAACC,IAAI,CAACC,WAAW;eAA2BH,IAAAA,gBAAO,EAACT;SAAY;QACjFD,4BAA4B;YAAC;eAAoBA;SAA2B;QAC5Ec,mBAAmB;YAAC;YAAY;YAAQ;YAAQ;YAAa;SAAO;QACpEC,qBAAqB;YAAC;SAAgB;QACtCC,QAAQL,aAAI,CAACC,IAAI,CAACC,WAAW;IACjC;AACJ;AAMO,MAAMhB,gBAAgB;IACzB,MAAM,EAAEG,0BAA0B,EAAEC,UAAU,EAAEC,sBAAsB,EAAE,GAAGe,QAAQ,GAC/EC,IAAAA,sCAAoB;IACxB,OAAO;QACH,GAAGnB,kBAAkB;YACjBC;YACAC;YACAC;QACJ,EAAE;QACF,GAAGe,MAAM;IACb;AACJ;AAKO,MAAMnB,mBAAmB,CAACqB;IAC7B,MAAM,EAAEnB,0BAA0B,EAAEC,UAAU,EAAEC,sBAAsB,EAAEkB,OAAO,EAAE,GAAGH,QAAQ,GAAG;QAC3F,GAAGC,IAAAA,sCAAoB,GAAE;QACzB,GAAGC,IAAI;IACX;IAEA,MAAM,EAAEJ,mBAAmB,EAAEZ,gBAAgB,EAAE,GAAGkB,MAAM,GAAGtB,kBAAkB;QACzEC;QACAC;QACAC;IACJ;IAEA,OAAO;QACHa,qBAAqBO,KAAKC,SAAS,CAACR;QACpCK,SAASE,KAAKC,SAAS,CAACH;QACxBjB,kBAAkBmB,KAAKC,SAAS,CAACpB;QACjC,GAAGkB,IAAI;QACP,GAAGJ,MAAM;IACb;AACJ"}
1
+ {"version":3,"sources":["../../src/utils/get-jest-config.ts"],"sourcesContent":["import { Config } from '@jest/types';\nimport path from 'path';\nimport { getJestConfiguration } from './get-configuration';\nimport { getDestinationFolders } from './get-destination-folders';\nimport { toArray } from './to-array';\n\nfunction getDefaultJestConfiguration({\n coveragePathIgnorePatterns = [],\n setupFiles = [],\n testPathIgnorePatterns = [],\n}: {\n coveragePathIgnorePatterns?: string[];\n setupFiles?: string[];\n testPathIgnorePatterns?: string[];\n}) {\n const moduleNameMapper = {\n '\\\\.(css|scss|less|png|svg|svg\\\\?\\\\w+|jpg|jpeg|gif|woff|woff2|eot|ttf|otf)$':\n 'identity-obj-proxy',\n };\n\n return {\n collectCoverageFrom: ['**/*.{ts,tsx}'],\n coveragePathIgnorePatterns: ['^.+\\\\.d\\\\.ts$', ...coveragePathIgnorePatterns],\n coverageReporters: ['html-spa', 'text', 'json', 'cobertura', 'lcov'],\n moduleNameMapper,\n modulePathIgnorePatterns: ['<rootDir>/.*/__mocks__'],\n preset: path.join(__dirname, '../../jest'),\n setupFiles: [path.join(__dirname, '../../jest/setup.js'), ...toArray(setupFiles)],\n testEnvironment: 'jsdom',\n testPathIgnorePatterns: [\n '\\\\.yalc',\n ...getDestinationFolders(),\n ...toArray(testPathIgnorePatterns),\n ],\n testRunner: 'jest-circus/runner',\n transformIgnorePatterns: ['node_modules/(?!(@servicetitan|@react-hook|nanoid|axios)/)'],\n verbose: true,\n };\n}\n\n/**\n * Get Jest config for running it using jest CLI (see jest runCLI function)\n */\nexport function getJestConfigCLI(args: Config.Argv): Config.Argv {\n const { coveragePathIgnorePatterns, setupFiles, testPathIgnorePatterns, ...config } = {\n ...getJestConfiguration(),\n ...args,\n };\n\n return stringifyForCLI({\n ...getDefaultJestConfiguration({\n coveragePathIgnorePatterns,\n setupFiles,\n testPathIgnorePatterns,\n }),\n ...config,\n });\n}\n\nfunction stringifyForCLI(config: any): Config.Argv {\n return ['collectCoverageFrom', 'globals', 'moduleNameMapper', 'transform'].reduce(\n (result, key) => {\n const value = result[key];\n if (value && typeof value !== 'string') {\n result[key] = JSON.stringify(result[key]);\n }\n return result;\n },\n config\n );\n}\n"],"names":["getJestConfigCLI","getDefaultJestConfiguration","coveragePathIgnorePatterns","setupFiles","testPathIgnorePatterns","moduleNameMapper","collectCoverageFrom","coverageReporters","modulePathIgnorePatterns","preset","path","join","__dirname","toArray","testEnvironment","getDestinationFolders","testRunner","transformIgnorePatterns","verbose","args","config","getJestConfiguration","stringifyForCLI","reduce","result","key","value","JSON","stringify"],"mappings":";;;;+BA2CgBA;;;eAAAA;;;6DA1CC;kCACoB;uCACC;yBACd;;;;;;AAExB,SAASC,4BAA4B,EACjCC,6BAA6B,EAAE,EAC/BC,aAAa,EAAE,EACfC,yBAAyB,EAAE,EAK9B;IACG,MAAMC,mBAAmB;QACrB,8EACI;IACR;IAEA,OAAO;QACHC,qBAAqB;YAAC;SAAgB;QACtCJ,4BAA4B;YAAC;eAAoBA;SAA2B;QAC5EK,mBAAmB;YAAC;YAAY;YAAQ;YAAQ;YAAa;SAAO;QACpEF;QACAG,0BAA0B;YAAC;SAAyB;QACpDC,QAAQC,aAAI,CAACC,IAAI,CAACC,WAAW;QAC7BT,YAAY;YAACO,aAAI,CAACC,IAAI,CAACC,WAAW;eAA2BC,IAAAA,gBAAO,EAACV;SAAY;QACjFW,iBAAiB;QACjBV,wBAAwB;YACpB;eACGW,IAAAA,4CAAqB;eACrBF,IAAAA,gBAAO,EAACT;SACd;QACDY,YAAY;QACZC,yBAAyB;YAAC;SAA6D;QACvFC,SAAS;IACb;AACJ;AAKO,SAASlB,iBAAiBmB,IAAiB;IAC9C,MAAM,EAAEjB,0BAA0B,EAAEC,UAAU,EAAEC,sBAAsB,EAAE,GAAGgB,QAAQ,GAAG;QAClF,GAAGC,IAAAA,sCAAoB,GAAE;QACzB,GAAGF,IAAI;IACX;IAEA,OAAOG,gBAAgB;QACnB,GAAGrB,4BAA4B;YAC3BC;YACAC;YACAC;QACJ,EAAE;QACF,GAAGgB,MAAM;IACb;AACJ;AAEA,SAASE,gBAAgBF,MAAW;IAChC,OAAO;QAAC;QAAuB;QAAW;QAAoB;KAAY,CAACG,MAAM,CAC7E,CAACC,QAAQC;QACL,MAAMC,QAAQF,MAAM,CAACC,IAAI;QACzB,IAAIC,SAAS,OAAOA,UAAU,UAAU;YACpCF,MAAM,CAACC,IAAI,GAAGE,KAAKC,SAAS,CAACJ,MAAM,CAACC,IAAI;QAC5C;QACA,OAAOD;IACX,GACAJ;AAER"}
@@ -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';
@@ -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,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,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,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,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  _export_star(require("./find-packages"), exports);
6
6
  _export_star(require("./find-up"), exports);
7
7
  _export_star(require("./format-duration"), exports);
8
+ _export_star(require("./get-branch-configs"), exports);
8
9
  _export_star(require("./get-configuration"), exports);
9
10
  _export_star(require("./get-destination-folders"), exports);
10
11
  _export_star(require("./get-folders"), 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 './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 './pick';\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"}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './find-packages';\nexport * from './find-up';\nexport * from './format-duration';\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 './pick';\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"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/webpack/utils/testing/get-compiler.ts"],"sourcesContent":["import path from 'path';\n\nimport webpack, { Configuration } from 'webpack';\nimport { merge } from 'webpack-merge';\n\nimport { createFsFromVolume, Volume } from 'memfs';\n\nexport function getCompilerFactory(cwd: string) {\n return function getCompiler(entry: string, loaderOptions = {}, config: Configuration = {}) {\n const compiler = webpack(\n merge(\n {\n mode: 'development',\n devtool: config.devtool ?? false,\n context: path.resolve(cwd, './__tests__/__mocks__'),\n entry: path.resolve(cwd, './__tests__/__mocks__', entry),\n output: {\n path: path.resolve(cwd, './__tests__/dist'),\n filename: '[name].bundle.js',\n chunkFilename: '[name].chunk.js',\n },\n module: {\n rules: [\n {\n test: new RegExp(`\\\\.${path.basename(cwd)}\\\\.\\\\w+$`, 'i'),\n rules: [\n {\n loader: require.resolve(cwd),\n options: loaderOptions,\n },\n ],\n },\n ],\n },\n plugins: [],\n },\n config\n )\n );\n\n compiler.outputFileSystem = createFsFromVolume(new Volume()) as any;\n\n return compiler;\n };\n}\n"],"names":["getCompilerFactory","cwd","getCompiler","entry","loaderOptions","config","compiler","webpack","merge","mode","devtool","context","path","resolve","output","filename","chunkFilename","module","rules","test","RegExp","basename","loader","require","options","plugins","outputFileSystem","createFsFromVolume","Volume"],"mappings":";;;;+BAOgBA;;;eAAAA;;;6DAPC;gEAEsB;8BACjB;uBAEqB;;;;;;AAEpC,SAASA,mBAAmBC,GAAW;IAC1C,OAAO,SAASC,YAAYC,KAAa,EAAEC,gBAAgB,CAAC,CAAC,EAAEC,SAAwB,CAAC,CAAC;YAKhEA;QAJrB,MAAMC,WAAWC,IAAAA,gBAAO,EACpBC,IAAAA,mBAAK,EACD;YACIC,MAAM;YACNC,SAASL,CAAAA,kBAAAA,OAAOK,OAAO,cAAdL,6BAAAA,kBAAkB;YAC3BM,SAASC,aAAI,CAACC,OAAO,CAACZ,KAAK;YAC3BE,OAAOS,aAAI,CAACC,OAAO,CAACZ,KAAK,yBAAyBE;YAClDW,QAAQ;gBACJF,MAAMA,aAAI,CAACC,OAAO,CAACZ,KAAK;gBACxBc,UAAU;gBACVC,eAAe;YACnB;YACAC,QAAQ;gBACJC,OAAO;oBACH;wBACIC,MAAM,IAAIC,OAAO,CAAC,GAAG,EAAER,aAAI,CAACS,QAAQ,CAACpB,KAAK,QAAQ,CAAC,EAAE;wBACrDiB,OAAO;4BACH;gCACII,QAAQC,QAAQV,OAAO,CAACZ;gCACxBuB,SAASpB;4BACb;yBACH;oBACL;iBACH;YACL;YACAqB,SAAS,EAAE;QACf,GACApB;QAIRC,SAASoB,gBAAgB,GAAGC,IAAAA,yBAAkB,EAAC,IAAIC,aAAM;QAEzD,OAAOtB;IACX;AACJ"}
1
+ {"version":3,"sources":["../../../../src/webpack/utils/testing/get-compiler.ts"],"sourcesContent":["import path from 'path';\n\nimport webpack, { Configuration } from 'webpack';\nimport { merge } from 'webpack-merge';\n\nimport { createFsFromVolume, Volume } from 'memfs';\n\nexport function getCompilerFactory(cwd: string) {\n return function getCompiler(entry: string, loaderOptions = {}, config: Configuration = {}) {\n const compiler = webpack(\n merge(\n {\n mode: 'development',\n devtool: config.devtool ?? false,\n context: path.resolve(cwd, './__tests__/__mocks__'),\n entry: path.resolve(cwd, './__tests__/__mocks__', entry),\n output: {\n path: path.resolve(cwd, './__tests__/dist'),\n filename: '[name].bundle.js',\n chunkFilename: '[name].chunk.js',\n },\n module: {\n rules: [\n {\n test: new RegExp(`\\\\.${path.basename(cwd)}\\\\.\\\\w+$`, 'i'),\n rules: [\n {\n loader: require.resolve(cwd),\n options: loaderOptions,\n },\n ],\n },\n ],\n },\n plugins: [],\n },\n config\n )\n )!;\n\n compiler.outputFileSystem = createFsFromVolume(new Volume()) as any;\n\n return compiler;\n };\n}\n"],"names":["getCompilerFactory","cwd","getCompiler","entry","loaderOptions","config","compiler","webpack","merge","mode","devtool","context","path","resolve","output","filename","chunkFilename","module","rules","test","RegExp","basename","loader","require","options","plugins","outputFileSystem","createFsFromVolume","Volume"],"mappings":";;;;+BAOgBA;;;eAAAA;;;6DAPC;gEAEsB;8BACjB;uBAEqB;;;;;;AAEpC,SAASA,mBAAmBC,GAAW;IAC1C,OAAO,SAASC,YAAYC,KAAa,EAAEC,gBAAgB,CAAC,CAAC,EAAEC,SAAwB,CAAC,CAAC;YAKhEA;QAJrB,MAAMC,WAAWC,IAAAA,gBAAO,EACpBC,IAAAA,mBAAK,EACD;YACIC,MAAM;YACNC,SAASL,CAAAA,kBAAAA,OAAOK,OAAO,cAAdL,6BAAAA,kBAAkB;YAC3BM,SAASC,aAAI,CAACC,OAAO,CAACZ,KAAK;YAC3BE,OAAOS,aAAI,CAACC,OAAO,CAACZ,KAAK,yBAAyBE;YAClDW,QAAQ;gBACJF,MAAMA,aAAI,CAACC,OAAO,CAACZ,KAAK;gBACxBc,UAAU;gBACVC,eAAe;YACnB;YACAC,QAAQ;gBACJC,OAAO;oBACH;wBACIC,MAAM,IAAIC,OAAO,CAAC,GAAG,EAAER,aAAI,CAACS,QAAQ,CAACpB,KAAK,QAAQ,CAAC,EAAE;wBACrDiB,OAAO;4BACH;gCACII,QAAQC,QAAQV,OAAO,CAACZ;gCACxBuB,SAASpB;4BACb;yBACH;oBACL;iBACH;YACL;YACAqB,SAAS,EAAE;QACf,GACApB;QAIRC,SAASoB,gBAAgB,GAAGC,IAAAA,yBAAkB,EAAC,IAAIC,aAAM;QAEzD,OAAOtB;IACX;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/startup",
3
- "version": "31.5.1",
3
+ "version": "32.0.0",
4
4
  "description": "",
5
5
  "homepage": "https://docs.st.dev/docs/frontend/startup",
6
6
  "repository": {
@@ -37,21 +37,22 @@
37
37
  "@jest/core": "~29.7.0",
38
38
  "@jest/types": "~29.6.3",
39
39
  "@jsdevtools/coverage-istanbul-loader": "^3.0.5",
40
- "@servicetitan/eslint-config": "31.5.1",
41
- "@servicetitan/stylelint-config": "31.5.1",
40
+ "@servicetitan/eslint-config": "32.0.0",
41
+ "@servicetitan/stylelint-config": "32.0.0",
42
42
  "@svgr/webpack": "^8.1.0",
43
43
  "@swc/cli": "^0.5.0",
44
- "@swc/core": "1.13.3",
44
+ "@swc/core": "1.13.5",
45
45
  "@types/debug": "^4.1.12",
46
46
  "@types/jest": "~29.5.12",
47
+ "@vitest/coverage-v8": "^3.2.4",
47
48
  "chalk": "~4.1.2",
48
49
  "cpx2": "8.0.0",
49
50
  "css-loader": "~7.1.2",
50
51
  "css-minimizer-webpack-plugin": "^7.0.2",
51
52
  "debounce": "^2.2.0",
52
- "debug": "^4.4.1",
53
+ "debug": "^4.4.3",
53
54
  "deepmerge": "~4.3.1",
54
- "eslint": "~9.33.0",
55
+ "eslint": "~9.35.0",
55
56
  "execa": "~5.1.1",
56
57
  "glob": "~11.0.3",
57
58
  "html-webpack-plugin": "~5.6.4",
@@ -62,31 +63,32 @@
62
63
  "jest-environment-jsdom": "^29.7.0",
63
64
  "jest-fetch-mock": "~3.0.3",
64
65
  "json5": "^2.2.3",
65
- "lerna": "~8.2.3",
66
- "less": "~4.4.0",
66
+ "lerna": "~8.2.4",
67
+ "less": "~4.4.1",
67
68
  "less-loader": "~12.3.0",
68
69
  "less-plugin-npm-import": "~2.1.0",
69
70
  "lodash.memoize": "^4.1.2",
70
- "memfs": "~4.36.0",
71
+ "memfs": "~4.38.2",
71
72
  "mini-css-extract-plugin": "~2.9.4",
72
73
  "moment-locales-webpack-plugin": "~1.2.0",
73
74
  "multimatch": "~5.0.0",
74
- "portfinder": "~1.0.37",
75
+ "portfinder": "~1.0.38",
75
76
  "postcss": "~8.5.6",
76
77
  "prettier": "~3.6.2",
77
- "sass": "~1.90.0",
78
+ "sass": "~1.92.1",
78
79
  "sass-loader": "~16.0.5",
79
80
  "semver": "~7.7.2",
80
81
  "source-map-loader": "~5.0.0",
81
82
  "style-loader": "~4.0.0",
82
- "stylelint": "~16.23.1",
83
+ "stylelint": "~16.24.0",
83
84
  "terminal-link": "^4.0.0",
84
85
  "terser-webpack-plugin": "^5.3.14",
85
86
  "ts-jest": "29.4.1",
86
87
  "ts-node": "~10.9.2",
87
88
  "typed-css-modules": "~0.9.1",
88
89
  "typescript": "5.9.2",
89
- "webpack": "~5.99.9",
90
+ "vitest": "^3.2.4",
91
+ "webpack": "~5.101.3",
90
92
  "webpack-assets-manifest": "~6.2.2",
91
93
  "webpack-bundle-analyzer": "^4.10.2",
92
94
  "webpack-dev-server": "~5.2.2",
@@ -118,5 +120,5 @@
118
120
  "cli": {
119
121
  "webpack": false
120
122
  },
121
- "gitHead": "8eb35a6e98b9e3cb3b18b452ce9ba76f278d0e61"
123
+ "gitHead": "af064114b3ec8c08a4b693a66c4062a52b03504c"
122
124
  }
@@ -2,40 +2,38 @@ import { fs, vol } from 'memfs';
2
2
  import { mkdirSync, rmSync } from 'fs';
3
3
  import path from 'path';
4
4
 
5
+ import { log } from '../../../utils';
6
+ import { gitCloneRepo, gitIsReachable } from '../../utils';
5
7
  import { Init } from '../init';
6
- import { runCommand, runCommandOutput } from '../../utils/cli-os';
7
8
 
8
9
  jest.mock('fs', () => fs);
9
- jest.mock('../../utils//cli-os', () => ({ runCommand: jest.fn(), runCommandOutput: jest.fn() }));
10
+ jest.mock('../../utils', () => ({
11
+ gitCloneRepo: jest.fn(),
12
+ gitIsReachable: jest.fn(),
13
+ }));
10
14
  jest.mock('../../../utils', () => ({
11
- log: { info: jest.fn() }, // suppress log output
15
+ log: { debug: jest.fn(), error: jest.fn(), info: jest.fn() },
12
16
  }));
13
17
 
14
- const webUrl = 'https://github.com/servicetitan/frontend-example.git';
15
- const sshUrl = 'git@github.com:servicetitan/frontend-example.git';
16
-
17
18
  describe(`[startup] ${Init.name}`, () => {
18
19
  let args: ConstructorParameters<typeof Init>[0];
19
20
 
20
21
  beforeEach(() => {
21
22
  args = {};
22
23
  vol.reset();
23
- jest.clearAllMocks();
24
- jest.mocked(runCommand).mockImplementation(jest.fn());
25
- jest.mocked(runCommandOutput).mockImplementation(jest.fn());
24
+ jest.mocked(gitCloneRepo).mockResolvedValue(true);
26
25
  jest.spyOn(fs, 'mkdirSync').mockImplementation(jest.fn());
27
26
  jest.spyOn(fs, 'rmSync').mockImplementation(jest.fn());
27
+ jest.spyOn(log, 'error').mockImplementation(jest.fn()); // suppress error output
28
28
  });
29
29
 
30
30
  const subject = async () => new Init(args).execute();
31
31
 
32
- test(`clones ${webUrl} to current directory`, async () => {
32
+ test('clones "frontend-example" to current directory', async () => {
33
33
  const cwd = path.resolve('.');
34
34
  await subject();
35
35
 
36
- expect(runCommand).toHaveBeenCalledWith(`git clone -q ${webUrl} ${cwd}`, {
37
- quiet: true,
38
- });
36
+ expect(gitCloneRepo).toHaveBeenCalledWith({ destination: cwd, name: 'frontend-example' });
39
37
  expect(rmSync).toHaveBeenCalledWith(path.join(cwd, '.git'), {
40
38
  recursive: true,
41
39
  force: true,
@@ -44,59 +42,18 @@ describe(`[startup] ${Init.name}`, () => {
44
42
  expect(rmSync).toHaveBeenCalledWith(path.join(cwd, 'package-lock.json'));
45
43
  });
46
44
 
47
- describe(`when cloning ${webUrl} fails`, () => {
48
- beforeEach(() => jest.mocked(runCommand).mockRejectedValueOnce('Nope!'));
49
-
50
- test(`clones ${sshUrl} to current directory`, async () => {
51
- await subject();
52
-
53
- expect(runCommand).toHaveBeenCalledWith(
54
- `git clone -q ${sshUrl} ${path.resolve('.')}`,
55
- expect.anything()
56
- );
57
- });
45
+ describe('when cloning fails', () => {
46
+ beforeEach(() => jest.mocked(gitCloneRepo).mockResolvedValue(false));
58
47
 
59
- describe(`when cloning ${sshUrl} also fails`, () => {
48
+ describe('when repo is not reachable', () => {
60
49
  beforeEach(() => {
61
- jest.mocked(runCommand).mockRejectedValue('Nope!');
62
- });
63
-
64
- test(`checks if ${webUrl} is reachable`, async () => {
65
- await subject();
66
-
67
- expect(runCommandOutput).toHaveBeenCalledWith(`git ls-remote -qt ${webUrl}`, {
68
- quiet: true,
69
- });
50
+ jest.mocked(gitIsReachable).mockReturnValue(false);
70
51
  });
71
52
 
72
- describe(`when ${webUrl} is not reachable`, () => {
73
- beforeEach(() => {
74
- jest.mocked(runCommandOutput).mockImplementationOnce(() => {
75
- throw new Error('Oops!');
76
- });
77
- });
78
-
79
- test(`checks if ${sshUrl} is reachable`, async () => {
80
- await subject();
81
-
82
- expect(runCommandOutput).toHaveBeenCalledWith(`git ls-remote -qt ${sshUrl}`, {
83
- quiet: true,
84
- });
85
- });
86
-
87
- describe(`when ${sshUrl} is also unreachable`, () => {
88
- beforeEach(() =>
89
- jest.mocked(runCommandOutput).mockImplementation(() => {
90
- throw new Error('Oops');
91
- })
92
- );
93
-
94
- test('raises error', async () => {
95
- await expect(subject()).rejects.toThrow(
96
- /could not read servicetitan\/frontend-example repository/
97
- );
98
- });
99
- });
53
+ test('raises error', async () => {
54
+ await expect(subject()).rejects.toThrow(
55
+ /could not read servicetitan\/frontend-example repository/
56
+ );
100
57
  });
101
58
  });
102
59
  });
@@ -104,15 +61,13 @@ describe(`[startup] ${Init.name}`, () => {
104
61
  describe('with an output location', () => {
105
62
  beforeEach(() => (args.output = 'foo/bar'));
106
63
 
107
- test(`clones ${webUrl} to output location`, async () => {
64
+ test('clones repo to output location', async () => {
108
65
  const destination = path.resolve(args.output!);
109
66
 
110
67
  await subject();
111
68
 
112
69
  expect(mkdirSync).toHaveBeenCalledWith(destination, { recursive: true });
113
- expect(runCommand).toHaveBeenCalledWith(`git clone -q ${webUrl} ${destination}`, {
114
- quiet: true,
115
- });
70
+ expect(gitCloneRepo).toHaveBeenCalledWith(expect.objectContaining({ destination }));
116
71
  });
117
72
 
118
73
  describe('when output location is a file', () => {
@@ -131,25 +86,4 @@ describe(`[startup] ${Init.name}`, () => {
131
86
  });
132
87
  });
133
88
  });
134
-
135
- describe('when running in CI environment with GITHUB_TOKEN', () => {
136
- const originalEnv = process.env;
137
- const token = 'foo-bar';
138
-
139
- beforeEach(() => {
140
- process.env.CI = 'true';
141
- process.env.GITHUB_TOKEN = token;
142
- });
143
- afterEach(() => (process.env = originalEnv));
144
-
145
- test(`adds token to ${webUrl}`, async () => {
146
- await subject();
147
-
148
- const urlWithToken = webUrl.replace('github.com', `oauth2:${token}@github.com`);
149
- expect(runCommand).toHaveBeenCalledWith(
150
- `git clone -q ${urlWithToken} ${path.resolve('.')}`,
151
- expect.anything()
152
- );
153
- });
154
- });
155
89
  });