@corva/create-app 0.42.0-0 → 0.42.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/README.md +2 -0
- package/lib/bump-version.option.js +12 -5
- package/lib/flow.js +1 -1
- package/lib/flows/attach.js +8 -0
- package/lib/flows/lib/api.js +109 -79
- package/lib/flows/lib/notification.js +139 -0
- package/lib/flows/lib/waitForMs.js +1 -1
- package/lib/flows/release.js +1 -1
- package/lib/flows/steps/attach/add-app-to-stream.js +24 -0
- package/lib/flows/steps/attach/get-all-live-assets.js +142 -0
- package/lib/flows/steps/attach/index.js +9 -0
- package/lib/flows/steps/attach/prepare-data.js +20 -0
- package/lib/flows/steps/release/add-label.js +2 -3
- package/lib/flows/steps/release/add-notes.js +2 -2
- package/lib/flows/steps/release/get-config.js +4 -1
- package/lib/flows/steps/release/prepare-data.js +3 -3
- package/lib/flows/steps/release/publish.js +6 -4
- package/lib/flows/steps/release/remove-failed-upload.js +18 -7
- package/lib/flows/steps/release/upload-zip-to-corva.js +9 -6
- package/lib/flows/steps/release/wait-for-build.js +4 -4
- package/lib/flows/steps/rerun/create-task.js +12 -15
- package/lib/flows/steps/rerun/ensure-that-app-in-stream.js +33 -25
- package/lib/flows/steps/rerun/get-app-version.js +14 -12
- package/lib/flows/steps/rerun/prepare-data.js +6 -8
- package/lib/flows/steps/rerun/prepare-well-and-stream-data.js +29 -36
- package/lib/flows/steps/rerun/rerun.js +5 -5
- package/lib/helpers/logger.js +22 -22
- package/lib/main.js +61 -31
- package/package.json +4 -3
- package/templates/python/scheduler/README.md +1 -1
- package/templates/python/stream/README.md +1 -1
- package/templates/python/task/README.md +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PREPARE_DATA_TASK_STEP } from './prepare-data.js';
|
|
2
|
+
import { GET_ALL_LIVE_ASSETS_TASK_STEP } from './get-all-live-assets.js';
|
|
3
|
+
import { ADD_APP_TO_STREAM_TASK_STEP } from './add-app-to-stream.js';
|
|
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
|
+
];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import { StepError } from '../../lib/step-error.js';
|
|
3
|
+
|
|
4
|
+
export const PREPARE_DATA_TASK_STEP = {
|
|
5
|
+
message: 'Preparing and checking data...',
|
|
6
|
+
fn: async (context) => {
|
|
7
|
+
const { manifest, api } = context;
|
|
8
|
+
|
|
9
|
+
if (!['scheduler', 'stream'].includes(manifest.manifest.application.type)) {
|
|
10
|
+
throw new StepError('Command supports only "scheduler" or "stream" apps');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const app = await api.getAppByKey(manifest.manifest.application.key.toLowerCase());
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
app,
|
|
17
|
+
...context,
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -4,6 +4,7 @@ import dotenv from 'dotenv';
|
|
|
4
4
|
import { resolve } from 'node:path';
|
|
5
5
|
import { StepError } from '../../lib/step-error.js';
|
|
6
6
|
import { Api } from '../../lib/api.js';
|
|
7
|
+
import { Notification } from '../../lib/notification.js';
|
|
7
8
|
|
|
8
9
|
async function getVarsFromDotEnv({ dirName }) {
|
|
9
10
|
try {
|
|
@@ -28,10 +29,12 @@ export const SETUP_API_CLIENT_STEP = {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
const api = new Api(CORVA_API_ENV, API_KEY, AUTH_TOKEN);
|
|
32
|
+
const notification = new Notification(CORVA_API_ENV);
|
|
31
33
|
|
|
32
34
|
return {
|
|
33
35
|
CORVA_API_ENV: CORVA_API_ENV || 'qa',
|
|
34
|
-
api
|
|
36
|
+
api,
|
|
37
|
+
notification,
|
|
35
38
|
};
|
|
36
39
|
},
|
|
37
40
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export const PUBLISH_PACKAGE_STEP = {
|
|
2
2
|
message: 'Publishing app...',
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {object} param0
|
|
4
|
+
*
|
|
5
|
+
* @param {object} param0
|
|
6
6
|
* @param {import('../../lib/api').Api} param0.api
|
|
7
7
|
*/
|
|
8
|
-
async fn({ api, appId, packageId }) {
|
|
9
|
-
|
|
8
|
+
async fn({ api, appId, packageId }) {
|
|
9
|
+
await api.publishApp(appId, packageId);
|
|
10
|
+
},
|
|
11
|
+
};
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import { resolve } from 'node:path'
|
|
2
|
-
import { unlink } from 'node:fs/promises'
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { unlink } from 'node:fs/promises';
|
|
3
3
|
|
|
4
4
|
export const REMOVE_FAILED_UPLOAD_STEP = {
|
|
5
5
|
message: 'Cleaning up...',
|
|
6
|
-
async fn({
|
|
6
|
+
async fn({
|
|
7
|
+
api,
|
|
8
|
+
appId,
|
|
9
|
+
packageId,
|
|
10
|
+
removeOnFail,
|
|
11
|
+
uploadStatus,
|
|
12
|
+
dirName,
|
|
13
|
+
zipFileName,
|
|
14
|
+
removeOnSuccess,
|
|
15
|
+
}) {
|
|
7
16
|
if (uploadStatus === 'draft') {
|
|
8
|
-
await unlink(resolve(dirName, zipFileName));
|
|
17
|
+
removeOnSuccess && (await unlink(resolve(dirName, zipFileName)));
|
|
9
18
|
|
|
10
19
|
return;
|
|
11
20
|
}
|
|
@@ -15,6 +24,8 @@ export const REMOVE_FAILED_UPLOAD_STEP = {
|
|
|
15
24
|
await api.deleteAppUpload(appId, packageId);
|
|
16
25
|
}
|
|
17
26
|
|
|
18
|
-
throw new Error(
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
throw new Error(
|
|
28
|
+
`Got unexpected status '${uploadStatus}' while processing package ${packageId}.`
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
@@ -8,18 +8,21 @@ import _ from 'lodash/fp.js';
|
|
|
8
8
|
export const UPLOAD_ZIP_TO_CORVA_STEP = {
|
|
9
9
|
message: RELEASE.uploadApp,
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {object} param0
|
|
13
|
-
* @param {import('../../lib/api').Api} param0.api
|
|
14
|
-
* @param {import('../../lib/manifest').Manifest} param0.manifest
|
|
11
|
+
*
|
|
12
|
+
* @param {object} param0
|
|
13
|
+
* @param {import('../../lib/api').Api} param0.api
|
|
14
|
+
* @param {import('../../lib/manifest').Manifest} param0.manifest
|
|
15
15
|
*/
|
|
16
16
|
fn: async ({ zipFileName, manifest, api, dirName }) => {
|
|
17
17
|
const form = new FormData();
|
|
18
18
|
|
|
19
19
|
form.append('package', createReadStream(resolve(dirName, zipFileName)), 'package.zip');
|
|
20
20
|
|
|
21
|
-
const { id: packageId, status: uploadStatus } = await api.uploadPackages(
|
|
21
|
+
const { id: packageId, status: uploadStatus } = await api.uploadPackages(
|
|
22
|
+
manifest.manifest.application.key,
|
|
23
|
+
form
|
|
24
|
+
);
|
|
22
25
|
|
|
23
|
-
return { packageId }
|
|
26
|
+
return { packageId };
|
|
24
27
|
},
|
|
25
28
|
};
|
|
@@ -9,13 +9,13 @@ export const WAIT_FOR_BUILD_FINISH_STEP = {
|
|
|
9
9
|
message: 'Wait till the app will process to draft status...',
|
|
10
10
|
/**
|
|
11
11
|
* @param {object} param0
|
|
12
|
-
* @param {import('../../lib/api').Api} param0.api
|
|
12
|
+
* @param {import('../../lib/api').Api} param0.api
|
|
13
13
|
*/
|
|
14
14
|
async fn({ api, appId, packageId, progress }) {
|
|
15
15
|
do {
|
|
16
16
|
const { status } = await api.checkApp(appId, packageId);
|
|
17
17
|
|
|
18
|
-
progress()
|
|
18
|
+
progress();
|
|
19
19
|
|
|
20
20
|
debug(`Status: ${status}`);
|
|
21
21
|
|
|
@@ -25,5 +25,5 @@ export const WAIT_FOR_BUILD_FINISH_STEP = {
|
|
|
25
25
|
|
|
26
26
|
await waitForMs(5000);
|
|
27
27
|
} while (true);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -6,9 +6,9 @@ import { logger } from '../../../helpers/logger.js';
|
|
|
6
6
|
export const CREATE_TASK_STEP = {
|
|
7
7
|
message: 'Creating tasks...',
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @param {object} param0
|
|
11
|
-
* @param {import('../../lib/api').Api} param0.api
|
|
9
|
+
*
|
|
10
|
+
* @param {object} param0
|
|
11
|
+
* @param {import('../../lib/api').Api} param0.api
|
|
12
12
|
*/
|
|
13
13
|
fn: async ({
|
|
14
14
|
app,
|
|
@@ -22,9 +22,7 @@ export const CREATE_TASK_STEP = {
|
|
|
22
22
|
CORVA_API_ENV,
|
|
23
23
|
}) => {
|
|
24
24
|
if (!assets.length) {
|
|
25
|
-
logger.write(
|
|
26
|
-
`\n\n${chalk.yellow.bold('There is no asset ID to create a new task')}`
|
|
27
|
-
);
|
|
25
|
+
logger.write(`\n\n${chalk.yellow.bold('There is no asset ID to create a new task')}`);
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
for (const assetId of assets) {
|
|
@@ -41,14 +39,12 @@ export const CREATE_TASK_STEP = {
|
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
try {
|
|
44
|
-
const result = await api
|
|
45
|
-
app.id,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
streamId,
|
|
51
|
-
).catch(e => { console.log(e.response.body); throw e });
|
|
42
|
+
const result = await api
|
|
43
|
+
.queueAppRun(app.id, version, interval, wellId, appDatasetsNames, streamId)
|
|
44
|
+
.catch((e) => {
|
|
45
|
+
console.log(e.response.body);
|
|
46
|
+
throw e;
|
|
47
|
+
});
|
|
52
48
|
|
|
53
49
|
logger.write(
|
|
54
50
|
`\n Created a new task with ID ${chalk.yellow(result.id)} for asset ID - ${chalk.green(
|
|
@@ -57,7 +53,8 @@ export const CREATE_TASK_STEP = {
|
|
|
57
53
|
);
|
|
58
54
|
|
|
59
55
|
logger.write(
|
|
60
|
-
`\n Task link - https://app${
|
|
56
|
+
`\n Task link - https://app${
|
|
57
|
+
CORVA_API_ENV === 'production' ? '.' : `.${CORVA_API_ENV}.`
|
|
61
58
|
}corva.ai/dev-center/apps/${app.id}/runner`
|
|
62
59
|
);
|
|
63
60
|
} catch (e) {
|
|
@@ -7,11 +7,11 @@ import { logger } from '../../../helpers/logger.js';
|
|
|
7
7
|
export const ENSURE_APP_IN_STREAM_TASK_STEP = {
|
|
8
8
|
message: 'Ensure that app in the stream...',
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {object} context
|
|
10
|
+
*
|
|
11
|
+
* @param {object} context
|
|
12
12
|
*/
|
|
13
13
|
fn: async (context) => {
|
|
14
|
-
const {mappedAssetsToStreams, app, api, manifest } = context;
|
|
14
|
+
const { mappedAssetsToStreams, app, api, manifest } = context;
|
|
15
15
|
|
|
16
16
|
await Promise.all(
|
|
17
17
|
[...mappedAssetsToStreams].map(([assetId, stream]) => {
|
|
@@ -23,29 +23,37 @@ export const ENSURE_APP_IN_STREAM_TASK_STEP = {
|
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Ensure if the app is in the stream, if no, add app to the stream
|
|
28
|
+
*
|
|
29
|
+
* @param {string} assetId
|
|
30
|
+
* @param {object} stream
|
|
31
|
+
* @param {string} appId
|
|
32
|
+
* @param {import('../lib/api').Api} api
|
|
33
33
|
* @param {object} manifest
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const newConnection = await api.connectAppToStream(appId, stream.id, manifest.settings.app);
|
|
47
|
-
|
|
34
|
+
*
|
|
35
|
+
* @returns {void}
|
|
36
|
+
*/
|
|
37
|
+
const ensureAppIsInTheStream = async (assetId, stream, appId, api, manifest) => {
|
|
38
|
+
const connectedApp = stream.app_connections.find(
|
|
39
|
+
(connection) => connection.app_id === parseInt(appId)
|
|
40
|
+
);
|
|
41
|
+
if (connectedApp) {
|
|
48
42
|
logger.write(
|
|
49
|
-
`\n\n${chalk.black.underline.bold(
|
|
43
|
+
`\n\n${chalk.black.underline.bold(
|
|
44
|
+
`App has been already connected to the stream ID: ${stream.id}, for asset ID: ${assetId}`
|
|
45
|
+
)}`
|
|
50
46
|
);
|
|
47
|
+
return;
|
|
51
48
|
}
|
|
49
|
+
|
|
50
|
+
const newConnection = await api.connectAppToStream(appId, stream.id, manifest.settings.app);
|
|
51
|
+
|
|
52
|
+
logger.write(
|
|
53
|
+
`\n\n${chalk.black.underline.bold(
|
|
54
|
+
`Added app to the stream, connect ID - ${chalk.green(
|
|
55
|
+
newConnection.id
|
|
56
|
+
)}, for asset ID: ${assetId}`
|
|
57
|
+
)}`
|
|
58
|
+
);
|
|
59
|
+
};
|
|
@@ -7,18 +7,18 @@ import { logger } from '../../../helpers/logger.js';
|
|
|
7
7
|
export const GET_APP_VERSION_TASK_STEP = {
|
|
8
8
|
message: 'Get app version...',
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {object} context
|
|
10
|
+
*
|
|
11
|
+
* @param {object} context
|
|
12
12
|
*/
|
|
13
13
|
fn: async (context) => {
|
|
14
|
-
const {app, options, api } = context;
|
|
14
|
+
const { app, options, api } = context;
|
|
15
15
|
const { appVersion } = options;
|
|
16
16
|
|
|
17
17
|
const currentAppVersion = await getAppVersion(app.id, appVersion, api);
|
|
18
18
|
|
|
19
19
|
return {
|
|
20
20
|
...context,
|
|
21
|
-
version: currentAppVersion
|
|
21
|
+
version: currentAppVersion,
|
|
22
22
|
};
|
|
23
23
|
},
|
|
24
24
|
};
|
|
@@ -32,7 +32,7 @@ export const GET_APP_VERSION_TASK_STEP = {
|
|
|
32
32
|
*
|
|
33
33
|
* @returns {Promise<{number}>}
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
const getAppVersion = async (appId, optionAppVersion, api) => {
|
|
36
36
|
logger.write('\n Checking app versions...');
|
|
37
37
|
const appPackages = await api.getAppPackages(appId);
|
|
38
38
|
|
|
@@ -41,14 +41,14 @@ export const GET_APP_VERSION_TASK_STEP = {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const confirmUseVersionMessage = (version) => {
|
|
44
|
-
logger.write(
|
|
45
|
-
`\n\n${chalk.black.underline.bold(`Use app version - ${chalk.green(version)}`)}`
|
|
46
|
-
);
|
|
44
|
+
logger.write(`\n\n${chalk.black.underline.bold(`Use app version - ${chalk.green(version)}`)}`);
|
|
47
45
|
};
|
|
48
46
|
|
|
49
47
|
// try to get version from CLI option
|
|
50
48
|
if (optionAppVersion) {
|
|
51
|
-
const currentAppPackageByOption = appPackages.find(
|
|
49
|
+
const currentAppPackageByOption = appPackages.find(
|
|
50
|
+
(appPackage) => appPackage.attributes.version == optionAppVersion
|
|
51
|
+
);
|
|
52
52
|
if (currentAppPackageByOption) {
|
|
53
53
|
const version = currentAppPackageByOption.attributes.version;
|
|
54
54
|
confirmUseVersionMessage(version);
|
|
@@ -56,7 +56,9 @@ export const GET_APP_VERSION_TASK_STEP = {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
logger.write(
|
|
59
|
-
`\n\n${chalk.black.underline.bold(
|
|
59
|
+
`\n\n${chalk.black.underline.bold(
|
|
60
|
+
`Could not find app version - ${chalk.green(optionAppVersion)}`
|
|
61
|
+
)}`
|
|
60
62
|
);
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -73,9 +75,9 @@ export const GET_APP_VERSION_TASK_STEP = {
|
|
|
73
75
|
value: appPackage.attributes.version,
|
|
74
76
|
name: appPackage.attributes.version,
|
|
75
77
|
};
|
|
76
|
-
})
|
|
78
|
+
});
|
|
77
79
|
|
|
78
|
-
logger.log('\n')
|
|
80
|
+
logger.log('\n');
|
|
79
81
|
|
|
80
82
|
return inquirer
|
|
81
83
|
.prompt([
|
|
@@ -52,7 +52,7 @@ export const PREPARE_DATA_TASK_STEP = {
|
|
|
52
52
|
options,
|
|
53
53
|
manifest,
|
|
54
54
|
appDatasetsNames,
|
|
55
|
-
interval: getInterval(manifest.manifest, interval)
|
|
55
|
+
interval: getInterval(manifest.manifest, interval),
|
|
56
56
|
};
|
|
57
57
|
},
|
|
58
58
|
};
|
|
@@ -63,7 +63,7 @@ export const PREPARE_DATA_TASK_STEP = {
|
|
|
63
63
|
* @returns
|
|
64
64
|
*/
|
|
65
65
|
const promptAreYouSure = async () => {
|
|
66
|
-
logger.log('\n')
|
|
66
|
+
logger.log('\n');
|
|
67
67
|
const answers = await inquirer.prompt([
|
|
68
68
|
{
|
|
69
69
|
message:
|
|
@@ -122,17 +122,15 @@ const getExistAppRuns = async (appId, assets, appDatasetsNames, api) => {
|
|
|
122
122
|
*
|
|
123
123
|
* @returns {number | null}
|
|
124
124
|
*/
|
|
125
|
-
|
|
125
|
+
const getInterval = (manifest, intervalOption) => {
|
|
126
126
|
if (manifest.application.type !== 'scheduler') {
|
|
127
127
|
return null;
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
|
|
130
130
|
const DEFAULT_INTERVAL = 3600;
|
|
131
131
|
const interval = intervalOption || DEFAULT_INTERVAL;
|
|
132
132
|
|
|
133
|
-
logger.write(
|
|
134
|
-
`\n\n${chalk.black.underline.bold(`Use interval - ${chalk.green(interval)}`)}`
|
|
135
|
-
);
|
|
133
|
+
logger.write(`\n\n${chalk.black.underline.bold(`Use interval - ${chalk.green(interval)}`)}`);
|
|
136
134
|
|
|
137
135
|
return parseInt(interval);
|
|
138
|
-
|
|
136
|
+
};
|
|
@@ -7,15 +7,15 @@ import { logger } from '../../../helpers/logger.js';
|
|
|
7
7
|
export const PREPARE_WELL_AND_STREAM_TASK_STEP = {
|
|
8
8
|
message: 'Prepare well and stream data...',
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {object} context
|
|
10
|
+
*
|
|
11
|
+
* @param {object} context
|
|
12
12
|
*/
|
|
13
13
|
fn: async (context) => {
|
|
14
14
|
let { assets } = context;
|
|
15
|
-
const { api } = context;
|
|
15
|
+
const { api, manifest } = context;
|
|
16
16
|
|
|
17
17
|
const { mappedAssetsToWells, mappedAssetsToStreams, assetsToDelete } =
|
|
18
|
-
await prepareWellAndStreamData(assets, api);
|
|
18
|
+
await prepareWellAndStreamData(assets, api, manifest);
|
|
19
19
|
|
|
20
20
|
if (assetsToDelete.length) {
|
|
21
21
|
// remove asset ID if could not found stream or well
|
|
@@ -26,7 +26,7 @@ export const PREPARE_WELL_AND_STREAM_TASK_STEP = {
|
|
|
26
26
|
...context,
|
|
27
27
|
assets,
|
|
28
28
|
mappedAssetsToStreams,
|
|
29
|
-
mappedAssetsToWells
|
|
29
|
+
mappedAssetsToWells,
|
|
30
30
|
};
|
|
31
31
|
},
|
|
32
32
|
};
|
|
@@ -36,11 +36,9 @@ export const PREPARE_WELL_AND_STREAM_TASK_STEP = {
|
|
|
36
36
|
*
|
|
37
37
|
* @param {object[]} streams
|
|
38
38
|
*
|
|
39
|
-
* @returns
|
|
39
|
+
* @returns {Promise<object>}
|
|
40
40
|
*/
|
|
41
|
-
|
|
42
|
-
let stream = {};
|
|
43
|
-
|
|
41
|
+
const getStreamWithPrompt = async (streams) => {
|
|
44
42
|
const choices = streams.map((stream) => {
|
|
45
43
|
return {
|
|
46
44
|
value: stream,
|
|
@@ -49,7 +47,7 @@ export const PREPARE_WELL_AND_STREAM_TASK_STEP = {
|
|
|
49
47
|
});
|
|
50
48
|
|
|
51
49
|
if (!choices.length) {
|
|
52
|
-
throw new Error('No completed streams')
|
|
50
|
+
throw new Error('No completed streams');
|
|
53
51
|
}
|
|
54
52
|
|
|
55
53
|
if (choices.length === 1) {
|
|
@@ -58,12 +56,12 @@ export const PREPARE_WELL_AND_STREAM_TASK_STEP = {
|
|
|
58
56
|
logger.write(
|
|
59
57
|
`\n\n${chalk.black.underline.bold(`Process stream - ${chalk.green(stream.name)}`)}`
|
|
60
58
|
);
|
|
61
|
-
return stream.value
|
|
59
|
+
return stream.value;
|
|
62
60
|
}
|
|
63
61
|
|
|
64
|
-
logger.log('\n')
|
|
62
|
+
logger.log('\n');
|
|
65
63
|
|
|
66
|
-
|
|
64
|
+
return inquirer
|
|
67
65
|
.prompt([
|
|
68
66
|
{
|
|
69
67
|
message: 'Please choose stream?',
|
|
@@ -72,11 +70,7 @@ export const PREPARE_WELL_AND_STREAM_TASK_STEP = {
|
|
|
72
70
|
choices,
|
|
73
71
|
},
|
|
74
72
|
])
|
|
75
|
-
.then((answers) =>
|
|
76
|
-
stream = answers.option;
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
return stream;
|
|
73
|
+
.then((answers) => answers.option);
|
|
80
74
|
};
|
|
81
75
|
|
|
82
76
|
/**
|
|
@@ -85,11 +79,9 @@ export const PREPARE_WELL_AND_STREAM_TASK_STEP = {
|
|
|
85
79
|
* @param {object[]} wells
|
|
86
80
|
* @param {import('../lib/api').Api} api
|
|
87
81
|
*
|
|
88
|
-
* @returns
|
|
82
|
+
* @returns {Promise<object>}
|
|
89
83
|
*/
|
|
90
84
|
const getWellWithPrompt = async (wells, api) => {
|
|
91
|
-
let well = {};
|
|
92
|
-
|
|
93
85
|
const choices = await Promise.all(
|
|
94
86
|
wells.map(async (well) => {
|
|
95
87
|
const assetDetails = await api.getAssetById(well.data.attributes.asset_id);
|
|
@@ -108,15 +100,13 @@ const getWellWithPrompt = async (wells, api) => {
|
|
|
108
100
|
if (choices.length === 1) {
|
|
109
101
|
const [well] = choices;
|
|
110
102
|
|
|
111
|
-
logger.write(
|
|
112
|
-
|
|
113
|
-
);
|
|
114
|
-
return well.value
|
|
103
|
+
logger.write(`\n\n${chalk.black.underline.bold(`Process well - ${chalk.green(well.name)}`)}`);
|
|
104
|
+
return well.value;
|
|
115
105
|
}
|
|
116
106
|
|
|
117
|
-
logger.log('\n')
|
|
107
|
+
logger.log('\n');
|
|
118
108
|
|
|
119
|
-
|
|
109
|
+
return inquirer
|
|
120
110
|
.prompt([
|
|
121
111
|
{
|
|
122
112
|
message: 'Please choose the well?',
|
|
@@ -125,24 +115,19 @@ const getWellWithPrompt = async (wells, api) => {
|
|
|
125
115
|
choices,
|
|
126
116
|
},
|
|
127
117
|
])
|
|
128
|
-
.then((answers) =>
|
|
129
|
-
well = answers.option;
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
return well;
|
|
118
|
+
.then((answers) => answers.option);
|
|
133
119
|
};
|
|
134
120
|
|
|
135
121
|
/**
|
|
136
122
|
* Get stream and well data for assets
|
|
137
123
|
*
|
|
138
124
|
* @param {string[]} assets
|
|
139
|
-
* @param {string} appId
|
|
140
125
|
* @param {import('../lib/api').Api} api
|
|
141
126
|
* @param {object} manifest
|
|
142
127
|
*
|
|
143
|
-
* @returns {object}
|
|
128
|
+
* @returns {Promise<object>}
|
|
144
129
|
*/
|
|
145
|
-
const prepareWellAndStreamData = async (assets, api) => {
|
|
130
|
+
const prepareWellAndStreamData = async (assets, api, manifest) => {
|
|
146
131
|
const mappedAssetsToWells = new Map();
|
|
147
132
|
const mappedAssetsToStreams = new Map();
|
|
148
133
|
const assetsToDelete = [];
|
|
@@ -161,7 +146,15 @@ const prepareWellAndStreamData = async (assets, api) => {
|
|
|
161
146
|
|
|
162
147
|
logger.write('\n Loading streams...');
|
|
163
148
|
|
|
164
|
-
const streams = await api.
|
|
149
|
+
const streams = await api.getStreamsByAssetIds(
|
|
150
|
+
[assetId],
|
|
151
|
+
manifest.manifest.application.segments
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
if (!streams.length) {
|
|
155
|
+
throw new Error(`Could not found streams for asset ID - ${assetId}`);
|
|
156
|
+
}
|
|
157
|
+
|
|
165
158
|
const stream = await getStreamWithPrompt(streams);
|
|
166
159
|
mappedAssetsToStreams.set(stream.asset_id, stream);
|
|
167
160
|
} catch (e) {
|
|
@@ -5,9 +5,9 @@ import { ENSURE_APP_IN_STREAM_TASK_STEP } from './ensure-that-app-in-stream.js';
|
|
|
5
5
|
import { PREPARE_WELL_AND_STREAM_TASK_STEP } from './prepare-well-and-stream-data.js';
|
|
6
6
|
|
|
7
7
|
export const RERUN_STEPS = [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
PREPARE_DATA_TASK_STEP,
|
|
9
|
+
GET_APP_VERSION_TASK_STEP,
|
|
10
|
+
PREPARE_WELL_AND_STREAM_TASK_STEP,
|
|
11
|
+
ENSURE_APP_IN_STREAM_TASK_STEP,
|
|
12
|
+
CREATE_TASK_STEP,
|
|
13
13
|
];
|
package/lib/helpers/logger.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
export class Logger {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
write(str) {
|
|
7
|
-
if (this.isSilent) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
2
|
+
constructor() {
|
|
3
|
+
this.isSilent = process.argv.includes('--silent');
|
|
4
|
+
}
|
|
10
5
|
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
write(str) {
|
|
7
|
+
if (this.isSilent) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
if (str === undefined) {
|
|
12
|
+
process.stdout.write();
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
return;
|
|
18
15
|
}
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
17
|
+
process.stdout.write(str);
|
|
18
|
+
}
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
log(str) {
|
|
21
|
+
if (this.isSilent) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
if (str === undefined) {
|
|
26
|
+
console.log();
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
return;
|
|
32
29
|
}
|
|
30
|
+
|
|
31
|
+
console.log(str);
|
|
32
|
+
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export const logger = new Logger();
|