@sentry/cli 1.77.0 → 1.77.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=18c1972b79aeaeacb86a512076f355a7a1fd0cf7c0830d41e99ac579f12d6533
2
- sentry-cli-Darwin-universal=56973c245b5288de36d3fcb3420d67dc7f04e26c2c1cd35379ce617491f1d837
3
- sentry-cli-Darwin-x86_64=e60f59132433c1ec50e8570766a644a1abcf0e6fdf1f2bcca6de852daa260b62
4
- sentry-cli-Linux-aarch64=629e731a9dd2e925934eeab5e33f02ba2b60e8c2224b95321ab117a775ed6861
5
- sentry-cli-Linux-armv7=a8fbf4543d42372743ee8bc0ea7b43cb60b78d3e260d355ad4855c3bacf53f5c
6
- sentry-cli-Linux-i686=9b8982a2ebec0ba0b6199e070362f26e916e79e7d923cf2615f0af85afd1171b
7
- sentry-cli-Linux-x86_64=55fe5bdd1112bd6ff625df8cf97aca3e61df52293ab5b7d8f7466f334298bb27
8
- sentry-cli-Windows-i686.exe=fd53c35331d6208d9c1a2bdfc156235dcabb841c66162070470946215d4d79dd
9
- sentry-cli-Windows-x86_64.exe=e40cf0bde9c64f9e1f9936350b80e2e14708bca7744ecba0494d489c1ad56eba
1
+ sentry-cli-Darwin-arm64=a69b907a4984a5d69fdb8fa018d08e45254e57a7038839a39deee09545137c9c
2
+ sentry-cli-Darwin-universal=88648343df5e7e6bbf7e95fb8c67681b7949fdc919c00c0acaedf2ac8e258acc
3
+ sentry-cli-Darwin-x86_64=26593639d98aa5e853951d1a4303ab578f1964545984b22e7f51feafcbe56152
4
+ sentry-cli-Linux-aarch64=62f023ef7741facc7d4faead1717840aa83572991f9bcf42172b0ad82f27a820
5
+ sentry-cli-Linux-armv7=23570b65e0c31428914d388b8e5e7ffb499627af810f60965517148cce0ac6fc
6
+ sentry-cli-Linux-i686=a8e77f18ddadb5035d1c54b5978d7528b87fda62804a19a272f21761cdd0c889
7
+ sentry-cli-Linux-x86_64=088ac6568445c4ebb5b82652190f51c711e13d40d5bd94a62cc37f2f1865412d
8
+ sentry-cli-Windows-i686.exe=1d8a960afa3e6ef6f08125974d2ae2e79e8a7b38ae30f7c0b7a32db26f8b8e8b
9
+ sentry-cli-Windows-x86_64.exe=6c30d85138bac891ba490a222870067c82c0617226bcd8b32768f11b7a5c9585
package/js/helper.js CHANGED
@@ -1,21 +1,30 @@
1
1
  'use strict';
2
2
 
3
+ const os = require('os');
3
4
  const path = require('path');
5
+ const fs = require('fs');
4
6
  const childProcess = require('child_process');
5
7
 
8
+ const BINARY_DISTRIBUTIONS = [
9
+ { packageName: '@sentry/cli-darwin', subpath: 'bin/sentry-cli' },
10
+ { packageName: '@sentry/cli-linux-x64', subpath: 'bin/sentry-cli' },
11
+ { packageName: '@sentry/cli-linux-i686', subpath: 'bin/sentry-cli' },
12
+ { packageName: '@sentry/cli-linux-arm64', subpath: 'bin/sentry-cli' },
13
+ { packageName: '@sentry/cli-linux-arm', subpath: 'bin/sentry-cli' },
14
+ { packageName: '@sentry/cli-win32-x64', subpath: 'bin/sentry-cli.exe' },
15
+ { packageName: '@sentry/cli-win32-i686', subpath: 'bin/sentry-cli.exe' },
16
+ ];
17
+
6
18
  /**
7
- * This convoluted function resolves the path to the `sentry-cli` binary in a
8
- * way that can't be analysed by @vercel/nft.
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.
9
21
  *
10
22
  * Without this, the binary can be detected as an asset and included by bundlers
11
23
  * that use @vercel/nft.
24
+ *
12
25
  * @returns {string} The path to the sentry-cli binary
13
26
  */
