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

chore: publishing initium-cli as an NPM package #99

Merged
merged 17 commits into from
Sep 21, 2023
Merged

Conversation

Pehesi97
Copy link
Contributor

@Pehesi97 Pehesi97 commented Sep 6, 2023

This PR enables us to publish initium-cli as an NPM package.

For publishing the package, see the docs: https://docs.npmjs.com/cli/v8/commands/npm-publish. I've tested it with this package I published and it worked fine. See for yourself:

npx initium-cli

This PR also implements code that checks for updates when the CLI is run via npx, from the node_modules folder, or when installed globally if the user has nvm installed.

It also adds a new projectLanguage flag to initium-cli. If it's set to auto, then the existing detectType code will run and detect the project language by the existing files (package.json, go.mod, and so on). If not, the initium-cli will take the INITIUM_PROJECT_LANGUAGE or --project-language variable values as the projectLanguage.

TODO (PLEASE DON'T MERGE THIS YET!!!!): Set up an auth token in GitHub Actions' secrets, named NPM_TOKEN. I'll leave this for @LucaLanziani, once we figure out the Nearform account NPM permissions.

This PR closes #78 and closes #74 as well.

@Pehesi97 Pehesi97 requested review from LucaLanziani and a team September 6, 2023 18:17
@Pehesi97 Pehesi97 self-assigned this Sep 6, 2023
@LucaLanziani
Copy link
Member

This looks great, I'm not sure why but I also see the "detect language" changes in this PR.

I believe that we might want to release this with optic this is something to discuss with the tech hub

@LucaLanziani
Copy link
Member

I'm now debating if we should split this to its own repository.
If we leave it here we want to add a npmignore, right now we are publishing all the source code in the package :D

@Pehesi97
Copy link
Contributor Author

Pehesi97 commented Sep 7, 2023

1- My idea was to add a language flag that would default to auto. If it was auto, then the detectType function would do its job, but if not, there was no need to detect the project type. I did that because this is a go project, but when I added the package.json file, initium started treating it as a node project.
When I added the flag and the matchType function, the tests started failing. My latest commit was supposed to fix them but I need to give it some more work.

2- If I'm not mistaken, we can define what is published with the package when running npm publish. And yeah we can add a npmignore file too.

@Pehesi97
Copy link
Contributor Author

Pehesi97 commented Sep 8, 2023

@nearform/initium this should be ready to merge. Can anybody take a look on the PR so we can merge it?

@LucaLanziani LucaLanziani merged commit 1677fae into main Sep 21, 2023
2 checks passed
@LucaLanziani LucaLanziani deleted the feature/issue-74 branch September 21, 2023 08:12
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

Successfully merging this pull request may close these issues.

Check for update on very run of the CLI Publish the initium cli as an NPM package
3 participants