@corva/create-app 0.0.0-2576df8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +218 -0
- package/bin/cca.js +5 -0
- package/bin/create-corva-app.cjs +25 -0
- package/common/node/.env +15 -0
- package/common/node/.env.sample +26 -0
- package/common/node/gitignore +130 -0
- package/common/package.json +3 -0
- package/common/python/.env +5 -0
- package/common/python/.env.sample +7 -0
- package/common/python/Makefile +15 -0
- package/common/python/gitignore +161 -0
- package/common/python/requirements.txt +2 -0
- package/lib/commands/attach.js +28 -0
- package/lib/commands/create.js +463 -0
- package/lib/commands/release.js +58 -0
- package/lib/commands/rerun.js +34 -0
- package/lib/commands/zip.js +39 -0
- package/lib/constants/cache.js +5 -0
- package/lib/constants/cli.js +35 -0
- package/lib/constants/manifest.js +263 -0
- package/lib/constants/messages.js +15 -0
- package/lib/constants/package.js +288 -0
- package/lib/flow.js +53 -0
- package/lib/flows/attach.js +8 -0
- package/lib/flows/lib/api.js +385 -0
- package/lib/flows/lib/create-zip-archive.js +83 -0
- package/lib/flows/lib/json.js +30 -0
- package/lib/flows/lib/manifest.js +81 -0
- package/lib/flows/lib/notification.js +142 -0
- package/lib/flows/lib/step-error.js +10 -0
- package/lib/flows/lib/waitForMs.js +3 -0
- package/lib/flows/prepare.js +6 -0
- package/lib/flows/release.js +26 -0
- package/lib/flows/rerun.js +8 -0
- package/lib/flows/steps/attach/add-app-to-stream.js +23 -0
- package/lib/flows/steps/attach/get-all-live-assets.js +135 -0
- package/lib/flows/steps/attach/index.js +5 -0
- package/lib/flows/steps/attach/prepare-data.js +19 -0
- package/lib/flows/steps/prepare-load-app-files.js +12 -0
- package/lib/flows/steps/release/add-label.js +10 -0
- package/lib/flows/steps/release/add-notes.js +10 -0
- package/lib/flows/steps/release/get-config.js +41 -0
- package/lib/flows/steps/release/prepare-data.js +12 -0
- package/lib/flows/steps/release/publish.js +11 -0
- package/lib/flows/steps/release/remove-failed-upload.js +21 -0
- package/lib/flows/steps/release/upload-zip-to-corva.js +136 -0
- package/lib/flows/steps/release/wait-for-build.js +36 -0
- package/lib/flows/steps/rerun/create-task.js +77 -0
- package/lib/flows/steps/rerun/ensure-that-app-in-stream.js +68 -0
- package/lib/flows/steps/rerun/get-app-version.js +111 -0
- package/lib/flows/steps/rerun/prepare-data.js +162 -0
- package/lib/flows/steps/rerun/prepare-well-and-stream-data.js +188 -0
- package/lib/flows/steps/rerun/rerun.js +13 -0
- package/lib/flows/steps/zip-cleanup.js +17 -0
- package/lib/flows/steps/zip-create-archive.js +15 -0
- package/lib/flows/steps/zip-file-list-resolve.js +266 -0
- package/lib/flows/steps/zip-prepare.js +20 -0
- package/lib/flows/steps/zip.js +6 -0
- package/lib/flows/zip-simple.js +6 -0
- package/lib/flows/zip.js +7 -0
- package/lib/helpers/cli-version.js +150 -0
- package/lib/helpers/commands.js +13 -0
- package/lib/helpers/logger.js +35 -0
- package/lib/helpers/manifest.js +82 -0
- package/lib/helpers/resolve-app-runtime.js +132 -0
- package/lib/helpers/utils.js +97 -0
- package/lib/helpers/versioning.js +94 -0
- package/lib/main.js +64 -0
- package/lib/options/api-key.js +6 -0
- package/lib/options/app-key.js +6 -0
- package/lib/options/app-version.js +3 -0
- package/lib/options/bump-version.js +19 -0
- package/lib/options/cache.js +11 -0
- package/lib/options/env.js +3 -0
- package/lib/options/original-cwd.js +3 -0
- package/lib/options/silent.js +3 -0
- package/package.json +1 -0
- package/template_extensions/corva/.commitlintrc.json +6 -0
- package/template_extensions/corva/.eslintrc +32 -0
- package/template_extensions/corva/.github/pull_request_template.md +14 -0
- package/template_extensions/corva/.github/workflows/code-checks.yml +15 -0
- package/template_extensions/corva/.github/workflows/develop.yml +19 -0
- package/template_extensions/corva/.github/workflows/feat-fix-delete.yml +14 -0
- package/template_extensions/corva/.github/workflows/feat-fix.yml +23 -0
- package/template_extensions/corva/.github/workflows/release-fix-X.X.X.yml +16 -0
- package/template_extensions/corva/.github/workflows/validate-pr-title.yml +19 -0
- package/template_extensions/corva/.husky/commit-msg +5 -0
- package/template_extensions/corva/.husky/pre-commit +4 -0
- package/template_extensions/corva/.release-please-manifest.json +3 -0
- package/template_extensions/corva/release-please-config.json +10 -0
- package/templates/scheduler_data-time/javascript/README.md +19 -0
- package/templates/scheduler_data-time/javascript/__tests__/processor.spec.js +15 -0
- package/templates/scheduler_data-time/javascript/index.js +15 -0
- package/templates/scheduler_data-time/python/README.md +31 -0
- package/templates/scheduler_data-time/python/lambda_function.py +7 -0
- package/templates/scheduler_data-time/python/test/__init__.py +0 -0
- package/templates/scheduler_data-time/python/test/app_test.py +10 -0
- package/templates/scheduler_data-time/typescript/README.md +25 -0
- package/templates/scheduler_data-time/typescript/__tests__/processor.spec.ts +15 -0
- package/templates/scheduler_data-time/typescript/index.ts +8 -0
- package/templates/scheduler_depth/javascript/README.md +19 -0
- package/templates/scheduler_depth/javascript/__tests__/processor.spec.js +17 -0
- package/templates/scheduler_depth/javascript/index.js +15 -0
- package/templates/scheduler_depth/python/README.md +31 -0
- package/templates/scheduler_depth/python/lambda_function.py +7 -0
- package/templates/scheduler_depth/python/test/__init__.py +0 -0
- package/templates/scheduler_depth/python/test/app_test.py +10 -0
- package/templates/scheduler_depth/typescript/README.md +25 -0
- package/templates/scheduler_depth/typescript/__tests__/processor.spec.ts +17 -0
- package/templates/scheduler_depth/typescript/index.ts +8 -0
- package/templates/scheduler_natural-time/javascript/README.md +19 -0
- package/templates/scheduler_natural-time/javascript/__tests__/processor.spec.js +15 -0
- package/templates/scheduler_natural-time/javascript/index.js +15 -0
- package/templates/scheduler_natural-time/python/README.md +31 -0
- package/templates/scheduler_natural-time/python/lambda_function.py +7 -0
- package/templates/scheduler_natural-time/python/test/__init__.py +0 -0
- package/templates/scheduler_natural-time/python/test/app_test.py +10 -0
- package/templates/scheduler_natural-time/typescript/README.md +25 -0
- package/templates/scheduler_natural-time/typescript/__tests__/processor.spec.ts +15 -0
- package/templates/scheduler_natural-time/typescript/index.ts +8 -0
- package/templates/stream_depth/javascript/README.md +19 -0
- package/templates/stream_depth/javascript/__tests__/processor.spec.js +20 -0
- package/templates/stream_depth/javascript/index.js +14 -0
- package/templates/stream_depth/python/README.md +31 -0
- package/templates/stream_depth/python/lambda_function.py +7 -0
- package/templates/stream_depth/python/test/__init__.py +0 -0
- package/templates/stream_depth/python/test/app_test.py +16 -0
- package/templates/stream_depth/typescript/README.md +25 -0
- package/templates/stream_depth/typescript/__tests__/processor.spec.ts +20 -0
- package/templates/stream_depth/typescript/index.ts +8 -0
- package/templates/stream_time/javascript/README.md +19 -0
- package/templates/stream_time/javascript/__tests__/processor.spec.js +14 -0
- package/templates/stream_time/javascript/index.js +14 -0
- package/templates/stream_time/python/README.md +31 -0
- package/templates/stream_time/python/lambda_function.py +7 -0
- package/templates/stream_time/python/test/__init__.py +0 -0
- package/templates/stream_time/python/test/app_test.py +16 -0
- package/templates/stream_time/typescript/README.md +25 -0
- package/templates/stream_time/typescript/__tests__/processor.spec.ts +14 -0
- package/templates/stream_time/typescript/index.ts +8 -0
- package/templates/task/javascript/README.md +19 -0
- package/templates/task/javascript/__tests__/processor.spec.js +16 -0
- package/templates/task/javascript/index.js +15 -0
- package/templates/task/python/README.md +31 -0
- package/templates/task/python/lambda_function.py +7 -0
- package/templates/task/python/test/__init__.py +0 -0
- package/templates/task/python/test/app_test.py +8 -0
- package/templates/task/typescript/README.md +25 -0
- package/templates/task/typescript/__tests__/processor.spec.ts +16 -0
- package/templates/task/typescript/index.ts +8 -0
- package/templates/ui/javascript/.codex/config.toml +3 -0
- package/templates/ui/javascript/.cursor/mcp.json +8 -0
- package/templates/ui/javascript/.eslintrc +11 -0
- package/templates/ui/javascript/.mcp.json +8 -0
- package/templates/ui/javascript/.prettierrc +1 -0
- package/templates/ui/javascript/AGENTS.md +304 -0
- package/templates/ui/javascript/CLAUDE.md +1 -0
- package/templates/ui/javascript/README.md +31 -0
- package/templates/ui/javascript/config/jest/babelTransform.js +16 -0
- package/templates/ui/javascript/config/jest/cssTransform.js +16 -0
- package/templates/ui/javascript/config/jest/fileTransform.js +48 -0
- package/templates/ui/javascript/config/jest/globalSetup.js +5 -0
- package/templates/ui/javascript/config/jest/setupTests.js +30 -0
- package/templates/ui/javascript/config-overrides.js +10 -0
- package/templates/ui/javascript/gitignore +27 -0
- package/templates/ui/javascript/src/App.completion.js +52 -0
- package/templates/ui/javascript/src/App.drilling.js +49 -0
- package/templates/ui/javascript/src/App.scss +17 -0
- package/templates/ui/javascript/src/AppSettings.js +28 -0
- package/templates/ui/javascript/src/__tests__/App.test.js +26 -0
- package/templates/ui/javascript/src/__tests__/AppSettings.test.js +28 -0
- package/templates/ui/javascript/src/__tests__/TestsExample.test.js +37 -0
- package/templates/ui/javascript/src/assets/logo.svg +7 -0
- package/templates/ui/javascript/src/constants.js +3 -0
- package/templates/ui/javascript/src/index.js +8 -0
- package/templates/ui/typescript/.codex/config.toml +3 -0
- package/templates/ui/typescript/.cursor/mcp.json +8 -0
- package/templates/ui/typescript/.eslintrc +28 -0
- package/templates/ui/typescript/.mcp.json +8 -0
- package/templates/ui/typescript/.prettierrc +1 -0
- package/templates/ui/typescript/AGENTS.md +344 -0
- package/templates/ui/typescript/CLAUDE.md +1 -0
- package/templates/ui/typescript/README.md +31 -0
- package/templates/ui/typescript/config/jest/babelTransform.js +16 -0
- package/templates/ui/typescript/config/jest/cssTransform.js +16 -0
- package/templates/ui/typescript/config/jest/fileTransform.js +48 -0
- package/templates/ui/typescript/config/jest/globalSetup.js +5 -0
- package/templates/ui/typescript/config/jest/setupTests.js +30 -0
- package/templates/ui/typescript/config-overrides.js +10 -0
- package/templates/ui/typescript/gitignore +27 -0
- package/templates/ui/typescript/src/App.completion.tsx +52 -0
- package/templates/ui/typescript/src/App.drilling.tsx +49 -0
- package/templates/ui/typescript/src/App.scss +17 -0
- package/templates/ui/typescript/src/AppSettings.tsx +28 -0
- package/templates/ui/typescript/src/__mocks__/mockData.ts +22 -0
- package/templates/ui/typescript/src/__tests__/App.test.tsx +27 -0
- package/templates/ui/typescript/src/__tests__/AppSettings.test.tsx +28 -0
- package/templates/ui/typescript/src/__tests__/TestsExample.test.tsx +37 -0
- package/templates/ui/typescript/src/assets/logo.svg +7 -0
- package/templates/ui/typescript/src/constants.ts +3 -0
- package/templates/ui/typescript/src/custom.d.ts +19 -0
- package/templates/ui/typescript/src/index.js +8 -0
- package/templates/ui/typescript/src/types.ts +3 -0
- package/templates/ui/typescript/tsconfig.json +7 -0
|
@@ -0,0 +1,263 @@
|
|
|
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', '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 Object.values(APP_RUNTIMES).filter((value) => value !== APP_RUNTIMES.UI);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return Object.values(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,288 @@
|
|
|
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.17.21',
|
|
16
|
+
'mapbox.js': '3.2.1',
|
|
17
|
+
'moment': '2.29.4',
|
|
18
|
+
'moment-timezone': '0.5.43',
|
|
19
|
+
'react': '17.0.1',
|
|
20
|
+
'react-dom': '17.0.1',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const jsUiDevDependencies = {
|
|
24
|
+
'@corva/dc-platform-shared': 'latest',
|
|
25
|
+
'@corva/eslint-config-browser': '0.2.2',
|
|
26
|
+
'@testing-library/jest-dom': '^5.14.1',
|
|
27
|
+
'@testing-library/react': '^12.1.5',
|
|
28
|
+
'@testing-library/react-hooks': '^8.0.1',
|
|
29
|
+
'@testing-library/user-event': '^13.2.1',
|
|
30
|
+
'babel-jest': '^27.4.2',
|
|
31
|
+
'babel-preset-react-app': '^10.0.1',
|
|
32
|
+
'eslint': '7.32.0',
|
|
33
|
+
'identity-obj-proxy': '^3.0.0',
|
|
34
|
+
'jest': '^27.4.3',
|
|
35
|
+
'jest-watch-typeahead': '^1.0.0',
|
|
36
|
+
'postcss-loader': '4.1.0',
|
|
37
|
+
'sass': '^1.89.2',
|
|
38
|
+
'sass-loader': '^16.0.5',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const tsUiDevDependencies = {
|
|
42
|
+
...jsUiDevDependencies,
|
|
43
|
+
'@tsconfig/create-react-app': '1.0.2',
|
|
44
|
+
'@types/lodash': '4.17.5',
|
|
45
|
+
'@types/material-ui': '0.21.9',
|
|
46
|
+
'@types/minimatch': '3.0.5',
|
|
47
|
+
'@types/mime': '3.0.1',
|
|
48
|
+
'@types/node': '18.19.47',
|
|
49
|
+
'@types/react': '^17.0.22',
|
|
50
|
+
'@types/react-dom': '^17.0.9',
|
|
51
|
+
'@types/jest': '^27.0.1',
|
|
52
|
+
'@typescript-eslint/eslint-plugin': '^4.31.2',
|
|
53
|
+
'@typescript-eslint/parser': '^4.31.2',
|
|
54
|
+
'ts-loader': '8.2.0',
|
|
55
|
+
'typescript': '4.6.3',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const corvaUiExtension = {
|
|
59
|
+
scripts: {
|
|
60
|
+
prepare: 'husky install',
|
|
61
|
+
},
|
|
62
|
+
dependencies: {
|
|
63
|
+
'@tanstack/react-query': '4.35.3',
|
|
64
|
+
},
|
|
65
|
+
devDependencies: {
|
|
66
|
+
'@commitlint/cli': '^17.0.0',
|
|
67
|
+
'@commitlint/config-conventional': '^17.0.0',
|
|
68
|
+
'husky': '^8.0.0',
|
|
69
|
+
'lint-staged': '^13.0.0',
|
|
70
|
+
'@tanstack/eslint-plugin-query': '4.34.1',
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
function applyUiExtension(packageJson, extensionNames) {
|
|
75
|
+
if (!Array.isArray(extensionNames) || extensionNames.length === 0) {
|
|
76
|
+
return packageJson;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const extensions = extensionNames
|
|
80
|
+
.map((extensionName) => {
|
|
81
|
+
if (extensionName === APP_EXTENSIONS.CORVA) {
|
|
82
|
+
return corvaUiExtension;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return null;
|
|
86
|
+
})
|
|
87
|
+
.filter(Boolean);
|
|
88
|
+
|
|
89
|
+
return _.merge({}, packageJson, ...extensions);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const uiScripts = {
|
|
93
|
+
build: 'webpack --config=./config-overrides.js --mode production',
|
|
94
|
+
start: 'webpack-dev-server --config=./config-overrides.js --open --mode development',
|
|
95
|
+
zip: 'create-corva-app zip .',
|
|
96
|
+
lint: 'eslint --cache ./src/',
|
|
97
|
+
release: 'create-corva-app release .',
|
|
98
|
+
test: 'jest',
|
|
99
|
+
coverage: 'jest --coverage',
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const uiPackage = {
|
|
103
|
+
'version': '0.0.1',
|
|
104
|
+
'main': 'src/index.js',
|
|
105
|
+
'scripts': uiScripts,
|
|
106
|
+
'dependencies': uiDependencies,
|
|
107
|
+
'devDependencies': jsUiDevDependencies,
|
|
108
|
+
'jest': {
|
|
109
|
+
roots: ['<rootDir>/src'],
|
|
110
|
+
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/**/*.d.ts'],
|
|
111
|
+
coverageThreshold: {
|
|
112
|
+
global: {
|
|
113
|
+
branches: 60,
|
|
114
|
+
functions: 60,
|
|
115
|
+
lines: 60,
|
|
116
|
+
statements: 60,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
setupFilesAfterEnv: ['<rootDir>/config/jest/setupTests.js'],
|
|
120
|
+
globalSetup: '<rootDir>/config/jest/globalSetup.js',
|
|
121
|
+
testMatch: ['<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}', '<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}'],
|
|
122
|
+
testEnvironment: 'jsdom',
|
|
123
|
+
transform: {
|
|
124
|
+
'^.+\\.(js|jsx|mjs|cjs|ts|tsx)$': '<rootDir>/config/jest/babelTransform.js',
|
|
125
|
+
'^.+\\.css$': '<rootDir>/config/jest/cssTransform.js',
|
|
126
|
+
'^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)': '<rootDir>/config/jest/fileTransform.js',
|
|
127
|
+
},
|
|
128
|
+
transformIgnorePatterns: [
|
|
129
|
+
'/node_modules/(?!.*@babel/runtime|@icon-park/react/es).+\\.(js|jsx|mjs|cjs|ts|tsx)$',
|
|
130
|
+
'^.+\\.(css|sass|scss)$',
|
|
131
|
+
],
|
|
132
|
+
modulePaths: [],
|
|
133
|
+
moduleNameMapper: {
|
|
134
|
+
'~(.*)': '<rootDir>/src/$1',
|
|
135
|
+
'^.+\\.(css|sass|scss)$': 'identity-obj-proxy',
|
|
136
|
+
'@corva/ui(.*)': '@corva/ui/cjs-bundle/$1',
|
|
137
|
+
},
|
|
138
|
+
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
|
|
139
|
+
resetMocks: true,
|
|
140
|
+
},
|
|
141
|
+
'lint-staged': {
|
|
142
|
+
'src/**/*.{js,jsx,ts,tsx}': 'eslint --fix',
|
|
143
|
+
},
|
|
144
|
+
'resolutions': {
|
|
145
|
+
'@noble/hashes': '1.8.0',
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const tsUiPackage = {
|
|
150
|
+
...uiPackage,
|
|
151
|
+
devDependencies: tsUiDevDependencies,
|
|
152
|
+
// todo: temporary solution, ref https://github.com/oppia/oppia/issues/22283#issuecomment-2756641371
|
|
153
|
+
resolutions: {
|
|
154
|
+
...uiPackage.resolutions,
|
|
155
|
+
'@types/babel__traverse': '7.20.6',
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const nodeNpmScripts = {
|
|
160
|
+
'bundle': 'create-corva-app zip .',
|
|
161
|
+
'test': 'npm run unit',
|
|
162
|
+
'unit': 'jest',
|
|
163
|
+
'lint': 'eslint --ext .js,.ts .',
|
|
164
|
+
'lint:fix': 'eslint --ext .js,.ts --fix .',
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const nodeDependencies = {
|
|
168
|
+
'@corva/node-sdk': '^8.3.0',
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const nodeDevDependencies = {
|
|
172
|
+
'@corva/eslint-config-node': '^5.1.1',
|
|
173
|
+
'jest': '^29.7.0',
|
|
174
|
+
'dotenv': '^16.0.3',
|
|
175
|
+
'eslint': '^8.2.0',
|
|
176
|
+
'prettier': '^2.0.0',
|
|
177
|
+
'typescript': '^5.5.4',
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const nodeTsDevDependencies = {
|
|
181
|
+
...nodeDevDependencies,
|
|
182
|
+
'@types/jest': '^29.5.12',
|
|
183
|
+
'ts-jest': '^29.2.4',
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const nodeYarnScripts = {
|
|
187
|
+
...nodeNpmScripts,
|
|
188
|
+
test: 'yarn unit',
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const commonTsScripts = {
|
|
192
|
+
'build': 'tsc -p tsconfig.build.json',
|
|
193
|
+
'postbuild': 'cp manifest.json dist/manifest.json',
|
|
194
|
+
'lint': 'eslint --ext .ts .',
|
|
195
|
+
'lint:fix': 'eslint --ext .ts --fix .',
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const nodeTsScripts = {
|
|
199
|
+
...nodeNpmScripts,
|
|
200
|
+
...commonTsScripts,
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const nodeTsYarnScripts = {
|
|
204
|
+
...nodeYarnScripts,
|
|
205
|
+
...commonTsScripts,
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const nodeNpmPackage = {
|
|
209
|
+
version: '0.0.1',
|
|
210
|
+
main: 'index.js',
|
|
211
|
+
private: true,
|
|
212
|
+
dependencies: nodeDependencies,
|
|
213
|
+
devDependencies: nodeDevDependencies,
|
|
214
|
+
scripts: nodeNpmScripts,
|
|
215
|
+
jest: {
|
|
216
|
+
setupFiles: ['dotenv/config'],
|
|
217
|
+
},
|
|
218
|
+
prettier: '@corva/eslint-config-node/prettier',
|
|
219
|
+
eslintConfig: {
|
|
220
|
+
root: true,
|
|
221
|
+
extends: '@corva/eslint-config-node',
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const nodeYarnPackage = {
|
|
226
|
+
...nodeNpmPackage,
|
|
227
|
+
scripts: nodeYarnScripts,
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const nodeTsNpmPackage = {
|
|
231
|
+
...nodeNpmPackage,
|
|
232
|
+
devDependencies: nodeTsDevDependencies,
|
|
233
|
+
scripts: nodeTsScripts,
|
|
234
|
+
jest: {
|
|
235
|
+
preset: 'ts-jest',
|
|
236
|
+
testEnvironment: 'node',
|
|
237
|
+
...nodeNpmPackage.jest,
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const nodeTsYarnPackage = {
|
|
242
|
+
...nodeTsNpmPackage,
|
|
243
|
+
scripts: nodeTsYarnScripts,
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const extendWithTsConfig = (packageJson, version) => {
|
|
247
|
+
packageJson.devDependencies = {
|
|
248
|
+
[`@tsconfig/node${version}`]: `^${version === '12' ? '1.0.9' : '1.0.1'}`,
|
|
249
|
+
...packageJson.devDependencies,
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
return packageJson;
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const defaults = {
|
|
256
|
+
javascript: {
|
|
257
|
+
yarn: {
|
|
258
|
+
ui: (runtime, opts) => applyUiExtension(uiPackage, opts?.extensions),
|
|
259
|
+
task: () => nodeYarnPackage,
|
|
260
|
+
scheduler: () => nodeYarnPackage,
|
|
261
|
+
stream: () => nodeYarnPackage,
|
|
262
|
+
},
|
|
263
|
+
npm: {
|
|
264
|
+
ui: (runtime, opts) => applyUiExtension(uiPackage, opts?.extensions),
|
|
265
|
+
task: () => nodeNpmPackage,
|
|
266
|
+
scheduler: () => nodeNpmPackage,
|
|
267
|
+
stream: () => nodeNpmPackage,
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
typescript: {
|
|
271
|
+
yarn: {
|
|
272
|
+
ui: (runtime, opts) => applyUiExtension(tsUiPackage, opts?.extensions),
|
|
273
|
+
task: ({ version }) => extendWithTsConfig(nodeTsYarnPackage, version),
|
|
274
|
+
scheduler: ({ version }) => extendWithTsConfig(nodeTsYarnPackage, version),
|
|
275
|
+
stream: ({ version }) => extendWithTsConfig(nodeTsYarnPackage, version),
|
|
276
|
+
},
|
|
277
|
+
npm: {
|
|
278
|
+
ui: (runtime, opts) => applyUiExtension(tsUiPackage, opts?.extensions),
|
|
279
|
+
task: ({ version }) => extendWithTsConfig(nodeTsNpmPackage, version),
|
|
280
|
+
scheduler: ({ version }) => extendWithTsConfig(nodeTsNpmPackage, version),
|
|
281
|
+
stream: ({ version }) => extendWithTsConfig(nodeTsNpmPackage, version),
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
export const getDefaultsForPackageJson = (manifest, runtime, opts) => {
|
|
287
|
+
return defaults[runtime.language][runtime.packageManager][manifest.type](runtime, opts);
|
|
288
|
+
};
|
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
|
+
};
|