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

danger-plugin-yarn

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

danger-plugin-yarn - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0

4

dist/index.d.ts

@@ -49,7 +49,7 @@ import { JSONDiff } from "../node_modules/danger/distribution/dsl/GitDSL";

*/
export declare function _renderNPMTable({usedInPackageJSONPaths, npmData: {details, readme}}: {
export declare function _renderNPMTable({ usedInPackageJSONPaths, npmData: { details, readme }, }: {
usedInPackageJSONPaths: string[];
npmData: PartiallyRenderedNPMMetadata;
}): string;
export declare const checkForLockfileDiff: (packageDiff: any) => void;
export declare const checkForLockfileDiff: (packagePath: any, packageDiff: any) => void;
export declare const checkForTypesInDeps: (packageDiff: any) => void;

@@ -56,0 +56,0 @@ export interface Options {

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -11,5 +12,6 @@ });

Object.defineProperty(exports, "__esModule", { value: true });
exports._operateOnSingleDiff = exports.checkForTypesInDeps = exports.checkForLockfileDiff = exports._renderNPMTable = exports.getNPMMetadataForDep = exports.getYarnMetadataForDep = exports.findNewDependencies = exports.checkForNewDependencies = exports.checkForRelease = void 0;
const child_process = require("child_process");
const date_fns_1 = require("date-fns");
const fetch = require("node-fetch");
const node_fetch_1 = require("node-fetch");
const semver = require("semver");

@@ -19,3 +21,3 @@ const includesOriginal = require("lodash.includes");

// Celebrate when a new release is being shipped
exports.checkForRelease = packageDiff => {
const checkForRelease = packageDiff => {
if (packageDiff.version && packageDiff.version.before && packageDiff.version.after) {

@@ -27,2 +29,3 @@ if (semver.lt(packageDiff.version.before, packageDiff.version.after)) {

};
exports.checkForRelease = checkForRelease;
const cacheEntryForDep = (cache, depName) => {

@@ -44,4 +47,4 @@ if (cache[depName]) {

// Initial stab at showing information about a new dependency
exports.checkForNewDependencies = (packagePath, packageDiff, duplicationCache, npmAuthToken) => __awaiter(this, void 0, void 0, function* () {
const newDependencies = exports.findNewDependencies(packageDiff);
const checkForNewDependencies = (packagePath, packageDiff, duplicationCache, npmAuthToken) => __awaiter(void 0, void 0, void 0, function* () {
const newDependencies = (0, exports.findNewDependencies)(packageDiff);
for (const dep of newDependencies) {

@@ -54,3 +57,3 @@ const [freshlyCreated, cacheEntry] = cacheEntryForDep(duplicationCache, dep);

// Pump out a bunch of metadata information
const npm = yield exports.getNPMMetadataForDep(dep, npmAuthToken);
const npm = yield (0, exports.getNPMMetadataForDep)(dep, npmAuthToken);
if (npm) {

@@ -64,3 +67,3 @@ cacheEntry.npmData.details = npm.details;

if ("undefined" === typeof peril) {
const yarn = yield exports.getYarnMetadataForDep(dep);
const yarn = yield (0, exports.getYarnMetadataForDep)(dep);
if (yarn && yarn.length) {

@@ -75,3 +78,4 @@ cacheEntry.yarnBody = yarn;

});
exports.findNewDependencies = (packageDiff) => {
exports.checkForNewDependencies = checkForNewDependencies;
const findNewDependencies = (packageDiff) => {
const added = [];

@@ -85,3 +89,4 @@ for (const element of [packageDiff.dependencies, packageDiff.devDependencies]) {

};
exports.getYarnMetadataForDep = (dep) => __awaiter(this, void 0, void 0, function* () {
exports.findNewDependencies = findNewDependencies;
const getYarnMetadataForDep = (dep) => __awaiter(void 0, void 0, void 0, function* () {
return new Promise(resolve => {

@@ -109,2 +114,3 @@ child_process.exec(`yarn why '${dep}' --json`, (err, output) => {

});
exports.getYarnMetadataForDep = getYarnMetadataForDep;
const safeLink = (name) => `<a href='${linkToNPM(name)}'><code>${printDep(name)}</code></a>`;

@@ -129,3 +135,3 @@ const printDep = (name) => name.replace(/@/, "&#64;");

};
exports.getNPMMetadataForDep = (dep, npmAuthToken) => __awaiter(this, void 0, void 0, function* () {
const getNPMMetadataForDep = (dep, npmAuthToken) => __awaiter(void 0, void 0, void 0, function* () {
const sentence = danger.utils.sentence;

@@ -135,3 +141,3 @@ // Note: NPM can't handle encoded '@'

const headers = npmAuthToken ? { Authorization: `Bearer ${npmAuthToken}` } : undefined;
const npmResponse = yield fetch(`https://registry.npmjs.org/${urlDep}`, { headers });
const npmResponse = yield (0, node_fetch_1.default)(`https://registry.npmjs.org/${urlDep}`, { headers });
if (npmResponse.ok) {

@@ -143,3 +149,3 @@ /**

const tableDeets = [];
const npm = yield npmResponse.json();
const npm = (yield npmResponse.json());
const homepage = npm.homepage ? npm.homepage : `http://npmjs.com/package/${dep}`;

@@ -182,6 +188,6 @@ // Left

const createdTimeStr = npm.time && npm.time.created
? `${date_fns_1.distanceInWords(new Date(npm.time.created), new Date())} ago`
? `${(0, date_fns_1.distanceInWords)(new Date(npm.time.created), new Date())} ago`
: "Unknown";
const updatedTimeStr = npm.time && npm.time.modified
? `${date_fns_1.distanceInWords(new Date(npm.time.modified), new Date())} ago`
? `${(0, date_fns_1.distanceInWords)(new Date(npm.time.modified), new Date())} ago`
: createdTimeStr;

@@ -248,2 +254,3 @@ // Left

});
exports.getNPMMetadataForDep = getNPMMetadataForDep;
function renderCell({ colspanToUse = 1, content }) {

@@ -284,3 +291,3 @@ return `<td${colspanToUse !== 1 ? ` colspan="${colspanToUse}"` : ""}> ${content} </td>`;

</table>
${readme}}
${readme}
`;

@@ -303,7 +310,8 @@ }

// someone has only used `npm install` instead of `yarn.
exports.checkForLockfileDiff = packageDiff => {
const checkForLockfileDiff = (packagePath, packageDiff) => {
if (packageDiff.dependencies || packageDiff.devDependencies) {
const lockfileChanged = includes(danger.git.modified_files, "yarn.lock");
const lockfilePath = packagePath.replace(/package\.json$/, "yarn.lock");
const lockfileChanged = includes(danger.git.modified_files, lockfilePath);
if (!lockfileChanged) {
const message = "Changes were made to package.json, but not to yarn.lock.";
const message = `Changes were made to ${packagePath}, but not to ${lockfilePath}.`;
const idea = "Perhaps you need to run `yarn install`?";

@@ -314,4 +322,5 @@ warn(`${message}<br/><i>${idea}</i>`);

};
exports.checkForLockfileDiff = checkForLockfileDiff;
// Don't ship @types dependencies to consumers of Danger
exports.checkForTypesInDeps = packageDiff => {
const checkForTypesInDeps = packageDiff => {
const sentence = danger.utils.sentence;

@@ -327,2 +336,3 @@ if (packageDiff.dependencies && packageDiff.dependencies.added) {

};
exports.checkForTypesInDeps = checkForTypesInDeps;
/** @private Only exported for testing reasons */

@@ -332,12 +342,12 @@ function _operateOnSingleDiff(packagePath, packageDiff, duplicationCache, options) {

if (!options.disableCheckForRelease) {
exports.checkForRelease(packageDiff);
(0, exports.checkForRelease)(packageDiff);
}
if (!options.disableCheckForLockfileDiff) {
exports.checkForLockfileDiff(packageDiff);
(0, exports.checkForLockfileDiff)(packagePath, packageDiff);
}
if (!options.disableCheckForTypesInDeps) {
exports.checkForTypesInDeps(packageDiff);
(0, exports.checkForTypesInDeps)(packageDiff);
}
if (!options.disableCheckForNewDependencies) {
yield exports.checkForNewDependencies(packagePath, packageDiff, duplicationCache, options.npmAuthToken);
yield (0, exports.checkForNewDependencies)(packagePath, packageDiff, duplicationCache, options.npmAuthToken);
}

@@ -344,0 +354,0 @@ });

@@ -21,3 +21,3 @@ {

],
"version": "1.4.1",
"version": "1.5.0",
"main": "dist/index.js",

@@ -47,3 +47,3 @@ "types": "dist/index.d.ts",

"lodash.includes": "^4.3.0",
"node-fetch": "^2.6.1",
"node-fetch": "^3.1.1",
"semver": "^5.4.1"

@@ -53,3 +53,3 @@ },

"@types/jest": "^19.2.4",
"@types/node": "^7.0.29",
"@types/node": "^10.0.29",
"commitizen": "^2.9.6",

@@ -66,3 +66,3 @@ "cz-conventional-changelog": "^2.0.0",

"tslint": "^5.4.3",
"typescript": "^2.3.2",
"typescript": "^4.6",
"validate-commit-msg": "^2.12.1"

@@ -69,0 +69,0 @@ },

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