{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/web-build-tools/issues/721","repository_url":"https://api.github.com/repos/Microsoft/web-build-tools","labels_url":"https://api.github.com/repos/Microsoft/web-build-tools/issues/721/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/web-build-tools/issues/721/comments","events_url":"https://api.github.com/repos/Microsoft/web-build-tools/issues/721/events","html_url":"https://github.com/Microsoft/web-build-tools/issues/721","id":335452380,"node_id":"MDU6SXNzdWUzMzU0NTIzODA=","number":721,"title":"Proposal: Add a 'variants' feature to support validating multiple dependency sets in the same repo","user":{"login":"ThomasMichon","id":6828233,"node_id":"MDQ6VXNlcjY4MjgyMzM=","avatar_url":"https://avatars0.githubusercontent.com/u/6828233?v=4","gravatar_id":"","url":"https://api.github.com/users/ThomasMichon","html_url":"https://github.com/ThomasMichon","followers_url":"https://api.github.com/users/ThomasMichon/followers","following_url":"https://api.github.com/users/ThomasMichon/following{/other_user}","gists_url":"https://api.github.com/users/ThomasMichon/gists{/gist_id}","starred_url":"https://api.github.com/users/ThomasMichon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThomasMichon/subscriptions","organizations_url":"https://api.github.com/users/ThomasMichon/orgs","repos_url":"https://api.github.com/users/ThomasMichon/repos","events_url":"https://api.github.com/users/ThomasMichon/events{/privacy}","received_events_url":"https://api.github.com/users/ThomasMichon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-25T15:17:06Z","updated_at":"2018-06-26T20:55:13Z","closed_at":null,"author_association":"MEMBER","body":"# Summary\r\n\r\nAdd support for a `--variant` command-line parameter to core Rush commands which can be used to install and link an alternate configuration of `node_modules` based on selected overrides. This option would allow for continuous integration which validates that packages published from a Repo actually support the dependency range declared in their `package.json` file.\r\n\r\n```bash\r\nrush install\r\nrush build\r\nrush install --variant old-dependencies\r\nrush build\r\n```\r\n\r\n# Concepts\r\n\r\nIntroduce the concept of a `variant`, which is an override for `common-versions.json` and an associated alternate Shrinkwrap file, which may be checked into the repository alongside the original versions. This variant may be selected and used by adding `--variant <name>` to Rush commands which interact with the Shrinkwrap file, such as `rush install`, `rush update`, `rush link`, and `rush check`.\r\n\r\nA variant is created by adding a subfolder under Rush configuration:\r\n\r\n```\r\ncommon/\r\n  config/\r\n    rush/\r\n      variants/\r\n        old-dependencies/ <-- Name of variant\r\n          common-versions.json <-- Overrides for variant\r\n      common-versions.json <-- Original Rush config\r\n```\r\n\r\nThe expectation is that each `package.json` in the repository may declare support for a range of a dependency, but that `common-versions.json` typically declares a `preferredVersion` for such a dependency, and thus only that version is installed and validated against. The `common-versions.json` under `variants` subfolder may declare a different version of that dependency in `preferredVersions`:\r\n\r\n`foo/package.json`:\r\n```json\r\n{\r\n    \"dependencies\": {\r\n        \"dependency-a\": \"^4.0.0 || ^5.0.0\"\r\n    }\r\n}\r\n```\r\n\r\n`common/config/rush/common-versions.json`:\r\n```json\r\n{\r\n    \"preferredVersions\": {\r\n        \"dependency-a\": \"5.0.1\"\r\n    }\r\n}\r\n```\r\n\r\n`common/config/rush/variants/old-dependencies/common-versions.json`:\r\n```json\r\n{\r\n    \"preferredVersions\": {\r\n        \"dependency-a\": \"4.13.2\"\r\n    }\r\n}\r\n```\r\n\r\nEach variant will have its own Shrinkwrap file, which will ensure that it installs deterministically for all consumers.\r\n\r\nBy default, `rush install` will install the *default* variant. But developers or lab automation may install a different variant by using `rush install --variant old-dependencies`. Developers will also need to create or update the variant's Shrinkwrap file by using `rush update --variant old-dependencies`.\r\n\r\n# Modifications\r\n\r\nAdd `--variant` as a single-argument command line parameter to all Rush commands which depend on or modify the dependency configuration in Rush. These include\r\n\r\n- `rush install`\r\n- `rush update`\r\n- `rush check`\r\n- `rush link`\r\n\r\nAllow `--variant` to pull automatically from a `RUSH_VARIANT` environment variable, if present, to simplify modification to existing lab automation tasks.\r\n\r\n# Benefits\r\n\r\nThis 'variants' feature will allow repository maintainers to ensure that their published packages truly support the range of dependencies they declare, by providing a way to maintain multiple sets of preferred dependency versions within the repository, and by making it possible to switch to variants at any time before running validation.\r\n\r\nSince this feature will add a way to create alternate `common-versions.json` and Shrinkwrap files than the default checked-in versions, it will also provide a clean mechanism to run repo-wide validation against incoming new versions of packages, since a script may easily generate a variant subfolder and configuration, and then install that variant. The given named variant may be added to `.gitignore`, ensuring it does not disturb other local changes.\r\n\r\n`.gitignore`:\r\n```\r\n/common/config/rush/variants/dev\r\n```\r\n\r\n`common/config/rush/variants/dev/common-versions.json`:\r\n```json\r\n{\r\n    \"preferredVersions\": {\r\n        \"dependency-a\": \"5.0.1-dev.1\"\r\n    }\r\n}\r\n```\r\n\r\n```\r\nrush update --variant dev\r\nrush build\r\n```\r\n\r\nSuch a system could be used to create multi-repo build validation jobs with some additional work."},"comment":{"url":"https://api.github.com/repos/Microsoft/web-build-tools/issues/comments/400459058","html_url":"https://github.com/Microsoft/web-build-tools/issues/721#issuecomment-400459058","issue_url":"https://api.github.com/repos/Microsoft/web-build-tools/issues/721","id":400459058,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDQ1OTA1OA==","user":{"login":"pgonzal","id":4673363,"node_id":"MDQ6VXNlcjQ2NzMzNjM=","avatar_url":"https://avatars0.githubusercontent.com/u/4673363?v=4","gravatar_id":"","url":"https://api.github.com/users/pgonzal","html_url":"https://github.com/pgonzal","followers_url":"https://api.github.com/users/pgonzal/followers","following_url":"https://api.github.com/users/pgonzal/following{/other_user}","gists_url":"https://api.github.com/users/pgonzal/gists{/gist_id}","starred_url":"https://api.github.com/users/pgonzal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgonzal/subscriptions","organizations_url":"https://api.github.com/users/pgonzal/orgs","repos_url":"https://api.github.com/users/pgonzal/repos","events_url":"https://api.github.com/users/pgonzal/events{/privacy}","received_events_url":"https://api.github.com/users/pgonzal/received_events","type":"User","site_admin":false},"created_at":"2018-06-26T20:55:13Z","updated_at":"2018-06-26T20:55:13Z","author_association":"CONTRIBUTOR","body":"We reviewed this design with Thomas today.  We think it’s an insightful idea and useful feature!  The impact on other Rush features seems minimal.  Our main feedback was to declare the variants in rush.json and include descriptions for them."}}
{"actor":{"display_login":"pgonzal"}}