@yarnpkg/core
Advanced tools
Comparing version 4.0.0-rc.45 to 4.0.0-rc.46
@@ -15,3 +15,3 @@ "use strict"; | ||
const structUtils = tslib_1.__importStar(require("./structUtils")); | ||
const CACHE_VERSION = 9; | ||
const CACHE_VERSION = 10; | ||
class Cache { | ||
@@ -18,0 +18,0 @@ static async find(configuration, { immutable, check } = {}) { |
@@ -71,6 +71,7 @@ /// <reference types="node" /> | ||
export declare function maybeExecuteWorkspaceLifecycleScript(workspace: Workspace, lifecycleScriptName: string, opts: ExecuteWorkspaceLifecycleScriptOptions): Promise<void>; | ||
export declare function isNodeScript(p: PortablePath): boolean; | ||
type GetPackageAccessibleBinariesOptions = { | ||
project: Project; | ||
}; | ||
type Binary = [Locator, NativePath]; | ||
type Binary = [Locator, NativePath, boolean]; | ||
type PackageAccessibleBinaries = Map<string, Binary>; | ||
@@ -77,0 +78,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.executeWorkspaceAccessibleBinary = exports.executePackageAccessibleBinary = exports.getWorkspaceAccessibleBinaries = exports.getPackageAccessibleBinaries = exports.maybeExecuteWorkspaceLifecycleScript = exports.executeWorkspaceLifecycleScript = exports.hasWorkspaceScript = exports.executeWorkspaceScript = exports.executePackageShellcode = exports.executePackageScript = exports.hasPackageScript = exports.prepareExternalProject = exports.makeScriptEnv = exports.detectPackageManager = exports.PackageManager = void 0; | ||
exports.executeWorkspaceAccessibleBinary = exports.executePackageAccessibleBinary = exports.getWorkspaceAccessibleBinaries = exports.getPackageAccessibleBinaries = exports.isNodeScript = exports.maybeExecuteWorkspaceLifecycleScript = exports.executeWorkspaceLifecycleScript = exports.hasWorkspaceScript = exports.executeWorkspaceScript = exports.executePackageShellcode = exports.executePackageScript = exports.hasPackageScript = exports.prepareExternalProject = exports.makeScriptEnv = exports.detectPackageManager = exports.PackageManager = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -384,3 +384,3 @@ const fslib_1 = require("@yarnpkg/fslib"); | ||
const env = await makeScriptEnv({ project: workspace.project, locator: workspace.anchoredLocator, binFolder, lifecycleScript }); | ||
await Promise.all(Array.from(await getWorkspaceAccessibleBinaries(workspace), ([binaryName, [, binaryPath]]) => makePathWrapper(binFolder, (0, fslib_2.toFilename)(binaryName), process.execPath, [binaryPath]))); | ||
await installBinaries(binFolder, await getWorkspaceAccessibleBinaries(workspace)); | ||
// When operating under PnP, `initializePackageEnvironment` | ||
@@ -425,3 +425,3 @@ // yields package location to the linker, which goes into | ||
const env = await makeScriptEnv({ project, locator, binFolder, lifecycleScript }); | ||
await Promise.all(Array.from(await getPackageAccessibleBinaries(locator, { project }), ([binaryName, [, binaryPath]]) => makePathWrapper(binFolder, (0, fslib_2.toFilename)(binaryName), process.execPath, [binaryPath]))); | ||
await installBinaries(binFolder, await getPackageAccessibleBinaries(locator, { project })); | ||
const packageLocation = await linker.findPackageLocation(pkg, linkerOptions); | ||
@@ -471,2 +471,32 @@ const packageFs = new fslib_1.CwdFS(packageLocation, { baseFs: zipOpenFs }); | ||
exports.maybeExecuteWorkspaceLifecycleScript = maybeExecuteWorkspaceLifecycleScript; | ||
function isNodeScript(p) { | ||
const ext = fslib_2.ppath.extname(p); | ||
if (ext.match(/\.[cm]?[jt]sx?$/)) | ||
return true; | ||
if (ext === `.exe` || ext === `.bin`) | ||
return false; | ||
const buf = Buffer.alloc(4); | ||
let fd; | ||
try { | ||
fd = fslib_2.xfs.openSync(p, `r`); | ||
} | ||
catch { | ||
return true; | ||
} | ||
try { | ||
fslib_2.xfs.readSync(fd, buf, 0, buf.length, 0); | ||
} | ||
finally { | ||
fslib_2.xfs.closeSync(fd); | ||
} | ||
const magic = buf.readUint32BE(); | ||
if (magic === 0xcafebabe || // OSX Universal Binary | ||
magic === 0xcffaedfe || // Mach-O | ||
magic === 0x7f454c46 || // ELF | ||
(magic & 0xffff0000) === 0x4d5a0000 // DOS MZ Executable | ||
) | ||
return false; | ||
return true; | ||
} | ||
exports.isNodeScript = isNodeScript; | ||
/** | ||
@@ -525,3 +555,4 @@ * Return the binaries that can be accessed by the specified package | ||
for (const [name, target] of dependency.bin) { | ||
binaries.set(name, [dependency, fslib_2.npath.fromPortablePath(fslib_2.ppath.resolve(packageLocation, target))]); | ||
const binaryPath = fslib_2.ppath.resolve(packageLocation, target); | ||
binaries.set(name, [dependency, fslib_2.npath.fromPortablePath(binaryPath), isNodeScript(binaryPath)]); | ||
} | ||
@@ -541,2 +572,9 @@ } | ||
exports.getWorkspaceAccessibleBinaries = getWorkspaceAccessibleBinaries; | ||
async function installBinaries(target, binaries) { | ||
await Promise.all(Array.from(binaries, ([binaryName, [, binaryPath, isScript]]) => { | ||
return isScript | ||
? makePathWrapper(target, (0, fslib_2.toFilename)(binaryName), process.execPath, [binaryPath]) | ||
: makePathWrapper(target, (0, fslib_2.toFilename)(binaryName), binaryPath, []); | ||
})); | ||
} | ||
/** | ||
@@ -561,6 +599,9 @@ * Execute a binary from the specified package. | ||
const env = await makeScriptEnv({ project, locator, binFolder }); | ||
await Promise.all(Array.from(packageAccessibleBinaries, ([binaryName, [, binaryPath]]) => makePathWrapper(env.BERRY_BIN_FOLDER, (0, fslib_2.toFilename)(binaryName), process.execPath, [binaryPath]))); | ||
await installBinaries(env.BERRY_BIN_FOLDER, packageAccessibleBinaries); | ||
const promise = isNodeScript(fslib_2.npath.toPortablePath(binaryPath)) | ||
? execUtils.pipevp(process.execPath, [...nodeArgs, binaryPath, ...args], { cwd, env, stdin, stdout, stderr }) | ||
: execUtils.pipevp(binaryPath, args, { cwd, env, stdin, stdout, stderr }); | ||
let result; | ||
try { | ||
result = await execUtils.pipevp(process.execPath, [...nodeArgs, binaryPath, ...args], { cwd, env, stdin, stdout, stderr }); | ||
result = await promise; | ||
} | ||
@@ -567,0 +608,0 @@ finally { |
@@ -9,2 +9,3 @@ "use strict"; | ||
const target = {}; | ||
let n = 0; | ||
const copyTree = (printNode, targetNode) => { | ||
@@ -23,3 +24,7 @@ const iterator = Array.isArray(printNode) | ||
const finalLabel = finalParts.join(`: `); | ||
const createdNode = targetNode[finalLabel] = {}; | ||
// The library we use, treeify, doesn't support having multiple nodes with | ||
// the same label. To work around that, we prefix each label with a unique | ||
// string that we strip before output. | ||
const uniquePrefix = `\0${n++}\0`; | ||
const createdNode = targetNode[`${uniquePrefix}${finalLabel}`] = {}; | ||
if (typeof children !== `undefined`) { | ||
@@ -51,3 +56,3 @@ copyTree(children, createdNode); | ||
for (const [key, child] of iterator) | ||
targetChildren[key] = copyTree(child); | ||
targetChildren[cleanKey(key)] = copyTree(child); | ||
if (typeof printNode.value === `undefined`) | ||
@@ -79,2 +84,3 @@ return targetChildren; | ||
let treeOutput = (0, treeify_1.asTree)(treeNodeToTreeify(tree, { configuration }), false, false); | ||
treeOutput = treeOutput.replace(/\0[0-9]+\0/g, ``); | ||
// A slight hack to add line returns between two top-level entries | ||
@@ -92,1 +98,4 @@ if (separators >= 1) | ||
exports.emitTree = emitTree; | ||
function cleanKey(key) { | ||
return typeof key === `string` ? key.replace(/^\0[0-9]+\0/, ``) : key; | ||
} |
{ | ||
"name": "@yarnpkg/core", | ||
"version": "4.0.0-rc.45", | ||
"stableVersion": "3.5.1", | ||
"version": "4.0.0-rc.46", | ||
"stableVersion": "3.5.2", | ||
"license": "BSD-2-Clause", | ||
@@ -16,10 +16,10 @@ "main": "./lib/index.js", | ||
"@types/treeify": "^1.0.0", | ||
"@yarnpkg/fslib": "^3.0.0-rc.45", | ||
"@yarnpkg/libzip": "^3.0.0-rc.45", | ||
"@yarnpkg/parsers": "^3.0.0-rc.45", | ||
"@yarnpkg/shell": "^4.0.0-rc.45", | ||
"@yarnpkg/fslib": "^3.0.0-rc.46", | ||
"@yarnpkg/libzip": "^3.0.0-rc.46", | ||
"@yarnpkg/parsers": "^3.0.0-rc.46", | ||
"@yarnpkg/shell": "^4.0.0-rc.46", | ||
"camelcase": "^5.3.1", | ||
"chalk": "^3.0.0", | ||
"ci-info": "^3.2.0", | ||
"clipanion": "^3.2.0-rc.10", | ||
"clipanion": "^3.2.1", | ||
"cross-spawn": "7.0.3", | ||
@@ -52,6 +52,6 @@ "diff": "^5.1.0", | ||
"@types/tunnel": "^0.0.0", | ||
"@yarnpkg/cli": "^4.0.0-rc.45", | ||
"@yarnpkg/plugin-link": "^3.0.0-rc.45", | ||
"@yarnpkg/plugin-npm": "^3.0.0-rc.45", | ||
"@yarnpkg/plugin-pnp": "^4.0.0-rc.45", | ||
"@yarnpkg/cli": "^4.0.0-rc.46", | ||
"@yarnpkg/plugin-link": "^3.0.0-rc.46", | ||
"@yarnpkg/plugin-npm": "^3.0.0-rc.46", | ||
"@yarnpkg/plugin-pnp": "^4.0.0-rc.46", | ||
"comment-json": "^2.2.0", | ||
@@ -58,0 +58,0 @@ "esbuild": "npm:esbuild-wasm@^0.15.15", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
770202
13930
Updated@yarnpkg/fslib@^3.0.0-rc.46
Updated@yarnpkg/libzip@^3.0.0-rc.46
Updated@yarnpkg/shell@^4.0.0-rc.46
Updatedclipanion@^3.2.1