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

New ReleaseVersion component into HelpButton #310

Merged
merged 7 commits into from
Dec 19, 2024

Conversation

hoshinotsuyoshi
Copy link
Member

@hoshinotsuyoshi hoshinotsuyoshi commented Dec 18, 2024

Summary

Example output for cliVersion:

  • Released version:
    v0.0.11 (2024-12-19)
  • Unreleased version:
    v0.0.11 + 0d6169a (2024-12-19)

Explanation:

  • "Released version" means the current Git hash matches a tagged release.
スクリーンショット 2024-12-19 9 12 34
  • "Unreleased version" includes a short Git hash prefix to indicate changes since the last release.
スクリーンショット 2024-12-19 9 11 47

Related Issue

Changes

  • b400891 : feat(cli): inject new VITE_CLI_VERSION_* env vars into Vite build process
  • 6fdbbdd : feat: add CliVersionProvider and schema definition for CLI version context
  • 343e01d : ✨ New ReleaseVersion component into HelpButton

Testing

Manually tested.

Other Information

In pull requests, the commit hash displayed in the HelpButton may differ from the hash of the latest commit. This happens because when using on: pull_request in GitHub Actions, a special merge is performed before the code is checked out.

1

…rocess

- Introduced `scripts/set-env.mjs` to dynamically set `VITE_CLI_VERSION_*` environment variables during build and dev processes.
  - `VITE_CLI_VERSION_VERSION`: Package version from `package.json`.
  - `VITE_CLI_VERSION_GIT_HASH`: Current Git commit hash.
  - `VITE_CLI_VERSION_IS_RELEASED_GIT_HASH`: Flag indicating if the commit matches the latest tagged release.
  - `VITE_CLI_VERSION_DATE`: Commit date or fallback to the current date.
@hoshinotsuyoshi hoshinotsuyoshi changed the title ERD display version New ReleaseVersion component into HelpButton Dec 19, 2024
@hoshinotsuyoshi hoshinotsuyoshi changed the title New ReleaseVersion component into HelpButton New ReleaseVersion component into HelpButton Dec 19, 2024
- Added `ReleaseVersion` component:
  - Displays the current CLI version, including:
    - Released version (e.g., `v0.0.11 (2024-12-19)`).
    - Unreleased version with short Git hash (e.g., `v0.0.11 + 0d6169a (2024-12-19)`).
  - Fetches version information from the `CliVersionProvider`.

- Updated `App.tsx`:
  - Initialized `cliVersion` using `import.meta.env.VITE_CLI_VERSION_*` environment variables.
  - Wrapped `ERDRenderer` with `CliVersionProvider` to provide version context globally.
"command:build": "node ./dist-cli/bin/cli.js erd build --input fixtures/input.schema.rb --format schemarb",
"cp:prism": "cp ../db-structure/node_modules/@ruby/prism/src/prism.wasm ./dist-cli/bin/prism.wasm",
"dev": "pnpm command:build && cp dist/schema.json public/ && pnpm run '/^dev:.*/'",
"dev:app": "vite",
"dev:app": "node scripts/set-env.mjs vite",

This comment was marked as outdated.

Comment on lines +1 to +3
export * from './cliVersion'
export * from './queryParam'
export * from './showMode'
Copy link
Member Author

Choose a reason for hiding this comment

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

I only wanted the cliVersion here, but I'm also exporting the others for consistency

Copy link
Member Author

Choose a reason for hiding this comment

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

I created a new directory, but is it appropriate? 💭

@hoshinotsuyoshi hoshinotsuyoshi marked this pull request as ready for review December 19, 2024 00:27
@hoshinotsuyoshi hoshinotsuyoshi requested a review from a team as a code owner December 19, 2024 00:27
@hoshinotsuyoshi hoshinotsuyoshi requested review from FunamaYukina, junkisai, MH4GF and sasamuku and removed request for a team December 19, 2024 00:27
This commit removes the 'set-env.mjs' script and integrates environment variable setup directly within the Vite build process using a custom Vite plugin. This change simplifies the build and development commands by removing the dependency on the external environment setup script.
Copy link
Member

@MH4GF MH4GF left a comment

Choose a reason for hiding this comment

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

Great!!
I've wrote some comments!

@@ -25,7 +26,7 @@ export default defineConfig({
],
},
},
plugins: [react(), tsconfigPaths()],
plugins: [react(), tsconfigPaths(), setEnvPlugin()],
Copy link
Member

Choose a reason for hiding this comment

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

Cool 🚀

Comment on lines 1 to 12
.cliVersion {
padding: var(--spacing-2);
}

.cliVersionInner {
border-radius: var(--border-radius-full);
background: var(--pane-muted-background);
padding: var(--spacing-1) var(--spacing-2);
color: var(--global-mute-text);
font-family: var(--code-font);
font-size: var(--font-size-1);
}
Copy link
Member

Choose a reason for hiding this comment

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

nits: If we use margin, it would be simple to implement without nesting divs.

Suggested change
.cliVersion {
padding: var(--spacing-2);
}
.cliVersionInner {
border-radius: var(--border-radius-full);
background: var(--pane-muted-background);
padding: var(--spacing-1) var(--spacing-2);
color: var(--global-mute-text);
font-family: var(--code-font);
font-size: var(--font-size-1);
}
.cliVersion {
margin: var(--spacing-2);
border-radius: var(--border-radius-full);
background: var(--pane-muted-background);
padding: var(--spacing-1) var(--spacing-2);
color: var(--global-mute-text);
font-family: var(--code-font);
font-size: var(--font-size-1);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I see!

Comment on lines 19 to 27
<div className={styles.cliVersionInner}>
<span>{`v${cliVersion.version}`}</span>
<span>
{' '}
{cliVersion.isReleasedGitHash ||
`+ ${cliVersion.gitHash.slice(0, 7)} `}
</span>
<span>{cliVersion.date.length > 0 && ` (${cliVersion.date})`}</span>
</div>
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
<div className={styles.cliVersionInner}>
<span>{`v${cliVersion.version}`}</span>
<span>
{' '}
{cliVersion.isReleasedGitHash ||
`+ ${cliVersion.gitHash.slice(0, 7)} `}
</span>
<span>{cliVersion.date.length > 0 && ` (${cliVersion.date})`}</span>
</div>
<span>{`v${cliVersion.version}`}</span>
<span>
{' '}
{cliVersion.isReleasedGitHash ||
`+ ${cliVersion.gitHash.slice(0, 7)} `}
</span>
<span>{cliVersion.date.length > 0 && ` (${cliVersion.date})`}</span>

@hoshinotsuyoshi hoshinotsuyoshi added this pull request to the merge queue Dec 19, 2024
Merged via the queue into main with commit 9dfa9ec Dec 19, 2024
12 checks passed
@hoshinotsuyoshi hoshinotsuyoshi deleted the erd-display-cli-version branch December 19, 2024 06:37
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.

2 participants