@corva/create-app 0.0.0-73c49372

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 (193) hide show
  1. package/README.md +211 -0
  2. package/bin/cca.js +5 -0
  3. package/bin/create-corva-app.cjs +30 -0
  4. package/common/node/.env +15 -0
  5. package/common/node/.env.sample +26 -0
  6. package/common/node/gitignore +130 -0
  7. package/common/package.json +3 -0
  8. package/common/python/.env +5 -0
  9. package/common/python/.env.sample +7 -0
  10. package/common/python/Makefile +15 -0
  11. package/common/python/gitignore +161 -0
  12. package/common/python/requirements.txt +2 -0
  13. package/lib/commands/attach.js +28 -0
  14. package/lib/commands/create.js +463 -0
  15. package/lib/commands/release.js +52 -0
  16. package/lib/commands/rerun.js +34 -0
  17. package/lib/commands/zip.js +39 -0
  18. package/lib/constants/cache.js +5 -0
  19. package/lib/constants/cli.js +24 -0
  20. package/lib/constants/manifest.js +262 -0
  21. package/lib/constants/messages.js +15 -0
  22. package/lib/constants/package.js +269 -0
  23. package/lib/flow.js +53 -0
  24. package/lib/flows/attach.js +8 -0
  25. package/lib/flows/lib/api.js +376 -0
  26. package/lib/flows/lib/create-zip-archive.js +83 -0
  27. package/lib/flows/lib/json.js +30 -0
  28. package/lib/flows/lib/manifest.js +81 -0
  29. package/lib/flows/lib/notification.js +142 -0
  30. package/lib/flows/lib/step-error.js +10 -0
  31. package/lib/flows/lib/waitForMs.js +3 -0
  32. package/lib/flows/prepare.js +6 -0
  33. package/lib/flows/release.js +26 -0
  34. package/lib/flows/rerun.js +8 -0
  35. package/lib/flows/steps/attach/add-app-to-stream.js +23 -0
  36. package/lib/flows/steps/attach/get-all-live-assets.js +135 -0
  37. package/lib/flows/steps/attach/index.js +5 -0
  38. package/lib/flows/steps/attach/prepare-data.js +19 -0
  39. package/lib/flows/steps/prepare-load-app-files.js +12 -0
  40. package/lib/flows/steps/release/add-label.js +10 -0
  41. package/lib/flows/steps/release/add-notes.js +10 -0
  42. package/lib/flows/steps/release/get-config.js +41 -0
  43. package/lib/flows/steps/release/prepare-data.js +12 -0
  44. package/lib/flows/steps/release/publish.js +11 -0
  45. package/lib/flows/steps/release/remove-failed-upload.js +21 -0
  46. package/lib/flows/steps/release/upload-zip-to-corva.js +62 -0
  47. package/lib/flows/steps/release/wait-for-build.js +36 -0
  48. package/lib/flows/steps/rerun/create-task.js +77 -0
  49. package/lib/flows/steps/rerun/ensure-that-app-in-stream.js +68 -0
  50. package/lib/flows/steps/rerun/get-app-version.js +111 -0
  51. package/lib/flows/steps/rerun/prepare-data.js +162 -0
  52. package/lib/flows/steps/rerun/prepare-well-and-stream-data.js +188 -0
  53. package/lib/flows/steps/rerun/rerun.js +13 -0
  54. package/lib/flows/steps/zip-cleanup.js +17 -0
  55. package/lib/flows/steps/zip-create-archive.js +15 -0
  56. package/lib/flows/steps/zip-file-list-resolve.js +260 -0
  57. package/lib/flows/steps/zip-prepare.js +20 -0
  58. package/lib/flows/steps/zip.js +6 -0
  59. package/lib/flows/zip-simple.js +6 -0
  60. package/lib/flows/zip.js +7 -0
  61. package/lib/helpers/cli-version.js +114 -0
  62. package/lib/helpers/commands.js +13 -0
  63. package/lib/helpers/logger.js +35 -0
  64. package/lib/helpers/manifest.js +74 -0
  65. package/lib/helpers/resolve-app-runtime.js +128 -0
  66. package/lib/helpers/utils.js +91 -0
  67. package/lib/helpers/versioning.js +94 -0
  68. package/lib/main.js +68 -0
  69. package/lib/options/api-key.js +6 -0
  70. package/lib/options/app-key.js +6 -0
  71. package/lib/options/app-version.js +3 -0
  72. package/lib/options/bump-version.js +19 -0
  73. package/lib/options/cache.js +11 -0
  74. package/lib/options/env.js +3 -0
  75. package/lib/options/original-cwd.js +3 -0
  76. package/lib/options/silent.js +3 -0
  77. package/package.json +104 -0
  78. package/template_extensions/corva/.commitlintrc.json +6 -0
  79. package/template_extensions/corva/.github/pull_request_template.md +14 -0
  80. package/template_extensions/corva/.github/workflows/code-checks.yml +15 -0
  81. package/template_extensions/corva/.github/workflows/develop.yml +17 -0
  82. package/template_extensions/corva/.github/workflows/feat-fix-delete.yml +14 -0
  83. package/template_extensions/corva/.github/workflows/feat-fix.yml +23 -0
  84. package/template_extensions/corva/.github/workflows/release-fix-X.X.X.yml +16 -0
  85. package/template_extensions/corva/.github/workflows/validate-pr-title.yml +19 -0
  86. package/template_extensions/corva/.husky/commit-msg +5 -0
  87. package/template_extensions/corva/.husky/pre-commit +4 -0
  88. package/templates/scheduler_data-time/javascript/README.md +19 -0
  89. package/templates/scheduler_data-time/javascript/__tests__/processor.spec.js +15 -0
  90. package/templates/scheduler_data-time/javascript/index.js +15 -0
  91. package/templates/scheduler_data-time/python/README.md +31 -0
  92. package/templates/scheduler_data-time/python/lambda_function.py +7 -0
  93. package/templates/scheduler_data-time/python/test/__init__.py +0 -0
  94. package/templates/scheduler_data-time/python/test/app_test.py +10 -0
  95. package/templates/scheduler_data-time/typescript/README.md +25 -0
  96. package/templates/scheduler_data-time/typescript/__tests__/processor.spec.ts +15 -0
  97. package/templates/scheduler_data-time/typescript/index.ts +8 -0
  98. package/templates/scheduler_depth/javascript/README.md +19 -0
  99. package/templates/scheduler_depth/javascript/__tests__/processor.spec.js +17 -0
  100. package/templates/scheduler_depth/javascript/index.js +15 -0
  101. package/templates/scheduler_depth/python/README.md +31 -0
  102. package/templates/scheduler_depth/python/lambda_function.py +7 -0
  103. package/templates/scheduler_depth/python/test/__init__.py +0 -0
  104. package/templates/scheduler_depth/python/test/app_test.py +10 -0
  105. package/templates/scheduler_depth/typescript/README.md +25 -0
  106. package/templates/scheduler_depth/typescript/__tests__/processor.spec.ts +17 -0
  107. package/templates/scheduler_depth/typescript/index.ts +8 -0
  108. package/templates/scheduler_natural-time/javascript/README.md +19 -0
  109. package/templates/scheduler_natural-time/javascript/__tests__/processor.spec.js +15 -0
  110. package/templates/scheduler_natural-time/javascript/index.js +15 -0
  111. package/templates/scheduler_natural-time/python/README.md +31 -0
  112. package/templates/scheduler_natural-time/python/lambda_function.py +7 -0
  113. package/templates/scheduler_natural-time/python/test/__init__.py +0 -0
  114. package/templates/scheduler_natural-time/python/test/app_test.py +10 -0
  115. package/templates/scheduler_natural-time/typescript/README.md +25 -0
  116. package/templates/scheduler_natural-time/typescript/__tests__/processor.spec.ts +15 -0
  117. package/templates/scheduler_natural-time/typescript/index.ts +8 -0
  118. package/templates/stream_depth/javascript/README.md +19 -0
  119. package/templates/stream_depth/javascript/__tests__/processor.spec.js +20 -0
  120. package/templates/stream_depth/javascript/index.js +14 -0
  121. package/templates/stream_depth/python/README.md +31 -0
  122. package/templates/stream_depth/python/lambda_function.py +7 -0
  123. package/templates/stream_depth/python/test/__init__.py +0 -0
  124. package/templates/stream_depth/python/test/app_test.py +16 -0
  125. package/templates/stream_depth/typescript/README.md +25 -0
  126. package/templates/stream_depth/typescript/__tests__/processor.spec.ts +20 -0
  127. package/templates/stream_depth/typescript/index.ts +8 -0
  128. package/templates/stream_time/javascript/README.md +19 -0
  129. package/templates/stream_time/javascript/__tests__/processor.spec.js +14 -0
  130. package/templates/stream_time/javascript/index.js +14 -0
  131. package/templates/stream_time/python/README.md +31 -0
  132. package/templates/stream_time/python/lambda_function.py +7 -0
  133. package/templates/stream_time/python/test/__init__.py +0 -0
  134. package/templates/stream_time/python/test/app_test.py +16 -0
  135. package/templates/stream_time/typescript/README.md +25 -0
  136. package/templates/stream_time/typescript/__tests__/processor.spec.ts +14 -0
  137. package/templates/stream_time/typescript/index.ts +8 -0
  138. package/templates/task/javascript/README.md +19 -0
  139. package/templates/task/javascript/__tests__/processor.spec.js +16 -0
  140. package/templates/task/javascript/index.js +15 -0
  141. package/templates/task/python/README.md +31 -0
  142. package/templates/task/python/lambda_function.py +7 -0
  143. package/templates/task/python/test/__init__.py +0 -0
  144. package/templates/task/python/test/app_test.py +8 -0
  145. package/templates/task/typescript/README.md +25 -0
  146. package/templates/task/typescript/__tests__/processor.spec.ts +16 -0
  147. package/templates/task/typescript/index.ts +8 -0
  148. package/templates/ui/javascript/.eslintrc +11 -0
  149. package/templates/ui/javascript/.prettierrc +1 -0
  150. package/templates/ui/javascript/README.md +31 -0
  151. package/templates/ui/javascript/config/jest/babelTransform.js +16 -0
  152. package/templates/ui/javascript/config/jest/cssTransform.js +16 -0
  153. package/templates/ui/javascript/config/jest/fileTransform.js +48 -0
  154. package/templates/ui/javascript/config/jest/globalSetup.js +5 -0
  155. package/templates/ui/javascript/config/jest/setupTests.js +11 -0
  156. package/templates/ui/javascript/config-overrides.js +10 -0
  157. package/templates/ui/javascript/gitignore +27 -0
  158. package/templates/ui/javascript/src/App.completion.js +64 -0
  159. package/templates/ui/javascript/src/App.css +30 -0
  160. package/templates/ui/javascript/src/App.drilling.js +58 -0
  161. package/templates/ui/javascript/src/AppSettings.js +42 -0
  162. package/templates/ui/javascript/src/__mocks__/mockAppProps.js +590 -0
  163. package/templates/ui/javascript/src/__mocks__/mockAppSettingsProps.js +290 -0
  164. package/templates/ui/javascript/src/__tests__/App.test.js +21 -0
  165. package/templates/ui/javascript/src/__tests__/AppSettings.test.js +21 -0
  166. package/templates/ui/javascript/src/__tests__/TestsExample.test.js +37 -0
  167. package/templates/ui/javascript/src/assets/logo.svg +7 -0
  168. package/templates/ui/javascript/src/constants.js +3 -0
  169. package/templates/ui/javascript/src/index.js +7 -0
  170. package/templates/ui/typescript/.eslintrc +28 -0
  171. package/templates/ui/typescript/.prettierrc +1 -0
  172. package/templates/ui/typescript/README.md +31 -0
  173. package/templates/ui/typescript/config/jest/babelTransform.js +16 -0
  174. package/templates/ui/typescript/config/jest/cssTransform.js +16 -0
  175. package/templates/ui/typescript/config/jest/fileTransform.js +48 -0
  176. package/templates/ui/typescript/config/jest/globalSetup.js +5 -0
  177. package/templates/ui/typescript/config/jest/setupTests.js +11 -0
  178. package/templates/ui/typescript/config-overrides.js +10 -0
  179. package/templates/ui/typescript/gitignore +27 -0
  180. package/templates/ui/typescript/src/App.completion.tsx +66 -0
  181. package/templates/ui/typescript/src/App.css +30 -0
  182. package/templates/ui/typescript/src/App.drilling.tsx +60 -0
  183. package/templates/ui/typescript/src/AppSettings.tsx +38 -0
  184. package/templates/ui/typescript/src/__mocks__/mockAppProps.ts +590 -0
  185. package/templates/ui/typescript/src/__mocks__/mockAppSettingsProps.ts +290 -0
  186. package/templates/ui/typescript/src/__tests__/App.test.tsx +21 -0
  187. package/templates/ui/typescript/src/__tests__/AppSettings.test.tsx +21 -0
  188. package/templates/ui/typescript/src/__tests__/TestsExample.test.tsx +37 -0
  189. package/templates/ui/typescript/src/assets/logo.svg +7 -0
  190. package/templates/ui/typescript/src/constants.ts +3 -0
  191. package/templates/ui/typescript/src/custom.d.ts +9 -0
  192. package/templates/ui/typescript/src/index.js +7 -0
  193. package/templates/ui/typescript/tsconfig.json +8 -0
