netlify-cli 12.0.1 → 12.0.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/npm-shrinkwrap.json +9 -9
- package/package.json +2 -2
- package/src/commands/dev/dev.js +20 -7
- package/src/lib/http-agent.js +3 -3
- package/src/utils/proxy.js +7 -3
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.2",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "netlify-cli",
|
|
9
|
-
"version": "12.0.
|
|
9
|
+
"version": "12.0.2",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"unixify": "^1.0.0",
|
|
114
114
|
"update-notifier": "^5.0.0",
|
|
115
115
|
"uuid": "^9.0.0",
|
|
116
|
-
"wait-port": "^0.
|
|
116
|
+
"wait-port": "^1.0.1",
|
|
117
117
|
"winston": "^3.2.1",
|
|
118
118
|
"write-file-atomic": "^4.0.0"
|
|
119
119
|
},
|
|
@@ -22275,9 +22275,9 @@
|
|
|
22275
22275
|
}
|
|
22276
22276
|
},
|
|
22277
22277
|
"node_modules/wait-port": {
|
|
22278
|
-
"version": "0.
|
|
22279
|
-
"resolved": "https://registry.npmjs.org/wait-port/-/wait-port-0.
|
|
22280
|
-
"integrity": "sha512-
|
|
22278
|
+
"version": "1.0.1",
|
|
22279
|
+
"resolved": "https://registry.npmjs.org/wait-port/-/wait-port-1.0.1.tgz",
|
|
22280
|
+
"integrity": "sha512-JkEgxQRZqqBz449/bRVQAvl+e8LJ8fpW8J1W7WkKKo8PypoXX7EXGE47BmkNLTb5Ly/eI15IyTeAxDBwOEQ8DQ==",
|
|
22281
22281
|
"dependencies": {
|
|
22282
22282
|
"chalk": "^4.1.2",
|
|
22283
22283
|
"commander": "^9.3.0",
|
|
@@ -39123,9 +39123,9 @@
|
|
|
39123
39123
|
}
|
|
39124
39124
|
},
|
|
39125
39125
|
"wait-port": {
|
|
39126
|
-
"version": "0.
|
|
39127
|
-
"resolved": "https://registry.npmjs.org/wait-port/-/wait-port-0.
|
|
39128
|
-
"integrity": "sha512-
|
|
39126
|
+
"version": "1.0.1",
|
|
39127
|
+
"resolved": "https://registry.npmjs.org/wait-port/-/wait-port-1.0.1.tgz",
|
|
39128
|
+
"integrity": "sha512-JkEgxQRZqqBz449/bRVQAvl+e8LJ8fpW8J1W7WkKKo8PypoXX7EXGE47BmkNLTb5Ly/eI15IyTeAxDBwOEQ8DQ==",
|
|
39129
39129
|
"requires": {
|
|
39130
39130
|
"chalk": "^4.1.2",
|
|
39131
39131
|
"commander": "^9.3.0",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
3
|
"description": "Netlify command line tool",
|
|
4
|
-
"version": "12.0.
|
|
4
|
+
"version": "12.0.2",
|
|
5
5
|
"author": "Netlify Inc.",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"@whitep4nth3r (https://twitter.com/whitep4nth3r)",
|
|
@@ -326,7 +326,7 @@
|
|
|
326
326
|
"unixify": "^1.0.0",
|
|
327
327
|
"update-notifier": "^5.0.0",
|
|
328
328
|
"uuid": "^9.0.0",
|
|
329
|
-
"wait-port": "^0.
|
|
329
|
+
"wait-port": "^1.0.1",
|
|
330
330
|
"winston": "^3.2.1",
|
|
331
331
|
"write-file-atomic": "^4.0.0"
|
|
332
332
|
},
|
package/src/commands/dev/dev.js
CHANGED
|
@@ -178,18 +178,25 @@ const runCommand = (command, env = {}, spinner = null) => {
|
|
|
178
178
|
return commandProcess
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
/**
|
|
182
|
+
* @typedef StartReturnObject
|
|
183
|
+
* @property {4 | 6 | undefined=} ipVersion The version the open port was found on
|
|
184
|
+
*/
|
|
185
|
+
|
|
181
186
|
/**
|
|
182
187
|
* Start a static server if the `useStaticServer` is provided or a framework specific server
|
|
183
188
|
* @param {object} config
|
|
184
189
|
* @param {Partial<import('../../utils/types').ServerSettings>} config.settings
|
|
185
|
-
* @returns {Promise<
|
|
190
|
+
* @returns {Promise<StartReturnObject>}
|
|
186
191
|
*/
|
|
187
192
|
const startFrameworkServer = async function ({ settings }) {
|
|
188
193
|
if (settings.useStaticServer) {
|
|
189
194
|
if (settings.command) {
|
|
190
195
|
runCommand(settings.command, settings.env)
|
|
191
196
|
}
|
|
192
|
-
|
|
197
|
+
await startStaticServer({ settings })
|
|
198
|
+
|
|
199
|
+
return {}
|
|
193
200
|
}
|
|
194
201
|
|
|
195
202
|
log(`${NETLIFYDEVLOG} Starting Netlify Dev with ${settings.framework || 'custom config'}`)
|
|
@@ -200,17 +207,17 @@ const startFrameworkServer = async function ({ settings }) {
|
|
|
200
207
|
|
|
201
208
|
runCommand(settings.command, settings.env, spinner)
|
|
202
209
|
|
|
210
|
+
let port
|
|
203
211
|
try {
|
|
204
|
-
|
|
212
|
+
port = await waitPort({
|
|
205
213
|
port: settings.frameworkPort,
|
|
206
|
-
|
|
207
|
-
host: '127.0.0.1',
|
|
214
|
+
host: 'localhost',
|
|
208
215
|
output: 'silent',
|
|
209
216
|
timeout: FRAMEWORK_PORT_TIMEOUT,
|
|
210
217
|
...(settings.pollingStrategies.includes('HTTP') && { protocol: 'http' }),
|
|
211
218
|
})
|
|
212
219
|
|
|
213
|
-
if (!open) {
|
|
220
|
+
if (!port.open) {
|
|
214
221
|
throw new Error(`Timed out waiting for port '${settings.frameworkPort}' to be open`)
|
|
215
222
|
}
|
|
216
223
|
|
|
@@ -221,6 +228,8 @@ const startFrameworkServer = async function ({ settings }) {
|
|
|
221
228
|
log(NETLIFYDEVERR, `Please make sure your framework server is running on port ${settings.frameworkPort}`)
|
|
222
229
|
exit(1)
|
|
223
230
|
}
|
|
231
|
+
|
|
232
|
+
return { ipVersion: port?.ipVersion }
|
|
224
233
|
}
|
|
225
234
|
|
|
226
235
|
// 10 minutes
|
|
@@ -501,7 +510,11 @@ const dev = async (options, command) => {
|
|
|
501
510
|
|
|
502
511
|
log(`${NETLIFYDEVWARN} Setting up local development server`)
|
|
503
512
|
|
|
504
|
-
const devCommand = () =>
|
|
513
|
+
const devCommand = async () => {
|
|
514
|
+
const { ipVersion } = await startFrameworkServer({ settings })
|
|
515
|
+
// eslint-disable-next-line no-magic-numbers
|
|
516
|
+
settings.frameworkHost = ipVersion === 6 ? '::1' : '127.0.0.1'
|
|
517
|
+
}
|
|
505
518
|
const startDevOptions = getBuildOptions({
|
|
506
519
|
cachedConfig,
|
|
507
520
|
options,
|
package/src/lib/http-agent.js
CHANGED
|
@@ -43,9 +43,9 @@ const tryGetAgent = async ({ certificateFile, httpProxy }) => {
|
|
|
43
43
|
return { error: `${httpProxy} must have a scheme of http or https` }
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
let
|
|
46
|
+
let port
|
|
47
47
|
try {
|
|
48
|
-
|
|
48
|
+
port = await waitPort({
|
|
49
49
|
port: Number.parseInt(proxyUrl.port) || (scheme === 'http' ? DEFAULT_HTTP_PORT : DEFAULT_HTTPS_PORT),
|
|
50
50
|
host: proxyUrl.hostname,
|
|
51
51
|
timeout: AGENT_PORT_TIMEOUT,
|
|
@@ -56,7 +56,7 @@ const tryGetAgent = async ({ certificateFile, httpProxy }) => {
|
|
|
56
56
|
return { error: `${httpProxy} is not available.`, message: error.message }
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
if (!open) {
|
|
59
|
+
if (!port.open) {
|
|
60
60
|
// timeout error
|
|
61
61
|
return { error: `Could not connect to '${httpProxy}'` }
|
|
62
62
|
}
|
package/src/utils/proxy.js
CHANGED
|
@@ -4,6 +4,7 @@ const { once } = require('events')
|
|
|
4
4
|
const { readFile } = require('fs').promises
|
|
5
5
|
const http = require('http')
|
|
6
6
|
const https = require('https')
|
|
7
|
+
const { isIPv6 } = require('net')
|
|
7
8
|
const path = require('path')
|
|
8
9
|
|
|
9
10
|
const contentType = require('content-type')
|
|
@@ -281,11 +282,11 @@ const reqToURL = function (req, pathname) {
|
|
|
281
282
|
|
|
282
283
|
const MILLISEC_TO_SEC = 1e3
|
|
283
284
|
|
|
284
|
-
const initializeProxy = async function ({ configPath, distDir, port, projectDir }) {
|
|
285
|
+
const initializeProxy = async function ({ configPath, distDir, host, port, projectDir }) {
|
|
285
286
|
const proxy = httpProxy.createProxyServer({
|
|
286
287
|
selfHandleResponse: true,
|
|
287
288
|
target: {
|
|
288
|
-
host
|
|
289
|
+
host,
|
|
289
290
|
port,
|
|
290
291
|
},
|
|
291
292
|
})
|
|
@@ -434,7 +435,9 @@ const onRequest = async ({ addonsUrls, edgeFunctionsProxy, functionsServer, prox
|
|
|
434
435
|
const options = {
|
|
435
436
|
match,
|
|
436
437
|
addonsUrls,
|
|
437
|
-
target: `http
|
|
438
|
+
target: `http://${isIPv6(settings.frameworkHost) ? `[${settings.frameworkHost}]` : settings.frameworkHost}:${
|
|
439
|
+
settings.frameworkPort
|
|
440
|
+
}`,
|
|
438
441
|
publicFolder: settings.dist,
|
|
439
442
|
functionsServer,
|
|
440
443
|
functionsPort: settings.functionsPort,
|
|
@@ -498,6 +501,7 @@ const startProxy = async function ({
|
|
|
498
501
|
state,
|
|
499
502
|
})
|
|
500
503
|
const proxy = await initializeProxy({
|
|
504
|
+
host: settings.frameworkHost,
|
|
501
505
|
port: settings.frameworkPort,
|
|
502
506
|
distDir: settings.dist,
|
|
503
507
|
projectDir,
|