netlify-cli 9.6.0 → 9.6.1
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 +2 -2
- package/package.json +1 -1
- package/src/commands/dev/dev.js +44 -2
- package/src/functions-templates/javascript/scheduled-function/package.json +1 -1
- package/src/functions-templates/typescript/hello-world/package-lock.json +8 -8
- package/src/functions-templates/typescript/hello-world/package.json +1 -1
- package/src/functions-templates/typescript/scheduled-function/package.json +1 -1
- package/src/lib/functions/server.js +1 -45
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
|
-
"version": "9.6.
|
|
3
|
+
"version": "9.6.1",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "netlify-cli",
|
|
9
|
-
"version": "9.6.
|
|
9
|
+
"version": "9.6.1",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
package/package.json
CHANGED
package/src/commands/dev/dev.js
CHANGED
|
@@ -33,6 +33,7 @@ const {
|
|
|
33
33
|
detectServerSettings,
|
|
34
34
|
error,
|
|
35
35
|
exit,
|
|
36
|
+
generateNetlifyGraphJWT,
|
|
36
37
|
getSiteInformation,
|
|
37
38
|
injectEnvVariables,
|
|
38
39
|
log,
|
|
@@ -262,6 +263,44 @@ const printBanner = ({ url }) => {
|
|
|
262
263
|
)
|
|
263
264
|
}
|
|
264
265
|
|
|
266
|
+
const startPollingForAPIAuthentication = async function (options) {
|
|
267
|
+
const { api, command, config, site, siteInfo } = options
|
|
268
|
+
const frequency = 5000
|
|
269
|
+
|
|
270
|
+
const helper = async (maybeSiteData) => {
|
|
271
|
+
const siteData = await (maybeSiteData || api.getSite({ siteId: site.id }))
|
|
272
|
+
const authlifyTokenId = siteData && siteData.authlify_token_id
|
|
273
|
+
|
|
274
|
+
const existingAuthlifyTokenId = config && config.netlifyGraphConfig && config.netlifyGraphConfig.authlifyTokenId
|
|
275
|
+
if (authlifyTokenId && authlifyTokenId !== existingAuthlifyTokenId) {
|
|
276
|
+
const netlifyToken = await command.authenticate()
|
|
277
|
+
// Only inject the authlify config if a token ID exists. This prevents
|
|
278
|
+
// calling command.authenticate() (which opens a browser window) if the
|
|
279
|
+
// user hasn't enabled API Authentication
|
|
280
|
+
const netlifyGraphConfig = {
|
|
281
|
+
netlifyToken,
|
|
282
|
+
authlifyTokenId: siteData.authlify_token_id,
|
|
283
|
+
siteId: site.id,
|
|
284
|
+
}
|
|
285
|
+
config.netlifyGraphConfig = netlifyGraphConfig
|
|
286
|
+
|
|
287
|
+
const netlifyGraphJWT = generateNetlifyGraphJWT(netlifyGraphConfig)
|
|
288
|
+
|
|
289
|
+
if (netlifyGraphJWT != null) {
|
|
290
|
+
// XXX(anmonteiro): this name is deprecated. Delete after 3/31/2022
|
|
291
|
+
process.env.ONEGRAPH_AUTHLIFY_TOKEN = netlifyGraphJWT
|
|
292
|
+
process.env.NETLIFY_GRAPH_TOKEN = netlifyGraphJWT
|
|
293
|
+
}
|
|
294
|
+
} else {
|
|
295
|
+
delete config.netlifyGraphConfig
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
setTimeout(helper, frequency)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
await helper(siteInfo)
|
|
302
|
+
}
|
|
303
|
+
|
|
265
304
|
/**
|
|
266
305
|
* The dev command
|
|
267
306
|
* @param {import('commander').OptionValues} options
|
|
@@ -287,7 +326,6 @@ const dev = async (options, command) => {
|
|
|
287
326
|
)
|
|
288
327
|
}
|
|
289
328
|
|
|
290
|
-
const startNetlifyGraphWatcher = Boolean(options.graph)
|
|
291
329
|
await injectEnvVariables({ env: command.netlify.cachedConfig.env, site })
|
|
292
330
|
|
|
293
331
|
const { addonsUrls, capabilities, siteUrl, timeouts } = await getSiteInformation({
|
|
@@ -309,11 +347,15 @@ const dev = async (options, command) => {
|
|
|
309
347
|
|
|
310
348
|
command.setAnalyticsPayload({ projectType: settings.framework || 'custom', live: options.live })
|
|
311
349
|
|
|
350
|
+
const startNetlifyGraphWatcher = Boolean(options.graph)
|
|
351
|
+
if (startNetlifyGraphWatcher) {
|
|
352
|
+
startPollingForAPIAuthentication({ api, command, config, site, siteInfo })
|
|
353
|
+
}
|
|
354
|
+
|
|
312
355
|
await startFunctionsServer({
|
|
313
356
|
api,
|
|
314
357
|
command,
|
|
315
358
|
config,
|
|
316
|
-
isGraphEnabled: startNetlifyGraphWatcher,
|
|
317
359
|
settings,
|
|
318
360
|
site,
|
|
319
361
|
siteInfo,
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@netlify/functions": "^0.11.
|
|
13
|
-
"@types/node": "^14.
|
|
12
|
+
"@netlify/functions": "^0.11.1",
|
|
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.11.
|
|
19
|
-
"resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-0.11.
|
|
20
|
-
"integrity": "sha512
|
|
18
|
+
"version": "0.11.1",
|
|
19
|
+
"resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-0.11.1.tgz",
|
|
20
|
+
"integrity": "sha512-J2QUAYRblvTrl/cOYU2RNHdv/EYy4qnKQhds0aDNB560Y83wfpaMS3F7PKpHygGWrVuLRyevenIzsV9MaQrKlQ==",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"is-promise": "^4.0.0"
|
|
23
23
|
},
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@netlify/functions": {
|
|
53
|
-
"version": "0.11.
|
|
54
|
-
"resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-0.11.
|
|
55
|
-
"integrity": "sha512
|
|
53
|
+
"version": "0.11.1",
|
|
54
|
+
"resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-0.11.1.tgz",
|
|
55
|
+
"integrity": "sha512-J2QUAYRblvTrl/cOYU2RNHdv/EYy4qnKQhds0aDNB560Y83wfpaMS3F7PKpHygGWrVuLRyevenIzsV9MaQrKlQ==",
|
|
56
56
|
"requires": {
|
|
57
57
|
"is-promise": "^4.0.0"
|
|
58
58
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
const process = require('process')
|
|
3
|
-
|
|
4
2
|
const jwtDecode = require('jwt-decode')
|
|
5
3
|
|
|
6
4
|
const {
|
|
@@ -47,51 +45,9 @@ const buildClientContext = function (headers) {
|
|
|
47
45
|
}
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
const startPollingForAPIAuthentication = async function (options) {
|
|
51
|
-
const { api, command, config, site, siteInfo } = options
|
|
52
|
-
const frequency = 5000
|
|
53
|
-
|
|
54
|
-
const helper = async (maybeSiteData) => {
|
|
55
|
-
const siteData = await (maybeSiteData || api.getSite({ siteId: site.id }))
|
|
56
|
-
const authlifyTokenId = siteData && siteData.authlify_token_id
|
|
57
|
-
|
|
58
|
-
const existingAuthlifyTokenId = config && config.netlifyGraphConfig && config.netlifyGraphConfig.authlifyTokenId
|
|
59
|
-
if (authlifyTokenId && authlifyTokenId !== existingAuthlifyTokenId) {
|
|
60
|
-
const netlifyToken = await command.authenticate()
|
|
61
|
-
// Only inject the authlify config if a token ID exists. This prevents
|
|
62
|
-
// calling command.authenticate() (which opens a browser window) if the
|
|
63
|
-
// user hasn't enabled API Authentication
|
|
64
|
-
const netlifyGraphConfig = {
|
|
65
|
-
netlifyToken,
|
|
66
|
-
authlifyTokenId: siteData.authlify_token_id,
|
|
67
|
-
siteId: site.id,
|
|
68
|
-
}
|
|
69
|
-
config.netlifyGraphConfig = netlifyGraphConfig
|
|
70
|
-
|
|
71
|
-
const netlifyGraphJWT = generateNetlifyGraphJWT(netlifyGraphConfig)
|
|
72
|
-
|
|
73
|
-
if (netlifyGraphJWT != null) {
|
|
74
|
-
// XXX(anmonteiro): this name is deprecated. Delete after 3/31/2022
|
|
75
|
-
process.env.ONEGRAPH_AUTHLIFY_TOKEN = netlifyGraphJWT
|
|
76
|
-
process.env.NETLIFY_GRAPH_TOKEN = netlifyGraphJWT
|
|
77
|
-
}
|
|
78
|
-
} else {
|
|
79
|
-
delete config.authlify
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
setTimeout(helper, frequency)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
await helper(siteInfo)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
48
|
const createHandler = function (options) {
|
|
89
49
|
const { config, functionsRegistry } = options
|
|
90
50
|
|
|
91
|
-
if (options.isGraphEnabled) {
|
|
92
|
-
startPollingForAPIAuthentication(options)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
51
|
return async function handler(request, response) {
|
|
96
52
|
// handle proxies without path re-writes (http-servr)
|
|
97
53
|
const cleanPath = request.path.replace(/^\/.netlify\/(functions|builders)/, '')
|
|
@@ -152,7 +108,7 @@ const createHandler = function (options) {
|
|
|
152
108
|
rawQuery,
|
|
153
109
|
}
|
|
154
110
|
|
|
155
|
-
if (config && config.
|
|
111
|
+
if (config && config.netlifyGraphConfig && config.netlifyGraphConfig.authlifyTokenId != null) {
|
|
156
112
|
// XXX(anmonteiro): this name is deprecated. Delete after 3/31/2022
|
|
157
113
|
const jwt = generateNetlifyGraphJWT(config.netlifyGraphConfig)
|
|
158
114
|
event.authlifyToken = jwt
|