@yarnpkg/pnpify
Advanced tools
Comparing version 2.0.0-rc.7 to 2.0.0-rc.8
@@ -32,3 +32,3 @@ #!/usr/bin/env node | ||
const { packageLocation } = getPackageInformation(topLevel); | ||
const projectRoot = fslib_1.NodeFS.toPortablePath(packageLocation); | ||
const projectRoot = fslib_1.npath.toPortablePath(packageLocation); | ||
generateSdk_1.generateSdk(projectRoot).catch(error => { | ||
@@ -35,0 +35,0 @@ console.error(error.stack); |
@@ -7,6 +7,6 @@ "use strict"; | ||
const fslib_1 = require("@yarnpkg/fslib"); | ||
const json5_1 = __importDefault(require("json5")); | ||
const comment_json_1 = __importDefault(require("comment-json")); | ||
const dynamicRequire_1 = require("./dynamicRequire"); | ||
const TEMPLATE = (relPnpApiPath, module, { usePnpify }) => [ | ||
`const relPnpApiPath = ${JSON.stringify(fslib_1.NodeFS.toPortablePath(relPnpApiPath))};\n`, | ||
`const relPnpApiPath = ${JSON.stringify(fslib_1.npath.toPortablePath(relPnpApiPath))};\n`, | ||
`const absPnpApiPath = require(\`path\`).resolve(__dirname, relPnpApiPath);\n`, | ||
@@ -33,4 +33,4 @@ `\n`, | ||
const content = await fslib_1.xfs.existsPromise(settingsPath) ? await fslib_1.xfs.readFilePromise(settingsPath, `utf8`) : `{}`; | ||
const data = json5_1.default.parse(content); | ||
const patched = `${json5_1.default.stringify(Object.assign(Object.assign({}, data), settings), null, 2)}\n`; | ||
const data = comment_json_1.default.parse(content); | ||
const patched = `${comment_json_1.default.stringify(Object.assign(Object.assign({}, data), settings), null, 2)}\n`; | ||
await fslib_1.xfs.mkdirpPromise(fslib_1.ppath.dirname(settingsPath)); | ||
@@ -47,3 +47,3 @@ await fslib_1.xfs.changeFilePromise(settingsPath, patched); | ||
await fslib_1.xfs.writeFilePromise(tsserver, TEMPLATE(relPnpApiPath, "typescript/lib/tsserver", { usePnpify: true })); | ||
await addVSCodeWorkspaceSettings(projectRoot, { 'typescript.tsdk': fslib_1.NodeFS.fromPortablePath(fslib_1.ppath.relative(projectRoot, fslib_1.ppath.dirname(tsserver))) }); | ||
await addVSCodeWorkspaceSettings(projectRoot, { 'typescript.tsdk': fslib_1.npath.fromPortablePath(fslib_1.ppath.relative(projectRoot, fslib_1.ppath.dirname(tsserver))) }); | ||
}; | ||
@@ -58,3 +58,3 @@ exports.generateEslintWrapper = async (projectRoot, target) => { | ||
await fslib_1.xfs.writeFilePromise(api, TEMPLATE(relPnpApiPath, "eslint", { usePnpify: false })); | ||
await addVSCodeWorkspaceSettings(projectRoot, { 'eslint.nodePath': fslib_1.NodeFS.fromPortablePath(fslib_1.ppath.relative(projectRoot, fslib_1.ppath.dirname(eslint))) }); | ||
await addVSCodeWorkspaceSettings(projectRoot, { 'eslint.nodePath': fslib_1.npath.fromPortablePath(fslib_1.ppath.relative(projectRoot, fslib_1.ppath.dirname(eslint))) }); | ||
}; | ||
@@ -61,0 +61,0 @@ const isPackageInstalled = (name) => { |
@@ -18,6 +18,6 @@ "use strict"; | ||
mapFromBase(path) { | ||
return fslib_2.NodeFS.fromPortablePath(path); | ||
return fslib_3.npath.fromPortablePath(path); | ||
} | ||
mapToBase(path) { | ||
return fslib_2.NodeFS.toPortablePath(path); | ||
return fslib_3.npath.toPortablePath(path); | ||
} | ||
@@ -32,3 +32,3 @@ } | ||
this.watchManager = new WatchManager_1.WatchManager(); | ||
const pnpRootPath = fslib_2.NodeFS.toPortablePath(pnp.getPackageInformation(pnp.topLevel).packageLocation); | ||
const pnpRootPath = fslib_3.npath.toPortablePath(pnp.getPackageInformation(pnp.topLevel).packageLocation); | ||
this.watchPnpFile(pnpRootPath); | ||
@@ -73,2 +73,13 @@ } | ||
} | ||
resolveDirOrFilePath(p) { | ||
if (typeof p === `number`) | ||
return p; | ||
const pnpPath = this.resolvePath(p); | ||
if (!pnpPath.resolvedPath) { | ||
throw PortableNodeModulesFs.createFsError('ENOENT', `no such file or directory, stat '${p}'`); | ||
} | ||
else { | ||
return pnpPath.statPath || pnpPath.resolvedPath; | ||
} | ||
} | ||
resolveLink(p, op, onSymlink, onRealPath) { | ||
@@ -105,22 +116,2 @@ const pnpPath = this.resolvePath(p); | ||
} | ||
throwIfPathReadonly(op, p) { | ||
if (typeof p === `number`) | ||
return p; | ||
const pnpPath = this.resolvePath(p); | ||
if (pnpPath.resolvedPath !== pnpPath.fullOriginalPath) { | ||
throw PortableNodeModulesFs.createFsError('EPERM', `operation not permitted, ${op} '${p}'`); | ||
} | ||
else { | ||
return p; | ||
} | ||
} | ||
resolveDirOrFilePath(p) { | ||
const pnpPath = this.resolvePath(p); | ||
if (!pnpPath.resolvedPath) { | ||
throw PortableNodeModulesFs.createFsError('ENOENT', `no such file or directory, stat '${p}'`); | ||
} | ||
else { | ||
return pnpPath.statPath || pnpPath.resolvedPath; | ||
} | ||
} | ||
getRealPath() { | ||
@@ -167,3 +158,3 @@ return this.baseFs.getRealPath(); | ||
createWriteStream(p, opts) { | ||
return this.baseFs.createWriteStream(p !== null ? this.throwIfPathReadonly('createWriteStream', p) : p, opts); | ||
return this.baseFs.createWriteStream(p !== null ? this.resolveDirOrFilePath(p) : p, opts); | ||
} | ||
@@ -225,36 +216,36 @@ async realpathPromise(p) { | ||
async chmodPromise(p, mask) { | ||
return await this.baseFs.chmodPromise(this.throwIfPathReadonly('chmod', p), mask); | ||
return await this.baseFs.chmodPromise(this.resolveDirOrFilePath(p), mask); | ||
} | ||
chmodSync(p, mask) { | ||
return this.baseFs.chmodSync(this.throwIfPathReadonly('chmodSync', p), mask); | ||
return this.baseFs.chmodSync(this.resolveDirOrFilePath(p), mask); | ||
} | ||
async renamePromise(oldP, newP) { | ||
return await this.baseFs.renamePromise(this.throwIfPathReadonly('rename', oldP), this.throwIfPathReadonly('rename', newP)); | ||
return await this.baseFs.renamePromise(this.resolveDirOrFilePath(oldP), this.resolveDirOrFilePath(newP)); | ||
} | ||
renameSync(oldP, newP) { | ||
return this.baseFs.renameSync(this.throwIfPathReadonly('renameSync', oldP), this.throwIfPathReadonly('renameSync', newP)); | ||
return this.baseFs.renameSync(this.resolveDirOrFilePath(oldP), this.resolveDirOrFilePath(newP)); | ||
} | ||
async copyFilePromise(sourceP, destP, flags) { | ||
return await this.baseFs.copyFilePromise(this.resolveFilePath(sourceP), this.throwIfPathReadonly('copyFile', destP), flags); | ||
return await this.baseFs.copyFilePromise(this.resolveFilePath(sourceP), this.resolveDirOrFilePath(destP), flags); | ||
} | ||
copyFileSync(sourceP, destP, flags) { | ||
return this.baseFs.copyFileSync(this.resolveFilePath(sourceP), this.throwIfPathReadonly('copyFileSync', destP), flags); | ||
return this.baseFs.copyFileSync(this.resolveFilePath(sourceP), this.resolveDirOrFilePath(destP), flags); | ||
} | ||
async appendFilePromise(p, content, opts) { | ||
return await this.baseFs.appendFilePromise(this.throwIfPathReadonly('appendFile', p), content, opts); | ||
return await this.baseFs.appendFilePromise(this.resolveDirOrFilePath(p), content, opts); | ||
} | ||
appendFileSync(p, content, opts) { | ||
return this.baseFs.appendFileSync(this.throwIfPathReadonly('appendFileSync', p), content, opts); | ||
return this.baseFs.appendFileSync(this.resolveDirOrFilePath(p), content, opts); | ||
} | ||
async writeFilePromise(p, content, opts) { | ||
return await this.baseFs.writeFilePromise(this.throwIfPathReadonly('writeFile', p), content, opts); | ||
return await this.baseFs.writeFilePromise(this.resolveDirOrFilePath(p), content, opts); | ||
} | ||
writeFileSync(p, content, opts) { | ||
return this.baseFs.writeFileSync(this.throwIfPathReadonly('writeFileSync', p), content, opts); | ||
return this.baseFs.writeFileSync(this.resolveDirOrFilePath(p), content, opts); | ||
} | ||
async unlinkPromise(p) { | ||
return await this.baseFs.unlinkPromise(this.throwIfPathReadonly('unlink', p)); | ||
return await this.baseFs.unlinkPromise(this.resolveDirOrFilePath(p)); | ||
} | ||
unlinkSync(p) { | ||
return this.baseFs.unlinkSync(this.throwIfPathReadonly('unlinkSync', p)); | ||
return this.baseFs.unlinkSync(this.resolveDirOrFilePath(p)); | ||
} | ||
@@ -268,18 +259,18 @@ async utimesPromise(p, atime, mtime) { | ||
async mkdirPromise(p) { | ||
return await this.baseFs.mkdirPromise(this.throwIfPathReadonly('mkdir', p)); | ||
return await this.baseFs.mkdirPromise(this.resolveDirOrFilePath(p)); | ||
} | ||
mkdirSync(p) { | ||
return this.baseFs.mkdirSync(this.throwIfPathReadonly('mkdirSync', p)); | ||
return this.baseFs.mkdirSync(this.resolveDirOrFilePath(p)); | ||
} | ||
async rmdirPromise(p) { | ||
return await this.baseFs.rmdirPromise(this.throwIfPathReadonly('rmdir', p)); | ||
return await this.baseFs.rmdirPromise(this.resolveDirOrFilePath(p)); | ||
} | ||
rmdirSync(p) { | ||
return this.baseFs.rmdirSync(this.throwIfPathReadonly('rmdirSync', p)); | ||
return this.baseFs.rmdirSync(this.resolveDirOrFilePath(p)); | ||
} | ||
async symlinkPromise(target, p) { | ||
return await this.baseFs.symlinkPromise(this.resolveDirOrFilePath(target), this.throwIfPathReadonly('symlink', p)); | ||
return await this.baseFs.symlinkPromise(this.resolveDirOrFilePath(target), this.resolveDirOrFilePath(p)); | ||
} | ||
symlinkSync(target, p) { | ||
return this.baseFs.symlinkSync(this.resolveDirOrFilePath(target), this.throwIfPathReadonly('symlinkSync', p)); | ||
return this.baseFs.symlinkSync(this.resolveDirOrFilePath(target), this.resolveDirOrFilePath(p)); | ||
} | ||
@@ -286,0 +277,0 @@ async readFilePromise(p, encoding) { |
@@ -18,3 +18,3 @@ "use strict"; | ||
portableInfo = { | ||
packageLocation: fslib_1.NodeFS.toPortablePath(nativeInfo.packageLocation), | ||
packageLocation: fslib_1.npath.toPortablePath(nativeInfo.packageLocation), | ||
packageDependencies: nativeInfo.packageDependencies, | ||
@@ -27,16 +27,16 @@ linkType: nativeInfo.linkType, | ||
findPackageLocator(location) { | ||
return this.pnp.findPackageLocator(fslib_1.NodeFS.fromPortablePath(location)); | ||
return this.pnp.findPackageLocator(fslib_1.npath.fromPortablePath(location)); | ||
} | ||
resolveToUnqualified(request, issuer, opts) { | ||
const result = this.pnp.resolveToUnqualified(request, !issuer ? null : fslib_1.NodeFS.fromPortablePath(issuer), opts); | ||
return !result ? null : fslib_1.NodeFS.toPortablePath(result); | ||
const result = this.pnp.resolveToUnqualified(request, !issuer ? null : fslib_1.npath.fromPortablePath(issuer), opts); | ||
return !result ? null : fslib_1.npath.toPortablePath(result); | ||
} | ||
resolveUnqualified(unqualified, opts) { | ||
return fslib_1.NodeFS.toPortablePath(this.pnp.resolveUnqualified(fslib_1.NodeFS.fromPortablePath(unqualified), opts)); | ||
return fslib_1.npath.toPortablePath(this.pnp.resolveUnqualified(fslib_1.npath.fromPortablePath(unqualified), opts)); | ||
} | ||
resolveRequest(request, issuer, opts) { | ||
const result = this.pnp.resolveRequest(request, !issuer ? null : fslib_1.NodeFS.fromPortablePath(issuer), opts); | ||
return !result ? null : fslib_1.NodeFS.toPortablePath(result); | ||
const result = this.pnp.resolveRequest(request, !issuer ? null : fslib_1.npath.fromPortablePath(issuer), opts); | ||
return !result ? null : fslib_1.npath.toPortablePath(result); | ||
} | ||
} | ||
exports.PortablePnPApi = PortablePnPApi; |
{ | ||
"name": "@yarnpkg/pnpify", | ||
"version": "2.0.0-rc.7", | ||
"version": "2.0.0-rc.8", | ||
"main": "./lib/index.js", | ||
@@ -8,9 +8,9 @@ "bin": "./lib/cli.js", | ||
"dependencies": { | ||
"@yarnpkg/fslib": "2.0.0-rc.5", | ||
"cross-spawn": "^6.0.5", | ||
"json5": "^2.1.0" | ||
"@yarnpkg/fslib": "2.0.0-rc.7", | ||
"comment-json": "^2.2.0", | ||
"cross-spawn": "^6.0.5" | ||
}, | ||
"devDependencies": { | ||
"@yarnpkg/monorepo": "0.0.0", | ||
"@yarnpkg/pnp": "2.0.0-rc.6", | ||
"@yarnpkg/pnp": "2.0.0-rc.7", | ||
"eslint": "^5.16.0", | ||
@@ -17,0 +17,0 @@ "typescript": "next" |
38970
901
+ Addedcomment-json@^2.2.0
+ Added@yarnpkg/fslib@2.0.0-rc.7(transitive)
+ Addedcomment-json@2.4.2(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedhas-own-prop@2.0.0(transitive)
+ Addedrepeat-string@1.6.1(transitive)
- Removedjson5@^2.1.0
- Removed@yarnpkg/fslib@2.0.0-rc.5(transitive)
- Removedjson5@2.2.3(transitive)
Updated@yarnpkg/fslib@2.0.0-rc.7