1 | 'use strict';
|
2 |
|
3 | const path = require('path');
|
4 | const chalk = require('chalk');
|
5 |
|
6 | const input = require('./input');
|
7 | const validate = require('./validate');
|
8 | const rename = require('./rename');
|
9 | const install = require('./install');
|
10 |
|
11 |
|
12 |
|
13 | const { projectName, includeEditor } = input.getProjectName();
|
14 | validate.checkProjectName(projectName);
|
15 |
|
16 |
|
17 |
|
18 | const appRoot = path.resolve(projectName);
|
19 | install.createDir(appRoot);
|
20 |
|
21 |
|
22 |
|
23 | validate.checkFileConflicts(appRoot);
|
24 | console.log(`Creating a new Cloud Block in ${chalk.green(appRoot)}`);
|
25 |
|
26 |
|
27 |
|
28 | console.log('Extracting example files');
|
29 | install.copyExample(appRoot);
|
30 | install.addGitIgnore(appRoot);
|
31 |
|
32 |
|
33 |
|
34 | const appName = path.basename(appRoot);
|
35 |
|
36 | rename.updatePkg(appRoot, projectName, includeEditor);
|
37 | rename.updateFiles(appRoot, appName);
|
38 | rename.renameBlock(appRoot, appName);
|
39 |
|
40 |
|
41 |
|
42 | console.log('Installing packages. This might take a couple of minutes.');
|
43 | install.runNPM(appRoot);
|
44 |
|
45 |
|
46 |
|
47 | console.log(`Success! Created ${chalk.green(projectName)} at ${appRoot}`);
|
48 | console.log(`Inside that directory, you can run several commands:`);
|
49 | if(includeEditor) {
|
50 | console.log();
|
51 | console.log(` ${chalk.cyan('npm start')}`);
|
52 | console.log(` Starts the development editor (no live reload currently).`);
|
53 | }
|
54 | console.log();
|
55 | console.log(` ${chalk.cyan('npm run build')}`);
|
56 | console.log(` Bundles the app into static files for production.`);
|
57 | console.log();
|
58 | console.log(` ${chalk.cyan('npm publish')}`);
|
59 | console.log(` Publish the production static files to NPM.`);
|
60 | console.log();
|
61 | console.log(`You can start by typing:`);
|
62 | console.log(` ${chalk.cyan('cd')} ${chalk.green(projectName)}`);
|
63 | if(includeEditor) {
|
64 | console.log(` ${chalk.cyan('npm start')}`);
|
65 | }
|
66 | console.log();
|
67 | console.log('🚀');
|