@corva/create-app 0.50.0-3 → 0.50.0-rc.0
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 -1
- package/lib/commands/attach.js +7 -0
- package/lib/commands/create.js +6 -1
- package/lib/commands/release.js +7 -0
- package/lib/commands/rerun.js +7 -1
- package/lib/commands/zip.js +8 -1
- package/lib/constants/messages.js +3 -3
- package/lib/flow.js +2 -2
- package/lib/main.js +9 -59
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ Usage: create-corva-app create <project-directory> [options]
|
|
|
41
41
|
Create a new app
|
|
42
42
|
|
|
43
43
|
Arguments:
|
|
44
|
-
project-directory
|
|
44
|
+
project-directory Project directory to work with (default: "Current working dir")
|
|
45
45
|
|
|
46
46
|
Options:
|
|
47
47
|
--developerName [string] Enter the Developer Name (default: "O&G Company")
|
package/lib/commands/attach.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
1
2
|
import { Command } from 'commander';
|
|
3
|
+
import { ERROR_ICON } from '../constants/messages.js';
|
|
2
4
|
import { runFlow } from '../flow.js';
|
|
3
5
|
import { ATTACH_FLOW } from '../flows/attach.js';
|
|
4
6
|
import { getRealWorkingDir } from '../helpers/commands.js';
|
|
@@ -18,4 +20,9 @@ export const attachCommand = new Command('attach')
|
|
|
18
20
|
.addOption(originalCwdOption)
|
|
19
21
|
.action(async (dirName, options) => {
|
|
20
22
|
await runFlow(ATTACH_FLOW, { dirName: getRealWorkingDir(dirName, options), options });
|
|
23
|
+
})
|
|
24
|
+
.showHelpAfterError()
|
|
25
|
+
.showSuggestionAfterError(true)
|
|
26
|
+
.configureOutput({
|
|
27
|
+
outputError: (str, write) => write(chalk.red(`${ERROR_ICON} ${str}`)),
|
|
21
28
|
});
|
package/lib/commands/create.js
CHANGED
|
@@ -23,6 +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 { ERROR_ICON } from '../constants/messages.js';
|
|
26
27
|
|
|
27
28
|
const __filename = fileURLToPath(import.meta.url);
|
|
28
29
|
const __dirname = dirname(__filename);
|
|
@@ -36,7 +37,11 @@ export const createCommand = new Command('create')
|
|
|
36
37
|
.description('Create a new app')
|
|
37
38
|
.argument('[project-directory]', 'project directory to work with', process.argv[process.argv.length - 1])
|
|
38
39
|
.addOption(originalCwdOption)
|
|
39
|
-
.
|
|
40
|
+
.showHelpAfterError()
|
|
41
|
+
.showSuggestionAfterError(true)
|
|
42
|
+
.configureOutput({
|
|
43
|
+
outputError: (str, write) => write(chalk.red(`${ERROR_ICON} ${str}`)),
|
|
44
|
+
});
|
|
40
45
|
|
|
41
46
|
manifestOptions().forEach((value) => {
|
|
42
47
|
const type = typeof value.default;
|
package/lib/commands/release.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
1
2
|
import { Command, Option } from 'commander';
|
|
2
3
|
import { runFlow } from '../flow.js';
|
|
3
4
|
import { RELEASE_FLOW } from '../flows/release.js';
|
|
@@ -8,6 +9,7 @@ import { envOption } from '../options/env.js';
|
|
|
8
9
|
import { originalCwdOption } from '../options/original-cwd.js';
|
|
9
10
|
import { silentOption } from '../options/silent.js';
|
|
10
11
|
import { ensureBumpVersion } from '../helpers/cli-version.js';
|
|
12
|
+
import { ERROR_ICON } from '../constants/messages.js';
|
|
11
13
|
|
|
12
14
|
export const releaseCommand = new Command('release')
|
|
13
15
|
.description('Release app')
|
|
@@ -40,4 +42,9 @@ export const releaseCommand = new Command('release')
|
|
|
40
42
|
patterns,
|
|
41
43
|
options,
|
|
42
44
|
});
|
|
45
|
+
})
|
|
46
|
+
.showHelpAfterError()
|
|
47
|
+
.showSuggestionAfterError(true)
|
|
48
|
+
.configureOutput({
|
|
49
|
+
outputError: (str, write) => write(chalk.red(`${ERROR_ICON} ${str}`)),
|
|
43
50
|
});
|
package/lib/commands/rerun.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
1
2
|
import { Command, Option } from 'commander';
|
|
2
|
-
|
|
3
|
+
import { ERROR_ICON } from '../constants/messages.js';
|
|
3
4
|
import { runFlow } from '../flow.js';
|
|
4
5
|
import { RERUN_FLOW } from '../flows/rerun.js';
|
|
5
6
|
import { getRealWorkingDir } from '../helpers/commands.js';
|
|
@@ -22,4 +23,9 @@ export const rerunCommand = new Command('rerun')
|
|
|
22
23
|
.addOption(originalCwdOption)
|
|
23
24
|
.action(async (dirName, options) => {
|
|
24
25
|
await runFlow(RERUN_FLOW, { dirName: getRealWorkingDir(dirName, options), options });
|
|
26
|
+
})
|
|
27
|
+
.showHelpAfterError()
|
|
28
|
+
.showSuggestionAfterError(true)
|
|
29
|
+
.configureOutput({
|
|
30
|
+
outputError: (str, write) => write(chalk.red(`${ERROR_ICON} ${str}`)),
|
|
25
31
|
});
|
package/lib/commands/zip.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
1
2
|
import { Command, Option } from 'commander';
|
|
2
3
|
import _ from 'lodash/fp.js';
|
|
3
4
|
|
|
@@ -8,6 +9,7 @@ import { bumpVersionOption } from '../options/bump-version.js';
|
|
|
8
9
|
import { originalCwdOption } from '../options/original-cwd.js';
|
|
9
10
|
import { silentOption } from '../options/silent.js';
|
|
10
11
|
import { ensureBumpVersion } from '../helpers/cli-version.js';
|
|
12
|
+
import { ERROR_ICON } from '../constants/messages.js';
|
|
11
13
|
|
|
12
14
|
export const zipCommand = new Command('zip')
|
|
13
15
|
.description('Bundle app')
|
|
@@ -29,4 +31,9 @@ export const zipCommand = new Command('zip')
|
|
|
29
31
|
options,
|
|
30
32
|
}).then(_.get('zipFileName'));
|
|
31
33
|
}),
|
|
32
|
-
)
|
|
34
|
+
)
|
|
35
|
+
.showHelpAfterError()
|
|
36
|
+
.showSuggestionAfterError(true)
|
|
37
|
+
.configureOutput({
|
|
38
|
+
outputError: (str, write) => write(chalk.red(`${ERROR_ICON} ${str}`)),
|
|
39
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
|
|
3
|
-
export const SUCCESS_ICON = '
|
|
4
|
-
export const ERROR_ICON = '
|
|
3
|
+
export const SUCCESS_ICON = '✅';
|
|
4
|
+
export const ERROR_ICON = '❌';
|
|
5
5
|
|
|
6
6
|
export const RELEASE = {
|
|
7
7
|
createZip: 'Creating zip archive...\n',
|
|
8
8
|
createZipError: 'Could not create zip archive.',
|
|
9
|
-
createZipSuccess: `Zip archive has been created ${SUCCESS_ICON}`,
|
|
9
|
+
createZipSuccess: `Zip archive has been created ${SUCCESS_ICON}\n`,
|
|
10
10
|
getAuthToken: 'Reading auth token...',
|
|
11
11
|
getAuthTokenError: `Could not find auth token or API_KEY in .env file.\nFor UI app please run ${chalk.cyan`yarn start`} and login to Corva to fetch it or set API_KEY in your .env file`,
|
|
12
12
|
getAppKey: 'Reading app key...',
|
package/lib/flow.js
CHANGED
|
@@ -16,7 +16,7 @@ export const runFlow = async (flow, context, indent = '') => {
|
|
|
16
16
|
|
|
17
17
|
const result = await runSteps(flow.steps, context, indent + ' ');
|
|
18
18
|
|
|
19
|
-
logger.write(`${indent}Done!` + SUCCESS_ICON);
|
|
19
|
+
logger.write(`${indent}Done!` + SUCCESS_ICON + '\n');
|
|
20
20
|
|
|
21
21
|
return result;
|
|
22
22
|
};
|
|
@@ -40,7 +40,7 @@ const runSteps = async (steps = [], context = {}, indent = '') => {
|
|
|
40
40
|
|
|
41
41
|
Object.assign(context, result);
|
|
42
42
|
|
|
43
|
-
logger.write(SUCCESS_ICON);
|
|
43
|
+
logger.write(SUCCESS_ICON + '\n');
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
return context;
|
package/lib/main.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { Command
|
|
2
|
+
import { Command } from 'commander';
|
|
3
3
|
import semver from 'semver';
|
|
4
4
|
|
|
5
5
|
import { warnIfOutdated } from './helpers/cli-version.js';
|
|
6
|
-
import { ERROR_ICON } from './constants/messages.js';
|
|
7
|
-
import { StepError } from './flows/lib/step-error.js';
|
|
8
6
|
import { logger } from './helpers/logger.js';
|
|
9
7
|
|
|
10
8
|
import { zipCommand } from './commands/zip.js';
|
|
@@ -13,6 +11,8 @@ import { rerunCommand } from './commands/rerun.js';
|
|
|
13
11
|
import { attachCommand } from './commands/attach.js';
|
|
14
12
|
import { createCommand } from './commands/create.js';
|
|
15
13
|
|
|
14
|
+
import { ERROR_ICON } from './constants/messages.js';
|
|
15
|
+
|
|
16
16
|
function checkNodeVersion() {
|
|
17
17
|
logger.write('Checking node version...');
|
|
18
18
|
|
|
@@ -40,70 +40,20 @@ export async function run() {
|
|
|
40
40
|
|
|
41
41
|
await warnIfOutdated();
|
|
42
42
|
})
|
|
43
|
-
.configureOutput({ writeErr: () => undefined })
|
|
44
|
-
.exitOverride()
|
|
45
43
|
.addCommand(createCommand, { isDefault: true })
|
|
46
44
|
.addCommand(zipCommand)
|
|
47
45
|
.addCommand(releaseCommand)
|
|
48
46
|
.addCommand(rerunCommand)
|
|
49
|
-
.addCommand(attachCommand)
|
|
47
|
+
.addCommand(attachCommand)
|
|
48
|
+
.showHelpAfterError()
|
|
49
|
+
.showSuggestionAfterError(true)
|
|
50
|
+
.configureOutput({
|
|
51
|
+
outputError: (str, write) => write(chalk.red(`${ERROR_ICON} ${str}`)),
|
|
52
|
+
});
|
|
50
53
|
|
|
51
54
|
try {
|
|
52
55
|
await program.parseAsync(process.argv);
|
|
53
56
|
} catch (e) {
|
|
54
|
-
handleError(program, e);
|
|
55
|
-
|
|
56
57
|
process.exit(1);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
const handleError = (program, e) => {
|
|
61
|
-
if (e instanceof CommanderError) {
|
|
62
|
-
handleCommanderError(program, e);
|
|
63
|
-
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
logger.write(ERROR_ICON);
|
|
68
|
-
|
|
69
|
-
if (!(e instanceof StepError)) {
|
|
70
|
-
console.error(chalk.red(e));
|
|
71
|
-
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
console.log(chalk.red(e.message));
|
|
76
|
-
e.cause && console.error(chalk.red(e.cause));
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const handleCommanderError = (program, e) => {
|
|
80
|
-
switch (e.code) {
|
|
81
|
-
case 'commander.missingArgument': {
|
|
82
|
-
const match = /error:.*'(.*)'/.exec(e.message);
|
|
83
|
-
|
|
84
|
-
if (match && match[1] === 'project-directory') {
|
|
85
|
-
const commandName = program.args[0] || program._defaultCommandName;
|
|
86
|
-
|
|
87
|
-
console.error('Please specify the project directory:');
|
|
88
|
-
logger.log(` ${chalk.cyan(program.name())} ${commandName} ${chalk.green('<project-directory>')}`);
|
|
89
|
-
logger.log();
|
|
90
|
-
logger.log('For example:');
|
|
91
|
-
logger.log(` ${chalk.cyan(program.name())} ${commandName} ${chalk.green('my-react-app')}`);
|
|
92
|
-
logger.log();
|
|
93
|
-
logger.log(`Run ${chalk.cyan(`${program.name()} help ${commandName}`)} to see all options.`);
|
|
94
|
-
} else {
|
|
95
|
-
console.error('❌', e.message);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
case 'commander.help':
|
|
101
|
-
case 'commander.helpDisplayed': {
|
|
102
|
-
// ignore
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
default: {
|
|
106
|
-
console.error('❌', e.message);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corva/create-app",
|
|
3
|
-
"version": "0.50.0-
|
|
3
|
+
"version": "0.50.0-rc.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Create an app to use it in CORVA.AI",
|
|
6
6
|
"keywords": [
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"release-rc": "npm run release -- --prerelease"
|
|
36
36
|
},
|
|
37
37
|
"lint-staged": {
|
|
38
|
-
"*.
|
|
38
|
+
"*.js": "npm run lint:fix"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"archiver": "^5.3.0",
|