Get started
Review the script below, then run it. That's it. The whole CLI is a single POSIX shell file — no runtime, no package manager, no magic.
install
curl -fsSL https://yo.urspace.net/yourspace.sh | shyourspace.sh
#!/bin/sh
# yourspace.sh — bootstrap script for YourSpace CDN
# Audit this file before running: https://yo.urspace.net/yourspace.sh
# Usage: curl -fsSL https://yo.urspace.net/yourspace.sh | sh
#
# POSIX-compliant. No bash-isms.
set -e
YOURSPACE_DIR="${YOURSPACE_DIR:-$HOME/.yourspace}"
BIN_DIR="$YOURSPACE_DIR/bin"
VERSION="0.1.0"
log() {
printf ' \033[1;32m✓\033[0m %s\n' "$1"
}
err() {
printf ' \033[1;31m✗\033[0m %s\n' "$1" >&2
exit 1
}
# ---------------------------------------------------------------------------
# yourspace init
# Creates yourspace.yml in the current directory with sensible defaults.
# ---------------------------------------------------------------------------
cmd_init() {
if [ -f "yourspace.yml" ]; then
err "yourspace.yml already exists in this directory"
fi
cat > yourspace.yml <<'YAML'
# yourspace.yml — routing & edge configuration
# Docs: https://yo.urspace.net/docs
name: my-site
# Origin your CDN sits in front of
origin: https://localhost:3000
# TLS — auto-provisioned by default
tls:
auto: true
# cert: ./certs/my-cert.pem # uncomment to bring your own
# key: ./certs/my-key.pem
# Routes are matched top-to-bottom. First match wins.
routes:
- path: /api/*
target: origin
cache: none
- path: /static/*
target: cache
ttl: 7d
- path: /*
target: edge-nearest
cache: 1h
YAML
log "yourspace.yml created"
}
# ---------------------------------------------------------------------------
# yourspace new <name>
# Scaffold a new routing.yml with comment pragmas explaining each directive.
# ---------------------------------------------------------------------------
cmd_new() {
name="${1:-routing}"
file="${name}.yml"
if [ -f "$file" ]; then
err "$file already exists"
fi
cat > "$file" <<'YAML'
# routing.yml — yourspace routing definition
#
# Pragma reference:
# path: Glob pattern for matching request paths.
# Supports * (single segment) and ** (recursive).
#
# target: Where matched requests are sent.
# Values: origin | cache | edge-nearest | <url>
#
# cache: Cache behaviour for this route.
# Values: none | <duration> (e.g. 30m, 1h, 7d)
#
# ttl: Alias for cache duration. Ignored if cache is set.
#
# headers: Key-value pairs merged into the response.
# Useful for CORS, security headers, etc.
#
# edge: Name of an edge function to run on this route.
# Functions live in ./edge/<name>.js
#
# Routes are evaluated top-to-bottom. First match wins.
routes:
- path: /api/*
target: origin
cache: none
headers:
Access-Control-Allow-Origin: "*"
- path: /assets/**
target: cache
ttl: 30d
headers:
Cache-Control: "public, immutable"
- path: /*
target: edge-nearest
cache: 1h
YAML
log "$file created"
}
# ---------------------------------------------------------------------------
# yourspace deploy
# Validates config, provisions TLS, and pushes to the edge network.
# ---------------------------------------------------------------------------
cmd_deploy() {
if [ ! -f "yourspace.yml" ]; then
err "No yourspace.yml found. Run 'yourspace init' first."
fi
log "Validating yourspace.yml"
log "TLS provisioned"
log "14 edge nodes active"
# In a real implementation this would:
# 1. Parse and validate yourspace.yml
# 2. Bundle edge functions from ./edge/
# 3. Push config + assets to the YourSpace API
# 4. Wait for propagation confirmation
name="$(grep '^name:' yourspace.yml | head -1 | sed 's/name: *//')"
printf ' \033[1;32m✓\033[0m live → %s.yo.urspace.net\n' "${name:-my-site}"
}
# ---------------------------------------------------------------------------
# Dispatch
# ---------------------------------------------------------------------------
cmd="${1:-help}"
case "$cmd" in
init) cmd_init ;;
new) shift; cmd_new "$@" ;;
deploy) cmd_deploy ;;
help|--help|-h)
printf 'Usage: yourspace <command>\n\n'
printf 'Commands:\n'
printf ' init Create yourspace.yml in the current directory\n'
printf ' new Scaffold a new routing.yml file\n'
printf ' deploy Push your site to the edge\n'
printf ' help Show this message\n'
;;
*)
err "Unknown command: $cmd. Run 'yourspace help'."
;;
esac~140 lines. Read it. Fork it. It's yours.