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

action formatting package.json in wrong way #366

Open
technophile-04 opened this issue Apr 28, 2024 · 3 comments
Open

action formatting package.json in wrong way #366

technophile-04 opened this issue Apr 28, 2024 · 3 comments

Comments

@technophile-04
Copy link

Description :

When the "Version Packages" PR is created it updates the package.json version but also formats other fields in the wrong way.

Screenshot 2024-04-28 at 10 41 30 PM

It's not respecting my biome.json config and instead I think its using prettier to format the file

@errmayank
Copy link

Found a way to fix this, in the action's "Create a release pull request" step you can add a custom script using version

BUT it fails for some reason if you add the format script right there, like if you do this

# release.yml

- name: "Create a release pull request"
  uses: changesets/action@v1
  with:
    commit: "chore(release): version packages"
    title: "chore(release): version packages"
    version: pnpm changeset version && pnpm format
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

So instead create a separate script that does both and add it there

/* package.json */

  "scripts": {
    "format": "prettier --write \"**/*.{svelte,js,cjs,mjs,ts,cts,mts,json,md,yaml,yml}\"",
    "changeset-add": "changeset add",
    "changeset-status": "changeset status --verbose",
    "changeset-version": "changeset version && pnpm format"
  },
# release.yml

- name: "Create a release pull request"
  uses: changesets/action@v1
  with:
    commit: "chore(release): version packages"
    title: "chore(release): version packages"
    version: pnpm changeset-version
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

@mhpaler
Copy link

mhpaler commented Dec 12, 2024

@errmayank I assume this mean you need to install prettier in addition to biome?

I was doing something similar, however, the package.json arrays were still being reformatted. :(

/* package.json */

"scripts": {
    "changeset:version": "changeset version && pnpm format",
    "format": "biome format --write",
}
# release.yml

- name: "Create a release pull request"
  uses: changesets/action@v1
  with:
    commit: "chore(release): version packages"
    title: "chore(release): version packages"
    version: pnpm changeset:version
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

@errmayank
Copy link

@mhpaler it should work with any formatter because the pnpm format command runs last. are you sure it's not biome formatting it like this? maybe try running the biome format command locally to see if there's any difference?

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

3 participants