aaden-cli 1.6.118 → 1.6.119

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.
@@ -4,6 +4,8 @@
4
4
  #
5
5
  # light-update 只发 PHP/,AppCenter 以前只能跟 465MB 的 latest.zip 走;这里单独按应用同步。
6
6
  # - 灰度门:manifest 的 rollout = {"devices":[...], "percent":N},本机在名单里或 deviceId%100 < N 才动;没有 rollout = 全量
7
+ # - 按应用灰度:manifest 带 perAppRollout=true 时,每个应用按自己的 apps.<App>.rollout 判断(没有 = 全量),
8
+ # 顶层 rollout 只管 ensureNoCache;老版本 CLI 不认 perAppRollout,照旧整体按顶层 rollout
7
9
  # - ensureNoCache:manifest 打开时先确保 AppCenter 的 index.html 带 no-cache(ensureAppCenterNoCache.sh)
8
10
  # - manifest 门:本机 .appcenter-manifest 的 sha256 == manifest 的 treeSha256 且 `sha256sum -c` 通过 → 什么都不做,
9
11
  # 每天只花一次几 KB 的请求。被 latest.zip 全量覆盖过、文件对不上 → 校验失败 → 重新铺一遍(自愈)
@@ -19,7 +21,7 @@
19
21
  # APPCENTER_DEVICE_ID 本机 deviceId(CLI 会传);不传就问本机 PHP
20
22
  # APPCENTER_RESULT 结果行另存的文件(CLI 会传)
21
23
  # 结果行(同时写进 $RESULT 给 CLI 上报):APP_OK <App> <sha12> | APP_UP_TO_DATE <App> | APP_SKIP <App> <原因> |
22
- # APP_ROLLED_BACK <App> | APP_ABORT_* <App> | NOCACHE_* | SKIP_ROLLOUT | SKIP_DEPS | SKIP_LOCKED | ABORT_*
24
+ # APP_ROLLED_BACK <App> | APP_ABORT_* <App> | APP_SKIP_ROLLOUT <App> | NOCACHE_* | SKIP_ROLLOUT | SKIP_DEPS | SKIP_LOCKED | ABORT_*
23
25
  # 退出码:0=全部成功、无需更新或不在灰度内;1=有失败(失败的已回滚或未动线上目录)
24
26
  set -uo pipefail
25
27
  BASE="${APPCENTER_BASE:-https://aaden-backend.s3.eu-central-1.amazonaws.com/appcenter}"
@@ -48,21 +50,29 @@ flock -n 9 || { res "SKIP_LOCKED"; exit 0; }
48
50
 
49
51
  MANIFEST=$(curl -fsSL --max-time 30 "$BASE/$CHANNEL/manifest.json") \
50
52
  || { echo "取不到 $BASE/$CHANNEL/manifest.json"; res "ABORT_MANIFEST"; exit 1; }