14
- function getBinaryPath() {
15
- if (process.env.SENTRY_BINARY_PATH) {
16
- return process.env.SENTRY_BINARY_PATH;
17
- }
18
-
27
+ function getFallbackBinaryPath() {
19
28
  const parts = [];
20
29
  parts.push(__dirname);
21
30
  parts.push('..');
@@ -23,19 +32,143 @@ function getBinaryPath() {
23
32
  return path.resolve(...parts);
24
33
  }
25
34
 
35
+ function getDistributionForThisPlatform() {
36
+ const arch = os.arch();
37
+ const platform = os.platform();
38
+
39
+ let packageName = undefined;
40
+ if (platform === 'darwin') {
41
+ packageName = '@sentry/cli-darwin';
42
+ } else if (platform === 'linux' || platform === 'freebsd') {
43
+ switch (arch) {
44
+ case 'x64':
45
+ packageName = '@sentry/cli-linux-x64';
46
+ break;
47
+ case 'x86':
48
+ case 'ia32':
49
+ packageName = '@sentry/cli-linux-i686';
50
+ break;
51
+ case 'arm64':
52
+ packageName = '@sentry/cli-linux-arm64';
53
+ break;
54
+ case 'arm':
55
+ packageName = '@sentry/cli-linux-arm';
56
+ break;
57
+ }
58
+ } else if (platform === 'win32') {
59
+ switch (arch) {
60
+ case 'x64':
61
+ packageName = '@sentry/cli-win32-x64';
62
+ break;
63
+ case 'x86':
64
+ case 'ia32':
65
+ packageName = '@sentry/cli-win32-i686';
66
+ break;
67
+ }
68
+ }
69
+
70
+ let subpath = undefined;
71
+ switch (platform) {
72
+ case 'win32':
73
+ subpath = 'bin/sentry-cli.exe';
74
+ break;
75
+ case 'darwin':
76
+ case 'linux':
77
+ case 'freebsd':
78
+ subpath = 'bin/sentry-cli';
79
+ break;
80
+ default:
81
+ subpath = 'bin/sentry-cli';
82
+ break;
83
+ }
84
+
85
+ return { packageName, subpath };
86
+ }
87
+
88
+ /**
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.
107
+ *
108
+ * @returns {string} The path to the sentry-cli binary
109
+ */
110
+ function getBinaryPath() {
111
+ if (process.env.SENTRY_BINARY_PATH) {
112
+ return process.env.SENTRY_BINARY_PATH;
113
+ }
114
+
115
+ const { packageName, subpath } = getDistributionForThisPlatform();
116
+
117
+ if (packageName === undefined) {
118
+ throwUnsupportedPlatformError();
119
+ }
120
+
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;
125
+ }
126
+
127
+ let compatibleBinaryPath;
128
+ try {
129
+ compatibleBinaryPath = require.resolve(`${packageName}/${subpath}`);
130
+ } catch (e) {
131
+ const otherInstalledDistribution = BINARY_DISTRIBUTIONS.find(({ packageName, subpath }) => {
132
+ try {
133
+ require.resolve(`${packageName}/${subpath}`);
134
+ return true;
135
+ } catch (e) {
136
+ return false;
137
+ }
138
+ });
139
+
140
+ // These error messages are heavily inspired by esbuild's error messages: https://github.com/evanw/esbuild/blob/f3d535262e3998d845d0f102b944ecd5a9efda57/lib/npm/node-platform.ts#L150
141
+ if (otherInstalledDistribution) {
142
+ throw new Error(`Sentry CLI binary for this platform/architecture not found!
143
+
144
+ The "${otherInstalledDistribution.packageName}" package is installed, but for the current platform, you should have the "${packageName}" package installed instead. This usually happens if the "@sentry/cli" package is installed on one platform (for example Windows or MacOS) and then the "node_modules" folder is reused on another operating system (for example Linux in Docker).
145
+
146
+ To fix this, avoid copying the "node_modules" folder, and instead freshly install your dependencies on the target system. You can also configure your package manager to install the right package. For example, yarn has the "supportedArchitectures" feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitecture.`);
147
+ } else {
148
+ throw new Error(`Sentry CLI binary for this platform/architecture not found!
149
+
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.`);
151
+ }
152
+ }
153
+
154
+ return compatibleBinaryPath;
155
+ }
156
+
26
157
  /**
27
- * Absolute path to the sentry-cli binary (platform dependent).
28
- * @type {string}
158
+ * Will be used as the binary path when defined with `mockBinaryPath`.
159
+ * @type {string | undefined}
29
160
  */
30
- let binaryPath = getBinaryPath();
161
+ let mockedBinaryPath;
31
162
 
32
163
  /**
33
164
  * Overrides the default binary path with a mock value, useful for testing.
34
165
  *
35
166
  * @param {string} mockPath The new path to the mock sentry-cli binary
167
+ * @deprecated This was used in tests internally and will be removed in the next major version.
36
168
  */
169
+ // TODO(v3): Remove this function
37
170
  function mockBinaryPath(mockPath) {
38
- binaryPath = mockPath;
171
+ mockedBinaryPath = mockPath;
39
172
  }
40
173
 
41
174
  /**
@@ -121,7 +254,7 @@ function prepareCommand(command, schema, options) {
121
254
  * @returns {string}
122
255
  */
123
256
  function getPath() {
124
- return binaryPath;
257
+ return mockedBinaryPath !== undefined ? mockedBinaryPath : getBinaryPath();
125
258
  }
126
259
 
127
260
  /**
@@ -217,4 +350,7 @@ module.exports = {
217
350
  mockBinaryPath,
218
351
  prepareCommand,
219
352
  serializeOptions,
353
+ getDistributionForThisPlatform,
354
+ throwUnsupportedPlatformError,
355
+ getFallbackBinaryPath,
220
356
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/cli",
3
- "version": "1.77.0",
3
+ "version": "1.77.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/",
@@ -27,10 +27,19 @@
27
27
  "eslint-config-prettier": "^8.5.0",
28
28
  "jest": "^27.5.1",
29
29
  "npm-run-all": "^4.1.5",
30
- "prettier": "^2.6.2"
30
+ "prettier": "2.8.8"
31
+ },
32
+ "optionalDependencies": {
33
+ "@sentry/cli-darwin": "1.77.2",
34
+ "@sentry/cli-linux-arm": "1.77.2",
35
+ "@sentry/cli-linux-arm64": "1.77.2",
36
+ "@sentry/cli-linux-i686": "1.77.2",
37
+ "@sentry/cli-linux-x64": "1.77.2",
38
+ "@sentry/cli-win32-i686": "1.77.2",
39
+ "@sentry/cli-win32-x64": "1.77.2"
31
40
  },
32
41
  "scripts": {
33
- "install": "node ./scripts/install.js",
42
+ "postinstall": "node ./scripts/install.js",
34
43
  "fix": "npm-run-all fix:eslint fix:prettier",
35
44
  "fix:eslint": "eslint --fix bin/* scripts/**/*.js js/**/*.js",
36
45
  "fix:prettier": "prettier --write bin/* scripts/**/*.js js/**/*.js",
@@ -49,7 +58,7 @@
49
58
  ]
