@whyour/qinglong 0.13.3 → 0.14.1

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.
Files changed (212) hide show
  1. package/README-en.md +13 -15
  2. package/README.md +14 -17
  3. package/docker/Dockerfile +6 -8
  4. package/docker/docker-entrypoint.sh +2 -16
  5. package/docker/front.conf +12 -0
  6. package/ecosystem.config.js +8 -0
  7. package/package.json +13 -8
  8. package/sample/config.sample.sh +10 -20
  9. package/sample/notify.js +115 -136
  10. package/sample/notify.py +7 -7
  11. package/shell/api.sh +4 -4
  12. package/shell/bot.sh +0 -3
  13. package/shell/check.sh +1 -13
  14. package/shell/env.sh +0 -0
  15. package/shell/share.sh +2 -4
  16. package/shell/start.sh +0 -10
  17. package/shell/update.sh +6 -17
  18. package/static/build/api/config.js +23 -6
  19. package/static/build/api/log.js +3 -32
  20. package/static/build/api/script.js +31 -21
  21. package/static/build/api/system.js +76 -8
  22. package/static/build/config/const.js +18 -1
  23. package/static/build/config/index.js +3 -0
  24. package/static/build/config/util.js +98 -95
  25. package/static/build/data/notify.js +2 -2
  26. package/static/build/data/{auth.js → system.js} +3 -3
  27. package/static/build/loaders/db.js +4 -4
  28. package/static/build/loaders/deps.js +11 -14
  29. package/static/build/loaders/express.js +4 -6
  30. package/static/build/loaders/initFile.js +16 -16
  31. package/static/build/loaders/sentry.js +2 -3
  32. package/static/build/loaders/sock.js +3 -3
  33. package/static/build/public.js +1 -1
  34. package/static/build/schedule/client.js +1 -1
  35. package/static/build/schedule/health.js +1 -1
  36. package/static/build/schedule/index.js +1 -1
  37. package/static/build/services/cron.js +32 -25
  38. package/static/build/services/dependence.js +15 -5
  39. package/static/build/services/env.js +2 -2
  40. package/static/build/services/notify.js +8 -7
  41. package/static/build/services/script.js +2 -6
  42. package/static/build/services/sshKey.js +27 -52
  43. package/static/build/services/subscription.js +19 -21
  44. package/static/build/services/system.js +112 -21
  45. package/static/build/services/user.js +52 -41
  46. package/static/build/shared/pLimit.js +4 -4
  47. package/static/dist/{6644.1f11b8fa.async.js → 1431.36b64dc5.async.js} +1 -1
  48. package/static/dist/3752.56c3fba2.async.js +1 -0
  49. package/static/dist/{419.e21ea0bd.async.js → 419.d9597044.async.js} +1 -1
  50. package/static/dist/{8008.cf4ff203.async.js → 8008.fbdcf863.async.js} +1 -1
  51. package/static/dist/833.7348bf8c.async.js +1 -0
  52. package/static/dist/8722.408e3112.async.js +1 -0
  53. package/static/dist/{8171.e2986b87.async.js → 9847.d72d4b37.async.js} +1 -1
  54. package/static/dist/index.html +1 -1
  55. package/static/dist/layouts__index.2c89a418.async.js +1 -0
  56. package/static/dist/monaco-editor/min/vs/base/browser/ui/codicons/codicon/codicon.ttf +0 -0
  57. package/static/dist/monaco-editor/min/vs/base/worker/workerMain.js +22 -0
  58. package/static/dist/monaco-editor/min/vs/basic-languages/abap/abap.js +10 -0
  59. package/static/dist/monaco-editor/min/vs/basic-languages/apex/apex.js +10 -0
  60. package/static/dist/monaco-editor/min/vs/basic-languages/azcli/azcli.js +10 -0
  61. package/static/dist/monaco-editor/min/vs/basic-languages/bat/bat.js +10 -0
  62. package/static/dist/monaco-editor/min/vs/basic-languages/bicep/bicep.js +11 -0
  63. package/static/dist/monaco-editor/min/vs/basic-languages/cameligo/cameligo.js +10 -0
  64. package/static/dist/monaco-editor/min/vs/basic-languages/clojure/clojure.js +10 -0
  65. package/static/dist/monaco-editor/min/vs/basic-languages/coffee/coffee.js +10 -0
  66. package/static/dist/monaco-editor/min/vs/basic-languages/cpp/cpp.js +10 -0
  67. package/static/dist/monaco-editor/min/vs/basic-languages/csharp/csharp.js +10 -0
  68. package/static/dist/monaco-editor/min/vs/basic-languages/csp/csp.js +10 -0
  69. package/static/dist/monaco-editor/min/vs/basic-languages/css/css.js +12 -0
  70. package/static/dist/monaco-editor/min/vs/basic-languages/dart/dart.js +10 -0
  71. package/static/dist/monaco-editor/min/vs/basic-languages/dockerfile/dockerfile.js +10 -0
  72. package/static/dist/monaco-editor/min/vs/basic-languages/ecl/ecl.js +10 -0
  73. package/static/dist/monaco-editor/min/vs/basic-languages/elixir/elixir.js +10 -0
  74. package/static/dist/monaco-editor/min/vs/basic-languages/flow9/flow9.js +10 -0
  75. package/static/dist/monaco-editor/min/vs/basic-languages/freemarker2/freemarker2.js +12 -0
  76. package/static/dist/monaco-editor/min/vs/basic-languages/fsharp/fsharp.js +10 -0
  77. package/static/dist/monaco-editor/min/vs/basic-languages/go/go.js +10 -0
  78. package/static/dist/monaco-editor/min/vs/basic-languages/graphql/graphql.js +10 -0
  79. package/static/dist/monaco-editor/min/vs/basic-languages/handlebars/handlebars.js +10 -0
  80. package/static/dist/monaco-editor/min/vs/basic-languages/hcl/hcl.js +10 -0
  81. package/static/dist/monaco-editor/min/vs/basic-languages/html/html.js +10 -0
  82. package/static/dist/monaco-editor/min/vs/basic-languages/ini/ini.js +10 -0
  83. package/static/dist/monaco-editor/min/vs/basic-languages/java/java.js +10 -0
  84. package/static/dist/monaco-editor/min/vs/basic-languages/javascript/javascript.js +10 -0
  85. package/static/dist/monaco-editor/min/vs/basic-languages/julia/julia.js +10 -0
  86. package/static/dist/monaco-editor/min/vs/basic-languages/kotlin/kotlin.js +10 -0
  87. package/static/dist/monaco-editor/min/vs/basic-languages/less/less.js +11 -0
  88. package/static/dist/monaco-editor/min/vs/basic-languages/lexon/lexon.js +10 -0
  89. package/static/dist/monaco-editor/min/vs/basic-languages/liquid/liquid.js +10 -0
  90. package/static/dist/monaco-editor/min/vs/basic-languages/lua/lua.js +10 -0
  91. package/static/dist/monaco-editor/min/vs/basic-languages/m3/m3.js +10 -0
  92. package/static/dist/monaco-editor/min/vs/basic-languages/markdown/markdown.js +10 -0
  93. package/static/dist/monaco-editor/min/vs/basic-languages/mips/mips.js +10 -0
  94. package/static/dist/monaco-editor/min/vs/basic-languages/msdax/msdax.js +10 -0
  95. package/static/dist/monaco-editor/min/vs/basic-languages/mysql/mysql.js +10 -0
  96. package/static/dist/monaco-editor/min/vs/basic-languages/objective-c/objective-c.js +10 -0
  97. package/static/dist/monaco-editor/min/vs/basic-languages/pascal/pascal.js +10 -0
  98. package/static/dist/monaco-editor/min/vs/basic-languages/pascaligo/pascaligo.js +10 -0
  99. package/static/dist/monaco-editor/min/vs/basic-languages/perl/perl.js +10 -0
  100. package/static/dist/monaco-editor/min/vs/basic-languages/pgsql/pgsql.js +10 -0
  101. package/static/dist/monaco-editor/min/vs/basic-languages/php/php.js +10 -0
  102. package/static/dist/monaco-editor/min/vs/basic-languages/pla/pla.js +10 -0
  103. package/static/dist/monaco-editor/min/vs/basic-languages/postiats/postiats.js +10 -0
  104. package/static/dist/monaco-editor/min/vs/basic-languages/powerquery/powerquery.js +10 -0
  105. package/static/dist/monaco-editor/min/vs/basic-languages/powershell/powershell.js +10 -0
  106. package/static/dist/monaco-editor/min/vs/basic-languages/protobuf/protobuf.js +11 -0
  107. package/static/dist/monaco-editor/min/vs/basic-languages/pug/pug.js +10 -0
  108. package/static/dist/monaco-editor/min/vs/basic-languages/python/python.js +10 -0
  109. package/static/dist/monaco-editor/min/vs/basic-languages/qsharp/qsharp.js +10 -0
  110. package/static/dist/monaco-editor/min/vs/basic-languages/r/r.js +10 -0
  111. package/static/dist/monaco-editor/min/vs/basic-languages/razor/razor.js +10 -0
  112. package/static/dist/monaco-editor/min/vs/basic-languages/redis/redis.js +10 -0
  113. package/static/dist/monaco-editor/min/vs/basic-languages/redshift/redshift.js +10 -0
  114. package/static/dist/monaco-editor/min/vs/basic-languages/restructuredtext/restructuredtext.js +10 -0
  115. package/static/dist/monaco-editor/min/vs/basic-languages/ruby/ruby.js +10 -0
  116. package/static/dist/monaco-editor/min/vs/basic-languages/rust/rust.js +10 -0
  117. package/static/dist/monaco-editor/min/vs/basic-languages/sb/sb.js +10 -0
  118. package/static/dist/monaco-editor/min/vs/basic-languages/scala/scala.js +10 -0
  119. package/static/dist/monaco-editor/min/vs/basic-languages/scheme/scheme.js +10 -0
  120. package/static/dist/monaco-editor/min/vs/basic-languages/scss/scss.js +12 -0
  121. package/static/dist/monaco-editor/min/vs/basic-languages/shell/shell.js +10 -0
  122. package/static/dist/monaco-editor/min/vs/basic-languages/solidity/solidity.js +10 -0
  123. package/static/dist/monaco-editor/min/vs/basic-languages/sophia/sophia.js +10 -0
  124. package/static/dist/monaco-editor/min/vs/basic-languages/sparql/sparql.js +10 -0
  125. package/static/dist/monaco-editor/min/vs/basic-languages/sql/sql.js +10 -0
  126. package/static/dist/monaco-editor/min/vs/basic-languages/st/st.js +10 -0
  127. package/static/dist/monaco-editor/min/vs/basic-languages/swift/swift.js +13 -0
  128. package/static/dist/monaco-editor/min/vs/basic-languages/systemverilog/systemverilog.js +10 -0
  129. package/static/dist/monaco-editor/min/vs/basic-languages/tcl/tcl.js +10 -0
  130. package/static/dist/monaco-editor/min/vs/basic-languages/twig/twig.js +10 -0
  131. package/static/dist/monaco-editor/min/vs/basic-languages/typescript/typescript.js +10 -0
  132. package/static/dist/monaco-editor/min/vs/basic-languages/vb/vb.js +10 -0
  133. package/static/dist/monaco-editor/min/vs/basic-languages/xml/xml.js +10 -0
  134. package/static/dist/monaco-editor/min/vs/basic-languages/yaml/yaml.js +10 -0
  135. package/static/dist/monaco-editor/min/vs/editor/editor.main.css +6 -0
  136. package/static/dist/monaco-editor/min/vs/editor/editor.main.js +805 -0
  137. package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.de.js +29 -0
  138. package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.es.js +29 -0
  139. package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.fr.js +27 -0
  140. package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.it.js +27 -0
  141. package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.ja.js +29 -0
  142. package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.js +27 -0
  143. package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.ko.js +27 -0
  144. package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.ru.js +29 -0
  145. package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.zh-cn.js +29 -0
  146. package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.zh-tw.js +27 -0
  147. package/static/dist/monaco-editor/min/vs/language/css/cssMode.js +13 -0
  148. package/static/dist/monaco-editor/min/vs/language/css/cssWorker.js +63 -0
  149. package/static/dist/monaco-editor/min/vs/language/html/htmlMode.js +13 -0
  150. package/static/dist/monaco-editor/min/vs/language/html/htmlWorker.js +453 -0
  151. package/static/dist/monaco-editor/min/vs/language/json/jsonMode.js +15 -0
  152. package/static/dist/monaco-editor/min/vs/language/json/jsonWorker.js +36 -0
  153. package/static/dist/monaco-editor/min/vs/language/typescript/tsMode.js +20 -0
  154. package/static/dist/monaco-editor/min/vs/language/typescript/tsWorker.js +33970 -0
  155. package/static/dist/monaco-editor/min/vs/loader.js +11 -0
  156. package/static/dist/src__pages__config__index.e809a5d0.async.js +1 -0
  157. package/static/dist/src__pages__crontab__detail.5b509309.async.js +1 -0
  158. package/static/dist/src__pages__crontab__index.73fc56e9.chunk.css +1 -0
  159. package/static/dist/src__pages__crontab__index.da430aa9.async.js +1 -0
  160. package/static/dist/{src__pages__crontab__modal.3fa8f075.async.js → src__pages__crontab__modal.13de83de.async.js} +1 -1
  161. package/static/dist/src__pages__dependence__index.27d29203.async.js +1 -0
  162. package/static/dist/src__pages__dependence__logModal.b55dacc8.async.js +1 -0
  163. package/static/dist/src__pages__dependence__modal.3cc1a9be.async.js +1 -0
  164. package/static/dist/src__pages__diff__index.b7927e8c.async.js +1 -0
  165. package/static/dist/{src__pages__env__editNameModal.25c21e59.async.js → src__pages__env__editNameModal.08af0049.async.js} +1 -1
  166. package/static/dist/src__pages__env__modal.4c039f3d.async.js +1 -0
  167. package/static/dist/src__pages__error__index.1748dfaa.async.js +1 -0
  168. package/static/dist/src__pages__initialization__index.8f114cca.async.js +1 -0
  169. package/static/dist/src__pages__log__index.84556deb.async.js +1 -0
  170. package/static/dist/src__pages__script__editModal.17bcb1c2.async.js +1 -0
  171. package/static/dist/{src__pages__script__editNameModal.ca76e055.async.js → src__pages__script__editNameModal.61262353.async.js} +1 -1
  172. package/static/dist/src__pages__script__index.27582916.async.js +1 -0
  173. package/static/dist/{src__pages__script__renameModal.c166915b.async.js → src__pages__script__renameModal.3e39fdf4.async.js} +1 -1
  174. package/static/dist/src__pages__script__saveModal.449e50d8.async.js +1 -0
  175. package/static/dist/{src__pages__script__setting.020a7629.async.js → src__pages__script__setting.7944fdd6.async.js} +1 -1
  176. package/static/dist/{src__pages__setting__about.e3293e77.chunk.css → src__pages__setting__about.f6325812.chunk.css} +1 -1
  177. package/static/dist/{src__pages__setting__appModal.efa5bb29.async.js → src__pages__setting__appModal.a419e539.async.js} +1 -1
  178. package/static/dist/{src__pages__setting__other.b4adcffe.chunk.css → src__pages__setting__dependence.55c598d0.chunk.css} +1 -1
  179. package/static/dist/src__pages__setting__dependence.7bcddc85.async.js +1 -0
  180. package/static/dist/src__pages__setting__index.d2fc96f6.async.js +1 -0
  181. package/static/dist/{src__pages__setting__index.d57cc3fc.chunk.css → src__pages__setting__index.d666f8ec.chunk.css} +1 -1
  182. package/static/dist/src__pages__setting__notification.552e6815.async.js +1 -0
  183. package/static/dist/src__pages__setting__other.55c598d0.chunk.css +1 -0
  184. package/static/dist/src__pages__setting__other.a029d99a.async.js +1 -0
  185. package/static/dist/{src__pages__setting__security.d14993c7.async.js → src__pages__setting__security.c667d9e8.async.js} +1 -1
  186. package/static/dist/src__pages__subscription__modal.07629f02.async.js +1 -0
  187. package/static/dist/{umi.decd4ae2.js → umi.d9c7e2bb.js} +1 -1
  188. package/version.yaml +27 -5
  189. package/sample/package.json +0 -12
  190. package/static/dist/5619.db04f386.async.js +0 -1
  191. package/static/dist/6747.36513965.async.js +0 -1
  192. package/static/dist/833.5add31bf.async.js +0 -1
  193. package/static/dist/layouts__index.931ce4c3.async.js +0 -1
  194. package/static/dist/src__pages__config__index.9d83dfb7.async.js +0 -1
  195. package/static/dist/src__pages__crontab__detail.7bceef05.async.js +0 -1
  196. package/static/dist/src__pages__crontab__index.55c93601.async.js +0 -1
  197. package/static/dist/src__pages__crontab__index.9fb90359.chunk.css +0 -1
  198. package/static/dist/src__pages__dependence__index.21153c24.async.js +0 -1
  199. package/static/dist/src__pages__dependence__logModal.5aada63c.async.js +0 -1
  200. package/static/dist/src__pages__dependence__modal.96353c88.async.js +0 -1
  201. package/static/dist/src__pages__diff__index.e644b15f.async.js +0 -1
  202. package/static/dist/src__pages__env__modal.4fd6abc2.async.js +0 -1
  203. package/static/dist/src__pages__error__index.f3ca5563.async.js +0 -1
  204. package/static/dist/src__pages__initialization__index.727e0f70.async.js +0 -1
  205. package/static/dist/src__pages__log__index.ba2c1721.async.js +0 -1
  206. package/static/dist/src__pages__script__editModal.8d7bac2a.async.js +0 -1
  207. package/static/dist/src__pages__script__index.da31e2c2.async.js +0 -1
  208. package/static/dist/src__pages__script__saveModal.7ee07566.async.js +0 -1
  209. package/static/dist/src__pages__setting__index.540c33a4.async.js +0 -1
  210. package/static/dist/src__pages__setting__notification.b99a4c64.async.js +0 -1
  211. package/static/dist/src__pages__setting__other.d20be1c1.async.js +0 -1
  212. package/static/dist/src__pages__subscription__modal.61e787ce.async.js +0 -1
