@corva/create-app 0.0.0-210a1a8

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 (204) hide show
  1. package/README.md +220 -0
  2. package/bin/cca.js +5 -0
  3. package/bin/create-corva-app.cjs +25 -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 +18 -0
  11. package/common/python/gitignore +161 -0
  12. package/common/python/pyproject.toml +25 -0
  13. package/common/python/uv.lock +381 -0
  14. package/common/ui/config/vite/corva-vite-config.mjs +384 -0
  15. package/common/ui/devApp.js +1 -0
  16. package/common/ui/index.html +17 -0
  17. package/common/ui/isolatedApp.js +1 -0
  18. package/common/ui/public/DevCenterIsolatedAppPage.html +26 -0
  19. package/common/ui/public/favicon.ico +0 -0
  20. package/common/ui/vite.config.mjs +3 -0
  21. package/common/ui/vitest.global-setup.js +4 -0
  22. package/common/ui/vitest.setup.js +26 -0
  23. package/lib/commands/attach.js +28 -0
  24. package/lib/commands/create.js +471 -0
  25. package/lib/commands/release.js +73 -0
  26. package/lib/commands/rerun.js +34 -0
  27. package/lib/commands/zip.js +39 -0
  28. package/lib/constants/cache.js +5 -0
  29. package/lib/constants/cli.js +32 -0
  30. package/lib/constants/manifest.js +263 -0
  31. package/lib/constants/messages.js +15 -0
  32. package/lib/constants/package.js +300 -0
  33. package/lib/flow.js +59 -0
  34. package/lib/flows/attach.js +8 -0
  35. package/lib/flows/lib/api.js +385 -0
  36. package/lib/flows/lib/create-zip-archive.js +83 -0
  37. package/lib/flows/lib/json.js +30 -0
  38. package/lib/flows/lib/manifest.js +81 -0
  39. package/lib/flows/lib/notification.js +142 -0
  40. package/lib/flows/lib/step-error.js +10 -0
  41. package/lib/flows/lib/waitForMs.js +3 -0
  42. package/lib/flows/prepare.js +6 -0
  43. package/lib/flows/release.js +30 -0
  44. package/lib/flows/rerun.js +8 -0
  45. package/lib/flows/steps/attach/add-app-to-stream.js +23 -0
  46. package/lib/flows/steps/attach/get-all-live-assets.js +135 -0
  47. package/lib/flows/steps/attach/index.js +5 -0
  48. package/lib/flows/steps/attach/prepare-data.js +19 -0
  49. package/lib/flows/steps/prepare-load-app-files.js +12 -0
  50. package/lib/flows/steps/release/add-label.js +10 -0
  51. package/lib/flows/steps/release/add-notes.js +10 -0
  52. package/lib/flows/steps/release/get-config.js +41 -0
  53. package/lib/flows/steps/release/prepare-data.js +12 -0
  54. package/lib/flows/steps/release/publish.js +11 -0
  55. package/lib/flows/steps/release/remove-failed-upload.js +21 -0
  56. package/lib/flows/steps/release/resolve-prebuilt-zip.js +35 -0
  57. package/lib/flows/steps/release/upload-zip-to-corva.js +136 -0
  58. package/lib/flows/steps/release/wait-for-build.js +36 -0
  59. package/lib/flows/steps/rerun/create-task.js +77 -0
  60. package/lib/flows/steps/rerun/ensure-that-app-in-stream.js +68 -0
  61. package/lib/flows/steps/rerun/get-app-version.js +111 -0
  62. package/lib/flows/steps/rerun/prepare-data.js +162 -0
  63. package/lib/flows/steps/rerun/prepare-well-and-stream-data.js +188 -0
  64. package/lib/flows/steps/rerun/rerun.js +13 -0
  65. package/lib/flows/steps/zip-cleanup.js +17 -0
  66. package/lib/flows/steps/zip-create-archive.js +15 -0
  67. package/lib/flows/steps/zip-file-list-resolve.js +273 -0
  68. package/lib/flows/steps/zip-prepare.js +20 -0
  69. package/lib/flows/steps/zip.js +6 -0
  70. package/lib/flows/zip-simple.js +8 -0
  71. package/lib/flows/zip.js +7 -0
  72. package/lib/helpers/cli-version.js +163 -0
  73. package/lib/helpers/commands.js +13 -0
  74. package/lib/helpers/logger.js +35 -0
  75. package/lib/helpers/manifest.js +82 -0
  76. package/lib/helpers/resolve-app-runtime.js +143 -0
  77. package/lib/helpers/utils.js +101 -0
  78. package/lib/helpers/versioning.js +94 -0
  79. package/lib/main.js +63 -0
  80. package/lib/options/api-key.js +6 -0
  81. package/lib/options/app-key.js +6 -0
  82. package/lib/options/app-version.js +3 -0
  83. package/lib/options/bump-version.js +19 -0
  84. package/lib/options/cache.js +11 -0
  85. package/lib/options/env.js +3 -0
  86. package/lib/options/original-cwd.js +3 -0
  87. package/lib/options/silent.js +3 -0
  88. package/lib/options/zip-file-name.js +18 -0
  89. package/package.json +1 -0
  90. package/template_extensions/corva/.commitlintrc.json +6 -0
  91. package/template_extensions/corva/.eslintrc +32 -0
  92. package/template_extensions/corva/.github/pull_request_template.md +14 -0
  93. package/template_extensions/corva/.github/workflows/code-checks.yml +15 -0
  94. package/template_extensions/corva/.github/workflows/develop.yml +19 -0
  95. package/template_extensions/corva/.github/workflows/feat-fix-delete.yml +14 -0
  96. package/template_extensions/corva/.github/workflows/feat-fix.yml +23 -0
  97. package/template_extensions/corva/.github/workflows/release-fix-X.X.X.yml +16 -0
  98. package/template_extensions/corva/.github/workflows/validate-pr-title.yml +19 -0
  99. package/template_extensions/corva/.husky/commit-msg +5 -0
  100. package/template_extensions/corva/.husky/pre-commit +4 -0
  101. package/template_extensions/corva/.release-please-manifest.json +3 -0
  102. package/template_extensions/corva/release-please-config.json +10 -0
  103. package/templates/scheduler_data-time/javascript/README.md +19 -0
  104. package/templates/scheduler_data-time/javascript/__tests__/processor.spec.js +15 -0
  105. package/templates/scheduler_data-time/javascript/index.js +15 -0
  106. package/templates/scheduler_data-time/python/README.md +31 -0
  107. package/templates/scheduler_data-time/python/lambda_function.py +7 -0
  108. package/templates/scheduler_data-time/python/test/__init__.py +0 -0
  109. package/templates/scheduler_data-time/python/test/app_test.py +10 -0
  110. package/templates/scheduler_data-time/typescript/README.md +25 -0
  111. package/templates/scheduler_data-time/typescript/__tests__/processor.spec.ts +15 -0
  112. package/templates/scheduler_data-time/typescript/index.ts +8 -0
  113. package/templates/scheduler_depth/javascript/README.md +19 -0
  114. package/templates/scheduler_depth/javascript/__tests__/processor.spec.js +17 -0
  115. package/templates/scheduler_depth/javascript/index.js +15 -0
  116. package/templates/scheduler_depth/python/README.md +31 -0
  117. package/templates/scheduler_depth/python/lambda_function.py +7 -0
  118. package/templates/scheduler_depth/python/test/__init__.py +0 -0
  119. package/templates/scheduler_depth/python/test/app_test.py +10 -0
  120. package/templates/scheduler_depth/typescript/README.md +25 -0
  121. package/templates/scheduler_depth/typescript/__tests__/processor.spec.ts +17 -0
  122. package/templates/scheduler_depth/typescript/index.ts +8 -0
  123. package/templates/scheduler_natural-time/javascript/README.md +19 -0
  124. package/templates/scheduler_natural-time/javascript/__tests__/processor.spec.js +15 -0
  125. package/templates/scheduler_natural-time/javascript/index.js +15 -0
  126. package/templates/scheduler_natural-time/python/README.md +31 -0
  127. package/templates/scheduler_natural-time/python/lambda_function.py +7 -0
  128. package/templates/scheduler_natural-time/python/test/__init__.py +0 -0
  129. package/templates/scheduler_natural-time/python/test/app_test.py +10 -0
  130. package/templates/scheduler_natural-time/typescript/README.md +25 -0
  131. package/templates/scheduler_natural-time/typescript/__tests__/processor.spec.ts +15 -0
  132. package/templates/scheduler_natural-time/typescript/index.ts +8 -0
  133. package/templates/stream_depth/javascript/README.md +19 -0
  134. package/templates/stream_depth/javascript/__tests__/processor.spec.js +20 -0
  135. package/templates/stream_depth/javascript/index.js +14 -0
  136. package/templates/stream_depth/python/README.md +31 -0
  137. package/templates/stream_depth/python/lambda_function.py +7 -0
  138. package/templates/stream_depth/python/test/__init__.py +0 -0
  139. package/templates/stream_depth/python/test/app_test.py +16 -0
  140. package/templates/stream_depth/typescript/README.md +25 -0
  141. package/templates/stream_depth/typescript/__tests__/processor.spec.ts +20 -0
  142. package/templates/stream_depth/typescript/index.ts +8 -0
  143. package/templates/stream_time/javascript/README.md +19 -0
  144. package/templates/stream_time/javascript/__tests__/processor.spec.js +14 -0
  145. package/templates/stream_time/javascript/index.js +14 -0
  146. package/templates/stream_time/python/README.md +31 -0
  147. package/templates/stream_time/python/lambda_function.py +7 -0
  148. package/templates/stream_time/python/test/__init__.py +0 -0
  149. package/templates/stream_time/python/test/app_test.py +16 -0
  150. package/templates/stream_time/typescript/README.md +25 -0
  151. package/templates/stream_time/typescript/__tests__/processor.spec.ts +14 -0
  152. package/templates/stream_time/typescript/index.ts +8 -0
  153. package/templates/task/javascript/README.md +19 -0
  154. package/templates/task/javascript/__tests__/processor.spec.js +16 -0
  155. package/templates/task/javascript/index.js +15 -0
  156. package/templates/task/python/README.md +31 -0
  157. package/templates/task/python/lambda_function.py +7 -0
  158. package/templates/task/python/test/__init__.py +0 -0
  159. package/templates/task/python/test/app_test.py +8 -0
  160. package/templates/task/typescript/README.md +25 -0
  161. package/templates/task/typescript/__tests__/processor.spec.ts +16 -0
  162. package/templates/task/typescript/index.ts +8 -0
  163. package/templates/ui/javascript/.codex/config.toml +3 -0
  164. package/templates/ui/javascript/.cursor/mcp.json +8 -0
  165. package/templates/ui/javascript/.eslintrc +13 -0
  166. package/templates/ui/javascript/.mcp.json +8 -0
  167. package/templates/ui/javascript/.prettierrc +1 -0
  168. package/templates/ui/javascript/AGENTS.md +306 -0
  169. package/templates/ui/javascript/CLAUDE.md +1 -0
  170. package/templates/ui/javascript/README.md +31 -0
  171. package/templates/ui/javascript/gitignore +27 -0
  172. package/templates/ui/javascript/src/App.completion.jsx +52 -0
  173. package/templates/ui/javascript/src/App.drilling.jsx +49 -0
  174. package/templates/ui/javascript/src/App.module.scss +17 -0
  175. package/templates/ui/javascript/src/AppSettings.jsx +28 -0
  176. package/templates/ui/javascript/src/__tests__/App.test.jsx +26 -0
  177. package/templates/ui/javascript/src/__tests__/AppSettings.test.jsx +28 -0
  178. package/templates/ui/javascript/src/__tests__/TestsExample.test.jsx +37 -0
  179. package/templates/ui/javascript/src/assets/logo.svg +7 -0
  180. package/templates/ui/javascript/src/constants.js +3 -0
  181. package/templates/ui/javascript/src/index.js +8 -0
  182. package/templates/ui/typescript/.codex/config.toml +3 -0
  183. package/templates/ui/typescript/.cursor/mcp.json +8 -0
  184. package/templates/ui/typescript/.eslintrc +31 -0
  185. package/templates/ui/typescript/.mcp.json +8 -0
  186. package/templates/ui/typescript/.prettierrc +1 -0
  187. package/templates/ui/typescript/AGENTS.md +347 -0
  188. package/templates/ui/typescript/CLAUDE.md +1 -0
  189. package/templates/ui/typescript/README.md +31 -0
  190. package/templates/ui/typescript/gitignore +27 -0
  191. package/templates/ui/typescript/src/App.completion.tsx +52 -0
  192. package/templates/ui/typescript/src/App.drilling.tsx +49 -0
  193. package/templates/ui/typescript/src/App.module.scss +17 -0
  194. package/templates/ui/typescript/src/AppSettings.tsx +28 -0
  195. package/templates/ui/typescript/src/__mocks__/mockData.ts +22 -0
  196. package/templates/ui/typescript/src/__tests__/App.test.tsx +27 -0
  197. package/templates/ui/typescript/src/__tests__/AppSettings.test.tsx +28 -0
  198. package/templates/ui/typescript/src/__tests__/TestsExample.test.tsx +37 -0
  199. package/templates/ui/typescript/src/assets/logo.svg +7 -0
  200. package/templates/ui/typescript/src/constants.ts +3 -0
  201. package/templates/ui/typescript/src/custom.d.ts +19 -0
  202. package/templates/ui/typescript/src/index.js +8 -0
  203. package/templates/ui/typescript/src/types.ts +3 -0
  204. package/templates/ui/typescript/tsconfig.json +20 -0
