stackblitz-labs / pkg.pr.new

Continuous (Preview) Releases for your libraries!
https://pkg.pr.new
292 stars 4 forks source link

PR comment options #104

Closed benmccann closed 2 weeks ago

benmccann commented 2 weeks ago

We're looking at setting up pkg.pr.new. It's such a great idea!

I wonder if it'd be possible to turn off the PR comments? We don't necessarily need them most of the time and can probably just add some text in our PR template telling folks where the packages will be published

The other thing we're looking into is whether we can list only changed packages in the comment. We have a lot of packages in our repo, so the comment fills about three screens (example). We might be able to do this one our side, but if there were anything built-in for it or even a recommendation in the docs, that would be helpful

AdrianGonz97 commented 2 weeks ago

Just wanted to note here that we managed to get the "only publish changed packages" portion working in userland. Here's an example snippet using https://github.com/tj-actions/changed-files:

...
    - name: Run changed-files
      id: changed-files
      uses: tj-actions/changed-files@v44
      with:
          separator: " "
          dir_names: "true"
          dir_names_max_depth: "2" # truncates the path to adders/X and packages/Y
          files: |
              adders/**
              packages/**
          files_ignore: |
              packages/dev-utils/**
              packages/tests/**
              packages/website/**

    - name: publish preview
      if: ${{ steps.changed-files.outputs.all_changed_files_count > 0 }}
      run: pnpm dlx pkg-pr-new@latest publish ${{ steps.changed-files.outputs.all_changed_files }}
...

It would still be really nice to have this integrated into the action as well!

Aslemammad commented 2 weeks ago

Thank you so much folks for considering the project!

The comment issue was also a concern for the vite folks. What do you recommend for that? collapsible lines? or anything you feel comfortable with?


Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

playground-a (bdc5024)

``` npm i https://pkg.pr.new/AdrianGonz97/svelte-add/@svelte-add/bulma@1 ```

playground-a (bdc5024)

``` npm i https://pkg.pr.new/AdrianGonz97/svelte-add/@svelte-add/bulma@1 ```

playground-a (bdc5024)

``` npm i https://pkg.pr.new/AdrianGonz97/svelte-add/@svelte-add/bulma@1 ```


I tried tables but it turned a bit ugly honestly. So please let me know what do you prefer in that case.

Around the changed packages only, I do not know how to handle them and I cannot think of an API! plus i think it'd not be straightforward so might add complexity to the package, this way we keep it more abstract so we have solutions like your amazing solution. But I'd be happy to hear your thoughts.

For compact mode, the package should be available in npm so we can resolve the github link from there (the repository field in package.json should be configured). I wonder if the package is there.

Sec-ant commented 2 weeks ago

The regex to match the repository url in order to use compact mode is rather strict. It requires the link to end with .git: https://github.com/stackblitz-labs/pkg.pr.new/blob/fc43e0bbbdf4f5e8c4d40da2c806a5cff8cff1fe/packages/utils/index.ts#L4 While the stated packages like @svelte-add/core don't.

Edit: And I just noticed it also points to a subpath instead of the repo url.

We encountered the .git issue in Biome, and we used npm pkg fix to fix all of our manisfest files so all the repo urls end with .git. Maybe pkg.pr.new should relax the regex a bit.

@benmccann @AdrianGonz97 @Aslemammad

Aslemammad commented 2 weeks ago

Oh that makes complete sense, thank you so much for the finding!

I think let's stick to what npm suggests which uses the .git extension, wdyt? https://docs.npmjs.com/cli/v10/configuring-npm/package-json#repository

Aslemammad commented 2 weeks ago

And also what do you think about the --silent option, this would disable the pr comments when publishing. I'd be happy to add it.

Sec-ant commented 2 weeks ago

Oh that makes complete sense, thank you so much for the finding!

I think let's stick to what npm suggests which uses the .git extension, wdyt? https://docs.npmjs.com/cli/v10/configuring-npm/package-json#repository

I think if we stick to the npm suggestions, we should at least document the behavior / provide some useful error messages when compact fails to work because of this.

Aslemammad commented 2 weeks ago

I'd be happy to have that. Let me know if you want to send a PR (either docs or an error message)

Sec-ant commented 2 weeks ago

I'd be happy to have that. Let me know if you want to send a PR (either docs or an error message)

Yes I'd like to add an error message. Will create a PR later.

AdrianGonz97 commented 2 weeks ago

The comment issue was also a concern for the vite folks. What do you recommend for that? collapsible lines? or anything you feel comfortable with?

Ooh, collapsible lines do look better to my eye. They take up less than half as much space and it certainly feels less polluted.

Around the changed packages only, I do not know how to handle them and I cannot think of an API! plus i think it'd not be straightforward so might add complexity to the package, this way we keep it more abstract so we have solutions like your amazing solution. But I'd be happy to hear your thoughts.

Since it's possible to do this in userland, I'm perfectly content with not having this particular feature included. Keeping the action simple and avoiding additional complexity is always a plus 🙂

And also what do you think about the --silent option, this would disable the pr comments when publishing. I'd be happy to add it.

A --silent flag would be perfect!

Aslemammad commented 2 weeks ago

Thank you so much, sure! I'll get all of those soon to you.

Aslemammad commented 2 weeks ago

Done! We'll release soon!

We now have --comment=update, --comment=create and what you want is silent mode which --comment=off!

We also added collapsible lines formatting, so you should soon have shorter comments.

Aslemammad commented 2 weeks ago

Let me know if you need anything else.

benmccann commented 2 weeks ago

Thank you so much!!

Aslemammad commented 2 weeks ago

just released 0.0.9!