Skip to content

Commit 0b1be8d

Browse files
JohnCampionJrclaude
andcommitted
Bring commands-implementation-details up to date
Document every command (adds pre, tag, info, ui, shell-init) and correct the stale sections: add now lists its flags, publish describes the registry-aware behavior (not the old git-diff approach), and status describes the grouped plan. Add an interop/front-door delegation section and note the changelog generators. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f925b28 commit 0b1be8d

1 file changed

Lines changed: 104 additions & 46 deletions

File tree

Lines changed: 104 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,151 @@
11
# Commands implementation details
22

3-
On this page, we will discuss implementation details that differ slightly from the original changeset implementation [@changesets/cli](https://github.com/changesets/changesets/tree/main).
3+
This page covers each net-changesets command and where its behaviour differs from the original
4+
[`@changesets/cli`](https://github.com/changesets/changesets/tree/main). All commands share the
5+
`.changeset/config.json` schema described in [config-file-options.md](config-file-options.md).
46

57
## `init`
68

79
```bash
810
changeset init
911
```
1012

11-
This command works the same, only difference is that we have different configuration schema to satisfy .NET implementation. You can read more about it in [config-file-options.md](https://github.com/solarwinds/net-changesets/blob/main/docs/config-file-options.md).
13+
Creates the `.changeset` folder and a `config.json`. The only difference from `@changesets` is the
14+
configuration schema, which adds a `dotnet` section for the .NET-only settings (see
15+
[config-file-options.md](config-file-options.md)).
1216

1317
## `add`
1418

1519
```bash
16-
changeset add
20+
changeset add # or just `changeset` (add is the default command)
1721
```
1822

19-
or just (`add` is the default command)
23+
Discovers projects, prompts for which changed, the bump type, and a summary, then writes a changeset to
24+
`.changeset/<random-name>.md`. Options:
25+
26+
- `--empty` — writes a changeset with no releases (useful to force a release run).
27+
- `-m`, `--message <summary>` — supplies the summary instead of prompting.
28+
- `--open` — opens the new changeset in your editor (`$VISUAL` / `$EDITOR`).
29+
- `--since <ref>` — pre-selects the projects that changed since a git ref.
30+
31+
Differences from `@changesets`: a single bump type is chosen for all selected projects (the Node version
32+
allows a different bump per project); in interop mode the file is written with the
33+
[`changesetExtension`](config-file-options.md#changesetextension) (default `.net.mkd`).
34+
35+
## `version`
2036

2137
```bash
22-
changeset
38+
changeset version
39+
changeset version --snapshot [tag]
40+
changeset version --independent
2341
```
2442

25-
This is the default command when running Changesets without specifying a command.
26-
Currently, the tool does not support any command-line options and runs only in interactive mode.
27-
The changeset file name is randomly generated using lowercase letters from the English alphabet.
43+
Consumes changesets, bumps versions, writes `CHANGELOG.md` files, and (by default) deletes the processed
44+
changesets. It also bumps every project that depends (via `ProjectReference`) on a changed project — always by
45+
a patch, because a `ProjectReference` carries no version range (matching `@changesets` for out-of-range
46+
dependencies).
47+
48+
- **Changelog generator** — honours the [`changelog` config key](config-file-options.md#changelog): the
49+
default format, `changelog-git` (short commit-hash prefix), or `changelog-github` (PR/commit links and
50+
author thanks). Dependency-update lines always use the default format.
51+
- **Snapshot**`--snapshot [tag]` writes `0.0.0-<tag>-<datetime>` (or the calculated base when
52+
`snapshot.useCalculatedVersion` is set) and consumes the changesets without entering prerelease state.
53+
- **Prerelease** — in `pre` mode it writes `x.y.z-<tag>.<n>` versions, keeps the changesets, and records the
54+
consumed ids in `pre.json`.
55+
- **Shared versions** — projects whose version comes from a shared `Directory.Build.props` move together
56+
(`lockstep`), unless `--independent` (or `versionStrategy`) writes an inline `<Version>` per project.
57+
- **No .NET projects** — guides you to the Node tool (or, with `autoRunNode`, delegates to it; see
58+
[Interop and the front door](#interop-and-the-front-door)) and leaves changesets untouched.
59+
60+
In interop mode, only changesets that name .NET projects are processed; a Node-only changeset is left in place,
61+
and a shared changeset keeps its Node remainder for the Node tool.
2862

29-
How it works
63+
## `status`
3064

31-
- The command reads all .csproj project files from the SourcePath.
32-
- It prompts the user with a multi-select option to choose which projects have changed.
33-
- It prompts the user to select the type of change (patch, minor, or major).
34-
- It prompts the user to describe what has changed.
35-
- It generates a changeset file with the selected projects, change type, and description and stores it in `.changeset` folder.
65+
```bash
66+
changeset status
67+
changeset status --verbose
68+
changeset status --output <file>
69+
changeset status --since <ref>
70+
```
3671

37-
Notes
38-
The only difference compared to the Node.js implementation is that this version currently supports selecting only a single change type for all selected projects.
39-
The Node.js version allows selecting a different change type for each project individually.
40-
This additional functionality can be implemented easily if needed.
72+
Prints the pending release plan — the packages to be bumped, grouped by bump level (and, in interop mode, by
73+
ecosystem). `--verbose` shows each package's new version and the changeset files driving it; `--output` writes
74+
the plan as JSON instead of printing it; `--since` narrows the changesets to those added since a ref. Exits
75+
with a non-zero code when there are no changesets. Differs from `@changesets`, whose default output is a
76+
simpler summary.
4177

42-
## `version`
78+
## `pre`
4379

4480
```bash
45-
changeset version
81+
changeset pre enter <tag>
82+
changeset pre exit
4683
```
4784

48-
If there are any existing changesets the command generates changelogs for every project dependent on the updated project. It also amends SemVer version of the affected project.
85+
Enters or exits prerelease mode by writing `.changeset/pre.json`. While in pre mode, `version` produces
86+
`x.y.z-<tag>.<n>` versions and keeps changesets; `pre exit` clears the state so the next `version` graduates to
87+
stable versions.
4988

50-
## `publish`
89+
## `tag`
5190

5291
```bash
53-
changeset publish
92+
changeset tag
5493
```
5594

56-
Creates NuGet packages of affected projects and publishes them to the predefined package source.
95+
Creates a git tag per project at its current version (`<package-id>@<version>`, using the project's
96+
`PackageId` when set), skipping tags that already exist. Useful after `version` to tag a release.
5797

58-
### How it works (current .NET implementation)
59-
60-
Currently, the `publish` command assumes that the changes made by the `version` command have **already been committed**. The intended flow is:
98+
## `publish`
6199

62-
1. Run `changeset version` to bump versions, update changelogs, and delete processed changesets.
63-
2. Commit the changes produced by the `version` command.
64-
3. Run `changeset publish` to create and push NuGet packages based on the committed changes.
100+
```bash
101+
changeset publish
102+
changeset publish --no-git-tag
103+
```
65104

66-
The `publish` command does following:
105+
Packs every discovered project with `dotnet pack` and pushes with `dotnet nuget push --skip-duplicate` to the
106+
configured `packageSource`, then creates any missing git tags (unless `--no-git-tag`).
67107

68-
1. Gets all modified `.csproj` files from the predefined source directory by comparing the last two commits `git diff --name-only HEAD~1 HEAD {sourcePath}`
69-
2. For each changed `.csproj` file, creates a NuGet package using `dotnet pack`.
70-
3. Pushes the created NuGet packages to the predefined NuGet source using `dotnet nuget push`.
108+
Unlike the original net-changesets approach (which compared `git diff HEAD~1 HEAD`), publish is now
109+
**registry-aware**, matching `@changesets`: it asks the feed which versions already exist and packs/pushes only
110+
the projects whose current version is missing. This makes publish idempotent and order-independent — it makes
111+
no assumption about which commit ran `version`. When the feed cannot be queried, the project is packed and the
112+
feed's `--skip-duplicate` dedupes.
71113

72-
The package source can be configured via the `.changeset/config.json` file (see `docs/config-file-options.md`).
114+
## `info`
73115

74-
This approach relies on the fact that the `version` command only performs three types of changes:
116+
```bash
117+
changeset info
118+
```
75119

76-
- Deleting processed changeset files from the `.changeset` folder
77-
- Modifying or creating `CHANGELOG.md` files
78-
- Bumping versions in `.csproj` files
120+
Prints the resolved configuration, the discovered projects (and any skipped for lacking a version), and the
121+
count of pending changesets broken down by ecosystem. A diagnostic to confirm net-changesets sees your repo as
122+
expected.
79123

80-
By looking at the diff between `HEAD~1` and `HEAD`, `publish` can safely identify which projects had their versions bumped and therefore need to be published.
124+
## `ui`
81125

82-
### Comparison with original Node.js changesets implementation
126+
```bash
127+
changeset ui
128+
```
83129

84-
The original `@changesets/cli` implementation for Node.js works differently. Instead of relying on a Git diff,
85-
it checks whether a package with the **current version** from `package.json` already exists in the package registry; if it does not, the package is published.
130+
An interactive menu that dispatches the other commands — a convenience entry point.
86131

87-
## `status`
132+
## `shell-init`
88133

89134
```bash
90-
changeset status
135+
changeset shell-init [zsh|bash|pwsh]
91136
```
92137

93-
The command writes number of changesets in the `.changeset` folder to the console.
138+
Prints a shell snippet that defines a `changeset-net` function pointing at the net-changesets binary, so you
139+
can invoke net even when the shared `changeset` command resolves to the Node tool on your `PATH`. Run with no
140+
shell argument for setup instructions. See the
141+
["Using alongside @changesets" README section](../README.md#using-alongside-changesets-node).
142+
143+
## Interop and the front door
144+
145+
When [`interop`](config-file-options.md#interop) is on, net-changesets and the Node `@changesets` tool share
146+
one `.changeset/` folder: net versions only .NET projects and never deletes a Node changeset. With
147+
[`autoRunNode`](config-file-options.md#autorunnode), net becomes a front door — `version`, `status`, and
148+
`publish` run the Node tool ([`nodeChangesetCommand`](config-file-options.md#nodechangesetcommand)) after their
149+
own pass, and in a repository with no .NET projects they delegate to it entirely (`version` passes a snapshot
150+
tag through). A loop guard, set on the Node child process only, prevents infinite recursion if
151+
`nodeChangesetCommand` is misconfigured to resolve back to net.

0 commit comments

Comments
 (0)