UNPKG

3.82 kBJavaScriptView Raw
1#!/usr/bin/env node
2'use strict';
3
4Object.defineProperty(exports, "__esModule", {
5 value: true
6});
7
8var _yargs = require('yargs');
9
10var _yargs2 = _interopRequireDefault(_yargs);
11
12var _utilities = require('../utilities');
13
14function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
16var devToolkit = function devToolkit(_ref) {
17 var cmdArgs = _ref.cmdArgs;
18
19 // eslint-disable-next-line no-unused-expressions
20 _yargs2.default.usage('\nUsage: dev-toolkit <command> [options]').command({
21 command: 'init',
22 aliases: ['init', 'i'],
23 desc: 'Initializes a new project',
24 handler: function handler(argv) {
25 return (0, _utilities.runCommand)({
26 options: {
27 programmatic: false,
28 projectName: argv._[1],
29 template: argv.template || false,
30 silent: argv.silent || false,
31 skipComments: argv.skipComments || argv['skip-comments'] || false
32 },
33 command: 'init',
34 message: 'Initializing a new project'
35 });
36 }
37 }).command({
38 command: 'build',
39 aliases: ['build', 'b'],
40 desc: 'Generates a static build',
41 handler: function handler(argv) {
42 return (0, _utilities.runCommand)({
43 options: {
44 programmatic: false,
45 silent: argv.silent || false,
46 skipPreRender: argv.skipPreRender || argv['skip-prerender'] || argv['skip-pre-render'] || false
47 },
48 command: 'build',
49 message: 'Generating a static build'
50 });
51 }
52 }).command({
53 command: 'version',
54 aliases: ['version', 'v', '-v'],
55 desc: 'Outputs current version number',
56 handler: function handler() {
57 return (0, _utilities.runCommand)({
58 options: {
59 programmatic: false
60 },
61 command: 'version',
62 message: 'Output current version number',
63 skipPrimaryLog: true
64 });
65 }
66 }).command({
67 command: 'watch',
68 aliases: ['watch', 'w'],
69 desc: 'Watches files for development',
70 handler: function handler(argv) {
71 return (0, _utilities.runCommand)({
72 options: {
73 programmatic: false,
74 silent: argv.silent || false
75 },
76 command: 'watch',
77 message: 'Watching files for development'
78 });
79 }
80 }).command({
81 command: 'serve',
82 aliases: ['serve', 's'],
83 desc: 'Serves the app',
84 handler: function handler(argv) {
85 return (0, _utilities.runCommand)({
86 options: {
87 programmatic: false,
88 silent: argv.silent || false
89 },
90 command: 'serve',
91 message: 'Serving app with `start`-method'
92 });
93 }
94 }).command({
95 command: 'preRender',
96 aliases: ['preRender', 'prerender', 'pre-render', 'p'],
97 desc: 'preRender the app',
98 handler: function handler(argv) {
99 return (0, _utilities.runCommand)({
100 options: {
101 programmatic: false,
102 silent: argv.silent || false
103 },
104 command: 'preRender',
105 message: 'Pre-rendering app with `preRender`-method'
106 });
107 }
108 }).command({
109 command: 'bootstrap',
110 aliases: ['bootstrap'],
111 desc: 'Bootstraps a file with defined babel & nodeHooks configuration and makes dev-toolkit settings available for import',
112 handler: function handler(argv) {
113 return (0, _utilities.runCommand)({
114 options: {
115 programmatic: false,
116 silent: argv.silent || false,
117 file: argv.file || ''
118 },
119 command: 'bootstrap',
120 message: 'Bootstrap with universal configuration & dev-toolkit settings'
121 });
122 }
123 }).help().argv;
124
125 _yargs2.default.parse(cmdArgs);
126};
127
128// Run toolkit immediately using yargs if we're not testing it
129if (!process.env.TOOLKIT_TEST) {
130 devToolkit({ cmdArgs: process.argv });
131}
132
133exports.default = devToolkit;
\No newline at end of file