netlify-cli 8.0.7 → 8.1.0-rc
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/bin/run +81 -3
- package/npm-shrinkwrap.json +305 -2105
- package/package.json +10 -33
- package/src/commands/addons/addons-auth.js +50 -0
- package/src/commands/addons/addons-config.js +180 -0
- package/src/commands/addons/addons-create.js +129 -0
- package/src/commands/addons/addons-delete.js +59 -0
- package/src/commands/addons/addons-list.js +62 -0
- package/src/commands/addons/addons.js +49 -0
- package/src/commands/addons/index.js +3 -24
- package/src/commands/api/api.js +83 -0
- package/src/commands/api/index.js +5 -0
- package/src/commands/base-command.js +322 -0
- package/src/commands/build/build.js +58 -0
- package/src/commands/build/index.js +3 -61
- package/src/commands/completion/completion.js +18 -0
- package/src/commands/completion/index.js +5 -0
- package/src/commands/{deploy.js → deploy/deploy.js} +306 -278
- package/src/commands/deploy/index.js +5 -0
- package/src/commands/dev/dev-exec.js +39 -0
- package/src/commands/dev/dev-trace.js +50 -0
- package/src/commands/dev/dev.js +349 -0
- package/src/commands/dev/index.js +3 -335
- package/src/commands/env/env-get.js +51 -0
- package/src/commands/env/env-import.js +93 -0
- package/src/commands/env/env-list.js +63 -0
- package/src/commands/env/env-set.js +67 -0
- package/src/commands/env/env-unset.js +66 -0
- package/src/commands/env/env.js +47 -0
- package/src/commands/env/index.js +3 -23
- package/src/commands/functions/functions-build.js +59 -0
- package/src/commands/functions/{create.js → functions-create.js} +133 -94
- package/src/commands/functions/functions-invoke.js +276 -0
- package/src/commands/functions/functions-list.js +107 -0
- package/src/commands/functions/functions-serve.js +63 -0
- package/src/commands/functions/functions.js +53 -0
- package/src/commands/functions/index.js +3 -45
- package/src/commands/index.js +5 -0
- package/src/commands/init/index.js +6 -0
- package/src/commands/{init.js → init/init.js} +79 -68
- package/src/commands/link/index.js +6 -0
- package/src/{utils/link/link-by-prompt.js → commands/link/link.js} +153 -14
- package/src/commands/lm/index.js +3 -19
- package/src/commands/lm/lm-info.js +42 -0
- package/src/commands/lm/lm-install.js +36 -0
- package/src/commands/lm/lm-setup.js +106 -0
- package/src/commands/lm/lm-uninstall.js +25 -0
- package/src/commands/lm/lm.js +39 -0
- package/src/commands/login/index.js +6 -0
- package/src/commands/login/login.js +52 -0
- package/src/commands/logout/index.js +5 -0
- package/src/commands/logout/logout.js +43 -0
- package/src/commands/main.js +117 -0
- package/src/commands/open/index.js +3 -39
- package/src/commands/open/open-admin.js +56 -0
- package/src/commands/open/open-site.js +49 -0
- package/src/commands/open/open.js +42 -0
- package/src/commands/sites/index.js +5 -20
- package/src/commands/sites/sites-create.js +184 -0
- package/src/commands/sites/sites-delete.js +108 -0
- package/src/commands/sites/sites-list.js +89 -0
- package/src/commands/sites/sites.js +36 -0
- package/src/commands/status/index.js +3 -118
- package/src/commands/status/status-hooks.js +73 -0
- package/src/commands/status/status.js +125 -0
- package/src/commands/switch/index.js +5 -0
- package/src/commands/switch/switch.js +50 -0
- package/src/commands/unlink/index.js +5 -0
- package/src/commands/unlink/unlink.js +48 -0
- package/src/commands/watch/index.js +5 -0
- package/src/commands/watch/watch.js +121 -0
- package/src/lib/build.js +21 -7
- package/src/lib/exec-fetcher.js +5 -3
- package/src/lib/fs.js +54 -36
- package/src/lib/functions/background.js +1 -1
- package/src/lib/functions/form-submissions-handler.js +2 -1
- package/src/lib/functions/local-proxy.js +2 -1
- package/src/lib/functions/netlify-function.js +4 -1
- package/src/lib/functions/registry.js +4 -6
- package/src/lib/functions/runtimes/go/index.js +2 -1
- package/src/lib/functions/runtimes/js/builders/netlify-lambda.js +6 -4
- package/src/lib/functions/runtimes/js/builders/zisi.js +3 -3
- package/src/lib/functions/runtimes/rust/index.js +4 -3
- package/src/lib/functions/server.js +2 -3
- package/src/lib/functions/synchronous.js +2 -1
- package/src/lib/functions/utils.js +2 -3
- package/src/lib/functions/watcher.js +1 -0
- package/src/lib/http-agent.js +3 -5
- package/src/lib/log.js +2 -1
- package/src/lib/spinner.js +22 -0
- package/src/utils/addons/diffs/index.js +1 -0
- package/src/utils/addons/diffs/options.js +3 -1
- package/src/utils/addons/prepare.js +13 -6
- package/src/utils/addons/prompts.js +2 -1
- package/src/utils/addons/render.js +3 -1
- package/src/utils/command-helpers.js +156 -43
- package/src/utils/create-stream-promise.js +5 -5
- package/src/utils/deferred.js +1 -0
- package/src/utils/deploy/deploy-site.js +1 -1
- package/src/utils/deploy/index.js +4 -0
- package/src/utils/detect-server-settings.js +10 -12
- package/src/utils/dev.js +18 -10
- package/src/utils/dot-env.js +4 -2
- package/src/utils/{edge-handlers.js → functions/edge-handlers.js} +8 -7
- package/src/utils/functions/functions.js +36 -0
- package/src/utils/{get-functions.js → functions/get-functions.js} +2 -1
- package/src/utils/functions/index.js +8 -26
- package/src/utils/get-global-config.js +3 -2
- package/src/utils/get-repo-data.js +1 -0
- package/src/utils/gh-auth.js +1 -0
- package/src/utils/gitignore.js +7 -5
- package/src/utils/header.js +2 -2
- package/src/utils/headers.js +1 -2
- package/src/utils/index.js +42 -0
- package/src/utils/init/config-github.js +12 -5
- package/src/utils/init/config-manual.js +9 -2
- package/src/utils/init/config.js +13 -7
- package/src/utils/init/frameworks.js +1 -0
- package/src/utils/init/node-version.js +4 -2
- package/src/utils/init/plugins.js +1 -0
- package/src/utils/init/utils.js +10 -6
- package/src/utils/live-tunnel.js +3 -4
- package/src/utils/lm/install.js +10 -15
- package/src/utils/lm/requirements.js +3 -1
- package/src/utils/lm/steps.js +1 -1
- package/src/utils/lm/ui.js +7 -3
- package/src/utils/open-browser.js +8 -2
- package/src/utils/parse-raw-flags.js +4 -4
- package/src/utils/proxy.js +6 -5
- package/src/utils/read-repo-url.js +1 -0
- package/src/utils/redirects.js +2 -2
- package/src/utils/rules-proxy.js +2 -1
- package/src/utils/state-config.js +1 -1
- package/src/utils/telemetry/index.js +2 -113
- package/src/utils/telemetry/request.js +3 -1
- package/src/utils/telemetry/telemetry.js +117 -0
- package/src/utils/telemetry/validation.js +13 -12
- package/src/utils/traffic-mesh.js +3 -3
- package/oclif.manifest.json +0 -1
- package/src/commands/addons/auth.js +0 -42
- package/src/commands/addons/config.js +0 -177
- package/src/commands/addons/create.js +0 -127
- package/src/commands/addons/delete.js +0 -69
- package/src/commands/addons/list.js +0 -54
- package/src/commands/api.js +0 -84
- package/src/commands/dev/exec.js +0 -32
- package/src/commands/dev/trace.js +0 -61
- package/src/commands/env/get.js +0 -44
- package/src/commands/env/import.js +0 -90
- package/src/commands/env/list.js +0 -49
- package/src/commands/env/set.js +0 -64
- package/src/commands/env/unset.js +0 -58
- package/src/commands/functions/build.js +0 -60
- package/src/commands/functions/invoke.js +0 -277
- package/src/commands/functions/list.js +0 -102
- package/src/commands/functions/serve.js +0 -70
- package/src/commands/link.js +0 -133
- package/src/commands/lm/info.js +0 -36
- package/src/commands/lm/install.js +0 -30
- package/src/commands/lm/setup.js +0 -107
- package/src/commands/lm/uninstall.js +0 -17
- package/src/commands/login.js +0 -54
- package/src/commands/logout.js +0 -37
- package/src/commands/open/admin.js +0 -51
- package/src/commands/open/site.js +0 -43
- package/src/commands/sites/create.js +0 -191
- package/src/commands/sites/delete.js +0 -116
- package/src/commands/sites/list.js +0 -84
- package/src/commands/status/hooks.js +0 -60
- package/src/commands/switch.js +0 -44
- package/src/commands/unlink.js +0 -38
- package/src/commands/watch.js +0 -115
- package/src/hooks/init.js +0 -46
- package/src/index.js +0 -25
- package/src/lib/help.js +0 -26
- package/src/utils/chalk.js +0 -16
- package/src/utils/check-command-inputs.js +0 -21
- package/src/utils/command.js +0 -262
- package/src/utils/detect-functions-builder.js +0 -25
- package/src/utils/difference.js +0 -4
- package/src/utils/logo.js +0 -11
- package/src/utils/show-help.js +0 -5
- package/src/utils/telemetry/tracked-command.js +0 -51
package/src/commands/lm/info.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const Listr = require('listr')
|
|
2
|
-
|
|
3
|
-
const Command = require('../../utils/command')
|
|
4
|
-
const {
|
|
5
|
-
checkGitLFSVersionStep,
|
|
6
|
-
checkGitVersionStep,
|
|
7
|
-
checkHelperVersionStep,
|
|
8
|
-
checkLFSFiltersStep,
|
|
9
|
-
} = require('../../utils/lm/steps')
|
|
10
|
-
|
|
11
|
-
class LmInfoCommand extends Command {
|
|
12
|
-
async run() {
|
|
13
|
-
this.parse(LmInfoCommand)
|
|
14
|
-
const steps = [
|
|
15
|
-
checkGitVersionStep,
|
|
16
|
-
checkGitLFSVersionStep,
|
|
17
|
-
checkLFSFiltersStep((ctx, task, installed) => {
|
|
18
|
-
if (!installed) {
|
|
19
|
-
throw new Error('Git LFS filters are not installed, run `git lfs install` to install them')
|
|
20
|
-
}
|
|
21
|
-
}),
|
|
22
|
-
checkHelperVersionStep,
|
|
23
|
-
]
|
|
24
|
-
|
|
25
|
-
const tasks = new Listr(steps, { concurrent: true, exitOnError: false })
|
|
26
|
-
try {
|
|
27
|
-
await tasks.run()
|
|
28
|
-
} catch {
|
|
29
|
-
// an error is already reported when a task fails
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
LmInfoCommand.description = `Show large media requirements information.`
|
|
35
|
-
|
|
36
|
-
module.exports = LmInfoCommand
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const { flags: flagsLib } = require('@oclif/command')
|
|
2
|
-
|
|
3
|
-
const Command = require('../../utils/command')
|
|
4
|
-
const { installPlatform } = require('../../utils/lm/install')
|
|
5
|
-
const { printBanner } = require('../../utils/lm/ui')
|
|
6
|
-
|
|
7
|
-
class LmInstallCommand extends Command {
|
|
8
|
-
async run() {
|
|
9
|
-
const { flags } = this.parse(LmInstallCommand)
|
|
10
|
-
|
|
11
|
-
const installed = await installPlatform({ force: flags.force })
|
|
12
|
-
if (installed) {
|
|
13
|
-
printBanner(this, flags.force)
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
LmInstallCommand.aliases = ['lm:init']
|
|
19
|
-
LmInstallCommand.flags = {
|
|
20
|
-
force: flagsLib.boolean({
|
|
21
|
-
char: 'f',
|
|
22
|
-
description: 'Force the credentials helper installation',
|
|
23
|
-
}),
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
LmInstallCommand.description = `Configures your computer to use Netlify Large Media.
|
|
27
|
-
It installs the required credentials helper for Git,
|
|
28
|
-
and configures your Git environment with the right credentials.`
|
|
29
|
-
|
|
30
|
-
module.exports = LmInstallCommand
|
package/src/commands/lm/setup.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
const { flags: flagsLib } = require('@oclif/command')
|
|
2
|
-
const execa = require('execa')
|
|
3
|
-
const Listr = require('listr')
|
|
4
|
-
|
|
5
|
-
const Command = require('../../utils/command')
|
|
6
|
-
const { error } = require('../../utils/command-helpers')
|
|
7
|
-
const { installPlatform } = require('../../utils/lm/install')
|
|
8
|
-
const { checkHelperVersion } = require('../../utils/lm/requirements')
|
|
9
|
-
const { printBanner } = require('../../utils/lm/ui')
|
|
10
|
-
|
|
11
|
-
const installHelperIfMissing = async function ({ force }) {
|
|
12
|
-
let installHelper = false
|
|
13
|
-
try {
|
|
14
|
-
const version = await checkHelperVersion()
|
|
15
|
-
if (!version) {
|
|
16
|
-
installHelper = true
|
|
17
|
-
}
|
|
18
|
-
} catch {
|
|
19
|
-
installHelper = true
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (installHelper) {
|
|
23
|
-
return installPlatform({ force })
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return false
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const provisionService = async function (siteId, api) {
|
|
30
|
-
const addonName = 'large-media'
|
|
31
|
-
|
|
32
|
-
if (!siteId) {
|
|
33
|
-
throw new Error('No site id found, please run inside a site folder or `netlify link`')
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
await api.createServiceInstance({
|
|
37
|
-
siteId,
|
|
38
|
-
addon: addonName,
|
|
39
|
-
body: {},
|
|
40
|
-
})
|
|
41
|
-
} catch (error_) {
|
|
42
|
-
// error is JSONHTTPError
|
|
43
|
-
throw new Error(error_.json.error)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const configureLFSURL = async function (siteId, api) {
|
|
48
|
-
const siteInfo = await api.getSite({ siteId })
|
|
49
|
-
const url = `https://${siteInfo.id_domain}/.netlify/large-media`
|
|
50
|
-
|
|
51
|
-
return execa('git', ['config', '-f', '.lfsconfig', 'lfs.url', url])
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
class LmSetupCommand extends Command {
|
|
55
|
-
async run() {
|
|
56
|
-
await this.authenticate()
|
|
57
|
-
|
|
58
|
-
const { flags } = this.parse(LmSetupCommand)
|
|
59
|
-
const { api, site } = this.netlify
|
|
60
|
-
|
|
61
|
-
let helperInstalled = false
|
|
62
|
-
if (!flags['skip-install']) {
|
|
63
|
-
try {
|
|
64
|
-
helperInstalled = await installHelperIfMissing({ force: flags['force-install'] })
|
|
65
|
-
} catch (error_) {
|
|
66
|
-
error(error_)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const tasks = new Listr([
|
|
71
|
-
{
|
|
72
|
-
title: 'Provisioning Netlify Large Media',
|
|
73
|
-
async task() {
|
|
74
|
-
await provisionService(site.id, api)
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
title: 'Configuring Git LFS for this site',
|
|
79
|
-
async task() {
|
|
80
|
-
await configureLFSURL(site.id, api)
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
])
|
|
84
|
-
await tasks.run().catch(() => {})
|
|
85
|
-
|
|
86
|
-
if (helperInstalled) {
|
|
87
|
-
printBanner(this, flags['force-install'])
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
LmSetupCommand.flags = {
|
|
93
|
-
'skip-install': flagsLib.boolean({
|
|
94
|
-
char: 's',
|
|
95
|
-
description: 'Skip the credentials helper installation check',
|
|
96
|
-
}),
|
|
97
|
-
'force-install': flagsLib.boolean({
|
|
98
|
-
char: 'f',
|
|
99
|
-
description: 'Force the credentials helper installation',
|
|
100
|
-
}),
|
|
101
|
-
...LmSetupCommand.flags,
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
LmSetupCommand.description = `Configures your site to use Netlify Large Media.
|
|
105
|
-
It runs the install command if you have not installed the dependencies yet.`
|
|
106
|
-
|
|
107
|
-
module.exports = LmSetupCommand
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const Command = require('../../utils/command')
|
|
2
|
-
const { uninstall } = require('../../utils/lm/install')
|
|
3
|
-
|
|
4
|
-
class LmUninstallCommand extends Command {
|
|
5
|
-
async run() {
|
|
6
|
-
this.parse(LmUninstallCommand)
|
|
7
|
-
await uninstall()
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
LmUninstallCommand.aliases = ['lm:remove']
|
|
12
|
-
LmUninstallCommand.hidden = true
|
|
13
|
-
|
|
14
|
-
LmUninstallCommand.description =
|
|
15
|
-
'Uninstalls Netlify git credentials helper and cleans up any related configuration changes made by the install command.'
|
|
16
|
-
|
|
17
|
-
module.exports = LmUninstallCommand
|
package/src/commands/login.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const { flags: flagsLib } = require('@oclif/command')
|
|
2
|
-
const chalk = require('chalk')
|
|
3
|
-
|
|
4
|
-
const Command = require('../utils/command')
|
|
5
|
-
const { exit, getToken, log } = require('../utils/command-helpers')
|
|
6
|
-
|
|
7
|
-
class LoginCommand extends Command {
|
|
8
|
-
async run() {
|
|
9
|
-
const [accessToken, location] = await getToken()
|
|
10
|
-
const { flags } = this.parse(LoginCommand)
|
|
11
|
-
|
|
12
|
-
this.setAnalyticsPayload({ new: flags.new })
|
|
13
|
-
|
|
14
|
-
if (accessToken && !flags.new) {
|
|
15
|
-
log(`Already logged in ${msg(location)}`)
|
|
16
|
-
log()
|
|
17
|
-
log(`Run ${chalk.cyanBright('netlify status')} for account details`)
|
|
18
|
-
log()
|
|
19
|
-
log(`To see all available commands run: ${chalk.cyanBright('netlify help')}`)
|
|
20
|
-
log()
|
|
21
|
-
return exit()
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
await this.expensivelyAuthenticate()
|
|
25
|
-
|
|
26
|
-
return exit()
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const msg = function (location) {
|
|
31
|
-
switch (location) {
|
|
32
|
-
case 'env':
|
|
33
|
-
return 'via process.env.NETLIFY_AUTH_TOKEN set in your terminal session'
|
|
34
|
-
case 'flag':
|
|
35
|
-
return 'via CLI --auth flag'
|
|
36
|
-
case 'config':
|
|
37
|
-
return 'via netlify config on your machine'
|
|
38
|
-
default:
|
|
39
|
-
return ''
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
LoginCommand.flags = {
|
|
44
|
-
new: flagsLib.boolean({
|
|
45
|
-
description: 'Login to new Netlify account',
|
|
46
|
-
}),
|
|
47
|
-
...LoginCommand.flags,
|
|
48
|
-
}
|
|
49
|
-
LoginCommand.description = `Login to your Netlify account
|
|
50
|
-
|
|
51
|
-
Opens a web browser to acquire an OAuth token.
|
|
52
|
-
`
|
|
53
|
-
|
|
54
|
-
module.exports = LoginCommand
|
package/src/commands/logout.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const Command = require('../utils/command')
|
|
2
|
-
const { exit, getToken, log } = require('../utils/command-helpers')
|
|
3
|
-
const { track } = require('../utils/telemetry')
|
|
4
|
-
|
|
5
|
-
class LogoutCommand extends Command {
|
|
6
|
-
async run() {
|
|
7
|
-
const [accessToken, location] = await getToken()
|
|
8
|
-
|
|
9
|
-
if (!accessToken) {
|
|
10
|
-
log(`Already logged out`)
|
|
11
|
-
log()
|
|
12
|
-
log('To login run "netlify login"')
|
|
13
|
-
exit()
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
await track('user_logout')
|
|
17
|
-
|
|
18
|
-
// unset userID without deleting key
|
|
19
|
-
this.netlify.globalConfig.set('userId', null)
|
|
20
|
-
|
|
21
|
-
if (location === 'env') {
|
|
22
|
-
log('The "process.env.NETLIFY_AUTH_TOKEN" is still set in your terminal session')
|
|
23
|
-
log()
|
|
24
|
-
log('To logout completely, unset the environment variable')
|
|
25
|
-
log()
|
|
26
|
-
exit()
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
log(`Logging you out of Netlify. Come back soon!`)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
LogoutCommand.description = `Logout of your Netlify account`
|
|
34
|
-
|
|
35
|
-
LogoutCommand.hidden = true
|
|
36
|
-
|
|
37
|
-
module.exports = LogoutCommand
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
const Command = require('../../utils/command')
|
|
2
|
-
const { error, exit, log, warn } = require('../../utils/command-helpers')
|
|
3
|
-
const { openBrowser } = require('../../utils/open-browser')
|
|
4
|
-
|
|
5
|
-
class OpenAdminCommand extends Command {
|
|
6
|
-
async run() {
|
|
7
|
-
const { api, site } = this.netlify
|
|
8
|
-
|
|
9
|
-
await this.authenticate()
|
|
10
|
-
|
|
11
|
-
const siteId = site.id
|
|
12
|
-
|
|
13
|
-
if (!siteId) {
|
|
14
|
-
warn(`No Site ID found in current directory.
|
|
15
|
-
Run \`netlify link\` to connect to this folder to a site`)
|
|
16
|
-
return false
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let siteData
|
|
20
|
-
try {
|
|
21
|
-
siteData = await api.getSite({ siteId })
|
|
22
|
-
log(`Opening "${siteData.name}" site admin UI:`)
|
|
23
|
-
log(`> ${siteData.admin_url}`)
|
|
24
|
-
} catch (error_) {
|
|
25
|
-
// unauthorized
|
|
26
|
-
if (error_.status === 401) {
|
|
27
|
-
warn(`Log in with a different account or re-link to a site you have permission for`)
|
|
28
|
-
error(`Not authorized to view the currently linked site (${siteId})`)
|
|
29
|
-
}
|
|
30
|
-
// site not found
|
|
31
|
-
if (error_.status === 404) {
|
|
32
|
-
log()
|
|
33
|
-
log('Please double check this ID and verify you are logged in with the correct account')
|
|
34
|
-
log()
|
|
35
|
-
log('To fix this, run `netlify unlink` then `netlify link` to reconnect to the correct site ID')
|
|
36
|
-
log()
|
|
37
|
-
error(`Site "${siteId}" not found in account`)
|
|
38
|
-
}
|
|
39
|
-
error(error_)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
await openBrowser({ url: siteData.admin_url })
|
|
43
|
-
exit()
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
OpenAdminCommand.description = `Opens current site admin UI in Netlify`
|
|
48
|
-
|
|
49
|
-
OpenAdminCommand.examples = ['netlify open:admin']
|
|
50
|
-
|
|
51
|
-
module.exports = OpenAdminCommand
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const Command = require('../../utils/command')
|
|
2
|
-
const { error, exit, log, warn } = require('../../utils/command-helpers')
|
|
3
|
-
const { openBrowser } = require('../../utils/open-browser')
|
|
4
|
-
|
|
5
|
-
class OpenAdminCommand extends Command {
|
|
6
|
-
async run() {
|
|
7
|
-
const { api, site } = this.netlify
|
|
8
|
-
await this.authenticate()
|
|
9
|
-
|
|
10
|
-
const siteId = site.id
|
|
11
|
-
|
|
12
|
-
if (!siteId) {
|
|
13
|
-
warn(`No Site ID found in current directory.
|
|
14
|
-
Run \`netlify link\` to connect to this folder to a site`)
|
|
15
|
-
return false
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let siteData
|
|
19
|
-
let url
|
|
20
|
-
try {
|
|
21
|
-
siteData = await api.getSite({ siteId })
|
|
22
|
-
url = siteData.ssl_url || siteData.url
|
|
23
|
-
log(`Opening "${siteData.name}" site url:`)
|
|
24
|
-
log(`> ${url}`)
|
|
25
|
-
} catch (error_) {
|
|
26
|
-
// unauthorized
|
|
27
|
-
if (error_.status === 401) {
|
|
28
|
-
warn(`Log in with a different account or re-link to a site you have permission for`)
|
|
29
|
-
error(`Not authorized to view the currently linked site (${siteId})`)
|
|
30
|
-
}
|
|
31
|
-
error(error_)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
await openBrowser({ url })
|
|
35
|
-
exit()
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
OpenAdminCommand.description = `Opens current site url in browser`
|
|
40
|
-
|
|
41
|
-
OpenAdminCommand.examples = ['netlify open:site']
|
|
42
|
-
|
|
43
|
-
module.exports = OpenAdminCommand
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
const { flags: flagsLib } = require('@oclif/command')
|
|
2
|
-
const slugify = require('@sindresorhus/slugify')
|
|
3
|
-
const chalk = require('chalk')
|
|
4
|
-
const inquirer = require('inquirer')
|
|
5
|
-
const pick = require('lodash/pick')
|
|
6
|
-
const sample = require('lodash/sample')
|
|
7
|
-
const prettyjson = require('prettyjson')
|
|
8
|
-
const { v4: uuidv4 } = require('uuid')
|
|
9
|
-
|
|
10
|
-
const Command = require('../../utils/command')
|
|
11
|
-
const { error, log, logJson, warn } = require('../../utils/command-helpers')
|
|
12
|
-
const { getRepoData } = require('../../utils/get-repo-data')
|
|
13
|
-
const { configureRepo } = require('../../utils/init/config')
|
|
14
|
-
const { track } = require('../../utils/telemetry')
|
|
15
|
-
|
|
16
|
-
const SITE_NAME_SUGGESTION_SUFFIX_LENGTH = 5
|
|
17
|
-
|
|
18
|
-
class SitesCreateCommand extends Command {
|
|
19
|
-
async run() {
|
|
20
|
-
const { flags } = this.parse(SitesCreateCommand)
|
|
21
|
-
const { api } = this.netlify
|
|
22
|
-
|
|
23
|
-
await this.authenticate()
|
|
24
|
-
|
|
25
|
-
const accounts = await api.listAccountsForUser()
|
|
26
|
-
|
|
27
|
-
let accountSlug = flags['account-slug']
|
|
28
|
-
if (!accountSlug) {
|
|
29
|
-
const { accountSlug: accountSlugInput } = await inquirer.prompt([
|
|
30
|
-
{
|
|
31
|
-
type: 'list',
|
|
32
|
-
name: 'accountSlug',
|
|
33
|
-
message: 'Team:',
|
|
34
|
-
choices: accounts.map((account) => ({
|
|
35
|
-
value: account.slug,
|
|
36
|
-
name: account.name,
|
|
37
|
-
})),
|
|
38
|
-
},
|
|
39
|
-
])
|
|
40
|
-
accountSlug = accountSlugInput
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const { name: nameFlag } = flags
|
|
44
|
-
let user
|
|
45
|
-
let site
|
|
46
|
-
|
|
47
|
-
// Allow the user to reenter site name if selected one isn't available
|
|
48
|
-
const inputSiteName = async (name) => {
|
|
49
|
-
if (!user) user = await api.getCurrentUser()
|
|
50
|
-
|
|
51
|
-
if (!name) {
|
|
52
|
-
let { slug } = user
|
|
53
|
-
let suffix = ''
|
|
54
|
-
|
|
55
|
-
// If the user doesn't have a slug, we'll compute one. Because `full_name` is not guaranteed to be unique, we
|
|
56
|
-
// append a short randomly-generated ID to reduce the likelihood of a conflict.
|
|
57
|
-
if (!slug) {
|
|
58
|
-
slug = slugify(user.full_name || user.email)
|
|
59
|
-
suffix = `-${uuidv4().slice(0, SITE_NAME_SUGGESTION_SUFFIX_LENGTH)}`
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const suggestions = [
|
|
63
|
-
`super-cool-site-by-${slug}${suffix}`,
|
|
64
|
-
`the-awesome-${slug}-site${suffix}`,
|
|
65
|
-
`${slug}-makes-great-sites${suffix}`,
|
|
66
|
-
`netlify-thinks-${slug}-is-great${suffix}`,
|
|
67
|
-
`the-great-${slug}-site${suffix}`,
|
|
68
|
-
`isnt-${slug}-awesome${suffix}`,
|
|
69
|
-
]
|
|
70
|
-
const siteSuggestion = sample(suggestions)
|
|
71
|
-
|
|
72
|
-
console.log(
|
|
73
|
-
`Choose a unique site name (e.g. ${siteSuggestion}.netlify.app) or leave it blank for a random name. You can update the site name later.`,
|
|
74
|
-
)
|
|
75
|
-
const { name: nameInput } = await inquirer.prompt([
|
|
76
|
-
{
|
|
77
|
-
type: 'input',
|
|
78
|
-
name: 'name',
|
|
79
|
-
message: 'Site name (optional):',
|
|
80
|
-
filter: (val) => (val === '' ? undefined : val),
|
|
81
|
-
validate: (input) => /^[a-zA-Z\d-]+$/.test(input) || 'Only alphanumeric characters and hyphens are allowed',
|
|
82
|
-
},
|
|
83
|
-
])
|
|
84
|
-
name = nameInput
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const body = {}
|
|
88
|
-
if (typeof name === 'string') {
|
|
89
|
-
body.name = name.trim()
|
|
90
|
-
}
|
|
91
|
-
try {
|
|
92
|
-
site = await api.createSiteInTeam({
|
|
93
|
-
accountSlug,
|
|
94
|
-
body,
|
|
95
|
-
})
|
|
96
|
-
} catch (error_) {
|
|
97
|
-
if (error_.status === 422) {
|
|
98
|
-
warn(`${name}.netlify.app already exists. Please try a different slug.`)
|
|
99
|
-
await inputSiteName()
|
|
100
|
-
} else {
|
|
101
|
-
error(`createSiteInTeam error: ${error_.status}: ${error_.message}`)
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
await inputSiteName(nameFlag)
|
|
106
|
-
|
|
107
|
-
log()
|
|
108
|
-
log(chalk.greenBright.bold.underline(`Site Created`))
|
|
109
|
-
log()
|
|
110
|
-
|
|
111
|
-
const siteUrl = site.ssl_url || site.url
|
|
112
|
-
log(
|
|
113
|
-
prettyjson.render({
|
|
114
|
-
'Admin URL': site.admin_url,
|
|
115
|
-
URL: siteUrl,
|
|
116
|
-
'Site ID': site.id,
|
|
117
|
-
}),
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
track('sites_created', {
|
|
121
|
-
siteId: site.id,
|
|
122
|
-
adminUrl: site.admin_url,
|
|
123
|
-
siteUrl,
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
if (flags['with-ci']) {
|
|
127
|
-
log('Configuring CI')
|
|
128
|
-
const repoData = await getRepoData()
|
|
129
|
-
await configureRepo({ context: this, siteId: site.id, repoData, manual: flags.manual })
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (flags.json) {
|
|
133
|
-
logJson(
|
|
134
|
-
pick(site, [
|
|
135
|
-
'id',
|
|
136
|
-
'state',
|
|
137
|
-
'plan',
|
|
138
|
-
'name',
|
|
139
|
-
'custom_domain',
|
|
140
|
-
'domain_aliases',
|
|
141
|
-
'url',
|
|
142
|
-
'ssl_url',
|
|
143
|
-
'admin_url',
|
|
144
|
-
'screenshot_url',
|
|
145
|
-
'created_at',
|
|
146
|
-
'updated_at',
|
|
147
|
-
'user_id',
|
|
148
|
-
'ssl',
|
|
149
|
-
'force_ssl',
|
|
150
|
-
'managed_dns',
|
|
151
|
-
'deploy_url',
|
|
152
|
-
'account_name',
|
|
153
|
-
'account_slug',
|
|
154
|
-
'git_provider',
|
|
155
|
-
'deploy_hook',
|
|
156
|
-
'capabilities',
|
|
157
|
-
'id_domain',
|
|
158
|
-
]),
|
|
159
|
-
)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return site
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
SitesCreateCommand.description = `Create an empty site (advanced)
|
|
167
|
-
|
|
168
|
-
Create a blank site that isn't associated with any git remote. Does not link to the current working directory.
|
|
169
|
-
`
|
|
170
|
-
|
|
171
|
-
SitesCreateCommand.flags = {
|
|
172
|
-
name: flagsLib.string({
|
|
173
|
-
char: 'n',
|
|
174
|
-
description: 'name of site',
|
|
175
|
-
}),
|
|
176
|
-
'account-slug': flagsLib.string({
|
|
177
|
-
char: 'a',
|
|
178
|
-
description: 'account slug to create the site under',
|
|
179
|
-
}),
|
|
180
|
-
'with-ci': flagsLib.boolean({
|
|
181
|
-
char: 'c',
|
|
182
|
-
description: 'initialize CI hooks during site creation',
|
|
183
|
-
}),
|
|
184
|
-
manual: flagsLib.boolean({
|
|
185
|
-
char: 'm',
|
|
186
|
-
description: 'Force manual CI setup. Used --with-ci flag',
|
|
187
|
-
}),
|
|
188
|
-
...SitesCreateCommand.flags,
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
module.exports = SitesCreateCommand
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
const { flags: flagsLib } = require('@oclif/command')
|
|
2
|
-
const chalk = require('chalk')
|
|
3
|
-
const inquirer = require('inquirer')
|
|
4
|
-
|
|
5
|
-
const Command = require('../../utils/command')
|
|
6
|
-
const { error, exit, log } = require('../../utils/command-helpers')
|
|
7
|
-
const { parseRawFlags } = require('../../utils/parse-raw-flags')
|
|
8
|
-
|
|
9
|
-
class SitesDeleteCommand extends Command {
|
|
10
|
-
async run() {
|
|
11
|
-
const { args, flags, raw } = this.parse(SitesDeleteCommand)
|
|
12
|
-
|
|
13
|
-
this.setAnalyticsPayload({ force: flags.force })
|
|
14
|
-
|
|
15
|
-
const { api, site } = this.netlify
|
|
16
|
-
const { siteId } = args
|
|
17
|
-
const cwdSiteId = site.id
|
|
18
|
-
|
|
19
|
-
// 1. Prompt user for verification
|
|
20
|
-
await this.authenticate(flags.auth)
|
|
21
|
-
|
|
22
|
-
let siteData
|
|
23
|
-
try {
|
|
24
|
-
siteData = await api.getSite({ siteId })
|
|
25
|
-
} catch (error_) {
|
|
26
|
-
if (error_.status === 404) {
|
|
27
|
-
error(`No site with id ${siteId} found. Please verify the siteId & try again.`)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (!siteData) {
|
|
32
|
-
error(`Unable to process site`)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const rawFlags = parseRawFlags(raw)
|
|
36
|
-
const noForce = !rawFlags.force && !rawFlags.f
|
|
37
|
-
|
|
38
|
-
/* Verify the user wants to delete the site */
|
|
39
|
-
if (noForce) {
|
|
40
|
-
log(`${chalk.redBright('Warning')}: You are about to permanently delete "${chalk.bold(siteData.name)}"`)
|
|
41
|
-
log(` Verify this siteID "${siteId}" supplied is correct and proceed.`)
|
|
42
|
-
log(' To skip this prompt, pass a --force flag to the delete command')
|
|
43
|
-
log()
|
|
44
|
-
log(`${chalk.bold('Be careful here. There is no undo!')}`)
|
|
45
|
-
log()
|
|
46
|
-
const { wantsToDelete } = await inquirer.prompt({
|
|
47
|
-
type: 'confirm',
|
|
48
|
-
name: 'wantsToDelete',
|
|
49
|
-
message: `WARNING: Are you sure you want to delete the "${siteData.name}" site?`,
|
|
50
|
-
default: false,
|
|
51
|
-
})
|
|
52
|
-
log()
|
|
53
|
-
if (!wantsToDelete) {
|
|
54
|
-
exit()
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/* Validation logic if siteId passed in does not match current site ID */
|
|
59
|
-
if (noForce && cwdSiteId && cwdSiteId !== siteId) {
|
|
60
|
-
log(`${chalk.redBright('Warning')}: The siteId supplied does not match the current working directory siteId`)
|
|
61
|
-
log()
|
|
62
|
-
log(`Supplied: "${siteId}"`)
|
|
63
|
-
log(`Current Site: "${cwdSiteId}"`)
|
|
64
|
-
log()
|
|
65
|
-
log(`Verify this siteID "${siteId}" supplied is correct and proceed.`)
|
|
66
|
-
log('To skip this prompt, pass a --force flag to the delete command')
|
|
67
|
-
const { wantsToDelete } = await inquirer.prompt({
|
|
68
|
-
type: 'confirm',
|
|
69
|
-
name: 'wantsToDelete',
|
|
70
|
-
message: `Verify & Proceed with deletion of site "${siteId}"?`,
|
|
71
|
-
default: false,
|
|
72
|
-
})
|
|
73
|
-
if (!wantsToDelete) {
|
|
74
|
-
exit()
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
log(`Deleting site "${siteId}"...`)
|
|
79
|
-
|
|
80
|
-
try {
|
|
81
|
-
await api.deleteSite({ site_id: siteId })
|
|
82
|
-
} catch (error_) {
|
|
83
|
-
if (error_.status === 404) {
|
|
84
|
-
error(`No site with id ${siteId} found. Please verify the siteId & try again.`)
|
|
85
|
-
} else {
|
|
86
|
-
error(`Delete Site error: ${error_.status}: ${error_.message}`)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
log(`Site "${siteId}" successfully deleted!`)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
SitesDeleteCommand.description = `Delete a site
|
|
94
|
-
|
|
95
|
-
This command will permanently delete the site on Netlify. Use with caution.
|
|
96
|
-
`
|
|
97
|
-
|
|
98
|
-
SitesDeleteCommand.args = [
|
|
99
|
-
{
|
|
100
|
-
name: 'siteId',
|
|
101
|
-
required: true,
|
|
102
|
-
description: 'Site ID to delete.',
|
|
103
|
-
},
|
|
104
|
-
]
|
|
105
|
-
|
|
106
|
-
SitesDeleteCommand.flags = {
|
|
107
|
-
force: flagsLib.boolean({
|
|
108
|
-
char: 'f',
|
|
109
|
-
description: 'delete without prompting (useful for CI)',
|
|
110
|
-
}),
|
|
111
|
-
...SitesDeleteCommand.flags,
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
SitesDeleteCommand.examples = ['netlify sites:delete 1234-3262-1211']
|
|
115
|
-
|
|
116
|
-
module.exports = SitesDeleteCommand
|