netlify-cli 8.9.9 → 8.9.10

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 CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- /* eslint-disable promise/prefer-await-to-then,promise/prefer-await-to-callbacks,eslint-comments/disable-enable-pair */
3
2
  const process = require('process')
4
3
 
5
4
  const updateNotifier = require('update-notifier')
@@ -18,23 +17,13 @@ if (require.main === module) {
18
17
  pkg,
19
18
  updateCheckInterval: UPDATE_CHECK_INTERVAL,
20
19
  }).notify()
21
- } catch (error) {
20
+ } catch (error_) {
22
21
  console.log('Error checking for updates:')
23
- console.log(error)
22
+ console.log(error_)
24
23
  }
25
24
 
26
- /** @type {Error} */
27
- let caughtError
28
-
29
25
  const program = createMainCommand()
30
26
 
31
- program.parseAsync(process.argv).catch((error) => {
32
- caughtError = error
33
- })
34
-
35
- // long running commands like dev server cannot be caught by a post action hook
36
- // they are running on the main command
37
- process.on('exit', () => {
38
- program.onEnd(caughtError)
39
- })
27
+ // eslint-disable-next-line promise/prefer-await-to-then
28
+ program.parseAsync(process.argv).catch((error_) => program.onEnd(error_))
40
29
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "netlify-cli",
3
- "version": "8.9.9",
3
+ "version": "8.9.10",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "netlify-cli",
9
- "version": "8.9.9",
9
+ "version": "8.9.10",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
@@ -134,6 +134,7 @@
134
134
  "mock-fs": "^5.1.2",
135
135
  "mock-require": "^3.0.3",
136
136
  "p-timeout": "^4.0.0",
137
+ "proxyquire": "^2.1.3",
137
138
  "seedrandom": "^3.0.5",
138
139
  "serialize-javascript": "^6.0.0",
139
140
  "sinon": "^12.0.0",
@@ -10432,6 +10433,19 @@
10432
10433
  "node": ">=6"
10433
10434
  }
10434
10435
  },
10436
+ "node_modules/fill-keys": {
10437
+ "version": "1.0.2",
10438
+ "resolved": "https://registry.npmjs.org/fill-keys/-/fill-keys-1.0.2.tgz",
10439
+ "integrity": "sha1-mo+jb06K1jTjv2tPPIiCVRRS6yA=",
10440
+ "dev": true,
10441
+ "dependencies": {
10442
+ "is-object": "~1.0.1",
10443
+ "merge-descriptors": "~1.0.0"
10444
+ },
10445
+ "engines": {
10446
+ "node": ">=0.10.0"
10447
+ }
10448
+ },
10435
10449
  "node_modules/fill-range": {
10436
10450
  "version": "7.0.1",
10437
10451
  "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
@@ -14854,6 +14868,12 @@
14854
14868
  "node": ">=6.0"
14855
14869
  }
14856
14870
  },
14871
+ "node_modules/module-not-found-error": {
14872
+ "version": "1.0.1",
14873
+ "resolved": "https://registry.npmjs.org/module-not-found-error/-/module-not-found-error-1.0.1.tgz",
14874
+ "integrity": "sha1-z4tP9PKWQGdNbN0CsOO8UjwrvcA=",
14875
+ "dev": true
14876
+ },
14857
14877
  "node_modules/moize": {
14858
14878
  "version": "6.1.0",
14859
14879
  "resolved": "https://registry.npmjs.org/moize/-/moize-6.1.0.tgz",
@@ -17488,6 +17508,34 @@
17488
17508
  "node": ">= 0.10"
17489
17509
  }
17490
17510
  },
17511
+ "node_modules/proxyquire": {
17512
+ "version": "2.1.3",
17513
+ "resolved": "https://registry.npmjs.org/proxyquire/-/proxyquire-2.1.3.tgz",
17514
+ "integrity": "sha512-BQWfCqYM+QINd+yawJz23tbBM40VIGXOdDw3X344KcclI/gtBbdWF6SlQ4nK/bYhF9d27KYug9WzljHC6B9Ysg==",
17515
+ "dev": true,
17516
+ "dependencies": {
17517
+ "fill-keys": "^1.0.2",
17518
+ "module-not-found-error": "^1.0.1",
17519
+ "resolve": "^1.11.1"
17520
+ }
17521
+ },
17522
+ "node_modules/proxyquire/node_modules/resolve": {
17523
+ "version": "1.21.0",
17524
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.21.0.tgz",
17525
+ "integrity": "sha512-3wCbTpk5WJlyE4mSOtDLhqQmGFi0/TD9VPwmiolnk8U0wRgMEktqCXd3vy5buTO3tljvalNvKrjHEfrd2WpEKA==",
17526
+ "dev": true,
17527
+ "dependencies": {
17528
+ "is-core-module": "^2.8.0",
17529
+ "path-parse": "^1.0.7",
17530
+ "supports-preserve-symlinks-flag": "^1.0.0"
17531
+ },
17532
+ "bin": {
17533
+ "resolve": "bin/resolve"
17534
+ },
17535
+ "funding": {
17536
+ "url": "https://github.com/sponsors/ljharb"
17537
+ }
17538
+ },
17491
17539
  "node_modules/ps-list": {
17492
17540
  "version": "7.2.0",
17493
17541
  "resolved": "https://registry.npmjs.org/ps-list/-/ps-list-7.2.0.tgz",
@@ -29792,6 +29840,16 @@
29792
29840
  "trim-repeated": "^1.0.0"
29793
29841
  }
