Reimplement changesets as a core command group #586
Closed
paularmstrong
started this conversation in
Ideas
Replies: 1 comment
-
This work has been done in #582 and merged. It may not be complete and there may be some bugs. Consumers should utilize @onerepo/plugin-changesets until stable 1.0.0 release. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem:
The changesets plugin relies on changesets, a third-party open source tool. While it exposes various packages that can be used within other tools, it is not primarily designed to do so.
There are also various issues:
Solution:
Design details
Entry-point
one change
one changeet
,one changeets
one change add
one change
Changeset files
Changeset files should be added to the Workspace they are related to. This requires that any changeset that spans multiple Workspaces be duplicated to each Workspace.
The third-party changesets package writes to a root directory for all changes with a single file per change (regardless of the number of Workspaces they affect). This is generally fine, except when you have a distributed team working on many different projects, potentially unrelated. It also requires adding the changeset files to an ignore list when determining the affected graph for any given commit/pr.
By duplicating changeset within each Workspace, we have a clearer birds-eye view of the affected Workspaces without needing to run any scripts, as well as allow special rules per Workspace when adding/modifying and requiring changeset entries. Furthermore, this prevents requiring that two modules sharing a changeset be versioned at the same time, when those two modules may not actually share a dependency tree.
Example:
In the event that a change affects both
carrot
andraddish
, we will write the same file in each Workspace's.changes/
directory:File details
Filename
The filenames shall be composed of a number and hash of the contents, separated by a dash (
-
).The number will be determined as a 0-based incremental index against the other files within each Workspace's individual
.changes
directory. This allows developers to quickly determine order of changes when reviewing, before versioning & publishing.It is explicitly okay if two change entries have the same index. This is helpful in understanding potential parallel work done across changes.
The
hash
value will be determined via the initial hash of the contents written to the file. Thehash
does not need to stay up to date and is only used as an initial way to create uniqueness of filename quickly.Example:
Frontmatter:
type
'patch' | 'minor' | 'major'
related
Array<string>
Modifying change entries
Change entries may be modified manually at any time. Validity will be determined at version time.
one change migrate
.changeset
files to oneRepo changesone change pre
one change prerelease
,one change pre-release
one change version
pre
1.0.0-pre.0
,1.0.0-pre.1
,1.0.0-pre.2
package.json
for both theversion
string in each Workspace as well as thedependencies
anddevDependencies
versions.peerDependencies
versions will be verified for overlapone change version
one change up
includeGitLogs
false
, warns about dependencies with git log entries but no change entries since last version. Prompts for okay (bypass with-y
)true
, will present git logs without change entries for each Workspace and prompt for semantic version increment type.-y
)writeSafe
modepackage.json
for both theversion
string in each Workspace as well as thedependencies
anddevDependencies
versions.peerDependencies
versions will be verified for overlapone change publish
Determining version-able Workspaces
Glob for
.changes/*.md
in each workspace. If there are files, mark it versionable and continue to next workspace.If there are not change files, get the SHA from the last time the
"version": "${workspace.version}"
was modifiedgit log -S '"version": "…"' -n 1 --format=format:%H -- path/to/package.json
If there were git logs modifying anything in each workspace since its version modification SHA, it should be considered available for versioning.
Alternative lookup methods
This could be problematic in repositories where merge-commits and history modification may be allowed.
Beta Was this translation helpful? Give feedback.
All reactions