refactor: 配置收敛为运行目录单一带注释 .env,移除 config 目录与 JSON 运行时配置
This commit is contained in:
@@ -19,7 +19,6 @@ export const appApi = {
|
||||
|
||||
export interface InstallStatus {
|
||||
installed: boolean;
|
||||
traceCodeSalt: string | null;
|
||||
defaults: {
|
||||
mysqlHost: string;
|
||||
mysqlPort: number;
|
||||
|
||||
@@ -24,11 +24,6 @@
|
||||
</n-result>
|
||||
|
||||
<template v-else>
|
||||
<div v-if="traceCodeSalt" class="salt">
|
||||
<span>traceCodeSalt</span>
|
||||
<code>{{ traceCodeSalt }}</code>
|
||||
</div>
|
||||
|
||||
<div class="grid">
|
||||
<section class="box">
|
||||
<h2>{{ tt('base') }}</h2>
|
||||
@@ -233,7 +228,6 @@ const form = reactive<InstallForm>({
|
||||
const loading = ref(true);
|
||||
const submitting = ref(false);
|
||||
const installed = ref(false);
|
||||
const traceCodeSalt = ref('');
|
||||
const error = ref('');
|
||||
const success = ref('');
|
||||
|
||||
@@ -246,7 +240,6 @@ onMounted(async () => {
|
||||
const res = await fetch('/api/install/status');
|
||||
const body = await res.json();
|
||||
installed.value = Boolean(body.data?.installed);
|
||||
traceCodeSalt.value = body.data?.traceCodeSalt || '';
|
||||
const d = body.data?.defaults || {};
|
||||
form.port = d.port || form.port;
|
||||
form.mysql.host = d.mysqlHost || form.mysql.host;
|
||||
@@ -335,20 +328,6 @@ async function submit(): Promise<void> {
|
||||
font-size: 13px;
|
||||
color: var(--n-text-color-3, #6a7687);
|
||||
}
|
||||
.salt {
|
||||
display: grid;
|
||||
grid-template-columns: 120px 1fr;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
margin-bottom: 14px;
|
||||
padding: 10px 12px;
|
||||
background: var(--soft-bg, #f7f9fc);
|
||||
border: 1px solid var(--border, #e1e7f0);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.salt code {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { loadRuntimeConfig } from './runtime-config';
|
||||
import { preloadRuntimeEnv } from './runtime-config';
|
||||
|
||||
export interface AppConfig {
|
||||
appName: string;
|
||||
@@ -35,60 +35,50 @@ export interface AppConfig {
|
||||
}
|
||||
|
||||
export default (): AppConfig => {
|
||||
const runtime = loadRuntimeConfig();
|
||||
if (!process.env.DATABASE_URL && runtime.databaseUrl) process.env.DATABASE_URL = runtime.databaseUrl;
|
||||
if (!process.env.BACKUP_DIR && runtime.backupDir) process.env.BACKUP_DIR = runtime.backupDir;
|
||||
const storage = runtime.storage || {};
|
||||
const oss = storage.oss || {};
|
||||
const blockchain = runtime.blockchain || {};
|
||||
const tianhe = blockchain.tianhe || {};
|
||||
const clientOrigin = process.env.CLIENT_ORIGIN || runtime.clientOrigin || 'http://localhost:5174';
|
||||
preloadRuntimeEnv();
|
||||
const clientOrigin = process.env.CLIENT_ORIGIN || 'http://localhost:5174';
|
||||
return {
|
||||
appName: process.env.APP_NAME || runtime.appName || '艺术品溯源平台',
|
||||
appName: process.env.APP_NAME || '艺术品溯源平台',
|
||||
env: process.env.NODE_ENV || 'development',
|
||||
port: parseInt(process.env.API_PORT || String(runtime.port || 3000), 10),
|
||||
baseUrl: process.env.BASE_URL || runtime.baseUrl || 'http://localhost:3000',
|
||||
port: parseInt(process.env.API_PORT || '3000', 10),
|
||||
baseUrl: process.env.BASE_URL || 'http://localhost:3000',
|
||||
publicTracePath: process.env.PUBLIC_TRACE_PATH || '/t',
|
||||
adminOrigin: process.env.ADMIN_ORIGIN || runtime.adminOrigin || 'http://localhost:5173',
|
||||
adminOrigin: process.env.ADMIN_ORIGIN || 'http://localhost:5173',
|
||||
clientOrigin,
|
||||
// 短链跳转到 C 端溯源页的地址模板,{code} 会被替换为短码
|
||||
traceUrlTemplate: process.env.TRACE_URL_TEMPLATE || `${clientOrigin}/#/trace/{code}`,
|
||||
jwt: {
|
||||
secret: process.env.JWT_SECRET || runtime.jwt?.secret || 'artveris_dev_secret',
|
||||
expiresIn: process.env.JWT_EXPIRES_IN || runtime.jwt?.expiresIn || '7d',
|
||||
secret: process.env.JWT_SECRET || 'artveris_dev_secret',
|
||||
expiresIn: process.env.JWT_EXPIRES_IN || '7d',
|
||||
},
|
||||
settingsEncryptionKey:
|
||||
process.env.SETTING_ENCRYPTION_KEY ||
|
||||
runtime.settingsEncryptionKey ||
|
||||
process.env.JWT_SECRET ||
|
||||
runtime.jwt?.secret ||
|
||||
'artveris_dev_secret',
|
||||
process.env.SETTING_ENCRYPTION_KEY || process.env.JWT_SECRET || 'artveris_dev_secret',
|
||||
redis: {
|
||||
host: process.env.REDIS_HOST || runtime.redis?.host || 'localhost',
|
||||
port: parseInt(process.env.REDIS_PORT || String(runtime.redis?.port || 6379), 10),
|
||||
password: process.env.REDIS_PASSWORD || runtime.redis?.password || undefined,
|
||||
host: process.env.REDIS_HOST || 'localhost',
|
||||
port: parseInt(process.env.REDIS_PORT || '6379', 10),
|
||||
password: process.env.REDIS_PASSWORD || undefined,
|
||||
},
|
||||
storage: {
|
||||
driver: (process.env.STORAGE_DRIVER as 'local' | 'oss') || storage.driver || 'local',
|
||||
localDir: process.env.STORAGE_LOCAL_DIR || storage.localDir || './storage',
|
||||
publicPrefix: process.env.STORAGE_PUBLIC_PREFIX || storage.publicPrefix || '/uploads',
|
||||
cdnBaseUrl: process.env.CDN_BASE_URL || storage.cdnBaseUrl || '',
|
||||
driver: (process.env.STORAGE_DRIVER as 'local' | 'oss') || 'local',
|
||||
localDir: process.env.STORAGE_LOCAL_DIR || './storage',
|
||||
publicPrefix: process.env.STORAGE_PUBLIC_PREFIX || '/uploads',
|
||||
cdnBaseUrl: process.env.CDN_BASE_URL || '',
|
||||
oss: {
|
||||
endpoint: process.env.OSS_ENDPOINT || oss.endpoint || '',
|
||||
region: process.env.OSS_REGION || oss.region || '',
|
||||
bucket: process.env.OSS_BUCKET || oss.bucket || '',
|
||||
accessKeyId: process.env.OSS_ACCESS_KEY_ID || oss.accessKeyId || '',
|
||||
accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET || oss.accessKeySecret || '',
|
||||
endpoint: process.env.OSS_ENDPOINT || '',
|
||||
region: process.env.OSS_REGION || '',
|
||||
bucket: process.env.OSS_BUCKET || '',
|
||||
accessKeyId: process.env.OSS_ACCESS_KEY_ID || '',
|
||||
accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET || '',
|
||||
},
|
||||
},
|
||||
blockchain: {
|
||||
driver: (process.env.BLOCKCHAIN_DRIVER as 'mock' | 'tianhe') || blockchain.driver || 'mock',
|
||||
driver: (process.env.BLOCKCHAIN_DRIVER as 'mock' | 'tianhe') || 'mock',
|
||||
tianhe: {
|
||||
baseUrl: process.env.TIANHE_BASE_URL || tianhe.baseUrl || 'https://test.api.tichain.tianhecloud.com',
|
||||
appId: process.env.TIANHE_APP_ID || tianhe.appId || '',
|
||||
appKey: process.env.TIANHE_APP_KEY || tianhe.appKey || '',
|
||||
userId: process.env.TIANHE_USER_ID || tianhe.userId || '',
|
||||
userKey: process.env.TIANHE_USER_KEY || tianhe.userKey || '',
|
||||
baseUrl: process.env.TIANHE_BASE_URL || 'https://test.api.tichain.tianhecloud.com',
|
||||
appId: process.env.TIANHE_APP_ID || '',
|
||||
appKey: process.env.TIANHE_APP_KEY || '',
|
||||
userId: process.env.TIANHE_USER_ID || '',
|
||||
userKey: process.env.TIANHE_USER_KEY || '',
|
||||
},
|
||||
},
|
||||
seedAdmin: {
|
||||
|
||||
@@ -1,62 +1,10 @@
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { dirname, resolve } from 'path';
|
||||
import { resolve } from 'path';
|
||||
|
||||
export interface RuntimeConfigFile {
|
||||
appName?: string;
|
||||
port?: number;
|
||||
baseUrl?: string;
|
||||
adminOrigin?: string;
|
||||
clientOrigin?: string;
|
||||
databaseUrl?: string;
|
||||
redis?: { host?: string; port?: number; password?: string };
|
||||
jwt?: { secret?: string; expiresIn?: string };
|
||||
settingsEncryptionKey?: string;
|
||||
storage?: {
|
||||
driver?: 'local' | 'oss';
|
||||
localDir?: string;
|
||||
publicPrefix?: string;
|
||||
cdnBaseUrl?: string;
|
||||
oss?: {
|
||||
endpoint?: string;
|
||||
region?: string;
|
||||
bucket?: string;
|
||||
accessKeyId?: string;
|
||||
accessKeySecret?: string;
|
||||
};
|
||||
};
|
||||
backupDir?: string;
|
||||
blockchain?: {
|
||||
driver?: 'mock' | 'tianhe';
|
||||
tianhe?: { baseUrl?: string; appId?: string; appKey?: string; userId?: string; userKey?: string };
|
||||
};
|
||||
}
|
||||
|
||||
export function runtimeRoot(): string {
|
||||
// 统一配置目录:优先 ARTVERIS_CONFIG_DIR,兼容旧的 ARTVERIS_RUNTIME_DIR / RUNTIME_DIR,默认 <cwd>/config
|
||||
return resolve(
|
||||
process.env.ARTVERIS_CONFIG_DIR ||
|
||||
process.env.ARTVERIS_RUNTIME_DIR ||
|
||||
process.env.RUNTIME_DIR ||
|
||||
resolve(process.cwd(), 'config'),
|
||||
);
|
||||
}
|
||||
|
||||
export function runtimeConfigPath(): string {
|
||||
return resolve(process.env.ARTVERIS_CONFIG_PATH || resolve(runtimeRoot(), 'artveris.config.json'));
|
||||
}
|
||||
|
||||
export function runtimeEnvPath(): string {
|
||||
return resolve(dirname(runtimeConfigPath()), '.env');
|
||||
}
|
||||
|
||||
export function loadRuntimeConfig(): RuntimeConfigFile {
|
||||
const path = runtimeConfigPath();
|
||||
if (!existsSync(path)) return {};
|
||||
try {
|
||||
return JSON.parse(readFileSync(path, 'utf8')) as RuntimeConfigFile;
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
// 唯一配置来源:运行目录下的 .env(安装向导写入、升级不覆盖)。
|
||||
// 可用 ARTVERIS_ENV_FILE 覆盖该文件路径,主要用于本地调试安装向导。
|
||||
export function envFilePath(): string {
|
||||
return resolve(process.env.ARTVERIS_ENV_FILE || resolve(process.cwd(), '.env'));
|
||||
}
|
||||
|
||||
function loadEnvFile(path: string): void {
|
||||
@@ -77,20 +25,24 @@ function loadEnvFile(path: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
// 启动早期把 .env 载入 process.env:优先 ARTVERIS_ENV_FILE / 运行目录 .env,
|
||||
// 再兼容仓库根 ../../.env(本地开发时 API 的 cwd 为 apps/api)。
|
||||
export function preloadRuntimeEnv(): void {
|
||||
loadEnvFile(envFilePath());
|
||||
loadEnvFile(resolve(process.cwd(), '.env'));
|
||||
loadEnvFile(resolve(process.cwd(), '../../.env'));
|
||||
loadEnvFile(runtimeEnvPath());
|
||||
}
|
||||
|
||||
export function hasRuntimeConfig(): boolean {
|
||||
return existsSync(runtimeConfigPath());
|
||||
export function isInstalled(): boolean {
|
||||
preloadRuntimeEnv();
|
||||
return Boolean(process.env.DATABASE_URL) || existsSync(envFilePath());
|
||||
}
|
||||
|
||||
export function isInstallMode(): boolean {
|
||||
preloadRuntimeEnv();
|
||||
if (process.env.ARTVERIS_INSTALL_MODE === '1') return !hasRuntimeConfig();
|
||||
// 强制安装模式:按目标 .env 是否已生成判定(便于本地用 ARTVERIS_ENV_FILE 调试安装向导)
|
||||
if (process.env.ARTVERIS_INSTALL_MODE === '1') return !existsSync(envFilePath());
|
||||
if (process.env.ARTVERIS_INSTALL_MODE === '0') return false;
|
||||
if (process.env.DATABASE_URL) return false;
|
||||
return !hasRuntimeConfig();
|
||||
// 常规:未配置 DATABASE_URL(即未安装)则进入安装向导
|
||||
return !process.env.DATABASE_URL;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,22 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { createCipheriv, createHash, randomBytes } from 'crypto';
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
||||
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
||||
import { dirname, resolve } from 'path';
|
||||
import { execFileSync } from 'child_process';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import { PrismaClient, RoleType, UserStatus } from '@prisma/client';
|
||||
import Redis from 'ioredis';
|
||||
import { runtimeConfigPath, runtimeEnvPath, runtimeRoot } from '../config/runtime-config';
|
||||
import { envFilePath, isInstallMode } from '../config/runtime-config';
|
||||
import { InstallRequestDto } from './dto/install.dto';
|
||||
|
||||
const INSTALL_STATE_FILE = 'install-state.json';
|
||||
const ENCRYPTED_PREFIX = 'enc:v1:';
|
||||
|
||||
@Injectable()
|
||||
export class InstallService {
|
||||
status() {
|
||||
const configPath = runtimeConfigPath();
|
||||
const installed = existsSync(configPath) || (process.env.ARTVERIS_INSTALL_MODE !== '1' && Boolean(process.env.DATABASE_URL));
|
||||
const prefillSecrets = process.env.INSTALL_PREFILL_SECRETS === '1';
|
||||
return {
|
||||
installed,
|
||||
configPath,
|
||||
traceCodeSalt: installed ? null : this.pendingTraceCodeSalt(),
|
||||
installed: !isInstallMode(),
|
||||
defaults: {
|
||||
mysqlHost: process.env.INSTALL_MYSQL_HOST || '127.0.0.1',
|
||||
mysqlPort: Number(process.env.INSTALL_MYSQL_PORT || 3306),
|
||||
@@ -37,38 +32,22 @@ export class InstallService {
|
||||
}
|
||||
|
||||
async install(dto: InstallRequestDto) {
|
||||
if (existsSync(runtimeConfigPath()) || (process.env.ARTVERIS_INSTALL_MODE !== '1' && process.env.DATABASE_URL)) {
|
||||
if (!isInstallMode()) {
|
||||
return { installed: true, restartRequired: false };
|
||||
}
|
||||
const traceCodeSalt = this.pendingTraceCodeSalt();
|
||||
const traceCodeSalt = randomBytes(32).toString('hex');
|
||||
const settingsEncryptionKey = randomBytes(32).toString('hex');
|
||||
const databaseUrl = this.buildMysqlUrl(dto);
|
||||
await this.ensureDatabase(dto);
|
||||
await this.assertMysql(databaseUrl);
|
||||
await this.assertRedis(dto);
|
||||
const config = this.buildRuntimeConfig(dto, databaseUrl);
|
||||
this.runPrismaMigrate(databaseUrl);
|
||||
await this.seedInstallData(databaseUrl, dto, traceCodeSalt, String(config.settingsEncryptionKey || ''));
|
||||
this.writeRuntimeConfig(config, traceCodeSalt);
|
||||
await this.seedInstallData(databaseUrl, dto, traceCodeSalt, settingsEncryptionKey);
|
||||
this.writeEnvFile(dto, databaseUrl, traceCodeSalt, settingsEncryptionKey);
|
||||
setTimeout(() => process.exit(0), 600);
|
||||
return { installed: true, restartRequired: true };
|
||||
}
|
||||
|
||||
private pendingTraceCodeSalt(): string {
|
||||
const path = resolve(runtimeRoot(), INSTALL_STATE_FILE);
|
||||
try {
|
||||
if (existsSync(path)) {
|
||||
const state = JSON.parse(readFileSync(path, 'utf8')) as { traceCodeSalt?: string };
|
||||
if (state.traceCodeSalt) return state.traceCodeSalt;
|
||||
}
|
||||
} catch {
|
||||
// Regenerate below when the pending state file is malformed.
|
||||
}
|
||||
const traceCodeSalt = randomBytes(32).toString('hex');
|
||||
mkdirSync(dirname(path), { recursive: true });
|
||||
writeFileSync(path, JSON.stringify({ traceCodeSalt }, null, 2), 'utf8');
|
||||
return traceCodeSalt;
|
||||
}
|
||||
|
||||
private buildMysqlUrl(dto: InstallRequestDto): string {
|
||||
const user = encodeURIComponent(dto.mysql.username);
|
||||
const password = encodeURIComponent(dto.mysql.password);
|
||||
@@ -137,54 +116,79 @@ export class InstallService {
|
||||
}
|
||||
}
|
||||
|
||||
private buildRuntimeConfig(dto: InstallRequestDto, databaseUrl: string) {
|
||||
const localDir = dto.storage.localDir || resolve(process.cwd(), 'storage');
|
||||
const baseUrl = dto.baseUrl.replace(/\/$/, '');
|
||||
return {
|
||||
appName: dto.appName,
|
||||
port: Number(dto.port || process.env.API_PORT || 3000),
|
||||
baseUrl,
|
||||
adminOrigin: `${baseUrl}/admin`,
|
||||
clientOrigin: `${baseUrl}/trace`,
|
||||
databaseUrl,
|
||||
redis: {
|
||||
host: dto.redis.host,
|
||||
port: dto.redis.port,
|
||||
password: dto.redis.password || '',
|
||||
},
|
||||
jwt: {
|
||||
secret: dto.jwtSecret || randomBytes(32).toString('hex'),
|
||||
expiresIn: dto.jwtExpiresIn || '7d',
|
||||
},
|
||||
settingsEncryptionKey: randomBytes(32).toString('hex'),
|
||||
storage: {
|
||||
driver: dto.storage.driver,
|
||||
localDir,
|
||||
publicPrefix: '/uploads',
|
||||
cdnBaseUrl: dto.storage.cdnBaseUrl || '',
|
||||
oss: {
|
||||
endpoint: dto.storage.ossEndpoint || '',
|
||||
region: dto.storage.ossRegion || '',
|
||||
bucket: dto.storage.ossBucket || '',
|
||||
accessKeyId: dto.storage.ossAccessKeyId || '',
|
||||
accessKeySecret: '',
|
||||
},
|
||||
},
|
||||
backupDir: resolve(process.cwd(), 'backups'),
|
||||
blockchain: { driver: 'mock', tianhe: {} },
|
||||
};
|
||||
private envValue(value: string): string {
|
||||
// 统一用双引号包裹(安装输入不含双引号;DATABASE_URL 中的凭据已 URL 编码)
|
||||
return `"${String(value ?? '')}"`;
|
||||
}
|
||||
|
||||
private writeRuntimeConfig(config: Record<string, unknown>, traceCodeSalt: string): void {
|
||||
const path = runtimeConfigPath();
|
||||
mkdirSync(dirname(path), { recursive: true });
|
||||
writeFileSync(path, JSON.stringify(config, null, 2), 'utf8');
|
||||
const envLines = [
|
||||
`DATABASE_URL="${config.databaseUrl}"`,
|
||||
`TRACE_CODE_SALT=${traceCodeSalt}`,
|
||||
`ARTVERIS_CONFIG_PATH=${path.replace(/\\/g, '/')}`,
|
||||
// 安装向导把配置落盘为运行目录下的单一 .env(带注释)。升级不会覆盖本文件。
|
||||
private writeEnvFile(
|
||||
dto: InstallRequestDto,
|
||||
databaseUrl: string,
|
||||
traceCodeSalt: string,
|
||||
settingsEncryptionKey: string,
|
||||
): void {
|
||||
const baseUrl = dto.baseUrl.replace(/\/$/, '');
|
||||
const clientOrigin = `${baseUrl}/trace`;
|
||||
const localDir = dto.storage.localDir || resolve(process.cwd(), 'storage');
|
||||
const jwtSecret = dto.jwtSecret || randomBytes(32).toString('hex');
|
||||
const q = (v: string) => this.envValue(v);
|
||||
const lines = [
|
||||
'# Artveris 运行配置(安装向导生成)。升级不会覆盖本文件。',
|
||||
'# 改配置:可直接编辑本文件后重启服务;平台名/存储/区块链等也可在后台「系统设置」在线修改。',
|
||||
'',
|
||||
'# ===== 应用 =====',
|
||||
`APP_NAME=${q(dto.appName)}`,
|
||||
'NODE_ENV=production',
|
||||
'# 服务监听端口(由前置 Nginx/宝塔反代指向此端口)',
|
||||
`API_PORT=${q(String(dto.port || 3000))}`,
|
||||
'# 对外访问地址:三端共用,客户端在 /trace、后台 /admin、接口 /api、短链 /t',
|
||||
`BASE_URL=${q(baseUrl)}`,
|
||||
'PUBLIC_TRACE_PATH=/t',
|
||||
`ADMIN_ORIGIN=${q(baseUrl)}`,
|
||||
`CLIENT_ORIGIN=${q(clientOrigin)}`,
|
||||
`TRACE_URL_TEMPLATE=${q(`${clientOrigin}/#/trace/{code}`)}`,
|
||||
'',
|
||||
'# ===== 数据库(Prisma 直接读取 DATABASE_URL)=====',
|
||||
`DATABASE_URL=${q(databaseUrl)}`,
|
||||
'',
|
||||
'# ===== Redis =====',
|
||||
`REDIS_HOST=${q(dto.redis.host)}`,
|
||||
`REDIS_PORT=${q(String(dto.redis.port))}`,
|
||||
`REDIS_PASSWORD=${q(dto.redis.password || '')}`,
|
||||
'',
|
||||
'# ===== 安全密钥(务必保密,勿随意更改)=====',
|
||||
'# 登录令牌密钥;更改会使已签发登录失效',
|
||||
`JWT_SECRET=${q(jwtSecret)}`,
|
||||
`JWT_EXPIRES_IN=${q(dto.jwtExpiresIn || '7d')}`,
|
||||
'# 设置项加密密钥(加密 OSS/天河链等密钥);更改会导致已加密数据无法解密',
|
||||
`SETTING_ENCRYPTION_KEY=${q(settingsEncryptionKey)}`,
|
||||
'# 溯源码盐(决定 12 位码生成),勿更改',
|
||||
`TRACE_CODE_SALT=${q(traceCodeSalt)}`,
|
||||
'',
|
||||
'# ===== 文件存储:local | oss =====',
|
||||
`STORAGE_DRIVER=${q(dto.storage.driver)}`,
|
||||
`STORAGE_LOCAL_DIR=${q(localDir)}`,
|
||||
'STORAGE_PUBLIC_PREFIX=/uploads',
|
||||
`CDN_BASE_URL=${q(dto.storage.cdnBaseUrl || '')}`,
|
||||
`OSS_ENDPOINT=${q(dto.storage.ossEndpoint || '')}`,
|
||||
`OSS_REGION=${q(dto.storage.ossRegion || '')}`,
|
||||
`OSS_BUCKET=${q(dto.storage.ossBucket || '')}`,
|
||||
`OSS_ACCESS_KEY_ID=${q(dto.storage.ossAccessKeyId || '')}`,
|
||||
'# OSS 密钥的加密副本存于数据库;此处留空,需要时在后台系统设置维护',
|
||||
'OSS_ACCESS_KEY_SECRET=',
|
||||
'',
|
||||
'# ===== 区块链存证(默认 mock,可后台切天河链)=====',
|
||||
'BLOCKCHAIN_DRIVER=mock',
|
||||
'',
|
||||
'# ===== 其它 =====',
|
||||
`BACKUP_DIR=${q(resolve(process.cwd(), 'backups'))}`,
|
||||
'LOG_RETENTION_DAYS=365',
|
||||
'',
|
||||
];
|
||||
writeFileSync(runtimeEnvPath(), `${envLines.join('\n')}\n`, 'utf8');
|
||||
const path = envFilePath();
|
||||
mkdirSync(dirname(path), { recursive: true });
|
||||
writeFileSync(path, `${lines.join('\n')}\n`, 'utf8');
|
||||
}
|
||||
|
||||
private runPrismaMigrate(databaseUrl: string): void {
|
||||
|
||||
Reference in New Issue
Block a user