netlify-cli 14.3.1 → 15.0.0-rc.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 +0 -16
- package/npm-shrinkwrap.json +2 -63
- package/package.json +1 -2
- package/src/commands/build/build.mjs +1 -24
- package/src/commands/dev/dev.mjs +1 -26
- package/src/commands/main.mjs +0 -2
- package/src/commands/serve/serve.mjs +1 -1
- package/src/lib/functions/server.mjs +1 -10
- package/src/utils/dev.mjs +0 -22
- package/src/commands/graph/graph-config-write.mjs +0 -56
- package/src/commands/graph/graph-edit.mjs +0 -104
- package/src/commands/graph/graph-handler.mjs +0 -102
- package/src/commands/graph/graph-init.mjs +0 -163
- package/src/commands/graph/graph-library.mjs +0 -88
- package/src/commands/graph/graph-operations.mjs +0 -116
- package/src/commands/graph/graph-pull.mjs +0 -168
- package/src/commands/graph/graph.mjs +0 -45
- package/src/commands/graph/index.mjs +0 -1
- package/src/lib/one-graph/cli-client.mjs +0 -1392
- package/src/lib/one-graph/cli-netlify-graph.mjs +0 -1033
- package/src/utils/graph.mjs +0 -170
package/README.md
CHANGED
|
@@ -27,7 +27,6 @@ See the [CLI command line reference](https://cli.netlify.com/commands/) to get s
|
|
|
27
27
|
- [dev](#dev)
|
|
28
28
|
- [env](#env)
|
|
29
29
|
- [functions](#functions)
|
|
30
|
-
- [graph](#graph)
|
|
31
30
|
- [init](#init)
|
|
32
31
|
- [link](#link)
|
|
33
32
|
- [lm](#lm)
|
|
@@ -163,21 +162,6 @@ Manage netlify functions
|
|
|
163
162
|
| [`functions:serve`](/docs/commands/functions.md#functionsserve) | (Beta) Serve functions locally |
|
|
164
163
|
|
|
165
164
|
|
|
166
|
-
### [graph](/docs/commands/graph.md)
|
|
167
|
-
|
|
168
|
-
(Deprecated) Control the Netlify Graph functions for the current site
|
|
169
|
-
|
|
170
|
-
| Subcommand | description |
|
|
171
|
-
|:--------------------------- |:-----|
|
|
172
|
-
| [`graph:config:write`](/docs/commands/graph.md#graphconfigwrite) | Write a .graphqlrc.json file to the current directory for use with local tooling (e.g. the graphql extension for vscode) |
|
|
173
|
-
| [`graph:edit`](/docs/commands/graph.md#graphedit) | Launch the browser to edit your local graph functions from Netlify |
|
|
174
|
-
| [`graph:handler`](/docs/commands/graph.md#graphhandler) | Generate a handler for a Graph operation given its name. See `graph:operations` for a list of operations. |
|
|
175
|
-
| [`graph:init`](/docs/commands/graph.md#graphinit) | Initialize all the resources for Netlify Graph |
|
|
176
|
-
| [`graph:library`](/docs/commands/graph.md#graphlibrary) | Generate the Graph function library |
|
|
177
|
-
| [`graph:operations`](/docs/commands/graph.md#graphoperations) | List all of the locally available operations |
|
|
178
|
-
| [`graph:pull`](/docs/commands/graph.md#graphpull) | Pull your remote Netlify Graph schema locally, and process pending Graph edit events |
|
|
179
|
-
|
|
180
|
-
|
|
181
165
|
### [init](/docs/commands/init.md)
|
|
182
166
|
|
|
183
167
|
Configure continuous deployment for a new or existing site. To create a new site without continuous deployment, use `netlify sites:create`
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0-rc.0",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "netlify-cli",
|
|
9
|
-
"version": "
|
|
9
|
+
"version": "15.0.0-rc.0",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
@@ -83,7 +83,6 @@
|
|
|
83
83
|
"multiparty": "^4.2.1",
|
|
84
84
|
"netlify": "^13.1.5",
|
|
85
85
|
"netlify-headers-parser": "^7.1.2",
|
|
86
|
-
"netlify-onegraph-internal": "0.10.1",
|
|
87
86
|
"netlify-redirect-parser": "^14.1.2",
|
|
88
87
|
"netlify-redirector": "^0.4.0",
|
|
89
88
|
"node-fetch": "^2.6.0",
|
|
@@ -8222,14 +8221,6 @@
|
|
|
8222
8221
|
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
|
|
8223
8222
|
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA=="
|
|
8224
8223
|
},
|
|
8225
|
-
"node_modules/graphql": {
|
|
8226
|
-
"version": "16.5.0",
|
|
8227
|
-
"resolved": "https://registry.npmjs.org/graphql/-/graphql-16.5.0.tgz",
|
|
8228
|
-
"integrity": "sha512-qbHgh8Ix+j/qY+a/ZcJnFQ+j8ezakqPiHwPiZhV/3PgGlgf96QMBB5/f2rkiC9sgLoy/xvT6TSiaf2nTHJh5iA==",
|
|
8229
|
-
"engines": {
|
|
8230
|
-
"node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0"
|
|
8231
|
-
}
|
|
8232
|
-
},
|
|
8233
8224
|
"node_modules/has": {
|
|
8234
8225
|
"version": "1.0.3",
|
|
8235
8226
|
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
|
@@ -10784,25 +10775,6 @@
|
|
|
10784
10775
|
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
10785
10776
|
}
|
|
10786
10777
|
},
|
|
10787
|
-
"node_modules/netlify-onegraph-internal": {
|
|
10788
|
-
"version": "0.10.1",
|
|
10789
|
-
"resolved": "https://registry.npmjs.org/netlify-onegraph-internal/-/netlify-onegraph-internal-0.10.1.tgz",
|
|
10790
|
-
"integrity": "sha512-lGHBUfILWoMO2iJN3zmqd/S+pbgYyQI4WgWDiMrEPkDQPF6wO1JUmhcMOGiZfsmaX/leD9S+CKDKX7iDc440Hw==",
|
|
10791
|
-
"dependencies": {
|
|
10792
|
-
"graphql": "16.5.0",
|
|
10793
|
-
"node-fetch": "^2.6.0",
|
|
10794
|
-
"rusha": "^0.8.14",
|
|
10795
|
-
"uuid": "^8.3.2"
|
|
10796
|
-
}
|
|
10797
|
-
},
|
|
10798
|
-
"node_modules/netlify-onegraph-internal/node_modules/uuid": {
|
|
10799
|
-
"version": "8.3.2",
|
|
10800
|
-
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
|
10801
|
-
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
|
10802
|
-
"bin": {
|
|
10803
|
-
"uuid": "dist/bin/uuid"
|
|
10804
|
-
}
|
|
10805
|
-
},
|
|
10806
10778
|
"node_modules/netlify-redirect-parser": {
|
|
10807
10779
|
"version": "14.1.2",
|
|
10808
10780
|
"resolved": "https://registry.npmjs.org/netlify-redirect-parser/-/netlify-redirect-parser-14.1.2.tgz",
|
|
@@ -12586,11 +12558,6 @@
|
|
|
12586
12558
|
"queue-microtask": "^1.2.2"
|
|
12587
12559
|
}
|
|
12588
12560
|
},
|
|
12589
|
-
"node_modules/rusha": {
|
|
12590
|
-
"version": "0.8.14",
|
|
12591
|
-
"resolved": "https://registry.npmjs.org/rusha/-/rusha-0.8.14.tgz",
|
|
12592
|
-
"integrity": "sha512-cLgakCUf6PedEu15t8kbsjnwIFFR2D4RfL+W3iWFJ4iac7z4B0ZI8fxy4R3J956kAI68HclCFGL8MPoUVC3qVA=="
|
|
12593
|
-
},
|
|
12594
12561
|
"node_modules/rxjs": {
|
|
12595
12562
|
"version": "6.6.7",
|
|
12596
12563
|
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz",
|
|
@@ -20939,11 +20906,6 @@
|
|
|
20939
20906
|
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
|
|
20940
20907
|
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA=="
|
|
20941
20908
|
},
|
|
20942
|
-
"graphql": {
|
|
20943
|
-
"version": "16.5.0",
|
|
20944
|
-
"resolved": "https://registry.npmjs.org/graphql/-/graphql-16.5.0.tgz",
|
|
20945
|
-
"integrity": "sha512-qbHgh8Ix+j/qY+a/ZcJnFQ+j8ezakqPiHwPiZhV/3PgGlgf96QMBB5/f2rkiC9sgLoy/xvT6TSiaf2nTHJh5iA=="
|
|
20946
|
-
},
|
|
20947
20909
|
"has": {
|
|
20948
20910
|
"version": "1.0.3",
|
|
20949
20911
|
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
|
@@ -22813,24 +22775,6 @@
|
|
|
22813
22775
|
}
|
|
22814
22776
|
}
|
|
22815
22777
|
},
|
|
22816
|
-
"netlify-onegraph-internal": {
|
|
22817
|
-
"version": "0.10.1",
|
|
22818
|
-
"resolved": "https://registry.npmjs.org/netlify-onegraph-internal/-/netlify-onegraph-internal-0.10.1.tgz",
|
|
22819
|
-
"integrity": "sha512-lGHBUfILWoMO2iJN3zmqd/S+pbgYyQI4WgWDiMrEPkDQPF6wO1JUmhcMOGiZfsmaX/leD9S+CKDKX7iDc440Hw==",
|
|
22820
|
-
"requires": {
|
|
22821
|
-
"graphql": "16.5.0",
|
|
22822
|
-
"node-fetch": "^2.6.0",
|
|
22823
|
-
"rusha": "^0.8.14",
|
|
22824
|
-
"uuid": "^8.3.2"
|
|
22825
|
-
},
|
|
22826
|
-
"dependencies": {
|
|
22827
|
-
"uuid": {
|
|
22828
|
-
"version": "8.3.2",
|
|
22829
|
-
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
|
22830
|
-
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
|
|
22831
|
-
}
|
|
22832
|
-
}
|
|
22833
|
-
},
|
|
22834
22778
|
"netlify-redirect-parser": {
|
|
22835
22779
|
"version": "14.1.2",
|
|
22836
22780
|
"resolved": "https://registry.npmjs.org/netlify-redirect-parser/-/netlify-redirect-parser-14.1.2.tgz",
|
|
@@ -24037,11 +23981,6 @@
|
|
|
24037
23981
|
"queue-microtask": "^1.2.2"
|
|
24038
23982
|
}
|
|
24039
23983
|
},
|
|
24040
|
-
"rusha": {
|
|
24041
|
-
"version": "0.8.14",
|
|
24042
|
-
"resolved": "https://registry.npmjs.org/rusha/-/rusha-0.8.14.tgz",
|
|
24043
|
-
"integrity": "sha512-cLgakCUf6PedEu15t8kbsjnwIFFR2D4RfL+W3iWFJ4iac7z4B0ZI8fxy4R3J956kAI68HclCFGL8MPoUVC3qVA=="
|
|
24044
|
-
},
|
|
24045
23984
|
"rxjs": {
|
|
24046
23985
|
"version": "6.6.7",
|
|
24047
23986
|
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
3
|
"description": "Netlify command line tool",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "15.0.0-rc.0",
|
|
5
5
|
"author": "Netlify Inc.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -115,7 +115,6 @@
|
|
|
115
115
|
"multiparty": "^4.2.1",
|
|
116
116
|
"netlify": "^13.1.5",
|
|
117
117
|
"netlify-headers-parser": "^7.1.2",
|
|
118
|
-
"netlify-onegraph-internal": "0.10.1",
|
|
119
118
|
"netlify-redirect-parser": "^14.1.2",
|
|
120
119
|
"netlify-redirector": "^0.4.0",
|
|
121
120
|
"node-fetch": "^2.6.0",
|
|
@@ -3,7 +3,6 @@ import process from 'process'
|
|
|
3
3
|
|
|
4
4
|
import { getBuildOptions, runBuild } from '../../lib/build.mjs'
|
|
5
5
|
import { error, exit, getToken } from '../../utils/command-helpers.mjs'
|
|
6
|
-
import { generateNetlifyGraphJWT } from '../../utils/dev.mjs'
|
|
7
6
|
import { getEnvelopeEnv, normalizeContext } from '../../utils/env/index.mjs'
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -19,35 +18,13 @@ const checkOptions = ({ cachedConfig: { siteInfo = {} }, token }) => {
|
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
const injectEnv = async function (command, { api, buildOptions, context,
|
|
21
|
+
const injectEnv = async function (command, { api, buildOptions, context, siteInfo }) {
|
|
23
22
|
const isUsingEnvelope = siteInfo && siteInfo.use_envelope
|
|
24
|
-
const authlifyTokenId = siteInfo && siteInfo.authlify_token_id
|
|
25
23
|
|
|
26
24
|
const { env } = buildOptions.cachedConfig
|
|
27
25
|
if (isUsingEnvelope) {
|
|
28
26
|
buildOptions.cachedConfig.env = await getEnvelopeEnv({ api, context, env, siteInfo })
|
|
29
27
|
}
|
|
30
|
-
|
|
31
|
-
if (authlifyTokenId) {
|
|
32
|
-
const netlifyToken = await command.authenticate()
|
|
33
|
-
// Only inject the authlify config if a token ID exists. This prevents
|
|
34
|
-
// calling command.authenticate() (which opens a browser window) if the
|
|
35
|
-
// user hasn't enabled API Authentication
|
|
36
|
-
const netlifyGraphConfig = {
|
|
37
|
-
netlifyToken,
|
|
38
|
-
authlifyTokenId,
|
|
39
|
-
siteId: site.id,
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const netlifyGraphJWT = generateNetlifyGraphJWT(netlifyGraphConfig)
|
|
43
|
-
|
|
44
|
-
if (netlifyGraphJWT != null) {
|
|
45
|
-
// XXX(anmonteiro): this name is deprecated. Delete after 3/31/2022
|
|
46
|
-
const varData = { sources: ['general'], value: netlifyGraphJWT }
|
|
47
|
-
buildOptions.cachedConfig.env.ONEGRAPH_AUTHLIFY_TOKEN = varData
|
|
48
|
-
buildOptions.cachedConfig.env.NETLIFY_GRAPH_TOKEN = varData
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
28
|
}
|
|
52
29
|
|
|
53
30
|
/**
|
package/src/commands/dev/dev.mjs
CHANGED
|
@@ -21,7 +21,6 @@ import detectServerSettings, { getConfigWithPlugins } from '../../utils/detect-s
|
|
|
21
21
|
import { getDotEnvVariables, getSiteInformation, injectEnvVariables } from '../../utils/dev.mjs'
|
|
22
22
|
import { getEnvelopeEnv, normalizeContext } from '../../utils/env/index.mjs'
|
|
23
23
|
import { ensureNetlifyIgnore } from '../../utils/gitignore.mjs'
|
|
24
|
-
import { startNetlifyGraph, startPollingForAPIAuthentication } from '../../utils/graph.mjs'
|
|
25
24
|
import { startLiveTunnel } from '../../utils/live-tunnel.mjs'
|
|
26
25
|
import openBrowser from '../../utils/open-browser.mjs'
|
|
27
26
|
import { generateInspectSettings, startProxyServer } from '../../utils/proxy-server.mjs'
|
|
@@ -124,12 +123,7 @@ const dev = async (options, command) => {
|
|
|
124
123
|
exit(1)
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
command.setAnalyticsPayload({ projectType: settings.framework || 'custom', live: options.live
|
|
128
|
-
|
|
129
|
-
const startNetlifyGraphWatcher = Boolean(options.graph)
|
|
130
|
-
if (startNetlifyGraphWatcher) {
|
|
131
|
-
startPollingForAPIAuthentication({ api, command, config, site, siteInfo })
|
|
132
|
-
}
|
|
126
|
+
command.setAnalyticsPayload({ projectType: settings.framework || 'custom', live: options.live })
|
|
133
127
|
|
|
134
128
|
const liveTunnelUrl = await handleLiveTunnel({ options, site, api, settings })
|
|
135
129
|
const url = liveTunnelUrl || getProxyUrl(settings)
|
|
@@ -201,16 +195,6 @@ const dev = async (options, command) => {
|
|
|
201
195
|
await openBrowser({ url, silentBrowserNoneError: true })
|
|
202
196
|
}
|
|
203
197
|
|
|
204
|
-
await startNetlifyGraph({
|
|
205
|
-
command,
|
|
206
|
-
config,
|
|
207
|
-
options,
|
|
208
|
-
settings,
|
|
209
|
-
site,
|
|
210
|
-
startNetlifyGraphWatcher,
|
|
211
|
-
state,
|
|
212
|
-
})
|
|
213
|
-
|
|
214
198
|
printBanner({ url })
|
|
215
199
|
}
|
|
216
200
|
|
|
@@ -271,14 +255,6 @@ export const createDevCommand = (program) => {
|
|
|
271
255
|
.argParser((value) => Number.parseInt(value))
|
|
272
256
|
.hideHelp(),
|
|
273
257
|
)
|
|
274
|
-
.addOption(new Option('--graph', 'enable Netlify Graph support').hideHelp())
|
|
275
|
-
.addOption(
|
|
276
|
-
new Option(
|
|
277
|
-
'--sessionId [sessionId]',
|
|
278
|
-
'Old, prefer --session-id. (Graph) connect to cloud session with ID [sessionId]',
|
|
279
|
-
).hideHelp(true),
|
|
280
|
-
)
|
|
281
|
-
.option('--session-id [sessionId]', '(Graph) connect to cloud session with ID [sessionId]')
|
|
282
258
|
.addOption(
|
|
283
259
|
new Option(
|
|
284
260
|
'-e, --edgeInspect [address]',
|
|
@@ -318,7 +294,6 @@ export const createDevCommand = (program) => {
|
|
|
318
294
|
'netlify dev -d public',
|
|
319
295
|
'netlify dev -c "hugo server -w" --target-port 1313',
|
|
320
296
|
'netlify dev --context production',
|
|
321
|
-
'netlify dev --graph',
|
|
322
297
|
'netlify dev --edge-inspect',
|
|
323
298
|
'netlify dev --edge-inspect=127.0.0.1:9229',
|
|
324
299
|
'netlify dev --edge-inspect-brk',
|
package/src/commands/main.mjs
CHANGED
|
@@ -20,7 +20,6 @@ import { createDeployCommand } from './deploy/index.mjs'
|
|
|
20
20
|
import { createDevCommand } from './dev/index.mjs'
|
|
21
21
|
import { createEnvCommand } from './env/index.mjs'
|
|
22
22
|
import { createFunctionsCommand } from './functions/index.mjs'
|
|
23
|
-
import { createGraphCommand } from './graph/index.mjs'
|
|
24
23
|
import { createInitCommand } from './init/index.mjs'
|
|
25
24
|
import { createLinkCommand } from './link/index.mjs'
|
|
26
25
|
import { createLmCommand } from './lm/index.mjs'
|
|
@@ -167,7 +166,6 @@ export const createMainCommand = () => {
|
|
|
167
166
|
createEnvCommand(program)
|
|
168
167
|
createFunctionsCommand(program)
|
|
169
168
|
createRecipesCommand(program)
|
|
170
|
-
createGraphCommand(program)
|
|
171
169
|
createInitCommand(program)
|
|
172
170
|
createLinkCommand(program)
|
|
173
171
|
createLmCommand(program)
|
|
@@ -80,7 +80,7 @@ const serve = async (options, command) => {
|
|
|
80
80
|
exit(1)
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
command.setAnalyticsPayload({ projectType: settings.framework || 'custom', live: options.live
|
|
83
|
+
command.setAnalyticsPayload({ projectType: settings.framework || 'custom', live: options.live })
|
|
84
84
|
|
|
85
85
|
log(`${NETLIFYDEVLOG} Building site for production`)
|
|
86
86
|
log(
|
|
@@ -3,7 +3,6 @@ import { get } from 'dot-prop'
|
|
|
3
3
|
import jwtDecode from 'jwt-decode'
|
|
4
4
|
|
|
5
5
|
import { NETLIFYDEVERR, NETLIFYDEVLOG, error as errorExit, log } from '../../utils/command-helpers.mjs'
|
|
6
|
-
import { generateNetlifyGraphJWT } from '../../utils/dev.mjs'
|
|
7
6
|
import { CLOCKWORK_USERAGENT, getFunctionsDistPath, getInternalFunctionsDir } from '../../utils/functions/index.mjs'
|
|
8
7
|
|
|
9
8
|
import { handleBackgroundFunction, handleBackgroundFunctionResult } from './background.mjs'
|
|
@@ -49,7 +48,7 @@ const hasBody = (req) =>
|
|
|
49
48
|
(typeof req.body === 'string' || Buffer.isBuffer(req.body))
|
|
50
49
|
|
|
51
50
|
export const createHandler = function (options) {
|
|
52
|
-
const {
|
|
51
|
+
const { functionsRegistry } = options
|
|
53
52
|
|
|
54
53
|
return async function handler(request, response) {
|
|
55
54
|
// handle proxies without path re-writes (http-servr)
|
|
@@ -115,14 +114,6 @@ export const createHandler = function (options) {
|
|
|
115
114
|
rawQuery,
|
|
116
115
|
}
|
|
117
116
|
|
|
118
|
-
if (config && config.netlifyGraphConfig && config.netlifyGraphConfig.authlifyTokenId != null) {
|
|
119
|
-
// XXX(anmonteiro): this name is deprecated. Delete after 3/31/2022
|
|
120
|
-
const jwt = generateNetlifyGraphJWT(config.netlifyGraphConfig)
|
|
121
|
-
event.authlifyToken = jwt
|
|
122
|
-
event.netlifyGraphToken = jwt
|
|
123
|
-
event.headers['X-Nf-Graph-Token'] = jwt
|
|
124
|
-
}
|
|
125
|
-
|
|
126
117
|
const clientContext = buildClientContext(request.headers) || {}
|
|
127
118
|
|
|
128
119
|
if (func.isBackground) {
|
package/src/utils/dev.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import process from 'process'
|
|
|
3
3
|
|
|
4
4
|
import { get } from 'dot-prop'
|
|
5
5
|
import getPort from 'get-port'
|
|
6
|
-
import jwt from 'jsonwebtoken'
|
|
7
6
|
import isEmpty from 'lodash/isEmpty.js'
|
|
8
7
|
|
|
9
8
|
import { supportsBackgroundFunctions } from '../lib/account.mjs'
|
|
@@ -207,27 +206,6 @@ export const acquirePort = async ({ configuredPort, defaultPort, errorMessage })
|
|
|
207
206
|
return acquiredPort
|
|
208
207
|
}
|
|
209
208
|
|
|
210
|
-
// Generates a Netlify Graph JWT with the following claims:
|
|
211
|
-
// - site_id
|
|
212
|
-
// - netlify_token -- the bearer token for the Netlify API
|
|
213
|
-
// - authlify_token_id -- the authlify token ID stored for the site after
|
|
214
|
-
// enabling API Authentication.
|
|
215
|
-
export const generateNetlifyGraphJWT = ({ authlifyTokenId, netlifyToken, siteId }) => {
|
|
216
|
-
const claims = {
|
|
217
|
-
netlify_token: netlifyToken,
|
|
218
|
-
authlify_token_id: authlifyTokenId,
|
|
219
|
-
site_id: siteId,
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return jwt.sign(
|
|
223
|
-
{ 'https://netlify.com/jwt/claims': claims },
|
|
224
|
-
// doesn't matter. OneGraph doesn't check the signature. The presence of
|
|
225
|
-
// the Netlify API bearer token is enough because we've authenticated the
|
|
226
|
-
// user through `command.authenticate()`
|
|
227
|
-
'NOT_SIGNED',
|
|
228
|
-
)
|
|
229
|
-
}
|
|
230
|
-
|
|
231
209
|
export const processOnExit = (fn) => {
|
|
232
210
|
const signals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP', 'exit']
|
|
233
211
|
signals.forEach((signal) => {
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import fs from 'fs'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import process from 'process'
|
|
5
|
-
|
|
6
|
-
import { getNetlifyGraphConfig } from '../../lib/one-graph/cli-netlify-graph.mjs'
|
|
7
|
-
import { NETLIFYDEVERR, chalk, error, log } from '../../utils/command-helpers.mjs'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Creates the `netlify graph:config:write` command
|
|
11
|
-
* @param {import('commander').OptionValues} options
|
|
12
|
-
* @param {import('../base-command.mjs').default} command
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
const graphConfigWrite = async (options, command) => {
|
|
16
|
-
const { site } = command.netlify
|
|
17
|
-
|
|
18
|
-
if (!site.id) {
|
|
19
|
-
error(
|
|
20
|
-
`${NETLIFYDEVERR} Warning: no siteId defined, unable to start Netlify Graph. To enable, run ${chalk.yellow(
|
|
21
|
-
'netlify init',
|
|
22
|
-
)} or ${chalk.yellow('netlify link')}`,
|
|
23
|
-
)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const netlifyGraphConfig = await getNetlifyGraphConfig({ command, options })
|
|
27
|
-
|
|
28
|
-
const schemaPath = netlifyGraphConfig.graphQLSchemaFilename.join('/')
|
|
29
|
-
|
|
30
|
-
// Support tools that looks for the schema under different keys
|
|
31
|
-
const graphQLConfig = {
|
|
32
|
-
schema: [schemaPath],
|
|
33
|
-
schemaPath: [schemaPath],
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const filePath = path.resolve(...netlifyGraphConfig.graphQLConfigJsonFilename)
|
|
37
|
-
fs.writeFileSync(filePath, JSON.stringify(graphQLConfig, null, 2))
|
|
38
|
-
|
|
39
|
-
const relativePath = path.relative(process.cwd(), filePath)
|
|
40
|
-
log(`Wrote ${chalk.cyan(relativePath)}`)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Creates the `netlify graph:config:write` command
|
|
45
|
-
* @param {import('../base-command.mjs').default} program
|
|
46
|
-
* @returns
|
|
47
|
-
*/
|
|
48
|
-
export const createGraphConfigWriteCommand = (program) =>
|
|
49
|
-
program
|
|
50
|
-
.command('graph:config:write')
|
|
51
|
-
.description(
|
|
52
|
-
'Write a .graphqlrc.json file to the current directory for use with local tooling (e.g. the graphql extension for vscode)',
|
|
53
|
-
)
|
|
54
|
-
.action(async (options, command) => {
|
|
55
|
-
await graphConfigWrite(options, command)
|
|
56
|
-
})
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import gitRepoInfo from 'git-repo-info'
|
|
3
|
-
|
|
4
|
-
import { OneGraphCliClient, ensureCLISession, upsertMergeCLISessionMetadata } from '../../lib/one-graph/cli-client.mjs'
|
|
5
|
-
import {
|
|
6
|
-
defaultExampleOperationsDoc,
|
|
7
|
-
getGraphEditUrlBySiteId,
|
|
8
|
-
getNetlifyGraphConfig,
|
|
9
|
-
readGraphQLOperationsSourceFile,
|
|
10
|
-
} from '../../lib/one-graph/cli-netlify-graph.mjs'
|
|
11
|
-
import { NETLIFYDEVERR, chalk, error, log } from '../../utils/command-helpers.mjs'
|
|
12
|
-
import openBrowser from '../../utils/open-browser.mjs'
|
|
13
|
-
|
|
14
|
-
const { ensureAppForSite, executeCreatePersistedQueryMutation } = OneGraphCliClient
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Creates the `netlify graph:edit` command
|
|
18
|
-
* @param {import('commander').OptionValues} options
|
|
19
|
-
* @param {import('../base-command.mjs').default} command
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
const graphEdit = async (options, command) => {
|
|
23
|
-
const { config, site, state } = command.netlify
|
|
24
|
-
const siteId = site.id
|
|
25
|
-
|
|
26
|
-
if (!site.id) {
|
|
27
|
-
error(
|
|
28
|
-
`${NETLIFYDEVERR} Warning: no siteId defined, unable to start Netlify Graph. To enable, run ${chalk.yellow(
|
|
29
|
-
'netlify init',
|
|
30
|
-
)} or ${chalk.yellow('netlify link')}`,
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
const netlifyGraphConfig = await getNetlifyGraphConfig({ command, options })
|
|
34
|
-
|
|
35
|
-
let graphqlDocument = readGraphQLOperationsSourceFile(netlifyGraphConfig)
|
|
36
|
-
|
|
37
|
-
if (graphqlDocument.trim().length === 0) {
|
|
38
|
-
graphqlDocument = defaultExampleOperationsDoc
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const netlifyToken = await command.authenticate()
|
|
42
|
-
const { jwt } = await OneGraphCliClient.getGraphJwtForSite({ siteId, nfToken: netlifyToken })
|
|
43
|
-
|
|
44
|
-
await ensureAppForSite(netlifyToken, siteId)
|
|
45
|
-
|
|
46
|
-
const oneGraphSessionId = await ensureCLISession({
|
|
47
|
-
config,
|
|
48
|
-
metadata: {},
|
|
49
|
-
netlifyToken,
|
|
50
|
-
site,
|
|
51
|
-
state,
|
|
52
|
-
netlifyGraphConfig,
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const { branch } = gitRepoInfo()
|
|
56
|
-
const persistedResult = await executeCreatePersistedQueryMutation(
|
|
57
|
-
{
|
|
58
|
-
nfToken: netlifyToken,
|
|
59
|
-
appId: siteId,
|
|
60
|
-
description: 'Temporary snapshot of local queries',
|
|
61
|
-
query: graphqlDocument,
|
|
62
|
-
tags: ['netlify-cli', `session:${oneGraphSessionId}`, `git-branch:${branch}`],
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
accessToken: jwt,
|
|
66
|
-
siteId,
|
|
67
|
-
},
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
const persistedDoc =
|
|
71
|
-
persistedResult.data &&
|
|
72
|
-
persistedResult.data.oneGraph &&
|
|
73
|
-
persistedResult.data.oneGraph.createPersistedQuery &&
|
|
74
|
-
persistedResult.data.oneGraph.createPersistedQuery.persistedQuery
|
|
75
|
-
|
|
76
|
-
const newMetadata = { docId: persistedDoc.id }
|
|
77
|
-
|
|
78
|
-
await upsertMergeCLISessionMetadata({
|
|
79
|
-
config,
|
|
80
|
-
jwt,
|
|
81
|
-
siteId,
|
|
82
|
-
siteRoot: site.root,
|
|
83
|
-
oneGraphSessionId,
|
|
84
|
-
newMetadata,
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
const graphEditUrl = getGraphEditUrlBySiteId({ siteId, oneGraphSessionId })
|
|
88
|
-
|
|
89
|
-
log(`Opening graph:edit session at ${chalk.cyan(graphEditUrl)}`)
|
|
90
|
-
await openBrowser({ url: graphEditUrl })
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Creates the `netlify graph:edit` command
|
|
95
|
-
* @param {import('../base-command.mjs').default} program
|
|
96
|
-
* @returns
|
|
97
|
-
*/
|
|
98
|
-
export const createGraphEditCommand = (program) =>
|
|
99
|
-
program
|
|
100
|
-
.command('graph:edit')
|
|
101
|
-
.description('Launch the browser to edit your local graph functions from Netlify')
|
|
102
|
-
.action(async (options, command) => {
|
|
103
|
-
await graphEdit(options, command)
|
|
104
|
-
})
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/* eslint-disable eslint-comments/disable-enable-pair */
|
|
2
|
-
// @ts-check
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
autocompleteCodegenModules,
|
|
6
|
-
autocompleteOperationNames,
|
|
7
|
-
buildSchema,
|
|
8
|
-
generateHandlerByOperationName,
|
|
9
|
-
getCodegenFunctionById,
|
|
10
|
-
getCodegenModule,
|
|
11
|
-
getNetlifyGraphConfig,
|
|
12
|
-
readGraphQLSchemaFile,
|
|
13
|
-
} from '../../lib/one-graph/cli-netlify-graph.mjs'
|
|
14
|
-
import { error, log } from '../../utils/command-helpers.mjs'
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Creates the `netlify graph:handler` command
|
|
18
|
-
* @param {import('commander').OptionValues} options
|
|
19
|
-
* @param {import('../base-command.mjs').default} command
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
const graphHandler = async (args, options, command) => {
|
|
23
|
-
const netlifyGraphConfig = await getNetlifyGraphConfig({ command, options })
|
|
24
|
-
const { config } = command.netlify
|
|
25
|
-
|
|
26
|
-
const schemaString = readGraphQLSchemaFile(netlifyGraphConfig)
|
|
27
|
-
|
|
28
|
-
let schema
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
schema = buildSchema(schemaString)
|
|
32
|
-
} catch (buildSchemaError) {
|
|
33
|
-
error(`Error parsing schema: ${buildSchemaError}`)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const userOperationNames = args.operationNames
|
|
37
|
-
const userCodegenId = options.codegen
|
|
38
|
-
|
|
39
|
-
const handlerOptions = options.data ? JSON.parse(options.data) : {}
|
|
40
|
-
|
|
41
|
-
let operationNames = userOperationNames
|
|
42
|
-
if (!operationNames || operationNames.length === 0) {
|
|
43
|
-
const operationName = await autocompleteOperationNames({ netlifyGraphConfig })
|
|
44
|
-
operationNames = [operationName]
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (!operationNames || operationNames.length === 0) {
|
|
48
|
-
error(`No operation name provided`)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const codegenModule = await getCodegenModule({ config })
|
|
52
|
-
if (!codegenModule) {
|
|
53
|
-
error(
|
|
54
|
-
`No Netlify Graph codegen module specified in netlify.toml under the [graph] header. Please specify 'codeGenerator' field and try again.`,
|
|
55
|
-
)
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let codeGenerator = userCodegenId ? await getCodegenFunctionById({ config, id: userCodegenId }) : null
|
|
60
|
-
if (!codeGenerator) {
|
|
61
|
-
codeGenerator = await autocompleteCodegenModules({ config })
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!codeGenerator) {
|
|
65
|
-
error(`Unable to select appropriate Netlify Graph code generator`)
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (schema) {
|
|
70
|
-
/* eslint-disable fp/no-loops */
|
|
71
|
-
for (const operationName of operationNames) {
|
|
72
|
-
await generateHandlerByOperationName({
|
|
73
|
-
generate: codeGenerator.generateHandler,
|
|
74
|
-
logger: log,
|
|
75
|
-
netlifyGraphConfig,
|
|
76
|
-
schema,
|
|
77
|
-
operationName,
|
|
78
|
-
handlerOptions,
|
|
79
|
-
})
|
|
80
|
-
}
|
|
81
|
-
} else {
|
|
82
|
-
error(`Failed to parse Netlify GraphQL schema`)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Creates the `netlify graph:handler` command
|
|
88
|
-
* @param {import('../base-command.mjs').default} program
|
|
89
|
-
* @returns
|
|
90
|
-
*/
|
|
91
|
-
export const createGraphHandlerCommand = (program) =>
|
|
92
|
-
program
|
|
93
|
-
.command('graph:handler')
|
|
94
|
-
.argument('[name...]', 'Operation name(s)')
|
|
95
|
-
.option('-c, --codegen <id>', 'The id of the specific code generator to use')
|
|
96
|
-
.option("-d, --data '<json>'", 'Optional data to pass along to the code generator')
|
|
97
|
-
.description(
|
|
98
|
-
'Generate a handler for a Graph operation given its name. See `graph:operations` for a list of operations.',
|
|
99
|
-
)
|
|
100
|
-
.action(async (operationNames, options, command) => {
|
|
101
|
-
await graphHandler({ operationNames }, options, command)
|
|
102
|
-
})
|