Skip to content
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

New config flag: snapshot.prereleaseTemplate, and make snapshot feature stable #858

Merged
merged 24 commits into from Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
df1750c
Added `getCurrentCommitId` helper
dotansimha Jul 3, 2022
8668392
Added snapshotPreidTemplate
dotansimha Jul 5, 2022
ff191b8
added changeset
dotansimha Jul 5, 2022
198bbe1
fix lint
dotansimha Jul 5, 2022
ae64c8f
fix ts build issues
dotansimha Jul 5, 2022
b777f57
moved experimental docs to a new file
dotansimha Jul 6, 2022
4703ca3
use regex for replacing placeholders
dotansimha Jul 6, 2022
ec232f4
improve Date mocks in tests
dotansimha Jul 6, 2022
5692abb
prevent `--snapshot name` without `{tag}` placeholder
dotansimha Jul 6, 2022
0a639c3
fix lint
dotansimha Jul 6, 2022
255d122
Allow `--snapshot-preid-template` in cli
dotansimha Jul 7, 2022
5cb90c2
simplify cli->assembleReleasePlan interface
dotansimha Jul 10, 2022
272b016
remove the dateRef from assembleReleasePlan and calcualte it internally
dotansimha Jul 10, 2022
e1d6c96
Migrate to unified `snapshot` flag in config
dotansimha Jul 17, 2022
a2a664f
Make `snapshot` stable, avoid breaking changes and keep supporting `u…
dotansimha Jul 18, 2022
10e1dac
Tweak `mockGlobalDate`
Andarist Jul 22, 2022
abd7a76
Refactor code around creating snapshot suffix
Andarist Jul 22, 2022
3513f1a
Bring back the comment related to 0.0.0 versions used in snapshots by…
Andarist Jul 22, 2022
806b4dd
Update .changeset/strong-geckos-divide.md
Andarist Jul 22, 2022
d5541b7
Update .changeset/olive-ducks-camp.md
Andarist Jul 22, 2022
665bb7b
Fixed `--snapshot-prerelease-template` CLI param in the help string
Andarist Jul 22, 2022
7c0d677
Remove `null` from `WrittenConfig["snapshot"]["prereleaseTemplate"]`
Andarist Jul 22, 2022
5b9d69f
Juggle some docs and update `schema.json`
Andarist Jul 22, 2022
d046aaa
Only get the current commit if the template uses the `{commit}` variable
Andarist Jul 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions .changeset/olive-ducks-camp.md
@@ -0,0 +1,28 @@
---
"@changesets/cli": patch
"@changesets/config": patch
---

A possibility to use the calculated version for snapshot releases is now stable 🥳 All snapshot-related config parameters are now grouped under a single config property called `snapshot`.

To migrate, make sure to update your `config.json`.

Old usage (still works, but comes with a deprecated warning):

```json
{
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"useCalculatedVersionForSnapshots": true
}
}
```

New usage:

```json
{
"snapshot": {
"useCalculatedVersion": true
}
}
```
5 changes: 5 additions & 0 deletions .changeset/quick-squids-dance.md
@@ -0,0 +1,5 @@
---
"@changesets/cli": minor
---

Added a new config flag for `changesets version --snapshot` mode: `--snapshot-prerelease-template`
5 changes: 5 additions & 0 deletions .changeset/short-cats-invent.md
@@ -0,0 +1,5 @@
---
"@changesets/git": minor
---

Added a new helper function: `getCurrentCommitId`
8 changes: 8 additions & 0 deletions .changeset/strong-geckos-divide.md
@@ -0,0 +1,8 @@
---
"@changesets/assemble-release-plan": minor
"@changesets/cli": minor
"@changesets/config": minor
"@changesets/types": minor
---

Added a new config option: `snapshot.prereleaseTemplate` for customizing the way snapshot release numbers are being composed.
10 changes: 8 additions & 2 deletions .vscode/settings.json
@@ -1,3 +1,9 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
"typescript.tsdk": "node_modules/typescript/lib",
"grammarly.selectors": [
{
"language": "markdown",
"scheme": "file"
}
]
}
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -55,6 +55,7 @@ To make releasing easier, you can use [this changesets github action](https://gi
- [Prereleases](./docs/prereleases.md)
- [Problems publishing in monorepos](./docs/problems-publishing-in-monorepos.md)
- [Snapshot releases](./docs/snapshot-releases.md)
- [Experimental Options](./docs/experimental-options.md)

## Cool Projects already using Changesets for versioning and changelogs

Expand Down
39 changes: 38 additions & 1 deletion docs/config-file-options.md
Expand Up @@ -14,7 +14,7 @@ Changesets has a minimal amount of configuration options. Mostly these are for w
}
```

