sentry-cli 2.20.2__tar.gz → 2.20.4__tar.gz
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.
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/Cargo.lock +23 -3
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/Cargo.toml +3 -2
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/PKG-INFO +1 -1
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/sentry_cli.egg-info/PKG-INFO +1 -1
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/releases/set_commits.rs +5 -3
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/sourcemaps/inject.rs +61 -218
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/sourcemaps.rs +144 -112
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/LICENSE +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/MANIFEST.in +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/README.md +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/build.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/pyproject.toml +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/sentry_cli.egg-info/SOURCES.txt +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/sentry_cli.egg-info/dependency_links.txt +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/sentry_cli.egg-info/top_level.txt +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/setup.cfg +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/setup.py +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/api.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/bashsupport.sh +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/bash_hook.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/debug_files/bundle_jvm.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/debug_files/bundle_sources.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/debug_files/check.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/debug_files/find.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/debug_files/mod.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/debug_files/print_sources.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/debug_files/upload.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/deploys/list.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/deploys/mod.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/deploys/new.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/events/list.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/events/mod.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/files/delete.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/files/list.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/files/mod.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/files/upload.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/info.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/issues/list.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/issues/mod.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/issues/mute.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/issues/resolve.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/issues/unresolve.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/login.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/mod.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/monitors/list.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/monitors/mod.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/monitors/run.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/organizations/list.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/organizations/mod.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/projects/list.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/projects/mod.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/react_native/appcenter.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/react_native/gradle.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/react_native/mod.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/react_native/xcode.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/releases/archive.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/releases/delete.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/releases/finalize.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/releases/info.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/releases/list.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/releases/mod.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/releases/new.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/releases/propose_version.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/releases/restore.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/repos/list.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/repos/mod.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/send_envelope.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/send_event.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/sourcemaps/explain.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/sourcemaps/inject.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/sourcemaps/mod.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/sourcemaps/resolve.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/sourcemaps/upload.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/uninstall.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/update.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/upload_dif.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/upload_dsym.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/commands/upload_proguard.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/config.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/constants.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/main.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/android.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/appcenter.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/args.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/chunks.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/codepush.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/cordova.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/dif.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/dif_upload.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/enc.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/event.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/file_search.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/file_upload.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/formatting.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/fs.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/http.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/logging.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/mod.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/progress.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/releases.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/retry.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/snapshots/sentry_cli__utils__vcs__generate_patch_default_twenty.snap +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/snapshots/sentry_cli__utils__vcs__generate_patch_ignore_missing.snap +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/snapshots/sentry_cli__utils__vcs__generate_patch_set_base.snap +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/snapshots/sentry_cli__utils__vcs__generate_patch_set_previous_commit.snap +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/snapshots/sentry_cli__utils__vcs__get_commits_from_git.snap +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/system.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/ui.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/update.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/vcs.rs +0 -0
- {sentry_cli-2.20.2 → sentry_cli-2.20.4}/src/utils/xcode.rs +0 -0
|
@@ -1326,6 +1326,19 @@ dependencies = [
|
|
|
1326
1326
|
"cc",
|
|
1327
1327
|
]
|
|
1328
1328
|
|
|
1329
|
+
[[package]]
|
|
1330
|
+
name = "magic_string"
|
|
1331
|
+
version = "0.3.4"
|
|
1332
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1333
|
+
checksum = "6c8033ce8c43f7ccb207e4699f30eed50d7526379ee08fab47159f80b7934e18"
|
|
1334
|
+
dependencies = [
|
|
1335
|
+
"base64",
|
|
1336
|
+
"regex",
|
|
1337
|
+
"serde",
|
|
1338
|
+
"serde_json",
|
|
1339
|
+
"vlq",
|
|
1340
|
+
]
|
|
1341
|
+
|
|
1329
1342
|
[[package]]
|
|
1330
1343
|
name = "match_cfg"
|
|
1331
1344
|
version = "0.1.0"
|
|
@@ -2189,7 +2202,7 @@ dependencies = [
|
|
|
2189
2202
|
|
|
2190
2203
|
[[package]]
|
|
2191
2204
|
name = "sentry-cli"
|
|
2192
|
-
version = "2.20.
|
|
2205
|
+
version = "2.20.4"
|
|
2193
2206
|
dependencies = [
|
|
2194
2207
|
"anyhow",
|
|
2195
2208
|
"anylog",
|
|
@@ -2221,6 +2234,7 @@ dependencies = [
|
|
|
2221
2234
|
"libc",
|
|
2222
2235
|
"log",
|
|
2223
2236
|
"mac-process-info",
|
|
2237
|
+
"magic_string",
|
|
2224
2238
|
"might-be-minified",
|
|
2225
2239
|
"mockito",
|
|
2226
2240
|
"open",
|
|
@@ -2468,9 +2482,9 @@ dependencies = [
|
|
|
2468
2482
|
|
|
2469
2483
|
[[package]]
|
|
2470
2484
|
name = "sourcemap"
|
|
2471
|
-
version = "6.
|
|
2485
|
+
version = "6.4.0"
|
|
2472
2486
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
2473
|
-
checksum = "
|
|
2487
|
+
checksum = "e9221a6bba3e9cfa7decfe64edf5233311e1bf837ea3234df6e7f35836e1093d"
|
|
2474
2488
|
dependencies = [
|
|
2475
2489
|
"data-encoding",
|
|
2476
2490
|
"debugid",
|
|
@@ -2947,6 +2961,12 @@ version = "0.9.4"
|
|
|
2947
2961
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
2948
2962
|
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
|
2949
2963
|
|
|
2964
|
+
[[package]]
|
|
2965
|
+
name = "vlq"
|
|
2966
|
+
version = "0.5.1"
|
|
2967
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
2968
|
+
checksum = "65dd7eed29412da847b0f78bcec0ac98588165988a8cfe41d4ea1d429f8ccfff"
|
|
2969
|
+
|
|
2950
2970
|
[[package]]
|
|
2951
2971
|
name = "wait-timeout"
|
|
2952
2972
|
version = "0.2.0"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
authors = ["Armin Ronacher <armin.ronacher@active-4.com>"]
|
|
3
3
|
build = "build.rs"
|
|
4
4
|
name = "sentry-cli"
|
|
5
|
-
version = "2.20.
|
|
5
|
+
version = "2.20.4"
|
|
6
6
|
edition = "2021"
|
|
7
7
|
rust-version = "1.65"
|
|
8
8
|
|
|
@@ -65,7 +65,7 @@ sentry = { version = "0.31.2", default-features = false, features = [
|
|
|
65
65
|
serde = { version = "1.0.152", features = ["derive"] }
|
|
66
66
|
serde_json = "1.0.93"
|
|
67
67
|
sha1_smol = { version = "1.0.0", features = ["serde"] }
|
|
68
|
-
sourcemap = { version = "6.
|
|
68
|
+
sourcemap = { version = "6.4.0", features = ["ram_bundle"] }
|
|
69
69
|
symbolic = { version = "12.1.5", features = ["debuginfo-serde", "il2cpp"] }
|
|
70
70
|
thiserror = "1.0.38"
|
|
71
71
|
url = "2.3.1"
|
|
@@ -75,6 +75,7 @@ walkdir = "2.3.2"
|
|
|
75
75
|
which = "4.4.0"
|
|
76
76
|
zip = "0.6.4"
|
|
77
77
|
data-encoding = "2.3.3"
|
|
78
|
+
magic_string = "0.3.4"
|
|
78
79
|
|
|
79
80
|
[dev-dependencies]
|
|
80
81
|
insta = { version = "1.26.0", features = ["redactions", "yaml"] }
|
|
@@ -34,7 +34,7 @@ pub fn make_command(command: Command) -> Command {
|
|
|
34
34
|
will create a release with the default commits count (or the one specified with `--initial-depth`) \
|
|
35
35
|
instead of failing the command."))
|
|
36
36
|
.arg(Arg::new("local")
|
|
37
|
-
.conflicts_with_all(["auto", "clear", "commits"
|
|
37
|
+
.conflicts_with_all(["auto", "clear", "commits"])
|
|
38
38
|
.long("local")
|
|
39
39
|
.action(ArgAction::SetTrue)
|
|
40
40
|
.help("Set commits of a release from local git.{n}\
|
|
@@ -42,7 +42,6 @@ pub fn make_command(command: Command) -> Command {
|
|
|
42
42
|
sentry-cli will then automatically find remotely configured \
|
|
43
43
|
repositories and discover commits."))
|
|
44
44
|
.arg(Arg::new("initial-depth")
|
|
45
|
-
.conflicts_with("auto")
|
|
46
45
|
.long("initial-depth")
|
|
47
46
|
.value_name("INITIAL DEPTH")
|
|
48
47
|
.value_parser(clap::value_parser!(usize))
|
|
@@ -107,7 +106,10 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
|
|
|
107
106
|
if let Some(commits) = matches.get_many::<String>("commits") {
|
|
108
107
|
for spec in commits {
|
|
109
108
|
let commit_spec = CommitSpec::parse(spec)?;
|
|
110
|
-
if repos
|
|
109
|
+
if repos
|
|
110
|
+
.iter()
|
|
111
|
+
.any(|r| r.name.to_lowercase() == commit_spec.repo.to_lowercase())
|
|
112
|
+
{
|
|
111
113
|
commit_specs.push(commit_spec);
|
|
112
114
|
} else {
|
|
113
115
|
bail!("Unknown repo '{}'", commit_spec.repo);
|
|
@@ -7,18 +7,26 @@ use std::fmt;
|
|
|
7
7
|
use std::io::{BufRead, Write};
|
|
8
8
|
use std::path::PathBuf;
|
|
9
9
|
|
|
10
|
-
use anyhow::
|
|
10
|
+
use anyhow::Result;
|
|
11
11
|
use lazy_static::lazy_static;
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
use magic_string::{GenerateDecodedMapOptions, MagicString};
|
|
13
14
|
use sentry::types::DebugId;
|
|
14
|
-
use
|
|
15
|
+
use sourcemap::SourceMap;
|
|
15
16
|
|
|
16
17
|
const CODE_SNIPPET_TEMPLATE: &str = r#"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="__SENTRY_DEBUG_ID__")}catch(e){}}();"#;
|
|
17
18
|
const DEBUGID_PLACEHOLDER: &str = "__SENTRY_DEBUG_ID__";
|
|
18
19
|
const DEBUGID_COMMENT_PREFIX: &str = "//# debugId";
|
|
19
20
|
|
|
20
21
|
lazy_static! {
|
|
21
|
-
|
|
22
|
+
// A regex that captures
|
|
23
|
+
// 1. an optional initial hashbang,
|
|
24
|
+
// 2. a block of line comments, block comments, and empty lines,
|
|
25
|
+
// 3. and an optional `"use strict";` statement.`
|
|
26
|
+
static ref PRE_INJECT_RE: Regex = Regex::new(
|
|
27
|
+
r#"^(#!.*[\n\r])?(?:\s*|/\*(?:.|\r|\n)*?\*/|//.*[\n\r])*(?:"[^"]*";|'[^']*';[\n\r]?)?"#
|
|
28
|
+
)
|
|
29
|
+
.unwrap();
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
fn print_section_with_debugid(
|
|
@@ -105,110 +113,48 @@ impl fmt::Display for InjectReport {
|
|
|
105
113
|
/// `<CODE_SNIPPET>[<debug_id>]`
|
|
106
114
|
/// is inserted at the earliest possible position, which is after an
|
|
107
115
|
/// optional hashbang, followed by a
|
|
108
|
-
/// block of comments, empty lines, and `"use […]";` or `'use […]';`
|
|
116
|
+
/// block of comments, empty lines, and an optional `"use […]";` or `'use […]';` pragma.
|
|
109
117
|
/// 2. A comment of the form `//# debugId=<debug_id>` is appended to the file.
|
|
110
|
-
/// 3. The last source mapping comment (a comment starting with
|
|
111
|
-
/// `//# sourceMappingURL=` or `//@ sourceMappingURL=`) is moved to
|
|
112
|
-
/// the very end of the file, after the debug id comment from 2.
|
|
113
|
-
///
|
|
114
|
-
/// This function will naturally mess with the correspondence between a source file
|
|
115
|
-
/// and its sourcemap. Use [`insert_empty_mapping`] on the sourcemap to fix this.
|
|
116
|
-
/// # Example
|
|
117
|
-
/// ```
|
|
118
|
-
/// let file = "
|
|
119
|
-
/// // a
|
|
120
|
-
/// // comment
|
|
121
|
-
/// // block
|
|
122
|
-
///
|
|
123
|
-
/// // another
|
|
124
|
-
/// // comment
|
|
125
|
-
/// // block
|
|
126
|
-
///
|
|
127
|
-
/// 'use strict';
|
|
128
|
-
/// function t(t) {
|
|
129
|
-
/// return '[object Object]' === Object.prototype.toString.call(t);
|
|
130
|
-
/// }
|
|
131
|
-
/// //# sourceMappingURL=/path/to/sourcemap
|
|
132
|
-
/// ";
|
|
133
|
-
///
|
|
134
|
-
/// let mut file = file.as_bytes().to_vec();
|
|
135
|
-
/// fixup_js_file(&mut file, DebugId::default()).unwrap();
|
|
136
|
-
///
|
|
137
|
-
/// assert_eq!(
|
|
138
|
-
/// std::str::from_utf8(&file).unwrap(),
|
|
139
|
-
/// r#"
|
|
140
|
-
/// // a
|
|
141
|
-
/// // comment
|
|
142
|
-
/// // block
|
|
143
|
-
///
|
|
144
|
-
/// // another
|
|
145
|
-
/// // comment
|
|
146
|
-
/// // block
|
|
147
118
|
///
|
|
148
|
-
///
|
|
149
|
-
///
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
/// }
|
|
153
|
-
/// //# debugId=00000000-0000-0000-0000-000000000000
|
|
154
|
-
/// //# sourceMappingURL=/path/to/sourcemap
|
|
155
|
-
/// "#
|
|
156
|
-
/// );
|
|
157
|
-
/// ```
|
|
158
|
-
pub fn fixup_js_file(js_contents: &mut Vec<u8>, debug_id: DebugId) -> Result<()> {
|
|
159
|
-
let mut js_lines = js_contents.lines().collect::<Result<Vec<_>, _>>()?;
|
|
119
|
+
/// This function returns a [`SourceMap`] that maps locations in the injected file
|
|
120
|
+
/// to their corresponding places in the original file.
|
|
121
|
+
pub fn fixup_js_file(js_contents: &mut Vec<u8>, debug_id: DebugId) -> Result<SourceMap> {
|
|
122
|
+
let contents = std::str::from_utf8(js_contents)?;
|
|
160
123
|
|
|
161
|
-
|
|
124
|
+
let m = PRE_INJECT_RE
|
|
125
|
+
.find(contents)
|
|
126
|
+
.expect("regex is infallible")
|
|
127
|
+
.range();
|
|
162
128
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
.
|
|
166
|
-
|
|
167
|
-
.rev()
|
|
168
|
-
.find(|(_idx, line)| {
|
|
169
|
-
line.starts_with("//# sourceMappingURL=") || line.starts_with("//@ sourceMappingURL=")
|
|
170
|
-
})
|
|
171
|
-
.map(|(idx, _)| idx);
|
|
172
|
-
|
|
173
|
-
let sourcemap_comment = sourcemap_comment_idx.map(|idx| js_lines.remove(idx));
|
|
129
|
+
let code_snippet = format!(
|
|
130
|
+
"\n{}\n",
|
|
131
|
+
CODE_SNIPPET_TEMPLATE.replace(DEBUGID_PLACEHOLDER, &debug_id.to_string())
|
|
132
|
+
);
|
|
174
133
|
|
|
175
|
-
let
|
|
176
|
-
|
|
177
|
-
// Handle initial hashbang
|
|
178
|
-
if let Some(hashbang) = js_lines.next_if(|line| line.trim().starts_with("#!")) {
|
|
179
|
-
writeln!(js_contents, "{hashbang}")?;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Write comments and empty lines at the start back to the file
|
|
183
|
-
while let Some(comment_or_empty) =
|
|
184
|
-
js_lines.next_if(|line| line.trim().is_empty() || line.trim().starts_with("//"))
|
|
185
|
-
{
|
|
186
|
-
writeln!(js_contents, "{comment_or_empty}")?;
|
|
187
|
-
}
|
|
134
|
+
let debug_id_comment = format!("\n{DEBUGID_COMMENT_PREFIX}={debug_id}\n");
|
|
188
135
|
|
|
189
|
-
|
|
190
|
-
while let Some(use_pragma) = js_lines.next_if(|line| USE_PRAGMA_RE.is_match(line)) {
|
|
191
|
-
writeln!(js_contents, "{use_pragma}")?;
|
|
192
|
-
}
|
|
136
|
+
let mut magic = MagicString::new(contents);
|
|
193
137
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
138
|
+
magic
|
|
139
|
+
.append_left(m.end as u32, &code_snippet)
|
|
140
|
+
.unwrap()
|
|
141
|
+
.append(&debug_id_comment)
|
|
142
|
+
.unwrap();
|
|
197
143
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
writeln!(js_contents, "{line}")?;
|
|
201
|
-
}
|
|
144
|
+
js_contents.clear();
|
|
145
|
+
write!(js_contents, "{}", magic.to_string())?;
|
|
202
146
|
|
|
203
|
-
|
|
204
|
-
|
|
147
|
+
let map = magic
|
|
148
|
+
.generate_map(GenerateDecodedMapOptions {
|
|
149
|
+
source: Some("pre_injection.js".to_string()),
|
|
150
|
+
include_content: true,
|
|
151
|
+
..Default::default()
|
|
152
|
+
})
|
|
153
|
+
.unwrap();
|
|
205
154
|
|
|
206
|
-
|
|
207
|
-
if let Some(sourcemap_comment) = sourcemap_comment {
|
|
208
|
-
writeln!(js_contents, "{sourcemap_comment}")?;
|
|
209
|
-
}
|
|
155
|
+
let map = map.to_string().unwrap();
|
|
210
156
|
|
|
211
|
-
Ok(())
|
|
157
|
+
Ok(SourceMap::from_slice(map.as_bytes()).unwrap())
|
|
212
158
|
}
|
|
213
159
|
|
|
214
160
|
/// Fixes up a minified JS source file with a debug id without messing with mappings.
|
|
@@ -231,14 +177,9 @@ pub fn fixup_js_file_end(js_contents: &mut Vec<u8>, debug_id: DebugId) -> Result
|
|
|
231
177
|
|
|
232
178
|
js_contents.clear();
|
|
233
179
|
|
|
234
|
-
let sourcemap_comment_idx = js_lines
|
|
235
|
-
.
|
|
236
|
-
|
|
237
|
-
.rev()
|
|
238
|
-
.find(|(_idx, line)| {
|
|
239
|
-
line.starts_with("//# sourceMappingURL=") || line.starts_with("//@ sourceMappingURL=")
|
|
240
|
-
})
|
|
241
|
-
.map(|(idx, _)| idx);
|
|
180
|
+
let sourcemap_comment_idx = js_lines.iter().rposition(|line| {
|
|
181
|
+
line.starts_with("//# sourceMappingURL=") || line.starts_with("//@ sourceMappingURL=")
|
|
182
|
+
});
|
|
242
183
|
|
|
243
184
|
let sourcemap_comment = sourcemap_comment_idx.map(|idx| js_lines.remove(idx));
|
|
244
185
|
|
|
@@ -248,11 +189,10 @@ pub fn fixup_js_file_end(js_contents: &mut Vec<u8>, debug_id: DebugId) -> Result
|
|
|
248
189
|
|
|
249
190
|
let to_inject = CODE_SNIPPET_TEMPLATE.replace(DEBUGID_PLACEHOLDER, &debug_id.to_string());
|
|
250
191
|
writeln!(js_contents, "{to_inject}")?;
|
|
251
|
-
writeln!(js_contents, "{DEBUGID_COMMENT_PREFIX}={debug_id}")?;
|
|
252
|
-
|
|
253
192
|
if let Some(sourcemap_comment) = sourcemap_comment {
|
|
254
193
|
writeln!(js_contents, "{sourcemap_comment}")?;
|
|
255
194
|
}
|
|
195
|
+
writeln!(js_contents, "{DEBUGID_COMMENT_PREFIX}={debug_id}")?;
|
|
256
196
|
|
|
257
197
|
Ok(())
|
|
258
198
|
}
|
|
@@ -264,11 +204,10 @@ pub fn fixup_js_file_end(js_contents: &mut Vec<u8>, debug_id: DebugId) -> Result
|
|
|
264
204
|
pub fn replace_sourcemap_url(js_contents: &mut Vec<u8>, new_url: &str) -> Result<()> {
|
|
265
205
|
let js_lines = js_contents.lines().collect::<Result<Vec<_>, _>>()?;
|
|
266
206
|
|
|
267
|
-
let sourcemap_comment_idx =
|
|
207
|
+
let Some(sourcemap_comment_idx) = js_lines.iter().rposition(|line| {
|
|
268
208
|
line.starts_with("//# sourceMappingURL=") || line.starts_with("//@ sourceMappingURL=")
|
|
269
|
-
}) {
|
|
270
|
-
|
|
271
|
-
None => return Ok(()),
|
|
209
|
+
}) else {
|
|
210
|
+
return Ok(());
|
|
272
211
|
};
|
|
273
212
|
|
|
274
213
|
js_contents.clear();
|
|
@@ -295,74 +234,6 @@ pub fn debug_id_from_bytes_hashed(bytes: &[u8]) -> DebugId {
|
|
|
295
234
|
DebugId::from_uuid(uuid::Builder::from_sha1_bytes(sha1_bytes).into_uuid())
|
|
296
235
|
}
|
|
297
236
|
|
|
298
|
-
/// Fixes up a sourcemap file with a debug id.
|
|
299
|
-
///
|
|
300
|
-
/// If the file already contains a debug id under the `debug_id` key, it is left unmodified.
|
|
301
|
-
/// Otherwise, a fresh debug id is inserted under that key.
|
|
302
|
-
///
|
|
303
|
-
/// In either case, the value of the `debug_id` key is returned.
|
|
304
|
-
pub fn fixup_sourcemap(sourcemap_contents: &mut Vec<u8>) -> Result<(DebugId, bool)> {
|
|
305
|
-
match sourcemap::decode_slice(sourcemap_contents).context("Invalid sourcemap")? {
|
|
306
|
-
sourcemap::DecodedMap::Regular(mut sm) => {
|
|
307
|
-
if let Some(debug_id) = sm.get_debug_id() {
|
|
308
|
-
debug!("Sourcemap already has a debug id");
|
|
309
|
-
Ok((debug_id, false))
|
|
310
|
-
} else {
|
|
311
|
-
let debug_id = debug_id_from_bytes_hashed(sourcemap_contents);
|
|
312
|
-
sm.set_debug_id(Some(debug_id));
|
|
313
|
-
|
|
314
|
-
sourcemap_contents.clear();
|
|
315
|
-
sm.to_writer(sourcemap_contents)?;
|
|
316
|
-
Ok((debug_id, true))
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
sourcemap::DecodedMap::Hermes(mut smh) => {
|
|
320
|
-
if let Some(debug_id) = smh.get_debug_id() {
|
|
321
|
-
debug!("Sourcemap already has a debug id");
|
|
322
|
-
Ok((debug_id, false))
|
|
323
|
-
} else {
|
|
324
|
-
let debug_id = debug_id_from_bytes_hashed(sourcemap_contents);
|
|
325
|
-
smh.set_debug_id(Some(debug_id));
|
|
326
|
-
|
|
327
|
-
sourcemap_contents.clear();
|
|
328
|
-
smh.to_writer(sourcemap_contents)?;
|
|
329
|
-
Ok((debug_id, true))
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
sourcemap::DecodedMap::Index(_) => {
|
|
333
|
-
bail!("DebugId injection is not supported for sourcemap indexes")
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
/// This adds an empty mapping at the start of a sourcemap.
|
|
339
|
-
///
|
|
340
|
-
/// This is used to adjust a sourcemap when the corresponding source file has a
|
|
341
|
-
/// new line injected near the top (see [`fixup_js_file`]).
|
|
342
|
-
pub fn insert_empty_mapping(sourcemap_contents: &mut Vec<u8>) -> Result<()> {
|
|
343
|
-
let mut sourcemap: Value = serde_json::from_slice(sourcemap_contents)?;
|
|
344
|
-
|
|
345
|
-
let Some(map) = sourcemap.as_object_mut() else {
|
|
346
|
-
bail!("Invalid sourcemap");
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
let Some(mappings) = map.get_mut("mappings") else {
|
|
350
|
-
bail!("Invalid sourcemap");
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
let Value::String(mappings) = mappings else {
|
|
354
|
-
bail!("Invalid sourcemap");
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
// Insert empty mapping at the start
|
|
358
|
-
*mappings = format!(";{mappings}");
|
|
359
|
-
|
|
360
|
-
sourcemap_contents.clear();
|
|
361
|
-
serde_json::to_writer(sourcemap_contents, &sourcemap)?;
|
|
362
|
-
|
|
363
|
-
Ok(())
|
|
364
|
-
}
|
|
365
|
-
|
|
366
237
|
/// Computes a normalized sourcemap URL from a source file's own URL und the relative URL of its sourcemap.
|
|
367
238
|
///
|
|
368
239
|
/// Roughly, this will combine a source URL of `some/dir/source.js` and a sourcemap URL of `path/to/source.min.js`
|
|
@@ -441,44 +312,12 @@ pub fn find_matching_paths(candidate_paths: &[String], expected_path: &str) -> V
|
|
|
441
312
|
|
|
442
313
|
#[cfg(test)]
|
|
443
314
|
mod tests {
|
|
444
|
-
use std::io::Write;
|
|
445
|
-
|
|
446
315
|
use sentry::types::DebugId;
|
|
447
316
|
|
|
448
317
|
use crate::utils::fs::TempFile;
|
|
449
318
|
|
|
450
319
|
use super::*;
|
|
451
320
|
|
|
452
|
-
#[test]
|
|
453
|
-
fn test_fixup_sourcemap() {
|
|
454
|
-
for sourcemap_path in &[
|
|
455
|
-
"server/chunks/1.js.map",
|
|
456
|
-
"server/edge-runtime-webpack.js.map",
|
|
457
|
-
"server/pages/_document.js.map",
|
|
458
|
-
"server/pages/asdf.js.map",
|
|
459
|
-
"static/chunks/575-bb7d7e0e6de8d623.js.map",
|
|
460
|
-
"static/chunks/app/client/page-d5742c254d9533f8.js.map",
|
|
461
|
-
"static/chunks/pages/asdf-05b39167abbe433b.js.map",
|
|
462
|
-
] {
|
|
463
|
-
let mut sourcemap_contents = std::fs::read(format!(
|
|
464
|
-
"tests/integration/_fixtures/inject/{sourcemap_path}"
|
|
465
|
-
))
|
|
466
|
-
.unwrap();
|
|
467
|
-
|
|
468
|
-
assert!(
|
|
469
|
-
sourcemap::decode_slice(&sourcemap_contents).is_ok(),
|
|
470
|
-
"sourcemap is valid before injection"
|
|
471
|
-
);
|
|
472
|
-
|
|
473
|
-
fixup_sourcemap(&mut sourcemap_contents).unwrap();
|
|
474
|
-
|
|
475
|
-
assert!(
|
|
476
|
-
sourcemap::decode_slice(&sourcemap_contents).is_ok(),
|
|
477
|
-
"sourcemap is valid after injection"
|
|
478
|
-
);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
321
|
#[test]
|
|
483
322
|
fn test_fixup_js_file() {
|
|
484
323
|
let source = r#"//# sourceMappingURL=fake1
|
|
@@ -494,12 +333,13 @@ something else"#;
|
|
|
494
333
|
fixup_js_file(&mut source, debug_id).unwrap();
|
|
495
334
|
|
|
496
335
|
let expected = r#"//# sourceMappingURL=fake1
|
|
336
|
+
|
|
497
337
|
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000")}catch(e){}}();
|
|
498
338
|
some line
|
|
499
339
|
//# sourceMappingURL=fake2
|
|
340
|
+
//# sourceMappingURL=real
|
|
500
341
|
something else
|
|
501
342
|
//# debugId=00000000-0000-0000-0000-000000000000
|
|
502
|
-
//# sourceMappingURL=real
|
|
503
343
|
"#;
|
|
504
344
|
|
|
505
345
|
assert_eq!(std::str::from_utf8(&source).unwrap(), expected);
|
|
@@ -547,6 +387,7 @@ something else"#;
|
|
|
547
387
|
let expected = r#"//# sourceMappingURL=fake
|
|
548
388
|
|
|
549
389
|
|
|
390
|
+
|
|
550
391
|
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000")}catch(e){}}();
|
|
551
392
|
some line
|
|
552
393
|
//# sourceMappingURL=fake
|
|
@@ -562,9 +403,9 @@ some line
|
|
|
562
403
|
//# sourceMappingURL=fake
|
|
563
404
|
//# sourceMappingURL=fake
|
|
564
405
|
//# sourceMappingURL=fake
|
|
406
|
+
//# sourceMappingURL=real
|
|
565
407
|
something else
|
|
566
408
|
//# debugId=00000000-0000-0000-0000-000000000000
|
|
567
|
-
//# sourceMappingURL=real
|
|
568
409
|
"#;
|
|
569
410
|
|
|
570
411
|
println!("{}", result);
|
|
@@ -594,14 +435,15 @@ something else"#;
|
|
|
594
435
|
//# sourceMappingURL=fake1
|
|
595
436
|
|
|
596
437
|
// some other comment
|
|
597
|
-
"use strict";
|
|
598
|
-
'use strict';
|
|
438
|
+
"use strict";
|
|
599
439
|
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000")}catch(e){}}();
|
|
440
|
+
rest of the line
|
|
441
|
+
'use strict';
|
|
600
442
|
some line
|
|
601
443
|
//# sourceMappingURL=fake2
|
|
444
|
+
//# sourceMappingURL=real
|
|
602
445
|
something else
|
|
603
446
|
//# debugId=00000000-0000-0000-0000-000000000000
|
|
604
|
-
//# sourceMappingURL=real
|
|
605
447
|
"#;
|
|
606
448
|
|
|
607
449
|
assert_eq!(std::str::from_utf8(&source).unwrap(), expected);
|
|
@@ -630,14 +472,15 @@ something else"#;
|
|
|
630
472
|
//# sourceMappingURL=fake1
|
|
631
473
|
|
|
632
474
|
// some other comment
|
|
633
|
-
"use strict";
|
|
475
|
+
"use strict";
|
|
634
476
|
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000")}catch(e){}}();
|
|
477
|
+
rest of the line
|
|
635
478
|
(this.foo=this.bar||[]).push([[2],[function(e,t,n){"use strict"; […] }
|
|
636
479
|
some line
|
|
637
480
|
//# sourceMappingURL=fake2
|
|
481
|
+
//# sourceMappingURL=real
|
|
638
482
|
something else
|
|
639
483
|
//# debugId=00000000-0000-0000-0000-000000000000
|
|
640
|
-
//# sourceMappingURL=real
|
|
641
484
|
"#;
|
|
642
485
|
|
|
643
486
|
assert_eq!(std::str::from_utf8(&source).unwrap(), expected);
|