1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | var chalk = require("chalk");
|
9 | var resolve = require("resolve");
|
10 | var path = require("path");
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | exports.getHelp = function() {
|
16 | console.log();
|
17 | console.log(chalk.green(" Usage: uba <plugin-name>"));
|
18 | console.log();
|
19 | console.log(chalk.green(" Options:"));
|
20 | console.log();
|
21 | console.log(chalk.green(" -h, --help output usage information"));
|
22 | console.log(chalk.green(" -v, --version output the version number"));
|
23 | console.log();
|
24 | }
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | exports.checkNodeVersion = function(number) {
|
31 | var currentNodeVersion = process.versions.node;
|
32 | if (currentNodeVersion.split(".")[0] < number) {
|
33 | console.error(chalk.red(`You are running Node ${currentNodeVersion}\nCreate Uba App requires Node 6 or higher. \nPlease update your version of Node.`));
|
34 | process.exit(1);
|
35 | }
|
36 | }
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | exports.findPluginPath = function(command) {
|
43 | if (command && /^\w+$/.test(command)) {
|
44 | try {
|
45 | return resolve.sync("uba-" + command, {
|
46 | paths: [path.join(__dirname, "..", "node_modules")]
|
47 | });
|
48 | } catch (e) {
|
49 | console.log(e);
|
50 | console.log(" " + chalk.green(command) + " command is not installed.");
|
51 | console.log(" You can try to install it by " + chalk.blue.bold("npm install uba-" + command) + ".");
|
52 | console.log("");
|
53 | }
|
54 | }
|
55 | }
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | exports.getVersion = function() {
|
62 | console.log(chalk.green(require("../package.json").version));
|
63 | process.exit(0);
|
64 | } |
\ | No newline at end of file |