Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bugsnag/source-maps

Package Overview
Dependencies
Maintainers
12
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bugsnag/source-maps - npm Package Compare versions

Comparing version 1.0.0-beta.1 to 1.0.0-beta.2

2

dist/commands/CommandDefinitions.js

@@ -7,3 +7,3 @@ "use strict";

{ name: 'overwrite', type: Boolean, description: 'whether to replace exiting source maps uploaded with the same version' },
{ name: 'project-root', type: String, description: 'the top level directory of your project' },
{ name: 'project-root', type: String, description: 'the top level directory of your project (defaults to the current directory)' },
{ name: 'endpoint', type: String, description: 'customize the endpoint for Bugsnag On-Premise' },

@@ -10,0 +10,0 @@ { name: 'quiet', type: Boolean, description: 'less verbose logging' },

@@ -61,2 +61,8 @@ "use strict";

Logger_1.default.error(`Invalid argument provided. ${e.message}`);
// Check if the user provided an argument that allows a wildcard ('*') and
// if so, warn them about wrapping the value in quotes
const wildcardArgument = argv.find(arg => arg === '--bundle-url' || arg === '--base-url');
if (wildcardArgument) {
Logger_1.default.info(`Values that contain a wildcard must be wrapped in quotes to prevent shell expansion, for example ${wildcardArgument} "*"`);
}
}

@@ -80,2 +86,3 @@ else {

endpoint: browserOpts.endpoint,
detectAppVersion: browserOpts.detectAppVersion,
logger: Logger_1.default

@@ -94,2 +101,3 @@ });

endpoint: browserOpts.endpoint,
detectAppVersion: browserOpts.detectAppVersion,
logger: Logger_1.default

@@ -128,3 +136,13 @@ });

}
const browserCommandCommonDefs = [{ name: 'app-version', type: String }];
const browserCommandCommonDefs = [
{
name: 'app-version',
type: String
},
{
name: 'detect-app-version',
type: Boolean,
description: 'detect the app version from the package.json file'
}
];
const browserCommandSingleDefs = [

@@ -135,3 +153,3 @@ {

description: 'the path to the source map {bold required}',
typeLabel: '{underline file}'
typeLabel: '{underline filepath}'
},

@@ -141,3 +159,3 @@ {

type: String,
description: 'the URL the bundle is served at (may contain * wildcards) {bold required}',
description: 'the URL of the bundle file (may contain * wildcards) {bold required}',
typeLabel: '{underline url}'

@@ -149,3 +167,3 @@ },

description: 'the path to the bundle',
typeLabel: '{underline file}'
typeLabel: '{underline filepath}'
},

@@ -157,3 +175,3 @@ ];

type: String,
description: 'the directory to start searching for source maps in {bold required}',
description: 'the directory to start searching for source maps in, relative to the project root {bold required}',
typeLabel: '{underline path}'

@@ -164,3 +182,3 @@ },

type: String,
description: 'the base URL that JS bundles are served from (may contain * wildcards) {bold required}',
description: 'the URL of the base directory that JS files are served from (may contain * wildcards) {bold required}',
typeLabel: '{underline url}'

@@ -170,8 +188,12 @@ },

function validateBrowserOpts(opts) {
if (!opts['apiKey'])
if (!opts['apiKey']) {
throw new Error('--api-key is required');
}
if (opts['appVersion'] && opts['detectAppVersion']) {
throw new Error('--app-version and --detect-app-version cannot both be given');
}
const anySingleSet = opts['sourceMap'] || opts['bundleUrl'] || opts['bundle'];
const anyMultipleSet = opts['baseUrl'] || opts['directory'];
if (anySingleSet && anyMultipleSet) {
throw new Error('Incompatible options are set. Use either single mode options (--source-map, --bundle, --bundle-url) or multiple mode options (--directory,--base-url).');
throw new Error('Incompatible options are set. Use either single mode options (--source-map, --bundle, --bundle-url) or multiple mode options (--directory, --base-url).');
}

@@ -178,0 +200,0 @@ if (!anySingleSet && !anyMultipleSet)

@@ -78,2 +78,3 @@ "use strict";

endpoint: nodeOpts.endpoint,
detectAppVersion: nodeOpts.detectAppVersion,
logger: Logger_1.default

@@ -91,2 +92,3 @@ });

