mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +08:00
修复 node 依赖匹配判断
This commit is contained in:
parent
6131fe0110
commit
04edd97967
|
@ -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 });
|
||||||
});
|
});
|
||||||
|
|
|
@ -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,}/, ' ');
|
||||||
|
|
||||||
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依赖${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({
|
||||||
|
|
Loading…
Reference in New Issue
Block a user