51
- # 读 manifest:mf apps.Admin.zip / mf ensureNoCache / mf eligible <deviceId>
53
+ # 读 manifest:mf apps.Admin.zip / mf ensureNoCache / mf eligible <deviceId> / mf eligible_app <App> <deviceId>
52
54
  mf(){
53
55
  printf '%s' "$MANIFEST" | python3 -c '
54
56
  import json, sys
55
57
  m = json.load(sys.stdin)
56
- if sys.argv[1] == "eligible":
57
- r = m.get("rollout")
58
+ def gate(r, dev):
58
59
  if r is None:
59
- print("yes"); sys.exit()
60
+ return "yes"
60
61
  try:
61
- d = int(sys.argv[2])
62
+ d = int(dev)
62
63
  except ValueError:
63
- print("no"); sys.exit()
64
+ return "no"
64
65
  ok = d in [int(x) for x in r.get("devices", [])] or d % 100 < int(r.get("percent", 0))
65
- print("yes" if ok else "no"); sys.exit()
66
+ return "yes" if ok else "no"
67
+ if sys.argv[1] == "eligible":
68
+ print(gate(m.get("rollout"), sys.argv[2])); sys.exit()
69
+ if sys.argv[1] == "eligible_app":
70
+ if m.get("perAppRollout") is True:
71
+ app = (m.get("apps") or {}).get(sys.argv[2]) or {}
72
+ print(gate(app.get("rollout"), sys.argv[3]))
73
+ else:
74
+ print(gate(m.get("rollout"), sys.argv[3]))
75
+ sys.exit()
66
76
  v = m
67
77
  for k in sys.argv[1].split("."):
68
78
  v = v.get(k) if isinstance(v, dict) else None
@@ -76,13 +86,14 @@ if [ -z "$DEVICE_ID" ] || [ "$DEVICE_ID" = "-1" ]; then
76
86
  DEVICE_ID=$(curl -s --max-time 10 "http://localhost/PHP/AccessLog.php?op=deviceId" \
77
87
  | python3 -c 'import json,sys; print(json.load(sys.stdin).get("content",""))' 2>/dev/null)
78
88
  fi
79
- if [ "$(mf eligible "${DEVICE_ID:-x}")" != "yes" ]; then
89
+ TOP_ELIGIBLE=$(mf eligible "${DEVICE_ID:-x}")
90
+ if [ "$TOP_ELIGIBLE" != "yes" ] && [ "$(mf perAppRollout)" != "true" ]; then
80
91
  res "SKIP_ROLLOUT device=${DEVICE_ID:-?}"; exit 0
81
92
  fi
82
93
 
83
94
  FAILED=0
84
95
  # ---- index.html no-cache(先于换前端:让之后拿到的 index.html 都不再被启发式缓存)----
85
- if [ "$(mf ensureNoCache)" = "true" ]; then
96
+ if [ "$TOP_ELIGIBLE" = "yes" ] && [ "$(mf ensureNoCache)" = "true" ]; then
86
97
  NC=$(bash "$HERE/ensureAppCenterNoCache.sh"); NC_CODE=$?
87
98
  printf '%s\n' "$NC" | sed '$d'
88
99
  res "$(printf '%s\n' "$NC" | tail -1)"
@@ -101,6 +112,7 @@ sync_app(){
101
112
  local APP="$1" LIVE="$WEB/$1" NEW="$STAGE/$1" TREE ZIP ZSHA
102
113
  TREE=$(mf "apps.$APP.treeSha256"); ZIP=$(mf "apps.$APP.zip"); ZSHA=$(mf "apps.$APP.zipSha256")
103
114
  if [ -z "$TREE" ]; then res "APP_SKIP $APP 不在manifest里"; return 0; fi
115
+ if [ "$(mf eligible_app "$APP" "${DEVICE_ID:-x}")" != "yes" ]; then res "APP_SKIP_ROLLOUT $APP"; return 0; fi
104
116
  # manifest 来自网络:只接受预期格式,防止路径穿越
105
117
  if ! [[ "$TREE" =~ ^[0-9a-f]{64}$ && "$ZSHA" =~ ^[0-9a-f]{64}$ && "$ZIP" =~ ^blobs/[A-Za-z0-9._-]+\.zip$ ]]; then
106
118
  res "APP_ABORT_BAD_MANIFEST $APP"; return 1
package/dist/index.js CHANGED
@@ -19246,7 +19246,7 @@ module.exports = JSON.parse('{"name":"axios","version":"0.19.2","description":"P
19246
19246
  /***/ ((module) => {
19247
19247
 
19248
19248
  "use strict";
19249
- module.exports = {"i8":"1.6.118"};
19249
+ module.exports = {"i8":"1.6.119"};
19250
19250
 
19251
19251
  /***/ })
19252
19252
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aaden-cli",
3
- "version": "1.6.118",
3
+ "version": "1.6.119",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {