-
Notifications
You must be signed in to change notification settings - Fork 797
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
feat(lifecycle): add support for lifecycle hooks stor… #167
feat(lifecycle): add support for lifecycle hooks stor… #167
Conversation
…ed in <cwd>/.standard-version/hooks Closes conventional-changelog#157
… existent lifecycle hook script
1 similar comment
Hey, this is a great start! Sorry for the despicable turnaround time around I think the hooks should live in a {
"standard-version": {
"hooks": {
"pre-commit": "node hook.js",
"post-bump": "validate-artifacts"
}
}
} @stevemao @bcoe What do you think about hook config, and what should the names for the hooks be? |
Yeah I like that approach. I think it feels comfortable to follow git hooks lead on naming as most dev's would probably feel comfortable with that (keeping the learning curve really low) |
@lancecaraccioli @Tapppi I like the idea of lifecycle scripts 👍 but I agree with @Tapppi that I think they'd make sense in a We use the yargs command line parser which supports most of this functionality already: |
I'll be working on updating the PR today. Not sure about the yargs approach though. Seems like that would take some refactoring as cli.js imports command.js and then passes it to standardVersion as an argument, but there is no guarantee from the perspective of index.js that the argument will be a yargs object. Also it's current usage is as a plain object. I'll think about it more. Thoughts? |
…it hook style per PR comments
@Tapppi give this one another look please. Thanks |
@lancecaraccioli this is looking great! sorry for the slow turnaround these days -- as @Tapppi has said himself, I think we're all buried under a few too many issues these days! rather than the logic: var hooks = pkg['standard-version'] && pkg['standard-version']['hooks'] ? pkg['standard-version']['hooks'] : {} I'd love to see us use the pkgConf feature of yargs -- this is what I use for nyc, and yargs itself. It provides some extra logic around finding the appropriate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really digging this work; really just one nit about using yargs' pkgConf
feature.
I'm thinking that pulling configuration into the package.json
could be the way we solve your other open issue surrounding configuring presets ... I just want to be really mindful about minimizing the amount of flexibility we add to standard-version
within reason I want it to feel like magic, and push people towards a commit format that we advocate.
Hey @bcoe I'll try to give this a look soon, hopefully this evening. Thanks |
@lancecaraccioli if you have any cycles soon; I'd love to get some of these issues closed out. |
if (err) { | ||
return done(err) | ||
} | ||
return tag(newVersion, pkg.private, args, done) | ||
runLifecycleHook(args, 'pre-commit', newVersion, hooks, function (err) { | ||
if (err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a suggestion here, as this would help my own use case which I will outline below. If you allow the lifecycle hook to mutate/return a modified args struct that could allow more flexibility. (I'm currently considering using a prepare-commit-message
hook to achieve this).
My company uses PivotalTracker which uses [(Fixes|Finishes) #12312]
to indicate a story is fixed in a commit and then '[Delivers #12312]to mark it as delivered and a github integration to detect the commit message and update the stories. What I'd want to do in this feature is change the
message` argument depending on all "fixed" commits since last version. (It'd be awesome if standard-version/conventional-changelog could pass all the commits it builds the changelog off to the hook as well but that might be asking for too much).
Example
Git History:
fix: Some Issue [Fixes #123]
feat: Shiny Feature [Finishes #333]
chore(release): v1.1.2
On running standard-version
I ideally want the release commit to be as follows so my stories automatically get updated to the delivered (for QA) state.
chore(release): v1.2.0
[Delivers #123]
[Delivers #333]
Assuming the hook allowed us to return a modified args I could append the new messages onto the message
argument.
Hi all, I work on marky-markdown; @bcoe recently helped get the project onto standard-version and suggested I throw my two cents in here. This looks pretty great to me; in our case, for each release we build a small JSON file that includes the new package version number. We'd been doing that in the In particular our use case is to have something run after the new version number is known, and to be able to programmatically generate changes to add to the commit that performs the version bump. So I'm guessing either of the I don't have a strong or worthwhile opinion on decisions like how and where to specify the contents of the hooks themselves or anything; I'm just very interested in this feature overall 👍 |
@revin @SimeonC @lancecaraccioli please give this a shot:
https://github.com/conventional-changelog/standard-version#lifecycle-scripts @SimeonC I tried to at least partially solve your use-case, you can provide a git message in the |
@lancecaraccioli I've continued polishing the lifecycle script, documented here: https://github.com/conventional-changelog/standard-version#lifecycle-scripts Would love your help QAing, since the
|
See: - conventional-changelog/standard-version#172 - conventional-changelog/standard-version#167 - conventional-changelog/standard-version#168 Signed-off-by: Fery Wardiyanto <ferywardiyanto@gmail.com>
Add hook support via "standard-version" package.json stanza
Closes #157