"添加前端模板和运行代码模块"
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# 这个脚本用于 beta 发布前演练,不会执行真实 npm publish。
|
||||
# 目标是提前发现“构建、打包内容、依赖声明、发布前校验”类问题。
|
||||
#
|
||||
# 演练内容:
|
||||
# 1) 运行 release-preflight(registry / 版本一致 / workspace 协议)
|
||||
# 2) 构建所有包
|
||||
# 3) 在每个发布包目录执行 npm publish --dry-run --tag beta,检查将发布的 tarball 内容
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
echo "[dry-run-beta] step 1/3: preflight checks..."
|
||||
bash ./scripts/release-preflight.sh
|
||||
|
||||
echo "[dry-run-beta] step 2/3: build all packages..."
|
||||
pnpm -r --filter './packages/**' build
|
||||
|
||||
echo "[dry-run-beta] step 3/3: simulate npm publish (beta tag)..."
|
||||
(
|
||||
cd packages/client-shared
|
||||
npm publish --access=public --tag beta --dry-run
|
||||
)
|
||||
(
|
||||
cd packages/client-react
|
||||
npm publish --access=public --tag beta --dry-run
|
||||
)
|
||||
(
|
||||
cd packages/client-vue
|
||||
npm publish --access=public --tag beta --dry-run
|
||||
)
|
||||
(
|
||||
cd packages/plugin
|
||||
npm publish --access=public --tag beta --dry-run
|
||||
)
|
||||
|
||||
echo "[dry-run-beta] done. no package was actually published."
|
||||
40
qiming-vite-plugin-design-mode/scripts/release-dry-run.sh
Normal file
40
qiming-vite-plugin-design-mode/scripts/release-dry-run.sh
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# 这个脚本用于发布前演练,不会执行真实 npm publish。
|
||||
# 目标是提前发现“构建、打包内容、依赖声明、发布前校验”类问题。
|
||||
#
|
||||
# 演练内容:
|
||||
# 1) 运行 release-preflight(registry / 版本一致 / workspace 协议)
|
||||
# 2) 构建所有包
|
||||
# 3) 在每个发布包目录执行 npm publish --dry-run,检查将发布的 tarball 内容
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
echo "[dry-run] step 1/3: preflight checks..."
|
||||
bash ./scripts/release-preflight.sh
|
||||
|
||||
echo "[dry-run] step 2/3: build all packages..."
|
||||
pnpm -r --filter './packages/**' build
|
||||
|
||||
echo "[dry-run] step 3/3: simulate npm publish..."
|
||||
(
|
||||
cd packages/client-shared
|
||||
npm publish --access=public --tag next --dry-run
|
||||
)
|
||||
(
|
||||
cd packages/client-react
|
||||
npm publish --access=public --tag next --dry-run
|
||||
)
|
||||
(
|
||||
cd packages/client-vue
|
||||
npm publish --access=public --tag next --dry-run
|
||||
)
|
||||
(
|
||||
cd packages/plugin
|
||||
npm publish --access=public --tag next --dry-run
|
||||
)
|
||||
|
||||
echo "[dry-run] done. no package was actually published."
|
||||
62
qiming-vite-plugin-design-mode/scripts/release-preflight.sh
Normal file
62
qiming-vite-plugin-design-mode/scripts/release-preflight.sh
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# 这个脚本用于发布前的硬性校验。
|
||||
# 设计目标:尽量在真正 npm publish 之前发现问题,避免发布一半才失败。
|
||||
#
|
||||
# 校验项:
|
||||
# 1) 当前 npm registry 必须是 npmjs 官方源(防止发到镜像源)
|
||||
# 2) 根包与 4 个发布包版本号必须完全一致(统一版本策略)
|
||||
# 3) 发布包 package.json 中禁止出现 workspace:*(外部安装无法解析)
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
echo "[preflight] checking npm registry..."
|
||||
REGISTRY="$(npm config get registry)"
|
||||
if [[ "$REGISTRY" != "https://registry.npmjs.org/" ]]; then
|
||||
echo "[preflight] error: registry is '$REGISTRY', expected 'https://registry.npmjs.org/'"
|
||||
echo "[preflight] hint: run 'nrm use npm' first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[preflight] checking version consistency..."
|
||||
node <<'NODE'
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const root = process.cwd();
|
||||
const packageFiles = [
|
||||
"package.json",
|
||||
"packages/client-shared/package.json",
|
||||
"packages/client-react/package.json",
|
||||
"packages/client-vue/package.json",
|
||||
"packages/plugin/package.json",
|
||||
];
|
||||
|
||||
const versions = packageFiles.map((file) => {
|
||||
const pkg = JSON.parse(fs.readFileSync(path.join(root, file), "utf8"));
|
||||
return { file, version: pkg.version };
|
||||
});
|
||||
|
||||
const uniqueVersions = [...new Set(versions.map((item) => item.version))];
|
||||
if (uniqueVersions.length !== 1) {
|
||||
console.error("[preflight] error: versions are not aligned:");
|
||||
for (const item of versions) {
|
||||
console.error(` - ${item.file}: ${item.version}`);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`[preflight] version aligned: ${uniqueVersions[0]}`);
|
||||
NODE
|
||||
|
||||
echo "[preflight] checking workspace protocol leakage..."
|
||||
if rg "workspace:\\*" packages/*/package.json >/dev/null; then
|
||||
echo "[preflight] error: found 'workspace:*' in publishable package dependencies."
|
||||
echo "[preflight] hint: replace with explicit semver before publish."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[preflight] all checks passed."
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# 这个脚本按依赖拓扑发布到 npm beta tag。
|
||||
# 发布顺序不能乱:
|
||||
# 1) shared 必须先发布(react/vue/plugin 都依赖它)
|
||||
# 2) react 与 vue 互不依赖,可以并发发布提升速度
|
||||
# 3) plugin 最后发布(依赖 shared + react + vue)
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
echo "[publish-beta] publishing @xagi/design-mode-shared..."
|
||||
(
|
||||
cd packages/client-shared
|
||||
npm publish --access=public --tag beta
|
||||
)
|
||||
|
||||
echo "[publish-beta] publishing @xagi/design-mode-client-react and @xagi/design-mode-client-vue in parallel..."
|
||||
(
|
||||
cd packages/client-react
|
||||
npm publish --access=public --tag beta
|
||||
) &
|
||||
PID_REACT=$!
|
||||
|
||||
(
|
||||
cd packages/client-vue
|
||||
npm publish --access=public --tag beta
|
||||
) &
|
||||
PID_VUE=$!
|
||||
|
||||
wait "$PID_REACT"
|
||||
wait "$PID_VUE"
|
||||
|
||||
echo "[publish-beta] publishing @xagi/vite-plugin-design-mode..."
|
||||
(
|
||||
cd packages/plugin
|
||||
npm publish --access=public --tag beta
|
||||
)
|
||||
|
||||
echo "[publish-beta] done."
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# 这个脚本按依赖拓扑发布到 npm next tag。
|
||||
# 发布顺序不能乱:
|
||||
# 1) shared 必须先发布(react/vue/plugin 都依赖它)
|
||||
# 2) react 与 vue 互不依赖,可以并发发布提升速度
|
||||
# 3) plugin 最后发布(依赖 shared + react + vue)
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
echo "[publish-next] publishing @xagi/design-mode-shared..."
|
||||
(
|
||||
cd packages/client-shared
|
||||
npm publish --access=public --tag next
|
||||
)
|
||||
|
||||
echo "[publish-next] publishing @xagi/design-mode-client-react and @xagi/design-mode-client-vue in parallel..."
|
||||
(
|
||||
cd packages/client-react
|
||||
npm publish --access=public --tag next
|
||||
) &
|
||||
PID_REACT=$!
|
||||
|
||||
(
|
||||
cd packages/client-vue
|
||||
npm publish --access=public --tag next
|
||||
) &
|
||||
PID_VUE=$!
|
||||
|
||||
wait "$PID_REACT"
|
||||
wait "$PID_VUE"
|
||||
|
||||
echo "[publish-next] publishing @xagi/vite-plugin-design-mode..."
|
||||
(
|
||||
cd packages/plugin
|
||||
npm publish --access=public --tag next
|
||||
)
|
||||
|
||||
echo "[publish-next] done."
|
||||
echo ""
|
||||
echo "[publish-next] --- 给集成方 / 模板维护者(复制即可)---"
|
||||
echo " pnpm add @xagi/vite-plugin-design-mode@next -D"
|
||||
echo " 请勿在 README 中写死 beta.N;next 即当前灰度线。"
|
||||
echo "[publish-next] ---"
|
||||
198
qiming-vite-plugin-design-mode/scripts/release-sync-npmmirror.sh
Normal file
198
qiming-vite-plugin-design-mode/scripts/release-sync-npmmirror.sh
Normal file
@@ -0,0 +1,198 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# 手动触发 npmmirror 同步(适用于当前 monorepo 的 4 个发布包)。
|
||||
#
|
||||
# 目标:
|
||||
# 1) 发布完成后,主动触发 npmmirror 拉取 npm 官方源的最新包元数据与 tarball
|
||||
# 2) 可选做只读校验,确认镜像上是否已经可见指定版本
|
||||
#
|
||||
# 接口:
|
||||
# PUT https://registry.npmmirror.com/<包名>/sync
|
||||
#
|
||||
# 模式:
|
||||
# 默认 sync - 对目标包执行 PUT .../sync
|
||||
# --dry dry - 仅打印将调用的 URL,不发请求
|
||||
# --check check - 不发 PUT,仅检查镜像 registry 是否已有该版本
|
||||
#
|
||||
# 包列表:
|
||||
# - 不传包名:使用默认 4 包(shared/react/vue/plugin)
|
||||
# - 传包名参数:仅处理传入包名(可多个)
|
||||
#
|
||||
# 环境变量:
|
||||
# NPM_MIRROR_VERSION 目标版本;未设置时读取根 package.json version
|
||||
# NPM_MIRROR_REGISTRY 镜像 registry;默认 https://registry.npmmirror.com
|
||||
# NPM_MIRROR_RETRIES 失败重试次数;默认 3
|
||||
# NPM_MIRROR_SLEEP_SECS 重试间隔秒数;默认 2
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
REGISTRY="${NPM_MIRROR_REGISTRY:-https://registry.npmmirror.com}"
|
||||
RETRIES="${NPM_MIRROR_RETRIES:-3}"
|
||||
SLEEP_SECS="${NPM_MIRROR_SLEEP_SECS:-2}"
|
||||
|
||||
MODE="sync"
|
||||
declare -a USER_PACKAGES=()
|
||||
|
||||
print_help() {
|
||||
cat <<'EOF'
|
||||
用法:
|
||||
./scripts/release-sync-npmmirror.sh [--dry | --check] [package...]
|
||||
|
||||
示例:
|
||||
./scripts/release-sync-npmmirror.sh
|
||||
./scripts/release-sync-npmmirror.sh --dry
|
||||
./scripts/release-sync-npmmirror.sh --check
|
||||
./scripts/release-sync-npmmirror.sh @xagi/vite-plugin-design-mode
|
||||
|
||||
说明:
|
||||
默认模式会对每个包调用 PUT <registry>/<pkg>/sync
|
||||
--dry 仅打印将调用的 URL
|
||||
--check 使用 npm view --registry=<npmmirror> 校验版本是否可见
|
||||
|
||||
环境变量:
|
||||
NPM_MIRROR_VERSION 目标版本(默认读取根 package.json version)
|
||||
NPM_MIRROR_REGISTRY 默认 https://registry.npmmirror.com
|
||||
NPM_MIRROR_RETRIES 默认 3
|
||||
NPM_MIRROR_SLEEP_SECS 默认 2
|
||||
EOF
|
||||
}
|
||||
|
||||
# 参数解析:支持模式参数与可选包名参数混合。
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--dry)
|
||||
MODE="dry"
|
||||
shift
|
||||
;;
|
||||
--check)
|
||||
MODE="check"
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
print_help
|
||||
exit 0
|
||||
;;
|
||||
--)
|
||||
# 兼容 pnpm `script -- --flag` 形式:仅丢弃分隔符,后续参数继续按正常规则解析。
|
||||
shift
|
||||
;;
|
||||
-*)
|
||||
echo "未知参数: $1(支持 --dry / --check / --help)" >&2
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
USER_PACKAGES+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
TARGET_VERSION="${NPM_MIRROR_VERSION:-}"
|
||||
if [[ -z "$TARGET_VERSION" ]]; then
|
||||
TARGET_VERSION="$(node -pe "require('./package.json').version")"
|
||||
fi
|
||||
|
||||
# 默认发布包列表与 release 脚本保持一致。
|
||||
declare -a DEFAULT_PACKAGES=(
|
||||
"@xagi/design-mode-shared"
|
||||
"@xagi/design-mode-client-react"
|
||||
"@xagi/design-mode-client-vue"
|
||||
"@xagi/vite-plugin-design-mode"
|
||||
)
|
||||
|
||||
declare -a PACKAGES=()
|
||||
if [[ "${#USER_PACKAGES[@]}" -gt 0 ]]; then
|
||||
PACKAGES=("${USER_PACKAGES[@]}")
|
||||
else
|
||||
PACKAGES=("${DEFAULT_PACKAGES[@]}")
|
||||
fi
|
||||
|
||||
echo "版本: ${TARGET_VERSION}"
|
||||
echo "模式: ${MODE}"
|
||||
echo "镜像: ${REGISTRY}"
|
||||
echo "包数: ${#PACKAGES[@]}"
|
||||
echo "----------"
|
||||
|
||||
sync_one() {
|
||||
local pkg="$1"
|
||||
local url="${REGISTRY%/}/${pkg}/sync"
|
||||
local body_file
|
||||
body_file="$(mktemp)"
|
||||
|
||||
local attempt=1
|
||||
while [[ "$attempt" -le "$RETRIES" ]]; do
|
||||
if curl -fsS -X PUT "$url" -o "$body_file" 2>/dev/null; then
|
||||
local body
|
||||
body="$(tr -d '\n' < "$body_file" || true)"
|
||||
rm -f "$body_file"
|
||||
echo "OK ${pkg} (attempt ${attempt}/${RETRIES}) ${body}"
|
||||
return 0
|
||||
fi
|
||||
if [[ "$attempt" -lt "$RETRIES" ]]; then
|
||||
echo "RETRY ${pkg} (attempt ${attempt}/${RETRIES}), sleep ${SLEEP_SECS}s..."
|
||||
sleep "$SLEEP_SECS"
|
||||
fi
|
||||
attempt=$((attempt + 1))
|
||||
done
|
||||
|
||||
echo "FAIL ${pkg}"
|
||||
cat "$body_file" 2>/dev/null || true
|
||||
rm -f "$body_file"
|
||||
return 1
|
||||
}
|
||||
|
||||
check_one() {
|
||||
local pkg="$1"
|
||||
local got
|
||||
got="$(npm view "${pkg}@${TARGET_VERSION}" version --registry="${REGISTRY}" 2>/dev/null | tr -d '\r\n' || true)"
|
||||
if [[ "$got" == "$TARGET_VERSION" ]]; then
|
||||
echo "OK ${pkg}@${TARGET_VERSION}"
|
||||
return 0
|
||||
fi
|
||||
echo "MISS ${pkg}@${TARGET_VERSION} (镜像返回: ${got:-无/404})"
|
||||
return 1
|
||||
}
|
||||
|
||||
FAILED=0
|
||||
declare -a FAILED_PACKAGES=()
|
||||
|
||||
for pkg in "${PACKAGES[@]}"; do
|
||||
case "$MODE" in
|
||||
dry)
|
||||
echo "PUT ${REGISTRY%/}/${pkg}/sync"
|
||||
;;
|
||||
sync)
|
||||
if ! sync_one "$pkg"; then
|
||||
FAILED=1
|
||||
FAILED_PACKAGES+=("$pkg")
|
||||
fi
|
||||
;;
|
||||
check)
|
||||
if ! check_one "$pkg"; then
|
||||
FAILED=1
|
||||
FAILED_PACKAGES+=("$pkg")
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "----------"
|
||||
if [[ "$FAILED" -ne 0 ]]; then
|
||||
echo "失败包:"
|
||||
for pkg in "${FAILED_PACKAGES[@]}"; do
|
||||
echo " - ${pkg}"
|
||||
done
|
||||
if [[ "$MODE" == "check" ]]; then
|
||||
echo "提示: npm 官方可能已发布但镜像尚未同步,先执行 sync 模式后再 check。"
|
||||
else
|
||||
echo "提示: 可稍后重试;也可先确认 npm 官方 registry 已存在对应版本。"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "完成。"
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# 这个脚本用于 beta 发布后验证:
|
||||
# 1) 核验 plugin 的 beta dist-tag 是否指向目标版本
|
||||
# 2) 核验 4 个发布包在 registry 上可见
|
||||
#
|
||||
# 用法:
|
||||
# ./scripts/release-verify-beta.sh # 默认读取根 package.json 版本
|
||||
# ./scripts/release-verify-beta.sh 1.1.0-beta.5 # 手动指定版本
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
TARGET_VERSION="${1:-}"
|
||||
if [[ -z "$TARGET_VERSION" ]]; then
|
||||
TARGET_VERSION="$(node -p "require('./package.json').version")"
|
||||
fi
|
||||
|
||||
echo "[verify-beta] target version: $TARGET_VERSION"
|
||||
echo "[verify-beta] checking plugin dist-tags..."
|
||||
npm view @xagi/vite-plugin-design-mode dist-tags
|
||||
|
||||
CURRENT_BETA="$(npm view @xagi/vite-plugin-design-mode dist-tags.beta)"
|
||||
if [[ "$CURRENT_BETA" != "$TARGET_VERSION" ]]; then
|
||||
echo "[verify-beta] error: dist-tags.beta is '$CURRENT_BETA', expected '$TARGET_VERSION'"
|
||||
echo "[verify-beta] hint: run 'npm dist-tag add @xagi/vite-plugin-design-mode@$TARGET_VERSION beta'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[verify-beta] checking published versions exist..."
|
||||
npm view "@xagi/design-mode-shared@$TARGET_VERSION" version
|
||||
npm view "@xagi/design-mode-client-react@$TARGET_VERSION" version
|
||||
npm view "@xagi/design-mode-client-vue@$TARGET_VERSION" version
|
||||
npm view "@xagi/vite-plugin-design-mode@$TARGET_VERSION" version
|
||||
|
||||
echo "[verify-beta] all checks passed."
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# 这个脚本用于发布后验证:
|
||||
# 1) 核验 plugin 的 next dist-tag 是否指向目标版本
|
||||
# 2) 核验 4 个发布包在 registry 上可见
|
||||
#
|
||||
# 用法:
|
||||
# ./scripts/release-verify-next.sh # 默认读取根 package.json 版本
|
||||
# ./scripts/release-verify-next.sh 1.1.0-beta.5 # 手动指定版本
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
TARGET_VERSION="${1:-}"
|
||||
if [[ -z "$TARGET_VERSION" ]]; then
|
||||
TARGET_VERSION="$(node -p "require('./package.json').version")"
|
||||
fi
|
||||
|
||||
echo "[verify-next] target version: $TARGET_VERSION"
|
||||
|
||||
# npm 注册表在刚 publish 后可能短暂不一致;这里做有限次重试,避免 release:next 误报失败。
|
||||
MAX_TRIES="${VERIFY_NEXT_MAX_TRIES:-18}"
|
||||
SLEEP_SECS="${VERIFY_NEXT_SLEEP_SECS:-2}"
|
||||
|
||||
all_checks_ok() {
|
||||
local current_next
|
||||
current_next="$(npm view @xagi/vite-plugin-design-mode dist-tags.next 2>/dev/null || true)"
|
||||
if [[ "$current_next" != "$TARGET_VERSION" ]]; then
|
||||
return 1
|
||||
fi
|
||||
npm view "@xagi/design-mode-shared@$TARGET_VERSION" version >/dev/null 2>&1 || return 1
|
||||
npm view "@xagi/design-mode-client-react@$TARGET_VERSION" version >/dev/null 2>&1 || return 1
|
||||
npm view "@xagi/design-mode-client-vue@$TARGET_VERSION" version >/dev/null 2>&1 || return 1
|
||||
npm view "@xagi/vite-plugin-design-mode@$TARGET_VERSION" version >/dev/null 2>&1 || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
try=1
|
||||
while [[ "$try" -le "$MAX_TRIES" ]]; do
|
||||
if all_checks_ok; then
|
||||
echo "[verify-next] checking plugin dist-tags..."
|
||||
npm view @xagi/vite-plugin-design-mode dist-tags
|
||||
echo "[verify-next] checking published versions exist..."
|
||||
npm view "@xagi/design-mode-shared@$TARGET_VERSION" version
|
||||
npm view "@xagi/design-mode-client-react@$TARGET_VERSION" version
|
||||
npm view "@xagi/design-mode-client-vue@$TARGET_VERSION" version
|
||||
npm view "@xagi/vite-plugin-design-mode@$TARGET_VERSION" version
|
||||
echo "[verify-next] all checks passed (attempt $try/$MAX_TRIES)."
|
||||
echo "[verify-next] hint for consumers: pnpm add @xagi/vite-plugin-design-mode@next -D"
|
||||
exit 0
|
||||
fi
|
||||
echo "[verify-next] registry not fully consistent yet (attempt $try/$MAX_TRIES), sleeping ${SLEEP_SECS}s..."
|
||||
sleep "$SLEEP_SECS"
|
||||
try=$((try + 1))
|
||||
done
|
||||
|
||||
echo "[verify-next] error: after $MAX_TRIES attempts, dist-tag next or one of the packages is not visible for $TARGET_VERSION"
|
||||
echo "[verify-next] current dist-tags:"
|
||||
npm view @xagi/vite-plugin-design-mode dist-tags 2>/dev/null || true
|
||||
echo "[verify-next] hint: wait and re-run: ./scripts/release-verify-next.sh $TARGET_VERSION"
|
||||
echo "[verify-next] or: npm dist-tag add @xagi/vite-plugin-design-mode@$TARGET_VERSION next"
|
||||
exit 1
|
||||
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# 一次性同步多包版本号与内部依赖版本。
|
||||
# 这样可以避免手工修改多个 package.json 时漏改或改错。
|
||||
#
|
||||
# 用法:
|
||||
# ./scripts/release-version-sync.sh 1.1.0-beta.6
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 <version>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NEW_VERSION="$1"
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
echo "[version-sync] syncing all package versions to $NEW_VERSION..."
|
||||
node - "$NEW_VERSION" <<'NODE'
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const newVersion = process.argv[2];
|
||||
const root = process.cwd();
|
||||
|
||||
function readJson(file) {
|
||||
return JSON.parse(fs.readFileSync(path.join(root, file), "utf8"));
|
||||
}
|
||||
|
||||
function writeJson(file, data) {
|
||||
fs.writeFileSync(path.join(root, file), JSON.stringify(data, null, 2) + "\n");
|
||||
}
|
||||
|
||||
const files = {
|
||||
root: "package.json",
|
||||
shared: "packages/client-shared/package.json",
|
||||
react: "packages/client-react/package.json",
|
||||
vue: "packages/client-vue/package.json",
|
||||
plugin: "packages/plugin/package.json",
|
||||
};
|
||||
|
||||
const rootPkg = readJson(files.root);
|
||||
const sharedPkg = readJson(files.shared);
|
||||
const reactPkg = readJson(files.react);
|
||||
const vuePkg = readJson(files.vue);
|
||||
const pluginPkg = readJson(files.plugin);
|
||||
|
||||
rootPkg.version = newVersion;
|
||||
sharedPkg.version = newVersion;
|
||||
reactPkg.version = newVersion;
|
||||
vuePkg.version = newVersion;
|
||||
pluginPkg.version = newVersion;
|
||||
|
||||
reactPkg.dependencies = reactPkg.dependencies || {};
|
||||
vuePkg.dependencies = vuePkg.dependencies || {};
|
||||
pluginPkg.dependencies = pluginPkg.dependencies || {};
|
||||
|
||||
reactPkg.dependencies["@xagi/design-mode-shared"] = newVersion;
|
||||
vuePkg.dependencies["@xagi/design-mode-shared"] = newVersion;
|
||||
pluginPkg.dependencies["@xagi/design-mode-shared"] = newVersion;
|
||||
pluginPkg.dependencies["@xagi/design-mode-client-react"] = newVersion;
|
||||
pluginPkg.dependencies["@xagi/design-mode-client-vue"] = newVersion;
|
||||
|
||||
writeJson(files.root, rootPkg);
|
||||
writeJson(files.shared, sharedPkg);
|
||||
writeJson(files.react, reactPkg);
|
||||
writeJson(files.vue, vuePkg);
|
||||
writeJson(files.plugin, pluginPkg);
|
||||
NODE
|
||||
|
||||
echo "[version-sync] done."
|
||||
83
qiming-vite-plugin-design-mode/scripts/test-cli.sh
Normal file
83
qiming-vite-plugin-design-mode/scripts/test-cli.sh
Normal file
@@ -0,0 +1,83 @@
|
||||
#!/bin/bash
|
||||
|
||||
# CLI smoke test: install / uninstall flows
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 Starting CLI tests..."
|
||||
echo ""
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 1. Build
|
||||
echo -e "${BLUE}📦 Step 1: Building...${NC}"
|
||||
npm run build
|
||||
echo -e "${GREEN}✓ Build done${NC}"
|
||||
echo ""
|
||||
|
||||
# 2. Enter demo project
|
||||
TEST_DIR="examples/demo"
|
||||
if [ ! -d "$TEST_DIR" ]; then
|
||||
echo -e "${YELLOW}⚠️ Test directory missing: $TEST_DIR${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$TEST_DIR"
|
||||
echo -e "${BLUE}📁 Entering: $TEST_DIR${NC}"
|
||||
echo ""
|
||||
|
||||
# 3. Backup config files
|
||||
echo -e "${BLUE}💾 Step 2: Backing up config files...${NC}"
|
||||
if [ -f "vite.config.ts" ]; then
|
||||
cp vite.config.ts vite.config.ts.backup
|
||||
echo -e "${GREEN}✓ Backed up vite.config.ts${NC}"
|
||||
fi
|
||||
if [ -f "package.json" ]; then
|
||||
cp package.json package.json.backup
|
||||
echo -e "${GREEN}✓ Backed up package.json${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# 4. Test install
|
||||
echo -e "${BLUE}📥 Step 3: Testing install...${NC}"
|
||||
echo "Running: node ../../packages/plugin/dist/cli/index.js install"
|
||||
echo ""
|
||||
node ../../packages/plugin/dist/cli/index.js install
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Install test done${NC}"
|
||||
echo ""
|
||||
|
||||
read -p "Press Enter to continue with uninstall test..."
|
||||
echo ""
|
||||
|
||||
# 5. Test uninstall
|
||||
echo -e "${BLUE}📤 Step 4: Testing uninstall...${NC}"
|
||||
echo "Running: node ../../packages/plugin/dist/cli/index.js uninstall"
|
||||
echo ""
|
||||
node ../../packages/plugin/dist/cli/index.js uninstall
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Uninstall test done${NC}"
|
||||
echo ""
|
||||
|
||||
# 6. Restore backups?
|
||||
read -p "Restore backup files? (y/n) " -n 1 -r
|
||||
echo ""
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo -e "${BLUE}🔄 Restoring backups...${NC}"
|
||||
if [ -f "vite.config.ts.backup" ]; then
|
||||
mv vite.config.ts.backup vite.config.ts
|
||||
echo -e "${GREEN}✓ Restored vite.config.ts${NC}"
|
||||
fi
|
||||
if [ -f "package.json.backup" ]; then
|
||||
mv package.json.backup package.json
|
||||
echo -e "${GREEN}✓ Restored package.json${NC}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}✅ All tests finished.${NC}"
|
||||
|
||||
Reference in New Issue
Block a user