@whyour/qinglong 2.21.0 → 2.23.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.
Files changed (362) hide show
  1. package/.dockerignore +13 -0
  2. package/.env.example +7 -0
  3. package/AGENTS.md +2 -2
  4. package/README-en.md +24 -0
  5. package/README.md +24 -0
  6. package/back/protos/api.proto +9 -1
  7. package/back/protos/cron.proto +8 -1
  8. package/deploy/kubernetes/README.md +81 -0
  9. package/deploy/kubernetes/base/kustomization.yaml +5 -0
  10. package/deploy/kubernetes/base/qinglong.yaml +95 -0
  11. package/deploy/kubernetes/overlays/example/kustomization.yaml +10 -0
  12. package/docker/Dockerfile +31 -12
  13. package/docker/Dockerfile.310 +31 -12
  14. package/docker/Dockerfile.debian +22 -14
  15. package/docker/Dockerfile.debian310 +24 -14
  16. package/docker/build-manifest.cjs +28 -0
  17. package/docker/verify-build.cjs +49 -0
  18. package/docs/development/node-cron-migration.md +49 -0
  19. package/docs/development/task-startup.md +78 -0
  20. package/docs/releases/2.22.0-validation.md +49 -0
  21. package/docs/releases/2.22.0.md +62 -0
  22. package/docs/releases/2.23.0.md +33 -0
  23. package/docs/script-history.md +53 -0
  24. package/ecosystem.config.js +10 -1
  25. package/package.json +19 -13
  26. package/sample/config.sample.sh +17 -2
  27. package/sample/notify.js +118 -0
  28. package/sample/notify.py +93 -0
  29. package/scripts/benchmark-execution.cjs +96 -0
  30. package/scripts/benchmark-script-history.cjs +39 -0
  31. package/scripts/publish-static.sh +34 -0
  32. package/scripts/sync-static.sh +20 -0
  33. package/scripts/wait-for-mirror.sh +214 -0
  34. package/scripts/write-build-info.cjs +27 -0
  35. package/shell/api.sh +96 -83
  36. package/shell/check.sh +59 -19
  37. package/shell/lang/en.sh +6 -0
  38. package/shell/lang/zh.sh +6 -0
  39. package/shell/node_path_cache.sh +136 -0
  40. package/shell/otask.sh +17 -10
  41. package/shell/preload/sitecustomize.js +11 -3
  42. package/shell/preload/sitecustomize.py +4 -2
  43. package/shell/share.sh +27 -10
  44. package/shell/start.sh +6 -3
  45. package/shell/task-timeout.sh +63 -0
  46. package/shell/task.sh +21 -9
  47. package/shell/update.sh +104 -98
  48. package/shell/upgrade.cjs +8 -0
  49. package/static/build/api/clientIp.js +42 -0
  50. package/static/build/api/config.js +9 -21
  51. package/static/build/api/cron.js +39 -3
  52. package/static/build/api/dashboard.js +50 -6
  53. package/static/build/api/env.js +17 -16
  54. package/static/build/api/health.js +2 -2
  55. package/static/build/api/index.js +4 -0
  56. package/static/build/api/log.js +39 -19
  57. package/static/build/api/open.js +2 -1
  58. package/static/build/api/retention.js +63 -0
  59. package/static/build/api/script.js +172 -25
  60. package/static/build/api/subscription.js +19 -8
  61. package/static/build/api/system.js +66 -12
  62. package/static/build/api/user.js +75 -15
  63. package/static/build/app.js +63 -54
  64. package/static/build/bootstrap/database.js +51 -0
  65. package/static/build/config/const.js +2 -0
  66. package/static/build/config/grpcCerts.js +93 -44
  67. package/static/build/config/index.js +0 -4
  68. package/static/build/config/share.js +5 -4
  69. package/static/build/config/subscription.js +19 -11
  70. package/static/build/config/util.js +142 -45
  71. package/static/build/data/cron.js +1 -0
  72. package/static/build/data/notify.js +18 -1
  73. package/static/build/data/sock.js +1 -0
  74. package/static/build/loaders/app.js +8 -6
  75. package/static/build/loaders/db.js +5 -35
  76. package/static/build/loaders/deps.js +30 -22
  77. package/static/build/loaders/express.js +46 -32
  78. package/static/build/loaders/initData.js +26 -33
  79. package/static/build/loaders/initFile.js +1 -1
  80. package/static/build/loaders/initTask.js +14 -3
  81. package/static/build/loaders/server.js +1 -1
  82. package/static/build/loaders/sock.js +72 -6
  83. package/static/build/middlewares/monitoring.js +12 -33
  84. package/static/build/middlewares/protectedPathCase.js +17 -0
  85. package/static/build/middlewares/uniqueConstraintError.js +15 -0
  86. package/static/build/protos/api.js +78 -2
  87. package/static/build/protos/cron.js +83 -5
  88. package/static/build/protos/health.js +1 -1
  89. package/static/build/schedule/addCron.js +67 -19
  90. package/static/build/schedule/api.js +5 -2
  91. package/static/build/schedule/client.js +56 -6
  92. package/static/build/schedule/delCron.js +11 -1
  93. package/static/build/schedule/health.js +72 -7
  94. package/static/build/schedule/setConcurrency.js +27 -0
  95. package/static/build/services/config.js +5 -43
  96. package/static/build/services/cron.js +389 -174
  97. package/static/build/services/dependence.js +66 -18
  98. package/static/build/services/env.js +1 -1
  99. package/static/build/services/grpc.js +4 -3
  100. package/static/build/services/health.js +4 -7
  101. package/static/build/services/http.js +9 -3
  102. package/static/build/services/log.js +2 -3
  103. package/static/build/services/metrics.js +46 -14
  104. package/static/build/services/notify.js +73 -5
  105. package/static/build/services/open.js +106 -31
  106. package/static/build/services/retention.js +123 -0
  107. package/static/build/services/schedule.js +77 -43
  108. package/static/build/services/script.js +4 -5
  109. package/static/build/services/scriptHistory.js +30 -0
  110. package/static/build/services/sshKey.js +39 -14
  111. package/static/build/services/subscription.js +161 -87
  112. package/static/build/services/system.js +116 -43
  113. package/static/build/services/user.js +255 -37
  114. package/static/build/shared/auth.js +22 -3
  115. package/static/build/shared/authMutation.js +17 -0
  116. package/static/build/shared/childProcess.js +82 -0
  117. package/static/build/shared/clientIp.js +27 -0
  118. package/static/build/shared/cronCommand.js +17 -0
  119. package/static/build/shared/cronSchedule.js +101 -0
  120. package/static/build/shared/cronScheduler.js +73 -0
  121. package/static/build/shared/errors.js +9 -0
  122. package/static/build/shared/fileAccess.js +60 -0
  123. package/static/build/shared/i18n.js +63 -4
  124. package/static/build/shared/logPath.js +15 -0
  125. package/static/build/shared/logReader.js +85 -0
  126. package/static/build/shared/logStreamManager.js +80 -60
  127. package/static/build/shared/loginThrottle.js +45 -0
  128. package/static/build/shared/pLimit.js +22 -8
  129. package/static/build/shared/password.js +30 -0
  130. package/static/build/shared/retention.js +58 -0
  131. package/static/build/shared/runCron.js +39 -17
  132. package/static/build/shared/schedulerMutationLock.js +44 -0
  133. package/static/build/shared/schedulerReadiness.js +82 -0
  134. package/static/build/shared/schemaMigrations.js +58 -0
  135. package/static/build/shared/scriptHistory.js +445 -0
  136. package/static/build/shared/shellQuote.js +11 -0
  137. package/static/build/shared/startupProcess.js +48 -0
  138. package/static/build/shared/store.js +7 -0
  139. package/static/build/shared/subscriptionMutationLock.js +34 -0
  140. package/static/build/shared/subscriptionPath.js +41 -0
  141. package/static/build/shared/subscriptionStorage.js +98 -0
  142. package/static/build/shared/trustProxy.js +119 -0
  143. package/static/build/shared/utils.js +2 -1
  144. package/static/build/token.js +3 -14
  145. package/static/build/validation/schedule.js +6 -12
  146. package/static/dist/{1885.e1ea09f6.async.js → 1885.b8f427bf.async.js} +1 -1
  147. package/static/dist/2031.6af40025.async.js +1 -0
  148. package/static/dist/2693.51c2636b.async.js +1 -0
  149. package/static/dist/{2890.9e373f5b.async.js → 2890.add55e85.async.js} +1 -1
  150. package/static/dist/2901.2ca95295.async.js +1 -0
  151. package/static/dist/292.264757f0.async.js +1 -0
  152. package/static/dist/3512.95e41255.async.js +1 -0
  153. package/static/dist/445.a65ff63b.async.js +1 -0
  154. package/static/dist/4736.1d2b5cb6.async.js +1 -0
  155. package/static/dist/{6013.4e38de36.async.js → 6013.db535339.async.js} +1 -1
  156. package/static/dist/6212.9e6d9913.async.js +1 -0
  157. package/static/dist/{6339.ab305e96.async.js → 6431.4603ad0e.async.js} +1 -1
  158. package/static/dist/{6872.42f939f1.async.js → 6872.a503ef55.async.js} +1 -1
  159. package/static/dist/7231.f7e5b668.async.js +1 -0
  160. package/static/dist/{7355.f9f263d8.async.js → 7355.fca746f5.async.js} +1 -1
  161. package/static/dist/{7508.7dcee91c.async.js → 7508.d90eac63.async.js} +1 -1
  162. package/static/dist/{7984.594296a5.async.js → 7984.eaac7402.async.js} +1 -1
  163. package/static/dist/8844.a0fef08e.async.js +1 -0
  164. package/static/dist/index.html +2 -2
  165. package/static/dist/layouts__index.633d3553.async.js +1 -0
  166. package/static/dist/preload_helper.01fcd534.js +1 -0
  167. package/static/dist/{src__pages__config__index.a22ff7dc.async.js → src__pages__config__index.9aba4054.async.js} +1 -1
  168. package/static/dist/src__pages__crontab__detail.86b2eebb.async.js +1 -0
  169. package/static/dist/src__pages__crontab__index.ae4e06f2.async.js +1 -0
  170. package/static/dist/{src__pages__crontab__logModal.0b8cce8c.async.js → src__pages__crontab__logModal.930535e2.async.js} +1 -1
  171. package/static/dist/src__pages__crontab__modal.a2c8fdcc.async.js +1 -0
  172. package/static/dist/src__pages__crontab__viewCreateModal.7b4f9cbe.async.js +1 -0
  173. package/static/dist/src__pages__crontab__viewManageModal.cd454ea0.async.js +1 -0
  174. package/static/dist/src__pages__dashboard__index.243c5a35.async.js +1 -0
  175. package/static/dist/src__pages__dashboard__taskResultModal.7795d6e1.async.js +1 -0
  176. package/static/dist/src__pages__dependence__index.874d501f.async.js +1 -0
  177. package/static/dist/src__pages__dependence__logModal.154efe7a.async.js +1 -0
  178. package/static/dist/src__pages__dependence__modal.0fa8b421.async.js +1 -0
  179. package/static/dist/src__pages__diff__index.b94e5dc5.async.js +1 -0
  180. package/static/dist/src__pages__env__editNameModal.c13d47d2.async.js +1 -0
  181. package/static/dist/src__pages__env__index.fd6fd2b0.async.js +1 -0
  182. package/static/dist/src__pages__env__modal.4d71adb3.async.js +1 -0
  183. package/static/dist/src__pages__error__index.aae50c94.async.js +1 -0
  184. package/static/dist/src__pages__initialization__index.82a2e967.async.js +1 -0
  185. package/static/dist/src__pages__log__index.71250e0d.async.js +1 -0
  186. package/static/dist/{src__pages__login__index.8c813eb1.async.js → src__pages__login__index.a0fd5ed8.async.js} +1 -1
  187. package/static/dist/src__pages__script__editModal.afabf073.async.js +1 -0
  188. package/static/dist/src__pages__script__editNameModal.789ad87b.async.js +1 -0
  189. package/static/dist/src__pages__script__historyDrawer.8c58d958.async.js +1 -0
  190. package/static/dist/src__pages__script__historyDrawer.a449193a.chunk.css +1 -0
  191. package/static/dist/src__pages__script__index.ab360776.chunk.css +1 -0
  192. package/static/dist/src__pages__script__index.fc575945.async.js +1 -0
  193. package/static/dist/src__pages__script__renameModal.0ab029e7.async.js +1 -0
  194. package/static/dist/src__pages__script__saveModal.8fca1a22.async.js +1 -0
  195. package/static/dist/src__pages__script__saveWithHistory.99ece830.async.js +1 -0
  196. package/static/dist/src__pages__script__setting.35ad4f02.async.js +1 -0
  197. package/static/dist/src__pages__setting__appModal.7eaeb9d3.async.js +1 -0
  198. package/static/dist/src__pages__setting__checkUpdate.d175b154.async.js +1 -0
  199. package/static/dist/src__pages__setting__clientIp.3a8711ed.async.js +1 -0
  200. package/static/dist/src__pages__setting__dependence.9c0f749b.async.js +1 -0
  201. package/static/dist/src__pages__setting__index.cb397741.async.js +1 -0
  202. package/static/dist/src__pages__setting__loginLog.e0a1f54d.async.js +1 -0
  203. package/static/dist/src__pages__setting__notification.2ffe4e5a.async.js +1 -0
  204. package/static/dist/src__pages__setting__other.3d0b8492.async.js +1 -0
  205. package/static/dist/{src__pages__setting__progress.8823ac90.async.js → src__pages__setting__progress.2ccae3d7.async.js} +1 -1
  206. package/static/dist/src__pages__setting__security.e2d71ebb.async.js +1 -0
  207. package/static/dist/src__pages__setting__systemLog.b3046955.async.js +1 -0
  208. package/static/dist/src__pages__subscription__index.43086a06.async.js +1 -0
  209. package/static/dist/src__pages__subscription__logModal.cdba5139.async.js +1 -0
  210. package/static/dist/src__pages__subscription__modal.30868ba8.async.js +1 -0
  211. package/static/dist/{umi.ca04a019.js → umi.3a24a9fa.js} +1 -1
  212. package/test/back/advisory-input-security.test.cjs +416 -0
  213. package/test/back/auth-security.test.cjs +74 -0
  214. package/test/back/build-provenance.test.cjs +150 -0
  215. package/test/back/code-scanning-security.test.cjs +189 -0
  216. package/test/back/cron-log-name.test.cjs +110 -0
  217. package/test/back/cron-macros.test.cjs +51 -0
  218. package/test/back/cron-schedule-compatibility.test.cjs +69 -0
  219. package/test/back/cron-scheduler-routing.test.cjs +59 -0
  220. package/test/back/cron-validation.test.cjs +45 -0
  221. package/test/back/dashboard-failures.test.cjs +173 -0
  222. package/test/back/database-bootstrap.test.cjs +193 -0
  223. package/test/back/dependence-cache-status.test.cjs +125 -0
  224. package/test/back/deprecated-file-routes.test.cjs +82 -0
  225. package/test/back/draft-path-security.test.cjs +235 -0
  226. package/test/back/ecosystem.test.cjs +28 -0
  227. package/test/back/env-import-security.test.cjs +91 -0
  228. package/test/back/env-name-parsing.test.cjs +96 -0
  229. package/test/back/execution-lifecycle.test.cjs +236 -0
  230. package/test/back/file-access-scope.test.cjs +180 -0
  231. package/test/back/file-access-security.test.cjs +47 -0
  232. package/test/back/fileTreeListing.test.cjs +57 -0
  233. package/test/back/grpc-cron-response.test.cjs +60 -0
  234. package/test/back/grpc-mtls-security.test.cjs +136 -0
  235. package/test/back/http-exclusive-listen.test.cjs +31 -0
  236. package/test/back/http-security.test.cjs +313 -0
  237. package/test/back/legacy-cron-recovery.test.cjs +76 -0
  238. package/test/back/linux-mirror-result.test.cjs +176 -0
  239. package/test/back/listen-security.test.cjs +68 -0
  240. package/test/back/log-path-security.test.cjs +158 -0
  241. package/test/back/logReader.test.cjs +72 -0
  242. package/test/back/manual-execution.test.cjs +85 -0
  243. package/test/back/manual-stop-claim.test.cjs +220 -0
  244. package/test/back/metrics.test.cjs +34 -0
  245. package/test/back/mirror-status.test.cjs +257 -0
  246. package/test/back/monitoring.test.cjs +73 -0
  247. package/test/back/node-cron-migration.test.cjs +65 -0
  248. package/test/back/node-path-cache.test.cjs +202 -0
  249. package/test/back/node-path-lock.test.cjs +182 -0
  250. package/test/back/npm-publication.test.cjs +70 -0
  251. package/test/back/preload-lazy-notify.test.cjs +168 -0
  252. package/test/back/primary-apm.test.cjs +24 -0
  253. package/test/back/process-exit-state.test.cjs +81 -0
  254. package/test/back/process-stop-signal.test.cjs +77 -0
  255. package/test/back/protected-path-case.test.cjs +58 -0
  256. package/test/back/qlServiceLogCommand.test.cjs +128 -0
  257. package/test/back/queued-cron-invalidation.test.cjs +98 -0
  258. package/test/back/restart-instance-recovery.test.cjs +116 -0
  259. package/test/back/retention.test.cjs +131 -0
  260. package/test/back/role-loading.test.cjs +118 -0
  261. package/test/back/schedule-health.test.cjs +86 -0
  262. package/test/back/scheduler-bulk-recovery.test.cjs +40 -0
  263. package/test/back/scheduler-concurrency.test.cjs +411 -0
  264. package/test/back/scheduler-file-lock.test.cjs +51 -0
  265. package/test/back/scheduler-mutation.test.cjs +312 -0
  266. package/test/back/scheduler-readiness.test.cjs +85 -0
  267. package/test/back/scheduler-reconciliation.test.cjs +206 -0
  268. package/test/back/scheduler-rpc-timeout.test.cjs +49 -0
  269. package/test/back/schema-migrations.test.cjs +127 -0
  270. package/test/back/script-file-access.test.cjs +210 -0
  271. package/test/back/script-history-api.test.cjs +551 -0
  272. package/test/back/script-history.test.cjs +383 -0
  273. package/test/back/shell-api-parsing.test.cjs +184 -0
  274. package/test/back/shell-translation-output.test.cjs +16 -0
  275. package/test/back/shell-upgrade.test.cjs +312 -0
  276. package/test/back/shellApiToken.test.cjs +151 -0
  277. package/test/back/sock-polling.test.cjs +297 -0
  278. package/test/back/sock-security.test.cjs +72 -0
  279. package/test/back/ssh-config-home.test.cjs +113 -0
  280. package/test/back/start-env-preservation.test.cjs +53 -0
  281. package/test/back/static-mirror-trigger.test.cjs +441 -0
  282. package/test/back/static-mirror.test.cjs +179 -0
  283. package/test/back/stop-failure-feedback.test.cjs +158 -0
  284. package/test/back/stop-race.test.cjs +171 -0
  285. package/test/back/subscription-cleanup.test.cjs +53 -0
  286. package/test/back/subscription-mutation-lock.test.cjs +83 -0
  287. package/test/back/subscription-review-regression.test.cjs +607 -0
  288. package/test/back/subscription-stop-state.test.cjs +66 -0
  289. package/test/back/subscription-storage-regression.test.cjs +553 -0
  290. package/test/back/system-dependence-cache.test.cjs +127 -0
  291. package/test/back/system-export-history.test.cjs +119 -0
  292. package/test/back/systemTokenRenewal.test.cjs +497 -0
  293. package/test/back/task-shell-lifecycle.test.cjs +194 -0
  294. package/test/back/task-time.test.cjs +116 -0
  295. package/test/back/unique-constraint-error.test.cjs +72 -0
  296. package/test/back/upgrade-guards.test.cjs +285 -0
  297. package/test/back/upgrade-lifecycle.test.cjs +288 -0
  298. package/test/back/upgrade-transaction.test.cjs +133 -0
  299. package/test/back/user-api.test.cjs +99 -0
  300. package/test/back/user-security.test.cjs +349 -0
  301. package/test/back/worker-apm.test.cjs +84 -0
  302. package/test/back/wpush-grpc.test.cjs +116 -0
  303. package/test/fixtures/legacy-cron.json +1371 -0
  304. package/test/front/cron-log-pagination.test.cjs +214 -0
  305. package/test/front/diff-file-routing.test.cjs +126 -0
  306. package/test/front/http-auth.test.cjs +152 -0
  307. package/test/front/http-error.test.cjs +29 -0
  308. package/test/front/script-history-save.test.cjs +121 -0
  309. package/test/helpers/load-security-module.cjs +42 -0
  310. package/test/helpers/upgrade-fixture.cjs +30 -0
  311. package/version.yaml +14 -34
  312. package/CLAUDE.md +0 -43
  313. package/static/dist/1147.c420132e.async.js +0 -1
  314. package/static/dist/134.54df9e38.async.js +0 -1
  315. package/static/dist/2096.6d98fd12.async.js +0 -1
  316. package/static/dist/2208.f7ba3dfa.async.js +0 -1
  317. package/static/dist/2286.164bb089.async.js +0 -1
  318. package/static/dist/3191.63263871.async.js +0 -1
  319. package/static/dist/4859.6592cebb.async.js +0 -1
  320. package/static/dist/4902.555f92ab.async.js +0 -1
  321. package/static/dist/5520.ff2cfd6b.async.js +0 -1
  322. package/static/dist/6431.c50479be.async.js +0 -1
  323. package/static/dist/6707.801b886b.async.js +0 -1
  324. package/static/dist/8826.2447a104.async.js +0 -1
  325. package/static/dist/layouts__index.a7a2bfe0.async.js +0 -1
  326. package/static/dist/preload_helper.0431c0f3.js +0 -1
  327. package/static/dist/src__pages__crontab__detail.b9c36808.async.js +0 -1
  328. package/static/dist/src__pages__crontab__index.fed99fd0.async.js +0 -1
  329. package/static/dist/src__pages__crontab__modal.f7041c7c.async.js +0 -1
  330. package/static/dist/src__pages__crontab__viewCreateModal.4d589f66.async.js +0 -1
  331. package/static/dist/src__pages__crontab__viewManageModal.0e317746.async.js +0 -1
  332. package/static/dist/src__pages__dashboard__index.b30f2f47.async.js +0 -1
  333. package/static/dist/src__pages__dependence__index.3d87ceac.async.js +0 -1
  334. package/static/dist/src__pages__dependence__logModal.0681830b.async.js +0 -1
  335. package/static/dist/src__pages__dependence__modal.11124896.async.js +0 -1
  336. package/static/dist/src__pages__diff__index.013b7c75.async.js +0 -1
  337. package/static/dist/src__pages__env__editNameModal.5d264b25.async.js +0 -1
  338. package/static/dist/src__pages__env__index.baa27d4e.async.js +0 -1
  339. package/static/dist/src__pages__env__modal.7f2ef1bc.async.js +0 -1
  340. package/static/dist/src__pages__error__index.f156b45e.async.js +0 -1
  341. package/static/dist/src__pages__initialization__index.e96d4ba8.async.js +0 -1
  342. package/static/dist/src__pages__log__index.e0978bae.async.js +0 -1
  343. package/static/dist/src__pages__script__editModal.cbf4ec0e.async.js +0 -1
  344. package/static/dist/src__pages__script__editNameModal.3e7e100d.async.js +0 -1
  345. package/static/dist/src__pages__script__index.2765d1b8.async.js +0 -1
  346. package/static/dist/src__pages__script__index.60b6f827.chunk.css +0 -1
  347. package/static/dist/src__pages__script__renameModal.5e987ef5.async.js +0 -1
  348. package/static/dist/src__pages__script__saveModal.3f9d23d6.async.js +0 -1
  349. package/static/dist/src__pages__script__setting.a535793a.async.js +0 -1
  350. package/static/dist/src__pages__setting__appModal.251cd14f.async.js +0 -1
  351. package/static/dist/src__pages__setting__checkUpdate.46efe057.async.js +0 -1
  352. package/static/dist/src__pages__setting__dependence.8a7a9529.async.js +0 -1
  353. package/static/dist/src__pages__setting__index.cc85fdfb.async.js +0 -1
  354. package/static/dist/src__pages__setting__loginLog.cea6056c.async.js +0 -1
  355. package/static/dist/src__pages__setting__notification.390fc905.async.js +0 -1
  356. package/static/dist/src__pages__setting__other.b22d2165.async.js +0 -1
  357. package/static/dist/src__pages__setting__security.598720a8.async.js +0 -1
  358. package/static/dist/src__pages__setting__systemLog.67406721.async.js +0 -1
  359. package/static/dist/src__pages__subscription__index.d0ab2abc.async.js +0 -1
  360. package/static/dist/src__pages__subscription__logModal.3864b37f.async.js +0 -1
  361. package/static/dist/src__pages__subscription__modal.3562c670.async.js +0 -1
  362. /package/static/dist/{4859.1b962b29.chunk.css → 292.1b962b29.chunk.css} +0 -0
