@sentry/cli 2.23.0 → 2.23.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/checksums.txt CHANGED
@@ -1,9 +1,9 @@
1
- sentry-cli-Darwin-arm64=3714a30704eeee21456a60e75e044e4e3aa36bedeb084f8993ea089ff7577e99
2
- sentry-cli-Darwin-universal=042bf36aebe9081264a6d95a098712b4006b66df356ee4440851a3c26acbbbf4
3
- sentry-cli-Darwin-x86_64=5c4d0d3e9d5838a587bcca98163f779843c0207483493dda36630e8e03919331
4
- sentry-cli-Linux-aarch64=66d0b504d983ff2f7b5f60ebf5b3c933ba8a93c2a608f759863fd2b446b344fd
5
- sentry-cli-Linux-armv7=940b8844f60cc04c8aec65c38aedc20c2fde949f97576f7ae34f9febfb561d80
6
- sentry-cli-Linux-i686=180306e08e5ec10445aa2f0ce1abb07740dceb30685dc53cd8b26a35909db20f
7
- sentry-cli-Linux-x86_64=23d3fdb2e797a1f49917b13cd040874f6189aff3f24d56d3fb81d74c1f368372
8
- sentry-cli-Windows-i686.exe=a6cb2266418f418df0ce88f16086bbb60090805b9a5d38abee8f6ae1f7eba25f
9
- sentry-cli-Windows-x86_64.exe=bc51a87a60fa13a619ecaa93f9d442ae7e638a1718cb4616c6595ce7ab02ab25
1
+ sentry-cli-Darwin-arm64=2661e69e85fde9b8c1dc6e6bf9f9a61abb7a8b6986df3ba19abf00c0f681aeb9
2
+ sentry-cli-Darwin-universal=b8a1f6a855400e483a51e3c9efb2fc5c256879d88ded8cd2e2f97c5a3a0ee086
3
+ sentry-cli-Darwin-x86_64=33c9718a63ee620fb5716674c9dfffa4d82636918202c8e054f5185167a1b188
4
+ sentry-cli-Linux-aarch64=0caaa6ef000667a584ee4308a2c151ee9fb586d7d2ceef1f64837043e3b8bf79
5
+ sentry-cli-Linux-armv7=83d95451a7c2e788a806531bd9d0ccf7e6e6292f9e74cd771021bf03abc584da
6
+ sentry-cli-Linux-i686=d92e9d461db1bf0995abd48251490969ab955dc8a3bc525cf72d717a56fffac6
7
+ sentry-cli-Linux-x86_64=ce0b62603da9fdc3d37aeb1f2af1b04c82efaf32a8d36114c950d7dc32ed11a8
8
+ sentry-cli-Windows-i686.exe=392b59d3acb4d81504bb501a90ec0397a51cd1e090c897c1a10b274355585abd
9
+ sentry-cli-Windows-x86_64.exe=8fdafca0a16eac1ba633549beceb569f5e63c1ec1f3fad4f6b3b539e23620b1e
package/js/helper.js CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  const os = require('os');
4
+ const path = require('path');
5
+ const fs = require('fs');
4
6
  const childProcess = require('child_process');
5
7
 
