netlify-cli 7.0.2 → 7.1.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/npm-shrinkwrap.json +866 -595
- package/oclif.manifest.json +1 -1
- package/package.json +3 -3
- package/src/commands/dev/index.js +44 -19
- package/src/functions-templates/javascript/stripe-charge/package-lock.json +13 -13
- package/src/functions-templates/javascript/stripe-subscription/package-lock.json +13 -13
- package/src/functions-templates/javascript/url-shortener/package-lock.json +7 -7
- package/src/functions-templates/rust/hello-world/Cargo.toml +1 -1
- package/src/functions-templates/typescript/hello-world/package-lock.json +19 -19
- package/src/functions-templates/typescript/hello-world/package.json +1 -1
- package/src/utils/detect-server-settings.js +35 -10
- package/src/utils/proxy.js +2 -1
- package/src/utils/rules-proxy.js +2 -3
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@netlify/functions": "^0.
|
|
12
|
+
"@netlify/functions": "^0.10.0",
|
|
13
13
|
"@types/node": "^14.0.0",
|
|
14
14
|
"typescript": "^4.0.0"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"node_modules/@netlify/functions": {
|
|
18
|
-
"version": "0.
|
|
19
|
-
"resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-0.
|
|
20
|
-
"integrity": "sha512-
|
|
18
|
+
"version": "0.10.0",
|
|
19
|
+
"resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-0.10.0.tgz",
|
|
20
|
+
"integrity": "sha512-NNFADTPnokuoMY1OUhaXlE/Jrzk5lHOl1uB4L/8pw1UJ/CaectZJACMExijbJnqaKIhOQG0WmbBQUh1lgnK/Qg==",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"is-promise": "^4.0.0"
|
|
23
23
|
},
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"node_modules/@types/node": {
|
|
29
|
-
"version": "14.17.
|
|
30
|
-
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.
|
|
31
|
-
"integrity": "sha512-
|
|
29
|
+
"version": "14.17.34",
|
|
30
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.34.tgz",
|
|
31
|
+
"integrity": "sha512-USUftMYpmuMzeWobskoPfzDi+vkpe0dvcOBRNOscFrGxVp4jomnRxWuVohgqBow2xyIPC0S3gjxV/5079jhmDg=="
|
|
32
32
|
},
|
|
33
33
|
"node_modules/is-promise": {
|
|
34
34
|
"version": "4.0.0",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ=="
|
|
37
37
|
},
|
|
38
38
|
"node_modules/typescript": {
|
|
39
|
-
"version": "4.
|
|
40
|
-
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.
|
|
41
|
-
"integrity": "sha512-
|
|
39
|
+
"version": "4.5.2",
|
|
40
|
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz",
|
|
41
|
+
"integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==",
|
|
42
42
|
"bin": {
|
|
43
43
|
"tsc": "bin/tsc",
|
|
44
44
|
"tsserver": "bin/tsserver"
|
|
@@ -50,17 +50,17 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@netlify/functions": {
|
|
53
|
-
"version": "0.
|
|
54
|
-
"resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-0.
|
|
55
|
-
"integrity": "sha512-
|
|
53
|
+
"version": "0.10.0",
|
|
54
|
+
"resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-0.10.0.tgz",
|
|
55
|
+
"integrity": "sha512-NNFADTPnokuoMY1OUhaXlE/Jrzk5lHOl1uB4L/8pw1UJ/CaectZJACMExijbJnqaKIhOQG0WmbBQUh1lgnK/Qg==",
|
|
56
56
|
"requires": {
|
|
57
57
|
"is-promise": "^4.0.0"
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"@types/node": {
|
|
61
|
-
"version": "14.17.
|
|
62
|
-
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.
|
|
63
|
-
"integrity": "sha512-
|
|
61
|
+
"version": "14.17.34",
|
|
62
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.34.tgz",
|
|
63
|
+
"integrity": "sha512-USUftMYpmuMzeWobskoPfzDi+vkpe0dvcOBRNOscFrGxVp4jomnRxWuVohgqBow2xyIPC0S3gjxV/5079jhmDg=="
|
|
64
64
|
},
|
|
65
65
|
"is-promise": {
|
|
66
66
|
"version": "4.0.0",
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ=="
|
|
69
69
|
},
|
|
70
70
|
"typescript": {
|
|
71
|
-
"version": "4.
|
|
72
|
-
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.
|
|
73
|
-
"integrity": "sha512-
|
|
71
|
+
"version": "4.5.2",
|
|
72
|
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz",
|
|
73
|
+
"integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw=="
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
const { EOL } = require('os')
|
|
2
3
|
const path = require('path')
|
|
3
4
|
const process = require('process')
|
|
@@ -101,6 +102,14 @@ const getDefaultDist = () => {
|
|
|
101
102
|
return process.cwd()
|
|
102
103
|
}
|
|
103
104
|
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @param {object} param0
|
|
108
|
+
* @param {import('../commands/dev/types').DevConfig} param0.devConfig
|
|
109
|
+
* @param {Record<string, string>} param0.flags
|
|
110
|
+
* @param {string} param0.projectDir
|
|
111
|
+
* @returns {Promise<import('./types').BaseServerSettings>}
|
|
112
|
+
*/
|
|
104
113
|
const handleStaticServer = async ({ devConfig, flags, projectDir }) => {
|
|
105
114
|
validateNumberProperty({ devConfig, property: 'staticServerPort' })
|
|
106
115
|
|
|
@@ -114,14 +123,6 @@ const handleStaticServer = async ({ devConfig, flags, projectDir }) => {
|
|
|
114
123
|
)
|
|
115
124
|
}
|
|
116
125
|
|
|
117
|
-
if (devConfig.command) {
|
|
118
|
-
log(
|
|
119
|
-
`${NETLIFYDEVWARN} Ignoring command setting since using a simple static server. Configure ${formatProperty(
|
|
120
|
-
'command',
|
|
121
|
-
)} ${chalk.bold('and')} ${formatProperty('targetPort')} for a custom setup`,
|
|
122
|
-
)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
126
|
if (devConfig.targetPort) {
|
|
126
127
|
log(
|
|
127
128
|
`${NETLIFYDEVWARN} Ignoring ${formatProperty(
|
|
@@ -139,12 +140,18 @@ const handleStaticServer = async ({ devConfig, flags, projectDir }) => {
|
|
|
139
140
|
errorMessage: 'Could not acquire configured static server port',
|
|
140
141
|
})
|
|
141
142
|
return {
|
|
143
|
+
...(devConfig.command && { command: devConfig.command }),
|
|
142
144
|
useStaticServer: true,
|
|
143
145
|
frameworkPort,
|
|
144
146
|
dist,
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Retrieves the settings from a framework
|
|
152
|
+
* @param {import('./types').FrameworkInfo} framework
|
|
153
|
+
* @returns {import('./types').BaseServerSettings}
|
|
154
|
+
*/
|
|
148
155
|
const getSettingsFromFramework = (framework) => {
|
|
149
156
|
const {
|
|
150
157
|
build: { directory: dist },
|
|
@@ -171,7 +178,8 @@ const getSettingsFromFramework = (framework) => {
|
|
|
171
178
|
const hasDevCommand = (framework) => Array.isArray(framework.dev.commands) && framework.dev.commands.length !== 0
|
|
172
179
|
|
|
173
180
|
const detectFrameworkSettings = async ({ projectDir }) => {
|
|
174
|
-
const
|
|
181
|
+
const projectFrameworks = await listFrameworks({ projectDir })
|
|
182
|
+
const frameworks = projectFrameworks.filter((framework) => hasDevCommand(framework))
|
|
175
183
|
|
|
176
184
|
if (frameworks.length === 1) {
|
|
177
185
|
return getSettingsFromFramework(frameworks[0])
|
|
@@ -210,6 +218,11 @@ const detectFrameworkSettings = async ({ projectDir }) => {
|
|
|
210
218
|
|
|
211
219
|
const hasCommandAndTargetPort = ({ devConfig }) => devConfig.command && devConfig.targetPort
|
|
212
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Creates settings for the custom framework
|
|
223
|
+
* @param {*} param0
|
|
224
|
+
* @returns {import('./types').BaseServerSettings}
|
|
225
|
+
*/
|
|
213
226
|
const handleCustomFramework = ({ devConfig }) => {
|
|
214
227
|
if (!hasCommandAndTargetPort({ devConfig })) {
|
|
215
228
|
throw new Error(
|
|
@@ -227,6 +240,11 @@ const handleCustomFramework = ({ devConfig }) => {
|
|
|
227
240
|
}
|
|
228
241
|
}
|
|
229
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Handles a forced framework and retrieves the settings for it
|
|
245
|
+
* @param {*} param0
|
|
246
|
+
* @returns {Promise<import('./types').BaseServerSettings>}
|
|
247
|
+
*/
|
|
230
248
|
const handleForcedFramework = async ({ devConfig, projectDir }) => {
|
|
231
249
|
// this throws if `devConfig.framework` is not a supported framework
|
|
232
250
|
const { command, dist, env, framework, frameworkPort, pollingStrategies } = getSettingsFromFramework(
|
|
@@ -242,9 +260,17 @@ const handleForcedFramework = async ({ devConfig, projectDir }) => {
|
|
|
242
260
|
}
|
|
243
261
|
}
|
|
244
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Get the server settings based on the flags and the devConfig
|
|
265
|
+
* @param {import('../commands/dev/types').DevConfig} devConfig
|
|
266
|
+
* @param {Record<string, string>} flags
|
|
267
|
+
* @param {string} projectDir
|
|
268
|
+
* @returns {Promise<import('./types').ServerSettings>}
|
|
269
|
+
*/
|
|
245
270
|
const detectServerSettings = async (devConfig, flags, projectDir) => {
|
|
246
271
|
validateStringProperty({ devConfig, property: 'framework' })
|
|
247
272
|
|
|
273
|
+
/** @type {Partial<import('./types').BaseServerSettings>} */
|
|
248
274
|
let settings = {}
|
|
249
275
|
|
|
250
276
|
if (flags.dir || devConfig.framework === '#static') {
|
|
@@ -253,7 +279,6 @@ const detectServerSettings = async (devConfig, flags, projectDir) => {
|
|
|
253
279
|
} else if (devConfig.framework === '#auto') {
|
|
254
280
|
// this is the default CLI behavior
|
|
255
281
|
|
|
256
|
-
// we don't need to run the detection if both command and targetPort are configured
|
|
257
282
|
const runDetection = !hasCommandAndTargetPort({ devConfig })
|
|
258
283
|
const frameworkSettings = runDetection ? await detectFrameworkSettings({ projectDir }) : undefined
|
|
259
284
|
|
package/src/utils/proxy.js
CHANGED
|
@@ -286,9 +286,10 @@ const initializeProxy = async function ({ configPath, distDir, port, projectDir
|
|
|
286
286
|
|
|
287
287
|
const watchedHeadersFiles = configPath === undefined ? headersFiles : [...headersFiles, configPath]
|
|
288
288
|
onChanges(watchedHeadersFiles, async () => {
|
|
289
|
+
const existingHeadersFiles = await pFilter(watchedHeadersFiles, fileExistsAsync)
|
|
289
290
|
console.log(
|
|
290
291
|
`${NETLIFYDEVLOG} Reloading headers files from`,
|
|
291
|
-
|
|
292
|
+
existingHeadersFiles.map((headerFile) => path.relative(projectDir, headerFile)),
|
|
292
293
|
)
|
|
293
294
|
headers = await parseHeaders({ headersFiles, configPath })
|
|
294
295
|
})
|
package/src/utils/rules-proxy.js
CHANGED
|
@@ -37,11 +37,10 @@ const createRewriter = async function ({ configPath, distDir, jwtRoleClaim, jwtS
|
|
|
37
37
|
|
|
38
38
|
const watchedRedirectFiles = configPath === undefined ? redirectsFiles : [...redirectsFiles, configPath]
|
|
39
39
|
onChanges(watchedRedirectFiles, async () => {
|
|
40
|
+
const existingRedirectsFiles = await pFilter(watchedRedirectFiles, fileExistsAsync)
|
|
40
41
|
console.log(
|
|
41
42
|
`${NETLIFYDEVLOG} Reloading redirect rules from`,
|
|
42
|
-
|
|
43
|
-
path.relative(projectDir, redirectFile),
|
|
44
|
-
),
|
|
43
|
+
existingRedirectsFiles.map((redirectFile) => path.relative(projectDir, redirectFile)),
|
|
45
44
|
)
|
|
46
45
|
redirects = await parseRedirects({ redirectsFiles, configPath })
|
|
47
46
|
matcher = null
|