File tree Expand file tree Collapse file tree 5 files changed +11
-20
lines changed
Expand file tree Collapse file tree 5 files changed +11
-20
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @oxa/core " : patch
3+ ---
4+
5+ Export version statically rather than dynamically
Original file line number Diff line number Diff line change 22 "$schema" : " https://unpkg.com/@changesets/config@3.1.2/schema.json" ,
33 "changelog" : [" @changesets/changelog-github" , { "repo" : " oxa-dev/oxa" }],
44 "commit" : false ,
5- "fixed" : [],
5+ "fixed" : [[ " @oxa/core " , " oxa " ] ],
66 "linked" : [],
77 "access" : " public" ,
88 "baseBranch" : " main" ,
Original file line number Diff line number Diff line change 1+ src /version.ts
Original file line number Diff line number Diff line change 1616 " dist"
1717 ],
1818 "scripts" : {
19- "build" : " tsc && cp ../../schema/schema.json dist/ && pnpm run build:bundle" ,
19+ "copy:version" : " echo \" const version = '\" $npm_package_version\" ';\n export default version;\" > src/version.ts" ,
20+ "build" : " pnpm run copy:version && tsc && cp ../../schema/schema.json dist/ && pnpm run build:bundle" ,
2021 "build:bundle" : " esbuild src/cli.ts --bundle --platform=node --target=node22 --format=cjs --outfile=dist/cli.bundle.cjs --banner:js='#!/usr/bin/env node' --log-override:empty-import-meta=silent" ,
2122 "test" : " vitest run" ,
2223 "typecheck" : " tsc --noEmit" ,
Original file line number Diff line number Diff line change 55 */
66
77import { program } from "commander" ;
8- import { readFileSync } from "fs" ;
9- import { fileURLToPath } from "url" ;
10- import { dirname , join } from "path" ;
8+ import version from "./version.js" ;
119import {
1210 validateFile ,
1311 validateJson ,
@@ -82,24 +80,10 @@ async function readStdin(): Promise<string> {
8280 return Buffer . concat ( chunks ) . toString ( "utf-8" ) ;
8381}
8482
85- /**
86- * Get package version from package.json.
87- */
88- function getVersion ( ) : string {
89- try {
90- const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
91- const pkgPath = join ( __dirname , ".." , "package.json" ) ;
92- const pkg = JSON . parse ( readFileSync ( pkgPath , "utf-8" ) ) ;
93- return pkg . version ;
94- } catch {
95- return "0.0.0" ;
96- }
97- }
98-
9983program
10084 . name ( "oxa" )
10185 . description ( "CLI for validating OXA documents" )
102- . version ( getVersion ( ) ) ;
86+ . version ( version ) ;
10387
10488program
10589 . command ( "validate" )
You can’t perform that action at this time.
0 commit comments