6
8
  const BINARY_DISTRIBUTIONS = [
@@ -13,6 +15,23 @@ const BINARY_DISTRIBUTIONS = [
13
15
  { packageName: '@sentry/cli-win32-i686', subpath: 'bin/sentry-cli.exe' },
14
16
  ];
15
17
 
18
+ /**
19
+ * This convoluted function resolves the path to the manually downloaded fallback
20
+ * `sentry-cli` binary in a way that can't be analysed by @vercel/nft.
21
+ *
22
+ * Without this, the binary can be detected as an asset and included by bundlers
23
+ * that use @vercel/nft.
24
+ *
25
+ * @returns {string} The path to the sentry-cli binary
26
+ */
27
+ function getFallbackBinaryPath() {
28
+ const parts = [];
29
+ parts.push(__dirname);
30
+ parts.push('..');
31
+ parts.push(`sentry-cli${process.platform === 'win32' ? '.exe' : ''}`);
32
+ return path.resolve(...parts);
33
+ }
34
+
16
35
  function getDistributionForThisPlatform() {
17
36
  const arch = os.arch();
18
37
  const platform = os.platform();
@@ -67,11 +86,25 @@ function getDistributionForThisPlatform() {
67
86
  }
68
87
 
69
88
  /**
70
- * This convoluted function resolves the path to the `sentry-cli` binary in a
71
- * way that can't be analysed by @vercel/nft.
89
+ * Throws an error with a message stating that Sentry CLI doesn't support the current platform.
90
+ *
91
+ * @returns {never} nothing. It throws.
92
+ */
93
+ function throwUnsupportedPlatformError() {
94
+ throw new Error(
95
+ `Unsupported operating system or architecture! Sentry CLI does not work on this architecture.
96
+
97
+ Sentry CLI supports:
98
+ - Darwin (macOS)
99
+ - Linux and FreeBSD on x64, x86, ia32, arm64, and arm architectures
100
+ - Windows x64, x86, and ia32 architectures`
101
+ );
102
+ }
103
+
104
+ /**
105
+ * Tries to find the installed Sentry CLI binary - either by looking into the relevant
106
+ * optional dependencies or by trying to resolve the fallback binary.
72
107
  *
73
- * Without this, the binary can be detected as an asset and included by bundlers
74
- * that use @vercel/nft.
75
108
  * @returns {string} The path to the sentry-cli binary
76
109
  */
77
110
  function getBinaryPath() {
@@ -82,14 +115,13 @@ function getBinaryPath() {
82
115
  const { packageName, subpath } = getDistributionForThisPlatform();
83
116
 
84
117
  if (packageName === undefined) {
85
- throw new Error(
86
- `Unsupported operating system or architecture! Sentry CLI does not work on this architecture.
118
+ throwUnsupportedPlatformError();
119
+ }
87
120
 
88
- Sentry CLI supports:
89
- - Darwin (macOS)
90
- - Linux and FreeBSD on x64, x86, ia32, arm64, and arm architectures
91
- - Windows x64, x86, and ia32 architectures`
92
- );
121
+ let fallbackBinaryPath = getFallbackBinaryPath();
122
+ if (fs.existsSync(fallbackBinaryPath)) {
123
+ // Since the fallback got installed, the optional dependencies likely didn't get installed, so we just default to the fallback.
124
+ return fallbackBinaryPath;
93
125
  }
94
126
 
95
127
  let compatibleBinaryPath;
@@ -115,7 +147,7 @@ To fix this, avoid copying the "node_modules" folder, and instead freshly instal
115
147
  } else {
116
148
  throw new Error(`Sentry CLI binary for this platform/architecture not found!
117
149
 
118
- It seems like none of the "@sentry/cli" package's optional dependencies got installed. Please make sure your package manager is configured to install optional dependencies. If you are using npm to install your dependencies, please don't set the "--no-optional" or "--omit=optional" flags. Sentry CLI needs the "optionalDependencies" feature in order to install its binary.`);
150
+ It seems like none of the "@sentry/cli" package's optional dependencies got installed. Please make sure your package manager is configured to install optional dependencies. If you are using npm to install your dependencies, please don't set the "--no-optional", "--ignore-optional", or "--omit=optional" flags. Sentry CLI needs the "optionalDependencies" feature in order to install its binary.`);
119
151
  }
120
152
  }
121
153
 
@@ -123,10 +155,10 @@ It seems like none of the "@sentry/cli" package's optional dependencies got inst
123
155
  }
124
156
 
125
157
  /**
126
- * Absolute path to the sentry-cli binary (platform dependent).
127
- * @type {string}
158
+ * Will be used as the binary path when defined with `mockBinaryPath`.
159
+ * @type {string | undefined}
128
160
  */
129
- let binaryPath = getBinaryPath();
161
+ let mockedBinaryPath;
130
162
 
131
163
  /**
132
164
  * Overrides the default binary path with a mock value, useful for testing.
@@ -136,7 +168,7 @@ let binaryPath = getBinaryPath();
136
168
  */
137
169
  // TODO(v3): Remove this function
138
170
  function mockBinaryPath(mockPath) {
139
- binaryPath = mockPath;
171
+ mockedBinaryPath = mockPath;
140
172
  }
141
173
 
142
174
  /**
@@ -222,7 +254,7 @@ function prepareCommand(command, schema, options) {
222
254
  * @returns {string}
223
255
  */
224
256
  function getPath() {
225
- return binaryPath;
257
+ return mockedBinaryPath !== undefined ? mockedBinaryPath : getBinaryPath();
226
258
  }
227
259
 
228
260
  /**
@@ -318,4 +350,7 @@ module.exports = {
318
350
  mockBinaryPath,
319
351
  prepareCommand,
320
352
  serializeOptions,
353
+ getDistributionForThisPlatform,
354
+ throwUnsupportedPlatformError,
355
+ getFallbackBinaryPath,
321
356
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/cli",
3
- "version": "2.23.0",
3
+ "version": "2.23.2",
4
4
  "description": "A command line utility to work with Sentry. https://docs.sentry.io/hosted/learn/cli/",
5
5
  "repository": "git://github.com/getsentry/sentry-cli.git",
6
6
  "homepage": "https://docs.sentry.io/hosted/learn/cli/",
@@ -30,15 +30,16 @@
30
30
  "prettier": "2.8.8"
31
31
  },
32
32
  "optionalDependencies": {
33
- "@sentry/cli-darwin": "2.23.0",
34
- "@sentry/cli-linux-arm": "2.23.0",
35
- "@sentry/cli-linux-arm64": "2.23.0",
36
- "@sentry/cli-linux-i686": "2.23.0",
37
- "@sentry/cli-linux-x64": "2.23.0",
38
- "@sentry/cli-win32-i686": "2.23.0",
39
- "@sentry/cli-win32-x64": "2.23.0"
33
+ "@sentry/cli-darwin": "2.23.2",
34
+ "@sentry/cli-linux-arm": "2.23.2",
35
+ "@sentry/cli-linux-arm64": "2.23.2",
36
+ "@sentry/cli-linux-i686": "2.23.2",
37
+ "@sentry/cli-linux-x64": "2.23.2",
38
+ "@sentry/cli-win32-i686": "2.23.2",
39
+ "@sentry/cli-win32-x64": "2.23.2"
40
40
  },
41
41
  "scripts": {
42
+ "postinstall": "node ./scripts/install.js",
42
43
  "fix": "npm-run-all fix:eslint fix:prettier",
43
44
  "fix:eslint": "eslint --fix bin/* scripts/**/*.js js/**/*.js",
44
45
  "fix:prettier": "prettier --write bin/* scripts/**/*.js js/**/*.js",
@@ -2,12 +2,6 @@
2
2
 
3
3
  'use strict';
4
4
 
5
- // TODO(v3): Remove this file
6
-
7
- console.log(
8
- 'DEPRECATION NOTICE: The Sentry CLI install script has been deprecated. The package now uses "optionalDependencies" instead to install architecture-compatible binaries distributed over npm.'
9
- );
10
-
11
5
  const fs = require('fs');
12
6
  const os = require('os');
13
7
  const path = require('path');
@@ -84,6 +78,10 @@ function getDownloadUrl(platform, arch) {
84
78
  case 'darwin':
85
79
  return `${releasesUrl}-Darwin-universal`;
86
80
  case 'win32':
81
+ // Windows arm machines can run x64 binaries
82
+ if (arch === 'arm64') {
83
+ archString = 'x86_64';
84
+ }
87
85
  return `${releasesUrl}-Windows-${archString}.exe`;
88
86
  case 'linux':
89
87
  case 'freebsd':
@@ -194,7 +192,7 @@ function validateChecksum(tempPath, name) {
194
192
  async function downloadBinary() {
195
193
  const arch = os.arch();
196
194
  const platform = os.platform();
197
- const outputPath = helper.getPath();
195
+ const outputPath = helper.getFallbackBinaryPath();
198
196
 
199
197
  if (process.env.SENTRYCLI_USE_LOCAL === '1') {
200
198
  try {
@@ -319,14 +317,33 @@ if (process.env.SENTRYCLI_SKIP_DOWNLOAD === '1') {
319
317
  process.exit(0);
320
318
  }
321
319
 
322
- (async () => {
323
- try {
324
- await downloadBinary();
325
- await checkVersion();
326
- process.exit(0);
327
- } catch (e) {
328
- // eslint-disable-next-line no-console
329
- console.error(e.toString());
330
- process.exit(1);
331
- }
332
- })();
320
+ const { packageName: distributionPackageName, subpath: distributionSubpath } =
321
+ helper.getDistributionForThisPlatform();
322
+
323
+ if (distributionPackageName === undefined) {
324
+ helper.throwUnsupportedPlatformError();
325
+ }
326
+
327
+ try {
328
+ require.resolve(`${distributionPackageName}/${distributionSubpath}`);
329
+ // If the `resolve` call succeeds it means a binary was installed successfully via optional dependencies so we can skip the manual postinstall download.
330
+ process.exit(0);
331
+ } catch (e) {
332
+ // Optional dependencies likely didn't get installed - proceed with fallback downloading manually
333
+ // Log message inspired by esbuild: https://github.com/evanw/esbuild/blob/914f6080c77cfe32a54888caa51ca6ea13873ce9/lib/npm/node-install.ts#L253
334
+ logger.log(
335
+ `Sentry CLI failed to locate the "${distributionPackageName}" package after installation!
336
+
337
+ This can happen if you use an option to disable optional dependencies during installation, like "--no-optional", "--ignore-optional", or "--omit=optional". Sentry CLI uses the "optionalDependencies" package.json feature to install the correct binary for your platform and operating system. This post-install script will now try to work around this by manually downloading the Sentry CLI binary from the Sentry CDN. If this fails, you need to remove the "--no-optional", "--ignore-optional", and "--omit=optional" flags for Sentry CLI to work.`
338
+ );
339
+
340
+ downloadBinary()
341
+ .then(() => checkVersion())
342
+ .then(() => {
343
+ process.exit(0);
344
+ })
345
+ .catch((e) => {
346
+ console.error(e);
347
+ process.exit(1);
348
+ });
349
+ }