netlify-cli 10.17.4 → 10.17.5

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": "10.17.4",
3
+ "version": "10.17.5",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "netlify-cli",
9
- "version": "10.17.4",
9
+ "version": "10.17.5",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
@@ -81,7 +81,7 @@
81
81
  "multiparty": "^4.2.1",
82
82
  "netlify": "^12.0.0",
83
83
  "netlify-headers-parser": "^6.0.2",
84
- "netlify-onegraph-internal": "0.8.5",
84
+ "netlify-onegraph-internal": "0.8.6",
85
85
  "netlify-redirect-parser": "^13.0.5",
86
86
  "netlify-redirector": "^0.2.1",
87
87
  "node-fetch": "^2.6.0",
@@ -15996,9 +15996,9 @@
15996
15996
  }
15997
15997
  },
15998
15998
  "node_modules/netlify-onegraph-internal": {
15999
- "version": "0.8.5",
16000
- "resolved": "https://registry.npmjs.org/netlify-onegraph-internal/-/netlify-onegraph-internal-0.8.5.tgz",
16001
- "integrity": "sha512-UvxXqHbnzAJkshWkh7ihd4EYphFUYlQXnzeimx+Z8D9brkRGaccpIxiaMEbrLknLqWAD+g5LS/2UO11nGD6MSw==",
15999
+ "version": "0.8.6",
16000
+ "resolved": "https://registry.npmjs.org/netlify-onegraph-internal/-/netlify-onegraph-internal-0.8.6.tgz",
16001
+ "integrity": "sha512-B8xP8eonSNDe9ytJwQVND0eJYDd2JDwedwknJqtiANe11Hw4DHlw/eWZ7CdaTLiRXjD0WbMlW088NZrUZY2rtw==",
16002
16002
  "dependencies": {
16003
16003
  "graphql": "16.5.0",
16004
16004
  "node-fetch": "^2.6.0",
@@ -34229,9 +34229,9 @@
34229
34229
  }
34230
34230
  },
