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

Question: How to incorporate npm scripts into release process #1186

Closed
jdalrymple opened this issue May 1, 2020 · 9 comments
Closed

Question: How to incorporate npm scripts into release process #1186

jdalrymple opened this issue May 1, 2020 · 9 comments

Comments

@jdalrymple
Copy link

Description

For example, when auto updates the changelog etc, is it possible to trigger a linting fix script? This would normally be done by husky or lint-staged locally.

Describe the solution you'd like

This probably could be done through the exec plugin, I'm just not sure how exactly, or which hook

Describe alternatives you've considered

Could call each of the commands in the shipit process separately and call the npm script in between?

@hipstersmoothie
Copy link
Collaborator

There are two methods:

  1. using the npm lifecycle: preversion, postversion, prepublish, etc
  2. using auto's lifecycle: hooks

Could call each of the commands in the shipit process separately and call the npm script in between?

This would work but you would lose out on shipit and it's features.

This probably could be done through the exec plugin, I'm just not sure how exactly, or which hook

You're right!

The following would run lint right before the changelog is commited and stage the files

{
  "plugins": [["exec", {  "beforeCommitChangelog": "yarn lint --fix && git add ." }]]
}

Or if you want a separate commit for the lint fixes

{
  "plugins": [["exec", {  "afterAddToChangelog": "yarn lint --fix && git add . && git commit -m 'lint fixes'" }]]
}

For example, when auto updates the changelog etc, is it possible to trigger a linting fix script?

Is this what you're trying to do or is it just an example. IDK if I would recommend putting linting and testing into auto. In my opinion your CI should run those separately so it fails long before it gets to using auto.

@jdalrymple
Copy link
Author

Thank you! Yea the problem I was running into was when auto updated the changelog it would use different styling which caused my linting to fail for every build downstream. So my thought was why not just fix the linting for the commits that auto creates during the process?

@hipstersmoothie
Copy link
Collaborator

the easiest way might be to just ignore linting for **/CHANGELOG.md or if you think the fixes would be nice for everyone contribute them!

@jdalrymple
Copy link
Author

True! Here is the list:

  1. Prettier has a different styling for nested links:
[test]([test](link)) --> [test](<[test](link)>)
  1. Prettier also converts the lerna json without the expanded array:
// Comes out as this
"packages": [
  "packages/*
"],

// Instead of this
"packages": ["packages/*"],
  1. There is an extra space for the "Push to master" line
####  ⚠️ Pushed to `master`  // Comes out as this instead of 
#### ⚠️ Pushed to `master`   // this
  1. And finally the all-contributors gets an extra line between these two comments:
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

Out of all of these, i think 3 could be a PR, but im unsure about the rest.

@hipstersmoothie
Copy link
Collaborator

1 might be fixable. I can tak a look

2 is lerna itself doing it. they use JSON.stringify which has different standards

3 is easily fixable

4 would probably be a pr to all-contributors-cli? im unsure

@jdalrymple
Copy link
Author

I wouldnt worry to much over it. Besides the small adjustment for 3, and maybe 1. The rest could just opinionated.

@hipstersmoothie
Copy link
Collaborator

@jdalrymple Where does auto use nested links? I can't find any in my changlelogs

@jdalrymple
Copy link
Author

jdalrymple commented May 22, 2020

@jdalrymple Where does auto use nested links? I can't find any in my changlelogs

I think i found the problem. I was making commits like: "Linting [skip-ci]", which resulted in this in the changelog:

"- Linting [skip-ci]([@jdalrymple](https://github.com/jdalrymple))"

I think this ones on me lol 😅

I was trying to skip certain commits from the changelog, lol i failed.

@hipstersmoothie
Copy link
Collaborator

Thanks for the response! #1246 should address 3 and a few other things.

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

No branches or pull requests

2 participants