@vroskus/upload-sourcemaps 1.0.0
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/README.md +38 -0
- package/bin/index.js +90 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @vroskus/upload-sourcemaps
|
|
2
|
+
|
|
3
|
+
Tool for uploading project sourcemaps to Sentry.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Call:
|
|
8
|
+
|
|
9
|
+
`npm install -D @vroskus/upload-sourcemaps`
|
|
10
|
+
|
|
11
|
+
`yarn add -D @vroskus/upload-sourcemaps`
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
1. Ensure that you have added configuration to package.json. Example:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
// package.json
|
|
19
|
+
...
|
|
20
|
+
"uploadSourcemapsConfig": {
|
|
21
|
+
"org": "<Sentry Organization slug>",
|
|
22
|
+
"project": "<Sentry Project slug>",
|
|
23
|
+
"authToken": "<Sentry Authentication token for API>",
|
|
24
|
+
"filesPath": "Path to sourcemap files (optional)"
|
|
25
|
+
}
|
|
26
|
+
...
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
2. Call `upload-sourcemaps` after running build. Example:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
// package.json
|
|
33
|
+
...
|
|
34
|
+
"scripts": {
|
|
35
|
+
"upload:sourcemaps": "upload-sourcemaps",
|
|
36
|
+
}
|
|
37
|
+
...
|
|
38
|
+
```
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const SentryCli = require('@sentry/cli');
|
|
5
|
+
|
|
6
|
+
const getPackageJson = () => {
|
|
7
|
+
const file = fs.readFileSync('./package.json');
|
|
8
|
+
|
|
9
|
+
if (file) {
|
|
10
|
+
return JSON.parse(file);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const getConfig = () => {
|
|
17
|
+
const packageJson = getPackageJson();
|
|
18
|
+
|
|
19
|
+
if (packageJson === null) {
|
|
20
|
+
console.warning('Unable to get package.json');
|
|
21
|
+
|
|
22
|
+
return process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
uploadSourcemapsConfig,
|
|
27
|
+
version,
|
|
28
|
+
} = packageJson;
|
|
29
|
+
|
|
30
|
+
if (!version) {
|
|
31
|
+
console.warn('"version" is not set in package.json');
|
|
32
|
+
|
|
33
|
+
return process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!uploadSourcemapsConfig) {
|
|
37
|
+
console.warn('"uploadSourcemapsConfig" is not set in package.json');
|
|
38
|
+
|
|
39
|
+
return process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
uploadSourcemapsConfig,
|
|
44
|
+
version,
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
async function createReleaseAndUpload() {
|
|
49
|
+
try {
|
|
50
|
+
const {
|
|
51
|
+
uploadSourcemapsConfig,
|
|
52
|
+
version,
|
|
53
|
+
} = getConfig();
|
|
54
|
+
|
|
55
|
+
const cli = new SentryCli(
|
|
56
|
+
null,
|
|
57
|
+
uploadSourcemapsConfig,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
console.log(`Creating sentry release ${version}`);
|
|
61
|
+
|
|
62
|
+
await cli.releases.new(version);
|
|
63
|
+
|
|
64
|
+
console.log('Uploading source maps');
|
|
65
|
+
|
|
66
|
+
const filesPath = uploadSourcemapsConfig.filesPath || './dist';
|
|
67
|
+
|
|
68
|
+
await cli.releases.uploadSourceMaps(
|
|
69
|
+
version,
|
|
70
|
+
{
|
|
71
|
+
include: [filesPath],
|
|
72
|
+
rewrite: false,
|
|
73
|
+
urlPrefix: `~${filesPath}`,
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
console.log(`Finalizing release ${version}`);
|
|
78
|
+
|
|
79
|
+
await cli.releases.finalize(version);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
console.error(
|
|
82
|
+
'Source maps uploading failed:',
|
|
83
|
+
e,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return process.exit(0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
createReleaseAndUpload();
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vroskus/upload-sourcemaps",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/vroskus/upload-sourcemaps.git"
|
|
8
|
+
},
|
|
9
|
+
"description": "Tool for uploading project sourcemaps to Sentry",
|
|
10
|
+
"author": "Vilius Roškus",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"sourcemaps",
|
|
13
|
+
"sentry"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=8"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"upload-sourcemaps": "bin/index.js"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "echo 'No tests yet'"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@sentry/cli": "^2.13.0"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/vroskus/upload-sourcemaps/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/vroskus/upload-sourcemaps#readme",
|
|
31
|
+
"main": "bin/index.js"
|
|
32
|
+
}
|