From 8e7a9a6ebc6e77ec59b0e099db46e6b9013bd607 Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Tue, 17 Oct 2023 17:33:20 +0200 Subject: [PATCH 01/39] feat: compute supported archs from manifest --- config/config/src/getOptionsFromRootManifest.ts | 10 ++++++++++ packages/types/src/package.ts | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/config/config/src/getOptionsFromRootManifest.ts b/config/config/src/getOptionsFromRootManifest.ts index 48551611f8f..85d14226c19 100644 --- a/config/config/src/getOptionsFromRootManifest.ts +++ b/config/config/src/getOptionsFromRootManifest.ts @@ -1,6 +1,7 @@ import path from 'path' import { PnpmError } from '@pnpm/error' import { + type SupportedArchitectures, type AllowedDeprecatedVersions, type PackageExtension, type PeerDependencyRules, @@ -18,6 +19,7 @@ export interface OptionsFromRootManifest { packageExtensions?: Record patchedDependencies?: Record peerDependencyRules?: PeerDependencyRules + supportedArchitectures: SupportedArchitectures } export function getOptionsFromRootManifest (manifestDir: string, manifest: ProjectManifest): OptionsFromRootManifest { @@ -46,6 +48,13 @@ export function getOptionsFromRootManifest (manifestDir: string, manifest: Proje patchedDependencies[dep] = path.join(manifestDir, patchFile) } } + + const supportedArchitectures = { + os: manifest.pnpm?.supportedArchitectures?.os ?? ['current'], + cpu: manifest.pnpm?.supportedArchitectures?.cpu ?? ['current'], + libc: manifest.pnpm?.supportedArchitectures?.libc ?? ['current'], + } + const settings: OptionsFromRootManifest = { allowedDeprecatedVersions, allowNonAppliedPatches, @@ -54,6 +63,7 @@ export function getOptionsFromRootManifest (manifestDir: string, manifest: Proje packageExtensions, peerDependencyRules, patchedDependencies, + supportedArchitectures, } if (onlyBuiltDependencies) { settings.onlyBuiltDependencies = onlyBuiltDependencies diff --git a/packages/types/src/package.ts b/packages/types/src/package.ts index b9c729764e9..b6656b6f40d 100644 --- a/packages/types/src/package.ts +++ b/packages/types/src/package.ts @@ -140,6 +140,7 @@ export type ProjectManifest = BaseManifest & { ignoreCves?: string[] } requiredScripts?: string[] + supportedArchitectures?: SupportedArchitectures } private?: boolean resolutions?: Record @@ -148,3 +149,9 @@ export type ProjectManifest = BaseManifest & { export type PackageManifest = DependencyManifest & { deprecated?: string } + +export interface SupportedArchitectures { + os: string[] + cpu: string[] + libc: string[] +} \ No newline at end of file From 2feb12c035cb0ba7df936b44511010cfbc78adc1 Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Tue, 17 Oct 2023 18:47:44 +0200 Subject: [PATCH 02/39] feat: support different archs when installing --- config/config/src/Config.ts | 2 + .../src/checkPlatform.ts | 57 ++++++++++++++----- config/package-is-installable/src/index.ts | 7 ++- deps/graph-builder/src/lockfileToDepGraph.ts | 4 +- .../src/filterLockfileByImportersAndEngine.ts | 7 ++- .../plugin-commands-patching/src/patch.ts | 1 + .../src/patchCommit.ts | 2 +- .../src/writePackage.ts | 3 +- .../core/src/getPeerDependencyIssues.ts | 2 + .../core/src/install/extendInstallOptions.ts | 5 +- pkg-manager/core/src/install/index.ts | 1 + pkg-manager/headless/src/index.ts | 5 +- .../headless/src/lockfileToHoistedDepGraph.ts | 4 +- .../package-requester/src/packageRequester.ts | 1 + .../plugin-commands-installation/src/fetch.ts | 3 +- .../plugin-commands-installation/src/link.ts | 3 +- .../src/resolveDependencies.ts | 9 +++ .../src/resolveDependencyTree.ts | 3 + reviewing/license-scanner/src/licenses.ts | 3 + .../src/lockfileToLicenseNodeTree.ts | 5 +- .../src/licensesList.ts | 2 + store/plugin-commands-store/src/store.ts | 3 +- store/plugin-commands-store/src/storeAdd.ts | 4 +- store/store-controller-types/src/index.ts | 2 + 24 files changed, 109 insertions(+), 29 deletions(-) diff --git a/config/config/src/Config.ts b/config/config/src/Config.ts index 28127fc1c7b..f2f863e060d 100644 --- a/config/config/src/Config.ts +++ b/config/config/src/Config.ts @@ -1,4 +1,5 @@ import { + type SupportedArchitectures, type Project, type ProjectManifest, type ProjectsGraph, @@ -172,6 +173,7 @@ export interface Config { rootProjectManifestDir?: string rootProjectManifest?: ProjectManifest userConfig: Record + supportedArchitectures: SupportedArchitectures } export interface ConfigWithDeprecatedSettings extends Config { diff --git a/config/package-is-installable/src/checkPlatform.ts b/config/package-is-installable/src/checkPlatform.ts index 6119bb0d7fb..1d62f4fa4e0 100644 --- a/config/package-is-installable/src/checkPlatform.ts +++ b/config/package-is-installable/src/checkPlatform.ts @@ -1,4 +1,5 @@ import { PnpmError } from '@pnpm/error' +import { type SupportedArchitectures } from '@pnpm/types' import { familySync as getLibcFamilySync } from 'detect-libc' const currentLibc = getLibcFamilySync() ?? 'unknown' @@ -16,19 +17,26 @@ export class UnsupportedPlatformError extends PnpmError { export function checkPlatform ( packageId: string, - wantedPlatform: WantedPlatform + wantedPlatform: WantedPlatform, + supportedArchitectures: SupportedArchitectures ) { + const platforms = { + os: dedupeArchs(process.platform, supportedArchitectures?.os ?? ['current']), + cpu: dedupeArchs(process.arch, supportedArchitectures?.cpu ?? ['current']), + libc: dedupeArchs(currentLibc, supportedArchitectures?.libc ?? ['current']), + } + const { platform, arch } = process let osOk = true; let cpuOk = true; let libcOk = true if (wantedPlatform.os) { - osOk = checkList(platform, wantedPlatform.os) + osOk = checkList(platforms.os, wantedPlatform.os) } if (wantedPlatform.cpu) { - cpuOk = checkList(arch, wantedPlatform.cpu) + cpuOk = checkList(platforms.cpu, wantedPlatform.cpu) } if (wantedPlatform.libc && currentLibc !== 'unknown') { - libcOk = checkList(currentLibc, wantedPlatform.libc) + libcOk = checkList(platforms.libc, wantedPlatform.libc) } if (!osOk || !cpuOk || !libcOk) { @@ -45,25 +53,44 @@ export interface Platform { export type WantedPlatform = Partial -function checkList (value: string, list: string | string[]) { - let tmp; let match = false; let blc = 0 +function checkList (value: string | string[], list: string | string[]): boolean { + let tmp + let match = false + let blc = 0 + if (typeof list === 'string') { list = [list] } + if (list.length === 1 && list[0] === 'any') { return true } - for (let i = 0; i < list.length; ++i) { - tmp = list[i] - if (tmp[0] === '!') { - tmp = tmp.slice(1) - if (tmp === value) { - return false + + const values = Array.isArray(value) ? value : [value] + + for (const val of values) { + for (let i = 0; i < list.length; ++i) { + tmp = list[i] + if (tmp[0] === '!') { + tmp = tmp.slice(1) + if (tmp === val) { + return false + } + ++blc + } else { + match = match || tmp === val } - ++blc - } else { - match = match || tmp === value } } return match || blc === list.length } + +function dedupeArchs (current: string, supported: string[]) { + const result = supported.filter((arch) => arch !== 'current') + + if (supported.includes('current')) { + result.push(current) + } + + return result +} \ No newline at end of file diff --git a/config/package-is-installable/src/index.ts b/config/package-is-installable/src/index.ts index 0c0babe708b..15c76921914 100644 --- a/config/package-is-installable/src/index.ts +++ b/config/package-is-installable/src/index.ts @@ -5,6 +5,7 @@ import { import { checkEngine, UnsupportedEngineError, type WantedEngine } from './checkEngine' import { checkPlatform, UnsupportedPlatformError } from './checkPlatform' import { getSystemNodeVersion } from './getSystemNodeVersion' +import { type SupportedArchitectures } from '@pnpm/types' export type { Engine } from './checkEngine' export type { Platform, WantedPlatform } from './checkPlatform' @@ -31,6 +32,7 @@ export function packageIsInstallable ( optional: boolean pnpmVersion?: string lockfileDir: string + supportedArchitectures: SupportedArchitectures } ): boolean | null { const warn = checkPackage(pkgId, pkg, options) @@ -73,13 +75,14 @@ export function checkPackage ( options: { nodeVersion?: string pnpmVersion?: string + supportedArchitectures: SupportedArchitectures } ): null | UnsupportedEngineError | UnsupportedPlatformError { return checkPlatform(pkgId, { cpu: manifest.cpu ?? ['any'], os: manifest.os ?? ['any'], libc: manifest.libc ?? ['any'], - }) ?? ( + }, options.supportedArchitectures) ?? ( (manifest.engines == null) ? null : checkEngine(pkgId, manifest.engines, { @@ -87,4 +90,4 @@ export function checkPackage ( pnpm: options.pnpmVersion, }) ) -} +} \ No newline at end of file diff --git a/deps/graph-builder/src/lockfileToDepGraph.ts b/deps/graph-builder/src/lockfileToDepGraph.ts index b26d368185c..474d88c9b2a 100644 --- a/deps/graph-builder/src/lockfileToDepGraph.ts +++ b/deps/graph-builder/src/lockfileToDepGraph.ts @@ -16,7 +16,7 @@ import { import { logger } from '@pnpm/logger' import { type IncludedDependencies } from '@pnpm/modules-yaml' import { packageIsInstallable } from '@pnpm/package-is-installable' -import { type PatchFile, type Registries } from '@pnpm/types' +import { type SupportedArchitectures, type PatchFile, type Registries } from '@pnpm/types' import { type PkgRequestFetchResult, type FetchPackageToStoreFunction, @@ -68,6 +68,7 @@ export interface LockfileToDepGraphOptions { storeController: StoreController storeDir: string virtualStoreDir: string + supportedArchitectures: SupportedArchitectures } export interface DirectDependenciesByImporterId { @@ -121,6 +122,7 @@ export async function lockfileToDepGraph ( nodeVersion: opts.nodeVersion, optional: pkgSnapshot.optional === true, pnpmVersion: opts.pnpmVersion, + supportedArchitectures: opts.supportedArchitectures, }) === false ) { opts.skipped.add(depPath) diff --git a/lockfile/filter-lockfile/src/filterLockfileByImportersAndEngine.ts b/lockfile/filter-lockfile/src/filterLockfileByImportersAndEngine.ts index 795d6fbbd42..38d6d00ad6b 100644 --- a/lockfile/filter-lockfile/src/filterLockfileByImportersAndEngine.ts +++ b/lockfile/filter-lockfile/src/filterLockfileByImportersAndEngine.ts @@ -7,7 +7,7 @@ import { import { nameVerFromPkgSnapshot } from '@pnpm/lockfile-utils' import { logger } from '@pnpm/logger' import { packageIsInstallable } from '@pnpm/package-is-installable' -import { type DependenciesField } from '@pnpm/types' +import { type SupportedArchitectures, type DependenciesField } from '@pnpm/types' import * as dp from '@pnpm/dependency-path' import mapValues from 'ramda/src/map' import pickBy from 'ramda/src/pickBy' @@ -30,6 +30,7 @@ export function filterLockfileByImportersAndEngine ( failOnMissingDependencies: boolean lockfileDir: string skipped: Set + supportedArchitectures: SupportedArchitectures } ): { lockfile: Lockfile, selectedImporterIds: string[] } { const importerIdSet = new Set(importerIds) as Set @@ -50,6 +51,7 @@ export function filterLockfileByImportersAndEngine ( opts.includeIncompatiblePackages === true, lockfileDir: opts.lockfileDir, skipped: opts.skipped, + supportedArchitectures: opts.supportedArchitectures, }) : {} @@ -89,6 +91,7 @@ function pickPkgsWithAllDeps ( includeIncompatiblePackages: boolean lockfileDir: string skipped: Set + supportedArchitectures: SupportedArchitectures } ) { const pickedPackages = {} as PackageSnapshots @@ -115,6 +118,7 @@ function pkgAllDeps ( includeIncompatiblePackages: boolean lockfileDir: string skipped: Set + supportedArchitectures: SupportedArchitectures } ) { for (const depPath of depPaths) { @@ -150,6 +154,7 @@ function pkgAllDeps ( nodeVersion: opts.currentEngine.nodeVersion, optional: pkgSnapshot.optional === true, pnpmVersion: opts.currentEngine.pnpmVersion, + supportedArchitectures: opts.supportedArchitectures, }) !== false if (!installable) { if (!ctx.pickedPackages[depPath] && pkgSnapshot.optional === true) { diff --git a/patching/plugin-commands-patching/src/patch.ts b/patching/plugin-commands-patching/src/patch.ts index 75977782a63..b7242c18a4f 100644 --- a/patching/plugin-commands-patching/src/patch.ts +++ b/patching/plugin-commands-patching/src/patch.ts @@ -59,6 +59,7 @@ export type PatchCommandOptions = Pick & CreateStoreControllerOptions & { editDir?: string reporter?: (logObj: LogBase) => void diff --git a/patching/plugin-commands-patching/src/patchCommit.ts b/patching/plugin-commands-patching/src/patchCommit.ts index bdf38cd68e4..cd09d2bb1a3 100644 --- a/patching/plugin-commands-patching/src/patchCommit.ts +++ b/patching/plugin-commands-patching/src/patchCommit.ts @@ -42,7 +42,7 @@ export function help () { }) } -export async function handler (opts: install.InstallCommandOptions & Pick, params: string[]) { +export async function handler (opts: install.InstallCommandOptions & Pick, params: string[]) { const userDir = params[0] const lockfileDir = opts.lockfileDir ?? opts.dir ?? process.cwd() const patchesDirName = normalizePath(path.normalize(opts.patchesDir ?? 'patches')) diff --git a/patching/plugin-commands-patching/src/writePackage.ts b/patching/plugin-commands-patching/src/writePackage.ts index 4eb974b0f16..6738be5ffeb 100644 --- a/patching/plugin-commands-patching/src/writePackage.ts +++ b/patching/plugin-commands-patching/src/writePackage.ts @@ -6,7 +6,7 @@ import { import { pickRegistryForPackage } from '@pnpm/pick-registry-for-package' import type { ParseWantedDependencyResult } from '@pnpm/parse-wanted-dependency' -export type WritePackageOptions = CreateStoreControllerOptions & Pick +export type WritePackageOptions = CreateStoreControllerOptions & Pick export async function writePackage (dep: ParseWantedDependencyResult, dest: string, opts: WritePackageOptions) { const store = await createOrConnectStoreController({ @@ -19,6 +19,7 @@ export async function writePackage (dep: ParseWantedDependencyResult, dest: stri preferredVersions: {}, projectDir: opts.dir, registry: (dep.alias && pickRegistryForPackage(opts.registries, dep.alias)) ?? opts.registries.default, + supportedArchitectures: opts.supportedArchitectures, }) const { files } = await pkgResponse.fetching!() await store.ctrl.importPackage(dest, { diff --git a/pkg-manager/core/src/getPeerDependencyIssues.ts b/pkg-manager/core/src/getPeerDependencyIssues.ts index 728b5d2c91c..e42d053cb8a 100644 --- a/pkg-manager/core/src/getPeerDependencyIssues.ts +++ b/pkg-manager/core/src/getPeerDependencyIssues.ts @@ -19,6 +19,7 @@ export type ListMissingPeersOptions = Partial | 'storeController' | 'useGitBranchLockfile' | 'workspacePackages' +| 'supportedArchitectures' > & Pick @@ -84,6 +85,7 @@ export async function getPeerDependencyIssues ( virtualStoreDir: ctx.virtualStoreDir, wantedLockfile: ctx.wantedLockfile, workspacePackages: opts.workspacePackages ?? {}, + supportedArchitectures: opts.supportedArchitectures, } ) diff --git a/pkg-manager/core/src/install/extendInstallOptions.ts b/pkg-manager/core/src/install/extendInstallOptions.ts index a8cbdea4517..8bdc43fc54d 100644 --- a/pkg-manager/core/src/install/extendInstallOptions.ts +++ b/pkg-manager/core/src/install/extendInstallOptions.ts @@ -9,6 +9,7 @@ import { normalizeRegistries, DEFAULT_REGISTRIES } from '@pnpm/normalize-registr import { type WorkspacePackages } from '@pnpm/resolver-base' import { type StoreController } from '@pnpm/store-controller-types' import { + type SupportedArchitectures, type AllowedDeprecatedVersions, type PackageExtension, type PeerDependencyRules, @@ -136,11 +137,13 @@ export interface StrictInstallOptions { * The option might be used in the future to improve performance. */ disableRelinkLocalDirDeps: boolean + + supportedArchitectures: SupportedArchitectures } export type InstallOptions = & Partial - & Pick + & Pick const defaults = (opts: InstallOptions) => { const packageManager = opts.packageManager ?? { diff --git a/pkg-manager/core/src/install/index.ts b/pkg-manager/core/src/install/index.ts index 6f3e37625d4..3c03a3749f5 100644 --- a/pkg-manager/core/src/install/index.ts +++ b/pkg-manager/core/src/install/index.ts @@ -1038,6 +1038,7 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => { patchedDependencies: opts.patchedDependencies, lockfileIncludeTarballUrl: opts.lockfileIncludeTarballUrl, resolvePeersFromWorkspaceRoot: opts.resolvePeersFromWorkspaceRoot, + supportedArchitectures: opts.supportedArchitectures, } ) if (!opts.include.optionalDependencies || !opts.include.devDependencies || !opts.include.dependencies) { diff --git a/pkg-manager/headless/src/index.ts b/pkg-manager/headless/src/index.ts index 9a251087342..df584832676 100644 --- a/pkg-manager/headless/src/index.ts +++ b/pkg-manager/headless/src/index.ts @@ -55,7 +55,7 @@ import { type StoreController, } from '@pnpm/store-controller-types' import { symlinkDependency } from '@pnpm/symlink-dependency' -import { type DependencyManifest, type HoistedDependencies, type ProjectManifest, type Registries, DEPENDENCIES_FIELDS } from '@pnpm/types' +import { type DependencyManifest, type HoistedDependencies, type ProjectManifest, type Registries, DEPENDENCIES_FIELDS, type SupportedArchitectures } from '@pnpm/types' import * as dp from '@pnpm/dependency-path' import { symlinkAllModules } from '@pnpm/worker' import pLimit from 'p-limit' @@ -159,6 +159,7 @@ export interface HeadlessOptions { nodeLinker?: 'isolated' | 'hoisted' | 'pnp' useGitBranchLockfile?: boolean useLockfile?: boolean + supportedArchitectures: SupportedArchitectures } export interface InstallationResultStats { @@ -266,6 +267,7 @@ export async function headlessInstall (opts: HeadlessOptions): Promise & CreateStoreControllerOptions + opts: Pick & CreateStoreControllerOptions ) { const store = await createOrConnectStoreController(opts) const include = { @@ -67,5 +67,6 @@ export async function handler ( pruneStore: true, storeController: store.ctrl, storeDir: store.dir, + supportedArchitectures: opts.supportedArchitectures, } as InstallOptions) } diff --git a/pkg-manager/plugin-commands-installation/src/link.ts b/pkg-manager/plugin-commands-installation/src/link.ts index 39bd28c1e80..98968c0db13 100644 --- a/pkg-manager/plugin-commands-installation/src/link.ts +++ b/pkg-manager/plugin-commands-installation/src/link.ts @@ -44,7 +44,8 @@ type LinkOpts = CreateStoreControllerOptions & Pick & Partial> +| 'supportedArchitectures' +> & Partial> export const rcOptionsTypes = cliOptionsTypes diff --git a/pkg-manager/resolve-dependencies/src/resolveDependencies.ts b/pkg-manager/resolve-dependencies/src/resolveDependencies.ts index 6c0fc6fa332..92b2f9ae635 100644 --- a/pkg-manager/resolve-dependencies/src/resolveDependencies.ts +++ b/pkg-manager/resolve-dependencies/src/resolveDependencies.ts @@ -30,6 +30,7 @@ import { type StoreController, } from '@pnpm/store-controller-types' import { + type SupportedArchitectures, type AllowedDeprecatedVersions, type Dependencies, type PackageManifest, @@ -253,6 +254,7 @@ interface ResolvedDependenciesOptions { updateMatching?: UpdateMatchingFunction updateDepth: number prefix: string + supportedArchitectures: SupportedArchitectures } interface PostponedResolutionOpts { @@ -674,6 +676,7 @@ async function resolveDependenciesOfDependency ( update, updateDepth, updateMatching: options.updateMatching, + supportedArchitectures: options.supportedArchitectures, } const resolveDependencyResult = await resolveDependency(extendedWantedDep.wantedDependency, ctx, resolveDependencyOpts) @@ -709,6 +712,7 @@ async function resolveDependenciesOfDependency ( updateDepth, prefix: options.prefix, updateMatching: options.updateMatching, + supportedArchitectures: options.supportedArchitectures, }) return { resolveDependencyResult, @@ -756,6 +760,7 @@ async function resolveChildren ( updateDepth, updateMatching, prefix, + supportedArchitectures, }: { parentPkg: PkgAddress dependencyLockfile: PackageSnapshot | undefined @@ -763,6 +768,7 @@ async function resolveChildren ( updateDepth: number prefix: string updateMatching?: UpdateMatchingFunction + supportedArchitectures: SupportedArchitectures }, { parentPkgAliases, @@ -808,6 +814,7 @@ async function resolveChildren ( resolvedDependencies, updateDepth, updateMatching, + supportedArchitectures, } ) ctx.childrenByParentDepPath[parentPkg.depPath] = pkgAddresses.map((child) => ({ @@ -1011,6 +1018,7 @@ interface ResolveDependencyOptions { update: boolean updateDepth: number updateMatching?: UpdateMatchingFunction + supportedArchitectures: SupportedArchitectures } type ResolveDependencyResult = PkgAddress | LinkedDependency | null @@ -1083,6 +1091,7 @@ async function resolveDependency ( skipFetch: false, update: options.update, workspacePackages: ctx.workspacePackages, + supportedArchitectures: options.supportedArchitectures, }) } catch (err: any) { // eslint-disable-line if (wantedDependency.optional) { diff --git a/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts b/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts index 6c57dda9f4d..b5e3093b374 100644 --- a/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts +++ b/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts @@ -2,6 +2,7 @@ import { type Lockfile, type PatchFile } from '@pnpm/lockfile-types' import { type PreferredVersions, type Resolution, type WorkspacePackages } from '@pnpm/resolver-base' import { type StoreController } from '@pnpm/store-controller-types' import { + type SupportedArchitectures, type AllowedDeprecatedVersions, type ProjectManifest, type ReadPackageHook, @@ -87,6 +88,7 @@ export interface ResolveDependenciesOptions { virtualStoreDir: string wantedLockfile: Lockfile workspacePackages: WorkspacePackages + supportedArchitectures: SupportedArchitectures } export async function resolveDependencyTree ( @@ -153,6 +155,7 @@ export async function resolveDependencyTree ( updateDepth: -1, updateMatching: importer.updateMatching, prefix: importer.rootDir, + supportedArchitectures: opts.supportedArchitectures, } return { updatePackageManifest: importer.updatePackageManifest, diff --git a/reviewing/license-scanner/src/licenses.ts b/reviewing/license-scanner/src/licenses.ts index 68ed3342ae0..aa12318683a 100644 --- a/reviewing/license-scanner/src/licenses.ts +++ b/reviewing/license-scanner/src/licenses.ts @@ -1,6 +1,7 @@ import { PnpmError } from '@pnpm/error' import { type Lockfile } from '@pnpm/lockfile-file' import { + type SupportedArchitectures, type DependenciesField, type IncludedDependencies, type ProjectManifest, @@ -74,6 +75,7 @@ export async function findDependencyLicenses (opts: { registries: Registries wantedLockfile: Lockfile | null includedImporterIds?: string[] + supportedArchitectures: SupportedArchitectures }): Promise { if (opts.wantedLockfile == null) { throw new PnpmError( @@ -90,6 +92,7 @@ export async function findDependencyLicenses (opts: { include: opts.include, registries: opts.registries, includedImporterIds: opts.includedImporterIds, + supportedArchitectures: opts.supportedArchitectures, }) const licensePackages = new Map() diff --git a/reviewing/license-scanner/src/lockfileToLicenseNodeTree.ts b/reviewing/license-scanner/src/lockfileToLicenseNodeTree.ts index c60c95ce851..af8e3cb59a5 100644 --- a/reviewing/license-scanner/src/lockfileToLicenseNodeTree.ts +++ b/reviewing/license-scanner/src/lockfileToLicenseNodeTree.ts @@ -5,7 +5,7 @@ import { lockfileWalkerGroupImporterSteps, type LockfileWalkerStep, } from '@pnpm/lockfile-walker' -import { type DependenciesField, type Registries } from '@pnpm/types' +import { type SupportedArchitectures, type DependenciesField, type Registries } from '@pnpm/types' import { getPkgInfo } from './getPkgInfo' import mapValues from 'ramda/src/map' @@ -36,6 +36,7 @@ export interface LicenseExtractOptions { modulesDir?: string dir: string registries: Registries + supportedArchitectures: SupportedArchitectures } export async function lockfileToLicenseNode ( @@ -56,6 +57,7 @@ export async function lockfileToLicenseNode ( }, { optional: pkgSnapshot.optional ?? false, lockfileDir: options.dir, + supportedArchitectures: options.supportedArchitectures, }) // If the package is not installable on the given platform, we ignore the @@ -137,6 +139,7 @@ export async function lockfileToLicenseNodeTree ( modulesDir: opts.modulesDir, dir: opts.dir, registries: opts.registries, + supportedArchitectures: opts.supportedArchitectures, }) return [importerWalker.importerId, { dependencies: importerDeps, diff --git a/reviewing/plugin-commands-licenses/src/licensesList.ts b/reviewing/plugin-commands-licenses/src/licensesList.ts index 2da3e7985ad..565af178748 100644 --- a/reviewing/plugin-commands-licenses/src/licensesList.ts +++ b/reviewing/plugin-commands-licenses/src/licensesList.ts @@ -25,6 +25,7 @@ Config, | 'modulesDir' | 'pnpmHomeDir' | 'selectedProjectsGraph' +| 'supportedArchitectures' > & Partial> @@ -68,6 +69,7 @@ export async function licensesList (opts: LicensesCommandOptions) { wantedLockfile: lockfile, manifest, includedImporterIds, + supportedArchitectures: opts.supportedArchitectures, }) if (licensePackages.length === 0) diff --git a/store/plugin-commands-store/src/store.ts b/store/plugin-commands-store/src/store.ts index 0ec5fcaa30d..1a9b2d2c2ed 100644 --- a/store/plugin-commands-store/src/store.ts +++ b/store/plugin-commands-store/src/store.ts @@ -67,7 +67,7 @@ class StoreStatusError extends PnpmError { } } -export type StoreCommandOptions = Pick & CreateStoreControllerOptions & { +export type StoreCommandOptions = Pick & CreateStoreControllerOptions & { reporter?: (logObj: LogBase) => void } @@ -98,6 +98,7 @@ export async function handler (opts: StoreCommandOptions, params: string[]) { reporter: opts.reporter, storeController: store.ctrl, tag: opts.tag, + supportedArchitectures: opts.supportedArchitectures, }) default: return help() diff --git a/store/plugin-commands-store/src/storeAdd.ts b/store/plugin-commands-store/src/storeAdd.ts index 0c3e51d96c6..d9b5c99c5ea 100644 --- a/store/plugin-commands-store/src/storeAdd.ts +++ b/store/plugin-commands-store/src/storeAdd.ts @@ -3,7 +3,7 @@ import { logger, globalInfo, streamParser } from '@pnpm/logger' import { parseWantedDependency } from '@pnpm/parse-wanted-dependency' import { pickRegistryForPackage } from '@pnpm/pick-registry-for-package' import { type StoreController } from '@pnpm/store-controller-types' -import { type Registries } from '@pnpm/types' +import { type SupportedArchitectures, type Registries } from '@pnpm/types' import { type ReporterFunction } from './types' export async function storeAdd ( @@ -14,6 +14,7 @@ export async function storeAdd ( reporter?: ReporterFunction storeController: StoreController tag?: string + supportedArchitectures: SupportedArchitectures } ) { const reporter = opts?.reporter @@ -36,6 +37,7 @@ export async function storeAdd ( preferredVersions: {}, projectDir: prefix, registry: (dep.alias && pickRegistryForPackage(registries, dep.alias)) ?? registries.default, + supportedArchitectures: opts.supportedArchitectures, }) await pkgResponse.fetching!() globalInfo(`+ ${pkgResponse.body.id}`) diff --git a/store/store-controller-types/src/index.ts b/store/store-controller-types/src/index.ts index 39da1d2eef0..9b2d5f29b29 100644 --- a/store/store-controller-types/src/index.ts +++ b/store/store-controller-types/src/index.ts @@ -13,6 +13,7 @@ import { type ResolvedFrom, } from '@pnpm/cafs-types' import { + type SupportedArchitectures, type DependencyManifest, type PackageManifest, } from '@pnpm/types' @@ -128,6 +129,7 @@ export interface RequestPackageOptions { update?: boolean workspacePackages?: WorkspacePackages forceResolve?: boolean + supportedArchitectures: SupportedArchitectures } export type BundledManifestFunction = () => Promise From 13ad5eb6fdc565bc44dafb4fdf120b5a1ac638af Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Tue, 17 Oct 2023 18:51:03 +0200 Subject: [PATCH 03/39] feat: add changeset --- .changeset/spicy-spiders-nail.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .changeset/spicy-spiders-nail.md diff --git a/.changeset/spicy-spiders-nail.md b/.changeset/spicy-spiders-nail.md new file mode 100644 index 00000000000..d63057c0bef --- /dev/null +++ b/.changeset/spicy-spiders-nail.md @@ -0,0 +1,32 @@ +--- +"@pnpm/plugin-commands-installation": minor +"@pnpm/plugin-commands-licenses": minor +"@pnpm/plugin-commands-patching": minor +"@pnpm/resolve-dependencies": minor +"@pnpm/package-is-installable": minor +"@pnpm/package-requester": minor +"@pnpm/store-controller-types": minor +"@pnpm/plugin-commands-store": minor +"@pnpm/license-scanner": minor +"@pnpm/filter-lockfile": minor +"@pnpm/headless": minor +"@pnpm/deps.graph-builder": minor +"@pnpm/core": minor +"@pnpm/types": minor +"@pnpm/config": minor +--- + +Support different architectures when installing dependencies. + +Example: + +```json +{ + "pnpm": { + "supportedArchitectures": { + "os": ["current", "win32"], + "cpu": ["x64", "arm64"] + } + } +} +``` From 63672fff08c5c8945d805bdafb9dcf963532441a Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Tue, 17 Oct 2023 19:42:00 +0200 Subject: [PATCH 04/39] fix: fix type errors and tests --- cli/cli-utils/src/packageIsInstallable.ts | 3 + cli/cli-utils/src/readProjectManifest.ts | 14 ++- .../test/checkPlatform.ts | 54 +++++++-- exec/plugin-commands-rebuild/src/rebuild.ts | 1 + .../test/utils/index.ts | 5 + .../plugin-commands-script-runners/src/run.ts | 11 +- .../test/index.ts | 110 ++++++++++++++++++ .../test/utils/index.ts | 10 ++ .../src/install.ts | 1 + .../src/installDeps.ts | 1 + .../src/recursive.ts | 1 + .../src/remove.ts | 1 + .../src/unlink.ts | 1 + pnpm-lock.yaml | 12 +- pnpm/src/cmd/complete.ts | 8 +- pnpm/src/main.ts | 1 + .../plugin-commands-publishing/src/pack.ts | 10 +- .../plugin-commands-publishing/src/publish.ts | 4 +- .../src/recursivePublish.ts | 2 +- .../src/licensesList.ts | 8 +- .../plugin-commands-outdated/src/outdated.ts | 1 + .../filter-workspace-packages/package.json | 1 + .../filter-workspace-packages/src/index.ts | 6 +- .../filter-workspace-packages/tsconfig.json | 3 + workspace/find-packages/src/index.ts | 11 +- 25 files changed, 253 insertions(+), 27 deletions(-) diff --git a/cli/cli-utils/src/packageIsInstallable.ts b/cli/cli-utils/src/packageIsInstallable.ts index 1e1f0a9d3b4..ae05742af49 100644 --- a/cli/cli-utils/src/packageIsInstallable.ts +++ b/cli/cli-utils/src/packageIsInstallable.ts @@ -1,6 +1,7 @@ import { packageManager } from '@pnpm/cli-meta' import { logger } from '@pnpm/logger' import { checkPackage, UnsupportedEngineError, type WantedEngine } from '@pnpm/package-is-installable' +import { type SupportedArchitectures } from '@pnpm/types' export function packageIsInstallable ( pkgPath: string, @@ -13,6 +14,7 @@ export function packageIsInstallable ( opts: { engineStrict?: boolean nodeVersion?: string + supportedArchitectures: SupportedArchitectures } ) { const pnpmVersion = packageManager.name === 'pnpm' @@ -21,6 +23,7 @@ export function packageIsInstallable ( const err = checkPackage(pkgPath, pkg, { nodeVersion: opts.nodeVersion, pnpmVersion, + supportedArchitectures: opts.supportedArchitectures, }) if (err === null) return if ( diff --git a/cli/cli-utils/src/readProjectManifest.ts b/cli/cli-utils/src/readProjectManifest.ts index 2f35db73197..b532791eeba 100644 --- a/cli/cli-utils/src/readProjectManifest.ts +++ b/cli/cli-utils/src/readProjectManifest.ts @@ -1,5 +1,5 @@ import * as utils from '@pnpm/read-project-manifest' -import { type ProjectManifest } from '@pnpm/types' +import { type SupportedArchitectures, type ProjectManifest } from '@pnpm/types' import { packageIsInstallable } from './packageIsInstallable' export async function readProjectManifest ( @@ -7,6 +7,7 @@ export async function readProjectManifest ( opts: { engineStrict?: boolean nodeVersion?: string + supportedArchitectures: SupportedArchitectures } ): Promise<{ fileName: string @@ -23,9 +24,17 @@ export async function readProjectManifestOnly ( opts: { engineStrict?: boolean nodeVersion?: string - } = {} + supportedArchitectures: SupportedArchitectures + } = { + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, + } ): Promise { const manifest = await utils.readProjectManifestOnly(projectDir) + packageIsInstallable(projectDir, manifest as any, opts) // eslint-disable-line @typescript-eslint/no-explicit-any return manifest } @@ -35,6 +44,7 @@ export async function tryReadProjectManifest ( opts: { engineStrict?: boolean nodeVersion?: string + supportedArchitectures: SupportedArchitectures } ): Promise<{ fileName: string diff --git a/config/package-is-installable/test/checkPlatform.ts b/config/package-is-installable/test/checkPlatform.ts index 5eac631d5d7..47a38bf2fa8 100644 --- a/config/package-is-installable/test/checkPlatform.ts +++ b/config/package-is-installable/test/checkPlatform.ts @@ -16,7 +16,11 @@ test('target cpu wrong', () => { os: 'any', libc: 'any', } - const err = checkPlatform(packageId, target) + const err = checkPlatform(packageId, target, { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }) expect(err).toBeTruthy() expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') }) @@ -27,7 +31,11 @@ test('os wrong', () => { os: 'enten-os', libc: 'any', } - const err = checkPlatform(packageId, target) + const err = checkPlatform(packageId, target, { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }) expect(err).toBeTruthy() expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') }) @@ -38,7 +46,11 @@ test('libc wrong', () => { os: 'any', libc: 'enten-libc', } - const err = checkPlatform(packageId, target) + const err = checkPlatform(packageId, target, { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }) expect(err).toBeTruthy() expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') }) @@ -49,33 +61,57 @@ test('nothing wrong', () => { os: 'any', libc: 'any', } - expect(checkPlatform(packageId, target)).toBeFalsy() + expect(checkPlatform(packageId, target, { + os: ['current'], + cpu: ['current'], + libc: ['current'], + })).toBeFalsy() }) test('only target cpu wrong', () => { - const err = checkPlatform(packageId, { cpu: 'enten-cpu', os: 'any', libc: 'any' }) + const err = checkPlatform(packageId, { cpu: 'enten-cpu', os: 'any', libc: 'any' }, { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }) expect(err).toBeTruthy() expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') }) test('only os wrong', () => { - const err = checkPlatform(packageId, { cpu: 'any', os: 'enten-os', libc: 'any' }) + const err = checkPlatform(packageId, { cpu: 'any', os: 'enten-os', libc: 'any' }, { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }) expect(err).toBeTruthy() expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') }) test('everything wrong w/arrays', () => { - const err = checkPlatform(packageId, { cpu: ['enten-cpu'], os: ['enten-os'], libc: ['enten-libc'] }) + const err = checkPlatform(packageId, { cpu: ['enten-cpu'], os: ['enten-os'], libc: ['enten-libc'] }, { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }) expect(err).toBeTruthy() expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') }) test('os wrong (negation)', () => { - const err = checkPlatform(packageId, { cpu: 'any', os: `!${process.platform}`, libc: 'any' }) + const err = checkPlatform(packageId, { cpu: 'any', os: `!${process.platform}`, libc: 'any' }, { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }) expect(err).toBeTruthy() expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') }) test('nothing wrong (negation)', () => { - expect(checkPlatform(packageId, { cpu: '!enten-cpu', os: '!enten-os', libc: '!enten-libc' })).toBe(null) + expect(checkPlatform(packageId, { cpu: '!enten-cpu', os: '!enten-os', libc: '!enten-libc' }, { + os: ['current'], + cpu: ['current'], + libc: ['current'], + })).toBe(null) }) diff --git a/exec/plugin-commands-rebuild/src/rebuild.ts b/exec/plugin-commands-rebuild/src/rebuild.ts index 3350f760147..4c1e6e993e6 100644 --- a/exec/plugin-commands-rebuild/src/rebuild.ts +++ b/exec/plugin-commands-rebuild/src/rebuild.ts @@ -87,6 +87,7 @@ export async function handler ( | 'scriptsPrependNodePath' | 'shellEmulator' | 'workspaceDir' + | 'supportedArchitectures' > & CreateStoreControllerOptions & { diff --git a/exec/plugin-commands-rebuild/test/utils/index.ts b/exec/plugin-commands-rebuild/test/utils/index.ts index d05e3817b5e..21783bb9c88 100644 --- a/exec/plugin-commands-rebuild/test/utils/index.ts +++ b/exec/plugin-commands-rebuild/test/utils/index.ts @@ -46,4 +46,9 @@ export const DEFAULT_OPTS = { useRunningStoreServer: false, useStoreServer: false, workspaceConcurrency: 4, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } diff --git a/exec/plugin-commands-script-runners/src/run.ts b/exec/plugin-commands-script-runners/src/run.ts index 240b092e9d1..0e8ce325179 100644 --- a/exec/plugin-commands-script-runners/src/run.ts +++ b/exec/plugin-commands-script-runners/src/run.ts @@ -104,7 +104,14 @@ export const completion: CompletionFunc = async (cliOpts, params) => { if (params.length > 0) { return [] } - const manifest = await readProjectManifestOnly(cliOpts.dir as string ?? process.cwd(), cliOpts) + const manifest = await readProjectManifestOnly(cliOpts.dir as string ?? process.cwd(), { + ...cliOpts, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, + }) return Object.keys(manifest.scripts ?? {}).map((name) => ({ name })) } @@ -149,7 +156,7 @@ For options that may be used with `-r`, see "pnpm help recursive"', export type RunOpts = & Omit & { recursive?: boolean } - & Pick + & Pick & ( & { recursive?: false } & Partial> diff --git a/exec/plugin-commands-script-runners/test/index.ts b/exec/plugin-commands-script-runners/test/index.ts index d63aa52d84e..54cffc03e05 100644 --- a/exec/plugin-commands-script-runners/test/index.ts +++ b/exec/plugin-commands-script-runners/test/index.ts @@ -29,6 +29,11 @@ test('pnpm run: returns correct exit code', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['exit0']) let err!: Error & { errno: number } @@ -38,6 +43,11 @@ test('pnpm run: returns correct exit code', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['exit1']) } catch (_err: any) { // eslint-disable-line err = _err @@ -60,6 +70,11 @@ test('pnpm run --no-bail never fails', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['exit1']) const { default: args } = await import(path.resolve('args.json')) @@ -84,6 +99,11 @@ test('run: pass the args to the command that is specified in the build script', extraBinPaths: [], extraEnv: {}, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['foo', 'arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -106,6 +126,11 @@ test('run: pass the args to the command that is specified in the build script of extraBinPaths: [], extraEnv: {}, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['foo', 'arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -128,6 +153,11 @@ test('test: pass the args to the command that is specified in the build script o extraBinPaths: [], extraEnv: {}, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -150,6 +180,11 @@ test('run start: pass the args to the command that is specified in the build scr extraBinPaths: [], extraEnv: {}, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['start', 'arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -172,6 +207,11 @@ test('run stop: pass the args to the command that is specified in the build scri extraBinPaths: [], extraEnv: {}, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['stop', 'arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -201,6 +241,11 @@ test('restart: run stop, restart and start', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, []) const { default: scriptsRan } = await import(path.resolve('output.json')) @@ -235,6 +280,11 @@ test('restart: run stop, restart and start and all the pre/post scripts', async extraBinPaths: [], extraEnv: {}, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, []) const { default: scriptsRan } = await import(path.resolve('output.json')) @@ -264,6 +314,11 @@ test('"pnpm run" prints the list of available commands', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, []) expect(output).toBe(`\ @@ -315,6 +370,11 @@ test('"pnpm run" prints the list of available commands, including commands of th rawConfig: {}, selectedProjectsGraph, workspaceDir, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, []) expect(output).toBe(`\ @@ -342,6 +402,11 @@ Commands of the root workspace project (to run them, use "pnpm -w run"): rawConfig: {}, selectedProjectsGraph, workspaceDir, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, []) expect(output).toBe(`\ @@ -364,6 +429,11 @@ test('pnpm run does not fail with --if-present even if the wanted script is not extraEnv: {}, ifPresent: true, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['build']) }) @@ -432,6 +502,11 @@ test('scripts work with PnP', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['foo']) const { default: scriptsRan } = await import(path.resolve('output.json')) @@ -461,6 +536,11 @@ test('pnpm run with custom shell', async () => { extraEnv: {}, rawConfig: {}, scriptShell: path.resolve(`node_modules/.bin/shell-mock${isWindows() ? '.cmd' : ''}`), + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['build']) expect((await import(path.resolve('shell-input.json'))).default).toStrictEqual(['-c', 'foo bar']) @@ -485,6 +565,11 @@ test('pnpm run with RegExp script selector should work', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['/^(lint|build):.*/']) expect(await fs.readFile('output-build-a.txt', { encoding: 'utf-8' })).toEqual('a') @@ -510,6 +595,11 @@ test('pnpm run with RegExp script selector should work also for pre/post script' extraEnv: {}, rawConfig: {}, enablePrePostScripts: true, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['/build:.*/']) expect(await fs.readFile('output-a.txt', { encoding: 'utf-8' })).toEqual('a') @@ -531,6 +621,11 @@ test('pnpm run with RegExp script selector should work parallel as a default beh extraBinPaths: [], extraEnv: {}, rawConfig: {}, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['/build:.*/']) const { default: outputsA } = await import(path.resolve('output-a.json')) @@ -555,6 +650,11 @@ test('pnpm run with RegExp script selector should work sequentially with --works extraEnv: {}, rawConfig: {}, workspaceConcurrency: 1, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['/build:.*/']) const { default: outputsA } = await import(path.resolve('output-a.json')) @@ -579,6 +679,11 @@ test('pnpm run with RegExp script selector with flag should throw error', async extraEnv: {}, rawConfig: {}, workspaceConcurrency: 1, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['/build:.*/i']) } catch (_err: any) { // eslint-disable-line err = _err @@ -599,6 +704,11 @@ test('pnpm run with slightly incorrect command suggests correct one', async () = extraEnv: {}, rawConfig: {}, workspaceConcurrency: 1, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }, ['buil'])).rejects.toEqual(expect.objectContaining({ code: 'ERR_PNPM_NO_SCRIPT', hint: 'Command "buil" not found. Did you mean "pnpm run build"?', diff --git a/exec/plugin-commands-script-runners/test/utils/index.ts b/exec/plugin-commands-script-runners/test/utils/index.ts index 36f961d9343..5b89b9c1b3f 100644 --- a/exec/plugin-commands-script-runners/test/utils/index.ts +++ b/exec/plugin-commands-script-runners/test/utils/index.ts @@ -49,6 +49,11 @@ export const DEFAULT_OPTS = { useRunningStoreServer: false, useStoreServer: false, workspaceConcurrency: 4, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } export const DLX_DEFAULT_OPTS = { @@ -78,4 +83,9 @@ export const DLX_DEFAULT_OPTS = { storeDir: path.join(tmp, 'store'), userConfig: {}, workspaceConcurrency: 1, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } diff --git a/pkg-manager/plugin-commands-installation/src/install.ts b/pkg-manager/plugin-commands-installation/src/install.ts index a114dcbf4ec..173eb8ab61f 100644 --- a/pkg-manager/plugin-commands-installation/src/install.ts +++ b/pkg-manager/plugin-commands-installation/src/install.ts @@ -295,6 +295,7 @@ export type InstallCommandOptions = Pick & CreateStoreControllerOptions & { argv: { original: string[] diff --git a/pkg-manager/plugin-commands-installation/src/installDeps.ts b/pkg-manager/plugin-commands-installation/src/installDeps.ts index 754e8286d39..a9d1b94d7f5 100644 --- a/pkg-manager/plugin-commands-installation/src/installDeps.ts +++ b/pkg-manager/plugin-commands-installation/src/installDeps.ts @@ -83,6 +83,7 @@ export type InstallDepsOptions = Pick & CreateStoreControllerOptions & { argv: { original: string[] diff --git a/pkg-manager/plugin-commands-installation/src/recursive.ts b/pkg-manager/plugin-commands-installation/src/recursive.ts index bf77d8eb18f..19efbcf7683 100755 --- a/pkg-manager/plugin-commands-installation/src/recursive.ts +++ b/pkg-manager/plugin-commands-installation/src/recursive.ts @@ -70,6 +70,7 @@ type RecursiveOptions = CreateStoreControllerOptions & Pick & { include?: IncludedDependencies includeDirect?: IncludedDependencies diff --git a/pkg-manager/plugin-commands-installation/src/remove.ts b/pkg-manager/plugin-commands-installation/src/remove.ts index 14dee07071c..12fd6a34c07 100644 --- a/pkg-manager/plugin-commands-installation/src/remove.ts +++ b/pkg-manager/plugin-commands-installation/src/remove.ts @@ -149,6 +149,7 @@ export async function handler ( | 'selectedProjectsGraph' | 'workspaceDir' | 'sharedWorkspaceLockfile' + | 'supportedArchitectures' > & { recursive?: boolean }, diff --git a/pkg-manager/plugin-commands-installation/src/unlink.ts b/pkg-manager/plugin-commands-installation/src/unlink.ts index 87b4056e980..c47c20404e3 100644 --- a/pkg-manager/plugin-commands-installation/src/unlink.ts +++ b/pkg-manager/plugin-commands-installation/src/unlink.ts @@ -57,6 +57,7 @@ export async function handler ( | 'rootProjectManifestDir' | 'pnpmfile' | 'workspaceDir' + | 'supportedArchitectures' > & { recursive?: boolean }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8c1216f74be..393fb8bc189 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6050,7 +6050,7 @@ importers: version: link:../fs/symlink-dependency '@rushstack/worker-pool': specifier: 0.4.9 - version: 0.4.9 + version: 0.4.9(@types/node@16.18.58) load-json-file: specifier: ^6.2.0 version: 6.2.0 @@ -6095,6 +6095,9 @@ importers: '@pnpm/filter-workspace-packages': specifier: workspace:* version: 'link:' + '@pnpm/types': + specifier: workspace:* + version: link:../../packages/types '@types/is-windows': specifier: ^1.0.0 version: 1.0.0 @@ -8345,13 +8348,15 @@ packages: '@reflink/reflink-win32-x64-msvc': 0.1.12 dev: false - /@rushstack/worker-pool@0.4.9: + /@rushstack/worker-pool@0.4.9(@types/node@16.18.58): resolution: {integrity: sha512-ibAOeQCuz3g0c88GGawAPO2LVOTZE3uPh4DCEJILZS9SEv9opEUObsovC18EHPgeIuFy4HkoJT+t7l8LURZjIw==} peerDependencies: '@types/node': '*' peerDependenciesMeta: '@types/node': optional: true + dependencies: + '@types/node': 16.18.58 dev: false /@sinclair/typebox@0.27.8: @@ -8635,7 +8640,6 @@ packages: /@types/node@16.18.58: resolution: {integrity: sha512-YGncyA25/MaVtQkjWW9r0EFBukZ+JulsLcVZBlGUfIb96OBMjkoRWwQo5IEWJ8Fj06Go3GHw+bjYDitv6BaGsA==} - dev: true /@types/node@18.18.5: resolution: {integrity: sha512-4slmbtwV59ZxitY4ixUZdy1uRLf9eSIvBWPQxNjhHYWEtn0FryfKpyS2cvADYXTayWdKEIsJengncrVvkI4I6A==} @@ -9069,7 +9073,7 @@ packages: resolution: {integrity: sha512-YmG+oTBCyrAoMIx5g2I9CfyurSpHyoan+9SCj7laaFKseOe3lFEyIVKvwRBQMmSt8uzh+eY5RWeQnoyyOs6AbA==} engines: {node: '>=14.15.0'} peerDependencies: - '@yarnpkg/fslib': 3.0.0-rc.45 + '@yarnpkg/fslib': 3.0.0-rc.25 dependencies: '@types/emscripten': 1.39.8 '@yarnpkg/fslib': 3.0.0-rc.25 diff --git a/pnpm/src/cmd/complete.ts b/pnpm/src/cmd/complete.ts index 85b6b50facc..86e91221a70 100644 --- a/pnpm/src/cmd/complete.ts +++ b/pnpm/src/cmd/complete.ts @@ -31,7 +31,13 @@ export async function complete ( if (input.currentTypedWordType !== 'option') { if (input.lastOption === '--filter') { const workspaceDir = await findWorkspaceDir(process.cwd()) ?? process.cwd() - const allProjects = await findWorkspacePackages(workspaceDir, {}) + const allProjects = await findWorkspacePackages(workspaceDir, { + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, + }) return allProjects .filter(({ manifest }) => manifest.name) .map(({ manifest }) => ({ name: manifest.name })) diff --git a/pnpm/src/main.ts b/pnpm/src/main.ts index 6586fbf0fff..5af7293ea87 100644 --- a/pnpm/src/main.ts +++ b/pnpm/src/main.ts @@ -208,6 +208,7 @@ export async function main (inputArgv: string[]) { changedFilesIgnorePattern: config.changedFilesIgnorePattern, useGlobDirFiltering: !config.legacyDirFiltering, sharedWorkspaceLockfile: config.sharedWorkspaceLockfile, + supportedArchitectures: config.supportedArchitectures, }) if (filterResults.allProjects.length === 0) { diff --git a/releasing/plugin-commands-publishing/src/pack.ts b/releasing/plugin-commands-publishing/src/pack.ts index 25d420ff6b2..0127f1c87c4 100644 --- a/releasing/plugin-commands-publishing/src/pack.ts +++ b/releasing/plugin-commands-publishing/src/pack.ts @@ -58,7 +58,7 @@ export function help () { } export async function handler ( - opts: Pick & Pick & Partial> & { + opts: Pick & Pick & Partial> & { argv: { original: string[] } @@ -145,7 +145,13 @@ async function packPkg (opts: { projectDir, embedReadme, } = opts - const { manifest } = await readProjectManifest(projectDir, {}) + const { manifest } = await readProjectManifest(projectDir, { + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, + }) const bins = [ ...(await getBinsFromPackageManifest(manifest as DependencyManifest, projectDir)).map(({ path }) => path), ...(manifest.publishConfig?.executableFiles ?? []) diff --git a/releasing/plugin-commands-publishing/src/publish.ts b/releasing/plugin-commands-publishing/src/publish.ts index 2a600e61ab8..486cff19234 100644 --- a/releasing/plugin-commands-publishing/src/publish.ts +++ b/releasing/plugin-commands-publishing/src/publish.ts @@ -118,7 +118,7 @@ export async function handler ( engineStrict?: boolean recursive?: boolean workspaceDir?: string - } & Pick, + } & Pick, params: string[] ) { const result = await publish(opts, params) @@ -134,7 +134,7 @@ export async function publish ( engineStrict?: boolean recursive?: boolean workspaceDir?: string - } & Pick, + } & Pick, params: string[] ) { if (opts.gitChecks !== false && await isGitRepo()) { diff --git a/releasing/plugin-commands-publishing/src/recursivePublish.ts b/releasing/plugin-commands-publishing/src/recursivePublish.ts index 0c3b7f38399..0d7143437c8 100644 --- a/releasing/plugin-commands-publishing/src/recursivePublish.ts +++ b/releasing/plugin-commands-publishing/src/recursivePublish.ts @@ -55,7 +55,7 @@ Partial> + opts: PublishRecursiveOpts & Required> ): Promise<{ exitCode: number }> { const pkgs = Object.values(opts.selectedProjectsGraph).map((wsPkg) => wsPkg.package) const resolve = createResolver({ diff --git a/reviewing/plugin-commands-licenses/src/licensesList.ts b/reviewing/plugin-commands-licenses/src/licensesList.ts index 565af178748..d9096f5b03b 100644 --- a/reviewing/plugin-commands-licenses/src/licensesList.ts +++ b/reviewing/plugin-commands-licenses/src/licensesList.ts @@ -46,7 +46,13 @@ export async function licensesList (opts: LicensesCommandOptions) { optionalDependencies: opts.optional !== false, } - const manifest = await readProjectManifestOnly(opts.dir, {}) + const manifest = await readProjectManifestOnly(opts.dir, { + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, + }) const includedImporterIds = opts.selectedProjectsGraph ? Object.keys(opts.selectedProjectsGraph) diff --git a/reviewing/plugin-commands-outdated/src/outdated.ts b/reviewing/plugin-commands-outdated/src/outdated.ts index 20a93a6f580..a2a9fcd52bf 100644 --- a/reviewing/plugin-commands-outdated/src/outdated.ts +++ b/reviewing/plugin-commands-outdated/src/outdated.ts @@ -156,6 +156,7 @@ export type OutdatedCommandOptions = { | 'strictSsl' | 'tag' | 'userAgent' +| 'supportedArchitectures' > & Partial> export async function handler ( diff --git a/workspace/filter-workspace-packages/package.json b/workspace/filter-workspace-packages/package.json index 7e73ac85590..d63316ba3b2 100644 --- a/workspace/filter-workspace-packages/package.json +++ b/workspace/filter-workspace-packages/package.json @@ -41,6 +41,7 @@ }, "devDependencies": { "@pnpm/filter-workspace-packages": "workspace:*", + "@pnpm/types": "workspace:*", "@types/is-windows": "^1.0.0", "@types/micromatch": "^4.0.3", "@types/ramda": "0.28.20", diff --git a/workspace/filter-workspace-packages/src/index.ts b/workspace/filter-workspace-packages/src/index.ts index ba99cc24d90..d3ad59dba7e 100644 --- a/workspace/filter-workspace-packages/src/index.ts +++ b/workspace/filter-workspace-packages/src/index.ts @@ -1,4 +1,5 @@ import { createMatcher } from '@pnpm/matcher' +import { type SupportedArchitectures } from '@pnpm/types' import { findWorkspacePackages, type Project } from '@pnpm/workspace.find-packages' import { createPkgGraph, type Package, type PackageNode } from '@pnpm/workspace.pkgs-graph' import isSubdir from 'is-subdir' @@ -42,9 +43,10 @@ export async function readProjects ( engineStrict?: boolean linkWorkspacePackages?: boolean changedFilesIgnorePattern?: string[] + supportedArchitectures: SupportedArchitectures } ): Promise { - const allProjects = await findWorkspacePackages(workspaceDir, { engineStrict: opts?.engineStrict }) + const allProjects = await findWorkspacePackages(workspaceDir, { engineStrict: opts?.engineStrict, supportedArchitectures: opts?.supportedArchitectures ?? { os: ['current'], cpu: ['current'], libc: ['current'] } }) const { allProjectsGraph, selectedProjectsGraph } = await filterPkgsBySelectorObjects( allProjects, pkgSelectors, @@ -74,6 +76,7 @@ export async function filterPackagesFromDir ( engineStrict?: boolean nodeVersion?: string patterns: string[] + supportedArchitectures: SupportedArchitectures } ) { const allProjects = await findWorkspacePackages(workspaceDir, { @@ -81,6 +84,7 @@ export async function filterPackagesFromDir ( patterns: opts.patterns, sharedWorkspaceLockfile: opts.sharedWorkspaceLockfile, nodeVersion: opts.nodeVersion, + supportedArchitectures: opts.supportedArchitectures, }) return { allProjects, diff --git a/workspace/filter-workspace-packages/tsconfig.json b/workspace/filter-workspace-packages/tsconfig.json index 2163f295a77..fd439dc0399 100644 --- a/workspace/filter-workspace-packages/tsconfig.json +++ b/workspace/filter-workspace-packages/tsconfig.json @@ -15,6 +15,9 @@ { "path": "../../packages/error" }, + { + "path": "../../packages/types" + }, { "path": "../find-packages" }, diff --git a/workspace/find-packages/src/index.ts b/workspace/find-packages/src/index.ts index 7e61d9a84dc..2b4f6694600 100644 --- a/workspace/find-packages/src/index.ts +++ b/workspace/find-packages/src/index.ts @@ -1,7 +1,7 @@ import path from 'path' import { packageIsInstallable } from '@pnpm/cli-utils' import { WORKSPACE_MANIFEST_FILENAME } from '@pnpm/constants' -import { type ProjectManifest, type Project } from '@pnpm/types' +import { type ProjectManifest, type Project, type SupportedArchitectures } from '@pnpm/types' import { lexCompare } from '@pnpm/util.lex-comparator' import { findPackages } from '@pnpm/fs.find-packages' import { logger } from '@pnpm/logger' @@ -16,11 +16,18 @@ export async function findWorkspacePackages ( nodeVersion?: string patterns?: string[] sharedWorkspaceLockfile?: boolean + supportedArchitectures: SupportedArchitectures } ): Promise { const pkgs = await findWorkspacePackagesNoCheck(workspaceRoot, opts) for (const pkg of pkgs) { - packageIsInstallable(pkg.dir, pkg.manifest, opts ?? {}) + packageIsInstallable(pkg.dir, pkg.manifest, opts ?? { + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, + }) // When setting shared-workspace-lockfile=false, `pnpm` can be set in sub-project's package.json. if (opts?.sharedWorkspaceLockfile && pkg.dir !== workspaceRoot) { checkNonRootProjectManifest(pkg) From 6bbf7e88e77f8e1dfd521cacaf63eec0722a87ba Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Tue, 17 Oct 2023 19:46:10 +0200 Subject: [PATCH 05/39] fix: recreate changeset --- ...y-spiders-nail.md => silver-bugs-check.md} | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) rename .changeset/{spicy-spiders-nail.md => silver-bugs-check.md} (66%) diff --git a/.changeset/spicy-spiders-nail.md b/.changeset/silver-bugs-check.md similarity index 66% rename from .changeset/spicy-spiders-nail.md rename to .changeset/silver-bugs-check.md index d63057c0bef..0006e998161 100644 --- a/.changeset/spicy-spiders-nail.md +++ b/.changeset/silver-bugs-check.md @@ -1,32 +1,27 @@ --- "@pnpm/plugin-commands-installation": minor +"@pnpm/plugin-commands-publishing": minor +"@pnpm/plugin-commands-script-runners": minor +"@pnpm/filter-workspace-packages": minor "@pnpm/plugin-commands-licenses": minor +"@pnpm/plugin-commands-outdated": minor "@pnpm/plugin-commands-patching": minor "@pnpm/resolve-dependencies": minor "@pnpm/package-is-installable": minor "@pnpm/package-requester": minor +"@pnpm/plugin-commands-rebuild": minor "@pnpm/store-controller-types": minor "@pnpm/plugin-commands-store": minor "@pnpm/license-scanner": minor "@pnpm/filter-lockfile": minor +"@pnpm/workspace.find-packages": minor "@pnpm/headless": minor "@pnpm/deps.graph-builder": minor "@pnpm/core": minor "@pnpm/types": minor +"@pnpm/cli-utils": minor "@pnpm/config": minor +"pnpm": minor --- Support different architectures when installing dependencies. - -Example: - -```json -{ - "pnpm": { - "supportedArchitectures": { - "os": ["current", "win32"], - "cpu": ["x64", "arm64"] - } - } -} -``` From 1704b6b62d97a6b42770aa21779bae4f2764ede0 Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Tue, 17 Oct 2023 20:14:18 +0200 Subject: [PATCH 06/39] fix: type errors --- .../test/filterByImportersAndEngine.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lockfile/filter-lockfile/test/filterByImportersAndEngine.ts b/lockfile/filter-lockfile/test/filterByImportersAndEngine.ts index 8dcee6ca9b1..edbf69fb435 100644 --- a/lockfile/filter-lockfile/test/filterByImportersAndEngine.ts +++ b/lockfile/filter-lockfile/test/filterByImportersAndEngine.ts @@ -116,6 +116,11 @@ test('filterByImportersAndEngine(): skip packages that are not installable', () }, lockfileDir: process.cwd(), skipped: skippedPackages, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } ) @@ -297,6 +302,11 @@ test('filterByImportersAndEngine(): filter the packages that set os and cpu', () }, lockfileDir: process.cwd(), skipped: skippedPackages, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } ) @@ -467,6 +477,11 @@ test('filterByImportersAndEngine(): filter the packages that set libc', () => { }, lockfileDir: process.cwd(), skipped: skippedPackages, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } ) @@ -602,6 +617,11 @@ test('filterByImportersAndEngine(): includes linked packages', () => { }, lockfileDir: process.cwd(), skipped: new Set(), + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } ) From fb12599092f8c6a3a2509707b4d38f5dca7de5f0 Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Tue, 17 Oct 2023 20:41:03 +0200 Subject: [PATCH 07/39] fix: type errors --- lockfile/plugin-commands-audit/test/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lockfile/plugin-commands-audit/test/index.ts b/lockfile/plugin-commands-audit/test/index.ts index 7d8a029f9eb..4da774ccade 100644 --- a/lockfile/plugin-commands-audit/test/index.ts +++ b/lockfile/plugin-commands-audit/test/index.ts @@ -59,6 +59,11 @@ export const DEFAULT_OPTS = { useRunningStoreServer: false, useStoreServer: false, workspaceConcurrency: 4, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } describe('plugin-commands-audit', () => { From a11b9285cf0dc5f930e0df9ca0e353b68e2fe03c Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Wed, 18 Oct 2023 11:04:11 +0200 Subject: [PATCH 08/39] fix: type errors --- .../test/patch.test.ts | 25 +++++++++++++++++++ .../test/utils/index.ts | 5 ++++ 2 files changed, 30 insertions(+) diff --git a/patching/plugin-commands-patching/test/patch.test.ts b/patching/plugin-commands-patching/test/patch.test.ts index 1a1afc002a1..eed33d23d7a 100644 --- a/patching/plugin-commands-patching/test/patch.test.ts +++ b/patching/plugin-commands-patching/test/patch.test.ts @@ -47,6 +47,11 @@ describe('patch and commit', () => { cacheDir, dir: process.cwd(), storeDir, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } await install.handler({ @@ -352,6 +357,11 @@ describe('prompt to choose version', () => { cacheDir, dir: process.cwd(), storeDir, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } }) @@ -420,6 +430,11 @@ describe('patching should work when there is a no EOL in the patched file', () = cacheDir, dir: process.cwd(), storeDir, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } await install.handler({ @@ -526,6 +541,11 @@ describe('patch and commit in workspaces', () => { cacheDir, dir: process.cwd(), storeDir, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } await writeYamlFile('pnpm-workspace.yaml', { packages: ['project-1', 'project-2'] }) }) @@ -665,6 +685,11 @@ describe('patch with custom modules-dir and virtual-store-dir', () => { storeDir, modulesDir: 'fake_modules', virtualStoreDir: 'fake_modules/.fake_store', + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } }) diff --git a/patching/plugin-commands-patching/test/utils/index.ts b/patching/plugin-commands-patching/test/utils/index.ts index b409fb15de1..8fa6615d4fe 100644 --- a/patching/plugin-commands-patching/test/utils/index.ts +++ b/patching/plugin-commands-patching/test/utils/index.ts @@ -47,4 +47,9 @@ export const DEFAULT_OPTS = { useRunningStoreServer: false, useStoreServer: false, workspaceConcurrency: 4, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } From f2435bfcc00b5ed55acef8d6a85b34092af7f380 Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Wed, 18 Oct 2023 11:55:00 +0200 Subject: [PATCH 09/39] fix: type errors --- pkg-manager/package-requester/test/index.ts | 80 +++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/pkg-manager/package-requester/test/index.ts b/pkg-manager/package-requester/test/index.ts index 58ace6449c1..030caa8fb12 100644 --- a/pkg-manager/package-requester/test/index.ts +++ b/pkg-manager/package-requester/test/index.ts @@ -49,6 +49,11 @@ test('request package', async () => { preferredVersions: {}, projectDir, registry, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) expect(pkgResponse).toBeTruthy() @@ -92,6 +97,11 @@ test('request package but skip fetching', async () => { projectDir, registry, skipFetch: true, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) expect(pkgResponse).toBeTruthy() @@ -141,6 +151,11 @@ test('request package but skip fetching, when resolution is already available', registry, skipFetch: true, update: false, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) as PackageResponse & { body: { latest: string @@ -203,6 +218,11 @@ test('refetch local tarball if its integrity has changed', async () => { tarball, }, }, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) as PackageResponse & { fetching: () => Promise } @@ -234,6 +254,11 @@ test('refetch local tarball if its integrity has changed', async () => { tarball, }, }, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) const { files, bundledManifest } = await response.fetching!() @@ -260,6 +285,11 @@ test('refetch local tarball if its integrity has changed', async () => { tarball, }, }, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) as PackageResponse & { fetching: () => Promise } @@ -286,6 +316,11 @@ test('refetch local tarball if its integrity has changed. The requester does not projectDir, registry, update: false, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, } { @@ -576,6 +611,11 @@ test('always return a package manifest in the response', async () => { preferredVersions: {}, projectDir, registry, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) as PackageResponse & { body: { manifest: { name: string } } } expect(pkgResponse.body).toBeTruthy() @@ -597,6 +637,11 @@ test('always return a package manifest in the response', async () => { preferredVersions: {}, projectDir, registry, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) as PackageResponse & { fetching: () => Promise } expect(pkgResponse.body).toBeTruthy() @@ -771,6 +816,11 @@ test('do not fetch an optional package that is not installable', async () => { preferredVersions: {}, projectDir, registry, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) expect(pkgResponse).toBeTruthy() @@ -809,6 +859,11 @@ test('fetch a git package without a package.json', async () => { preferredVersions: {}, projectDir, registry, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) as PackageResponse & { body: { manifest: { name: string } } } expect(pkgResponse.body).toBeTruthy() @@ -840,6 +895,11 @@ test('throw exception if the package data in the store differs from the expected preferredVersions: {}, projectDir, registry, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) await pkgResponse.fetching!() } @@ -972,6 +1032,11 @@ test("don't throw an error if the package was updated, so the expectedPkg has a preferredVersions: {}, projectDir, registry, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) await pkgResponse.fetching!() } @@ -994,6 +1059,11 @@ test("don't throw an error if the package was updated, so the expectedPkg has a name: 'is-positive', version: '3.0.0', }, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) await expect(pkgResponse.fetching!()).resolves.toStrictEqual(expect.anything()) }) @@ -1017,6 +1087,11 @@ test('the version in the bundled manifest should be normalized', async () => { preferredVersions: {}, projectDir: tempy.directory(), registry, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) expect((await pkgResponse.fetching!()).bundledManifest).toStrictEqual(expect.objectContaining({ version: '1.2.1', @@ -1047,6 +1122,11 @@ test('should skip store integrity check and resolve manifest if fetchRawManifest preferredVersions: {}, projectDir, registry, + supportedArchitectures: { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) await pkgResponse.fetching!() From b71e17f43030fe6bb615bdc8c3c63e022664ce64 Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Wed, 18 Oct 2023 12:18:43 +0200 Subject: [PATCH 10/39] fix: make `supportedArchitectures` optional If not specified, it will use just the current system --- cli/cli-utils/src/packageIsInstallable.ts | 8 +- cli/cli-utils/src/readProjectManifest.ts | 12 +- config/config/src/Config.ts | 2 +- .../config/src/getOptionsFromRootManifest.ts | 2 +- .../src/checkPlatform.ts | 2 +- config/package-is-installable/src/index.ts | 4 +- deps/graph-builder/src/lockfileToDepGraph.ts | 2 +- exec/plugin-commands-rebuild/src/rebuild.ts | 1 - .../plugin-commands-script-runners/src/run.ts | 9 +- .../test/index.ts | 106 +++--------------- .../src/filterLockfileByImportersAndEngine.ts | 6 +- .../plugin-commands-patching/src/patch.ts | 5 +- .../src/patchCommit.ts | 2 +- .../src/writePackage.ts | 2 +- .../core/src/getPeerDependencyIssues.ts | 2 +- .../core/src/install/extendInstallOptions.ts | 4 +- pkg-manager/headless/src/index.ts | 2 +- .../headless/src/lockfileToHoistedDepGraph.ts | 2 +- pkg-manager/package-requester/test/index.ts | 42 ++----- .../plugin-commands-installation/src/fetch.ts | 2 +- .../src/install.ts | 3 +- .../src/installDeps.ts | 1 - .../plugin-commands-installation/src/link.ts | 3 +- .../src/recursive.ts | 2 +- .../src/remove.ts | 1 - .../src/unlink.ts | 1 - .../src/resolveDependencies.ts | 6 +- .../src/resolveDependencyTree.ts | 2 +- .../plugin-commands-publishing/src/pack.ts | 8 +- .../plugin-commands-publishing/src/publish.ts | 4 +- .../src/recursivePublish.ts | 3 +- reviewing/license-scanner/src/licenses.ts | 2 +- .../src/lockfileToLicenseNodeTree.ts | 2 +- .../src/licensesList.ts | 9 +- .../plugin-commands-outdated/src/outdated.ts | 3 +- store/plugin-commands-store/src/store.ts | 2 +- store/plugin-commands-store/src/storeAdd.ts | 2 +- store/store-connection-manager/src/index.ts | 2 +- store/store-controller-types/src/index.ts | 2 +- .../filter-workspace-packages/src/index.ts | 4 +- workspace/find-packages/src/index.ts | 2 +- 41 files changed, 80 insertions(+), 201 deletions(-) diff --git a/cli/cli-utils/src/packageIsInstallable.ts b/cli/cli-utils/src/packageIsInstallable.ts index ae05742af49..cd86c79456d 100644 --- a/cli/cli-utils/src/packageIsInstallable.ts +++ b/cli/cli-utils/src/packageIsInstallable.ts @@ -14,7 +14,7 @@ export function packageIsInstallable ( opts: { engineStrict?: boolean nodeVersion?: string - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } ) { const pnpmVersion = packageManager.name === 'pnpm' @@ -23,7 +23,11 @@ export function packageIsInstallable ( const err = checkPackage(pkgPath, pkg, { nodeVersion: opts.nodeVersion, pnpmVersion, - supportedArchitectures: opts.supportedArchitectures, + supportedArchitectures: opts.supportedArchitectures ?? { + os: ['current'], + cpu: ['current'], + libc: ['current'], + }, }) if (err === null) return if ( diff --git a/cli/cli-utils/src/readProjectManifest.ts b/cli/cli-utils/src/readProjectManifest.ts index b532791eeba..068f20fc8cb 100644 --- a/cli/cli-utils/src/readProjectManifest.ts +++ b/cli/cli-utils/src/readProjectManifest.ts @@ -7,7 +7,7 @@ export async function readProjectManifest ( opts: { engineStrict?: boolean nodeVersion?: string - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } ): Promise<{ fileName: string @@ -24,13 +24,9 @@ export async function readProjectManifestOnly ( opts: { engineStrict?: boolean nodeVersion?: string - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } = { - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + } ): Promise { const manifest = await utils.readProjectManifestOnly(projectDir) @@ -44,7 +40,7 @@ export async function tryReadProjectManifest ( opts: { engineStrict?: boolean nodeVersion?: string - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } ): Promise<{ fileName: string diff --git a/config/config/src/Config.ts b/config/config/src/Config.ts index f2f863e060d..76472505341 100644 --- a/config/config/src/Config.ts +++ b/config/config/src/Config.ts @@ -173,7 +173,7 @@ export interface Config { rootProjectManifestDir?: string rootProjectManifest?: ProjectManifest userConfig: Record - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } export interface ConfigWithDeprecatedSettings extends Config { diff --git a/config/config/src/getOptionsFromRootManifest.ts b/config/config/src/getOptionsFromRootManifest.ts index 85d14226c19..26f4b7d770e 100644 --- a/config/config/src/getOptionsFromRootManifest.ts +++ b/config/config/src/getOptionsFromRootManifest.ts @@ -19,7 +19,7 @@ export interface OptionsFromRootManifest { packageExtensions?: Record patchedDependencies?: Record peerDependencyRules?: PeerDependencyRules - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } export function getOptionsFromRootManifest (manifestDir: string, manifest: ProjectManifest): OptionsFromRootManifest { diff --git a/config/package-is-installable/src/checkPlatform.ts b/config/package-is-installable/src/checkPlatform.ts index 1d62f4fa4e0..0bdf35ac16f 100644 --- a/config/package-is-installable/src/checkPlatform.ts +++ b/config/package-is-installable/src/checkPlatform.ts @@ -18,7 +18,7 @@ export class UnsupportedPlatformError extends PnpmError { export function checkPlatform ( packageId: string, wantedPlatform: WantedPlatform, - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures ) { const platforms = { os: dedupeArchs(process.platform, supportedArchitectures?.os ?? ['current']), diff --git a/config/package-is-installable/src/index.ts b/config/package-is-installable/src/index.ts index 15c76921914..7b97ff17de7 100644 --- a/config/package-is-installable/src/index.ts +++ b/config/package-is-installable/src/index.ts @@ -32,7 +32,7 @@ export function packageIsInstallable ( optional: boolean pnpmVersion?: string lockfileDir: string - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } ): boolean | null { const warn = checkPackage(pkgId, pkg, options) @@ -75,7 +75,7 @@ export function checkPackage ( options: { nodeVersion?: string pnpmVersion?: string - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } ): null | UnsupportedEngineError | UnsupportedPlatformError { return checkPlatform(pkgId, { diff --git a/deps/graph-builder/src/lockfileToDepGraph.ts b/deps/graph-builder/src/lockfileToDepGraph.ts index 474d88c9b2a..65d17bc1571 100644 --- a/deps/graph-builder/src/lockfileToDepGraph.ts +++ b/deps/graph-builder/src/lockfileToDepGraph.ts @@ -68,7 +68,7 @@ export interface LockfileToDepGraphOptions { storeController: StoreController storeDir: string virtualStoreDir: string - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } export interface DirectDependenciesByImporterId { diff --git a/exec/plugin-commands-rebuild/src/rebuild.ts b/exec/plugin-commands-rebuild/src/rebuild.ts index 4c1e6e993e6..3350f760147 100644 --- a/exec/plugin-commands-rebuild/src/rebuild.ts +++ b/exec/plugin-commands-rebuild/src/rebuild.ts @@ -87,7 +87,6 @@ export async function handler ( | 'scriptsPrependNodePath' | 'shellEmulator' | 'workspaceDir' - | 'supportedArchitectures' > & CreateStoreControllerOptions & { diff --git a/exec/plugin-commands-script-runners/src/run.ts b/exec/plugin-commands-script-runners/src/run.ts index 0e8ce325179..fb734015165 100644 --- a/exec/plugin-commands-script-runners/src/run.ts +++ b/exec/plugin-commands-script-runners/src/run.ts @@ -106,11 +106,6 @@ export const completion: CompletionFunc = async (cliOpts, params) => { } const manifest = await readProjectManifestOnly(cliOpts.dir as string ?? process.cwd(), { ...cliOpts, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }) return Object.keys(manifest.scripts ?? {}).map((name) => ({ name })) } @@ -156,10 +151,10 @@ For options that may be used with `-r`, see "pnpm help recursive"', export type RunOpts = & Omit & { recursive?: boolean } - & Pick + & Pick & ( & { recursive?: false } - & Partial> + & Partial> | { recursive: true } & Required> ) diff --git a/exec/plugin-commands-script-runners/test/index.ts b/exec/plugin-commands-script-runners/test/index.ts index 54cffc03e05..a261213ede0 100644 --- a/exec/plugin-commands-script-runners/test/index.ts +++ b/exec/plugin-commands-script-runners/test/index.ts @@ -29,11 +29,7 @@ test('pnpm run: returns correct exit code', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, ['exit0']) let err!: Error & { errno: number } @@ -70,11 +66,7 @@ test('pnpm run --no-bail never fails', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, ['exit1']) const { default: args } = await import(path.resolve('args.json')) @@ -99,11 +91,7 @@ test('run: pass the args to the command that is specified in the build script', extraBinPaths: [], extraEnv: {}, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, ['foo', 'arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -126,11 +114,7 @@ test('run: pass the args to the command that is specified in the build script of extraBinPaths: [], extraEnv: {}, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, ['foo', 'arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -153,11 +137,7 @@ test('test: pass the args to the command that is specified in the build script o extraBinPaths: [], extraEnv: {}, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, ['arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -180,11 +160,7 @@ test('run start: pass the args to the command that is specified in the build scr extraBinPaths: [], extraEnv: {}, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, ['start', 'arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -207,11 +183,7 @@ test('run stop: pass the args to the command that is specified in the build scri extraBinPaths: [], extraEnv: {}, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, ['stop', 'arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -241,11 +213,7 @@ test('restart: run stop, restart and start', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, []) const { default: scriptsRan } = await import(path.resolve('output.json')) @@ -280,11 +248,7 @@ test('restart: run stop, restart and start and all the pre/post scripts', async extraBinPaths: [], extraEnv: {}, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, []) const { default: scriptsRan } = await import(path.resolve('output.json')) @@ -314,11 +278,7 @@ test('"pnpm run" prints the list of available commands', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, []) expect(output).toBe(`\ @@ -429,11 +389,7 @@ test('pnpm run does not fail with --if-present even if the wanted script is not extraEnv: {}, ifPresent: true, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, ['build']) }) @@ -502,11 +458,7 @@ test('scripts work with PnP', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, ['foo']) const { default: scriptsRan } = await import(path.resolve('output.json')) @@ -536,11 +488,7 @@ test('pnpm run with custom shell', async () => { extraEnv: {}, rawConfig: {}, scriptShell: path.resolve(`node_modules/.bin/shell-mock${isWindows() ? '.cmd' : ''}`), - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, ['build']) expect((await import(path.resolve('shell-input.json'))).default).toStrictEqual(['-c', 'foo bar']) @@ -565,11 +513,7 @@ test('pnpm run with RegExp script selector should work', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, ['/^(lint|build):.*/']) expect(await fs.readFile('output-build-a.txt', { encoding: 'utf-8' })).toEqual('a') @@ -595,11 +539,7 @@ test('pnpm run with RegExp script selector should work also for pre/post script' extraEnv: {}, rawConfig: {}, enablePrePostScripts: true, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, ['/build:.*/']) expect(await fs.readFile('output-a.txt', { encoding: 'utf-8' })).toEqual('a') @@ -621,11 +561,7 @@ test('pnpm run with RegExp script selector should work parallel as a default beh extraBinPaths: [], extraEnv: {}, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }, ['/build:.*/']) const { default: outputsA } = await import(path.resolve('output-a.json')) @@ -650,11 +586,6 @@ test('pnpm run with RegExp script selector should work sequentially with --works extraEnv: {}, rawConfig: {}, workspaceConcurrency: 1, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }, ['/build:.*/']) const { default: outputsA } = await import(path.resolve('output-a.json')) @@ -704,11 +635,6 @@ test('pnpm run with slightly incorrect command suggests correct one', async () = extraEnv: {}, rawConfig: {}, workspaceConcurrency: 1, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }, ['buil'])).rejects.toEqual(expect.objectContaining({ code: 'ERR_PNPM_NO_SCRIPT', hint: 'Command "buil" not found. Did you mean "pnpm run build"?', diff --git a/lockfile/filter-lockfile/src/filterLockfileByImportersAndEngine.ts b/lockfile/filter-lockfile/src/filterLockfileByImportersAndEngine.ts index 38d6d00ad6b..d9d1bda0625 100644 --- a/lockfile/filter-lockfile/src/filterLockfileByImportersAndEngine.ts +++ b/lockfile/filter-lockfile/src/filterLockfileByImportersAndEngine.ts @@ -30,7 +30,7 @@ export function filterLockfileByImportersAndEngine ( failOnMissingDependencies: boolean lockfileDir: string skipped: Set - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } ): { lockfile: Lockfile, selectedImporterIds: string[] } { const importerIdSet = new Set(importerIds) as Set @@ -91,7 +91,7 @@ function pickPkgsWithAllDeps ( includeIncompatiblePackages: boolean lockfileDir: string skipped: Set - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } ) { const pickedPackages = {} as PackageSnapshots @@ -118,7 +118,7 @@ function pkgAllDeps ( includeIncompatiblePackages: boolean lockfileDir: string skipped: Set - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } ) { for (const depPath of depPaths) { diff --git a/patching/plugin-commands-patching/src/patch.ts b/patching/plugin-commands-patching/src/patch.ts index b7242c18a4f..484911d738c 100644 --- a/patching/plugin-commands-patching/src/patch.ts +++ b/patching/plugin-commands-patching/src/patch.ts @@ -59,8 +59,9 @@ export type PatchCommandOptions = Pick & CreateStoreControllerOptions & { +> +& Partial> +& CreateStoreControllerOptions & { editDir?: string reporter?: (logObj: LogBase) => void ignoreExisting?: boolean diff --git a/patching/plugin-commands-patching/src/patchCommit.ts b/patching/plugin-commands-patching/src/patchCommit.ts index cd09d2bb1a3..bdf38cd68e4 100644 --- a/patching/plugin-commands-patching/src/patchCommit.ts +++ b/patching/plugin-commands-patching/src/patchCommit.ts @@ -42,7 +42,7 @@ export function help () { }) } -export async function handler (opts: install.InstallCommandOptions & Pick, params: string[]) { +export async function handler (opts: install.InstallCommandOptions & Pick, params: string[]) { const userDir = params[0] const lockfileDir = opts.lockfileDir ?? opts.dir ?? process.cwd() const patchesDirName = normalizePath(path.normalize(opts.patchesDir ?? 'patches')) diff --git a/patching/plugin-commands-patching/src/writePackage.ts b/patching/plugin-commands-patching/src/writePackage.ts index 6738be5ffeb..7e54dcc23b1 100644 --- a/patching/plugin-commands-patching/src/writePackage.ts +++ b/patching/plugin-commands-patching/src/writePackage.ts @@ -6,7 +6,7 @@ import { import { pickRegistryForPackage } from '@pnpm/pick-registry-for-package' import type { ParseWantedDependencyResult } from '@pnpm/parse-wanted-dependency' -export type WritePackageOptions = CreateStoreControllerOptions & Pick +export type WritePackageOptions = CreateStoreControllerOptions & Pick export async function writePackage (dep: ParseWantedDependencyResult, dest: string, opts: WritePackageOptions) { const store = await createOrConnectStoreController({ diff --git a/pkg-manager/core/src/getPeerDependencyIssues.ts b/pkg-manager/core/src/getPeerDependencyIssues.ts index e42d053cb8a..2daa8e4d00b 100644 --- a/pkg-manager/core/src/getPeerDependencyIssues.ts +++ b/pkg-manager/core/src/getPeerDependencyIssues.ts @@ -19,8 +19,8 @@ export type ListMissingPeersOptions = Partial | 'storeController' | 'useGitBranchLockfile' | 'workspacePackages' -| 'supportedArchitectures' > +& Partial> & Pick export async function getPeerDependencyIssues ( diff --git a/pkg-manager/core/src/install/extendInstallOptions.ts b/pkg-manager/core/src/install/extendInstallOptions.ts index 8bdc43fc54d..aaca95f6707 100644 --- a/pkg-manager/core/src/install/extendInstallOptions.ts +++ b/pkg-manager/core/src/install/extendInstallOptions.ts @@ -138,12 +138,12 @@ export interface StrictInstallOptions { */ disableRelinkLocalDirDeps: boolean - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } export type InstallOptions = & Partial - & Pick + & Pick const defaults = (opts: InstallOptions) => { const packageManager = opts.packageManager ?? { diff --git a/pkg-manager/headless/src/index.ts b/pkg-manager/headless/src/index.ts index df584832676..c8e33b4d24f 100644 --- a/pkg-manager/headless/src/index.ts +++ b/pkg-manager/headless/src/index.ts @@ -159,7 +159,7 @@ export interface HeadlessOptions { nodeLinker?: 'isolated' | 'hoisted' | 'pnp' useGitBranchLockfile?: boolean useLockfile?: boolean - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } export interface InstallationResultStats { diff --git a/pkg-manager/headless/src/lockfileToHoistedDepGraph.ts b/pkg-manager/headless/src/lockfileToHoistedDepGraph.ts index 1325b4405c0..e7c10f20c22 100644 --- a/pkg-manager/headless/src/lockfileToHoistedDepGraph.ts +++ b/pkg-manager/headless/src/lockfileToHoistedDepGraph.ts @@ -47,7 +47,7 @@ export interface LockfileToHoistedDepGraphOptions { storeController: StoreController storeDir: string virtualStoreDir: string - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } export async function lockfileToHoistedDepGraph ( diff --git a/pkg-manager/package-requester/test/index.ts b/pkg-manager/package-requester/test/index.ts index 030caa8fb12..0ff9a425920 100644 --- a/pkg-manager/package-requester/test/index.ts +++ b/pkg-manager/package-requester/test/index.ts @@ -49,11 +49,7 @@ test('request package', async () => { preferredVersions: {}, projectDir, registry, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }) expect(pkgResponse).toBeTruthy() @@ -97,11 +93,7 @@ test('request package but skip fetching', async () => { projectDir, registry, skipFetch: true, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }) expect(pkgResponse).toBeTruthy() @@ -151,11 +143,7 @@ test('request package but skip fetching, when resolution is already available', registry, skipFetch: true, update: false, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }) as PackageResponse & { body: { latest: string @@ -316,11 +304,7 @@ test('refetch local tarball if its integrity has changed. The requester does not projectDir, registry, update: false, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + } { @@ -816,11 +800,7 @@ test('do not fetch an optional package that is not installable', async () => { preferredVersions: {}, projectDir, registry, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }) expect(pkgResponse).toBeTruthy() @@ -1059,11 +1039,7 @@ test("don't throw an error if the package was updated, so the expectedPkg has a name: 'is-positive', version: '3.0.0', }, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }) await expect(pkgResponse.fetching!()).resolves.toStrictEqual(expect.anything()) }) @@ -1087,11 +1063,7 @@ test('the version in the bundled manifest should be normalized', async () => { preferredVersions: {}, projectDir: tempy.directory(), registry, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }) expect((await pkgResponse.fetching!()).bundledManifest).toStrictEqual(expect.objectContaining({ version: '1.2.1', diff --git a/pkg-manager/plugin-commands-installation/src/fetch.ts b/pkg-manager/plugin-commands-installation/src/fetch.ts index b0eb0554dc7..b58671c15a8 100644 --- a/pkg-manager/plugin-commands-installation/src/fetch.ts +++ b/pkg-manager/plugin-commands-installation/src/fetch.ts @@ -45,7 +45,7 @@ export function help () { } export async function handler ( - opts: Pick & CreateStoreControllerOptions + opts: Pick & CreateStoreControllerOptions ) { const store = await createOrConnectStoreController(opts) const include = { diff --git a/pkg-manager/plugin-commands-installation/src/install.ts b/pkg-manager/plugin-commands-installation/src/install.ts index 173eb8ab61f..e29b3293c48 100644 --- a/pkg-manager/plugin-commands-installation/src/install.ts +++ b/pkg-manager/plugin-commands-installation/src/install.ts @@ -295,7 +295,6 @@ export type InstallCommandOptions = Pick & CreateStoreControllerOptions & { argv: { original: string[] @@ -310,7 +309,7 @@ export type InstallCommandOptions = Pick> +} & Partial> export async function handler ( opts: InstallCommandOptions diff --git a/pkg-manager/plugin-commands-installation/src/installDeps.ts b/pkg-manager/plugin-commands-installation/src/installDeps.ts index a9d1b94d7f5..754e8286d39 100644 --- a/pkg-manager/plugin-commands-installation/src/installDeps.ts +++ b/pkg-manager/plugin-commands-installation/src/installDeps.ts @@ -83,7 +83,6 @@ export type InstallDepsOptions = Pick & CreateStoreControllerOptions & { argv: { original: string[] diff --git a/pkg-manager/plugin-commands-installation/src/link.ts b/pkg-manager/plugin-commands-installation/src/link.ts index 98968c0db13..1018d909411 100644 --- a/pkg-manager/plugin-commands-installation/src/link.ts +++ b/pkg-manager/plugin-commands-installation/src/link.ts @@ -44,8 +44,7 @@ type LinkOpts = CreateStoreControllerOptions & Pick & Partial> +> & Partial> export const rcOptionsTypes = cliOptionsTypes diff --git a/pkg-manager/plugin-commands-installation/src/recursive.ts b/pkg-manager/plugin-commands-installation/src/recursive.ts index 19efbcf7683..3c111ecd853 100755 --- a/pkg-manager/plugin-commands-installation/src/recursive.ts +++ b/pkg-manager/plugin-commands-installation/src/recursive.ts @@ -70,7 +70,6 @@ type RecursiveOptions = CreateStoreControllerOptions & Pick & { include?: IncludedDependencies includeDirect?: IncludedDependencies @@ -93,6 +92,7 @@ type RecursiveOptions = CreateStoreControllerOptions & Pick > & Required< Pick diff --git a/pkg-manager/plugin-commands-installation/src/remove.ts b/pkg-manager/plugin-commands-installation/src/remove.ts index 12fd6a34c07..14dee07071c 100644 --- a/pkg-manager/plugin-commands-installation/src/remove.ts +++ b/pkg-manager/plugin-commands-installation/src/remove.ts @@ -149,7 +149,6 @@ export async function handler ( | 'selectedProjectsGraph' | 'workspaceDir' | 'sharedWorkspaceLockfile' - | 'supportedArchitectures' > & { recursive?: boolean }, diff --git a/pkg-manager/plugin-commands-installation/src/unlink.ts b/pkg-manager/plugin-commands-installation/src/unlink.ts index c47c20404e3..87b4056e980 100644 --- a/pkg-manager/plugin-commands-installation/src/unlink.ts +++ b/pkg-manager/plugin-commands-installation/src/unlink.ts @@ -57,7 +57,6 @@ export async function handler ( | 'rootProjectManifestDir' | 'pnpmfile' | 'workspaceDir' - | 'supportedArchitectures' > & { recursive?: boolean }, diff --git a/pkg-manager/resolve-dependencies/src/resolveDependencies.ts b/pkg-manager/resolve-dependencies/src/resolveDependencies.ts index 92b2f9ae635..6d6267b98f8 100644 --- a/pkg-manager/resolve-dependencies/src/resolveDependencies.ts +++ b/pkg-manager/resolve-dependencies/src/resolveDependencies.ts @@ -254,7 +254,7 @@ interface ResolvedDependenciesOptions { updateMatching?: UpdateMatchingFunction updateDepth: number prefix: string - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } interface PostponedResolutionOpts { @@ -768,7 +768,7 @@ async function resolveChildren ( updateDepth: number prefix: string updateMatching?: UpdateMatchingFunction - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures }, { parentPkgAliases, @@ -1018,7 +1018,7 @@ interface ResolveDependencyOptions { update: boolean updateDepth: number updateMatching?: UpdateMatchingFunction - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } type ResolveDependencyResult = PkgAddress | LinkedDependency | null diff --git a/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts b/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts index b5e3093b374..3981c52d134 100644 --- a/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts +++ b/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts @@ -88,7 +88,7 @@ export interface ResolveDependenciesOptions { virtualStoreDir: string wantedLockfile: Lockfile workspacePackages: WorkspacePackages - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } export async function resolveDependencyTree ( diff --git a/releasing/plugin-commands-publishing/src/pack.ts b/releasing/plugin-commands-publishing/src/pack.ts index 0127f1c87c4..ef0004edc52 100644 --- a/releasing/plugin-commands-publishing/src/pack.ts +++ b/releasing/plugin-commands-publishing/src/pack.ts @@ -58,7 +58,7 @@ export function help () { } export async function handler ( - opts: Pick & Pick & Partial> & { + opts: Pick & Pick & Partial> & { argv: { original: string[] } @@ -146,11 +146,7 @@ async function packPkg (opts: { embedReadme, } = opts const { manifest } = await readProjectManifest(projectDir, { - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }) const bins = [ ...(await getBinsFromPackageManifest(manifest as DependencyManifest, projectDir)).map(({ path }) => path), diff --git a/releasing/plugin-commands-publishing/src/publish.ts b/releasing/plugin-commands-publishing/src/publish.ts index 486cff19234..2a600e61ab8 100644 --- a/releasing/plugin-commands-publishing/src/publish.ts +++ b/releasing/plugin-commands-publishing/src/publish.ts @@ -118,7 +118,7 @@ export async function handler ( engineStrict?: boolean recursive?: boolean workspaceDir?: string - } & Pick, + } & Pick, params: string[] ) { const result = await publish(opts, params) @@ -134,7 +134,7 @@ export async function publish ( engineStrict?: boolean recursive?: boolean workspaceDir?: string - } & Pick, + } & Pick, params: string[] ) { if (opts.gitChecks !== false && await isGitRepo()) { diff --git a/releasing/plugin-commands-publishing/src/recursivePublish.ts b/releasing/plugin-commands-publishing/src/recursivePublish.ts index 0d7143437c8..ec5f5e58bb4 100644 --- a/releasing/plugin-commands-publishing/src/recursivePublish.ts +++ b/releasing/plugin-commands-publishing/src/recursivePublish.ts @@ -46,6 +46,7 @@ Partial> & { access?: 'public' | 'restricted' argv: { @@ -55,7 +56,7 @@ Partial> + opts: PublishRecursiveOpts & Required> ): Promise<{ exitCode: number }> { const pkgs = Object.values(opts.selectedProjectsGraph).map((wsPkg) => wsPkg.package) const resolve = createResolver({ diff --git a/reviewing/license-scanner/src/licenses.ts b/reviewing/license-scanner/src/licenses.ts index aa12318683a..33ff4a63944 100644 --- a/reviewing/license-scanner/src/licenses.ts +++ b/reviewing/license-scanner/src/licenses.ts @@ -75,7 +75,7 @@ export async function findDependencyLicenses (opts: { registries: Registries wantedLockfile: Lockfile | null includedImporterIds?: string[] - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures }): Promise { if (opts.wantedLockfile == null) { throw new PnpmError( diff --git a/reviewing/license-scanner/src/lockfileToLicenseNodeTree.ts b/reviewing/license-scanner/src/lockfileToLicenseNodeTree.ts index af8e3cb59a5..642a0c7165d 100644 --- a/reviewing/license-scanner/src/lockfileToLicenseNodeTree.ts +++ b/reviewing/license-scanner/src/lockfileToLicenseNodeTree.ts @@ -36,7 +36,7 @@ export interface LicenseExtractOptions { modulesDir?: string dir: string registries: Registries - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } export async function lockfileToLicenseNode ( diff --git a/reviewing/plugin-commands-licenses/src/licensesList.ts b/reviewing/plugin-commands-licenses/src/licensesList.ts index d9096f5b03b..d67430b8a0b 100644 --- a/reviewing/plugin-commands-licenses/src/licensesList.ts +++ b/reviewing/plugin-commands-licenses/src/licensesList.ts @@ -25,9 +25,8 @@ Config, | 'modulesDir' | 'pnpmHomeDir' | 'selectedProjectsGraph' -| 'supportedArchitectures' > & -Partial> +Partial> export async function licensesList (opts: LicensesCommandOptions) { const lockfile = await readWantedLockfile(opts.lockfileDir ?? opts.dir, { @@ -47,11 +46,7 @@ export async function licensesList (opts: LicensesCommandOptions) { } const manifest = await readProjectManifestOnly(opts.dir, { - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, + }) const includedImporterIds = opts.selectedProjectsGraph diff --git a/reviewing/plugin-commands-outdated/src/outdated.ts b/reviewing/plugin-commands-outdated/src/outdated.ts index a2a9fcd52bf..560fd975200 100644 --- a/reviewing/plugin-commands-outdated/src/outdated.ts +++ b/reviewing/plugin-commands-outdated/src/outdated.ts @@ -156,8 +156,7 @@ export type OutdatedCommandOptions = { | 'strictSsl' | 'tag' | 'userAgent' -| 'supportedArchitectures' -> & Partial> +> & Partial> export async function handler ( opts: OutdatedCommandOptions, diff --git a/store/plugin-commands-store/src/store.ts b/store/plugin-commands-store/src/store.ts index 1a9b2d2c2ed..d7d4c8a27a9 100644 --- a/store/plugin-commands-store/src/store.ts +++ b/store/plugin-commands-store/src/store.ts @@ -67,7 +67,7 @@ class StoreStatusError extends PnpmError { } } -export type StoreCommandOptions = Pick & CreateStoreControllerOptions & { +export type StoreCommandOptions = Pick & CreateStoreControllerOptions & { reporter?: (logObj: LogBase) => void } diff --git a/store/plugin-commands-store/src/storeAdd.ts b/store/plugin-commands-store/src/storeAdd.ts index d9b5c99c5ea..0cfc80aa220 100644 --- a/store/plugin-commands-store/src/storeAdd.ts +++ b/store/plugin-commands-store/src/storeAdd.ts @@ -14,7 +14,7 @@ export async function storeAdd ( reporter?: ReporterFunction storeController: StoreController tag?: string - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } ) { const reporter = opts?.reporter diff --git a/store/store-connection-manager/src/index.ts b/store/store-connection-manager/src/index.ts index fd9194a8481..3332cdb38ec 100644 --- a/store/store-connection-manager/src/index.ts +++ b/store/store-connection-manager/src/index.ts @@ -21,7 +21,7 @@ export type CreateStoreControllerOptions = Omit +> & Partial> export async function createOrConnectStoreControllerCached ( storeControllerCache: Map>, diff --git a/store/store-controller-types/src/index.ts b/store/store-controller-types/src/index.ts index 9b2d5f29b29..8de9fa5f72d 100644 --- a/store/store-controller-types/src/index.ts +++ b/store/store-controller-types/src/index.ts @@ -129,7 +129,7 @@ export interface RequestPackageOptions { update?: boolean workspacePackages?: WorkspacePackages forceResolve?: boolean - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } export type BundledManifestFunction = () => Promise diff --git a/workspace/filter-workspace-packages/src/index.ts b/workspace/filter-workspace-packages/src/index.ts index d3ad59dba7e..95c7db0a4fe 100644 --- a/workspace/filter-workspace-packages/src/index.ts +++ b/workspace/filter-workspace-packages/src/index.ts @@ -43,7 +43,7 @@ export async function readProjects ( engineStrict?: boolean linkWorkspacePackages?: boolean changedFilesIgnorePattern?: string[] - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } ): Promise { const allProjects = await findWorkspacePackages(workspaceDir, { engineStrict: opts?.engineStrict, supportedArchitectures: opts?.supportedArchitectures ?? { os: ['current'], cpu: ['current'], libc: ['current'] } }) @@ -76,7 +76,7 @@ export async function filterPackagesFromDir ( engineStrict?: boolean nodeVersion?: string patterns: string[] - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } ) { const allProjects = await findWorkspacePackages(workspaceDir, { diff --git a/workspace/find-packages/src/index.ts b/workspace/find-packages/src/index.ts index 2b4f6694600..e9962c131e7 100644 --- a/workspace/find-packages/src/index.ts +++ b/workspace/find-packages/src/index.ts @@ -16,7 +16,7 @@ export async function findWorkspacePackages ( nodeVersion?: string patterns?: string[] sharedWorkspaceLockfile?: boolean - supportedArchitectures: SupportedArchitectures + supportedArchitectures?: SupportedArchitectures } ): Promise { const pkgs = await findWorkspacePackagesNoCheck(workspaceRoot, opts) From ff84b6f83a45ccbeacf16bf6d31072bc3b13ba1d Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Wed, 18 Oct 2023 17:17:11 +0200 Subject: [PATCH 11/39] style: format code --- cli/cli-utils/src/readProjectManifest.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cli/cli-utils/src/readProjectManifest.ts b/cli/cli-utils/src/readProjectManifest.ts index 068f20fc8cb..595d488ab40 100644 --- a/cli/cli-utils/src/readProjectManifest.ts +++ b/cli/cli-utils/src/readProjectManifest.ts @@ -25,12 +25,9 @@ export async function readProjectManifestOnly ( engineStrict?: boolean nodeVersion?: string supportedArchitectures?: SupportedArchitectures - } = { - - } + } = {} ): Promise { const manifest = await utils.readProjectManifestOnly(projectDir) - packageIsInstallable(projectDir, manifest as any, opts) // eslint-disable-line @typescript-eslint/no-explicit-any return manifest } From 1c27f8bbe8e9838860692ee90e39c2005198df1d Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Wed, 18 Oct 2023 17:17:29 +0200 Subject: [PATCH 12/39] refactor: rename `dedupeCurrent` function --- config/package-is-installable/src/checkPlatform.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/package-is-installable/src/checkPlatform.ts b/config/package-is-installable/src/checkPlatform.ts index 0bdf35ac16f..2a14bca94b5 100644 --- a/config/package-is-installable/src/checkPlatform.ts +++ b/config/package-is-installable/src/checkPlatform.ts @@ -21,9 +21,9 @@ export function checkPlatform ( supportedArchitectures?: SupportedArchitectures ) { const platforms = { - os: dedupeArchs(process.platform, supportedArchitectures?.os ?? ['current']), - cpu: dedupeArchs(process.arch, supportedArchitectures?.cpu ?? ['current']), - libc: dedupeArchs(currentLibc, supportedArchitectures?.libc ?? ['current']), + os: dedupeCurrent(process.platform, supportedArchitectures?.os ?? ['current']), + cpu: dedupeCurrent(process.arch, supportedArchitectures?.cpu ?? ['current']), + libc: dedupeCurrent(currentLibc, supportedArchitectures?.libc ?? ['current']), } const { platform, arch } = process @@ -85,7 +85,7 @@ function checkList (value: string | string[], list: string | string[]): boolean return match || blc === list.length } -function dedupeArchs (current: string, supported: string[]) { +function dedupeCurrent (current: string, supported: string[]) { const result = supported.filter((arch) => arch !== 'current') if (supported.includes('current')) { From e9d97a54075b71fdce9877124c17d9652f685cad Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Wed, 18 Oct 2023 17:20:27 +0200 Subject: [PATCH 13/39] perf: improve `dedupeCurrent` function --- config/package-is-installable/src/checkPlatform.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/config/package-is-installable/src/checkPlatform.ts b/config/package-is-installable/src/checkPlatform.ts index 2a14bca94b5..013a9fc0e0a 100644 --- a/config/package-is-installable/src/checkPlatform.ts +++ b/config/package-is-installable/src/checkPlatform.ts @@ -86,11 +86,5 @@ function checkList (value: string | string[], list: string | string[]): boolean } function dedupeCurrent (current: string, supported: string[]) { - const result = supported.filter((arch) => arch !== 'current') - - if (supported.includes('current')) { - result.push(current) - } - - return result + return supported.map((supported) => supported === 'current' ? current : supported) } \ No newline at end of file From bd758d09d6275bfc7b3d8553c5918f2635ca6ebe Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Wed, 18 Oct 2023 17:21:41 +0200 Subject: [PATCH 14/39] style: format code --- exec/plugin-commands-script-runners/test/index.ts | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/exec/plugin-commands-script-runners/test/index.ts b/exec/plugin-commands-script-runners/test/index.ts index a261213ede0..26c50cfd6df 100644 --- a/exec/plugin-commands-script-runners/test/index.ts +++ b/exec/plugin-commands-script-runners/test/index.ts @@ -29,7 +29,6 @@ test('pnpm run: returns correct exit code', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, - }, ['exit0']) let err!: Error & { errno: number } @@ -66,7 +65,6 @@ test('pnpm run --no-bail never fails', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, - }, ['exit1']) const { default: args } = await import(path.resolve('args.json')) @@ -91,7 +89,6 @@ test('run: pass the args to the command that is specified in the build script', extraBinPaths: [], extraEnv: {}, rawConfig: {}, - }, ['foo', 'arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -114,7 +111,6 @@ test('run: pass the args to the command that is specified in the build script of extraBinPaths: [], extraEnv: {}, rawConfig: {}, - }, ['foo', 'arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -137,7 +133,6 @@ test('test: pass the args to the command that is specified in the build script o extraBinPaths: [], extraEnv: {}, rawConfig: {}, - }, ['arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -160,7 +155,6 @@ test('run start: pass the args to the command that is specified in the build scr extraBinPaths: [], extraEnv: {}, rawConfig: {}, - }, ['start', 'arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -183,7 +177,6 @@ test('run stop: pass the args to the command that is specified in the build scri extraBinPaths: [], extraEnv: {}, rawConfig: {}, - }, ['stop', 'arg', '--flag=true', '--help', '-h']) const { default: args } = await import(path.resolve('args.json')) @@ -213,7 +206,6 @@ test('restart: run stop, restart and start', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, - }, []) const { default: scriptsRan } = await import(path.resolve('output.json')) @@ -248,7 +240,6 @@ test('restart: run stop, restart and start and all the pre/post scripts', async extraBinPaths: [], extraEnv: {}, rawConfig: {}, - }, []) const { default: scriptsRan } = await import(path.resolve('output.json')) @@ -278,7 +269,6 @@ test('"pnpm run" prints the list of available commands', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, - }, []) expect(output).toBe(`\ @@ -389,7 +379,6 @@ test('pnpm run does not fail with --if-present even if the wanted script is not extraEnv: {}, ifPresent: true, rawConfig: {}, - }, ['build']) }) @@ -458,7 +447,6 @@ test('scripts work with PnP', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, - }, ['foo']) const { default: scriptsRan } = await import(path.resolve('output.json')) @@ -513,7 +501,6 @@ test('pnpm run with RegExp script selector should work', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, - }, ['/^(lint|build):.*/']) expect(await fs.readFile('output-build-a.txt', { encoding: 'utf-8' })).toEqual('a') @@ -561,7 +548,6 @@ test('pnpm run with RegExp script selector should work parallel as a default beh extraBinPaths: [], extraEnv: {}, rawConfig: {}, - }, ['/build:.*/']) const { default: outputsA } = await import(path.resolve('output-a.json')) From 745bc80610966f42726a8e998821ca4d60e1f72a Mon Sep 17 00:00:00 2001 From: Ignacio Aldama Vicente Date: Wed, 18 Oct 2023 17:36:39 +0200 Subject: [PATCH 15/39] test: add tests for `checkPlatform` --- .../test/checkPlatform.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/config/package-is-installable/test/checkPlatform.ts b/config/package-is-installable/test/checkPlatform.ts index 47a38bf2fa8..dc34e9a8e9b 100644 --- a/config/package-is-installable/test/checkPlatform.ts +++ b/config/package-is-installable/test/checkPlatform.ts @@ -115,3 +115,45 @@ test('nothing wrong (negation)', () => { libc: ['current'], })).toBe(null) }) + +test('override OS', () => { + expect(checkPlatform(packageId, { cpu: 'any', os: 'win32', libc: 'any' }, { + os: ['win32'], + cpu: ['current'], + libc: ['current'], + })).toBe(null) +}) + +test('accept another CPU', () => { + expect(checkPlatform(packageId, { cpu: 'x64', os: 'any', libc: 'any' }, { + os: ['current'], + cpu: ['current', 'x64'], + libc: ['current'], + })).toBe(null) +}) + +test('fail when CPU is different', () => { + const err = checkPlatform(packageId, { cpu: 'x64', os: 'any', libc: 'any' }, { + os: ['current'], + cpu: ['arm64'], + libc: ['current'], + }) + expect(err).toBeTruthy() + expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') +}) + +test('override libc', () => { + expect(checkPlatform(packageId, { cpu: 'any', os: 'any', libc: 'glibc' }, { + os: ['current'], + cpu: ['current'], + libc: ['glibc'], + })).toBe(null) +}) + +test('accept another libc', () => { + expect(checkPlatform(packageId, { cpu: 'any', os: 'any', libc: 'glibc' }, { + os: ['current'], + cpu: ['current'], + libc: ['current', 'glibc'], + })).toBe(null) +}) \ No newline at end of file From 9f31bfb69a7442d0af0946839368633f604c9a35 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sat, 21 Oct 2023 15:19:24 +0300 Subject: [PATCH 16/39] test: updating optional deps --- __utils__/assert-project/package.json | 2 +- __utils__/assert-store/package.json | 2 +- exec/plugin-commands-rebuild/package.json | 4 +- .../package.json | 2 +- package.json | 2 +- .../plugin-commands-patching/package.json | 2 +- pkg-manager/core/package.json | 4 +- .../core/test/install/optionalDependencies.ts | 14 +++- pkg-manager/headless/package.json | 2 +- pkg-manager/package-requester/package.json | 2 +- .../plugin-commands-installation/package.json | 2 +- pnpm-lock.yaml | 84 ++++++++++--------- pnpm/package.json | 2 +- releasing/plugin-commands-deploy/package.json | 2 +- .../plugin-commands-publishing/package.json | 2 +- .../plugin-commands-licenses/package.json | 2 +- .../plugin-commands-listing/package.json | 2 +- .../plugin-commands-outdated/package.json | 2 +- store/plugin-commands-store/package.json | 2 +- 19 files changed, 76 insertions(+), 60 deletions(-) diff --git a/__utils__/assert-project/package.json b/__utils__/assert-project/package.json index 17d7645884a..d485d9d4425 100644 --- a/__utils__/assert-project/package.json +++ b/__utils__/assert-project/package.json @@ -44,7 +44,7 @@ "@pnpm/constants": "workspace:*", "@pnpm/lockfile-types": "workspace:*", "@pnpm/modules-yaml": "workspace:*", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@pnpm/types": "workspace:*", "is-windows": "^1.0.2", "isexe": "2.0.0", diff --git a/__utils__/assert-store/package.json b/__utils__/assert-store/package.json index 99b4feed132..da56b42ae85 100644 --- a/__utils__/assert-store/package.json +++ b/__utils__/assert-store/package.json @@ -40,7 +40,7 @@ "test": "pnpm pretest && pnpm run compile && jest" }, "dependencies": { - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@pnpm/store.cafs": "workspace:*", "path-exists": "^4.0.0" }, diff --git a/exec/plugin-commands-rebuild/package.json b/exec/plugin-commands-rebuild/package.json index 16cb1a65831..f8587d3b214 100644 --- a/exec/plugin-commands-rebuild/package.json +++ b/exec/plugin-commands-rebuild/package.json @@ -34,7 +34,7 @@ "@pnpm/filter-workspace-packages": "workspace:*", "@pnpm/plugin-commands-rebuild": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@pnpm/test-fixtures": "workspace:*", "@types/ramda": "0.28.20", "@types/semver": "7.5.3", @@ -53,10 +53,10 @@ "@pnpm/constants": "workspace:*", "@pnpm/core-loggers": "workspace:*", "@pnpm/dependency-path": "workspace:*", + "@pnpm/deps.graph-sequencer": "workspace:*", "@pnpm/error": "workspace:*", "@pnpm/fs.hard-link-dir": "workspace:*", "@pnpm/get-context": "workspace:*", - "@pnpm/deps.graph-sequencer": "workspace:*", "@pnpm/lifecycle": "workspace:*", "@pnpm/link-bins": "workspace:*", "@pnpm/lockfile-types": "workspace:*", diff --git a/exec/plugin-commands-script-runners/package.json b/exec/plugin-commands-script-runners/package.json index 6b2097eac25..34602dbfa6c 100644 --- a/exec/plugin-commands-script-runners/package.json +++ b/exec/plugin-commands-script-runners/package.json @@ -34,7 +34,7 @@ "@pnpm/filter-workspace-packages": "workspace:*", "@pnpm/plugin-commands-script-runners": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@types/is-windows": "^1.0.0", "@types/ramda": "0.28.20", "@types/which": "^2.0.2", diff --git a/package.json b/package.json index e3bcbd7d7b2..7dfdaf0753a 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "@commitlint/prompt-cli": "^17.8.0", "@pnpm/eslint-config": "workspace:*", "@pnpm/meta-updater": "1.0.0", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@pnpm/tsconfig": "workspace:*", "@pnpm/worker": "workspace:*", "@types/jest": "^29.5.5", diff --git a/patching/plugin-commands-patching/package.json b/patching/plugin-commands-patching/package.json index 014f2c37acc..81528889d07 100644 --- a/patching/plugin-commands-patching/package.json +++ b/patching/plugin-commands-patching/package.json @@ -34,7 +34,7 @@ "@pnpm/filter-workspace-packages": "workspace:*", "@pnpm/plugin-commands-patching": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@pnpm/test-fixtures": "workspace:*", "@types/normalize-path": "^3.0.0", "@types/npm-packlist": "^3.0.0", diff --git a/pkg-manager/core/package.json b/pkg-manager/core/package.json index c26ae1e0401..bc315d86145 100644 --- a/pkg-manager/core/package.json +++ b/pkg-manager/core/package.json @@ -23,10 +23,10 @@ "@pnpm/core-loggers": "workspace:*", "@pnpm/crypto.base32-hash": "workspace:*", "@pnpm/dependency-path": "workspace:*", + "@pnpm/deps.graph-sequencer": "workspace:*", "@pnpm/error": "workspace:*", "@pnpm/filter-lockfile": "workspace:*", "@pnpm/get-context": "workspace:*", - "@pnpm/deps.graph-sequencer": "workspace:*", "@pnpm/headless": "workspace:*", "@pnpm/hoist": "workspace:*", "@pnpm/hooks.read-package-hook": "workspace:*", @@ -81,7 +81,7 @@ "@pnpm/lockfile-types": "workspace:*", "@pnpm/package-store": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@pnpm/store-path": "workspace:*", "@pnpm/store.cafs": "workspace:*", "@pnpm/test-fixtures": "workspace:*", diff --git a/pkg-manager/core/test/install/optionalDependencies.ts b/pkg-manager/core/test/install/optionalDependencies.ts index 97d12317c76..98dbcf8d4cc 100644 --- a/pkg-manager/core/test/install/optionalDependencies.ts +++ b/pkg-manager/core/test/install/optionalDependencies.ts @@ -2,6 +2,7 @@ import path from 'path' import { type Lockfile } from '@pnpm/lockfile-file' import { prepareEmpty, preparePackages } from '@pnpm/prepare' import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' +import deepRequireCwd from 'deep-require-cwd' import readYamlFile from 'read-yaml-file' import { addDependenciesToPackage, @@ -13,7 +14,6 @@ import { import rimraf from '@zkochan/rimraf' import exists from 'path-exists' import sinon from 'sinon' -import deepRequireCwd from 'deep-require-cwd' import { testDefaults } from '../utils' test('successfully install optional dependency with subdependencies', async () => { @@ -575,3 +575,15 @@ test('fail on a package with failing postinstall if the package is both an optio ) ).rejects.toThrow() }) + +test('install optional dependency for the supported architecture set by the user', async () => { + prepareEmpty() + + const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-many-optional-deps@1.0.0'], await testDefaults({ supportedArchitectures: { os: ['darwin'], cpu: ['arm64'] } })) + + expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-arm64', './package.json']).version).toBe('1.0.0') + + await install(manifest, await testDefaults({ supportedArchitectures: { os: ['darwin'], cpu: ['x64'] } })) + + expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-x64', './package.json']).version).toBe('1.0.0') +}) diff --git a/pkg-manager/headless/package.json b/pkg-manager/headless/package.json index 9cc174c1da8..2547e3fdb1f 100644 --- a/pkg-manager/headless/package.json +++ b/pkg-manager/headless/package.json @@ -22,7 +22,7 @@ "@pnpm/package-store": "workspace:*", "@pnpm/prepare": "workspace:*", "@pnpm/read-projects-context": "workspace:*", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@pnpm/store-path": "workspace:*", "@pnpm/store.cafs": "workspace:*", "@pnpm/test-fixtures": "workspace:*", diff --git a/pkg-manager/package-requester/package.json b/pkg-manager/package-requester/package.json index 38731650179..3ba9ba1b058 100644 --- a/pkg-manager/package-requester/package.json +++ b/pkg-manager/package-requester/package.json @@ -61,7 +61,7 @@ "@pnpm/client": "workspace:*", "@pnpm/create-cafs-store": "workspace:*", "@pnpm/package-requester": "workspace:*", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@pnpm/test-fixtures": "workspace:*", "@types/normalize-path": "^3.0.0", "@types/ramda": "0.28.20", diff --git a/pkg-manager/plugin-commands-installation/package.json b/pkg-manager/plugin-commands-installation/package.json index fd36093d03a..7c40c53848d 100644 --- a/pkg-manager/plugin-commands-installation/package.json +++ b/pkg-manager/plugin-commands-installation/package.json @@ -34,7 +34,7 @@ "@pnpm/modules-yaml": "workspace:*", "@pnpm/plugin-commands-installation": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@pnpm/test-fixtures": "workspace:*", "@types/proxyquire": "^1.3.29", "@types/ramda": "0.28.20", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 393fb8bc189..0818894681d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -109,8 +109,8 @@ importers: specifier: 1.0.0 version: 1.0.0 '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@pnpm/tsconfig': specifier: workspace:* version: link:__utils__/tsconfig @@ -224,8 +224,8 @@ importers: specifier: workspace:* version: link:../../pkg-manager/modules-yaml '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@pnpm/types': specifier: workspace:* version: link:../../packages/types @@ -261,8 +261,8 @@ importers: __utils__/assert-store: dependencies: '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@pnpm/store.cafs': specifier: workspace:* version: link:../../store/cafs @@ -1280,8 +1280,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -1395,8 +1395,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@types/is-windows': specifier: ^1.0.0 version: 1.0.0 @@ -2808,8 +2808,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -3068,8 +3068,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@pnpm/store-path': specifier: workspace:* version: link:../../store/store-path @@ -3344,8 +3344,8 @@ importers: specifier: workspace:* version: link:../read-projects-context '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@pnpm/store-path': specifier: workspace:* version: link:../../store/store-path @@ -3698,8 +3698,8 @@ importers: specifier: workspace:* version: 'link:' '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -3891,8 +3891,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -4439,8 +4439,8 @@ importers: specifier: workspace:* version: link:../pkg-manifest/read-project-manifest '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@pnpm/run-npm': specifier: workspace:* version: link:../exec/run-npm @@ -4693,8 +4693,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) releasing/plugin-commands-publishing: dependencies: @@ -4790,8 +4790,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@types/cross-spawn': specifier: ^6.0.3 version: 6.0.3 @@ -5338,8 +5338,8 @@ importers: specifier: workspace:* version: link:../../pkg-manifest/read-package-json '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -5402,8 +5402,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@types/ramda': specifier: 0.28.20 version: 0.28.20 @@ -5496,8 +5496,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -5825,8 +5825,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.13.0 - version: 3.13.0(typanion@3.14.0) + specifier: 3.15.0 + version: 3.15.0(typanion@3.14.0) '@types/archy': specifier: 0.0.33 version: 0.0.33 @@ -8189,8 +8189,8 @@ packages: strip-bom: 4.0.0 dev: true - /@pnpm/registry-mock@3.13.0(typanion@3.14.0): - resolution: {integrity: sha512-Tf5Ml98HpJWpzSnkSAYndlsWYSPNEonjE/rujvzeRB8j6NRnP6v5rrTK7m4nrXSDDPo/ADwyVXcp+7uQiCItrg==} + /@pnpm/registry-mock@3.15.0(typanion@3.14.0): + resolution: {integrity: sha512-XDJei+9ZYDtfF/7ML+4diDjcKFL5WTtpEh6Jc998c+e5pL6bfpmnqpcDfBuVsxWX3w6bXVTc30aBXm9p8UvCqg==} engines: {node: '>=10.13'} hasBin: true dependencies: @@ -8603,6 +8603,10 @@ packages: /@types/lodash@4.14.199: resolution: {integrity: sha512-Vrjz5N5Ia4SEzWWgIVwnHNEnb1UE1XMkvY5DGXrAeOGE9imk0hgTHh5GyDjLDJi9OTCn9oo9dXH1uToK1VRfrg==} + dev: true + + /@types/lodash@4.14.200: + resolution: {integrity: sha512-YI/M/4HRImtNf3pJgbF+W6FrXovqj+T+/HpENLTooK9PnkacBsDpeP3IpHab40CClUfhNmdM2WTNP2sa2dni5Q==} /@types/mdast@3.0.13: resolution: {integrity: sha512-HjiGiWedR0DVFkeNljpa6Lv4/IZU1+30VY5d747K7lBudFc3R0Ibr6yJ9lN3BE28VnZyDfLF/VB1Ql1ZIbKrmg==} @@ -12162,7 +12166,7 @@ packages: dependencies: assert-plus: 1.0.0 jsprim: 1.4.2 - sshpk: 1.17.0 + sshpk: 1.18.0 /http-status-codes@2.2.0: resolution: {integrity: sha512-feERVo9iWxvnejp3SEfm/+oNG517npqL2/PIA8ORjyOZjGC7TwCRQsZylciLS64i6pJ0wRYz3rkXLRwbtFa8Ng==} @@ -15878,8 +15882,8 @@ packages: /sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} - /sshpk@1.17.0: - resolution: {integrity: sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ==} + /sshpk@1.18.0: + resolution: {integrity: sha512-2p2KJZTSqQ/I3+HX42EpYOa2l3f8Erv8MWKsy2I9uf4wA7yFIkXRffYdsx86y6z4vHtV8u7g+pPlr8/4ouAxsQ==} engines: {node: '>=0.10.0'} hasBin: true dependencies: @@ -17353,7 +17357,7 @@ packages: engines: {node: '>=10'} dependencies: '@babel/runtime': 7.23.2 - '@types/lodash': 4.14.199 + '@types/lodash': 4.14.200 lodash: 4.17.21 lodash-es: 4.17.21 nanoclone: 0.2.1 diff --git a/pnpm/package.json b/pnpm/package.json index c701071db3d..3ce66dd9d95 100644 --- a/pnpm/package.json +++ b/pnpm/package.json @@ -62,7 +62,7 @@ "@pnpm/prepare": "workspace:*", "@pnpm/read-package-json": "workspace:*", "@pnpm/read-project-manifest": "workspace:*", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@pnpm/run-npm": "workspace:*", "@pnpm/tabtab": "^0.1.2", "@pnpm/test-fixtures": "workspace:*", diff --git a/releasing/plugin-commands-deploy/package.json b/releasing/plugin-commands-deploy/package.json index b54ea509aec..d10d74caa24 100644 --- a/releasing/plugin-commands-deploy/package.json +++ b/releasing/plugin-commands-deploy/package.json @@ -39,7 +39,7 @@ "@pnpm/lockfile-types": "workspace:*", "@pnpm/plugin-commands-deploy": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.13.0" + "@pnpm/registry-mock": "3.15.0" }, "dependencies": { "@pnpm/cli-utils": "workspace:*", diff --git a/releasing/plugin-commands-publishing/package.json b/releasing/plugin-commands-publishing/package.json index 1c67fa9a8f6..9d0b31278f4 100644 --- a/releasing/plugin-commands-publishing/package.json +++ b/releasing/plugin-commands-publishing/package.json @@ -35,7 +35,7 @@ "@pnpm/filter-workspace-packages": "workspace:*", "@pnpm/plugin-commands-publishing": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@types/cross-spawn": "^6.0.3", "@types/is-windows": "^1.0.0", "@types/npm-packlist": "^3.0.0", diff --git a/reviewing/plugin-commands-licenses/package.json b/reviewing/plugin-commands-licenses/package.json index 7e323c3351f..8ce39d7bbf8 100644 --- a/reviewing/plugin-commands-licenses/package.json +++ b/reviewing/plugin-commands-licenses/package.json @@ -36,7 +36,7 @@ "@pnpm/plugin-commands-licenses": "workspace:*", "@pnpm/prepare": "workspace:*", "@pnpm/read-package-json": "workspace:*", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@pnpm/test-fixtures": "workspace:*", "@types/ramda": "0.28.20", "@types/wrap-ansi": "^8.0.1", diff --git a/reviewing/plugin-commands-listing/package.json b/reviewing/plugin-commands-listing/package.json index fcc3990a2f0..d63d8a754ff 100644 --- a/reviewing/plugin-commands-listing/package.json +++ b/reviewing/plugin-commands-listing/package.json @@ -34,7 +34,7 @@ "@pnpm/plugin-commands-installation": "workspace:*", "@pnpm/plugin-commands-listing": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@types/ramda": "0.28.20", "execa": "npm:safe-execa@0.1.2", "strip-ansi": "^6.0.1", diff --git a/reviewing/plugin-commands-outdated/package.json b/reviewing/plugin-commands-outdated/package.json index 972d1af88ad..32377ec1044 100644 --- a/reviewing/plugin-commands-outdated/package.json +++ b/reviewing/plugin-commands-outdated/package.json @@ -35,7 +35,7 @@ "@pnpm/plugin-commands-installation": "workspace:*", "@pnpm/plugin-commands-outdated": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@pnpm/test-fixtures": "workspace:*", "@types/ramda": "0.28.20", "@types/wrap-ansi": "^8.0.1", diff --git a/store/plugin-commands-store/package.json b/store/plugin-commands-store/package.json index 1d60c6c74a8..0435a40c0c5 100644 --- a/store/plugin-commands-store/package.json +++ b/store/plugin-commands-store/package.json @@ -34,7 +34,7 @@ "@pnpm/lockfile-file": "workspace:*", "@pnpm/plugin-commands-store": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.13.0", + "@pnpm/registry-mock": "3.15.0", "@types/archy": "0.0.33", "@types/ramda": "0.28.20", "@types/ssri": "^7.1.2", From f1dd64c99ad38052c5294f4e8aaab0d0c6da34a9 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sat, 21 Oct 2023 21:43:59 +0300 Subject: [PATCH 17/39] fix: relink optional deps --- deps/graph-builder/src/lockfileToDepGraph.ts | 4 +++- pkg-manager/core/src/install/link.ts | 5 ++++- pkg-manager/core/test/install/optionalDependencies.ts | 7 ++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/deps/graph-builder/src/lockfileToDepGraph.ts b/deps/graph-builder/src/lockfileToDepGraph.ts index 65d17bc1571..c96fe6c133b 100644 --- a/deps/graph-builder/src/lockfileToDepGraph.ts +++ b/deps/graph-builder/src/lockfileToDepGraph.ts @@ -25,6 +25,7 @@ import { import * as dp from '@pnpm/dependency-path' import pathExists from 'path-exists' import equals from 'ramda/src/equals' +import isEmpty from 'ramda/src/isEmpty' const brokenModulesLogger = logger('_broken_node_modules') @@ -132,7 +133,8 @@ export async function lockfileToDepGraph ( if ( !refIsLocalDirectory(depPath) && currentPackages[depPath] && equals(currentPackages[depPath].dependencies, lockfile.packages![depPath].dependencies) && - equals(currentPackages[depPath].optionalDependencies, lockfile.packages![depPath].optionalDependencies) + isEmpty(currentPackages[depPath].optionalDependencies) && + isEmpty(lockfile.packages![depPath].optionalDependencies) ) { if (await pathExists(dir)) { return diff --git a/pkg-manager/core/src/install/link.ts b/pkg-manager/core/src/install/link.ts index a7ea3e48446..4b24a91a4c2 100644 --- a/pkg-manager/core/src/install/link.ts +++ b/pkg-manager/core/src/install/link.ts @@ -342,7 +342,9 @@ async function linkNewPackages ( for (const depPath of wantedRelDepPaths) { if (currentLockfile.packages[depPath] && (!equals(currentLockfile.packages[depPath].dependencies, wantedLockfile.packages[depPath].dependencies) || - !equals(currentLockfile.packages[depPath].optionalDependencies, wantedLockfile.packages[depPath].optionalDependencies))) { + !isEmpty(currentLockfile.packages[depPath].optionalDependencies) || + !isEmpty(wantedLockfile.packages[depPath].optionalDependencies)) + ) { // TODO: come up with a test that triggers the usecase of depGraph[depPath] undefined // see related issue: https://github.com/pnpm/pnpm/issues/870 if (depGraph[depPath] && !newDepPathsSet.has(depPath)) { @@ -479,6 +481,7 @@ async function linkAllModules ( optional: boolean } ) { + console.log(depNodes) await symlinkAllModules({ deps: depNodes.map((depNode) => { const children = opts.optional diff --git a/pkg-manager/core/test/install/optionalDependencies.ts b/pkg-manager/core/test/install/optionalDependencies.ts index 98dbcf8d4cc..3e992b837c4 100644 --- a/pkg-manager/core/test/install/optionalDependencies.ts +++ b/pkg-manager/core/test/install/optionalDependencies.ts @@ -580,10 +580,11 @@ test('install optional dependency for the supported architecture set by the user prepareEmpty() const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-many-optional-deps@1.0.0'], await testDefaults({ supportedArchitectures: { os: ['darwin'], cpu: ['arm64'] } })) - expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-arm64', './package.json']).version).toBe('1.0.0') - await install(manifest, await testDefaults({ supportedArchitectures: { os: ['darwin'], cpu: ['x64'] } })) - + await install(manifest, await testDefaults({ preferFrozenLockfile: false, supportedArchitectures: { os: ['darwin'], cpu: ['x64'] } })) expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-x64', './package.json']).version).toBe('1.0.0') + + await install(manifest, await testDefaults({ frozenLockfile: true, supportedArchitectures: { os: ['linux'], cpu: ['x64'] } })) + expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/linux-x64', './package.json']).version).toBe('1.0.0') }) From d4a2c2d3638a5e81ed31ae3d878d649c08b9efbe Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sat, 21 Oct 2023 22:17:30 +0300 Subject: [PATCH 18/39] fix: remove console log --- pkg-manager/core/src/install/link.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg-manager/core/src/install/link.ts b/pkg-manager/core/src/install/link.ts index 4b24a91a4c2..3bbc1a1f3c9 100644 --- a/pkg-manager/core/src/install/link.ts +++ b/pkg-manager/core/src/install/link.ts @@ -481,7 +481,6 @@ async function linkAllModules ( optional: boolean } ) { - console.log(depNodes) await symlinkAllModules({ deps: depNodes.map((depNode) => { const children = opts.optional From ce0ae43cdee483dec3acaa4b11b0aebe4fe723b3 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sat, 21 Oct 2023 22:57:05 +0300 Subject: [PATCH 19/39] test: fix --- deps/graph-builder/src/lockfileToDepGraph.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/deps/graph-builder/src/lockfileToDepGraph.ts b/deps/graph-builder/src/lockfileToDepGraph.ts index c96fe6c133b..085035b0a64 100644 --- a/deps/graph-builder/src/lockfileToDepGraph.ts +++ b/deps/graph-builder/src/lockfileToDepGraph.ts @@ -133,8 +133,11 @@ export async function lockfileToDepGraph ( if ( !refIsLocalDirectory(depPath) && currentPackages[depPath] && equals(currentPackages[depPath].dependencies, lockfile.packages![depPath].dependencies) && - isEmpty(currentPackages[depPath].optionalDependencies) && - isEmpty(lockfile.packages![depPath].optionalDependencies) + ( + equals(currentPackages[depPath].optionalDependencies, lockfile.packages![depPath].optionalDependencies) || + isEmpty(currentPackages[depPath].optionalDependencies) && + isEmpty(lockfile.packages![depPath].optionalDependencies) + ) ) { if (await pathExists(dir)) { return From 8400ab25935cf3cca333dbb2c275cfc1b4ad9a9e Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sat, 21 Oct 2023 23:38:02 +0300 Subject: [PATCH 20/39] test: fix --- deps/graph-builder/src/lockfileToDepGraph.ts | 60 ++++++++++++-------- exec/build-modules/src/buildSequence.ts | 2 +- exec/build-modules/src/index.ts | 10 ++-- pkg-manager/headless/src/index.ts | 1 + 4 files changed, 43 insertions(+), 30 deletions(-) diff --git a/deps/graph-builder/src/lockfileToDepGraph.ts b/deps/graph-builder/src/lockfileToDepGraph.ts index 085035b0a64..a13bddc5be8 100644 --- a/deps/graph-builder/src/lockfileToDepGraph.ts +++ b/deps/graph-builder/src/lockfileToDepGraph.ts @@ -34,7 +34,7 @@ export interface DependenciesGraphNode { hasBundledDependencies: boolean modules: string name: string - fetching: () => Promise + fetching?: () => Promise dir: string children: Record optionalDependencies: Set @@ -44,7 +44,7 @@ export interface DependenciesGraphNode { requiresBuild: boolean prepare: boolean hasBin: boolean - filesIndexFile: string + filesIndexFile?: string patchFile?: PatchFile } @@ -130,11 +130,10 @@ export async function lockfileToDepGraph ( return } const dir = path.join(modules, pkgName) - if ( - !refIsLocalDirectory(depPath) && - currentPackages[depPath] && equals(currentPackages[depPath].dependencies, lockfile.packages![depPath].dependencies) && + const depIsPresent = !refIsLocalDirectory(depPath) && + currentPackages[depPath] && equals(currentPackages[depPath].dependencies, lockfile.packages![depPath].dependencies) + if (depIsPresent && ( - equals(currentPackages[depPath].optionalDependencies, lockfile.packages![depPath].optionalDependencies) || isEmpty(currentPackages[depPath].optionalDependencies) && isEmpty(lockfile.packages![depPath].optionalDependencies) ) @@ -153,25 +152,36 @@ export async function lockfileToDepGraph ( requester: opts.lockfileDir, status: 'resolved', }) - let fetchResponse!: ReturnType - try { - fetchResponse = opts.storeController.fetchPackage({ - force: false, - lockfileDir: opts.lockfileDir, - ignoreScripts: opts.ignoreScripts, - pkg: { - id: packageId, - resolution, - }, - expectedPkg: { - name: pkgName, - version: pkgVersion, - }, - }) as any // eslint-disable-line - if (fetchResponse instanceof Promise) fetchResponse = await fetchResponse - } catch (err: any) { // eslint-disable-line - if (pkgSnapshot.optional) return - throw err + let fetchResponse!: Partial> + if (depIsPresent && equals(currentPackages[depPath].optionalDependencies, lockfile.packages![depPath].optionalDependencies)) { + if (await pathExists(dir)) { + fetchResponse = {} + } else { + brokenModulesLogger.debug({ + missing: dir, + }) + } + } + if (!fetchResponse) { + try { + fetchResponse = opts.storeController.fetchPackage({ + force: false, + lockfileDir: opts.lockfileDir, + ignoreScripts: opts.ignoreScripts, + pkg: { + id: packageId, + resolution, + }, + expectedPkg: { + name: pkgName, + version: pkgVersion, + }, + }) as any // eslint-disable-line + if (fetchResponse instanceof Promise) fetchResponse = await fetchResponse + } catch (err: any) { // eslint-disable-line + if (pkgSnapshot.optional) return + throw err + } } graph[dir] = { children: {}, diff --git a/exec/build-modules/src/buildSequence.ts b/exec/build-modules/src/buildSequence.ts index 9b7a0f3a45a..87247407705 100644 --- a/exec/build-modules/src/buildSequence.ts +++ b/exec/build-modules/src/buildSequence.ts @@ -8,7 +8,7 @@ export interface DependenciesGraphNode { name: string dir: string fetchingBundledManifest?: () => Promise - filesIndexFile: string + filesIndexFile?: string hasBin: boolean hasBundledDependencies: boolean installable?: boolean diff --git a/exec/build-modules/src/index.ts b/exec/build-modules/src/index.ts index 2cfb7f4e6b0..e76a2748904 100644 --- a/exec/build-modules/src/index.ts +++ b/exec/build-modules/src/index.ts @@ -135,10 +135,12 @@ async function buildDependency ( patchFileHash: depNode.patchFile?.hash, isBuilt: hasSideEffects, }) - await opts.storeController.upload(depNode.dir, { - sideEffectsCacheKey, - filesIndexFile: depNode.filesIndexFile, - }) + if (depNode.filesIndexFile) { + await opts.storeController.upload(depNode.dir, { + sideEffectsCacheKey, + filesIndexFile: depNode.filesIndexFile, + }) + } } catch (err: any) { // eslint-disable-line if (err.statusCode === 403) { logger.warn({ diff --git a/pkg-manager/headless/src/index.ts b/pkg-manager/headless/src/index.ts index c8e33b4d24f..5f8aa06ec82 100644 --- a/pkg-manager/headless/src/index.ts +++ b/pkg-manager/headless/src/index.ts @@ -790,6 +790,7 @@ async function linkAllPkgs ( ) { return Promise.all( depNodes.map(async (depNode) => { + if (!depNode.fetching) return let filesResponse!: PackageFilesResponse try { filesResponse = (await depNode.fetching()).files From e93bd5dfb0b6d720997326f4867b21a15da1ebd8 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 22 Oct 2023 00:13:02 +0300 Subject: [PATCH 21/39] test: fix --- deps/graph-builder/src/lockfileToDepGraph.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/deps/graph-builder/src/lockfileToDepGraph.ts b/deps/graph-builder/src/lockfileToDepGraph.ts index a13bddc5be8..4deac7caed5 100644 --- a/deps/graph-builder/src/lockfileToDepGraph.ts +++ b/deps/graph-builder/src/lockfileToDepGraph.ts @@ -132,11 +132,9 @@ export async function lockfileToDepGraph ( const dir = path.join(modules, pkgName) const depIsPresent = !refIsLocalDirectory(depPath) && currentPackages[depPath] && equals(currentPackages[depPath].dependencies, lockfile.packages![depPath].dependencies) - if (depIsPresent && - ( - isEmpty(currentPackages[depPath].optionalDependencies) && - isEmpty(lockfile.packages![depPath].optionalDependencies) - ) + if ( + depIsPresent && isEmpty(currentPackages[depPath].optionalDependencies) && + isEmpty(lockfile.packages![depPath].optionalDependencies) ) { if (await pathExists(dir)) { return @@ -146,12 +144,6 @@ export async function lockfileToDepGraph ( missing: dir, }) } - const resolution = pkgSnapshotToResolution(depPath, pkgSnapshot, opts.registries) - progressLogger.debug({ - packageId, - requester: opts.lockfileDir, - status: 'resolved', - }) let fetchResponse!: Partial> if (depIsPresent && equals(currentPackages[depPath].optionalDependencies, lockfile.packages![depPath].optionalDependencies)) { if (await pathExists(dir)) { @@ -163,6 +155,12 @@ export async function lockfileToDepGraph ( } } if (!fetchResponse) { + const resolution = pkgSnapshotToResolution(depPath, pkgSnapshot, opts.registries) + progressLogger.debug({ + packageId, + requester: opts.lockfileDir, + status: 'resolved', + }) try { fetchResponse = opts.storeController.fetchPackage({ force: false, From 00c8c78ec075045557b02d372c61af0cb78cfc3a Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 22 Oct 2023 04:20:51 +0300 Subject: [PATCH 22/39] test: refactor --- .../core/test/install/optionalDependencies.ts | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/pkg-manager/core/test/install/optionalDependencies.ts b/pkg-manager/core/test/install/optionalDependencies.ts index 3e992b837c4..70fb27ddd50 100644 --- a/pkg-manager/core/test/install/optionalDependencies.ts +++ b/pkg-manager/core/test/install/optionalDependencies.ts @@ -578,13 +578,50 @@ test('fail on a package with failing postinstall if the package is both an optio test('install optional dependency for the supported architecture set by the user', async () => { prepareEmpty() + const opts = await testDefaults() - const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-many-optional-deps@1.0.0'], await testDefaults({ supportedArchitectures: { os: ['darwin'], cpu: ['arm64'] } })) + const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-many-optional-deps@1.0.0'], { + ...opts, + supportedArchitectures: { os: ['darwin'], cpu: ['arm64'], libc: ['current'] }, + }) expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-arm64', './package.json']).version).toBe('1.0.0') - await install(manifest, await testDefaults({ preferFrozenLockfile: false, supportedArchitectures: { os: ['darwin'], cpu: ['x64'] } })) + await install(manifest, { + ...opts, + preferFrozenLockfile: false, + supportedArchitectures: { os: ['darwin'], cpu: ['x64'], libc: ['current'] }, + }) expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-x64', './package.json']).version).toBe('1.0.0') - await install(manifest, await testDefaults({ frozenLockfile: true, supportedArchitectures: { os: ['linux'], cpu: ['x64'] } })) + await install(manifest, { + ...opts, + frozenLockfile: true, + supportedArchitectures: { os: ['linux'], cpu: ['x64'], libc: ['current'] }, + }) + expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/linux-x64', './package.json']).version).toBe('1.0.0') +}) + +test('install optional dependency for the supported architecture set by the user in a hoisted node_modules', async () => { + prepareEmpty() + const opts = await testDefaults({ nodeLinker: 'hoisted' }) + + const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-many-optional-deps@1.0.0'], { + ...opts, + supportedArchitectures: { os: ['darwin'], cpu: ['arm64'], libc: ['current'] }, + }) + expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-arm64', './package.json']).version).toBe('1.0.0') + + await install(manifest, { + ...opts, + preferFrozenLockfile: false, + supportedArchitectures: { os: ['darwin'], cpu: ['x64'], libc: ['current'] }, + }) + expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-x64', './package.json']).version).toBe('1.0.0') + + await install(manifest, { + ...opts, + frozenLockfile: true, + supportedArchitectures: { os: ['linux'], cpu: ['x64'], libc: ['current'] }, + }) expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/linux-x64', './package.json']).version).toBe('1.0.0') }) From 04de31c4f51e78d81ea18c7085274a8ea4b9971a Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 22 Oct 2023 04:31:56 +0300 Subject: [PATCH 23/39] refactor: less changes --- .../test/checkPlatform.ts | 56 ++++--------------- .../test/index.ts | 21 ------- lockfile/plugin-commands-audit/test/index.ts | 5 -- packages/types/src/package.ts | 8 +-- .../test/patch.test.ts | 25 --------- .../core/test/install/optionalDependencies.ts | 12 ++-- 6 files changed, 20 insertions(+), 107 deletions(-) diff --git a/config/package-is-installable/test/checkPlatform.ts b/config/package-is-installable/test/checkPlatform.ts index dc34e9a8e9b..14d690b4765 100644 --- a/config/package-is-installable/test/checkPlatform.ts +++ b/config/package-is-installable/test/checkPlatform.ts @@ -16,11 +16,7 @@ test('target cpu wrong', () => { os: 'any', libc: 'any', } - const err = checkPlatform(packageId, target, { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }) + const err = checkPlatform(packageId, target) expect(err).toBeTruthy() expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') }) @@ -31,11 +27,7 @@ test('os wrong', () => { os: 'enten-os', libc: 'any', } - const err = checkPlatform(packageId, target, { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }) + const err = checkPlatform(packageId, target) expect(err).toBeTruthy() expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') }) @@ -46,11 +38,7 @@ test('libc wrong', () => { os: 'any', libc: 'enten-libc', } - const err = checkPlatform(packageId, target, { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }) + const err = checkPlatform(packageId, target) expect(err).toBeTruthy() expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') }) @@ -61,59 +49,35 @@ test('nothing wrong', () => { os: 'any', libc: 'any', } - expect(checkPlatform(packageId, target, { - os: ['current'], - cpu: ['current'], - libc: ['current'], - })).toBeFalsy() + expect(checkPlatform(packageId, target)).toBeFalsy() }) test('only target cpu wrong', () => { - const err = checkPlatform(packageId, { cpu: 'enten-cpu', os: 'any', libc: 'any' }, { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }) + const err = checkPlatform(packageId, { cpu: 'enten-cpu', os: 'any', libc: 'any' }) expect(err).toBeTruthy() expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') }) test('only os wrong', () => { - const err = checkPlatform(packageId, { cpu: 'any', os: 'enten-os', libc: 'any' }, { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }) + const err = checkPlatform(packageId, { cpu: 'any', os: 'enten-os', libc: 'any' }) expect(err).toBeTruthy() expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') }) test('everything wrong w/arrays', () => { - const err = checkPlatform(packageId, { cpu: ['enten-cpu'], os: ['enten-os'], libc: ['enten-libc'] }, { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }) + const err = checkPlatform(packageId, { cpu: ['enten-cpu'], os: ['enten-os'], libc: ['enten-libc'] }) expect(err).toBeTruthy() expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') }) test('os wrong (negation)', () => { - const err = checkPlatform(packageId, { cpu: 'any', os: `!${process.platform}`, libc: 'any' }, { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }) + const err = checkPlatform(packageId, { cpu: 'any', os: `!${process.platform}`, libc: 'any' }) expect(err).toBeTruthy() expect(err?.code).toBe('ERR_PNPM_UNSUPPORTED_PLATFORM') }) test('nothing wrong (negation)', () => { - expect(checkPlatform(packageId, { cpu: '!enten-cpu', os: '!enten-os', libc: '!enten-libc' }, { - os: ['current'], - cpu: ['current'], - libc: ['current'], - })).toBe(null) + expect(checkPlatform(packageId, { cpu: '!enten-cpu', os: '!enten-os', libc: '!enten-libc' })).toBe(null) }) test('override OS', () => { @@ -156,4 +120,4 @@ test('accept another libc', () => { cpu: ['current'], libc: ['current', 'glibc'], })).toBe(null) -}) \ No newline at end of file +}) diff --git a/exec/plugin-commands-script-runners/test/index.ts b/exec/plugin-commands-script-runners/test/index.ts index 7e4407c0159..08b8af3ada1 100644 --- a/exec/plugin-commands-script-runners/test/index.ts +++ b/exec/plugin-commands-script-runners/test/index.ts @@ -38,11 +38,6 @@ test('pnpm run: returns correct exit code', async () => { extraBinPaths: [], extraEnv: {}, rawConfig: {}, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }, ['exit1']) } catch (_err: any) { // eslint-disable-line err = _err @@ -320,11 +315,6 @@ test('"pnpm run" prints the list of available commands, including commands of th rawConfig: {}, selectedProjectsGraph, workspaceDir, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }, []) expect(output).toBe(`\ @@ -352,11 +342,6 @@ Commands of the root workspace project (to run them, use "pnpm -w run"): rawConfig: {}, selectedProjectsGraph, workspaceDir, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }, []) expect(output).toBe(`\ @@ -476,7 +461,6 @@ test('pnpm run with custom shell', async () => { extraEnv: {}, rawConfig: {}, scriptShell: path.resolve(`node_modules/.bin/shell-mock${isWindows() ? '.cmd' : ''}`), - }, ['build']) expect((await import(path.resolve('shell-input.json'))).default).toStrictEqual(['-c', 'foo bar']) @@ -596,11 +580,6 @@ test('pnpm run with RegExp script selector with flag should throw error', async extraEnv: {}, rawConfig: {}, workspaceConcurrency: 1, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }, ['/build:.*/i']) } catch (_err: any) { // eslint-disable-line err = _err diff --git a/lockfile/plugin-commands-audit/test/index.ts b/lockfile/plugin-commands-audit/test/index.ts index 4da774ccade..7d8a029f9eb 100644 --- a/lockfile/plugin-commands-audit/test/index.ts +++ b/lockfile/plugin-commands-audit/test/index.ts @@ -59,11 +59,6 @@ export const DEFAULT_OPTS = { useRunningStoreServer: false, useStoreServer: false, workspaceConcurrency: 4, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, } describe('plugin-commands-audit', () => { diff --git a/packages/types/src/package.ts b/packages/types/src/package.ts index b6656b6f40d..52c00acd28c 100644 --- a/packages/types/src/package.ts +++ b/packages/types/src/package.ts @@ -151,7 +151,7 @@ export type PackageManifest = DependencyManifest & { } export interface SupportedArchitectures { - os: string[] - cpu: string[] - libc: string[] -} \ No newline at end of file + os?: string[] + cpu?: string[] + libc?: string[] +} diff --git a/patching/plugin-commands-patching/test/patch.test.ts b/patching/plugin-commands-patching/test/patch.test.ts index eed33d23d7a..1a1afc002a1 100644 --- a/patching/plugin-commands-patching/test/patch.test.ts +++ b/patching/plugin-commands-patching/test/patch.test.ts @@ -47,11 +47,6 @@ describe('patch and commit', () => { cacheDir, dir: process.cwd(), storeDir, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, } await install.handler({ @@ -357,11 +352,6 @@ describe('prompt to choose version', () => { cacheDir, dir: process.cwd(), storeDir, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, } }) @@ -430,11 +420,6 @@ describe('patching should work when there is a no EOL in the patched file', () = cacheDir, dir: process.cwd(), storeDir, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, } await install.handler({ @@ -541,11 +526,6 @@ describe('patch and commit in workspaces', () => { cacheDir, dir: process.cwd(), storeDir, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, } await writeYamlFile('pnpm-workspace.yaml', { packages: ['project-1', 'project-2'] }) }) @@ -685,11 +665,6 @@ describe('patch with custom modules-dir and virtual-store-dir', () => { storeDir, modulesDir: 'fake_modules', virtualStoreDir: 'fake_modules/.fake_store', - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, } }) diff --git a/pkg-manager/core/test/install/optionalDependencies.ts b/pkg-manager/core/test/install/optionalDependencies.ts index 70fb27ddd50..ab5271fbe71 100644 --- a/pkg-manager/core/test/install/optionalDependencies.ts +++ b/pkg-manager/core/test/install/optionalDependencies.ts @@ -582,21 +582,21 @@ test('install optional dependency for the supported architecture set by the user const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-many-optional-deps@1.0.0'], { ...opts, - supportedArchitectures: { os: ['darwin'], cpu: ['arm64'], libc: ['current'] }, + supportedArchitectures: { os: ['darwin'], cpu: ['arm64'] }, }) expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-arm64', './package.json']).version).toBe('1.0.0') await install(manifest, { ...opts, preferFrozenLockfile: false, - supportedArchitectures: { os: ['darwin'], cpu: ['x64'], libc: ['current'] }, + supportedArchitectures: { os: ['darwin'], cpu: ['x64'] }, }) expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-x64', './package.json']).version).toBe('1.0.0') await install(manifest, { ...opts, frozenLockfile: true, - supportedArchitectures: { os: ['linux'], cpu: ['x64'], libc: ['current'] }, + supportedArchitectures: { os: ['linux'], cpu: ['x64'] }, }) expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/linux-x64', './package.json']).version).toBe('1.0.0') }) @@ -607,21 +607,21 @@ test('install optional dependency for the supported architecture set by the user const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-many-optional-deps@1.0.0'], { ...opts, - supportedArchitectures: { os: ['darwin'], cpu: ['arm64'], libc: ['current'] }, + supportedArchitectures: { os: ['darwin'], cpu: ['arm64'] }, }) expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-arm64', './package.json']).version).toBe('1.0.0') await install(manifest, { ...opts, preferFrozenLockfile: false, - supportedArchitectures: { os: ['darwin'], cpu: ['x64'], libc: ['current'] }, + supportedArchitectures: { os: ['darwin'], cpu: ['x64'] }, }) expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-x64', './package.json']).version).toBe('1.0.0') await install(manifest, { ...opts, frozenLockfile: true, - supportedArchitectures: { os: ['linux'], cpu: ['x64'], libc: ['current'] }, + supportedArchitectures: { os: ['linux'], cpu: ['x64'] }, }) expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/linux-x64', './package.json']).version).toBe('1.0.0') }) From 70a5f069dcd6e27b331842523d041b376cf30fcf Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 22 Oct 2023 04:36:33 +0300 Subject: [PATCH 24/39] refactor: less changes --- pkg-manager/package-requester/test/index.ts | 52 --------------------- 1 file changed, 52 deletions(-) diff --git a/pkg-manager/package-requester/test/index.ts b/pkg-manager/package-requester/test/index.ts index bda057b3b3a..0f06c8874e4 100644 --- a/pkg-manager/package-requester/test/index.ts +++ b/pkg-manager/package-requester/test/index.ts @@ -49,7 +49,6 @@ test('request package', async () => { preferredVersions: {}, projectDir, registry, - }) expect(pkgResponse).toBeTruthy() @@ -93,7 +92,6 @@ test('request package but skip fetching', async () => { projectDir, registry, skipFetch: true, - }) expect(pkgResponse).toBeTruthy() @@ -143,7 +141,6 @@ test('request package but skip fetching, when resolution is already available', registry, skipFetch: true, update: false, - }) as PackageResponse & { body: { latest: string @@ -206,11 +203,6 @@ test('refetch local tarball if its integrity has changed', async () => { tarball, }, }, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }) as PackageResponse & { fetching: () => Promise } @@ -242,11 +234,6 @@ test('refetch local tarball if its integrity has changed', async () => { tarball, }, }, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }) const { files, bundledManifest } = await response.fetching!() @@ -273,11 +260,6 @@ test('refetch local tarball if its integrity has changed', async () => { tarball, }, }, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }) as PackageResponse & { fetching: () => Promise } @@ -304,7 +286,6 @@ test('refetch local tarball if its integrity has changed. The requester does not projectDir, registry, update: false, - } { @@ -595,11 +576,6 @@ test('always return a package manifest in the response', async () => { preferredVersions: {}, projectDir, registry, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }) as PackageResponse & { body: { manifest: { name: string } } } expect(pkgResponse.body).toBeTruthy() @@ -621,11 +597,6 @@ test('always return a package manifest in the response', async () => { preferredVersions: {}, projectDir, registry, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }) as PackageResponse & { fetching: () => Promise } expect(pkgResponse.body).toBeTruthy() @@ -800,7 +771,6 @@ test('do not fetch an optional package that is not installable', async () => { preferredVersions: {}, projectDir, registry, - }) expect(pkgResponse).toBeTruthy() @@ -839,11 +809,6 @@ test('fetch a git package without a package.json', async () => { preferredVersions: {}, projectDir, registry, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }) as PackageResponse & { body: { manifest: { name: string } } } expect(pkgResponse.body).toBeTruthy() @@ -875,11 +840,6 @@ test('throw exception if the package data in the store differs from the expected preferredVersions: {}, projectDir, registry, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }) await pkgResponse.fetching!() } @@ -1012,11 +972,6 @@ test("don't throw an error if the package was updated, so the expectedPkg has a preferredVersions: {}, projectDir, registry, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }) await pkgResponse.fetching!() } @@ -1039,7 +994,6 @@ test("don't throw an error if the package was updated, so the expectedPkg has a name: 'is-positive', version: '3.0.0', }, - }) await expect(pkgResponse.fetching!()).resolves.toStrictEqual(expect.anything()) }) @@ -1063,7 +1017,6 @@ test('the version in the bundled manifest should be normalized', async () => { preferredVersions: {}, projectDir: tempy.directory(), registry, - }) expect((await pkgResponse.fetching!()).bundledManifest).toStrictEqual(expect.objectContaining({ version: '1.2.1', @@ -1094,11 +1047,6 @@ test('should skip store integrity check and resolve manifest if fetchRawManifest preferredVersions: {}, projectDir, registry, - supportedArchitectures: { - os: ['current'], - cpu: ['current'], - libc: ['current'], - }, }) await pkgResponse.fetching!() From 15693fe05c58f0a9297db6af4ae425ee385e2c21 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 22 Oct 2023 04:49:32 +0300 Subject: [PATCH 25/39] test: not needed optional deps are removed --- .../core/test/install/optionalDependencies.ts | 75 +++++++++---------- 1 file changed, 34 insertions(+), 41 deletions(-) diff --git a/pkg-manager/core/test/install/optionalDependencies.ts b/pkg-manager/core/test/install/optionalDependencies.ts index ab5271fbe71..eab23144bfb 100644 --- a/pkg-manager/core/test/install/optionalDependencies.ts +++ b/pkg-manager/core/test/install/optionalDependencies.ts @@ -1,3 +1,4 @@ +import fs from 'fs' import path from 'path' import { type Lockfile } from '@pnpm/lockfile-file' import { prepareEmpty, preparePackages } from '@pnpm/prepare' @@ -576,52 +577,44 @@ test('fail on a package with failing postinstall if the package is both an optio ).rejects.toThrow() }) -test('install optional dependency for the supported architecture set by the user', async () => { - prepareEmpty() - const opts = await testDefaults() - - const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-many-optional-deps@1.0.0'], { - ...opts, - supportedArchitectures: { os: ['darwin'], cpu: ['arm64'] }, - }) - expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-arm64', './package.json']).version).toBe('1.0.0') - - await install(manifest, { - ...opts, - preferFrozenLockfile: false, - supportedArchitectures: { os: ['darwin'], cpu: ['x64'] }, - }) - expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-x64', './package.json']).version).toBe('1.0.0') +describe('supported architectures', () => { + test.each(['isolated', 'hoisted'])('install optional dependency for the supported architecture set by the user (nodeLinker=%s)', async (nodeLinker) => { + prepareEmpty() + const opts = await testDefaults({ nodeLinker }) - await install(manifest, { - ...opts, - frozenLockfile: true, - supportedArchitectures: { os: ['linux'], cpu: ['x64'] }, - }) - expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/linux-x64', './package.json']).version).toBe('1.0.0') -}) + const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-many-optional-deps@1.0.0'], { + ...opts, + supportedArchitectures: { os: ['darwin'], cpu: ['arm64'] }, + }) + expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-arm64', './package.json']).version).toBe('1.0.0') -test('install optional dependency for the supported architecture set by the user in a hoisted node_modules', async () => { - prepareEmpty() - const opts = await testDefaults({ nodeLinker: 'hoisted' }) + await install(manifest, { + ...opts, + preferFrozenLockfile: false, + supportedArchitectures: { os: ['darwin'], cpu: ['x64'] }, + }) + expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-x64', './package.json']).version).toBe('1.0.0') - const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-many-optional-deps@1.0.0'], { - ...opts, - supportedArchitectures: { os: ['darwin'], cpu: ['arm64'] }, + await install(manifest, { + ...opts, + frozenLockfile: true, + supportedArchitectures: { os: ['linux'], cpu: ['x64'] }, + }) + expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/linux-x64', './package.json']).version).toBe('1.0.0') }) - expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-arm64', './package.json']).version).toBe('1.0.0') + test('remove optional dependencies that are not used', async () => { + prepareEmpty() + const opts = await testDefaults({ modulesCacheMaxAge: 0 }) - await install(manifest, { - ...opts, - preferFrozenLockfile: false, - supportedArchitectures: { os: ['darwin'], cpu: ['x64'] }, - }) - expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/darwin-x64', './package.json']).version).toBe('1.0.0') + const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-many-optional-deps@1.0.0'], { + ...opts, + supportedArchitectures: { os: ['darwin', 'linux', 'win32'], cpu: ['arm64', 'x64'] }, + }) - await install(manifest, { - ...opts, - frozenLockfile: true, - supportedArchitectures: { os: ['linux'], cpu: ['x64'] }, + await install(manifest, { + ...opts, + supportedArchitectures: { os: ['darwin'], cpu: ['x64'] }, + }) + expect(fs.readdirSync('node_modules/.pnpm').length).toBe(3) }) - expect(deepRequireCwd(['@pnpm.e2e/has-many-optional-deps', '@pnpm.e2e/linux-x64', './package.json']).version).toBe('1.0.0') }) From a49f69703faeb1a671ff51df6bdf74a0277825e3 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 22 Oct 2023 05:04:56 +0300 Subject: [PATCH 26/39] fix: remove unused optional deps --- pkg-manager/headless/src/index.ts | 48 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/pkg-manager/headless/src/index.ts b/pkg-manager/headless/src/index.ts index 5f8aa06ec82..4d9c6c7b04a 100644 --- a/pkg-manager/headless/src/index.ts +++ b/pkg-manager/headless/src/index.ts @@ -215,7 +215,30 @@ export async function headlessInstall (opts: HeadlessOptions): Promise() + const filterOpts = { + include: opts.include, + registries: opts.registries, + skipped, + } + const initialImporterIds = (opts.ignorePackageManifest === true || opts.nodeLinker === 'hoisted') + ? Object.keys(wantedLockfile.importers) + : selectedProjects.map(({ id }) => id) + const { lockfile: filteredLockfile, selectedImporterIds: importerIds } = filterLockfileByImportersAndEngine(wantedLockfile, initialImporterIds, { + ...filterOpts, + currentEngine: opts.currentEngine, + engineStrict: opts.engineStrict, + failOnMissingDependencies: true, + includeIncompatiblePackages: opts.force, + lockfileDir, + supportedArchitectures: opts.supportedArchitectures, + }) + let removed = 0 if (opts.nodeLinker !== 'hoisted') { if (currentLockfile != null && !opts.ignorePackageManifest) { @@ -235,7 +258,7 @@ export async function headlessInstall (opts: HeadlessOptions): Promise id) - const { lockfile: filteredLockfile, selectedImporterIds: importerIds } = filterLockfileByImportersAndEngine(wantedLockfile, initialImporterIds, { - ...filterOpts, - currentEngine: opts.currentEngine, - engineStrict: opts.engineStrict, - failOnMissingDependencies: true, - includeIncompatiblePackages: opts.force, - lockfileDir, - supportedArchitectures: opts.supportedArchitectures, - }) if (opts.excludeLinksFromLockfile) { for (const { id, manifest, rootDir } of selectedProjects) { if (filteredLockfile.importers[id]) { From 16b36f50104056579cdfc5e69b76a3dbe8908eb3 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Mon, 23 Oct 2023 03:37:50 +0300 Subject: [PATCH 27/39] Revert "fix: remove unused optional deps" This reverts commit a49f69703faeb1a671ff51df6bdf74a0277825e3. --- pkg-manager/headless/src/index.ts | 48 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/pkg-manager/headless/src/index.ts b/pkg-manager/headless/src/index.ts index 4d9c6c7b04a..5f8aa06ec82 100644 --- a/pkg-manager/headless/src/index.ts +++ b/pkg-manager/headless/src/index.ts @@ -215,30 +215,7 @@ export async function headlessInstall (opts: HeadlessOptions): Promise() - const filterOpts = { - include: opts.include, - registries: opts.registries, - skipped, - } - const initialImporterIds = (opts.ignorePackageManifest === true || opts.nodeLinker === 'hoisted') - ? Object.keys(wantedLockfile.importers) - : selectedProjects.map(({ id }) => id) - const { lockfile: filteredLockfile, selectedImporterIds: importerIds } = filterLockfileByImportersAndEngine(wantedLockfile, initialImporterIds, { - ...filterOpts, - currentEngine: opts.currentEngine, - engineStrict: opts.engineStrict, - failOnMissingDependencies: true, - includeIncompatiblePackages: opts.force, - lockfileDir, - supportedArchitectures: opts.supportedArchitectures, - }) - let removed = 0 if (opts.nodeLinker !== 'hoisted') { if (currentLockfile != null && !opts.ignorePackageManifest) { @@ -258,7 +235,7 @@ export async function headlessInstall (opts: HeadlessOptions): Promise id) + const { lockfile: filteredLockfile, selectedImporterIds: importerIds } = filterLockfileByImportersAndEngine(wantedLockfile, initialImporterIds, { + ...filterOpts, + currentEngine: opts.currentEngine, + engineStrict: opts.engineStrict, + failOnMissingDependencies: true, + includeIncompatiblePackages: opts.force, + lockfileDir, + supportedArchitectures: opts.supportedArchitectures, + }) if (opts.excludeLinksFromLockfile) { for (const { id, manifest, rootDir } of selectedProjects) { if (filteredLockfile.importers[id]) { From 3f2890775692f2969a36f657ffb670a47d211e4d Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Mon, 23 Oct 2023 03:52:12 +0300 Subject: [PATCH 28/39] fix: removing not needed artifacts --- .../src/filterLockfileByImportersAndEngine.ts | 36 ++++++++++++------- lockfile/filter-lockfile/src/index.ts | 2 +- pkg-manager/headless/src/index.ts | 29 ++++++++------- 3 files changed, 38 insertions(+), 29 deletions(-) diff --git a/lockfile/filter-lockfile/src/filterLockfileByImportersAndEngine.ts b/lockfile/filter-lockfile/src/filterLockfileByImportersAndEngine.ts index d9d1bda0625..64e772876cb 100644 --- a/lockfile/filter-lockfile/src/filterLockfileByImportersAndEngine.ts +++ b/lockfile/filter-lockfile/src/filterLockfileByImportersAndEngine.ts @@ -16,22 +16,32 @@ import { filterImporter } from './filterImporter' const lockfileLogger = logger('lockfile') +export function filterLockfileByEngine ( + lockfile: Lockfile, + opts: FilterLockfileOptions +) { + const importerIds = Object.keys(lockfile.importers) + return filterLockfileByImportersAndEngine(lockfile, importerIds, opts) +} + +export interface FilterLockfileOptions { + currentEngine: { + nodeVersion: string + pnpmVersion: string + } + engineStrict: boolean + include: { [dependenciesField in DependenciesField]: boolean } + includeIncompatiblePackages?: boolean + failOnMissingDependencies: boolean + lockfileDir: string + skipped: Set + supportedArchitectures?: SupportedArchitectures +} + export function filterLockfileByImportersAndEngine ( lockfile: Lockfile, importerIds: string[], - opts: { - currentEngine: { - nodeVersion: string - pnpmVersion: string - } - engineStrict: boolean - include: { [dependenciesField in DependenciesField]: boolean } - includeIncompatiblePackages?: boolean - failOnMissingDependencies: boolean - lockfileDir: string - skipped: Set - supportedArchitectures?: SupportedArchitectures - } + opts: FilterLockfileOptions ): { lockfile: Lockfile, selectedImporterIds: string[] } { const importerIdSet = new Set(importerIds) as Set diff --git a/lockfile/filter-lockfile/src/index.ts b/lockfile/filter-lockfile/src/index.ts index 2aa70a6fe45..37a57e97785 100644 --- a/lockfile/filter-lockfile/src/index.ts +++ b/lockfile/filter-lockfile/src/index.ts @@ -1,3 +1,3 @@ export { filterLockfile } from './filterLockfile' export { filterLockfileByImporters } from './filterLockfileByImporters' -export { filterLockfileByImportersAndEngine } from './filterLockfileByImportersAndEngine' +export { filterLockfileByImportersAndEngine, filterLockfileByEngine } from './filterLockfileByImportersAndEngine' diff --git a/pkg-manager/headless/src/index.ts b/pkg-manager/headless/src/index.ts index 5f8aa06ec82..77282381ebf 100644 --- a/pkg-manager/headless/src/index.ts +++ b/pkg-manager/headless/src/index.ts @@ -15,6 +15,7 @@ import { summaryLogger, } from '@pnpm/core-loggers' import { + filterLockfileByEngine, filterLockfileByImportersAndEngine, } from '@pnpm/filter-lockfile' import { hoist } from '@pnpm/hoist' @@ -216,6 +217,17 @@ export async function headlessInstall (opts: HeadlessOptions): Promise() + const filterOpts = { + include: opts.include, + registries: opts.registries, + skipped, + currentEngine: opts.currentEngine, + engineStrict: opts.engineStrict, + failOnMissingDependencies: true, + includeIncompatiblePackages: opts.force, + lockfileDir, + supportedArchitectures: opts.supportedArchitectures, + } let removed = 0 if (opts.nodeLinker !== 'hoisted') { if (currentLockfile != null && !opts.ignorePackageManifest) { @@ -235,7 +247,7 @@ export async function headlessInstall (opts: HeadlessOptions): Promise id) - const { lockfile: filteredLockfile, selectedImporterIds: importerIds } = filterLockfileByImportersAndEngine(wantedLockfile, initialImporterIds, { - ...filterOpts, - currentEngine: opts.currentEngine, - engineStrict: opts.engineStrict, - failOnMissingDependencies: true, - includeIncompatiblePackages: opts.force, - lockfileDir, - supportedArchitectures: opts.supportedArchitectures, - }) + const { lockfile: filteredLockfile, selectedImporterIds: importerIds } = filterLockfileByImportersAndEngine(wantedLockfile, initialImporterIds, filterOpts) if (opts.excludeLinksFromLockfile) { for (const { id, manifest, rootDir } of selectedProjects) { if (filteredLockfile.importers[id]) { From cca836ba69ef96d0740f3138a530fc27ac3875e0 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Mon, 23 Oct 2023 04:25:48 +0300 Subject: [PATCH 29/39] fix: prune hoisted node_modules --- .../core/test/install/optionalDependencies.ts | 15 +++++++++++++++ .../headless/src/lockfileToHoistedDepGraph.ts | 6 +++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pkg-manager/core/test/install/optionalDependencies.ts b/pkg-manager/core/test/install/optionalDependencies.ts index eab23144bfb..c335d508ea2 100644 --- a/pkg-manager/core/test/install/optionalDependencies.ts +++ b/pkg-manager/core/test/install/optionalDependencies.ts @@ -617,4 +617,19 @@ describe('supported architectures', () => { }) expect(fs.readdirSync('node_modules/.pnpm').length).toBe(3) }) + test('remove optional dependencies that are not used, when hoisted node linker is used', async () => { + prepareEmpty() + const opts = await testDefaults({ nodeLinker: 'hoisted' }) + + const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-many-optional-deps@1.0.0'], { + ...opts, + supportedArchitectures: { os: ['darwin', 'linux', 'win32'], cpu: ['arm64', 'x64'] }, + }) + + await install(manifest, { + ...opts, + supportedArchitectures: { os: ['darwin'], cpu: ['x64'] }, + }) + expect(fs.readdirSync('node_modules/@pnpm.e2e').sort()).toStrictEqual(['darwin-x64', 'has-many-optional-deps']) + }) }) diff --git a/pkg-manager/headless/src/lockfileToHoistedDepGraph.ts b/pkg-manager/headless/src/lockfileToHoistedDepGraph.ts index e7c10f20c22..9ef6b78621c 100644 --- a/pkg-manager/headless/src/lockfileToHoistedDepGraph.ts +++ b/pkg-manager/headless/src/lockfileToHoistedDepGraph.ts @@ -57,7 +57,11 @@ export async function lockfileToHoistedDepGraph ( ): Promise { let prevGraph!: DependenciesGraph if (currentLockfile?.packages != null) { - prevGraph = (await _lockfileToHoistedDepGraph(currentLockfile, opts)).graph + prevGraph = (await _lockfileToHoistedDepGraph(currentLockfile, { + ...opts, + force: true, + skipped: new Set(), + })).graph } else { prevGraph = {} } From b5274fc2084748eb5f0c144cb15c2c03070f5e93 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Mon, 23 Oct 2023 04:44:54 +0300 Subject: [PATCH 30/39] fix: prune --- __utils__/assert-project/package.json | 2 +- __utils__/assert-store/package.json | 2 +- exec/plugin-commands-rebuild/package.json | 2 +- .../package.json | 2 +- package.json | 2 +- .../plugin-commands-patching/package.json | 2 +- pkg-manager/core/package.json | 2 +- .../core/test/install/optionalDependencies.ts | 15 ++++ pkg-manager/headless/package.json | 2 +- pkg-manager/package-requester/package.json | 2 +- .../plugin-commands-installation/package.json | 2 +- pnpm-lock.yaml | 72 +++++++++---------- pnpm/package.json | 2 +- releasing/plugin-commands-deploy/package.json | 2 +- .../plugin-commands-publishing/package.json | 2 +- .../plugin-commands-licenses/package.json | 2 +- .../plugin-commands-listing/package.json | 2 +- .../plugin-commands-outdated/package.json | 2 +- store/plugin-commands-store/package.json | 2 +- 19 files changed, 68 insertions(+), 53 deletions(-) diff --git a/__utils__/assert-project/package.json b/__utils__/assert-project/package.json index d485d9d4425..c804c6fe2cf 100644 --- a/__utils__/assert-project/package.json +++ b/__utils__/assert-project/package.json @@ -44,7 +44,7 @@ "@pnpm/constants": "workspace:*", "@pnpm/lockfile-types": "workspace:*", "@pnpm/modules-yaml": "workspace:*", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@pnpm/types": "workspace:*", "is-windows": "^1.0.2", "isexe": "2.0.0", diff --git a/__utils__/assert-store/package.json b/__utils__/assert-store/package.json index da56b42ae85..56b1949e082 100644 --- a/__utils__/assert-store/package.json +++ b/__utils__/assert-store/package.json @@ -40,7 +40,7 @@ "test": "pnpm pretest && pnpm run compile && jest" }, "dependencies": { - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@pnpm/store.cafs": "workspace:*", "path-exists": "^4.0.0" }, diff --git a/exec/plugin-commands-rebuild/package.json b/exec/plugin-commands-rebuild/package.json index e91e42e4b72..4603e3cd2b8 100644 --- a/exec/plugin-commands-rebuild/package.json +++ b/exec/plugin-commands-rebuild/package.json @@ -34,7 +34,7 @@ "@pnpm/filter-workspace-packages": "workspace:*", "@pnpm/plugin-commands-rebuild": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@pnpm/test-fixtures": "workspace:*", "@types/ramda": "0.28.20", "@types/semver": "7.5.3", diff --git a/exec/plugin-commands-script-runners/package.json b/exec/plugin-commands-script-runners/package.json index 0ae1ce9b1c0..77886301336 100644 --- a/exec/plugin-commands-script-runners/package.json +++ b/exec/plugin-commands-script-runners/package.json @@ -34,7 +34,7 @@ "@pnpm/filter-workspace-packages": "workspace:*", "@pnpm/plugin-commands-script-runners": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@types/is-windows": "^1.0.0", "@types/ramda": "0.28.20", "@types/which": "^2.0.2", diff --git a/package.json b/package.json index 6440b196aad..fd9279cb180 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@commitlint/prompt-cli": "^17.8.0", "@pnpm/eslint-config": "workspace:*", "@pnpm/meta-updater": "1.0.0", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@pnpm/tsconfig": "workspace:*", "@pnpm/worker": "workspace:*", "@types/jest": "^29.5.5", diff --git a/patching/plugin-commands-patching/package.json b/patching/plugin-commands-patching/package.json index 81528889d07..ffd8c7160ea 100644 --- a/patching/plugin-commands-patching/package.json +++ b/patching/plugin-commands-patching/package.json @@ -34,7 +34,7 @@ "@pnpm/filter-workspace-packages": "workspace:*", "@pnpm/plugin-commands-patching": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@pnpm/test-fixtures": "workspace:*", "@types/normalize-path": "^3.0.0", "@types/npm-packlist": "^3.0.0", diff --git a/pkg-manager/core/package.json b/pkg-manager/core/package.json index bc315d86145..646850a7c79 100644 --- a/pkg-manager/core/package.json +++ b/pkg-manager/core/package.json @@ -81,7 +81,7 @@ "@pnpm/lockfile-types": "workspace:*", "@pnpm/package-store": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@pnpm/store-path": "workspace:*", "@pnpm/store.cafs": "workspace:*", "@pnpm/test-fixtures": "workspace:*", diff --git a/pkg-manager/core/test/install/optionalDependencies.ts b/pkg-manager/core/test/install/optionalDependencies.ts index c335d508ea2..90e0417899a 100644 --- a/pkg-manager/core/test/install/optionalDependencies.ts +++ b/pkg-manager/core/test/install/optionalDependencies.ts @@ -632,4 +632,19 @@ describe('supported architectures', () => { }) expect(fs.readdirSync('node_modules/@pnpm.e2e').sort()).toStrictEqual(['darwin-x64', 'has-many-optional-deps']) }) + test('remove optional dependencies if supported architectures have changed and a new dependency is added', async () => { + prepareEmpty() + const opts = await testDefaults({ modulesCacheMaxAge: 0 }) + + const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/parent-of-has-many-optional-deps@1.0.0'], { + ...opts, + supportedArchitectures: { os: ['darwin', 'linux', 'win32'], cpu: ['arm64', 'x64'] }, + }) + + await addDependenciesToPackage(manifest, ['is-positive@1.0.0'], { + ...opts, + supportedArchitectures: { os: ['darwin'], cpu: ['x64'] }, + }) + expect(fs.readdirSync('node_modules/.pnpm').length).toBe(5) + }) }) diff --git a/pkg-manager/headless/package.json b/pkg-manager/headless/package.json index 2547e3fdb1f..b8bf8654507 100644 --- a/pkg-manager/headless/package.json +++ b/pkg-manager/headless/package.json @@ -22,7 +22,7 @@ "@pnpm/package-store": "workspace:*", "@pnpm/prepare": "workspace:*", "@pnpm/read-projects-context": "workspace:*", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@pnpm/store-path": "workspace:*", "@pnpm/store.cafs": "workspace:*", "@pnpm/test-fixtures": "workspace:*", diff --git a/pkg-manager/package-requester/package.json b/pkg-manager/package-requester/package.json index 3ba9ba1b058..cafbdd7ad7c 100644 --- a/pkg-manager/package-requester/package.json +++ b/pkg-manager/package-requester/package.json @@ -61,7 +61,7 @@ "@pnpm/client": "workspace:*", "@pnpm/create-cafs-store": "workspace:*", "@pnpm/package-requester": "workspace:*", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@pnpm/test-fixtures": "workspace:*", "@types/normalize-path": "^3.0.0", "@types/ramda": "0.28.20", diff --git a/pkg-manager/plugin-commands-installation/package.json b/pkg-manager/plugin-commands-installation/package.json index 7c40c53848d..4d2366c42c0 100644 --- a/pkg-manager/plugin-commands-installation/package.json +++ b/pkg-manager/plugin-commands-installation/package.json @@ -34,7 +34,7 @@ "@pnpm/modules-yaml": "workspace:*", "@pnpm/plugin-commands-installation": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@pnpm/test-fixtures": "workspace:*", "@types/proxyquire": "^1.3.29", "@types/ramda": "0.28.20", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a230ad91a72..53833144337 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -109,8 +109,8 @@ importers: specifier: 1.0.0 version: 1.0.0 '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@pnpm/tsconfig': specifier: workspace:* version: link:__utils__/tsconfig @@ -227,8 +227,8 @@ importers: specifier: workspace:* version: link:../../pkg-manager/modules-yaml '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@pnpm/types': specifier: workspace:* version: link:../../packages/types @@ -264,8 +264,8 @@ importers: __utils__/assert-store: dependencies: '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@pnpm/store.cafs': specifier: workspace:* version: link:../../store/cafs @@ -1286,8 +1286,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -1404,8 +1404,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@types/is-windows': specifier: ^1.0.0 version: 1.0.0 @@ -2817,8 +2817,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -3077,8 +3077,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@pnpm/store-path': specifier: workspace:* version: link:../../store/store-path @@ -3353,8 +3353,8 @@ importers: specifier: workspace:* version: link:../read-projects-context '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@pnpm/store-path': specifier: workspace:* version: link:../../store/store-path @@ -3707,8 +3707,8 @@ importers: specifier: workspace:* version: 'link:' '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -3900,8 +3900,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -4448,8 +4448,8 @@ importers: specifier: workspace:* version: link:../pkg-manifest/read-project-manifest '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@pnpm/run-npm': specifier: workspace:* version: link:../exec/run-npm @@ -4702,8 +4702,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) releasing/plugin-commands-publishing: dependencies: @@ -4799,8 +4799,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@types/cross-spawn': specifier: ^6.0.3 version: 6.0.3 @@ -5350,8 +5350,8 @@ importers: specifier: workspace:* version: link:../../pkg-manifest/read-package-json '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -5414,8 +5414,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@types/ramda': specifier: 0.28.20 version: 0.28.20 @@ -5508,8 +5508,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -5837,8 +5837,8 @@ importers: specifier: workspace:* version: link:../../__utils__/prepare '@pnpm/registry-mock': - specifier: 3.15.0 - version: 3.15.0(typanion@3.14.0) + specifier: 3.16.0 + version: 3.16.0(typanion@3.14.0) '@types/archy': specifier: 0.0.33 version: 0.0.33 @@ -8499,8 +8499,8 @@ packages: strip-bom: 4.0.0 dev: true - /@pnpm/registry-mock@3.15.0(typanion@3.14.0): - resolution: {integrity: sha512-XDJei+9ZYDtfF/7ML+4diDjcKFL5WTtpEh6Jc998c+e5pL6bfpmnqpcDfBuVsxWX3w6bXVTc30aBXm9p8UvCqg==} + /@pnpm/registry-mock@3.16.0(typanion@3.14.0): + resolution: {integrity: sha512-lTkoNBAHth1wpEVsJzAED/uRvNAM40pN78aGcuYmoF37g2eQd3fw9xUhfOeq1DFL5KHm7Ql0eRLBWWg0t9xgGA==} engines: {node: '>=10.13'} hasBin: true dependencies: diff --git a/pnpm/package.json b/pnpm/package.json index 3ce66dd9d95..58322fc2564 100644 --- a/pnpm/package.json +++ b/pnpm/package.json @@ -62,7 +62,7 @@ "@pnpm/prepare": "workspace:*", "@pnpm/read-package-json": "workspace:*", "@pnpm/read-project-manifest": "workspace:*", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@pnpm/run-npm": "workspace:*", "@pnpm/tabtab": "^0.1.2", "@pnpm/test-fixtures": "workspace:*", diff --git a/releasing/plugin-commands-deploy/package.json b/releasing/plugin-commands-deploy/package.json index d10d74caa24..2099ec635d0 100644 --- a/releasing/plugin-commands-deploy/package.json +++ b/releasing/plugin-commands-deploy/package.json @@ -39,7 +39,7 @@ "@pnpm/lockfile-types": "workspace:*", "@pnpm/plugin-commands-deploy": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.15.0" + "@pnpm/registry-mock": "3.16.0" }, "dependencies": { "@pnpm/cli-utils": "workspace:*", diff --git a/releasing/plugin-commands-publishing/package.json b/releasing/plugin-commands-publishing/package.json index 9d0b31278f4..9de6f92eaad 100644 --- a/releasing/plugin-commands-publishing/package.json +++ b/releasing/plugin-commands-publishing/package.json @@ -35,7 +35,7 @@ "@pnpm/filter-workspace-packages": "workspace:*", "@pnpm/plugin-commands-publishing": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@types/cross-spawn": "^6.0.3", "@types/is-windows": "^1.0.0", "@types/npm-packlist": "^3.0.0", diff --git a/reviewing/plugin-commands-licenses/package.json b/reviewing/plugin-commands-licenses/package.json index 8ce39d7bbf8..ed4f496ecd8 100644 --- a/reviewing/plugin-commands-licenses/package.json +++ b/reviewing/plugin-commands-licenses/package.json @@ -36,7 +36,7 @@ "@pnpm/plugin-commands-licenses": "workspace:*", "@pnpm/prepare": "workspace:*", "@pnpm/read-package-json": "workspace:*", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@pnpm/test-fixtures": "workspace:*", "@types/ramda": "0.28.20", "@types/wrap-ansi": "^8.0.1", diff --git a/reviewing/plugin-commands-listing/package.json b/reviewing/plugin-commands-listing/package.json index d63d8a754ff..a869e7ba29e 100644 --- a/reviewing/plugin-commands-listing/package.json +++ b/reviewing/plugin-commands-listing/package.json @@ -34,7 +34,7 @@ "@pnpm/plugin-commands-installation": "workspace:*", "@pnpm/plugin-commands-listing": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@types/ramda": "0.28.20", "execa": "npm:safe-execa@0.1.2", "strip-ansi": "^6.0.1", diff --git a/reviewing/plugin-commands-outdated/package.json b/reviewing/plugin-commands-outdated/package.json index 32377ec1044..8b7503156ae 100644 --- a/reviewing/plugin-commands-outdated/package.json +++ b/reviewing/plugin-commands-outdated/package.json @@ -35,7 +35,7 @@ "@pnpm/plugin-commands-installation": "workspace:*", "@pnpm/plugin-commands-outdated": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@pnpm/test-fixtures": "workspace:*", "@types/ramda": "0.28.20", "@types/wrap-ansi": "^8.0.1", diff --git a/store/plugin-commands-store/package.json b/store/plugin-commands-store/package.json index 0435a40c0c5..48ebf44b236 100644 --- a/store/plugin-commands-store/package.json +++ b/store/plugin-commands-store/package.json @@ -34,7 +34,7 @@ "@pnpm/lockfile-file": "workspace:*", "@pnpm/plugin-commands-store": "workspace:*", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "3.15.0", + "@pnpm/registry-mock": "3.16.0", "@types/archy": "0.0.33", "@types/ramda": "0.28.20", "@types/ssri": "^7.1.2", From 93b894d628c0a72ea57a1ae156a13c45a01a7733 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Tue, 24 Oct 2023 05:11:50 +0300 Subject: [PATCH 31/39] fix: read supportedArchitectures from the right place --- cli/cli-utils/src/readProjectManifest.ts | 49 +++++++++---------- config/config/src/Config.ts | 4 +- .../implementation/extendRebuildOptions.ts | 2 +- exec/plugin-commands-rebuild/src/rebuild.ts | 2 + exec/plugin-commands-rebuild/src/recursive.ts | 2 + .../plugin-commands-script-runners/src/dlx.ts | 3 +- .../plugin-commands-script-runners/src/run.ts | 2 +- .../plugin-commands-patching/src/patch.ts | 1 - .../src/writePackage.ts | 1 - .../plugin-commands-installation/src/fetch.ts | 6 +-- .../src/install.ts | 3 +- .../plugin-commands-installation/src/link.ts | 2 +- .../src/recursive.ts | 1 - pnpm/src/main.ts | 1 - .../plugin-commands-publishing/src/pack.ts | 2 +- .../src/recursivePublish.ts | 1 - .../src/licensesList.ts | 12 ++--- .../plugin-commands-outdated/src/outdated.ts | 2 +- store/plugin-commands-store/src/store.ts | 1 - store/store-connection-manager/src/index.ts | 2 +- 20 files changed, 48 insertions(+), 51 deletions(-) diff --git a/cli/cli-utils/src/readProjectManifest.ts b/cli/cli-utils/src/readProjectManifest.ts index 595d488ab40..3e9d2675f0c 100644 --- a/cli/cli-utils/src/readProjectManifest.ts +++ b/cli/cli-utils/src/readProjectManifest.ts @@ -2,18 +2,25 @@ import * as utils from '@pnpm/read-project-manifest' import { type SupportedArchitectures, type ProjectManifest } from '@pnpm/types' import { packageIsInstallable } from './packageIsInstallable' +export interface ReadProjectManifestOpts { + engineStrict?: boolean + nodeVersion?: string + supportedArchitectures?: SupportedArchitectures +} + +interface BaseReadProjectManifestResult { + fileName: string + writeProjectManifest: (manifest: ProjectManifest, force?: boolean) => Promise +} + +export interface ReadProjectManifestResult extends BaseReadProjectManifestResult { + manifest: ProjectManifest +} + export async function readProjectManifest ( projectDir: string, - opts: { - engineStrict?: boolean - nodeVersion?: string - supportedArchitectures?: SupportedArchitectures - } -): Promise<{ - fileName: string - manifest: ProjectManifest - writeProjectManifest: (manifest: ProjectManifest, force?: boolean) => Promise - }> { + opts: ReadProjectManifestOpts +): Promise { const { fileName, manifest, writeProjectManifest } = await utils.readProjectManifest(projectDir) packageIsInstallable(projectDir, manifest as any, opts) // eslint-disable-line @typescript-eslint/no-explicit-any return { fileName, manifest, writeProjectManifest } @@ -21,29 +28,21 @@ export async function readProjectManifest ( export async function readProjectManifestOnly ( projectDir: string, - opts: { - engineStrict?: boolean - nodeVersion?: string - supportedArchitectures?: SupportedArchitectures - } = {} + opts: ReadProjectManifestOpts = {} ): Promise { const manifest = await utils.readProjectManifestOnly(projectDir) packageIsInstallable(projectDir, manifest as any, opts) // eslint-disable-line @typescript-eslint/no-explicit-any return manifest } +export interface TryReadProjectManifestResult extends BaseReadProjectManifestResult { + manifest: ProjectManifest | null +} + export async function tryReadProjectManifest ( projectDir: string, - opts: { - engineStrict?: boolean - nodeVersion?: string - supportedArchitectures?: SupportedArchitectures - } -): Promise<{ - fileName: string - manifest: ProjectManifest | null - writeProjectManifest: (manifest: ProjectManifest, force?: boolean) => Promise - }> { + opts: ReadProjectManifestOpts +): Promise { const { fileName, manifest, writeProjectManifest } = await utils.tryReadProjectManifest(projectDir) if (manifest == null) return { fileName, manifest, writeProjectManifest } packageIsInstallable(projectDir, manifest as any, opts) // eslint-disable-line @typescript-eslint/no-explicit-any diff --git a/config/config/src/Config.ts b/config/config/src/Config.ts index 76472505341..d602bdbba76 100644 --- a/config/config/src/Config.ts +++ b/config/config/src/Config.ts @@ -1,5 +1,4 @@ import { - type SupportedArchitectures, type Project, type ProjectManifest, type ProjectsGraph, @@ -170,10 +169,9 @@ export interface Config { testPattern?: string[] changedFilesIgnorePattern?: string[] - rootProjectManifestDir?: string + rootProjectManifestDir: string rootProjectManifest?: ProjectManifest userConfig: Record - supportedArchitectures?: SupportedArchitectures } export interface ConfigWithDeprecatedSettings extends Config { diff --git a/exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts b/exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts index 663928067a1..d6ddf3777f5 100644 --- a/exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts +++ b/exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts @@ -101,7 +101,7 @@ export async function extendRebuildOptions ( ...defaultOpts, ...opts, storeDir: defaultOpts.storeDir, - ...(opts.rootProjectManifest ? getOptionsFromRootManifest(opts.rootProjectManifestDir!, opts.rootProjectManifest) : {}), + ...(opts.rootProjectManifest ? getOptionsFromRootManifest(opts.rootProjectManifestDir, opts.rootProjectManifest) : {}), } extendedOpts.registries = normalizeRegistries(extendedOpts.registries) return extendedOpts diff --git a/exec/plugin-commands-rebuild/src/rebuild.ts b/exec/plugin-commands-rebuild/src/rebuild.ts index 3350f760147..37695c0df54 100644 --- a/exec/plugin-commands-rebuild/src/rebuild.ts +++ b/exec/plugin-commands-rebuild/src/rebuild.ts @@ -79,6 +79,8 @@ export async function handler ( | 'lockfileDir' | 'nodeLinker' | 'rawLocalConfig' + | 'rootProjectManifest' + | 'rootProjectManifestDir' | 'registries' | 'scriptShell' | 'selectedProjectsGraph' diff --git a/exec/plugin-commands-rebuild/src/recursive.ts b/exec/plugin-commands-rebuild/src/recursive.ts index f10eeec5f96..5206658675c 100755 --- a/exec/plugin-commands-rebuild/src/recursive.ts +++ b/exec/plugin-commands-rebuild/src/recursive.ts @@ -25,6 +25,8 @@ type RecursiveRebuildOpts = CreateStoreControllerOptions & Pick & { pending?: boolean diff --git a/exec/plugin-commands-script-runners/src/dlx.ts b/exec/plugin-commands-script-runners/src/dlx.ts index 2ff7c122a9d..f735214e729 100644 --- a/exec/plugin-commands-script-runners/src/dlx.ts +++ b/exec/plugin-commands-script-runners/src/dlx.ts @@ -90,10 +90,11 @@ export async function handler ( await add.handler({ // Ideally the config reader should ignore these settings when the dlx command is executed. // This is a temporary solution until "@pnpm/config" is refactored. - ...omit(['workspaceDir', 'rootProjectManifest', 'rootProjectManifestDir'], opts), + ...omit(['workspaceDir', 'rootProjectManifest'], opts), bin: binsDir, dir: prefix, lockfileDir: prefix, + rootProjectManifestDir: prefix, // This property won't be used as rootProjectManifest will be undefined }, pkgs) const binName = opts.package ? command diff --git a/exec/plugin-commands-script-runners/src/run.ts b/exec/plugin-commands-script-runners/src/run.ts index fb734015165..a8495ad9ec1 100644 --- a/exec/plugin-commands-script-runners/src/run.ts +++ b/exec/plugin-commands-script-runners/src/run.ts @@ -154,7 +154,7 @@ export type RunOpts = & Pick & ( & { recursive?: false } - & Partial> + & Partial> | { recursive: true } & Required> ) diff --git a/patching/plugin-commands-patching/src/patch.ts b/patching/plugin-commands-patching/src/patch.ts index 484911d738c..ffe2af4e976 100644 --- a/patching/plugin-commands-patching/src/patch.ts +++ b/patching/plugin-commands-patching/src/patch.ts @@ -60,7 +60,6 @@ export type PatchCommandOptions = Pick -& Partial> & CreateStoreControllerOptions & { editDir?: string reporter?: (logObj: LogBase) => void diff --git a/patching/plugin-commands-patching/src/writePackage.ts b/patching/plugin-commands-patching/src/writePackage.ts index 7e54dcc23b1..4eb974b0f16 100644 --- a/patching/plugin-commands-patching/src/writePackage.ts +++ b/patching/plugin-commands-patching/src/writePackage.ts @@ -19,7 +19,6 @@ export async function writePackage (dep: ParseWantedDependencyResult, dest: stri preferredVersions: {}, projectDir: opts.dir, registry: (dep.alias && pickRegistryForPackage(opts.registries, dep.alias)) ?? opts.registries.default, - supportedArchitectures: opts.supportedArchitectures, }) const { files } = await pkgResponse.fetching!() await store.ctrl.importPackage(dest, { diff --git a/pkg-manager/plugin-commands-installation/src/fetch.ts b/pkg-manager/plugin-commands-installation/src/fetch.ts index b58671c15a8..90f8e7652ff 100644 --- a/pkg-manager/plugin-commands-installation/src/fetch.ts +++ b/pkg-manager/plugin-commands-installation/src/fetch.ts @@ -1,6 +1,6 @@ import { docsUrl } from '@pnpm/cli-utils' import { UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help' -import { type Config } from '@pnpm/config' +import { type Config, getOptionsFromRootManifest } from '@pnpm/config' import { createOrConnectStoreController, type CreateStoreControllerOptions } from '@pnpm/store-connection-manager' import { type InstallOptions, mutateModulesInSingleProject } from '@pnpm/core' import renderHelp from 'render-help' @@ -45,7 +45,7 @@ export function help () { } export async function handler ( - opts: Pick & CreateStoreControllerOptions + opts: Pick & CreateStoreControllerOptions ) { const store = await createOrConnectStoreController(opts) const include = { @@ -61,12 +61,12 @@ export async function handler ( rootDir: process.cwd(), }, { ...opts, + ...getOptionsFromRootManifest(opts.rootProjectManifestDir!, opts.rootProjectManifest ?? {}), ignorePackageManifest: true, include, modulesCacheMaxAge: 0, pruneStore: true, storeController: store.ctrl, storeDir: store.dir, - supportedArchitectures: opts.supportedArchitectures, } as InstallOptions) } diff --git a/pkg-manager/plugin-commands-installation/src/install.ts b/pkg-manager/plugin-commands-installation/src/install.ts index e29b3293c48..fa5f459b11f 100644 --- a/pkg-manager/plugin-commands-installation/src/install.ts +++ b/pkg-manager/plugin-commands-installation/src/install.ts @@ -271,6 +271,7 @@ export type InstallCommandOptions = Pick> +} & Partial> export async function handler ( opts: InstallCommandOptions diff --git a/pkg-manager/plugin-commands-installation/src/link.ts b/pkg-manager/plugin-commands-installation/src/link.ts index 1018d909411..39bd28c1e80 100644 --- a/pkg-manager/plugin-commands-installation/src/link.ts +++ b/pkg-manager/plugin-commands-installation/src/link.ts @@ -44,7 +44,7 @@ type LinkOpts = CreateStoreControllerOptions & Pick & Partial> +> & Partial> export const rcOptionsTypes = cliOptionsTypes diff --git a/pkg-manager/plugin-commands-installation/src/recursive.ts b/pkg-manager/plugin-commands-installation/src/recursive.ts index 3c111ecd853..bf77d8eb18f 100755 --- a/pkg-manager/plugin-commands-installation/src/recursive.ts +++ b/pkg-manager/plugin-commands-installation/src/recursive.ts @@ -92,7 +92,6 @@ type RecursiveOptions = CreateStoreControllerOptions & Pick > & Required< Pick diff --git a/pnpm/src/main.ts b/pnpm/src/main.ts index 5af7293ea87..6586fbf0fff 100644 --- a/pnpm/src/main.ts +++ b/pnpm/src/main.ts @@ -208,7 +208,6 @@ export async function main (inputArgv: string[]) { changedFilesIgnorePattern: config.changedFilesIgnorePattern, useGlobDirFiltering: !config.legacyDirFiltering, sharedWorkspaceLockfile: config.sharedWorkspaceLockfile, - supportedArchitectures: config.supportedArchitectures, }) if (filterResults.allProjects.length === 0) { diff --git a/releasing/plugin-commands-publishing/src/pack.ts b/releasing/plugin-commands-publishing/src/pack.ts index ebfec6f9a76..3fabf734fa5 100644 --- a/releasing/plugin-commands-publishing/src/pack.ts +++ b/releasing/plugin-commands-publishing/src/pack.ts @@ -58,7 +58,7 @@ export function help () { } export async function handler ( - opts: Pick & Pick & Partial> & { + opts: Pick & Pick & Partial> & { argv: { original: string[] } diff --git a/releasing/plugin-commands-publishing/src/recursivePublish.ts b/releasing/plugin-commands-publishing/src/recursivePublish.ts index ec5f5e58bb4..0c3b7f38399 100644 --- a/releasing/plugin-commands-publishing/src/recursivePublish.ts +++ b/releasing/plugin-commands-publishing/src/recursivePublish.ts @@ -46,7 +46,6 @@ Partial> & { access?: 'public' | 'restricted' argv: { diff --git a/reviewing/plugin-commands-licenses/src/licensesList.ts b/reviewing/plugin-commands-licenses/src/licensesList.ts index d67430b8a0b..17921766647 100644 --- a/reviewing/plugin-commands-licenses/src/licensesList.ts +++ b/reviewing/plugin-commands-licenses/src/licensesList.ts @@ -1,5 +1,5 @@ import { readProjectManifestOnly } from '@pnpm/cli-utils' -import { type Config } from '@pnpm/config' +import { type Config, getOptionsFromRootManifest } from '@pnpm/config' import { PnpmError } from '@pnpm/error' import { getStorePath } from '@pnpm/store-path' import { WANTED_LOCKFILE } from '@pnpm/constants' @@ -25,8 +25,10 @@ Config, | 'modulesDir' | 'pnpmHomeDir' | 'selectedProjectsGraph' +| 'rootProjectManifest' +| 'rootProjectManifestDir' > & -Partial> +Partial> export async function licensesList (opts: LicensesCommandOptions) { const lockfile = await readWantedLockfile(opts.lockfileDir ?? opts.dir, { @@ -45,9 +47,7 @@ export async function licensesList (opts: LicensesCommandOptions) { optionalDependencies: opts.optional !== false, } - const manifest = await readProjectManifestOnly(opts.dir, { - - }) + const manifest = await readProjectManifestOnly(opts.dir) const includedImporterIds = opts.selectedProjectsGraph ? Object.keys(opts.selectedProjectsGraph) @@ -70,7 +70,7 @@ export async function licensesList (opts: LicensesCommandOptions) { wantedLockfile: lockfile, manifest, includedImporterIds, - supportedArchitectures: opts.supportedArchitectures, + supportedArchitectures: getOptionsFromRootManifest(opts.rootProjectManifestDir, opts.rootProjectManifest ?? {}).supportedArchitectures, }) if (licensePackages.length === 0) diff --git a/reviewing/plugin-commands-outdated/src/outdated.ts b/reviewing/plugin-commands-outdated/src/outdated.ts index 560fd975200..20a93a6f580 100644 --- a/reviewing/plugin-commands-outdated/src/outdated.ts +++ b/reviewing/plugin-commands-outdated/src/outdated.ts @@ -156,7 +156,7 @@ export type OutdatedCommandOptions = { | 'strictSsl' | 'tag' | 'userAgent' -> & Partial> +> & Partial> export async function handler ( opts: OutdatedCommandOptions, diff --git a/store/plugin-commands-store/src/store.ts b/store/plugin-commands-store/src/store.ts index d7d4c8a27a9..0ec5fcaa30d 100644 --- a/store/plugin-commands-store/src/store.ts +++ b/store/plugin-commands-store/src/store.ts @@ -98,7 +98,6 @@ export async function handler (opts: StoreCommandOptions, params: string[]) { reporter: opts.reporter, storeController: store.ctrl, tag: opts.tag, - supportedArchitectures: opts.supportedArchitectures, }) default: return help() diff --git a/store/store-connection-manager/src/index.ts b/store/store-connection-manager/src/index.ts index d37057821af..4fcf964a02c 100644 --- a/store/store-connection-manager/src/index.ts +++ b/store/store-connection-manager/src/index.ts @@ -22,7 +22,7 @@ export type CreateStoreControllerOptions = Omit & Partial> +> export async function createOrConnectStoreControllerCached ( storeControllerCache: Map>, From 25b7204c735116e9776b14bb14dedd5e98eaaf95 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Tue, 24 Oct 2023 05:41:18 +0300 Subject: [PATCH 32/39] refactor: supported archs --- cli/cli-utils/src/readProjectManifest.ts | 2 +- .../src/checkPlatform.ts | 19 ++++++++----------- .../test/utils/index.ts | 1 + .../test/index.ts | 1 - .../plugin-commands-patching/src/patch.ts | 3 +-- .../plugin-commands-publishing/src/pack.ts | 4 +--- 6 files changed, 12 insertions(+), 18 deletions(-) diff --git a/cli/cli-utils/src/readProjectManifest.ts b/cli/cli-utils/src/readProjectManifest.ts index 3e9d2675f0c..da7bdff8d19 100644 --- a/cli/cli-utils/src/readProjectManifest.ts +++ b/cli/cli-utils/src/readProjectManifest.ts @@ -19,7 +19,7 @@ export interface ReadProjectManifestResult extends BaseReadProjectManifestResult export async function readProjectManifest ( projectDir: string, - opts: ReadProjectManifestOpts + opts: ReadProjectManifestOpts = {} ): Promise { const { fileName, manifest, writeProjectManifest } = await utils.readProjectManifest(projectDir) packageIsInstallable(projectDir, manifest as any, opts) // eslint-disable-line @typescript-eslint/no-explicit-any diff --git a/config/package-is-installable/src/checkPlatform.ts b/config/package-is-installable/src/checkPlatform.ts index 013a9fc0e0a..bd26225e3aa 100644 --- a/config/package-is-installable/src/checkPlatform.ts +++ b/config/package-is-installable/src/checkPlatform.ts @@ -20,7 +20,7 @@ export function checkPlatform ( wantedPlatform: WantedPlatform, supportedArchitectures?: SupportedArchitectures ) { - const platforms = { + const current = { os: dedupeCurrent(process.platform, supportedArchitectures?.os ?? ['current']), cpu: dedupeCurrent(process.arch, supportedArchitectures?.cpu ?? ['current']), libc: dedupeCurrent(currentLibc, supportedArchitectures?.libc ?? ['current']), @@ -30,13 +30,13 @@ export function checkPlatform ( let osOk = true; let cpuOk = true; let libcOk = true if (wantedPlatform.os) { - osOk = checkList(platforms.os, wantedPlatform.os) + osOk = checkList(current.os, wantedPlatform.os) } if (wantedPlatform.cpu) { - cpuOk = checkList(platforms.cpu, wantedPlatform.cpu) + cpuOk = checkList(current.cpu, wantedPlatform.cpu) } if (wantedPlatform.libc && currentLibc !== 'unknown') { - libcOk = checkList(platforms.libc, wantedPlatform.libc) + libcOk = checkList(current.libc, wantedPlatform.libc) } if (!osOk || !cpuOk || !libcOk) { @@ -61,24 +61,21 @@ function checkList (value: string | string[], list: string | string[]): boolean if (typeof list === 'string') { list = [list] } - if (list.length === 1 && list[0] === 'any') { return true } - const values = Array.isArray(value) ? value : [value] - - for (const val of values) { + for (const value of values) { for (let i = 0; i < list.length; ++i) { tmp = list[i] if (tmp[0] === '!') { tmp = tmp.slice(1) - if (tmp === val) { + if (tmp === value) { return false } ++blc } else { - match = match || tmp === val + match = match || tmp === value } } } @@ -87,4 +84,4 @@ function checkList (value: string | string[], list: string | string[]): boolean function dedupeCurrent (current: string, supported: string[]) { return supported.map((supported) => supported === 'current' ? current : supported) -} \ No newline at end of file +} diff --git a/exec/plugin-commands-rebuild/test/utils/index.ts b/exec/plugin-commands-rebuild/test/utils/index.ts index 21783bb9c88..c62c446e97b 100644 --- a/exec/plugin-commands-rebuild/test/utils/index.ts +++ b/exec/plugin-commands-rebuild/test/utils/index.ts @@ -38,6 +38,7 @@ export const DEFAULT_OPTS = { rawLocalConfig: {}, registries: { default: REGISTRY }, registry: REGISTRY, + rootProjectManifestDir: '', sort: true, storeDir: '../store', strictSsl: false, diff --git a/exec/plugin-commands-script-runners/test/index.ts b/exec/plugin-commands-script-runners/test/index.ts index 08b8af3ada1..cd7ca827527 100644 --- a/exec/plugin-commands-script-runners/test/index.ts +++ b/exec/plugin-commands-script-runners/test/index.ts @@ -510,7 +510,6 @@ test('pnpm run with RegExp script selector should work also for pre/post script' extraEnv: {}, rawConfig: {}, enablePrePostScripts: true, - }, ['/build:.*/']) expect(await fs.readFile('output-a.txt', { encoding: 'utf-8' })).toEqual('a') diff --git a/patching/plugin-commands-patching/src/patch.ts b/patching/plugin-commands-patching/src/patch.ts index ffe2af4e976..75977782a63 100644 --- a/patching/plugin-commands-patching/src/patch.ts +++ b/patching/plugin-commands-patching/src/patch.ts @@ -59,8 +59,7 @@ export type PatchCommandOptions = Pick -& CreateStoreControllerOptions & { +> & CreateStoreControllerOptions & { editDir?: string reporter?: (logObj: LogBase) => void ignoreExisting?: boolean diff --git a/releasing/plugin-commands-publishing/src/pack.ts b/releasing/plugin-commands-publishing/src/pack.ts index 3fabf734fa5..ba9dc704dfa 100644 --- a/releasing/plugin-commands-publishing/src/pack.ts +++ b/releasing/plugin-commands-publishing/src/pack.ts @@ -146,9 +146,7 @@ async function packPkg (opts: { projectDir, embedReadme, } = opts - const { manifest } = await readProjectManifest(projectDir, { - - }) + const { manifest } = await readProjectManifest(projectDir) const bins = [ ...(await getBinsFromPackageManifest(manifest as DependencyManifest, projectDir)).map(({ path }) => path), ...(manifest.publishConfig?.executableFiles ?? []) From 4771553a65a27329c117e82fd45073b0b41b0e13 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Tue, 24 Oct 2023 06:10:23 +0300 Subject: [PATCH 33/39] test: fix --- exec/plugin-commands-script-runners/test/utils/index.ts | 2 ++ patching/plugin-commands-patching/test/utils/index.ts | 1 + pkg-manager/plugin-commands-installation/test/add.ts | 1 + pkg-manager/plugin-commands-installation/test/fetch.ts | 1 + pkg-manager/plugin-commands-installation/test/global.ts | 1 + pkg-manager/plugin-commands-installation/test/import.ts | 1 + .../plugin-commands-installation/test/importRecursive.ts | 1 + .../plugin-commands-installation/test/peerDependencies.ts | 1 + pkg-manager/plugin-commands-installation/test/prune.ts | 1 + .../plugin-commands-installation/test/update/interactive.ts | 1 + pkg-manager/plugin-commands-installation/test/utils/index.ts | 1 + reviewing/plugin-commands-outdated/test/utils/index.ts | 1 + 12 files changed, 13 insertions(+) diff --git a/exec/plugin-commands-script-runners/test/utils/index.ts b/exec/plugin-commands-script-runners/test/utils/index.ts index 5b89b9c1b3f..7af9bb71bda 100644 --- a/exec/plugin-commands-script-runners/test/utils/index.ts +++ b/exec/plugin-commands-script-runners/test/utils/index.ts @@ -40,6 +40,7 @@ export const DEFAULT_OPTS = { proxy: undefined, rawConfig: { registry: REGISTRY_URL }, rawLocalConfig: {}, + rootProjectManifestDir: '', registries: { default: REGISTRY_URL }, registry: REGISTRY_URL, sort: true, @@ -79,6 +80,7 @@ export const DLX_DEFAULT_OPTS = { registries: { default: REGISTRY_URL, }, + rootProjectManifestDir: '', sort: true, storeDir: path.join(tmp, 'store'), userConfig: {}, diff --git a/patching/plugin-commands-patching/test/utils/index.ts b/patching/plugin-commands-patching/test/utils/index.ts index 8fa6615d4fe..f9c76366222 100644 --- a/patching/plugin-commands-patching/test/utils/index.ts +++ b/patching/plugin-commands-patching/test/utils/index.ts @@ -39,6 +39,7 @@ export const DEFAULT_OPTS = { rawLocalConfig: {}, registries: { default: REGISTRY }, registry: REGISTRY, + rootProjectManifestDir: '', sort: true, storeDir: '../store', strictSsl: false, diff --git a/pkg-manager/plugin-commands-installation/test/add.ts b/pkg-manager/plugin-commands-installation/test/add.ts index 3ebf1a49265..8b57f42b9c7 100644 --- a/pkg-manager/plugin-commands-installation/test/add.ts +++ b/pkg-manager/plugin-commands-installation/test/add.ts @@ -32,6 +32,7 @@ const DEFAULT_OPTIONS = { registries: { default: REGISTRY_URL, }, + rootProjectManifestDir: '', sort: true, storeDir: path.join(tmp, 'store'), userConfig: {}, diff --git a/pkg-manager/plugin-commands-installation/test/fetch.ts b/pkg-manager/plugin-commands-installation/test/fetch.ts index f423d9824c1..f8dd4087dce 100644 --- a/pkg-manager/plugin-commands-installation/test/fetch.ts +++ b/pkg-manager/plugin-commands-installation/test/fetch.ts @@ -28,6 +28,7 @@ const DEFAULT_OPTIONS = { registries: { default: REGISTRY_URL, }, + rootProjectManifestDir: '', sort: true, userConfig: {}, workspaceConcurrency: 1, diff --git a/pkg-manager/plugin-commands-installation/test/global.ts b/pkg-manager/plugin-commands-installation/test/global.ts index 10308e3dce4..1d8643e60b4 100644 --- a/pkg-manager/plugin-commands-installation/test/global.ts +++ b/pkg-manager/plugin-commands-installation/test/global.ts @@ -31,6 +31,7 @@ const DEFAULT_OPTIONS = { registries: { default: REGISTRY_URL, }, + rootProjectManifestDir: '', sort: true, storeDir: path.join(tmp, 'store'), userConfig: {}, diff --git a/pkg-manager/plugin-commands-installation/test/import.ts b/pkg-manager/plugin-commands-installation/test/import.ts index 18401eb95a2..e3f805d40fc 100644 --- a/pkg-manager/plugin-commands-installation/test/import.ts +++ b/pkg-manager/plugin-commands-installation/test/import.ts @@ -33,6 +33,7 @@ const DEFAULT_OPTS = { rawConfig: { registry: REGISTRY }, registries: { default: REGISTRY }, registry: REGISTRY, + rootProjectManifestDir: '', storeDir: path.join(TMP, 'store'), strictSsl: false, userAgent: 'pnpm', diff --git a/pkg-manager/plugin-commands-installation/test/importRecursive.ts b/pkg-manager/plugin-commands-installation/test/importRecursive.ts index 8eb7cb49208..a1d2fab8ff1 100644 --- a/pkg-manager/plugin-commands-installation/test/importRecursive.ts +++ b/pkg-manager/plugin-commands-installation/test/importRecursive.ts @@ -31,6 +31,7 @@ const DEFAULT_OPTS = { rawConfig: { registry: REGISTRY }, registries: { default: REGISTRY }, registry: REGISTRY, + rootProjectManifestDir: '', storeDir: path.join(TMP, 'store'), strictSsl: false, userAgent: 'pnpm', diff --git a/pkg-manager/plugin-commands-installation/test/peerDependencies.ts b/pkg-manager/plugin-commands-installation/test/peerDependencies.ts index 194bcd4000a..80d4b7c6f48 100644 --- a/pkg-manager/plugin-commands-installation/test/peerDependencies.ts +++ b/pkg-manager/plugin-commands-installation/test/peerDependencies.ts @@ -30,6 +30,7 @@ const DEFAULT_OPTIONS = { registries: { default: REGISTRY_URL, }, + rootProjectManifestDir: '', sort: true, storeDir: path.join(TMP, 'store'), userConfig: {}, diff --git a/pkg-manager/plugin-commands-installation/test/prune.ts b/pkg-manager/plugin-commands-installation/test/prune.ts index e16fd5e705e..2ab96850df9 100644 --- a/pkg-manager/plugin-commands-installation/test/prune.ts +++ b/pkg-manager/plugin-commands-installation/test/prune.ts @@ -30,6 +30,7 @@ const DEFAULT_OPTIONS = { registries: { default: REGISTRY_URL, }, + rootProjectManifestDir: '', sort: true, userConfig: {}, workspaceConcurrency: 1, diff --git a/pkg-manager/plugin-commands-installation/test/update/interactive.ts b/pkg-manager/plugin-commands-installation/test/update/interactive.ts index d487df43272..972117b141e 100644 --- a/pkg-manager/plugin-commands-installation/test/update/interactive.ts +++ b/pkg-manager/plugin-commands-installation/test/update/interactive.ts @@ -37,6 +37,7 @@ const DEFAULT_OPTIONS = { registries: { default: REGISTRY_URL, }, + rootProjectManifestDir: '', sort: true, userConfig: {}, workspaceConcurrency: 1, diff --git a/pkg-manager/plugin-commands-installation/test/utils/index.ts b/pkg-manager/plugin-commands-installation/test/utils/index.ts index 2ffa712ea49..6c65333b736 100644 --- a/pkg-manager/plugin-commands-installation/test/utils/index.ts +++ b/pkg-manager/plugin-commands-installation/test/utils/index.ts @@ -40,6 +40,7 @@ export const DEFAULT_OPTS = { rawLocalConfig: {}, registries: { default: REGISTRY }, registry: REGISTRY, + rootProjectManifestDir: '', sort: true, storeDir: '../store', strictSsl: false, diff --git a/reviewing/plugin-commands-outdated/test/utils/index.ts b/reviewing/plugin-commands-outdated/test/utils/index.ts index c5096b0c2b2..c9af8cafd7e 100644 --- a/reviewing/plugin-commands-outdated/test/utils/index.ts +++ b/reviewing/plugin-commands-outdated/test/utils/index.ts @@ -41,6 +41,7 @@ export const DEFAULT_OPTS = { rawLocalConfig: {}, registries: { default: REGISTRY }, registry: REGISTRY, + rootProjectManifestDir: '', sort: true, storeDir: '../store', strictSsl: false, From 2490390f2f7a57de8aaa31bb4d7b57f8508d250c Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Tue, 24 Oct 2023 06:25:17 +0300 Subject: [PATCH 34/39] test: fix --- lockfile/plugin-commands-audit/test/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lockfile/plugin-commands-audit/test/index.ts b/lockfile/plugin-commands-audit/test/index.ts index 7d8a029f9eb..a5f1775c75a 100644 --- a/lockfile/plugin-commands-audit/test/index.ts +++ b/lockfile/plugin-commands-audit/test/index.ts @@ -50,6 +50,7 @@ export const DEFAULT_OPTS = { rawConfig, rawLocalConfig: {}, registries, + rootProjectManifestDir: '', // registry: REGISTRY, sort: true, storeDir: '../store', From 28ec8a3a48e28360683d88671182358569e8ce23 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Tue, 24 Oct 2023 07:01:36 +0300 Subject: [PATCH 35/39] test: fix --- releasing/plugin-commands-deploy/test/utils/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/releasing/plugin-commands-deploy/test/utils/index.ts b/releasing/plugin-commands-deploy/test/utils/index.ts index 2ffa712ea49..6c65333b736 100644 --- a/releasing/plugin-commands-deploy/test/utils/index.ts +++ b/releasing/plugin-commands-deploy/test/utils/index.ts @@ -40,6 +40,7 @@ export const DEFAULT_OPTS = { rawLocalConfig: {}, registries: { default: REGISTRY }, registry: REGISTRY, + rootProjectManifestDir: '', sort: true, storeDir: '../store', strictSsl: false, From 24011ef725579c877b608df89b9f17e10db172fd Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Tue, 24 Oct 2023 07:18:31 +0300 Subject: [PATCH 36/39] test: fix --- reviewing/plugin-commands-licenses/test/utils/index.ts | 1 + reviewing/plugin-commands-listing/test/utils/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/reviewing/plugin-commands-licenses/test/utils/index.ts b/reviewing/plugin-commands-licenses/test/utils/index.ts index 3a7b96d586e..e4517d6d18e 100644 --- a/reviewing/plugin-commands-licenses/test/utils/index.ts +++ b/reviewing/plugin-commands-licenses/test/utils/index.ts @@ -36,6 +36,7 @@ export const DEFAULT_OPTS = { rawConfig: { registry: REGISTRY }, rawLocalConfig: {}, registries: { default: REGISTRY }, + rootProjectManifestDir: '', // registry: REGISTRY, sort: true, storeDir: '../store', diff --git a/reviewing/plugin-commands-listing/test/utils/index.ts b/reviewing/plugin-commands-listing/test/utils/index.ts index c24e6b10157..6a46b3bec3a 100644 --- a/reviewing/plugin-commands-listing/test/utils/index.ts +++ b/reviewing/plugin-commands-listing/test/utils/index.ts @@ -38,6 +38,7 @@ export const DEFAULT_OPTS = { rawLocalConfig: {}, registries: { default: REGISTRY }, registry: REGISTRY, + rootProjectManifestDir: '', sort: true, storeDir: '../store', strictSsl: false, From d0c762397c96a8b82753efcd1ea018cf9603a3f2 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Tue, 24 Oct 2023 15:24:06 +0300 Subject: [PATCH 37/39] refactor: revert refactor --- exec/plugin-commands-script-runners/src/run.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/exec/plugin-commands-script-runners/src/run.ts b/exec/plugin-commands-script-runners/src/run.ts index a8495ad9ec1..240b092e9d1 100644 --- a/exec/plugin-commands-script-runners/src/run.ts +++ b/exec/plugin-commands-script-runners/src/run.ts @@ -104,9 +104,7 @@ export const completion: CompletionFunc = async (cliOpts, params) => { if (params.length > 0) { return [] } - const manifest = await readProjectManifestOnly(cliOpts.dir as string ?? process.cwd(), { - ...cliOpts, - }) + const manifest = await readProjectManifestOnly(cliOpts.dir as string ?? process.cwd(), cliOpts) return Object.keys(manifest.scripts ?? {}).map((name) => ({ name })) } From 6b8dc98b6479443d3597243ce8b8284d2a462ab5 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Tue, 24 Oct 2023 15:33:25 +0300 Subject: [PATCH 38/39] refactor: rootProjectManifestDir --- pkg-manager/plugin-commands-installation/src/fetch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg-manager/plugin-commands-installation/src/fetch.ts b/pkg-manager/plugin-commands-installation/src/fetch.ts index 90f8e7652ff..12be7421253 100644 --- a/pkg-manager/plugin-commands-installation/src/fetch.ts +++ b/pkg-manager/plugin-commands-installation/src/fetch.ts @@ -61,7 +61,7 @@ export async function handler ( rootDir: process.cwd(), }, { ...opts, - ...getOptionsFromRootManifest(opts.rootProjectManifestDir!, opts.rootProjectManifest ?? {}), + ...getOptionsFromRootManifest(opts.rootProjectManifestDir, opts.rootProjectManifest ?? {}), ignorePackageManifest: true, include, modulesCacheMaxAge: 0, From 6b20099c983a8c603fc945b7ffe17e2fa2156d6c Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Tue, 24 Oct 2023 15:47:11 +0300 Subject: [PATCH 39/39] docs: update changeset --- .changeset/angry-maps-hide.md | 55 +++++++++++++++++++++++++++++++++ .changeset/dirty-crews-boil.md | 5 +++ .changeset/silver-bugs-check.md | 27 ---------------- 3 files changed, 60 insertions(+), 27 deletions(-) create mode 100644 .changeset/angry-maps-hide.md create mode 100644 .changeset/dirty-crews-boil.md delete mode 100644 .changeset/silver-bugs-check.md diff --git a/.changeset/angry-maps-hide.md b/.changeset/angry-maps-hide.md new file mode 100644 index 00000000000..1792857ddc3 --- /dev/null +++ b/.changeset/angry-maps-hide.md @@ -0,0 +1,55 @@ +--- +"@pnpm/plugin-commands-publishing": minor +"@pnpm/plugin-commands-script-runners": minor +"@pnpm/filter-workspace-packages": minor +"@pnpm/plugin-commands-licenses": minor +"@pnpm/plugin-commands-patching": minor +"@pnpm/resolve-dependencies": minor +"@pnpm/package-is-installable": minor +"@pnpm/package-requester": minor +"@pnpm/plugin-commands-rebuild": minor +"@pnpm/store-controller-types": minor +"@pnpm/plugin-commands-store": minor +"@pnpm/license-scanner": minor +"@pnpm/filter-lockfile": minor +"@pnpm/workspace.find-packages": minor +"@pnpm/headless": minor +"@pnpm/deps.graph-builder": minor +"@pnpm/core": minor +"@pnpm/types": minor +"@pnpm/cli-utils": minor +"@pnpm/config": minor +"pnpm": minor +--- + +Support for multiple architectures when installing dependencies [#5965](https://github.com/pnpm/pnpm/issues/5965). + +You can now specify architectures for which you'd like to install optional dependencies, even if they don't match the architecture of the system running the install. Use the `supportedArchitectures` field in `package.json` to define your preferences. + +For example, the following configuration tells pnpm to install optional dependencies for Windows x64: + +```json +{ + "pnpm": { + "supportedArchitectures": { + "os": ["win32"], + "cpu": ["x64"] + } + } +} +``` + +Whereas this configuration will have pnpm install optional dependencies for Windows, macOS, and the architecture of the system currently running the install. It includes artifacts for both x64 and arm64 CPUs: + +```json +{ + "pnpm": { + "supportedArchitectures": { + "os": ["win32", "darwin", "current"], + "cpu": ["x64", "arm64"] + } + } +} +``` + +Additionally, `supportedArchitectures` also supports specifying the `libc` of the system. diff --git a/.changeset/dirty-crews-boil.md b/.changeset/dirty-crews-boil.md new file mode 100644 index 00000000000..1af9ea12d84 --- /dev/null +++ b/.changeset/dirty-crews-boil.md @@ -0,0 +1,5 @@ +--- +"@pnpm/build-modules": patch +--- + +`filesIndexFile` may be undefined. diff --git a/.changeset/silver-bugs-check.md b/.changeset/silver-bugs-check.md deleted file mode 100644 index 0006e998161..00000000000 --- a/.changeset/silver-bugs-check.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -"@pnpm/plugin-commands-installation": minor -"@pnpm/plugin-commands-publishing": minor -"@pnpm/plugin-commands-script-runners": minor -"@pnpm/filter-workspace-packages": minor -"@pnpm/plugin-commands-licenses": minor -"@pnpm/plugin-commands-outdated": minor -"@pnpm/plugin-commands-patching": minor -"@pnpm/resolve-dependencies": minor -"@pnpm/package-is-installable": minor -"@pnpm/package-requester": minor -"@pnpm/plugin-commands-rebuild": minor -"@pnpm/store-controller-types": minor -"@pnpm/plugin-commands-store": minor -"@pnpm/license-scanner": minor -"@pnpm/filter-lockfile": minor -"@pnpm/workspace.find-packages": minor -"@pnpm/headless": minor -"@pnpm/deps.graph-builder": minor -"@pnpm/core": minor -"@pnpm/types": minor -"@pnpm/cli-utils": minor -"@pnpm/config": minor -"pnpm": minor ---- - -Support different architectures when installing dependencies.