navy 4.1.2-rc.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli/config/index.js +57 -241
- package/lib/cli/config/wrapper.js +12 -36
- package/lib/cli/develop.js +63 -167
- package/lib/cli/doctor/clean-compose-files.js +19 -73
- package/lib/cli/doctor/index.js +34 -154
- package/lib/cli/doctor/invalid-compose-config.js +20 -110
- package/lib/cli/doctor/invalid-state.js +22 -115
- package/lib/cli/doctor/util.js +26 -93
- package/lib/cli/external-ip.js +9 -39
- package/lib/cli/health.js +18 -67
- package/lib/cli/https.js +92 -0
- package/lib/cli/import.js +22 -59
- package/lib/cli/index.js +11 -17
- package/lib/cli/lan-ip.js +18 -60
- package/lib/cli/launch.js +46 -127
- package/lib/cli/live.js +37 -111
- package/lib/cli/local-ip.js +16 -53
- package/lib/cli/logs.js +7 -35
- package/lib/cli/open.js +11 -45
- package/lib/cli/program.js +145 -167
- package/lib/cli/ps.js +36 -105
- package/lib/cli/refresh-config.js +18 -62
- package/lib/cli/run.js +8 -39
- package/lib/cli/status.js +41 -201
- package/lib/cli/updates.js +68 -160
- package/lib/cli/util/get-or-initialise-navy.js +14 -57
- package/lib/cli/util/import.js +33 -83
- package/lib/cli/util/index.js +10 -12
- package/lib/cli/util/reconfigure.js +12 -102
- package/lib/cli/wait-for-healthy.js +53 -100
- package/lib/config-provider.js +25 -127
- package/lib/config-providers/filesystem/index.js +58 -235
- package/lib/config-providers/npm/__tests__/util.js +3 -6
- package/lib/config-providers/npm/index.js +60 -231
- package/lib/config-providers/npm/util.js +6 -9
- package/lib/config.js +39 -76
- package/lib/driver-logging.js +23 -28
- package/lib/driver.js +5 -7
- package/lib/drivers/docker-compose/client.js +64 -172
- package/lib/drivers/docker-compose/index.js +153 -464
- package/lib/errors.js +27 -61
- package/lib/http-proxy.js +72 -158
- package/lib/index.js +26 -29
- package/lib/middleware/add-service-proxy-config.js +76 -0
- package/lib/middleware/develop.js +9 -23
- package/lib/middleware/helpers.js +20 -25
- package/lib/middleware/port-override.js +15 -37
- package/lib/middleware/set-env-vars.js +14 -18
- package/lib/middleware/set-image.js +12 -18
- package/lib/middleware/set-logging-driver.js +14 -18
- package/lib/middleware/tag-override.js +11 -19
- package/lib/navy/default-middleware.js +13 -27
- package/lib/navy/index.js +438 -1761
- package/lib/navy/middleware.js +15 -100
- package/lib/navy/plugin-interface.js +28 -108
- package/lib/navy/state.js +58 -147
- package/lib/navy/util.js +2 -1
- package/lib/service.js +5 -3
- package/lib/util/__tests__/external-ip.js +20 -96
- package/lib/util/__tests__/registry-client.js +11 -24
- package/lib/util/__tests__/service-host.js +19 -116
- package/lib/util/docker-client.js +10 -13
- package/lib/util/exec-async.js +9 -27
- package/lib/util/external-ip.js +48 -126
- package/lib/util/fs.js +7 -6
- package/lib/util/get-lan-ip.js +15 -52
- package/lib/util/has-update.js +23 -73
- package/lib/util/https.js +213 -0
- package/lib/util/navyrc.js +12 -50
- package/lib/util/registry-client.js +41 -112
- package/lib/util/service-host.js +40 -129
- package/lib/util/table.js +11 -21
- package/package.json +14 -14
- package/LICENSE +0 -21
- package/lib/middleware/add-virtual-hosts.js +0 -147
package/lib/cli/program.js
CHANGED
|
@@ -1,40 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
4
|
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
8
|
+
exports.default = void 0;
|
|
6
9
|
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
10
|
-
|
|
11
|
-
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
|
|
12
|
-
|
|
13
|
-
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
|
|
14
|
-
|
|
15
|
-
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
|
|
16
|
-
|
|
17
|
-
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
|
10
|
+
var _commander = _interopRequireDefault(require("commander"));
|
|
18
11
|
|
|
19
|
-
var
|
|
12
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
20
13
|
|
|
21
|
-
var
|
|
14
|
+
var _errors = require("../errors");
|
|
22
15
|
|
|
23
|
-
var
|
|
16
|
+
var _config = require("../config");
|
|
24
17
|
|
|
25
|
-
var
|
|
18
|
+
var _driverLogging = require("../driver-logging");
|
|
26
19
|
|
|
27
|
-
var
|
|
20
|
+
var _configProvider = require("../config-provider");
|
|
28
21
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var _driverLogging = require('../driver-logging');
|
|
32
|
-
|
|
33
|
-
var _configProvider = require('../config-provider');
|
|
34
|
-
|
|
35
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
|
-
|
|
37
|
-
var loadingLabelMap = {
|
|
22
|
+
const loadingLabelMap = {
|
|
38
23
|
destroy: 'Destroying services...',
|
|
39
24
|
start: 'Starting services...',
|
|
40
25
|
stop: 'Stopping services...',
|
|
@@ -49,26 +34,30 @@ var loadingLabelMap = {
|
|
|
49
34
|
resetPort: 'Resetting port mapping...'
|
|
50
35
|
};
|
|
51
36
|
|
|
52
|
-
function removeFirstLineFromStackTrace(
|
|
53
|
-
|
|
37
|
+
function removeFirstLineFromStackTrace(stack) {
|
|
38
|
+
var _stack$split, _stack$split$slice;
|
|
39
|
+
|
|
40
|
+
return stack === null || stack === void 0 ? void 0 : (_stack$split = stack.split('\n')) === null || _stack$split === void 0 ? void 0 : (_stack$split$slice = _stack$split.slice(1)) === null || _stack$split$slice === void 0 ? void 0 : _stack$split$slice.join('\n');
|
|
54
41
|
}
|
|
55
42
|
|
|
56
43
|
function wrapper(res) {
|
|
57
44
|
if (res.catch) {
|
|
58
|
-
res.catch(
|
|
59
|
-
(0, _driverLogging.stopDriverLogging)({
|
|
45
|
+
res.catch(ex => {
|
|
46
|
+
(0, _driverLogging.stopDriverLogging)({
|
|
47
|
+
success: false
|
|
48
|
+
});
|
|
60
49
|
|
|
61
50
|
if (ex instanceof _errors.NavyError) {
|
|
62
51
|
ex.prettyPrint();
|
|
63
52
|
} else if (ex.name === 'Invariant Violation') {
|
|
64
53
|
console.log();
|
|
65
|
-
console.log(
|
|
54
|
+
console.log(_chalk.default.bgRed(_chalk.default.bold(' ' + ex.name + ' ')));
|
|
66
55
|
console.log();
|
|
67
56
|
console.log(' ' + ex.message.substring(ex.message.indexOf(': ') + 2));
|
|
68
57
|
console.log();
|
|
69
|
-
console.log(' ' +
|
|
58
|
+
console.log(' ' + _chalk.default.blue('Run') + ' ' + _chalk.default.bold('navy doctor') + ' ' + _chalk.default.blue('to attempt troubleshooting'));
|
|
70
59
|
console.log();
|
|
71
|
-
console.log(
|
|
60
|
+
console.log(_chalk.default.dim(removeFirstLineFromStackTrace(ex.stack)));
|
|
72
61
|
console.log();
|
|
73
62
|
} else {
|
|
74
63
|
console.error(ex.stack);
|
|
@@ -81,185 +70,174 @@ function wrapper(res) {
|
|
|
81
70
|
return res;
|
|
82
71
|
}
|
|
83
72
|
|
|
84
|
-
function basicCliWrapper(fnName) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(maybeServices) {
|
|
91
|
-
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
92
|
-
args[_key - 1] = arguments[_key];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
var _require, getNavy, opts, otherArgs, envName, navy, returnVal;
|
|
96
|
-
|
|
97
|
-
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
98
|
-
while (1) {
|
|
99
|
-
switch (_context.prev = _context.next) {
|
|
100
|
-
case 0:
|
|
101
|
-
_require = require('../navy'), getNavy = _require.getNavy;
|
|
102
|
-
opts = args.length === 0 ? maybeServices : args[args.length - 1];
|
|
103
|
-
otherArgs = args.slice(0, args.length - 1);
|
|
104
|
-
envName = opts.navy;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (wrapperOpts.serviceBasedAlias && maybeServices.length) {
|
|
108
|
-
console.log('This command should not be called with a list of services. calling \'' + wrapperOpts.serviceBasedAlias + '\' instead');
|
|
109
|
-
fnName = wrapperOpts.serviceBasedAlias;
|
|
110
|
-
maybeServices = maybeServices.split(' ');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
process.on('unhandledRejection', function (ex) {
|
|
114
|
-
(0, _driverLogging.stopDriverLogging)({ success: false });
|
|
115
|
-
|
|
116
|
-
if (ex instanceof _errors.NavyError) {
|
|
117
|
-
ex.prettyPrint();
|
|
118
|
-
} else {
|
|
119
|
-
console.error(ex.stack);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
process.exit();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
if (driverLogging) (0, _driverLogging.startDriverLogging)(loadingLabelMap[fnName]);
|
|
126
|
-
|
|
127
|
-
navy = getNavy(envName);
|
|
128
|
-
_context.next = 10;
|
|
129
|
-
return navy.ensurePluginsLoaded();
|
|
73
|
+
function basicCliWrapper(fnName, wrapperOpts = {}) {
|
|
74
|
+
const driverLogging = wrapperOpts.driverLogging == null ? true : wrapperOpts.driverLogging;
|
|
75
|
+
return async function (maybeServices, ...args) {
|
|
76
|
+
const {
|
|
77
|
+
getNavy
|
|
78
|
+
} = require('../navy');
|
|
130
79
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
80
|
+
const opts = args.length === 0 ? maybeServices : args[args.length - 1];
|
|
81
|
+
const otherArgs = args.slice(0, args.length - 1);
|
|
82
|
+
const envName = opts.navy;
|
|
134
83
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
84
|
+
if (wrapperOpts.serviceBasedAlias && maybeServices.length) {
|
|
85
|
+
console.log(`This command should not be called with a list of services. calling '${wrapperOpts.serviceBasedAlias}' instead`);
|
|
86
|
+
fnName = wrapperOpts.serviceBasedAlias;
|
|
87
|
+
maybeServices = maybeServices.split(' ');
|
|
88
|
+
}
|
|
138
89
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
90
|
+
process.on('unhandledRejection', ex => {
|
|
91
|
+
(0, _driverLogging.stopDriverLogging)({
|
|
92
|
+
success: false
|
|
93
|
+
});
|
|
143
94
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
95
|
+
if (ex instanceof _errors.NavyError) {
|
|
96
|
+
ex.prettyPrint();
|
|
97
|
+
} else {
|
|
98
|
+
console.error(ex.stack);
|
|
99
|
+
}
|
|
147
100
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
101
|
+
process.exit();
|
|
102
|
+
});
|
|
103
|
+
if (driverLogging) (0, _driverLogging.startDriverLogging)(loadingLabelMap[fnName]);
|
|
104
|
+
const navy = getNavy(envName);
|
|
105
|
+
await navy.ensurePluginsLoaded();
|
|
106
|
+
await navy.emitAsync(`cli.before.${fnName}`, fnName);
|
|
107
|
+
const returnVal = await navy[fnName](Array.isArray(maybeServices) && maybeServices.length === 0 ? undefined : maybeServices, ...otherArgs);
|
|
108
|
+
await navy.emitAsync(`cli.after.${fnName}`, fnName);
|
|
109
|
+
if (driverLogging) (0, _driverLogging.stopDriverLogging)();
|
|
110
|
+
|
|
111
|
+
if (Array.isArray(returnVal)) {
|
|
112
|
+
return console.log(returnVal.join('\n'));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (returnVal != null) {
|
|
116
|
+
console.log(returnVal);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
152
120
|
|
|
153
|
-
|
|
121
|
+
function lazyRequire(path) {
|
|
122
|
+
return function (...args) {
|
|
123
|
+
const mod = require(path);
|
|
154
124
|
|
|
155
|
-
|
|
125
|
+
return wrapper((mod.default || mod)(...args));
|
|
126
|
+
};
|
|
127
|
+
}
|
|
156
128
|
|
|
157
|
-
|
|
158
|
-
console.log(returnVal);
|
|
159
|
-
}
|
|
129
|
+
const defaultNavy = process.env.NAVY_NAME || (0, _config.getConfig)().defaultNavy;
|
|
160
130
|
|
|
161
|
-
|
|
162
|
-
case 'end':
|
|
163
|
-
return _context.stop();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}, _callee, this);
|
|
167
|
-
}));
|
|
131
|
+
const importCommand = _commander.default.command('import').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Imports docker compose configuration from the current working directory and initialises a new navy').action(lazyRequire('./import'));
|
|
168
132
|
|
|
169
|
-
|
|
170
|
-
return _ref.apply(this, arguments);
|
|
171
|
-
};
|
|
172
|
-
}();
|
|
173
|
-
}
|
|
133
|
+
(0, _configProvider.getImportCommandLineOptions)().forEach(opt => importCommand.option(...opt));
|
|
174
134
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
};
|
|
180
|
-
}
|
|
135
|
+
_commander.default.command('launch [services...]').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Launches the given services in a navy').action(lazyRequire('./launch')).on('--help', () => console.log(`
|
|
136
|
+
This will prompt you for the services that you want to bring up.
|
|
137
|
+
You can optionally provide the names of services to bring up which will disable the interactive prompt.
|
|
138
|
+
`));
|
|
181
139
|
|
|
182
|
-
|
|
140
|
+
_commander.default.command('destroy').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Destroys a navy and all related data and services').action(basicCliWrapper('destroy', {
|
|
141
|
+
serviceBasedAlias: 'kill'
|
|
142
|
+
})).on('--help', () => console.log(`
|
|
143
|
+
This will destroy an entire navy and all of its data and services.
|
|
183
144
|
|
|
184
|
-
|
|
145
|
+
Examples:
|
|
146
|
+
$ navy destroy # destroy "${defaultNavy}" navy
|
|
147
|
+
$ navy destroy -e dev # destroy "dev" navy
|
|
148
|
+
$ navy destroy -e test # destroy "test" navy
|
|
149
|
+
`));
|
|
185
150
|
|
|
186
|
-
(
|
|
187
|
-
return importCommand.option.apply(importCommand, (0, _toConsumableArray3.default)(opt));
|
|
188
|
-
});
|
|
151
|
+
_commander.default.command('delete').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Removes a navy configuration without removing any docker containers or services').action(basicCliWrapper('delete'));
|
|
189
152
|
|
|
190
|
-
|
|
191
|
-
return console.log('\n This will prompt you for the services that you want to bring up.\n You can optionally provide the names of services to bring up which will disable the interactive prompt.\n ');
|
|
192
|
-
});
|
|
153
|
+
_commander.default.command('ps').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).option('--json', 'output JSON instead of a table').description('Lists the running services for a navy').action(lazyRequire('./ps'));
|
|
193
154
|
|
|
194
|
-
|
|
195
|
-
return console.log('\n This will destroy an entire navy and all of its data and services.\n\n Examples:\n $ navy destroy # destroy "' + defaultNavy + '" navy\n $ navy destroy -e dev # destroy "dev" navy\n $ navy destroy -e test # destroy "test" navy\n ');
|
|
196
|
-
});
|
|
155
|
+
_commander.default.command('start [services...]').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Starts the given services').action(basicCliWrapper('start'));
|
|
197
156
|
|
|
198
|
-
|
|
157
|
+
_commander.default.command('stop [services...]').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Stops the given services').action(basicCliWrapper('stop'));
|
|
199
158
|
|
|
200
|
-
|
|
159
|
+
_commander.default.command('restart [services...]').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Restarts the given services').action(basicCliWrapper('restart'));
|
|
201
160
|
|
|
202
|
-
|
|
161
|
+
_commander.default.command('kill [services...]').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Kills the given services').action(basicCliWrapper('kill'));
|
|
203
162
|
|
|
204
|
-
|
|
163
|
+
_commander.default.command('rm [services...]').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Removes the given services').action(basicCliWrapper('rm'));
|
|
205
164
|
|
|
206
|
-
|
|
165
|
+
_commander.default.command('update [services...]').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Pulls the given services\' images from their respective registries and relaunches the services').action(basicCliWrapper('update'));
|
|
207
166
|
|
|
208
|
-
|
|
167
|
+
_commander.default.command('updates').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Checks for updates for all the launched services').action(lazyRequire('./updates'));
|
|
209
168
|
|
|
210
|
-
|
|
169
|
+
_commander.default.command('logs [services...]').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Streams logs for the given services').action(lazyRequire('./logs'));
|
|
211
170
|
|
|
212
|
-
|
|
171
|
+
_commander.default.command('health').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Shows the health status for all of the launched services').action(lazyRequire('./health'));
|
|
213
172
|
|
|
214
|
-
|
|
173
|
+
_commander.default.command('wait-for-healthy [services...]').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Waits for the given services to be healthy').action(lazyRequire('./wait-for-healthy'));
|
|
215
174
|
|
|
216
|
-
|
|
175
|
+
_commander.default.command('use-tag <service> <tag>').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Uses a specific tag for the given service').action(basicCliWrapper('useTag'));
|
|
217
176
|
|
|
218
|
-
|
|
177
|
+
_commander.default.command('reset-tag <service>').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Resets any tag override on the given service').action(basicCliWrapper('resetTag'));
|
|
219
178
|
|
|
220
|
-
|
|
179
|
+
_commander.default.command('https [services...]').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).option('-d, --disable <service>', 'disable https (deletes cert) for a given service', null).description('Prints or enables HTTPS services').action(lazyRequire('./https')).on('--help', () => console.log(`
|
|
180
|
+
Examples:
|
|
181
|
+
List urls of services that listen on https:
|
|
182
|
+
$ navy https
|
|
221
183
|
|
|
222
|
-
|
|
184
|
+
Enable https for mywebservice and anotherwebservice services
|
|
185
|
+
$ navy https mywebservice anotherwebservice
|
|
223
186
|
|
|
224
|
-
|
|
187
|
+
Disable https for mywebservice
|
|
188
|
+
$ navy https -d mywebservice
|
|
189
|
+
`));
|
|
225
190
|
|
|
226
|
-
|
|
191
|
+
_commander.default.command('use-port <service> <internal> <external>').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Uses a specific external port for the given service and internal port').action(basicCliWrapper('usePort'));
|
|
227
192
|
|
|
228
|
-
|
|
193
|
+
_commander.default.command('reset-port <service> <internal>').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Resets a specific external port mapping set by use-port').action(basicCliWrapper('resetPort'));
|
|
229
194
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
})
|
|
195
|
+
_commander.default.command('url <service>').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Prints the external URL for the given service if it is a web service').action(basicCliWrapper('url', {
|
|
196
|
+
driverLogging: false
|
|
197
|
+
})).on('--help', () => console.log(`
|
|
198
|
+
Examples:
|
|
199
|
+
$ navy url mywebserver
|
|
200
|
+
http://mywebserver.dev.127.0.0.1.nip.io
|
|
201
|
+
`));
|
|
233
202
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
203
|
+
_commander.default.command('open <service>').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Opens the given service in the default web browser, if the service is configured with a URL').action(lazyRequire('./open')).on('--help', () => console.log(`
|
|
204
|
+
Examples:
|
|
205
|
+
$ navy open mywebserver
|
|
206
|
+
Opening mywebserver...
|
|
207
|
+
`));
|
|
237
208
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
})
|
|
209
|
+
_commander.default.command('port <service> <port>').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Prints the external port for the given internal port of the given service').action(basicCliWrapper('port', {
|
|
210
|
+
driverLogging: false
|
|
211
|
+
})).on('--help', () => console.log(`
|
|
212
|
+
Examples:
|
|
213
|
+
$ navy port mywebserver 80
|
|
214
|
+
35821
|
|
215
|
+
`));
|
|
241
216
|
|
|
242
|
-
|
|
217
|
+
_commander.default.command('available-services').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Prints the names of the services that are launched or can be launched').action(basicCliWrapper('getAvailableServiceNames', {
|
|
218
|
+
driverLogging: false
|
|
219
|
+
}));
|
|
243
220
|
|
|
244
|
-
|
|
221
|
+
_commander.default.command('develop [service]').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Puts the given service into development using the current working directory').action(lazyRequire('./develop'));
|
|
245
222
|
|
|
246
|
-
|
|
223
|
+
_commander.default.command('live [service]').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Takes the given service out of development').action(lazyRequire('./live'));
|
|
247
224
|
|
|
248
|
-
|
|
225
|
+
_commander.default.command('run <name> [args...]').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Runs a named command specific to the given Navy').action(lazyRequire('./run'));
|
|
249
226
|
|
|
250
|
-
|
|
227
|
+
_commander.default.command('refresh-config').option('-e, --navy [env]', `set the navy name to be used [${defaultNavy}]`, defaultNavy).description('Refreshes the configuration for the given Navy').action(lazyRequire('./refresh-config'));
|
|
251
228
|
|
|
252
|
-
|
|
229
|
+
_commander.default.command('status').option('--json', 'output JSON instead of a table').description('List all of the imported navies').action(lazyRequire('./status'));
|
|
253
230
|
|
|
254
|
-
|
|
231
|
+
_commander.default.command('doctor').description('Identifies and tries to fix some common issues which might cause Navy to stop working').action(lazyRequire('./doctor'));
|
|
255
232
|
|
|
256
|
-
|
|
233
|
+
_commander.default.command('config').description('Modify and get Navy global config - run `navy config` for help').action(lazyRequire('./config/wrapper'));
|
|
257
234
|
|
|
258
|
-
|
|
235
|
+
_commander.default.command('external-ip').description('Prints the external IP which services are accessible on').action(lazyRequire('./external-ip'));
|
|
259
236
|
|
|
260
|
-
|
|
237
|
+
_commander.default.command('use-lan-ip').description('Use your LAN ip address for connecting to Navy services').action(lazyRequire('./lan-ip'));
|
|
261
238
|
|
|
262
|
-
|
|
239
|
+
_commander.default.command('use-local-ip').description('Use your local ip address (127.0.0.1) for connecting to Navy services').action(lazyRequire('./local-ip'));
|
|
263
240
|
|
|
264
|
-
|
|
241
|
+
var _default = _commander.default;
|
|
242
|
+
exports.default = _default;
|
|
265
243
|
module.exports = exports.default;
|
package/lib/cli/ps.js
CHANGED
|
@@ -1,57 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
4
|
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
8
|
+
exports.default = _default;
|
|
6
9
|
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
10
|
-
|
|
11
|
-
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
|
|
12
|
-
|
|
13
|
-
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
|
|
14
|
-
|
|
15
|
-
var _stringify = require('babel-runtime/core-js/json/stringify');
|
|
16
|
-
|
|
17
|
-
var _stringify2 = _interopRequireDefault(_stringify);
|
|
18
|
-
|
|
19
|
-
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
|
|
20
|
-
|
|
21
|
-
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
|
22
|
-
|
|
23
|
-
var _keys = require('babel-runtime/core-js/object/keys');
|
|
24
|
-
|
|
25
|
-
var _keys2 = _interopRequireDefault(_keys);
|
|
26
|
-
|
|
27
|
-
var _chalk = require('chalk');
|
|
28
|
-
|
|
29
|
-
var _chalk2 = _interopRequireDefault(_chalk);
|
|
10
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
30
11
|
|
|
31
|
-
var _ = require(
|
|
12
|
+
var _ = require("../");
|
|
32
13
|
|
|
33
|
-
var _serviceHost = require(
|
|
14
|
+
var _serviceHost = require("../util/service-host");
|
|
34
15
|
|
|
35
|
-
var _table = require(
|
|
16
|
+
var _table = _interopRequireDefault(require("../util/table"));
|
|
36
17
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
|
-
|
|
41
|
-
var SMALL_WINDOW_COLUMNS = 185;
|
|
18
|
+
const SMALL_WINDOW_COLUMNS = 185;
|
|
42
19
|
|
|
43
20
|
function getStatus(service, state) {
|
|
44
|
-
|
|
21
|
+
let statusString = service.status === 'exited' ? _chalk.default.red(service.status) : service.status;
|
|
45
22
|
|
|
46
23
|
if (state && state.services && state.services[service.name]) {
|
|
47
|
-
|
|
24
|
+
const serviceState = state.services[service.name];
|
|
48
25
|
|
|
49
26
|
if (serviceState._develop) {
|
|
50
|
-
statusString += ' ' +
|
|
27
|
+
statusString += ' ' + _chalk.default.yellow('(development)');
|
|
51
28
|
}
|
|
52
29
|
|
|
53
30
|
if (serviceState._tag) {
|
|
54
|
-
statusString += ' ' +
|
|
31
|
+
statusString += ' ' + _chalk.default.cyan(`@ ${serviceState._tag}`);
|
|
55
32
|
}
|
|
56
33
|
}
|
|
57
34
|
|
|
@@ -63,77 +40,31 @@ function getPorts(service) {
|
|
|
63
40
|
return '-';
|
|
64
41
|
}
|
|
65
42
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return ports[portKey] ? ports[portKey].map(function (conf) {
|
|
71
|
-
return conf.HostPort;
|
|
72
|
-
}).join(', ') + '->' + portKey : portKey;
|
|
43
|
+
const ports = service.raw.NetworkSettings.Ports;
|
|
44
|
+
const portKeys = Object.keys(ports);
|
|
45
|
+
return portKeys.map(portKey => {
|
|
46
|
+
return ports[portKey] ? `${ports[portKey].map(conf => conf.HostPort).join(', ')}->${portKey}` : portKey;
|
|
73
47
|
}).join(', ');
|
|
74
48
|
}
|
|
75
49
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
case 6:
|
|
97
|
-
state = _context.sent;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// $FlowIgnore getWindowSize not on type
|
|
101
|
-
isSmallConsole = process.stdout.isTTY && process.stdout.getWindowSize()[0] < SMALL_WINDOW_COLUMNS;
|
|
102
|
-
|
|
103
|
-
if (!opts.json) {
|
|
104
|
-
_context.next = 10;
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return _context.abrupt('return', console.log((0, _stringify2.default)(ps, null, 2)));
|
|
109
|
-
|
|
110
|
-
case 10:
|
|
111
|
-
if (!isSmallConsole) {
|
|
112
|
-
_context.next = 12;
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return _context.abrupt('return', console.log((0, _table2.default)([['ID', 'NAME', 'STATUS', 'PORTS', 'URL']].concat((0, _toConsumableArray3.default)(ps.map(function (service) {
|
|
117
|
-
return [service.id.substring(0, 12), service.name, getStatus(service, state), getPorts(service), getDisplayUrl((0, _serviceHost.getUrlFromService)(service))];
|
|
118
|
-
}))))));
|
|
119
|
-
|
|
120
|
-
case 12:
|
|
121
|
-
|
|
122
|
-
console.log((0, _table2.default)([['ID', 'NAME', 'IMAGE', 'STATUS', 'PORTS', 'URL']].concat((0, _toConsumableArray3.default)(ps.map(function (service) {
|
|
123
|
-
return [service.id.substring(0, 12), service.name, service.image, getStatus(service, state), getPorts(service), getDisplayUrl((0, _serviceHost.getUrlFromService)(service))];
|
|
124
|
-
})))));
|
|
125
|
-
|
|
126
|
-
case 13:
|
|
127
|
-
case 'end':
|
|
128
|
-
return _context.stop();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}, _callee, this);
|
|
132
|
-
}));
|
|
133
|
-
|
|
134
|
-
return function (_x) {
|
|
135
|
-
return _ref.apply(this, arguments);
|
|
136
|
-
};
|
|
137
|
-
}();
|
|
50
|
+
const getDisplayUrl = serviceUrl => serviceUrl != null ? serviceUrl : '-';
|
|
51
|
+
|
|
52
|
+
async function _default(opts) {
|
|
53
|
+
const navy = (0, _.getNavy)(opts.navy);
|
|
54
|
+
const ps = await navy.ps();
|
|
55
|
+
const state = await navy.getState(); // $FlowIgnore getWindowSize not on type
|
|
56
|
+
|
|
57
|
+
const isSmallConsole = process.stdout.isTTY && process.stdout.getWindowSize()[0] < SMALL_WINDOW_COLUMNS;
|
|
58
|
+
|
|
59
|
+
if (opts.json) {
|
|
60
|
+
return console.log(JSON.stringify(ps, null, 2));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (isSmallConsole) {
|
|
64
|
+
return console.log((0, _table.default)([['ID', 'NAME', 'STATUS', 'PORTS', 'URL'], ...ps.map(service => [service.id.substring(0, 12), service.name, getStatus(service, state), getPorts(service), getDisplayUrl((0, _serviceHost.getUrlFromService)(service))])]));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
console.log((0, _table.default)([['ID', 'NAME', 'IMAGE', 'STATUS', 'PORTS', 'URL'], ...ps.map(service => [service.id.substring(0, 12), service.name, service.image, getStatus(service, state), getPorts(service), getDisplayUrl((0, _serviceHost.getUrlFromService)(service))])]));
|
|
68
|
+
}
|
|
138
69
|
|
|
139
70
|
module.exports = exports.default;
|