Skip to content

Commit

Permalink
refactor: generate release_info.json
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas committed Jul 1, 2023
1 parent 9a106d5 commit 68cdbfe
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions vite.config.inject-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ import { version } from './package.json'

import type { Plugin } from 'vite'

const writeVersionFile = async () => {
const versionFile = await fs.promises.open(path.resolve(__dirname, 'dist/.version'), 'w')

await versionFile.writeFile(`v${version}`)

await versionFile.close()
}

const writeReleaseInfoFile = async () => {
const releaseInfoFile = await fs.promises.open(path.resolve(__dirname, 'dist/release_info.json'), 'w')

await releaseInfoFile.writeFile(JSON.stringify({
project_name: 'fluidd',
project_owner: 'fluidd-core',
version: `v${version}`
}))

await releaseInfoFile.close()
}

const vitePluginInjectVersion = (): Plugin => {
return {
name: 'version',
Expand All @@ -22,11 +42,8 @@ const vitePluginInjectVersion = (): Plugin => {
},
writeBundle: () => {
setImmediate(async () => {
const versionFile = await fs.promises.open(path.resolve(__dirname, 'dist/.version'), 'w')

await versionFile.writeFile(`v${version}`)

await versionFile.close()
await writeVersionFile()
await writeReleaseInfoFile()
})
}
}
Expand Down

0 comments on commit 68cdbfe

Please sign in to comment.