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

@yarnpkg/core

Package Overview
Dependencies
Maintainers
6
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yarnpkg/core - npm Package Compare versions

Comparing version 4.0.0-rc.52 to 4.0.0-rc.53

lib/TaskPool.d.ts

2

lib/Configuration.d.ts

@@ -156,2 +156,4 @@ /// <reference types="node" />

enableStrictSsl: boolean;
taskPoolConcurrency: number;
taskPoolMode: string;
logFilters: Array<miscUtils.ToMapValue<{

@@ -158,0 +160,0 @@ code?: string;

6

lib/execUtils.js

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

const signalToCodeMap = new Map([
[`SIGINT`, 2],
[`SIGQUIT`, 3],
[`SIGKILL`, 9],
[`SIGINT`, 2], // ctrl-c
[`SIGQUIT`, 3], // ctrl-\
[`SIGKILL`, 9], // hard kill
[`SIGTERM`, 15], // default signal for kill

@@ -172,0 +172,0 @@ ]);

@@ -45,6 +45,10 @@ /// <reference types="node" />

export declare function convertMapsToIndexableObjects<T>(arg: T): MapValueToObjectValue<T>;
export declare function getFactoryWithDefault<K, T>(map: Map<K, T>, key: K, factory: () => T): T;
export declare function getArrayWithDefault<K, T>(map: Map<K, Array<T>>, key: K): T[];
export declare function getSetWithDefault<K, T>(map: Map<K, Set<T>>, key: K): Set<T>;
export declare function getMapWithDefault<K, MK, MV>(map: Map<K, Map<MK, MV>>, key: K): Map<MK, MV>;
export interface GetSetMap<K, V> {
get(k: K): V | undefined;
set(k: K, v: V): void;
}
export declare function getFactoryWithDefault<K, T>(map: GetSetMap<K, T>, key: K, factory: () => T): T;
export declare function getArrayWithDefault<K, T>(map: GetSetMap<K, Array<T>>, key: K): T[];
export declare function getSetWithDefault<K, T>(map: GetSetMap<K, Set<T>>, key: K): Set<T>;
export declare function getMapWithDefault<K, MK, MV>(map: GetSetMap<K, Map<MK, MV>>, key: K): Map<MK, MV>;
export declare function releaseAfterUseAsync<T>(fn: () => Promise<T>, cleanup?: (() => any) | null): Promise<T>;

@@ -51,0 +55,0 @@ export declare function prettifyAsyncErrors<T>(fn: () => Promise<T>, update: (message: string) => string): Promise<T>;

/// <reference types="node" />
import { Configuration } from '@yarnpkg/core';
import { FakeFS, PortablePath } from '@yarnpkg/fslib';
import { ZipCompression, ZipFS } from '@yarnpkg/libzip';
interface MakeArchiveFromDirectoryOptions {
import { TaskPool } from './TaskPool';
export type ConvertToZipPayload = {
tmpFile: PortablePath;
tgz: Buffer | Uint8Array;
extractBufferOpts: ExtractBufferOptions;
compressionLevel: ZipCompression;
};
export type ZipWorkerPool = TaskPool<ConvertToZipPayload, PortablePath>;
export declare function getDefaultTaskPool(): ZipWorkerPool;
export declare function getTaskPoolForConfiguration(configuration: Configuration | void): ZipWorkerPool;
export declare function convertToZipWorker(data: ConvertToZipPayload): Promise<PortablePath>;
export interface MakeArchiveFromDirectoryOptions {
baseFs?: FakeFS<PortablePath>;

@@ -12,8 +24,11 @@ prefixPath?: PortablePath | null;

export interface ExtractBufferOptions {
compressionLevel?: ZipCompression;
prefixPath?: PortablePath;
stripComponents?: number;
}
export declare function convertToZip(tgz: Buffer, opts: ExtractBufferOptions): Promise<ZipFS>;
export interface ConvertToZipOptions extends ExtractBufferOptions {
configuration?: Configuration;
compressionLevel?: ZipCompression;
taskPool?: ZipWorkerPool;
}
export declare function convertToZip(tgz: Buffer, opts?: ConvertToZipOptions): Promise<ZipFS>;
export declare function extractArchiveTo<T extends FakeFS<PortablePath>>(tgz: Buffer, targetFs: T, { stripComponents, prefixPath }?: ExtractBufferOptions): Promise<T>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractArchiveTo = exports.convertToZip = exports.makeArchiveFromDirectory = void 0;
exports.extractArchiveTo = exports.convertToZip = exports.makeArchiveFromDirectory = exports.convertToZipWorker = exports.getTaskPoolForConfiguration = exports.getDefaultTaskPool = void 0;
const tslib_1 = require("tslib");
const core_1 = require("@yarnpkg/core");
const fslib_1 = require("@yarnpkg/fslib");

@@ -9,5 +10,52 @@ const libzip_1 = require("@yarnpkg/libzip");

const tar_1 = tslib_1.__importDefault(require("tar"));
const WorkerPool_1 = require("./WorkerPool");
const TaskPool_1 = require("./TaskPool");
const miscUtils = tslib_1.__importStar(require("./miscUtils"));
const worker_zip_1 = require("./worker-zip");
function createTaskPool(poolMode, poolSize) {
switch (poolMode) {
case `async`:
return new TaskPool_1.AsyncPool(convertToZipWorker, { poolSize });
case `workers`:
return new TaskPool_1.WorkerPool((0, worker_zip_1.getContent)(), { poolSize });
default: {
throw new Error(`Assertion failed: Unknown value ${poolMode} for taskPoolMode`);
}
}
}
let defaultWorkerPool;
function getDefaultTaskPool() {
if (typeof defaultWorkerPool === `undefined`)
defaultWorkerPool = createTaskPool(`workers`, core_1.nodeUtils.availableParallelism());
return defaultWorkerPool;
}
exports.getDefaultTaskPool = getDefaultTaskPool;
const workerPools = new WeakMap();
function getTaskPoolForConfiguration(configuration) {
if (typeof configuration === `undefined`)
return getDefaultTaskPool();
return miscUtils.getFactoryWithDefault(workerPools, configuration, () => {
const poolMode = configuration.get(`taskPoolMode`);
const poolSize = configuration.get(`taskPoolConcurrency`);
switch (poolMode) {
case `async`:
return new TaskPool_1.AsyncPool(convertToZipWorker, { poolSize });
case `workers`:
return new TaskPool_1.WorkerPool((0, worker_zip_1.getContent)(), { poolSize });
default: {
throw new Error(`Assertion failed: Unknown value ${poolMode} for taskPoolMode`);
}
}
});
}
exports.getTaskPoolForConfiguration = getTaskPoolForConfiguration;
async function convertToZipWorker(data) {
const { tmpFile, tgz, compressionLevel, extractBufferOpts } = data;
const zipFs = new libzip_1.ZipFS(tmpFile, { create: true, level: compressionLevel, stats: fslib_1.statUtils.makeDefaultStats() });
// Buffers sent through Node are turned into regular Uint8Arrays
const tgzBuffer = Buffer.from(tgz.buffer, tgz.byteOffset, tgz.byteLength);
await extractArchiveTo(tgzBuffer, zipFs, extractBufferOpts);
zipFs.saveAndClose();
return tmpFile;
}
exports.convertToZipWorker = convertToZipWorker;
async function makeArchiveFromDirectory(source, { baseFs = new fslib_1.NodeFS(), prefixPath = fslib_1.PortablePath.root, compressionLevel, inMemory = false } = {}) {

@@ -28,8 +76,14 @@ let zipFs;

exports.makeArchiveFromDirectory = makeArchiveFromDirectory;
let workerPool;
async function convertToZip(tgz, opts) {
async function convertToZip(tgz, opts = {}) {
const tmpFolder = await fslib_1.xfs.mktempPromise();
const tmpFile = fslib_1.ppath.join(tmpFolder, `archive.zip`);
workerPool ||= new WorkerPool_1.WorkerPool((0, worker_zip_1.getContent)());
await workerPool.run({ tmpFile, tgz, opts });
const compressionLevel = opts.compressionLevel
?? opts.configuration?.get(`compressionLevel`)
?? `mixed`;
const extractBufferOpts = {
prefixPath: opts.prefixPath,
stripComponents: opts.stripComponents,
};
const taskPool = opts.taskPool ?? getTaskPoolForConfiguration(opts.configuration);
await taskPool.run({ tmpFile, tgz, compressionLevel, extractBufferOpts });
return new libzip_1.ZipFS(tmpFile, { level: opts.compressionLevel });

@@ -36,0 +90,0 @@ }

export function getContent(): string;
export type {ConvertToZipPayload} from './Worker';

@@ -1,8 +0,1 @@

/// <reference types="node" />
import { PortablePath } from '@yarnpkg/fslib';
import { ExtractBufferOptions } from '../tgzUtils';
export type ConvertToZipPayload = {
tmpFile: PortablePath;
tgz: Buffer | Uint8Array;
opts: ExtractBufferOptions;
};
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fslib_1 = require("@yarnpkg/fslib");
const libzip_1 = require("@yarnpkg/libzip");
const worker_threads_1 = require("worker_threads");

@@ -10,10 +8,3 @@ const tgzUtils_1 = require("../tgzUtils");

worker_threads_1.parentPort.on(`message`, async (data) => {
const { opts, tgz, tmpFile } = data;
const { compressionLevel, ...bufferOpts } = opts;
const zipFs = new libzip_1.ZipFS(tmpFile, { create: true, level: compressionLevel, stats: fslib_1.statUtils.makeDefaultStats() });
// Buffers sent through Node are turned into regular Uint8Arrays
const tgzBuffer = Buffer.from(tgz.buffer, tgz.byteOffset, tgz.byteLength);
await (0, tgzUtils_1.extractArchiveTo)(tgzBuffer, zipFs, bufferOpts);
zipFs.saveAndClose();
worker_threads_1.parentPort.postMessage(data.tmpFile);
worker_threads_1.parentPort.postMessage(await (0, tgzUtils_1.convertToZipWorker)(data));
});
{
"name": "@yarnpkg/core",
"version": "4.0.0-rc.52",
"stableVersion": "3.5.3",
"version": "4.0.0-rc.53",
"stableVersion": "3.5.4",
"license": "BSD-2-Clause",

@@ -16,6 +16,6 @@ "main": "./lib/index.js",

"@types/treeify": "^1.0.0",
"@yarnpkg/fslib": "^3.0.0-rc.52",
"@yarnpkg/libzip": "^3.0.0-rc.52",
"@yarnpkg/parsers": "^3.0.0-rc.52",
"@yarnpkg/shell": "^4.0.0-rc.52",
"@yarnpkg/fslib": "^3.0.0-rc.53",
"@yarnpkg/libzip": "^3.0.0-rc.53",
"@yarnpkg/parsers": "^3.0.0-rc.53",
"@yarnpkg/shell": "^4.0.0-rc.53",
"camelcase": "^5.3.1",

@@ -53,6 +53,6 @@ "chalk": "^3.0.0",

"@types/tunnel": "^0.0.0",
"@yarnpkg/cli": "^4.0.0-rc.52",
"@yarnpkg/plugin-link": "^3.0.0-rc.52",
"@yarnpkg/plugin-npm": "^3.0.0-rc.52",
"@yarnpkg/plugin-pnp": "^4.0.0-rc.52",
"@yarnpkg/cli": "^4.0.0-rc.53",
"@yarnpkg/plugin-link": "^3.0.0-rc.53",
"@yarnpkg/plugin-npm": "^3.0.0-rc.53",
"@yarnpkg/plugin-pnp": "^4.0.0-rc.53",
"comment-json": "^2.2.0",

@@ -59,0 +59,0 @@ "esbuild": "npm:esbuild-wasm@^0.15.15",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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