From 845dc13f2bc530e064151d410c8f15b677a5cfb0 Mon Sep 17 00:00:00 2001 From: merceyz Date: Mon, 11 Apr 2022 15:50:54 +0200 Subject: [PATCH] fix(plugin-nm): handle `supportedArchitectures` --- .yarn/versions/cb320125.yml | 23 ++++++++++++++++ CHANGELOG.md | 1 + .../sources/node-modules.test.ts | 27 +++++++++++++++++++ .../plugin-nm/sources/NodeModulesLinker.ts | 2 +- 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .yarn/versions/cb320125.yml diff --git a/.yarn/versions/cb320125.yml b/.yarn/versions/cb320125.yml new file mode 100644 index 000000000000..bd3ff1a3f753 --- /dev/null +++ b/.yarn/versions/cb320125.yml @@ -0,0 +1,23 @@ +releases: + "@yarnpkg/cli": patch + "@yarnpkg/plugin-nm": patch + +declined: + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-constraints" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-essentials" + - "@yarnpkg/plugin-init" + - "@yarnpkg/plugin-interactive-tools" + - "@yarnpkg/plugin-npm-cli" + - "@yarnpkg/plugin-pack" + - "@yarnpkg/plugin-patch" + - "@yarnpkg/plugin-pnp" + - "@yarnpkg/plugin-pnpm" + - "@yarnpkg/plugin-stage" + - "@yarnpkg/plugin-typescript" + - "@yarnpkg/plugin-version" + - "@yarnpkg/plugin-workspace-tools" + - "@yarnpkg/builder" + - "@yarnpkg/core" + - "@yarnpkg/doctor" diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dd1e89ffc62..585a27817438 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ The following changes only affect people writing Yarn plugins: - applies hoisting algorithm on aliased dependencies - reinstalls modules that have their directories removed from node_modules by the user - improves portal hoisting + - supports `supportedArchitectures` ### Bugfixes diff --git a/packages/acceptance-tests/pkg-tests-specs/sources/node-modules.test.ts b/packages/acceptance-tests/pkg-tests-specs/sources/node-modules.test.ts index c2de45103062..6d63f567b7e7 100644 --- a/packages/acceptance-tests/pkg-tests-specs/sources/node-modules.test.ts +++ b/packages/acceptance-tests/pkg-tests-specs/sources/node-modules.test.ts @@ -1722,4 +1722,31 @@ describe(`Node_Modules`, () => { }); }), ); + + it(`should support supportedArchitectures`, + makeTemporaryEnv( + { + dependencies: { + native: `1.0.0`, + }, + }, + async ({path, run}) => { + await xfs.writeJsonPromise(ppath.join(path, Filename.rc), { + nodeLinker: `node-modules`, + supportedArchitectures: { + os: [`foo`], + cpu: [`x64`, `x86`], + }, + }); + + await expect(run(`install`)).resolves.toMatchObject({code: 0}); + + await expect(xfs.readdirPromise(ppath.join(path, Filename.nodeModules))).resolves.toEqual([ + `.yarn-state.yml`, + `native`, + `native-foo-x64`, + `native-foo-x86`, + ]); + }), + ); }); diff --git a/packages/plugin-nm/sources/NodeModulesLinker.ts b/packages/plugin-nm/sources/NodeModulesLinker.ts index 5e4d23a4167b..f46bbd4888f2 100644 --- a/packages/plugin-nm/sources/NodeModulesLinker.ts +++ b/packages/plugin-nm/sources/NodeModulesLinker.ts @@ -148,7 +148,7 @@ class NodeModulesInstaller implements Installer { } // We don't link the package at all if it's for an unsupported platform - if (!jsInstallUtils.checkManifestCompatibility(pkg)) + if (!structUtils.isPackageCompatible(pkg, this.opts.project.configuration.getSupportedArchitectures())) return {packageLocation: null, buildDirective: null}; const packageDependencies = new Map();