netlify-cli 6.9.11 → 6.9.15
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 +25 -24
- package/oclif.manifest.json +1 -1
- package/package.json +3 -4
- package/src/commands/addons/config.js +0 -1
- package/src/commands/dev/index.js +1 -6
- package/src/commands/functions/serve.js +1 -3
- package/src/commands/init.js +12 -12
- package/src/commands/login.js +3 -3
- package/src/commands/logout.js +3 -3
- package/src/commands/switch.js +2 -2
- package/src/commands/watch.js +2 -2
- package/src/functions-templates/js/oauth-passport/package.json +0 -1
- package/src/functions-templates/js/oauth-passport/{{name}}.js +2 -3
- package/src/functions-templates/js/serverless-ssr/app/index.js +2 -3
- package/src/functions-templates/js/serverless-ssr/package.json +0 -1
- package/src/lib/functions/form-submissions-handler.js +4 -3
- package/src/lib/functions/netlify-function.js +2 -11
- package/src/lib/functions/registry.js +11 -17
- package/src/lib/functions/server.js +8 -21
- package/src/utils/addons/prepare.js +8 -8
- package/src/utils/command.js +18 -7
- package/src/utils/dev.js +8 -11
- package/src/utils/dot-env.js +1 -5
- package/src/utils/init/config-github.js +12 -14
- package/src/utils/init/config-manual.js +6 -8
- package/src/utils/init/node-version.js +2 -1
- package/src/utils/init/utils.js +7 -16
- package/src/utils/link/link-by-prompt.js +17 -17
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { Octokit } = require('@octokit/rest')
|
|
2
2
|
const chalk = require('chalk')
|
|
3
3
|
|
|
4
|
-
const { log } = require('../command-helpers')
|
|
4
|
+
const { log, error: failAndExit } = require('../command-helpers')
|
|
5
5
|
const ghauth = require('../gh-auth')
|
|
6
6
|
|
|
7
7
|
const { getBuildSettings, saveNetlifyToml, formatErrorMessage, createDeployKey, setupSite } = require('./utils')
|
|
@@ -35,9 +35,9 @@ const getGitHubClient = ({ token }) => {
|
|
|
35
35
|
return octokit
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const addDeployKey = async ({ api, octokit, repoOwner, repoName
|
|
38
|
+
const addDeployKey = async ({ api, octokit, repoOwner, repoName }) => {
|
|
39
39
|
log('Adding deploy key to repository...')
|
|
40
|
-
const key = await createDeployKey({ api
|
|
40
|
+
const key = await createDeployKey({ api })
|
|
41
41
|
try {
|
|
42
42
|
await octokit.repos.createDeployKey({
|
|
43
43
|
title: 'Netlify Deploy Key',
|
|
@@ -58,7 +58,7 @@ const addDeployKey = async ({ api, octokit, repoOwner, repoName, failAndExit })
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const getGitHubRepo = async ({ octokit, repoOwner, repoName
|
|
61
|
+
const getGitHubRepo = async ({ octokit, repoOwner, repoName }) => {
|
|
62
62
|
try {
|
|
63
63
|
const { data } = await octokit.repos.get({
|
|
64
64
|
owner: repoOwner,
|
|
@@ -90,7 +90,7 @@ const hookExists = async ({ deployHook, octokit, repoOwner, repoName }) => {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
const addDeployHook = async ({ deployHook, octokit, repoOwner, repoName
|
|
93
|
+
const addDeployHook = async ({ deployHook, octokit, repoOwner, repoName }) => {
|
|
94
94
|
const exists = await hookExists({ deployHook, octokit, repoOwner, repoName })
|
|
95
95
|
if (!exists) {
|
|
96
96
|
try {
|
|
@@ -148,7 +148,7 @@ const upsertHook = async ({ ntlHooks, event, api, siteId, token }) => {
|
|
|
148
148
|
})
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
const addNotificationHooks = async ({
|
|
151
|
+
const addNotificationHooks = async ({ siteId, api, token }) => {
|
|
152
152
|
log(`Creating Netlify GitHub Notification Hooks...`)
|
|
153
153
|
|
|
154
154
|
let ntlHooks
|
|
@@ -173,7 +173,7 @@ const addNotificationHooks = async ({ failAndExit, siteId, api, token }) => {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
module.exports = async function configGithub({ context, siteId, repoOwner, repoName }) {
|
|
176
|
-
const {
|
|
176
|
+
const { netlify } = context
|
|
177
177
|
const {
|
|
178
178
|
api,
|
|
179
179
|
globalConfig,
|
|
@@ -190,14 +190,13 @@ module.exports = async function configGithub({ context, siteId, repoOwner, repoN
|
|
|
190
190
|
siteRoot,
|
|
191
191
|
config,
|
|
192
192
|
env,
|
|
193
|
-
warn,
|
|
194
193
|
})
|
|
195
|
-
await saveNetlifyToml({ repositoryRoot, config, configPath, baseDir, buildCmd, buildDir, functionsDir
|
|
194
|
+
await saveNetlifyToml({ repositoryRoot, config, configPath, baseDir, buildCmd, buildDir, functionsDir })
|
|
196
195
|
|
|
197
196
|
const octokit = getGitHubClient({ token })
|
|
198
197
|
const [deployKey, githubRepo] = await Promise.all([
|
|
199
|
-
addDeployKey({ api, octokit, repoOwner, repoName
|
|
200
|
-
getGitHubRepo({ octokit, repoOwner, repoName
|
|
198
|
+
addDeployKey({ api, octokit, repoOwner, repoName }),
|
|
199
|
+
getGitHubRepo({ octokit, repoOwner, repoName }),
|
|
201
200
|
])
|
|
202
201
|
|
|
203
202
|
const repo = {
|
|
@@ -215,13 +214,12 @@ module.exports = async function configGithub({ context, siteId, repoOwner, repoN
|
|
|
215
214
|
|
|
216
215
|
const updatedSite = await setupSite({
|
|
217
216
|
api,
|
|
218
|
-
failAndExit,
|
|
219
217
|
siteId,
|
|
220
218
|
repo,
|
|
221
219
|
configPlugins: config.plugins,
|
|
222
220
|
pluginsToInstall,
|
|
223
221
|
})
|
|
224
|
-
await addDeployHook({ deployHook: updatedSite.deploy_hook, octokit, repoOwner, repoName
|
|
222
|
+
await addDeployHook({ deployHook: updatedSite.deploy_hook, octokit, repoOwner, repoName })
|
|
225
223
|
log()
|
|
226
|
-
await addNotificationHooks({
|
|
224
|
+
await addNotificationHooks({ siteId, api, token })
|
|
227
225
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const inquirer = require('inquirer')
|
|
2
2
|
|
|
3
|
-
const { log } = require('../command-helpers')
|
|
3
|
+
const { log, exit } = require('../command-helpers')
|
|
4
4
|
|
|
5
5
|
const { getBuildSettings, saveNetlifyToml, createDeployKey, setupSite } = require('./utils')
|
|
6
6
|
|
|
7
|
-
const addDeployKey = async ({
|
|
7
|
+
const addDeployKey = async ({ deployKey }) => {
|
|
8
8
|
log('\nGive this Netlify SSH public key access to your repository:\n')
|
|
9
9
|
log(`\n${deployKey.public_key}\n\n`)
|
|
10
10
|
|
|
@@ -52,7 +52,7 @@ const addDeployHook = async ({ deployHook }) => {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
module.exports = async function configManual({ context, siteId, repoData }) {
|
|
55
|
-
const {
|
|
55
|
+
const { netlify } = context
|
|
56
56
|
const {
|
|
57
57
|
api,
|
|
58
58
|
config,
|
|
@@ -66,12 +66,11 @@ module.exports = async function configManual({ context, siteId, repoData }) {
|
|
|
66
66
|
siteRoot,
|
|
67
67
|
config,
|
|
68
68
|
env,
|
|
69
|
-
warn,
|
|
70
69
|
})
|
|
71
|
-
await saveNetlifyToml({ repositoryRoot, config, configPath, baseDir, buildCmd, buildDir, functionsDir
|
|
70
|
+
await saveNetlifyToml({ repositoryRoot, config, configPath, baseDir, buildCmd, buildDir, functionsDir })
|
|
72
71
|
|
|
73
|
-
const deployKey = await createDeployKey({ api
|
|
74
|
-
await addDeployKey({
|
|
72
|
+
const deployKey = await createDeployKey({ api })
|
|
73
|
+
await addDeployKey({ deployKey })
|
|
75
74
|
|
|
76
75
|
const repoPath = await getRepoPath({ repoData })
|
|
77
76
|
const repo = {
|
|
@@ -88,7 +87,6 @@ module.exports = async function configManual({ context, siteId, repoData }) {
|
|
|
88
87
|
|
|
89
88
|
const updatedSite = await setupSite({
|
|
90
89
|
api,
|
|
91
|
-
failAndExit,
|
|
92
90
|
siteId,
|
|
93
91
|
repo,
|
|
94
92
|
configPlugins: config.plugins,
|
|
@@ -3,6 +3,7 @@ const locatePath = require('locate-path')
|
|
|
3
3
|
const nodeVersionAlias = require('node-version-alias')
|
|
4
4
|
|
|
5
5
|
const { readFileAsync } = require('../../lib/fs')
|
|
6
|
+
const { warn } = require('../command-helpers')
|
|
6
7
|
|
|
7
8
|
const DEFAULT_NODE_VERSION = '12.18.0'
|
|
8
9
|
const NVM_FLAG_PREFIX = '--'
|
|
@@ -11,7 +12,7 @@ const NVM_FLAG_PREFIX = '--'
|
|
|
11
12
|
const normalizeConfiguredVersion = (version) =>
|
|
12
13
|
version.startsWith(NVM_FLAG_PREFIX) ? version.slice(NVM_FLAG_PREFIX.length) : version
|
|
13
14
|
|
|
14
|
-
const detectNodeVersion = async ({ baseDirectory, env
|
|
15
|
+
const detectNodeVersion = async ({ baseDirectory, env }) => {
|
|
15
16
|
try {
|
|
16
17
|
const nodeVersionFile = await locatePath(['.nvmrc', '.node-version'], { cwd: baseDirectory })
|
|
17
18
|
const configuredVersion =
|
package/src/utils/init/utils.js
CHANGED
|
@@ -9,6 +9,7 @@ const isEmpty = require('lodash/isEmpty')
|
|
|
9
9
|
|
|
10
10
|
const { fileExistsAsync, writeFileAsync } = require('../../lib/fs')
|
|
11
11
|
const { normalizeBackslash } = require('../../lib/path')
|
|
12
|
+
const { error: failAndExit, warn } = require('../command-helpers')
|
|
12
13
|
|
|
13
14
|
const { getFrameworkInfo } = require('./frameworks')
|
|
14
15
|
const { detectNodeVersion } = require('./node-version')
|
|
@@ -131,9 +132,9 @@ const getPromptInputs = async ({
|
|
|
131
132
|
const getBaseDirectory = ({ repositoryRoot, siteRoot }) =>
|
|
132
133
|
path.normalize(repositoryRoot) === path.normalize(siteRoot) ? process.cwd() : siteRoot
|
|
133
134
|
|
|
134
|
-
const getBuildSettings = async ({ repositoryRoot, siteRoot, config, env
|
|
135
|
+
const getBuildSettings = async ({ repositoryRoot, siteRoot, config, env }) => {
|
|
135
136
|
const baseDirectory = getBaseDirectory({ repositoryRoot, siteRoot })
|
|
136
|
-
const nodeVersion = await detectNodeVersion({ baseDirectory, env
|
|
137
|
+
const nodeVersion = await detectNodeVersion({ baseDirectory, env })
|
|
137
138
|
const {
|
|
138
139
|
frameworkName,
|
|
139
140
|
frameworkBuildCommand,
|
|
@@ -200,16 +201,7 @@ const getNetlifyToml = ({
|
|
|
200
201
|
## more info on configuring this file: https://www.netlify.com/docs/netlify-toml-reference/
|
|
201
202
|
`
|
|
202
203
|
|
|
203
|
-
const saveNetlifyToml = async ({
|
|
204
|
-
repositoryRoot,
|
|
205
|
-
config,
|
|
206
|
-
configPath,
|
|
207
|
-
baseDir,
|
|
208
|
-
buildCmd,
|
|
209
|
-
buildDir,
|
|
210
|
-
functionsDir,
|
|
211
|
-
warn,
|
|
212
|
-
}) => {
|
|
204
|
+
const saveNetlifyToml = async ({ repositoryRoot, config, configPath, baseDir, buildCmd, buildDir, functionsDir }) => {
|
|
213
205
|
const tomlPathParts = [repositoryRoot, baseDir, 'netlify.toml'].filter(Boolean)
|
|
214
206
|
const tomlPath = path.join(...tomlPathParts)
|
|
215
207
|
const exists = await fileExistsAsync(tomlPath)
|
|
@@ -248,7 +240,7 @@ const formatErrorMessage = ({ message, error }) => {
|
|
|
248
240
|
|
|
249
241
|
const formatTitle = (title) => chalk.cyan(title)
|
|
250
242
|
|
|
251
|
-
const createDeployKey = async ({ api
|
|
243
|
+
const createDeployKey = async ({ api }) => {
|
|
252
244
|
try {
|
|
253
245
|
const deployKey = await api.createDeployKey()
|
|
254
246
|
return deployKey
|
|
@@ -258,7 +250,7 @@ const createDeployKey = async ({ api, failAndExit }) => {
|
|
|
258
250
|
}
|
|
259
251
|
}
|
|
260
252
|
|
|
261
|
-
const updateSite = async ({ siteId, api,
|
|
253
|
+
const updateSite = async ({ siteId, api, options }) => {
|
|
262
254
|
try {
|
|
263
255
|
const updatedSite = await api.updateSite({ siteId, body: options })
|
|
264
256
|
return updatedSite
|
|
@@ -268,11 +260,10 @@ const updateSite = async ({ siteId, api, failAndExit, options }) => {
|
|
|
268
260
|
}
|
|
269
261
|
}
|
|
270
262
|
|
|
271
|
-
const setupSite = async ({ api,
|
|
263
|
+
const setupSite = async ({ api, siteId, repo, configPlugins, pluginsToInstall }) => {
|
|
272
264
|
const updatedSite = await updateSite({
|
|
273
265
|
siteId,
|
|
274
266
|
api,
|
|
275
|
-
failAndExit,
|
|
276
267
|
// merge existing plugins with new ones
|
|
277
268
|
options: { repo, plugins: [...getUIPlugins(configPlugins), ...pluginsToInstall] },
|
|
278
269
|
})
|
|
@@ -5,7 +5,7 @@ const inquirer = require('inquirer')
|
|
|
5
5
|
const isEmpty = require('lodash/isEmpty')
|
|
6
6
|
|
|
7
7
|
const { listSites } = require('../../lib/api')
|
|
8
|
-
const { log } = require('../command-helpers')
|
|
8
|
+
const { log, error, exit } = require('../command-helpers')
|
|
9
9
|
const { getRepoData } = require('../get-repo-data')
|
|
10
10
|
const { track } = require('../telemetry')
|
|
11
11
|
|
|
@@ -70,7 +70,7 @@ Double check you are in the correct working directory and a remote origin repo i
|
|
|
70
70
|
|
|
71
71
|
Run ${chalk.cyanBright('git remote -v')} to see a list of your git remotes.`)
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
exit()
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// Matches a single site hooray!
|
|
@@ -94,7 +94,7 @@ Run ${chalk.cyanBright('git remote -v')} to see a list of your git remotes.`)
|
|
|
94
94
|
},
|
|
95
95
|
])
|
|
96
96
|
if (!selectedSite) {
|
|
97
|
-
|
|
97
|
+
error('No site selected')
|
|
98
98
|
}
|
|
99
99
|
site = selectedSite
|
|
100
100
|
}
|
|
@@ -118,16 +118,16 @@ Run ${chalk.cyanBright('git remote -v')} to see a list of your git remotes.`)
|
|
|
118
118
|
api,
|
|
119
119
|
options: { name: searchTerm, filter: 'all' },
|
|
120
120
|
})
|
|
121
|
-
} catch (
|
|
122
|
-
if (
|
|
123
|
-
|
|
121
|
+
} catch (error_) {
|
|
122
|
+
if (error_.status === 404) {
|
|
123
|
+
error(`'${searchTerm}' not found`)
|
|
124
124
|
} else {
|
|
125
|
-
|
|
125
|
+
error(error_)
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
if (isEmpty(matchingSites)) {
|
|
130
|
-
|
|
130
|
+
error(`No site names found containing '${searchTerm}'.
|
|
131
131
|
|
|
132
132
|
Run ${chalk.cyanBright('netlify link')} again to try a new search,
|
|
133
133
|
or run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
|
|
@@ -162,12 +162,12 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
|
|
|
162
162
|
let sites
|
|
163
163
|
try {
|
|
164
164
|
sites = await listSites({ api, options: { maxPages: 1, filter: 'all' } })
|
|
165
|
-
} catch (
|
|
166
|
-
|
|
165
|
+
} catch (error_) {
|
|
166
|
+
error(error_)
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
if (isEmpty(sites)) {
|
|
170
|
-
|
|
170
|
+
error(`You don't have any sites yet. Run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
const { selectedSite } = await inquirer.prompt([
|
|
@@ -180,7 +180,7 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
|
|
|
180
180
|
},
|
|
181
181
|
])
|
|
182
182
|
if (!selectedSite) {
|
|
183
|
-
|
|
183
|
+
error('No site selected')
|
|
184
184
|
}
|
|
185
185
|
site = selectedSite
|
|
186
186
|
break
|
|
@@ -197,11 +197,11 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
|
|
|
197
197
|
|
|
198
198
|
try {
|
|
199
199
|
site = await api.getSite({ siteId })
|
|
200
|
-
} catch (
|
|
201
|
-
if (
|
|
202
|
-
|
|
200
|
+
} catch (error_) {
|
|
201
|
+
if (error_.status === 404) {
|
|
202
|
+
error(new Error(`Site ID '${siteId}' not found`))
|
|
203
203
|
} else {
|
|
204
|
-
|
|
204
|
+
error(error_)
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
break
|
|
@@ -211,7 +211,7 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
if (!site) {
|
|
214
|
-
|
|
214
|
+
error(new Error(`No site found`))
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
// Save site ID to config
|