- Changed external links in settings-test.md and package.json to point to the new domestic website (guanzhangai.cn). - Updated electron-builder.yml to publish updates from the new domestic URL. - Introduced a new storage client for Tencent COS and refactored existing R2 client code to support both storage options. - Implemented environment variable checks and configurations for Tencent COS and Cloudflare R2. - Added tests for release storage configuration and ensured proper handling of live publish locks. - Updated telemetry service to use the new official website URL for event reporting.
46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
import { access, readFile } from 'node:fs/promises'
|
|
import os from 'node:os'
|
|
import path from 'node:path'
|
|
import process from 'node:process'
|
|
|
|
export const loadReleaseEnvironment = async (root) => {
|
|
const filePath = path.join(root, '.env')
|
|
const content = await readFile(filePath, 'utf8').catch((error) => {
|
|
if (error?.code === 'ENOENT') return ''
|
|
throw error
|
|
})
|
|
for (const rawLine of content.split(/\r?\n/u)) {
|
|
const line = rawLine.trim()
|
|
if (!line || line.startsWith('#')) continue
|
|
const separator = line.indexOf('=')
|
|
if (separator < 1) throw new Error(`invalid release environment line: ${rawLine}`)
|
|
const name = line.slice(0, separator).trim()
|
|
let value = line.slice(separator + 1).trim()
|
|
if (
|
|
(value.startsWith('"') && value.endsWith('"')) ||
|
|
(value.startsWith("'") && value.endsWith("'"))
|
|
) {
|
|
value = value.slice(1, -1)
|
|
}
|
|
if (!process.env[name]) process.env[name] = value
|
|
}
|
|
|
|
if (process.platform === 'win32' && !process.env.NCURATOR_AWS_CLI) {
|
|
const candidates = [
|
|
process.env.ProgramFiles
|
|
? path.join(process.env.ProgramFiles, 'Amazon', 'AWSCLIV2', 'aws.exe')
|
|
: '',
|
|
path.join(os.homedir(), '.ncurator', 'release-tools', 'awscli', 'aws.exe')
|
|
].filter(Boolean)
|
|
for (const candidate of candidates) {
|
|
const exists = await access(candidate)
|
|
.then(() => true)
|
|
.catch(() => false)
|
|
if (exists) {
|
|
process.env.NCURATOR_AWS_CLI = candidate
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|