@yarnpkg/pnpify
Advanced tools
Comparing version 2.0.0-rc.4 to 2.0.0-rc.5
@@ -0,1 +1,2 @@ | ||
#!/usr/bin/env node | ||
export {}; |
@@ -0,1 +1,2 @@ | ||
#!/usr/bin/env node | ||
"use strict"; | ||
@@ -2,0 +3,0 @@ var __importDefault = (this && this.__importDefault) || function (mod) { |
@@ -8,23 +8,39 @@ "use strict"; | ||
const fslib_2 = require("@yarnpkg/fslib"); | ||
const fslib_3 = require("@yarnpkg/fslib"); | ||
const fs_1 = __importDefault(require("fs")); | ||
const NodePathResolver_1 = require("./NodePathResolver"); | ||
class NodeModulesFS extends fslib_1.ProxiedFS { | ||
const WatchManager_1 = require("./WatchManager"); | ||
class NodeModulesFS extends fslib_2.ProxiedFS { | ||
constructor(pnp, { realFs = fs_1.default } = {}) { | ||
super(fslib_2.npath); | ||
this.baseFs = new PortableNodeModulesFs(pnp, { baseFs: new fslib_1.NodeFS(realFs) }); | ||
super(fslib_3.npath); | ||
this.baseFs = new PortableNodeModulesFs(pnp, { baseFs: new fslib_2.NodeFS(realFs) }); | ||
} | ||
mapFromBase(path) { | ||
return fslib_1.NodeFS.fromPortablePath(path); | ||
return fslib_2.NodeFS.fromPortablePath(path); | ||
} | ||
mapToBase(path) { | ||
return fslib_1.NodeFS.toPortablePath(path); | ||
return fslib_2.NodeFS.toPortablePath(path); | ||
} | ||
} | ||
exports.NodeModulesFS = NodeModulesFS; | ||
class PortableNodeModulesFs extends fslib_1.FakeFS { | ||
constructor(pnp, { baseFs = new fslib_1.NodeFS() } = {}) { | ||
super(fslib_2.ppath); | ||
class PortableNodeModulesFs extends fslib_2.FakeFS { | ||
constructor(pnp, { baseFs = new fslib_2.NodeFS() } = {}) { | ||
super(fslib_3.ppath); | ||
this.baseFs = baseFs; | ||
this.pathResolver = new NodePathResolver_1.NodePathResolver(pnp); | ||
this.watchManager = new WatchManager_1.WatchManager(); | ||
const pnpRootPath = fslib_2.NodeFS.toPortablePath(pnp.getPackageInformation(pnp.topLevel).packageLocation); | ||
this.watchPnpFile(pnpRootPath); | ||
} | ||
watchPnpFile(pnpRootPath) { | ||
const pnpFilePath = fslib_3.ppath.join(pnpRootPath, fslib_1.toFilename('.pnp.js')); | ||
this.baseFs.watch(pnpRootPath, { persistent: false }, (_, filename) => { | ||
if (filename === '.pnp.js') { | ||
delete require.cache[pnpFilePath]; | ||
const pnp = require(pnpFilePath); | ||
this.pathResolver = new NodePathResolver_1.NodePathResolver(pnp); | ||
this.watchManager.notifyWatchers(this.pathResolver); | ||
} | ||
}); | ||
} | ||
resolve(path) { | ||
@@ -289,3 +305,3 @@ return this.baseFs.resolve(this.resolvePath(path).resolvedPath); | ||
else if (pnpPath.dirList) { | ||
return pnpPath.dirList; | ||
return Array.from(pnpPath.dirList); | ||
} | ||
@@ -302,3 +318,3 @@ else { | ||
else if (pnpPath.dirList) { | ||
return pnpPath.dirList; | ||
return Array.from(pnpPath.dirList); | ||
} | ||
@@ -316,6 +332,14 @@ else { | ||
watch(p, a, b) { | ||
return this.baseFs.watch(p, | ||
// @ts-ignore | ||
a, b); | ||
const pnpPath = this.resolvePath(p); | ||
const watchPath = pnpPath.resolvedPath; | ||
if (watchPath && pnpPath.dirList) { | ||
const callback = typeof a === 'function' ? a : typeof b === 'function' ? b : () => { }; | ||
return this.watchManager.registerWatcher(watchPath, pnpPath.dirList, callback); | ||
} | ||
else { | ||
return this.baseFs.watch(p, | ||
// @ts-ignore | ||
a, b); | ||
} | ||
} | ||
} |
@@ -1,3 +0,3 @@ | ||
import { FSPath, PortablePath, Filename } from '@yarnpkg/fslib'; | ||
import { PnpApi, PackageInformation } from '@yarnpkg/pnp'; | ||
import { PortablePath, Filename } from '@yarnpkg/fslib'; | ||
import { PnpApi } from '@yarnpkg/pnp'; | ||
/** | ||
@@ -16,3 +16,3 @@ * Resolved `/node_modules` path inside PnP project info. | ||
*/ | ||
export interface ResolvedPath<PathType extends FSPath<PortablePath>> { | ||
export interface ResolvedPath { | ||
/** | ||
@@ -22,3 +22,3 @@ * Fully resolved path `/node_modules/...` path within PnP project, | ||
*/ | ||
resolvedPath: PathType | null; | ||
resolvedPath: PortablePath | null; | ||
/** | ||
@@ -35,3 +35,3 @@ * The path that should be used for stats. This field is returned for pathes ending | ||
*/ | ||
dirList?: Filename[]; | ||
dirList?: Set<Filename>; | ||
} | ||
@@ -60,3 +60,3 @@ /** | ||
*/ | ||
readDir(issuerInfo: PackageInformation<PortablePath>, scope: string | null): Filename[] | undefined; | ||
private readDir; | ||
private getIssuer; | ||
@@ -74,3 +74,3 @@ /** | ||
*/ | ||
resolvePath(nodePath: PortablePath): ResolvedPath<PortablePath>; | ||
resolvePath(nodePath: PortablePath): ResolvedPath; | ||
} |
@@ -50,3 +50,3 @@ "use strict"; | ||
} | ||
return result.size === 0 ? undefined : Array.from(result); | ||
return result.size === 0 ? undefined : result; | ||
} | ||
@@ -53,0 +53,0 @@ getIssuer(pnp, pathname) { |
@@ -20,2 +20,3 @@ "use strict"; | ||
packageDependencies: nativeInfo.packageDependencies, | ||
linkType: nativeInfo.linkType, | ||
}; | ||
@@ -22,0 +23,0 @@ } |
{ | ||
"name": "@yarnpkg/pnpify", | ||
"version": "2.0.0-rc.4", | ||
"version": "2.0.0-rc.5", | ||
"main": "./lib/index.js", | ||
@@ -13,3 +13,3 @@ "bin": "./lib/cli.js", | ||
"@yarnpkg/monorepo": "0.0.0", | ||
"@yarnpkg/pnp": "2.0.0-rc.3", | ||
"@yarnpkg/pnp": "2.0.0-rc.4", | ||
"eslint": "^5.16.0", | ||
@@ -33,3 +33,4 @@ "typescript": "^3.5.3" | ||
"prepack": "run build:compile packages/yarnpkg-pnpify", | ||
"release": "yarn npm publish" | ||
"release": "yarn npm publish", | ||
"test": "run test:unit packages/yarnpkg-pnpify" | ||
}, | ||
@@ -36,0 +37,0 @@ "publishConfig": { |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
38579
17
893
6