@whyour/qinglong 0.14.4 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-en.md +9 -1
- package/README.md +9 -1
- package/docker/310.Dockerfile +81 -0
- package/docker/Dockerfile +5 -0
- package/package.json +2 -2
- package/sample/notify.py +57 -57
- package/shell/update.sh +2 -2
- package/static/build/api/config.js +16 -20
- package/static/build/api/log.js +13 -1
- package/static/build/api/script.js +12 -3
- package/static/build/api/user.js +3 -0
- package/static/build/loaders/initData.js +23 -1
- package/static/build/services/config.js +45 -0
- package/static/build/services/script.js +29 -1
- package/static/build/services/system.js +4 -4
- package/static/dist/8008.ffb3ed8e.async.js +1 -0
- package/static/dist/index.html +1 -1
- package/static/dist/src__pages__config__index.634c902a.async.js +1 -0
- package/static/dist/src__pages__crontab__detail.7d1c2d15.async.js +1 -0
- package/static/dist/src__pages__crontab__index.5aece157.async.js +1 -0
- package/static/dist/src__pages__log__index.757b3471.async.js +1 -0
- package/static/dist/src__pages__script__editModal.1822dae7.async.js +1 -0
- package/static/dist/src__pages__script__index.ed44bc1b.async.js +1 -0
- package/static/dist/src__pages__script__renameModal.8bbbc126.async.js +1 -0
- package/static/dist/src__pages__setting__dependence.2efb8ee3.async.js +1 -0
- package/static/dist/src__pages__setting__index.9fe663df.async.js +1 -0
- package/static/dist/{umi.8daa227c.js → umi.d9511dd2.js} +1 -1
- package/version.yaml +12 -27
- package/static/dist/8008.2d18f19d.async.js +0 -1
- package/static/dist/src__pages__config__index.77dd013c.async.js +0 -1
- package/static/dist/src__pages__crontab__detail.5b509309.async.js +0 -1
- package/static/dist/src__pages__crontab__index.e74d65bc.async.js +0 -1
- package/static/dist/src__pages__log__index.84556deb.async.js +0 -1
- package/static/dist/src__pages__script__editModal.17bcb1c2.async.js +0 -1
- package/static/dist/src__pages__script__index.320f4af9.async.js +0 -1
- package/static/dist/src__pages__script__renameModal.90d4d26a.async.js +0 -1
- package/static/dist/src__pages__setting__dependence.1f8b48fc.async.js +0 -1
- package/static/dist/src__pages__setting__index.f8842b47.async.js +0 -1
package/README-en.md
CHANGED
|
@@ -166,6 +166,14 @@ podman run -dit \
|
|
|
166
166
|
It is recommended to use a pure system installation to avoid losing the original system data, you need to install node/npm/python3/pip3 yourself
|
|
167
167
|
|
|
168
168
|
```bash
|
|
169
|
+
# Debian/Ubuntu
|
|
170
|
+
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
|
|
171
|
+
# Centos
|
|
172
|
+
curl --silent --location https://rpm.nodesource.com/setup_20.x | sudo bash
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
npm install -g node-pre-gyp pnpm@8.3.1
|
|
169
177
|
npm install -g @whyour/qinglong
|
|
170
178
|
qinglong
|
|
171
179
|
# Add the environment variables QL_DIR and QL_DATA_DIR when prompted
|
|
@@ -178,7 +186,7 @@ qinglong
|
|
|
178
186
|
## Development
|
|
179
187
|
|
|
180
188
|
```bash
|
|
181
|
-
$ git clone
|
|
189
|
+
$ git clone https://github.com/whyour/qinglong.git
|
|
182
190
|
$ cd qinglong
|
|
183
191
|
$ cp .env.example .env
|
|
184
192
|
# Recommended use pnpm https://pnpm.io/zh/installation
|
package/README.md
CHANGED
|
@@ -166,6 +166,14 @@ podman run -dit \
|
|
|
166
166
|
建议使用纯净系统安装,避免系统原有数据丢失,需要自己安装 node/npm/python3/pip3
|
|
167
167
|
|
|
168
168
|
```bash
|
|
169
|
+
# Debian/Ubuntu
|
|
170
|
+
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
|
|
171
|
+
# Centos
|
|
172
|
+
curl --silent --location https://rpm.nodesource.com/setup_20.x | sudo bash
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
npm install -g node-pre-gyp pnpm@8.3.1
|
|
169
177
|
npm install -g @whyour/qinglong
|
|
170
178
|
qinglong
|
|
171
179
|
# 根据提示增加环境变量 QL_DIR 和 QL_DATA_DIR
|
|
@@ -178,7 +186,7 @@ qinglong
|
|
|
178
186
|
## 开发
|
|
179
187
|
|
|
180
188
|
```bash
|
|
181
|
-
$ git clone
|
|
189
|
+
$ git clone https://github.com/whyour/qinglong.git
|
|
182
190
|
$ cd qinglong
|
|
183
191
|
$ cp .env.example .env
|
|
184
192
|
# 推荐使用 pnpm https://pnpm.io/zh/installation
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
FROM node:20-slim as nodebuilder
|
|
2
|
+
|
|
3
|
+
FROM python:3.10-slim-bullseye as builder
|
|
4
|
+
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
|
|
5
|
+
COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
|
|
6
|
+
COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
|
7
|
+
RUN set -x && \
|
|
8
|
+
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
|
9
|
+
apt update && \
|
|
10
|
+
apt install --no-install-recommends -y libatomic1 && \
|
|
11
|
+
npm i -g pnpm@8.3.1 && \
|
|
12
|
+
cd /tmp/build && \
|
|
13
|
+
pnpm install --prod
|
|
14
|
+
|
|
15
|
+
FROM python:3.10-slim-bullseye
|
|
16
|
+
|
|
17
|
+
ARG QL_MAINTAINER="whyour"
|
|
18
|
+
LABEL maintainer="${QL_MAINTAINER}"
|
|
19
|
+
ARG QL_URL=https://github.com/${QL_MAINTAINER}/qinglong.git
|
|
20
|
+
ARG QL_BRANCH=develop
|
|
21
|
+
|
|
22
|
+
ENV PNPM_HOME=/root/.local/share/pnpm \
|
|
23
|
+
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/share/pnpm:/root/.local/share/pnpm/global/5/node_modules:$PNPM_HOME \
|
|
24
|
+
NODE_PATH=/usr/local/bin:/usr/local/pnpm-global/5/node_modules:/usr/local/lib/node_modules:/root/.local/share/pnpm/global/5/node_modules \
|
|
25
|
+
LANG=C.UTF-8 \
|
|
26
|
+
SHELL=/bin/bash \
|
|
27
|
+
PS1="\u@\h:\w \$ " \
|
|
28
|
+
QL_DIR=/ql \
|
|
29
|
+
QL_BRANCH=${QL_BRANCH}
|
|
30
|
+
|
|
31
|
+
COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
|
|
32
|
+
COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
|
33
|
+
|
|
34
|
+
RUN set -x && \
|
|
35
|
+
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
|
36
|
+
apt update && \
|
|
37
|
+
apt upgrade -y && \
|
|
38
|
+
apt install --no-install-recommends -y git \
|
|
39
|
+
curl \
|
|
40
|
+
wget \
|
|
41
|
+
tzdata \
|
|
42
|
+
perl \
|
|
43
|
+
openssl \
|
|
44
|
+
openssh-client \
|
|
45
|
+
nginx \
|
|
46
|
+
jq \
|
|
47
|
+
procps \
|
|
48
|
+
netcat \
|
|
49
|
+
unzip \
|
|
50
|
+
libatomic1 && \
|
|
51
|
+
apt clean && \
|
|
52
|
+
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
|
53
|
+
echo "Asia/Shanghai" >/etc/timezone && \
|
|
54
|
+
git config --global user.email "qinglong@@users.noreply.github.com" && \
|
|
55
|
+
git config --global user.name "qinglong" && \
|
|
56
|
+
git config --global http.postBuffer 524288000 && \
|
|
57
|
+
npm install -g pnpm@8.3.1 pm2 tsx && \
|
|
58
|
+
rm -rf /root/.pnpm-store && \
|
|
59
|
+
rm -rf /root/.local/share/pnpm/store && \
|
|
60
|
+
rm -rf /root/.cache && \
|
|
61
|
+
rm -rf /root/.npm
|
|
62
|
+
|
|
63
|
+
ARG SOURCE_COMMIT
|
|
64
|
+
RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} && \
|
|
65
|
+
cd ${QL_DIR} && \
|
|
66
|
+
cp -f .env.example .env && \
|
|
67
|
+
chmod 777 ${QL_DIR}/shell/*.sh && \
|
|
68
|
+
chmod 777 ${QL_DIR}/docker/*.sh && \
|
|
69
|
+
git clone --depth=1 -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /static && \
|
|
70
|
+
mkdir -p ${QL_DIR}/static && \
|
|
71
|
+
cp -rf /static/* ${QL_DIR}/static && \
|
|
72
|
+
rm -rf /static
|
|
73
|
+
|
|
74
|
+
COPY --from=builder /tmp/build/node_modules/. /ql/node_modules/
|
|
75
|
+
|
|
76
|
+
WORKDIR ${QL_DIR}
|
|
77
|
+
|
|
78
|
+
HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
|
|
79
|
+
CMD curl -sf --noproxy '*' http://127.0.0.1:5400/api/health || exit 1
|
|
80
|
+
|
|
81
|
+
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
package/docker/Dockerfile
CHANGED
|
@@ -33,6 +33,7 @@ COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_module
|
|
|
33
33
|
|
|
34
34
|
RUN set -x && \
|
|
35
35
|
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
|
36
|
+
ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx && \
|
|
36
37
|
apt update && \
|
|
37
38
|
apt upgrade -y && \
|
|
38
39
|
apt install --no-install-recommends -y git \
|
|
@@ -79,3 +80,7 @@ HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
|
|
|
79
80
|
CMD curl -sf --noproxy '*' http://127.0.0.1:5400/api/health || exit 1
|
|
80
81
|
|
|
81
82
|
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
|
83
|
+
|
|
84
|
+
VOLUME /ql/data
|
|
85
|
+
|
|
86
|
+
EXPOSE 5700
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whyour/qinglong",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Timed task management platform supporting Python3, JavaScript, Shell, Typescript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"sequelize": "^6.25.5",
|
|
106
106
|
"serve-handler": "^6.1.3",
|
|
107
107
|
"sockjs": "^0.3.24",
|
|
108
|
-
"sqlite3": "git+https://github.com/whyour/node-sqlite3.git#v1.0.
|
|
108
|
+
"sqlite3": "git+https://github.com/whyour/node-sqlite3.git#v1.0.3",
|
|
109
109
|
"tar": "^6.1.15",
|
|
110
110
|
"toad-scheduler": "^1.6.0",
|
|
111
111
|
"typedi": "^0.10.0",
|
package/sample/notify.py
CHANGED
|
@@ -841,60 +841,61 @@ def one() -> str:
|
|
|
841
841
|
return res["hitokoto"] + " ----" + res["from"]
|
|
842
842
|
|
|
843
843
|
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
)
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
)
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
)
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
844
|
+
def add_notify_function():
|
|
845
|
+
if push_config.get("BARK_PUSH"):
|
|
846
|
+
notify_function.append(bark)
|
|
847
|
+
if push_config.get("CONSOLE"):
|
|
848
|
+
notify_function.append(console)
|
|
849
|
+
if push_config.get("DD_BOT_TOKEN") and push_config.get("DD_BOT_SECRET"):
|
|
850
|
+
notify_function.append(dingding_bot)
|
|
851
|
+
if push_config.get("FSKEY"):
|
|
852
|
+
notify_function.append(feishu_bot)
|
|
853
|
+
if push_config.get("GOBOT_URL") and push_config.get("GOBOT_QQ"):
|
|
854
|
+
notify_function.append(go_cqhttp)
|
|
855
|
+
if push_config.get("GOTIFY_URL") and push_config.get("GOTIFY_TOKEN"):
|
|
856
|
+
notify_function.append(gotify)
|
|
857
|
+
if push_config.get("IGOT_PUSH_KEY"):
|
|
858
|
+
notify_function.append(iGot)
|
|
859
|
+
if push_config.get("PUSH_KEY"):
|
|
860
|
+
notify_function.append(serverJ)
|
|
861
|
+
if push_config.get("DEER_KEY"):
|
|
862
|
+
notify_function.append(pushdeer)
|
|
863
|
+
if push_config.get("CHAT_URL") and push_config.get("CHAT_TOKEN"):
|
|
864
|
+
notify_function.append(chat)
|
|
865
|
+
if push_config.get("PUSH_PLUS_TOKEN"):
|
|
866
|
+
notify_function.append(pushplus_bot)
|
|
867
|
+
if push_config.get("QMSG_KEY") and push_config.get("QMSG_TYPE"):
|
|
868
|
+
notify_function.append(qmsg_bot)
|
|
869
|
+
if push_config.get("QYWX_AM"):
|
|
870
|
+
notify_function.append(wecom_app)
|
|
871
|
+
if push_config.get("QYWX_KEY"):
|
|
872
|
+
notify_function.append(wecom_bot)
|
|
873
|
+
if push_config.get("TG_BOT_TOKEN") and push_config.get("TG_USER_ID"):
|
|
874
|
+
notify_function.append(telegram_bot)
|
|
875
|
+
if (
|
|
876
|
+
push_config.get("AIBOTK_KEY")
|
|
877
|
+
and push_config.get("AIBOTK_TYPE")
|
|
878
|
+
and push_config.get("AIBOTK_NAME")
|
|
879
|
+
):
|
|
880
|
+
notify_function.append(aibotk)
|
|
881
|
+
if (
|
|
882
|
+
push_config.get("SMTP_SERVER")
|
|
883
|
+
and push_config.get("SMTP_SSL")
|
|
884
|
+
and push_config.get("SMTP_EMAIL")
|
|
885
|
+
and push_config.get("SMTP_PASSWORD")
|
|
886
|
+
and push_config.get("SMTP_NAME")
|
|
887
|
+
):
|
|
888
|
+
notify_function.append(smtp)
|
|
889
|
+
if push_config.get("PUSHME_KEY"):
|
|
890
|
+
notify_function.append(pushme)
|
|
891
|
+
if (
|
|
892
|
+
push_config.get("CHRONOCAT_URL")
|
|
893
|
+
and push_config.get("CHRONOCAT_QQ")
|
|
894
|
+
and push_config.get("CHRONOCAT_TOKEN")
|
|
895
|
+
):
|
|
896
|
+
notify_function.append(chronocat)
|
|
897
|
+
if push_config.get("WEBHOOK_URL") and push_config.get("WEBHOOK_METHOD"):
|
|
898
|
+
notify_function.append(custom_notify)
|
|
898
899
|
|
|
899
900
|
|
|
900
901
|
def send(title: str, content: str) -> None:
|
|
@@ -910,10 +911,9 @@ def send(title: str, content: str) -> None:
|
|
|
910
911
|
return
|
|
911
912
|
|
|
912
913
|
hitokoto = push_config.get("HITOKOTO")
|
|
914
|
+
content += "\n\n" + one() if hitokoto else ""
|
|
913
915
|
|
|
914
|
-
|
|
915
|
-
content += "\n\n" + text
|
|
916
|
-
|
|
916
|
+
add_notify_function()
|
|
917
917
|
ts = [
|
|
918
918
|
threading.Thread(target=mode, args=(title, content), name=mode.__name__)
|
|
919
919
|
for mode in notify_function
|
package/shell/update.sh
CHANGED
|
@@ -267,8 +267,8 @@ update_qinglong() {
|
|
|
267
267
|
echo -e "使用 ${mirror} 源更新...\n"
|
|
268
268
|
|
|
269
269
|
local primary_branch="master"
|
|
270
|
-
if [[ "${QL_BRANCH}" == "develop" ]]; then
|
|
271
|
-
primary_branch="
|
|
270
|
+
if [[ "${QL_BRANCH}" == "develop" ]] || [[ "${QL_BRANCH}" == "debian" ]] || [[ "${QL_BRANCH}" == "debian-dev" ]]; then
|
|
271
|
+
primary_branch="${QL_BRANCH}"
|
|
272
272
|
fi
|
|
273
273
|
|
|
274
274
|
wget -cqO "${dir_tmp}/ql.zip" "${downloadQLUrl}/${primary_branch}.zip"
|
|
@@ -26,7 +26,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const util_1 = require("../config/util");
|
|
30
29
|
const express_1 = require("express");
|
|
31
30
|
const typedi_1 = require("typedi");
|
|
32
31
|
const config_1 = __importDefault(require("../config"));
|
|
@@ -34,7 +33,7 @@ const fs = __importStar(require("fs/promises"));
|
|
|
34
33
|
const celebrate_1 = require("celebrate");
|
|
35
34
|
const path_1 = require("path");
|
|
36
35
|
const const_1 = require("../config/const");
|
|
37
|
-
const
|
|
36
|
+
const config_2 = __importDefault(require("../services/config"));
|
|
38
37
|
const route = (0, express_1.Router)();
|
|
39
38
|
exports.default = (app) => {
|
|
40
39
|
app.use('/configs', route);
|
|
@@ -67,24 +66,9 @@ exports.default = (app) => {
|
|
|
67
66
|
}
|
|
68
67
|
});
|
|
69
68
|
route.get('/detail', async (req, res, next) => {
|
|
70
|
-
const logger = typedi_1.Container.get('logger');
|
|
71
69
|
try {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (config_1.default.blackFileList.includes(_path) || !_path) {
|
|
75
|
-
res.send({ code: 403, message: '文件无法访问' });
|
|
76
|
-
}
|
|
77
|
-
if (_path.startsWith('sample/')) {
|
|
78
|
-
const res = await got_1.default.get(`https://gitlab.com/whyour/qinglong/-/raw/master/${_path}`);
|
|
79
|
-
content = res.body;
|
|
80
|
-
}
|
|
81
|
-
else if (_path.startsWith('data/scripts/')) {
|
|
82
|
-
content = await (0, util_1.getFileContentByName)((0, path_1.join)(config_1.default.rootPath, _path));
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
content = await (0, util_1.getFileContentByName)((0, path_1.join)(config_1.default.configPath, _path));
|
|
86
|
-
}
|
|
87
|
-
res.send({ code: 200, data: content });
|
|
70
|
+
const configService = typedi_1.Container.get(config_2.default);
|
|
71
|
+
await configService.getFile(req.query.path, res);
|
|
88
72
|
}
|
|
89
73
|
catch (e) {
|
|
90
74
|
return next(e);
|
|
@@ -102,7 +86,10 @@ exports.default = (app) => {
|
|
|
102
86
|
if (config_1.default.blackFileList.includes(name)) {
|
|
103
87
|
res.send({ code: 403, message: '文件无法访问' });
|
|
104
88
|
}
|
|
105
|
-
|
|
89
|
+
let path = (0, path_1.join)(config_1.default.configPath, name);
|
|
90
|
+
if (name.startsWith('data/scripts/')) {
|
|
91
|
+
path = (0, path_1.join)(config_1.default.rootPath, name);
|
|
92
|
+
}
|
|
106
93
|
await fs.writeFile(path, content);
|
|
107
94
|
res.send({ code: 200, message: '保存成功' });
|
|
108
95
|
}
|
|
@@ -110,5 +97,14 @@ exports.default = (app) => {
|
|
|
110
97
|
return next(e);
|
|
111
98
|
}
|
|
112
99
|
});
|
|
100
|
+
route.get('/:file', async (req, res, next) => {
|
|
101
|
+
try {
|
|
102
|
+
const configService = typedi_1.Container.get(config_2.default);
|
|
103
|
+
await configService.getFile(req.params.file, res);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
return next(e);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
113
109
|
};
|
|
114
110
|
//# sourceMappingURL=config.js.map
|
package/static/build/api/log.js
CHANGED
|
@@ -27,8 +27,20 @@ exports.default = (app) => {
|
|
|
27
27
|
return next(e);
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
+
route.get('/detail', async (req, res, next) => {
|
|
31
|
+
try {
|
|
32
|
+
if (blacklist.includes(req.path)) {
|
|
33
|
+
return res.send({ code: 403, message: '暂无权限' });
|
|
34
|
+
}
|
|
35
|
+
const filePath = (0, path_1.join)(config_1.default.logPath, (req.query.path || ''), req.query.file);
|
|
36
|
+
const content = await (0, util_1.getFileContentByName)(filePath);
|
|
37
|
+
res.send({ code: 200, data: content });
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
return next(e);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
30
43
|
route.get('/:file', async (req, res, next) => {
|
|
31
|
-
const logger = typedi_1.Container.get('logger');
|
|
32
44
|
try {
|
|
33
45
|
if (blacklist.includes(req.path)) {
|
|
34
46
|
return res.send({ code: 403, message: '暂无权限' });
|
|
@@ -83,11 +83,20 @@ exports.default = (app) => {
|
|
|
83
83
|
return next(e);
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
|
+
route.get('/detail', async (req, res, next) => {
|
|
87
|
+
try {
|
|
88
|
+
const scriptService = typedi_1.Container.get(script_1.default);
|
|
89
|
+
const content = await scriptService.getFile(req.query.path, req.query.file);
|
|
90
|
+
res.send({ code: 200, data: content });
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
return next(e);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
86
96
|
route.get('/:file', async (req, res, next) => {
|
|
87
|
-
const logger = typedi_1.Container.get('logger');
|
|
88
97
|
try {
|
|
89
|
-
const
|
|
90
|
-
const content = await (
|
|
98
|
+
const scriptService = typedi_1.Container.get(script_1.default);
|
|
99
|
+
const content = await scriptService.getFile(req.query.path, req.params.file);
|
|
91
100
|
res.send({ code: 200, data: content });
|
|
92
101
|
}
|
|
93
102
|
catch (e) {
|
package/static/build/api/user.js
CHANGED
|
@@ -64,6 +64,9 @@ exports.default = (app) => {
|
|
|
64
64
|
}), async (req, res, next) => {
|
|
65
65
|
const logger = typedi_1.Container.get('logger');
|
|
66
66
|
try {
|
|
67
|
+
if (process.env.DeployEnv === 'demo') {
|
|
68
|
+
return res.send({ code: 450, message: '未知错误' });
|
|
69
|
+
}
|
|
67
70
|
const userService = typedi_1.Container.get(user_1.default);
|
|
68
71
|
await userService.updateUsernameAndPassword(req.body);
|
|
69
72
|
res.send({ code: 200, message: '更新成功' });
|
|
@@ -15,10 +15,30 @@ const config_1 = __importDefault(require("../config"));
|
|
|
15
15
|
const cronView_1 = require("../data/cronView");
|
|
16
16
|
const env_2 = require("../data/env");
|
|
17
17
|
const system_1 = require("../data/system");
|
|
18
|
+
const system_2 = __importDefault(require("../services/system"));
|
|
18
19
|
exports.default = async () => {
|
|
20
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19
21
|
const cronService = typedi_1.Container.get(cron_2.default);
|
|
20
22
|
const envService = typedi_1.Container.get(env_1.default);
|
|
21
23
|
const dependenceService = typedi_1.Container.get(dependence_1.default);
|
|
24
|
+
const systemService = typedi_1.Container.get(system_2.default);
|
|
25
|
+
// 初始化更新 linux/python/nodejs 镜像源配置
|
|
26
|
+
const systemConfig = await systemService.getSystemConfig();
|
|
27
|
+
if ((_a = systemConfig.info) === null || _a === void 0 ? void 0 : _a.pythonMirror) {
|
|
28
|
+
systemService.updatePythonMirror({
|
|
29
|
+
linuxMirror: (_b = systemConfig.info) === null || _b === void 0 ? void 0 : _b.linuxMirror,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if ((_c = systemConfig.info) === null || _c === void 0 ? void 0 : _c.linuxMirror) {
|
|
33
|
+
systemService.updateLinuxMirror({
|
|
34
|
+
linuxMirror: (_d = systemConfig.info) === null || _d === void 0 ? void 0 : _d.linuxMirror,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if ((_e = systemConfig.info) === null || _e === void 0 ? void 0 : _e.nodeMirror) {
|
|
38
|
+
systemService.updateNodeMirror({
|
|
39
|
+
linuxMirror: (_f = systemConfig.info) === null || _f === void 0 ? void 0 : _f.linuxMirror,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
22
42
|
// 初始化新增默认全部任务视图
|
|
23
43
|
cronView_1.CrontabViewModel.findAll({
|
|
24
44
|
where: { type: cronView_1.CronViewType.系统, name: '全部任务' },
|
|
@@ -44,7 +64,9 @@ exports.default = async () => {
|
|
|
44
64
|
raw: true,
|
|
45
65
|
}).then(async (docs) => {
|
|
46
66
|
await dependence_2.DependenceModel.update({ status: dependence_2.DependenceStatus.queued, log: [] }, { where: { id: docs.map((x) => x.id) } });
|
|
47
|
-
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
dependenceService.installDependenceOneByOne(docs);
|
|
69
|
+
}, 5000);
|
|
48
70
|
});
|
|
49
71
|
// 初始化时执行一次所有的 ql repo 任务
|
|
50
72
|
cron_1.CrontabModel.findAll({
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const typedi_1 = require("typedi");
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const config_1 = __importDefault(require("../config"));
|
|
18
|
+
const util_1 = require("../config/util");
|
|
19
|
+
const got_1 = __importDefault(require("got"));
|
|
20
|
+
let ConfigService = class ConfigService {
|
|
21
|
+
constructor() { }
|
|
22
|
+
async getFile(filePath, res) {
|
|
23
|
+
let content = '';
|
|
24
|
+
if (config_1.default.blackFileList.includes(filePath) || !filePath) {
|
|
25
|
+
res.send({ code: 403, message: '文件无法访问' });
|
|
26
|
+
}
|
|
27
|
+
if (filePath.startsWith('sample/')) {
|
|
28
|
+
const res = await got_1.default.get(`https://gitlab.com/whyour/qinglong/-/raw/master/${filePath}`);
|
|
29
|
+
content = res.body;
|
|
30
|
+
}
|
|
31
|
+
else if (filePath.startsWith('data/scripts/')) {
|
|
32
|
+
content = await (0, util_1.getFileContentByName)((0, path_1.join)(config_1.default.rootPath, filePath));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
content = await (0, util_1.getFileContentByName)((0, path_1.join)(config_1.default.configPath, filePath));
|
|
36
|
+
}
|
|
37
|
+
res.send({ code: 200, data: content });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
ConfigService = __decorate([
|
|
41
|
+
(0, typedi_1.Service)(),
|
|
42
|
+
__metadata("design:paramtypes", [])
|
|
43
|
+
], ConfigService);
|
|
44
|
+
exports.default = ConfigService;
|
|
45
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
2
18
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
21
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
23
|
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
8
31
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
32
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
33
|
};
|
|
@@ -17,7 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
41
|
const typedi_1 = require("typedi");
|
|
19
42
|
const winston_1 = __importDefault(require("winston"));
|
|
20
|
-
const path_1 =
|
|
43
|
+
const path_1 = __importStar(require("path"));
|
|
21
44
|
const sock_1 = __importDefault(require("./sock"));
|
|
22
45
|
const cron_1 = __importDefault(require("./cron"));
|
|
23
46
|
const schedule_1 = __importDefault(require("./schedule"));
|
|
@@ -67,6 +90,11 @@ let ScriptService = class ScriptService {
|
|
|
67
90
|
catch (error) { }
|
|
68
91
|
return { code: 200 };
|
|
69
92
|
}
|
|
93
|
+
async getFile(filePath, fileName) {
|
|
94
|
+
const _filePath = (0, path_1.join)(config_1.default.scriptPath, filePath, fileName);
|
|
95
|
+
const content = await (0, util_1.getFileContentByName)(_filePath);
|
|
96
|
+
return content;
|
|
97
|
+
}
|
|
70
98
|
};
|
|
71
99
|
ScriptService = __decorate([
|
|
72
100
|
(0, typedi_1.Service)(),
|
|
@@ -112,8 +112,8 @@ let SystemService = class SystemService {
|
|
|
112
112
|
const command = `cd && ${cmd} && pnpm i -g`;
|
|
113
113
|
this.scheduleService.runTask(command, {
|
|
114
114
|
onStart: async (cp) => {
|
|
115
|
-
res.setHeader('QL-Task-Pid', `${cp.pid}`);
|
|
116
|
-
res.end();
|
|
115
|
+
res === null || res === void 0 ? void 0 : res.setHeader('QL-Task-Pid', `${cp.pid}`);
|
|
116
|
+
res === null || res === void 0 ? void 0 : res.end();
|
|
117
117
|
},
|
|
118
118
|
onEnd: async () => {
|
|
119
119
|
this.sockService.sendMessage({
|
|
@@ -156,8 +156,8 @@ let SystemService = class SystemService {
|
|
|
156
156
|
const command = `sed -i 's/${defaultDomain.replace(/\//g, '\\/')}/${targetDomain.replace(/\//g, '\\/')}/g' /etc/apt/sources.list && apt update`;
|
|
157
157
|
this.scheduleService.runTask(command, {
|
|
158
158
|
onStart: async (cp) => {
|
|
159
|
-
res.setHeader('QL-Task-Pid', `${cp.pid}`);
|
|
160
|
-
res.end();
|
|
159
|
+
res === null || res === void 0 ? void 0 : res.setHeader('QL-Task-Pid', `${cp.pid}`);
|
|
160
|
+
res === null || res === void 0 ? void 0 : res.end();
|
|
161
161
|
},
|
|
162
162
|
onEnd: async () => {
|
|
163
163
|
this.sockService.sendMessage({
|