Files
skills-here-run-place/dist/server/chunks/sync_B_Og9xl3.mjs
Alejandro Martinez f09af719cf Initial commit
2026-02-12 02:04:10 +01:00

72 lines
2.1 KiB
JavaScript

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 };