Skip to content

fix: ol --version shows the wrong version#60

Open
Copilot wants to merge 1 commit intomainfrom
copilot/fix-ol-versions-return
Open

fix: ol --version shows the wrong version#60
Copilot wants to merge 1 commit intomainfrom
copilot/fix-ol-versions-return

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 11, 2026

ol --version was reporting a stale hardcoded value from src/index.ts instead of the package’s actual release version. This caused version output drift whenever package.json was updated.

  • Version source correction

    • Updated CLI program metadata in src/index.ts to read version from package.json rather than a literal string.
    • Aligns runtime version output with published package metadata.
  • Impact

    • ol --version now reflects the current package version consistently across releases.
import packageJson from '../package.json' with { type: 'json' }

program
	.name('ol')
	.version(packageJson.version)

Copy link
Copy Markdown
Member

@doistbot doistbot left a comment

Choose a reason for hiding this comment

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

Thank you for this update to dynamically pull the CLI version directly from package.json, which is a great maintainability improvement that ensures the runtime version always stays perfectly in sync with published releases. However, the current JSON import approach will cause a TypeScript build failure due to rootDir constraints, so the implementation will need to be adjusted to use a runtime file read instead.

Share FeedbackReview Logs

Comment thread src/index.ts
import { registerSearchCommand } from './commands/search.js'
import { registerSkillCommand } from './commands/skill.js'
import { registerUpdateCommand } from './commands/update/index.js'
import packageJson from '../package.json' with { type: 'json' }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[P0] Build failure due to missing resolveJsonModule and rootDir violation

Importing JSON modules directly requires resolveJsonModule: true in tsconfig.json. Even if that were enabled, importing ../package.json from src/index.ts violates the rootDir: "src" compiler option, as TypeScript expects all compiled files to reside within the source directory. This will cause tsc to fail the build.

To resolve this while remaining compatible with TypeScript and ESM module resolution, read and parse the file at runtime using readFileSync and import.meta.url instead of an import statement.

Suggested change
import packageJson from '../package.json' with { type: 'json' }
import { readFileSync } from 'node:fs'
const packageJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'))

@AfzalivE AfzalivE changed the title Use package.json as the single source of truth for CLI version fix: Use package.json as the single source of truth for CLI version Apr 16, 2026
@AfzalivE AfzalivE changed the title fix: Use package.json as the single source of truth for CLI version fix: package.json as the single source of truth for CLI version Apr 16, 2026
@AfzalivE AfzalivE changed the title fix: package.json as the single source of truth for CLI version fix: ol --version shows the wrong version Apr 16, 2026
@AfzalivE AfzalivE changed the title fix: ol --version shows the wrong version fix: ol --version shows the wrong version Apr 16, 2026
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.

3 participants