Skip to content

feat: add support for npm package#488

Merged
tusharmath merged 5 commits intotailcallhq:npm-packagefrom
b4s36t4:feat/npm
Nov 1, 2023
Merged

feat: add support for npm package#488
tusharmath merged 5 commits intotailcallhq:npm-packagefrom
b4s36t4:feat/npm

Conversation

@b4s36t4
Copy link
Copy Markdown
Contributor

@b4s36t4 b4s36t4 commented Oct 13, 2023

Summary:
This PR adds support for tailcall npm package to be publishable via CI pipelines.

Issue Reference(s):
Fixes #470

/claim #470

Build & Testing:

  • I ran cargo test successfully.
  • I have run ./lint.sh to address and fix linting issues.

Checklist:

  • I have added relevant unit & integration tests.
  • I have updated the documentation accordingly (if applicable).
  • I have performed a self-review of my own code.
Demo
as.mp4

@b4s36t4
Copy link
Copy Markdown
Contributor Author

b4s36t4 commented Oct 13, 2023

Heavily inspired from swc and biomejs implementations.

This version only installs the binary depends on the arch of user's system @tusharmath

@tusharmath
Copy link
Copy Markdown
Contributor

Saw the video ❤️
Will we be able to use it by installing globally?

npm i -g @tailcallhq/tailcall

@tusharmath
Copy link
Copy Markdown
Contributor

Can you run ./lint.sh

