netlify-cli 10.9.0 → 10.10.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/README.md +1 -1
- package/npm-shrinkwrap.json +1229 -1087
- package/package.json +10 -8
- package/src/commands/dev/dev.js +3 -1
- package/src/commands/env/{env-migrate.js → env-clone.js} +16 -18
- package/src/commands/env/env.js +3 -3
- package/src/commands/functions/functions-create.js +112 -14
- package/src/commands/graph/graph-edit.js +3 -1
- package/src/functions-templates/go/hello-world/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/apollo-graphql/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/apollo-graphql-rest/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/auth-fetch/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/create-user/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/fauna-crud/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/fauna-graphql/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/google-analytics/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/graphql-gateway/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/hasura-event-triggered/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/hello/.netlify-function-template.js +5 -0
- package/src/functions-templates/javascript/hello/{{name}}.js +5 -0
- package/src/functions-templates/javascript/hello-world/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/identity-signup/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/image-external/.netlify-function-template.js +5 -0
- package/src/functions-templates/javascript/image-external/{{name}}.js +12 -0
- package/src/functions-templates/javascript/localized-content/.netlify-function-template.js +5 -0
- package/src/functions-templates/javascript/localized-content/{{name}}.js +15 -0
- package/src/functions-templates/javascript/node-fetch/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/oauth-passport/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/protected-function/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/sanity-create/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/sanity-groq/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/scheduled-function/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/send-email/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/serverless-ssr/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/set-cookie/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/set-cookies/.netlify-function-template.js +5 -0
- package/src/functions-templates/javascript/set-cookies/{{name}}.js +28 -0
- package/src/functions-templates/javascript/set-req-header/.netlify-function-template.js +5 -0
- package/src/functions-templates/javascript/set-req-header/{{name}}.js +3 -0
- package/src/functions-templates/javascript/set-res-header/.netlify-function-template.js +5 -0
- package/src/functions-templates/javascript/set-res-header/{{name}}.js +5 -0
- package/src/functions-templates/javascript/slack-rate-limit/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/stripe-charge/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/stripe-charge/package-lock.json +6 -6
- package/src/functions-templates/javascript/stripe-subscription/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/stripe-subscription/package-lock.json +6 -6
- package/src/functions-templates/javascript/submission-created/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/token-hider/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/token-hider/package-lock.json +6 -6
- package/src/functions-templates/javascript/transform-response/.netlify-function-template.js +5 -0
- package/src/functions-templates/javascript/transform-response/{{name}}.js +12 -0
- package/src/functions-templates/javascript/url-shortener/.netlify-function-template.js +1 -0
- package/src/functions-templates/javascript/using-middleware/.netlify-function-template.js +1 -0
- package/src/functions-templates/rust/hello-world/.netlify-function-template.js +1 -0
- package/src/functions-templates/rust/hello-world/Cargo.toml +1 -1
- package/src/functions-templates/typescript/abtest/.netlify-function-template.js +5 -0
- package/src/functions-templates/typescript/abtest/{{name}}.ts +31 -0
- package/src/functions-templates/typescript/geolocation/.netlify-function-template.js +5 -0
- package/src/functions-templates/typescript/geolocation/{{name}}.ts +24 -0
- package/src/functions-templates/typescript/hello-world/.netlify-function-template.js +1 -0
- package/src/functions-templates/typescript/hello-world/package-lock.json +6 -6
- package/src/functions-templates/typescript/json/.netlify-function-template.js +5 -0
- package/src/functions-templates/typescript/json/{{name}}.ts +5 -0
- package/src/functions-templates/typescript/log/.netlify-function-template.js +5 -0
- package/src/functions-templates/typescript/log/{{name}}.ts +9 -0
- package/src/functions-templates/typescript/scheduled-function/.netlify-function-template.js +1 -0
- package/src/functions-templates/typescript/set-cookies/.netlify-function-template.js +5 -0
- package/src/functions-templates/typescript/set-cookies/{{name}}.ts +29 -0
- package/src/functions-templates/typescript/set-req-header/.netlify-function-template.js +5 -0
- package/src/functions-templates/typescript/set-req-header/{{name}}.ts +5 -0
- package/src/functions-templates/typescript/set-res-header/.netlify-function-template.js +5 -0
- package/src/functions-templates/typescript/set-res-header/{{name}}.ts +7 -0
- package/src/functions-templates/typescript/transform-response/.netlify-function-template.js +5 -0
- package/src/functions-templates/typescript/transform-response/{{name}}.ts +14 -0
- package/src/lib/one-graph/cli-client.js +22 -27
|
@@ -75,7 +75,7 @@ const monitorCLISessionEvents = (input) => {
|
|
|
75
75
|
// @ts-ignore
|
|
76
76
|
const heartbeatIntervalms = fullSession.session.cliHeartbeatIntervalMs || defaultHeartbeatFrequency
|
|
77
77
|
nextMarkActiveHeartbeat = heartbeatIntervalms
|
|
78
|
-
const markCLISessionActiveResult = await executeMarkCliSessionActiveHeartbeat(
|
|
78
|
+
const markCLISessionActiveResult = await executeMarkCliSessionActiveHeartbeat(graphJwt.jwt, site.id, sessionId)
|
|
79
79
|
if (markCLISessionActiveResult.errors && markCLISessionActiveResult.errors.length !== 0) {
|
|
80
80
|
warn(`Failed to mark CLI session active: ${markCLISessionActiveResult.errors.join(', ')}`)
|
|
81
81
|
}
|
|
@@ -84,9 +84,8 @@ const monitorCLISessionEvents = (input) => {
|
|
|
84
84
|
|
|
85
85
|
setTimeout(markActiveHelper, nextMarkActiveHeartbeat)
|
|
86
86
|
|
|
87
|
-
const enabledServiceWatcher = async (
|
|
87
|
+
const enabledServiceWatcher = async (jwt, siteId) => {
|
|
88
88
|
const enabledServices = state.get('oneGraphEnabledServices') || ['onegraph']
|
|
89
|
-
const { jwt } = await OneGraphClient.getGraphJwtForSite({ siteId: appId, nfToken: netlifyToken })
|
|
90
89
|
|
|
91
90
|
const enabledServicesInfo = await OneGraphClient.fetchEnabledServices(jwt, siteId)
|
|
92
91
|
if (!enabledServicesInfo) {
|
|
@@ -103,7 +102,7 @@ const monitorCLISessionEvents = (input) => {
|
|
|
103
102
|
'Reloading',
|
|
104
103
|
)} Netlify Graph schema..., ${enabledServicesCompareKey} => ${newEnabledServicesCompareKey}`,
|
|
105
104
|
)
|
|
106
|
-
await refetchAndGenerateFromOneGraph({ netlifyGraphConfig, state,
|
|
105
|
+
await refetchAndGenerateFromOneGraph({ netlifyGraphConfig, state, jwt, siteId })
|
|
107
106
|
log(`${chalk.green('Reloaded')} Netlify Graph schema and regenerated functions`)
|
|
108
107
|
}
|
|
109
108
|
}
|
|
@@ -142,7 +141,7 @@ const monitorCLISessionEvents = (input) => {
|
|
|
142
141
|
}
|
|
143
142
|
}
|
|
144
143
|
|
|
145
|
-
await enabledServiceWatcher(
|
|
144
|
+
await enabledServiceWatcher(graphJwt.jwt, appId)
|
|
146
145
|
|
|
147
146
|
handle = setTimeout(helper, frequency)
|
|
148
147
|
}
|
|
@@ -178,15 +177,14 @@ const monitorOperationFile = async ({ netlifyGraphConfig, onAdd, onChange, onUnl
|
|
|
178
177
|
* Fetch the schema for a site, and regenerate all of the downstream files
|
|
179
178
|
* @param {object} input
|
|
180
179
|
* @param {string} input.siteId The id of the site to query against
|
|
181
|
-
* @param {string} input.
|
|
180
|
+
* @param {string} input.jwt The Graph JWT
|
|
182
181
|
* @param {NetlifyGraph.NetlifyGraphConfig} input.netlifyGraphConfig A standalone config object that contains all the information necessary for Netlify Graph to process events
|
|
183
182
|
* @param {StateConfig} input.state A function to call to set/get the current state of the local Netlify project
|
|
184
183
|
* @param {(message: string) => void=} input.logger A function that if provided will be used to log messages
|
|
185
184
|
* @returns {Promise<void>}
|
|
186
185
|
*/
|
|
187
186
|
const refetchAndGenerateFromOneGraph = async (input) => {
|
|
188
|
-
const { logger, netlifyGraphConfig,
|
|
189
|
-
const { jwt } = await OneGraphClient.getGraphJwtForSite({ siteId, nfToken: netlifyToken })
|
|
187
|
+
const { jwt, logger, netlifyGraphConfig, siteId, state } = input
|
|
190
188
|
|
|
191
189
|
await OneGraphClient.ensureAppForSite(jwt, siteId)
|
|
192
190
|
|
|
@@ -403,17 +401,15 @@ const handleCliSessionEvent = async ({
|
|
|
403
401
|
/**
|
|
404
402
|
*
|
|
405
403
|
* @param {object} input
|
|
406
|
-
* @param {string} input.
|
|
404
|
+
* @param {string} input.jwt The GraphJWT string
|
|
407
405
|
* @param {string} input.oneGraphSessionId The id of the cli session to fetch the current metadata for
|
|
408
406
|
* @param {object} input.siteId The site object that contains the root file path for the site
|
|
409
407
|
*/
|
|
410
|
-
const getCLISession = async ({
|
|
411
|
-
const graphJwt = await OneGraphClient.getGraphJwtForSite({ siteId, nfToken: netlifyToken })
|
|
412
|
-
|
|
408
|
+
const getCLISession = async ({ jwt, oneGraphSessionId, siteId }) => {
|
|
413
409
|
const input = {
|
|
414
410
|
appId: siteId,
|
|
415
411
|
sessionId: oneGraphSessionId,
|
|
416
|
-
jwt
|
|
412
|
+
jwt,
|
|
417
413
|
desiredEventCount: 1,
|
|
418
414
|
}
|
|
419
415
|
return await OneGraphClient.fetchCliSession(input)
|
|
@@ -422,12 +418,12 @@ const getCLISession = async ({ netlifyToken, oneGraphSessionId, siteId }) => {
|
|
|
422
418
|
/**
|
|
423
419
|
*
|
|
424
420
|
* @param {object} input
|
|
425
|
-
* @param {string} input.
|
|
421
|
+
* @param {string} input.jwt The GraphJWT string
|
|
426
422
|
* @param {string} input.oneGraphSessionId The id of the cli session to fetch the current metadata for
|
|
427
423
|
* @param {string} input.siteId The site object that contains the root file path for the site
|
|
428
424
|
*/
|
|
429
|
-
const getCLISessionMetadata = async ({
|
|
430
|
-
const { errors, session } = await getCLISession({
|
|
425
|
+
const getCLISessionMetadata = async ({ jwt, oneGraphSessionId, siteId }) => {
|
|
426
|
+
const { errors, session } = await getCLISession({ jwt, oneGraphSessionId, siteId })
|
|
431
427
|
return { metadata: session && session.metadata, errors }
|
|
432
428
|
}
|
|
433
429
|
|
|
@@ -464,15 +460,15 @@ const detectLocalCLISessionMetadata = ({ siteRoot }) => {
|
|
|
464
460
|
* Fetch the existing cli session metadata if it exists, and mutate it remotely with the passed in metadata
|
|
465
461
|
* @param {object} input
|
|
466
462
|
* @param {NetlifyGraph.NetlifyGraphConfig} input.netlifyGraphConfig The (typically netlify) access token that is used for authentication, if any
|
|
467
|
-
* @param {string} input.
|
|
463
|
+
* @param {string} input.jwt The Graph JWT string
|
|
468
464
|
* @param {string} input.oneGraphSessionId The id of the cli session to fetch the current metadata for
|
|
469
465
|
* @param {string} input.siteId The site object that contains the root file path for the site
|
|
470
466
|
* @param {string} input.siteRoot The root file path for the site
|
|
471
467
|
* @param {object} input.newMetadata The metadata to merge into (with priority) the existing metadata
|
|
472
468
|
* @returns {Promise<object>}
|
|
473
469
|
*/
|
|
474
|
-
const upsertMergeCLISessionMetadata = async ({
|
|
475
|
-
const { errors, metadata } = await getCLISessionMetadata({
|
|
470
|
+
const upsertMergeCLISessionMetadata = async ({ jwt, newMetadata, oneGraphSessionId, siteId, siteRoot }) => {
|
|
471
|
+
const { errors, metadata } = await getCLISessionMetadata({ jwt, oneGraphSessionId, siteId })
|
|
476
472
|
if (errors) {
|
|
477
473
|
warn(`Error fetching cli session metadata: ${JSON.stringify(errors, null, 2)}`)
|
|
478
474
|
}
|
|
@@ -481,7 +477,6 @@ const upsertMergeCLISessionMetadata = async ({ netlifyToken, newMetadata, oneGra
|
|
|
481
477
|
|
|
482
478
|
// @ts-ignore
|
|
483
479
|
const finalMetadata = { ...metadata, ...detectedMetadata, ...newMetadata }
|
|
484
|
-
const { jwt } = await OneGraphClient.getGraphJwtForSite({ siteId, nfToken: netlifyToken })
|
|
485
480
|
|
|
486
481
|
return OneGraphClient.updateCLISessionMetadata(jwt, siteId, oneGraphSessionId, finalMetadata)
|
|
487
482
|
}
|
|
@@ -495,16 +490,16 @@ const persistNewOperationsDocForSession = async ({
|
|
|
495
490
|
siteRoot,
|
|
496
491
|
}) => {
|
|
497
492
|
const { branch } = gitRepoInfo()
|
|
493
|
+
const { jwt } = await OneGraphClient.getGraphJwtForSite({ siteId, nfToken: netlifyToken })
|
|
498
494
|
const persistedResult = await executeCreatePersistedQueryMutation(
|
|
499
495
|
{
|
|
500
|
-
nfToken: netlifyToken,
|
|
501
496
|
appId: siteId,
|
|
502
497
|
description: 'Temporary snapshot of local queries',
|
|
503
498
|
query: operationsDoc,
|
|
504
499
|
tags: ['netlify-cli', `session:${oneGraphSessionId}`, `git-branch:${branch}`, `local-change`],
|
|
505
500
|
},
|
|
506
501
|
{
|
|
507
|
-
accessToken:
|
|
502
|
+
accessToken: jwt,
|
|
508
503
|
siteId,
|
|
509
504
|
},
|
|
510
505
|
)
|
|
@@ -522,7 +517,7 @@ const persistNewOperationsDocForSession = async ({
|
|
|
522
517
|
const newMetadata = { docId: persistedDoc.id }
|
|
523
518
|
const result = await upsertMergeCLISessionMetadata({
|
|
524
519
|
netlifyGraphConfig,
|
|
525
|
-
|
|
520
|
+
jwt,
|
|
526
521
|
siteId,
|
|
527
522
|
oneGraphSessionId,
|
|
528
523
|
newMetadata,
|
|
@@ -656,7 +651,8 @@ const startOneGraphCLISession = async (input) => {
|
|
|
656
651
|
* @param {string} input.sessionId The session id to monitor CLI events for
|
|
657
652
|
*/
|
|
658
653
|
const markCliSessionInactive = async ({ netlifyToken, sessionId, siteId }) => {
|
|
659
|
-
const
|
|
654
|
+
const { jwt } = await OneGraphClient.getGraphJwtForSite({ siteId, nfToken: netlifyToken })
|
|
655
|
+
const result = await executeMarkCliSessionInactive(jwt, siteId, sessionId)
|
|
660
656
|
if (result.errors) {
|
|
661
657
|
warn(`Unable to mark CLI session ${sessionId} inactive: ${JSON.stringify(result.errors, null, 2)}`)
|
|
662
658
|
}
|
|
@@ -680,12 +676,11 @@ const ensureCLISession = async (input) => {
|
|
|
680
676
|
const { metadata, netlifyToken, site, state } = input
|
|
681
677
|
let oneGraphSessionId = input.oneGraphSessionId ? input.oneGraphSessionId : loadCLISession(state)
|
|
682
678
|
let parentCliSessionId = null
|
|
679
|
+
const { jwt } = await OneGraphClient.getGraphJwtForSite({ siteId: site.id, nfToken: netlifyToken })
|
|
683
680
|
|
|
684
681
|
// Validate that session still exists and we can access it
|
|
685
682
|
try {
|
|
686
683
|
if (oneGraphSessionId) {
|
|
687
|
-
const { jwt } = await OneGraphClient.getGraphJwtForSite({ siteId: site.id, nfToken: netlifyToken })
|
|
688
|
-
|
|
689
684
|
const sessionEvents = await OneGraphClient.fetchCliSessionEvents({
|
|
690
685
|
appId: site.id,
|
|
691
686
|
jwt,
|
|
@@ -728,7 +723,7 @@ const ensureCLISession = async (input) => {
|
|
|
728
723
|
|
|
729
724
|
state.set('oneGraphSessionId', oneGraphSessionId)
|
|
730
725
|
const { errors: markCLISessionActiveErrors } = await executeMarkCliSessionActiveHeartbeat(
|
|
731
|
-
|
|
726
|
+
jwt,
|
|
732
727
|
site.id,
|
|
733
728
|
oneGraphSessionId,
|
|
734
729
|
)
|