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

Add options to configure snapshot preid format #830

Closed

Conversation

jakubmazanec
Copy link
Contributor

@jakubmazanec jakubmazanec commented Jun 3, 2022

I took the liberty to implement feature that was requested in some opened issues (can't remember which): to allow . to separate timestamp part of the snapshot preid, and to allow timestamp part to come first.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 3, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 0ef05bd:

Sandbox Source
Vanilla Configuration

@changeset-bot
Copy link

changeset-bot bot commented Jun 3, 2022

🦋 Changeset detected

Latest commit: 0ef05bd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@changesets/assemble-release-plan Minor
@changesets/config Minor
@changesets/types Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

"@changesets/types": minor
---

Adds two options to configure snapshot preid format: which character separates timestamp part from the rest of the preid, and whether the timestamp part comes first in the preid.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I'm not a fan of adding so many different options for something that feels very related - it seems like we are aiming to tweak a "format"/pattern of the generated snapshot with both of those.

I might give some alternative suggestions for this later on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'm open to alternative way how to configure this, because TBH I don't like these two options either...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking about single option snapshotPreidTemplate, that would serve as a template for the snapshot preid, e.g. '{{label}}.{{timestamp}}'; placeholders would be replaced with actual timestamp and value of snapshot CLI option. But the problem is that snapshot option returns string | boolean, i.e. the label is optional, and that needs little more complex templating logic than simple placeholder replacement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And now I'm thinking that I would actually like to have different templates for the preid for different prereleases. So maybe it would be better to create a new CLI option rather than config option? 🤔

@Andarist
Copy link
Member

Andarist commented Jun 5, 2022

Could you refresh my memory on the motivation behind this being configurable? I know some~ relevant context but would love to hear out your arguments first.

@jakubmazanec
Copy link
Contributor Author

Could you refresh my memory on the motivation behind this being configurable? I know some~ relevant context but would love to hear out your arguments first.

AFAIK the reason for having the timestamp first in the preid is to be able to predictably sort prereleases, and using . is also related to sorting, because according to semver:

Precedence for two pre-release versions [...] determined by comparing each dot separated identifier [...].

@Andarist
Copy link
Member

A competing PR has been created, you might find it interesting: #858

@Andarist
Copy link
Member

The mentioned completing PR has been merged in and thus we can close this PR. Nevertheless, thank you for your contribution! It's very much appreciated.

@Andarist Andarist closed this Jul 22, 2022
@jakubmazanec jakubmazanec deleted the add-timestamp-separator branch July 24, 2022 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants