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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "netlify-cli",
3
- "version": "9.6.0",
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.0",
9
+ "version": "9.6.1",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "netlify-cli",
3
3
  "description": "Netlify command line tool",
4
- "version": "9.6.0",
4
+ "version": "9.6.1",
5
5
  "author": "Netlify Inc.",
6
6
  "contributors": [
7
7
  "Abraham Schilling <AbrahamSchilling@gmail.com> (https://gitlab.com/n4bb12)",
@@ -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,
@@ -15,6 +15,6 @@
15
15
  "author": "Netlify",
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
- "@netlify/functions": "^0.11.0"
18
+ "@netlify/functions": "^0.11.1"
19
19
  }
20
20
  }
@@ -9,15 +9,15 @@
9
9
  "version": "1.0.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@netlify/functions": "^0.11.0",
13
- "@types/node": "^14.18.11",
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.0",
19
- "resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-0.11.0.tgz",
20
- "integrity": "sha512-+WWX081UCkLZYkfh1Ru+PH5HTujNXugeskATGhZLTyS1U3Cqh2gYLArdG1a/vU8WWopu/wjpxEOdWq8/T5Nw5Q==",
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.0",
54
- "resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-0.11.0.tgz",
55
- "integrity": "sha512-+WWX081UCkLZYkfh1Ru+PH5HTujNXugeskATGhZLTyS1U3Cqh2gYLArdG1a/vU8WWopu/wjpxEOdWq8/T5Nw5Q==",
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
  }
@@ -14,7 +14,7 @@
14
14
  "author": "Netlify",
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@netlify/functions": "^0.11.0",
17
+ "@netlify/functions": "^0.11.1",
18
18
  "@types/node": "^14.0.0",
19
19
  "typescript": "^4.0.0"
20
20
  }
@@ -15,7 +15,7 @@
15
15
  "author": "Netlify",
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
- "@netlify/functions": "^0.11.0",
18
+ "@netlify/functions": "^0.11.1",
19
19
  "@types/node": "^14.18.9",
20
20
  "typescript": "^4.5.5"
21
21
  }
@@ -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.authlify && config.authlify.authlifyTokenId != null) {
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