@hot-updater/bugsnag-plugin 0.35.12

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/LICENSE ADDED
@@ -0,0 +1,33 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Sungyu Kang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ ADDITIONAL DISCLAIMER
26
+
27
+ The authors of this software shall not be held responsible for any legal issues,
28
+ regulatory violations, policy violations, or disputes arising from the use,
29
+ distribution, or integration of this software.
30
+
31
+ Users are solely responsible for ensuring compliance with all applicable laws,
32
+ regulations, and third-party policies (including but not limited to app store
33
+ policies).
package/dist/index.cjs ADDED
@@ -0,0 +1,77 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ let fs = require("fs");
25
+ fs = __toESM(fs);
26
+ let path = require("path");
27
+ path = __toESM(path);
28
+ let execa = require("execa");
29
+ //#region src/withBugsnag.ts
30
+ const ensureFilePath = (files, basePath, filename) => {
31
+ const file = files.find((file) => file.includes(filename));
32
+ if (!file) return null;
33
+ return path.default.resolve(basePath, file);
34
+ };
35
+ const withBugsnag = (buildFn, config) => (args) => {
36
+ const context = buildFn(args);
37
+ return {
38
+ ...context,
39
+ build: async (buildArgs) => {
40
+ const result = await context.build(buildArgs);
41
+ const files = await fs.default.promises.readdir(result.buildPath, { recursive: true });
42
+ const javascriptBundleFilename = `index.${buildArgs.platform}.bundle`;
43
+ const javascriptBundleSourcemapFilename = `${javascriptBundleFilename}.map`;
44
+ const hermesBundleFilename = `${javascriptBundleFilename}.hbc`;
45
+ const hermesBundleSourcemapFilename = `${javascriptBundleFilename}.hbc.map`;
46
+ const javascriptBundlePath = ensureFilePath(files, result.buildPath, javascriptBundleFilename);
47
+ const javascriptBundleSourcemapPath = ensureFilePath(files, result.buildPath, javascriptBundleSourcemapFilename);
48
+ const hermesBundlePath = ensureFilePath(files, result.buildPath, hermesBundleFilename);
49
+ const hermesBundleSourcemapPath = ensureFilePath(files, result.buildPath, hermesBundleSourcemapFilename);
50
+ if (!javascriptBundlePath || !javascriptBundleSourcemapPath) throw new Error("Sourcemap or original bundle not found. Please enable sourcemap in your build plugin. e.g build: bare({ sourcemap: true })");
51
+ if (!!hermesBundlePath !== !!hermesBundleSourcemapPath) throw new Error("Hermes bundle or sourcemap not found. Please enable Hermes in your build plugin. e.g build: bare({ hermes: true })");
52
+ const selectedBundleFilePath = hermesBundlePath ?? javascriptBundlePath;
53
+ const selectedSourcemapFilePath = hermesBundleSourcemapPath ?? javascriptBundleSourcemapPath;
54
+ await (0, execa.execa)("npx", [
55
+ "bugsnag-cli",
56
+ "upload",
57
+ "react-native-sourcemaps",
58
+ "--api-key",
59
+ config.apiKey,
60
+ "--platform",
61
+ buildArgs.platform,
62
+ "--bundle",
63
+ selectedBundleFilePath,
64
+ "--source-map",
65
+ selectedSourcemapFilePath,
66
+ "--code-bundle-id",
67
+ config.codeBundleId ?? result.bundleId,
68
+ "--project-root",
69
+ config.projectRoot ?? args.cwd,
70
+ ...config.overwrite ? ["--overwrite"] : []
71
+ ]);
72
+ return result;
73
+ }
74
+ };
75
+ };
76
+ //#endregion
77
+ exports.withBugsnag = withBugsnag;
@@ -0,0 +1,30 @@
1
+ import { BasePluginArgs, BuildPlugin } from "@hot-updater/plugin-core";
2
+
3
+ //#region src/withBugsnag.d.ts
4
+ interface WithBugsnagConfig {
5
+ /**
6
+ * The BugSnag API key of the project the source maps belong to.
7
+ */
8
+ apiKey: string;
9
+ /**
10
+ * A unique identifier for the JavaScript bundle so BugSnag can match errors
11
+ * to the deployed OTA bundle. Defaults to the hot-updater bundle id
12
+ * generated for the deploy. The same value must be passed as
13
+ * `codeBundleId` when starting BugSnag in your app.
14
+ */
15
+ codeBundleId?: string;
16
+ /**
17
+ * Whether to overwrite an existing upload with the same identifier
18
+ * instead of failing.
19
+ */
20
+ overwrite?: boolean;
21
+ /**
22
+ * The path to strip from the beginning of source file names referenced in
23
+ * stacktraces on the BugSnag dashboard. Defaults to the current working
24
+ * directory.
25
+ */
26
+ projectRoot?: string;
27
+ }
28
+ declare const withBugsnag: (buildFn: (args: BasePluginArgs) => BuildPlugin, config: WithBugsnagConfig) => (args: BasePluginArgs) => BuildPlugin;
29
+ //#endregion
30
+ export { withBugsnag };
@@ -0,0 +1,30 @@
1
+ import { BasePluginArgs, BuildPlugin } from "@hot-updater/plugin-core";
2
+
3
+ //#region src/withBugsnag.d.ts
4
+ interface WithBugsnagConfig {
5
+ /**
6
+ * The BugSnag API key of the project the source maps belong to.
7
+ */
8
+ apiKey: string;
9
+ /**
10
+ * A unique identifier for the JavaScript bundle so BugSnag can match errors
11
+ * to the deployed OTA bundle. Defaults to the hot-updater bundle id
12
+ * generated for the deploy. The same value must be passed as
13
+ * `codeBundleId` when starting BugSnag in your app.
14
+ */
15
+ codeBundleId?: string;
16
+ /**
17
+ * Whether to overwrite an existing upload with the same identifier
18
+ * instead of failing.
19
+ */
20
+ overwrite?: boolean;
21
+ /**
22
+ * The path to strip from the beginning of source file names referenced in
23
+ * stacktraces on the BugSnag dashboard. Defaults to the current working
24
+ * directory.
25
+ */
26
+ projectRoot?: string;
27
+ }
28
+ declare const withBugsnag: (buildFn: (args: BasePluginArgs) => BuildPlugin, config: WithBugsnagConfig) => (args: BasePluginArgs) => BuildPlugin;
29
+ //#endregion
30
+ export { withBugsnag };
package/dist/index.mjs ADDED
@@ -0,0 +1,52 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { execa } from "execa";
4
+ //#region src/withBugsnag.ts
5
+ const ensureFilePath = (files, basePath, filename) => {
6
+ const file = files.find((file) => file.includes(filename));
7
+ if (!file) return null;
8
+ return path.resolve(basePath, file);
9
+ };
10
+ const withBugsnag = (buildFn, config) => (args) => {
11
+ const context = buildFn(args);
12
+ return {
13
+ ...context,
14
+ build: async (buildArgs) => {
15
+ const result = await context.build(buildArgs);
16
+ const files = await fs.promises.readdir(result.buildPath, { recursive: true });
17
+ const javascriptBundleFilename = `index.${buildArgs.platform}.bundle`;
18
+ const javascriptBundleSourcemapFilename = `${javascriptBundleFilename}.map`;
19
+ const hermesBundleFilename = `${javascriptBundleFilename}.hbc`;
20
+ const hermesBundleSourcemapFilename = `${javascriptBundleFilename}.hbc.map`;
21
+ const javascriptBundlePath = ensureFilePath(files, result.buildPath, javascriptBundleFilename);
22
+ const javascriptBundleSourcemapPath = ensureFilePath(files, result.buildPath, javascriptBundleSourcemapFilename);
23
+ const hermesBundlePath = ensureFilePath(files, result.buildPath, hermesBundleFilename);
24
+ const hermesBundleSourcemapPath = ensureFilePath(files, result.buildPath, hermesBundleSourcemapFilename);
25
+ if (!javascriptBundlePath || !javascriptBundleSourcemapPath) throw new Error("Sourcemap or original bundle not found. Please enable sourcemap in your build plugin. e.g build: bare({ sourcemap: true })");
26
+ if (!!hermesBundlePath !== !!hermesBundleSourcemapPath) throw new Error("Hermes bundle or sourcemap not found. Please enable Hermes in your build plugin. e.g build: bare({ hermes: true })");
27
+ const selectedBundleFilePath = hermesBundlePath ?? javascriptBundlePath;
28
+ const selectedSourcemapFilePath = hermesBundleSourcemapPath ?? javascriptBundleSourcemapPath;
29
+ await execa("npx", [
30
+ "bugsnag-cli",
31
+ "upload",
32
+ "react-native-sourcemaps",
33
+ "--api-key",
34
+ config.apiKey,
35
+ "--platform",
36
+ buildArgs.platform,
37
+ "--bundle",
38
+ selectedBundleFilePath,
39
+ "--source-map",
40
+ selectedSourcemapFilePath,
41
+ "--code-bundle-id",
42
+ config.codeBundleId ?? result.bundleId,
43
+ "--project-root",
44
+ config.projectRoot ?? args.cwd,
45
+ ...config.overwrite ? ["--overwrite"] : []
46
+ ]);
47
+ return result;
48
+ }
49
+ };
50
+ };
51
+ //#endregion
52
+ export { withBugsnag };
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@hot-updater/bugsnag-plugin",
3
+ "version": "0.35.12",
4
+ "type": "module",
5
+ "description": "React Native OTA solution for self-hosted",
6
+ "sideEffects": false,
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.mjs",
9
+ "types": "./dist/index.d.cts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.cjs"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "package.json"
20
+ ],
21
+ "keywords": [
22
+ "react-native",
23
+ "react-native-code-push",
24
+ "code-push",
25
+ "bugsnag",
26
+ "eas",
27
+ "eas-update",
28
+ "expo",
29
+ "expo-update",
30
+ "self-hosted"
31
+ ],
32
+ "license": "MIT",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/gronxb/hot-updater"
36
+ },
37
+ "author": "gronxb <gron1gh1@gmail.com> (https://github.com/gronxb)",
38
+ "bugs": {
39
+ "url": "https://github.com/gronxb/hot-updater/issues"
40
+ },
41
+ "homepage": "https://github.com/gronxb/hot-updater#readme",
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "dependencies": {
46
+ "execa": "9.5.2",
47
+ "@hot-updater/core": "0.35.12",
48
+ "@hot-updater/plugin-core": "0.35.12"
49
+ },
50
+ "devDependencies": {
51
+ "@bugsnag/cli": "~3.10.4",
52
+ "@types/node": "^20"
53
+ },
54
+ "peerDependencies": {
55
+ "@bugsnag/cli": "*"
56
+ },
57
+ "scripts": {
58
+ "build": "tsdown",
59
+ "test:type": "tsc --noEmit"
60
+ }
61
+ }