-
Notifications
You must be signed in to change notification settings - Fork 135
feat(cli): expose bundled tool versions via vite-plus/versions export
#1162
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
Open
kazupon
wants to merge
7
commits into
voidzero-dev:main
Choose a base branch
from
kazupon:fix/1149
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+209
−2
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3424da0
Automated daily upgrade of upstream dependencies:
Brooooooklyn 74770fa
feat(cli): expose bundled tool versions via `vite-plus/versions` export
kazupon 7b1bef4
fix
kazupon 3a16e5f
fix: tweak comments
kazupon 6e8a81c
Merge branch 'main' into fix/1149
fengmk2 e907681
Merge branch 'main' into fix/1149
fengmk2 e29c173
Merge branch 'main' into fix/1149
fengmk2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| /** | ||
| * Verify that the vite-plus/versions export works correctly. | ||
| * | ||
| * Tests run against the already-built dist/ directory, ensuring | ||
| * that syncVersionsExport() produces correct artifacts. | ||
| */ | ||
| import fs from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import url from 'node:url'; | ||
|
|
||
| import { describe, expect, it } from '@voidzero-dev/vite-plus-test'; | ||
|
|
||
| const cliPkgDir = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '../..'); | ||
| const distDir = path.join(cliPkgDir, 'dist'); | ||
| const corePkgPath = path.join(cliPkgDir, '../core/package.json'); | ||
| const testPkgPath = path.join(cliPkgDir, '../test/package.json'); | ||
|
|
||
| describe('versions export', () => { | ||
| describe('build artifacts', () => { | ||
| it('dist/versions.js should exist', () => { | ||
| expect(fs.existsSync(path.join(distDir, 'versions.js'))).toBe(true); | ||
| }); | ||
|
|
||
| it('dist/versions.d.ts should exist', () => { | ||
| expect(fs.existsSync(path.join(distDir, 'versions.d.ts'))).toBe(true); | ||
| }); | ||
|
|
||
| it('dist/versions.js should export a versions object', () => { | ||
| const content = fs.readFileSync(path.join(distDir, 'versions.js'), 'utf-8'); | ||
| expect(content).toContain('export const versions'); | ||
| }); | ||
|
|
||
| it('dist/versions.d.ts should declare a versions type', () => { | ||
| const content = fs.readFileSync(path.join(distDir, 'versions.d.ts'), 'utf-8'); | ||
| expect(content).toContain('export declare const versions'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('bundledVersions consistency', () => { | ||
| it('should contain all core bundledVersions', async () => { | ||
| const corePkg = JSON.parse(fs.readFileSync(corePkgPath, 'utf-8')); | ||
| const mod = await import('../../dist/versions.js'); | ||
| const versions = mod.versions as Record<string, string>; | ||
| for (const [key, value] of Object.entries( | ||
| corePkg.bundledVersions as Record<string, string>, | ||
| )) { | ||
| expect(versions[key], `versions.${key} should match core bundledVersions`).toBe(value); | ||
| } | ||
| }); | ||
|
|
||
| it('should contain all test bundledVersions', async () => { | ||
| const testPkg = JSON.parse(fs.readFileSync(testPkgPath, 'utf-8')); | ||
| const mod = await import('../../dist/versions.js'); | ||
| const versions = mod.versions as Record<string, string>; | ||
| for (const [key, value] of Object.entries( | ||
| testPkg.bundledVersions as Record<string, string>, | ||
| )) { | ||
| expect(versions[key], `versions.${key} should match test bundledVersions`).toBe(value); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe('dependency tool versions', () => { | ||
| it('should contain oxlint version', async () => { | ||
| const mod = await import('../../dist/versions.js'); | ||
| const versions = mod.versions as Record<string, string>; | ||
| expect(versions.oxlint).toBeTypeOf('string'); | ||
| }); | ||
|
|
||
| it('should contain oxfmt version', async () => { | ||
| const mod = await import('../../dist/versions.js'); | ||
| const versions = mod.versions as Record<string, string>; | ||
| expect(versions.oxfmt).toBeTypeOf('string'); | ||
| }); | ||
|
|
||
| it('should contain oxlint-tsgolint version', async () => { | ||
| const mod = await import('../../dist/versions.js'); | ||
| const versions = mod.versions as Record<string, string>; | ||
| expect(versions['oxlint-tsgolint']).toBeTypeOf('string'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('type declarations', () => { | ||
| it('should have type fields for all bundled tools', () => { | ||
| const content = fs.readFileSync(path.join(distDir, 'versions.d.ts'), 'utf-8'); | ||
| const expectedKeys = [ | ||
| 'vite', | ||
| 'rolldown', | ||
| 'tsdown', | ||
| 'vitest', | ||
| 'oxlint', | ||
| 'oxfmt', | ||
| 'oxlint-tsgolint', | ||
| ]; | ||
| for (const key of expectedKeys) { | ||
| expect(content).toContain(key); | ||
| } | ||
| }); | ||
|
|
||
| it('should declare all fields as readonly string', () => { | ||
| const content = fs.readFileSync(path.join(distDir, 'versions.d.ts'), 'utf-8'); | ||
| const fieldMatches = content.match(/readonly [\w'-]+: string;/g); | ||
| expect(fieldMatches).not.toBeNull(); | ||
| expect(fieldMatches!.length).toBeGreaterThanOrEqual(7); | ||
| }); | ||
| }); | ||
|
|
||
| describe('runtime import', () => { | ||
| it('should be importable and return an object with expected keys', async () => { | ||
| const { versions } = await import('../../dist/versions.js'); | ||
| expect(versions).toBeDefined(); | ||
| expect(typeof versions).toBe('object'); | ||
| expect(versions.vite).toBeTypeOf('string'); | ||
| expect(versions.rolldown).toBeTypeOf('string'); | ||
| expect(versions.tsdown).toBeTypeOf('string'); | ||
| expect(versions.vitest).toBeTypeOf('string'); | ||
| expect(versions.oxlint).toBeTypeOf('string'); | ||
| expect(versions.oxfmt).toBeTypeOf('string'); | ||
| expect(versions['oxlint-tsgolint']).toBeTypeOf('string'); | ||
| }); | ||
|
|
||
| it('should have valid semver-like versions', async () => { | ||
| const { versions } = await import('../../dist/versions.js'); | ||
| const semverPattern = /^\d+\.\d+\.\d+/; | ||
| for (const [key, value] of Object.entries(versions as Record<string, string>)) { | ||
| expect(value, `${key} should be a valid version`).toMatch(semverPattern); | ||
| } | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.