-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: patch/replace @changesets/assemble-release-plan to disable major…
… on peer dep change (#3184)
- Loading branch information
1 parent
550e33f
commit c2a63a6
Showing
24 changed files
with
4,808 additions
and
1,416 deletions.
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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
*.md | ||
./assemble-release-plan |
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 |
---|---|---|
|
@@ -10,4 +10,4 @@ pnpm-lock.yaml | |
apps/website-new/docs | ||
|
||
/.nx/workspace-data | ||
/.nx/cache | ||
/.nx/cache |
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 @@ | ||
./dist |
Large diffs are not rendered by default.
Oops, something went wrong.
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,42 @@ | ||
# Assemble Release Plan | ||
|
||
[![View changelog](https://img.shields.io/badge/changelogs.xyz-Explore%20Changelog-brightgreen)](https://changelogs.xyz/@changesets/assemble-release-plan) | ||
|
||
Assemble a release plan for changesets from data about a repository. | ||
|
||
Usage | ||
|
||
```ts | ||
import assembleReleasePlan from "@changesets/assemble-release-plan"; | ||
import readChangesets from "@changesets/read"; | ||
import { read } from "@changesets/config"; | ||
import { getPackages } from "@manypkg/get-packages"; | ||
import { readPreState } from "@changesets/pre"; | ||
|
||
const packages = await getPackages(cwd); | ||
const preState = await readPreState(cwd); | ||
const config = await read(cwd, packages); | ||
const changesets = await readChangesets(cwd, sinceRef); | ||
|
||
const releasePlan = assembleReleasePlan(changesets, packages, config, preState); | ||
``` | ||
|
||
Signature | ||
|
||
```ts | ||
import { NewChangeset, Config, ReleasePlan } from "@changesets/types"; | ||
import { Packages } from "@manypkg/get-packages"; | ||
|
||
assembleReleasePlan = ( | ||
changesets: NewChangeset[], | ||
packages: Packages, | ||
config: Config | ||
) => ReleasePlan; | ||
``` | ||
|
||
This package exists so assembling a release plan can be done without reading from disc. | ||
This is useful primarily for testing within the changesets project, and when you cannot | ||
run commands within the repository you want a release plan for (some CI cases). | ||
|
||
For most cases, you should use `@changesets/get-release-plan` which will read local changeset | ||
files, config, and workspaces, to assemble the release plan from. |
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,11 @@ | ||
module.exports = { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { node: 8 }, | ||
}, | ||
], | ||
], | ||
overrides: [{ test: '**/*.ts', presets: ['@babel/preset-typescript'] }], | ||
}; |
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,59 @@ | ||
{ | ||
"name": "@changesets/assemble-release-plan", | ||
"version": "6.0.4", | ||
"private": true, | ||
"description": "Reads changesets and adds information on dependents that need bumping", | ||
"main": "dist/changesets-assemble-release-plan.cjs.js", | ||
"module": "dist/changesets-assemble-release-plan.esm.js", | ||
"exports": { | ||
".": { | ||
"types": { | ||
"import": "./dist/changesets-assemble-release-plan.cjs.mjs", | ||
"default": "./dist/changesets-assemble-release-plan.cjs.js" | ||
}, | ||
"module": "./dist/changesets-assemble-release-plan.esm.js", | ||
"import": "./dist/changesets-assemble-release-plan.cjs.mjs", | ||
"default": "./dist/changesets-assemble-release-plan.cjs.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"scripts": { | ||
"test": "jest", | ||
"build": "preconstruct build", | ||
"watch": "preconstruct watch", | ||
"postinstall": "preconstruct dev", | ||
"lint": "yarn eslint . --ext .ts,.tsx,.js", | ||
"types:check": "tsc", | ||
"changeset": "packages/cli/bin.js", | ||
"check-all": "yarn test && yarn types:check && yarn lint && yarn format", | ||
"version-packages": "changeset version && yarn format:fix", | ||
"release": "yarn build && changeset publish" | ||
}, | ||
"license": "MIT", | ||
"repository": "https://github.com/changesets/changesets/tree/main/packages/assemble-release-plan", | ||
"dependencies": { | ||
"@changesets/errors": "^0.2.0", | ||
"@changesets/get-dependents-graph": "^2.1.2", | ||
"@changesets/should-skip-package": "^0.1.1", | ||
"@changesets/types": "^6.0.0", | ||
"@manypkg/get-packages": "^1.1.3", | ||
"semver": "^7.5.3" | ||
}, | ||
"devDependencies": { | ||
"@changesets/config": "*", | ||
"@preconstruct/cli": "^2.8.1", | ||
"@babel/preset-typescript": "^7.26.0", | ||
"@babel/preset-env": "^7.26.0" | ||
}, | ||
"preconstruct": { | ||
"packages": [ | ||
"." | ||
], | ||
"exports": { | ||
"importConditionDefaultExport": "default" | ||
}, | ||
"___experimentalFlags_WILL_CHANGE_IN_PATCH": { | ||
"importsConditions": true | ||
} | ||
} | ||
} |
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 @@ | ||
# Get Release Info | ||
|
||
This package does the end-to-end work of reading in the current set of changesets, and generating a release plan | ||
based on them. |
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,57 @@ | ||
import { Linked } from '@changesets/types'; | ||
import { Package } from '@manypkg/get-packages'; | ||
import { InternalRelease } from './types'; | ||
import { getCurrentHighestVersion, getHighestReleaseType } from './utils'; | ||
|
||
/* | ||
WARNING: | ||
Important note for understanding how this package works: | ||
We are doing some kind of wacky things with manipulating the objects within the | ||
releases array, despite the fact that this was passed to us as an argument. We are | ||
aware that this is generally bad practice, but have decided to to this here as | ||
we control the entire flow of releases. | ||
We could solve this by inlining this function, or by returning a deep-cloned then | ||
modified array, but we decided both of those are worse than this solution. | ||
*/ | ||
export default function applyLinks( | ||
releases: Map<string, InternalRelease>, | ||
packagesByName: Map<string, Package>, | ||
linked: Linked, | ||
): boolean { | ||
let updated = false; | ||
|
||
// We do this for each set of linked packages | ||
for (let linkedPackages of linked) { | ||
// First we filter down to all the relevant releases for one set of linked packages | ||
let releasingLinkedPackages = [...releases.values()].filter( | ||
(release) => | ||
linkedPackages.includes(release.name) && release.type !== 'none', | ||
); | ||
|
||
// If we proceed any further we do extra work with calculating highestVersion for things that might | ||
// not need one, as they only have workspace based packages | ||
if (releasingLinkedPackages.length === 0) continue; | ||
|
||
let highestReleaseType = getHighestReleaseType(releasingLinkedPackages); | ||
let highestVersion = getCurrentHighestVersion( | ||
linkedPackages, | ||
packagesByName, | ||
); | ||
|
||
// Finally, we update the packages so all of them are on the highest version | ||
for (let linkedPackage of releasingLinkedPackages) { | ||
if (linkedPackage.type !== highestReleaseType) { | ||
updated = true; | ||
linkedPackage.type = highestReleaseType; | ||
} | ||
if (linkedPackage.oldVersion !== highestVersion) { | ||
updated = true; | ||
linkedPackage.oldVersion = highestVersion; | ||
} | ||
} | ||
} | ||
|
||
return updated; | ||
} |
Oops, something went wrong.