@corva/create-app 0.44.0-0 → 0.44.0-2
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/bin/create-corva-app.cjs +8 -11
- package/lib/bump-version.option.js +10 -18
- package/lib/constants/manifest.js +29 -10
- package/lib/constants/package.js +8 -4
- package/lib/flow.js +4 -6
- package/lib/flows/lib/api.js +14 -14
- package/lib/flows/lib/create-zip-archive.js +10 -4
- package/lib/flows/lib/json.js +4 -3
- package/lib/flows/lib/notification.js +3 -0
- package/lib/flows/steps/attach/add-app-to-stream.js +4 -5
- package/lib/flows/steps/attach/get-all-live-assets.js +7 -14
- package/lib/flows/steps/attach/index.js +1 -5
- package/lib/flows/steps/attach/prepare-data.js +0 -1
- package/lib/flows/steps/prepare-load-app-files.js +2 -4
- package/lib/flows/steps/release/get-config.js +3 -2
- package/lib/flows/steps/release/remove-failed-upload.js +2 -13
- package/lib/flows/steps/release/upload-zip-to-corva.js +3 -8
- package/lib/flows/steps/release/wait-for-build.js +3 -2
- package/lib/flows/steps/rerun/create-task.js +8 -9
- package/lib/flows/steps/rerun/ensure-that-app-in-stream.js +8 -12
- package/lib/flows/steps/rerun/get-app-version.js +8 -7
- package/lib/flows/steps/rerun/prepare-data.js +13 -12
- package/lib/flows/steps/rerun/prepare-well-and-stream-data.js +22 -18
- package/lib/flows/steps/zip-cleanup.js +2 -2
- package/lib/flows/steps/zip-create-archive.js +2 -2
- package/lib/flows/steps/zip-file-list-resolve.js +24 -14
- package/lib/flows/steps/zip-prepare.js +3 -3
- package/lib/flows/steps/zip.js +1 -6
- package/lib/helpers/resolve-app-runtime.js +8 -5
- package/lib/helpers/utils.js +5 -4
- package/lib/helpers/versioning.js +14 -2
- package/lib/main.js +59 -73
- package/lib/scripts/utils/version.js +2 -0
- package/package.json +76 -68
- package/templates/javascript/scheduler/.eslintrc.js +1 -0
- package/templates/javascript/scheduler/.prettierrc +1 -0
- package/templates/javascript/stream/.eslintrc.js +1 -0
- package/templates/javascript/stream/.prettierrc +1 -0
- package/templates/javascript/task/.eslintrc.js +1 -0
- package/templates/javascript/task/.prettierrc +1 -0
- package/templates/typescript/scheduler/.prettierrc +1 -0
- package/templates/typescript/stream/.prettierrc +1 -0
- package/templates/typescript/task/.prettierrc +1 -0
package/bin/create-corva-app.cjs
CHANGED
|
@@ -4,21 +4,18 @@ const { sync: spawnSync } = require('cross-spawn');
|
|
|
4
4
|
const { resolve } = require('path');
|
|
5
5
|
|
|
6
6
|
const cmd = 'node';
|
|
7
|
-
const originalCwd = process.cwd()
|
|
7
|
+
const originalCwd = process.cwd();
|
|
8
8
|
|
|
9
|
-
process.chdir(__dirname)
|
|
9
|
+
process.chdir(__dirname);
|
|
10
10
|
|
|
11
|
-
const preparedOriginalArgs = process.argv
|
|
11
|
+
const preparedOriginalArgs = process.argv
|
|
12
|
+
.slice(2)
|
|
12
13
|
// after changing the cwd need to pass the original path
|
|
13
14
|
.concat(['--original-cwd', originalCwd])
|
|
14
|
-
// leave spaces in place for arguments
|
|
15
|
-
.map(a => a.includes(
|
|
16
|
-
|
|
17
|
-
const args = [
|
|
18
|
-
'--no-warnings',
|
|
19
|
-
'--experimental-json-modules',
|
|
20
|
-
'cca.js',
|
|
21
|
-
].concat(preparedOriginalArgs);
|
|
15
|
+
// leave spaces in place for arguments
|
|
16
|
+
.map(a => (a.includes(' ') ? `"${a}"` : a));
|
|
17
|
+
|
|
18
|
+
const args = ['--no-warnings', '--experimental-json-modules', 'cca.js'].concat(preparedOriginalArgs);
|
|
22
19
|
|
|
23
20
|
const { signal, status, error } = spawnSync(cmd, args, {
|
|
24
21
|
stdio: 'inherit',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Option, InvalidArgumentError } from 'commander';
|
|
2
1
|
import chalk from 'chalk';
|
|
2
|
+
import { InvalidArgumentError, Option } from 'commander';
|
|
3
3
|
import semver from 'semver';
|
|
4
4
|
|
|
5
5
|
const flags = '--bump-version <string>';
|
|
@@ -7,42 +7,34 @@ const description = 'Bump version';
|
|
|
7
7
|
const choices = ['major', 'minor', 'patch', 'skip'];
|
|
8
8
|
|
|
9
9
|
function argParser(value, previous) {
|
|
10
|
+
// eslint-disable-next-line no-invalid-this
|
|
10
11
|
if (this.argChoices.includes(value) || semver.valid(value)) {
|
|
11
12
|
return value;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
throw new InvalidArgumentError(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.join(', ')} or a valid semver version.`
|
|
16
|
+
// eslint-disable-next-line no-invalid-this
|
|
17
|
+
`Allowed choices are ${this.argChoices.map((choice) => `"${choice}"`).join(', ')} or a valid semver version.`,
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
|
-
export const bumpVersionOption = new Option(flags, description)
|
|
21
|
-
.choices(choices)
|
|
22
|
-
.argParser(argParser);
|
|
20
|
+
export const bumpVersionOption = new Option(flags, description).choices(choices).argParser(argParser);
|
|
23
21
|
|
|
24
22
|
export const apiKeyOption = new Option(
|
|
25
23
|
'--api-key [string]',
|
|
26
|
-
'Pre generated API key for authorization during app upload'
|
|
24
|
+
'Pre generated API key for authorization during app upload',
|
|
27
25
|
);
|
|
28
26
|
|
|
29
27
|
export const appVersion = new Option('--app-version [number]', 'App version (exp. 1, 2, 3)');
|
|
30
28
|
|
|
31
|
-
export const envOption = new Option('--env [string]', 'Environment to use')
|
|
32
|
-
.choices(['qa', 'staging', 'production'])
|
|
33
|
-
.default('qa');
|
|
29
|
+
export const envOption = new Option('--env [string]', 'Environment to use').choices(['qa', 'staging', 'production']);
|
|
34
30
|
|
|
35
|
-
export const silentOption = new Option(
|
|
36
|
-
'--silent [boolean]',
|
|
37
|
-
'Only log result of the operation'
|
|
38
|
-
).default(false);
|
|
31
|
+
export const silentOption = new Option('--silent [boolean]', 'Only log result of the operation').default(false);
|
|
39
32
|
|
|
40
|
-
export const originalCwdOption =
|
|
33
|
+
export const originalCwdOption = new Option('--original-cwd <string>').hideHelp();
|
|
41
34
|
|
|
42
35
|
export const bumpVersionOptionDeprecated = new Option(
|
|
43
36
|
flags,
|
|
44
|
-
chalk.bgYellow`DEPRECATED` +
|
|
45
|
-
` Use with ${chalk.cyan`zip`} or ${chalk.cyan`release`} command instead`
|
|
37
|
+
chalk.bgYellow`DEPRECATED` + ` Use with ${chalk.cyan`zip`} or ${chalk.cyan`release`} command instead`,
|
|
46
38
|
)
|
|
47
39
|
.choices(choices)
|
|
48
40
|
.argParser(argParser);
|
|
@@ -99,13 +99,30 @@ export const getManifestMandatoryKeys = (opts) => {
|
|
|
99
99
|
return keys;
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
export const SCHEDULER_TYPE_NATURAL_TIME = {
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
export const SCHEDULER_TYPE_NATURAL_TIME = {
|
|
103
|
+
name: 'Natural Time',
|
|
104
|
+
value: 1,
|
|
105
|
+
};
|
|
106
|
+
export const SCHEDULER_TYPE_DATA_TIME = {
|
|
107
|
+
name: 'Data Time',
|
|
108
|
+
value: 2,
|
|
109
|
+
};
|
|
110
|
+
export const SCHEDULER_TYPE_DEPTH = {
|
|
111
|
+
name: 'Date Depth',
|
|
112
|
+
value: 4,
|
|
113
|
+
};
|
|
105
114
|
|
|
106
115
|
export const manifestOptions = (projectName = 'Corva Dev Center App') => [
|
|
107
|
-
{
|
|
108
|
-
|
|
116
|
+
{
|
|
117
|
+
name: 'developerName',
|
|
118
|
+
message: 'Enter the Developer Name',
|
|
119
|
+
default: 'O&G Company',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'developerIdentifier',
|
|
123
|
+
message: 'Enter the Developer Identifier',
|
|
124
|
+
default: 'oandgc',
|
|
125
|
+
},
|
|
109
126
|
{
|
|
110
127
|
type: 'rawlist',
|
|
111
128
|
name: 'appType',
|
|
@@ -126,8 +143,7 @@ export const manifestOptions = (projectName = 'Corva Dev Center App') => [
|
|
|
126
143
|
name: 'cronString',
|
|
127
144
|
message: 'Provide CRON string for the scheduler',
|
|
128
145
|
default: '*/5 * * * *',
|
|
129
|
-
when: (answers) =>
|
|
130
|
-
answers.schedulerType && answers.schedulerType !== SCHEDULER_TYPE_DEPTH.value,
|
|
146
|
+
when: (answers) => answers.schedulerType && answers.schedulerType !== SCHEDULER_TYPE_DEPTH.value,
|
|
131
147
|
},
|
|
132
148
|
{
|
|
133
149
|
name: 'depthMilestone',
|
|
@@ -164,7 +180,11 @@ export const manifestOptions = (projectName = 'Corva Dev Center App') => [
|
|
|
164
180
|
default: '',
|
|
165
181
|
required: true,
|
|
166
182
|
},
|
|
167
|
-
{
|
|
183
|
+
{
|
|
184
|
+
name: 'website',
|
|
185
|
+
message: 'Enter website',
|
|
186
|
+
default: 'https://www.oandgexample.com/my-app/',
|
|
187
|
+
},
|
|
168
188
|
{
|
|
169
189
|
type: 'rawlist',
|
|
170
190
|
name: 'segments',
|
|
@@ -201,8 +221,7 @@ export const manifestOptions = (projectName = 'Corva Dev Center App') => [
|
|
|
201
221
|
message: 'Would you like to use TypesScript?',
|
|
202
222
|
default: false,
|
|
203
223
|
when: (answers) =>
|
|
204
|
-
(answers.runtime && answers.runtime.startsWith(TEMPLATE_TYPES.NODE)) ||
|
|
205
|
-
answers.appType === APP_TYPES.UI,
|
|
224
|
+
(answers.runtime && answers.runtime.startsWith(TEMPLATE_TYPES.NODE)) || answers.appType === APP_TYPES.UI,
|
|
206
225
|
},
|
|
207
226
|
{
|
|
208
227
|
name: 'silent',
|
package/lib/constants/package.js
CHANGED
|
@@ -69,9 +69,11 @@ const tsUiPackage = {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
const nodeNpmScripts = {
|
|
72
|
-
bundle: 'create-corva-app zip .',
|
|
73
|
-
test: 'npm audit --production && npm run unit',
|
|
74
|
-
unit: 'jest --passWithNoTests',
|
|
72
|
+
'bundle': 'create-corva-app zip .',
|
|
73
|
+
'test': 'npm audit --production && npm run unit',
|
|
74
|
+
'unit': 'jest --passWithNoTests',
|
|
75
|
+
'lint': 'eslint .',
|
|
76
|
+
'lint:fix': 'eslint . --fix',
|
|
75
77
|
};
|
|
76
78
|
|
|
77
79
|
const nodeDependencies = {
|
|
@@ -79,10 +81,12 @@ const nodeDependencies = {
|
|
|
79
81
|
};
|
|
80
82
|
|
|
81
83
|
const nodeDevDependencies = {
|
|
82
|
-
|
|
84
|
+
'@corva/eslint-config-node': '^5.0.0',
|
|
85
|
+
'jest': '^27.5.1',
|
|
83
86
|
};
|
|
84
87
|
|
|
85
88
|
const nodeTsDevDependencies = {
|
|
89
|
+
'@corva/eslint-config-node': '^5.0.0',
|
|
86
90
|
'@types/jest': '^27.4.1',
|
|
87
91
|
'jest': '^27.5.1',
|
|
88
92
|
'ts-jest': '^27.1.4',
|
package/lib/flow.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { SUCCESS_ICON } from './constants/messages.js';
|
|
3
2
|
import { resolve, sep } from 'node:path';
|
|
3
|
+
import { SUCCESS_ICON } from './constants/messages.js';
|
|
4
4
|
import { logger } from './helpers/logger.js';
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import debugFn from 'debug';
|
|
7
7
|
|
|
8
|
-
const debug =
|
|
8
|
+
const debug = debugFn('cca:flow');
|
|
9
9
|
|
|
10
10
|
export const runFlow = async (flow, context, indent = '') => {
|
|
11
11
|
logger.write(
|
|
12
|
-
`${indent}Running ${chalk.cyan(flow.name)} in ${chalk.cyan(
|
|
13
|
-
resolve(context.dirName).split(sep).pop()
|
|
14
|
-
)}\n`
|
|
12
|
+
`${indent}Running ${chalk.cyan(flow.name)} in ${chalk.cyan(resolve(context.dirName).split(sep).pop())}\n`,
|
|
15
13
|
);
|
|
16
14
|
|
|
17
15
|
context.progress = () => logger.write('.');
|
package/lib/flows/lib/api.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import debugFn from 'debug';
|
|
1
2
|
import got from 'got';
|
|
2
|
-
import Debug from 'debug';
|
|
3
3
|
import { StepError } from './step-error.js';
|
|
4
4
|
|
|
5
|
-
const debug =
|
|
5
|
+
const debug = debugFn('cca:api');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Connect to Corva API
|
|
@@ -48,6 +48,7 @@ export class Api {
|
|
|
48
48
|
.json();
|
|
49
49
|
|
|
50
50
|
const app = data.find((app) => app.attributes.app_key === appKey);
|
|
51
|
+
|
|
51
52
|
if (!app) {
|
|
52
53
|
throw new Error(`App with key - ${appKey}, not exist`);
|
|
53
54
|
}
|
|
@@ -66,10 +67,9 @@ export class Api {
|
|
|
66
67
|
*/
|
|
67
68
|
async getAppDatasetsOperationWrite(appId) {
|
|
68
69
|
const { data } = await this.#api
|
|
69
|
-
.get(
|
|
70
|
-
`v2/apps/${appId}/app_datasets?dataset_operation=write&fields[]=app_dataset.dataset_name`
|
|
71
|
-
)
|
|
70
|
+
.get(`v2/apps/${appId}/app_datasets?dataset_operation=write&fields[]=app_dataset.dataset_name`)
|
|
72
71
|
.json();
|
|
72
|
+
|
|
73
73
|
return data;
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -125,6 +125,7 @@ export class Api {
|
|
|
125
125
|
searchParams: { status, per_page: perPage },
|
|
126
126
|
})
|
|
127
127
|
.json();
|
|
128
|
+
|
|
128
129
|
return data;
|
|
129
130
|
}
|
|
130
131
|
|
|
@@ -139,7 +140,9 @@ export class Api {
|
|
|
139
140
|
*/
|
|
140
141
|
async getWellByAssetId(assetId) {
|
|
141
142
|
const { wells } = await this.#api
|
|
142
|
-
.post('v2/assets/resolve', {
|
|
143
|
+
.post('v2/assets/resolve', {
|
|
144
|
+
json: { assets: [assetId] },
|
|
145
|
+
})
|
|
143
146
|
.json();
|
|
144
147
|
|
|
145
148
|
if (!wells.length) {
|
|
@@ -199,9 +202,7 @@ export class Api {
|
|
|
199
202
|
*/
|
|
200
203
|
async getAppRuns(appId) {
|
|
201
204
|
const { data } = await this.#api
|
|
202
|
-
.get(
|
|
203
|
-
`v2/apps/${appId}/app_runs?page=1&per_page=500&status[]=pending&status[]=in_progress&status[]=running`
|
|
204
|
-
)
|
|
205
|
+
.get(`v2/apps/${appId}/app_runs?page=1&per_page=500&status[]=pending&status[]=in_progress&status[]=running`)
|
|
205
206
|
.json();
|
|
206
207
|
|
|
207
208
|
return data;
|
|
@@ -233,10 +234,7 @@ export class Api {
|
|
|
233
234
|
status: data.attributes.status,
|
|
234
235
|
};
|
|
235
236
|
} catch (e) {
|
|
236
|
-
throw new StepError(
|
|
237
|
-
`${JSON.parse(e.response.body).message || ''} \nPOST: ${uploadURL} failed.`,
|
|
238
|
-
{ cause: e }
|
|
239
|
-
);
|
|
237
|
+
throw new StepError(`${JSON.parse(e.response.body).message || ''} \nPOST: ${uploadURL} failed.`, { cause: e });
|
|
240
238
|
}
|
|
241
239
|
}
|
|
242
240
|
|
|
@@ -295,6 +293,7 @@ export class Api {
|
|
|
295
293
|
console.log(`v2/apps/${appId}/packages/${id}`, {
|
|
296
294
|
json: { package: { status: 'published' } },
|
|
297
295
|
});
|
|
296
|
+
|
|
298
297
|
const { data } = await this.#api
|
|
299
298
|
.patch(`v2/apps/${appId}/packages/${id}`, {
|
|
300
299
|
json: { package: { status: 'published' } },
|
|
@@ -318,6 +317,7 @@ export class Api {
|
|
|
318
317
|
*/
|
|
319
318
|
async getAppPackages(appId) {
|
|
320
319
|
const { data } = await this.#api.get(`v2/apps/${appId}/packages`).json();
|
|
320
|
+
|
|
321
321
|
return data;
|
|
322
322
|
}
|
|
323
323
|
|
|
@@ -338,7 +338,7 @@ export class Api {
|
|
|
338
338
|
app_stream_id: streamId,
|
|
339
339
|
app_id: appId,
|
|
340
340
|
status,
|
|
341
|
-
settings
|
|
341
|
+
settings,
|
|
342
342
|
scheduler_type: settings.scheduler_type,
|
|
343
343
|
};
|
|
344
344
|
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import archiver from 'archiver';
|
|
2
|
-
import
|
|
2
|
+
import debugFn from 'debug';
|
|
3
3
|
|
|
4
|
-
const debug =
|
|
5
|
-
|
|
4
|
+
const debug = debugFn('cca:zip');
|
|
5
|
+
|
|
6
|
+
import { createWriteStream, promises as fs } from 'node:fs';
|
|
6
7
|
import path from 'node:path';
|
|
7
8
|
|
|
8
9
|
export const createZipArchive = async (dirName, zipName, itemsToZip = []) => {
|
|
9
10
|
const filePath = path.resolve(dirName, zipName);
|
|
10
11
|
const archive = archiver.create('zip', {});
|
|
11
12
|
const output = createWriteStream(filePath);
|
|
13
|
+
|
|
12
14
|
// pipe archive data to the file
|
|
13
15
|
archive.pipe(output);
|
|
14
16
|
|
|
17
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
15
18
|
await new Promise(async (resolve, reject) => {
|
|
16
19
|
output.once('close', resolve).once('end', function () {
|
|
17
20
|
debug('Data has been drained');
|
|
@@ -57,7 +60,10 @@ const getDataToZip = async (itemsToZip, dirName) => {
|
|
|
57
60
|
|
|
58
61
|
const { exists, isDir } = await fs
|
|
59
62
|
.lstat(filePath)
|
|
60
|
-
.then((stat) => ({
|
|
63
|
+
.then((stat) => ({
|
|
64
|
+
exists: true,
|
|
65
|
+
isDir: stat.isDirectory(),
|
|
66
|
+
}))
|
|
61
67
|
.catch(() => {
|
|
62
68
|
debug(`%s location not exist, filtering it out`, filePath);
|
|
63
69
|
|
package/lib/flows/lib/json.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
2
1
|
import { promises as fs } from 'node:fs';
|
|
3
2
|
import os from 'node:os';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import debugFn from 'debug';
|
|
6
6
|
|
|
7
|
-
const debug =
|
|
7
|
+
const debug = debugFn('cca:json');
|
|
8
8
|
|
|
9
9
|
export const loadJson = async (dirName, fileName) => {
|
|
10
10
|
const fullPath = resolve(dirName, fileName);
|
|
11
11
|
|
|
12
12
|
try {
|
|
13
13
|
debug('Loading file %s', fullPath);
|
|
14
|
+
|
|
14
15
|
const manifest = await fs.readFile(fullPath, 'utf8');
|
|
15
16
|
|
|
16
17
|
return JSON.parse(manifest);
|
|
@@ -91,6 +91,7 @@ export class Notification {
|
|
|
91
91
|
*/
|
|
92
92
|
getStreamLink(title, streamId) {
|
|
93
93
|
const streamUrl = `${this.#prefixUrl}/config/streams/${streamId}`;
|
|
94
|
+
|
|
94
95
|
return this._createLink(title, streamUrl);
|
|
95
96
|
}
|
|
96
97
|
|
|
@@ -106,6 +107,7 @@ export class Notification {
|
|
|
106
107
|
*/
|
|
107
108
|
printStreamLink(title, streamId) {
|
|
108
109
|
const link = this.getStreamLink(title, streamId);
|
|
110
|
+
|
|
109
111
|
this.print(link);
|
|
110
112
|
}
|
|
111
113
|
|
|
@@ -121,6 +123,7 @@ export class Notification {
|
|
|
121
123
|
*/
|
|
122
124
|
getAssetLink(title, assetId) {
|
|
123
125
|
const assetUrl = `${this.#prefixUrl}/assets/${assetId}`;
|
|
126
|
+
|
|
124
127
|
return this._createLink(title, assetUrl);
|
|
125
128
|
}
|
|
126
129
|
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
|
-
|
|
3
1
|
export const ADD_APP_TO_STREAM_TASK_STEP = {
|
|
4
2
|
message: 'Add app to streams...',
|
|
5
3
|
fn: async (context) => {
|
|
6
4
|
const { assetsStreamsDataToProcess, api, app, manifest, notification } = context;
|
|
7
5
|
|
|
8
6
|
let counter = 0;
|
|
7
|
+
|
|
9
8
|
for (const assetStreamsData of assetsStreamsDataToProcess) {
|
|
10
9
|
for (const stream of assetStreamsData.selectedStreams) {
|
|
11
10
|
notification.printStreamLink(stream.name, stream.id);
|
|
11
|
+
|
|
12
12
|
try {
|
|
13
13
|
await api.connectAppToStream(app.id, stream.id, manifest.manifest.settings.app);
|
|
14
14
|
++counter;
|
|
15
15
|
} catch (e) {
|
|
16
|
-
notification.printError(
|
|
17
|
-
`Could not add app to the stream, an error occurred: ${e.message}`
|
|
18
|
-
);
|
|
16
|
+
notification.printError(`Could not add app to the stream, an error occurred: ${e.message}`);
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
19
|
}
|
|
20
|
+
|
|
22
21
|
notification.print(`The app has been added to ${counter} - stream(s)`);
|
|
23
22
|
},
|
|
24
23
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
1
|
import inquirer from 'inquirer';
|
|
3
2
|
|
|
4
3
|
export const GET_ALL_LIVE_ASSETS_TASK_STEP = {
|
|
@@ -13,18 +12,11 @@ export const GET_ALL_LIVE_ASSETS_TASK_STEP = {
|
|
|
13
12
|
const selectedAssets = await getAssetsListWithPrompt(assets, notification);
|
|
14
13
|
|
|
15
14
|
const assetsIds = selectedAssets.map((asset) => asset.id);
|
|
16
|
-
const streams = await api.getStreamsByAssetIds(
|
|
17
|
-
assetsIds,
|
|
18
|
-
manifest.manifest.application.segments
|
|
19
|
-
);
|
|
15
|
+
const streams = await api.getStreamsByAssetIds(assetsIds, manifest.manifest.application.segments);
|
|
20
16
|
|
|
21
17
|
const mappedAssetStreamsData = mapAssetsStreamsData(selectedAssets, streams);
|
|
22
18
|
|
|
23
|
-
const assetsStreamsDataToProcess = await getAssetsStreamsWithPrompt(
|
|
24
|
-
mappedAssetStreamsData,
|
|
25
|
-
app.id,
|
|
26
|
-
notification
|
|
27
|
-
);
|
|
19
|
+
const assetsStreamsDataToProcess = await getAssetsStreamsWithPrompt(mappedAssetStreamsData, app.id, notification);
|
|
28
20
|
|
|
29
21
|
return {
|
|
30
22
|
...context,
|
|
@@ -73,6 +65,7 @@ const getAssetsListWithPrompt = (assets, notification) => {
|
|
|
73
65
|
const mapAssetsStreamsData = (assets, streamsData) => {
|
|
74
66
|
return assets.map((asset) => {
|
|
75
67
|
const currentStreams = streamsData.filter((stream) => stream.asset_id === parseInt(asset.id));
|
|
68
|
+
|
|
76
69
|
return {
|
|
77
70
|
assetId: asset.id,
|
|
78
71
|
assetName: asset.attributes.name,
|
|
@@ -93,7 +86,8 @@ const mapAssetsStreamsData = (assets, streamsData) => {
|
|
|
93
86
|
*/
|
|
94
87
|
const getAssetsStreamsWithPrompt = async (mappedAssetsStreamsData, appId, notification) => {
|
|
95
88
|
notification.printLineBreak();
|
|
96
|
-
|
|
89
|
+
|
|
90
|
+
for (const mappedData of mappedAssetsStreamsData) {
|
|
97
91
|
const currentStreamsCount = mappedData.streams.length;
|
|
98
92
|
|
|
99
93
|
if (!currentStreamsCount) {
|
|
@@ -101,9 +95,7 @@ const getAssetsStreamsWithPrompt = async (mappedAssetsStreamsData, appId, notifi
|
|
|
101
95
|
}
|
|
102
96
|
|
|
103
97
|
const streamsWithoutCurrentApp = mappedData.streams.filter((stream) => {
|
|
104
|
-
return !stream.app_connections.find(
|
|
105
|
-
(appConnection) => appConnection.app_id === parseInt(appId)
|
|
106
|
-
);
|
|
98
|
+
return !stream.app_connections.find((appConnection) => appConnection.app_id === parseInt(appId));
|
|
107
99
|
});
|
|
108
100
|
|
|
109
101
|
if (!streamsWithoutCurrentApp.length) {
|
|
@@ -112,6 +104,7 @@ const getAssetsStreamsWithPrompt = async (mappedAssetsStreamsData, appId, notifi
|
|
|
112
104
|
|
|
113
105
|
if (streamsWithoutCurrentApp.length === 1) {
|
|
114
106
|
mappedData.selectedStreams = streamsWithoutCurrentApp;
|
|
107
|
+
|
|
115
108
|
continue;
|
|
116
109
|
}
|
|
117
110
|
|
|
@@ -2,8 +2,4 @@ import { PREPARE_DATA_TASK_STEP } from './prepare-data.js';
|
|
|
2
2
|
import { GET_ALL_LIVE_ASSETS_TASK_STEP } from './get-all-live-assets.js';
|
|
3
3
|
import { ADD_APP_TO_STREAM_TASK_STEP } from './add-app-to-stream.js';
|
|
4
4
|
|
|
5
|
-
export const ATTACH_STEPS = [
|
|
6
|
-
PREPARE_DATA_TASK_STEP,
|
|
7
|
-
GET_ALL_LIVE_ASSETS_TASK_STEP,
|
|
8
|
-
ADD_APP_TO_STREAM_TASK_STEP,
|
|
9
|
-
];
|
|
5
|
+
export const ATTACH_STEPS = [PREPARE_DATA_TASK_STEP, GET_ALL_LIVE_ASSETS_TASK_STEP, ADD_APP_TO_STREAM_TASK_STEP];
|
|
@@ -4,10 +4,8 @@ import { Manifest } from '../lib/manifest.js';
|
|
|
4
4
|
export const LOAD_APP_FILES_STEP = {
|
|
5
5
|
message: "Loading Corva app's files...",
|
|
6
6
|
async fn(context) {
|
|
7
|
-
const manifest =
|
|
8
|
-
|
|
9
|
-
const pkg =
|
|
10
|
-
context.package || (manifest.isJs() && (await loadJson(context.dirName, 'package.json')));
|
|
7
|
+
const manifest = context.manifest || new Manifest(await loadJson(context.dirName, 'manifest.json'));
|
|
8
|
+
const pkg = context.package || (manifest.isJs() && (await loadJson(context.dirName, 'package.json')));
|
|
11
9
|
|
|
12
10
|
return { pkg, manifest };
|
|
13
11
|
},
|
|
@@ -9,6 +9,7 @@ import { Notification } from '../../lib/notification.js';
|
|
|
9
9
|
async function getVarsFromDotEnv({ dirName }) {
|
|
10
10
|
try {
|
|
11
11
|
const envFile = await fs.readFile(resolve(dirName, '.env'));
|
|
12
|
+
|
|
12
13
|
return dotenv.parse(envFile);
|
|
13
14
|
} catch (error) {
|
|
14
15
|
return {};
|
|
@@ -20,7 +21,7 @@ export const SETUP_API_CLIENT_STEP = {
|
|
|
20
21
|
fn: async ({ dirName, options: { apiKey, env } }) => {
|
|
21
22
|
const parsedEnv = await getVarsFromDotEnv({ dirName });
|
|
22
23
|
|
|
23
|
-
const CORVA_API_ENV = env || process.env.CORVA_API_ENV ||
|
|
24
|
+
const CORVA_API_ENV = env || parsedEnv.CORVA_API_ENV || process.env.CORVA_API_ENV || 'production';
|
|
24
25
|
const AUTH_TOKEN = process.env.AUTH_TOKEN || parsedEnv.AUTH_TOKEN;
|
|
25
26
|
const API_KEY = apiKey || process.env.API_KEY || parsedEnv.API_KEY;
|
|
26
27
|
|
|
@@ -32,7 +33,7 @@ export const SETUP_API_CLIENT_STEP = {
|
|
|
32
33
|
const notification = new Notification(CORVA_API_ENV);
|
|
33
34
|
|
|
34
35
|
return {
|
|
35
|
-
CORVA_API_ENV
|
|
36
|
+
CORVA_API_ENV,
|
|
36
37
|
api,
|
|
37
38
|
notification,
|
|
38
39
|
};
|
|
@@ -3,16 +3,7 @@ import { unlink } from 'node:fs/promises';
|
|
|
3
3
|
|
|
4
4
|
export const REMOVE_FAILED_UPLOAD_STEP = {
|
|
5
5
|
message: 'Cleaning up...',
|
|
6
|
-
async fn({
|
|
7
|
-
api,
|
|
8
|
-
appId,
|
|
9
|
-
packageId,
|
|
10
|
-
removeOnFail,
|
|
11
|
-
uploadStatus,
|
|
12
|
-
dirName,
|
|
13
|
-
zipFileName,
|
|
14
|
-
removeOnSuccess,
|
|
15
|
-
}) {
|
|
6
|
+
async fn({ api, appId, packageId, removeOnFail, uploadStatus, dirName, zipFileName, removeOnSuccess }) {
|
|
16
7
|
if (uploadStatus === 'draft') {
|
|
17
8
|
removeOnSuccess && (await unlink(resolve(dirName, zipFileName)));
|
|
18
9
|
|
|
@@ -24,8 +15,6 @@ export const REMOVE_FAILED_UPLOAD_STEP = {
|
|
|
24
15
|
await api.deleteAppUpload(appId, packageId);
|
|
25
16
|
}
|
|
26
17
|
|
|
27
|
-
throw new Error(
|
|
28
|
-
`Got unexpected status '${uploadStatus}' while processing package ${packageId}.`
|
|
29
|
-
);
|
|
18
|
+
throw new Error(`Got unexpected status '${uploadStatus}' while processing package ${packageId}.`);
|
|
30
19
|
},
|
|
31
20
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { RELEASE } from '../../../constants/messages.js';
|
|
2
1
|
import FormData from 'form-data';
|
|
3
|
-
import { resolve } from 'node:path';
|
|
4
2
|
import { createReadStream } from 'node:fs';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { RELEASE } from '../../../constants/messages.js';
|
|
7
5
|
|
|
8
6
|
export const UPLOAD_ZIP_TO_CORVA_STEP = {
|
|
9
7
|
message: RELEASE.uploadApp,
|
|
@@ -18,10 +16,7 @@ export const UPLOAD_ZIP_TO_CORVA_STEP = {
|
|
|
18
16
|
|
|
19
17
|
form.append('package', createReadStream(resolve(dirName, zipFileName)), 'package.zip');
|
|
20
18
|
|
|
21
|
-
const { id: packageId
|
|
22
|
-
manifest.manifest.application.key,
|
|
23
|
-
form
|
|
24
|
-
);
|
|
19
|
+
const { id: packageId } = await api.uploadPackages(manifest.manifest.application.key, form);
|
|
25
20
|
|
|
26
21
|
return { packageId };
|
|
27
22
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import debugFn from 'debug';
|
|
2
2
|
import { waitForMs } from '../../lib/waitForMs.js';
|
|
3
3
|
|
|
4
|
-
const debug =
|
|
4
|
+
const debug = debugFn('cca:flow:release:step:wait-for-build');
|
|
5
5
|
|
|
6
6
|
const PROCESSING_STATUSES = ['pending', 'processing', 'queued', 'deploying'];
|
|
7
7
|
|
|
@@ -24,6 +24,7 @@ export const WAIT_FOR_BUILD_FINISH_STEP = {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
await waitForMs(5000);
|
|
27
|
+
// eslint-disable-next-line no-constant-condition
|
|
27
28
|
} while (true);
|
|
28
29
|
},
|
|
29
30
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
1
|
import chalk from 'chalk';
|
|
3
2
|
|
|
4
3
|
import { logger } from '../../../helpers/logger.js';
|
|
@@ -32,9 +31,10 @@ export const CREATE_TASK_STEP = {
|
|
|
32
31
|
if (!wellId || !streamId) {
|
|
33
32
|
logger.write(
|
|
34
33
|
`\n\n${chalk.red.underline.bold(
|
|
35
|
-
`Skipped creating a task for asset ID - ${assetId}, well ID or stream ID is missing
|
|
36
|
-
)}\n\n
|
|
34
|
+
`Skipped creating a task for asset ID - ${assetId}, well ID or stream ID is missing`,
|
|
35
|
+
)}\n\n`,
|
|
37
36
|
);
|
|
37
|
+
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -43,25 +43,24 @@ export const CREATE_TASK_STEP = {
|
|
|
43
43
|
.queueAppRun(app.id, version, interval, wellId, appDatasetsNames, streamId)
|
|
44
44
|
.catch((e) => {
|
|
45
45
|
console.log(e.response.body);
|
|
46
|
+
|
|
46
47
|
throw e;
|
|
47
48
|
});
|
|
48
49
|
|
|
49
50
|
logger.write(
|
|
50
|
-
`\n Created a new task with ID ${chalk.yellow(result.id)} for asset ID - ${chalk.green(
|
|
51
|
-
assetId
|
|
52
|
-
)}`
|
|
51
|
+
`\n Created a new task with ID ${chalk.yellow(result.id)} for asset ID - ${chalk.green(assetId)}`,
|
|
53
52
|
);
|
|
54
53
|
|
|
55
54
|
logger.write(
|
|
56
55
|
`\n Task link - https://app${
|
|
57
56
|
CORVA_API_ENV === 'production' ? '.' : `.${CORVA_API_ENV}.`
|
|
58
|
-
}corva.ai/dev-center/apps/${app.id}/runner
|
|
57
|
+
}corva.ai/dev-center/apps/${app.id}/runner`,
|
|
59
58
|
);
|
|
60
59
|
} catch (e) {
|
|
61
60
|
logger.write(
|
|
62
61
|
`\n\n${chalk.red.underline.bold(
|
|
63
|
-
`Could not rerun app for asset ID - ${assetId}, an error occurred: ${e.message}
|
|
64
|
-
)}\n\n
|
|
62
|
+
`Could not rerun app for asset ID - ${assetId}, an error occurred: ${e.message}`,
|
|
63
|
+
)}\n\n`,
|
|
65
64
|
);
|
|
66
65
|
}
|
|
67
66
|
}
|