@@ -0,0 +1,262 @@
1
+ import { APP_RUNTIMES, APP_TYPES, TEMPLATE_TYPES } from './cli.js';
2
+
3
+ export const defaultManifest = {
4
+ format: 1,
5
+ license: {
6
+ type: 'MIT',
7
+ url: 'https://www.oandgexample.com/license/',
8
+ },
9
+ developer: {
10
+ name: 'O&G Company',
11
+ identifier: 'oandgc',
12
+ authors: [],
13
+ },
14
+ application: {
15
+ type: APP_TYPES.UI,
16
+ key: 'app.key-goes-here',
17
+ visibility: 'private',
18
+ name: 'Name of My App',
19
+ description: 'This is the description of my app. You can do great things with it!',
20
+ summary: 'More information about this app goes here',
21
+ category: '',
22
+ website: 'https://www.oandgexample.com/my-app/',
23
+ segments: ['drilling', 'completion'],
24
+ },
25
+ settings: {
26
+ entrypoint: {
27
+ file: 'index.js',
28
+ function: 'handler',
29
+ },
30
+ environment: {},
31
+ },
32
+ datasets: {},
33
+ };
34
+
35
+ export const defaultUIAppManifest = {
36
+ application: {
37
+ ui: {
38
+ initial_size: { w: 4, h: 10 },
39
+ multi_rig: false,
40
+ full_screen_report: false,
41
+ },
42
+ },
43
+ settings: {
44
+ entrypoint: {
45
+ file: 'src/index.js',
46
+ function: 'handler',
47
+ },
48
+ environment: {},
49
+ },
50
+ };
51
+
52
+ export const defaultDataAppNodeManifest = {
53
+ settings: {
54
+ entrypoint: {
55
+ file: 'index.js',
56
+ function: 'handler',
57
+ },
58
+ timeout: 120,
59
+ memory: 128,
60
+ environment: {},
61
+ },
62
+ };
63
+
64
+ export const defaultDataAppPythonManifest = {
65
+ settings: {
66
+ entrypoint: {
67
+ file: 'lambda_function',
68
+ function: 'lambda_handler',
69
+ },
70
+ timeout: 120,
71
+ memory: 128,
72
+ environment: {},
73
+ },
74
+ };
75
+
76
+ export const getManifestMandatoryKeys = (opts) => {
77
+ const keys = manifestOptions(opts.projectName).reduce((acc, option) => {
78
+ if (option.required) {
79
+ acc.push(option.name);
80
+ }
81
+
82
+ return acc;
83
+ }, []);
84
+
85
+ const { appType, schedulerType } = opts;
86
+
87
+ if (appType) {
88
+ if (appType !== APP_TYPES.UI) {
89
+ keys.push('runtime');
90
+ }
91
+
92
+ if (appType === APP_TYPES.SCHEDULER) {
93
+ if (!schedulerType) {
94
+ keys.push('schedulerType');
95
+ } else if (schedulerType === SCHEDULER_TYPE_DEPTH.value) {
96
+ keys.push('depthMilestone');
97
+ } else {
98
+ keys.push('cronString');
99
+ }
100
+ }
101
+ }
102
+
103
+ return keys;
104
+ };
105
+
106
+ export const SCHEDULER_TYPE_NATURAL_TIME = {
107
+ name: 'Natural Time',
108
+ value: 1,
109
+ };
110
+ export const SCHEDULER_TYPE_DATA_TIME = {
111
+ name: 'Data Time',
112
+ value: 2,
113
+ };
114
+ export const SCHEDULER_TYPE_DEPTH = {
115
+ name: 'Depth',
116
+ value: 4,
117
+ };
118
+
119
+ export const LOG_TYPES = {
120
+ TIME: 'time',
121
+ DEPTH: 'depth',
122
+ };
123
+
124
+ export const manifestOptions = (projectName = 'Corva Dev Center App') => [
125
+ {
126
+ name: 'developerName',
127
+ message: 'Enter the Developer Name',
128
+ default: 'O&G Company',
129
+ },
130
+ {
131
+ name: 'developerIdentifier',
132
+ message: 'Enter the Developer Identifier',
133
+ default: 'oandgc',
134
+ },
135
+ {
136
+ type: 'rawlist',
137
+ name: 'appType',
138
+ message: 'Choose the App Type',
139
+ default: APP_TYPES.UI,
140
+ choices: Object.values(APP_TYPES),
141
+ required: true,
142
+ },
143
+ {
144
+ type: 'rawlist',
145
+ name: 'schedulerType',
146
+ message: 'Choose the scheduler type',
147
+ default: SCHEDULER_TYPE_NATURAL_TIME.value,
148
+ choices: [SCHEDULER_TYPE_NATURAL_TIME, SCHEDULER_TYPE_DATA_TIME, SCHEDULER_TYPE_DEPTH],
149
+ when: (answers) => answers.appType === APP_TYPES.SCHEDULER,
150
+ },
151
+ {
152
+ name: 'cronString',
153
+ message: 'Provide CRON string for the scheduler',
154
+ default: '*/5 * * * *',
155
+ when: (answers) => answers.schedulerType && answers.schedulerType !== SCHEDULER_TYPE_DEPTH.value,
156
+ },
157
+ {
158
+ name: 'depthMilestone',
159
+ message: 'Provide depth milestone for the scheduler',
160
+ default: 1,
161
+ when: (answers) => answers.schedulerType === SCHEDULER_TYPE_DEPTH.value,
162
+ filter: (value) => (isNaN(value) ? value : Number(value)),
163
+ },
164
+ {
165
+ name: 'logType',
166
+ message: 'Choose the log type',
167
+ default: LOG_TYPES.TIME,
168
+ choices: Object.values(LOG_TYPES),
169
+ when: (answers) => answers.appType === APP_TYPES.STREAM,
170
+ },
171
+ {
172
+ name: 'appKey',
173
+ message: 'Enter the App Key',
174
+ default: 'app.key-goes-here',
175
+ required: true,
176
+ },
177
+ {
178
+ name: 'appName',
179
+ message: 'Enter the App Name',
180
+ default: projectName,
181
+ required: true,
182
+ },
183
+ {
184
+ name: 'description',
185
+ message: 'Enter description',
186
+ default: 'This is the description of my app. You can do great things with it!',
187
+ },
188
+ {
189
+ name: 'summary',
190
+ message: 'Enter summary',
191
+ default: 'More information about this app goes here',
192
+ },
193
+ {
194
+ name: 'category',
195
+ message: 'Enter category',
196
+ default: '',
197
+ required: true,
198
+ },
199
+ {
200
+ name: 'website',
201
+ message: 'Enter website',
202
+ default: 'https://www.oandgexample.com/my-app/',
203
+ },
204
+ {
205
+ type: 'rawlist',
206
+ name: 'segments',
207
+ message: 'Choose segments',
208
+ choices: ['drilling', 'completion'],
209
+ required: true,
210
+ },
211
+ {
212
+ type: 'rawlist',
213
+ name: 'runtime',
214
+ message: 'Choose runtime',
215
+ choices: (answers) => {
216
+ if (answers && answers.appType !== APP_TYPES.UI) {
217
+ return Object.values(APP_RUNTIMES).filter((value) => value !== APP_RUNTIMES.UI);
218
+ }
219
+
220
+ return Object.values(APP_RUNTIMES);
221
+ },
222
+ when: (answers) => answers.appType !== APP_TYPES.UI,
223
+ },
224
+ {
225
+ type: 'rawlist',
226
+ name: 'packageManager',
227
+ message: 'Please select the desired package manager',
228
+ alias: 'p',
229
+ default: 'yarn',
230
+ choices: ['yarn', 'npm'],
231
+ when: (answers) => !answers.runtime || !answers.runtime.startsWith(TEMPLATE_TYPES.PYTHON),
232
+ },
233
+ {
234
+ type: 'confirm',
235
+ name: 'useTypescript',
236
+ alias: 't',
237
+ message: 'Would you like to use TypesScript?',
238
+ default: false,
239
+ when: (answers) =>
240
+ (answers.runtime && answers.runtime.startsWith(TEMPLATE_TYPES.NODE)) || answers.appType === APP_TYPES.UI,
241
+ },
242
+ {
243
+ name: 'silent',
244
+ message: 'Only log result of the operation',
245
+ default: false,
246
+ },
247
+ {
248
+ name: 'no-dependencies-install',
249
+ message: 'Skip installing dependencies',
250
+ },
251
+ {
252
+ name: 'no-git-init',
253
+ message: 'Skip initializing git repository',
254
+ },
255
+ {
256
+ name: 'extensions',
257
+ message: 'App template extensions',
258
+ default: [],
259
+ when: (answers) => answers.appType === APP_TYPES.UI,
260
+ commaSeparated: true,
261
+ },
262
+ ];
@@ -0,0 +1,15 @@
1
+ import chalk from 'chalk';
2
+
3
+ export const SUCCESS_ICON = '✅';
4
+ export const ERROR_ICON = '❌';
5
+
6
+ export const RELEASE = {
7
+ createZip: 'Creating zip archive...\n',
8
+ createZipError: 'Could not create zip archive.',
9
+ createZipSuccess: `Zip archive has been created ${SUCCESS_ICON}\n`,
10
+ getAuthToken: 'Reading auth token...',
11
+ getAuthTokenError: `Could not find auth token or API_KEY in .env file.\nFor UI app please run ${chalk.cyan`yarn start`} and login to Corva to fetch it or set API_KEY in your .env file`,
12
+ getAppKey: 'Reading app key...',
13
+ getAppKeyError: "Could not find app key. Please make sure it's defined in manifest.json",
14
+ uploadApp: 'Uploading app...',
15
+ };
@@ -0,0 +1,269 @@
1
+ import _ from 'lodash';
2
+
3
+ const uiDependencies = {
4
+ '@corva/ui': 'latest',
5
+ '@material-ui/core': '4.11.2',
6
+ '@material-ui/icons': '4.9.1',
7
+ '@material-ui/lab': '4.0.0-alpha.57',
8
+ '@material-ui/pickers': '3.2.10',
9
+ '@icon-park/react': '1.4.2',
10
+ 'classnames': '2.2.6',
11
+ 'corva-convert-units': '1.10.33',
12
+ 'highcharts': '8.1.2',
13
+ 'highcharts-react-official': '2.2.2',
14
+ 'lodash': '^4.17.21',
15
+ 'mapbox.js': '3.2.1',
16
+ 'moment': '2.29.4',
17
+ 'moment-timezone': '0.5.43',
18
+ 'react': '17.0.1',
19
+ 'react-dom': '17.0.1',
20
+ };
21
+
22
+ const jsUiDevDependencies = {
23
+ '@corva/dc-platform-shared': 'latest',
24
+ '@corva/eslint-config-browser': 'latest',
25
+ '@testing-library/jest-dom': '^5.14.1',
26
+ '@testing-library/react': '^12.1.5',
27
+ '@testing-library/react-hooks': '^8.0.1',
28
+ '@testing-library/user-event': '^13.2.1',
29
+ 'jest-watch-typeahead': '^1.0.0',
30
+ 'jest': '^27.4.3',
31
+ 'babel-jest': '^27.4.2',
32
+ 'babel-preset-react-app': '^10.0.1',
33
+ 'eslint': '7.32.0',
34
+ 'postcss-loader': '4.1.0',
35
+ };
36
+
37
+ const tsUiDevDependencies = {
38
+ ...jsUiDevDependencies,
39
+ '@tsconfig/create-react-app': '1.0.2',
40
+ '@types/material-ui': '0.21.9',
41
+ '@types/mime': '3',
42
+ '@types/react': '^17.0.22',
43
+ '@types/react-dom': '^17.0.9',
44
+ '@types/jest': '^27.0.1',
45
+ '@typescript-eslint/eslint-plugin': '^4.31.2',
46
+ '@typescript-eslint/parser': '^4.31.2',
47
+ 'ts-loader': '8.2.0',
48
+ 'typescript': '4.6.3',
49
+ };
50
+
51
+ const corvaUiExtension = {
52
+ scripts: {
53
+ prepare: 'husky install',
54
+ },
55
+ devDependencies: {
56
+ '@commitlint/cli': '^17.0.0',
57
+ '@commitlint/config-conventional': '^17.0.0',
58
+ 'husky': '^8.0.0',
59
+ 'lint-staged': '^13.0.0',
60
+ },
61
+ };
62
+
63
+ function applyUiExtension(packageJson, extensionNames) {
64
+ if (!Array.isArray(extensionNames) || extensionNames.length === 0) {
65
+ return packageJson;
66
+ }
67
+
68
+ const extensions = extensionNames
69
+ .map((extensionName) => {
70
+ if (extensionName === 'corva') {
71
+ return corvaUiExtension;
72
+ }
73
+
74
+ return null;
75
+ })
76
+ .filter(Boolean);
77
+
78
+ return _.merge({}, packageJson, ...extensions);
79
+ }
80
+
81
+ const uiScripts = {
82
+ build: 'webpack --config=./config-overrides.js --mode production',
83
+ start: 'webpack-dev-server --config=./config-overrides.js --open --mode development',
84
+ zip: 'create-corva-app zip .',
85
+ lint: 'eslint --cache ./src/',
86
+ release: 'create-corva-app release .',
87
+ test: 'jest',
88
+ coverage: 'jest --coverage',
89
+ };
90
+
91
+ const uiPackage = {
92
+ 'version': '0.0.1',
93
+ 'main': 'src/index.js',
94
+ 'scripts': uiScripts,
95
+ 'dependencies': uiDependencies,
96
+ 'devDependencies': jsUiDevDependencies,
97
+ 'jest': {
98
+ roots: ['<rootDir>/src'],
99
+ collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/**/*.d.ts'],
100
+ coverageThreshold: {
101
+ global: {
102
+ branches: 60,
103
+ functions: 60,
104
+ lines: 60,
105
+ statements: 60,
106
+ },
107
+ },
108
+ setupFilesAfterEnv: ['<rootDir>/config/jest/setupTests.js'],
109
+ globalSetup: '<rootDir>/config/jest/globalSetup.js',
110
+ testMatch: ['<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}', '<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}'],
111
+ testEnvironment: 'jsdom',
112
+ transform: {
113
+ '^.+\\.(js|jsx|mjs|cjs|ts|tsx)$': '<rootDir>/config/jest/babelTransform.js',
114
+ '^.+\\.css$': '<rootDir>/config/jest/cssTransform.js',
115
+ '^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)': '<rootDir>/config/jest/fileTransform.js',
116
+ },
117
+ transformIgnorePatterns: [
118
+ '/node_modules/(?!.*@babel/runtime|@icon-park/react/es).+\\.(js|jsx|mjs|cjs|ts|tsx)$',
119
+ '^.+\\.module\\.(css|sass|scss)$',
120
+ ],
121
+ modulePaths: [],
122
+ moduleNameMapper: {
123
+ '~(.*)': '<rootDir>/src/$1',
124
+ '^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
125
+ '@corva/ui(.*)': '@corva/ui/cjs-bundle/$1',
126
+ },
127
+ watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
128
+ resetMocks: true,
129
+ },
130
+ 'lint-staged': {
131
+ 'src/**/*.{js,jsx,ts,tsx}': 'eslint --fix',
132
+ },
133
+ };
134
+
135
+ const tsUiPackage = {
136
+ ...uiPackage,
137
+ devDependencies: tsUiDevDependencies,
138
+ };
139
+
140
+ const nodeNpmScripts = {
141
+ 'bundle': 'create-corva-app zip .',
142
+ 'test': 'npm audit --production && npm run unit',
143
+ 'unit': 'jest',
144
+ 'lint': 'eslint --ext .js,.ts .',
145
+ 'lint:fix': 'eslint --ext .js,.ts --fix .',
146
+ };
147
+
148
+ const nodeDependencies = {
149
+ '@corva/node-sdk': '^8.3.0',
150
+ };
151
+
152
+ const nodeDevDependencies = {
153
+ '@corva/eslint-config-node': '^5.1.1',
154
+ 'jest': '^27.5.1',
155
+ 'dotenv': '^16.0.3',
156
+ 'eslint': '^8.2.0',
157
+ 'prettier': '^2.0.0',
158
+ 'typescript': '^4.9.4',
159
+ };
160
+
161
+ const nodeTsDevDependencies = {
162
+ ...nodeDevDependencies,
163
+ '@types/jest': '^27.4.1',
164
+ 'ts-jest': '^27.1.4',
165
+ };
166
+
167
+ const nodeYarnScripts = {
168
+ ...nodeNpmScripts,
169
+ test: 'yarn audit --groups dependencies && yarn unit',
170
+ };
171
+
172
+ const commonTsScripts = {
173
+ 'build': 'tsc -p tsconfig.build.json',
174
+ 'postbuild': 'cp manifest.json dist/manifest.json',
175
+ 'lint': 'eslint --ext .ts .',
176
+ 'lint:fix': 'eslint --ext .ts --fix .',
177
+ };
178
+
179
+ const nodeTsScripts = {
180
+ ...nodeNpmScripts,
181
+ ...commonTsScripts,
182
+ };
183
+
184
+ const nodeTsYarnScripts = {
185
+ ...nodeYarnScripts,
186
+ ...commonTsScripts,
187
+ };
188
+
189
+ const nodeNpmPackage = {
190
+ version: '0.0.1',
191
+ main: 'index.js',
192
+ private: true,
193
+ dependencies: nodeDependencies,
194
+ devDependencies: nodeDevDependencies,
195
+ scripts: nodeNpmScripts,
196
+ jest: {
197
+ setupFiles: ['dotenv/config'],
198
+ },
199
+ prettier: '@corva/eslint-config-node/prettier',
200
+ eslintConfig: {
201
+ root: true,
202
+ extends: '@corva/eslint-config-node',
203
+ },
204
+ };
205
+
206
+ const nodeYarnPackage = {
207
+ ...nodeNpmPackage,
208
+ scripts: nodeYarnScripts,
209
+ };
210
+
211
+ const nodeTsNpmPackage = {
212
+ ...nodeNpmPackage,
213
+ devDependencies: nodeTsDevDependencies,
214
+ scripts: nodeTsScripts,
215
+ jest: {
216
+ preset: 'ts-jest',
217
+ testEnvironment: 'node',
218
+ ...nodeNpmPackage.jest,
219
+ },
220
+ };
221
+
222
+ const nodeTsYarnPackage = {
223
+ ...nodeTsNpmPackage,
224
+ scripts: nodeTsYarnScripts,
225
+ };
226
+
227
+ const extendWithTsConfig = (packageJson, version) => {
228
+ packageJson.devDependencies = {
229
+ [`@tsconfig/node${version}`]: `^${version === '12' ? '1.0.9' : '1.0.1'}`,
230
+ ...packageJson.devDependencies,
231
+ };
232
+
233
+ return packageJson;
234
+ };
235
+
236
+ const defaults = {
237
+ javascript: {
238
+ yarn: {
239
+ ui: (runtime, opts) => applyUiExtension(uiPackage, opts?.extensions),
240
+ task: () => nodeYarnPackage,
241
+ scheduler: () => nodeYarnPackage,
242
+ stream: () => nodeYarnPackage,
243
+ },
244
+ npm: {
245
+ ui: (runtime, opts) => applyUiExtension(uiPackage, opts?.extensions),
246
+ task: () => nodeNpmPackage,
247
+ scheduler: () => nodeNpmPackage,
248
+ stream: () => nodeNpmPackage,
249
+ },
250
+ },
251
+ typescript: {
252
+ yarn: {
253
+ ui: (runtime, opts) => applyUiExtension(tsUiPackage, opts?.extensions),
254
+ task: ({ version }) => extendWithTsConfig(nodeTsYarnPackage, version),
255
+ scheduler: ({ version }) => extendWithTsConfig(nodeTsYarnPackage, version),
256
+ stream: ({ version }) => extendWithTsConfig(nodeTsYarnPackage, version),
257
+ },
258
+ npm: {
259
+ ui: (runtime, opts) => applyUiExtension(tsUiPackage, opts?.extensions),
260
+ task: ({ version }) => extendWithTsConfig(nodeTsNpmPackage, version),
261
+ scheduler: ({ version }) => extendWithTsConfig(nodeTsNpmPackage, version),
262
+ stream: ({ version }) => extendWithTsConfig(nodeTsNpmPackage, version),
263
+ },
264
+ },
265
+ };
266
+
267
+ export const getDefaultsForPackageJson = (manifest, runtime, opts) => {
268
+ return defaults[runtime.language][runtime.packageManager][manifest.type](runtime, opts);
269
+ };
package/lib/flow.js ADDED
@@ -0,0 +1,53 @@
1
+ import chalk from 'chalk';
2
+ import { resolve, sep } from 'node:path';
3
+ import { SUCCESS_ICON } from './constants/messages.js';
4
+ import { logger } from './helpers/logger.js';
5
+
6
+ import debugFn from 'debug';
7
+
8
+ const debug = debugFn('cca:flow');
9
+
10
+ export const runFlow = async (flow, context, indent = '') => {
11
+ logger.write(
12
+ `${indent}Running ${chalk.cyan(flow.name)} in ${chalk.cyan(resolve(context.dirName).split(sep).pop())}\n`,
13
+ );
14
+
15
+ context.progress = () => logger.write('.');
16
+
17
+ try {
18
+ const result = await runSteps(flow.steps, context, indent + ' ');
19
+
20
+ logger.write(`${indent}Done!` + SUCCESS_ICON + '\n');
21
+
22
+ return result;
23
+ } catch (error) {
24
+ logger.write(`\n`);
25
+
26
+ throw error;
27
+ }
28
+ };
29
+
30
+ const runSteps = async (steps = [], context = {}, indent = '') => {
31
+ for (const step of steps) {
32
+ if (step.name) {
33
+ const result = await runFlow(step, context, indent);
34
+
35
+ Object.assign(context, result);
36
+
37
+ continue;
38
+ }
39
+
40
+ const message = indent + step.message;
41
+
42
+ logger.write(message);
43
+ debug('Context: %o', context);
44
+
45
+ const result = await step.fn(context);
46
+
47
+ Object.assign(context, result);
48
+
49
+ logger.write(SUCCESS_ICON + '\n');
50
+ }
51
+
52
+ return context;
53
+ };
@@ -0,0 +1,8 @@
1
+ import { PREPARE_FLOW } from './prepare.js';
2
+ import { SETUP_API_CLIENT_STEP } from './steps/release/get-config.js';
3
+ import { ATTACH_STEPS } from './steps/attach/index.js';
4
+
5
+ export const ATTACH_FLOW = {
6
+ name: 'attach',
7
+ steps: [PREPARE_FLOW, SETUP_API_CLIENT_STEP, ...ATTACH_STEPS],
8
+ };