endpoint: nodeOpts.endpoint,
detectAppVersion: nodeOpts.detectAppVersion,
logger: Logger_1.default

@@ -125,3 +127,13 @@ });

}
const nodeCommandCommonDefs = [{ name: 'app-version', type: String }];
const nodeCommandCommonDefs = [
{
name: 'app-version',
type: String
},
{
name: 'detect-app-version',
type: Boolean,
description: 'detect the app version from the package.json file'
}
];
const nodeCommandSingleDefs = [

@@ -132,3 +144,3 @@ {

description: 'the path to the source map {bold required}',
typeLabel: '{underline file}'
typeLabel: '{underline filepath}'
},

@@ -139,3 +151,3 @@ {

description: 'the path to the bundle {bold required}',
typeLabel: '{underline file}'
typeLabel: '{underline filepath}'
}

@@ -147,3 +159,3 @@ ];

type: String,
description: 'the directory to start searching for source maps in {bold required}',
description: 'the directory to start searching for source maps in, relative to the project root {bold required}',
typeLabel: '{underline path}'

@@ -153,4 +165,8 @@ }

function validatenodeOpts(opts) {
if (!opts['apiKey'])
if (!opts['apiKey']) {
throw new Error('--api-key is required');
}
if (opts['appVersion'] && opts['detectAppVersion']) {
throw new Error('--app-version and --detect-app-version cannot both be given');
}
const anySingleSet = opts['sourceMap'] || opts['bundle'];

@@ -157,0 +173,0 @@ const anyMultipleSet = opts['directory'];

@@ -148,3 +148,3 @@ "use strict";

description: 'the path to the source map {bold required}',
typeLabel: '{underline file}',
typeLabel: '{underline filepath}',
},

@@ -155,3 +155,3 @@ {

description: 'the path to the bundle {bold required}',
typeLabel: '{underline file}',
typeLabel: '{underline filepath}',
},

@@ -163,3 +163,3 @@ ];

type: Boolean,
description: 'enable fetch mode {bold required}',
description: 'enable fetch mode',
},

@@ -169,3 +169,3 @@ {

type: String,
description: 'the URL of the React Native bundle server',
description: 'the URL of the React Native bundle server (defaults to http://localhost:8081)',
typeLabel: '{underline url}',

@@ -176,4 +176,4 @@ },

type: String,
description: 'the entry point of your React Native app',
typeLabel: '{underline file}',
description: 'the entry point file of your React Native app (defaults to index.js)',
typeLabel: '{underline filepath}',
},

@@ -212,3 +212,3 @@ ];

if (!opts.appVersion && !opts.appVersionCode && !opts.appBundleVersion) {
throw new Error('--code-bundle-id or at least one of --app-version, --app-version-code and --app-bundle-version must be given');
throw new Error('--code-bundle-id or at least one of --app-version, --app-version-code or --app-bundle-version must be given');
}

@@ -231,2 +231,5 @@ }

