Initial commit
This commit is contained in:
71
dist/server/chunks/sync_B_Og9xl3.mjs
vendored
Normal file
71
dist/server/chunks/sync_B_Og9xl3.mjs
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
import { l as listSkills } from './skills_COWfD5oy.mjs';
|
||||
|
||||
async function buildPushScript(baseUrl, skillsDir) {
|
||||
const lines = [
|
||||
"#!/usr/bin/env bash",
|
||||
"set -euo pipefail",
|
||||
"",
|
||||
`SKILLS_DIR="${skillsDir}"`,
|
||||
`BASE_URL="${baseUrl}"`,
|
||||
"",
|
||||
'if [ ! -d "$SKILLS_DIR" ]; then',
|
||||
' echo "No skills directory found at $SKILLS_DIR"',
|
||||
" exit 1",
|
||||
"fi",
|
||||
"",
|
||||
"count=0",
|
||||
'for file in "$SKILLS_DIR"/*.md; do',
|
||||
' [ -f "$file" ] || continue',
|
||||
' slug=$(basename "$file" .md)',
|
||||
' content=$(cat "$file")',
|
||||
"",
|
||||
" # Try PUT (update), fallback to POST (create)",
|
||||
' status=$(curl -s -o /dev/null -w "%{http_code}" -X PUT \\',
|
||||
' -H "Content-Type: application/json" \\',
|
||||
' -d "{\\"content\\": $(echo "$content" | jq -Rs .)}" \\',
|
||||
' "$BASE_URL/api/skills/$slug")',
|
||||
"",
|
||||
' if [ "$status" = "404" ]; then',
|
||||
" curl -fsS -X POST \\",
|
||||
' -H "Content-Type: application/json" \\',
|
||||
' -d "{\\"slug\\": \\"$slug\\", \\"content\\": $(echo "$content" | jq -Rs .)}" \\',
|
||||
' "$BASE_URL/api/skills" > /dev/null',
|
||||
" fi",
|
||||
"",
|
||||
' echo " ✓ $slug"',
|
||||
" count=$((count + 1))",
|
||||
"done",
|
||||
"",
|
||||
'echo "Pushed $count skill(s) to $BASE_URL"',
|
||||
""
|
||||
];
|
||||
return lines.join("\n");
|
||||
}
|
||||
async function buildSyncScript(baseUrl, skillsDir) {
|
||||
const skills = await listSkills();
|
||||
const lines = [
|
||||
"#!/usr/bin/env bash",
|
||||
"set -euo pipefail",
|
||||
"",
|
||||
`SKILLS_DIR="${skillsDir}"`,
|
||||
'mkdir -p "$SKILLS_DIR"',
|
||||
""
|
||||
];
|
||||
if (skills.length === 0) {
|
||||
lines.push('echo "No skills available to sync."');
|
||||
} else {
|
||||
lines.push(`echo "Syncing ${skills.length} skill(s) from ${baseUrl}..."`);
|
||||
lines.push("");
|
||||
for (const skill of skills) {
|
||||
const skillUrl = `${baseUrl}/${skill.slug}`;
|
||||
lines.push(`curl -fsSL "${skillUrl}" -o "$SKILLS_DIR/${skill.slug}.md"`);
|
||||
lines.push(`echo " ✓ ${skill.name}"`);
|
||||
}
|
||||
lines.push("");
|
||||
lines.push('echo "Done! Skills synced to $SKILLS_DIR"');
|
||||
}
|
||||
lines.push("");
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
export { buildPushScript as a, buildSyncScript as b };
|
||||
Reference in New Issue
Block a user