netlify-cli 8.0.13 → 8.1.0-rc.2
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 +12 -13
- package/bin/run +38 -2
- package/npm-shrinkwrap.json +260 -6244
- package/package.json +13 -35
- 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 +131 -0
- package/src/commands/addons/addons-delete.js +60 -0
- package/src/commands/addons/addons-list.js +62 -0
- package/src/commands/addons/addons.js +44 -0
- package/src/commands/addons/index.js +3 -24
- package/src/commands/api/api.js +75 -0
- package/src/commands/api/index.js +5 -0
- package/src/commands/base-command.js +509 -0
- package/src/commands/build/build.js +58 -0
- package/src/commands/build/index.js +3 -61
- package/src/commands/completion/completion.js +36 -0
- package/src/commands/completion/index.js +5 -0
- package/src/commands/{deploy.js → deploy/deploy.js} +295 -275
- package/src/commands/deploy/index.js +5 -0
- package/src/commands/dev/dev-exec.js +35 -0
- package/src/commands/dev/dev-trace.js +47 -0
- package/src/commands/dev/dev.js +340 -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 +42 -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} +130 -94
- package/src/commands/functions/functions-invoke.js +273 -0
- package/src/commands/functions/functions-list.js +106 -0
- package/src/commands/functions/functions-serve.js +63 -0
- package/src/commands/functions/functions.js +47 -0
- package/src/commands/functions/index.js +3 -45
- package/src/commands/index.js +7 -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} +141 -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 +33 -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 +34 -0
- package/src/commands/login/index.js +6 -0
- package/src/commands/login/login.js +55 -0
- package/src/commands/logout/index.js +5 -0
- package/src/commands/logout/logout.js +43 -0
- package/src/commands/main.js +188 -0
- package/src/commands/open/index.js +3 -39
- package/src/commands/open/open-admin.js +60 -0
- package/src/commands/open/open-site.js +53 -0
- package/src/commands/open/open.js +38 -0
- package/src/commands/sites/index.js +5 -20
- package/src/commands/sites/sites-create.js +187 -0
- package/src/commands/sites/sites-delete.js +104 -0
- package/src/commands/sites/sites-list.js +89 -0
- package/src/commands/sites/sites.js +32 -0
- package/src/commands/status/index.js +3 -118
- package/src/commands/status/status-hooks.js +69 -0
- package/src/commands/status/status.js +124 -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 +5 -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 +116 -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/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 +2 -4
- 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 +3 -5
- 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 -261
- package/src/utils/detect-functions-builder.js +0 -25
- package/src/utils/difference.js +0 -4
- package/src/utils/header.js +0 -18
- package/src/utils/logo.js +0 -11
- package/src/utils/show-help.js +0 -5
- package/src/utils/telemetry/tracked-command.js +0 -51
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
const { join } = require('path')
|
|
2
|
-
|
|
3
|
-
const { flags: flagsLib } = require('@oclif/command')
|
|
4
|
-
|
|
5
|
-
const { startFunctionsServer } = require('../../lib/functions/server')
|
|
6
|
-
const Command = require('../../utils/command')
|
|
7
|
-
const { acquirePort, getSiteInformation, injectEnvVariables } = require('../../utils/dev')
|
|
8
|
-
const { getFunctionsDir } = require('../../utils/functions')
|
|
9
|
-
|
|
10
|
-
const DEFAULT_PORT = 9999
|
|
11
|
-
|
|
12
|
-
class FunctionsServeCommand extends Command {
|
|
13
|
-
async run() {
|
|
14
|
-
const { flags } = this.parse(FunctionsServeCommand)
|
|
15
|
-
|
|
16
|
-
const { netlify } = this
|
|
17
|
-
const { api, config, site, siteInfo } = netlify
|
|
18
|
-
|
|
19
|
-
const functionsDir = getFunctionsDir({ flags, config }, join('netlify', 'functions'))
|
|
20
|
-
|
|
21
|
-
await injectEnvVariables({ env: this.netlify.cachedConfig.env, site })
|
|
22
|
-
|
|
23
|
-
const { capabilities, siteUrl, timeouts } = await getSiteInformation({
|
|
24
|
-
flags,
|
|
25
|
-
api,
|
|
26
|
-
site,
|
|
27
|
-
siteInfo,
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const functionsPort = await acquirePort({
|
|
31
|
-
configuredPort: flags.port || (config.dev && config.dev.functionsPort),
|
|
32
|
-
defaultPort: DEFAULT_PORT,
|
|
33
|
-
errorMessage: 'Could not acquire configured functions port',
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
await startFunctionsServer({
|
|
37
|
-
config,
|
|
38
|
-
settings: { functions: functionsDir, functionsPort },
|
|
39
|
-
site,
|
|
40
|
-
siteUrl,
|
|
41
|
-
capabilities,
|
|
42
|
-
timeouts,
|
|
43
|
-
functionsPrefix: '/.netlify/functions/',
|
|
44
|
-
buildersPrefix: '/.netlify/builders/',
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
FunctionsServeCommand.description = `(Beta) Serve functions locally
|
|
50
|
-
|
|
51
|
-
Helpful for debugging functions.
|
|
52
|
-
`
|
|
53
|
-
FunctionsServeCommand.aliases = ['function:serve']
|
|
54
|
-
FunctionsServeCommand.flags = {
|
|
55
|
-
functions: flagsLib.string({
|
|
56
|
-
char: 'f',
|
|
57
|
-
description: 'Specify a functions directory to serve',
|
|
58
|
-
}),
|
|
59
|
-
port: flagsLib.integer({
|
|
60
|
-
char: 'p',
|
|
61
|
-
description: 'Specify a port for the functions server',
|
|
62
|
-
}),
|
|
63
|
-
offline: flagsLib.boolean({
|
|
64
|
-
char: 'o',
|
|
65
|
-
description: 'disables any features that require network access',
|
|
66
|
-
}),
|
|
67
|
-
...FunctionsServeCommand.flags,
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
module.exports = FunctionsServeCommand
|
package/src/commands/link.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const process = require('process')
|
|
3
|
-
|
|
4
|
-
const { flags: flagsLib } = require('@oclif/command')
|
|
5
|
-
const chalk = require('chalk')
|
|
6
|
-
|
|
7
|
-
const { listSites } = require('../lib/api')
|
|
8
|
-
const Command = require('../utils/command')
|
|
9
|
-
const { error, exit, log } = require('../utils/command-helpers')
|
|
10
|
-
const ensureNetlifyIgnore = require('../utils/gitignore')
|
|
11
|
-
const linkPrompt = require('../utils/link/link-by-prompt')
|
|
12
|
-
const { track } = require('../utils/telemetry')
|
|
13
|
-
|
|
14
|
-
class LinkCommand extends Command {
|
|
15
|
-
async run() {
|
|
16
|
-
await this.authenticate()
|
|
17
|
-
|
|
18
|
-
const { flags } = this.parse(LinkCommand)
|
|
19
|
-
const {
|
|
20
|
-
api,
|
|
21
|
-
repositoryRoot,
|
|
22
|
-
site: { id: siteId },
|
|
23
|
-
state,
|
|
24
|
-
} = this.netlify
|
|
25
|
-
|
|
26
|
-
let siteData
|
|
27
|
-
try {
|
|
28
|
-
siteData = await api.getSite({ siteId })
|
|
29
|
-
} catch {
|
|
30
|
-
// silent api error
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Add .netlify to .gitignore file
|
|
34
|
-
await ensureNetlifyIgnore(repositoryRoot)
|
|
35
|
-
|
|
36
|
-
// Site id is incorrect
|
|
37
|
-
if (siteId && !siteData) {
|
|
38
|
-
console.log(`"${siteId}" was not found in your Netlify account.`)
|
|
39
|
-
console.log(`Please double check your siteID and which account you are logged into via \`netlify status\`.`)
|
|
40
|
-
return exit()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// If already linked to site. exit and prompt for unlink
|
|
44
|
-
if (siteData) {
|
|
45
|
-
log(`Site already linked to "${siteData.name}"`)
|
|
46
|
-
log(`Admin url: ${siteData.admin_url}`)
|
|
47
|
-
log()
|
|
48
|
-
log(`To unlink this site, run: ${chalk.cyanBright('netlify unlink')}`)
|
|
49
|
-
return exit()
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (flags.id) {
|
|
53
|
-
try {
|
|
54
|
-
siteData = await api.getSite({ site_id: flags.id })
|
|
55
|
-
} catch (error_) {
|
|
56
|
-
if (error_.status === 404) {
|
|
57
|
-
error(new Error(`Site id ${flags.id} not found`))
|
|
58
|
-
} else {
|
|
59
|
-
error(error_)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Save site ID
|
|
64
|
-
state.set('siteId', siteData.id)
|
|
65
|
-
log(`Linked to ${siteData.name} in ${state.path}`)
|
|
66
|
-
|
|
67
|
-
await track('sites_linked', {
|
|
68
|
-
siteId: siteData.id,
|
|
69
|
-
linkType: 'manual',
|
|
70
|
-
kind: 'byId',
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
return exit()
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (flags.name) {
|
|
77
|
-
let results
|
|
78
|
-
try {
|
|
79
|
-
results = await listSites({
|
|
80
|
-
api,
|
|
81
|
-
options: {
|
|
82
|
-
name: flags.name,
|
|
83
|
-
filter: 'all',
|
|
84
|
-
},
|
|
85
|
-
})
|
|
86
|
-
} catch (error_) {
|
|
87
|
-
if (error_.status === 404) {
|
|
88
|
-
error(new Error(`${flags.name} not found`))
|
|
89
|
-
} else {
|
|
90
|
-
error(error_)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (results.length === 0) {
|
|
95
|
-
error(new Error(`No sites found named ${flags.name}`))
|
|
96
|
-
}
|
|
97
|
-
const [firstSiteData] = results
|
|
98
|
-
state.set('siteId', firstSiteData.id)
|
|
99
|
-
|
|
100
|
-
log(`Linked to ${firstSiteData.name} in ${path.relative(path.join(process.cwd(), '..'), state.path)}`)
|
|
101
|
-
|
|
102
|
-
await track('sites_linked', {
|
|
103
|
-
siteId: (firstSiteData && firstSiteData.id) || siteId,
|
|
104
|
-
linkType: 'manual',
|
|
105
|
-
kind: 'byName',
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
return exit()
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
siteData = await linkPrompt(this, flags)
|
|
112
|
-
return siteData
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
LinkCommand.description = `Link a local repo or project folder to an existing site on Netlify`
|
|
117
|
-
|
|
118
|
-
LinkCommand.examples = ['netlify link', 'netlify link --id 123-123-123-123', 'netlify link --name my-site-name']
|
|
119
|
-
|
|
120
|
-
LinkCommand.flags = {
|
|
121
|
-
id: flagsLib.string({
|
|
122
|
-
description: 'ID of site to link to',
|
|
123
|
-
}),
|
|
124
|
-
name: flagsLib.string({
|
|
125
|
-
description: 'Name of site to link to',
|
|
126
|
-
}),
|
|
127
|
-
gitRemoteName: flagsLib.string({
|
|
128
|
-
description: 'Name of Git remote to use. e.g. "origin"',
|
|
129
|
-
}),
|
|
130
|
-
...LinkCommand.flags,
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
module.exports = LinkCommand
|
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
|