chore(ci): should directly import config

This commit is contained in:
Neko Ayaka
2026-03-27 15:32:46 +08:00
parent fc72b7a56c
commit 9caf6a4966
+7 -7
View File
@@ -2,20 +2,17 @@ import type { Configuration } from 'electron-builder'
import process from 'node:process'
import { readFile } from 'node:fs/promises'
import { resolve } from 'node:path'
import { x } from 'tinyexec'
import * as yaml from 'yaml'
import packageJSON from '../package.json' assert { type: 'json' }
export async function getVersion(options: { release: boolean, autoTag: boolean, tag: string[] }) {
if (!options.release || !options.tag) {
// Otherwise, fetch from the latest git ref
const res = await x('git', ['log', '-1', '--pretty=format:"%H"'])
// eslint-disable-next-line e18e/prefer-static-regex
const date = new Date().toISOString().split('T')[0].replace(/-/g, '')
// eslint-disable-next-line e18e/prefer-static-regex
return `nightly-${date}-${String(res.stdout.replace(/"/g, '')).trim().substring(0, 7)}`
}
@@ -24,6 +21,7 @@ export async function getVersion(options: { release: boolean, autoTag: boolean,
// If --tag is specified, use the provided tag
if (options.tag[0] !== 'true') {
// eslint-disable-next-line e18e/prefer-static-regex
version = String(options.tag[0]).replace(/^v/, '').trim()
}
// Otherwise, even for --tag option (true / enabled), ignore the input
@@ -44,6 +42,7 @@ export async function getVersion(options: { release: boolean, autoTag: boolean,
// fetch the latest git ref
try {
const res = await x('git', ['describe', '--tags', '--abbrev=0'])
// eslint-disable-next-line e18e/prefer-static-regex
return String(res.stdout).replace(/^v/, '').trim()
}
catch {
@@ -53,8 +52,9 @@ export async function getVersion(options: { release: boolean, autoTag: boolean,
}
}
export async function getElectronBuilderConfig() {
return yaml.parse(await readFile(resolve(import.meta.dirname, '..', 'electron-builder.yml'), 'utf-8')) as Configuration
export async function getElectronBuilderConfig(): Promise<Configuration> {
const config = await import ('../electron-builder.config')
return config.default
}
export function applyTemplateOfArtifactName(