@corva/create-app 0.60.0-0 → 0.60.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/lib/commands/create.js +4 -9
- package/lib/flow.js +1 -1
- package/lib/flows/lib/api.js +2 -2
- package/lib/flows/lib/json.js +2 -1
- package/lib/flows/steps/release/remove-failed-upload.js +2 -1
- package/lib/flows/steps/rerun/get-app-version.js +2 -1
- package/lib/flows/steps/zip-file-list-resolve.js +1 -1
- package/lib/main.js +13 -4
- package/package.json +1 -1
package/lib/commands/create.js
CHANGED
|
@@ -23,7 +23,7 @@ import { getRealWorkingDir } from '../helpers/commands.js';
|
|
|
23
23
|
import { Manifest } from '../flows/lib/manifest.js';
|
|
24
24
|
import { fillManifest } from '../helpers/manifest.js';
|
|
25
25
|
import { getManifestMandatoryKeys, manifestOptions } from '../constants/manifest.js';
|
|
26
|
-
import {
|
|
26
|
+
import { StepError } from '../flows/lib/step-error.js';
|
|
27
27
|
|
|
28
28
|
const __filename = fileURLToPath(import.meta.url);
|
|
29
29
|
const __dirname = dirname(__filename);
|
|
@@ -36,12 +36,7 @@ const WRITE_TO_JSON_OPTS = {
|
|
|
36
36
|
export const createCommand = new Command('create')
|
|
37
37
|
.description('Create a new app')
|
|
38
38
|
.argument('[project-directory]', 'project directory to work with', process.argv[process.argv.length - 1])
|
|
39
|
-
.addOption(originalCwdOption)
|
|
40
|
-
.showHelpAfterError()
|
|
41
|
-
.showSuggestionAfterError(true)
|
|
42
|
-
.configureOutput({
|
|
43
|
-
outputError: (str, write) => write(chalk.red(`${ERROR_ICON} ${str}`)),
|
|
44
|
-
});
|
|
39
|
+
.addOption(originalCwdOption);
|
|
45
40
|
|
|
46
41
|
manifestOptions().forEach((value) => {
|
|
47
42
|
const type = value.commaSeparated ? 'string' : typeof value.default;
|
|
@@ -110,7 +105,7 @@ async function initPackage(projectName, opts) {
|
|
|
110
105
|
const runtime = resolveAppRuntime(opts);
|
|
111
106
|
|
|
112
107
|
if (!(await runtime.isRuntimeAvailable())) {
|
|
113
|
-
throw new
|
|
108
|
+
throw new StepError(
|
|
114
109
|
`Runtime "${opts.runtime}" is not available locally. Please proceed to ${chalk.green(
|
|
115
110
|
getEnvManagementLink(manifest),
|
|
116
111
|
)} to install it locally.`,
|
|
@@ -141,7 +136,7 @@ async function initPackage(projectName, opts) {
|
|
|
141
136
|
if (shouldCleanup) {
|
|
142
137
|
await fs.emptyDir(root);
|
|
143
138
|
} else {
|
|
144
|
-
throw new
|
|
139
|
+
throw new StepError(`Directory is not empty: ${root}`);
|
|
145
140
|
}
|
|
146
141
|
}
|
|
147
142
|
|
package/lib/flow.js
CHANGED
package/lib/flows/lib/api.js
CHANGED
|
@@ -50,7 +50,7 @@ export class Api {
|
|
|
50
50
|
const app = data.find((app) => app.attributes.app_key === appKey);
|
|
51
51
|
|
|
52
52
|
if (!app) {
|
|
53
|
-
throw new
|
|
53
|
+
throw new StepError(
|
|
54
54
|
`App with key - ${appKey}, does not exist.\nThe key search is case-sensitive. You might need to update the app key in your app to exactly match the key.`,
|
|
55
55
|
);
|
|
56
56
|
}
|
|
@@ -155,7 +155,7 @@ export class Api {
|
|
|
155
155
|
.json();
|
|
156
156
|
|
|
157
157
|
if (!wells || !wells.length) {
|
|
158
|
-
throw new
|
|
158
|
+
throw new StepError(`Could not found wells by asset ID - ${assetId}`);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
return wells;
|
package/lib/flows/lib/json.js
CHANGED
|
@@ -3,6 +3,7 @@ import os from 'node:os';
|
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
|
|
5
5
|
import debugFn from 'debug';
|
|
6
|
+
import { StepError } from './step-error.js';
|
|
6
7
|
|
|
7
8
|
const debug = debugFn('cca:json');
|
|
8
9
|
|
|
@@ -17,7 +18,7 @@ export const loadJson = async (dirName, fileName) => {
|
|
|
17
18
|
return JSON.parse(manifest);
|
|
18
19
|
} catch (e) {
|
|
19
20
|
if (e.code === 'ENOENT') {
|
|
20
|
-
throw new
|
|
21
|
+
throw new StepError(`${fileName} was not found in ${resolve(dirName)}`, { cause: e });
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
throw e;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
import { unlink } from 'node:fs/promises';
|
|
3
|
+
import { StepError } from '../../lib/step-error.js';
|
|
3
4
|
|
|
4
5
|
export const REMOVE_FAILED_UPLOAD_STEP = {
|
|
5
6
|
message: 'Cleaning up...',
|
|
@@ -15,6 +16,6 @@ export const REMOVE_FAILED_UPLOAD_STEP = {
|
|
|
15
16
|
await api.deleteAppUpload(appId, packageId);
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
throw new
|
|
19
|
+
throw new StepError(`Got unexpected status '${uploadStatus}' while processing package ${packageId}.`);
|
|
19
20
|
},
|
|
20
21
|
};
|
|
@@ -2,6 +2,7 @@ import chalk from 'chalk';
|
|
|
2
2
|
import inquirer from 'inquirer';
|
|
3
3
|
|
|
4
4
|
import { logger } from '../../../helpers/logger.js';
|
|
5
|
+
import { StepError } from '../../lib/step-error.js';
|
|
5
6
|
|
|
6
7
|
export const GET_APP_VERSION_TASK_STEP = {
|
|
7
8
|
message: 'Get app version...',
|
|
@@ -37,7 +38,7 @@ const getAppVersion = async (appId, optionAppVersion, api) => {
|
|
|
37
38
|
const appPackages = await api.getAppPackages(appId);
|
|
38
39
|
|
|
39
40
|
if (!appPackages.length) {
|
|
40
|
-
throw new
|
|
41
|
+
throw new StepError('No app versions found');
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
const confirmUseVersionMessage = (version) => {
|
package/lib/main.js
CHANGED
|
@@ -12,6 +12,10 @@ import { attachCommand } from './commands/attach.js';
|
|
|
12
12
|
import { createCommand } from './commands/create.js';
|
|
13
13
|
|
|
14
14
|
import { ERROR_ICON } from './constants/messages.js';
|
|
15
|
+
import { StepError } from './flows/lib/step-error.js';
|
|
16
|
+
import debugFn from 'debug';
|
|
17
|
+
|
|
18
|
+
const debug = debugFn('cca:main');
|
|
15
19
|
|
|
16
20
|
function checkNodeVersion() {
|
|
17
21
|
logger.write('Checking node version...');
|
|
@@ -46,14 +50,19 @@ export async function run() {
|
|
|
46
50
|
.addCommand(rerunCommand)
|
|
47
51
|
.addCommand(attachCommand)
|
|
48
52
|
.showHelpAfterError()
|
|
49
|
-
.showSuggestionAfterError(true)
|
|
50
|
-
.configureOutput({
|
|
51
|
-
outputError: (str, write) => write(chalk.red(`${ERROR_ICON} ${str}`)),
|
|
52
|
-
});
|
|
53
|
+
.showSuggestionAfterError(true);
|
|
53
54
|
|
|
54
55
|
try {
|
|
55
56
|
await program.parseAsync(process.argv);
|
|
56
57
|
} catch (e) {
|
|
58
|
+
if (e instanceof StepError) {
|
|
59
|
+
console.error(chalk.red(`${ERROR_ICON} ${e.message}`));
|
|
60
|
+
} else {
|
|
61
|
+
debug(e);
|
|
62
|
+
|
|
63
|
+
console.error(chalk.red(`${ERROR_ICON} Unknown error occured, please contact support`));
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
process.exit(1);
|
|
58
67
|
}
|
|
59
68
|
}
|