@@ -0,0 +1,263 @@
1
+ import { APP_RUNTIMES, APP_TYPES, SUPPORTED_NON_UI_APP_RUNTIMES, 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', 'intervention'],
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
+ use_app_header_v3: true,
42
+ },
43
+ },
44
+ settings: {
45
+ entrypoint: {
46
+ file: 'src/index.js',
47
+ function: 'handler',
48
+ },
49
+ environment: {},
50
+ },
51
+ };
52
+
53
+ export const defaultDataAppNodeManifest = {
54
+ settings: {
55
+ entrypoint: {
56
+ file: 'index.js',
57
+ function: 'handler',
58
+ },
59
+ timeout: 120,
60
+ memory: 128,
61
+ environment: {},
62
+ },
63
+ };
64
+
65
+ export const defaultDataAppPythonManifest = {
66
+ settings: {
67
+ entrypoint: {
68
+ file: 'lambda_function',
69
+ function: 'lambda_handler',
70
+ },
71
+ timeout: 120,
72
+ memory: 128,
73
+ environment: {},
74
+ },
75
+ };
76
+
77
+ export const getManifestMandatoryKeys = (opts) => {
78
+ const keys = manifestOptions(opts.projectName).reduce((acc, option) => {
79
+ if (option.required) {
80
+ acc.push(option.name);
81
+ }
82
+
83
+ return acc;
84
+ }, []);
85
+
86
+ const { appType, schedulerType } = opts;
87
+
88
+ if (appType) {
89
+ if (appType !== APP_TYPES.UI) {
90
+ keys.push('runtime');
91
+ }
92
+
93
+ if (appType === APP_TYPES.SCHEDULER) {
94
+ if (!schedulerType) {
95
+ keys.push('schedulerType');
96
+ } else if (schedulerType === SCHEDULER_TYPE_DEPTH.value) {
97
+ keys.push('depthMilestone');
98
+ } else {
99
+ keys.push('cronString');
100
+ }
101
+ }
102
+ }
103
+
104
+ return keys;
105
+ };
106
+
107
+ export const SCHEDULER_TYPE_NATURAL_TIME = {
108
+ name: 'Natural Time',
109
+ value: 1,
110
+ };
111
+ export const SCHEDULER_TYPE_DATA_TIME = {
112
+ name: 'Data Time',
113
+ value: 2,
114
+ };
115
+ export const SCHEDULER_TYPE_DEPTH = {
116
+ name: 'Depth',
117
+ value: 4,
118
+ };
119
+
120
+ export const LOG_TYPES = {
121
+ TIME: 'time',
122
+ DEPTH: 'depth',
123
+ };
124
+
125
+ export const manifestOptions = (projectName = 'Corva Dev Center App') => [
126
+ {
127
+ name: 'developerName',
128
+ message: 'Enter the Developer Name',
129
+ default: 'O&G Company',
130
+ },
131
+ {
132
+ name: 'developerIdentifier',
133
+ message: 'Enter the Developer Identifier',
134
+ default: 'oandgc',
135
+ },
136
+ {
137
+ type: 'rawlist',
138
+ name: 'appType',
139
+ message: 'Choose the App Type',
140
+ default: APP_TYPES.UI,
141
+ choices: Object.values(APP_TYPES),
142
+ required: true,
143
+ },
144
+ {
145
+ type: 'rawlist',
146
+ name: 'schedulerType',
147
+ message: 'Choose the scheduler type',
148
+ default: SCHEDULER_TYPE_NATURAL_TIME.value,
149
+ choices: [SCHEDULER_TYPE_NATURAL_TIME, SCHEDULER_TYPE_DATA_TIME, SCHEDULER_TYPE_DEPTH],
150
+ when: (answers) => answers.appType === APP_TYPES.SCHEDULER,
151
+ },
152
+ {
153
+ name: 'cronString',
154
+ message: 'Provide CRON string for the scheduler',
155
+ default: '*/5 * * * *',
156
+ when: (answers) => answers.schedulerType && answers.schedulerType !== SCHEDULER_TYPE_DEPTH.value,
157
+ },
158
+ {
159
+ name: 'depthMilestone',
160
+ message: 'Provide depth milestone for the scheduler',
161
+ default: 1,
162
+ when: (answers) => answers.schedulerType === SCHEDULER_TYPE_DEPTH.value,
163
+ filter: (value) => (isNaN(value) ? value : Number(value)),
164
+ },
165
+ {
166
+ name: 'logType',
167
+ message: 'Choose the log type',
168
+ default: LOG_TYPES.TIME,
169
+ choices: Object.values(LOG_TYPES),
170
+ when: (answers) => answers.appType === APP_TYPES.STREAM,
171
+ },
172
+ {
173
+ name: 'appKey',
174
+ message: 'Enter the App Key',
175
+ default: 'app.key-goes-here',
176
+ required: true,
177
+ },
178
+ {
179
+ name: 'appName',
180
+ message: 'Enter the App Name',
181
+ default: projectName,
182
+ required: true,
183
+ },
184
+ {
185
+ name: 'description',
186
+ message: 'Enter description',
187
+ default: 'This is the description of my app. You can do great things with it!',
188
+ },
189
+ {
190
+ name: 'summary',
191
+ message: 'Enter summary',
192
+ default: 'More information about this app goes here',
193
+ },
194
+ {
195
+ name: 'category',
196
+ message: 'Enter category',
197
+ default: '',
198
+ required: true,
199
+ },
200
+ {
201
+ name: 'website',
202
+ message: 'Enter website',
203
+ default: 'https://www.oandgexample.com/my-app/',
204
+ },
205
+ {
206
+ type: 'rawlist',
207
+ name: 'segments',
208
+ message: 'Choose segments',
209
+ choices: ['drilling', 'completion', 'intervention'],
210
+ required: true,
211
+ },
212
+ {
213
+ type: 'rawlist',
214
+ name: 'runtime',
215
+ message: 'Choose runtime',
216
+ choices: (answers) => {
217
+ if (answers && answers.appType !== APP_TYPES.UI) {
218
+ return SUPPORTED_NON_UI_APP_RUNTIMES;
219
+ }
220
+
221
+ return [APP_RUNTIMES.UI, ...SUPPORTED_NON_UI_APP_RUNTIMES];
222
+ },
223
+ when: (answers) => answers.appType !== APP_TYPES.UI,
224
+ },
225
+ {
226
+ type: 'rawlist',
227
+ name: 'packageManager',
228
+ message: 'Please select the desired package manager',
229
+ alias: 'p',
230
+ default: 'yarn',
231
+ choices: ['yarn', 'npm'],
232
+ when: (answers) => !answers.runtime || !answers.runtime.startsWith(TEMPLATE_TYPES.PYTHON),
233
+ },
234
+ {
235
+ type: 'confirm',
236
+ name: 'useTypescript',
237
+ alias: 't',
238
+ message: 'Would you like to use TypesScript?',
239
+ default: false,
240
+ when: (answers) =>
241
+ (answers.runtime && answers.runtime.startsWith(TEMPLATE_TYPES.NODE)) || answers.appType === APP_TYPES.UI,
242
+ },
243
+ {
244
+ name: 'silent',
245
+ message: 'Only log result of the operation',
246
+ default: false,
247
+ },
248
+ {
249
+ name: 'no-dependencies-install',
250
+ message: 'Skip installing dependencies',
251
+ },
252
+ {
253
+ name: 'no-git-init',
254
+ message: 'Skip initializing git repository',
255
+ },
256
+ {
257
+ name: 'extensions',
258
+ message: 'App template extensions',
259
+ default: [],
260
+ when: (answers) => answers.appType === APP_TYPES.UI,
261
+ commaSeparated: true,
262
+ },
263
+ ];
@@ -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,300 @@
1
+ import _ from 'lodash';
2
+ import { APP_EXTENSIONS } from './cli.js';
3
+
4
+ const uiDependencies = {
5
+ '@corva/ui': 'latest',
6
+ '@material-ui/core': '4.11.2',
7
+ '@material-ui/icons': '4.9.1',
8
+ '@material-ui/lab': '4.0.0-alpha.57',
9
+ '@material-ui/pickers': '3.2.10',
10
+ '@icon-park/react': '1.4.2',
11
+ 'classnames': '2.2.6',
12
+ 'corva-convert-units': '1.10.33',
13
+ 'highcharts': '10.3.3',
14
+ 'highcharts-react-official': '2.2.2',
15
+ 'lodash': '^4.18.1',
16
+ 'mapbox-gl': '3.16.0',
17
+ 'moment': '2.29.4',
18
+ 'moment-timezone': '0.5.43',
19
+ 'react': '18.3.1',
20
+ 'react-dom': '18.3.1',
21
+ };
22
+
23
+ const jsUiDevDependencies = {
24
+ '@corva/dc-platform-shared': 'latest',
25
+ '@corva/eslint-config-browser': '0.2.2',
26
+ // @testing-library/react 16 moved this from a dependency to a peer
27
+ '@testing-library/dom': '10.4.1',
28
+ '@testing-library/jest-dom': '7.0.1',
29
+ '@testing-library/react': '16.3.2',
30
+ '@testing-library/user-event': '14.6.6',
31
+ '@vitejs/plugin-react': '6.1.1',
32
+ '@vitest/coverage-v8': '4.1.11',
33
+ 'dotenv': '16.4.7',
34
+ 'dotenv-expand': '11.0.7',
35
+ 'eslint': '7.32.0',
36
+ 'jsdom': '22.1.0',
37
+ 'postcss-preset-env': '11.3.0',
38
+ 'rollup-plugin-license': '3.6.0',
39
+ 'sass-embedded': '1.100.0',
40
+ 'terser': '5.47.1',
41
+ 'vite': '8.3.0',
42
+ 'vite-plugin-static-copy': '4.1.0',
43
+ 'vitest': '4.1.11',
44
+ };
45
+
46
+ const tsUiDevDependencies = {
47
+ ...jsUiDevDependencies,
48
+ '@types/lodash': '^4.17.25',
49
+ '@types/material-ui': '0.21.9',
50
+ '@types/minimatch': '3.0.5',
51
+ '@types/mime': '3.0.1',
52
+ '@types/node': '24.12.2',
53
+ '@types/react': '18.2.42',
54
+ '@types/react-dom': '^18.2',
55
+ '@typescript-eslint/eslint-plugin': '^4.31.2',
56
+ '@typescript-eslint/parser': '^4.31.2',
57
+ 'typescript': '^5.9.3',
58
+ };
59
+
60
+ const corvaUiExtension = {
61
+ scripts: {
62
+ prepare: 'husky install',
63
+ },
64
+ dependencies: {
65
+ '@tanstack/react-query': '4.35.3',
66
+ },
67
+ devDependencies: {
68
+ '@commitlint/cli': '^17.0.0',
69
+ '@commitlint/config-conventional': '^17.0.0',
70
+ 'husky': '^8.0.0',
71
+ 'lint-staged': '^13.0.0',
72
+ '@tanstack/eslint-plugin-query': '4.34.1',
73
+ },
74
+ };
75
+
76
+ function applyUiExtension(packageJson, extensionNames) {
77
+ if (!Array.isArray(extensionNames) || extensionNames.length === 0) {
78
+ return packageJson;
79
+ }
80
+
81
+ const extensions = extensionNames
82
+ .map((extensionName) => {
83
+ if (extensionName === APP_EXTENSIONS.CORVA) {
84
+ return corvaUiExtension;
85
+ }
86
+
87
+ return null;
88
+ })
89
+ .filter(Boolean);
90
+
91
+ return _.merge({}, packageJson, ...extensions);
92
+ }
93
+
94
+ const uiScripts = {
95
+ build: 'vite build',
96
+ start: 'vite --open',
97
+ zip: 'create-corva-app zip .',
98
+ lint: 'eslint --cache --ext .js,.jsx,.ts,.tsx ./src/',
99
+ release: 'create-corva-app release .',
100
+ test: 'vitest run',
101
+ coverage: 'vitest run --coverage',
102
+ };
103
+
104
+ const uiPackage = {
105
+ 'version': '0.0.1',
106
+ 'main': 'src/index.js',
107
+ 'scripts': uiScripts,
108
+ 'dependencies': uiDependencies,
109
+ 'devDependencies': jsUiDevDependencies,
110
+ 'lint-staged': {
111
+ 'src/**/*.{js,jsx,ts,tsx}': 'eslint --fix',
112
+ },
113
+ 'resolutions': {
114
+ '@noble/hashes': '1.8.0',
115
+ 'lodash': '4.18.1',
116
+ },
117
+ };
118
+
119
+ const tsUiPackage = {
120
+ ...uiPackage,
121
+ scripts: { ...uiScripts, typecheck: 'tsc --noEmit' },
122
+ devDependencies: tsUiDevDependencies,
123
+ // todo: temporary solution, ref https://github.com/oppia/oppia/issues/22283#issuecomment-2756641371
124
+ resolutions: {
125
+ ...uiPackage.resolutions,
126
+ '@types/babel__traverse': '7.20.6',
127
+ },
128
+ };
129
+
130
+ const nodeNpmScripts = {
131
+ 'bundle': 'create-corva-app zip .',
132
+ 'test': 'npm run unit',
133
+ 'unit': 'jest',
134
+ 'lint': 'eslint --ext .js,.ts .',
135
+ 'lint:fix': 'eslint --ext .js,.ts --fix .',
136
+ };
137
+
138
+ const nodeDependencies = {
139
+ '@corva/node-sdk': '^8.5.0',
140
+ };
141
+
142
+ const nodeDevDependencies = {
143
+ '@corva/eslint-config-node': '^6.0.0',
144
+ '@typescript-eslint/eslint-plugin': '^8.58.1',
145
+ '@typescript-eslint/parser': '^8.58.1',
146
+ 'jest': '^29.7.0',
147
+ 'dotenv': '^16.0.3',
148
+ 'eslint': '^8.2.0',
149
+ 'eslint-plugin-jest': '^27.1.5',
150
+ 'prettier': '^2.0.0',
151
+ 'typescript': '^5.9.3',
152
+ };
153
+
154
+ const nodeTsDevDependencies = {
155
+ ...nodeDevDependencies,
156
+ '@types/jest': '^29.5.12',
157
+ 'ts-jest': '^29.2.4',
158
+ };
159
+
160
+ const nodeYarnScripts = {
161
+ ...nodeNpmScripts,
162
+ test: 'yarn unit',
163
+ };
164
+
165
+ const commonTsScripts = {
166
+ 'build': 'tsc -p tsconfig.build.json',
167
+ 'postbuild': 'cp manifest.json dist/manifest.json',
168
+ 'lint': 'eslint --ext .ts .',
169
+ 'lint:fix': 'eslint --ext .ts --fix .',
170
+ };
171
+
172
+ const nodeTsScripts = {
173
+ ...nodeNpmScripts,
174
+ ...commonTsScripts,
175
+ };
176
+
177
+ const nodeTsYarnScripts = {
178
+ ...nodeYarnScripts,
179
+ ...commonTsScripts,
180
+ };
181
+
182
+ const nodeNpmPackage = {
183
+ version: '0.0.1',
184
+ main: 'index.js',
185
+ private: true,
186
+ dependencies: nodeDependencies,
187
+ devDependencies: nodeDevDependencies,
188
+ scripts: nodeNpmScripts,
189
+ jest: {
190
+ setupFiles: ['dotenv/config'],
191
+ },
192
+ prettier: '@corva/eslint-config-node/prettier',
193
+ eslintConfig: {
194
+ root: true,
195
+ extends: '@corva/eslint-config-node',
196
+ overrides: [
197
+ {
198
+ files: ['**/*.ts'],
199
+ parser: '@typescript-eslint/parser',
200
+ parserOptions: {
201
+ project: 'tsconfig.json',
202
+ sourceType: 'module',
203
+ },
204
+ plugins: ['@typescript-eslint/eslint-plugin'],
205
+ rules: {
206
+ '@typescript-eslint/padding-line-between-statements': 'off',
207
+ },
208
+ },
209
+ {
210
+ files: [
211
+ '**/*.spec.js',
212
+ '**/*.spec.ts',
213
+ '**/*.spec.mjs',
214
+ '**/*.spec.cjs',
215
+ '**/__mocks__/**/*.js',
216
+ '**/__mocks__/**/*.ts',
217
+ '**/__mocks__/**/*.cjs',
218
+ '**/__mocks__/**/*.mjs',
219
+ ],
220
+ plugins: ['jest'],
221
+ env: {
222
+ jest: true,
223
+ },
224
+ },
225
+ ],
226
+ },
227
+ overrides: {
228
+ lodash: '4.18.1',
229
+ },
230
+ };
231
+
232
+ const nodeYarnPackage = {
233
+ ...nodeNpmPackage,
234
+ scripts: nodeYarnScripts,
235
+ overrides: undefined,
236
+ resolutions: nodeNpmPackage.overrides,
237
+ };
238
+
239
+ const nodeTsNpmPackage = {
240
+ ...nodeNpmPackage,
241
+ devDependencies: nodeTsDevDependencies,
242
+ scripts: nodeTsScripts,
243
+ jest: {
244
+ preset: 'ts-jest',
245
+ testEnvironment: 'node',
246
+ ...nodeNpmPackage.jest,
247
+ },
248
+ };
249
+
250
+ const nodeTsYarnPackage = {
251
+ ...nodeTsNpmPackage,
252
+ scripts: nodeTsYarnScripts,
253
+ overrides: undefined,
254
+ resolutions: nodeNpmPackage.overrides,
255
+ };
256
+
257
+ const extendWithTsConfig = (packageJson, version) => {
258
+ packageJson.devDependencies = {
259
+ // New @tsconfig/nodeX package versioning: it starts with X major version
260
+ [`@tsconfig/node${version}`]: `^${version}`,
261
+ ...packageJson.devDependencies,
262
+ };
263
+
264
+ return packageJson;
265
+ };
266
+
267
+ const defaults = {
268
+ javascript: {
269
+ yarn: {
270
+ ui: (runtime, opts) => applyUiExtension(uiPackage, opts?.extensions),
271
+ task: () => nodeYarnPackage,
272
+ scheduler: () => nodeYarnPackage,
273
+ stream: () => nodeYarnPackage,
274
+ },
275
+ npm: {
276
+ ui: (runtime, opts) => applyUiExtension(uiPackage, opts?.extensions),
277
+ task: () => nodeNpmPackage,
278
+ scheduler: () => nodeNpmPackage,
279
+ stream: () => nodeNpmPackage,
280
+ },
281
+ },
282
+ typescript: {
283
+ yarn: {
284
+ ui: (runtime, opts) => applyUiExtension(tsUiPackage, opts?.extensions),
285
+ task: ({ version }) => extendWithTsConfig(nodeTsYarnPackage, version),
286
+ scheduler: ({ version }) => extendWithTsConfig(nodeTsYarnPackage, version),
287
+ stream: ({ version }) => extendWithTsConfig(nodeTsYarnPackage, version),
288
+ },
289
+ npm: {
290
+ ui: (runtime, opts) => applyUiExtension(tsUiPackage, opts?.extensions),
291
+ task: ({ version }) => extendWithTsConfig(nodeTsNpmPackage, version),
292
+ scheduler: ({ version }) => extendWithTsConfig(nodeTsNpmPackage, version),
293
+ stream: ({ version }) => extendWithTsConfig(nodeTsNpmPackage, version),
294
+ },
295
+ },
296
+ };
297
+
298
+ export const getDefaultsForPackageJson = (manifest, runtime, opts) => {
299
+ return defaults[runtime.language][runtime.packageManager][manifest.type](runtime, opts);
300
+ };
package/lib/flow.js ADDED
@@ -0,0 +1,59 @@
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 (typeof step.skip === 'function' && step.skip(context)) {
33
+ debug('Skipping %s', step.name || step.message);
34
+
35
+ continue;
36
+ }
37
+
38
+ if (step.name) {
39
+ const result = await runFlow(step, context, indent);
40
+
41
+ Object.assign(context, result);
42
+
43
+ continue;
44
+ }
45
+
46
+ const message = indent + step.message;
47
+
48
+ logger.write(message);
49
+ debug('Context: %o', context);
50
+
51
+ const result = await step.fn(context);
52
+
53
+ Object.assign(context, result);
54
+
55
+ logger.write(SUCCESS_ICON + '\n');
56
+ }
57
+
58
+ return context;
59
+ };
@@ -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
+ };