mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
pref: 启动输出版本和站点id
This commit is contained in:
@@ -1,16 +1,10 @@
|
||||
import { Autoload, Config, Init, Inject, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { logger } from '@certd/pipeline';
|
||||
import { UserService } from '../sys/authority/service/user-service.js';
|
||||
import { PlusService, SysSettingsService } from '@certd/lib-server';
|
||||
import { PlusService, SysInstallInfo, SysPrivateSettings, SysSettingsService } from '@certd/lib-server';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { SysInstallInfo, SysPrivateSettings } from '@certd/lib-server';
|
||||
import crypto from 'crypto';
|
||||
|
||||
export type InstallInfo = {
|
||||
installTime: number;
|
||||
instanceId?: string;
|
||||
};
|
||||
|
||||
@Autoload()
|
||||
@Scope(ScopeEnum.Singleton)
|
||||
export class AutoInitSite {
|
||||
@@ -59,8 +53,6 @@ export class AutoInitSite {
|
||||
}
|
||||
|
||||
logger.info('初始化站点完成');
|
||||
// const pkg = require('../../../package.json');
|
||||
// logger.info(`当前版本为:${pkg.version}`);
|
||||
}
|
||||
|
||||
async startOptimizeDb() {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { Autoload, Init, Inject, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { logger } from '@certd/pipeline';
|
||||
import { SysInstallInfo, SysSettingsService } from '@certd/lib-server';
|
||||
import { getVersion } from '../../utils/version.js';
|
||||
|
||||
@Autoload()
|
||||
@Scope(ScopeEnum.Singleton)
|
||||
export class AutoZPrint {
|
||||
@Inject()
|
||||
sysSettingsService: SysSettingsService;
|
||||
|
||||
@Init()
|
||||
async init() {
|
||||
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
|
||||
logger.info('=========================================');
|
||||
logger.info('当前站点ID:', installInfo.siteId);
|
||||
const version = await getVersion();
|
||||
logger.info(`当前版本:${version}`);
|
||||
logger.info('服务启动完成');
|
||||
logger.info('=========================================');
|
||||
}
|
||||
}
|
||||
@@ -34,20 +34,27 @@ export class PluginConfigService {
|
||||
return configs;
|
||||
}
|
||||
|
||||
async saveCommPluginConfig(body: CommPluginConfig) {
|
||||
const certApplyConfig = body.CertApply;
|
||||
const CertApply = await this.pluginService.getRepository().findOne({
|
||||
where: { name: 'CertApply' },
|
||||
async saveCommPluginConfig(config: CommPluginConfig) {
|
||||
await this.savePluginConfig('CertApply', config.CertApply);
|
||||
}
|
||||
|
||||
async savePluginConfig(name: string, config: PluginConfig) {
|
||||
const sysSetting = config?.sysSetting;
|
||||
if (!sysSetting) {
|
||||
throw new Error(`${name}.sysSetting is required`);
|
||||
}
|
||||
const pluginEntity = await this.pluginService.getRepository().findOne({
|
||||
where: { name },
|
||||
});
|
||||
if (!CertApply) {
|
||||
if (!pluginEntity) {
|
||||
await this.pluginService.add({
|
||||
name: 'CertApply',
|
||||
sysSetting: JSON.stringify(certApplyConfig),
|
||||
name,
|
||||
sysSetting: JSON.stringify(sysSetting),
|
||||
type: 'builtIn',
|
||||
disabled: false,
|
||||
});
|
||||
} else {
|
||||
await this.pluginService.getRepository().update({ name: 'CertApply' }, { sysSetting: JSON.stringify(certApplyConfig) });
|
||||
await this.pluginService.getRepository().update({ name }, { sysSetting: JSON.stringify(sysSetting) });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import fs from 'fs';
|
||||
|
||||
export async function getVersion() {
|
||||
const pkg = await fs.promises.readFile('../../../package.json');
|
||||
const pkgJson = JSON.parse(pkg.toString());
|
||||
return pkgJson.version;
|
||||
}
|
||||
Reference in New Issue
Block a user