Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add --libc option to override platform specific install #6817

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Install extends ArboristWorkspaceCmd {
'dry-run',
'cpu',
'os',
'libc',
...super.params,
]

Expand Down
2 changes: 2 additions & 0 deletions tap-snapshots/test/lib/commands/config.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"commit-hooks": true,
"cpu": null,
"os": null,
"libc": null,
"depth": null,
"description": true,
"dev": false,
Expand Down Expand Up @@ -245,6 +246,7 @@ json = false
key = null
legacy-bundling = false
legacy-peer-deps = false
libc = null
link = false
local-address = null
location = "user"
Expand Down
4 changes: 2 additions & 2 deletions workspaces/arborist/lib/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ module.exports = cls => class Reifier extends cls {
process.emit('time', timer)
this.addTracker('reify', node.name, node.location)

const { npmVersion, nodeVersion, cpu, os } = this.options
const { npmVersion, nodeVersion, cpu, os, libc } = this.options
const p = Promise.resolve().then(async () => {
// when we reify an optional node, check the engine and platform
// first. be sure to ignore the --force and --engine-strict flags,
Expand All @@ -638,7 +638,7 @@ module.exports = cls => class Reifier extends cls {
// eslint-disable-next-line promise/always-return
if (node.optional) {
checkEngine(node.package, npmVersion, nodeVersion, false)
checkPlatform(node.package, false, { cpu, os })
checkPlatform(node.package, false, { cpu, os, libc })
}
await this[_checkBins](node)
await this[_extractOrLink](node)
Expand Down
16 changes: 10 additions & 6 deletions workspaces/arborist/test/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,17 +465,21 @@ t.test('still do not install optional deps with mismatched platform specificatio
t.test('fail to install deps with mismatched platform specifications', t =>
t.rejects(printReified(fixture(t, 'platform-specification')), { code: 'EBADPLATFORM' }))

t.test('success to install optional deps with matched platform specifications with os and cpu options', t =>
t.test('success to install optional deps with matched platform specifications with os and cpu and libc options', t =>
t.resolveMatchSnapshot(printReified(
fixture(t, 'optional-platform-specification'), { os: 'not-your-os', cpu: 'not-your-cpu' })))
fixture(t, 'optional-platform-specification'), { os: 'not-your-os', cpu: 'not-your-cpu', libc: 'not-your-libc' })))

t.test('fail to install optional deps with matched os and mismatched cpu with os and cpu options', t =>
t.test('fail to install optional deps with matched os and mismatched cpu with os and cpu and libc options', t =>
t.resolveMatchSnapshot(printReified(
fixture(t, 'optional-platform-specification'), { os: 'not-your-os', cpu: 'another-cpu' })))
fixture(t, 'optional-platform-specification'), { os: 'not-your-os', cpu: 'another-cpu', libc: 'not-your-libc' })))

t.test('fail to install optional deps with mismatched os and matched cpu with os and cpu options', t =>
t.test('fail to install optional deps with mismatched os and matched cpu with os and cpu and libc options', t =>
t.resolveMatchSnapshot(printReified(
fixture(t, 'optional-platform-specification'), { os: 'another-os', cpu: 'not-your-cpu' })))
fixture(t, 'optional-platform-specification'), { os: 'another-os', cpu: 'not-your-cpu', libc: 'not-your-libc' })))

t.test('fail to install optional deps with matched os and matched cpu and mismatched libc with os and cpu and libc options', t =>
t.resolveMatchSnapshot(printReified(
fixture(t, 'optional-platform-specification'), { os: 'another-os', cpu: 'not-your-cpu', libc: 'not-your-libc' })))

t.test('dry run, do not get anything wet', async t => {
const cases = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"cpu": [
"not-your-cpu"
],
"libc": [
"not-your-libc"
],
"_id": "platform-specifying-test-package@1.0.0",
"_nodeVersion": "12.18.4",
"_npmVersion": "6.14.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
"unpackedSize": 3481,
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfbRvlCRA9TVsSAnZWagAAIQMP/jgNB73uGp5pHvkumGq7\nyA6DC6pqL3vU7Pwctr7QzYi+1jHcWwHtNHHTYwrZZru04xLpiQk8BohAfmOt\nEXstFVfMR/C/Y1pAxi3ITPj79zTmgixUVaor9knGWov8gHyFgQsg+2Jf/90E\nv0fOnAKe4+tb1xZNtKiG+Jc2KBIBhVG3g+YjYc8xYz8FaS4Gj9GPwozhE/kl\nHOu+cAXI/CM2nu1U0Q9Jgxna3i/uzXs8exZVzErgHs6sQPKxBpRwItcl4bOi\nkvUJA+QKmiUNHJauJc/1/vK4O8TD35+kiFSrg82MHnrYuDSzfpRhnjWFKlSb\nfcdLICfV0PhR/6KX4ct+uepUAHHJXBpOe48X5zXjMtFcl1MkImzNzXLbuOZ+\nXo+8LCCc7K5AuBx4HDkAHU0hjdG7k6FLf+fjIdeDbFy/bjPHzb6ecyKf73hX\n+Fh1szs37uwsT2M500qgYgfsLl2GuguBEz2IrFaA7ZGmzXZSF34lsH1dXDgY\nl/CFekaEvA4QaIvGL8BM8CdWkFA2VN8xTuZ9+gC9vsLOSnmaM8Qp1iS+mfr9\nVC5FhANvIi8Ckx0iNJQZ0pC8hMdrT5ox8/oSA42l8XZn4PWQWUco3RA6ksig\n2tcUTuRUDeb40SZV3i1l2xS76YBT4ROeYGyXoiPHBECIo4ps0mGmSd1v3Jdk\nk1n3\r\n=gZQk\r\n-----END PGP SIGNATURE-----\r\n"
},
"os": [
"not-your-os"
],
"cpu": [
"not-your-cpu"
]
"os": ["not-your-os"],
"cpu": ["not-your-cpu"],
"libc": ["not-your-libc"]
}
},
"modified": "2020-09-24T22:21:27.433Z"
Expand Down
10 changes: 10 additions & 0 deletions workspaces/config/lib/definitions/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,16 @@ define('os', {
flatten,
})

define('libc', {
default: null,
type: [null, String],
description: `
Override libc of native modules to install.
Acceptable values are same as \`libc\` field of package.json
`,
flatten,
})

define('depth', {
default: null,
defaultDescription: `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ Object {
"legacy-peer-deps": Array [
"boolean value (true or false)",
],
"libc": Array [
null,
Function String(),
],
"link": Array [
"boolean value (true or false)",
],
Expand Down
Loading