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

#291: Save dependencies to clib manifest by default #299

Merged
merged 2 commits into from Nov 8, 2023

Conversation

exbotanical
Copy link
Contributor

This PR modifies the behavior of clib-install such that dependencies are saved to the clib manifest (clib.json/package.json) by default, mirroring the behavior of npm >= 5. It accomplishes this by deprecating the --save option and adding an additional flag --no-save which can be passed to prevent the dependency from being written to the clib manifest.

Note I've retained the --save-dev option so users can specify they want the dependency to save under dev dependencies. This is also aligned with the behavior of npm >= 5.

Changes:

  • Deprecate --save option and add a logger warning. Behavior when this flag is passed is effectively the same to prevent backward compatibility issues.
  • Add new --no-save flag, which changes the install behavior such that the dependency is not added to the clib manifest.
  • In an additional commit, I added the make target for the binaries as a dependency of the test target. I noticed that if you run make test without having run make first, the tests will fail.
  • Added new test cases for --no-save. Also updated existing test cases where necessary with --no-save just to maintain parity with what was there before. We could probably refactor the --save and --no-save tests to use a common function, but I wanted to keep the PR small, and having separate test files lets us fine-tune the behavior for one without clobbering the other.

Resolves #291.

When we're good, I can push a tag to bump the version or however you prefer. Happy to make any suggested changes.

command_option(&program, "-D", "--save-dev",
"save development dependency in clib.json or package.json",
setopt_savedev);
command_option(&program, "-N", "--no-save",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not super sure about the shorthand flag. If commander supports passing NULL here, maybe we just allow the long option only?

Copy link
Member

Choose a reason for hiding this comment

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

I think -N is okay!

Copy link
Member

@diasbruno diasbruno Nov 3, 2023

Choose a reason for hiding this comment

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

I opened a PR long time ago on commander to omit the short version. clibs/commander#25
I'll see if it still valid...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jwerle Cool, sounds good.

What's the standard procedure for clib - I push a tag (for this I'd bump the minor version) and merge? Thanks for the reviews!

@diasbruno
Copy link
Member

Looks good!

@jwerle jwerle merged commit dfa5f32 into clibs:master Nov 8, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically Add Dependencies to clib.json when clib install is called.
4 participants