@corva/create-app 0.40.0-0 → 0.40.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 +4 -1
- package/lib/constants/manifest.js +5 -0
- package/lib/flow.js +5 -4
- package/lib/flows/steps/zip-prepare.js +2 -1
- package/lib/helpers/logger.js +27 -0
- package/lib/helpers/versioning.js +3 -2
- package/lib/index.js +49 -38
- package/lib/scripts/utils/version.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,6 +60,7 @@ Options:
|
|
|
60
60
|
--segments [string] Choose segments (choices: "drilling", "completion")
|
|
61
61
|
--summary [string] Enter summary (default: "More information about this app goes here")
|
|
62
62
|
--website [string] Enter website (default: "https://www.oandgexample.com/my-app/")
|
|
63
|
+
--silent [boolean] Only log result of the operation
|
|
63
64
|
-V, --version output the version number
|
|
64
65
|
-h, --help display help for command
|
|
65
66
|
-p, --packageManager [string] Please select the desired package manager (choices: "yarn", "npm", default: "yarn")
|
|
@@ -102,6 +103,7 @@ Arguments:
|
|
|
102
103
|
|
|
103
104
|
Options:
|
|
104
105
|
--bump-version <string> bump version (choices: "major", "minor", "patch", "skip")
|
|
106
|
+
--silent [boolean] Only log result of the operation
|
|
105
107
|
-h, --help display help for command
|
|
106
108
|
```
|
|
107
109
|
|
|
@@ -173,6 +175,7 @@ Arguments:
|
|
|
173
175
|
|
|
174
176
|
Options:
|
|
175
177
|
--bump-version <string> bump version (choices: "major", "minor", "patch", "skip")
|
|
178
|
+
--silent [boolean] Only log result of the operation
|
|
176
179
|
-h, --help display help for command
|
|
177
180
|
```
|
|
178
181
|
|
|
@@ -200,4 +203,4 @@ create-corva-app release test-app --bump-version=patch
|
|
|
200
203
|
|
|
201
204
|
```sh
|
|
202
205
|
create-corva-app release test-app --bump-version=4.2.0
|
|
203
|
-
```
|
|
206
|
+
```
|
|
@@ -204,6 +204,11 @@ const manifestOptions = (projectName = 'Corva Dev Center App') => [
|
|
|
204
204
|
(answers.runtime && answers.runtime.startsWith(TEMPLATE_TYPES.NODE)) ||
|
|
205
205
|
answers.appType === APP_TYPES.UI,
|
|
206
206
|
},
|
|
207
|
+
{
|
|
208
|
+
name: 'silent',
|
|
209
|
+
message: 'Only log result of the operation',
|
|
210
|
+
default: false,
|
|
211
|
+
},
|
|
207
212
|
];
|
|
208
213
|
|
|
209
214
|
module.exports = {
|
package/lib/flow.js
CHANGED
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
const chalk = require('chalk');
|
|
4
4
|
const { SUCCESS_ICON } = require('./constants/messages');
|
|
5
5
|
const { resolve, sep } = require('path');
|
|
6
|
+
const logger = require('./helpers/logger');
|
|
6
7
|
|
|
7
8
|
const debug = require('debug')('cca:flow');
|
|
8
9
|
|
|
9
10
|
const runFlow = async (flow, context, indent = '') => {
|
|
10
|
-
|
|
11
|
+
logger.write(
|
|
11
12
|
`${indent}Running ${chalk.cyan(flow.name)} in ${chalk.cyan(resolve(context.dirName).split(sep).pop())}\n`
|
|
12
13
|
);
|
|
13
14
|
|
|
14
15
|
const result = await runSteps(flow.steps, context, indent + ' ');
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
logger.write(`${indent}Done!` + SUCCESS_ICON);
|
|
17
18
|
|
|
18
19
|
return result;
|
|
19
20
|
};
|
|
@@ -30,14 +31,14 @@ const runSteps = async (steps = [], context = {}, indent = '') => {
|
|
|
30
31
|
|
|
31
32
|
const message = indent + step.message;
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
logger.write(message);
|
|
34
35
|
debug('Context: %o', context);
|
|
35
36
|
|
|
36
37
|
const result = await step.fn(context);
|
|
37
38
|
|
|
38
39
|
Object.assign(context, result);
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
logger.write(SUCCESS_ICON);
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
return context;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { saveJson } = require('../lib/json');
|
|
2
|
+
const logger = require('../../helpers/logger');
|
|
2
3
|
|
|
3
4
|
const debug = require('debug')('cca:flow:zip:prepare');
|
|
4
5
|
|
|
@@ -10,7 +11,7 @@ const PREPARE_FILES_BEFORE_ZIP_STEP = {
|
|
|
10
11
|
await saveJson(dirName, item.name, item.content);
|
|
11
12
|
|
|
12
13
|
if (item.message) {
|
|
13
|
-
|
|
14
|
+
logger.write(item.message);
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
},
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class Logger {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.isSilent = process.argv.includes('--silent');
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
write(str) {
|
|
7
|
+
if (this.isSilent) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
process.stdout.write(str);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
writeDirectlyToConsole(str) {
|
|
15
|
+
process.stdout.write(str);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
log(str) {
|
|
19
|
+
if (this.isSilent) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
console.log(str);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = new Logger();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const execSync = require('child_process').execSync;
|
|
2
|
+
const logger = require('./logger');
|
|
2
3
|
|
|
3
4
|
function isInGitRepository(appPath) {
|
|
4
5
|
try {
|
|
@@ -20,7 +21,7 @@ function tryGitInit(appPath) {
|
|
|
20
21
|
execSync('git --version', { stdio: 'ignore', cwd: appPath });
|
|
21
22
|
|
|
22
23
|
execSync('git init', { stdio: 'ignore', cwd: appPath });
|
|
23
|
-
|
|
24
|
+
logger.log('Initialized git repo in app');
|
|
24
25
|
return true;
|
|
25
26
|
} catch (e) {
|
|
26
27
|
console.warn('Git repo not initialized', e);
|
|
@@ -35,7 +36,7 @@ function tryGitCommit(appPath) {
|
|
|
35
36
|
stdio: 'ignore',
|
|
36
37
|
cwd: appPath,
|
|
37
38
|
});
|
|
38
|
-
|
|
39
|
+
logger.log('Added first git commit');
|
|
39
40
|
return true;
|
|
40
41
|
} catch (e) {
|
|
41
42
|
// We couldn't commit in already initialized git repo,
|
package/lib/index.js
CHANGED
|
@@ -36,6 +36,7 @@ const { bumpVersionOptionDeprecated, bumpVersionOption } = require('./bump-versi
|
|
|
36
36
|
const { Manifest } = require('./flows/lib/manifest');
|
|
37
37
|
const { resolveAppRuntime } = require('./helpers/resolve-app-runtime');
|
|
38
38
|
const { existsSync } = require('fs');
|
|
39
|
+
const logger = require('./helpers/logger');
|
|
39
40
|
|
|
40
41
|
const writejsonOptions = {
|
|
41
42
|
spaces: 2,
|
|
@@ -49,11 +50,11 @@ function startingMessage() {
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
function checkNodeVersion() {
|
|
52
|
-
|
|
53
|
+
logger.write('Checking node version...');
|
|
53
54
|
|
|
54
55
|
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=16');
|
|
55
56
|
if (unsupportedNodeVersion) {
|
|
56
|
-
|
|
57
|
+
logger.log(
|
|
57
58
|
chalk.red(
|
|
58
59
|
`\nYou are using Node ${process.version}.\n\n` +
|
|
59
60
|
`Please update to Node 16 or higher for a better, fully supported experience.\n`
|
|
@@ -62,7 +63,7 @@ function checkNodeVersion() {
|
|
|
62
63
|
// Fall back to latest supported react-scripts on Node 4
|
|
63
64
|
return process.exit(1);
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
+
logger.write(' ✅ \n');
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
function checkOptions(opts) {
|
|
@@ -180,9 +181,14 @@ async function initialChecks() {
|
|
|
180
181
|
.argument('[patterns...]', 'Additional patterns to zip', [])
|
|
181
182
|
.addOption(bumpVersionOption)
|
|
182
183
|
.addOption(new Option('--ignored-files [ignoredFiles...]', 'Patterns to skip zip', []))
|
|
184
|
+
.addOption(new Option('--silent [boolean]', 'Only log result of the operation', []))
|
|
183
185
|
.action(async (dirName, patterns, options) => {
|
|
184
186
|
options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
|
|
185
187
|
|
|
188
|
+
if (options.silent) {
|
|
189
|
+
console.log(dirName);
|
|
190
|
+
}
|
|
191
|
+
|
|
186
192
|
return runFlow(ZIP_FLOW, { dirName, patterns, options });
|
|
187
193
|
});
|
|
188
194
|
|
|
@@ -193,9 +199,14 @@ async function initialChecks() {
|
|
|
193
199
|
.argument('[patterns...]', 'Additional patterns to zip', [])
|
|
194
200
|
.addOption(bumpVersionOption)
|
|
195
201
|
.addOption(new Option('--ignored-files [ignoredFiles...]', 'Patterns to skip zip', []))
|
|
202
|
+
.addOption(new Option('--silent [boolean]', 'Only log result of the operation', []))
|
|
196
203
|
.action(async (dirName, patterns, options) => {
|
|
197
204
|
options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
|
|
198
205
|
|
|
206
|
+
if (options.silent) {
|
|
207
|
+
console.log(dirName);
|
|
208
|
+
}
|
|
209
|
+
|
|
199
210
|
return runFlow(RELEASE_FLOW, { dirName, patterns, options });
|
|
200
211
|
});
|
|
201
212
|
|
|
@@ -224,7 +235,7 @@ const handleError = (e) => {
|
|
|
224
235
|
return;
|
|
225
236
|
}
|
|
226
237
|
|
|
227
|
-
|
|
238
|
+
logger.write(ERROR_ICON);
|
|
228
239
|
|
|
229
240
|
if (!(e instanceof StepError)) {
|
|
230
241
|
console.error(chalk.red(e));
|
|
@@ -245,16 +256,16 @@ const handleCommanderError = (e) => {
|
|
|
245
256
|
const commandName = program.args[0] || program._defaultCommandName;
|
|
246
257
|
|
|
247
258
|
console.error('Please specify the project directory:');
|
|
248
|
-
|
|
259
|
+
logger.log(
|
|
249
260
|
` ${chalk.cyan(program.name())} ${commandName} ${chalk.green('<project-directory>')}`
|
|
250
261
|
);
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
262
|
+
logger.log();
|
|
263
|
+
logger.log('For example:');
|
|
264
|
+
logger.log(
|
|
254
265
|
` ${chalk.cyan(program.name())} ${commandName} ${chalk.green('my-react-app')}`
|
|
255
266
|
);
|
|
256
|
-
|
|
257
|
-
|
|
267
|
+
logger.log();
|
|
268
|
+
logger.log(
|
|
258
269
|
`Run ${chalk.cyan(`${program.name()} help ${commandName}`)} to see all options.`
|
|
259
270
|
);
|
|
260
271
|
} else {
|
|
@@ -288,7 +299,7 @@ async function initPackage(projectName, opts) {
|
|
|
288
299
|
|
|
289
300
|
const root = path.resolve(projectName);
|
|
290
301
|
|
|
291
|
-
|
|
302
|
+
logger.log(`Creating a new Corva app in ${chalk.green(root)}.`);
|
|
292
303
|
|
|
293
304
|
if (fs.existsSync(root)) {
|
|
294
305
|
throw new Error(`Directory already exists: ${root}`);
|
|
@@ -300,7 +311,7 @@ async function initPackage(projectName, opts) {
|
|
|
300
311
|
await configureApp(root, manifest, runtime);
|
|
301
312
|
await installApp(root, manifest, runtime);
|
|
302
313
|
|
|
303
|
-
|
|
314
|
+
logger.log();
|
|
304
315
|
}
|
|
305
316
|
|
|
306
317
|
async function createApp(dirName, opts) {
|
|
@@ -308,7 +319,7 @@ async function createApp(dirName, opts) {
|
|
|
308
319
|
|
|
309
320
|
if (isValid) {
|
|
310
321
|
Object.keys(values).forEach((key) => {
|
|
311
|
-
|
|
322
|
+
logger.log(`${key} : ${values[key]}`);
|
|
312
323
|
});
|
|
313
324
|
|
|
314
325
|
return initPackage(dirName, opts);
|
|
@@ -328,8 +339,8 @@ async function createApp(dirName, opts) {
|
|
|
328
339
|
* @param {*} runtime
|
|
329
340
|
*/
|
|
330
341
|
async function addTemplate(root, manifest, runtime) {
|
|
331
|
-
|
|
332
|
-
|
|
342
|
+
logger.log(chalk.green('Copying app template...'));
|
|
343
|
+
logger.log();
|
|
333
344
|
|
|
334
345
|
const templateFolder = path.resolve(
|
|
335
346
|
__dirname,
|
|
@@ -354,7 +365,7 @@ async function addTemplate(root, manifest, runtime) {
|
|
|
354
365
|
// That's why we manually rename gitignore to .gitignore after copying template
|
|
355
366
|
fs.renameSync(path.join(root, 'gitignore'), path.join(root, '.gitignore'));
|
|
356
367
|
|
|
357
|
-
|
|
368
|
+
logger.log(chalk.green('Done: copying app template!'));
|
|
358
369
|
}
|
|
359
370
|
|
|
360
371
|
/**
|
|
@@ -471,7 +482,7 @@ async function installApp(root, manifest, runtime) {
|
|
|
471
482
|
const args = ['install'];
|
|
472
483
|
const opts = { stdio: ['inherit', 'inherit', 'pipe'], cwd: root }
|
|
473
484
|
|
|
474
|
-
|
|
485
|
+
logger.log(chalk.yellow(`Installing template dependencies using ${runtime.packageManager}...`));
|
|
475
486
|
const proc = manifest.isJs() && existsSync(`${os.homedir()}/.nvm/nvm.sh`) ?
|
|
476
487
|
spawn.sync(`\\. ${os.homedir()}/.nvm/nvm.sh && nvm i && ${command} ${args.join(' ')}`, { shell: true, ...opts }) :
|
|
477
488
|
spawn.sync(command, args, opts);
|
|
@@ -491,20 +502,20 @@ async function installApp(root, manifest, runtime) {
|
|
|
491
502
|
return;
|
|
492
503
|
}
|
|
493
504
|
|
|
494
|
-
|
|
505
|
+
logger.log(chalk.green('Successfull project install'));
|
|
495
506
|
|
|
496
507
|
if (versioning.tryGitInit(root)) {
|
|
497
|
-
|
|
498
|
-
|
|
508
|
+
logger.log();
|
|
509
|
+
logger.log('Initialized a git repository.');
|
|
499
510
|
|
|
500
511
|
if (versioning.tryGitCommit(root)) {
|
|
501
|
-
|
|
502
|
-
|
|
512
|
+
logger.log();
|
|
513
|
+
logger.log('Created git commit.');
|
|
503
514
|
}
|
|
504
515
|
}
|
|
505
516
|
|
|
506
|
-
|
|
507
|
-
|
|
517
|
+
logger.log();
|
|
518
|
+
logger.log(`Success! Created ${manifest.name} at ${root}`);
|
|
508
519
|
|
|
509
520
|
helpCommands(manifest, runtime);
|
|
510
521
|
}
|
|
@@ -516,20 +527,20 @@ async function helpCommands(manifest, { packageManager: displayedCommand }) {
|
|
|
516
527
|
|
|
517
528
|
const useYarn = displayedCommand === 'yarn';
|
|
518
529
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
530
|
+
logger.log('Inside that directory, you can run several commands:');
|
|
531
|
+
logger.log();
|
|
532
|
+
logger.log(chalk.cyan(` ${displayedCommand} start`));
|
|
533
|
+
logger.log(' Starts the development server.');
|
|
534
|
+
logger.log();
|
|
535
|
+
logger.log(chalk.cyan(` ${displayedCommand} ${useYarn ? '' : 'run '}build`));
|
|
536
|
+
logger.log(' Bundles the app into static files for production.');
|
|
537
|
+
logger.log();
|
|
538
|
+
logger.log(chalk.cyan(` ${displayedCommand} ${useYarn ? '' : 'run '}zip`));
|
|
539
|
+
logger.log(' Bundles the app into ZIP file in app root directory');
|
|
540
|
+
logger.log();
|
|
541
|
+
logger.log(chalk.cyan(` ${displayedCommand} ${useYarn ? '' : 'run '}release`));
|
|
542
|
+
logger.log(' Uploads the app ZIP to Corva');
|
|
543
|
+
logger.log();
|
|
533
544
|
}
|
|
534
545
|
|
|
535
546
|
initialChecks();
|
|
@@ -3,6 +3,7 @@ const chalk = require('chalk');
|
|
|
3
3
|
const semver = require('semver');
|
|
4
4
|
const inquirer = require('inquirer');
|
|
5
5
|
|
|
6
|
+
const logger = require('../../helpers/logger');
|
|
6
7
|
const packageJson = require('../../../package.json');
|
|
7
8
|
const npm = new NpmApi();
|
|
8
9
|
|
|
@@ -37,7 +38,7 @@ async function ensureLatestVersion() {
|
|
|
37
38
|
|
|
38
39
|
// NOTE: Show user-friendly warning if version is outdated
|
|
39
40
|
async function warnIfOutdated() {
|
|
40
|
-
|
|
41
|
+
logger.write('Checking for updates...\n');
|
|
41
42
|
|
|
42
43
|
const currentVersion = getCurrentVersion();
|
|
43
44
|
const latestVersion = await getLatestVersion();
|
|
@@ -55,7 +56,7 @@ async function warnIfOutdated() {
|
|
|
55
56
|
`);
|
|
56
57
|
console.log(warning(asterisks));
|
|
57
58
|
} else {
|
|
58
|
-
|
|
59
|
+
logger.write(' ✅ \n');
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
|