@@ -0,0 +1,27 @@
1
+ const fs = require('node:fs');
2
+ const path = require('node:path');
3
+ const crypto = require('node:crypto');
4
+ const { execFileSync } = require('node:child_process');
5
+ const { collectBuildFiles } = require('../docker/build-manifest.cjs');
6
+
7
+ const root = process.cwd();
8
+ for (const output of ['static/build/app.js', 'static/dist/index.html']) {
9
+ if (!fs.existsSync(path.join(root, output)))
10
+ throw new Error(`Missing build output: ${output}`);
11
+ }
12
+ const git = (...args) =>
13
+ execFileSync('git', args, { cwd: root, encoding: 'utf8' }).trim();
14
+ const manifest = {
15
+ version: 1,
16
+ files: collectBuildFiles(),
17
+ sourceCommit: git('rev-parse', 'HEAD'),
18
+ dirty: git('status', '--porcelain', '--untracked-files=all') !== '',
19
+ lockfileSha256: crypto
20
+ .createHash('sha256')
21
+ .update(fs.readFileSync('pnpm-lock.yaml'))
22
+ .digest('hex'),
23
+ };
24
+ fs.writeFileSync(
25
+ 'static/build-info.json',
26
+ JSON.stringify(manifest, null, 2) + '\n',
27
+ );
package/shell/api.sh CHANGED
@@ -10,16 +10,61 @@ create_token() {
10
10
  }
