新しいスクリプトファイルの追加: JSONマニフェストを生成するためのmake-json.shとgen_manifest.shを作成し、必要なディレクトリ構造を設定。画像情報を取得するためのAPI呼び出しを実装。バイナリファイル.DS_Storeを追加。
This commit is contained in:
BIN
images/.DS_Store
vendored
Normal file
BIN
images/.DS_Store
vendored
Normal file
Binary file not shown.
24
make-json.sh
Normal file
24
make-json.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TOKEN="578edf8a8328fb37d6c32f56eb1450622db3492a"
|
||||
BASE="https://git.sunamura-llc.com"
|
||||
OWNER="openRepo"
|
||||
REPO="AI-ART"
|
||||
BRANCH="main"
|
||||
|
||||
OUT="manifest.json"
|
||||
|
||||
images_json=$(curl -s \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
"${BASE}/api/v1/repos/${OWNER}/${REPO}/contents/images")
|
||||
|
||||
echo "{
|
||||
\"repo\": \"${OWNER}/${REPO}\",
|
||||
\"branch\": \"${BRANCH}\",
|
||||
\"readme\": \"${BASE}/${OWNER}/${REPO}/raw/branch/${BRANCH}/README.md\",
|
||||
\"task_template\": \"${BASE}/${OWNER}/${REPO}/raw/branch/${BRANCH}/prompts/task_template.md\",
|
||||
\"rules\": \"${BASE}/${OWNER}/${REPO}/raw/branch/${BRANCH}/.cursorrules\",
|
||||
\"images\": $(echo "$images_json" | jq '[.[] | {name: .name, url: .download_url}]')
|
||||
}" > "${OUT}"
|
||||
|
||||
echo "✔ manifest.json generated"
|
||||
58
maker.sh
Executable file
58
maker.sh
Executable file
@@ -0,0 +1,58 @@
|
||||
mkdir -p tools
|
||||
cat > tools/gen_manifest.sh <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
BASE="${GITEA_BASE:-https://git.sunamura-llc.com}"
|
||||
OWNER="${GITEA_OWNER:-openRepo}"
|
||||
REPO="${GITEA_REPO:-AI-ART}"
|
||||
BRANCH="${GITEA_BRANCH:-main}"
|
||||
|
||||
OUT="${OUT:-manifest.json}"
|
||||
TOKEN="${GITEA_TOKEN:-}"
|
||||
|
||||
command -v curl >/dev/null 2>&1 || { echo "ERROR: curl not found"; exit 1; }
|
||||
command -v jq >/dev/null 2>&1 || { echo "ERROR: jq not found (mac: brew install jq)"; exit 1; }
|
||||
|
||||
if [[ -z "$TOKEN" ]]; then
|
||||
echo "ERROR: GITEA_TOKEN is empty"
|
||||
echo "例: export GITEA_TOKEN='xxxxx'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
API="${BASE}/api/v1"
|
||||
AUTH_HEADER="Authorization: token ${TOKEN}"
|
||||
|
||||
images_json="$(curl -sS -H "$AUTH_HEADER" \
|
||||
"${API}/repos/${OWNER}/${REPO}/contents/images" \
|
||||
|| true)"
|
||||
|
||||
images_array="$(echo "$images_json" | jq -c '
|
||||
if type=="array" then
|
||||
[.[] | select(.type=="file") | {name: .name, path: .path, url: .download_url}]
|
||||
else
|
||||
[]
|
||||
end
|
||||
')"
|
||||
|
||||
cat > "$OUT" <<MANIFEST
|
||||
{
|
||||
"repo": "${OWNER}/${REPO}",
|
||||
"branch": "${BRANCH}",
|
||||
"readme": "${BASE}/${OWNER}/${REPO}/raw/branch/${BRANCH}/README.md",
|
||||
"task_template": "${BASE}/${OWNER}/${REPO}/raw/branch/${BRANCH}/prompts/task_template.md",
|
||||
"rules": "${BASE}/${OWNER}/${REPO}/raw/branch/${BRANCH}/.cursorrules",
|
||||
"images_dir": "${BASE}/${OWNER}/${REPO}/src/branch/${BRANCH}/images",
|
||||
"images": ${images_array},
|
||||
"notes": [
|
||||
"README.md を条件(ポリシー)として読む",
|
||||
"prompts/task_template.md を実行指示として扱う"
|
||||
]
|
||||
}
|
||||
MANIFEST
|
||||
|
||||
echo "✔ generated: ${OUT}"
|
||||
echo " images: $(echo "$images_array" | jq 'length') files"
|
||||
EOF
|
||||
|
||||
chmod +x tools/gen_manifest.sh
|
||||
53
tools/gen_manifest.sh
Executable file
53
tools/gen_manifest.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
BASE="${GITEA_BASE:-https://git.sunamura-llc.com}"
|
||||
OWNER="${GITEA_OWNER:-openRepo}"
|
||||
REPO="${GITEA_REPO:-AI-ART}"
|
||||
BRANCH="${GITEA_BRANCH:-main}"
|
||||
|
||||
OUT="${OUT:-manifest.json}"
|
||||
TOKEN="${GITEA_TOKEN:-}"
|
||||
|
||||
command -v curl >/dev/null 2>&1 || { echo "ERROR: curl not found"; exit 1; }
|
||||
command -v jq >/dev/null 2>&1 || { echo "ERROR: jq not found (mac: brew install jq)"; exit 1; }
|
||||
|
||||
if [[ -z "$TOKEN" ]]; then
|
||||
echo "ERROR: GITEA_TOKEN is empty"
|
||||
echo "例: export GITEA_TOKEN='xxxxx'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
API="${BASE}/api/v1"
|
||||
AUTH_HEADER="Authorization: token ${TOKEN}"
|
||||
|
||||
images_json="$(curl -sS -H "$AUTH_HEADER" \
|
||||
"${API}/repos/${OWNER}/${REPO}/contents/images" \
|
||||
|| true)"
|
||||
|
||||
images_array="$(echo "$images_json" | jq -c '
|
||||
if type=="array" then
|
||||
[.[] | select(.type=="file") | {name: .name, path: .path, url: .download_url}]
|
||||
else
|
||||
[]
|
||||
end
|
||||
')"
|
||||
|
||||
cat > "$OUT" <<MANIFEST
|
||||
{
|
||||
"repo": "${OWNER}/${REPO}",
|
||||
"branch": "${BRANCH}",
|
||||
"readme": "${BASE}/${OWNER}/${REPO}/raw/branch/${BRANCH}/README.md",
|
||||
"task_template": "${BASE}/${OWNER}/${REPO}/raw/branch/${BRANCH}/prompts/task_template.md",
|
||||
"rules": "${BASE}/${OWNER}/${REPO}/raw/branch/${BRANCH}/.cursorrules",
|
||||
"images_dir": "${BASE}/${OWNER}/${REPO}/src/branch/${BRANCH}/images",
|
||||
"images": ${images_array},
|
||||
"notes": [
|
||||
"README.md を条件(ポリシー)として読む",
|
||||
"prompts/task_template.md を実行指示として扱う"
|
||||
]
|
||||
}
|
||||
MANIFEST
|
||||
|
||||
echo "✔ generated: ${OUT}"
|
||||
echo " images: $(echo "$images_array" | jq 'length') files"
|
||||
Reference in New Issue
Block a user