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

@rnx-kit/third-party-notices

Package Overview
Dependencies
Maintainers
7
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rnx-kit/third-party-notices - npm Package Compare versions

Comparing version 1.3.3 to 1.3.4

76

lib/write-third-party-notices.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.gatherModulesFromSources = exports.extractLicenses = exports.extractModuleNameToPathMap = exports.parseSourceMap = exports.parseModule = exports.splitSourcePath = exports.normalizePath = exports.getCurrentPackageId = exports.writeThirdPartyNoticesFromMap = exports.writeThirdPartyNotices = void 0;
const fs_1 = __importDefault(require("fs"));
const module_1 = require("@rnx-kit/tools-node/module");
const package_1 = require("@rnx-kit/tools-node/package");
const path_1 = require("path");
const util_1 = require("util");
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const json_1 = require("./output/json");

@@ -33,6 +53,6 @@ const text_1 = require("./output/text");

async function writeThirdPartyNotices(options) {
const readFileAsync = (0, util_1.promisify)(fs_1.default.readFile);
const fileOptions = { encoding: "utf-8" };
const { additionalText, json, outputFile, preambleText, sourceMapFile } = options;
// Parse source map file
const sourceMapJson = await readFileAsync(sourceMapFile, "utf8");
const sourceMapJson = fs.readFileSync(sourceMapFile, fileOptions);
const sourceMap = JSON.parse(sourceMapJson);

@@ -46,4 +66,3 @@ const currentPackageId = await getCurrentPackageId(options.rootPath);

if (outputFile) {
const writeFileAsync = (0, util_1.promisify)(fs_1.default.writeFile);
await writeFileAsync(outputFile, outputText, "utf8");
fs.writeFileSync(outputFile, outputText, fileOptions);
}

@@ -67,3 +86,3 @@ else {

}
fs_1.default.writeFileSync(outputFile, outputText);
fs.writeFileSync(outputFile, outputText);
}

@@ -98,6 +117,7 @@ exports.writeThirdPartyNoticesFromMap = writeThirdPartyNoticesFromMap;

// pnpm: <repo-root>/common/temp/node_modules/.yourProject.pkgs.visualstudio.com/fbjs/0.8.17/node_modules/fbjs
let nodeModulesPath;
let relativeSourcePath;
//
// bundles use WebPack's dll plugin to perform cross-bundle module retrieval.
// cross bundle modules' paths are appended with 'delegated ', which we need to remove from path.
// cross bundle modules' paths are appended with 'delegated ', which we need
// to remove from path.
//
// ** example **

@@ -109,20 +129,17 @@ // delegated ../../../common/temp/node_modules/.yourProject.pkgs.visualstudio.com/react-native/0.3003.5/react@16.0.0/node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js from dll-reference runtime20

}
const pnpmRegExp = /(.*?node_modules\/[.].+?\/node_modules\/)(.*)/;
const pnpmPathComponents = pnpmRegExp.exec(p);
if (pnpmPathComponents !== null) {
nodeModulesPath = pnpmPathComponents[1];
relativeSourcePath = pnpmPathComponents[2];
const absolutePath = path.resolve(rootPath, p).replace(/[\\]+/g, "/");
const idx = absolutePath.lastIndexOf(modulesRoot);
if (idx == null || idx < 0) {
throw new Error(`Unexpected module: ${p}`);
}
else {
nodeModulesPath = p.substring(0, p.lastIndexOf(modulesRoot) + modulesRoot.length);
relativeSourcePath = p.substring(nodeModulesPath.length);
const ref = (0, module_1.parseModuleRef)(absolutePath.substring(idx + modulesRoot.length));
if (!(0, module_1.isPackageModuleRef)(ref)) {
throw new Error(`Could not parse module: ${p}`);
}
let moduleName;
if (relativeSourcePath[0] === "@") {
moduleName = relativeSourcePath.split("/").slice(0, 2).join("/");
}
else {
moduleName = relativeSourcePath.split("/")[0];
}
return [moduleName, (0, path_1.resolve)(rootPath, `${nodeModulesPath}${moduleName}`)];
return [
ref.scope ? `${ref.scope}/${ref.name}` : ref.name,
ref.path
? absolutePath.substring(0, absolutePath.length - ref.path.length - 1)
: absolutePath,
];
}

@@ -132,3 +149,2 @@ exports.splitSourcePath = splitSourcePath;

const [moduleName, modulePath] = splitSourcePath(options.rootPath, p);
const fs = require("fs");
if ((options.ignoreScopes &&

@@ -135,0 +151,0 @@ options.ignoreScopes.some((scope) => moduleName.startsWith(scope + "/"))) ||

{
"name": "@rnx-kit/third-party-notices",
"version": "1.3.3",
"version": "1.3.4",
"description": "Library and tool to build a third party notices file based on a js bundle's source map",

@@ -37,8 +37,8 @@ "homepage": "https://github.com/microsoft/rnx-kit/tree/main/packages/third-party-notices#readme",

"@rnx-kit/scripts": "*",
"@types/jest": "^29.0.0",
"@types/jest": "^29.2.1",
"@types/metro-source-map": "^0.76.0",
"@types/yargs": "^16.0.0",
"eslint": "^8.0.0",
"jest": "^29.0.0",
"prettier": "^2.8.0",
"jest": "^29.2.1",
"prettier": "^3.0.0",
"typescript": "^5.0.0"

@@ -45,0 +45,0 @@ },

@@ -27,3 +27,7 @@ # @rnx-kit/third-party-notices

`npx @rnx-kit/third-party-notices --rootPath <myPackage> --sourceMapFile <myPackage/dist/myPackage.js.map>`
```
npx @rnx-kit/third-party-notices \
--rootPath <myPackage> \
--sourceMapFile <myPackage/dist/myPackage.js.map>
```

@@ -30,0 +34,0 @@ ```

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