29794
29842
  },
29843
+ "fill-keys": {
29844
+ "version": "1.0.2",
29845
+ "resolved": "https://registry.npmjs.org/fill-keys/-/fill-keys-1.0.2.tgz",
29846
+ "integrity": "sha1-mo+jb06K1jTjv2tPPIiCVRRS6yA=",
29847
+ "dev": true,
29848
+ "requires": {
29849
+ "is-object": "~1.0.1",
29850
+ "merge-descriptors": "~1.0.0"
29851
+ }
29852
+ },
29795
29853
  "fill-range": {
29796
29854
  "version": "7.0.1",
29797
29855
  "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
@@ -33098,6 +33156,12 @@
33098
33156
  "node-source-walk": "^4.0.0"
33099
33157
  }
33100
33158
  },
33159
+ "module-not-found-error": {
33160
+ "version": "1.0.1",
33161
+ "resolved": "https://registry.npmjs.org/module-not-found-error/-/module-not-found-error-1.0.1.tgz",
33162
+ "integrity": "sha1-z4tP9PKWQGdNbN0CsOO8UjwrvcA=",
33163
+ "dev": true
33164
+ },
33101
33165
  "moize": {
33102
33166
  "version": "6.1.0",
33103
33167
  "resolved": "https://registry.npmjs.org/moize/-/moize-6.1.0.tgz",
@@ -35107,6 +35171,30 @@
35107
35171
  "ipaddr.js": "1.9.1"
35108
35172
  }
35109
35173
  },