50
59
  },
51
60
  "volta": {
52
- "node": "10.24.1",
61
+ "node": "20.10.0",
53
62
  "yarn": "1.22.19"
54
63
  }
55
64
  }
@@ -21,4 +21,17 @@ cargo update -p sentry-cli
21
21
 
22
22
  # Do not tag and commit changes made by "npm version"
23
23
  export npm_config_git_tag_version=false
24
+
25
+ # Bump main sentry cli npm package
24
26
  npm version "${TARGET}"
27
+
28
+ # Bump the binary npm distributions
29
+ for dir in $SCRIPT_DIR/../npm-binary-distributions/*; do
30
+ cd $dir
31
+ npm version "${TARGET}"
32
+ cd -
33
+ done
34
+
35
+ # Update the optional deps in the main cli npm package
36
+ # Requires jq to be installed - should be installed ootb on github runners
37
+ jq '.optionalDependencies |= map_values("'"${TARGET}"'")' $SCRIPT_DIR/../package.json > package.json.tmp && mv package.json.tmp $SCRIPT_DIR/../package.json
@@ -3,7 +3,6 @@
3
3
  'use strict';
4
4
 
5
5
  const fs = require('fs');
6
- const http = require('http');
7
6
  const os = require('os');
8
7
  const path = require('path');
9
8
  const crypto = require('crypto');
@@ -79,6 +78,10 @@ function getDownloadUrl(platform, arch) {
79
78
  case 'darwin':
80
79
  return `${releasesUrl}-Darwin-universal`;
81
80
  case 'win32':
81
+ // Windows arm machines can run x64 binaries
82
+ if (arch === 'arm64') {
83
+ archString = 'x86_64';
84
+ }
82
85
  return `${releasesUrl}-Windows-${archString}.exe`;
83
86
  case 'linux':
84
87
  case 'freebsd':
@@ -189,7 +192,7 @@ function validateChecksum(tempPath, name) {
189
192
  async function downloadBinary() {
190
193
  const arch = os.arch();
191
194
  const platform = os.platform();
192
- const outputPath = helper.getPath();
195
+ const outputPath = helper.getFallbackBinaryPath();
193
196
 
194
197
  if (process.env.SENTRYCLI_USE_LOCAL === '1') {
195
198
  try {
@@ -303,40 +306,44 @@ async function downloadBinary() {
303
306
  async function checkVersion() {
304
307
  const output = await helper.execute(['--version']);
305
308
  const version = output.replace('sentry-cli ', '').trim();
306
- const expected = process.env.SENTRYCLI_LOCAL_CDNURL ? 'DEV' : pkgInfo.version;
309
+ const expected = pkgInfo.version;
307
310
  if (version !== expected) {
308
311
  throw new Error(`Unexpected sentry-cli version "${version}", expected "${expected}"`);
309
312
  }
310
313
  }
311
314
 
312
- if (process.env.SENTRYCLI_LOCAL_CDNURL) {
313
- // For testing, mock the CDN by spawning a local server
314
- const server = http.createServer((request, response) => {
315
- const contents = fs.readFileSync(path.join(__dirname, '../js/__mocks__/sentry-cli'));
316
- response.writeHead(200, {
317
- 'Content-Type': 'application/octet-stream',
318
- 'Content-Length': String(contents.byteLength),
319
- });
320
- response.end(contents);
321
- });
322
-
323
- server.listen(8999);
324
- process.on('exit', () => server.close());
325
- }
326
-
327
315
  if (process.env.SENTRYCLI_SKIP_DOWNLOAD === '1') {
328
316
  logger.log(`Skipping download because SENTRYCLI_SKIP_DOWNLOAD=1 detected.`);
329
317
  process.exit(0);
330
318
  }
331
319
 
332
- (async () => {
333
- try {
334
- await downloadBinary();
335
- await checkVersion();
336
- process.exit(0);
337
- } catch (e) {
338
- // eslint-disable-next-line no-console
339
- console.error(e.toString());
340
- process.exit(1);
341
- }
342
- })();
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
+ }