34231
34231
  "netlify-onegraph-internal": {
34232
- "version": "0.8.5",
34233
- "resolved": "https://registry.npmjs.org/netlify-onegraph-internal/-/netlify-onegraph-internal-0.8.5.tgz",
34234
- "integrity": "sha512-UvxXqHbnzAJkshWkh7ihd4EYphFUYlQXnzeimx+Z8D9brkRGaccpIxiaMEbrLknLqWAD+g5LS/2UO11nGD6MSw==",
34232
+ "version": "0.8.6",
34233
+ "resolved": "https://registry.npmjs.org/netlify-onegraph-internal/-/netlify-onegraph-internal-0.8.6.tgz",
34234
+ "integrity": "sha512-B8xP8eonSNDe9ytJwQVND0eJYDd2JDwedwknJqtiANe11Hw4DHlw/eWZ7CdaTLiRXjD0WbMlW088NZrUZY2rtw==",
34235
34235
  "requires": {
34236
34236
  "graphql": "16.5.0",
34237
34237
  "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.17.4",
4
+ "version": "10.17.5",
5
5
  "author": "Netlify Inc.",
6
6
  "contributors": [
7
7
  "@whitep4nth3r (https://twitter.com/whitep4nth3r)",
@@ -81,6 +81,7 @@
81
81
  "Liran Tal <liran.tal@gmail.com> (https://twitter.com/liran_tal)",
82
82
  "Louis DeScioli (https://twitter.com/descioli)",
83
83
  "Lukas Holzer <lukas.holzer@netlify.com> (https://twitter.com/luka5c0m)",
84
+ "Lxxyx <Lxxyxzj@gmail.com> (https://twitter.com/Lxxyx_)",
84
85
  "Marc Littlemore (https://twitter.com/marclittlemore)",
85
86
  "Marcus Weiner",
86
87
  "Mark Bello <mark@markbello.dev> (https://markbello.dev)",
@@ -292,7 +293,7 @@
292
293
  "multiparty": "^4.2.1",
293
294
  "netlify": "^12.0.0",
294
295
  "netlify-headers-parser": "^6.0.2",
295
- "netlify-onegraph-internal": "0.8.5",
296
+ "netlify-onegraph-internal": "0.8.6",
296
297
  "netlify-redirect-parser": "^13.0.5",
297
298
  "netlify-redirector": "^0.2.1",
298
299
  "node-fetch": "^2.6.0",
@@ -36,6 +36,8 @@ const graphHandler = async (args, options, command) => {
36
36
  const userOperationName = args.operationName
37
37
  const userCodegenId = options.codegen
38
38
 
39
+ const handlerOptions = options.data ? JSON.parse(options.data) : {}
40
+
39
41
  let operationName = userOperationName
40
42
  if (!operationName) {
41
43
  operationName = await autocompleteOperationNames({ netlifyGraphConfig })
@@ -70,7 +72,7 @@ const graphHandler = async (args, options, command) => {
70
72
  netlifyGraphConfig,
71
73
  schema,
72
74
  operationName,
73
- handlerOptions: {},
75
+ handlerOptions,
74
76
  })
75
77
  } else {
76
78
  error(`Failed to parse Netlify GraphQL schema`)
@@ -87,6 +89,7 @@ const createGraphHandlerCommand = (program) =>
87
89
  .command('graph:handler')
88
90
  .argument('[name]', 'Operation name')
89
91
  .option('-c, --codegen <id>', 'The id of the specific code generator to use')
92
+ .option("-d, --data '<json>'", 'Optional data to pass along to the code generator')
90
93
  .description(
91
94
  'Generate a handler for a Graph operation given its name. See `graph:operations` for a list of operations.',
92
95
  )
@@ -1,6 +1,7 @@
1
1
  // @ts-check
2
2
 
3
3
  const slugify = require('@sindresorhus/slugify')
4
+ const { InvalidArgumentError } = require('commander')
4
5
  const inquirer = require('inquirer')
5
6
  const pick = require('lodash/pick')
6
7
  const sample = require('lodash/sample')
@@ -84,7 +85,6 @@ const sitesCreate = async (options, command) => {
84
85
  accountSlug = accountSlugInput
85
86
  }
86
87
 
87
- const { name: nameFlag } = options
88
88
  let user
89
89
  let site
90
90
 
@@ -110,7 +110,7 @@ const sitesCreate = async (options, command) => {
110
110
  }
111
111
  }
112
112
  }
113
- await inputSiteName(nameFlag)
113
+ await inputSiteName(options.name)
114
114
 
115
115
  log()
116
116
  log(chalk.greenBright.bold.underline(`Site Created`))
@@ -175,6 +175,16 @@ const sitesCreate = async (options, command) => {
175
175
  return site
176
176
  }
177
177
 
178
+ const MAX_SITE_NAME_LENGTH = 63
179
+ const validateName = function (value) {
180
+ // netlify sites:create --name <A string of more than 63 words>
181
+ if (typeof value === 'string' && value.length > MAX_SITE_NAME_LENGTH) {
182
+ throw new InvalidArgumentError(`--name should be less than 64 characters, input length: ${value.length}`)
183
+ }
184
+
185
+ return value
186
+ }
187
+
178
188
  /**
179
189
  * Creates the `netlify sites:create` command
180
190
  * @param {import('../base-command').BaseCommand} program
@@ -187,8 +197,8 @@ const createSitesCreateCommand = (program) =>
187
197
  `Create an empty site (advanced)
188
198
  Create a blank site that isn't associated with any git remote. Will link the site to the current working directory.`,
189
199
  )
190
- .option('-n, --name [name]', 'name of site')
191
- .option('-a, --account-slug [slug]', 'account slug to create the site under')
200
+ .option('-n, --name <name>', 'name of site', validateName)
201
+ .option('-a, --account-slug <slug>', 'account slug to create the site under')
192
202
  .option('-c, --with-ci', 'initialize CI hooks during site creation')
193
203
  .option('-m, --manual', 'force manual CI setup. Used --with-ci flag')
194
204
  .option('--disable-linking', 'create the site without linking it to current directory')
@@ -15,6 +15,6 @@
15
15
  "author": "Netlify",
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
- "@netlify/functions": "^1.0.0"
18
+ "@netlify/functions": "^1.1.0"
19
19
  }
20
20
  }
@@ -9,15 +9,15 @@
9
9
  "version": "1.0.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@netlify/functions": "^1.0.0",
12
+ "@netlify/functions": "^1.1.0",
13
13
  "@types/node": "^14.0.0",
14
14
  "typescript": "^4.0.0"
15
15
  }
16
16
  },
17
17
  "node_modules/@netlify/functions": {
18
- "version": "1.0.0",
19
- "resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-1.0.0.tgz",
20
- "integrity": "sha512-7fnJv3vr8uyyyOYPChwoec6MjzsCw1CoRUO2DhQ1BD6bOyJRlD4DUaOOGlMILB2LCT8P24p5LexEGx8AJb7xdA==",
18
+ "version": "1.1.0",
19
+ "resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-1.1.0.tgz",
20
+ "integrity": "sha512-XUFC5nt4iLMrDK+6WjYrDOW9h6XGIQlEk3o++xglFbDKc6dsP+k6rjfz3vl0w8S9Oiosxj3uLaPW18szJc1UgA==",
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": "1.0.0",
54
- "resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-1.0.0.tgz",
55
- "integrity": "sha512-7fnJv3vr8uyyyOYPChwoec6MjzsCw1CoRUO2DhQ1BD6bOyJRlD4DUaOOGlMILB2LCT8P24p5LexEGx8AJb7xdA==",
53
+ "version": "1.1.0",
54
+ "resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-1.1.0.tgz",
55
+ "integrity": "sha512-XUFC5nt4iLMrDK+6WjYrDOW9h6XGIQlEk3o++xglFbDKc6dsP+k6rjfz3vl0w8S9Oiosxj3uLaPW18szJc1UgA==",
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": "^1.0.0",
17
+ "@netlify/functions": "^1.1.0",
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": "^1.0.0",
18
+ "@netlify/functions": "^1.1.0",
19
19
  "@types/node": "^14.18.9",
20
20
  "typescript": "^4.5.5"
21
21
  }
@@ -685,13 +685,19 @@ const generateHandlerByOperationName = ({
685
685
  }
686
686
 
687
687
  const parsedDoc = parse(currentOperationsDoc)
688
- const { functions } = extractFunctionsFromOperationDoc(GraphQL, parsedDoc)
688
+ const { fragments, functions } = extractFunctionsFromOperationDoc(GraphQL, parsedDoc)
689
689
 
690
- const operation = Object.values(functions).find(
691
- (potentialOperation) => potentialOperation.operationName === operationName,
690
+ const functionDefinition = Object.values(functions).find(
691
+ (potentialDefinition) => potentialDefinition.operationName === operationName,
692
692
  )
693
693
 
694
- if (!operation) {
694
+ const fragmentDefinition = Object.values(fragments).find(
695
+ (potentialDefinition) => potentialDefinition.fragmentName === operationName,
696
+ )
697
+
698
+ const definition = functionDefinition || fragmentDefinition
699
+
700
+ if (!definition) {
695
701
  warn(`No operation named ${operationName} was found in the operations doc`)
696
702
  return
697
703
  }
@@ -701,7 +707,7 @@ const generateHandlerByOperationName = ({
701
707
  generate,
702
708
  netlifyGraphConfig,
703
709
  schema,
704
- operationId: operation.id,
710
+ operationId: definition.id,
705
711
  handlerOptions,
706
712
  })
707
713
  }
@@ -201,10 +201,9 @@ const serveRedirect = async function ({ match, options, proxy, req, res }) {
201
201
  // construct destination URL from redirect rule match
202
202
  const dest = new URL(match.to, `${reqUrl.protocol}//${reqUrl.host}`)
203
203
 
204
- // We pass through request params in one of the following cases:
205
- // 1. The redirect rule doesn't have any query params
206
- // 2. This is a function redirect https://github.com/netlify/cli/issues/1605
207
- if ([...dest.searchParams].length === 0 || isFunction(options.functionsPort, stripOrigin(dest))) {
204
+ // We pass through request params if the redirect rule
205
+ // doesn't have any query params
206
+ if ([...dest.searchParams].length === 0) {
208
207
  dest.searchParams.forEach((_, key) => {
209
208
  dest.searchParams.delete(key)
210
209
  })