netlify-cli 10.8.0 → 10.9.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 +16 -16
- package/package.json +3 -3
- package/src/commands/dev/dev.js +23 -0
- package/src/commands/graph/graph-pull.js +3 -2
- package/src/lib/edge-functions/proxy.js +2 -1
- package/src/lib/geo-location.js +17 -11
- package/src/lib/one-graph/cli-client.js +42 -22
- package/src/utils/proxy.js +2 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.9.0",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "netlify-cli",
|
|
9
|
-
"version": "10.
|
|
9
|
+
"version": "10.9.0",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@netlify/edge-bundler": "^1.5.0",
|
|
16
16
|
"@netlify/framework-info": "^9.1.0",
|
|
17
17
|
"@netlify/local-functions-proxy": "^1.1.1",
|
|
18
|
-
"@netlify/plugins-list": "^6.
|
|
18
|
+
"@netlify/plugins-list": "^6.32.0",
|
|
19
19
|
"@netlify/zip-it-and-ship-it": "^5.12.0",
|
|
20
20
|
"@octokit/rest": "^18.0.0",
|
|
21
21
|
"@sindresorhus/slugify": "^1.1.0",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"multiparty": "^4.2.1",
|
|
82
82
|
"netlify": "^11.0.2",
|
|
83
83
|
"netlify-headers-parser": "^6.0.2",
|
|
84
|
-
"netlify-onegraph-internal": "0.3.
|
|
84
|
+
"netlify-onegraph-internal": "0.3.6",
|
|
85
85
|
"netlify-redirect-parser": "^13.0.5",
|
|
86
86
|
"netlify-redirector": "^0.2.1",
|
|
87
87
|
"node-fetch": "^2.6.0",
|
|
@@ -3946,9 +3946,9 @@
|
|
|
3946
3946
|
"integrity": "sha512-ZJF4nbLPfxsWrVgp2reCb23HMxsWl5+r+K0RtIhxcZ/RxbHVihRA9mwyzIcxPWrT5x9uAAxCr1aKGP7IdsDe+Q=="
|
|
3947
3947
|
},
|
|
3948
3948
|
"node_modules/@netlify/plugins-list": {
|
|
3949
|
-
"version": "6.
|
|
3950
|
-
"resolved": "https://registry.npmjs.org/@netlify/plugins-list/-/plugins-list-6.
|
|
3951
|
-
"integrity": "sha512-
|
|
3949
|
+
"version": "6.32.0",
|
|
3950
|
+
"resolved": "https://registry.npmjs.org/@netlify/plugins-list/-/plugins-list-6.32.0.tgz",
|
|
3951
|
+
"integrity": "sha512-ZYaik41Xl7Jg7k204daKG26eT8pywThqvrwsDqW3gVuVx+Clo3uSrPTwNEuHme9Py0smdw2/oG2qp1jH3Q5sLQ==",
|
|
3952
3952
|
"engines": {
|
|
3953
3953
|
"node": "^12.20.0 || ^14.14.0 || >=16.0.0"
|
|
3954
3954
|
}
|
|
@@ -16342,9 +16342,9 @@
|
|
|
16342
16342
|
}
|
|
16343
16343
|
},
|
|
16344
16344
|
"node_modules/netlify-onegraph-internal": {
|
|
16345
|
-
"version": "0.3.
|
|
16346
|
-
"resolved": "https://registry.npmjs.org/netlify-onegraph-internal/-/netlify-onegraph-internal-0.3.
|
|
16347
|
-
"integrity": "sha512-
|
|
16345
|
+
"version": "0.3.6",
|
|
16346
|
+
"resolved": "https://registry.npmjs.org/netlify-onegraph-internal/-/netlify-onegraph-internal-0.3.6.tgz",
|
|
16347
|
+
"integrity": "sha512-nNqCWT2jzPmqw/3/sKf1RFicL2JEFjmxXTpnIzJKt5U+bnS633cOy5pImNnfBGTd50NTNvdZ0GXMhQ7AwH16Qg==",
|
|
16348
16348
|
"dependencies": {
|
|
16349
16349
|
"graphql": "16.0.0",
|
|
16350
16350
|
"node-fetch": "^2.6.0",
|
|
@@ -25771,9 +25771,9 @@
|
|
|
25771
25771
|
"integrity": "sha512-ZJF4nbLPfxsWrVgp2reCb23HMxsWl5+r+K0RtIhxcZ/RxbHVihRA9mwyzIcxPWrT5x9uAAxCr1aKGP7IdsDe+Q=="
|
|
25772
25772
|
},
|
|
25773
25773
|
"@netlify/plugins-list": {
|
|
25774
|
-
"version": "6.
|
|
25775
|
-
"resolved": "https://registry.npmjs.org/@netlify/plugins-list/-/plugins-list-6.
|
|
25776
|
-
"integrity": "sha512-
|
|
25774
|
+
"version": "6.32.0",
|
|
25775
|
+
"resolved": "https://registry.npmjs.org/@netlify/plugins-list/-/plugins-list-6.32.0.tgz",
|
|
25776
|
+
"integrity": "sha512-ZYaik41Xl7Jg7k204daKG26eT8pywThqvrwsDqW3gVuVx+Clo3uSrPTwNEuHme9Py0smdw2/oG2qp1jH3Q5sLQ=="
|
|
25777
25777
|
},
|
|
25778
25778
|
"@netlify/run-utils": {
|
|
25779
25779
|
"version": "4.0.1",
|
|
@@ -35237,9 +35237,9 @@
|
|
|
35237
35237
|
}
|
|
35238
35238
|
},
|
|
35239
35239
|
"netlify-onegraph-internal": {
|
|
35240
|
-
"version": "0.3.
|
|
35241
|
-
"resolved": "https://registry.npmjs.org/netlify-onegraph-internal/-/netlify-onegraph-internal-0.3.
|
|
35242
|
-
"integrity": "sha512-
|
|
35240
|
+
"version": "0.3.6",
|
|
35241
|
+
"resolved": "https://registry.npmjs.org/netlify-onegraph-internal/-/netlify-onegraph-internal-0.3.6.tgz",
|
|
35242
|
+
"integrity": "sha512-nNqCWT2jzPmqw/3/sKf1RFicL2JEFjmxXTpnIzJKt5U+bnS633cOy5pImNnfBGTd50NTNvdZ0GXMhQ7AwH16Qg==",
|
|
35243
35243
|
"requires": {
|
|
35244
35244
|
"graphql": "16.0.0",
|
|
35245
35245
|
"node-fetch": "^2.6.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": "10.
|
|
4
|
+
"version": "10.9.0",
|
|
5
5
|
"author": "Netlify Inc.",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Abraham Schilling <AbrahamSchilling@gmail.com> (https://gitlab.com/n4bb12)",
|
|
@@ -221,7 +221,7 @@
|
|
|
221
221
|
"@netlify/edge-bundler": "^1.5.0",
|
|
222
222
|
"@netlify/framework-info": "^9.1.0",
|
|
223
223
|
"@netlify/local-functions-proxy": "^1.1.1",
|
|
224
|
-
"@netlify/plugins-list": "^6.
|
|
224
|
+
"@netlify/plugins-list": "^6.32.0",
|
|
225
225
|
"@netlify/zip-it-and-ship-it": "^5.12.0",
|
|
226
226
|
"@octokit/rest": "^18.0.0",
|
|
227
227
|
"@sindresorhus/slugify": "^1.1.0",
|
|
@@ -287,7 +287,7 @@
|
|
|
287
287
|
"multiparty": "^4.2.1",
|
|
288
288
|
"netlify": "^11.0.2",
|
|
289
289
|
"netlify-headers-parser": "^6.0.2",
|
|
290
|
-
"netlify-onegraph-internal": "0.3.
|
|
290
|
+
"netlify-onegraph-internal": "0.3.6",
|
|
291
291
|
"netlify-redirect-parser": "^13.0.5",
|
|
292
292
|
"netlify-redirector": "^0.2.1",
|
|
293
293
|
"node-fetch": "^2.6.0",
|
package/src/commands/dev/dev.js
CHANGED
|
@@ -234,6 +234,7 @@ const FRAMEWORK_PORT_TIMEOUT = 6e5
|
|
|
234
234
|
* @param {InspectSettings} params.inspectSettings
|
|
235
235
|
* @param {() => Promise<object>} params.getUpdatedConfig
|
|
236
236
|
* @param {string} params.geolocationMode
|
|
237
|
+
* @param {string} params.geoCountry
|
|
237
238
|
* @param {*} params.settings
|
|
238
239
|
* @param {boolean} params.offline
|
|
239
240
|
* @param {*} params.site
|
|
@@ -243,6 +244,7 @@ const FRAMEWORK_PORT_TIMEOUT = 6e5
|
|
|
243
244
|
const startProxyServer = async ({
|
|
244
245
|
addonsUrls,
|
|
245
246
|
config,
|
|
247
|
+
geoCountry,
|
|
246
248
|
geolocationMode,
|
|
247
249
|
getUpdatedConfig,
|
|
248
250
|
inspectSettings,
|
|
@@ -256,6 +258,7 @@ const startProxyServer = async ({
|
|
|
256
258
|
config,
|
|
257
259
|
configPath: site.configPath,
|
|
258
260
|
geolocationMode,
|
|
261
|
+
geoCountry,
|
|
259
262
|
getUpdatedConfig,
|
|
260
263
|
inspectSettings,
|
|
261
264
|
offline,
|
|
@@ -386,6 +389,19 @@ const validateShortFlagArgs = (args) => {
|
|
|
386
389
|
return args
|
|
387
390
|
}
|
|
388
391
|
|
|
392
|
+
const validateGeoCountryCode = (arg) => {
|
|
393
|
+
// Validate that the arg passed is two letters only for country
|
|
394
|
+
// See https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
|
|
395
|
+
if (!/^[a-z]{2}$/i.test(arg)) {
|
|
396
|
+
throw new Error(
|
|
397
|
+
`The geo country code must use a two letter abbreviation.
|
|
398
|
+
${chalk.red(BANG)} Example:
|
|
399
|
+
netlify dev --geo=mock --country=FR`,
|
|
400
|
+
)
|
|
401
|
+
}
|
|
402
|
+
return arg.toUpperCase()
|
|
403
|
+
}
|
|
404
|
+
|
|
389
405
|
/**
|
|
390
406
|
* The dev command
|
|
391
407
|
* @param {import('commander').OptionValues} options
|
|
@@ -460,6 +476,7 @@ const dev = async (options, command) => {
|
|
|
460
476
|
addonsUrls,
|
|
461
477
|
config,
|
|
462
478
|
geolocationMode: options.geo,
|
|
479
|
+
geoCountry: options.country,
|
|
463
480
|
getUpdatedConfig,
|
|
464
481
|
inspectSettings,
|
|
465
482
|
offline: options.offline,
|
|
@@ -599,6 +616,12 @@ const createDevCommand = (program) => {
|
|
|
599
616
|
.choices(['cache', 'mock', 'update'])
|
|
600
617
|
.default('cache'),
|
|
601
618
|
)
|
|
619
|
+
.addOption(
|
|
620
|
+
new Option(
|
|
621
|
+
'--country <geoCountry>',
|
|
622
|
+
'Two-letter country code (ISO 3166-1 alpha-2, https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) to use as mock geolocation (enables --geo=mock autmatically)',
|
|
623
|
+
).argParser(validateGeoCountryCode),
|
|
624
|
+
)
|
|
602
625
|
.addOption(
|
|
603
626
|
new Option('--staticServerPort <port>', 'port of the static app server used when no framework is detected')
|
|
604
627
|
.argParser((value) => Number.parseInt(value))
|
|
@@ -56,9 +56,10 @@ const graphPull = async (options, command) => {
|
|
|
56
56
|
error(`Failed to fetch and update Netlify GraphQL schema`)
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
const { jwt } = await OneGraphCliClient.getGraphJwtForSite({ siteId, nfToken: netlifyToken })
|
|
59
60
|
const next = await OneGraphCliClient.fetchCliSessionEvents({
|
|
60
61
|
appId: siteId,
|
|
61
|
-
|
|
62
|
+
jwt,
|
|
62
63
|
sessionId: oneGraphSessionId,
|
|
63
64
|
})
|
|
64
65
|
|
|
@@ -83,7 +84,7 @@ const graphPull = async (options, command) => {
|
|
|
83
84
|
|
|
84
85
|
await OneGraphCliClient.ackCLISessionEvents({
|
|
85
86
|
appId: siteId,
|
|
86
|
-
|
|
87
|
+
jwt,
|
|
87
88
|
sessionId: oneGraphSessionId,
|
|
88
89
|
eventIds: ackIds,
|
|
89
90
|
})
|
|
@@ -48,6 +48,7 @@ const handleProxyRequest = (req, proxyReq) => {
|
|
|
48
48
|
const initializeProxy = async ({
|
|
49
49
|
config,
|
|
50
50
|
configPath,
|
|
51
|
+
geoCountry,
|
|
51
52
|
geolocationMode,
|
|
52
53
|
getUpdatedConfig,
|
|
53
54
|
inspectSettings,
|
|
@@ -84,7 +85,7 @@ const initializeProxy = async ({
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
const [geoLocation, registry] = await Promise.all([
|
|
87
|
-
getGeoLocation({ mode: geolocationMode, offline, state }),
|
|
88
|
+
getGeoLocation({ mode: geolocationMode, geoCountry, offline, state }),
|
|
88
89
|
server,
|
|
89
90
|
])
|
|
90
91
|
|
package/src/lib/geo-location.js
CHANGED
|
@@ -3,7 +3,6 @@ const fetch = require('node-fetch')
|
|
|
3
3
|
|
|
4
4
|
const API_URL = 'https://netlifind.netlify.app'
|
|
5
5
|
const STATE_GEO_PROPERTY = 'geolocation'
|
|
6
|
-
|
|
7
6
|
// 24 hours
|
|
8
7
|
const CACHE_TTL = 8.64e7
|
|
9
8
|
|
|
@@ -17,12 +16,11 @@ const REQUEST_TIMEOUT = 1e4
|
|
|
17
16
|
* @property {object} country
|
|
18
17
|
* @property {string} country.code
|
|
19
18
|
* @property {string} country.name
|
|
20
|
-
* @property {object}
|
|
21
|
-
* @property {string}
|
|
22
|
-
* @property {string}
|
|
19
|
+
* @property {object} subdivision
|
|
20
|
+
* @property {string} subdivision.code
|
|
21
|
+
* @property {string} subdivision.name
|
|
23
22
|
*/
|
|
24
23
|
|
|
25
|
-
// The default location to be used if we're unable to talk to the API.
|
|
26
24
|
const mockLocation = {
|
|
27
25
|
city: 'San Francisco',
|
|
28
26
|
country: { code: 'US', name: 'United States' },
|
|
@@ -34,13 +32,13 @@ const mockLocation = {
|
|
|
34
32
|
* location, depending on the mode selected.
|
|
35
33
|
*
|
|
36
34
|
* @param {object} params
|
|
37
|
-
* @param {string} params.geolocationMode
|
|
38
35
|
* @param {"cache"|"update"|"mock"} params.mode
|
|
36
|
+
* @param {string} params.geoCountry
|
|
39
37
|
* @param {boolean} params.offline
|
|
40
38
|
* @param {import('../utils/state-config').StateConfig} params.state
|
|
41
39
|
* @returns {Promise<GeoLocation>}
|
|
42
40
|
*/
|
|
43
|
-
const getGeoLocation = async ({ mode, offline, state }) => {
|
|
41
|
+
const getGeoLocation = async ({ geoCountry, mode, offline, state }) => {
|
|
44
42
|
const cacheObject = state.get(STATE_GEO_PROPERTY)
|
|
45
43
|
|
|
46
44
|
// If we have cached geolocation data and the `--geo` option is set to
|
|
@@ -56,10 +54,18 @@ const getGeoLocation = async ({ mode, offline, state }) => {
|
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
|
|
59
|
-
// If the `--geo` option is set to `mock`, we use the mock location.
|
|
60
|
-
//
|
|
61
|
-
// also use the mock location.
|
|
62
|
-
|
|
57
|
+
// If the `--geo` option is set to `mock`, we use the default mock location.
|
|
58
|
+
// If the `--offline` option was used, we can't talk to the API, so let's
|
|
59
|
+
// also use the mock location. Otherwise, use the country code passed in by
|
|
60
|
+
// the user.
|
|
61
|
+
if (mode === 'mock' || offline || geoCountry) {
|
|
62
|
+
if (geoCountry) {
|
|
63
|
+
return {
|
|
64
|
+
city: 'Mock City',
|
|
65
|
+
country: { code: geoCountry, name: 'Mock Country' },
|
|
66
|
+
subdivision: { code: 'SD', name: 'Mock Subdivision' },
|
|
67
|
+
}
|
|
68
|
+
}
|
|
63
69
|
return mockLocation
|
|
64
70
|
}
|
|
65
71
|
|
|
@@ -70,7 +70,8 @@ const monitorCLISessionEvents = (input) => {
|
|
|
70
70
|
let nextMarkActiveHeartbeat = defaultHeartbeatFrequency
|
|
71
71
|
|
|
72
72
|
const markActiveHelper = async () => {
|
|
73
|
-
const
|
|
73
|
+
const graphJwt = await OneGraphClient.getGraphJwtForSite({ siteId: appId, nfToken: netlifyToken })
|
|
74
|
+
const fullSession = await OneGraphClient.fetchCliSession({ jwt: graphJwt.jwt, appId, sessionId })
|
|
74
75
|
// @ts-ignore
|
|
75
76
|
const heartbeatIntervalms = fullSession.session.cliHeartbeatIntervalMs || defaultHeartbeatFrequency
|
|
76
77
|
nextMarkActiveHeartbeat = heartbeatIntervalms
|
|
@@ -85,12 +86,14 @@ const monitorCLISessionEvents = (input) => {
|
|
|
85
86
|
|
|
86
87
|
const enabledServiceWatcher = async (innerNetlifyToken, siteId) => {
|
|
87
88
|
const enabledServices = state.get('oneGraphEnabledServices') || ['onegraph']
|
|
88
|
-
const
|
|
89
|
+
const { jwt } = await OneGraphClient.getGraphJwtForSite({ siteId: appId, nfToken: netlifyToken })
|
|
90
|
+
|
|
91
|
+
const enabledServicesInfo = await OneGraphClient.fetchEnabledServices(jwt, siteId)
|
|
89
92
|
if (!enabledServicesInfo) {
|
|
90
93
|
warn('Unable to fetch enabled services for site for code generation')
|
|
91
94
|
return
|
|
92
95
|
}
|
|
93
|
-
const newEnabledServices = enabledServicesInfo.map((service) => service.
|
|
96
|
+
const newEnabledServices = enabledServicesInfo.map((service) => service.graphQLField)
|
|
94
97
|
const enabledServicesCompareKey = enabledServices.sort().join(',')
|
|
95
98
|
const newEnabledServicesCompareKey = newEnabledServices.sort().join(',')
|
|
96
99
|
|
|
@@ -117,15 +120,16 @@ const monitorCLISessionEvents = (input) => {
|
|
|
117
120
|
onClose && onClose()
|
|
118
121
|
}
|
|
119
122
|
|
|
120
|
-
const
|
|
123
|
+
const graphJwt = await OneGraphClient.getGraphJwtForSite({ siteId: appId, nfToken: netlifyToken })
|
|
124
|
+
const next = await OneGraphClient.fetchCliSessionEvents({ appId, jwt: graphJwt.jwt, sessionId })
|
|
121
125
|
|
|
122
|
-
if (next.errors) {
|
|
126
|
+
if (next && next.errors) {
|
|
123
127
|
next.errors.forEach((fetchEventError) => {
|
|
124
128
|
onError(fetchEventError)
|
|
125
129
|
})
|
|
126
130
|
}
|
|
127
131
|
|
|
128
|
-
const
|
|
132
|
+
const events = (next && next.events) || []
|
|
129
133
|
|
|
130
134
|
if (events.length !== 0) {
|
|
131
135
|
let ackIds = []
|
|
@@ -134,7 +138,7 @@ const monitorCLISessionEvents = (input) => {
|
|
|
134
138
|
} catch (eventHandlerError) {
|
|
135
139
|
warn(`Error handling event: ${eventHandlerError}`)
|
|
136
140
|
} finally {
|
|
137
|
-
await OneGraphClient.ackCLISessionEvents({ appId,
|
|
141
|
+
await OneGraphClient.ackCLISessionEvents({ appId, jwt: graphJwt.jwt, sessionId, eventIds: ackIds })
|
|
138
142
|
}
|
|
139
143
|
}
|
|
140
144
|
|
|
@@ -182,16 +186,18 @@ const monitorOperationFile = async ({ netlifyGraphConfig, onAdd, onChange, onUnl
|
|
|
182
186
|
*/
|
|
183
187
|
const refetchAndGenerateFromOneGraph = async (input) => {
|
|
184
188
|
const { logger, netlifyGraphConfig, netlifyToken, siteId, state } = input
|
|
185
|
-
await OneGraphClient.
|
|
189
|
+
const { jwt } = await OneGraphClient.getGraphJwtForSite({ siteId, nfToken: netlifyToken })
|
|
190
|
+
|
|
191
|
+
await OneGraphClient.ensureAppForSite(jwt, siteId)
|
|
186
192
|
|
|
187
|
-
const enabledServicesInfo = await OneGraphClient.fetchEnabledServices(
|
|
193
|
+
const enabledServicesInfo = await OneGraphClient.fetchEnabledServices(jwt, siteId)
|
|
188
194
|
if (!enabledServicesInfo) {
|
|
189
195
|
warn('Unable to fetch enabled services for site for code generation')
|
|
190
196
|
return
|
|
191
197
|
}
|
|
192
198
|
|
|
193
199
|
const enabledServices = enabledServicesInfo
|
|
194
|
-
.map((service) => service.
|
|
200
|
+
.map((service) => service.graphQLField)
|
|
195
201
|
.sort((aString, bString) => aString.localeCompare(bString))
|
|
196
202
|
|
|
197
203
|
const schema = await OneGraphClient.fetchOneGraphSchemaForServices(siteId, enabledServices)
|
|
@@ -266,7 +272,8 @@ const quickHash = (input) => {
|
|
|
266
272
|
*/
|
|
267
273
|
const updateGraphQLOperationsFileFromPersistedDoc = async (input) => {
|
|
268
274
|
const { docId, logger, netlifyGraphConfig, netlifyToken, schema, siteId } = input
|
|
269
|
-
const
|
|
275
|
+
const { jwt } = await OneGraphClient.getGraphJwtForSite({ siteId, nfToken: netlifyToken })
|
|
276
|
+
const persistedDoc = await OneGraphClient.fetchPersistedQuery(jwt, siteId, docId)
|
|
270
277
|
if (!persistedDoc) {
|
|
271
278
|
warn(`No persisted doc found for: ${docId}`)
|
|
272
279
|
return
|
|
@@ -341,11 +348,15 @@ const handleCliSessionEvent = async ({
|
|
|
341
348
|
},
|
|
342
349
|
}
|
|
343
350
|
|
|
344
|
-
await OneGraphClient.
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
351
|
+
const graphJwt = await OneGraphClient.getGraphJwtForSite({ siteId, nfToken: netlifyToken })
|
|
352
|
+
|
|
353
|
+
await OneGraphClient.executeCreateCLISessionEventMutation(
|
|
354
|
+
{
|
|
355
|
+
sessionId,
|
|
356
|
+
payload: fileWrittenEvent,
|
|
357
|
+
},
|
|
358
|
+
{ accesToken: graphJwt.jwt },
|
|
359
|
+
)
|
|
349
360
|
}
|
|
350
361
|
break
|
|
351
362
|
}
|
|
@@ -397,10 +408,12 @@ const handleCliSessionEvent = async ({
|
|
|
397
408
|
* @param {object} input.siteId The site object that contains the root file path for the site
|
|
398
409
|
*/
|
|
399
410
|
const getCLISession = async ({ netlifyToken, oneGraphSessionId, siteId }) => {
|
|
411
|
+
const graphJwt = await OneGraphClient.getGraphJwtForSite({ siteId, nfToken: netlifyToken })
|
|
412
|
+
|
|
400
413
|
const input = {
|
|
401
414
|
appId: siteId,
|
|
402
415
|
sessionId: oneGraphSessionId,
|
|
403
|
-
|
|
416
|
+
jwt: graphJwt.jwt,
|
|
404
417
|
desiredEventCount: 1,
|
|
405
418
|
}
|
|
406
419
|
return await OneGraphClient.fetchCliSession(input)
|
|
@@ -468,7 +481,9 @@ const upsertMergeCLISessionMetadata = async ({ netlifyToken, newMetadata, oneGra
|
|
|
468
481
|
|
|
469
482
|
// @ts-ignore
|
|
470
483
|
const finalMetadata = { ...metadata, ...detectedMetadata, ...newMetadata }
|
|
471
|
-
|
|
484
|
+
const { jwt } = await OneGraphClient.getGraphJwtForSite({ siteId, nfToken: netlifyToken })
|
|
485
|
+
|
|
486
|
+
return OneGraphClient.updateCLISessionMetadata(jwt, siteId, oneGraphSessionId, finalMetadata)
|
|
472
487
|
}
|
|
473
488
|
|
|
474
489
|
const persistNewOperationsDocForSession = async ({
|
|
@@ -519,8 +534,9 @@ const persistNewOperationsDocForSession = async ({
|
|
|
519
534
|
}
|
|
520
535
|
}
|
|
521
536
|
|
|
522
|
-
const createCLISession = ({ metadata, netlifyToken, sessionName, siteId }) => {
|
|
523
|
-
const
|
|
537
|
+
const createCLISession = async ({ metadata, netlifyToken, sessionName, siteId }) => {
|
|
538
|
+
const { jwt } = await OneGraphClient.getGraphJwtForSite({ siteId, nfToken: netlifyToken })
|
|
539
|
+
const result = OneGraphClient.createCLISession(jwt, siteId, sessionName, metadata)
|
|
524
540
|
return result
|
|
525
541
|
}
|
|
526
542
|
|
|
@@ -542,7 +558,8 @@ const loadCLISession = (state) => state.get('oneGraphSessionId')
|
|
|
542
558
|
*/
|
|
543
559
|
const startOneGraphCLISession = async (input) => {
|
|
544
560
|
const { netlifyGraphConfig, netlifyToken, site, state } = input
|
|
545
|
-
OneGraphClient.
|
|
561
|
+
const { jwt } = await OneGraphClient.getGraphJwtForSite({ siteId: site.id, nfToken: netlifyToken })
|
|
562
|
+
OneGraphClient.ensureAppForSite(jwt, site.id)
|
|
546
563
|
|
|
547
564
|
const oneGraphSessionId = await ensureCLISession({
|
|
548
565
|
metadata: {},
|
|
@@ -667,9 +684,11 @@ const ensureCLISession = async (input) => {
|
|
|
667
684
|
// Validate that session still exists and we can access it
|
|
668
685
|
try {
|
|
669
686
|
if (oneGraphSessionId) {
|
|
687
|
+
const { jwt } = await OneGraphClient.getGraphJwtForSite({ siteId: site.id, nfToken: netlifyToken })
|
|
688
|
+
|
|
670
689
|
const sessionEvents = await OneGraphClient.fetchCliSessionEvents({
|
|
671
690
|
appId: site.id,
|
|
672
|
-
|
|
691
|
+
jwt,
|
|
673
692
|
sessionId: oneGraphSessionId,
|
|
674
693
|
})
|
|
675
694
|
if (sessionEvents.errors) {
|
|
@@ -728,6 +747,7 @@ const OneGraphCliClient = {
|
|
|
728
747
|
fetchCliSessionEvents: OneGraphClient.fetchCliSessionEvents,
|
|
729
748
|
ensureAppForSite,
|
|
730
749
|
updateCLISessionMetadata,
|
|
750
|
+
getGraphJwtForSite: OneGraphClient.getGraphJwtForSite,
|
|
731
751
|
}
|
|
732
752
|
|
|
733
753
|
module.exports = {
|
package/src/utils/proxy.js
CHANGED
|
@@ -465,6 +465,7 @@ const startProxy = async function ({
|
|
|
465
465
|
addonsUrls,
|
|
466
466
|
config,
|
|
467
467
|
configPath,
|
|
468
|
+
geoCountry,
|
|
468
469
|
geolocationMode,
|
|
469
470
|
getUpdatedConfig,
|
|
470
471
|
inspectSettings,
|
|
@@ -478,6 +479,7 @@ const startProxy = async function ({
|
|
|
478
479
|
config,
|
|
479
480
|
configPath,
|
|
480
481
|
geolocationMode,
|
|
482
|
+
geoCountry,
|
|
481
483
|
getUpdatedConfig,
|
|
482
484
|
inspectSettings,
|
|
483
485
|
offline,
|