> NOTE: the `linked`, `updateInternalDependencies`, and `ignore` options are only for behaviour in monorepos.
> NOTE: the `linked`, `fixed`, `updateInternalDependencies`, `bumpVersionsWithWorkspaceProtocolOnly`, and `ignore` options are only for behaviour in monorepos.

## `commit` (`boolean`, or module path as a `string`, or a tuple like `[modulePath: string, options: any]`)

Expand Down Expand Up @@ -156,3 +156,40 @@ You would specify our github changelog generator with:
```

For more details on these functions and information on how to write your own see [changelog-functions](./modifying-changelog-format.md)

## `bumpVersionsWithWorkspaceProtocolOnly` (boolean)

Determines whether Changesets should only bump dependency ranges that use workspace protocol of packages that are part of the workspace.

## `snapshot` (object or undefined)

Default value: `undefined`

### `useCalculatedVersion` (optional boolean)

Default value: `false`

When `changesets version --snapshot` is used, the default behavior is to use `0.0.0` as the base version for the snapshot release.

Setting `useCalculatedVersion: true` will change the default behavior and will use the calculated version, based on the changeset files.

### `prereleaseTemplate` (optional string)

Default value: `undefined` (see note below)

Configures the suffix for the snapshot releases, using a template with placeholders.

**Available placeholders:**

You can use the following placeholders for customizing the snapshot release version:

- `{tag}` - the name of the snapshot tag, as specified in `--snapshot something`
- `{commit}` - the Git commit ID
- `{timestamp}` - Unix timestamp of the time of the release
- `{datetime}` - date and time of the release (14 characters, for example, `20211213000730`)

> Note: if you are using `--snapshot` with empty tag name, you cannot use `{tag}` as placeholder - this will result in error.

**Default behavior**

If you are not specifying `prereleaseTemplate`, the default behavior will fall back to using the following template: `{tag}-{datetime}`, and in cases where the tag is empty (`--snapshot` with no tag name), it will use `{datetime}` only.
17 changes: 17 additions & 0 deletions docs/experimental-options.md
@@ -0,0 +1,17 @@
# Experimental Options

All experimental options are configured in `config.json` under `___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH` flag.

> Please use these experimental flags with caution, and please pay attention to release notes - these config flags might change in patch versions.

## `updateInternalDependents` (type: `'out-of-range' | 'always'`)

Default value: `out-of-range`.

The config flag can be used to add dependent packages to the release (if they are not already a part of it) with patch bumps.

## `onlyUpdatePeerDependentsWhenOutOfRange` (type: `boolean`)

Default value: `false`

When set to `true`, Changesets will only bump peer dependents when `peerDependencies` are leaving the range.
126 changes: 90 additions & 36 deletions packages/apply-release-plan/src/index.test.ts
Expand Up @@ -51,8 +51,11 @@ class FakeReleasePlan {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
},
...config
};
Expand Down Expand Up @@ -87,10 +90,13 @@ async function testSetup(
baseBranch: "main",
updateInternalDependencies: "patch",
ignore: [],
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
},
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
}
};
}
Expand Down Expand Up @@ -490,8 +496,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -553,8 +562,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -743,8 +755,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -828,8 +843,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -905,8 +923,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -982,8 +1003,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -1062,8 +1086,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -1147,8 +1174,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -1224,8 +1254,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -1301,8 +1334,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -1382,8 +1418,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: true,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -1544,8 +1583,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -1649,8 +1691,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -1734,8 +1779,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -1823,8 +1871,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down Expand Up @@ -1926,8 +1977,11 @@ describe("apply release plan", () => {
ignore: [],
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
onlyUpdatePeerDependentsWhenOutOfRange: false,
updateInternalDependents: "out-of-range",
useCalculatedVersionForSnapshots: false
updateInternalDependents: "out-of-range"
},
snapshot: {
useCalculatedVersion: false,
prereleaseTemplate: null
}
}
);
Expand Down