netlify-cli 10.4.0 → 10.6.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/README.md +1 -1
- package/npm-shrinkwrap.json +1347 -1893
- package/package.json +14 -13
- package/src/commands/dev/dev.js +4 -1
- package/src/commands/graph/graph-pull.js +9 -1
- package/src/functions-templates/go/hello-world/go.mod +1 -1
- package/src/functions-templates/javascript/oauth-passport/package.json +1 -1
- package/src/functions-templates/javascript/set-cookie/package.json +1 -1
- package/src/functions-templates/javascript/stripe-charge/package-lock.json +7 -7
- package/src/functions-templates/javascript/stripe-charge/package.json +1 -1
- package/src/functions-templates/javascript/stripe-subscription/package-lock.json +7 -7
- package/src/functions-templates/javascript/stripe-subscription/package.json +1 -1
- package/src/functions-templates/javascript/token-hider/package-lock.json +6 -6
- package/src/functions-templates/rust/hello-world/Cargo.toml +2 -2
- package/src/functions-templates/typescript/hello-world/package-lock.json +12 -12
- package/src/functions-templates/typescript/scheduled-function/{{name}}.ts +1 -1
- package/src/lib/edge-functions/headers.js +1 -0
- package/src/lib/edge-functions/proxy.js +1 -0
- package/src/lib/functions/netlify-function.js +2 -2
- package/src/lib/functions/registry.js +4 -3
- package/src/lib/functions/runtimes/js/builders/zisi.js +2 -1
- package/src/lib/one-graph/cli-client.js +102 -18
- package/src/lib/one-graph/cli-netlify-graph.js +30 -4
- package/src/recipes/vscode/index.js +33 -4
- package/src/utils/deploy/hash-fns.js +1 -5
- package/src/functions-templates/go/scheduled-function/.netlify-function-template.js +0 -5
- package/src/functions-templates/go/scheduled-function/go.mod +0 -5
- package/src/functions-templates/go/scheduled-function/go.sum +0 -21
- package/src/functions-templates/go/scheduled-function/netlify.toml +0 -11
- package/src/functions-templates/go/scheduled-function/src/hourly-schedule/main.go +0 -36
|
@@ -298,10 +298,10 @@ const runPrettier = async (filePath) => {
|
|
|
298
298
|
* @param {Record<string, NetlifyGraph.ExtractedFunction>} context.functions The parsed queries with metadata to use when generating library functions
|
|
299
299
|
* @param {Record<string, NetlifyGraph.ExtractedFragment>} context.fragments The parsed queries with metadata to use when generating library functions
|
|
300
300
|
* @param {(message: string) => void=} context.logger A function that if provided will be used to log messages
|
|
301
|
-
* @returns {void} Void, effectfully writes the generated library to the filesystem
|
|
301
|
+
* @returns {Promise<void>} Void, effectfully writes the generated library to the filesystem
|
|
302
302
|
*/
|
|
303
|
-
const generateFunctionsFile = ({ fragments, functions, logger, netlifyGraphConfig, operationsDoc, schema }) => {
|
|
304
|
-
const { clientSource, typeDefinitionsSource } = NetlifyGraph.generateFunctionsSource(
|
|
303
|
+
const generateFunctionsFile = async ({ fragments, functions, logger, netlifyGraphConfig, operationsDoc, schema }) => {
|
|
304
|
+
const { clientSource, typeDefinitionsSource } = await NetlifyGraph.generateFunctionsSource(
|
|
305
305
|
netlifyGraphConfig,
|
|
306
306
|
schema,
|
|
307
307
|
operationsDoc,
|
|
@@ -394,7 +394,7 @@ const readGraphQLSchemaFile = (netlifyGraphConfig) => {
|
|
|
394
394
|
* @param {string} input.operationId The operationId to use when generating the handler
|
|
395
395
|
* @param {object} input.handlerOptions The options to use when generating the handler
|
|
396
396
|
* @param {(message: string) => void=} input.logger A function that if provided will be used to log messages
|
|
397
|
-
* @returns
|
|
397
|
+
* @returns {Array<{filePath: string, prettierSuccess: boolean}>} An array of the generated handler filepaths
|
|
398
398
|
*/
|
|
399
399
|
const generateHandlerByOperationId = ({ handlerOptions, logger, netlifyGraphConfig, operationId, schema }) => {
|
|
400
400
|
let currentOperationsDoc = readGraphQLOperationsSourceFile(netlifyGraphConfig)
|
|
@@ -425,6 +425,8 @@ const generateHandlerByOperationId = ({ handlerOptions, logger, netlifyGraphConf
|
|
|
425
425
|
return
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
+
const results = []
|
|
429
|
+
|
|
428
430
|
exportedFiles.forEach((exportedFile) => {
|
|
429
431
|
const { content } = exportedFile
|
|
430
432
|
const isNamed = exportedFile.kind === 'NamedExportedFile'
|
|
@@ -453,7 +455,14 @@ const generateHandlerByOperationId = ({ handlerOptions, logger, netlifyGraphConf
|
|
|
453
455
|
const relativePath = path.relative(process.cwd(), absoluteFilename)
|
|
454
456
|
logger && logger(`Wrote ${chalk.cyan(relativePath)}`)
|
|
455
457
|
runPrettier(absoluteFilename)
|
|
458
|
+
|
|
459
|
+
results.push({
|
|
460
|
+
filePath: absoluteFilename,
|
|
461
|
+
prettierSuccess: true,
|
|
462
|
+
})
|
|
456
463
|
})
|
|
464
|
+
|
|
465
|
+
return results
|
|
457
466
|
}
|
|
458
467
|
|
|
459
468
|
/**
|
|
@@ -520,6 +529,22 @@ const getGraphEditUrlBySiteId = ({ oneGraphSessionId, siteId }) => {
|
|
|
520
529
|
return url
|
|
521
530
|
}
|
|
522
531
|
|
|
532
|
+
/**
|
|
533
|
+
* Load `netlifyGraph.json` from the appropriate location
|
|
534
|
+
* @param {string} siteRoot The root directory of the site
|
|
535
|
+
* @returns {import('netlify-onegraph-internal').NetlifyGraphJsonConfig.JsonConfig}
|
|
536
|
+
*/
|
|
537
|
+
const loadNetlifyGraphConfig = (siteRoot) => {
|
|
538
|
+
const configPath = path.join(siteRoot, 'netlifyGraph.json')
|
|
539
|
+
if (fs.existsSync(configPath)) {
|
|
540
|
+
// eslint-disable-next-line unicorn/prefer-json-parse-buffer
|
|
541
|
+
const file = fs.readFileSync(configPath, 'utf-8')
|
|
542
|
+
return JSON.parse(file)
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
return {}
|
|
546
|
+
}
|
|
547
|
+
|
|
523
548
|
module.exports = {
|
|
524
549
|
buildSchema,
|
|
525
550
|
defaultExampleOperationsDoc: NetlifyGraph.defaultExampleOperationsDoc,
|
|
@@ -532,6 +557,7 @@ module.exports = {
|
|
|
532
557
|
getGraphEditUrlBySiteId,
|
|
533
558
|
getGraphEditUrlBySiteName,
|
|
534
559
|
getNetlifyGraphConfig,
|
|
560
|
+
loadNetlifyGraphConfig,
|
|
535
561
|
normalizeOperationsDoc: GraphQLHelpers.normalizeOperationsDoc,
|
|
536
562
|
parse,
|
|
537
563
|
readGraphQLOperationsSourceFile,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { join } = require('path')
|
|
2
2
|
|
|
3
|
+
const execa = require('execa')
|
|
3
4
|
const inquirer = require('inquirer')
|
|
4
5
|
|
|
5
6
|
const { NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, error, log } = require('../../utils/command-helpers')
|
|
@@ -27,6 +28,26 @@ const getEdgeFunctionsPath = ({ config, repositoryRoot }) =>
|
|
|
27
28
|
|
|
28
29
|
const getSettingsPath = (repositoryRoot) => join(repositoryRoot, '.vscode', 'settings.json')
|
|
29
30
|
|
|
31
|
+
const hasDenoVSCodeExt = async () => {
|
|
32
|
+
const { stdout: extensions } = await execa('code', ['--list-extensions'], { stderr: 'inherit' })
|
|
33
|
+
return extensions.split('\n').includes('denoland.vscode-deno')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const getDenoVSCodeExt = async () => {
|
|
37
|
+
await execa('code', ['--install-extension', 'denoland.vscode-deno'], { stdio: 'inherit' })
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const getDenoExtPrompt = () => {
|
|
41
|
+
const message = 'The Deno VS Code extension is recommended. Would you like to install it now?'
|
|
42
|
+
|
|
43
|
+
return inquirer.prompt({
|
|
44
|
+
type: 'confirm',
|
|
45
|
+
name: 'confirm',
|
|
46
|
+
message,
|
|
47
|
+
default: true,
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
30
51
|
const run = async ({ config, repositoryRoot }) => {
|
|
31
52
|
const { DenoBridge } = await import('@netlify/edge-bundler')
|
|
32
53
|
const deno = new DenoBridge({
|
|
@@ -45,14 +66,22 @@ const run = async ({ config, repositoryRoot }) => {
|
|
|
45
66
|
}
|
|
46
67
|
|
|
47
68
|
try {
|
|
48
|
-
await
|
|
49
|
-
|
|
50
|
-
|
|
69
|
+
if (!(await hasDenoVSCodeExt())) {
|
|
70
|
+
const { confirm: denoExtConfirm } = await getDenoExtPrompt()
|
|
71
|
+
if (denoExtConfirm) getDenoVSCodeExt()
|
|
72
|
+
}
|
|
73
|
+
} catch {
|
|
51
74
|
log(
|
|
52
|
-
`${NETLIFYDEVWARN}
|
|
75
|
+
`${NETLIFYDEVWARN} Unable to install Deno VS Code extension. To install it manually, visit ${chalk.blue(
|
|
53
76
|
'https://ntl.fyi/deno-vscode',
|
|
54
77
|
)}.`,
|
|
55
78
|
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
await writeSettings({ settings, settingsPath })
|
|
83
|
+
|
|
84
|
+
log(`${NETLIFYDEVLOG} VS Code settings file ${fileExists ? 'updated' : 'created'}.`)
|
|
56
85
|
} catch {
|
|
57
86
|
error('Could not write VS Code settings file.')
|
|
58
87
|
}
|
|
@@ -61,11 +61,7 @@ const getFunctionZips = async ({
|
|
|
61
61
|
})
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
zisi_detect_esm: true,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return await zipIt.zipFunctions(directories, tmpDir, { basePath: rootDir, config: functionsConfig, featureFlags })
|
|
64
|
+
return await zipIt.zipFunctions(directories, tmpDir, { basePath: rootDir, config: functionsConfig })
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
const hashFns = async (
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
|
2
|
-
github.com/aws/aws-lambda-go v1.28.0 h1:fZiik1PZqW2IyAN4rj+Y0UBaO1IDFlsNo9Zz/XnArK4=
|
|
3
|
-
github.com/aws/aws-lambda-go v1.28.0/go.mod h1:jJmlefzPfGnckuHdXX7/80O3BvUUi12XOkbv4w9SGLU=
|
|
4
|
-
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
|
5
|
-
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
|
6
|
-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
7
|
-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
8
|
-
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
9
|
-
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
|
10
|
-
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
|
11
|
-
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
|
12
|
-
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
|
13
|
-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
|
14
|
-
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
|
15
|
-
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
16
|
-
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
|
17
|
-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
18
|
-
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
19
|
-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
20
|
-
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
|
|
21
|
-
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
package main
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"context"
|
|
5
|
-
"encoding/json"
|
|
6
|
-
"log"
|
|
7
|
-
"net/http"
|
|
8
|
-
"time"
|
|
9
|
-
|
|
10
|
-
"github.com/aws/aws-lambda-go/events"
|
|
11
|
-
"github.com/aws/aws-lambda-go/lambda"
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
type requestBody struct {
|
|
15
|
-
NextRun time.Time `json:"next_run"`
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// The schedule for this function is defined inside the netlify.toml file. To learn about scheduled functions
|
|
19
|
-
// and supported cron extensions, visit https://ntl.fyi/sched-func.
|
|
20
|
-
func handler(ctx context.Context, request events.APIGatewayProxyRequest) (*events.APIGatewayProxyResponse, error) {
|
|
21
|
-
requestBody := requestBody{}
|
|
22
|
-
|
|
23
|
-
if err := json.Unmarshal([]byte(request.Body), &requestBody); err != nil {
|
|
24
|
-
log.Fatalf("cannot parse request body: %s", err.Error())
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
log.Printf("Next run at %s\n", requestBody.NextRun.Local())
|
|
28
|
-
|
|
29
|
-
return &events.APIGatewayProxyResponse{
|
|
30
|
-
StatusCode: http.StatusNoContent,
|
|
31
|
-
}, nil
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
func main() {
|
|
35
|
-
lambda.Start(handler)
|
|
36
|
-
}
|