# CD to package and publish and move back to top-level folder
run: for package in npm/*; do cd $package; npm publish --tag latest --access public --provenance; cd ../..; done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Can we not publish everything together? What happens if one of the publish command fails?
  • Can we log after every publish?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If one of them fails other one continues.

Logging in the sense? Just printing that one of the package is published right?

Also by default npm would console everything related to push and the reason for push fails etc.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good point. npm logs should be enough.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

but ignoring error in that case could mask the problem as the ci will pass successfully and to know about problem we need to thoroughly read through logs or inspect npm packages

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we can also add an dry-run npm release workflow in order to able to test that everything works as expected especially before merging this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should use npm publish --workspaces command instead of looping using bash.

https://docs.npmjs.com/cli/v7/commands/npm-publish#workspaces

@tusharmath
Copy link
Copy Markdown
Contributor

We can remove the generated files from being committed to git?

@b4s36t4
Copy link
Copy Markdown
Contributor Author

b4s36t4 commented Oct 14, 2023

Yes, we can able to run it globally too.

I will update the PR with the comments you provided. Thanks.

@b4s36t4
Copy link
Copy Markdown
Contributor Author

b4s36t4 commented Oct 14, 2023

I can't able to lint.sh can you provide a doc on how to run it? Some errors it seems.

@tusharmath
Copy link
Copy Markdown
Contributor

There are a few other comments @b4s36t4
For the lint, you can just run prettier. The build is passing, so it might not be required.

@b4s36t4
Copy link
Copy Markdown
Contributor Author

b4s36t4 commented Oct 14, 2023

I think due to the difference in remote config and other issues.
Also I did a force push which caused some of issues stale.

If you could can you please review it again?

except removing postinstall.js file exporting in package.json.

Rest looks good to me based on previous review.

@tusharmath
Copy link
Copy Markdown
Contributor

Yikes!
Commenting below so that it doesn't get lost —

  • Remove generated files from Git.

@tusharmath tusharmath mentioned this pull request Oct 14, 2023
# CD to package and publish and move back to top-level folder
run: for package in npm/*; do cd $package; npm publish --tag latest --access public --provenance; cd ../..; done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

but ignoring error in that case could mask the problem as the ci will pass successfully and to know about problem we need to thoroughly read through logs or inspect npm packages

@b4s36t4
Copy link
Copy Markdown
Contributor Author

b4s36t4 commented Oct 15, 2023

@meskill Thanks for the review, it does make a lot of sense to make your suggested changes. It did came up nice and easy.

Really appreciate it :)

@b4s36t4
Copy link
Copy Markdown
Contributor Author

b4s36t4 commented Oct 15, 2023

@tusharmath Please review the PR now. Let me know if there's anything missing thanks :).

@tusharmath
Copy link
Copy Markdown
Contributor

@b4s36t4 #488 (comment)

@b4s36t4
Copy link
Copy Markdown
Contributor Author

b4s36t4 commented Oct 15, 2023

I don't think there are any generated files. All the package.json files are intended.

https://github.com/swc-project/swc/tree/main/scripts/npm/ see this for the reference.

@tusharmath
Copy link
Copy Markdown
Contributor

@b4s36t4 Though SWC is committing the files to git, I don't think it's a good idea for our current setup. These files can be generated, and contain the release version in them. We will end up creating a commit everytime we make a release, which is unnecessary.

@b4s36t4
Copy link
Copy Markdown
Contributor Author

b4s36t4 commented Oct 15, 2023

Will update.

@b4s36t4
Copy link
Copy Markdown
Contributor Author

b4s36t4 commented Oct 16, 2023

@tusharmath Sorry for asking questions such lately.

But As you mentioned we need to wipe/no-commit package.json files committed to github, I want to bring this attention if we delete the package.json and do this file generation with the script wouldn't that be complex?

If you see we're building the tailcall for different platforms for different arch types handling these conditions inside the script would make the script a bit complex, agree?

As per the comment to commit everytime the package.json we don't have to. We can keep them as a read-only files (need to remove version key from package.json) except I don't see any problem with committing these files.

Let me know your thoughts.

@tusharmath
Copy link
Copy Markdown
Contributor

But As you mentioned we need to wipe/no-commit package.json files committed to github, I want to bring this attention if we delete the package.json and do this file generation with the script wouldn't that be complex?

It would be easier to manage the platforms this way. We could just configure the script to generate the package.json file for that particular platform. This is quite standard in node.js projects actually.

If you see we're building the tailcall for different platforms for different arch types handling these conditions inside the script would make the script a bit complex, agree?

I am not sure why should the build script change. What I am saying is - we should write a node.js script, that generates the dirs, readme, package.json, and copy appropriate release builds for the platforms we wish to support. Those package.json should be created from a template.package.json.

As per the comment to commit everytime the package.json we don't have to. We can keep them as a read-only files (need to remove version key from package.json) except I don't see any problem with committing these files.

You are right we don't "need" to commit. However as discussed, generating the files using a template would make it easier for us to change the meta data about the package easily.

"engines": {
"node": ">=14.*"
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be a private package.
set private:true.

Add workspaces for each supported platform.

@github-actions
Copy link
Copy Markdown

Action required: PR inactive for 2 days.
Status update or closure in 2 days.

@github-actions github-actions bot added the Stale label Oct 19, 2023
@b4s36t4
Copy link
Copy Markdown
Contributor Author

b4s36t4 commented Oct 19, 2023

Working on few other things, probably would be completing things by tomorrow.

@github-actions github-actions bot removed the Stale label Oct 19, 2023
@github-actions
Copy link
Copy Markdown

Action required: PR inactive for 2 days.
Status update or closure in 2 days.

@github-actions github-actions bot added the Stale label Oct 21, 2023
@github-actions
Copy link
Copy Markdown

PR closed after 2 days of inactivity.

@github-actions github-actions bot closed this Oct 23, 2023
@tusharmath tusharmath reopened this Nov 1, 2023
@tusharmath tusharmath changed the base branch from main to npm-package November 1, 2023 05:26
@tusharmath tusharmath changed the base branch from npm-package to main November 1, 2023 05:26
@tusharmath tusharmath enabled auto-merge (squash) November 1, 2023 05:27
@tusharmath tusharmath changed the base branch from main to npm-package November 1, 2023 05:28
@tusharmath tusharmath merged commit a177f16 into tailcallhq:npm-package Nov 1, 2023
@tusharmath tusharmath mentioned this pull request Nov 1, 2023
5 tasks
@tusharmath
Copy link
Copy Markdown
Contributor

/tip $10 @b4s36t4

@algora-pbc
Copy link
Copy Markdown

algora-pbc bot commented Nov 3, 2023

🎉🎈 @b4s36t4 has been awarded $10! 🎈🎊

@github-actions github-actions bot added the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🙋 Bounty claim 💰 Rewarded state: inactive No current action needed/possible; issue fixed, out of scope, or superseded.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Publish tailcall on npm

3 participants