11
11
 
12
12
  get_token() {
13
- if [[ -f $file_auth_token ]]; then
14
- __ql_token__=$(cat $file_auth_token | jq -r .value)
15
- local expiration=$(cat $file_auth_token | jq -r .expiration)
16
- local currentTimeStamp=$(date +%s)
17
- if [[ $currentTimeStamp -ge $expiration ]]; then
18
- create_token
13
+ local token_data expiration token_value
14
+ local currentTimeStamp=${EPOCHSECONDS:-$(date +%s)}
15
+ if [[ -f "$file_auth_token" ]] && token_data=$(jq -er \
16
+ 'select((.expiration | type) == "number" and (.value | type) == "string" and (.value | length) > 0 and (.value | test("[\r\n]") | not)) | .expiration, .value' \
17
+ "$file_auth_token" 2>/dev/null); then
18
+ expiration=${token_data%%$'\n'*}
19
+ token_value=${token_data#*$'\n'}
20
+ if [[ "$expiration" =~ ^[1-9][0-9]{0,10}$ && -n "$token_value" && "$token_value" != *$'\n'* && "$token_value" != *$'\r'* ]] && \
21
+ (( currentTimeStamp < expiration )); then
22
+ __ql_token__=$token_value
23
+ return 0
19
24
  fi
20
- else
21
- create_token
22
25
  fi
26
+ create_token
27
+ }
28
+
29
+ # Check the cached token before every authenticated API request. A rejected
30
+ # token is refreshed and retried once; other failures are never retried.
31
+ # Arguments are curl options, including the URL, method and optional body.
32
+ ql_api_request() {
33
+ local api=""
34
+ local attempt
35
+ get_token || return $?
36
+ for attempt in 1 2; do
37
+ api=$(curl -s --noproxy "*" \
38
+ -H "Authorization: Bearer ${__ql_token__}" \
39
+ -H "Content-Type: application/json;charset=UTF-8" \
40
+ "$@" \
41
+ --compressed)
42
+ if [[ "$attempt" == 2 || "$api" == '{"code":200}' ]] ||
43
+ [[ "$(jq -r '.code' <<< "$api" 2>/dev/null)" != 401 ]]; then
44
+ break
45
+ fi
46
+ create_token || return $?
47
+ done
48
+ printf '%s' "$api"
49
+ }
50
+
51
+ # Read the status response once; preserve multiline error messages and the
52
+ # legacy code/message variables used by the shell API callers.
53
+ ql_parse_status_response() {
54
+ # Both task status and statistics endpoints normally return this exact body.
55
+ # Match the whole document; all other JSON and malformed responses still
56
+ # use jq. Keep its missing-message result for existing callers.
57
+ if [[ "$1" == '{"code":200}' ]]; then
58
+ code=200
59
+ message=null
60
+ return 0
61
+ fi
62
+ local parsed
63
+ code=""
64
+ message=""
65
+ parsed=$(jq -r '.code, .message' <<< "$1") || return $?
66
+ code=${parsed%%$'\n'*}
67
+ message=${parsed#*$'\n'}
23
68
  }
24
69
 
25
70
  add_cron_api() {
@@ -40,13 +85,10 @@ add_cron_api() {
40
85
  sub_id="null"
41
86
  fi
42
87
 
43
- local api=$(
44
- curl -s --noproxy "*" "http://localhost:${ql_port}/open/crons?t=$currentTimeStamp" \
45
- -H "Authorization: Bearer ${__ql_token__}" \
46
- -H "Content-Type: application/json;charset=UTF-8" \
47
- --data-raw "{\"name\":\"${name//\"/\\\"}\",\"command\":\"${command//\"/\\\"}\",\"schedule\":\"$schedule\",\"sub_id\":$sub_id}" \
48
- --compressed
49
- )
88
+ local api=$(ql_api_request \
89
+ "http://localhost:${ql_port}/open/crons?t=$currentTimeStamp" \
90
+ --data-raw "{\"name\":\"${name//\"/\\\"}\",\"command\":\"${command//\"/\\\"}\",\"schedule\":\"$schedule\",\"sub_id\":$sub_id}" \
91
+ -X POST)
50
92
  code=$(echo "$api" | jq -r .code)
51
93
  message=$(echo "$api" | jq -r .message)
52
94
  if [[ $code == 200 ]]; then
@@ -70,14 +112,10 @@ update_cron_api() {
70
112
  local id="$4"
71
113
  fi
72
114
 
73
- local api=$(
74
- curl -s --noproxy "*" "http://localhost:${ql_port}/open/crons?t=$currentTimeStamp" \
75
- -X 'PUT' \
76
- -H "Authorization: Bearer ${__ql_token__}" \
77
- -H "Content-Type: application/json;charset=UTF-8" \
78
- --data-raw "{\"name\":\"${name//\"/\\\"}\",\"command\":\"${command//\"/\\\"}\",\"schedule\":\"$schedule\",\"id\":\"$id\"}" \
79
- --compressed
80
- )
115
+ local api=$(ql_api_request \
116
+ "http://localhost:${ql_port}/open/crons?t=$currentTimeStamp" \
117
+ -X PUT \
118
+ --data-raw "{\"name\":\"${name//\"/\\\"}\",\"command\":\"${command//\"/\\\"}\",\"schedule\":\"$schedule\",\"id\":\"$id\"}")
81
119
  code=$(echo "$api" | jq -r .code)
82
120
  message=$(echo "$api" | jq -r .message)
83
121
  if [[ $code == 200 ]]; then
@@ -97,14 +135,10 @@ update_cron_command_api() {
97
135
  local id="$2"
98
136
  fi
99
137
 
100
- local api=$(
101
- curl -s --noproxy "*" "http://localhost:${ql_port}/open/crons?t=$currentTimeStamp" \
102
- -X 'PUT' \
103
- -H "Authorization: Bearer ${__ql_token__}" \
104
- -H "Content-Type: application/json;charset=UTF-8" \
105
- --data-raw "{\"command\":\"${command//\"/\\\"}\",\"id\":\"$id\"}" \
106
- --compressed
107
- )
138
+ local api=$(ql_api_request \
139
+ "http://localhost:${ql_port}/open/crons?t=$currentTimeStamp" \
140
+ -X PUT \
141
+ --data-raw "{\"command\":\"${command//\"/\\\"}\",\"id\":\"$id\"}")
108
142
  code=$(echo "$api" | jq -r .code)
109
143
  message=$(echo "$api" | jq -r .message)
110
144
  if [[ $code == 200 ]]; then
@@ -117,14 +151,10 @@ update_cron_command_api() {
117
151
  del_cron_api() {
118
152
  local ids="$1"
119
153
  local currentTimeStamp=$(date +%s)
120
- local api=$(
121
- curl -s --noproxy "*" "http://localhost:${ql_port}/open/crons?t=$currentTimeStamp" \
122
- -X 'DELETE' \
123
- -H "Authorization: Bearer ${__ql_token__}" \
124
- -H "Content-Type: application/json;charset=UTF-8" \
125
- --data-raw "[$ids]" \
126
- --compressed
127
- )
154
+ local api=$(ql_api_request \
155
+ "http://localhost:${ql_port}/open/crons?t=$currentTimeStamp" \
156
+ -X DELETE \
157
+ --data-raw "[$ids]")
128
158
  code=$(echo "$api" | jq -r .code)
129
159
  message=$(echo "$api" | jq -r .message)
130
160
  if [[ $code == 200 ]]; then
@@ -141,17 +171,18 @@ update_cron() {
141
171
  local logPath="$4"
142
172
  local lastExecutingTime="${5:-0}"
143
173
  local runningTime="${6:-0}"
144
- local currentTimeStamp=$(date +%s)
145
- local api=$(
146
- curl -s --noproxy "*" "http://localhost:${ql_port}/open/crons/status?t=$currentTimeStamp" \
147
- -X 'PUT' \
148
- -H "Authorization: Bearer ${__ql_token__}" \
149
- -H "Content-Type: application/json;charset=UTF-8" \
150
- --data-raw "{\"ids\":[$ids],\"status\":\"$status\",\"pid\":\"$pid\",\"log_path\":\"$logPath\",\"last_execution_time\":$lastExecutingTime,\"last_running_time\":$runningTime}" \
151
- --compressed
152
- )
153
- code=$(echo "$api" | jq -r .code)
154
- message=$(echo "$api" | jq -r .message)
174
+ local exitCode="${7:-}"
175
+ local currentTimeStamp=${EPOCHSECONDS:-$(date +%s)}
176
+ local dataRaw="{\"ids\":[$ids],\"status\":\"$status\",\"pid\":\"$pid\",\"log_path\":\"$logPath\",\"last_execution_time\":$lastExecutingTime,\"last_running_time\":$runningTime"
177
+ if [[ -n $exitCode ]]; then
178
+ dataRaw="${dataRaw},\"exit_code\":$exitCode"
179
+ fi
180
+ dataRaw="${dataRaw}}"
181
+ local api=$(ql_api_request \
182
+ "http://localhost:${ql_port}/open/crons/status?t=$currentTimeStamp" \
183
+ -X PUT \
184
+ --data-raw "$dataRaw")
185
+ ql_parse_status_response "$api" || true
155
186
  if [[ $code != 200 ]]; then
156
187
  if [[ ! $message ]]; then
157
188
  message="$api"
@@ -164,14 +195,10 @@ notify_api() {
164
195
  local title="$1"
165
196
  local content="$2"
166
197
  local currentTimeStamp=$(date +%s)
167
- local api=$(
168
- curl -s --noproxy "*" "http://localhost:${ql_port}/open/system/notify?t=$currentTimeStamp" \
169
- -X 'PUT' \
170
- -H "Authorization: Bearer ${__ql_token__}" \
171
- -H "Content-Type: application/json;charset=UTF-8" \
172
- --data-raw "{\"title\":\"${title//\"/\\\"}\",\"content\":\"${content//\"/\\\"}\"}" \
173
- --compressed
174
- )
198
+ local api=$(ql_api_request \
199
+ "http://localhost:${ql_port}/open/system/notify?t=$currentTimeStamp" \
200
+ -X PUT \
201
+ --data-raw "{\"title\":\"${title//\"/\\\"}\",\"content\":\"${content//\"/\\\"}\"}")
175
202
  code=$(echo "$api" | jq -r .code)
176
203
  message=$(echo "$api" | jq -r .message)
177
204
  if [[ $code == 200 ]]; then
@@ -184,12 +211,9 @@ notify_api() {
184
211
  find_cron_api() {
185
212
  local params="$1"
186
213
  local currentTimeStamp=$(date +%s)
187
- local api=$(
188
- curl -s --noproxy "*" "http://localhost:${ql_port}/open/crons/detail?$params&t=$currentTimeStamp" \
189
- -H "Authorization: Bearer ${__ql_token__}" \
190
- -H "Content-Type: application/json;charset=UTF-8" \
191
- --compressed
192
- )
214
+ local api=$(ql_api_request \
215
+ "http://localhost:${ql_port}/open/crons/detail?$params&t=$currentTimeStamp" \
216
+ -X GET)
193
217
  data=$(echo "$api" | jq -r .data)
194
218
  if [[ $data == 'null' ]]; then
195
219
  echo -e ""
@@ -203,14 +227,10 @@ update_auth_config() {
203
227
  local body="$1"
204
228
  local tip="$2"
205
229
  local currentTimeStamp=$(date +%s)
206
- local api=$(
207
- curl -s --noproxy "*" "http://localhost:${ql_port}/open/system/auth/reset?t=$currentTimeStamp" \
208
- -X 'PUT' \
209
- -H "Authorization: Bearer ${__ql_token__}" \
210
- -H "Content-Type: application/json;charset=UTF-8" \
211
- --data-raw "{$body}" \
212
- --compressed
213
- )
230
+ local api=$(ql_api_request \
231
+ "http://localhost:${ql_port}/open/system/auth/reset?t=$currentTimeStamp" \
232
+ -X PUT \
233
+ --data-raw "{$body}")
214
234
  code=$(echo "$api" | jq -r .code)
215
235
  message=$(echo "$api" | jq -r .message)
216
236
  if [[ $code == 200 ]]; then
@@ -226,16 +246,11 @@ record_cron_stat() {
226
246
  local elapsed="${3:-0}"
227
247
  [[ $ref_id ]] && [[ $ref_id -gt 0 ]] 2>/dev/null || return
228
248
 
229
- local api=$(
230
- curl -s --noproxy "*" "http://localhost:${ql_port:-5700}/open/dashboard/record" \
249
+ local api=$(ql_api_request \
250
+ "http://localhost:${ql_port:-5700}/open/dashboard/record" \
231
251
  -X POST \
232
- -H "Authorization: Bearer ${__ql_token__}" \
233
- -H "Content-Type: application/json;charset=UTF-8" \
234
- --data-raw "{\"ref_id\":$ref_id,\"code\":$exit_code,\"elapsed\":$elapsed}" \
235
- --compressed
236
- )
237
- code=$(echo "$api" | jq -r .code)
238
- message=$(echo "$api" | jq -r .message)
252
+ --data-raw "{\"ref_id\":$ref_id,\"code\":$exit_code,\"elapsed\":$elapsed}")
253
+ ql_parse_status_response "$api" || true
239
254
  if [[ $code != 200 ]]; then
240
255
  if [[ ! $message ]]; then
241
256
  message="$api"
@@ -243,5 +258,3 @@ record_cron_stat() {
243
258
  echo -e "${message}"
244
259
  fi
245
260
  }
246
-
247
- get_token
package/shell/check.sh CHANGED
@@ -23,50 +23,90 @@ copy_dep() {
23
23
  }
24
24
 
25
25
  pm2_log() {
26
- t '---> pm2日志'
27
- local panelOut="/root/.pm2/logs/qinglong-out.log"
28
- local panelError="/root/.pm2/logs/qinglong-error.log"
29
- tail -n 300 "$panelOut"
30
- tail -n 300 "$panelError"
26
+ t '---> 服务诊断信息'
27
+ pm2 status || true
28
+
29
+ local systemLogDir="$dir_data/syslog"
30
+ local latestSystemLog
31
+ latestSystemLog=$(find "$systemLogDir" -maxdepth 1 -type f -name '*.log' 2>/dev/null | sort | tail -n 1)
32
+ if [[ -n "$latestSystemLog" ]]; then
33
+ t '---> 最近的系统日志: %s' "$latestSystemLog"
34
+ tail -n 300 "$latestSystemLog"
35
+ else
36
+ t '---> 未找到系统日志: %s' "$systemLogDir"
37
+ fi
38
+
39
+ if [[ "$QL_CONTAINER" == "true" ]]; then
40
+ t '---> 容器内 PM2 日志不落盘;早期启动错误请执行 docker logs --tail 300 <容器名>'
41
+ return
42
+ fi
43
+
44
+ local pm2Home="${PM2_HOME:-$HOME/.pm2}"
45
+ local panelOut="$pm2Home/logs/qinglong-out.log"
46
+ local panelError="$pm2Home/logs/qinglong-error.log"
47
+ [[ -f "$panelOut" ]] && tail -n 300 "$panelOut"
48
+ [[ -f "$panelError" ]] && tail -n 300 "$panelError"
31
49
  }
32
50
 
33
51
  check_ql() {
34
- local api=$(curl -s --noproxy "*" "http://localhost:${ql_port}")
52
+ local basePath="${ql_base_url%/}"
53
+ local api
54
+ local attempt
55
+ for ((attempt = 1; attempt <= 10; attempt++)); do
56
+ api=$(curl -s --max-time 2 --noproxy "*" "http://localhost:${ql_port}${basePath}/")
57
+ [[ $api =~ "<div id=\"root\"></div>" ]] && break
58
+ sleep 1
59
+ done
35
60
  t '\n=====> 检测面板'
36
61
  echo -e "\n\n$api\n"
37
62
  if [[ $api =~ "<div id=\"root\"></div>" ]]; then
38
63
  t '=====> 面板服务启动正常\n'
64
+ else
65
+ t '=====> 面板服务启动异常,请检查上方诊断信息\n'
66
+ return 1
39
67
  fi
40
68
  }
41
69
 
42
70
  check_pm2() {
43
- pm2_log
44
71
  local currentTimeStamp=$(date +%s)
45
- local api=$(
46
- curl -s --noproxy "*" "http://localhost:${ql_port}/api/system?t=$currentTimeStamp" \
47
- -H 'Accept: */*' \
48
- -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36' \
49
- -H "Referer: http://localhost:${ql_port}/crontab" \
50
- -H 'Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7' \
51
- --compressed
52
- )
72
+ local basePath="${ql_base_url%/}"
73
+ local api
74
+ local attempt
75
+ for ((attempt = 1; attempt <= 10; attempt++)); do
76
+ api=$(
77
+ curl -s --max-time 2 --noproxy "*" "http://localhost:${ql_port}${basePath}/api/health?t=$currentTimeStamp" \
78
+ -H 'Accept: */*' \
79
+ -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36' \
80
+ -H "Referer: http://localhost:${ql_port}/crontab" \
81
+ -H 'Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7' \
82
+ --compressed
83
+ )
84
+ [[ $api == *'"code":200'* && $api == *'"status":"ok"'* ]] && break
85
+ sleep 1
86
+ done
53
87
  t '\n=====> 检测后台'
54
88
  echo -e "\n\n$api\n"
55
- if [[ $api =~ "{\"code\"" ]]; then
89
+ if [[ $api == *'"code":200'* && $api == *'"status":"ok"'* ]]; then
56
90
  t '=====> 后台服务启动正常\n'
91
+ else
92
+ pm2_log
93
+ t '=====> 后台服务启动异常,请检查上方诊断信息\n'
94
+ return 1
57
95
  fi
58
96
  }
59
97
 
60
98
  main() {
61
99
  t '=====> 开始检测'
62
- npm i -g pnpm@8.3.1 pm2 ts-node
100
+ npm i -g pnpm@8.3.1 pm2 ts-node typescript@5
63
101
 
64
102
  reset_env
65
103
  copy_dep
66
- check_ql
67
- check_pm2
68
104
  reload_pm2
105
+ local checkStatus=0
106
+ check_ql || checkStatus=1
107
+ check_pm2 || checkStatus=1
69
108
  t '\n=====> 检测结束\n'
109
+ return $checkStatus
70
110
  }
71
111
 
72
112
  main
package/shell/lang/en.sh CHANGED
@@ -82,10 +82,16 @@ declare -gA LANG_MESSAGES=(
82
82
  ['---> 复制一份 %s 为 %s\n']='---> Copying %s to %s\n'
83
83
  ['---> 通知文件复制完成\n']='---> Notification files copied\n'
84
84
  ['---> pm2日志']='---> pm2 log'
85
+ ['---> 服务诊断信息']='---> Service diagnostics'
86
+ ['---> 最近的系统日志: %s']='---> Recent system log: %s'
87
+ ['---> 未找到系统日志: %s']='---> No system log found: %s'
88
+ ['---> 容器内 PM2 日志不落盘;早期启动错误请执行 docker logs --tail 300 <容器名>']='---> PM2 logs are not persisted in containers; run docker logs --tail 300 <container> for early startup errors'
85
89
  ['\n=====> 检测面板']='\n=====> Checking panel'
86
90
  ['=====> 面板服务启动正常\n']='=====> Panel service running normally\n'
91
+ ['=====> 面板服务启动异常,请检查上方诊断信息\n']='=====> Panel failed to start; check the diagnostics above\n'
87
92
  ['\n=====> 检测后台']='\n=====> Checking backend'
88
93
  ['=====> 后台服务启动正常\n']='=====> Backend service running normally\n'
94
+ ['=====> 后台服务启动异常,请检查上方诊断信息\n']='=====> Backend failed to start; check the diagnostics above\n'
89
95
  ['=====> 开始检测']='=====> Starting check'
90
96
  ['\n=====> 检测结束\n']='\n=====> Check complete\n'
91
97
  # rmlog.sh
package/shell/lang/zh.sh CHANGED
@@ -82,10 +82,16 @@ declare -gA LANG_MESSAGES=(
82
82
  ['---> 复制一份 %s 为 %s\n']='---> 复制一份 %s 为 %s\n'
83
83
  ['---> 通知文件复制完成\n']='---> 通知文件复制完成\n'
84
84
  ['---> pm2日志']='---> pm2日志'
85
+ ['---> 服务诊断信息']='---> 服务诊断信息'
86
+ ['---> 最近的系统日志: %s']='---> 最近的系统日志: %s'
87
+ ['---> 未找到系统日志: %s']='---> 未找到系统日志: %s'
88
+ ['---> 容器内 PM2 日志不落盘;早期启动错误请执行 docker logs --tail 300 <容器名>']='---> 容器内 PM2 日志不落盘;早期启动错误请执行 docker logs --tail 300 <容器名>'
85
89
  ['\n=====> 检测面板']='\n=====> 检测面板'
86
90
  ['=====> 面板服务启动正常\n']='=====> 面板服务启动正常\n'
91
+ ['=====> 面板服务启动异常,请检查上方诊断信息\n']='=====> 面板服务启动异常,请检查上方诊断信息\n'
87
92
  ['\n=====> 检测后台']='\n=====> 检测后台'
88
93
  ['=====> 后台服务启动正常\n']='=====> 后台服务启动正常\n'
94
+ ['=====> 后台服务启动异常,请检查上方诊断信息\n']='=====> 后台服务启动异常,请检查上方诊断信息\n'
89
95
  ['=====> 开始检测']='=====> 开始检测'
90
96
  ['\n=====> 检测结束\n']='\n=====> 检测结束\n'
91
97
  # rmlog.sh
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Cache discovery only, never the installed packages. Ordinary installs at the
4
+ # same root are visible immediately. TTL bounds changes outside known inputs.
5
+ ql_node_path_cache_key() {
6
+ local pnpm_bin node_bin name directory file
7
+ pnpm_bin=$(type -P pnpm) || return 1
8
+ node_bin=$(type -P node) || return 1
9
+ {
10
+ printf '%s\n' 'v1' "$EUID" "$PWD" "$PATH" "${HOME:-}" \
11
+ "${PNPM_HOME:-}" "${XDG_CONFIG_HOME:-}" "${XDG_DATA_HOME:-}" \
12
+ "$pnpm_bin" "$node_bin"
13
+ for name in ${!npm_config_@} ${!NPM_CONFIG_@}; do
14
+ printf '%s=%s\n' "$name" "${!name}"
15
+ done
16
+ # Follow executable symlinks, detecting upgrades at the same command path.
17
+ stat -Lc '%n:%i:%s:%Y:%Z' "$pnpm_bin" "$node_bin" 2>/dev/null || \
18
+ stat -Lf '%N:%i:%z:%m:%c' "$pnpm_bin" "$node_bin" 2>/dev/null
19
+ directory=$PWD
20
+ while :; do
21
+ for file in "$directory/.npmrc" "$directory/pnpm-workspace.yaml"; do
22
+ if [[ -f "$file" ]]; then
23
+ printf '%s\n' "$file"
24
+ cat -- "$file"
25
+ printf '\n'
26
+ fi
27
+ done
28
+ [[ "$directory" == / ]] && break
29
+ directory=${directory%/*}
30
+ [[ -n "$directory" ]] || directory=/
31
+ done
32
+ for file in "${HOME:-}/.npmrc" \
33
+ "${XDG_CONFIG_HOME:-${HOME:-}/.config}/pnpm/rc" \
34
+ "${npm_config_userconfig:-${NPM_CONFIG_USERCONFIG:-/dev/null}}" \
35
+ "${npm_config_globalconfig:-${NPM_CONFIG_GLOBALCONFIG:-/dev/null}}"; do
36
+ if [[ -f "$file" ]]; then
37
+ printf '%s\n' "$file"
38
+ cat -- "$file"
39
+ printf '\n'
40
+ fi
41
+ done
42
+ } | cksum
43
+ }
44
+
45
+ ql_read_node_path_cache() {
46
+ local cache="$1" key="$2" now
47
+ local stored_key="" stored_at="" stored_path=""
48
+ now=${EPOCHSECONDS:-$(date +%s)}
49
+ if [[ -f "$cache" && ! -L "$cache" && -O "$cache" ]]; then
50
+ if ! {
51
+ IFS= read -r stored_key && IFS= read -r stored_at && IFS= read -r stored_path
52
+ } < "$cache"; then
53
+ return 1
54
+ fi
55
+ if [[ "$stored_key" == "$key" && "$stored_at" =~ ^(0|[1-9][0-9]{0,10})$ && "$stored_path" == /* ]] && \
56
+ (( now >= stored_at && now - stored_at < 60 )); then
57
+ printf '%s\n' "$stored_path"
58
+ return 0
59
+ fi
60
+ fi
61
+ return 1
62
+ }
63
+
64
+ # Keep the lock descriptor in a subshell so sourcing this helper never changes
65
+ # the caller's descriptors. A crashed refresher releases the kernel lock.
66
+ ql_refresh_node_global_path() (
67
+ local cache="$1" key="$2" now result previous_umask
68
+ # Keep one persistent lock per owner. Removing per-key lock files could
69
+ # split concurrent waiters across different inodes during cache cleanup.
70
+ local lock="${dir_tmp}/pnpm-root-${EUID}.lock"
71
+ previous_umask=$(umask)
72
+ umask 077
73
+ if type -P flock &>/dev/null && mkdir -p -- "$dir_tmp" 2>/dev/null; then
74
+ if [[ ! -L "$lock" && ( ! -e "$lock" || ( -f "$lock" && -O "$lock" ) ) ]] && \
75
+ { exec 9>> "$lock"; } 2>/dev/null; then
76
+ # BusyBox flock (Alpine) has no -w. Both implementations support -n;
77
+ # bound contention retries and fall back immediately on other failures.
78
+ # Never remove the lock file while waiters exist.
79
+ local lock_attempt=0 lock_status
80
+ while :; do
81
+ if flock -n 9 2>/dev/null; then
82
+ if ql_read_node_path_cache "$cache" "$key"; then
83
+ return 0
84
+ fi
85
+ break
86
+ else
87
+ lock_status=$?
88
+ fi
89
+ [[ "$lock_status" == 1 && "$lock_attempt" -lt 20 ]] || break
90
+ lock_attempt=$((lock_attempt + 1))
91
+ sleep 0.1
92
+ done
93
+ fi
94
+ fi
95
+
96
+ # Private lock creation must not change pnpm's inherited creation mask.
97
+ umask "$previous_umask"
98
+ # Warm lookups never scan the directory. Retire old environment records on
99
+ # refresh, while preserving the shared lock and unrelated cache files.
100
+ find "$dir_tmp" -maxdepth 1 -type f -user "$EUID" \
101
+ -name "pnpm-root-${EUID}-*.cache" -mmin +60 -delete 2>/dev/null || true
102
+ now=${EPOCHSECONDS:-$(date +%s)}
103
+ result=$(pnpm root -g 9>&- 2>/dev/null) || return $?
104
+ # Never cache failed, empty, multiline or non-absolute answers.
105
+ if [[ "$result" == /* && "$result" != *$'\n'* && "$result" != *$'\r'* ]]; then
106
+ (
107
+ umask 077
108
+ mkdir -p -- "$dir_tmp" || exit 0
109
+ local temporary
110
+ temporary=$(mktemp "${cache}.XXXXXX") || exit 0
111
+ if printf '%s\n%s\n%s\n' "$key" "$now" "$result" > "$temporary"; then
112
+ mv -f -- "$temporary" "$cache" || rm -f -- "$temporary"
113
+ else
114
+ rm -f -- "$temporary"
115
+ fi
116
+ ) 2>/dev/null
117
+ fi
118
+ printf '%s\n' "$result"
119
+ )
120
+
121
+ ql_get_node_global_path() {
122
+ if [[ "${QL_NODE_PATH_CACHE:-1}" == 0 ]]; then
123
+ pnpm root -g 2>/dev/null
124
+ return $?
125
+ fi
126
+
127
+ local key cache
128
+ key=$(ql_node_path_cache_key) || { pnpm root -g 2>/dev/null; return $?; }
129
+ # Node and crond may have different working directories/configuration.
130
+ # Preserve both discoveries instead of evicting each other on every run.
131
+ cache="${dir_tmp}/pnpm-root-${EUID}-${key// /-}.cache"
132
+ if ql_read_node_path_cache "$cache" "$key"; then
133
+ return 0
134
+ fi
135
+ ql_refresh_node_global_path "$cache" "$key"
136
+ }
package/shell/otask.sh CHANGED
@@ -84,7 +84,9 @@ env_str_to_array() {
84
84
  }
85
85
 
86
86
  clear_non_sh_env() {
87
- if [[ $file_param != *.sh ]]; then
87
+ # Only automatic Node/Python preloads reconstruct the generated environment.
88
+ # Explicit interpreters and other commands must keep the shell-loaded values.
89
+ if [[ $isJsOrPythonFile == 'true' ]]; then
88
90
  clear_env
89
91
  fi
90
92
  }
@@ -92,7 +94,16 @@ clear_non_sh_env() {
92
94
  append_node_dependency_path() {
93
95
  export PREV_NODE_PATH="${NODE_PATH:=}"
94
96
 
95
- local pnpm_global_path=$(pnpm root -g 2>/dev/null)
97
+ # 用户依赖目录加入 NODE_PATH,替代 symlink 到 node_modules 的方式
98
+ export NODE_PATH="${NODE_PATH:+${NODE_PATH}:}${dir_dep}"
99
+
100
+ local pnpm_global_path
101
+ if [[ -f "$dir_shell/node_path_cache.sh" ]]; then
102
+ . "$dir_shell/node_path_cache.sh"
103
+ pnpm_global_path=$(ql_get_node_global_path) || true
104
+ else
105
+ pnpm_global_path=$(pnpm root -g 2>/dev/null) || true
106
+ fi
96
107
  if [[ -n "$pnpm_global_path" ]]; then
97
108
  export QL_NODE_GLOBAL_PATH="$pnpm_global_path"
98
109
  export NODE_PATH="${NODE_PATH:+${NODE_PATH}:}${pnpm_global_path}"
@@ -153,7 +164,7 @@ run_normal() {
153
164
  if [[ $isJsOrPythonFile == 'false' ]]; then
154
165
  clear_non_sh_env
155
166
  fi
156
- $timeoutCmd $which_program $file_param "${script_params[@]}"
167
+ run_task_command $which_program $file_param "${script_params[@]}"
157
168
  }
158
169
 
159
170
  handle_env_split() {
@@ -192,7 +203,7 @@ run_concurrent() {
192
203
  export "${env_param}=${array[$i - 1]}"
193
204
  clear_non_sh_env
194
205
  fi
195
- eval envParam="${env_param}" numParam="${i}" $timeoutCmd $which_program $file_param "${script_params[@]}" &>$single_log_path &
206
+ eval envParam="${env_param}" numParam="${i}" run_task_command $which_program $file_param "${script_params[@]}" &>$single_log_path &
196
207
  done
197
208
 
198
209
  wait
@@ -232,7 +243,7 @@ run_designated() {
232
243
 
233
244
  enter_script_workdir
234
245
 
235
- envParam="${env_param}" numParam="${num_param}" $timeoutCmd $which_program $file_param "${script_params[@]}"
246
+ envParam="${env_param}" numParam="${num_param}" run_task_command $which_program $file_param "${script_params[@]}"
236
247
  }
237
248
 
238
249
  ## 运行其他命令
@@ -288,7 +299,7 @@ run_else() {
288
299
  fi
289
300
 
290
301
  clear_non_sh_env
291
- $timeoutCmd $which_program $file_param "$@"
302
+ run_task_command $which_program $file_param "$@"
292
303
  }
293
304
 
294
305
  check_file() {
@@ -325,10 +336,6 @@ check_nounset() {
325
336
 
326
337
  main() {
327
338
  if [[ $1 == *.js ]] || [[ $1 == *.mjs ]] || [[ $1 == *.py ]] || [[ $1 == *.pyc ]] || [[ $1 == *.sh ]] || [[ $1 == *.ts ]]; then
328
- if [[ $1 == *.sh ]]; then
329
- timeoutCmd=""
330
- fi
331
-
332
339
  case $# in
333
340
  1)
334
341
  run_normal "$1"