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
|
@@ -1,194 +1,86 @@
|
|
|
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
|
});
|
|
6
|
-
|
|
7
|
-
var _regenerator = require('babel-runtime/regenerator');
|
|
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);
|
|
18
|
-
|
|
19
8
|
exports.createComposeClient = createComposeClient;
|
|
20
9
|
|
|
21
|
-
var _path = require(
|
|
22
|
-
|
|
23
|
-
var _path2 = _interopRequireDefault(_path);
|
|
24
|
-
|
|
25
|
-
var _invariant = require('invariant');
|
|
26
|
-
|
|
27
|
-
var _invariant2 = _interopRequireDefault(_invariant);
|
|
28
|
-
|
|
29
|
-
var _fs = require('../../util/fs');
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
30
11
|
|
|
31
|
-
var
|
|
12
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
32
13
|
|
|
33
|
-
var
|
|
14
|
+
var _fs = _interopRequireDefault(require("../../util/fs"));
|
|
34
15
|
|
|
35
|
-
var
|
|
16
|
+
var _execAsync = require("../../util/exec-async");
|
|
36
17
|
|
|
37
|
-
var
|
|
18
|
+
var _driverLogging = require("../../driver-logging");
|
|
38
19
|
|
|
39
|
-
|
|
20
|
+
var _state = require("../../navy/state");
|
|
40
21
|
|
|
41
22
|
function createComposeClient(navy) {
|
|
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
|
-
break;
|
|
73
|
-
|
|
74
|
-
case 10:
|
|
75
|
-
_context.next = 12;
|
|
76
|
-
return client.getOriginalDockerComposeDirectory();
|
|
77
|
-
|
|
78
|
-
case 12:
|
|
79
|
-
composeOpts.cwd = _context.sent;
|
|
80
|
-
|
|
81
|
-
case 13:
|
|
82
|
-
|
|
83
|
-
composeArgs.push.apply(composeArgs, [command].concat((0, _toConsumableArray3.default)(args)));
|
|
84
|
-
|
|
85
|
-
_context.prev = 14;
|
|
86
|
-
_context.next = 17;
|
|
87
|
-
return (0, _execAsync.execAsync)('docker-compose', composeArgs, function (childProcess) {
|
|
88
|
-
if (!noLog && !pipeLog) {
|
|
89
|
-
childProcess.stdout.on('data', function (data) {
|
|
90
|
-
return (0, _driverLogging.log)(data);
|
|
91
|
-
});
|
|
92
|
-
childProcess.stderr.on('data', function (data) {
|
|
93
|
-
return (0, _driverLogging.log)(data);
|
|
94
|
-
});
|
|
95
|
-
} else if (pipeLog) {
|
|
96
|
-
childProcess.stdout.on('data', function (data) {
|
|
97
|
-
return process.stdout.write(data);
|
|
98
|
-
});
|
|
99
|
-
childProcess.stderr.on('data', function (data) {
|
|
100
|
-
return process.stderr.write(data);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}, composeOpts);
|
|
104
|
-
|
|
105
|
-
case 17:
|
|
106
|
-
return _context.abrupt('return', _context.sent);
|
|
107
|
-
|
|
108
|
-
case 20:
|
|
109
|
-
_context.prev = 20;
|
|
110
|
-
_context.t0 = _context['catch'](14);
|
|
111
|
-
|
|
112
|
-
if (_context.t0.message && _context.t0.message.indexOf('Can\'t find a suitable configuration file') !== -1) {
|
|
113
|
-
(0, _invariant2.default)(false, 'NO_DOCKER_COMPOSE_FILE: No docker-compose.yml (or valid Docker Compose config) found');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
throw _context.t0;
|
|
117
|
-
|
|
118
|
-
case 24:
|
|
119
|
-
case 'end':
|
|
120
|
-
return _context.stop();
|
|
121
|
-
}
|
|
23
|
+
const client = {
|
|
24
|
+
async exec(command, args = [], opts = {}) {
|
|
25
|
+
const composeArgs = ['-p', navy.normalisedName];
|
|
26
|
+
const {
|
|
27
|
+
useOriginalDockerComposeFiles,
|
|
28
|
+
noLog,
|
|
29
|
+
pipeLog,
|
|
30
|
+
maxBuffer
|
|
31
|
+
} = opts;
|
|
32
|
+
const composeOpts = {
|
|
33
|
+
maxBuffer: maxBuffer || Infinity
|
|
34
|
+
};
|
|
35
|
+
const composeFilePath = await client.getDockerComposeFilePath();
|
|
36
|
+
|
|
37
|
+
if (composeFilePath && !useOriginalDockerComposeFiles) {
|
|
38
|
+
composeArgs.push('-f', composeFilePath);
|
|
39
|
+
} else {
|
|
40
|
+
composeOpts.cwd = await client.getOriginalDockerComposeDirectory();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
composeArgs.push(command, ...args);
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
return await (0, _execAsync.execAsync)('docker-compose', composeArgs, childProcess => {
|
|
47
|
+
if (!noLog && !pipeLog) {
|
|
48
|
+
childProcess.stdout.on('data', data => (0, _driverLogging.log)(data));
|
|
49
|
+
childProcess.stderr.on('data', data => (0, _driverLogging.log)(data));
|
|
50
|
+
} else if (pipeLog) {
|
|
51
|
+
childProcess.stdout.on('data', data => process.stdout.write(data));
|
|
52
|
+
childProcess.stderr.on('data', data => process.stderr.write(data));
|
|
122
53
|
}
|
|
123
|
-
},
|
|
124
|
-
}
|
|
54
|
+
}, composeOpts);
|
|
55
|
+
} catch (ex) {
|
|
56
|
+
if (ex.message && ex.message.indexOf('Can\'t find a suitable configuration file') !== -1) {
|
|
57
|
+
(0, _invariant.default)(false, "NO_DOCKER_COMPOSE_FILE: No docker-compose.yml (or valid Docker Compose config) found");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
throw ex;
|
|
61
|
+
}
|
|
125
62
|
},
|
|
126
|
-
getCompiledDockerComposePath: function getCompiledDockerComposePath() {
|
|
127
|
-
return _path2.default.join((0, _state.pathToNavy)(navy.normalisedName), 'docker-compose.tmp.yml');
|
|
128
|
-
},
|
|
129
|
-
getOriginalDockerComposeDirectory: function getOriginalDockerComposeDirectory() {
|
|
130
|
-
var _this2 = this;
|
|
131
|
-
|
|
132
|
-
return (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
|
|
133
|
-
var configProvider;
|
|
134
|
-
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
|
135
|
-
while (1) {
|
|
136
|
-
switch (_context2.prev = _context2.next) {
|
|
137
|
-
case 0:
|
|
138
|
-
_context2.next = 2;
|
|
139
|
-
return navy.getConfigProvider();
|
|
140
|
-
|
|
141
|
-
case 2:
|
|
142
|
-
configProvider = _context2.sent;
|
|
143
63
|
|
|
64
|
+
getCompiledDockerComposePath() {
|
|
65
|
+
return _path.default.join((0, _state.pathToNavy)(navy.normalisedName), 'docker-compose.tmp.yml');
|
|
66
|
+
},
|
|
144
67
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
case 5:
|
|
150
|
-
case 'end':
|
|
151
|
-
return _context2.stop();
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}, _callee2, _this2);
|
|
155
|
-
}))();
|
|
68
|
+
async getOriginalDockerComposeDirectory() {
|
|
69
|
+
const configProvider = await navy.getConfigProvider();
|
|
70
|
+
(0, _invariant.default)(configProvider, "NO_CONFIG_PROVIDER: Couldn't determine config provider for navy %s", navy.name);
|
|
71
|
+
return configProvider.getNavyPath();
|
|
156
72
|
},
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
_context3.prev = 0;
|
|
167
|
-
_context3.next = 3;
|
|
168
|
-
return client.getCompiledDockerComposePath();
|
|
169
|
-
|
|
170
|
-
case 3:
|
|
171
|
-
compiledComposePath = _context3.sent;
|
|
172
|
-
_context3.next = 6;
|
|
173
|
-
return _fs2.default.statAsync(compiledComposePath);
|
|
174
|
-
|
|
175
|
-
case 6:
|
|
176
|
-
return _context3.abrupt('return', compiledComposePath);
|
|
177
|
-
|
|
178
|
-
case 9:
|
|
179
|
-
_context3.prev = 9;
|
|
180
|
-
_context3.t0 = _context3['catch'](0);
|
|
181
|
-
return _context3.abrupt('return', null);
|
|
182
|
-
|
|
183
|
-
case 12:
|
|
184
|
-
case 'end':
|
|
185
|
-
return _context3.stop();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}, _callee3, _this3, [[0, 9]]);
|
|
189
|
-
}))();
|
|
73
|
+
|
|
74
|
+
async getDockerComposeFilePath() {
|
|
75
|
+
try {
|
|
76
|
+
const compiledComposePath = await client.getCompiledDockerComposePath();
|
|
77
|
+
await _fs.default.statAsync(compiledComposePath);
|
|
78
|
+
return compiledComposePath;
|
|
79
|
+
} catch (ex) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
190
82
|
}
|
|
191
|
-
};
|
|
192
83
|
|
|
84
|
+
};
|
|
193
85
|
return client;
|
|
194
86
|
}
|