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.
Files changed (75) hide show
  1. package/lib/cli/config/index.js +57 -241
  2. package/lib/cli/config/wrapper.js +12 -36
  3. package/lib/cli/develop.js +63 -167
  4. package/lib/cli/doctor/clean-compose-files.js +19 -73
  5. package/lib/cli/doctor/index.js +34 -154
  6. package/lib/cli/doctor/invalid-compose-config.js +20 -110
  7. package/lib/cli/doctor/invalid-state.js +22 -115
  8. package/lib/cli/doctor/util.js +26 -93
  9. package/lib/cli/external-ip.js +9 -39
  10. package/lib/cli/health.js +18 -67
  11. package/lib/cli/https.js +92 -0
  12. package/lib/cli/import.js +22 -59
  13. package/lib/cli/index.js +11 -17
  14. package/lib/cli/lan-ip.js +18 -60
  15. package/lib/cli/launch.js +46 -127
  16. package/lib/cli/live.js +37 -111
  17. package/lib/cli/local-ip.js +16 -53
  18. package/lib/cli/logs.js +7 -35
  19. package/lib/cli/open.js +11 -45
  20. package/lib/cli/program.js +145 -167
  21. package/lib/cli/ps.js +36 -105
  22. package/lib/cli/refresh-config.js +18 -62
  23. package/lib/cli/run.js +8 -39
  24. package/lib/cli/status.js +41 -201
  25. package/lib/cli/updates.js +68 -160
  26. package/lib/cli/util/get-or-initialise-navy.js +14 -57
  27. package/lib/cli/util/import.js +33 -83
  28. package/lib/cli/util/index.js +10 -12
  29. package/lib/cli/util/reconfigure.js +12 -102
  30. package/lib/cli/wait-for-healthy.js +53 -100
  31. package/lib/config-provider.js +25 -127
  32. package/lib/config-providers/filesystem/index.js +58 -235
  33. package/lib/config-providers/npm/__tests__/util.js +3 -6
  34. package/lib/config-providers/npm/index.js +60 -231
  35. package/lib/config-providers/npm/util.js +6 -9
  36. package/lib/config.js +39 -76
  37. package/lib/driver-logging.js +23 -28
  38. package/lib/driver.js +5 -7
  39. package/lib/drivers/docker-compose/client.js +64 -172
  40. package/lib/drivers/docker-compose/index.js +153 -464
  41. package/lib/errors.js +27 -61
  42. package/lib/http-proxy.js +72 -158
  43. package/lib/index.js +26 -29
  44. package/lib/middleware/add-service-proxy-config.js +76 -0
  45. package/lib/middleware/develop.js +9 -23
  46. package/lib/middleware/helpers.js +20 -25
  47. package/lib/middleware/port-override.js +15 -37
  48. package/lib/middleware/set-env-vars.js +14 -18
  49. package/lib/middleware/set-image.js +12 -18
  50. package/lib/middleware/set-logging-driver.js +14 -18
  51. package/lib/middleware/tag-override.js +11 -19
  52. package/lib/navy/default-middleware.js +13 -27
  53. package/lib/navy/index.js +438 -1761
  54. package/lib/navy/middleware.js +15 -100
  55. package/lib/navy/plugin-interface.js +28 -108
  56. package/lib/navy/state.js +58 -147
  57. package/lib/navy/util.js +2 -1
  58. package/lib/service.js +5 -3
  59. package/lib/util/__tests__/external-ip.js +20 -96
  60. package/lib/util/__tests__/registry-client.js +11 -24
  61. package/lib/util/__tests__/service-host.js +19 -116
  62. package/lib/util/docker-client.js +10 -13
  63. package/lib/util/exec-async.js +9 -27
  64. package/lib/util/external-ip.js +48 -126
  65. package/lib/util/fs.js +7 -6
  66. package/lib/util/get-lan-ip.js +15 -52
  67. package/lib/util/has-update.js +23 -73
  68. package/lib/util/https.js +213 -0
  69. package/lib/util/navyrc.js +12 -50
  70. package/lib/util/registry-client.js +41 -112
  71. package/lib/util/service-host.js +40 -129
  72. package/lib/util/table.js +11 -21
  73. package/package.json +14 -14
  74. package/LICENSE +0 -21
  75. package/lib/middleware/add-virtual-hosts.js +0 -147
@@ -1,194 +1,86 @@
1
- 'use strict';
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('path');
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 _fs2 = _interopRequireDefault(_fs);
12
+ var _invariant = _interopRequireDefault(require("invariant"));
32
13
 
33
- var _execAsync = require('../../util/exec-async');
14
+ var _fs = _interopRequireDefault(require("../../util/fs"));
34
15
 
35
- var _driverLogging = require('../../driver-logging');
16
+ var _execAsync = require("../../util/exec-async");
36
17
 
37
- var _state = require('../../navy/state');
18
+ var _driverLogging = require("../../driver-logging");
38
19
 
39
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+ var _state = require("../../navy/state");
40
21
 
41
22
  function createComposeClient(navy) {
42
- var client = {
43
- exec: function exec(command) {
44
- var _this = this;
45
-
46
- var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
47
- var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
48
- return (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
49
- var composeArgs, useOriginalDockerComposeFiles, noLog, pipeLog, maxBuffer, composeOpts, composeFilePath;
50
- return _regenerator2.default.wrap(function _callee$(_context) {
51
- while (1) {
52
- switch (_context.prev = _context.next) {
53
- case 0:
54
- composeArgs = ['-p', navy.normalisedName];
55
- useOriginalDockerComposeFiles = opts.useOriginalDockerComposeFiles, noLog = opts.noLog, pipeLog = opts.pipeLog, maxBuffer = opts.maxBuffer;
56
- composeOpts = {
57
- maxBuffer: maxBuffer || Infinity
58
- };
59
- _context.next = 5;
60
- return client.getDockerComposeFilePath();
61
-
62
- case 5:
63
- composeFilePath = _context.sent;
64
-
65
- if (!(composeFilePath && !useOriginalDockerComposeFiles)) {
66
- _context.next = 10;
67
- break;
68
- }
69
-
70
- composeArgs.push('-f', composeFilePath);
71
- _context.next = 13;
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
- }, _callee, _this, [[14, 20]]);
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
- (0, _invariant2.default)(configProvider, 'NO_CONFIG_PROVIDER: Couldn\'t determine config provider for navy %s', navy.name);
146
-
147
- return _context2.abrupt('return', configProvider.getNavyPath());
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
- getDockerComposeFilePath: function getDockerComposeFilePath() {
158
- var _this3 = this;
159
-
160
- return (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
161
- var compiledComposePath;
162
- return _regenerator2.default.wrap(function _callee3$(_context3) {
163
- while (1) {
164
- switch (_context3.prev = _context3.next) {
165
- case 0:
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
  }