From 68cdbfe21bdd54a18020b1ee58b90377bea11ef3 Mon Sep 17 00:00:00 2001 From: Pedro Lamas Date: Sat, 1 Jul 2023 21:10:02 +0100 Subject: [PATCH] refactor: generate release_info.json Signed-off-by: Pedro Lamas --- vite.config.inject-version.ts | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/vite.config.inject-version.ts b/vite.config.inject-version.ts index 0a748333e6..d1321fcfd2 100644 --- a/vite.config.inject-version.ts +++ b/vite.config.inject-version.ts @@ -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', @@ -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() }) } }