This repository has been archived by the owner on Dec 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
executable file
·83 lines (75 loc) · 2.86 KB
/
index.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
76
77
78
79
80
81
82
83
#! /usr/bin/env node
/*
* Copyright (c) 2020. by Pablo Klaschka
*/
const program = require('commander');
const packageJSON = require('./package.json');
const {log} = require("./lib/error-handler");
const {fatal} = require("./lib/error-handler");
const {setVerbose} = require("./lib/error-handler");
program
.name('xd-deploy')
.version(packageJSON.version)
.action(() => {
program.outputHelp();
log();
fatal(new Error('No valid command specified.'));
});
program
.command('server')
.description('start the server providing a bridge between clients and dev-client')
.option('-p, --port [port]', 'Which port to use', parseFloat, 8080)
.option('-s, --https', 'Use https. The server then generates self-signed certificates and uses them for communication')
.option('-d, --debug', 'enable verbose debugging output')
.action(
/**
*
* @param {{https: boolean, port: number, debug: boolean}} options
* @returns {Promise<void>}
*/
async (options) => {
setVerbose(options.debug);
try {
const server = require('./server');
await server(options.port, options.https);
} catch (e) {
fatal(e);
}
}
);
program
.command('develop <action> <serverLocation> [directory]')
.description('Submit the plugin to the server', {
action: '"watch" or "install". With "install" the plugin gets deployed once, with "watch" the plugin folder gets watched for changes.',
serverLocation: 'The server url of the server started via "xd-deploy server',
directory: 'The plugin directory. The current working directory by default'
})
.usage('<action> <serverLocation> [directory]')
.alias('dev')
.option('-d, --debug', 'enable verbose debugging output')
.action(async (action, serverLocation, directory, options) => {
setVerbose(options.debug);
try {
const devClient = require('./dev-client');
await devClient(action, serverLocation, directory || '.');
} catch (e) {
fatal(e);
}
});
program.command('client <serverLocation>')
.description('starts a client on a machine that has XD installed and installs all plugins, connects to the specified server, and updates them when possible.', {
serverLocation: 'The url of the server started with "xd-deploy server"'
})
.option('-d, --debug', 'enable verbose debugging output')
.action(async (serverLocation, options) => {
setVerbose(options.debug);
try {
const client = require('./client');
await client(serverLocation);
} catch (e) {
fatal(e);
}
});
program.parse(process.argv);
const noCommandSpecified = process.argv.length < 3;
if (noCommandSpecified) program.help();