@corva/create-app 0.45.0-rc.0 → 0.46.0-0-test-2f3568e
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 +1 -0
- package/lib/flows/steps/release/upload-zip-to-corva.js +32 -5
- package/lib/main.js +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -178,6 +178,7 @@ Options:
|
|
|
178
178
|
--remove-on-fail [boolean] Remove release if it fails during deployment (default: false)
|
|
179
179
|
--silent [boolean] Only log result of the operation (default: false)
|
|
180
180
|
--remove-on-success App package (.zip) will not be deleted after upload (default: true)
|
|
181
|
+
--remove-existing [boolean] If package version is already taken - remove the previous package and upload a new one (default: false)
|
|
181
182
|
```
|
|
182
183
|
|
|
183
184
|
### Examples
|
|
@@ -2,6 +2,20 @@ import FormData from 'form-data';
|
|
|
2
2
|
import { createReadStream } from 'node:fs';
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
import { RELEASE } from '../../../constants/messages.js';
|
|
5
|
+
import { StepError } from '../../lib/step-error.js';
|
|
6
|
+
|
|
7
|
+
async function deleteAppPackage({ api, appId, appPkgVersion }) {
|
|
8
|
+
const appPackages = await api.getAppPackages(appId);
|
|
9
|
+
const packageToDelete = appPackages.find(
|
|
10
|
+
(appPackage) => appPackage.attributes.package_code_version === appPkgVersion,
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
if (!packageToDelete) {
|
|
14
|
+
throw new StepError('Failed to remove the package with the same version');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
await api.deleteAppUpload(appId, packageToDelete?.id);
|
|
18
|
+
}
|
|
5
19
|
|
|
6
20
|
export const UPLOAD_ZIP_TO_CORVA_STEP = {
|
|
7
21
|
message: RELEASE.uploadApp,
|
|
@@ -11,13 +25,26 @@ export const UPLOAD_ZIP_TO_CORVA_STEP = {
|
|
|
11
25
|
* @param {import('../../lib/api').Api} param0.api
|
|
12
26
|
* @param {import('../../lib/manifest').Manifest} param0.manifest
|
|
13
27
|
*/
|
|
14
|
-
fn: async ({ zipFileName, manifest, api, dirName }) => {
|
|
15
|
-
|
|
28
|
+
fn: async ({ zipFileName, manifest, api, appId, dirName, options, pkg }) => {
|
|
29
|
+
async function uploadAppPackage() {
|
|
30
|
+
const form = new FormData();
|
|
31
|
+
form.append('package', createReadStream(resolve(dirName, zipFileName)), 'package.zip');
|
|
32
|
+
|
|
33
|
+
const { id: packageId } = await api.uploadPackages(manifest.manifest.application.key, form);
|
|
34
|
+
|
|
35
|
+
return { packageId };
|
|
36
|
+
}
|
|
16
37
|
|
|
17
|
-
|
|
38
|
+
try {
|
|
39
|
+
return await uploadAppPackage();
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (error?.message?.includes('version has already been taken') && options.removeExisting) {
|
|
42
|
+
await deleteAppPackage({ api, appPkgVersion: pkg.version, appId });
|
|
18
43
|
|
|
19
|
-
|
|
44
|
+
return uploadAppPackage();
|
|
45
|
+
}
|
|
20
46
|
|
|
21
|
-
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
22
49
|
},
|
|
23
50
|
};
|
package/lib/main.js
CHANGED
|
@@ -207,6 +207,12 @@ export async function run() {
|
|
|
207
207
|
.addOption(
|
|
208
208
|
new Option('--remove-on-success [boolean]', 'App package (.zip) will not be deleted after upload').default(true),
|
|
209
209
|
)
|
|
210
|
+
.addOption(
|
|
211
|
+
new Option(
|
|
212
|
+
'--remove-existing [boolean]',
|
|
213
|
+
'If package version is already taken - remove the previously published package and upload a new one',
|
|
214
|
+
).default(false),
|
|
215
|
+
)
|
|
210
216
|
// .addOption(new Option('--zip-file-name [string]', 'Prebuilt zip file name in dir'))
|
|
211
217
|
.action(async (dirName, patterns, options) => {
|
|
212
218
|
options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
|