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

Simplify CLI version command to use version from package.json #2258

Merged
merged 3 commits into from Sep 18, 2020

Conversation

META-DREAMER
Copy link
Collaborator

@META-DREAMER META-DREAMER commented Sep 14, 2020

This will make it easier to keep the package version and the CLI version in sync by directly using the version in package.json instead of maintaining a separate versioning system.

I also went pretty aggro in removing some of the extra formatting and git-state handling logic in the file since I didn't see it being used anywhere and @decentralion mentioned that it wasn't as necessary now that we have the NPM package as the main entrypoint for users. @wchargin if you think we should still keep that stuff around let me know!

Related: #2257

Test Plan: Run sourcecred --version and ensure it returns "v0.7.0-beta-16", or whatever is currently
in the package.json

This will make it easier to keep the package version and the CLI version in sync by directly
using the version in package.json instead of maintaining a separate versioning system.

I also removed some of the extra formatting and git-state handling logic in the file since
I didnt see it being used anywhere and @decentralion mentioned that it wasn't as necessary
now that we have the NPM package as the main entrypoint for users.

Test Plan: Run `sourcecred --version` and ensure it returns "v0.7.0-beta-16", or whatever is currently
in the package.json
@@ -28,7 +28,7 @@ describe("cli/sourcecred", () => {
it("responds to '--version'", async () => {
expect(await run(sourcecred, ["--version"])).toEqual({
exitCode: 0,
stdout: [expect.stringMatching(/^sourcecred v\d+\.\d+\.\d+$/)],
stdout: [expect.stringMatching(/^sourcecred v\d+\.\d+\.[a-z\d-]+$/)],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added this to allow for versions such as 0.7.0-beta-16

Copy link
Contributor

@teamdandelion teamdandelion left a comment

Choose a reason for hiding this comment

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

I think as written, it would be impossible to depend on the version in the frontend. However, showing version info in the frontend would be really nice. I've made a PR to do this: #2259. Can you try re-basing this on top of that PR, and see if it still works?

@META-DREAMER
Copy link
Collaborator Author

I think as written, it would be impossible to depend on the version in the frontend. However, showing version info in the frontend would be really nice. I've made a PR to do this: #2259. Can you try re-basing this on top of that PR, and see if it still works?

Yea, I was gonna implement that in a separate PR by injecting the version into the frontend build. This way might work too, but it would result in the package.json showing up in client side code, which is not ideal

@META-DREAMER
Copy link
Collaborator Author

@decentralion Verified it works:
image

Copy link
Contributor

@teamdandelion teamdandelion left a comment

Choose a reason for hiding this comment

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

Lets give @wchargin a chance to look before merge

Copy link
Member

@wchargin wchargin left a comment

Choose a reason for hiding this comment

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

I’m okay with this. I do think that it can be really helpful for the
frontend to report the exact Git version at which it was built, and we
used to display that, but we don’t anymore. I’m happy to add it back in
later with an easier mechanism: e.g., setting it in an environment
variable at build time.

+dirty: boolean, // does the worktree have unstaged/uncommitted changes?
|};
export type Environment = "development" | "production" | "test";
const packageJSON = require("../../package.json");
Copy link
Member

Choose a reason for hiding this comment

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

I’m curious—as you mentioned, this might pull package.json into the
frontend, which isn’t ideal (though not end of world); have you checked
whether it actually does, and if so whether destructuring here lets
Webpack tree-shake (const {version: packageVersion} = require(…))?
I’m not familiar enough with Webpack to guess whether this will help.

+dirty: boolean, // does the worktree have unstaged/uncommitted changes?
|};
export type Environment = "development" | "production" | "test";
const packageJSON = require("../../package.json");
Copy link
Member

Choose a reason for hiding this comment

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

nit: packageJson, please; we use consistent camel-case except where
there’s a strong API reason not to (e.g., toJSON integration point).
Cf. JsonLog.

teamdandelion and others added 2 commits September 18, 2020 12:57
This commit prints the SourceCred version into the console on frontend
load. This will be useful to help provide tech support for users, since
we'll be able to find what version of SourceCred they'll be using.

Test plan: Run `yarn start`, and check the console.
Following naming standards in codebase
@META-DREAMER META-DREAMER merged commit 99dfb33 into master Sep 18, 2020
@META-DREAMER META-DREAMER deleted the simplify-version-command branch September 18, 2020 19:14
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.

None yet

3 participants