Socket
Socket
Sign inDemoInstall

@pnpm/directory-fetcher

Package Overview
Dependencies
Maintainers
2
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pnpm/directory-fetcher - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

8

lib/index.d.ts

@@ -7,3 +7,6 @@ import { Cafs, DeferredManifestPromise } from '@pnpm/fetcher-base';

}
declare const _default: () => {
export interface CreateDirectoryFetcherOptions {
includeOnlyPackageFiles?: boolean;
}
declare const _default: (opts?: CreateDirectoryFetcherOptions | undefined) => {
directory: (cafs: Cafs, resolution: DirectoryResolution, opts: DirectoryFetcherOptions) => Promise<{

@@ -16,3 +19,4 @@ local: true;

export default _default;
export declare function fetchFromDir(dir: string, opts: Omit<DirectoryFetcherOptions, 'lockfileDir'>): Promise<{
declare type FetchFromDirOpts = Omit<DirectoryFetcherOptions, 'lockfileDir'>;
export declare function fetchFromDir(dir: string, opts: FetchFromDirOpts & CreateDirectoryFetcherOptions): Promise<{
local: true;

@@ -19,0 +23,0 @@ filesIndex: Record<string, string>;

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

exports.fetchFromDir = void 0;
const fs_1 = require("fs");
const path_1 = __importDefault(require("path"));

@@ -12,3 +13,4 @@ const read_project_manifest_1 = require("@pnpm/read-project-manifest");

const npm_packlist_1 = __importDefault(require("npm-packlist"));
exports.default = () => {
exports.default = (opts) => {
const fetchFromDir = opts?.includeOnlyPackageFiles ? fetchPackageFilesFromDir : fetchAllFilesFromDir;
return {

@@ -22,2 +24,43 @@ directory: (cafs, resolution, opts) => {

async function fetchFromDir(dir, opts) {
if (opts.includeOnlyPackageFiles) {
return fetchPackageFilesFromDir(dir, opts);
}
return fetchAllFilesFromDir(dir, opts);
}
exports.fetchFromDir = fetchFromDir;
async function fetchAllFilesFromDir(dir, opts) {
const filesIndex = await _fetchAllFilesFromDir(dir);
if (opts.manifest) {
// In a regular pnpm workspace it will probably never happen that a dependency has no package.json file.
// Safe read was added to support the Bit workspace in which the components have no package.json files.
// Related PR in Bit: https://github.com/teambit/bit/pull/5251
const manifest = await (0, read_project_manifest_1.safeReadProjectManifestOnly)(dir) ?? {};
opts.manifest.resolve(manifest); // eslint-disable-line @typescript-eslint/no-explicit-any
}
return {
local: true,
filesIndex,
packageImportMethod: 'hardlink',
};
}
async function _fetchAllFilesFromDir(dir, relativeDir = '') {
const filesIndex = {};
const files = await fs_1.promises.readdir(dir);
await Promise.all(files
.filter((file) => file !== 'node_modules')
.map(async (file) => {
const filePath = path_1.default.join(dir, file);
const stat = await fs_1.promises.stat(filePath);
const relativeSubdir = `${relativeDir}${relativeDir ? '/' : ''}${file}`;
if (stat.isDirectory()) {
const subFilesIndex = await _fetchAllFilesFromDir(filePath, relativeSubdir);
Object.assign(filesIndex, subFilesIndex);
}
else {
filesIndex[relativeSubdir] = filePath;
}
}));
return filesIndex;
}
async function fetchPackageFilesFromDir(dir, opts) {
const files = await (0, npm_packlist_1.default)({ path: dir });

@@ -38,3 +81,2 @@ const filesIndex = (0, fromPairs_1.default)(files.map((file) => [file, path_1.default.join(dir, file)]));

}
exports.fetchFromDir = fetchFromDir;
//# sourceMappingURL=index.js.map
{
"name": "@pnpm/directory-fetcher",
"version": "2.0.0",
"version": "3.0.0",
"description": "A fetcher for local directory packages",

@@ -28,3 +28,3 @@ "funding": "https://opencollective.com/pnpm",

"@pnpm/fetcher-base": "12.0.0",
"@pnpm/read-project-manifest": "3.0.0",
"@pnpm/read-project-manifest": "3.0.1",
"@pnpm/resolver-base": "9.0.0",

@@ -35,4 +35,6 @@ "npm-packlist": "^3.0.0",

"devDependencies": {
"@pnpm/directory-fetcher": "2.0.0",
"@pnpm/test-fixtures": "0.0.6"
"@pnpm/directory-fetcher": "3.0.0",
"@pnpm/test-fixtures": "0.0.7",
"@types/npm-packlist": "^1.1.2",
"@types/ramda": "0.27.39"
},

@@ -39,0 +41,0 @@ "exports": {

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