package/shell/update.sh CHANGED
@@ -138,7 +138,7 @@ update_repo() {
138
138
  echo -e "\n拉取 ${uniq_path} 成功...\n"
139
139
  diff_scripts "$repo_path" "$author" "$path" "$blackword" "$dependence" "$extensions" "$autoAddCron" "$autoDelCron"
140
140
  else
141
- echo -e "\n拉取 ${uniq_path} 失败,请检查网络...\n"
141
+ echo -e "\n拉取 ${uniq_path} 失败,请检查日志...\n"
142
142
  fi
143
143
  }
144
144
 
@@ -245,6 +245,7 @@ reload_qinglong() {
245
245
  fi
246
246
 
247
247
  if [[ "$reload_target" == 'data' ]]; then
248
+ rm -rf ${dir_root}/data
248
249
  cp -rf ${dir_tmp}/data ${dir_root}/
249
250
  fi
250
251
 
@@ -300,11 +301,6 @@ update_qinglong_static() {
300
301
 
301
302
  check_update_dep() {
302
303
  echo -e "\n开始检测依赖...\n"
303
- if [[ ! -s $dir_scripts/package.json ]] || [[ $(diff $dir_sample/package.json $dir_scripts/package.json) ]]; then
304
- cp -f $dir_sample/package.json $dir_scripts/package.json
305
- npm_install_2 $dir_scripts
306
- fi
307
-
308
304
  if [[ $(diff $dir_root/package.json ${dir_tmp}/qinglong-${primary_branch}/package.json) ]]; then
309
305
  npm_install_2 "${dir_tmp}/qinglong-${primary_branch}"
310
306
  fi
@@ -476,8 +472,10 @@ main() {
476
472
  local log_path="${log_dir}/${log_time}.log"
477
473
  local file_path="$dir_log/$log_path"
478
474
 
479
- cmd=">> $file_path 2>&1"
480
- [[ "$show_log" == "true" ]] && cmd=""
475
+ cmd="2>&1 | tee -a $file_path"
476
+ if [[ "$no_tee" == "true" ]]; then
477
+ cmd=">> $file_path 2>&1"
478
+ fi
481
479
 
482
480
  local time_format="%Y-%m-%d %H:%M:%S"
483
481
  local time=$(date "+$time_format")
@@ -490,11 +488,6 @@ main() {
490
488
  eval echo -e "\#\# 开始执行... $begin_time\\\n" $cmd
491
489
  fi
492
490
 
493
- if [[ "$show_log" == "true" ]] && [[ $ID ]]; then
494
- eval echo -e "请移除 -l 参数" $cmd
495
- exit 1
496
- fi
497
-
498
491
  case $p1 in
499
492
  update)
500
493
  fix_config
@@ -559,10 +552,6 @@ main() {
559
552
  if [[ "$p1" != "repo" ]] && [[ "$p1" != "raw" ]]; then
560
553
  eval echo -e "\\\n\#\# 执行结束... $end_time 耗时 $diff_time 秒     " $cmd
561
554
  fi
562
-
563
- if [[ -f $file_path ]]; then
564
- cat $file_path
565
- fi
566
555
  }
567
556
 
568
557
  main "$@"
@@ -30,16 +30,29 @@ const util_1 = require("../config/util");
30
30
  const express_1 = require("express");
31
31
  const typedi_1 = require("typedi");
32
32
  const config_1 = __importDefault(require("../config"));
33
- const fs = __importStar(require("fs"));
33
+ const fs = __importStar(require("fs/promises"));
34
34
  const celebrate_1 = require("celebrate");
35
35
  const path_1 = require("path");
36
+ const const_1 = require("../config/const");
37
+ const got_1 = __importDefault(require("got"));
36
38
  const route = (0, express_1.Router)();
37
39
  exports.default = (app) => {
38
40
  app.use('/configs', route);
41
+ route.get('/samples', async (req, res, next) => {
42
+ try {
43
+ res.send({
44
+ code: 200,
45
+ data: const_1.SAMPLE_FILES,
46
+ });
47
+ }
48
+ catch (e) {
49
+ return next(e);
50
+ }
51
+ });
39
52
  route.get('/files', async (req, res, next) => {
40
53
  const logger = typedi_1.Container.get('logger');
41
54
  try {
42
- const fileList = fs.readdirSync(config_1.default.configPath, 'utf-8');
55
+ const fileList = await fs.readdir(config_1.default.configPath, 'utf-8');
43
56
  res.send({
44
57
  code: 200,
45
58
  data: fileList
@@ -60,11 +73,15 @@ exports.default = (app) => {
60
73
  if (config_1.default.blackFileList.includes(req.params.file)) {
61
74
  res.send({ code: 403, message: '文件无法访问' });
62
75
  }
63
- if (req.params.file.includes('sample')) {
64
- content = (0, util_1.getFileContentByName)((0, path_1.join)(config_1.default.samplePath, req.params.file));
76
+ if (req.params.file.startsWith('sample/')) {
77
+ const res = await got_1.default.get(`https://gitlab.com/whyour/qinglong/-/raw/master/${req.params.file}`);
78
+ content = res.body;
79
+ }
80
+ else if (req.params.file.startsWith('data/scripts/')) {
81
+ content = await (0, util_1.getFileContentByName)((0, path_1.join)(config_1.default.rootPath, req.params.file));
65
82
  }
66
83
  else {
67
- content = (0, util_1.getFileContentByName)((0, path_1.join)(config_1.default.configPath, req.params.file));
84
+ content = await (0, util_1.getFileContentByName)((0, path_1.join)(config_1.default.configPath, req.params.file));
68
85
  }
69
86
  res.send({ code: 200, data: content });
70
87
  }
@@ -85,7 +102,7 @@ exports.default = (app) => {
85
102
  res.send({ code: 403, message: '文件无法访问' });
86
103
  }
87
104
  const path = (0, path_1.join)(config_1.default.configPath, name);
88
- fs.writeFileSync(path, content);
105
+ await fs.writeFile(path, content);
89
106
  res.send({ code: 200, message: '保存成功' });
90
107
  }
91
108
  catch (e) {
@@ -1,34 +1,10 @@
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
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
6
  const express_1 = require("express");
30
7
  const typedi_1 = require("typedi");
31
- const fs = __importStar(require("fs"));
32
8
  const config_1 = __importDefault(require("../config"));
33
9
  const util_1 = require("../config/util");
34
10
  const path_1 = require("path");
@@ -40,7 +16,7 @@ exports.default = (app) => {
40
16
  route.get('/', async (req, res, next) => {
41
17
  const logger = typedi_1.Container.get('logger');
42
18
  try {
43
- const result = (0, util_1.readDirs)(config_1.default.logPath, config_1.default.logPath, blacklist);
19
+ const result = await (0, util_1.readDirs)(config_1.default.logPath, config_1.default.logPath, blacklist);
44
20
  res.send({
45
21
  code: 200,
46
22
  data: result,
@@ -58,7 +34,7 @@ exports.default = (app) => {
58
34
  return res.send({ code: 403, message: '暂无权限' });
59
35
  }
60
36
  const filePath = (0, path_1.join)(config_1.default.logPath, (req.query.path || ''), req.params.file);
61
- const content = (0, util_1.getFileContentByName)(filePath);
37
+ const content = await (0, util_1.getFileContentByName)(filePath);
62
38
  res.send({ code: 200, data: content });
63
39
  }
64
40
  catch (e) {
@@ -75,12 +51,7 @@ exports.default = (app) => {
75
51
  try {
76
52
  let { filename, path, type } = req.body;
77
53
  const filePath = (0, path_1.join)(config_1.default.logPath, path, filename);
78
- if (type === 'directory') {
79
- await (0, util_1.emptyDir)(filePath);
80
- }
81
- else {
82
- fs.unlinkSync(filePath);
83
- }
54
+ await (0, util_1.rmPath)(filePath);
84
55
  res.send({ code: 200 });
85
56
  }
86
57
  catch (e) {
@@ -30,7 +30,7 @@ const util_1 = require("../config/util");
30
30
  const express_1 = require("express");
31
31
  const typedi_1 = require("typedi");
32
32
  const config_1 = __importDefault(require("../config"));
33
- const fs = __importStar(require("fs"));
33
+ const fs = __importStar(require("fs/promises"));
34
34
  const celebrate_1 = require("celebrate");
35
35
  const path_1 = __importStar(require("path"));
36
36
  const script_1 = __importDefault(require("../services/script"));
@@ -51,13 +51,27 @@ exports.default = (app) => {
51
51
  const logger = typedi_1.Container.get('logger');
52
52
  try {
53
53
  let result = [];
54
- const blacklist = ['node_modules', '.git', '.pnpm'];
54
+ const blacklist = [
55
+ 'node_modules',
56
+ '.git',
57
+ '.pnpm',
58
+ 'pnpm-lock.yaml',
59
+ 'yarn.lock',
60
+ 'package-lock.json',
61
+ ];
55
62
  if (req.query.path) {
56
63
  const targetPath = path_1.default.join(config_1.default.scriptPath, req.query.path);
57
- result = (0, util_1.readDir)(targetPath, config_1.default.scriptPath, blacklist);
64
+ result = await (0, util_1.readDir)(targetPath, config_1.default.scriptPath, blacklist);
58
65
  }
59
66
  else {
60
- result = (0, util_1.readDirs)(config_1.default.scriptPath, config_1.default.scriptPath, blacklist);
67
+ result = await (0, util_1.readDirs)(config_1.default.scriptPath, config_1.default.scriptPath, blacklist, (a, b) => {
68
+ if (a.type === b.type) {
69
+ return a.title.localeCompare(b.title);
70
+ }
71
+ else {
72
+ return a.type === 'directory' ? -1 : 1;
73
+ }
74
+ });
61
75
  }
62
76
  res.send({
63
77
  code: 200,
@@ -73,7 +87,7 @@ exports.default = (app) => {
73
87
  const logger = typedi_1.Container.get('logger');
74
88
  try {
75
89
  const filePath = (0, path_1.join)(config_1.default.scriptPath, req.query.path, req.params.file);
76
- const content = (0, util_1.getFileContentByName)(filePath);
90
+ const content = await (0, util_1.getFileContentByName)(filePath);
77
91
  res.send({ code: 200, data: content });
78
92
  }
79
93
  catch (e) {
@@ -100,11 +114,11 @@ exports.default = (app) => {
100
114
  });
101
115
  }
102
116
  if (req.file) {
103
- fs.renameSync(req.file.path, (0, path_1.join)(path, req.file.filename));
117
+ await fs.rename(req.file.path, (0, path_1.join)(path, req.file.filename));
104
118
  return res.send({ code: 200 });
105
119
  }
106
120
  if (directory) {
107
- fs.mkdirSync((0, path_1.join)(path, directory), { recursive: true });
121
+ await fs.mkdir((0, path_1.join)(path, directory), { recursive: true });
108
122
  return res.send({ code: 200 });
109
123
  }
110
124
  if (!originFilename) {
@@ -112,13 +126,14 @@ exports.default = (app) => {
112
126
  }
113
127
  const originFilePath = (0, path_1.join)(path, `${originFilename.replace(/\//g, '')}`);
114
128
  const filePath = (0, path_1.join)(path, `${filename.replace(/\//g, '')}`);
115
- if (fs.existsSync(originFilePath)) {
116
- fs.copyFileSync(originFilePath, (0, path_1.join)(config_1.default.bakPath, originFilename.replace(/\//g, '')));
129
+ const fileExists = await (0, util_1.fileExist)(filePath);
130
+ if (fileExists) {
131
+ await fs.copyFile(originFilePath, (0, path_1.join)(config_1.default.bakPath, originFilename.replace(/\//g, '')));
117
132
  if (filename !== originFilename) {
118
- fs.unlinkSync(originFilePath);
133
+ await (0, util_1.rmPath)(originFilePath);
119
134
  }
120
135
  }
121
- fs.writeFileSync(filePath, content);
136
+ await fs.writeFile(filePath, content);
122
137
  return res.send({ code: 200 });
123
138
  }
124
139
  catch (e) {
@@ -136,7 +151,7 @@ exports.default = (app) => {
136
151
  try {
137
152
  let { filename, content, path } = req.body;
138
153
  const filePath = (0, path_1.join)(config_1.default.scriptPath, path, filename);
139
- fs.writeFileSync(filePath, content);
154
+ await fs.writeFile(filePath, content);
140
155
  return res.send({ code: 200 });
141
156
  }
142
157
  catch (e) {
@@ -154,12 +169,7 @@ exports.default = (app) => {
154
169
  try {
155
170
  let { filename, path, type } = req.body;
156
171
  const filePath = (0, path_1.join)(config_1.default.scriptPath, path, filename);
157
- if (type === 'directory') {
158
- await (0, util_1.emptyDir)(filePath);
159
- }
160
- else {
161
- fs.unlinkSync(filePath);
162
- }
172
+ await (0, util_1.rmPath)(filePath);
163
173
  res.send({ code: 200 });
164
174
  }
165
175
  catch (e) {
@@ -202,7 +212,7 @@ exports.default = (app) => {
202
212
  let { filename, content, path } = req.body;
203
213
  const { name, ext } = (0, path_1.parse)(filename);
204
214
  const filePath = (0, path_1.join)(config_1.default.scriptPath, path, `${name}.swap${ext}`);
205
- fs.writeFileSync(filePath, content || '', { encoding: 'utf8' });
215
+ await fs.writeFile(filePath, content || '', { encoding: 'utf8' });
206
216
  const scriptService = typedi_1.Container.get(script_1.default);
207
217
  const result = await scriptService.runScript(filePath);
208
218
  res.send(result);
@@ -226,7 +236,7 @@ exports.default = (app) => {
226
236
  const scriptService = typedi_1.Container.get(script_1.default);
227
237
  const result = await scriptService.stopScript(filePath, pid);
228
238
  setTimeout(() => {
229
- (0, util_1.emptyDir)(logPath);
239
+ (0, util_1.rmPath)(logPath);
230
240
  }, 3000);
231
241
  res.send(result);
232
242
  }
@@ -245,7 +255,7 @@ exports.default = (app) => {
245
255
  let { filename, path, type, newFilename } = req.body;
246
256
  const filePath = (0, path_1.join)(config_1.default.scriptPath, path, filename);
247
257
  const newPath = (0, path_1.join)(config_1.default.scriptPath, path, newFilename);
248
- fs.renameSync(filePath, newPath);
258
+ await fs.rename(filePath, newPath);
249
259
  res.send({ code: 200 });
250
260
  }
251
261
  catch (e) {
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const express_1 = require("express");
30
30
  const typedi_1 = require("typedi");
31
- const fs = __importStar(require("fs"));
31
+ const fs = __importStar(require("fs/promises"));
32
32
  const config_1 = __importDefault(require("../config"));
33
33
  const system_1 = __importDefault(require("../services/system"));
34
34
  const celebrate_1 = require("celebrate");
@@ -88,22 +88,90 @@ exports.default = (app) => {
88
88
  return next(e);
89
89
  }
90
90
  });
91
- route.put('/config', (0, celebrate_1.celebrate)({
91
+ route.put('/config/log-remove-frequency', (0, celebrate_1.celebrate)({
92
92
  body: celebrate_1.Joi.object({
93
- logRemoveFrequency: celebrate_1.Joi.number().optional().allow(null),
94
- cronConcurrency: celebrate_1.Joi.number().optional().allow(null),
93
+ logRemoveFrequency: celebrate_1.Joi.number().allow(null),
94
+ }),
95
+ }), async (req, res, next) => {
96
+ try {
97
+ const systemService = typedi_1.Container.get(system_1.default);
98
+ const result = await systemService.updateLogRemoveFrequency(req.body);
99
+ res.send(result);
100
+ }
101
+ catch (e) {
102
+ return next(e);
103
+ }
104
+ });
105
+ route.put('/config/cron-concurrency', (0, celebrate_1.celebrate)({
106
+ body: celebrate_1.Joi.object({
107
+ cronConcurrency: celebrate_1.Joi.number().allow(null),
108
+ }),
109
+ }), async (req, res, next) => {
110
+ try {
111
+ const systemService = typedi_1.Container.get(system_1.default);
112
+ const result = await systemService.updateCronConcurrency(req.body);
113
+ res.send(result);
114
+ }
115
+ catch (e) {
116
+ return next(e);
117
+ }
118
+ });
119
+ route.put('/config/dependence-proxy', (0, celebrate_1.celebrate)({
120
+ body: celebrate_1.Joi.object({
121
+ dependenceProxy: celebrate_1.Joi.string().allow('').allow(null),
122
+ }),
123
+ }), async (req, res, next) => {
124
+ try {
125
+ const systemService = typedi_1.Container.get(system_1.default);
126
+ const result = await systemService.updateDependenceProxy(req.body);
127
+ res.send(result);
128
+ }
129
+ catch (e) {
130
+ return next(e);
131
+ }
132
+ });
133
+ route.put('/config/node-mirror', (0, celebrate_1.celebrate)({
134
+ body: celebrate_1.Joi.object({
135
+ nodeMirror: celebrate_1.Joi.string().allow('').allow(null),
136
+ }),
137
+ }), async (req, res, next) => {
138
+ try {
139
+ const systemService = typedi_1.Container.get(system_1.default);
140
+ res.setHeader('Content-type', 'application/octet-stream');
141
+ await systemService.updateNodeMirror(req.body, res);
142
+ }
143
+ catch (e) {
144
+ return next(e);
145
+ }
146
+ });
147
+ route.put('/config/python-mirror', (0, celebrate_1.celebrate)({
148
+ body: celebrate_1.Joi.object({
149
+ pythonMirror: celebrate_1.Joi.string().allow('').allow(null),
95
150
  }),
96
151
  }), async (req, res, next) => {
97
- const logger = typedi_1.Container.get('logger');
98
152
  try {
99
153
  const systemService = typedi_1.Container.get(system_1.default);
100
- const result = await systemService.updateSystemConfig(req.body);
154
+ const result = await systemService.updatePythonMirror(req.body);
101
155
  res.send(result);
102
156
  }
103
157
  catch (e) {
104
158
  return next(e);
105
159
  }
106
160
  });
161
+ route.put('/config/linux-mirror', (0, celebrate_1.celebrate)({
162
+ body: celebrate_1.Joi.object({
163
+ linuxMirror: celebrate_1.Joi.string().allow('').allow(null),
164
+ }),
165
+ }), async (req, res, next) => {
166
+ try {
167
+ const systemService = typedi_1.Container.get(system_1.default);
168
+ res.setHeader('Content-type', 'application/octet-stream');
169
+ await systemService.updateLinuxMirror(req.body, res);
170
+ }
171
+ catch (e) {
172
+ return next(e);
173
+ }
174
+ });
107
175
  route.put('/update-check', async (req, res, next) => {
108
176
  const logger = typedi_1.Container.get('logger');
109
177
  try {
@@ -181,12 +249,12 @@ exports.default = (app) => {
181
249
  onError: async (message) => {
182
250
  res.write(`\n${message}`);
183
251
  const absolutePath = await (0, util_1.handleLogPath)(logPath);
184
- fs.appendFileSync(absolutePath, `\n${message}`);
252
+ await fs.appendFile(absolutePath, `\n${message}`);
185
253
  },
186
254
  onLog: async (message) => {
187
255
  res.write(`\n${message}`);
188
256
  const absolutePath = await (0, util_1.handleLogPath)(logPath);
189
- fs.appendFileSync(absolutePath, `\n${message}`);
257
+ await fs.appendFile(absolutePath, `\n${message}`);
190
258
  },
191
259
  });
192
260
  }
@@ -1,9 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QL_PREFIX = exports.TASK_PREFIX = exports.QL_COMMAND = exports.TASK_COMMAND = exports.LOG_END_SYMBOL = void 0;
3
+ exports.SAMPLE_FILES = exports.QL_PREFIX = exports.TASK_PREFIX = exports.QL_COMMAND = exports.TASK_COMMAND = exports.LOG_END_SYMBOL = void 0;
4
4
  exports.LOG_END_SYMBOL = '     ';
5
5
  exports.TASK_COMMAND = 'task';
6
6
  exports.QL_COMMAND = 'ql';
7
7
  exports.TASK_PREFIX = `${exports.TASK_COMMAND} `;
8
8
  exports.QL_PREFIX = `${exports.QL_COMMAND} `;
9
+ exports.SAMPLE_FILES = [
10
+ {
11
+ title: 'config.sample.sh',
12
+ value: 'sample/config.sample.sh',
13
+ target: 'config.sh',
14
+ },
15
+ {
16
+ title: 'notify.js',
17
+ value: 'sample/notify.js',
18
+ target: 'data/scripts/sendNotify.js',
19
+ },
20
+ {
21
+ title: 'notify.py',
22
+ value: 'sample/notify.py',
23
+ target: 'data/scripts/notify.py',
24
+ },
25
+ ];
9
26
  //# sourceMappingURL=const.js.map
@@ -48,6 +48,7 @@ const configString = 'config sample crontab shareCode diy';
48
48
  const versionFile = path_1.default.join(rootPath, 'version.yaml');
49
49
  const dataTgzFile = path_1.default.join(tmpPath, 'data.tgz');
50
50
  const shareShellFile = path_1.default.join(shellPath, 'share.sh');
51
+ const dependenceProxyFile = path_1.default.join(configPath, 'dependence-proxy.sh');
51
52
  if (envFound.error) {
52
53
  throw new Error("⚠️ Couldn't find .env file ⚠️");
53
54
  }
@@ -67,6 +68,7 @@ exports.default = {
67
68
  dataPath,
68
69
  dataTgzFile,
69
70
  shareShellFile,
71
+ dependenceProxyFile,
70
72
  configString,
71
73
  loginFaild,
72
74
  authError,
@@ -88,6 +90,7 @@ exports.default = {
88
90
  'config.sh.sample',
89
91
  'cookie.sh',
90
92
  'crontab.list',
93
+ 'dependence-proxy.sh',
91
94
  'env.sh',
92
95
  'token.json',
93
96
  ],