|
1 | 1 | require('grunt-6to5/node_modules/6to5/polyfill');
|
| 2 | +var program = require('commander'); |
2 | 3 |
|
3 |
| -var localconfig = require('../config'), |
4 |
| - helpers = require('../helpers'), |
5 |
| - program = require('commander'), |
6 |
| - logo = require('../cli/logo'); |
| 4 | +import { version } from '../config'; |
| 5 | +import { cliColor } from '../helpers'; |
| 6 | +import logo from './logo'; |
| 7 | +import { init, config, newFile, run } from './util'; |
7 | 8 |
|
8 | 9 | program
|
9 |
| - .version(localconfig.version); |
| 10 | + .version(version); |
10 | 11 |
|
11 | 12 | program
|
12 | 13 | .command('init')
|
13 | 14 | .description('Init your static website')
|
14 |
| - .action(function(path) { |
15 |
| - var util = require('../cli/util'); |
| 15 | + .action((path) => { |
16 | 16 | console.log(logo);
|
17 |
| - util.init(typeof path === 'string' ? path : './'); |
| 17 | + init(typeof path === 'string' ? path : './'); |
18 | 18 | });
|
19 | 19 |
|
20 | 20 | program
|
21 | 21 | .command('config')
|
22 | 22 | .description('Config your static website')
|
23 |
| - .action(function() { |
24 |
| - var util = require('../cli/util'); |
| 23 | + .action(() => { |
25 | 24 | console.log(logo);
|
26 |
| - util.config(); |
| 25 | + config(); |
27 | 26 | });
|
28 | 27 |
|
29 | 28 | program
|
30 | 29 | .command('build')
|
31 | 30 | .description('Build your static website')
|
32 |
| - .action(function() { |
33 |
| - var core = require('../core'); |
| 31 | + .action(() => { |
| 32 | + let core = require('../core'); |
34 | 33 | core.init();
|
35 | 34 | });
|
36 | 35 |
|
37 | 36 | program
|
38 | 37 | .command('new_post ["title"]')
|
39 | 38 | .description('Create a new post')
|
40 |
| - .action(function(title) { |
41 |
| - require('../cli/util').newFile('post', title); |
| 39 | + .action((title) => { |
| 40 | + newFile('post', title); |
42 | 41 | });
|
43 | 42 |
|
44 | 43 | program
|
45 | 44 | .command('new_page ["title"]')
|
46 | 45 | .description('Create a new page')
|
47 |
| - .action(function(title) { |
48 |
| - require('../cli/util').newFile('page', title); |
| 46 | + .action((title) => { |
| 47 | + newFile('page', title); |
49 | 48 | });
|
50 | 49 |
|
51 | 50 | program
|
52 | 51 | .command('run [port]')
|
53 | 52 | .description('Run you static site locally. Port is optional')
|
54 |
| - .action(function(port = 9356) { |
55 |
| - var util = require('../cli/util'), |
56 |
| - core = require('../core'), |
| 53 | + .action(function(port = 9356) { // We're not using arrow function here due to an jshint issue |
| 54 | + let core = require('../core'), |
57 | 55 | build = core.init();
|
58 | 56 | if (build) {
|
59 | 57 | build.then(function() {
|
60 |
| - util.run(port); |
| 58 | + run(port); |
61 | 59 | });
|
62 | 60 | }
|
63 | 61 | });
|
64 | 62 |
|
65 |
| -program.on('*', function(args) { |
66 |
| - var clc = helpers.cliColor(); |
| 63 | +program.on('*', (args) => { |
| 64 | + let clc = cliColor(); |
67 | 65 | console.error('Unknown command: ' + clc.error(args[0]));
|
68 | 66 | process.exit(1);
|
69 | 67 | });
|
|
0 commit comments