Download the public scaffold archive with curl instead of GitHub CLI.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -10,10 +10,10 @@ React 应用脚手架。创建新项目时,包名、源码和 `src` 下文件
|
|||||||
|
|
||||||
## 创建项目
|
## 创建项目
|
||||||
|
|
||||||
需要 Node.js,以及已登录的 GitHub CLI(`gh auth login`)。
|
需要 Node.js 和 curl。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -fsSL https://raw.githubusercontent.com/bql-691/bq_react/v0.1.0/scripts/create.sh | bash -s -- shop
|
curl -fsSL https://raw.githubusercontent.com/bql-691/bq_react/v0.1.1/scripts/create.sh | bash -s -- shop
|
||||||
```
|
```
|
||||||
|
|
||||||
这会在当前目录生成 `shop`,并执行 `npm install`。
|
这会在当前目录生成 `shop`,并执行 `npm install`。
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# 从公开 GitHub 仓库创建项目,并把源码中的 bq 前缀换成项目名。
|
# 从公开 GitHub 仓库创建项目,并把源码中的 bq 前缀换成项目名。
|
||||||
# 用法:
|
# 用法:
|
||||||
# curl -fsSL https://raw.githubusercontent.com/bql-691/bq_react/v0.1.0/scripts/create.sh | bash -s -- shop
|
# curl -fsSL https://raw.githubusercontent.com/bql-691/bq_react/v0.1.1/scripts/create.sh | bash -s -- shop
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
OWNER="bql-691"
|
OWNER="bql-691"
|
||||||
REPO="bq_react"
|
REPO="bq_react"
|
||||||
REF="${BQ_REF:-v0.1.0}"
|
REF="${BQ_REF:-v0.1.1}"
|
||||||
NAME="${1:-}"
|
NAME="${1:-}"
|
||||||
|
|
||||||
if [[ ! "$NAME" =~ ^[a-z][a-z0-9-]*$ ]]; then
|
if [[ ! "$NAME" =~ ^[a-z][a-z0-9-]*$ ]]; then
|
||||||
@@ -20,26 +20,23 @@ if [[ -e "$NAME" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
command -v gh >/dev/null 2>&1 || {
|
command -v curl >/dev/null 2>&1 || {
|
||||||
echo "需要 GitHub CLI。安装后执行: gh auth login" >&2
|
echo "需要 curl" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
command -v node >/dev/null 2>&1 || {
|
command -v node >/dev/null 2>&1 || {
|
||||||
echo "需要 Node.js" >&2
|
echo "需要 Node.js" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
gh auth status >/dev/null 2>&1 || {
|
|
||||||
echo "请先登录 GitHub CLI: gh auth login" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
TMP="$(mktemp -d)"
|
TMP="$(mktemp -d)"
|
||||||
cleanup() { rm -rf "$TMP"; }
|
cleanup() { rm -rf "$TMP"; }
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
ARCHIVE="$TMP/src.tar.gz"
|
ARCHIVE="$TMP/src.tar.gz"
|
||||||
if ! gh api "repos/${OWNER}/${REPO}/tarball/${REF}" >"$ARCHIVE"; then
|
URL="https://github.com/${OWNER}/${REPO}/archive/refs/tags/${REF}.tar.gz"
|
||||||
echo "下载失败。请确认 ${OWNER}/${REPO} 上存在引用 ${REF}。" >&2
|
if ! curl -fsSL "$URL" -o "$ARCHIVE"; then
|
||||||
|
echo "下载失败。请确认 ${OWNER}/${REPO} 上存在标签 ${REF}。" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if ! tar -tzf "$ARCHIVE" >/dev/null 2>&1; then
|
if ! tar -tzf "$ARCHIVE" >/dev/null 2>&1; then
|
||||||
|
|||||||
Reference in New Issue
Block a user