Skip to content

Commit

Permalink
refactor: create version file and delete loading package.json version
Browse files Browse the repository at this point in the history
Co-authored-by: camcam-lemon <omega.camcamlemon@gmail.com>
  • Loading branch information
camcam-lemon authored and aloisklink committed Dec 2, 2024
1 parent 162a640 commit 9a42e3c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ jobs:

- name: Prepare release
run: npm version --no-git-tag-version --allow-same-version ${{env.RELEASE_VERSION}}


- name: Update version file
run: |
echo "export const version = '${{env.RELEASE_VERSION}}'" > src/version.js
git add src/version.js
- name: Convert repository name to lower case
run: echo "GITHUB_REPOSITORY_LOWER_CASE=$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

Expand Down
7 changes: 2 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import { resolve } from 'import-meta-resolve'
import path from 'path'
import puppeteer from 'puppeteer'
import url from 'url'
import { version } from './version.js'

// importing JSON is still experimental in Node.JS https://nodejs.org/docs/latest-v16.x/api/esm.html#json-modules
import { createRequire } from 'module'
const require = createRequire(import.meta.url)
const pkg = require('../package.json')
// __dirname is not available in ESM modules by default
const __dirname = url.fileURLToPath(new url.URL('.', import.meta.url))

Expand Down Expand Up @@ -108,7 +105,7 @@ function parseCommanderInt (value, _unused) {
async function cli () {
const commander = new Command()
commander
.version(pkg.version)
.version(version)
.addOption(new Option('-t, --theme [theme]', 'Theme of the chart').choices(['default', 'forest', 'dark', 'neutral']).default('default'))
.addOption(new Option('-w, --width [width]', 'Width of the page').argParser(parseCommanderInt).default(800))
.addOption(new Option('-H, --height [height]', 'Height of the page').argParser(parseCommanderInt).default(600))
Expand Down
1 change: 1 addition & 0 deletions src/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const version = '11.4.0'

0 comments on commit 9a42e3c

Please sign in to comment.