-
Notifications
You must be signed in to change notification settings - Fork 1
/
awly.js
executable file
·75 lines (59 loc) · 2.07 KB
/
awly.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#! /usr/bin/env node
const ShellJS = require("shelljs");
const path = require( "path" );
const fs = require( "fs" );
const Minimist = require( "minimist" );
const Vorpal = require( "vorpal" )();
const cwd = ShellJS.pwd().toString();
const awlyCliConfig = require(path.resolve(__dirname, "./package.json"));
function insideAwlyDir(){
if (fs.existsSync(path.resolve(cwd, "./project-config/main.config.js"))) {
return true;
} else {
return false;
}
}
let argv = process.argv.slice( 0 );
let args = Minimist( argv.slice( 2 ) );
let repl = !( args._ && args._.length ) &&
!( args.h || args.help ) &&
!( args.v || args.version );
if ( args.h || args.help ) {
argv = [].concat.apply( argv.slice( 0, 2 ).concat( "help" ), argv.slice( 2 ).filter( i => i[0] !== "-" ) );
}
Vorpal.catch( "[words...]", "Catches incorrect commands" )
.action( function( args, cb ) {
this.log( ( args.words ? args.words.join( " " ) : "<unknown>" ) + " is not a valid command." );
cb();
} );
require("./cli/version.js")(Vorpal, awlyCliConfig.version);
// require("./cli/info.js")(Vorpal, awlyCliConfig);
require("./cli/init.js")(Vorpal);
if(insideAwlyDir()){
const projectConfig = require("./lib/utils").getProjectConfig();
require("./cli/server/start.js")(Vorpal, projectConfig);
require("./cli/server/cert-update.js")(Vorpal, projectConfig);
require("./cli/page/create.js")(Vorpal, projectConfig);
require("./cli/page/deploy.js")(Vorpal, projectConfig);
require("./cli/api/deploy.js")(Vorpal, projectConfig);
require("./cli/assets/upload.js")(Vorpal, projectConfig);
require("./cli/aws/sync-cloudfront.js")(Vorpal, projectConfig);
}
// Vorpal
// .on( "client_command_executed", function() {
// process.exit( 0 )
// } )
// .delimiter( "awly > " )
// .parse( argv.slice( 0 ) );
if ( repl ) {
Vorpal
.delimiter( "awly > " )
.show();
} else {
Vorpal
.on( "client_command_executed", function() {
process.exit( 0 );
} )
.delimiter( "awly > " )
.parse( argv.slice( 0 ) );
}