forked from yarnpkg/berry
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Variants #1
Open
Mike-Dax
wants to merge
29
commits into
master
Choose a base branch
from
variants
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Variants #1
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
30a5e75
wip: Variants
Mike-Dax b0b0b10
bug: Fixed scheduling incorrect descriptor resolution
Mike-Dax 6c476af
wip: Replace packages on variants found
Mike-Dax ec03740
chore: Added variants to all resolvers
Mike-Dax 0c7b9b5
test: Variant Utility tests
Mike-Dax b95e473
wip: Custom comparators for variant parameters
Mike-Dax 4732b34
refactor: Allow dependenciesMeta to change variant parameters
Mike-Dax 3f1c0bb
feat: PackageExtensions support Variant information
Mike-Dax 5752541
wip: Added untyped configuration for Variants
Mike-Dax 6d00881
chore: Don't overwrite Manifest if variants is null
Mike-Dax bad1289
bug: Compare the correct locator when replacing packages
Mike-Dax ca8089f
bug: Register the old package
Mike-Dax 9d933da
refactor: Removed candidates key
Mike-Dax 8b9da9a
feat: Cache parameters for variants
Mike-Dax eb3c338
feat: Explicit includes for variants
Mike-Dax c4086a9
feat: Reach into the parent package and delete the old dependency
Mike-Dax d476c04
refactor: Replace the descriptor hashes with our new dependency
Mike-Dax f7b71af
test: Added variant fixtures
Mike-Dax d68e502
test: Initial variant integration tests
Mike-Dax d694886
feat: Workspace getDependencyMeta method
Mike-Dax 11019ec
test: Fixed variantUtil unit tests
Mike-Dax 9e45dfe
feat: Download variants
Mike-Dax b8e2f6e
chore: Minor cleanup
Mike-Dax 2eb91d1
chore: Bind descriptor
Mike-Dax b761a9d
chore: Cleanup of log spam
Mike-Dax df6530c
chore: Added temporary test case into the repo
Mike-Dax 0967f6d
chore: Use variant-fallback test package
Mike-Dax f8f0961
refactor: Use VariantRemapResolver instead of npm one
Mike-Dax 5446f9e
chore: Fixed ordering of debug log
Mike-Dax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-1.0.0/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* @flow */ | ||
|
||
module.exports = require(`./package.json`); | ||
|
||
for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
for (const dep of Object.keys(module.exports[key] || {})) { | ||
// $FlowFixMe The whole point of this file is to be dynamic | ||
module.exports[key][dep] = require(dep); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-1.0.0/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "variants", | ||
"version": "1.0.0", | ||
"variants": [ | ||
{ | ||
"pattern": "variants-%par1-%par2@%version", | ||
"matrix": { | ||
"par1": [ | ||
"a", | ||
"b", | ||
"c" | ||
], | ||
"par2": [ | ||
1, | ||
2 | ||
] | ||
}, | ||
"exclude": [ | ||
{ | ||
"par1": "c", | ||
"par2": 1 | ||
} | ||
] | ||
}, | ||
{ | ||
"pattern": "variants-%par1@%version", | ||
"matrix": { | ||
"par1": [ | ||
"d" | ||
] | ||
} | ||
}, | ||
{ | ||
"pattern": "variants-fallback@%version" | ||
} | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-a-1-1.0.0/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* @flow */ | ||
|
||
module.exports = require(`./package.json`); | ||
|
||
for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
for (const dep of Object.keys(module.exports[key] || {})) { | ||
// $FlowFixMe The whole point of this file is to be dynamic | ||
module.exports[key][dep] = require(dep); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-a-1-1.0.0/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "variants-a-1", | ||
"version": "1.0.0" | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-a-2-1.0.0/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* @flow */ | ||
|
||
module.exports = require(`./package.json`); | ||
|
||
for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
for (const dep of Object.keys(module.exports[key] || {})) { | ||
// $FlowFixMe The whole point of this file is to be dynamic | ||
module.exports[key][dep] = require(dep); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-a-2-1.0.0/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "variants-a-2", | ||
"version": "1.0.0" | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-b-1-1.0.0/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* @flow */ | ||
|
||
module.exports = require(`./package.json`); | ||
|
||
for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
for (const dep of Object.keys(module.exports[key] || {})) { | ||
// $FlowFixMe The whole point of this file is to be dynamic | ||
module.exports[key][dep] = require(dep); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-b-1-1.0.0/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "variants-b-1", | ||
"version": "1.0.0" | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-b-2-1.0.0/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* @flow */ | ||
|
||
module.exports = require(`./package.json`); | ||
|
||
for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
for (const dep of Object.keys(module.exports[key] || {})) { | ||
// $FlowFixMe The whole point of this file is to be dynamic | ||
module.exports[key][dep] = require(dep); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-b-2-1.0.0/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "variants-b-2", | ||
"version": "1.0.0" | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-c-2-1.0.0/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* @flow */ | ||
|
||
module.exports = require(`./package.json`); | ||
|
||
for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
for (const dep of Object.keys(module.exports[key] || {})) { | ||
// $FlowFixMe The whole point of this file is to be dynamic | ||
module.exports[key][dep] = require(dep); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-c-2-1.0.0/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "variants-c-2", | ||
"version": "1.0.0" | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-d-1.0.0/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* @flow */ | ||
|
||
module.exports = require(`./package.json`); | ||
|
||
for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
for (const dep of Object.keys(module.exports[key] || {})) { | ||
// $FlowFixMe The whole point of this file is to be dynamic | ||
module.exports[key][dep] = require(dep); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-d-1.0.0/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "variants-d", | ||
"version": "1.0.0" | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-fallback-1.0.0/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* @flow */ | ||
|
||
module.exports = require(`./package.json`); | ||
|
||
for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
for (const dep of Object.keys(module.exports[key] || {})) { | ||
// $FlowFixMe The whole point of this file is to be dynamic | ||
module.exports[key][dep] = require(dep); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/acceptance-tests/pkg-tests-fixtures/packages/variants-fallback-1.0.0/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "variants-fallback", | ||
"version": "1.0.0" | ||
} |
88 changes: 88 additions & 0 deletions
88
packages/acceptance-tests/pkg-tests-specs/sources/variants.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import {PortablePath, xfs} from '@yarnpkg/fslib'; | ||
import {yarn} from 'pkg-tests-core'; | ||
|
||
const {writeConfiguration} = yarn; | ||
|
||
describe(`Variant tests`, () => { | ||
test( | ||
`it should install the fallback dependency when no matching pattern can be found`, | ||
makeTemporaryEnv( | ||
{ | ||
dependencies: {[`variants`]: `1.0.0`}, | ||
}, | ||
async ({run, source}) => { | ||
await run(`install`); | ||
|
||
await expect(source(`require('variants')`)).resolves.toMatchObject({ | ||
name: `variants-fallback`, | ||
version: `1.0.0`, | ||
}); | ||
}, | ||
), | ||
); | ||
|
||
test( | ||
`it should correctly install a dependency matching parameters set in the dependenciesMeta`, | ||
makeTemporaryEnv( | ||
{ | ||
dependencies: {[`variants`]: `1.0.0`}, | ||
dependenciesMeta: { | ||
[`variants`]: { | ||
parameters: { | ||
par1: `a`, | ||
par2: 1, | ||
}, | ||
}, | ||
}, | ||
}, | ||
async ({run, source}) => { | ||
await run(`install`); | ||
|
||
await expect(source(`require('variants')`)).resolves.toMatchObject({ | ||
name: `variants-a-1`, | ||
version: `1.0.0`, | ||
}); | ||
}, | ||
), | ||
); | ||
|
||
test( | ||
`it should fetch the matrix of cached variants set in the yarnrc`, | ||
makeTemporaryEnv( | ||
{ | ||
dependencies: {[`variants`]: `1.0.0`}, | ||
dependenciesMeta: { | ||
[`variants`]: { | ||
parameters: { | ||
par1: `a`, | ||
par2: 1, | ||
}, | ||
}, | ||
}, | ||
}, | ||
async ({path, run}) => { | ||
await writeConfiguration(path, { | ||
cacheParameters: { | ||
matrix: { | ||
par1: [`a`, `b`, `c`], | ||
par2: [1], | ||
}, | ||
}, | ||
}); | ||
|
||
await run(`install`); | ||
|
||
|
||
const cache = await xfs.readdirPromise(`${path}/.yarn/cache` as PortablePath); | ||
|
||
const variantA1 = cache.find(file => file.startsWith(`variants-a-1-npm-1.0.0`)); | ||
const variantB1 = cache.find(file => file.startsWith(`variants-b-1-npm-1.0.0`)); | ||
const variantC1 = cache.find(file => file.startsWith(`variants-c-1-npm-1.0.0`)); | ||
|
||
expect(variantA1).toBeDefined(); | ||
expect(variantB1).toBeDefined(); | ||
expect(variantC1).not.toBeDefined(); // C1 is excluded by the variants package | ||
}, | ||
), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* @flow */ | ||
|
||
module.exports = require(`./package.json`); | ||
|
||
for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
for (const dep of Object.keys(module.exports[key] || {})) { | ||
// $FlowFixMe The whole point of this file is to be dynamic | ||
module.exports[key][dep] = require(dep); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "variant-fallback", | ||
"version": "0.12.22" | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* @flow */ | ||
|
||
module.exports = require(`./package.json`); | ||
|
||
for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
for (const dep of Object.keys(module.exports[key] || {})) { | ||
// $FlowFixMe The whole point of this file is to be dynamic | ||
module.exports[key][dep] = require(dep); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you accidentally put this package in the wrong folder (it should be in the acceptance tests folder)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was testing just 'in the yarn repo' since the iteration speed was faster, but I'll clean this up before the actual PR.