@whyour/qinglong 0.15.1 → 0.15.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whyour/qinglong",
3
- "version": "0.15.1",
3
+ "version": "0.15.3",
4
4
  "description": "Timed task management platform supporting Python3, JavaScript, Shell, Typescript",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,21 +22,40 @@ exports.default = async () => {
22
22
  const envService = typedi_1.Container.get(env_1.default);
23
23
  const dependenceService = typedi_1.Container.get(dependence_1.default);
24
24
  const systemService = typedi_1.Container.get(system_2.default);
25
+ const installDependencies = () => {
26
+ // 初始化时安装所有处于安装中,安装成功,安装失败的依赖
27
+ dependence_2.DependenceModel.findAll({
28
+ where: {},
29
+ order: [
30
+ ['type', 'DESC'],
31
+ ['createdAt', 'DESC'],
32
+ ],
33
+ raw: true,
34
+ }).then(async (docs) => {
35
+ await dependence_2.DependenceModel.update({ status: dependence_2.DependenceStatus.queued, log: [] }, { where: { id: docs.map((x) => x.id) } });
36
+ setTimeout(() => {
37
+ dependenceService.installDependenceOneByOne(docs);
38
+ }, 5000);
39
+ });
40
+ };
25
41
  // 初始化更新 linux/python/nodejs 镜像源配置
26
42
  const systemConfig = await systemService.getSystemConfig();
27
43
  if ((_a = systemConfig.info) === null || _a === void 0 ? void 0 : _a.pythonMirror) {
28
44
  systemService.updatePythonMirror({
29
- linuxMirror: (_b = systemConfig.info) === null || _b === void 0 ? void 0 : _b.linuxMirror,
45
+ pythonMirror: (_b = systemConfig.info) === null || _b === void 0 ? void 0 : _b.pythonMirror,
30
46
  });
31
47
  }
32
48
  if ((_c = systemConfig.info) === null || _c === void 0 ? void 0 : _c.linuxMirror) {
33
49
  systemService.updateLinuxMirror({
34
50
  linuxMirror: (_d = systemConfig.info) === null || _d === void 0 ? void 0 : _d.linuxMirror,
35
- });
51
+ }, undefined, () => installDependencies());
52
+ }
53
+ else {
54
+ installDependencies();
36
55
  }
37
56
  if ((_e = systemConfig.info) === null || _e === void 0 ? void 0 : _e.nodeMirror) {
38
57
  systemService.updateNodeMirror({
39
- linuxMirror: (_f = systemConfig.info) === null || _f === void 0 ? void 0 : _f.linuxMirror,
58
+ nodeMirror: (_f = systemConfig.info) === null || _f === void 0 ? void 0 : _f.nodeMirror,
40
59
  });
41
60
  }
42
61
  // 初始化新增默认全部任务视图
@@ -54,20 +73,6 @@ exports.default = async () => {
54
73
  });
55
74
  // 初始化更新所有任务状态为空闲
56
75
  await cron_1.CrontabModel.update({ status: cron_1.CrontabStatus.idle }, { where: {} });
57
- // 初始化时安装所有处于安装中,安装成功,安装失败的依赖
58
- dependence_2.DependenceModel.findAll({
59
- where: {},
60
- order: [
61
- ['type', 'DESC'],
62
- ['createdAt', 'DESC'],
63
- ],
64
- raw: true,
65
- }).then(async (docs) => {
66
- await dependence_2.DependenceModel.update({ status: dependence_2.DependenceStatus.queued, log: [] }, { where: { id: docs.map((x) => x.id) } });
67
- setTimeout(() => {
68
- dependenceService.installDependenceOneByOne(docs);
69
- }, 5000);
70
- });
71
76
  // 初始化时执行一次所有的 ql repo 任务
72
77
  cron_1.CrontabModel.findAll({
73
78
  where: {
@@ -141,14 +141,17 @@ let SystemService = class SystemService {
141
141
  await (0, util_1.promiseExec)(cmd);
142
142
  return { code: 200, data: info };
143
143
  }
144
- async updateLinuxMirror(info, res) {
145
- var _a;
144
+ async updateLinuxMirror(info, res, onEnd) {
146
145
  const oDoc = await this.getSystemConfig();
147
146
  await this.updateAuthDb(Object.assign(Object.assign({}, oDoc), { info: Object.assign(Object.assign({}, oDoc.info), info) }));
148
147
  let defaultDomain = 'http://deb.debian.org';
149
148
  let targetDomain = 'http://deb.debian.org';
150
- if ((_a = oDoc.info) === null || _a === void 0 ? void 0 : _a.linuxMirror) {
151
- defaultDomain = oDoc.info.linuxMirror;
149
+ const content = await fs_1.default.promises.readFile('/etc/apt/sources.list', {
150
+ encoding: 'utf-8',
151
+ });
152
+ const domainMatch = content.match(/(http.*)\/debian /);
153
+ if (domainMatch) {
154
+ defaultDomain = domainMatch[1];
152
155
  }
153
156
  if (info.linuxMirror) {
154
157
  targetDomain = info.linuxMirror;
@@ -164,6 +167,7 @@ let SystemService = class SystemService {
164
167
  type: 'updateLinuxMirror',
165
168
  message: 'update linux mirror end',
166
169
  });
170
+ onEnd === null || onEnd === void 0 ? void 0 : onEnd();
167
171
  },
168
172
  onError: async (message) => {
169
173
  this.sockService.sendMessage({ type: 'updateLinuxMirror', message });