function validateRetrieval(opts) {
if (!opts.fetch && !opts.sourceMap && !opts.bundle) {
throw new Error('Not enough arguments provided. Either use --fetch mode, or provide both --source-map and --bundle.');
}
if (!opts.fetch) {

@@ -233,0 +236,0 @@ if (!opts.sourceMap || typeof opts.sourceMap !== 'string') {

@@ -40,3 +40,2 @@ "use strict";

if (((_a = map.sources) === null || _a === void 0 ? void 0 : _a.length) === ((_b = map.sourcesContent) === null || _b === void 0 ? void 0 : _b.length)) {
logger.debug('sourcesContent is already included in source map');
return map;

@@ -43,0 +42,0 @@ }

@@ -14,6 +14,7 @@ /// <reference types="node" />

endpoint?: string;
detectAppVersion?: boolean;
requestOpts?: http.RequestOptions;
logger?: Logger;
}
export declare function uploadOne({ apiKey, bundleUrl, bundle, sourceMap, appVersion, codeBundleId, overwrite, projectRoot, endpoint, requestOpts, logger }: UploadSingleOpts): Promise<void>;
export declare function uploadOne({ apiKey, bundleUrl, bundle, sourceMap, appVersion, codeBundleId, overwrite, projectRoot, endpoint, detectAppVersion, requestOpts, logger }: UploadSingleOpts): Promise<void>;
interface UploadMultipleOpts {

@@ -27,6 +28,7 @@ apiKey: string;

endpoint?: string;
detectAppVersion?: boolean;
requestOpts?: http.RequestOptions;
logger?: Logger;
}
export declare function uploadMultiple({ apiKey, baseUrl, directory, appVersion, overwrite, projectRoot, endpoint, requestOpts, logger }: UploadMultipleOpts): Promise<void>;
export declare function uploadMultiple({ apiKey, baseUrl, directory, appVersion, overwrite, detectAppVersion, projectRoot, endpoint, requestOpts, logger }: UploadMultipleOpts): Promise<void>;
export {};

@@ -28,5 +28,5 @@ "use strict";

const UPLOAD_ENDPOINT = 'https://upload.bugsnag.com/source-map';
function uploadOne({ apiKey, bundleUrl, bundle, sourceMap, appVersion, codeBundleId, overwrite = false, projectRoot = process.cwd(), endpoint = UPLOAD_ENDPOINT, requestOpts = {}, logger = Logger_1.noopLogger }) {
function uploadOne({ apiKey, bundleUrl, bundle, sourceMap, appVersion, codeBundleId, overwrite = false, projectRoot = process.cwd(), endpoint = UPLOAD_ENDPOINT, detectAppVersion = false, requestOpts = {}, logger = Logger_1.noopLogger }) {
return __awaiter(this, void 0, void 0, function* () {
logger.info(`Uploading browser source map for "${bundleUrl}"`);
logger.info(`Preparing upload of browser source map for "${bundleUrl}"`);
const [sourceMapContent, fullSourceMapPath] = yield ReadSourceMap_1.default(sourceMap, projectRoot, logger);

@@ -40,6 +40,12 @@ let bundleContent;

const transformedSourceMap = yield ApplyTransformations_1.default(fullSourceMapPath, sourceMapJson, projectRoot, logger);
if (!appVersion) {
appVersion = yield DetectAppVersion_1.default(projectRoot, logger);
if (detectAppVersion) {
try {
appVersion = yield DetectAppVersion_1.default(projectRoot, logger);
}
catch (e) {
logger.error(e.message);
throw e;
}
}
logger.debug(`Initiating upload "${endpoint}"`);
logger.debug(`Initiating upload to "${endpoint}"`);
const start = new Date().getTime();

@@ -57,3 +63,4 @@ try {

}, requestOpts);
logger.success(`Success, uploaded ${sourceMap} to ${endpoint} in ${(new Date()).getTime() - start}ms`);
const uploadedFiles = (bundleContent && fullBundlePath) ? `${sourceMap} and ${bundle}` : sourceMap;
logger.success(`Success, uploaded ${uploadedFiles} to ${endpoint} in ${(new Date()).getTime() - start}ms`);
}

@@ -72,7 +79,7 @@ catch (e) {

exports.uploadOne = uploadOne;
function uploadMultiple({ apiKey, baseUrl, directory, appVersion, overwrite = false, projectRoot = process.cwd(), endpoint = UPLOAD_ENDPOINT, requestOpts = {}, logger = Logger_1.noopLogger }) {
function uploadMultiple({ apiKey, baseUrl, directory, appVersion, overwrite = false, detectAppVersion = false, projectRoot = process.cwd(), endpoint = UPLOAD_ENDPOINT, requestOpts = {}, logger = Logger_1.noopLogger }) {
return __awaiter(this, void 0, void 0, function* () {
logger.info(`Uploading browser source maps for "${baseUrl}"`);
logger.info(`Preparing upload of browser source maps for "${baseUrl}"`);
logger.debug(`Searching for source maps "${directory}"`);
const absoluteSearchPath = path_1.default.join(projectRoot, directory);
const absoluteSearchPath = path_1.default.resolve(projectRoot, directory);
const sourceMaps = yield new Promise((resolve, reject) => {

@@ -89,6 +96,12 @@ glob_1.default('**/*.map', { ignore: '**/*.css.map', cwd: absoluteSearchPath }, (err, files) => {

}
logger.debug(`Found ${sourceMaps.length} source map:`);
logger.debug(`Found ${sourceMaps.length} source map(s):`);
logger.debug(` ${sourceMaps.join(', ')}`);
if (!appVersion) {
appVersion = yield DetectAppVersion_1.default(projectRoot, logger);
if (detectAppVersion) {
try {
appVersion = yield DetectAppVersion_1.default(projectRoot, logger);
}
catch (e) {
logger.error(e.message);
throw e;
}
}

@@ -110,3 +123,3 @@ let n = 0;

const transformedSourceMap = yield ApplyTransformations_1.default(fullSourceMapPath, sourceMapJson, projectRoot, logger);
logger.debug(`Initiating upload "${endpoint}"`);
logger.debug(`Initiating upload to "${endpoint}"`);
const start = new Date().getTime();

@@ -123,3 +136,4 @@ try {

}, requestOpts);
logger.success(`Success, uploaded ${sourceMap} to ${endpoint} in ${(new Date()).getTime() - start}ms`);
const uploadedFiles = (bundleContent && fullBundlePath) ? `${sourceMap} and ${bundlePath}` : sourceMap;
logger.success(`Success, uploaded ${uploadedFiles} to ${endpoint} in ${(new Date()).getTime() - start}ms`);
}

@@ -126,0 +140,0 @@ catch (e) {

import { Logger } from '../../Logger';
export default function detectAppVersion(projectRoot: string, logger: Logger): Promise<string | undefined>;
export default function detectAppVersion(projectRoot: string, logger: Logger): Promise<string>;

@@ -20,5 +20,7 @@ "use strict";

const version = pkg === null || pkg === void 0 ? void 0 : pkg.packageJson.version;
if (version)
logger.debug(`Detected appVersion "${version}"`);
return version ? version : undefined;
if (!version) {
throw new Error('Unable to automatically detect app version. Provide the "--app-version" argument or add a "version" key to your package.json file.');
}
logger.debug(`Detected appVersion "${version}"`);
return version;
});

@@ -25,0 +27,0 @@ }

@@ -12,6 +12,7 @@ /// <reference types="node" />

endpoint?: string;
detectAppVersion?: boolean;
requestOpts?: http.RequestOptions;
logger?: Logger;
}
export declare function uploadOne({ apiKey, bundle, sourceMap, appVersion, overwrite, projectRoot, endpoint, requestOpts, logger }: UploadSingleOpts): Promise<void>;
export declare function uploadOne({ apiKey, bundle, sourceMap, appVersion, overwrite, projectRoot, endpoint, detectAppVersion, requestOpts, logger }: UploadSingleOpts): Promise<void>;
interface UploadMultipleOpts {

@@ -24,6 +25,7 @@ apiKey: string;

endpoint?: string;
detectAppVersion?: boolean;
requestOpts?: http.RequestOptions;
logger?: Logger;
}
export declare function uploadMultiple({ apiKey, directory, appVersion, overwrite, projectRoot, endpoint, requestOpts, logger }: UploadMultipleOpts): Promise<void>;
export declare function uploadMultiple({ apiKey, directory, appVersion, overwrite, projectRoot, endpoint, detectAppVersion, requestOpts, logger }: UploadMultipleOpts): Promise<void>;
export {};

@@ -28,5 +28,5 @@ "use strict";

const UPLOAD_ENDPOINT = 'https://upload.bugsnag.com/source-map';
function uploadOne({ apiKey, bundle, sourceMap, appVersion, overwrite = false, projectRoot = process.cwd(), endpoint = UPLOAD_ENDPOINT, requestOpts = {}, logger = Logger_1.noopLogger }) {
function uploadOne({ apiKey, bundle, sourceMap, appVersion, overwrite = false, projectRoot = process.cwd(), endpoint = UPLOAD_ENDPOINT, detectAppVersion = false, requestOpts = {}, logger = Logger_1.noopLogger }) {
return __awaiter(this, void 0, void 0, function* () {
logger.info(`Uploading node source map for "${bundle}"`);
logger.info(`Preparing upload of node source map for "${bundle}"`);
const [sourceMapContent, fullSourceMapPath] = yield ReadSourceMap_1.default(sourceMap, projectRoot, logger);

@@ -36,6 +36,12 @@ const [bundleContent, fullBundlePath] = yield ReadBundleContent_1.default(bundle, projectRoot, sourceMap, logger);

const transformedSourceMap = yield ApplyTransformations_1.default(fullSourceMapPath, sourceMapJson, projectRoot, logger);
if (!appVersion) {
appVersion = yield DetectAppVersion_1.default(projectRoot, logger);
if (detectAppVersion) {
try {
appVersion = yield DetectAppVersion_1.default(projectRoot, logger);
}
catch (e) {
logger.error(e.message);
throw e;
}
}
logger.debug(`Initiating upload "${endpoint}"`);
logger.debug(`Initiating upload to "${endpoint}"`);
const start = new Date().getTime();

@@ -52,3 +58,3 @@ try {

}, requestOpts);
logger.success(`Success, uploaded ${sourceMap} to ${endpoint} in ${(new Date()).getTime() - start}ms`);
logger.success(`Success, uploaded ${sourceMap} and ${bundle} to ${endpoint} in ${(new Date()).getTime() - start}ms`);
}

@@ -67,7 +73,7 @@ catch (e) {

exports.uploadOne = uploadOne;
function uploadMultiple({ apiKey, directory, appVersion, overwrite = false, projectRoot = process.cwd(), endpoint = UPLOAD_ENDPOINT, requestOpts = {}, logger = Logger_1.noopLogger }) {
function uploadMultiple({ apiKey, directory, appVersion, overwrite = false, projectRoot = process.cwd(), endpoint = UPLOAD_ENDPOINT, detectAppVersion = false, requestOpts = {}, logger = Logger_1.noopLogger }) {
return __awaiter(this, void 0, void 0, function* () {
logger.info(`Uploading node source maps for "${directory}"`);
logger.info(`Preparing upload of node source maps for "${directory}"`);
logger.debug(`Searching for source maps "${directory}"`);
const absoluteSearchPath = path_1.default.join(projectRoot, directory);
const absoluteSearchPath = path_1.default.resolve(projectRoot, directory);
const sourceMaps = yield new Promise((resolve, reject) => {

@@ -86,4 +92,10 @@ glob_1.default('**/*.map', { ignore: '**/node_modules/**', cwd: absoluteSearchPath }, (err, files) => {

logger.debug(` ${sourceMaps.join(', ')}`);
if (!appVersion) {
appVersion = yield DetectAppVersion_1.default(projectRoot, logger);
if (detectAppVersion) {
try {
appVersion = yield DetectAppVersion_1.default(projectRoot, logger);
}
catch (e) {
logger.error(e.message);
throw e;
}
}

@@ -105,3 +117,3 @@ let n = 0;

const transformedSourceMap = yield ApplyTransformations_1.default(fullSourceMapPath, sourceMapJson, projectRoot, logger);
logger.debug(`Initiating upload "${endpoint}"`);
logger.debug(`Initiating upload to "${endpoint}"`);
const start = new Date().getTime();

@@ -118,3 +130,4 @@ try {

}, requestOpts);
logger.success(`Success, uploaded ${sourceMap} to ${endpoint} in ${(new Date()).getTime() - start}ms`);
const uploadedFiles = (bundleContent && fullBundlePath) ? `${sourceMap} and ${bundlePath}` : sourceMap;
logger.success(`Success, uploaded ${uploadedFiles} to ${endpoint} in ${(new Date()).getTime() - start}ms`);
}

@@ -121,0 +134,0 @@ catch (e) {

@@ -48,3 +48,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
logger.info(`Uploading React Native source map (${dev ? 'dev' : 'release'} / ${platform})`);
logger.info(`Preparing upload of React Native source map (${dev ? 'dev' : 'release'} / ${platform})`);
const [sourceMapContent, fullSourceMapPath] = yield ReadSourceMap_1.default(sourceMap, projectRoot, logger);

@@ -55,3 +55,3 @@ const [bundleContent, fullBundlePath] = yield ReadBundleContent_1.default(bundle, projectRoot, sourceMap, logger);

const marshalledVersions = marshallVersionOptions({ appVersion, codeBundleId, appBundleVersion, appVersionCode }, platform);
logger.debug(`Initiating upload "${endpoint}"`);
logger.debug(`Initiating upload to "${endpoint}"`);
const start = new Date().getTime();

@@ -61,3 +61,3 @@ try {

dev }, marshalledVersions), { overwrite }), requestOpts);
logger.success(`Success, uploaded ${sourceMap} to ${endpoint} in ${(new Date()).getTime() - start}ms`);
logger.success(`Success, uploaded ${sourceMap} and ${bundle} to ${endpoint} in ${(new Date()).getTime() - start}ms`);
}

@@ -78,5 +78,5 @@ catch (e) {

return __awaiter(this, void 0, void 0, function* () {
logger.info(`Fetching and uploading React Native source map (${dev ? 'dev' : 'release'} / ${platform})`);
logger.info(`Fetching React Native source map (${dev ? 'dev' : 'release'} / ${platform})`);
const queryString = querystring_1.default.stringify({ platform, dev });
const entryPoint = bundlerEntryPoint.replace(/\.js$/, '');
const entryPoint = bundlerEntryPoint.replace(/\.(js|bundle)$/, '');
const sourceMapUrl = `${bundlerUrl}/${entryPoint}.js.map?${queryString}`;

@@ -106,3 +106,3 @@ const bundleUrl = `${bundlerUrl}/${entryPoint}.bundle?${queryString}`;

const marshalledVersions = marshallVersionOptions({ appVersion, codeBundleId, appBundleVersion, appVersionCode }, platform);
logger.debug(`Initiating upload "${endpoint}"`);
logger.debug(`Initiating upload to "${endpoint}"`);
const start = new Date().getTime();

@@ -140,3 +140,3 @@ try {

if (!(err instanceof NetworkError_1.NetworkError)) {
return `An unexpected error occurred.\n\n`;
return `An unexpected error occurred during the request to ${url}.\n\n`;
}

@@ -147,9 +147,9 @@ switch (err.code) {

case NetworkError_1.NetworkErrorCode.SERVER_ERROR:
return `Recieved an error from the server. Does the entry point file '${entryPoint}' exist?\n\n`;
return `Received an error from the server at ${url}. Does the entry point file '${entryPoint}' exist?\n\n`;
case NetworkError_1.NetworkErrorCode.TIMEOUT:
return `The request timed out.\n\n`;
return `The request to ${url} timed out.\n\n`;
default:
return `An unexpected error occurred.\n\n`;
return `An unexpected error occurred during the request to ${url}.\n\n`;
}
}
//# sourceMappingURL=ReactNativeUploader.js.map
{
"name": "@bugsnag/source-maps",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc