Skip to content

Commit f167a81

Browse files
authored
ref: Transition to binaries over npm (#1836)
1 parent 67826f6 commit f167a81

File tree

11 files changed

+37
-89
lines changed

11 files changed

+37
-89
lines changed

.eslintrc

+9-7
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
"node": true
66
},
77
"parserOptions": {
8-
"ecmaVersion": "latest"
8+
"ecmaVersion": 9
99
},
10-
"overrides": [{
11-
"env": {
12-
"jest": true
13-
},
14-
"files": ["*.test.js"]
15-
}]
10+
"overrides": [
11+
{
12+
"env": {
13+
"jest": true
14+
},
15+
"files": ["*.test.js"]
16+
}
17+
]
1618
}

.github/workflows/ci.yml

+1-44
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
strategy:
7575
fail-fast: false
7676
matrix:
77-
node-version: [10.x, 12.x, 14.x, 16.x, 18.x]
77+
node-version: [10.x, 12.x, 14.x, 16.x, 18.x, 20.x]
7878

7979
name: Test Node ${{ matrix.node-version }}
8080
runs-on: ubuntu-latest
@@ -88,52 +88,9 @@ jobs:
8888
node-version: ${{ matrix.node-version }}
8989

9090
- run: npm install
91-
env:
92-
SENTRYCLI_LOCAL_CDNURL: 'http://localhost:8999/'
9391

9492
# older node versions need an older nft
9593
- run: npm install @vercel/[email protected]
9694
if: matrix.node-version == '10.x' || matrix.node-version == '12.x'
9795

9896
- run: npm test
99-
100-
test_install:
101-
# Don't run install test on release branches, as at this point binaries were not published to CDN yet.
102-
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
103-
104-
strategy:
105-
fail-fast: false
106-
matrix:
107-
node-version: [10.x, 12.x, 14.x, 16.x, 18.x]
108-
109-
name: Test install script on Node ${{ matrix.node-version }}
110-
runs-on: ubuntu-latest
111-
112-
steps:
113-
- uses: actions/checkout@v2
114-
with:
115-
path: sentry-cli-dep
116-
117-
- name: Use Node.js ${{ matrix.node-version }}
118-
uses: actions/setup-node@v1
119-
with:
120-
node-version: ${{ matrix.node-version }}
121-
122-
- name: Setup empty test app
123-
run: mkdir test-app && cd test-app && npm init --yes
124-
125-
- name: Install @sentry/cli
126-
run: npm install ../sentry-cli-dep --install-links
127-
working-directory: ./test-app
128-
129-
- name: Ensure binary can be called from paths
130-
run: |
131-
node_modules/.bin/sentry-cli help
132-
node_modules/@sentry/cli/sentry-cli help
133-
working-directory: ./test-app
134-
135-
- name: Install @sentry/cli globally
136-
run: npm install ./sentry-cli-dep --install-links -g
137-
138-
- name: Ensure binary is installed globally
139-
run: sentry-cli help

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ coverage
66
dist
77
dump
88
checksums.txt
9+
yarn-error.log
910

1011
/sentry-cli
1112
/sentry-cli.exe

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
"You know what they say. Fool me once, strike one, but fool me twice... strike three." — Michael Scott
44

5+
## 2.22.3
6+
7+
ref: Transition to binaries over npm (#1836)
8+
59
## 2.22.2
610

711
This release contains no changes and was done for technical purposes.

jest.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
setupFiles: ['<rootDir>/setupTests.js'],
3+
testPathIgnorePatterns: ['<rootDir>/src/'],
4+
};

js/__tests__/helper.test.js

-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
const os = require('os');
2-
const path = require('path');
32

43
const helper = require('../helper');
54

65
const SOURCEMAPS_OPTIONS = require('../releases/options/uploadSourcemaps');
76

87
describe('SentryCli helper', () => {
9-
beforeEach(() => {
10-
helper.mockBinaryPath(path.resolve(__dirname, '../__mocks__/sentry-cli'));
11-
});
12-
138
test('call sentry-cli --version', () => {
149
expect.assertions(1);
1510
return helper

js/helper.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const os = require('os');
4-
const path = require('path');
54
const childProcess = require('child_process');
65

76
const BINARY_DISTRIBUTIONS = [
@@ -80,14 +79,6 @@ function getBinaryPath() {
8079
return process.env.SENTRY_BINARY_PATH;
8180
}
8281

83-
if (!process.env.USE_SENTRY_BINARY_NPM_DISTRIBUTION) {
84-
const parts = [];
85-
parts.push(__dirname);
86-
parts.push('..');
87-
parts.push(`sentry-cli${process.platform === 'win32' ? '.exe' : ''}`);
88-
return path.resolve(...parts);
89-
}
90-
9182
const { packageName, subpath } = getDistributionForThisPlatform();
9283

9384
if (packageName === undefined) {
@@ -141,7 +132,9 @@ let binaryPath = getBinaryPath();
141132
* Overrides the default binary path with a mock value, useful for testing.
142133
*
143134
* @param {string} mockPath The new path to the mock sentry-cli binary
135+
* @deprecated This was used in tests internally and will be removed in the next major version.
144136
*/
137+
// TODO(v3): Remove this function
145138
function mockBinaryPath(mockPath) {
146139
binaryPath = mockPath;
147140
}

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"eslint-config-prettier": "^8.5.0",
2828
"jest": "^27.5.1",
2929
"npm-run-all": "^4.1.5",
30-
"prettier": "^2.6.2"
30+
"prettier": "2.8.8"
3131
},
3232
"optionalDependencies": {
3333
"@sentry/cli-darwin": "2.22.2",
@@ -39,7 +39,6 @@
3939
"@sentry/cli-win32-x64": "2.22.2"
4040
},
4141
"scripts": {
42-
"install": "node ./scripts/install.js",
4342
"fix": "npm-run-all fix:eslint fix:prettier",
4443
"fix:eslint": "eslint --fix bin/* scripts/**/*.js js/**/*.js",
4544
"fix:prettier": "prettier --write bin/* scripts/**/*.js js/**/*.js",
@@ -58,7 +57,7 @@
5857
]
5958
},
6059
"volta": {
61-
"node": "10.24.1",
60+
"node": "20.10.0",
6261
"yarn": "1.22.19"
6362
}
6463
}

scripts/install.js

+7-17
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
'use strict';
44

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+
511
const fs = require('fs');
6-
const http = require('http');
712
const os = require('os');
813
const path = require('path');
914
const crypto = require('crypto');
@@ -303,27 +308,12 @@ async function downloadBinary() {
303308
async function checkVersion() {
304309
const output = await helper.execute(['--version']);
305310
const version = output.replace('sentry-cli ', '').trim();
306-
const expected = process.env.SENTRYCLI_LOCAL_CDNURL ? 'DEV' : pkgInfo.version;
311+
const expected = pkgInfo.version;
307312
if (version !== expected) {
308313
throw new Error(`Unexpected sentry-cli version "${version}", expected "${expected}"`);
309314
}
310315
}
311316

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-
327317
if (process.env.SENTRYCLI_SKIP_DOWNLOAD === '1') {
328318
logger.log(`Skipping download because SENTRYCLI_SKIP_DOWNLOAD=1 detected.`);
329319
process.exit(0);

setupTests.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const path = require('path');
2+
3+
process.env.SENTRY_BINARY_PATH = path.join(__dirname, 'js', '__mocks__', 'sentry-cli');

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -3069,10 +3069,10 @@ prelude-ls@~1.1.2:
30693069
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
30703070
integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==
30713071

3072-
prettier@^2.6.2:
3073-
version "2.8.3"
3074-
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.3.tgz#ab697b1d3dd46fb4626fbe2f543afe0cc98d8632"
3075-
integrity sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==
3072+
prettier@2.8.8:
3073+
version "2.8.8"
3074+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
3075+
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
30763076

30773077
pretty-format@^27.5.1:
30783078
version "27.5.1"

0 commit comments

Comments
 (0)