mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-13 12:23:29 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3987ef8d97 | ||
|
|
8b0dedaf8c | ||
|
|
04edd97967 |
@@ -20,6 +20,7 @@ const rootPath = process.env.QL_DIR as string;
|
|||||||
const envFound = dotenv.config({ path: path.join(rootPath, '.env') });
|
const envFound = dotenv.config({ path: path.join(rootPath, '.env') });
|
||||||
|
|
||||||
const dataPath = path.join(rootPath, 'data/');
|
const dataPath = path.join(rootPath, 'data/');
|
||||||
|
const shellPath = path.join(rootPath, 'shell/');
|
||||||
const tmpPath = path.join(rootPath, '.tmp/');
|
const tmpPath = path.join(rootPath, '.tmp/');
|
||||||
const samplePath = path.join(rootPath, 'sample/');
|
const samplePath = path.join(rootPath, 'sample/');
|
||||||
const configPath = path.join(dataPath, 'config/');
|
const configPath = path.join(dataPath, 'config/');
|
||||||
@@ -44,6 +45,7 @@ const loginFaild = '请先登录!';
|
|||||||
const configString = 'config sample crontab shareCode diy';
|
const configString = 'config sample crontab shareCode diy';
|
||||||
const versionFile = path.join(rootPath, 'version.yaml');
|
const versionFile = path.join(rootPath, 'version.yaml');
|
||||||
const dataTgzFile = path.join(tmpPath, 'data.tgz');
|
const dataTgzFile = path.join(tmpPath, 'data.tgz');
|
||||||
|
const shareShellFile = path.join(shellPath, 'share.sh');
|
||||||
|
|
||||||
if (envFound.error) {
|
if (envFound.error) {
|
||||||
throw new Error("⚠️ Couldn't find .env file ⚠️");
|
throw new Error("⚠️ Couldn't find .env file ⚠️");
|
||||||
@@ -64,6 +66,7 @@ export default {
|
|||||||
tmpPath,
|
tmpPath,
|
||||||
dataPath,
|
dataPath,
|
||||||
dataTgzFile,
|
dataTgzFile,
|
||||||
|
shareShellFile,
|
||||||
configString,
|
configString,
|
||||||
loginFaild,
|
loginFaild,
|
||||||
authError,
|
authError,
|
||||||
|
|||||||
@@ -43,13 +43,13 @@ export enum DependenceTypes {
|
|||||||
export enum InstallDependenceCommandTypes {
|
export enum InstallDependenceCommandTypes {
|
||||||
'pnpm add -g',
|
'pnpm add -g',
|
||||||
'pip3 install --disable-pip-version-check --root-user-action=ignore',
|
'pip3 install --disable-pip-version-check --root-user-action=ignore',
|
||||||
'apk add',
|
'apk add --no-check-certificate',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum GetDependenceCommandTypes {
|
export enum GetDependenceCommandTypes {
|
||||||
'pnpm ls -g ',
|
'pnpm ls -g ',
|
||||||
'pip3 show --disable-pip-version-check',
|
'pip3 show --disable-pip-version-check',
|
||||||
'apk info',
|
'apk info -es',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum versionDependenceCommandTypes {
|
export enum versionDependenceCommandTypes {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export default async () => {
|
|||||||
// 初始化时安装所有处于安装中,安装成功,安装失败的依赖
|
// 初始化时安装所有处于安装中,安装成功,安装失败的依赖
|
||||||
DependenceModel.findAll({
|
DependenceModel.findAll({
|
||||||
where: {},
|
where: {},
|
||||||
order: [['type', 'DESC']],
|
order: [['type', 'DESC'], ['createdAt', 'DESC']],
|
||||||
raw: true,
|
raw: true,
|
||||||
}).then(async (docs) => {
|
}).then(async (docs) => {
|
||||||
await DependenceModel.update(
|
await DependenceModel.update(
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ const client = new HealthClient(
|
|||||||
app.get('/api/health', (req, res) => {
|
app.get('/api/health', (req, res) => {
|
||||||
client.check({ service: 'cron' }, (err, response) => {
|
client.check({ service: 'cron' }, (err, response) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return res.status(500).send({ code: 500, error: err });
|
return res.status(200).send({ code: 500, error: err });
|
||||||
}
|
}
|
||||||
return res.status(200).send({ code: 200, data: response });
|
return res.status(200).send({ code: 200, data: response });
|
||||||
});
|
});
|
||||||
|
|||||||
+17
-11
@@ -168,7 +168,7 @@ export default class DependenceService {
|
|||||||
const socketMessageType = isInstall
|
const socketMessageType = isInstall
|
||||||
? 'installDependence'
|
? 'installDependence'
|
||||||
: 'uninstallDependence';
|
: 'uninstallDependence';
|
||||||
const depName = dependency.name.trim();
|
let depName = dependency.name.trim();
|
||||||
const depRunCommand = (
|
const depRunCommand = (
|
||||||
isInstall
|
isInstall
|
||||||
? InstallDependenceCommandTypes
|
? InstallDependenceCommandTypes
|
||||||
@@ -191,29 +191,35 @@ export default class DependenceService {
|
|||||||
if (isInstall) {
|
if (isInstall) {
|
||||||
const getCommandPrefix = GetDependenceCommandTypes[dependency.type];
|
const getCommandPrefix = GetDependenceCommandTypes[dependency.type];
|
||||||
const depVersionStr = versionDependenceCommandTypes[dependency.type];
|
const depVersionStr = versionDependenceCommandTypes[dependency.type];
|
||||||
const [_depName, _depVersion] = dependency.name
|
let depVersion = '';
|
||||||
.trim()
|
if (depName.includes(depVersionStr)) {
|
||||||
.split(depVersionStr);
|
const symbolRegx = new RegExp(`(.*)${depVersionStr}([0-9\\.\\-\\+a-zA-Z]*)`);
|
||||||
|
const [, _depName, _depVersion] = depName.match(symbolRegx) || [];
|
||||||
|
if (_depVersion && _depName) {
|
||||||
|
depName = _depName;
|
||||||
|
depVersion = _depVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
const isNodeDependence = dependency.type === DependenceTypes.nodejs;
|
const isNodeDependence = dependency.type === DependenceTypes.nodejs;
|
||||||
const isLinuxDependence = dependency.type === DependenceTypes.linux;
|
const isLinuxDependence = dependency.type === DependenceTypes.linux;
|
||||||
const isPythonDependence = dependency.type === DependenceTypes.python3;
|
const isPythonDependence = dependency.type === DependenceTypes.python3;
|
||||||
const depInfo = (
|
const depInfo = (
|
||||||
await promiseExecSuccess(
|
await promiseExecSuccess(
|
||||||
isNodeDependence
|
isNodeDependence
|
||||||
? `${getCommandPrefix} | grep "${_depName}" | head -1`
|
? `${getCommandPrefix} | grep "${depName}" | head -1`
|
||||||
: `${getCommandPrefix} ${_depName}`,
|
: `${getCommandPrefix} ${depName}`,
|
||||||
)
|
)
|
||||||
).replace(/\s{2,}/, ' ');
|
).replace(/\s{2,}/, ' ').replace(/\s+$/, '');
|
||||||
|
|
||||||
if (
|
if (
|
||||||
depInfo &&
|
depInfo &&
|
||||||
((isNodeDependence && depInfo.split(' ')?.[0] === _depName) ||
|
((isNodeDependence && depInfo.split(' ')?.[0] === depName) ||
|
||||||
(isLinuxDependence && depInfo.toLocaleLowerCase().includes('installed')) ||
|
(isLinuxDependence && depInfo.toLocaleLowerCase().includes('installed')) ||
|
||||||
isPythonDependence) &&
|
isPythonDependence) &&
|
||||||
(!_depVersion || depInfo.includes(_depVersion))
|
(!depVersion || depInfo.includes(depVersion))
|
||||||
) {
|
) {
|
||||||
const endTime = dayjs();
|
const endTime = dayjs();
|
||||||
const _message = `检测到已经安装 ${_depName}\n\n${depInfo}\n跳过安装\n\n依赖${actionText}成功,结束时间 ${endTime.format(
|
const _message = `检测到已经安装 ${depName}\n\n${depInfo}\n\n跳过安装\n\n依赖${actionText}成功,结束时间 ${endTime.format(
|
||||||
'YYYY-MM-DD HH:mm:ss',
|
'YYYY-MM-DD HH:mm:ss',
|
||||||
)},耗时 ${endTime.diff(startTime, 'second')} 秒`;
|
)},耗时 ${endTime.diff(startTime, 'second')} 秒`;
|
||||||
this.sockService.sendMessage({
|
this.sockService.sendMessage({
|
||||||
@@ -230,7 +236,7 @@ export default class DependenceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cp = spawn(`${depRunCommand} ${depName}`, {
|
const cp = spawn(`${depRunCommand} ${dependency.name.trim()}`, {
|
||||||
shell: '/bin/bash',
|
shell: '/bin/bash',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -79,8 +79,6 @@ main() {
|
|||||||
npm i -g pnpm@8.3.1
|
npm i -g pnpm@8.3.1
|
||||||
patch_version
|
patch_version
|
||||||
|
|
||||||
apk add procps netcat-openbsd
|
|
||||||
|
|
||||||
if [[ $PipMirror ]]; then
|
if [[ $PipMirror ]]; then
|
||||||
pip3 config set global.index-url $PipMirror
|
pip3 config set global.index-url $PipMirror
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -314,7 +314,6 @@ reload_pm2() {
|
|||||||
unset_proxy
|
unset_proxy
|
||||||
pm2 flush &>/dev/null
|
pm2 flush &>/dev/null
|
||||||
pm2 startOrGracefulReload $file_ecosystem_js --update-env
|
pm2 startOrGracefulReload $file_ecosystem_js --update-env
|
||||||
pm2 sendSignal SIGKILL panel &>/dev/null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
diff_time() {
|
diff_time() {
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ const Dependence = () => {
|
|||||||
const handleDependence = (dependence: any) => {
|
const handleDependence = (dependence: any) => {
|
||||||
const result = [...value];
|
const result = [...value];
|
||||||
if (Array.isArray(dependence)) {
|
if (Array.isArray(dependence)) {
|
||||||
result.push(...dependence);
|
result.unshift(...dependence);
|
||||||
} else {
|
} else {
|
||||||
const index = value.findIndex((x) => x.id === dependence.id);
|
const index = value.findIndex((x) => x.id === dependence.id);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ interface IResponseData {
|
|||||||
code?: number;
|
code?: number;
|
||||||
data?: any;
|
data?: any;
|
||||||
message?: string;
|
message?: string;
|
||||||
|
error?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Override<
|
type Override<
|
||||||
|
|||||||
+5
-6
@@ -1,7 +1,6 @@
|
|||||||
version: 2.15.19
|
version: 2.15.20
|
||||||
changeLogLink: https://t.me/jiao_long/385
|
changeLogLink: https://t.me/jiao_long/386
|
||||||
publishTime: 2023-07-20 23:59
|
publishTime: 2023-07-22 16:00
|
||||||
changeLog: |
|
changeLog: |
|
||||||
1. 通知支持 pushMe
|
1. 修复判断 linux 依赖已安装逻辑
|
||||||
2. 修复系统通知设置保存失败
|
2. 修复未启动完成时,页面提示 500
|
||||||
3. 修复判断依赖已安装逻辑
|
|
||||||
|
|||||||
Reference in New Issue
Block a user