navy 6.0.0 → 7.0.0-alpha.2
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/__tests__/config-provider.js +75 -0
- package/lib/__tests__/config.js +130 -0
- package/lib/__tests__/driver-logging.js +148 -0
- package/lib/__tests__/driver.js +19 -0
- package/lib/__tests__/errors.js +49 -0
- package/lib/__tests__/http-proxy.js +214 -0
- package/lib/__tests__/index.js +25 -0
- package/lib/__tests__/service.js +16 -0
- package/lib/cli/__tests__/develop.js +239 -0
- package/lib/cli/__tests__/external-ip.js +68 -0
- package/lib/cli/__tests__/health.js +257 -0
- package/lib/cli/__tests__/https.js +210 -0
- package/lib/cli/__tests__/import.js +110 -0
- package/lib/cli/__tests__/index.js +118 -0
- package/lib/cli/__tests__/lan-ip.js +90 -0
- package/lib/cli/__tests__/launch.js +179 -0
- package/lib/cli/__tests__/live.js +155 -0
- package/lib/cli/__tests__/local-ip.js +72 -0
- package/lib/cli/__tests__/logs.js +52 -0
- package/lib/cli/__tests__/open.js +65 -0
- package/lib/cli/__tests__/program.js +472 -0
- package/lib/cli/__tests__/ps.js +345 -0
- package/lib/cli/__tests__/refresh-config.js +95 -0
- package/lib/cli/__tests__/run.js +54 -0
- package/lib/cli/__tests__/status.js +204 -0
- package/lib/cli/__tests__/updates.js +243 -0
- package/lib/cli/__tests__/wait-for-healthy.js +134 -0
- package/lib/cli/config/__tests__/index.js +275 -0
- package/lib/cli/config/__tests__/wrapper.js +53 -0
- package/lib/cli/config/index.js +19 -37
- package/lib/cli/config/wrapper.js +0 -6
- package/lib/cli/develop.js +7 -21
- package/lib/cli/doctor/__tests__/clean-compose-files.js +78 -0
- package/lib/cli/doctor/__tests__/index.js +67 -0
- package/lib/cli/doctor/__tests__/invalid-compose-config.js +103 -0
- package/lib/cli/doctor/__tests__/invalid-state.js +83 -0
- package/lib/cli/doctor/__tests__/util.js +91 -0
- package/lib/cli/doctor/clean-compose-files.js +5 -13
- package/lib/cli/doctor/index.js +0 -12
- package/lib/cli/doctor/invalid-compose-config.js +0 -4
- package/lib/cli/doctor/invalid-state.js +0 -6
- package/lib/cli/doctor/util.js +0 -10
- package/lib/cli/external-ip.js +0 -4
- package/lib/cli/health.js +0 -12
- package/lib/cli/https.js +9 -25
- package/lib/cli/import.js +0 -12
- package/lib/cli/index.js +0 -9
- package/lib/cli/lan-ip.js +2 -8
- package/lib/cli/launch.js +0 -9
- package/lib/cli/live.js +6 -16
- package/lib/cli/local-ip.js +2 -7
- package/lib/cli/logs.js +0 -3
- package/lib/cli/open.js +2 -7
- package/lib/cli/program.js +73 -101
- package/lib/cli/ps.js +1 -21
- package/lib/cli/refresh-config.js +0 -7
- package/lib/cli/run.js +0 -3
- package/lib/cli/status.js +0 -11
- package/lib/cli/updates.js +0 -22
- package/lib/cli/util/__tests__/get-or-initialise-navy.js +66 -0
- package/lib/cli/util/__tests__/import.js +123 -0
- package/lib/cli/util/__tests__/index.js +17 -0
- package/lib/cli/util/__tests__/merge-action-options.js +47 -0
- package/lib/cli/util/__tests__/reconfigure.js +78 -0
- package/lib/cli/util/get-or-initialise-navy.js +0 -7
- package/lib/cli/util/import.js +0 -9
- package/lib/cli/util/index.js +0 -2
- package/lib/cli/util/merge-action-options.js +20 -0
- package/lib/cli/util/reconfigure.js +0 -4
- package/lib/cli/wait-for-healthy.js +0 -21
- package/lib/client/registry/__tests__/get-credentials.js +62 -0
- package/lib/client/registry/__tests__/get-endpoint.js +124 -0
- package/lib/client/registry/__tests__/get-fat-manifest.js +67 -0
- package/lib/client/registry/__tests__/get-token.js +66 -0
- package/lib/client/registry/__tests__/helpers.js +26 -0
- package/lib/client/registry/get-credentials.js +3 -9
- package/lib/client/registry/get-endpoint.js +29 -63
- package/lib/client/registry/get-fat-manifest.js +2 -9
- package/lib/client/registry/get-token.js +2 -13
- package/lib/client/registry/helpers.js +0 -4
- package/lib/config-provider.js +0 -12
- package/lib/config-providers/filesystem/__tests__/index.js +176 -0
- package/lib/config-providers/filesystem/index.js +5 -23
- package/lib/config-providers/npm/__tests__/index.js +226 -0
- package/lib/config-providers/npm/__tests__/util.js +1 -2
- package/lib/config-providers/npm/index.js +12 -35
- package/lib/config-providers/npm/util.js +0 -3
- package/lib/config.js +4 -19
- package/lib/domain/__tests__/container-image.js +81 -0
- package/lib/domain/__tests__/oci-api-specification.js +23 -0
- package/lib/domain/container-image.js +8 -21
- package/lib/domain/oci-api-specification.js +3 -5
- package/lib/driver-logging.js +0 -19
- package/lib/driver.js +0 -4
- package/lib/drivers/docker-compose/__tests__/client.js +249 -0
- package/lib/drivers/docker-compose/__tests__/index.js +430 -0
- package/lib/drivers/docker-compose/client.js +0 -16
- package/lib/drivers/docker-compose/index.js +7 -49
- package/lib/errors.js +0 -10
- package/lib/http-proxy.js +28 -23
- package/lib/index.js +1 -9
- package/lib/middleware/__tests__/add-service-proxy-config.js +258 -0
- package/lib/middleware/__tests__/develop.js +120 -0
- package/lib/middleware/__tests__/helpers.js +154 -0
- package/lib/middleware/__tests__/port-override.js +125 -0
- package/lib/middleware/__tests__/set-env-vars.js +94 -0
- package/lib/middleware/__tests__/set-image.js +76 -0
- package/lib/middleware/__tests__/set-logging-driver.js +94 -0
- package/lib/middleware/__tests__/tag-override.js +92 -0
- package/lib/middleware/add-service-proxy-config.js +8 -16
- package/lib/middleware/develop.js +2 -5
- package/lib/middleware/helpers.js +6 -12
- package/lib/middleware/port-override.js +5 -8
- package/lib/middleware/set-env-vars.js +6 -6
- package/lib/middleware/set-image.js +4 -5
- package/lib/middleware/set-logging-driver.js +6 -6
- package/lib/middleware/tag-override.js +4 -6
- package/lib/navy/__tests__/default-middleware.js +40 -0
- package/lib/navy/__tests__/index.js +1612 -0
- package/lib/navy/__tests__/middleware.js +71 -0
- package/lib/navy/__tests__/plugin-interface.js +121 -0
- package/lib/navy/__tests__/state.js +103 -0
- package/lib/navy/__tests__/util.js +24 -0
- package/lib/navy/default-middleware.js +0 -10
- package/lib/navy/index.js +83 -138
- package/lib/navy/middleware.js +0 -6
- package/lib/navy/plugin-interface.js +2 -10
- package/lib/navy/state.js +12 -24
- package/lib/navy/util.js +0 -1
- package/lib/service.js +2 -3
- package/lib/util/__tests__/exec-async.js +83 -0
- package/lib/util/__tests__/external-ip.js +97 -2
- package/lib/util/__tests__/get-lan-ip.js +46 -0
- package/lib/util/__tests__/has-update.js +136 -0
- package/lib/util/__tests__/https.js +301 -0
- package/lib/util/__tests__/navyrc.js +45 -0
- package/lib/util/__tests__/service-host.js +63 -5
- package/lib/util/__tests__/table.js +44 -0
- package/lib/util/docker-client.js +2 -10
- package/lib/util/exec-async.js +0 -4
- package/lib/util/external-ip.js +8 -12
- package/lib/util/fs.js +1 -6
- package/lib/util/get-lan-ip.js +0 -5
- package/lib/util/has-update.js +2 -14
- package/lib/util/https.js +11 -55
- package/lib/util/navyrc.js +0 -5
- package/lib/util/service-host.js +0 -17
- package/lib/util/table.js +0 -6
- package/package.json +14 -13
package/lib/util/has-update.js
CHANGED
|
@@ -1,31 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var R = _interopRequireWildcard(require("ramda"));
|
|
11
|
-
|
|
12
9
|
var _dockerClient = _interopRequireDefault(require("./docker-client"));
|
|
13
|
-
|
|
14
10
|
var _getFatManifest = _interopRequireDefault(require("../client/registry/get-fat-manifest"));
|
|
15
|
-
|
|
16
11
|
var _containerImage = require("../domain/container-image");
|
|
17
|
-
|
|
18
|
-
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); }
|
|
19
|
-
|
|
20
|
-
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; }
|
|
21
|
-
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
22
13
|
const hasUpdate = async (imageWithTag, currentImageId, navyFile) => {
|
|
23
14
|
const tag = (0, _containerImage.getTagFromImageWithTag)(imageWithTag);
|
|
24
15
|
const image = (0, _containerImage.getImageFromImageWithTag)(imageWithTag);
|
|
25
16
|
const registry = (0, _containerImage.getRegistryFromImage)(image);
|
|
26
17
|
const repository = (0, _containerImage.getRepositoryFromImage)(image);
|
|
27
18
|
const allowUnauthorizedRequest = R.includes(registry, R.path(['ignoreUnauthorizedRequestsForRegistries'], navyFile));
|
|
28
|
-
|
|
29
19
|
try {
|
|
30
20
|
const {
|
|
31
21
|
RepoDigests
|
|
@@ -42,7 +32,5 @@ const hasUpdate = async (imageWithTag, currentImageId, navyFile) => {
|
|
|
42
32
|
return 'INVALID_REMOTE';
|
|
43
33
|
}
|
|
44
34
|
};
|
|
45
|
-
|
|
46
|
-
var _default = hasUpdate;
|
|
47
|
-
exports.default = _default;
|
|
35
|
+
var _default = exports.default = hasUpdate;
|
|
48
36
|
module.exports = exports.default;
|
package/lib/util/https.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -9,30 +8,19 @@ exports.createCert = createCert;
|
|
|
9
8
|
exports.generateRootCa = generateRootCa;
|
|
10
9
|
exports.getCertsPath = getCertsPath;
|
|
11
10
|
exports.removeCert = removeCert;
|
|
12
|
-
|
|
13
11
|
var _path = _interopRequireDefault(require("path"));
|
|
14
|
-
|
|
15
12
|
var _config = require("../config");
|
|
16
|
-
|
|
17
13
|
var _errors = require("../errors");
|
|
18
|
-
|
|
19
14
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
20
|
-
|
|
21
15
|
var _fs = _interopRequireDefault(require("fs"));
|
|
22
|
-
|
|
23
16
|
var _nodeForge = require("node-forge");
|
|
24
|
-
|
|
25
17
|
var _navy = require("../navy");
|
|
26
|
-
|
|
27
18
|
const debug = require('debug')('navy:https');
|
|
28
|
-
|
|
29
19
|
function getCertsPath(create = false) {
|
|
30
20
|
const certsPath = _path.default.join((0, _config.getConfigDir)(), 'tls-certs');
|
|
31
|
-
|
|
32
21
|
if (!_fs.default.existsSync(certsPath)) {
|
|
33
22
|
if (create) {
|
|
34
|
-
debug(`Create ${certsPath} dir`);
|
|
35
|
-
|
|
23
|
+
debug(`Create ${certsPath} dir`);
|
|
36
24
|
_fs.default.mkdirSync(certsPath, {
|
|
37
25
|
recursive: true
|
|
38
26
|
});
|
|
@@ -40,20 +28,16 @@ function getCertsPath(create = false) {
|
|
|
40
28
|
return '';
|
|
41
29
|
}
|
|
42
30
|
}
|
|
43
|
-
|
|
44
31
|
return certsPath;
|
|
45
32
|
}
|
|
46
|
-
|
|
47
33
|
async function removeCert(opts) {
|
|
48
34
|
const certsPath = getCertsPath();
|
|
49
35
|
const navy = await (0, _navy.getNavy)(opts.navy);
|
|
50
36
|
const serviceUrl = await navy.url(opts.disable);
|
|
51
37
|
const baseName = serviceUrl.split('//')[1];
|
|
52
38
|
const extensions = ['crt', 'key'];
|
|
53
|
-
|
|
54
39
|
for (const ext of extensions) {
|
|
55
40
|
const file = `${certsPath}/${baseName}.${ext}`;
|
|
56
|
-
|
|
57
41
|
if (_fs.default.existsSync(file)) {
|
|
58
42
|
try {
|
|
59
43
|
await _fs.default.unlinkSync(file);
|
|
@@ -64,15 +48,11 @@ async function removeCert(opts) {
|
|
|
64
48
|
}
|
|
65
49
|
}
|
|
66
50
|
}
|
|
67
|
-
|
|
68
51
|
async function generateRootCa() {
|
|
69
52
|
const tlsRootCaDir = (0, _config.getConfig)().tlsRootCaDir || _config.DEFAULT_TLS_ROOT_CA_DIR;
|
|
70
|
-
|
|
71
53
|
if (!_fs.default.existsSync(tlsRootCaDir)) {
|
|
72
54
|
debug(`Creating ${tlsRootCaDir} Root CA dir`);
|
|
73
|
-
|
|
74
55
|
try {
|
|
75
|
-
// $FlowIgnore
|
|
76
56
|
_fs.default.mkdirSync(tlsRootCaDir, {
|
|
77
57
|
recursive: true
|
|
78
58
|
});
|
|
@@ -80,21 +60,15 @@ async function generateRootCa() {
|
|
|
80
60
|
throw new _errors.NavyError(err);
|
|
81
61
|
}
|
|
82
62
|
}
|
|
83
|
-
|
|
84
63
|
if (_fs.default.existsSync(`${tlsRootCaDir}/ca.crt`) && _fs.default.existsSync(`${tlsRootCaDir}/ca.key`)) {
|
|
85
|
-
debug(
|
|
64
|
+
debug('Root CA already exists, skipping generation');
|
|
86
65
|
return;
|
|
87
66
|
}
|
|
88
|
-
|
|
89
67
|
debug('Generating Root CA');
|
|
90
68
|
debug('Generating 2048-bit key-pair...');
|
|
91
|
-
|
|
92
69
|
const keys = _nodeForge.pki.rsa.generateKeyPair(2048);
|
|
93
|
-
|
|
94
70
|
debug('Creating self-signed certificate...');
|
|
95
|
-
|
|
96
71
|
const cert = _nodeForge.pki.createCertificate();
|
|
97
|
-
|
|
98
72
|
cert.publicKey = keys.publicKey;
|
|
99
73
|
cert.serialNumber = '01';
|
|
100
74
|
cert.validity.notBefore = new Date();
|
|
@@ -117,63 +91,47 @@ async function generateRootCa() {
|
|
|
117
91
|
}, {
|
|
118
92
|
name: 'authorityKeyIdentifier'
|
|
119
93
|
}]);
|
|
120
|
-
|
|
121
94
|
try {
|
|
122
95
|
// self-sign certificate
|
|
123
|
-
cert.sign(keys.privateKey, _nodeForge.md.sha256.create());
|
|
96
|
+
cert.sign(keys.privateKey, _nodeForge.md.sha256.create());
|
|
124
97
|
|
|
98
|
+
// PEM-format keys and cert
|
|
125
99
|
const pem = {
|
|
126
100
|
privateKey: _nodeForge.pki.privateKeyToPem(keys.privateKey),
|
|
127
101
|
publicKey: _nodeForge.pki.publicKeyToPem(keys.publicKey),
|
|
128
102
|
certificate: _nodeForge.pki.certificateToPem(cert)
|
|
129
103
|
};
|
|
130
|
-
|
|
131
104
|
_fs.default.writeFileSync(tlsRootCaDir + '/ca.key', pem.privateKey, {
|
|
132
105
|
mode: 0o400
|
|
133
106
|
});
|
|
134
|
-
|
|
135
107
|
_fs.default.writeFileSync(tlsRootCaDir + '/ca.pub.key', pem.publicKey, {
|
|
136
108
|
mode: 0o640
|
|
137
109
|
});
|
|
138
|
-
|
|
139
110
|
_fs.default.writeFileSync(tlsRootCaDir + '/ca.crt', pem.certificate, {
|
|
140
111
|
mode: 0o640
|
|
141
112
|
});
|
|
142
|
-
|
|
143
113
|
console.log(_chalk.default.green(`✅ CA Certificate created at ${tlsRootCaDir}/ca.crt`));
|
|
144
|
-
console.log(_chalk.default.yellow(
|
|
114
|
+
console.log(_chalk.default.yellow('⚠️ Importing a self-signed CA into a browser/truststore/keychain is not advisable ⚠️'));
|
|
145
115
|
} catch (e) {
|
|
146
116
|
throw new _errors.NavyError(e);
|
|
147
117
|
}
|
|
148
118
|
}
|
|
149
|
-
|
|
150
119
|
async function createCert(opts) {
|
|
151
120
|
const tlsRootCaDir = (0, _config.getConfig)().tlsRootCaDir || _config.DEFAULT_TLS_ROOT_CA_DIR;
|
|
152
|
-
|
|
153
121
|
const certName = opts.hostName || opts.serviceUrl.split('//')[1];
|
|
154
122
|
const certsPath = getCertsPath(true);
|
|
155
|
-
|
|
156
123
|
if (_fs.default.existsSync(`${certsPath}/${certName}.crt`)) {
|
|
157
124
|
debug(`Certificate for ${certName} already exists, skipping generation`);
|
|
158
125
|
return;
|
|
159
126
|
}
|
|
160
|
-
|
|
161
127
|
await generateRootCa();
|
|
162
|
-
|
|
163
128
|
const caCertString = _fs.default.readFileSync(`${tlsRootCaDir}/ca.crt`, 'utf8');
|
|
164
|
-
|
|
165
129
|
const caKeyString = _fs.default.readFileSync(`${tlsRootCaDir}/ca.key`, 'utf8');
|
|
166
|
-
|
|
167
130
|
debug(`Generating cert for ${certName} in ${certsPath}`);
|
|
168
|
-
|
|
169
131
|
const privateCAKey = _nodeForge.pki.privateKeyFromPem(caKeyString);
|
|
170
|
-
|
|
171
132
|
const keys = _nodeForge.pki.rsa.generateKeyPair(2048);
|
|
172
|
-
|
|
173
133
|
const cert = _nodeForge.pki.createCertificate();
|
|
174
|
-
|
|
175
134
|
const caCert = _nodeForge.pki.certificateFromPem(caCertString);
|
|
176
|
-
|
|
177
135
|
cert.publicKey = keys.publicKey;
|
|
178
136
|
cert.serialNumber = Math.floor(Math.random() * (99 - 2) + 2).toString();
|
|
179
137
|
cert.validity.notBefore = new Date();
|
|
@@ -187,7 +145,6 @@ async function createCert(opts) {
|
|
|
187
145
|
name: 'organizationName',
|
|
188
146
|
value: 'navy-dev'
|
|
189
147
|
}];
|
|
190
|
-
|
|
191
148
|
try {
|
|
192
149
|
cert.setSubject(attrs);
|
|
193
150
|
cert.setIssuer(caCert.subject.attributes);
|
|
@@ -195,18 +152,17 @@ async function createCert(opts) {
|
|
|
195
152
|
name: 'extKeyUsage',
|
|
196
153
|
serverAuth: true
|
|
197
154
|
}]);
|
|
198
|
-
cert.sign(privateCAKey, _nodeForge.md.sha256.create());
|
|
155
|
+
cert.sign(privateCAKey, _nodeForge.md.sha256.create());
|
|
199
156
|
|
|
157
|
+
// PEM-format keys and cert
|
|
200
158
|
const pem = {
|
|
201
159
|
privateKey: _nodeForge.pki.privateKeyToPem(keys.privateKey),
|
|
202
|
-
certificate: _nodeForge.pki.certificateToPem(cert)
|
|
203
|
-
|
|
160
|
+
certificate: _nodeForge.pki.certificateToPem(cert)
|
|
161
|
+
// publicKey: pki.publicKeyToPem(keys.publicKey),
|
|
204
162
|
};
|
|
205
|
-
|
|
206
163
|
_fs.default.writeFileSync(`${certsPath}/${certName}.key`, pem.privateKey);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
164
|
+
_fs.default.writeFileSync(`${certsPath}/${certName}.crt`, pem.certificate);
|
|
165
|
+
// fs.writeFileSync(`${certsPath}/${certName}.pub.key`, pem.publicKey)
|
|
210
166
|
} catch (e) {
|
|
211
167
|
throw new _errors.NavyError(e);
|
|
212
168
|
}
|
package/lib/util/navyrc.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = getNavyRc;
|
|
9
|
-
|
|
10
8
|
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
|
|
12
9
|
var _fs = _interopRequireDefault(require("./fs"));
|
|
13
|
-
|
|
14
10
|
async function getNavyRc(dir) {
|
|
15
11
|
try {
|
|
16
12
|
return JSON.parse(await _fs.default.readFileAsync(_path.default.join(dir, '.navyrc')));
|
|
@@ -18,5 +14,4 @@ async function getNavyRc(dir) {
|
|
|
18
14
|
return null;
|
|
19
15
|
}
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
module.exports = exports.default;
|
package/lib/util/service-host.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -9,61 +8,45 @@ exports.createHostForService = createHostForService;
|
|
|
9
8
|
exports.createUrlForService = createUrlForService;
|
|
10
9
|
exports.getNIPSubdomain = getNIPSubdomain;
|
|
11
10
|
exports.getUrlFromService = getUrlFromService;
|
|
12
|
-
|
|
13
11
|
var _https = require("./https");
|
|
14
|
-
|
|
15
12
|
var _fs = _interopRequireDefault(require("fs"));
|
|
16
|
-
|
|
17
13
|
const BASE = 'nip.io';
|
|
18
|
-
|
|
19
14
|
function isValidIpv4Addr(ip) {
|
|
20
15
|
return /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g.test(ip);
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
async function getNIPSubdomain(externalIP) {
|
|
24
18
|
if (!isValidIpv4Addr(externalIP)) {
|
|
25
19
|
// invalid IP address, fallback to local
|
|
26
20
|
return `127.0.0.1.${BASE}`;
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
return `${externalIP}.${BASE}`;
|
|
30
23
|
}
|
|
31
|
-
|
|
32
24
|
async function createHostForService(service, navyNormalisedName, externalIP) {
|
|
33
25
|
return `${service}.${navyNormalisedName}.${process.env.NAVY_EXTERNAL_SUBDOMAIN || (await getNIPSubdomain(externalIP))}`;
|
|
34
26
|
}
|
|
35
|
-
|
|
36
27
|
async function createUrlForService(service, navyNormalisedName, externalIP) {
|
|
37
28
|
const certsPath = (0, _https.getCertsPath)();
|
|
38
29
|
let proto = 'http';
|
|
39
30
|
const baseUrl = await createHostForService(service, navyNormalisedName, externalIP);
|
|
40
|
-
|
|
41
31
|
if (_fs.default.existsSync(`${certsPath}/${baseUrl}.crt`)) {
|
|
42
32
|
proto = 'https';
|
|
43
33
|
}
|
|
44
|
-
|
|
45
34
|
return `${proto}://${await createHostForService(service, navyNormalisedName, externalIP)}`;
|
|
46
35
|
}
|
|
47
|
-
|
|
48
36
|
function getUrlFromService(service) {
|
|
49
37
|
if (!service || !service.raw || !service.raw.Config || !service.raw.Config.Env) {
|
|
50
38
|
return null;
|
|
51
39
|
}
|
|
52
|
-
|
|
53
40
|
const env = service.raw.Config.Env;
|
|
54
41
|
const certsPath = (0, _https.getCertsPath)();
|
|
55
|
-
|
|
56
42
|
for (const envVar of env) {
|
|
57
43
|
if (envVar.indexOf('VIRTUAL_HOST=') === 0) {
|
|
58
44
|
let proto = 'http';
|
|
59
|
-
|
|
60
45
|
if (_fs.default.existsSync(`${certsPath}/${envVar.substring('VIRTUAL_HOST='.length)}.crt`)) {
|
|
61
46
|
proto = 'https';
|
|
62
47
|
}
|
|
63
|
-
|
|
64
48
|
return proto + '://' + envVar.substring('VIRTUAL_HOST='.length);
|
|
65
49
|
}
|
|
66
50
|
}
|
|
67
|
-
|
|
68
51
|
return null;
|
|
69
52
|
}
|
package/lib/util/table.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = table;
|
|
9
|
-
|
|
10
8
|
var _pad = _interopRequireDefault(require("pad"));
|
|
11
|
-
|
|
12
9
|
var _stripAnsi = _interopRequireDefault(require("strip-ansi"));
|
|
13
|
-
|
|
14
10
|
function table(rows) {
|
|
15
11
|
if (rows.length === 0) {
|
|
16
12
|
return '';
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
const cols = rows[0];
|
|
20
15
|
const colSizes = cols.map((col, colIndex) => rows.reduce((currentSize, row) => currentSize = Math.max(currentSize, (0, _stripAnsi.default)(row[colIndex] || '').length), 0) + 2);
|
|
21
16
|
return rows.map(row => row.map((col, colIndex) => (0, _pad.default)(col || '', colSizes[colIndex], {
|
|
22
17
|
colors: true
|
|
23
18
|
})).join('')).join('\n');
|
|
24
19
|
}
|
|
25
|
-
|
|
26
20
|
module.exports = exports.default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "navy",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.2",
|
|
4
4
|
"description": "Quick and powerful development environments using Docker and Docker Compose",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -24,29 +24,30 @@
|
|
|
24
24
|
"url": "https://github.com/moneyhub/navy/issues"
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/moneyhub/navy#readme",
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=22"
|
|
29
|
+
},
|
|
27
30
|
"dependencies": {
|
|
28
31
|
"@babel/runtime": "^7",
|
|
29
32
|
"bluebird": "^3.7.2",
|
|
30
|
-
"chalk": "^
|
|
33
|
+
"chalk": "^4.1.2",
|
|
31
34
|
"cli-spinners": "^2.6.1",
|
|
32
|
-
"commander": "^
|
|
33
|
-
"debug": "^
|
|
34
|
-
"dockerode": "^
|
|
35
|
+
"commander": "^12.1.0",
|
|
36
|
+
"debug": "^4.4.0",
|
|
37
|
+
"dockerode": "^5.0.0",
|
|
35
38
|
"eventemitter2": "^6.4.5",
|
|
36
|
-
"inquirer": "^
|
|
39
|
+
"inquirer": "^8.2.6",
|
|
37
40
|
"invariant": "^2.2.4",
|
|
38
|
-
"js-yaml": "^
|
|
41
|
+
"js-yaml": "^4.1.0",
|
|
39
42
|
"lodash": "^4.17.21",
|
|
40
|
-
"mkdirp": "^0.5.5",
|
|
41
43
|
"node-fetch": "^2.6.5",
|
|
42
44
|
"node-forge": "^1.3.0",
|
|
43
|
-
"
|
|
45
|
+
"open": "^8.4.2",
|
|
44
46
|
"pad": "^3.2.0",
|
|
45
|
-
"promise-retry": "^
|
|
46
|
-
"ramda": "^0.
|
|
47
|
+
"promise-retry": "^2.0.1",
|
|
48
|
+
"ramda": "^0.30.1",
|
|
47
49
|
"resolve": "^1.20.0",
|
|
48
|
-
"
|
|
49
|
-
"strip-ansi": "^3.0.1",
|
|
50
|
+
"strip-ansi": "^6.0.1",
|
|
50
51
|
"www-authenticate": "^0.6.3"
|
|
51
52
|
}
|
|
52
53
|
}
|