35174
+ "proxyquire": {
35175
+ "version": "2.1.3",
35176
+ "resolved": "https://registry.npmjs.org/proxyquire/-/proxyquire-2.1.3.tgz",
35177
+ "integrity": "sha512-BQWfCqYM+QINd+yawJz23tbBM40VIGXOdDw3X344KcclI/gtBbdWF6SlQ4nK/bYhF9d27KYug9WzljHC6B9Ysg==",
35178
+ "dev": true,
35179
+ "requires": {
35180
+ "fill-keys": "^1.0.2",
35181
+ "module-not-found-error": "^1.0.1",
35182
+ "resolve": "^1.11.1"
35183
+ },
35184
+ "dependencies": {
35185
+ "resolve": {
35186
+ "version": "1.21.0",
35187
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.21.0.tgz",
35188
+ "integrity": "sha512-3wCbTpk5WJlyE4mSOtDLhqQmGFi0/TD9VPwmiolnk8U0wRgMEktqCXd3vy5buTO3tljvalNvKrjHEfrd2WpEKA==",
35189
+ "dev": true,
35190
+ "requires": {
35191
+ "is-core-module": "^2.8.0",
35192
+ "path-parse": "^1.0.7",
35193
+ "supports-preserve-symlinks-flag": "^1.0.0"
35194
+ }
35195
+ }
35196
+ }
35197
+ },
35110
35198
  "ps-list": {
35111
35199
  "version": "7.2.0",
35112
35200
  "resolved": "https://registry.npmjs.org/ps-list/-/ps-list-7.2.0.tgz",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "netlify-cli",
3
3
  "description": "Netlify command line tool",
4
- "version": "8.9.9",
4
+ "version": "8.9.10",
5
5
  "author": "Netlify Inc.",
6
6
  "contributors": [
7
7
  "Mathias Biilmann <matt@netlify.com> (https://twitter.com/biilmann)",
@@ -196,6 +196,7 @@
196
196
  "mock-fs": "^5.1.2",
197
197
  "mock-require": "^3.0.3",
198
198
  "p-timeout": "^4.0.0",
199
+ "proxyquire": "^2.1.3",
199
200
  "seedrandom": "^3.0.5",
200
201
  "serialize-javascript": "^6.0.0",
201
202
  "sinon": "^12.0.0",
@@ -303,12 +303,14 @@ class BaseCommand extends Command {
303
303
  debug(`${this.name()}:onEnd`)(`Status: ${status}`)
304
304
  debug(`${this.name()}:onEnd`)(`Duration: ${duration}ms`)
305
305
 
306
- await track('command', {
307
- ...payload,
308
- command: this.name(),
309
- duration,
310
- status,
311
- })
306
+ try {
307
+ await track('command', {
308
+ ...payload,
309
+ command: this.name(),
310
+ duration,
311
+ status,
312
+ })
313
+ } catch {}
312
314
 
313
315
  if (error_ !== undefined) {
314
316
  error(error_ instanceof Error ? error_ : format(error_), { exit: false })
@@ -4,10 +4,11 @@ const process = require('process')
4
4
 
5
5
  const { fetchLatest, fetchVersion, newerVersion, updateAvailable } = require('gh-release-fetch')
6
6
  const isExe = require('isexe')
7
+ const terminalLink = require('terminal-link')
7
8
 
8
9
  // cannot directly import from ../utils as it would create a circular dependency.
9
10
  // the file `src/utils/live-tunnel.js` depends on this file
10
- const { NETLIFYDEVWARN, log } = require('../utils/command-helpers')
11
+ const { NETLIFYDEVWARN, chalk, error, log } = require('../utils/command-helpers')
11
12
  const execa = require('../utils/execa')
12
13
 
13
14
  const isWindows = () => process.platform === 'win32'
@@ -62,27 +63,80 @@ const shouldFetchLatestVersion = async ({ binPath, execArgs, execName, latestVer
62
63
  latestVersion,
63
64
  })
64
65
  return outdated
65
- } catch (error) {
66
+ } catch (error_) {
66
67
  if (exists) {
67
68
  log(NETLIFYDEVWARN, `failed checking for new version of '${packageName}'. Using existing version`)
68
69
  return false
69
70
  }
70
- throw error
71
+ throw error_
71
72
  }
72
73
  }
73
74
 
75
+ const getArch = () => {
76
+ switch (process.arch) {
77
+ case 'x64':
78
+ return 'amd64'
79
+ case 'ia32':
80
+ return '386'
81
+ default:
82
+ return process.arch
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Tries to get the latest release from the github releases to download the binary.
88
+ * Is throwing an error if there is no binary that matches the system os or arch
89
+ * @param {object} config
90
+ * @param {string} config.destination
91
+ * @param {string} config.execName
92
+ * @param {string} config.destination
93
+ * @param {string} config.extension
94
+ * @param {string} config.packageName
95
+ * @param {string} [config.latestVersion ]
96
+ */
74
97
  const fetchLatestVersion = async ({ destination, execName, extension, latestVersion, packageName }) => {
75
98
  const win = isWindows()
99
+ const arch = getArch()
76
100
  const platform = win ? 'windows' : process.platform
101
+ const pkgName = `${execName}-${platform}-${arch}.${extension}`
102
+
77
103
  const release = {
78
104
  repository: getRepository({ packageName }),
79
- package: `${execName}-${platform}-amd64.${extension}`,
105
+ package: pkgName,
80
106
  destination,
81
107
  extract: true,
82
108
  }
83
109
 
84
110
  const options = getOptions()
85
- await (latestVersion ? fetchVersion({ ...release, version: latestVersion }, options) : fetchLatest(release, options))
111
+ const fetch = latestVersion
112
+ ? fetchVersion({ ...release, version: latestVersion }, options)
113
+ : fetchLatest(release, options)
114
+
115
+ try {
116
+ await fetch
117
+ } catch (error_) {
118
+ if (typeof error_ === 'object' && 'statusCode' in error_ && error_.statusCode === 404) {
119
+ const createIssueLink = new URL('https://github.com/netlify/cli/issues/new')
120
+ createIssueLink.searchParams.set('assignees', '')
121
+ createIssueLink.searchParams.set('labels', 'type: bug')
122
+ createIssueLink.searchParams.set('template', 'bug_report.md')
123
+ createIssueLink.searchParams.set(
124
+ 'title',
125
+ `${execName} is not supported on ${platform} with CPU architecture ${arch}`,
126
+ )
127
+
128
+ const issueLink = terminalLink('Create a new CLI issue', createIssueLink.href)
129
+
130
+ error(`The operating system ${chalk.cyan(platform)} with the CPU architecture ${chalk.cyan(
131
+ arch,
132
+ )} is currently not supported!
133
+
134
+ Please open up an issue on our CLI repository so that we can support it:
135
+ ${issueLink}`)
136
+ }
137
+
138
+ error(error_)
139
+ }
86
140
  }
87
141
 
88
- module.exports = { getExecName, shouldFetchLatestVersion, fetchLatestVersion }
142
+ module.exports = { getArch, getExecName, shouldFetchLatestVersion, fetchLatestVersion }
@@ -179,7 +179,7 @@ const error = (message = '', options = {}) => {
179
179
  if (process.env.DEBUG) {
180
180
  process.stderr.write(` ${bang} Warning: ${err.stack.split('\n').join(`\n ${bang} `)}`)
181
181
  } else {
182
- process.stderr.write(` ${bang} ${err.name}: ${err.message}\n`)
182
+ process.stderr.write(` ${bang} ${chalk.red(`${err.name}:`)} ${err.message}\n`)
183
183
  }
184
184
  } else {
185
185
  throw err