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,272 +1,101 @@
|
|
|
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 _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
|
|
12
|
-
|
|
13
|
-
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
|
14
|
-
|
|
15
|
-
var tryAndInstall = function () {
|
|
16
|
-
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(pkgName) {
|
|
17
|
-
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
18
|
-
while (1) {
|
|
19
|
-
switch (_context.prev = _context.next) {
|
|
20
|
-
case 0:
|
|
21
|
-
_context.next = 2;
|
|
22
|
-
return mkdirp(nodeModulesPath);
|
|
23
|
-
|
|
24
|
-
case 2:
|
|
25
|
-
_context.prev = 2;
|
|
26
|
-
|
|
27
|
-
// $FlowIgnore some weird bug with execSync
|
|
28
|
-
(0, _child_process.execSync)('npm info ' + pkgName + ' name', { stdio: 'ignore' });
|
|
29
|
-
_context.next = 9;
|
|
30
|
-
break;
|
|
31
|
-
|
|
32
|
-
case 6:
|
|
33
|
-
_context.prev = 6;
|
|
34
|
-
_context.t0 = _context['catch'](2);
|
|
35
|
-
throw new Error('Package "' + pkgName + '" not found or unreachable');
|
|
36
|
-
|
|
37
|
-
case 9:
|
|
38
|
-
|
|
39
|
-
// $FlowIgnore some weird bug with execSync
|
|
40
|
-
(0, _child_process.execSync)('npm i ' + pkgName, { stdio: 'inherit', cwd: npmContext });
|
|
41
|
-
|
|
42
|
-
case 10:
|
|
43
|
-
case 'end':
|
|
44
|
-
return _context.stop();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}, _callee, this, [[2, 6]]);
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
return function tryAndInstall(_x) {
|
|
51
|
-
return _ref.apply(this, arguments);
|
|
52
|
-
};
|
|
53
|
-
}();
|
|
54
|
-
|
|
55
8
|
exports.default = createNpmConfigProvider;
|
|
56
9
|
|
|
57
|
-
var _path = require(
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
58
11
|
|
|
59
|
-
var
|
|
12
|
+
var _child_process = require("child_process");
|
|
60
13
|
|
|
61
|
-
var
|
|
14
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
62
15
|
|
|
63
|
-
var
|
|
16
|
+
var _bluebird = _interopRequireDefault(require("bluebird"));
|
|
64
17
|
|
|
65
|
-
var
|
|
18
|
+
var _fs = _interopRequireDefault(require("../../util/fs"));
|
|
66
19
|
|
|
67
|
-
var
|
|
20
|
+
var _state = require("../../navy/state");
|
|
68
21
|
|
|
69
|
-
var
|
|
22
|
+
var _util = require("./util");
|
|
70
23
|
|
|
71
|
-
|
|
24
|
+
const mkdirp = _bluebird.default.promisify(require('mkdirp'));
|
|
72
25
|
|
|
73
|
-
|
|
26
|
+
const npmContext = _path.default.join((0, _state.pathToNavyRoot)(), 'npm');
|
|
74
27
|
|
|
75
|
-
|
|
28
|
+
const nodeModulesPath = _path.default.join(npmContext, 'node_modules');
|
|
76
29
|
|
|
77
|
-
|
|
30
|
+
async function tryAndInstall(pkgName) {
|
|
31
|
+
await mkdirp(nodeModulesPath);
|
|
78
32
|
|
|
79
|
-
|
|
33
|
+
try {
|
|
34
|
+
// $FlowIgnore some weird bug with execSync
|
|
35
|
+
(0, _child_process.execSync)(`npm info ${pkgName} name`, {
|
|
36
|
+
stdio: 'ignore'
|
|
37
|
+
});
|
|
38
|
+
} catch (ex) {
|
|
39
|
+
throw new Error(`Package "${pkgName}" not found or unreachable`);
|
|
40
|
+
} // $FlowIgnore some weird bug with execSync
|
|
80
41
|
|
|
81
|
-
var mkdirp = _bluebird2.default.promisify(require('mkdirp'));
|
|
82
42
|
|
|
83
|
-
|
|
84
|
-
|
|
43
|
+
(0, _child_process.execSync)(`npm i ${pkgName}`, {
|
|
44
|
+
stdio: 'inherit',
|
|
45
|
+
cwd: npmContext
|
|
46
|
+
});
|
|
47
|
+
}
|
|
85
48
|
|
|
86
49
|
function createNpmConfigProvider(navy) {
|
|
87
50
|
return {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
|
94
|
-
while (1) {
|
|
95
|
-
switch (_context2.prev = _context2.next) {
|
|
96
|
-
case 0:
|
|
97
|
-
_context2.next = 2;
|
|
98
|
-
return navy.getState();
|
|
99
|
-
|
|
100
|
-
case 2:
|
|
101
|
-
envState = _context2.sent;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
(0, _invariant2.default)(!!envState, 'STATE_NONEXISTANT: State doesn\'t exist for navy %s', navy.name);
|
|
105
|
-
(0, _invariant2.default)(!!envState.npmPackage, 'NPM_PROVIDER_REQUIRES_PACKAGE: NPM config provider requires an NPM package for %s', navy.name);
|
|
106
|
-
|
|
107
|
-
_context2.next = 7;
|
|
108
|
-
return (0, _util.pathToModule)(nodeModulesPath, envState.npmPackage);
|
|
109
|
-
|
|
110
|
-
case 7:
|
|
111
|
-
navyPath = _context2.sent;
|
|
51
|
+
async getNavyPath() {
|
|
52
|
+
const envState = await navy.getState();
|
|
53
|
+
(0, _invariant.default)(!!envState, "STATE_NONEXISTANT: State doesn't exist for navy %s", navy.name);
|
|
54
|
+
(0, _invariant.default)(!!envState.npmPackage, "NPM_PROVIDER_REQUIRES_PACKAGE: NPM config provider requires an NPM package for %s", navy.name);
|
|
55
|
+
const navyPath = await (0, _util.pathToModule)(nodeModulesPath, envState.npmPackage);
|
|
112
56
|
|
|
57
|
+
_fs.default.accessSync(navyPath); // see if path exists
|
|
113
58
|
|
|
114
|
-
_fs2.default.accessSync(navyPath); // see if path exists
|
|
115
59
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
case 10:
|
|
119
|
-
case 'end':
|
|
120
|
-
return _context2.stop();
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}, _callee2, _this);
|
|
124
|
-
}))();
|
|
60
|
+
return navyPath;
|
|
125
61
|
},
|
|
126
|
-
getNavyFilePath: function getNavyFilePath() {
|
|
127
|
-
var _this2 = this;
|
|
128
|
-
|
|
129
|
-
return (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
|
|
130
|
-
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
|
131
|
-
while (1) {
|
|
132
|
-
switch (_context3.prev = _context3.next) {
|
|
133
|
-
case 0:
|
|
134
|
-
_context3.t0 = _path2.default;
|
|
135
|
-
_context3.next = 3;
|
|
136
|
-
return _this2.getNavyPath();
|
|
137
|
-
|
|
138
|
-
case 3:
|
|
139
|
-
_context3.t1 = _context3.sent;
|
|
140
|
-
return _context3.abrupt('return', _context3.t0.join.call(_context3.t0, _context3.t1, 'Navyfile.js'));
|
|
141
62
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return _context3.stop();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}, _callee3, _this2);
|
|
148
|
-
}))();
|
|
63
|
+
async getNavyFilePath() {
|
|
64
|
+
return _path.default.join(await this.getNavyPath(), 'Navyfile.js');
|
|
149
65
|
},
|
|
150
|
-
refreshConfig: function refreshConfig() {
|
|
151
|
-
var _this3 = this;
|
|
152
|
-
|
|
153
|
-
return (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4() {
|
|
154
|
-
var envState;
|
|
155
|
-
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
|
156
|
-
while (1) {
|
|
157
|
-
switch (_context4.prev = _context4.next) {
|
|
158
|
-
case 0:
|
|
159
|
-
_context4.next = 2;
|
|
160
|
-
return navy.getState();
|
|
161
|
-
|
|
162
|
-
case 2:
|
|
163
|
-
envState = _context4.sent;
|
|
164
|
-
|
|
165
66
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
case 7:
|
|
173
|
-
return _context4.abrupt('return', true);
|
|
174
|
-
|
|
175
|
-
case 8:
|
|
176
|
-
case 'end':
|
|
177
|
-
return _context4.stop();
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}, _callee4, _this3);
|
|
181
|
-
}))();
|
|
67
|
+
async refreshConfig() {
|
|
68
|
+
const envState = await navy.getState();
|
|
69
|
+
(0, _invariant.default)(!!envState, "STATE_NONEXISTANT: State doesn't exist for navy %s", navy.name);
|
|
70
|
+
(0, _invariant.default)(!!envState.npmPackage, "NPM_PROVIDER_REQUIRES_PACKAGE: NPM config provider requires an NPM package for %s", navy.name);
|
|
71
|
+
await tryAndInstall(envState.npmPackage);
|
|
72
|
+
return true;
|
|
182
73
|
},
|
|
183
|
-
getLocationDisplayName: function getLocationDisplayName() {
|
|
184
|
-
var _this4 = this;
|
|
185
|
-
|
|
186
|
-
return (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5() {
|
|
187
|
-
var envState;
|
|
188
|
-
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
|
189
|
-
while (1) {
|
|
190
|
-
switch (_context5.prev = _context5.next) {
|
|
191
|
-
case 0:
|
|
192
|
-
_context5.next = 2;
|
|
193
|
-
return navy.getState();
|
|
194
|
-
|
|
195
|
-
case 2:
|
|
196
|
-
envState = _context5.sent;
|
|
197
74
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
case 5:
|
|
204
|
-
case 'end':
|
|
205
|
-
return _context5.stop();
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}, _callee5, _this4);
|
|
209
|
-
}))();
|
|
75
|
+
async getLocationDisplayName() {
|
|
76
|
+
const envState = await navy.getState();
|
|
77
|
+
(0, _invariant.default)(!!envState, "STATE_NONEXISTANT: State doesn't exist for navy %s", navy.name);
|
|
78
|
+
return envState.npmPackage;
|
|
210
79
|
},
|
|
211
|
-
isDangling: function isDangling() {
|
|
212
|
-
var _this5 = this;
|
|
213
|
-
|
|
214
|
-
return (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6() {
|
|
215
|
-
var envState;
|
|
216
|
-
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
|
217
|
-
while (1) {
|
|
218
|
-
switch (_context6.prev = _context6.next) {
|
|
219
|
-
case 0:
|
|
220
|
-
_context6.next = 2;
|
|
221
|
-
return navy.getState();
|
|
222
|
-
|
|
223
|
-
case 2:
|
|
224
|
-
envState = _context6.sent;
|
|
225
|
-
return _context6.abrupt('return', !envState || !envState.npmPackage);
|
|
226
80
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}, _callee6, _this5);
|
|
233
|
-
}))();
|
|
81
|
+
async isDangling() {
|
|
82
|
+
const envState = await navy.getState();
|
|
83
|
+
return !envState || !envState.npmPackage;
|
|
234
84
|
}
|
|
85
|
+
|
|
235
86
|
};
|
|
236
87
|
}
|
|
237
88
|
|
|
238
89
|
createNpmConfigProvider.importCliOptions = [['--npm-package [package]', 'set the NPM package to use for docker compose config']];
|
|
239
90
|
|
|
240
|
-
createNpmConfigProvider.getImportOptionsForCLI =
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
_context7.next = 3;
|
|
252
|
-
return tryAndInstall(opts.npmPackage);
|
|
253
|
-
|
|
254
|
-
case 3:
|
|
255
|
-
return _context7.abrupt('return', {
|
|
256
|
-
configProvider: 'npm',
|
|
257
|
-
npmPackage: opts.npmPackage
|
|
258
|
-
});
|
|
91
|
+
createNpmConfigProvider.getImportOptionsForCLI = async opts => {
|
|
92
|
+
if (opts.npmPackage) {
|
|
93
|
+
await tryAndInstall(opts.npmPackage);
|
|
94
|
+
return {
|
|
95
|
+
configProvider: 'npm',
|
|
96
|
+
npmPackage: opts.npmPackage
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
};
|
|
259
100
|
|
|
260
|
-
case 4:
|
|
261
|
-
case 'end':
|
|
262
|
-
return _context7.stop();
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}, _callee7, undefined);
|
|
266
|
-
}));
|
|
267
|
-
|
|
268
|
-
return function (_x2) {
|
|
269
|
-
return _ref2.apply(this, arguments);
|
|
270
|
-
};
|
|
271
|
-
}();
|
|
272
101
|
module.exports = exports.default;
|
|
@@ -1,18 +1,15 @@
|
|
|
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
8
|
exports.pathToModule = pathToModule;
|
|
7
9
|
|
|
8
|
-
var _path = require(
|
|
9
|
-
|
|
10
|
-
var _path2 = _interopRequireDefault(_path);
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
13
11
|
|
|
14
12
|
function pathToModule(nodeModulesPath, pkgName) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return _path2.default.join(nodeModulesPath, pkgNameWithNoTags);
|
|
13
|
+
const pkgNameWithNoTags = pkgName.lastIndexOf('@') !== 0 && pkgName.lastIndexOf('@') !== -1 ? pkgName.substring(0, pkgName.lastIndexOf('@')) : pkgName;
|
|
14
|
+
return _path.default.join(nodeModulesPath, pkgNameWithNoTags);
|
|
18
15
|
}
|
package/lib/config.js
CHANGED
|
@@ -1,93 +1,46 @@
|
|
|
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
|
-
exports.
|
|
7
|
-
|
|
8
|
-
var _regenerator = require('babel-runtime/regenerator');
|
|
9
|
-
|
|
10
|
-
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
11
|
-
|
|
12
|
-
var _stringify = require('babel-runtime/core-js/json/stringify');
|
|
13
|
-
|
|
14
|
-
var _stringify2 = _interopRequireDefault(_stringify);
|
|
15
|
-
|
|
16
|
-
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
|
|
17
|
-
|
|
18
|
-
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
|
19
|
-
|
|
20
|
-
var setConfig = exports.setConfig = function () {
|
|
21
|
-
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(config) {
|
|
22
|
-
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
23
|
-
while (1) {
|
|
24
|
-
switch (_context.prev = _context.next) {
|
|
25
|
-
case 0:
|
|
26
|
-
if (config == null) config = DEFAULT_CONFIG;
|
|
27
|
-
|
|
28
|
-
_context.next = 3;
|
|
29
|
-
return mkdirp(_path2.default.dirname(getConfigPath()));
|
|
30
|
-
|
|
31
|
-
case 3:
|
|
32
|
-
_context.next = 5;
|
|
33
|
-
return _fs2.default.writeFileAsync(getConfigPath(), (0, _stringify2.default)(config, null, 2));
|
|
34
|
-
|
|
35
|
-
case 5:
|
|
36
|
-
|
|
37
|
-
// trash cached config
|
|
38
|
-
_config = null;
|
|
39
|
-
|
|
40
|
-
case 6:
|
|
41
|
-
case 'end':
|
|
42
|
-
return _context.stop();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}, _callee, this);
|
|
46
|
-
}));
|
|
47
|
-
|
|
48
|
-
return function setConfig(_x) {
|
|
49
|
-
return _ref.apply(this, arguments);
|
|
50
|
-
};
|
|
51
|
-
}();
|
|
52
|
-
|
|
53
|
-
exports.getConfigPath = getConfigPath;
|
|
8
|
+
exports.DEFAULT_TLS_ROOT_CA_DIR = void 0;
|
|
54
9
|
exports.getConfig = getConfig;
|
|
10
|
+
exports.getConfigDir = getConfigDir;
|
|
11
|
+
exports.getConfigPath = getConfigPath;
|
|
12
|
+
exports.setConfig = setConfig;
|
|
55
13
|
|
|
56
|
-
var _path = require(
|
|
57
|
-
|
|
58
|
-
var _path2 = _interopRequireDefault(_path);
|
|
59
|
-
|
|
60
|
-
var _bluebird = require('bluebird');
|
|
61
|
-
|
|
62
|
-
var _bluebird2 = _interopRequireDefault(_bluebird);
|
|
63
|
-
|
|
64
|
-
var _invariant = require('invariant');
|
|
65
|
-
|
|
66
|
-
var _invariant2 = _interopRequireDefault(_invariant);
|
|
14
|
+
var _path = _interopRequireDefault(require("path"));
|
|
67
15
|
|
|
68
|
-
var
|
|
16
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
69
17
|
|
|
70
|
-
var
|
|
18
|
+
var _fs = _interopRequireWildcard(require("fs"));
|
|
71
19
|
|
|
72
|
-
function
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
73
21
|
|
|
74
|
-
var
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
75
23
|
|
|
76
|
-
|
|
24
|
+
// $FlowIgnore
|
|
25
|
+
const DEFAULT_ENVIRONMENT_NAME = 'dev';
|
|
26
|
+
const DEFAULT_TLS_ROOT_CA_DIR = `${getConfigDir()}/tls-root-ca`;
|
|
27
|
+
exports.DEFAULT_TLS_ROOT_CA_DIR = DEFAULT_TLS_ROOT_CA_DIR;
|
|
28
|
+
const DEFAULT_CONFIG = {
|
|
77
29
|
defaultNavy: DEFAULT_ENVIRONMENT_NAME,
|
|
78
|
-
externalIP: null
|
|
30
|
+
externalIP: null,
|
|
31
|
+
tlsRootCaDir: DEFAULT_TLS_ROOT_CA_DIR
|
|
79
32
|
};
|
|
33
|
+
let _config = null;
|
|
80
34
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
35
|
+
function getConfigDir() {
|
|
36
|
+
const home = process.env.HOME;
|
|
37
|
+
(0, _invariant.default)(home, "NO_HOME_DIRECTORY: No home directory available");
|
|
38
|
+
return _path.default.join(home, '.navy');
|
|
39
|
+
}
|
|
84
40
|
|
|
85
41
|
function getConfigPath() {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
(0, _invariant2.default)(home, 'NO_HOME_DIRECTORY: No home directory available');
|
|
89
|
-
|
|
90
|
-
return _path2.default.join(home, '.navy', 'config.json');
|
|
42
|
+
const configDir = getConfigDir();
|
|
43
|
+
return _path.default.join(configDir, 'config.json');
|
|
91
44
|
}
|
|
92
45
|
|
|
93
46
|
function getConfig() {
|
|
@@ -96,11 +49,21 @@ function getConfig() {
|
|
|
96
49
|
}
|
|
97
50
|
|
|
98
51
|
try {
|
|
99
|
-
|
|
100
|
-
_config = JSON.parse(file);
|
|
52
|
+
const file = _fs.default.readFileSync(getConfigPath(), 'utf8');
|
|
101
53
|
|
|
54
|
+
_config = JSON.parse(file);
|
|
102
55
|
return _config;
|
|
103
56
|
} catch (ex) {
|
|
104
57
|
return DEFAULT_CONFIG;
|
|
105
58
|
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function setConfig(config) {
|
|
62
|
+
if (config == null) config = DEFAULT_CONFIG;
|
|
63
|
+
await _fs.promises.mkdir(_path.default.dirname(getConfigPath()), {
|
|
64
|
+
recursive: true
|
|
65
|
+
});
|
|
66
|
+
await _fs.promises.writeFile(getConfigPath(), JSON.stringify(config, null, 2)); // trash cached config
|
|
67
|
+
|
|
68
|
+
_config = null;
|
|
106
69
|
}
|
package/lib/driver-logging.js
CHANGED
|
@@ -1,35 +1,31 @@
|
|
|
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
|
-
exports.startDriverLogging = startDriverLogging;
|
|
7
|
-
exports.stopDriverLogging = stopDriverLogging;
|
|
8
8
|
exports.isDriverLogging = isDriverLogging;
|
|
9
9
|
exports.log = log;
|
|
10
|
+
exports.startDriverLogging = startDriverLogging;
|
|
11
|
+
exports.stopDriverLogging = stopDriverLogging;
|
|
10
12
|
|
|
11
|
-
var _cliSpinners = require(
|
|
12
|
-
|
|
13
|
-
var _chalk = require('chalk');
|
|
14
|
-
|
|
15
|
-
var _chalk2 = _interopRequireDefault(_chalk);
|
|
16
|
-
|
|
17
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
var _cliSpinners = require("cli-spinners");
|
|
18
14
|
|
|
19
|
-
var
|
|
20
|
-
var _spinnerInterval = null;
|
|
21
|
-
var _spinnerIndex = 0;
|
|
22
|
-
var _message = null;
|
|
15
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
let _isDriverLogging = false;
|
|
18
|
+
let _spinnerInterval = null;
|
|
19
|
+
let _spinnerIndex = 0;
|
|
20
|
+
let _message = null;
|
|
26
21
|
|
|
27
|
-
|
|
22
|
+
function _redraw(opts = {}) {
|
|
23
|
+
let symbol = _chalk.default.cyan(_cliSpinners.dots.frames[_spinnerIndex]);
|
|
28
24
|
|
|
29
25
|
if (opts.success === true) {
|
|
30
|
-
symbol =
|
|
26
|
+
symbol = _chalk.default.green('✔');
|
|
31
27
|
} else if (opts.success === false) {
|
|
32
|
-
symbol =
|
|
28
|
+
symbol = _chalk.default.red('•');
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
if (!process.stdout.isTTY) {
|
|
@@ -40,11 +36,12 @@ function _redraw() {
|
|
|
40
36
|
console.log();
|
|
41
37
|
console.log(symbol, 'FAILURE');
|
|
42
38
|
}
|
|
39
|
+
|
|
43
40
|
return;
|
|
44
41
|
}
|
|
45
42
|
|
|
46
43
|
process.stdout.write(' \n');
|
|
47
|
-
process.stdout.write(
|
|
44
|
+
process.stdout.write(` ${symbol} ${opts.success === false ? _chalk.default.red(_message, 'FAILED') : _message}\n`);
|
|
48
45
|
process.stdout.cursorTo(0);
|
|
49
46
|
process.stdout.moveCursor(0, -2);
|
|
50
47
|
}
|
|
@@ -55,7 +52,7 @@ function startDriverLogging(message) {
|
|
|
55
52
|
|
|
56
53
|
_redraw();
|
|
57
54
|
|
|
58
|
-
_spinnerInterval = setInterval(
|
|
55
|
+
_spinnerInterval = setInterval(() => {
|
|
59
56
|
_spinnerIndex++;
|
|
60
57
|
|
|
61
58
|
if (_spinnerIndex >= _cliSpinners.dots.frames.length) {
|
|
@@ -66,15 +63,14 @@ function startDriverLogging(message) {
|
|
|
66
63
|
}, _cliSpinners.dots.interval);
|
|
67
64
|
}
|
|
68
65
|
|
|
69
|
-
function stopDriverLogging() {
|
|
70
|
-
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
71
|
-
|
|
66
|
+
function stopDriverLogging(opts = {}) {
|
|
72
67
|
if (!isDriverLogging()) return;
|
|
73
|
-
|
|
74
68
|
_isDriverLogging = false;
|
|
75
69
|
clearInterval(_spinnerInterval);
|
|
76
70
|
|
|
77
|
-
_redraw({
|
|
71
|
+
_redraw({
|
|
72
|
+
success: opts.success != null ? opts.success : true
|
|
73
|
+
});
|
|
78
74
|
|
|
79
75
|
if (process.stdout.isTTY) console.log('\n\n');
|
|
80
76
|
}
|
|
@@ -85,6 +81,5 @@ function isDriverLogging() {
|
|
|
85
81
|
|
|
86
82
|
function log(message) {
|
|
87
83
|
if (!isDriverLogging()) return;
|
|
88
|
-
|
|
89
|
-
process.stdout.write(_chalk2.default.dim(message));
|
|
84
|
+
process.stdout.write(_chalk.default.dim(message));
|
|
90
85
|
}
|
package/lib/driver.js
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
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
8
|
exports.resolveDriverFromName = resolveDriverFromName;
|
|
7
9
|
|
|
8
|
-
var _dockerCompose = require(
|
|
9
|
-
|
|
10
|
-
var _dockerCompose2 = _interopRequireDefault(_dockerCompose);
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
var _dockerCompose = _interopRequireDefault(require("./drivers/docker-compose"));
|
|
13
11
|
|
|
14
12
|
function resolveDriverFromName(driverName) {
|
|
15
13
|
switch (driverName) {
|
|
16
14
|
case 'docker-compose':
|
|
17
|
-
return
|
|
15
|
+
return _dockerCompose.default;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
return null;
|