@corva/create-app 0.28.0-0 → 0.28.0-3
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 +160 -17
- package/bin/create-corva-app.js +5 -0
- package/lib/app.js +9 -0
- package/lib/bump-version.option.js +29 -0
- package/{constants → lib/constants}/cli.js +1 -0
- package/{constants → lib/constants}/manifest.js +5 -13
- package/lib/constants/messages.js +21 -0
- package/lib/constants/package.js +161 -0
- package/lib/flow.js +46 -0
- package/lib/flows/lib/create-zip-archive.js +77 -0
- package/lib/flows/lib/json.js +28 -0
- package/lib/flows/lib/manifest.js +47 -0
- package/lib/flows/lib/step-error.js +12 -0
- package/lib/flows/prepare.js +8 -0
- package/lib/flows/release.js +18 -0
- package/lib/flows/steps/prepare-load-app-files.js +18 -0
- package/lib/flows/steps/release-get-app-key.js +16 -0
- package/lib/flows/steps/release-get-config.js +30 -0
- package/lib/flows/steps/release-upload-zip-to-corva.js +34 -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 +185 -0
- package/lib/flows/steps/zip-prepare.js +21 -0
- package/lib/flows/steps/zip.js +15 -0
- package/lib/flows/zip-simple.js +8 -0
- package/lib/flows/zip.js +9 -0
- package/{helpers → lib/helpers}/manifest.js +11 -13
- package/lib/helpers/resolve-app-runtime.js +29 -0
- package/{helpers → lib/helpers}/utils.js +17 -17
- package/{helpers → lib/helpers}/versioning.js +0 -0
- package/lib/index.js +502 -0
- package/{scripts → lib/scripts}/utils/version.js +49 -26
- package/package.json +13 -8
- package/{template/scheduler/node → templates/javascript/scheduler}/README.md +0 -0
- package/{template/scheduler/node → templates/javascript/scheduler}/__test__/processor.test.js +0 -0
- package/{template/scheduler/node → templates/javascript/scheduler}/index.js +0 -0
- package/{template/scheduler/node → templates/javascript/scheduler}/src/processor.js +0 -0
- package/{template/stream/node → templates/javascript/stream}/README.md +0 -0
- package/{template/stream/node → templates/javascript/stream}/__test__/processor.test.js +0 -0
- package/{template/stream/node → templates/javascript/stream}/index.js +0 -0
- package/{template/stream/node → templates/javascript/stream}/src/processor.js +0 -0
- package/{template/task/node → templates/javascript/task}/README.md +0 -0
- package/{template/task/node → templates/javascript/task}/__test__/processor.test.js +0 -0
- package/{template/task/node → templates/javascript/task}/index.js +0 -0
- package/{template/task/node → templates/javascript/task}/src/processor.js +0 -0
- package/{template/ui/js → templates/javascript/ui}/.env +0 -0
- package/{template/ui/js → templates/javascript/ui}/.env.sample +0 -0
- package/{template/ui/js → templates/javascript/ui}/.eslintrc +0 -0
- package/{template/ui/js → templates/javascript/ui}/.prettierrc +0 -0
- package/{template/ui/js → templates/javascript/ui}/README.md +0 -0
- package/{template/ui/js → templates/javascript/ui}/config-overrides.js +0 -0
- package/{template/ui/js → templates/javascript/ui}/gitignore +0 -0
- package/{template/ui/js → templates/javascript/ui}/src/App.css +0 -0
- package/{template/ui/js → templates/javascript/ui}/src/App.js +0 -0
- package/{template/ui/js → templates/javascript/ui}/src/AppSettings.js +0 -0
- package/{template/ui/js → templates/javascript/ui}/src/assets/logo.svg +0 -0
- package/{template/ui/js → templates/javascript/ui}/src/constants.js +0 -0
- package/{template/ui/js → templates/javascript/ui}/src/index.js +0 -0
- package/templates/python/scheduler/README.md +31 -0
- package/{template/scheduler/python → templates/python/scheduler}/lambda_function.py +0 -0
- package/{template/scheduler/python → templates/python/scheduler}/test/__init__.py +0 -0
- package/{template/scheduler/python → templates/python/scheduler}/test/app_test.py +0 -0
- package/templates/python/stream/README.md +31 -0
- package/{template/stream/python → templates/python/stream}/lambda_function.py +0 -0
- package/{template/stream/python → templates/python/stream}/test/__init__.py +0 -0
- package/{template/stream/python → templates/python/stream}/test/app_test.py +0 -0
- package/templates/python/task/README.md +31 -0
- package/{template/task/python → templates/python/task}/lambda_function.py +0 -0
- package/{template/task/python → templates/python/task}/test/__init__.py +0 -0
- package/{template/task/python → templates/python/task}/test/app_test.py +0 -0
- package/{template/scheduler/node-ts → templates/typescript/scheduler}/README.md +0 -0
- package/{template/scheduler/node-ts → templates/typescript/scheduler}/__test__/processor.spec.ts +0 -0
- package/{template/scheduler/node-ts → templates/typescript/scheduler}/index.ts +0 -0
- package/{template/scheduler/node-ts → templates/typescript/scheduler}/lib/processor.ts +0 -0
- package/{template/stream/node-ts → templates/typescript/stream}/README.md +0 -0
- package/{template/stream/node-ts → templates/typescript/stream}/__test__/processor.spec.ts +0 -0
- package/{template/stream/node-ts → templates/typescript/stream}/index.ts +0 -0
- package/{template/stream/node-ts → templates/typescript/stream}/lib/processor.ts +0 -0
- package/{template/task/node-ts → templates/typescript/task}/README.md +0 -0
- package/{template/task/node-ts → templates/typescript/task}/__test__/processor.spec.ts +0 -0
- package/{template/task/node-ts → templates/typescript/task}/index.ts +0 -0
- package/{template/task/node-ts → templates/typescript/task}/src/processor.ts +0 -0
- package/{template/ui/ts → templates/typescript/ui}/.env +0 -0
- package/{template/ui/ts → templates/typescript/ui}/.env.sample +0 -0
- package/{template/ui/ts → templates/typescript/ui}/.eslintrc +0 -0
- package/{template/ui/ts → templates/typescript/ui}/.prettierrc +0 -0
- package/{template/ui/ts → templates/typescript/ui}/README.md +0 -0
- package/{template/ui/ts → templates/typescript/ui}/config-overrides.js +0 -0
- package/{template/ui/ts → templates/typescript/ui}/gitignore +0 -0
- package/{template/ui/ts → templates/typescript/ui}/src/App.css +0 -0
- package/{template/ui/ts → templates/typescript/ui}/src/App.tsx +0 -0
- package/{template/ui/ts → templates/typescript/ui}/src/AppSettings.tsx +0 -0
- package/{template/ui/ts → templates/typescript/ui}/src/assets/logo.svg +0 -0
- package/{template/ui/ts → templates/typescript/ui}/src/constants.ts +0 -0
- package/{template/ui/ts → templates/typescript/ui}/src/custom.d.ts +0 -0
- package/{template/ui/ts → templates/typescript/ui}/src/index.js +0 -0
- package/{template/ui/ts → templates/typescript/ui}/tsconfig.json +0 -0
- package/constants/package.js +0 -50
- package/index.js +0 -386
- package/scripts/ui/index.js +0 -7
- package/scripts/ui/releaseAppZip.js +0 -91
- package/scripts/ui/zipAppSource.js +0 -103
- package/template/scheduler/node/gitignore +0 -21
- package/template/scheduler/node/package.json +0 -17
- package/template/scheduler/node-ts/gitignore +0 -25
- package/template/scheduler/node-ts/package.json +0 -37
- package/template/scheduler/node-ts/tsconfig.build.json +0 -11
- package/template/scheduler/node-ts/tsconfig.json +0 -34
- package/template/scheduler/python/README.md +0 -19
- package/template/scheduler/python/requirements.txt +0 -2
- package/template/stream/node/gitignore +0 -21
- package/template/stream/node/package.json +0 -17
- package/template/stream/node-ts/gitignore +0 -25
- package/template/stream/node-ts/package.json +0 -37
- package/template/stream/node-ts/tsconfig.build.json +0 -11
- package/template/stream/node-ts/tsconfig.json +0 -34
- package/template/stream/python/README.md +0 -19
- package/template/stream/python/requirements.txt +0 -2
- package/template/task/node/gitignore +0 -21
- package/template/task/node/package.json +0 -17
- package/template/task/node-ts/gitignore +0 -25
- package/template/task/node-ts/package.json +0 -37
- package/template/task/node-ts/tsconfig.build.json +0 -11
- package/template/task/node-ts/tsconfig.json +0 -34
- package/template/task/python/README.md +0 -19
- package/template/task/python/requirements.txt +0 -2
package/README.md
CHANGED
|
@@ -17,41 +17,184 @@ npm i -g @corva/create-app
|
|
|
17
17
|
`corva-create-app` provides a user-friendly CLI wizard to create an app.
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
|
-
Usage: corva-
|
|
20
|
+
Usage: create-corva-app [options] [command]
|
|
21
|
+
|
|
22
|
+
Options:
|
|
23
|
+
-h, --help display help for command
|
|
24
|
+
|
|
25
|
+
Commands:
|
|
26
|
+
create [options] [project-directory] Create a new app
|
|
27
|
+
zip [options] <project-directory> [patterns...] Bundle app
|
|
28
|
+
release [options] <project-directory> [patterns...] Release app
|
|
29
|
+
help [command] display help for command
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Create an app
|
|
33
|
+
|
|
34
|
+
To create a new app use `create` command.
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
Usage: create-corva-app create <project-directory> [options]
|
|
38
|
+
|
|
39
|
+
Create a new app
|
|
21
40
|
|
|
22
41
|
Arguments:
|
|
23
|
-
project-directory
|
|
42
|
+
project-directory project directory to work with (default: "Current working dir")
|
|
24
43
|
|
|
25
44
|
Options:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
--
|
|
31
|
-
--
|
|
32
|
-
--
|
|
33
|
-
--
|
|
34
|
-
--
|
|
35
|
-
--
|
|
36
|
-
|
|
45
|
+
--developerName [string] Enter the Developer Name (default: "O&G Company")
|
|
46
|
+
--developerIdentifier [string] Enter the Developer Identifier (default: "oandgc")
|
|
47
|
+
--appType [string] Choose the App Type (choices: "ui", "scheduler", "stream", "task", default: "ui")
|
|
48
|
+
--schedulerType [number] Choose the scheduler type (choices: "1", "2", "4", default: 1)
|
|
49
|
+
--cronString [string] Provide CRON string for the scheduler (default: "*/5 * * * *")
|
|
50
|
+
--depthMilestone [number] Provide depth milestone for the scheduler (default: 1)
|
|
51
|
+
--appKey [string] Enter the App Key (default: "app.key-goes-here")
|
|
52
|
+
--appName [string] Enter the App Name
|
|
53
|
+
--description [string] Enter description (default: "This is the description of my app. You can do great things with it!")
|
|
54
|
+
--summary [string] Enter summary (default: "More information about this app goes here")
|
|
55
|
+
--category [string] Enter category (default: "")
|
|
56
|
+
--website [string] Enter website (default: "https://www.oandgexample.com/my-app/")
|
|
57
|
+
--segments [string] Choose segments (choices: "drilling", "completion")
|
|
58
|
+
--runtime [string] Choose runtime (choices: "ui", "nodejs12.x", "nodejs14.x", "python3.8")
|
|
59
|
+
-p, --packageManager [string] Please select the desired package manager (choices: "yarn", "npm", default: "yarn")
|
|
60
|
+
-t, --useTypescript [boolean] Would you like to use TypesScript? (default: false)
|
|
61
|
+
-V, --version output the version number
|
|
62
|
+
-z, --zip [string] DEPRECATED Use zip command instead
|
|
63
|
+
--release DEPRECATED Use release command instead
|
|
64
|
+
--bump-version <string> DEPRECATED Use with zip or release command instead (choices: "major", "minor", "patch", "skip")
|
|
65
|
+
-h, --help display help for command
|
|
37
66
|
```
|
|
38
67
|
|
|
39
|
-
|
|
68
|
+
### Examples
|
|
40
69
|
|
|
41
|
-
|
|
70
|
+
#### Create a UI application
|
|
42
71
|
|
|
43
72
|
```sh
|
|
44
73
|
create-corva-app test --appName "Test" --segments "drilling" --category "wellDesign" --appKey "some-company.test.ui" --appType "ui" --runtime "ui"
|
|
45
74
|
```
|
|
46
75
|
|
|
47
|
-
|
|
76
|
+
#### Create a NodeJs TypeScript application
|
|
48
77
|
|
|
49
78
|
```sh
|
|
50
79
|
create-corva-app test --appName "Test" --segments "drilling" --category "wellDesign" --appKey "some-company.test.scheduler" --appType "scheduler" --runtime "nodejs12.x" -t
|
|
51
80
|
```
|
|
52
81
|
|
|
53
|
-
|
|
82
|
+
#### Create a Python application
|
|
54
83
|
|
|
55
84
|
```sh
|
|
56
85
|
create-corva-app test --appName "Test" --segments "drilling" --category "analytics" --appKey "some-company.test.stream" --appType "stream" --runtime "python3.8"
|
|
57
86
|
```
|
|
87
|
+
|
|
88
|
+
## Zip
|
|
89
|
+
|
|
90
|
+
To create a zip that contains app ready to be deployed to Corva use `zip` command.
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
Usage: create-corva-app zip [options] <project-directory> [patterns...]
|
|
94
|
+
|
|
95
|
+
Bundle app
|
|
96
|
+
|
|
97
|
+
Arguments:
|
|
98
|
+
project-directory Project directory to work with
|
|
99
|
+
patterns Additional patterns to zip (default: [])
|
|
100
|
+
|
|
101
|
+
Options:
|
|
102
|
+
--bump-version <string> bump version (choices: "major", "minor", "patch", "skip")
|
|
103
|
+
-h, --help display help for command
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### What is getting zipped?
|
|
107
|
+
|
|
108
|
+
By default next files will be included.
|
|
109
|
+
|
|
110
|
+
For `frontend` apps:
|
|
111
|
+
|
|
112
|
+
- `manifest.json`
|
|
113
|
+
- `package.json`
|
|
114
|
+
- `yarn.lock`
|
|
115
|
+
- `.npmrc`
|
|
116
|
+
- `config-overrides.js`
|
|
117
|
+
- all files under `src`
|
|
118
|
+
- `tsconfig.json`
|
|
119
|
+
|
|
120
|
+
For apps that written in `node`:
|
|
121
|
+
|
|
122
|
+
- `manifest.json`
|
|
123
|
+
- `package.json`
|
|
124
|
+
- either `package-lock.json` or `yarn.lock`
|
|
125
|
+
- all files under `config` folder
|
|
126
|
+
- all `*.js` files under `src` and `lib` folders (if `typescript` is not used)
|
|
127
|
+
- `tsconfig.json`, `tsconfig.build.json` (if `typescript` is used)
|
|
128
|
+
- all `*.ts` files under `src` and `lib` folders (if `typescript` is used)
|
|
129
|
+
|
|
130
|
+
For apps that written in `python`:
|
|
131
|
+
|
|
132
|
+
- `manifest.json`
|
|
133
|
+
- `requirements.txt`
|
|
134
|
+
- all `*.py` files
|
|
135
|
+
|
|
136
|
+
If you want to zip some files that are not included pass that as `patterns` arguments.
|
|
137
|
+
|
|
138
|
+
### Examples
|
|
139
|
+
|
|
140
|
+
#### Create a zip file from the content of `test-app` folder & put zip file in it.
|
|
141
|
+
|
|
142
|
+
```sh
|
|
143
|
+
create-corva-app zip test-app
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Create a zip file & automatically bump version
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
create-corva-app zip test-app --bump-version=patch
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### Create a zip file from the content of `test-app` folder with custom content ([globs](<https://en.wikipedia.org/wiki/Glob_(programming)>) are supported)
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
create-corva-app zip test-app some/missing/file1 some/other/missing/file2 all/files/*.glob
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Release
|
|
159
|
+
|
|
160
|
+
To push app to Corva use `release` command.
|
|
161
|
+
|
|
162
|
+
```sh
|
|
163
|
+
Usage: create-corva-app release [options] <project-directory> [patterns...]
|
|
164
|
+
|
|
165
|
+
Release app
|
|
166
|
+
|
|
167
|
+
Arguments:
|
|
168
|
+
project-directory Project directory to work with
|
|
169
|
+
patterns Additional patterns to zip (default: [])
|
|
170
|
+
|
|
171
|
+
Options:
|
|
172
|
+
--bump-version <string> bump version (choices: "major", "minor", "patch", "skip")
|
|
173
|
+
-h, --help display help for command
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Examples
|
|
177
|
+
|
|
178
|
+
#### Make a release with ask for version
|
|
179
|
+
|
|
180
|
+
```sh
|
|
181
|
+
create-corva-app release test-app
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Make a release without version increase
|
|
185
|
+
|
|
186
|
+
```sh
|
|
187
|
+
create-corva-app release test-app --bump-version=skip
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
#### Make a release with increased version
|
|
191
|
+
|
|
192
|
+
```sh
|
|
193
|
+
create-corva-app release test-app --bump-version=patch
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### Make a release with custom version
|
|
197
|
+
|
|
198
|
+
```sh
|
|
199
|
+
create-corva-app release test-app --bump-version=4.2.0
|
|
200
|
+
```
|
package/lib/app.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { Option, InvalidArgumentError } = require('commander');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
|
|
4
|
+
const flags = '--bump-version <string>';
|
|
5
|
+
const description = 'Bump version';
|
|
6
|
+
const choices = ['major', 'minor', 'patch', 'skip'];
|
|
7
|
+
|
|
8
|
+
function argParser(value, previous) {
|
|
9
|
+
if (this.argChoices.includes(value) || semver.valid(value)) {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
throw new InvalidArgumentError(
|
|
14
|
+
`Allowed choices are ${this.argChoices
|
|
15
|
+
.map((choice) => `"${choice}"`)
|
|
16
|
+
.join(', ')} or a valid semver version.`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
const bumpVersionOption = new Option(flags, description).choices(choices).argParser(argParser);
|
|
20
|
+
|
|
21
|
+
const bumpVersionOptionDeprecated = new Option(
|
|
22
|
+
flags,
|
|
23
|
+
chalk.bgYellow`DEPRECATED` +
|
|
24
|
+
` Use with ${chalk.cyan`zip`} or ${chalk.cyan`release`} command instead`
|
|
25
|
+
)
|
|
26
|
+
.choices(choices)
|
|
27
|
+
.argParser(argParser);
|
|
28
|
+
|
|
29
|
+
module.exports = { bumpVersionOption, bumpVersionOptionDeprecated };
|
|
@@ -69,14 +69,6 @@ const defaultDataAppPythonManifest = {
|
|
|
69
69
|
},
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
const defaultTimeSchedulerSettings = {
|
|
73
|
-
cron_string: '*/5 * * * *',
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const defaultDepthSchedulerSettings = {
|
|
77
|
-
depth_milestone: 1,
|
|
78
|
-
};
|
|
79
|
-
|
|
80
72
|
const getManifestMandatoryKeys = (opts) => {
|
|
81
73
|
const keys = manifestOptions(opts.projectName).reduce((acc, option) => {
|
|
82
74
|
if (option.required) {
|
|
@@ -111,7 +103,7 @@ const SCHEDULER_TYPE_NATURAL_TIME = { name: 'Natural Time', value: 1 };
|
|
|
111
103
|
const SCHEDULER_TYPE_DATA_TIME = { name: 'Data Time', value: 2 };
|
|
112
104
|
const SCHEDULER_TYPE_DEPTH = { name: 'Date Depth', value: 4 };
|
|
113
105
|
|
|
114
|
-
const manifestOptions = (projectName) => [
|
|
106
|
+
const manifestOptions = (projectName = 'Corva Dev Center App') => [
|
|
115
107
|
{ name: 'developerName', message: 'Enter the Developer Name', default: 'O&G Company' },
|
|
116
108
|
{ name: 'developerIdentifier', message: 'Enter the Developer Identifier', default: 'oandgc' },
|
|
117
109
|
{
|
|
@@ -134,14 +126,15 @@ const manifestOptions = (projectName) => [
|
|
|
134
126
|
name: 'cronString',
|
|
135
127
|
message: 'Provide CRON string for the scheduler',
|
|
136
128
|
default: '*/5 * * * *',
|
|
137
|
-
when: (answers) =>
|
|
129
|
+
when: (answers) =>
|
|
130
|
+
answers.schedulerType && answers.schedulerType !== SCHEDULER_TYPE_DEPTH.value,
|
|
138
131
|
},
|
|
139
132
|
{
|
|
140
133
|
name: 'depthMilestone',
|
|
141
134
|
message: 'Provide depth milestone for the scheduler',
|
|
142
135
|
default: 1,
|
|
143
136
|
when: (answers) => answers.schedulerType === SCHEDULER_TYPE_DEPTH.value,
|
|
144
|
-
filter: (value) => (isNaN(value) ? value : Number(value))
|
|
137
|
+
filter: (value) => (isNaN(value) ? value : Number(value)),
|
|
145
138
|
},
|
|
146
139
|
{
|
|
147
140
|
name: 'appKey',
|
|
@@ -196,6 +189,7 @@ const manifestOptions = (projectName) => [
|
|
|
196
189
|
type: 'rawlist',
|
|
197
190
|
name: 'packageManager',
|
|
198
191
|
message: 'Please select the desired package manager',
|
|
192
|
+
alias: 'p',
|
|
199
193
|
default: 'yarn',
|
|
200
194
|
choices: ['yarn', 'npm'],
|
|
201
195
|
when: (answers) => !answers.runtime || !answers.runtime.startsWith(TEMPLATE_TYPES.PYTHON),
|
|
@@ -217,8 +211,6 @@ module.exports = {
|
|
|
217
211
|
defaultUIAppManifest,
|
|
218
212
|
defaultDataAppNodeManifest,
|
|
219
213
|
defaultDataAppPythonManifest,
|
|
220
|
-
defaultTimeSchedulerSettings,
|
|
221
|
-
defaultDepthSchedulerSettings,
|
|
222
214
|
manifestOptions,
|
|
223
215
|
getManifestMandatoryKeys,
|
|
224
216
|
SCHEDULER_TYPE_NATURAL_TIME,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
|
|
3
|
+
const SUCCESS_ICON = ' ✅ \n';
|
|
4
|
+
const ERROR_ICON = ' ❌ \n';
|
|
5
|
+
|
|
6
|
+
const RELEASE = {
|
|
7
|
+
createZip: 'Creating zip archive...\n',
|
|
8
|
+
createZipError: 'Could not create zip archive.',
|
|
9
|
+
createZipSuccess: `Zip archive has been created ${SUCCESS_ICON}`,
|
|
10
|
+
getAuthToken: 'Reading auth token...',
|
|
11
|
+
getAuthTokenError: `Could not find auth token. For UI app please run ${chalk.cyan`yarn start`} and login to Corva to fetch it.`,
|
|
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
|
+
};
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
RELEASE,
|
|
19
|
+
SUCCESS_ICON,
|
|
20
|
+
ERROR_ICON,
|
|
21
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
const uiDependencies = {
|
|
2
|
+
'@corva/ui': 'latest',
|
|
3
|
+
'@material-ui/core': '4.11.2',
|
|
4
|
+
'@material-ui/icons': '4.9.1',
|
|
5
|
+
'@material-ui/lab': '4.0.0-alpha.57',
|
|
6
|
+
'@material-ui/pickers': '3.2.10',
|
|
7
|
+
'classnames': '2.2.6',
|
|
8
|
+
'corva-convert-units': '1.10.17',
|
|
9
|
+
'highcharts': '8.1.2',
|
|
10
|
+
'highcharts-react-official': '2.2.2',
|
|
11
|
+
'lodash': '^4.17.4',
|
|
12
|
+
'mapbox.js': '3.2.1',
|
|
13
|
+
'moment': '2.23.0',
|
|
14
|
+
'moment-timezone': '0.5.23',
|
|
15
|
+
'prop-types': '^15.6.1',
|
|
16
|
+
'react': '17.0.1',
|
|
17
|
+
'react-dom': '17.0.1',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const jsUiDevDependencies = {
|
|
21
|
+
'postcss-loader': '4.1.0',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const tsUiDevDependencies = {
|
|
25
|
+
'@tsconfig/create-react-app': '1.0.2',
|
|
26
|
+
'@types/material-ui': '0.21.9',
|
|
27
|
+
'@types/react': '^17.0.22',
|
|
28
|
+
'@types/react-dom': '^17.0.9',
|
|
29
|
+
'@typescript-eslint/eslint-plugin': '^4.31.2',
|
|
30
|
+
'@typescript-eslint/parser': '^4.31.2',
|
|
31
|
+
'ts-loader': '8.2.0',
|
|
32
|
+
'typescript': '^4.4.3',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const uiScripts = {
|
|
36
|
+
build: 'webpack --config=./config-overrides.js --mode production',
|
|
37
|
+
start: 'webpack-dev-server --config=./config-overrides.js --open --mode development',
|
|
38
|
+
zip: 'create-corva-app zip .',
|
|
39
|
+
lint: 'eslint --cache ./src/',
|
|
40
|
+
release: 'create-corva-app release .',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const uiPackage = {
|
|
44
|
+
version: '0.0.1',
|
|
45
|
+
main: 'src/index.js',
|
|
46
|
+
scripts: uiScripts,
|
|
47
|
+
dependencies: uiDependencies,
|
|
48
|
+
devDependencies: jsUiDevDependencies
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const tsUiPackage = {
|
|
52
|
+
...uiPackage,
|
|
53
|
+
devDependencies: tsUiDevDependencies
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const nodeNpmScripts = {
|
|
57
|
+
"bundle": "create-corva-app zip .",
|
|
58
|
+
"test": "npm audit --production && npm run unit",
|
|
59
|
+
"unit": "jest --passWithNoTests"
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const nodeDependencies = {
|
|
63
|
+
"@corva/node-sdk": "^6.2.0"
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const nodeDevDependencies = {
|
|
67
|
+
"jest": "^27.5.1"
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const nodeTsDevDependencies = {
|
|
71
|
+
"@types/jest": "^27.4.1",
|
|
72
|
+
"jest": "^27.5.1",
|
|
73
|
+
"ts-jest": "^27.1.4",
|
|
74
|
+
"typescript": "^4.6.3"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const nodeYarnScripts = {
|
|
78
|
+
...nodeNpmScripts,
|
|
79
|
+
"test": "yarn audit --groups dependencies && yarn unit",
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const nodeTsScripts = {
|
|
83
|
+
...nodeNpmScripts,
|
|
84
|
+
"build": "tsc -p tsconfig.build.json",
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const nodeTsYarnScripts = {
|
|
88
|
+
...nodeYarnScripts,
|
|
89
|
+
"build": "tsc -p tsconfig.build.json",
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const nodeNpmPackage = {
|
|
93
|
+
version: '0.0.1',
|
|
94
|
+
main: 'index.js',
|
|
95
|
+
private: true,
|
|
96
|
+
dependencies: nodeDependencies,
|
|
97
|
+
devDependencies: nodeDevDependencies,
|
|
98
|
+
scripts: nodeNpmScripts
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const nodeYarnPackage = {
|
|
102
|
+
...nodeNpmPackage,
|
|
103
|
+
scripts: nodeYarnScripts
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const nodeTsNpmPackage = {
|
|
107
|
+
...nodeNpmPackage,
|
|
108
|
+
devDependencies: nodeTsDevDependencies,
|
|
109
|
+
scripts: nodeTsScripts
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const nodeTsYarnPackage = {
|
|
113
|
+
...nodeTsNpmPackage,
|
|
114
|
+
scripts: nodeTsYarnScripts
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const extendWithTsConfig = (package, version) => {
|
|
118
|
+
package.devDependencies = {
|
|
119
|
+
[`@tsconfig/node${version}`]: `^${version === '12' ? '1.0.9' : '1.0.1'}`,
|
|
120
|
+
...package.devDependencies,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
return package;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const defaults = {
|
|
127
|
+
javascript: {
|
|
128
|
+
yarn: {
|
|
129
|
+
ui: () => uiPackage,
|
|
130
|
+
task: () => nodeYarnPackage,
|
|
131
|
+
scheduler: () => nodeYarnPackage,
|
|
132
|
+
stream: () => nodeYarnPackage
|
|
133
|
+
},
|
|
134
|
+
npm: {
|
|
135
|
+
ui: () => uiPackage,
|
|
136
|
+
task: () => nodeNpmPackage,
|
|
137
|
+
scheduler: () => nodeNpmPackage,
|
|
138
|
+
stream: () => nodeNpmPackage
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
typescript: {
|
|
142
|
+
yarn: {
|
|
143
|
+
ui: () => tsUiPackage,
|
|
144
|
+
task: ({ version }) => extendWithTsConfig(nodeTsYarnPackage, version),
|
|
145
|
+
scheduler: ({ version }) => extendWithTsConfig(nodeTsYarnPackage, version),
|
|
146
|
+
stream: ({ version }) => extendWithTsConfig(nodeTsYarnPackage, version)
|
|
147
|
+
},
|
|
148
|
+
npm: {
|
|
149
|
+
ui: () => tsUiPackage,
|
|
150
|
+
task: ({ version }) => extendWithTsConfig(nodeTsNpmPackage, version),
|
|
151
|
+
scheduler: ({ version }) => extendWithTsConfig(nodeTsNpmPackage, version),
|
|
152
|
+
stream: ({ version }) => extendWithTsConfig(nodeTsNpmPackage, version)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
module.exports = {
|
|
158
|
+
getDefaultsForPackageJson: (manifest, runtime) => {
|
|
159
|
+
return defaults[runtime.language][runtime.packageManager][manifest.type](runtime);
|
|
160
|
+
}
|
|
161
|
+
}
|
package/lib/flow.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const { SUCCESS_ICON } = require('./constants/messages');
|
|
5
|
+
const { resolve, sep } = require('path');
|
|
6
|
+
|
|
7
|
+
const debug = require('debug')('cca:flow');
|
|
8
|
+
|
|
9
|
+
const runFlow = async (flow, context, indent = '') => {
|
|
10
|
+
process.stdout.write(
|
|
11
|
+
`${indent}Running ${chalk.cyan(flow.name)} in ${chalk.cyan(resolve(context.dirName).split(sep).pop())}\n`
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const result = await runSteps(flow.steps, context, indent + ' ');
|
|
15
|
+
|
|
16
|
+
process.stdout.write(`${indent}Done!` + SUCCESS_ICON);
|
|
17
|
+
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const runSteps = async (steps = [], context = {}, indent = '') => {
|
|
22
|
+
for (const step of steps) {
|
|
23
|
+
if (step.name) {
|
|
24
|
+
const result = await runFlow(step, context, indent);
|
|
25
|
+
|
|
26
|
+
Object.assign(context, result);
|
|
27
|
+
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const message = indent + step.message;
|
|
32
|
+
|
|
33
|
+
process.stdout.write(message);
|
|
34
|
+
debug('Context: %o', context);
|
|
35
|
+
|
|
36
|
+
const result = await step.fn(context);
|
|
37
|
+
|
|
38
|
+
Object.assign(context, result);
|
|
39
|
+
|
|
40
|
+
process.stdout.write(SUCCESS_ICON);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return context;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
module.exports = { runFlow };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const archiver = require('archiver');
|
|
2
|
+
const debug = require('debug')('cca:zip');
|
|
3
|
+
const { promises: fs, createWriteStream } = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const createZipArchive = async (dirName, zipName, itemsToZip = []) => {
|
|
7
|
+
const filePath = path.resolve(dirName, zipName);
|
|
8
|
+
const archive = archiver.create('zip', {});
|
|
9
|
+
const output = createWriteStream(filePath);
|
|
10
|
+
// pipe archive data to the file
|
|
11
|
+
archive.pipe(output);
|
|
12
|
+
|
|
13
|
+
await new Promise(async (resolve, reject) => {
|
|
14
|
+
output.once('close', resolve).once('end', function () {
|
|
15
|
+
debug('Data has been drained');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
archive.on('warning', function (err) {
|
|
19
|
+
if (err.code === 'ENOENT') {
|
|
20
|
+
console.warn(err.message);
|
|
21
|
+
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
throw err;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
archive.once('error', reject);
|
|
29
|
+
|
|
30
|
+
const dataToZip = await getDataToZip(itemsToZip, dirName);
|
|
31
|
+
|
|
32
|
+
for (const item of dataToZip) {
|
|
33
|
+
if (item.isDir) {
|
|
34
|
+
debug(`Adding directory %s -> %s`, item.path, item.name);
|
|
35
|
+
archive.directory(item.path, item.name);
|
|
36
|
+
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
debug(`Adding file %s -> %s`, item.path, item.name);
|
|
41
|
+
archive.file(item.path, { name: item.name });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
archive.finalize();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return archive.pointer();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const getDataToZip = async (itemsToZip, dirName) => {
|
|
51
|
+
const promises = itemsToZip.map(async (name) => {
|
|
52
|
+
const nameWasProvided = typeof name === 'string';
|
|
53
|
+
const filePath = nameWasProvided ? path.resolve(dirName, name) : name.path;
|
|
54
|
+
const fileName = nameWasProvided ? name : name.name;
|
|
55
|
+
|
|
56
|
+
const { exists, isDir } = await fs
|
|
57
|
+
.lstat(filePath)
|
|
58
|
+
.then((stat) => ({ exists: true, isDir: stat.isDirectory() }))
|
|
59
|
+
.catch(() => {
|
|
60
|
+
debug(`%s location not exist, filtering it out`, filePath);
|
|
61
|
+
|
|
62
|
+
return { exists: false, isDir: false };
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
name: fileName,
|
|
67
|
+
path: filePath,
|
|
68
|
+
exists,
|
|
69
|
+
isDir,
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
const allData = await Promise.all(promises);
|
|
73
|
+
|
|
74
|
+
return allData.filter((f) => f.exists);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
module.exports = { createZipArchive };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { resolve } = require('path');
|
|
2
|
+
const { promises: fs } = require('fs');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
|
|
5
|
+
const debug = require('debug')('cca:json');
|
|
6
|
+
|
|
7
|
+
const loadJson = async (dirName, fileName) => {
|
|
8
|
+
const fullPath = resolve(dirName, fileName);
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
debug('Loading file %s', fullPath);
|
|
12
|
+
const manifest = await fs.readFile(fullPath, 'utf8');
|
|
13
|
+
|
|
14
|
+
return JSON.parse(manifest);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
if (e.code === 'ENOENT') {
|
|
17
|
+
throw new Error(`${fileName} was not found in ${resolve(dirName)}`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
throw e;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const saveJson = async (dirName, fileName, data) => {
|
|
25
|
+
return fs.writeFile(resolve(dirName, fileName), JSON.stringify(data, null, 2) + os.EOL);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = { loadJson, saveJson };
|