netlify-cli 8.0.10 → 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 +471 -2182
- package/package.json +12 -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 +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 +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 +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 +7 -5
- package/src/utils/read-repo-url.js +1 -0
- package/src/utils/redirects.js +2 -2
- package/src/utils/rules-proxy.js +4 -2
- 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/logo.js +0 -11
- package/src/utils/show-help.js +0 -5
- package/src/utils/telemetry/tracked-command.js +0 -51
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
const { flags: flagsLib } = require('@oclif/command')
|
|
2
|
-
const chalk = require('chalk')
|
|
3
|
-
const { cli } = require('cli-ux')
|
|
4
|
-
|
|
5
|
-
const { listSites } = require('../../lib/api')
|
|
6
|
-
const Command = require('../../utils/command')
|
|
7
|
-
const { log, logJson } = require('../../utils/command-helpers')
|
|
8
|
-
|
|
9
|
-
class SitesListCommand extends Command {
|
|
10
|
-
async run() {
|
|
11
|
-
const { flags } = this.parse(SitesListCommand)
|
|
12
|
-
|
|
13
|
-
const { api } = this.netlify
|
|
14
|
-
if (!flags.json) {
|
|
15
|
-
cli.action.start('Loading your sites')
|
|
16
|
-
}
|
|
17
|
-
await this.authenticate()
|
|
18
|
-
|
|
19
|
-
const sites = await listSites({ api, options: { filter: 'all' } })
|
|
20
|
-
if (!flags.json) {
|
|
21
|
-
cli.action.stop()
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (sites && sites.length !== 0) {
|
|
25
|
-
const logSites = sites.map((site) => {
|
|
26
|
-
const siteInfo = {
|
|
27
|
-
id: site.id,
|
|
28
|
-
name: site.name,
|
|
29
|
-
ssl_url: site.ssl_url,
|
|
30
|
-
account_name: site.account_name,
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (site.build_settings && site.build_settings.repo_url) {
|
|
34
|
-
siteInfo.repo_url = site.build_settings.repo_url
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return siteInfo
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
// Json response for piping commands
|
|
41
|
-
if (flags.json) {
|
|
42
|
-
const redactedSites = sites.map((site) => {
|
|
43
|
-
if (site && site.build_settings) {
|
|
44
|
-
delete site.build_settings.env
|
|
45
|
-
}
|
|
46
|
-
return site
|
|
47
|
-
})
|
|
48
|
-
logJson(redactedSites)
|
|
49
|
-
return false
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
log(`
|
|
53
|
-
────────────────────────────┐
|
|
54
|
-
Current Netlify Sites │
|
|
55
|
-
────────────────────────────┘
|
|
56
|
-
|
|
57
|
-
Count: ${logSites.length}
|
|
58
|
-
`)
|
|
59
|
-
|
|
60
|
-
logSites.forEach((logSite) => {
|
|
61
|
-
log(`${chalk.greenBright(logSite.name)} - ${logSite.id}`)
|
|
62
|
-
log(` ${chalk.whiteBright.bold('url:')} ${chalk.yellowBright(logSite.ssl_url)}`)
|
|
63
|
-
if (logSite.repo_url) {
|
|
64
|
-
log(` ${chalk.whiteBright.bold('repo:')} ${chalk.white(logSite.repo_url)}`)
|
|
65
|
-
}
|
|
66
|
-
if (logSite.account_name) {
|
|
67
|
-
log(` ${chalk.whiteBright.bold('account:')} ${chalk.white(logSite.account_name)}`)
|
|
68
|
-
}
|
|
69
|
-
log(`─────────────────────────────────────────────────`)
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
SitesListCommand.description = `List all sites you have access to`
|
|
76
|
-
|
|
77
|
-
SitesListCommand.flags = {
|
|
78
|
-
json: flagsLib.boolean({
|
|
79
|
-
description: 'Output site data as JSON',
|
|
80
|
-
}),
|
|
81
|
-
...SitesListCommand.flags,
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
module.exports = SitesListCommand
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
const { get } = require('dot-prop')
|
|
2
|
-
const prettyjson = require('prettyjson')
|
|
3
|
-
|
|
4
|
-
const Command = require('../../utils/command')
|
|
5
|
-
const { error, log, warn } = require('../../utils/command-helpers')
|
|
6
|
-
|
|
7
|
-
class StatusHooksCommand extends Command {
|
|
8
|
-
async run() {
|
|
9
|
-
const { api, site } = this.netlify
|
|
10
|
-
|
|
11
|
-
await this.authenticate()
|
|
12
|
-
|
|
13
|
-
const siteId = site.id
|
|
14
|
-
if (!siteId) {
|
|
15
|
-
warn('Did you run `netlify link` yet?')
|
|
16
|
-
error(`You don't appear to be in a folder that is linked to a site`)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let siteData
|
|
20
|
-
try {
|
|
21
|
-
siteData = await api.getSite({ siteId })
|
|
22
|
-
} catch (error_) {
|
|
23
|
-
// unauthorized
|
|
24
|
-
if (error_.status === 401) {
|
|
25
|
-
warn(`Log in with a different account or re-link to a site you have permission for`)
|
|
26
|
-
error(`Not authorized to view the currently linked site (${siteId})`)
|
|
27
|
-
}
|
|
28
|
-
// missing
|
|
29
|
-
if (error_.status === 404) {
|
|
30
|
-
error(`The site this folder is linked to can't be found`)
|
|
31
|
-
}
|
|
32
|
-
error(error_)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const ntlHooks = await api.listHooksBySiteId({ siteId: siteData.id })
|
|
36
|
-
const data = {
|
|
37
|
-
site: siteData.name,
|
|
38
|
-
hooks: {},
|
|
39
|
-
}
|
|
40
|
-
ntlHooks.forEach((hook) => {
|
|
41
|
-
data.hooks[hook.id] = {
|
|
42
|
-
type: hook.type,
|
|
43
|
-
event: hook.event,
|
|
44
|
-
id: hook.id,
|
|
45
|
-
disabled: hook.disabled,
|
|
46
|
-
}
|
|
47
|
-
if (get(siteData, 'build_settings.repo_url')) {
|
|
48
|
-
data.hooks[hook.id].repo_url = get(siteData, 'build_settings.repo_url')
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
log(`─────────────────┐
|
|
52
|
-
Site Hook Status │
|
|
53
|
-
─────────────────┘`)
|
|
54
|
-
log(prettyjson.render(data))
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
StatusHooksCommand.description = `Print hook information of the linked site`
|
|
59
|
-
|
|
60
|
-
module.exports = StatusHooksCommand
|
package/src/commands/switch.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const chalk = require('chalk')
|
|
2
|
-
const inquirer = require('inquirer')
|
|
3
|
-
|
|
4
|
-
const Command = require('../utils/command')
|
|
5
|
-
const { exit, log } = require('../utils/command-helpers')
|
|
6
|
-
|
|
7
|
-
const LoginCommand = require('./login')
|
|
8
|
-
|
|
9
|
-
class SwitchCommand extends Command {
|
|
10
|
-
async run() {
|
|
11
|
-
const LOGIN_NEW = 'I would like to login to a new account'
|
|
12
|
-
const availableUsersChoices = Object.values(this.netlify.globalConfig.get('users')).reduce(
|
|
13
|
-
(prev, current) =>
|
|
14
|
-
Object.assign(prev, { [current.id]: current.name ? `${current.name} (${current.email})` : current.email }),
|
|
15
|
-
{},
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
const { accountSwitchChoice } = await inquirer.prompt([
|
|
19
|
-
{
|
|
20
|
-
type: 'list',
|
|
21
|
-
name: 'accountSwitchChoice',
|
|
22
|
-
message: 'Please select the account you want to use:',
|
|
23
|
-
choices: [...Object.entries(availableUsersChoices).map(([, val]) => val), LOGIN_NEW],
|
|
24
|
-
},
|
|
25
|
-
])
|
|
26
|
-
|
|
27
|
-
if (accountSwitchChoice === LOGIN_NEW) {
|
|
28
|
-
await LoginCommand.run(['--new'])
|
|
29
|
-
} else {
|
|
30
|
-
const selectedAccount = Object.entries(availableUsersChoices).find(
|
|
31
|
-
([, availableUsersChoice]) => availableUsersChoice === accountSwitchChoice,
|
|
32
|
-
)
|
|
33
|
-
this.netlify.globalConfig.set('userId', selectedAccount[0])
|
|
34
|
-
log('')
|
|
35
|
-
log(`You're now using ${chalk.bold(selectedAccount[1])}.`)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return exit()
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
SwitchCommand.description = `Switch your active Netlify account`
|
|
43
|
-
|
|
44
|
-
module.exports = SwitchCommand
|
package/src/commands/unlink.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const Command = require('../utils/command')
|
|
2
|
-
const { exit, log } = require('../utils/command-helpers')
|
|
3
|
-
const { track } = require('../utils/telemetry')
|
|
4
|
-
|
|
5
|
-
class UnlinkCommand extends Command {
|
|
6
|
-
async run() {
|
|
7
|
-
const { site, state } = this.netlify
|
|
8
|
-
const siteId = site.id
|
|
9
|
-
|
|
10
|
-
if (!siteId) {
|
|
11
|
-
log(`Folder is not linked to a Netlify site. Run 'netlify link' to link it`)
|
|
12
|
-
return exit()
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let siteData = {}
|
|
16
|
-
try {
|
|
17
|
-
siteData = await this.netlify.api.getSite({ siteId })
|
|
18
|
-
} catch (error) {
|
|
19
|
-
// ignore errors if we can't get the site
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
state.delete('siteId')
|
|
23
|
-
|
|
24
|
-
await track('sites_unlinked', {
|
|
25
|
-
siteId: siteData.id || siteId,
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
if (site) {
|
|
29
|
-
log(`Unlinked ${site.configPath} from ${siteData ? siteData.name : siteId}`)
|
|
30
|
-
} else {
|
|
31
|
-
log('Unlinked site')
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
UnlinkCommand.description = `Unlink a local folder from a Netlify site`
|
|
37
|
-
|
|
38
|
-
module.exports = UnlinkCommand
|
package/src/commands/watch.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
const { CLIError } = require('@oclif/errors')
|
|
2
|
-
const chalk = require('chalk')
|
|
3
|
-
const cli = require('cli-ux').default
|
|
4
|
-
const pWaitFor = require('p-wait-for')
|
|
5
|
-
const prettyjson = require('prettyjson')
|
|
6
|
-
|
|
7
|
-
const Command = require('../utils/command')
|
|
8
|
-
const { exit, log } = require('../utils/command-helpers')
|
|
9
|
-
|
|
10
|
-
const InitCommand = require('./init')
|
|
11
|
-
|
|
12
|
-
// 1 second
|
|
13
|
-
const INIT_WAIT = 1e3
|
|
14
|
-
|
|
15
|
-
class SitesWatchCommand extends Command {
|
|
16
|
-
async run() {
|
|
17
|
-
await this.authenticate()
|
|
18
|
-
const client = this.netlify.api
|
|
19
|
-
let siteId = this.netlify.site.id
|
|
20
|
-
|
|
21
|
-
if (!siteId) {
|
|
22
|
-
const siteData = await InitCommand.run([])
|
|
23
|
-
siteId = siteData.id
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// wait for 1 sec for everything to kickoff
|
|
27
|
-
console.time('Deploy time')
|
|
28
|
-
await cli.wait(INIT_WAIT)
|
|
29
|
-
|
|
30
|
-
// Get latest commit and look for that
|
|
31
|
-
// git rev-parse HEAD
|
|
32
|
-
|
|
33
|
-
// if no sha, its a manual "triggered deploy"
|
|
34
|
-
//
|
|
35
|
-
// {
|
|
36
|
-
// "id": "5b4e23db82d3f1780abd74f3",
|
|
37
|
-
// "deploy_id": "5b4e23db82d3f1780abd74f2",
|
|
38
|
-
// "sha": "pull/1/head",
|
|
39
|
-
// "log": [],
|
|
40
|
-
// "done": false,
|
|
41
|
-
// "error": null,
|
|
42
|
-
// "created_at": "2018-07-17T17:14:03.423Z"
|
|
43
|
-
// }
|
|
44
|
-
//
|
|
45
|
-
cli.action.start('Waiting for active site deploys to complete')
|
|
46
|
-
try {
|
|
47
|
-
// Fetch all builds!
|
|
48
|
-
// const builds = await client.listSiteBuilds({siteId})
|
|
49
|
-
//
|
|
50
|
-
// // Filter down to any that are not done
|
|
51
|
-
// const buildsToWatch = builds.filter((build) => {
|
|
52
|
-
// return !build.done
|
|
53
|
-
// })
|
|
54
|
-
|
|
55
|
-
const noActiveBuilds = await waitForBuildFinish(client, siteId)
|
|
56
|
-
|
|
57
|
-
const siteData = await client.getSite({ siteId })
|
|
58
|
-
|
|
59
|
-
const message = chalk.cyanBright.bold.underline(noActiveBuilds ? 'Last build' : 'Deploy complete')
|
|
60
|
-
log()
|
|
61
|
-
log(message)
|
|
62
|
-
log(
|
|
63
|
-
prettyjson.render({
|
|
64
|
-
URL: siteData.ssl_url || siteData.url,
|
|
65
|
-
Admin: siteData.admin_url,
|
|
66
|
-
}),
|
|
67
|
-
)
|
|
68
|
-
console.timeEnd('Deploy time')
|
|
69
|
-
} catch (error) {
|
|
70
|
-
throw new CLIError(error)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
exit()
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
SitesWatchCommand.description = `Watch for site deploy to finish`
|
|
78
|
-
|
|
79
|
-
SitesWatchCommand.examples = [`netlify watch`, `git push && netlify watch`]
|
|
80
|
-
|
|
81
|
-
// 1 second
|
|
82
|
-
const BUILD_FINISH_INTERVAL = 1e3
|
|
83
|
-
// 20 minutes
|
|
84
|
-
const BUILD_FINISH_TIMEOUT = 12e5
|
|
85
|
-
|
|
86
|
-
const waitForBuildFinish = async function (api, siteId) {
|
|
87
|
-
let firstPass = true
|
|
88
|
-
|
|
89
|
-
const waitForBuildToFinish = async function () {
|
|
90
|
-
const builds = await api.listSiteBuilds({ siteId })
|
|
91
|
-
// build.error
|
|
92
|
-
const currentBuilds = builds.filter((build) => !build.done)
|
|
93
|
-
|
|
94
|
-
// if build.error
|
|
95
|
-
// @TODO implement build error messages into this
|
|
96
|
-
|
|
97
|
-
if (!currentBuilds || currentBuilds.length === 0) {
|
|
98
|
-
cli.action.stop()
|
|
99
|
-
return true
|
|
100
|
-
}
|
|
101
|
-
firstPass = false
|
|
102
|
-
return false
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
await pWaitFor(waitForBuildToFinish, {
|
|
106
|
-
interval: BUILD_FINISH_INTERVAL,
|
|
107
|
-
timeout: BUILD_FINISH_TIMEOUT,
|
|
108
|
-
message: 'Timeout while waiting for deploy to finish',
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
// return only when build done or timeout happens
|
|
112
|
-
return firstPass
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
module.exports = SitesWatchCommand
|
package/src/hooks/init.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const process = require('process')
|
|
2
|
-
|
|
3
|
-
const getGlobalConfig = require('../utils/get-global-config')
|
|
4
|
-
const header = require('../utils/header')
|
|
5
|
-
const { track } = require('../utils/telemetry')
|
|
6
|
-
|
|
7
|
-
module.exports = async function initHooks(context) {
|
|
8
|
-
const globalConfig = await getGlobalConfig()
|
|
9
|
-
// Enable/disable telemetry Global flags. TODO refactor where these fire
|
|
10
|
-
if (context.id === '--telemetry-disable') {
|
|
11
|
-
globalConfig.set('telemetryDisabled', true)
|
|
12
|
-
console.log('Netlify telemetry has been disabled')
|
|
13
|
-
console.log('You can renable it anytime with the --telemetry-enable flag')
|
|
14
|
-
process.exit()
|
|
15
|
-
}
|
|
16
|
-
if (context.id === '--telemetry-enable') {
|
|
17
|
-
globalConfig.set('telemetryDisabled', false)
|
|
18
|
-
console.log('Netlify telemetry has been enabled')
|
|
19
|
-
console.log('You can disable it anytime with the --telemetry-disable flag')
|
|
20
|
-
await track('user_telemetryEnabled')
|
|
21
|
-
process.exit()
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
process.argv.length > 3 &&
|
|
26
|
-
['-v', '--version', 'version'].includes(process.argv[2]) &&
|
|
27
|
-
process.argv[3] === '--verbose'
|
|
28
|
-
) {
|
|
29
|
-
console.log(`────────────────────┐
|
|
30
|
-
Environment Info │
|
|
31
|
-
────────────────────┘`)
|
|
32
|
-
|
|
33
|
-
// performance optimization - load envinfo on demand
|
|
34
|
-
// eslint-disable-next-line node/global-require
|
|
35
|
-
const envinfo = require('envinfo')
|
|
36
|
-
const data = await envinfo.run({
|
|
37
|
-
System: ['OS', 'CPU'],
|
|
38
|
-
Binaries: ['Node', 'Yarn', 'npm'],
|
|
39
|
-
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
|
|
40
|
-
npmGlobalPackages: ['netlify-cli'],
|
|
41
|
-
})
|
|
42
|
-
console.log(data)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
header(context)
|
|
46
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const process = require('process')
|
|
2
|
-
|
|
3
|
-
const updateNotifier = require('update-notifier')
|
|
4
|
-
|
|
5
|
-
const pkg = require('../package.json')
|
|
6
|
-
|
|
7
|
-
// 12 hours
|
|
8
|
-
const UPDATE_CHECK_INTERVAL = 432e5
|
|
9
|
-
|
|
10
|
-
// performance optimization to disable built in oclif TypeScript support
|
|
11
|
-
// see https://github.com/oclif/config/blob/1066a42a61a71b9a0708a2beff498d2cbbb9a3fd/src/ts-node.ts#L51
|
|
12
|
-
// oclif registers ts-node which can be quite slow
|
|
13
|
-
process.env.OCLIF_TS_NODE = '0'
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
updateNotifier({
|
|
17
|
-
pkg,
|
|
18
|
-
updateCheckInterval: UPDATE_CHECK_INTERVAL,
|
|
19
|
-
}).notify()
|
|
20
|
-
} catch (error) {
|
|
21
|
-
console.log('Error checking for updates:')
|
|
22
|
-
console.log(error)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = require('@oclif/command')
|
package/src/lib/help.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const Help = require('@oclif/plugin-help').default
|
|
2
|
-
|
|
3
|
-
const isBetaPlugin = (id) => id === 'completion'
|
|
4
|
-
|
|
5
|
-
const isHelpCommand = (id) => id === 'help'
|
|
6
|
-
|
|
7
|
-
const formatDescription = (description, id) => {
|
|
8
|
-
if (isBetaPlugin(id)) {
|
|
9
|
-
return `(Beta) ${description}`
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (isHelpCommand(id)) {
|
|
13
|
-
return 'Display help. To display help for a specific command run `netlify help [command]`'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return description
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
module.exports = class CustomHelp extends Help {
|
|
20
|
-
constructor(config, opts = {}) {
|
|
21
|
-
config.commands.forEach((command) => {
|
|
22
|
-
command.description = formatDescription(command.description, command.id)
|
|
23
|
-
})
|
|
24
|
-
super(config, opts)
|
|
25
|
-
}
|
|
26
|
-
}
|
package/src/utils/chalk.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const chalk = require('chalk')
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Chalk instance for CLI
|
|
5
|
-
* @param {boolean} noColors - disable chalk colors
|
|
6
|
-
* @return {object} - default or custom chalk instance
|
|
7
|
-
*/
|
|
8
|
-
const safeChalk = function (noColors) {
|
|
9
|
-
if (noColors) {
|
|
10
|
-
const colorlessChalk = new chalk.Instance({ level: 0 })
|
|
11
|
-
return colorlessChalk
|
|
12
|
-
}
|
|
13
|
-
return chalk
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
module.exports = safeChalk
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Checks for args or flags supplied to command
|
|
2
|
-
const isEmptyCommand = function (flags, args) {
|
|
3
|
-
if (!hasFlags(flags) && !hasArgs(args)) {
|
|
4
|
-
return true
|
|
5
|
-
}
|
|
6
|
-
return false
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const hasFlags = function (flags) {
|
|
10
|
-
return Object.keys(flags).length
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const hasArgs = function (args) {
|
|
14
|
-
return Object.keys(args).length
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
module.exports = {
|
|
18
|
-
hasFlags,
|
|
19
|
-
hasArgs,
|
|
20
|
-
isEmptyCommand,
|
|
21
|
-
}
|