@corva/create-app 0.40.0-0 → 0.41.0-1
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 +19 -17
- package/bin/cca.js +5 -0
- package/bin/create-corva-app.cjs +14 -0
- package/lib/bump-version.option.js +17 -8
- package/lib/constants/cli.js +5 -11
- package/lib/constants/manifest.js +15 -22
- package/lib/constants/messages.js +4 -10
- package/lib/constants/package.js +6 -8
- package/lib/flow.js +16 -13
- package/lib/flows/lib/api.js +153 -84
- package/lib/flows/lib/create-zip-archive.js +7 -7
- package/lib/flows/lib/json.js +8 -8
- package/lib/flows/lib/manifest.js +5 -7
- package/lib/flows/lib/step-error.js +1 -3
- package/lib/flows/prepare.js +2 -4
- package/lib/flows/release.js +18 -10
- package/lib/flows/rerun.js +5 -7
- package/lib/flows/steps/prepare-load-app-files.js +3 -7
- package/lib/flows/steps/release/add-label.js +11 -0
- package/lib/flows/steps/release/add-notes.js +10 -0
- package/lib/flows/steps/release/get-config.js +37 -0
- package/lib/flows/steps/release/prepare-data.js +10 -0
- package/lib/flows/steps/release/publish.js +9 -0
- package/lib/flows/steps/release/remove-failed-upload.js +20 -0
- package/lib/flows/steps/release/upload-zip-to-corva.js +25 -0
- package/lib/flows/steps/release/wait-for-build.js +29 -0
- package/lib/flows/steps/rerun-create-task.js +22 -15
- package/lib/flows/steps/rerun-prepare-data.js +150 -127
- package/lib/flows/steps/rerun.js +3 -7
- package/lib/flows/steps/zip-cleanup.js +6 -6
- package/lib/flows/steps/zip-create-archive.js +5 -5
- package/lib/flows/steps/zip-file-list-resolve.js +34 -29
- package/lib/flows/steps/zip-prepare.js +7 -8
- package/lib/flows/steps/zip.js +5 -9
- package/lib/flows/zip-simple.js +2 -4
- package/lib/flows/zip.js +3 -5
- package/lib/helpers/logger.js +35 -0
- package/lib/helpers/manifest.js +6 -10
- package/lib/helpers/resolve-app-runtime.js +47 -45
- package/lib/helpers/utils.js +4 -9
- package/lib/helpers/versioning.js +8 -13
- package/lib/{index.js → main.js} +118 -116
- package/lib/scripts/utils/version.js +12 -13
- package/package.json +5 -3
- package/bin/create-corva-app.js +0 -5
- package/lib/app.js +0 -9
- package/lib/flows/steps/release-get-app-key.js +0 -16
- package/lib/flows/steps/release-get-config.js +0 -37
- package/lib/flows/steps/release-upload-zip-to-corva.js +0 -25
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import { logger } from '../../helpers/logger.js';
|
|
5
|
+
|
|
6
|
+
export const CREATE_TASK_STEP = {
|
|
5
7
|
message: 'Creating tasks...',
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {object} param0
|
|
11
|
+
* @param {import('../lib/api').Api} param0.api
|
|
12
|
+
*/
|
|
6
13
|
fn: async ({
|
|
7
14
|
appId,
|
|
8
15
|
assets,
|
|
@@ -14,38 +21,38 @@ const CREATE_TASK_STEP = {
|
|
|
14
21
|
CORVA_API_ENV,
|
|
15
22
|
}) => {
|
|
16
23
|
if (!assets.length) {
|
|
17
|
-
|
|
24
|
+
logger.write(
|
|
18
25
|
`\n\n${chalk.yellow.bold('There is not a asset ID to create new task')}`
|
|
19
26
|
);
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
for (const assetId of assets) {
|
|
23
|
-
|
|
24
30
|
try {
|
|
25
31
|
const result = await api.queueAppRun(
|
|
26
32
|
appId,
|
|
27
33
|
version,
|
|
28
|
-
|
|
34
|
+
assetId,
|
|
29
35
|
appDatasetsNames,
|
|
30
36
|
mappedAssetsToStreams.get(parseInt(assetId))
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
).catch(e => { console.log(e.response.body); throw e });
|
|
38
|
+
|
|
39
|
+
logger.write(
|
|
34
40
|
`\n Created new task with ID ${chalk.yellow(result.id)} for asset ID - ${chalk.green(
|
|
35
41
|
assetId
|
|
36
42
|
)}`
|
|
37
43
|
);
|
|
38
44
|
|
|
39
|
-
|
|
40
|
-
`\n Task link - https://app${CORVA_API_ENV === 'production' ? '.' : `.${CORVA_API_ENV}.`
|
|
45
|
+
logger.write(
|
|
46
|
+
`\n Task link - https://app${CORVA_API_ENV === 'production' ? '.' : `.${CORVA_API_ENV}.`
|
|
47
|
+
}corva.ai/dev-center/apps/${appId}/runner`
|
|
41
48
|
);
|
|
42
49
|
} catch (e) {
|
|
43
|
-
|
|
44
|
-
`\n\n${chalk.red.underline.bold(
|
|
50
|
+
logger.write(
|
|
51
|
+
`\n\n${chalk.red.underline.bold(
|
|
52
|
+
`Could not rerun app for asset ID - ${assetId}, an error occured: ${e.message}`
|
|
53
|
+
)}\n\n`
|
|
45
54
|
);
|
|
46
55
|
}
|
|
47
56
|
}
|
|
48
57
|
},
|
|
49
58
|
};
|
|
50
|
-
|
|
51
|
-
module.exports = { CREATE_TASK_STEP };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { StepError } from '../lib/step-error.js';
|
|
5
|
+
import { logger } from '../../helpers/logger.js';
|
|
6
6
|
|
|
7
7
|
const MAX_ASSET_IDS_COUNT = 10;
|
|
8
8
|
|
|
9
|
-
const PREPARE_DATA_STEP = {
|
|
9
|
+
export const PREPARE_DATA_STEP = {
|
|
10
10
|
message: 'Preparing data for tasks...',
|
|
11
11
|
fn: async (context) => {
|
|
12
|
-
const { manifest,
|
|
13
|
-
let { assets } =
|
|
12
|
+
const { manifest, options, api, pkg } = context;
|
|
13
|
+
let { assets } = options;
|
|
14
14
|
|
|
15
15
|
assets = _.uniq(assets);
|
|
16
16
|
|
|
@@ -22,12 +22,10 @@ const PREPARE_DATA_STEP = {
|
|
|
22
22
|
throw new StepError('Rerun command supports only "scheduler" or "stream" apps');
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
if (!await promptAreYouSure()) {
|
|
25
|
+
if (!(await promptAreYouSure())) {
|
|
26
26
|
throw new StepError('Command stopped');
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const api = new Api(CORVA_API_ENV, API_KEY);
|
|
30
|
-
|
|
31
29
|
const app = await api.getAppByKey(manifest.manifest.application.key.toLowerCase());
|
|
32
30
|
const appDatasets = await api.getAppDatasetsOperationWrite(app.id);
|
|
33
31
|
const appDatasetsNames = appDatasets.map((dataset) => dataset.attributes.dataset_name);
|
|
@@ -40,13 +38,16 @@ const PREPARE_DATA_STEP = {
|
|
|
40
38
|
|
|
41
39
|
const run = existingAppRuns.get(appRunAssetId);
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
`\n\n${chalk.yellow.bold(
|
|
41
|
+
logger.write(
|
|
42
|
+
`\n\n${chalk.yellow.bold(
|
|
43
|
+
`Similar rerun with ID ${run.id}, for asset ID ${appRunAssetId} - already exist. Will be skipped!`
|
|
44
|
+
)}`
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const {mappedAssetsToWells, mappedAssetsToStreams, assetsToDelete} =
|
|
49
|
+
const { mappedAssetsToWells, mappedAssetsToStreams, assetsToDelete } =
|
|
50
|
+
await prepareWellAndStreamData(assets, api);
|
|
50
51
|
|
|
51
52
|
if (assetsToDelete.length) {
|
|
52
53
|
// remove asset ID if could not found stream or well
|
|
@@ -59,8 +60,6 @@ const PREPARE_DATA_STEP = {
|
|
|
59
60
|
appDatasetsNames,
|
|
60
61
|
mappedAssetsToStreams,
|
|
61
62
|
mappedAssetsToWells,
|
|
62
|
-
api,
|
|
63
|
-
CORVA_API_ENV,
|
|
64
63
|
version: pkg.version,
|
|
65
64
|
};
|
|
66
65
|
},
|
|
@@ -71,145 +70,167 @@ const PREPARE_DATA_STEP = {
|
|
|
71
70
|
*
|
|
72
71
|
* @returns
|
|
73
72
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/**
|
|
73
|
+
const promptAreYouSure = async () => {
|
|
74
|
+
const answers = await inquirer.prompt([
|
|
75
|
+
{
|
|
76
|
+
message:
|
|
77
|
+
'\n This command will create additional load on the server, which may take a long time. \n Are you sure you want to do this?',
|
|
78
|
+
name: 'option',
|
|
79
|
+
type: 'list',
|
|
80
|
+
choices: [
|
|
81
|
+
{ value: true, name: 'Yes' },
|
|
82
|
+
{ value: false, name: 'No' },
|
|
83
|
+
],
|
|
84
|
+
default: false,
|
|
85
|
+
},
|
|
86
|
+
]);
|
|
87
|
+
return answers.option;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
93
91
|
* CLI prompt question - Please choose the stream
|
|
94
|
-
*
|
|
95
|
-
|
|
92
|
+
*
|
|
93
|
+
* @param {object[]} streams
|
|
96
94
|
*
|
|
97
95
|
* @returns
|
|
98
96
|
*/
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
const getStreamWithPrompt = async (streams) => {
|
|
98
|
+
let stream = {};
|
|
101
99
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
const choices = streams.map((stream) => {
|
|
101
|
+
return {
|
|
102
|
+
value: stream,
|
|
103
|
+
name: stream.name,
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
if (!choices.length) {
|
|
108
|
+
throw new Error('No completed streams')
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (choices.length === 1) {
|
|
112
|
+
const [stream] = choices;
|
|
113
|
+
|
|
114
|
+
logger.write(
|
|
115
|
+
`\n\n${chalk.black.underline.bold(`Process stream - ${chalk.green(stream.name)}`)}`
|
|
116
|
+
);
|
|
117
|
+
return stream.value
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
await inquirer
|
|
121
|
+
.prompt([
|
|
122
|
+
{
|
|
123
|
+
message: '\n Please choose stream?',
|
|
124
|
+
name: 'option',
|
|
125
|
+
type: 'list',
|
|
126
|
+
choices,
|
|
127
|
+
},
|
|
128
|
+
])
|
|
129
|
+
.then((answers) => {
|
|
130
|
+
stream = answers.option;
|
|
107
131
|
});
|
|
108
132
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
'\n Please choose stream?',
|
|
114
|
-
name: 'option',
|
|
115
|
-
type: 'list',
|
|
116
|
-
choices,
|
|
117
|
-
},
|
|
118
|
-
])
|
|
119
|
-
.then((answers) => {
|
|
120
|
-
stream = answers.option;
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
return stream;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
133
|
+
return stream;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
127
137
|
* CLI prompt question - Please choose the well
|
|
128
|
-
*
|
|
138
|
+
*
|
|
129
139
|
* @param {object[]} wells
|
|
130
|
-
* @param {
|
|
140
|
+
* @param {import('../lib/api').Api} api
|
|
131
141
|
*
|
|
132
142
|
* @returns
|
|
133
143
|
*/
|
|
134
|
-
|
|
135
|
-
|
|
144
|
+
const getWellWithPrompt = async (wells, api) => {
|
|
145
|
+
let well = {};
|
|
136
146
|
|
|
137
|
-
|
|
147
|
+
const choices = await Promise.all(
|
|
148
|
+
wells.map(async (well) => {
|
|
138
149
|
const assetDetails = await api.getAssetById(well.data.attributes.asset_id);
|
|
139
150
|
well.data.name = assetDetails.attributes.name;
|
|
140
151
|
return {
|
|
141
152
|
value: well.data,
|
|
142
153
|
name: well.data.name,
|
|
143
154
|
};
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
155
|
+
})
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
if (!choices.length) {
|
|
159
|
+
throw new Error('No wells found');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (choices.length === 1) {
|
|
163
|
+
const [well] = choices;
|
|
164
|
+
|
|
165
|
+
logger.write(
|
|
166
|
+
`\n\n${chalk.black.underline.bold(`Process well - ${chalk.green(well.name)}`)}`
|
|
167
|
+
);
|
|
168
|
+
return well.value
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
await inquirer
|
|
172
|
+
.prompt([
|
|
173
|
+
{
|
|
174
|
+
message: '\n Please choose the well?',
|
|
175
|
+
name: 'option',
|
|
176
|
+
type: 'list',
|
|
177
|
+
choices,
|
|
178
|
+
},
|
|
179
|
+
])
|
|
180
|
+
.then((answers) => {
|
|
181
|
+
well = answers.option;
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
return well;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
165
188
|
* Get stream and well data for assets
|
|
166
|
-
*
|
|
189
|
+
*
|
|
167
190
|
* @param {string[]} assets
|
|
168
|
-
* @param {
|
|
191
|
+
* @param {import('../lib/api').Api} api
|
|
169
192
|
*
|
|
170
193
|
* @returns {object}
|
|
171
194
|
*/
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
for (const assetId of assets) {
|
|
178
|
-
try {
|
|
179
|
-
process.stdout.write(
|
|
180
|
-
`\n\n${chalk.black.underline.bold(`Process asset ID - ${chalk.green(assetId)}`)}`
|
|
181
|
-
);
|
|
195
|
+
const prepareWellAndStreamData = async (assets, api) => {
|
|
196
|
+
const mappedAssetsToWells = new Map();
|
|
197
|
+
const mappedAssetsToStreams = new Map();
|
|
198
|
+
const assetsToDelete = [];
|
|
182
199
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
200
|
+
for (const assetId of assets) {
|
|
201
|
+
try {
|
|
202
|
+
logger.write(
|
|
203
|
+
`\n\n${chalk.black.underline.bold(`Process asset ID - ${chalk.green(assetId)}`)}`
|
|
204
|
+
);
|
|
186
205
|
|
|
187
|
-
|
|
188
|
-
const well = await getWellWithPrompt(wells, api);
|
|
189
|
-
mappedAssetsToWells.set(well.attributes.asset_id, well.id);
|
|
190
|
-
|
|
191
|
-
process.stdout.write(
|
|
192
|
-
'\n Loading streams...'
|
|
193
|
-
);
|
|
206
|
+
logger.write('\n Loading wells...');
|
|
194
207
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
} catch (e) {
|
|
199
|
-
process.stdout.write(
|
|
200
|
-
`\n\n${chalk.red.underline.bold(`Skipped the asset ID - ${assetId}, an error occured: ${e.message}`)}`
|
|
201
|
-
);
|
|
208
|
+
const wells = await api.getWellByAssetId(assetId);
|
|
209
|
+
const well = await getWellWithPrompt(wells, api);
|
|
210
|
+
mappedAssetsToWells.set(well.attributes.asset_id, well.id);
|
|
202
211
|
|
|
203
|
-
|
|
212
|
+
logger.write('\n Loading streams...');
|
|
204
213
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
214
|
+
const streams = await api.getStreamByAssetId(assetId);
|
|
215
|
+
const stream = await getStreamWithPrompt(streams);
|
|
216
|
+
mappedAssetsToStreams.set(stream.asset_id, stream.id);
|
|
217
|
+
} catch (e) {
|
|
218
|
+
logger.write(
|
|
219
|
+
`\n\n${chalk.red.underline.bold(
|
|
220
|
+
`Skipped the asset ID - ${assetId}, an error occured: ${e.message}`
|
|
221
|
+
)}`
|
|
222
|
+
);
|
|
209
223
|
|
|
210
|
-
|
|
224
|
+
assetsToDelete.push(assetId);
|
|
225
|
+
|
|
226
|
+
if (mappedAssetsToWells.has(assetId)) mappedAssetsToWells.delete(assetId);
|
|
227
|
+
if (mappedAssetsToStreams.has(assetId)) mappedAssetsToStreams.delete(assetId);
|
|
228
|
+
}
|
|
211
229
|
}
|
|
212
230
|
|
|
231
|
+
return { mappedAssetsToWells, mappedAssetsToStreams, assetsToDelete };
|
|
232
|
+
};
|
|
233
|
+
|
|
213
234
|
/**
|
|
214
235
|
* Check if current runs already exist
|
|
215
236
|
*
|
|
@@ -226,10 +247,14 @@ const getExistAppRuns = async (appId, assets, appDatasetsNames, api) => {
|
|
|
226
247
|
|
|
227
248
|
// go through all assets ids
|
|
228
249
|
for (const assetId of assets) {
|
|
229
|
-
const runsForCurrentAsset = existingAppRuns.filter(
|
|
250
|
+
const runsForCurrentAsset = existingAppRuns.filter(
|
|
251
|
+
(run) => run.attributes.well_asset_id == assetId
|
|
252
|
+
);
|
|
230
253
|
// go through all existing runs for current asset ID
|
|
231
254
|
for (const run of runsForCurrentAsset) {
|
|
232
|
-
const currentAppDatasetsNames = run.attributes.app_run_datasets.map(
|
|
255
|
+
const currentAppDatasetsNames = run.attributes.app_run_datasets.map(
|
|
256
|
+
(dataset) => dataset.name
|
|
257
|
+
);
|
|
233
258
|
// if datasets names matched for the same asset ID - then run already exist
|
|
234
259
|
if (appDatasetsNames.sort().toString() === currentAppDatasetsNames.sort().toString()) {
|
|
235
260
|
appRuns.set(assetId, run);
|
|
@@ -239,5 +264,3 @@ const getExistAppRuns = async (appId, assets, appDatasetsNames, api) => {
|
|
|
239
264
|
|
|
240
265
|
return appRuns;
|
|
241
266
|
};
|
|
242
|
-
|
|
243
|
-
module.exports = { PREPARE_DATA_STEP };
|
package/lib/flows/steps/rerun.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { PREPARE_DATA_STEP } from './rerun-prepare-data.js';
|
|
2
|
+
import { CREATE_TASK_STEP } from './rerun-create-task.js';
|
|
3
3
|
|
|
4
|
-
const RERUN_STEPS = [PREPARE_DATA_STEP, CREATE_TASK_STEP];
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
RERUN_STEPS,
|
|
8
|
-
};
|
|
4
|
+
export const RERUN_STEPS = [PREPARE_DATA_STEP, CREATE_TASK_STEP];
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import Debug from 'debug';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const debug = Debug('cca:flow:zip:cleanup');
|
|
7
|
+
|
|
8
|
+
export const CLEANUP_STEP = {
|
|
7
9
|
message: 'Removing temporary files...',
|
|
8
10
|
fn: async ({ itemsToRemove, dirName }) => {
|
|
9
11
|
for (const item of itemsToRemove) {
|
|
@@ -13,5 +15,3 @@ const CLEANUP_STEP = {
|
|
|
13
15
|
}
|
|
14
16
|
},
|
|
15
17
|
};
|
|
16
|
-
|
|
17
|
-
module.exports = { CLEANUP_STEP };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { createZipArchive } from '../lib/create-zip-archive.js';
|
|
2
|
+
import Debug from 'debug';
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const debug = Debug('cca:flow:zip:archive');
|
|
5
|
+
|
|
6
|
+
export const CREATE_ARCHIVE_STEP = {
|
|
5
7
|
message: 'Creating archive...',
|
|
6
8
|
fn: async ({ itemsToZip, zipFileName, dirName }) => {
|
|
7
9
|
debug(`Zipping %d items to %s`, itemsToZip.length, zipFileName);
|
|
@@ -11,5 +13,3 @@ const CREATE_ARCHIVE_STEP = {
|
|
|
11
13
|
debug(`Created %s with %d items (%d bytes)`, zipFileName, itemsToZip.length, bytes);
|
|
12
14
|
},
|
|
13
15
|
};
|
|
14
|
-
|
|
15
|
-
module.exports = { CREATE_ARCHIVE_STEP };
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import _ from 'lodash/fp.js';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { promises as fs } from 'node:fs';
|
|
4
|
+
import Glob from 'glob';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import isGlob from 'is-glob';
|
|
7
|
+
import { promisify } from 'node:util';
|
|
8
|
+
import { getIncreasedVersion } from '../../scripts/utils/version.js';
|
|
9
|
+
import { loadJson } from '../lib/json.js';
|
|
10
|
+
import { StepError } from '../lib/step-error.js';
|
|
11
11
|
|
|
12
12
|
const glob = promisify(Glob);
|
|
13
|
-
|
|
13
|
+
import Debug from 'debug';
|
|
14
|
+
|
|
15
|
+
const debug = Debug('cca:flow:zip:resolve');
|
|
14
16
|
|
|
15
17
|
const uniqueValues = (array) => Array.from(new Set(array));
|
|
16
18
|
|
|
17
|
-
const FILE_LIST_RESOLVE_STEP = {
|
|
19
|
+
export const FILE_LIST_RESOLVE_STEP = {
|
|
18
20
|
message: 'Resolving files list...',
|
|
19
21
|
fn: async (context) => {
|
|
20
22
|
const { patterns, manifest, dirName, options } = context;
|
|
@@ -65,11 +67,11 @@ const transformPatternsIntoFileNames = async (dirName, patterns, ignoredFiles =
|
|
|
65
67
|
};
|
|
66
68
|
|
|
67
69
|
/**
|
|
68
|
-
*
|
|
69
|
-
* @param {string[]} itemsToZip
|
|
70
|
-
* @param {object} param1
|
|
70
|
+
*
|
|
71
|
+
* @param {string[]} itemsToZip
|
|
72
|
+
* @param {object} param1
|
|
71
73
|
* @param {import('../lib/manifest').Manifest} param1.manifest
|
|
72
|
-
* @returns
|
|
74
|
+
* @returns
|
|
73
75
|
*/
|
|
74
76
|
const resolveDataToZipUiApp = async (itemsToZip = [], { options, pkg, dirName, manifest }) => {
|
|
75
77
|
const version = await getIncreasedVersion(pkg.version, options);
|
|
@@ -91,7 +93,7 @@ const resolveDataToZipUiApp = async (itemsToZip = [], { options, pkg, dirName, m
|
|
|
91
93
|
|
|
92
94
|
itemsToSave.push({
|
|
93
95
|
name: 'packageForSource.json',
|
|
94
|
-
content: set(
|
|
96
|
+
content: _.set(
|
|
95
97
|
'scripts',
|
|
96
98
|
{
|
|
97
99
|
build: 'webpack --config=./config-overrides.js --mode production',
|
|
@@ -122,11 +124,11 @@ const resolveDataToZipUiApp = async (itemsToZip = [], { options, pkg, dirName, m
|
|
|
122
124
|
};
|
|
123
125
|
|
|
124
126
|
/**
|
|
125
|
-
*
|
|
126
|
-
* @param {string[]} itemsToZip
|
|
127
|
-
* @param {object} param1
|
|
127
|
+
*
|
|
128
|
+
* @param {string[]} itemsToZip
|
|
129
|
+
* @param {object} param1
|
|
128
130
|
* @param {import('../lib/manifest').Manifest} param1.manifest
|
|
129
|
-
* @returns
|
|
131
|
+
* @returns
|
|
130
132
|
*/
|
|
131
133
|
const resolveDataForZipNodeJsApp = async (itemsToZip = [], { options, pkg, dirName, manifest }) => {
|
|
132
134
|
const version = await getIncreasedVersion(pkg.version, options);
|
|
@@ -157,7 +159,7 @@ const resolveDataForZipNodeJsApp = async (itemsToZip = [], { options, pkg, dirNa
|
|
|
157
159
|
if (shouldUpdateVersion) {
|
|
158
160
|
itemsToSave.push({
|
|
159
161
|
name: 'package-lock.json',
|
|
160
|
-
content: set('version', version, await loadJson(dirName, 'package-lock.json')),
|
|
162
|
+
content: _.set('version', version, await loadJson(dirName, 'package-lock.json')),
|
|
161
163
|
});
|
|
162
164
|
}
|
|
163
165
|
} else if (packageDirContent.includes('yarn.lock')) {
|
|
@@ -191,17 +193,22 @@ const resolveDataForZipNodeJsApp = async (itemsToZip = [], { options, pkg, dirNa
|
|
|
191
193
|
};
|
|
192
194
|
|
|
193
195
|
/**
|
|
194
|
-
*
|
|
195
|
-
* @param {string[]} itemsToZip
|
|
196
|
-
* @param {object} param1
|
|
196
|
+
*
|
|
197
|
+
* @param {string[]} itemsToZip
|
|
198
|
+
* @param {object} param1
|
|
197
199
|
* @param {import('../lib/manifest').Manifest} param1.manifest
|
|
198
|
-
* @returns
|
|
200
|
+
* @returns
|
|
199
201
|
*/
|
|
200
202
|
const resolveDataForZipPythonApp = async (itemsToZip = [], { manifest, dirName, options }) => {
|
|
201
203
|
const zipFileName = `${manifest.unix_name}.zip`;
|
|
202
204
|
|
|
203
205
|
if (!itemsToZip.length) {
|
|
204
|
-
itemsToZip.push(
|
|
206
|
+
itemsToZip.push(
|
|
207
|
+
...(await glob('**/*.py', {
|
|
208
|
+
cwd: dirName,
|
|
209
|
+
ignore: [...(options.ignoredFiles || []), 'venv/**/*'],
|
|
210
|
+
}))
|
|
211
|
+
);
|
|
205
212
|
}
|
|
206
213
|
|
|
207
214
|
itemsToZip.push('manifest.json', 'requirements.txt');
|
|
@@ -213,5 +220,3 @@ const resolveDataForZipPythonApp = async (itemsToZip = [], { manifest, dirName,
|
|
|
213
220
|
itemsToRemove: [],
|
|
214
221
|
};
|
|
215
222
|
};
|
|
216
|
-
|
|
217
|
-
module.exports = { FILE_LIST_RESOLVE_STEP };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { saveJson } from '../lib/json.js';
|
|
2
|
+
import { logger } from '../../helpers/logger.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
import Debug from 'debug';
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
+
const debug = Debug('cca:flow:zip:prepare');
|
|
7
|
+
|
|
8
|
+
export const PREPARE_FILES_BEFORE_ZIP_STEP = {
|
|
6
9
|
message: 'Preparing...',
|
|
7
10
|
fn: async ({ itemsToSave, dirName }) => {
|
|
8
11
|
for (const item of itemsToSave) {
|
|
@@ -10,12 +13,8 @@ const PREPARE_FILES_BEFORE_ZIP_STEP = {
|
|
|
10
13
|
await saveJson(dirName, item.name, item.content);
|
|
11
14
|
|
|
12
15
|
if (item.message) {
|
|
13
|
-
|
|
16
|
+
logger.write(item.message);
|
|
14
17
|
}
|
|
15
18
|
}
|
|
16
19
|
},
|
|
17
20
|
};
|
|
18
|
-
|
|
19
|
-
module.exports = {
|
|
20
|
-
PREPARE_FILES_BEFORE_ZIP_STEP,
|
|
21
|
-
};
|
package/lib/flows/steps/zip.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { CLEANUP_STEP } from './zip-cleanup.js';
|
|
2
|
+
import { CREATE_ARCHIVE_STEP } from './zip-create-archive.js';
|
|
3
|
+
import { FILE_LIST_RESOLVE_STEP } from './zip-file-list-resolve.js';
|
|
4
|
+
import { PREPARE_FILES_BEFORE_ZIP_STEP } from './zip-prepare.js';
|
|
5
5
|
|
|
6
|
-
const ZIP_STEPS = [
|
|
6
|
+
export const ZIP_STEPS = [
|
|
7
7
|
FILE_LIST_RESOLVE_STEP,
|
|
8
8
|
PREPARE_FILES_BEFORE_ZIP_STEP,
|
|
9
9
|
CREATE_ARCHIVE_STEP,
|
|
10
10
|
CLEANUP_STEP,
|
|
11
11
|
];
|
|
12
|
-
|
|
13
|
-
module.exports = {
|
|
14
|
-
ZIP_STEPS,
|
|
15
|
-
};
|
package/lib/flows/zip-simple.js
CHANGED