first commit
This commit is contained in:
@@ -0,0 +1,164 @@
|
||||
# Scripts
|
||||
|
||||
Use these durable entrypoints for normal work:
|
||||
|
||||
| Task | Command |
|
||||
| ---- | ------- |
|
||||
| Set up dev symlinks | `scripts/dev/setup-symlinks.sh` |
|
||||
| Check dev symlinks | `scripts/dev/setup-symlinks.sh --check` |
|
||||
| Bundle production outputs | `scripts/bundle/bundle.sh --clean` |
|
||||
| Check production outputs are fresh | `scripts/bundle/bundle.sh --check` |
|
||||
| Bundle one skill output | `scripts/bundle/bundle-skill.sh <skill-id>` |
|
||||
| Run code tests | `scripts/test/test.sh` |
|
||||
| Run docs checks | `scripts/test/test-docs.sh` |
|
||||
| Check canonical release version | `scripts/release/check-version.sh` |
|
||||
| Install local skills into agents | `scripts/install/install-skills.sh --agent codex` |
|
||||
| Uninstall local skill links | `scripts/install/uninstall-skills.sh --agent codex` |
|
||||
|
||||
Lower-level scripts stay grouped by ownership:
|
||||
|
||||
- `bundle/`: production bundle wrapper, skill bundle router, skill runtime
|
||||
bundlers, and plugin package bundle/check scripts.
|
||||
- `test/`: code test runner and targeted test subcommands.
|
||||
- `github-workflows/`: release-layout and development-layout check entrypoints
|
||||
used by GitHub Actions.
|
||||
- `dev/`: symlink layout setup and verification for development checkouts.
|
||||
- `install/`: local skill install/uninstall scripts for agent skill folders.
|
||||
- `utils/`: shared helper scripts used by durable repo commands.
|
||||
- `release/`: version bumping, release commits, tags, and GitHub Releases.
|
||||
- `viewer/`, `git-hooks/`: specialized repo tooling.
|
||||
|
||||
Root `tests/` contains repo-wide policy tests that are not owned by one package,
|
||||
skill, or app runtime.
|
||||
|
||||
## Bundle
|
||||
|
||||
`scripts/bundle/bundle.sh` is the master production bundle script. It runs every
|
||||
bundle-capable skill through the skill bundle router and then refreshes the plugin
|
||||
package copy:
|
||||
|
||||
```text
|
||||
scripts/bundle/bundle-skill.sh --all
|
||||
scripts/bundle/bundle-plugin.sh
|
||||
```
|
||||
|
||||
Use:
|
||||
|
||||
```bash
|
||||
scripts/bundle/bundle.sh --clean
|
||||
scripts/bundle/bundle.sh --check
|
||||
scripts/bundle/bundle-skill.sh <skill-id> --check
|
||||
```
|
||||
|
||||
`scripts/github-workflows/check-builds.sh` is the release-layout gate. It verifies
|
||||
there are no symlinks under production runtime paths, then runs
|
||||
`scripts/bundle/bundle.sh --check` by default. Use `--skip-bundle-check` only in
|
||||
workflows that already ran `scripts/bundle/bundle.sh --clean` in the same
|
||||
checkout. Plugin skill-copy
|
||||
freshness and plugin metadata validation are part of
|
||||
`scripts/bundle/bundle-plugin.sh --check`, which runs through the master bundle
|
||||
check.
|
||||
|
||||
`skills/cad-viewer/scripts/viewer/dist/` is generated and ignored in source
|
||||
layout, but the root `.gitignore` unignores that exact production-runtime path so
|
||||
`Publish` can commit the bundled Viewer assets on `main`. On `develop`,
|
||||
`scripts/dev/setup-symlinks.sh --check` requires `skills/cad-viewer/scripts/viewer`
|
||||
to be the source symlink instead.
|
||||
|
||||
## Dev
|
||||
|
||||
`scripts/dev/setup-symlinks.sh` is the master development-layout script:
|
||||
|
||||
```bash
|
||||
scripts/dev/setup-symlinks.sh
|
||||
scripts/dev/setup-symlinks.sh --check
|
||||
```
|
||||
|
||||
It links generated-copy targets back to their canonical source directories and
|
||||
checks that those symlinks are present.
|
||||
|
||||
## Install
|
||||
|
||||
Use the install scripts for local agent links:
|
||||
|
||||
```bash
|
||||
scripts/install/install-skills.sh --agent codex
|
||||
scripts/install/uninstall-skills.sh --agent codex
|
||||
```
|
||||
|
||||
They install or remove local development skill symlinks in agent-specific skill
|
||||
directories.
|
||||
|
||||
## Test
|
||||
|
||||
`scripts/test/test.sh` is the broad code test runner for source/package tests.
|
||||
Documentation checks are separate so CI can run them with production bundle
|
||||
checks. Python tests live under `tests/python/`, grouped by tested surface, so
|
||||
skill and package runtimes do not carry test-only modules. Production bundle
|
||||
copy steps also exclude conventional test directories and `*.test.*` /
|
||||
`*.spec.*` files as a safety net. Focused subcommands can be run directly for
|
||||
smaller checks:
|
||||
|
||||
```bash
|
||||
scripts/test/test-js.sh
|
||||
scripts/test/test-docs.sh
|
||||
scripts/test/test-python.sh
|
||||
scripts/test/test-global.sh
|
||||
```
|
||||
|
||||
## Version And Release
|
||||
|
||||
Use `scripts/release/check-version.sh` for CI/read-only checks:
|
||||
|
||||
```bash
|
||||
scripts/release/check-version.sh
|
||||
scripts/release/check-version.sh --incremented-from origin/main
|
||||
```
|
||||
|
||||
Normal development branches should not bump `plugins/cad/VERSION`. Use the
|
||||
`Release` GitHub Actions workflow to open and ship the release PR from
|
||||
`develop`; use `scripts/release/bump-version.sh` only as a local fallback for
|
||||
that release PR:
|
||||
|
||||
```bash
|
||||
scripts/release/bump-version.sh patch --dry-run
|
||||
scripts/release/bump-version.sh patch --no-commit
|
||||
```
|
||||
|
||||
`plugins/cad/VERSION` is the only canonical release bump file. Duplicate
|
||||
package, plugin, lockfile, and Python `pyproject.toml` versions are derived from
|
||||
it; the `Release` workflow stamps them with `scripts/release/sync-version.mjs`,
|
||||
and `scripts/bundle/bundle.sh` re-checks the same metadata before writing or
|
||||
checking production outputs.
|
||||
|
||||
Use `scripts/release/publish-github-release.sh` only from the `Release`
|
||||
workflow after a main production bundle, or as a manual production-branch
|
||||
fallback. It creates the semver git tag from `plugins/cad/VERSION` and creates
|
||||
a GitHub Release with generated notes; unlike the `Release` workflow, which
|
||||
publishes the release by default, the script creates a draft unless
|
||||
`--publish` is passed.
|
||||
Use `scripts/release/check-publish-source.sh` to verify that a source ref
|
||||
contains the previous release source before the publish job writes a new
|
||||
generated target commit.
|
||||
Use `scripts/github-workflows/deploy-vercel-app.sh` only from the `Deploy Docs`
|
||||
and `Deploy Viewer` workflows; it configures Vercel Authentication for preview
|
||||
deployments only, deploys one Vercel project to production, and verifies its
|
||||
public URLs.
|
||||
`scripts/release/create-github-release.sh` remains as a manual all-in-one
|
||||
fallback, but the workflow path is preferred.
|
||||
|
||||
## CI
|
||||
|
||||
| Workflow | Branches/events | Purpose |
|
||||
| -------- | --------------- | ------- |
|
||||
| `test.yml` | pushes to `develop`; PRs to `develop`; manual dispatch | Checks `plugins/cad/VERSION` and derived metadata as a separate job so the test job still runs if release metadata is wrong. The test job checks the `develop` symlink layout, bundles temporary production outputs, checks that layout without rebuilding it, and runs docs and code tests against the generated output. Superseded PR runs are cancelled. |
|
||||
| `release.yml` | manual dispatch | The single release workflow: release PR, production publish commit to the target branch, models upload, web-app deploys, semver tag, and GitHub Release in one run. See the Releases section in `CONTRIBUTING.md` for the full flow, CI/CD-testing, and resume options. |
|
||||
| `deploy-docs.yml` | manual dispatch; called by `release.yml` | Deploys the docs app to Vercel production from a production-layout ref (default `main`): configures Vercel Authentication for preview deployments only, runs `vercel pull/build/deploy --prod`, and verifies the public production URLs. |
|
||||
| `deploy-viewer.yml` | manual dispatch; called by `release.yml` | Deploys the demo viewer app to Vercel production from a production-layout ref (default `main`), with the same protection and public URL checks as `deploy-docs.yml`. |
|
||||
| `upload-models.yml` | manual dispatch; called by `release.yml` | Uploads the `models/` catalog and CAD Viewer assets to Vercel Blob via `scripts/viewer/upload-viewer-models-catalog.sh`, skipping assets that already match remote and fetching only the missing LFS objects. Upload from a source ref (default `develop`); `main` does not contain `models/`. |
|
||||
|
||||
In short: use `release.yml` for releases, use `deploy-docs.yml` and
|
||||
`deploy-viewer.yml` to redeploy the individual web apps from `main`, use
|
||||
`upload-models.yml` to push new models to Vercel Blob from `develop`, treat
|
||||
`develop` as the editable symlink branch, and keep `main` as the explicit
|
||||
publish-only production branch for user clones and published releases.
|
||||
+340
@@ -0,0 +1,340 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
|
||||
MODE="write"
|
||||
CLEAN=0
|
||||
|
||||
SOURCE_SKILLS_ROOT="$REPO_ROOT/skills"
|
||||
PLUGIN_ROOT="$REPO_ROOT/plugins/cad"
|
||||
TARGET_SKILLS_ROOT="$PLUGIN_ROOT/skills"
|
||||
CHECK_DIR="${PLUGIN_BUNDLE_CHECK_DIR:-${PLUGIN_BUILD_CHECK_DIR:-$REPO_ROOT/tmp/plugin-cad-check}}"
|
||||
LIST_SKILLS_SCRIPT="$REPO_ROOT/scripts/utils/list-skills.sh"
|
||||
PYTHON_BIN="${PYTHON_BIN:-python3}"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/bundle/bundle-plugin.sh [--check] [--clean]
|
||||
|
||||
Bundles the installable cad plugin package by copying the root skills/
|
||||
sources into plugins/cad/skills. The plugin package must not contain symlinks
|
||||
because provider installers cache plugin roots independently of this checkout.
|
||||
|
||||
Options:
|
||||
--check Bundle into tmp/ and fail if plugin outputs or metadata are stale.
|
||||
--clean Remove temporary bundle/check directories first.
|
||||
-h, --help
|
||||
Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
--clean)
|
||||
CLEAN=1
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
ensure_deps() {
|
||||
if ! command -v rsync >/dev/null 2>&1; then
|
||||
echo "rsync is required to bundle plugin skill copies." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "$SOURCE_SKILLS_ROOT" ]; then
|
||||
echo "Missing source skills directory: $SOURCE_SKILLS_ROOT" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "$PLUGIN_ROOT" ]; then
|
||||
echo "Missing plugin directory: $PLUGIN_ROOT" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -x "$LIST_SKILLS_SCRIPT" ]; then
|
||||
echo "Missing skill list script: $LIST_SKILLS_SCRIPT" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
list_skills() {
|
||||
"$LIST_SKILLS_SCRIPT"
|
||||
}
|
||||
|
||||
assert_no_symlinks() {
|
||||
local target_dir="$1"
|
||||
local first_link
|
||||
first_link="$(find "$target_dir" -type l -print -quit)"
|
||||
if [ -n "$first_link" ]; then
|
||||
echo "Plugin skill copy contains a symlink: $first_link" >&2
|
||||
echo "Run scripts/bundle/bundle-plugin.sh to bundle plugin skill copies." >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
sync_skills() {
|
||||
local target_root="$1"
|
||||
local skill
|
||||
|
||||
rm -rf "$target_root"
|
||||
mkdir -p "$target_root"
|
||||
|
||||
while IFS= read -r skill; do
|
||||
local source_dir="$SOURCE_SKILLS_ROOT/$skill"
|
||||
local target_dir="$target_root/$skill"
|
||||
if [ ! -d "$source_dir" ]; then
|
||||
echo "Missing source skill directory: skills/$skill" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$source_dir/SKILL.md" ]; then
|
||||
echo "Missing source skill manifest: skills/$skill/SKILL.md" >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$target_dir"
|
||||
rsync -aL --delete \
|
||||
--delete-excluded \
|
||||
--exclude __pycache__ \
|
||||
--exclude .pytest_cache \
|
||||
--exclude node_modules \
|
||||
--exclude '*.pyc' \
|
||||
--exclude tests \
|
||||
--exclude __tests__ \
|
||||
--exclude 'test_*.py' \
|
||||
--exclude '*_test.py' \
|
||||
--exclude '*.test.js' \
|
||||
--exclude '*.test.mjs' \
|
||||
--exclude '*.test.ts' \
|
||||
--exclude '*.test.tsx' \
|
||||
--exclude '*.spec.js' \
|
||||
--exclude '*.spec.mjs' \
|
||||
--exclude '*.spec.ts' \
|
||||
--exclude '*.spec.tsx' \
|
||||
"$source_dir/" "$target_dir/"
|
||||
done < <(list_skills)
|
||||
|
||||
assert_no_symlinks "$target_root"
|
||||
}
|
||||
|
||||
check_skill_names() {
|
||||
local target_root="$1"
|
||||
local expected actual
|
||||
expected="$(list_skills)"
|
||||
actual="$(find "$target_root" -maxdepth 1 -mindepth 1 -type d -exec basename {} \; | sort)"
|
||||
if [ "$actual" != "$expected" ]; then
|
||||
echo "Plugin skill list is stale." >&2
|
||||
echo "Expected:" >&2
|
||||
printf '%s\n' "$expected" >&2
|
||||
echo "Actual:" >&2
|
||||
printf '%s\n' "$actual" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_skills() {
|
||||
local check_skills_root="$CHECK_DIR/skills"
|
||||
local first_link
|
||||
|
||||
if [ ! -d "$TARGET_SKILLS_ROOT" ]; then
|
||||
echo "Missing generated plugin skill copy: plugins/cad/skills" >&2
|
||||
echo "Run scripts/bundle/bundle-plugin.sh and commit plugins/cad/skills." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
first_link="$(find "$TARGET_SKILLS_ROOT" -type l -print -quit)"
|
||||
if [ -n "$first_link" ]; then
|
||||
"$REPO_ROOT/scripts/dev/setup-plugin-symlink.sh" --check
|
||||
echo "Plugin skill copy is in development symlink layout; production copy freshness is checked on build-test/main."
|
||||
return
|
||||
fi
|
||||
|
||||
assert_no_symlinks "$TARGET_SKILLS_ROOT"
|
||||
check_skill_names "$TARGET_SKILLS_ROOT"
|
||||
|
||||
if ! diff -qr \
|
||||
-x __pycache__ \
|
||||
-x .pytest_cache \
|
||||
-x '*.pyc' \
|
||||
"$check_skills_root" "$TARGET_SKILLS_ROOT" >/tmp/plugin-cad-skills-diff.txt; then
|
||||
cat /tmp/plugin-cad-skills-diff.txt >&2
|
||||
echo "" >&2
|
||||
echo "Plugin skill copy is stale." >&2
|
||||
echo "Run scripts/bundle/bundle-plugin.sh and commit plugins/cad/skills." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Plugin skill copy is up to date."
|
||||
}
|
||||
|
||||
validate_plugin() {
|
||||
"$PYTHON_BIN" - "$REPO_ROOT" <<'PY'
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
repo_root = Path(sys.argv[1])
|
||||
|
||||
plugin_name = "cad"
|
||||
skills = sorted(
|
||||
path.name
|
||||
for path in (repo_root / "skills").iterdir()
|
||||
if path.is_dir() and (path / "SKILL.md").is_file()
|
||||
)
|
||||
|
||||
plugin_root = repo_root / "plugins" / plugin_name
|
||||
codex_manifest_path = plugin_root / ".codex-plugin" / "plugin.json"
|
||||
claude_manifest_path = plugin_root / ".claude-plugin" / "plugin.json"
|
||||
claude_marketplace_path = repo_root / ".claude-plugin" / "marketplace.json"
|
||||
codex_marketplace_path = repo_root / ".codex-plugin" / "marketplace.json"
|
||||
version_path = plugin_root / "VERSION"
|
||||
errors: list[str] = []
|
||||
|
||||
|
||||
def require(condition: bool, message: str) -> None:
|
||||
if not condition:
|
||||
errors.append(message)
|
||||
|
||||
|
||||
require(plugin_root.is_dir(), f"missing plugin directory: {plugin_root}")
|
||||
require(codex_manifest_path.is_file(), f"missing Codex plugin manifest: {codex_manifest_path}")
|
||||
require(claude_manifest_path.is_file(), f"missing Claude plugin manifest: {claude_manifest_path}")
|
||||
require(claude_marketplace_path.is_file(), f"missing Claude marketplace: {claude_marketplace_path}")
|
||||
require(codex_marketplace_path.is_file(), f"missing Codex marketplace: {codex_marketplace_path}")
|
||||
require(version_path.is_file(), f"missing plugin version file: {version_path}")
|
||||
|
||||
|
||||
def load_json_object(path: Path) -> dict[str, object]:
|
||||
if not path.is_file():
|
||||
return {}
|
||||
try:
|
||||
payload = json.loads(path.read_text(encoding="utf-8"))
|
||||
except json.JSONDecodeError as exc:
|
||||
errors.append(f"invalid JSON in {path}: {exc}")
|
||||
return {}
|
||||
if not isinstance(payload, dict):
|
||||
errors.append(f"{path} must contain a JSON object")
|
||||
return {}
|
||||
return payload
|
||||
|
||||
|
||||
def plugin_version() -> str:
|
||||
if not version_path.is_file():
|
||||
return ""
|
||||
return version_path.read_text(encoding="utf-8").strip()
|
||||
|
||||
|
||||
version = plugin_version()
|
||||
|
||||
|
||||
def validate_plugin_manifest(path: Path, provider: str) -> None:
|
||||
manifest = load_json_object(path)
|
||||
if not manifest:
|
||||
return
|
||||
require(manifest.get("name") == plugin_name, f"{provider} plugin manifest name is stale")
|
||||
require(manifest.get("version") == version, f"{provider} plugin manifest version is stale")
|
||||
require(manifest.get("skills") in {"./skills/", "./skills", "skills"}, f"{provider} plugin manifest must point at ./skills/")
|
||||
|
||||
|
||||
validate_plugin_manifest(codex_manifest_path, "Codex")
|
||||
validate_plugin_manifest(claude_manifest_path, "Claude")
|
||||
|
||||
codex_marketplace = load_json_object(codex_marketplace_path)
|
||||
if codex_marketplace:
|
||||
require(codex_marketplace.get("name") == "text-to-cad", "Codex marketplace name is stale")
|
||||
plugins = codex_marketplace.get("plugins")
|
||||
if not isinstance(plugins, list):
|
||||
errors.append("Codex marketplace plugins must be an array")
|
||||
else:
|
||||
cad_entries = [
|
||||
entry for entry in plugins
|
||||
if isinstance(entry, dict) and entry.get("name") == plugin_name
|
||||
]
|
||||
require(len(cad_entries) == 1, "Codex marketplace must contain exactly one cad plugin entry")
|
||||
if cad_entries:
|
||||
source = cad_entries[0].get("source")
|
||||
if not isinstance(source, dict):
|
||||
errors.append("Codex marketplace cad source must be an object")
|
||||
else:
|
||||
require(source.get("path") == "./plugins/cad", "Codex marketplace cad source path is stale")
|
||||
|
||||
claude_marketplace = load_json_object(claude_marketplace_path)
|
||||
if claude_marketplace:
|
||||
require(claude_marketplace.get("name") == "text-to-cad", "Claude marketplace name is stale")
|
||||
require(claude_marketplace.get("version") == version, "Claude marketplace version is stale")
|
||||
plugins = claude_marketplace.get("plugins")
|
||||
if not isinstance(plugins, list):
|
||||
errors.append("Claude marketplace plugins must be an array")
|
||||
else:
|
||||
cad_entries = [
|
||||
entry for entry in plugins
|
||||
if isinstance(entry, dict) and entry.get("name") == plugin_name
|
||||
]
|
||||
require(len(cad_entries) == 1, "Claude marketplace must contain exactly one cad plugin entry")
|
||||
if cad_entries:
|
||||
entry = cad_entries[0]
|
||||
require(entry.get("source") == "./plugins/cad", "Claude marketplace cad source is stale")
|
||||
require(entry.get("version") == version, "Claude marketplace cad version is stale")
|
||||
|
||||
skills_root = plugin_root / "skills"
|
||||
for skill in skills:
|
||||
root_skill = repo_root / "skills" / skill
|
||||
bundled_skill = skills_root / skill
|
||||
require(root_skill.is_dir(), f"missing source skill: {root_skill}")
|
||||
require((root_skill / "SKILL.md").is_file(), f"missing source skill manifest: {root_skill / 'SKILL.md'}")
|
||||
require(bundled_skill.is_dir(), f"plugin skill copy must be a directory: {bundled_skill}")
|
||||
if bundled_skill.is_symlink():
|
||||
require(
|
||||
bundled_skill.resolve() == root_skill.resolve(),
|
||||
f"plugin development symlink points at the wrong skill: {bundled_skill}",
|
||||
)
|
||||
require((bundled_skill / "SKILL.md").is_file(), f"missing plugin skill manifest: {bundled_skill / 'SKILL.md'}")
|
||||
|
||||
if skills_root.is_dir():
|
||||
for path in skills_root.rglob("*"):
|
||||
if path.is_symlink():
|
||||
if path.parent != skills_root:
|
||||
errors.append(f"plugin skill copy must not contain nested symlinks: {path}")
|
||||
|
||||
if skills_root.is_dir():
|
||||
bundled_names = sorted(path.name for path in skills_root.iterdir() if not path.name.startswith("."))
|
||||
require(bundled_names == skills, f"cad plugin bundled skill list is stale: {bundled_names}")
|
||||
|
||||
if errors:
|
||||
print("Plugin validation failed:")
|
||||
for error in errors:
|
||||
print(f"- {error}")
|
||||
raise SystemExit(1)
|
||||
|
||||
print(f"Plugin validation passed: {plugin_root}")
|
||||
PY
|
||||
}
|
||||
|
||||
ensure_deps
|
||||
|
||||
if [ "$CLEAN" -eq 1 ]; then
|
||||
rm -rf "$CHECK_DIR"
|
||||
fi
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
sync_skills "$CHECK_DIR/skills"
|
||||
check_skills
|
||||
validate_plugin
|
||||
else
|
||||
sync_skills "$TARGET_SKILLS_ROOT"
|
||||
echo "Bundled plugins/cad/skills"
|
||||
fi
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
SKILL_BUNDLE_DIR="$SCRIPT_DIR/skills"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/bundle/bundle-skill.sh <skill-id> [skill-bundle-args...]
|
||||
scripts/bundle/bundle-skill.sh --all [shared-skill-bundle-args...]
|
||||
|
||||
Runs bundle logic for one skill. Skill IDs map to
|
||||
scripts/bundle/skills/bundle-<skill-id>.sh.
|
||||
|
||||
Options:
|
||||
--all Run every skill bundle script under scripts/bundle/skills.
|
||||
-h, --help Show this help.
|
||||
|
||||
Skill-specific arguments are passed through to the selected bundle script.
|
||||
If a skill has no bundle script, this command fails.
|
||||
EOF
|
||||
}
|
||||
|
||||
list_bundleable_skills() {
|
||||
find "$SKILL_BUNDLE_DIR" -maxdepth 1 -type f -name 'bundle-*.sh' -print |
|
||||
while IFS= read -r script; do
|
||||
basename "$script" | sed -e 's/^bundle-//' -e 's/\.sh$//'
|
||||
done |
|
||||
LC_ALL=C sort
|
||||
}
|
||||
|
||||
run_skill_bundle() {
|
||||
local skill_id="$1"
|
||||
shift
|
||||
local bundle_script="$SKILL_BUNDLE_DIR/bundle-$skill_id.sh"
|
||||
|
||||
if [ ! -f "$REPO_ROOT/skills/$skill_id/SKILL.md" ]; then
|
||||
echo "Unknown skill: $skill_id" >&2
|
||||
echo "Known skills:" >&2
|
||||
"$REPO_ROOT/scripts/utils/list-skills.sh" | sed 's/^/- /' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x "$bundle_script" ]; then
|
||||
echo "Skill has no bundle logic: $skill_id" >&2
|
||||
echo "Expected bundle script: ${bundle_script#$REPO_ROOT/}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
"$bundle_script" "$@"
|
||||
}
|
||||
|
||||
if [ "$#" -eq 0 ]; then
|
||||
usage >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--all)
|
||||
shift
|
||||
while IFS= read -r skill_id; do
|
||||
run_skill_bundle "$skill_id" "$@"
|
||||
done < <(list_bundleable_skills)
|
||||
;;
|
||||
-*)
|
||||
echo "Unknown option: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
skill_id="$1"
|
||||
shift
|
||||
run_skill_bundle "$skill_id" "$@"
|
||||
;;
|
||||
esac
|
||||
Executable
+85
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
|
||||
MODE="write"
|
||||
SKILL_ARGS=()
|
||||
PLUGIN_ARGS=()
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/bundle/bundle.sh [--check] [--clean]
|
||||
|
||||
Universal generated-runtime and plugin package bundle wrapper.
|
||||
|
||||
Options:
|
||||
--check Bundle into tmp/ and fail if checked-in outputs are stale.
|
||||
--clean Remove temporary bundle/check directories first.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
SKILL_ARGS+=("--check")
|
||||
PLUGIN_ARGS+=("--check")
|
||||
;;
|
||||
--clean)
|
||||
SKILL_ARGS+=("--clean")
|
||||
PLUGIN_ARGS+=("--clean")
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
echo "Checking derived version metadata..."
|
||||
node "$REPO_ROOT/scripts/release/sync-version.mjs" --check
|
||||
else
|
||||
echo "Syncing derived version metadata..."
|
||||
node "$REPO_ROOT/scripts/release/sync-version.mjs"
|
||||
fi
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
echo "Checking bundle-capable skill outputs..."
|
||||
else
|
||||
echo "Bundling skill outputs..."
|
||||
fi
|
||||
if [ "${#SKILL_ARGS[@]}" -gt 0 ]; then
|
||||
"$SCRIPT_DIR/bundle-skill.sh" --all "${SKILL_ARGS[@]}"
|
||||
else
|
||||
"$SCRIPT_DIR/bundle-skill.sh" --all
|
||||
fi
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
echo "Checking plugin package skill copy..."
|
||||
else
|
||||
echo "Bundling plugin package skill copy..."
|
||||
fi
|
||||
if [ "${#PLUGIN_ARGS[@]}" -gt 0 ]; then
|
||||
"$SCRIPT_DIR/bundle-plugin.sh" "${PLUGIN_ARGS[@]}"
|
||||
else
|
||||
"$SCRIPT_DIR/bundle-plugin.sh"
|
||||
fi
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
echo "All bundle outputs are up to date."
|
||||
else
|
||||
echo "Bundled all production outputs."
|
||||
fi
|
||||
+513
@@ -0,0 +1,513 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
|
||||
MODE="write"
|
||||
BUILD=1
|
||||
CLEAN=0
|
||||
|
||||
CADJS_PACKAGE_DIR="$REPO_ROOT/packages/cadjs"
|
||||
CADPY_PACKAGE_DIR="$REPO_ROOT/packages/cadpy"
|
||||
IMPLICITJS_PACKAGE_DIR="$REPO_ROOT/packages/implicitjs"
|
||||
VIEWER_DIR="$REPO_ROOT/viewer"
|
||||
VIEWER_CADJS_DIR="$VIEWER_DIR/packages/cadjs"
|
||||
VIEWER_CADPY_DIR="$VIEWER_DIR/packages/cadpy"
|
||||
VIEWER_IMPLICITJS_DIR="$VIEWER_DIR/packages/implicitjs"
|
||||
RUNTIME_DIR="$REPO_ROOT/skills/cad-viewer/scripts/viewer"
|
||||
CHECK_DIR="${CAD_VIEWER_RUNTIME_CHECK_DIR:-${RENDER_VIEWER_RUNTIME_CHECK_DIR:-$REPO_ROOT/tmp/cad-viewer-runtime-check}}"
|
||||
VIEWER_PACKAGE_MANAGER="${CAD_VIEWER_PACKAGE_MANAGER:-}"
|
||||
ESBUILD_BIN="${CAD_VIEWER_ESBUILD_BIN:-}"
|
||||
RELEASE_VERSION="$(tr -d '[:space:]' < "$REPO_ROOT/plugins/cad/VERSION")"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/bundle/bundle-skill.sh cad-viewer [--check] [--clean] [--no-build]
|
||||
|
||||
Bundles the viewer-local package copies and the self-contained production CAD
|
||||
Viewer runtime used by skills/cad-viewer. Client sourcemaps are included so
|
||||
installed skill runtimes can be debugged from browser DevTools.
|
||||
|
||||
Options:
|
||||
--check Bundle into tmp/ and fail if viewer package copies or
|
||||
skills/cad-viewer/scripts/viewer are stale.
|
||||
--clean Remove generated package copies and temporary check directories first.
|
||||
--no-build Reuse the current viewer/dist instead of rebuilding the viewer.
|
||||
The existing dist must already include client sourcemaps.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
--clean)
|
||||
CLEAN=1
|
||||
;;
|
||||
--no-build)
|
||||
BUILD=0
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
require_path() {
|
||||
local path_to_check="$1"
|
||||
local label="$2"
|
||||
if [ ! -e "$path_to_check" ]; then
|
||||
echo "Missing $label: $path_to_check" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
require_command() {
|
||||
if ! command -v "$1" >/dev/null 2>&1; then
|
||||
echo "$1 is required to build the CAD Viewer runtime." >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
resolve_viewer_package_manager() {
|
||||
if [ -n "$VIEWER_PACKAGE_MANAGER" ]; then
|
||||
echo "$VIEWER_PACKAGE_MANAGER"
|
||||
return
|
||||
fi
|
||||
if command -v pnpm >/dev/null 2>&1; then
|
||||
echo "pnpm"
|
||||
return
|
||||
fi
|
||||
echo "npm"
|
||||
}
|
||||
|
||||
run_viewer_build() {
|
||||
local package_manager
|
||||
package_manager="$(resolve_viewer_package_manager)"
|
||||
require_command "$package_manager"
|
||||
case "$package_manager" in
|
||||
pnpm)
|
||||
CI=true pnpm --dir "$VIEWER_DIR" run build --sourcemap true
|
||||
;;
|
||||
npm)
|
||||
npm --prefix "$VIEWER_DIR" run build -- --sourcemap true
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported CAD Viewer package manager: $package_manager" >&2
|
||||
echo "Set CAD_VIEWER_PACKAGE_MANAGER to pnpm or npm." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
resolve_esbuild_bin() {
|
||||
if [ -n "$ESBUILD_BIN" ]; then
|
||||
echo "$ESBUILD_BIN"
|
||||
return
|
||||
fi
|
||||
if [ -x "$VIEWER_DIR/node_modules/.bin/esbuild" ]; then
|
||||
echo "$VIEWER_DIR/node_modules/.bin/esbuild"
|
||||
return
|
||||
fi
|
||||
local pnpm_esbuild_bin
|
||||
pnpm_esbuild_bin="$(find "$VIEWER_DIR/node_modules/.pnpm" -path '*/node_modules/esbuild/bin/esbuild' -type f -perm -111 -print -quit 2>/dev/null || true)"
|
||||
if [ -n "$pnpm_esbuild_bin" ]; then
|
||||
echo "$pnpm_esbuild_bin"
|
||||
return
|
||||
fi
|
||||
echo "$VIEWER_DIR/node_modules/.bin/esbuild"
|
||||
}
|
||||
|
||||
require_client_sourcemaps() {
|
||||
local dist_dir="$1"
|
||||
local map_count
|
||||
if [ ! -d "$dist_dir/assets" ]; then
|
||||
echo "Missing Viewer dist assets directory: $dist_dir/assets" >&2
|
||||
exit 1
|
||||
fi
|
||||
map_count="$(find "$dist_dir/assets" -type f -name '*.map' | wc -l | tr -d '[:space:]')"
|
||||
if [ "$map_count" -eq 0 ]; then
|
||||
echo "Missing Viewer client sourcemaps in $dist_dir/assets." >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh cad-viewer without --no-build to regenerate viewer/dist with sourcemaps." >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
sync_cadjs_package() {
|
||||
local target_dir="${1:-$VIEWER_CADJS_DIR}"
|
||||
rm -rf "$target_dir"
|
||||
mkdir -p "$target_dir"
|
||||
rsync -a --delete \
|
||||
--prune-empty-dirs \
|
||||
--delete-excluded \
|
||||
--exclude node_modules \
|
||||
--exclude dist \
|
||||
--exclude coverage \
|
||||
--exclude tmp \
|
||||
--exclude .vite \
|
||||
--exclude /common \
|
||||
--exclude /lib \
|
||||
--exclude .DS_Store \
|
||||
--exclude tests \
|
||||
--exclude __tests__ \
|
||||
--exclude '*.test.js' \
|
||||
--exclude '*.test.mjs' \
|
||||
--exclude '*.test.ts' \
|
||||
--exclude '*.test.tsx' \
|
||||
--exclude '*.spec.js' \
|
||||
--exclude '*.spec.mjs' \
|
||||
--exclude '*.spec.ts' \
|
||||
--exclude '*.spec.tsx' \
|
||||
"$CADJS_PACKAGE_DIR/" "$target_dir/"
|
||||
}
|
||||
|
||||
sync_implicitjs_package() {
|
||||
local target_dir="${1:-$VIEWER_IMPLICITJS_DIR}"
|
||||
rm -rf "$target_dir"
|
||||
mkdir -p "$target_dir"
|
||||
rsync -a --delete \
|
||||
--prune-empty-dirs \
|
||||
--delete-excluded \
|
||||
--exclude node_modules \
|
||||
--exclude dist \
|
||||
--exclude coverage \
|
||||
--exclude tmp \
|
||||
--exclude .vite \
|
||||
--exclude .DS_Store \
|
||||
"$IMPLICITJS_PACKAGE_DIR/" "$target_dir/"
|
||||
}
|
||||
|
||||
sync_cadpy_package() {
|
||||
local source_dir="$1"
|
||||
local target_dir="$2"
|
||||
rm -rf "$target_dir"
|
||||
mkdir -p "$target_dir"
|
||||
rsync -a --delete \
|
||||
--prune-empty-dirs \
|
||||
--delete-excluded \
|
||||
--exclude __pycache__ \
|
||||
--exclude .pytest_cache \
|
||||
--exclude '*.pyc' \
|
||||
--exclude '*.egg-info' \
|
||||
--exclude '*.md' \
|
||||
--exclude build \
|
||||
--exclude dist \
|
||||
--exclude tests \
|
||||
--exclude __tests__ \
|
||||
--exclude 'test_*.py' \
|
||||
--exclude '*_test.py' \
|
||||
"$source_dir/" "$target_dir/"
|
||||
}
|
||||
|
||||
check_cadjs_package() {
|
||||
local label="${VIEWER_CADJS_DIR#$REPO_ROOT/}"
|
||||
local diff_path="${TMPDIR:-/tmp}/viewer-cadjs-package-diff.txt"
|
||||
local expected_dir="${TMPDIR:-/tmp}/viewer-cadjs-package-check"
|
||||
if [ ! -d "$VIEWER_CADJS_DIR" ]; then
|
||||
echo "Missing generated viewer cadjs package: $label" >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh cad-viewer and commit the generated copy." >&2
|
||||
exit 1
|
||||
fi
|
||||
rm -rf "$expected_dir"
|
||||
sync_cadjs_package "$expected_dir"
|
||||
if ! diff -qr \
|
||||
-x node_modules \
|
||||
-x dist \
|
||||
-x coverage \
|
||||
-x tmp \
|
||||
-x .vite \
|
||||
-x .DS_Store \
|
||||
-x tests \
|
||||
-x __tests__ \
|
||||
-x '*.test.js' \
|
||||
-x '*.test.mjs' \
|
||||
-x '*.test.ts' \
|
||||
-x '*.test.tsx' \
|
||||
-x '*.spec.js' \
|
||||
-x '*.spec.mjs' \
|
||||
-x '*.spec.ts' \
|
||||
-x '*.spec.tsx' \
|
||||
"$expected_dir" "$VIEWER_CADJS_DIR" >"$diff_path"; then
|
||||
cat "$diff_path" >&2
|
||||
echo "" >&2
|
||||
echo "Viewer cadjs package is stale." >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh cad-viewer and commit viewer/packages/cadjs." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "$label is up to date."
|
||||
}
|
||||
|
||||
check_implicitjs_package() {
|
||||
local label="${VIEWER_IMPLICITJS_DIR#$REPO_ROOT/}"
|
||||
local diff_path="${TMPDIR:-/tmp}/viewer-implicitjs-package-diff.txt"
|
||||
local expected_dir="${TMPDIR:-/tmp}/viewer-implicitjs-package-check"
|
||||
if [ ! -d "$VIEWER_IMPLICITJS_DIR" ]; then
|
||||
echo "Missing generated viewer implicitjs package: $label" >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh cad-viewer and commit the generated copy." >&2
|
||||
exit 1
|
||||
fi
|
||||
rm -rf "$expected_dir"
|
||||
sync_implicitjs_package "$expected_dir"
|
||||
if ! diff -qr \
|
||||
-x node_modules \
|
||||
-x dist \
|
||||
-x coverage \
|
||||
-x tmp \
|
||||
-x .vite \
|
||||
-x .DS_Store \
|
||||
"$expected_dir" "$VIEWER_IMPLICITJS_DIR" >"$diff_path"; then
|
||||
cat "$diff_path" >&2
|
||||
echo "" >&2
|
||||
echo "Viewer implicitjs package is stale." >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh cad-viewer and commit viewer/packages/implicitjs." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "$label is up to date."
|
||||
}
|
||||
|
||||
check_cadpy_package() {
|
||||
local label="${VIEWER_CADPY_DIR#$REPO_ROOT/}"
|
||||
local diff_path="${TMPDIR:-/tmp}/viewer-cadpy-package-diff.txt"
|
||||
local expected_dir="${TMPDIR:-/tmp}/viewer-cadpy-package-check"
|
||||
if [ ! -d "$VIEWER_CADPY_DIR" ]; then
|
||||
echo "Missing generated viewer cadpy package: $label" >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh cad-viewer and commit the generated copy." >&2
|
||||
exit 1
|
||||
fi
|
||||
rm -rf "$expected_dir"
|
||||
sync_cadpy_package "$CADPY_PACKAGE_DIR" "$expected_dir"
|
||||
if ! diff -qr \
|
||||
-x __pycache__ \
|
||||
-x .pytest_cache \
|
||||
-x '*.pyc' \
|
||||
-x '*.egg-info' \
|
||||
-x '*.md' \
|
||||
-x build \
|
||||
-x dist \
|
||||
-x tests \
|
||||
-x __tests__ \
|
||||
-x 'test_*.py' \
|
||||
-x '*_test.py' \
|
||||
"$expected_dir" "$VIEWER_CADPY_DIR" >"$diff_path"; then
|
||||
cat "$diff_path" >&2
|
||||
echo "" >&2
|
||||
echo "Viewer cadpy package is stale." >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh cad-viewer and commit viewer/packages/cadpy." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "$label is up to date."
|
||||
}
|
||||
|
||||
build_viewer_packages() {
|
||||
if [ "$CLEAN" -eq 1 ]; then
|
||||
rm -rf "$VIEWER_CADJS_DIR"
|
||||
rm -rf "$VIEWER_CADPY_DIR"
|
||||
rm -rf "$VIEWER_IMPLICITJS_DIR"
|
||||
fi
|
||||
sync_cadjs_package
|
||||
sync_cadpy_package "$CADPY_PACKAGE_DIR" "$VIEWER_CADPY_DIR"
|
||||
sync_implicitjs_package
|
||||
echo "Bundled ${VIEWER_CADJS_DIR#$REPO_ROOT/}"
|
||||
echo "Bundled ${VIEWER_CADPY_DIR#$REPO_ROOT/}"
|
||||
echo "Bundled ${VIEWER_IMPLICITJS_DIR#$REPO_ROOT/}"
|
||||
}
|
||||
|
||||
ensure_viewer_cadjs_node_module_subpaths() {
|
||||
local cadjs_node_module="$VIEWER_DIR/node_modules/cadjs"
|
||||
if [ ! -d "$cadjs_node_module" ]; then
|
||||
return
|
||||
fi
|
||||
if [ -L "$cadjs_node_module" ]; then
|
||||
return
|
||||
fi
|
||||
local subpath
|
||||
for subpath in common lib; do
|
||||
if [ -d "$VIEWER_CADJS_DIR/src/$subpath" ] && [ ! -e "$cadjs_node_module/$subpath/stepSidecars.mjs" ] && [ ! -e "$cadjs_node_module/$subpath/pathUtils.mjs" ]; then
|
||||
rm -rf "$cadjs_node_module/$subpath"
|
||||
ln -s "$VIEWER_CADJS_DIR/src/$subpath" "$cadjs_node_module/$subpath"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
check_viewer_packages() {
|
||||
check_cadjs_package
|
||||
check_cadpy_package
|
||||
check_implicitjs_package
|
||||
}
|
||||
|
||||
write_runtime_package_json() {
|
||||
local target_dir="$1"
|
||||
cat > "$target_dir/package.json" <<EOF
|
||||
{
|
||||
"name": "cad-viewer-runtime",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"version": "$RELEASE_VERSION",
|
||||
"scripts": {
|
||||
"serve": "node backend/server.mjs",
|
||||
"start": "node backend/server.mjs",
|
||||
"moveit2:setup": "moveit2_server/setup.sh",
|
||||
"moveit2:check": "moveit2_server/check-moveit2-server.sh",
|
||||
"moveit2:serve": "moveit2_server/run-moveit2-server.sh"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
write_runtime_gitignore() {
|
||||
local target_dir="$1"
|
||||
cat > "$target_dir/.gitignore" <<'EOF'
|
||||
node_modules
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
!.env.*.example
|
||||
__pycache__
|
||||
*.py[cod]
|
||||
.pytest_cache
|
||||
tmp
|
||||
|
||||
!dist
|
||||
!dist/**
|
||||
EOF
|
||||
}
|
||||
|
||||
write_runtime_requirements() {
|
||||
local target_dir="$1"
|
||||
cat > "$target_dir/requirements.txt" <<'EOF'
|
||||
--editable ./packages/cadpy
|
||||
EOF
|
||||
}
|
||||
|
||||
sync_dir() {
|
||||
local source_dir="$1"
|
||||
local target_dir="$2"
|
||||
mkdir -p "$target_dir"
|
||||
rsync -a --delete \
|
||||
--prune-empty-dirs \
|
||||
--delete-excluded \
|
||||
--exclude node_modules \
|
||||
--exclude build \
|
||||
--exclude dist \
|
||||
--exclude .vite \
|
||||
--exclude .pytest_cache \
|
||||
--exclude __pycache__ \
|
||||
--exclude '*.pyc' \
|
||||
--exclude '*.egg-info' \
|
||||
--exclude '*.md' \
|
||||
--exclude '*.test.js' \
|
||||
--exclude '*.test.mjs' \
|
||||
--exclude '*.test.ts' \
|
||||
--exclude '*.test.tsx' \
|
||||
--exclude '*.spec.js' \
|
||||
--exclude '*.spec.mjs' \
|
||||
--exclude '*.spec.ts' \
|
||||
--exclude '*.spec.tsx' \
|
||||
--exclude tests \
|
||||
--exclude __tests__ \
|
||||
--exclude 'test_*.py' \
|
||||
--exclude '*_test.py' \
|
||||
"$source_dir/" "$target_dir/"
|
||||
}
|
||||
|
||||
build_runtime() {
|
||||
local target_dir="$1"
|
||||
rm -rf "$target_dir"
|
||||
mkdir -p "$target_dir/backend"
|
||||
|
||||
sync_dir "$VIEWER_DIR/dist" "$target_dir/dist"
|
||||
|
||||
if [ -d "$VIEWER_DIR/moveit2_server" ]; then
|
||||
sync_dir "$VIEWER_DIR/moveit2_server" "$target_dir/moveit2_server"
|
||||
fi
|
||||
|
||||
sync_dir "$VIEWER_DIR/packages" "$target_dir/packages"
|
||||
|
||||
(
|
||||
cd "$REPO_ROOT"
|
||||
"$(resolve_esbuild_bin)" "$VIEWER_DIR/src/server/server.mjs" \
|
||||
--bundle \
|
||||
--format=esm \
|
||||
--platform=node \
|
||||
--target=node22 \
|
||||
--main-fields=module,main \
|
||||
--legal-comments=none \
|
||||
--outfile="$target_dir/backend/server.mjs"
|
||||
|
||||
)
|
||||
|
||||
write_runtime_package_json "$target_dir"
|
||||
write_runtime_gitignore "$target_dir"
|
||||
write_runtime_requirements "$target_dir"
|
||||
}
|
||||
|
||||
check_runtime() {
|
||||
if [ -L "$RUNTIME_DIR" ]; then
|
||||
echo "CAD Viewer runtime is in development symlink layout; production runtime diff is checked on build-test/main."
|
||||
return
|
||||
fi
|
||||
if ! diff -qr \
|
||||
-x __pycache__ \
|
||||
-x .pytest_cache \
|
||||
-x '*.pyc' \
|
||||
-x '*.egg-info' \
|
||||
"$CHECK_DIR" "$RUNTIME_DIR" >/tmp/cad-viewer-runtime-diff.txt; then
|
||||
cat /tmp/cad-viewer-runtime-diff.txt >&2
|
||||
echo "" >&2
|
||||
echo "CAD Viewer runtime is stale." >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh cad-viewer and commit skills/cad-viewer/scripts/viewer." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "CAD Viewer runtime is up to date."
|
||||
}
|
||||
|
||||
require_command rsync
|
||||
require_path "$CADJS_PACKAGE_DIR/package.json" "cadjs package"
|
||||
require_path "$CADJS_PACKAGE_DIR/src" "cadjs source"
|
||||
require_path "$CADPY_PACKAGE_DIR/pyproject.toml" "cadpy package"
|
||||
require_path "$CADPY_PACKAGE_DIR/src/cadpy" "cadpy source"
|
||||
require_path "$IMPLICITJS_PACKAGE_DIR/package.json" "implicitjs package"
|
||||
require_path "$IMPLICITJS_PACKAGE_DIR/src" "implicitjs source"
|
||||
require_path "$VIEWER_DIR/package.json" "viewer package"
|
||||
require_path "$(resolve_esbuild_bin)" "viewer esbuild binary; install viewer dependencies"
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
check_viewer_packages
|
||||
else
|
||||
build_viewer_packages
|
||||
fi
|
||||
require_path "$VIEWER_CADPY_DIR/pyproject.toml" "viewer cadpy package"
|
||||
require_path "$VIEWER_CADPY_DIR/src/cadpy" "viewer cadpy source"
|
||||
require_path "$VIEWER_IMPLICITJS_DIR/package.json" "viewer implicitjs package"
|
||||
require_path "$VIEWER_IMPLICITJS_DIR/src" "viewer implicitjs source"
|
||||
|
||||
if [ "$CLEAN" -eq 1 ]; then
|
||||
rm -rf "$CHECK_DIR"
|
||||
fi
|
||||
|
||||
if [ "$BUILD" -eq 1 ]; then
|
||||
ensure_viewer_cadjs_node_module_subpaths
|
||||
run_viewer_build
|
||||
fi
|
||||
|
||||
require_path "$VIEWER_DIR/dist/index.html" "viewer production bundle"
|
||||
require_client_sourcemaps "$VIEWER_DIR/dist"
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
build_runtime "$CHECK_DIR"
|
||||
check_runtime
|
||||
else
|
||||
build_runtime "$RUNTIME_DIR"
|
||||
echo "Bundled skills/cad-viewer/scripts/viewer"
|
||||
fi
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
|
||||
MODE="write"
|
||||
CLEAN=0
|
||||
INSTALL_DEPS=1
|
||||
|
||||
ESBUILD_VERSION="${CAD_SNAPSHOT_ESBUILD_VERSION:-0.27.7}"
|
||||
THREE_VERSION="${CAD_SNAPSHOT_THREE_VERSION:-0.160.0}"
|
||||
GIFENC_VERSION="${CAD_SNAPSHOT_GIFENC_VERSION:-1.0.3}"
|
||||
|
||||
BUILD_DEPS_DIR="${CAD_SNAPSHOT_BUILD_DEPS_DIR:-$REPO_ROOT/tmp/cad-snapshot-build}"
|
||||
CHECK_DIR="${CAD_SNAPSHOT_CHECK_DIR:-$REPO_ROOT/tmp/cad-snapshot-runtime-check}"
|
||||
RUNTIME_DIR="$REPO_ROOT/skills/cad/scripts/snapshot/runtime"
|
||||
ENTRYPOINT="$REPO_ROOT/packages/cadjs/src/common/headlessRenderEntry.js"
|
||||
CADPY_PACKAGE_DIR="$REPO_ROOT/packages/cadpy"
|
||||
CADPY_RUNTIME_DIR="$REPO_ROOT/skills/cad/scripts/packages/cadpy"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/bundle/bundle-skill.sh cad [--check] [--clean] [--no-install]
|
||||
|
||||
Bundles the self-contained browser runtime used by skills/cad/scripts/snapshot
|
||||
and the bundled Python package runtime used by skills/cad/scripts.
|
||||
|
||||
Options:
|
||||
--check Bundle into tmp/ and fail if snapshot/runtime is stale.
|
||||
--clean Remove the temporary dependency/build directories first.
|
||||
--no-install Require existing build dependencies in tmp/cad-snapshot-build.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
--clean)
|
||||
CLEAN=1
|
||||
;;
|
||||
--no-install)
|
||||
INSTALL_DEPS=0
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ ! -f "$ENTRYPOINT" ]; then
|
||||
echo "Missing snapshot render entrypoint: $ENTRYPOINT" >&2
|
||||
echo "The CAD snapshot runtime is built from the same shared render entrypoint used by CAD Viewer." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$CADPY_PACKAGE_DIR/pyproject.toml" ] || [ ! -d "$CADPY_PACKAGE_DIR/src/cadpy" ]; then
|
||||
echo "Missing cadpy package source: $CADPY_PACKAGE_DIR" >&2
|
||||
echo "The CAD skill Python runtime is bundled from packages/cadpy." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$CLEAN" -eq 1 ]; then
|
||||
rm -rf "$BUILD_DEPS_DIR" "$CHECK_DIR"
|
||||
fi
|
||||
|
||||
need_install() {
|
||||
[ -x "$BUILD_DEPS_DIR/node_modules/.bin/esbuild" ] || return 0
|
||||
node <<EOF || return 0
|
||||
const deps = {
|
||||
esbuild: "$ESBUILD_VERSION",
|
||||
three: "$THREE_VERSION",
|
||||
gifenc: "$GIFENC_VERSION",
|
||||
};
|
||||
for (const [name, expected] of Object.entries(deps)) {
|
||||
const actual = require("$BUILD_DEPS_DIR/node_modules/" + name + "/package.json").version;
|
||||
if (actual !== expected) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
EOF
|
||||
return 1
|
||||
}
|
||||
|
||||
ensure_deps() {
|
||||
if ! command -v rsync >/dev/null 2>&1; then
|
||||
echo "rsync is required to build the CAD skill Python runtime." >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! command -v npm >/dev/null 2>&1; then
|
||||
echo "npm is required to build the CAD snapshot runtime." >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! command -v node >/dev/null 2>&1; then
|
||||
echo "node is required to build the CAD snapshot runtime." >&2
|
||||
exit 1
|
||||
fi
|
||||
if need_install; then
|
||||
if [ "$INSTALL_DEPS" -eq 0 ]; then
|
||||
echo "Missing or stale build dependencies in $BUILD_DEPS_DIR." >&2
|
||||
echo "Run without --no-install to install them." >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$BUILD_DEPS_DIR"
|
||||
npm install --prefix "$BUILD_DEPS_DIR" --no-audit --no-fund \
|
||||
--fetch-retries=1 --fetch-timeout=10000 \
|
||||
"esbuild@$ESBUILD_VERSION" \
|
||||
"three@$THREE_VERSION" \
|
||||
"gifenc@$GIFENC_VERSION"
|
||||
fi
|
||||
}
|
||||
|
||||
write_render_html() {
|
||||
local target_dir="$1"
|
||||
cat > "$target_dir/render.html" <<'EOF'
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>CAD snapshot render</title>
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
min-width: 100%;
|
||||
min-height: 100%;
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module" src="/snapshot-render.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
}
|
||||
|
||||
build_runtime() {
|
||||
local target_dir="$1"
|
||||
rm -rf "$target_dir"
|
||||
mkdir -p "$target_dir"
|
||||
write_render_html "$target_dir"
|
||||
"$BUILD_DEPS_DIR/node_modules/.bin/esbuild" "$ENTRYPOINT" \
|
||||
--bundle \
|
||||
--format=esm \
|
||||
--platform=browser \
|
||||
--target=es2022 \
|
||||
--main-fields=module,main \
|
||||
--minify \
|
||||
--legal-comments=none \
|
||||
--alias:three="$BUILD_DEPS_DIR/node_modules/three" \
|
||||
--alias:gifenc="$BUILD_DEPS_DIR/node_modules/gifenc/dist/gifenc.esm.js" \
|
||||
--outfile="$target_dir/snapshot-render.js"
|
||||
}
|
||||
|
||||
sync_cadpy_runtime() {
|
||||
local target_dir="$1"
|
||||
rm -rf "$target_dir"
|
||||
mkdir -p "$target_dir"
|
||||
rsync -a --delete \
|
||||
--delete-excluded \
|
||||
--exclude __pycache__ \
|
||||
--exclude .pytest_cache \
|
||||
--exclude '*.pyc' \
|
||||
--exclude '*.md' \
|
||||
--exclude build \
|
||||
--exclude dist \
|
||||
--exclude '*.egg-info' \
|
||||
--exclude tests \
|
||||
--exclude __tests__ \
|
||||
--exclude 'test_*.py' \
|
||||
--exclude '*_test.py' \
|
||||
"$CADPY_PACKAGE_DIR/" "$target_dir/"
|
||||
}
|
||||
|
||||
check_runtime() {
|
||||
local stale=0
|
||||
for file in render.html snapshot-render.js; do
|
||||
if [ ! -f "$RUNTIME_DIR/$file" ]; then
|
||||
echo "Missing generated runtime file: skills/cad/scripts/snapshot/runtime/$file" >&2
|
||||
stale=1
|
||||
continue
|
||||
fi
|
||||
if ! cmp -s "$CHECK_DIR/$file" "$RUNTIME_DIR/$file"; then
|
||||
echo "Stale generated runtime file: skills/cad/scripts/snapshot/runtime/$file" >&2
|
||||
stale=1
|
||||
fi
|
||||
done
|
||||
if [ "$stale" -ne 0 ]; then
|
||||
echo "" >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh cad and commit the updated runtime files." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "CAD snapshot runtime is up to date."
|
||||
}
|
||||
|
||||
check_cadpy_runtime() {
|
||||
local check_dir="$CHECK_DIR/packages/cadpy"
|
||||
if [ ! -d "$CADPY_RUNTIME_DIR" ]; then
|
||||
echo "Missing generated cadpy runtime: skills/cad/scripts/packages/cadpy" >&2
|
||||
echo "" >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh cad and commit the updated runtime files." >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! diff -qr \
|
||||
-x __pycache__ \
|
||||
-x .pytest_cache \
|
||||
-x '*.pyc' \
|
||||
-x '*.egg-info' \
|
||||
-x '*.md' \
|
||||
-x tests \
|
||||
-x __tests__ \
|
||||
-x 'test_*.py' \
|
||||
-x '*_test.py' \
|
||||
"$check_dir" "$CADPY_RUNTIME_DIR" >/tmp/cad-skill-cadpy-runtime-diff.txt; then
|
||||
cat /tmp/cad-skill-cadpy-runtime-diff.txt >&2
|
||||
echo "" >&2
|
||||
echo "CAD skill cadpy runtime is stale." >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh cad and commit skills/cad/scripts/packages/cadpy." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "CAD skill cadpy runtime is up to date."
|
||||
}
|
||||
|
||||
ensure_deps
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
build_runtime "$CHECK_DIR"
|
||||
sync_cadpy_runtime "$CHECK_DIR/packages/cadpy"
|
||||
check_runtime
|
||||
check_cadpy_runtime
|
||||
else
|
||||
build_runtime "$RUNTIME_DIR"
|
||||
sync_cadpy_runtime "$CADPY_RUNTIME_DIR"
|
||||
echo "Bundled skills/cad/scripts/snapshot/runtime"
|
||||
echo "Bundled skills/cad/scripts/packages/cadpy"
|
||||
fi
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
|
||||
MODE="write"
|
||||
CLEAN=0
|
||||
|
||||
CHECK_DIR="${DXF_SKILL_CHECK_DIR:-$REPO_ROOT/tmp/dxf-skill-runtime-check}"
|
||||
CADPY_PACKAGE_DIR="$REPO_ROOT/packages/cadpy"
|
||||
CADPY_RUNTIME_DIR="$REPO_ROOT/skills/dxf/scripts/packages/cadpy"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/bundle/bundle-skill.sh dxf [--check] [--clean]
|
||||
|
||||
Vendors packages/cadpy into skills/dxf/scripts/packages/cadpy.
|
||||
|
||||
Options:
|
||||
--check Fail if the generated DXF skill runtime copy is stale.
|
||||
--clean Remove the temporary check directory first.
|
||||
-h, --help
|
||||
Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
--clean)
|
||||
CLEAN=1
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ ! -f "$CADPY_PACKAGE_DIR/pyproject.toml" ] || [ ! -d "$CADPY_PACKAGE_DIR/src/cadpy" ]; then
|
||||
echo "Missing cadpy package source: $CADPY_PACKAGE_DIR" >&2
|
||||
echo "The DXF skill Python runtime is bundled from packages/cadpy." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v rsync >/dev/null 2>&1; then
|
||||
echo "rsync is required to vendor cadpy into the DXF skill runtime." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$CLEAN" -eq 1 ]; then
|
||||
rm -rf "$CHECK_DIR"
|
||||
fi
|
||||
|
||||
sync_cadpy_runtime() {
|
||||
local target_dir="$1"
|
||||
rm -rf "$target_dir"
|
||||
mkdir -p "$target_dir"
|
||||
rsync -a --delete \
|
||||
--delete-excluded \
|
||||
--exclude __pycache__ \
|
||||
--exclude .pytest_cache \
|
||||
--exclude '*.pyc' \
|
||||
--exclude '*.md' \
|
||||
--exclude build \
|
||||
--exclude dist \
|
||||
--exclude '*.egg-info' \
|
||||
--exclude tests \
|
||||
--exclude __tests__ \
|
||||
--exclude 'test_*.py' \
|
||||
--exclude '*_test.py' \
|
||||
"$CADPY_PACKAGE_DIR/" "$target_dir/"
|
||||
}
|
||||
|
||||
check_cadpy_runtime() {
|
||||
local check_dir="$CHECK_DIR/packages/cadpy"
|
||||
if [ ! -d "$CADPY_RUNTIME_DIR" ]; then
|
||||
echo "Missing generated cadpy runtime: skills/dxf/scripts/packages/cadpy" >&2
|
||||
echo "" >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh dxf and commit the updated runtime files." >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! diff -qr \
|
||||
-x __pycache__ \
|
||||
-x .pytest_cache \
|
||||
-x '*.pyc' \
|
||||
-x '*.egg-info' \
|
||||
-x '*.md' \
|
||||
-x tests \
|
||||
-x __tests__ \
|
||||
-x 'test_*.py' \
|
||||
-x '*_test.py' \
|
||||
"$check_dir" "$CADPY_RUNTIME_DIR" >/tmp/dxf-skill-cadpy-runtime-diff.txt; then
|
||||
cat /tmp/dxf-skill-cadpy-runtime-diff.txt >&2
|
||||
echo "" >&2
|
||||
echo "DXF skill cadpy runtime is stale." >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh dxf and commit skills/dxf/scripts/packages/cadpy." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "DXF skill cadpy runtime is up to date."
|
||||
}
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
sync_cadpy_runtime "$CHECK_DIR/packages/cadpy"
|
||||
check_cadpy_runtime
|
||||
else
|
||||
sync_cadpy_runtime "$CADPY_RUNTIME_DIR"
|
||||
echo "Bundled skills/dxf/scripts/packages/cadpy"
|
||||
fi
|
||||
@@ -0,0 +1,144 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
|
||||
MODE="write"
|
||||
CLEAN=0
|
||||
|
||||
IMPLICITJS_PACKAGE_DIR="$REPO_ROOT/packages/implicitjs"
|
||||
IMPLICITJS_RUNTIME_DIR="$REPO_ROOT/skills/implicit-cad/scripts/packages/implicitjs"
|
||||
CHECK_DIR="${IMPLICIT_CAD_SKILL_BUNDLE_CHECK_DIR:-$REPO_ROOT/tmp/implicit-cad-skill-runtime-check}"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/bundle/bundle-skill.sh implicit-cad [--check] [--clean]
|
||||
|
||||
Bundles the implicitjs package copy used by skills/implicit-cad in production
|
||||
layouts.
|
||||
|
||||
Options:
|
||||
--check Bundle into tmp/ and fail if checked-in production outputs are stale.
|
||||
--clean Remove temporary check directories first.
|
||||
-h, --help
|
||||
Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
--clean)
|
||||
CLEAN=1
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
require_file() {
|
||||
local path_to_check="$1"
|
||||
local label="$2"
|
||||
if [ ! -f "$path_to_check" ]; then
|
||||
echo "Missing $label: $path_to_check" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
require_dir() {
|
||||
local path_to_check="$1"
|
||||
local label="$2"
|
||||
if [ ! -d "$path_to_check" ]; then
|
||||
echo "Missing $label: $path_to_check" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
sync_implicitjs_package() {
|
||||
local target_dir="$1"
|
||||
rm -rf "$target_dir"
|
||||
mkdir -p "$target_dir"
|
||||
rsync -a --delete \
|
||||
--prune-empty-dirs \
|
||||
--delete-excluded \
|
||||
--exclude node_modules \
|
||||
--exclude dist \
|
||||
--exclude coverage \
|
||||
--exclude tmp \
|
||||
--exclude .vite \
|
||||
--exclude .DS_Store \
|
||||
"$IMPLICITJS_PACKAGE_DIR/" "$target_dir/"
|
||||
}
|
||||
|
||||
check_implicitjs_package() {
|
||||
local expected_dir="$CHECK_DIR/packages/implicitjs"
|
||||
local label="${IMPLICITJS_RUNTIME_DIR#$REPO_ROOT/}"
|
||||
local diff_path="${TMPDIR:-/tmp}/implicit-cad-skill-implicitjs-package-diff.txt"
|
||||
if [ ! -d "$IMPLICITJS_RUNTIME_DIR" ]; then
|
||||
echo "Missing generated implicitjs package runtime: $label" >&2
|
||||
return 1
|
||||
fi
|
||||
if ! diff -qr \
|
||||
-x node_modules \
|
||||
-x dist \
|
||||
-x coverage \
|
||||
-x tmp \
|
||||
-x .vite \
|
||||
-x .DS_Store \
|
||||
"$expected_dir" "$IMPLICITJS_RUNTIME_DIR" >"$diff_path"; then
|
||||
cat "$diff_path" >&2
|
||||
echo "" >&2
|
||||
echo "Implicit CAD skill implicitjs package runtime is stale." >&2
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
check_development_layout() {
|
||||
"$REPO_ROOT/scripts/dev/setup-skill-symlink.sh" implicit-cad --check
|
||||
echo "Implicit CAD skill is in development symlink layout; production package freshness is checked on build-test/main."
|
||||
}
|
||||
|
||||
require_file "$IMPLICITJS_PACKAGE_DIR/package.json" "implicitjs package"
|
||||
require_dir "$IMPLICITJS_PACKAGE_DIR/src" "implicitjs source"
|
||||
require_file "$IMPLICITJS_PACKAGE_DIR/scripts/snapshot.mjs" "implicit CAD snapshot CLI"
|
||||
require_file "$IMPLICITJS_PACKAGE_DIR/scripts/export.mjs" "implicit CAD export CLI"
|
||||
|
||||
if [ "$MODE" = "check" ] && [ -L "$IMPLICITJS_RUNTIME_DIR" ]; then
|
||||
check_development_layout
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$CLEAN" -eq 1 ]; then
|
||||
rm -rf "$CHECK_DIR"
|
||||
fi
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
rm -rf "$CHECK_DIR"
|
||||
sync_implicitjs_package "$CHECK_DIR/packages/implicitjs"
|
||||
|
||||
stale=0
|
||||
check_implicitjs_package || stale=1
|
||||
|
||||
if [ "$stale" -ne 0 ]; then
|
||||
echo "" >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh implicit-cad and commit the updated production package copy." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Implicit CAD skill production outputs are up to date."
|
||||
else
|
||||
sync_implicitjs_package "$IMPLICITJS_RUNTIME_DIR"
|
||||
echo "Bundled skills/implicit-cad/scripts/packages/implicitjs"
|
||||
fi
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
|
||||
MODE="write"
|
||||
CLEAN=0
|
||||
PACKAGE_DIR="$REPO_ROOT/packages/cadpy_metadata"
|
||||
RUNTIME_DIR="$REPO_ROOT/skills/sdf/scripts/packages/cadpy_metadata"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/bundle/bundle-skill.sh sdf [--check] [--clean]
|
||||
|
||||
Vendors packages/cadpy_metadata into skills/sdf/scripts/packages/cadpy_metadata.
|
||||
|
||||
Options:
|
||||
--check Fail if the generated SDF skill runtime copy is stale.
|
||||
--clean Remove the generated runtime copy before writing it.
|
||||
-h, --help
|
||||
Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
--clean)
|
||||
CLEAN=1
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ ! -f "$PACKAGE_DIR/pyproject.toml" ] || [ ! -d "$PACKAGE_DIR/src/cadpy_metadata" ]; then
|
||||
echo "Missing cadpy_metadata package source: $PACKAGE_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v rsync >/dev/null 2>&1; then
|
||||
echo "rsync is required to vendor cadpy_metadata into the SDF skill runtime." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sync_runtime() {
|
||||
rm -rf "$RUNTIME_DIR"
|
||||
mkdir -p "$RUNTIME_DIR"
|
||||
rsync -a --delete \
|
||||
--delete-excluded \
|
||||
--exclude __pycache__ \
|
||||
--exclude .pytest_cache \
|
||||
--exclude '*.pyc' \
|
||||
--exclude '*.egg-info' \
|
||||
--exclude '*.md' \
|
||||
--exclude build \
|
||||
--exclude dist \
|
||||
--exclude tests \
|
||||
--exclude __tests__ \
|
||||
--exclude 'test_*.py' \
|
||||
--exclude '*_test.py' \
|
||||
"$PACKAGE_DIR/" "$RUNTIME_DIR/"
|
||||
}
|
||||
|
||||
check_runtime() {
|
||||
local label="${RUNTIME_DIR#$REPO_ROOT/}"
|
||||
local diff_path="${TMPDIR:-/tmp}/sdf-skill-cadpy-metadata-diff.txt"
|
||||
if [ ! -d "$RUNTIME_DIR" ]; then
|
||||
echo "Missing generated cadpy_metadata runtime: $label" >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh sdf and commit the generated copy." >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! diff -qr \
|
||||
-x __pycache__ \
|
||||
-x .pytest_cache \
|
||||
-x '*.pyc' \
|
||||
-x '*.egg-info' \
|
||||
-x '*.md' \
|
||||
-x build \
|
||||
-x dist \
|
||||
-x tests \
|
||||
-x __tests__ \
|
||||
-x 'test_*.py' \
|
||||
-x '*_test.py' \
|
||||
"$PACKAGE_DIR" "$RUNTIME_DIR" >"$diff_path"; then
|
||||
cat "$diff_path" >&2
|
||||
echo "" >&2
|
||||
echo "Stale generated cadpy_metadata runtime: $label" >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh sdf and commit the generated copy." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "$label is up to date."
|
||||
}
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
check_runtime
|
||||
else
|
||||
if [ "$CLEAN" -eq 1 ]; then
|
||||
rm -rf "$RUNTIME_DIR"
|
||||
fi
|
||||
sync_runtime
|
||||
echo "Bundled ${RUNTIME_DIR#$REPO_ROOT/}"
|
||||
fi
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
|
||||
MODE="write"
|
||||
CLEAN=0
|
||||
PACKAGE_DIR="$REPO_ROOT/packages/cadpy_metadata"
|
||||
RUNTIME_DIR="$REPO_ROOT/skills/srdf/scripts/packages/cadpy_metadata"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/bundle/bundle-skill.sh srdf [--check] [--clean]
|
||||
|
||||
Vendors packages/cadpy_metadata into skills/srdf/scripts/packages/cadpy_metadata.
|
||||
|
||||
Options:
|
||||
--check Fail if the generated SRDF skill runtime copy is stale.
|
||||
--clean Remove the generated runtime copy before writing it.
|
||||
-h, --help
|
||||
Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
--clean)
|
||||
CLEAN=1
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ ! -f "$PACKAGE_DIR/pyproject.toml" ] || [ ! -d "$PACKAGE_DIR/src/cadpy_metadata" ]; then
|
||||
echo "Missing cadpy_metadata package source: $PACKAGE_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v rsync >/dev/null 2>&1; then
|
||||
echo "rsync is required to vendor cadpy_metadata into the SRDF skill runtime." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sync_runtime() {
|
||||
rm -rf "$RUNTIME_DIR"
|
||||
mkdir -p "$RUNTIME_DIR"
|
||||
rsync -a --delete \
|
||||
--delete-excluded \
|
||||
--exclude __pycache__ \
|
||||
--exclude .pytest_cache \
|
||||
--exclude '*.pyc' \
|
||||
--exclude '*.egg-info' \
|
||||
--exclude '*.md' \
|
||||
--exclude build \
|
||||
--exclude dist \
|
||||
--exclude tests \
|
||||
--exclude __tests__ \
|
||||
--exclude 'test_*.py' \
|
||||
--exclude '*_test.py' \
|
||||
"$PACKAGE_DIR/" "$RUNTIME_DIR/"
|
||||
}
|
||||
|
||||
check_runtime() {
|
||||
local label="${RUNTIME_DIR#$REPO_ROOT/}"
|
||||
local diff_path="${TMPDIR:-/tmp}/srdf-skill-cadpy-metadata-diff.txt"
|
||||
if [ ! -d "$RUNTIME_DIR" ]; then
|
||||
echo "Missing generated cadpy_metadata runtime: $label" >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh srdf and commit the generated copy." >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! diff -qr \
|
||||
-x __pycache__ \
|
||||
-x .pytest_cache \
|
||||
-x '*.pyc' \
|
||||
-x '*.egg-info' \
|
||||
-x '*.md' \
|
||||
-x build \
|
||||
-x dist \
|
||||
-x tests \
|
||||
-x __tests__ \
|
||||
-x 'test_*.py' \
|
||||
-x '*_test.py' \
|
||||
"$PACKAGE_DIR" "$RUNTIME_DIR" >"$diff_path"; then
|
||||
cat "$diff_path" >&2
|
||||
echo "" >&2
|
||||
echo "Stale generated cadpy_metadata runtime: $label" >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh srdf and commit the generated copy." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "$label is up to date."
|
||||
}
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
check_runtime
|
||||
else
|
||||
if [ "$CLEAN" -eq 1 ]; then
|
||||
rm -rf "$RUNTIME_DIR"
|
||||
fi
|
||||
sync_runtime
|
||||
echo "Bundled ${RUNTIME_DIR#$REPO_ROOT/}"
|
||||
fi
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
|
||||
MODE="write"
|
||||
CLEAN=0
|
||||
PACKAGE_DIR="$REPO_ROOT/packages/cadpy_metadata"
|
||||
RUNTIME_DIR="$REPO_ROOT/skills/urdf/scripts/packages/cadpy_metadata"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/bundle/bundle-skill.sh urdf [--check] [--clean]
|
||||
|
||||
Vendors packages/cadpy_metadata into skills/urdf/scripts/packages/cadpy_metadata.
|
||||
|
||||
Options:
|
||||
--check Fail if the generated URDF skill runtime copy is stale.
|
||||
--clean Remove the generated runtime copy before writing it.
|
||||
-h, --help
|
||||
Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
--clean)
|
||||
CLEAN=1
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ ! -f "$PACKAGE_DIR/pyproject.toml" ] || [ ! -d "$PACKAGE_DIR/src/cadpy_metadata" ]; then
|
||||
echo "Missing cadpy_metadata package source: $PACKAGE_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v rsync >/dev/null 2>&1; then
|
||||
echo "rsync is required to vendor cadpy_metadata into the URDF skill runtime." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sync_runtime() {
|
||||
rm -rf "$RUNTIME_DIR"
|
||||
mkdir -p "$RUNTIME_DIR"
|
||||
rsync -a --delete \
|
||||
--delete-excluded \
|
||||
--exclude __pycache__ \
|
||||
--exclude .pytest_cache \
|
||||
--exclude '*.pyc' \
|
||||
--exclude '*.egg-info' \
|
||||
--exclude '*.md' \
|
||||
--exclude build \
|
||||
--exclude dist \
|
||||
--exclude tests \
|
||||
--exclude __tests__ \
|
||||
--exclude 'test_*.py' \
|
||||
--exclude '*_test.py' \
|
||||
"$PACKAGE_DIR/" "$RUNTIME_DIR/"
|
||||
}
|
||||
|
||||
check_runtime() {
|
||||
local label="${RUNTIME_DIR#$REPO_ROOT/}"
|
||||
local diff_path="${TMPDIR:-/tmp}/urdf-skill-cadpy-metadata-diff.txt"
|
||||
if [ ! -d "$RUNTIME_DIR" ]; then
|
||||
echo "Missing generated cadpy_metadata runtime: $label" >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh urdf and commit the generated copy." >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! diff -qr \
|
||||
-x __pycache__ \
|
||||
-x .pytest_cache \
|
||||
-x '*.pyc' \
|
||||
-x '*.egg-info' \
|
||||
-x '*.md' \
|
||||
-x build \
|
||||
-x dist \
|
||||
-x tests \
|
||||
-x __tests__ \
|
||||
-x 'test_*.py' \
|
||||
-x '*_test.py' \
|
||||
"$PACKAGE_DIR" "$RUNTIME_DIR" >"$diff_path"; then
|
||||
cat "$diff_path" >&2
|
||||
echo "" >&2
|
||||
echo "Stale generated cadpy_metadata runtime: $label" >&2
|
||||
echo "Run scripts/bundle/bundle-skill.sh urdf and commit the generated copy." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "$label is up to date."
|
||||
}
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
check_runtime
|
||||
else
|
||||
if [ "$CLEAN" -eq 1 ]; then
|
||||
rm -rf "$RUNTIME_DIR"
|
||||
fi
|
||||
sync_runtime
|
||||
echo "Bundled ${RUNTIME_DIR#$REPO_ROOT/}"
|
||||
fi
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
LIST_SKILLS_SCRIPT="$REPO_ROOT/scripts/utils/list-skills.sh"
|
||||
UTILS_SCRIPT="$SCRIPT_DIR/symlink-utils.sh"
|
||||
|
||||
MODE="write"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/dev/setup-plugin-symlink.sh [--check]
|
||||
|
||||
Sets up plugins/cad/skills as symlinks to root skills/* for development.
|
||||
|
||||
Options:
|
||||
--check Verify plugin development symlinks are intact without changing files.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ ! -x "$LIST_SKILLS_SCRIPT" ]; then
|
||||
echo "Missing skill list script: $LIST_SKILLS_SCRIPT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# shellcheck source=scripts/dev/symlink-utils.sh
|
||||
source "$UTILS_SCRIPT"
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
if [ "$MODE" != "check" ]; then
|
||||
mkdir -p "plugins/cad/skills"
|
||||
fi
|
||||
|
||||
while IFS= read -r skill; do
|
||||
setup_link "$MODE" "plugins/cad/skills/$skill" "../../../skills/$skill"
|
||||
done < <("$LIST_SKILLS_SCRIPT")
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
SKILL_SYMLINK_DIR="$SCRIPT_DIR/skills"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/dev/setup-skill-symlink.sh <skill-id> [skill-symlink-args...]
|
||||
scripts/dev/setup-skill-symlink.sh --all [shared-skill-symlink-args...]
|
||||
|
||||
Sets up development symlinks for one skill. Skill IDs map to
|
||||
scripts/dev/skills/setup-<skill-id>-skill-symlink.sh.
|
||||
|
||||
Options:
|
||||
--all Run every skill symlink setup script under scripts/dev/skills.
|
||||
-h, --help Show this help.
|
||||
|
||||
Skill-specific arguments are passed through to the selected setup script.
|
||||
If a skill has no symlink setup script, this command fails.
|
||||
EOF
|
||||
}
|
||||
|
||||
list_linkable_skills() {
|
||||
find "$SKILL_SYMLINK_DIR" -maxdepth 1 -type f -name 'setup-*-skill-symlink.sh' -print |
|
||||
while IFS= read -r script; do
|
||||
basename "$script" | sed -e 's/^setup-//' -e 's/-skill-symlink\.sh$//'
|
||||
done |
|
||||
LC_ALL=C sort
|
||||
}
|
||||
|
||||
run_skill_setup() {
|
||||
local skill_id="$1"
|
||||
shift
|
||||
local setup_script="$SKILL_SYMLINK_DIR/setup-$skill_id-skill-symlink.sh"
|
||||
|
||||
if [ ! -f "$REPO_ROOT/skills/$skill_id/SKILL.md" ]; then
|
||||
echo "Unknown skill: $skill_id" >&2
|
||||
echo "Known skills:" >&2
|
||||
"$REPO_ROOT/scripts/utils/list-skills.sh" | sed 's/^/- /' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x "$setup_script" ]; then
|
||||
echo "Skill has no development symlink setup: $skill_id" >&2
|
||||
echo "Expected setup script: ${setup_script#$REPO_ROOT/}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
"$setup_script" "$@"
|
||||
}
|
||||
|
||||
if [ "$#" -eq 0 ]; then
|
||||
usage >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--all)
|
||||
shift
|
||||
while IFS= read -r skill_id; do
|
||||
run_skill_setup "$skill_id" "$@"
|
||||
done < <(list_linkable_skills)
|
||||
;;
|
||||
-*)
|
||||
echo "Unknown option: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
skill_id="$1"
|
||||
shift
|
||||
run_skill_setup "$skill_id" "$@"
|
||||
;;
|
||||
esac
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
|
||||
MODE="write"
|
||||
SKILL_ARGS=()
|
||||
PLUGIN_ARGS=()
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/dev/setup-symlinks.sh [--check]
|
||||
|
||||
Sets up the development symlink layout by replacing production bundle outputs
|
||||
with links to their canonical source paths.
|
||||
|
||||
Options:
|
||||
--check Verify development symlinks are intact without changing files.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
SKILL_ARGS+=("--check")
|
||||
PLUGIN_ARGS+=("--check")
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
echo "Checking skill development symlinks..."
|
||||
else
|
||||
echo "Setting up skill development symlinks..."
|
||||
fi
|
||||
if [ "${#SKILL_ARGS[@]}" -gt 0 ]; then
|
||||
"$SCRIPT_DIR/setup-skill-symlink.sh" --all "${SKILL_ARGS[@]}"
|
||||
else
|
||||
"$SCRIPT_DIR/setup-skill-symlink.sh" --all
|
||||
fi
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
echo "Checking plugin development symlinks..."
|
||||
else
|
||||
echo "Setting up plugin development symlinks..."
|
||||
fi
|
||||
if [ "${#PLUGIN_ARGS[@]}" -gt 0 ]; then
|
||||
"$SCRIPT_DIR/setup-plugin-symlink.sh" "${PLUGIN_ARGS[@]}"
|
||||
else
|
||||
"$SCRIPT_DIR/setup-plugin-symlink.sh"
|
||||
fi
|
||||
|
||||
if [ "$MODE" = "check" ]; then
|
||||
echo "Development symlink layout is valid."
|
||||
else
|
||||
echo "Development symlink layout is ready."
|
||||
fi
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
UTILS_SCRIPT="$REPO_ROOT/scripts/dev/symlink-utils.sh"
|
||||
|
||||
MODE="write"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/dev/setup-skill-symlink.sh cad [--check]
|
||||
|
||||
Sets up CAD skill development symlinks.
|
||||
|
||||
Options:
|
||||
--check Verify symlinks are intact without changing files.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# shellcheck source=scripts/dev/symlink-utils.sh
|
||||
source "$UTILS_SCRIPT"
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
setup_link "$MODE" "skills/cad/scripts/packages/cadpy" "../../../../packages/cadpy"
|
||||
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
UTILS_SCRIPT="$REPO_ROOT/scripts/dev/symlink-utils.sh"
|
||||
|
||||
MODE="write"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/dev/setup-skill-symlink.sh cad-viewer [--check]
|
||||
|
||||
Sets up CAD Viewer development symlinks.
|
||||
|
||||
Options:
|
||||
--check Verify symlinks are intact without changing files.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# shellcheck source=scripts/dev/symlink-utils.sh
|
||||
source "$UTILS_SCRIPT"
|
||||
|
||||
check_no_tracked_runtime_dist() {
|
||||
local tracked_dist
|
||||
tracked_dist="$(
|
||||
git ls-files \
|
||||
"skills/cad-viewer/scripts/viewer/dist" \
|
||||
"skills/cad-viewer/scripts/viewer/dist/**" \
|
||||
2>/dev/null || true
|
||||
)"
|
||||
|
||||
if [ -n "$tracked_dist" ]; then
|
||||
echo "skills/cad-viewer/scripts/viewer/dist must not be tracked on develop." >&2
|
||||
echo "Run scripts/dev/setup-symlinks.sh to restore the cad-viewer runtime symlink." >&2
|
||||
echo "$tracked_dist" | sed 's/^/- /' >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
setup_link "$MODE" "viewer/packages/cadjs" "../../packages/cadjs"
|
||||
setup_link "$MODE" "viewer/packages/cadpy" "../../packages/cadpy"
|
||||
setup_link "$MODE" "viewer/packages/implicitjs" "../../packages/implicitjs"
|
||||
setup_link "$MODE" "skills/cad-viewer/scripts/viewer" "../../../viewer"
|
||||
if [ "$MODE" = "check" ]; then
|
||||
check_no_tracked_runtime_dist
|
||||
fi
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
UTILS_SCRIPT="$REPO_ROOT/scripts/dev/symlink-utils.sh"
|
||||
|
||||
MODE="write"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/dev/setup-skill-symlink.sh dxf [--check]
|
||||
|
||||
Sets up DXF skill development symlinks.
|
||||
|
||||
Options:
|
||||
--check Verify symlinks are intact without changing files.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# shellcheck source=scripts/dev/symlink-utils.sh
|
||||
source "$UTILS_SCRIPT"
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
setup_link "$MODE" "skills/dxf/scripts/packages/cadpy" "../../../../packages/cadpy"
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
UTILS_SCRIPT="$REPO_ROOT/scripts/dev/symlink-utils.sh"
|
||||
|
||||
MODE="write"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/dev/setup-skill-symlink.sh implicit-cad [--check]
|
||||
|
||||
Sets up Implicit CAD skill development symlinks.
|
||||
|
||||
Options:
|
||||
--check Verify symlinks are intact without changing files.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# shellcheck source=scripts/dev/symlink-utils.sh
|
||||
source "$UTILS_SCRIPT"
|
||||
|
||||
check_no_generated_runtimes() {
|
||||
local tracked_runtime
|
||||
tracked_runtime="$(
|
||||
git ls-files \
|
||||
"skills/implicit-cad/scripts/export/runtime" \
|
||||
"skills/implicit-cad/scripts/export/runtime/**" \
|
||||
"skills/implicit-cad/scripts/snapshot/runtime" \
|
||||
"skills/implicit-cad/scripts/snapshot/runtime/**" \
|
||||
2>/dev/null || true
|
||||
)"
|
||||
|
||||
if [ -n "$tracked_runtime" ]; then
|
||||
echo "Implicit CAD generated runtimes must not be tracked on develop." >&2
|
||||
echo "Run scripts/dev/setup-symlinks.sh to restore the implicit-cad development layout." >&2
|
||||
echo "$tracked_runtime" | sed 's/^/- /' >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
setup_link "$MODE" "skills/implicit-cad/scripts/packages/implicitjs" "../../../../packages/implicitjs"
|
||||
if [ "$MODE" = "check" ]; then
|
||||
check_no_generated_runtimes
|
||||
fi
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
UTILS_SCRIPT="$REPO_ROOT/scripts/dev/symlink-utils.sh"
|
||||
|
||||
MODE="write"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/dev/setup-skill-symlink.sh sdf [--check]
|
||||
|
||||
Sets up SDF skill development symlinks.
|
||||
|
||||
Options:
|
||||
--check Verify symlinks are intact without changing files.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# shellcheck source=scripts/dev/symlink-utils.sh
|
||||
source "$UTILS_SCRIPT"
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
setup_link "$MODE" "skills/sdf/scripts/packages/cadpy_metadata" "../../../../packages/cadpy_metadata"
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
UTILS_SCRIPT="$REPO_ROOT/scripts/dev/symlink-utils.sh"
|
||||
|
||||
MODE="write"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/dev/setup-skill-symlink.sh srdf [--check]
|
||||
|
||||
Sets up SRDF skill development symlinks.
|
||||
|
||||
Options:
|
||||
--check Verify symlinks are intact without changing files.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# shellcheck source=scripts/dev/symlink-utils.sh
|
||||
source "$UTILS_SCRIPT"
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
setup_link "$MODE" "skills/srdf/scripts/packages/cadpy_metadata" "../../../../packages/cadpy_metadata"
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
UTILS_SCRIPT="$REPO_ROOT/scripts/dev/symlink-utils.sh"
|
||||
|
||||
MODE="write"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/dev/setup-skill-symlink.sh urdf [--check]
|
||||
|
||||
Sets up URDF skill development symlinks.
|
||||
|
||||
Options:
|
||||
--check Verify symlinks are intact without changing files.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# shellcheck source=scripts/dev/symlink-utils.sh
|
||||
source "$UTILS_SCRIPT"
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
setup_link "$MODE" "skills/urdf/scripts/packages/cadpy_metadata" "../../../../packages/cadpy_metadata"
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
link_path() {
|
||||
local path="$1"
|
||||
local target="$2"
|
||||
|
||||
if [ -L "$path" ] && [ "$(readlink "$path")" = "$target" ]; then
|
||||
echo "Already linked $path -> $target"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -e "$path" ] || [ -L "$path" ]; then
|
||||
rm -rf "$path"
|
||||
fi
|
||||
|
||||
mkdir -p "$(dirname "$path")"
|
||||
ln -s "$target" "$path"
|
||||
echo "Linked $path -> $target"
|
||||
}
|
||||
|
||||
check_link() {
|
||||
local path="$1"
|
||||
local expected_target="$2"
|
||||
local actual_target
|
||||
|
||||
if [ ! -L "$path" ]; then
|
||||
echo "$path must be a symlink to $expected_target" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
actual_target="$(readlink "$path")"
|
||||
if [ "$actual_target" != "$expected_target" ]; then
|
||||
echo "$path points to $actual_target, expected $expected_target" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -e "$path" ]; then
|
||||
echo "$path points to missing target $expected_target" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
setup_link() {
|
||||
local mode="$1"
|
||||
local path="$2"
|
||||
local target="$3"
|
||||
|
||||
if [ "$mode" = "check" ]; then
|
||||
check_link "$path" "$target"
|
||||
else
|
||||
link_path "$path" "$target"
|
||||
fi
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
if ! git diff --cached --quiet -- packages viewer skills plugins/cad/skills scripts/bundle; then
|
||||
scripts/bundle/bundle.sh --check
|
||||
fi
|
||||
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
RUN_BUNDLE_CHECK=1
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/github-workflows/check-builds.sh [--skip-bundle-check]
|
||||
|
||||
Checks the production bundle layout. By default this also verifies generated
|
||||
outputs are fresh with scripts/bundle/bundle.sh --check. Use
|
||||
--skip-bundle-check only after the current workflow has already run
|
||||
scripts/bundle/bundle.sh --clean in the same checkout.
|
||||
|
||||
Options:
|
||||
--skip-bundle-check Skip the generated-output freshness rebuild.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--skip-bundle-check)
|
||||
RUN_BUNDLE_CHECK=0
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
check_no_symlinks() {
|
||||
local root="$1"
|
||||
local first_link
|
||||
|
||||
if [ ! -e "$root" ]; then
|
||||
echo "Missing production bundle path: $root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
first_link="$(find "$root" -type l -print -quit)"
|
||||
if [ -n "$first_link" ]; then
|
||||
echo "Production bundle paths must not contain symlinks." >&2
|
||||
echo "First symlink: $first_link" >&2
|
||||
echo "Run scripts/bundle/bundle.sh --clean and commit the generated outputs." >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_no_symlinks "viewer/packages"
|
||||
check_no_symlinks "skills/cad/scripts/packages"
|
||||
check_no_symlinks "skills/cad-viewer/scripts/viewer"
|
||||
check_no_symlinks "skills/urdf/scripts/packages"
|
||||
check_no_symlinks "skills/srdf/scripts/packages"
|
||||
check_no_symlinks "skills/sdf/scripts/packages"
|
||||
check_no_symlinks "plugins/cad/skills"
|
||||
|
||||
if [ "$RUN_BUNDLE_CHECK" -eq 1 ]; then
|
||||
"$REPO_ROOT/scripts/bundle/bundle.sh" --check
|
||||
else
|
||||
echo "Skipping bundle freshness rebuild; current workflow already bundled outputs."
|
||||
fi
|
||||
|
||||
echo "Production bundle layout is valid."
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
|
||||
"$REPO_ROOT/scripts/dev/setup-symlinks.sh" --check
|
||||
@@ -0,0 +1,160 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd -P)"
|
||||
|
||||
LABEL=""
|
||||
PROJECT_ID=""
|
||||
PUBLIC_URLS=""
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/github-workflows/deploy-vercel-app.sh \
|
||||
--label "Docs app" \
|
||||
--project-id PROJECT_ID \
|
||||
--public-urls "https://example.com https://www.example.com"
|
||||
|
||||
Deploys one Vercel project to production from the current checkout:
|
||||
|
||||
1. configures Vercel Authentication to protect preview deployments only
|
||||
2. runs vercel pull/build/deploy --prod with the project root taken from the
|
||||
Vercel project settings
|
||||
3. verifies each public production URL responds with HTTP 2xx/3xx
|
||||
4. appends a deployment summary to GITHUB_STEP_SUMMARY when set
|
||||
|
||||
Requires VERCEL_TOKEN and VERCEL_ORG_ID in the environment and the vercel CLI
|
||||
on PATH. Run from a production-layout checkout (a main publish commit).
|
||||
EOF
|
||||
}
|
||||
|
||||
die() {
|
||||
echo "error: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--label)
|
||||
[ "$#" -ge 2 ] || die "--label requires a value"
|
||||
LABEL="$2"
|
||||
shift
|
||||
;;
|
||||
--project-id)
|
||||
[ "$#" -ge 2 ] || die "--project-id requires a value"
|
||||
PROJECT_ID="$2"
|
||||
shift
|
||||
;;
|
||||
--public-urls)
|
||||
[ "$#" -ge 2 ] || die "--public-urls requires a value"
|
||||
PUBLIC_URLS="$2"
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
die "unknown argument: $1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
[ -n "$LABEL" ] || die "--label is required"
|
||||
[ -n "$PROJECT_ID" ] || die "--project-id is required"
|
||||
[ -n "$PUBLIC_URLS" ] || die "--public-urls is required"
|
||||
[ -n "${VERCEL_TOKEN:-}" ] || die "VERCEL_TOKEN must be set"
|
||||
[ -n "${VERCEL_ORG_ID:-}" ] || die "VERCEL_ORG_ID must be set"
|
||||
command -v vercel >/dev/null 2>&1 || die "vercel CLI is required"
|
||||
command -v curl >/dev/null 2>&1 || die "curl is required"
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
configure_project_protection() {
|
||||
local response_file
|
||||
local status
|
||||
|
||||
response_file="$(mktemp)"
|
||||
if ! status="$(
|
||||
curl --silent --show-error --location --max-time 30 \
|
||||
--request PATCH \
|
||||
--header "Authorization: Bearer $VERCEL_TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--output "$response_file" \
|
||||
--write-out "%{http_code}" \
|
||||
--data '{"ssoProtection":{"deploymentType":"preview"}}' \
|
||||
"https://api.vercel.com/v9/projects/$PROJECT_ID?teamId=$VERCEL_ORG_ID"
|
||||
)"; then
|
||||
status="000"
|
||||
fi
|
||||
|
||||
if [ "$status" -lt 200 ] || [ "$status" -ge 300 ]; then
|
||||
echo "$LABEL Vercel Authentication update failed with HTTP $status" >&2
|
||||
cat "$response_file" >&2
|
||||
rm -f "$response_file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f "$response_file"
|
||||
echo "$LABEL Vercel Authentication set to preview deployments only."
|
||||
}
|
||||
|
||||
check_public_url() {
|
||||
local public_url="$1"
|
||||
local public_status="000"
|
||||
local attempt
|
||||
|
||||
for attempt in 1 2 3 4 5; do
|
||||
if ! public_status="$(curl --silent --show-error --location --max-time 30 --output /dev/null --write-out "%{http_code}" "$public_url")"; then
|
||||
public_status="000"
|
||||
fi
|
||||
if [ "$public_status" -ge 200 ] && [ "$public_status" -lt 400 ]; then
|
||||
echo "$LABEL public URL check passed: $public_url returned HTTP $public_status"
|
||||
return 0
|
||||
fi
|
||||
if [ "$attempt" -lt 5 ]; then
|
||||
echo "$LABEL public URL check waiting for $public_url; attempt $attempt returned HTTP $public_status"
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$LABEL public URL check failed: $public_url returned HTTP $public_status" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
configure_project_protection
|
||||
|
||||
rm -rf .vercel
|
||||
export VERCEL_ORG_ID
|
||||
export VERCEL_PROJECT_ID="$PROJECT_ID"
|
||||
|
||||
echo "Using Vercel project root from project settings for $LABEL."
|
||||
vercel pull --yes --environment=production --token="$VERCEL_TOKEN"
|
||||
vercel build --prod --token="$VERCEL_TOKEN"
|
||||
deployment_output="$(vercel deploy --prebuilt --prod --token="$VERCEL_TOKEN")"
|
||||
echo "$deployment_output"
|
||||
deployment_url="$(printf '%s\n' "$deployment_output" | tail -n 1)"
|
||||
|
||||
for public_url in $PUBLIC_URLS; do
|
||||
check_public_url "$public_url"
|
||||
done
|
||||
|
||||
if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then
|
||||
{
|
||||
echo "### $LABEL"
|
||||
echo
|
||||
echo "Public production URLs:"
|
||||
for public_url in $PUBLIC_URLS; do
|
||||
echo "- $public_url"
|
||||
done
|
||||
echo
|
||||
echo "Raw Vercel deployment URL: $deployment_url"
|
||||
echo
|
||||
echo "> Raw Vercel deployment URLs may require Vercel Authentication. Use the public production URLs above for release testing and sharing."
|
||||
echo
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
|
||||
echo "$LABEL deployed to Vercel production."
|
||||
+273
@@ -0,0 +1,273 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd -P)"
|
||||
SKILLS_ROOT="$(cd "$REPO_ROOT/skills" && pwd -P)"
|
||||
LIST_SKILLS_SCRIPT="$REPO_ROOT/scripts/utils/list-skills.sh"
|
||||
SKILL_IDS=()
|
||||
while IFS= read -r skill; do
|
||||
SKILL_IDS+=("$skill")
|
||||
done < <("$LIST_SKILLS_SCRIPT")
|
||||
|
||||
ALL_AGENTS=(
|
||||
codex
|
||||
claude
|
||||
gemini
|
||||
universal
|
||||
project
|
||||
)
|
||||
|
||||
SELECTED_AGENTS=()
|
||||
DRY_RUN=0
|
||||
DESTINATION_WOULD_REPLACE=0
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/install/install-skills.sh [--agent <agent>]... [--all] [--dry-run]
|
||||
scripts/install/install-skills.sh --list-agents
|
||||
|
||||
Installs per-skill symlinks from this checkout's skills/ directory into local
|
||||
agent skill directories. Existing matching symlinks are left alone.
|
||||
|
||||
Agents:
|
||||
codex ${CODEX_HOME:-$HOME/.codex}/skills
|
||||
claude ${CLAUDE_CONFIG_DIR:-$HOME/.claude}/skills
|
||||
gemini $HOME/.gemini/skills
|
||||
universal ${XDG_CONFIG_HOME:-$HOME/.config}/agents/skills
|
||||
project .agents/skills in this repository
|
||||
|
||||
Aliases:
|
||||
claude-code -> claude
|
||||
gemini-cli -> gemini
|
||||
agents -> universal
|
||||
repo -> project
|
||||
|
||||
Options:
|
||||
-a, --agent Install links for one agent. May be repeated.
|
||||
--all Install links for every supported agent above.
|
||||
--dry-run Print actions without changing files.
|
||||
--list-agents Show resolved destination paths.
|
||||
-h, --help Show this help.
|
||||
|
||||
With no --agent or --all, the script installs Codex links.
|
||||
EOF
|
||||
}
|
||||
|
||||
agent_destination() {
|
||||
case "$1" in
|
||||
codex)
|
||||
printf '%s\n' "${CODEX_HOME:-$HOME/.codex}/skills"
|
||||
;;
|
||||
claude)
|
||||
printf '%s\n' "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/skills"
|
||||
;;
|
||||
gemini)
|
||||
printf '%s\n' "$HOME/.gemini/skills"
|
||||
;;
|
||||
universal)
|
||||
printf '%s\n' "${XDG_CONFIG_HOME:-$HOME/.config}/agents/skills"
|
||||
;;
|
||||
project)
|
||||
printf '%s\n' "$REPO_ROOT/.agents/skills"
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
canonical_agent() {
|
||||
case "$1" in
|
||||
codex) printf 'codex\n' ;;
|
||||
claude|claude-code) printf 'claude\n' ;;
|
||||
gemini|gemini-cli) printf 'gemini\n' ;;
|
||||
universal|agents) printf 'universal\n' ;;
|
||||
project|repo) printf 'project\n' ;;
|
||||
*)
|
||||
echo "Unknown agent: $1" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
contains_agent() {
|
||||
local needle="$1"
|
||||
local agent
|
||||
if [ "${#SELECTED_AGENTS[@]}" -eq 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
for agent in "${SELECTED_AGENTS[@]}"; do
|
||||
if [ "$agent" = "$needle" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
add_agent() {
|
||||
local agent
|
||||
agent="$(canonical_agent "$1")"
|
||||
if ! contains_agent "$agent"; then
|
||||
SELECTED_AGENTS+=("$agent")
|
||||
fi
|
||||
}
|
||||
|
||||
run() {
|
||||
if [ "$DRY_RUN" -eq 1 ]; then
|
||||
printf 'dry-run:'
|
||||
printf ' %q' "$@"
|
||||
printf '\n'
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
resolve_link_dir() {
|
||||
local link="$1"
|
||||
local target
|
||||
local link_dir
|
||||
target="$(readlink "$link")"
|
||||
if [[ "$target" = /* ]]; then
|
||||
cd "$target" && pwd -P
|
||||
else
|
||||
link_dir="$(cd "$(dirname "$link")" && pwd -P)"
|
||||
cd "$link_dir/$target" && pwd -P
|
||||
fi
|
||||
}
|
||||
|
||||
prepare_destination() {
|
||||
local destination="$1"
|
||||
local resolved
|
||||
DESTINATION_WOULD_REPLACE=0
|
||||
if [ -L "$destination" ]; then
|
||||
resolved="$(resolve_link_dir "$destination" 2>/dev/null || true)"
|
||||
if [ "$resolved" = "$SKILLS_ROOT" ]; then
|
||||
if [ "$DRY_RUN" -eq 1 ]; then
|
||||
echo "would replace whole-directory skills link with per-skill link directory: $destination"
|
||||
DESTINATION_WOULD_REPLACE=1
|
||||
else
|
||||
echo "Replacing whole-directory skills link with per-skill link directory: $destination"
|
||||
fi
|
||||
run rm "$destination"
|
||||
else
|
||||
echo "Refusing to replace destination symlink: $destination -> $(readlink "$destination")" >&2
|
||||
echo "Remove it manually or choose another agent destination." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e "$destination" ] && [ ! -d "$destination" ]; then
|
||||
echo "Destination exists but is not a directory: $destination" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run mkdir -p "$destination"
|
||||
}
|
||||
|
||||
install_skill_link() {
|
||||
local skill="$1"
|
||||
local destination="$2"
|
||||
local source="$SKILLS_ROOT/$skill"
|
||||
local link="$destination/$skill"
|
||||
local resolved
|
||||
|
||||
if [ ! -d "$source" ]; then
|
||||
echo "Missing supported skill directory: $source" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -L "$link" ]; then
|
||||
resolved="$(resolve_link_dir "$link" 2>/dev/null || true)"
|
||||
if [ "$resolved" = "$source" ]; then
|
||||
echo "ok: $link -> $source"
|
||||
return
|
||||
fi
|
||||
run rm "$link"
|
||||
elif [ -e "$link" ]; then
|
||||
echo "Skipping existing non-symlink path: $link" >&2
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$DRY_RUN" -eq 1 ]; then
|
||||
run ln -s "$source" "$link"
|
||||
echo "would link: $link -> $source"
|
||||
else
|
||||
run ln -s "$source" "$link"
|
||||
echo "linked: $link -> $source"
|
||||
fi
|
||||
}
|
||||
|
||||
install_for_agent() {
|
||||
local agent="$1"
|
||||
local destination
|
||||
local skill
|
||||
|
||||
destination="$(agent_destination "$agent")"
|
||||
echo "Installing $agent skill links into $destination"
|
||||
prepare_destination "$destination"
|
||||
|
||||
if [ "$DRY_RUN" -eq 1 ] && [ "$DESTINATION_WOULD_REPLACE" -eq 1 ]; then
|
||||
for skill in "${SKILL_IDS[@]}"; do
|
||||
echo "would link: $destination/$skill -> $SKILLS_ROOT/$skill"
|
||||
done
|
||||
return
|
||||
fi
|
||||
|
||||
for skill in "${SKILL_IDS[@]}"; do
|
||||
install_skill_link "$skill" "$destination"
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
list_agents() {
|
||||
local agent
|
||||
for agent in "${ALL_AGENTS[@]}"; do
|
||||
printf '%-10s %s\n' "$agent" "$(agent_destination "$agent")"
|
||||
done
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
-a|--agent)
|
||||
if [ "$#" -lt 2 ]; then
|
||||
echo "Missing value for $1" >&2
|
||||
exit 2
|
||||
fi
|
||||
add_agent "$2"
|
||||
shift
|
||||
;;
|
||||
--all)
|
||||
SELECTED_AGENTS=()
|
||||
for agent in "${ALL_AGENTS[@]}"; do
|
||||
add_agent "$agent"
|
||||
done
|
||||
;;
|
||||
--dry-run)
|
||||
DRY_RUN=1
|
||||
;;
|
||||
--list-agents)
|
||||
list_agents
|
||||
exit 0
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "${#SELECTED_AGENTS[@]}" -eq 0 ]; then
|
||||
add_agent codex
|
||||
fi
|
||||
|
||||
for agent in "${SELECTED_AGENTS[@]}"; do
|
||||
install_for_agent "$agent"
|
||||
done
|
||||
+277
@@ -0,0 +1,277 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd -P)"
|
||||
SKILLS_ROOT="$(cd "$REPO_ROOT/skills" && pwd -P)"
|
||||
LIST_SKILLS_SCRIPT="$REPO_ROOT/scripts/utils/list-skills.sh"
|
||||
SKILL_IDS=()
|
||||
while IFS= read -r skill; do
|
||||
SKILL_IDS+=("$skill")
|
||||
done < <("$LIST_SKILLS_SCRIPT")
|
||||
|
||||
ALL_AGENTS=(
|
||||
codex
|
||||
claude
|
||||
gemini
|
||||
universal
|
||||
project
|
||||
)
|
||||
|
||||
SELECTED_AGENTS=()
|
||||
DRY_RUN=0
|
||||
PRUNE_EMPTY=1
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/install/uninstall-skills.sh [--agent <agent>]... [--all] [--dry-run] [--keep-empty-dirs]
|
||||
scripts/install/uninstall-skills.sh --list-agents
|
||||
|
||||
Removes local development skill links that point back to this checkout. Existing
|
||||
non-symlink skills and symlinks to other locations are left untouched.
|
||||
|
||||
Agents:
|
||||
codex ${CODEX_HOME:-$HOME/.codex}/skills
|
||||
claude ${CLAUDE_CONFIG_DIR:-$HOME/.claude}/skills
|
||||
gemini $HOME/.gemini/skills
|
||||
universal ${XDG_CONFIG_HOME:-$HOME/.config}/agents/skills
|
||||
project .agents/skills in this repository
|
||||
|
||||
Aliases:
|
||||
claude-code -> claude
|
||||
gemini-cli -> gemini
|
||||
agents -> universal
|
||||
repo -> project
|
||||
|
||||
Options:
|
||||
-a, --agent Remove links for one agent. May be repeated.
|
||||
--all Remove links for every supported agent above.
|
||||
--dry-run Print actions without changing files.
|
||||
--keep-empty-dirs Leave empty skill destination directories in place.
|
||||
--list-agents Show resolved destination paths.
|
||||
-h, --help Show this help.
|
||||
|
||||
With no --agent or --all, the script removes Codex links.
|
||||
EOF
|
||||
}
|
||||
|
||||
agent_destination() {
|
||||
case "$1" in
|
||||
codex)
|
||||
printf '%s\n' "${CODEX_HOME:-$HOME/.codex}/skills"
|
||||
;;
|
||||
claude)
|
||||
printf '%s\n' "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/skills"
|
||||
;;
|
||||
gemini)
|
||||
printf '%s\n' "$HOME/.gemini/skills"
|
||||
;;
|
||||
universal)
|
||||
printf '%s\n' "${XDG_CONFIG_HOME:-$HOME/.config}/agents/skills"
|
||||
;;
|
||||
project)
|
||||
printf '%s\n' "$REPO_ROOT/.agents/skills"
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
canonical_agent() {
|
||||
case "$1" in
|
||||
codex) printf 'codex\n' ;;
|
||||
claude|claude-code) printf 'claude\n' ;;
|
||||
gemini|gemini-cli) printf 'gemini\n' ;;
|
||||
universal|agents) printf 'universal\n' ;;
|
||||
project|repo) printf 'project\n' ;;
|
||||
*)
|
||||
echo "Unknown agent: $1" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
contains_value() {
|
||||
local needle="$1"
|
||||
shift
|
||||
local value
|
||||
for value in "$@"; do
|
||||
if [ "$value" = "$needle" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
add_agent() {
|
||||
local agent
|
||||
agent="$(canonical_agent "$1")"
|
||||
if [ "${#SELECTED_AGENTS[@]}" -eq 0 ] || ! contains_value "$agent" "${SELECTED_AGENTS[@]}"; then
|
||||
SELECTED_AGENTS+=("$agent")
|
||||
fi
|
||||
}
|
||||
|
||||
run() {
|
||||
if [ "$DRY_RUN" -eq 1 ]; then
|
||||
printf 'dry-run:'
|
||||
printf ' %q' "$@"
|
||||
printf '\n'
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
resolve_link_dir() {
|
||||
local link="$1"
|
||||
local target
|
||||
local link_dir
|
||||
target="$(readlink "$link")"
|
||||
if [[ "$target" = /* ]]; then
|
||||
cd "$target" && pwd -P
|
||||
else
|
||||
link_dir="$(cd "$(dirname "$link")" && pwd -P)"
|
||||
cd "$link_dir/$target" && pwd -P
|
||||
fi
|
||||
}
|
||||
|
||||
remove_skill_link() {
|
||||
local skill="$1"
|
||||
local destination="$2"
|
||||
local source="$SKILLS_ROOT/$skill"
|
||||
local link="$destination/$skill"
|
||||
local resolved
|
||||
|
||||
if [ -L "$link" ]; then
|
||||
resolved="$(resolve_link_dir "$link" 2>/dev/null || true)"
|
||||
if [ "$resolved" = "$source" ]; then
|
||||
run rm "$link"
|
||||
if [ "$DRY_RUN" -eq 1 ]; then
|
||||
echo "would remove: $link"
|
||||
else
|
||||
echo "removed: $link"
|
||||
fi
|
||||
return
|
||||
fi
|
||||
echo "skipping non-repo skill symlink: $link -> $(readlink "$link")"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -e "$link" ]; then
|
||||
echo "skipping existing non-symlink path: $link"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "ok: no link at $link"
|
||||
}
|
||||
|
||||
prune_empty_destination() {
|
||||
local destination="$1"
|
||||
if [ "$PRUNE_EMPTY" -eq 0 ] || [ ! -d "$destination" ] || [ -L "$destination" ]; then
|
||||
return
|
||||
fi
|
||||
if [ -z "$(find "$destination" -mindepth 1 -maxdepth 1 -print -quit)" ]; then
|
||||
run rmdir "$destination"
|
||||
if [ "$DRY_RUN" -eq 1 ]; then
|
||||
echo "would remove empty directory: $destination"
|
||||
else
|
||||
echo "removed empty directory: $destination"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
uninstall_for_agent() {
|
||||
local agent="$1"
|
||||
local destination
|
||||
local resolved
|
||||
local skill
|
||||
|
||||
destination="$(agent_destination "$agent")"
|
||||
echo "Removing $agent skill links from $destination"
|
||||
|
||||
if [ -L "$destination" ]; then
|
||||
resolved="$(resolve_link_dir "$destination" 2>/dev/null || true)"
|
||||
if [ "$resolved" = "$SKILLS_ROOT" ]; then
|
||||
run rm "$destination"
|
||||
if [ "$DRY_RUN" -eq 1 ]; then
|
||||
echo "would remove whole-directory skills link: $destination"
|
||||
else
|
||||
echo "removed whole-directory skills link: $destination"
|
||||
fi
|
||||
else
|
||||
echo "skipping non-repo destination symlink: $destination -> $(readlink "$destination")"
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -e "$destination" ]; then
|
||||
echo "ok: no skill directory at $destination"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -d "$destination" ]; then
|
||||
echo "skipping non-directory destination: $destination"
|
||||
return
|
||||
fi
|
||||
|
||||
for skill in "${SKILL_IDS[@]}"; do
|
||||
remove_skill_link "$skill" "$destination"
|
||||
done
|
||||
|
||||
prune_empty_destination "$destination"
|
||||
}
|
||||
|
||||
list_agents() {
|
||||
local agent
|
||||
for agent in "${ALL_AGENTS[@]}"; do
|
||||
printf '%-10s %s\n' "$agent" "$(agent_destination "$agent")"
|
||||
done
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
-a|--agent)
|
||||
if [ "$#" -lt 2 ]; then
|
||||
echo "Missing value for $1" >&2
|
||||
exit 2
|
||||
fi
|
||||
add_agent "$2"
|
||||
shift
|
||||
;;
|
||||
--all)
|
||||
SELECTED_AGENTS=()
|
||||
for agent in "${ALL_AGENTS[@]}"; do
|
||||
add_agent "$agent"
|
||||
done
|
||||
;;
|
||||
--dry-run)
|
||||
DRY_RUN=1
|
||||
;;
|
||||
--keep-empty-dirs)
|
||||
PRUNE_EMPTY=0
|
||||
;;
|
||||
--list-agents)
|
||||
list_agents
|
||||
exit 0
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "${#SELECTED_AGENTS[@]}" -eq 0 ]; then
|
||||
add_agent codex
|
||||
fi
|
||||
|
||||
for agent in "${SELECTED_AGENTS[@]}"; do
|
||||
uninstall_for_agent "$agent"
|
||||
done
|
||||
+367
@@ -0,0 +1,367 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
VERSION_PATH="plugins/cad/VERSION"
|
||||
VERSION_FILE="$REPO_ROOT/$VERSION_PATH"
|
||||
|
||||
PART=""
|
||||
SET_VERSION=""
|
||||
FROM_VERSION=""
|
||||
DRY_RUN=0
|
||||
CHECK=0
|
||||
CHECK_INCREMENTED_FROM=""
|
||||
COMMIT=0
|
||||
AMEND=0
|
||||
NO_EDIT=0
|
||||
NO_VERIFY=0
|
||||
SIGNOFF=0
|
||||
TAG=0
|
||||
FORCE_TAG=0
|
||||
MESSAGES=()
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/release/bump-version.sh major|minor|patch [options]
|
||||
scripts/release/bump-version.sh --set-version X.Y.Z [options]
|
||||
scripts/release/bump-version.sh --check
|
||||
scripts/release/bump-version.sh --check-incremented-from REF
|
||||
|
||||
Bumps or checks the canonical repo release version in plugins/cad/VERSION.
|
||||
Duplicate package and plugin metadata is synchronized from that file by
|
||||
scripts/release/sync-version.mjs during release preparation and production
|
||||
bundling.
|
||||
|
||||
Common options:
|
||||
--dry-run Show planned edits and git actions without changing files.
|
||||
--no-commit Write files but do not commit. This is the default.
|
||||
--commit Commit the bump.
|
||||
--amend Amend the current commit instead of creating a new commit.
|
||||
-m, --message MSG Pass a commit message to git commit. May be repeated.
|
||||
--no-edit Reuse the current commit message with --amend.
|
||||
--no-verify Pass --no-verify to git commit.
|
||||
--signoff Pass --signoff to git commit.
|
||||
--no-tag Do not create a local tag. This is the default.
|
||||
--tag Create a local tag after committing. Manual fallback only.
|
||||
--force-tag Move an existing local release tag to HEAD.
|
||||
--from-version X Require the current canonical version to be X.Y.Z.
|
||||
EOF
|
||||
}
|
||||
|
||||
die() {
|
||||
echo "error: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
validate_semver() {
|
||||
local version="$1"
|
||||
if [[ ! "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
|
||||
die "expected a plain semver version like 1.2.3, got '$version'"
|
||||
fi
|
||||
}
|
||||
|
||||
read_version() {
|
||||
local version
|
||||
[ -f "$VERSION_FILE" ] || die "missing canonical version file: $VERSION_PATH"
|
||||
version="$(tr -d '[:space:]' < "$VERSION_FILE")"
|
||||
validate_semver "$version"
|
||||
printf '%s\n' "$version"
|
||||
}
|
||||
|
||||
bump_version() {
|
||||
local current="$1"
|
||||
local part="$2"
|
||||
local major minor patch
|
||||
validate_semver "$current"
|
||||
IFS=. read -r major minor patch <<< "$current"
|
||||
case "$part" in
|
||||
major)
|
||||
printf '%s.0.0\n' "$((10#$major + 1))"
|
||||
;;
|
||||
minor)
|
||||
printf '%s.%s.0\n' "$major" "$((10#$minor + 1))"
|
||||
;;
|
||||
patch)
|
||||
printf '%s.%s.%s\n' "$major" "$minor" "$((10#$patch + 1))"
|
||||
;;
|
||||
*)
|
||||
die "unknown bump part: $part"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
semver_greater() {
|
||||
local left="$1"
|
||||
local right="$2"
|
||||
local left_major left_minor left_patch right_major right_minor right_patch
|
||||
validate_semver "$left"
|
||||
validate_semver "$right"
|
||||
IFS=. read -r left_major left_minor left_patch <<< "$left"
|
||||
IFS=. read -r right_major right_minor right_patch <<< "$right"
|
||||
|
||||
if [ "$((10#$left_major))" -ne "$((10#$right_major))" ]; then
|
||||
[ "$((10#$left_major))" -gt "$((10#$right_major))" ]
|
||||
return
|
||||
fi
|
||||
if [ "$((10#$left_minor))" -ne "$((10#$right_minor))" ]; then
|
||||
[ "$((10#$left_minor))" -gt "$((10#$right_minor))" ]
|
||||
return
|
||||
fi
|
||||
[ "$((10#$left_patch))" -gt "$((10#$right_patch))" ]
|
||||
}
|
||||
|
||||
git_text_at_ref() {
|
||||
local ref="$1"
|
||||
[ -n "$ref" ] || die "base ref must not be empty"
|
||||
if [[ "$ref" =~ ^0+$ ]]; then
|
||||
die "base ref must be a real commit, not an empty all-zero ref"
|
||||
fi
|
||||
git -C "$REPO_ROOT" show "$ref:$VERSION_PATH"
|
||||
}
|
||||
|
||||
stage_paths() {
|
||||
git -C "$REPO_ROOT" add -- "$VERSION_PATH"
|
||||
}
|
||||
|
||||
commit_version_bump() {
|
||||
local next_version="$1"
|
||||
local command=(commit)
|
||||
|
||||
stage_paths
|
||||
if [ "$AMEND" -eq 1 ]; then
|
||||
command+=(--amend)
|
||||
fi
|
||||
if [ "$NO_VERIFY" -eq 1 ]; then
|
||||
command+=(--no-verify)
|
||||
fi
|
||||
if [ "$SIGNOFF" -eq 1 ]; then
|
||||
command+=(--signoff)
|
||||
fi
|
||||
if [ "$NO_EDIT" -eq 1 ]; then
|
||||
command+=(--no-edit)
|
||||
elif [ "${#MESSAGES[@]}" -gt 0 ]; then
|
||||
local message
|
||||
for message in "${MESSAGES[@]}"; do
|
||||
command+=(-m "$message")
|
||||
done
|
||||
elif [ "$AMEND" -eq 1 ]; then
|
||||
command+=(--no-edit)
|
||||
else
|
||||
command+=(-m "Bump version to $next_version")
|
||||
fi
|
||||
git -C "$REPO_ROOT" "${command[@]}"
|
||||
}
|
||||
|
||||
tag_exists() {
|
||||
git -C "$REPO_ROOT" rev-parse --verify --quiet "refs/tags/$1" >/dev/null
|
||||
}
|
||||
|
||||
create_release_tag() {
|
||||
local tag_name="$1"
|
||||
local tag_commit head_commit
|
||||
if tag_exists "$tag_name"; then
|
||||
tag_commit="$(git -C "$REPO_ROOT" rev-list -n 1 "$tag_name")"
|
||||
head_commit="$(git -C "$REPO_ROOT" rev-parse HEAD)"
|
||||
if [ "$tag_commit" = "$head_commit" ]; then
|
||||
echo "Release tag already exists on HEAD: $tag_name"
|
||||
return
|
||||
fi
|
||||
[ "$FORCE_TAG" -eq 1 ] || die "release tag already exists on a different commit: $tag_name"
|
||||
git -C "$REPO_ROOT" tag -f "$tag_name" HEAD
|
||||
echo "Moved release tag: $tag_name"
|
||||
return
|
||||
fi
|
||||
git -C "$REPO_ROOT" tag "$tag_name" HEAD
|
||||
echo "Created release tag: $tag_name"
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
major|minor|patch)
|
||||
[ -z "$PART" ] || die "provide only one semver bump part"
|
||||
PART="$1"
|
||||
;;
|
||||
--set-version)
|
||||
[ "$#" -ge 2 ] || die "--set-version requires a value"
|
||||
SET_VERSION="$2"
|
||||
shift
|
||||
;;
|
||||
--set-version=*)
|
||||
SET_VERSION="${1#--set-version=}"
|
||||
;;
|
||||
--from-version)
|
||||
[ "$#" -ge 2 ] || die "--from-version requires a value"
|
||||
FROM_VERSION="$2"
|
||||
shift
|
||||
;;
|
||||
--from-version=*)
|
||||
FROM_VERSION="${1#--from-version=}"
|
||||
;;
|
||||
--dry-run)
|
||||
DRY_RUN=1
|
||||
;;
|
||||
--check)
|
||||
CHECK=1
|
||||
;;
|
||||
--check-incremented-from)
|
||||
[ "$#" -ge 2 ] || die "--check-incremented-from requires a ref"
|
||||
CHECK=1
|
||||
CHECK_INCREMENTED_FROM="$2"
|
||||
shift
|
||||
;;
|
||||
--check-incremented-from=*)
|
||||
CHECK=1
|
||||
CHECK_INCREMENTED_FROM="${1#--check-incremented-from=}"
|
||||
;;
|
||||
--no-commit)
|
||||
COMMIT=0
|
||||
TAG=0
|
||||
;;
|
||||
--commit)
|
||||
COMMIT=1
|
||||
;;
|
||||
--amend)
|
||||
AMEND=1
|
||||
;;
|
||||
-m|--message)
|
||||
[ "$#" -ge 2 ] || die "$1 requires a value"
|
||||
MESSAGES+=("$2")
|
||||
shift
|
||||
;;
|
||||
--message=*)
|
||||
MESSAGES+=("${1#--message=}")
|
||||
;;
|
||||
--no-edit)
|
||||
NO_EDIT=1
|
||||
;;
|
||||
--no-verify)
|
||||
NO_VERIFY=1
|
||||
;;
|
||||
--signoff)
|
||||
SIGNOFF=1
|
||||
;;
|
||||
--no-tag)
|
||||
TAG=0
|
||||
;;
|
||||
--tag)
|
||||
TAG=1
|
||||
;;
|
||||
--force-tag)
|
||||
FORCE_TAG=1
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
die "unknown argument: $1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
if [ "$CHECK" -eq 1 ]; then
|
||||
if [ -n "$PART" ] || [ -n "$SET_VERSION" ] || [ -n "$FROM_VERSION" ] || [ "$DRY_RUN" -eq 1 ] ||
|
||||
[ "$COMMIT" -eq 1 ] || [ "$AMEND" -eq 1 ] || [ "${#MESSAGES[@]}" -gt 0 ] ||
|
||||
[ "$NO_EDIT" -eq 1 ] || [ "$NO_VERIFY" -eq 1 ] || [ "$SIGNOFF" -eq 1 ] ||
|
||||
[ "$TAG" -eq 1 ] || [ "$FORCE_TAG" -eq 1 ]; then
|
||||
die "version bump, git commit, and tag arguments cannot be combined with check modes"
|
||||
fi
|
||||
|
||||
current_version="$(read_version)"
|
||||
if [ -n "$CHECK_INCREMENTED_FROM" ]; then
|
||||
base_version="$(git_text_at_ref "$CHECK_INCREMENTED_FROM" | tr -d '[:space:]')"
|
||||
validate_semver "$base_version"
|
||||
if ! semver_greater "$current_version" "$base_version"; then
|
||||
die "current version $current_version must be greater than $base_version from $CHECK_INCREMENTED_FROM"
|
||||
fi
|
||||
echo "Canonical release version is incremented from $CHECK_INCREMENTED_FROM: $base_version -> $current_version"
|
||||
else
|
||||
echo "Canonical release version is valid: $current_version"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "$PART" ] && [ -n "$SET_VERSION" ]; then
|
||||
die "provide exactly one of major/minor/patch or --set-version"
|
||||
fi
|
||||
if [ -z "$PART" ] && [ -z "$SET_VERSION" ]; then
|
||||
die "provide exactly one of major/minor/patch or --set-version"
|
||||
fi
|
||||
if [ -n "$SET_VERSION" ]; then
|
||||
validate_semver "$SET_VERSION"
|
||||
fi
|
||||
if [ -n "$FROM_VERSION" ]; then
|
||||
validate_semver "$FROM_VERSION"
|
||||
fi
|
||||
if [ "$COMMIT" -eq 1 ] && [ "$AMEND" -eq 1 ]; then
|
||||
die "--commit and --amend are mutually exclusive"
|
||||
fi
|
||||
if [ "$NO_EDIT" -eq 1 ] && [ "$AMEND" -eq 0 ]; then
|
||||
die "--no-edit only applies with --amend"
|
||||
fi
|
||||
if [ "$NO_EDIT" -eq 1 ] && [ "${#MESSAGES[@]}" -gt 0 ]; then
|
||||
die "--no-edit cannot be combined with --message"
|
||||
fi
|
||||
if [ "$TAG" -eq 1 ] && [ "$COMMIT" -eq 0 ] && [ "$AMEND" -eq 0 ] && [ "$DRY_RUN" -eq 0 ]; then
|
||||
die "--tag requires --commit or --amend"
|
||||
fi
|
||||
if [ "$FORCE_TAG" -eq 1 ] && [ "$TAG" -eq 0 ]; then
|
||||
die "--force-tag requires --tag"
|
||||
fi
|
||||
|
||||
current_version="$(read_version)"
|
||||
if [ -n "$FROM_VERSION" ] && [ "$current_version" != "$FROM_VERSION" ]; then
|
||||
die "$VERSION_PATH is $current_version, expected $FROM_VERSION"
|
||||
fi
|
||||
|
||||
if [ -n "$SET_VERSION" ]; then
|
||||
next_version="$SET_VERSION"
|
||||
else
|
||||
next_version="$(bump_version "$current_version" "$PART")"
|
||||
fi
|
||||
|
||||
if [ "$next_version" = "$current_version" ]; then
|
||||
die "next version matches current version: $current_version"
|
||||
fi
|
||||
|
||||
echo "Version bump: $current_version -> $next_version"
|
||||
echo "- $VERSION_PATH (canonical plugin version)"
|
||||
|
||||
if [ "$DRY_RUN" -eq 1 ]; then
|
||||
echo "Dry run only; no files changed."
|
||||
if [ "$COMMIT" -eq 1 ] || [ "$AMEND" -eq 1 ]; then
|
||||
if [ "$AMEND" -eq 1 ]; then
|
||||
echo "Would amend the current commit."
|
||||
else
|
||||
echo "Would create a commit."
|
||||
fi
|
||||
fi
|
||||
if [ "$TAG" -eq 1 ]; then
|
||||
echo "Would create release tag: $next_version"
|
||||
fi
|
||||
echo "Release workflow: gh workflow run release.yml"
|
||||
echo "Local fallback: scripts/release/bump-version.sh --set-version $next_version --no-commit"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf '%s\n' "$next_version" > "$VERSION_FILE"
|
||||
echo "Updated 1 file."
|
||||
|
||||
if [ "$COMMIT" -eq 1 ] || [ "$AMEND" -eq 1 ]; then
|
||||
commit_version_bump "$next_version"
|
||||
echo "Committed version bump."
|
||||
fi
|
||||
|
||||
if [ "$TAG" -eq 1 ]; then
|
||||
create_release_tag "$next_version"
|
||||
elif [ "$COMMIT" -eq 1 ] || [ "$AMEND" -eq 1 ]; then
|
||||
echo "Release tag to create separately: $next_version"
|
||||
else
|
||||
echo "Release workflow: gh workflow run release.yml"
|
||||
echo "Local fallback: scripts/release/bump-version.sh --set-version $next_version --no-commit"
|
||||
fi
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="${RELEASE_REPO_ROOT:-$(cd "$SCRIPT_DIR/../.." && pwd)}"
|
||||
|
||||
SOURCE_REF="HEAD"
|
||||
TARGET_REF="origin/main"
|
||||
PRINT_PREVIOUS_SOURCE=0
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/release/check-publish-source.sh [--source-ref REF] [--target-ref REF]
|
||||
scripts/release/check-publish-source.sh --print-previous-source [--target-ref REF]
|
||||
|
||||
Checks that a publish source contains the source commit used by the previous
|
||||
publish target. This keeps main as a generated-output branch without requiring
|
||||
develop to merge generated publish commits back into source history.
|
||||
|
||||
Options:
|
||||
--source-ref REF Source branch, tag, or SHA to publish. Defaults to HEAD.
|
||||
--target-ref REF Previous publish target ref. Defaults to origin/main.
|
||||
--print-previous-source Print only the resolved previous source commit.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
die() {
|
||||
echo "error: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
resolve_commit() {
|
||||
local ref="$1"
|
||||
local label="$2"
|
||||
local commit
|
||||
commit="$(git rev-parse --verify "$ref^{commit}" 2>/dev/null)" ||
|
||||
die "could not resolve $label ref as a commit: $ref"
|
||||
printf '%s\n' "$commit"
|
||||
}
|
||||
|
||||
source_commit_from_message() {
|
||||
local target_commit="$1"
|
||||
local recorded
|
||||
recorded="$(
|
||||
git log -1 --format=%B "$target_commit" |
|
||||
sed -nE 's/^Source commit:[[:space:]]*([0-9a-fA-F]{7,64})[[:space:]]*$/\1/p' |
|
||||
head -n 1
|
||||
)"
|
||||
[ -n "$recorded" ] || return 1
|
||||
resolve_commit "$recorded" "recorded source"
|
||||
}
|
||||
|
||||
previous_source_for_target() {
|
||||
local target_commit="$1"
|
||||
local previous_source
|
||||
|
||||
if previous_source="$(source_commit_from_message "$target_commit")"; then
|
||||
printf '%s\n' "$previous_source"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if git rev-parse --verify --quiet "$target_commit^" >/dev/null; then
|
||||
git rev-parse "$target_commit^"
|
||||
return 0
|
||||
fi
|
||||
|
||||
die "could not determine previous publish source for $TARGET_REF; expected a Source commit line or a parent commit"
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--source-ref)
|
||||
[ "$#" -ge 2 ] || die "--source-ref requires a value"
|
||||
SOURCE_REF="$2"
|
||||
shift
|
||||
;;
|
||||
--source-ref=*)
|
||||
SOURCE_REF="${1#--source-ref=}"
|
||||
;;
|
||||
--target-ref)
|
||||
[ "$#" -ge 2 ] || die "--target-ref requires a value"
|
||||
TARGET_REF="$2"
|
||||
shift
|
||||
;;
|
||||
--target-ref=*)
|
||||
TARGET_REF="${1#--target-ref=}"
|
||||
;;
|
||||
--print-previous-source)
|
||||
PRINT_PREVIOUS_SOURCE=1
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
die "unknown argument: $1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
source_sha="$(resolve_commit "$SOURCE_REF" "source")"
|
||||
target_sha="$(resolve_commit "$TARGET_REF" "target")"
|
||||
previous_source="$(previous_source_for_target "$target_sha")"
|
||||
|
||||
if [ "$PRINT_PREVIOUS_SOURCE" -eq 1 ]; then
|
||||
printf '%s\n' "$previous_source"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! git merge-base --is-ancestor "$previous_source" "$source_sha"; then
|
||||
{
|
||||
echo "previous publish source is not an ancestor of the requested source"
|
||||
echo "target ref: $TARGET_REF"
|
||||
echo "target commit: $target_sha"
|
||||
echo "previous source: $previous_source"
|
||||
echo "requested source: $source_sha"
|
||||
echo
|
||||
echo "Use source_ref=develop after the release PR has merged, or rebase/merge the source branch so it contains the previous release source."
|
||||
} >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Publish source is valid: $source_sha contains previous publish source $previous_source from $TARGET_REF."
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/release/check-version.sh [--incremented-from REF]
|
||||
|
||||
Checks that plugins/cad/VERSION contains a valid canonical release version.
|
||||
With --incremented-from, also checks that the current version is greater than
|
||||
the version at REF.
|
||||
|
||||
Options:
|
||||
--incremented-from REF Compare current release version against REF.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
BASE_REF=""
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--incremented-from)
|
||||
[ "$#" -ge 2 ] || {
|
||||
echo "--incremented-from requires a ref" >&2
|
||||
exit 2
|
||||
}
|
||||
BASE_REF="$2"
|
||||
shift
|
||||
;;
|
||||
--incremented-from=*)
|
||||
BASE_REF="${1#--incremented-from=}"
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
if [ -n "$BASE_REF" ]; then
|
||||
"$SCRIPT_DIR/bump-version.sh" --check-incremented-from "$BASE_REF"
|
||||
else
|
||||
"$SCRIPT_DIR/bump-version.sh" --check
|
||||
fi
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd -P)"
|
||||
|
||||
BUMP_VERSION="$SCRIPT_DIR/bump-version.sh"
|
||||
REMOTE="${RELEASE_REMOTE:-origin}"
|
||||
REPO=""
|
||||
DRY_RUN=0
|
||||
SKIP_CHECKS=0
|
||||
RUN_TESTS=0
|
||||
SKIP_PUSH=0
|
||||
SKIP_RELEASE=0
|
||||
PUBLISH=0
|
||||
BUMP_ARGS=()
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/release/create-github-release.sh <major|minor|patch> [options]
|
||||
scripts/release/create-github-release.sh --set-version X.Y.Z [options]
|
||||
|
||||
Runs the repo release-prep flow:
|
||||
|
||||
1. calls scripts/release/bump-version.sh
|
||||
2. bundles generated skill/plugin outputs
|
||||
3. runs generated-output and plugin checks
|
||||
4. commits the release version bump
|
||||
5. creates and pushes the git tag
|
||||
6. creates a draft GitHub Release for that tag
|
||||
|
||||
Options:
|
||||
--from-version X.Y.Z Pass through to bump-version.sh.
|
||||
--set-version X.Y.Z Pass through to bump-version.sh instead of bumping a part.
|
||||
--dry-run Show the planned bump and release steps without writing.
|
||||
--skip-checks Skip bundle/check scripts after bumping.
|
||||
--run-tests Run scripts/test/test.sh before committing.
|
||||
--skip-push Do not push the branch or tag.
|
||||
--skip-release Do not create the GitHub Release.
|
||||
--publish Publish the GitHub Release immediately instead of creating a draft.
|
||||
--remote NAME Git remote to push to. Defaults to origin.
|
||||
--repo OWNER/REPO GitHub repository for gh release commands.
|
||||
-h, --help Show this help.
|
||||
|
||||
The worktree must be clean before a non-dry-run release prep starts.
|
||||
This is a manual all-in-one fallback. Prefer the Release GitHub Actions
|
||||
workflow for normal releases.
|
||||
EOF
|
||||
}
|
||||
|
||||
die() {
|
||||
echo "error: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
require_command() {
|
||||
command -v "$1" >/dev/null 2>&1 || die "$1 is required"
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
major|minor|patch)
|
||||
BUMP_ARGS+=("$1")
|
||||
;;
|
||||
--from-version|--set-version|--remote|--repo)
|
||||
[ "$#" -ge 2 ] || die "$1 requires a value"
|
||||
case "$1" in
|
||||
--remote)
|
||||
REMOTE="$2"
|
||||
;;
|
||||
--repo)
|
||||
REPO="$2"
|
||||
;;
|
||||
*)
|
||||
BUMP_ARGS+=("$1" "$2")
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
;;
|
||||
--dry-run)
|
||||
DRY_RUN=1
|
||||
;;
|
||||
--skip-checks)
|
||||
SKIP_CHECKS=1
|
||||
;;
|
||||
--run-tests)
|
||||
RUN_TESTS=1
|
||||
;;
|
||||
--skip-push)
|
||||
SKIP_PUSH=1
|
||||
;;
|
||||
--skip-release)
|
||||
SKIP_RELEASE=1
|
||||
;;
|
||||
--publish)
|
||||
PUBLISH=1
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
die "unknown argument: $1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
require_command git
|
||||
[ -x "$BUMP_VERSION" ] || die "missing executable bump-version script: $BUMP_VERSION"
|
||||
|
||||
if [ "$SKIP_PUSH" -eq 1 ] && [ "$SKIP_RELEASE" -eq 0 ]; then
|
||||
die "--skip-push requires --skip-release because gh release create --verify-tag needs the remote tag"
|
||||
fi
|
||||
|
||||
bump_output="$("$BUMP_VERSION" "${BUMP_ARGS[@]}" --dry-run)"
|
||||
version_pair="$(printf '%s\n' "$bump_output" | sed -nE 's/^Version bump: ([0-9]+\.[0-9]+\.[0-9]+) -> ([0-9]+\.[0-9]+\.[0-9]+)$/\1 \2/p')"
|
||||
[ -n "$version_pair" ] || die "could not determine target version from bump-version.sh"
|
||||
read -r current_version next_version <<<"$version_pair"
|
||||
|
||||
if [ "$DRY_RUN" -eq 1 ]; then
|
||||
printf '%s\n' "$bump_output"
|
||||
echo ""
|
||||
echo "Release prep dry run for $current_version -> $next_version:"
|
||||
echo "- Bundle generated outputs with scripts/bundle/bundle.sh"
|
||||
if [ "$SKIP_CHECKS" -eq 0 ]; then
|
||||
echo "- Check generated outputs and plugin metadata with scripts/bundle/bundle.sh --check"
|
||||
fi
|
||||
if [ "$RUN_TESTS" -eq 1 ]; then
|
||||
echo "- Run scripts/test/test.sh"
|
||||
fi
|
||||
echo "- Commit canonical release version and bundled outputs as: Release $next_version"
|
||||
echo "- Create git tag: $next_version"
|
||||
if [ "$SKIP_PUSH" -eq 0 ]; then
|
||||
echo "- Push current branch and tag to $REMOTE"
|
||||
fi
|
||||
if [ "$SKIP_RELEASE" -eq 0 ]; then
|
||||
if [ "$PUBLISH" -eq 1 ]; then
|
||||
echo "- Create published GitHub Release: $next_version"
|
||||
else
|
||||
echo "- Create draft GitHub Release: $next_version"
|
||||
fi
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
branch="$(git symbolic-ref -q --short HEAD || true)"
|
||||
[ -n "$branch" ] || die "release prep must run on a named branch, not detached HEAD"
|
||||
|
||||
if ! git diff --quiet || ! git diff --cached --quiet || [ -n "$(git ls-files --others --exclude-standard)" ]; then
|
||||
die "working tree must be clean before release prep starts"
|
||||
fi
|
||||
|
||||
if git rev-parse -q --verify "refs/tags/$next_version" >/dev/null; then
|
||||
die "local tag already exists: $next_version"
|
||||
fi
|
||||
|
||||
if git ls-remote --exit-code --tags "$REMOTE" "refs/tags/$next_version" >/dev/null 2>&1; then
|
||||
die "remote tag already exists on $REMOTE: $next_version"
|
||||
else
|
||||
ls_remote_status=$?
|
||||
if [ "$ls_remote_status" -ne 2 ]; then
|
||||
die "failed to check remote tags on $REMOTE"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$SKIP_RELEASE" -eq 0 ]; then
|
||||
require_command gh
|
||||
gh_repo_args=()
|
||||
if [ -n "$REPO" ]; then
|
||||
gh_repo_args=(-R "$REPO")
|
||||
fi
|
||||
if gh "${gh_repo_args[@]}" release view "$next_version" >/dev/null 2>&1; then
|
||||
die "GitHub Release already exists: $next_version"
|
||||
fi
|
||||
fi
|
||||
|
||||
"$BUMP_VERSION" "${BUMP_ARGS[@]}"
|
||||
|
||||
"$REPO_ROOT/scripts/bundle/bundle.sh"
|
||||
|
||||
if [ "$SKIP_CHECKS" -eq 0 ]; then
|
||||
"$REPO_ROOT/scripts/bundle/bundle.sh" --check
|
||||
fi
|
||||
|
||||
if [ "$RUN_TESTS" -eq 1 ]; then
|
||||
"$REPO_ROOT/scripts/test/test.sh"
|
||||
fi
|
||||
|
||||
git add -A
|
||||
if git diff --cached --quiet; then
|
||||
die "release prep did not produce any committed changes"
|
||||
fi
|
||||
|
||||
git commit -m "Release $next_version"
|
||||
git tag "$next_version"
|
||||
|
||||
if [ "$SKIP_PUSH" -eq 0 ]; then
|
||||
git push "$REMOTE" "$branch"
|
||||
git push "$REMOTE" "$next_version"
|
||||
fi
|
||||
|
||||
if [ "$SKIP_RELEASE" -eq 0 ]; then
|
||||
release_args=(release create "$next_version" --verify-tag --generate-notes --title "$next_version")
|
||||
if [ "$PUBLISH" -eq 0 ]; then
|
||||
release_args+=(--draft)
|
||||
fi
|
||||
gh "${gh_repo_args[@]}" "${release_args[@]}"
|
||||
fi
|
||||
|
||||
echo "Prepared release $next_version."
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd -P)"
|
||||
|
||||
REMOTE="${RELEASE_REMOTE:-origin}"
|
||||
REPO=""
|
||||
DRY_RUN=0
|
||||
CREATE_RELEASE=1
|
||||
DRAFT=1
|
||||
TARGET_REF="HEAD"
|
||||
SKIP_EXISTING_VERSION=0
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/release/publish-github-release.sh [options]
|
||||
|
||||
Creates the immutable release identity for the current repo version:
|
||||
|
||||
1. verifies plugins/cad/VERSION contains a valid canonical version
|
||||
2. verifies a new version is greater than the latest local semver tag
|
||||
3. creates and pushes the semver git tag for plugins/cad/VERSION
|
||||
4. creates a GitHub Release for that tag with generated notes
|
||||
|
||||
Options:
|
||||
--target REF Commit/ref to tag. Defaults to HEAD.
|
||||
--remote NAME Git remote to push tags to. Defaults to origin.
|
||||
--repo OWNER/REPO GitHub repository for gh release commands.
|
||||
--dry-run Print planned tag/release actions without writing.
|
||||
--skip-existing-version
|
||||
Exit successfully when the version tag already exists.
|
||||
--skip-release Create/push the tag but do not create a GitHub Release.
|
||||
--draft Create a draft GitHub Release. This is the default.
|
||||
--publish Publish the GitHub Release immediately.
|
||||
-h, --help Show this help.
|
||||
|
||||
The workflow path should run this from the production branch after generated
|
||||
outputs have been validated. Local use is a manual fallback.
|
||||
EOF
|
||||
}
|
||||
|
||||
die() {
|
||||
echo "error: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
require_command() {
|
||||
command -v "$1" >/dev/null 2>&1 || die "$1 is required"
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--target)
|
||||
[ "$#" -ge 2 ] || die "--target requires a value"
|
||||
TARGET_REF="$2"
|
||||
shift
|
||||
;;
|
||||
--remote)
|
||||
[ "$#" -ge 2 ] || die "--remote requires a value"
|
||||
REMOTE="$2"
|
||||
shift
|
||||
;;
|
||||
--repo)
|
||||
[ "$#" -ge 2 ] || die "--repo requires a value"
|
||||
REPO="$2"
|
||||
shift
|
||||
;;
|
||||
--dry-run)
|
||||
DRY_RUN=1
|
||||
;;
|
||||
--skip-existing-version)
|
||||
SKIP_EXISTING_VERSION=1
|
||||
;;
|
||||
--skip-release)
|
||||
CREATE_RELEASE=0
|
||||
;;
|
||||
--draft)
|
||||
DRAFT=1
|
||||
;;
|
||||
--publish)
|
||||
DRAFT=0
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
die "unknown argument: $1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
require_command git
|
||||
|
||||
"$SCRIPT_DIR/check-version.sh"
|
||||
|
||||
version="$(tr -d '[:space:]' < "$REPO_ROOT/plugins/cad/VERSION")"
|
||||
[ -n "$version" ] || die "plugins/cad/VERSION is empty"
|
||||
tag_name="$version"
|
||||
target_commit="$(git rev-parse "$TARGET_REF^{commit}")"
|
||||
latest_tag="$(git tag --list '[0-9]*.[0-9]*.[0-9]*' --sort=-version:refname | head -n 1 || true)"
|
||||
|
||||
tag_commit=""
|
||||
if git rev-parse --verify --quiet "refs/tags/$tag_name" >/dev/null; then
|
||||
tag_commit="$(git rev-list -n 1 "$tag_name")"
|
||||
fi
|
||||
|
||||
if [ -n "$tag_commit" ]; then
|
||||
if [ "$tag_commit" != "$target_commit" ]; then
|
||||
if [ "$SKIP_EXISTING_VERSION" -eq 1 ]; then
|
||||
echo "Release tag already exists for $tag_name at $tag_commit; skipping $target_commit."
|
||||
exit 0
|
||||
fi
|
||||
die "release tag $tag_name already points at $tag_commit, not $target_commit"
|
||||
fi
|
||||
echo "Release tag already points at target commit: $tag_name"
|
||||
else
|
||||
if [ -n "$latest_tag" ]; then
|
||||
"$SCRIPT_DIR/check-version.sh" --incremented-from "refs/tags/$latest_tag"
|
||||
fi
|
||||
if [ "$DRY_RUN" -eq 1 ]; then
|
||||
echo "Would create release tag: $tag_name -> $target_commit"
|
||||
echo "Would push release tag to $REMOTE"
|
||||
else
|
||||
git tag "$tag_name" "$target_commit"
|
||||
git push "$REMOTE" "refs/tags/$tag_name"
|
||||
echo "Created and pushed release tag: $tag_name"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$CREATE_RELEASE" -eq 0 ]; then
|
||||
echo "Skipping GitHub Release creation."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
gh_repo_args=()
|
||||
if [ -n "$REPO" ]; then
|
||||
gh_repo_args=(-R "$REPO")
|
||||
fi
|
||||
|
||||
if [ "$DRY_RUN" -eq 1 ]; then
|
||||
if [ "$DRAFT" -eq 1 ]; then
|
||||
echo "Would create draft GitHub Release: $tag_name"
|
||||
else
|
||||
echo "Would create published GitHub Release: $tag_name"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
require_command gh
|
||||
|
||||
if gh "${gh_repo_args[@]}" release view "$tag_name" >/dev/null 2>&1; then
|
||||
echo "GitHub Release already exists: $tag_name"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
release_args=(release create "$tag_name" --verify-tag --generate-notes --title "$tag_name")
|
||||
if [ "$DRAFT" -eq 1 ]; then
|
||||
release_args+=(--draft)
|
||||
fi
|
||||
gh "${gh_repo_args[@]}" "${release_args[@]}"
|
||||
echo "Created GitHub Release: $tag_name"
|
||||
+262
@@ -0,0 +1,262 @@
|
||||
#!/usr/bin/env node
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import process from "node:process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
|
||||
const repoRoot = path.resolve(scriptDir, "../..");
|
||||
const canonicalVersionPath = "plugins/cad/VERSION";
|
||||
const semverPattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
||||
|
||||
const jsonTargets = [
|
||||
{ path: "docs/package.json", fields: [["version"]] },
|
||||
{ path: "docs/package-lock.json", fields: [["version"], ["packages", "", "version"]] },
|
||||
{ path: "packages/cadjs/package.json", fields: [["version"]] },
|
||||
{ path: "packages/cadjs/package-lock.json", fields: [["version"], ["packages", "", "version"]] },
|
||||
{ path: "viewer/package.json", fields: [["version"]] },
|
||||
{
|
||||
path: "viewer/package-lock.json",
|
||||
fields: [
|
||||
["version"],
|
||||
["packages", "", "version"],
|
||||
["packages", "packages/cadjs", "version"],
|
||||
],
|
||||
},
|
||||
{ path: "skills/cad-viewer/scripts/viewer/package.json", fields: [["version"]] },
|
||||
{ path: "plugins/cad/skills/cad-viewer/scripts/viewer/package.json", fields: [["version"]] },
|
||||
{ path: "plugins/cad/.claude-plugin/plugin.json", fields: [["version"]] },
|
||||
{ path: "plugins/cad/.codex-plugin/plugin.json", fields: [["version"]] },
|
||||
{ path: ".claude-plugin/marketplace.json", fields: [["version"]], pluginEntries: ["cad"] },
|
||||
{ path: "viewer/packages/cadjs/package.json", fields: [["version"]], required: false },
|
||||
{ path: "viewer/packages/cadjs/package-lock.json", fields: [["version"], ["packages", "", "version"]], required: false },
|
||||
{ path: "skills/cad-viewer/scripts/viewer/packages/cadjs/package.json", fields: [["version"]], required: false },
|
||||
{
|
||||
path: "skills/cad-viewer/scripts/viewer/packages/cadjs/package-lock.json",
|
||||
fields: [["version"], ["packages", "", "version"]],
|
||||
required: false,
|
||||
},
|
||||
{ path: "plugins/cad/skills/cad-viewer/scripts/viewer/packages/cadjs/package.json", fields: [["version"]], required: false },
|
||||
{
|
||||
path: "plugins/cad/skills/cad-viewer/scripts/viewer/packages/cadjs/package-lock.json",
|
||||
fields: [["version"], ["packages", "", "version"]],
|
||||
required: false,
|
||||
},
|
||||
];
|
||||
|
||||
const tomlTargets = [
|
||||
"packages/cadpy/pyproject.toml",
|
||||
"packages/cadpy_metadata/pyproject.toml",
|
||||
"viewer/moveit2_server/pyproject.toml",
|
||||
"viewer/packages/cadpy/pyproject.toml",
|
||||
"skills/cad-viewer/scripts/viewer/moveit2_server/pyproject.toml",
|
||||
"skills/cad-viewer/scripts/viewer/packages/cadpy/pyproject.toml",
|
||||
"skills/cad/scripts/packages/cadpy/pyproject.toml",
|
||||
"skills/sdf/scripts/packages/cadpy_metadata/pyproject.toml",
|
||||
"skills/srdf/scripts/packages/cadpy_metadata/pyproject.toml",
|
||||
"skills/urdf/scripts/packages/cadpy_metadata/pyproject.toml",
|
||||
"plugins/cad/skills/cad/scripts/packages/cadpy/pyproject.toml",
|
||||
"plugins/cad/skills/cad-viewer/scripts/viewer/moveit2_server/pyproject.toml",
|
||||
"plugins/cad/skills/cad-viewer/scripts/viewer/packages/cadpy/pyproject.toml",
|
||||
"plugins/cad/skills/sdf/scripts/packages/cadpy_metadata/pyproject.toml",
|
||||
"plugins/cad/skills/srdf/scripts/packages/cadpy_metadata/pyproject.toml",
|
||||
"plugins/cad/skills/urdf/scripts/packages/cadpy_metadata/pyproject.toml",
|
||||
];
|
||||
|
||||
function usage() {
|
||||
console.log(`Usage:
|
||||
scripts/release/sync-version.mjs [--check]
|
||||
|
||||
Synchronizes duplicate package and plugin metadata versions from
|
||||
plugins/cad/VERSION. Release preparation edits the canonical VERSION file, then
|
||||
stamps derived metadata from it; the bundle script and the Release workflow
|
||||
re-check the same metadata before production output is written.
|
||||
|
||||
Options:
|
||||
--check Fail if derived version metadata is stale.
|
||||
-h, --help`);
|
||||
}
|
||||
|
||||
function parseArgs(argv) {
|
||||
const options = { check: false };
|
||||
for (const arg of argv) {
|
||||
if (arg === "--check") {
|
||||
options.check = true;
|
||||
} else if (arg === "-h" || arg === "--help") {
|
||||
usage();
|
||||
process.exit(0);
|
||||
} else {
|
||||
throw new Error(`unknown argument: ${arg}`);
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
function repoPath(relativePath) {
|
||||
return path.join(repoRoot, relativePath);
|
||||
}
|
||||
|
||||
function readRequiredText(relativePath) {
|
||||
return readFileSync(repoPath(relativePath), "utf8");
|
||||
}
|
||||
|
||||
function readOptionalText(relativePath, required = true) {
|
||||
try {
|
||||
return readRequiredText(relativePath);
|
||||
} catch (error) {
|
||||
if (!required && error && error.code === "ENOENT") {
|
||||
return null;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function canonicalVersion() {
|
||||
const version = readRequiredText(canonicalVersionPath).trim();
|
||||
if (!semverPattern.test(version)) {
|
||||
throw new Error(`${canonicalVersionPath} must contain a plain X.Y.Z semver version`);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
function formatJsonPath(parts) {
|
||||
const labels = [];
|
||||
for (const part of parts) {
|
||||
if (part === "") {
|
||||
labels[labels.length - 1] = `${labels[labels.length - 1]}[""]`;
|
||||
} else {
|
||||
labels.push(part);
|
||||
}
|
||||
}
|
||||
return labels.join(".");
|
||||
}
|
||||
|
||||
function syncJsonField(data, fieldPath, version, staleLabels) {
|
||||
let cursor = data;
|
||||
for (const key of fieldPath.slice(0, -1)) {
|
||||
if (!cursor || typeof cursor !== "object" || Array.isArray(cursor) || !(key in cursor)) {
|
||||
throw new Error(`missing JSON path: ${formatJsonPath(fieldPath)}`);
|
||||
}
|
||||
cursor = cursor[key];
|
||||
}
|
||||
const key = fieldPath[fieldPath.length - 1];
|
||||
if (!cursor || typeof cursor !== "object" || Array.isArray(cursor) || !(key in cursor)) {
|
||||
throw new Error(`missing JSON path: ${formatJsonPath(fieldPath)}`);
|
||||
}
|
||||
if (cursor[key] !== version) {
|
||||
cursor[key] = version;
|
||||
staleLabels.push(formatJsonPath(fieldPath));
|
||||
}
|
||||
}
|
||||
|
||||
function syncPluginEntry(data, pluginName, version, staleLabels) {
|
||||
if (!Array.isArray(data.plugins)) {
|
||||
throw new Error("plugins must be an array");
|
||||
}
|
||||
const matches = data.plugins.filter((entry) => entry && typeof entry === "object" && entry.name === pluginName);
|
||||
if (matches.length !== 1) {
|
||||
throw new Error(`expected exactly one plugin entry named ${JSON.stringify(pluginName)}`);
|
||||
}
|
||||
if (matches[0].version !== version) {
|
||||
matches[0].version = version;
|
||||
staleLabels.push(`plugins[${pluginName}].version`);
|
||||
}
|
||||
}
|
||||
|
||||
function syncJsonTarget(target, version) {
|
||||
const text = readOptionalText(target.path, target.required !== false);
|
||||
if (text === null) {
|
||||
return null;
|
||||
}
|
||||
const data = JSON.parse(text);
|
||||
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
||||
throw new Error(`${target.path} must contain a JSON object`);
|
||||
}
|
||||
const staleLabels = [];
|
||||
for (const field of target.fields) {
|
||||
syncJsonField(data, field, version, staleLabels);
|
||||
}
|
||||
for (const pluginName of target.pluginEntries ?? []) {
|
||||
syncPluginEntry(data, pluginName, version, staleLabels);
|
||||
}
|
||||
if (staleLabels.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
path: target.path,
|
||||
labels: staleLabels,
|
||||
text: `${JSON.stringify(data, null, 2)}\n`,
|
||||
};
|
||||
}
|
||||
|
||||
function syncTomlTarget(relativePath, version) {
|
||||
const text = readOptionalText(relativePath);
|
||||
if (text === null) {
|
||||
return null;
|
||||
}
|
||||
const matches = [...text.matchAll(/^(version\s*=\s*)"([^"]+)"/gm)];
|
||||
if (matches.length !== 1) {
|
||||
throw new Error(`${relativePath} must contain exactly one double-quoted version field`);
|
||||
}
|
||||
const match = matches[0];
|
||||
if (match[2] === version) {
|
||||
return null;
|
||||
}
|
||||
const start = match.index + match[1].length + 1;
|
||||
const end = start + match[2].length;
|
||||
return {
|
||||
path: relativePath,
|
||||
labels: ["version"],
|
||||
text: `${text.slice(0, start)}${version}${text.slice(end)}`,
|
||||
};
|
||||
}
|
||||
|
||||
function main() {
|
||||
const options = parseArgs(process.argv.slice(2));
|
||||
const version = canonicalVersion();
|
||||
const changes = [];
|
||||
|
||||
for (const target of jsonTargets) {
|
||||
const change = syncJsonTarget(target, version);
|
||||
if (change) {
|
||||
changes.push(change);
|
||||
}
|
||||
}
|
||||
for (const target of tomlTargets) {
|
||||
const change = syncTomlTarget(target, version);
|
||||
if (change) {
|
||||
changes.push(change);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.check) {
|
||||
if (changes.length > 0) {
|
||||
console.error(`Derived version metadata is stale for ${version}:`);
|
||||
for (const change of changes) {
|
||||
console.error(`- ${change.path} (${change.labels.join(", ")})`);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(`Derived version metadata is synced from ${canonicalVersionPath}: ${version}`);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const change of changes) {
|
||||
writeFileSync(repoPath(change.path), change.text, "utf8");
|
||||
}
|
||||
if (changes.length === 0) {
|
||||
console.log(`Derived version metadata already synced from ${canonicalVersionPath}: ${version}`);
|
||||
return;
|
||||
}
|
||||
console.log(`Synced derived version metadata from ${canonicalVersionPath}: ${version}`);
|
||||
for (const change of changes) {
|
||||
console.log(`- ${change.path} (${change.labels.join(", ")})`);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
main();
|
||||
} catch (error) {
|
||||
console.error(`error: ${error.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
|
||||
if [ -z "${PYTHON_BIN:-}" ]; then
|
||||
if [ -x "$REPO_ROOT/.venv/bin/python" ]; then
|
||||
PYTHON_BIN="$REPO_ROOT/.venv/bin/python"
|
||||
else
|
||||
PYTHON_BIN="python3"
|
||||
fi
|
||||
fi
|
||||
|
||||
section() {
|
||||
printf '\n==> %s\n' "$1"
|
||||
}
|
||||
|
||||
run_python_unittest() {
|
||||
local name="$1"
|
||||
local start_dir="$2"
|
||||
shift 2
|
||||
local test_files=()
|
||||
local python_path="$REPO_ROOT:$REPO_ROOT/$start_dir"
|
||||
local path_entry
|
||||
|
||||
section "$name"
|
||||
|
||||
while IFS= read -r test_file; do
|
||||
test_files+=("$test_file")
|
||||
done < <(find "$REPO_ROOT/$start_dir" -name 'test*.py' -print | sort)
|
||||
|
||||
if [ "${#test_files[@]}" -eq 0 ]; then
|
||||
echo "No Python tests found under $start_dir"
|
||||
return 0
|
||||
fi
|
||||
|
||||
for path_entry in "$@"; do
|
||||
if [[ "$path_entry" = /* ]]; then
|
||||
python_path="$python_path:$path_entry"
|
||||
else
|
||||
python_path="$python_path:$REPO_ROOT/$path_entry"
|
||||
fi
|
||||
done
|
||||
|
||||
PYTHONPATH="$python_path${PYTHONPATH:+:$PYTHONPATH}" \
|
||||
"$PYTHON_BIN" -m unittest "${test_files[@]}"
|
||||
}
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/test/common.sh
|
||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh"
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
section "Documentation checks"
|
||||
if git rev-parse --is-inside-work-tree >/dev/null 2>&1 && git lfs version >/dev/null 2>&1; then
|
||||
if git lfs ls-files --name-only | grep -q '^docs/public/hero/'; then
|
||||
git lfs pull --include="docs/public/hero/**" --exclude=""
|
||||
fi
|
||||
fi
|
||||
npm --prefix docs run check
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/test/common.sh
|
||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh"
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
run_python_unittest "Global policy tests" "tests/python/global"
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/test/common.sh
|
||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh"
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
section "cadjs tests"
|
||||
npm --prefix packages/cadjs test
|
||||
|
||||
section "implicitjs tests"
|
||||
npm --prefix packages/implicitjs test
|
||||
|
||||
section "CAD Viewer tests"
|
||||
npm --prefix viewer run test
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/test/common.sh
|
||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh"
|
||||
|
||||
LIST_SKILLS_SCRIPT="$REPO_ROOT/scripts/utils/list-skills.sh"
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
run_python_unittest "cadpy package Python tests" "tests/python/packages/cadpy" "packages/cadpy/src"
|
||||
run_python_unittest "cadpy_metadata package Python tests" "tests/python/packages/cadpy_metadata" "packages/cadpy_metadata/src"
|
||||
|
||||
while IFS= read -r skill; do
|
||||
test_dir="tests/python/skills/$skill"
|
||||
if [ -d "$test_dir" ]; then
|
||||
skill_paths=("skills/$skill/scripts")
|
||||
if [ "$skill" = "cad" ] || [ "$skill" = "dxf" ]; then
|
||||
skill_paths+=("skills/$skill/scripts/packages/cadpy/src")
|
||||
fi
|
||||
run_python_unittest "$skill skill Python tests" "$test_dir" "${skill_paths[@]}"
|
||||
fi
|
||||
done < <("$LIST_SKILLS_SCRIPT")
|
||||
|
||||
run_python_unittest "MoveIt2 server Python tests" "tests/python/viewer/moveit2_server" "viewer/moveit2_server"
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
"$SCRIPT_DIR/test-js.sh"
|
||||
"$SCRIPT_DIR/test-python.sh"
|
||||
"$SCRIPT_DIR/test-global.sh"
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
SKILLS_ROOT="$REPO_ROOT/skills"
|
||||
|
||||
if [ ! -d "$SKILLS_ROOT" ]; then
|
||||
echo "Missing skills directory: $SKILLS_ROOT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find "$SKILLS_ROOT" -mindepth 1 -maxdepth 1 -type d -print |
|
||||
while IFS= read -r skill_dir; do
|
||||
if [ -f "$skill_dir/SKILL.md" ]; then
|
||||
basename "$skill_dir"
|
||||
fi
|
||||
done |
|
||||
LC_ALL=C sort
|
||||
@@ -0,0 +1,217 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
function usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
VIEWER_VERCEL_BLOB_PREFIX=<public-url-prefix> scripts/viewer/download-viewer-models-catalog.sh <target-dir> [--force]
|
||||
|
||||
Downloads catalog.json and all catalog-referenced Blob assets from VIEWER_VERCEL_BLOB_PREFIX.
|
||||
|
||||
Environment:
|
||||
VIEWER_VERCEL_BLOB_PREFIX Required. Public Blob URL prefix, for example: https://<store>.public.blob.vercel-storage.com/models
|
||||
VIEWER_ASSET_BACKEND Optional. Defaults to vercel-blob.
|
||||
|
||||
Options:
|
||||
--force Replace <target-dir> if it already exists.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
: "${VIEWER_VERCEL_BLOB_PREFIX:?Set VIEWER_VERCEL_BLOB_PREFIX to the public Vercel Blob URL prefix before downloading.}"
|
||||
|
||||
export VIEWER_ASSET_BACKEND="${VIEWER_ASSET_BACKEND:-vercel-blob}"
|
||||
|
||||
node --input-type=module - "$@" <<'NODE'
|
||||
import { createWriteStream } from "node:fs";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { Readable } from "node:stream";
|
||||
import { pipeline } from "node:stream/promises";
|
||||
|
||||
function usage() {
|
||||
return `Usage:
|
||||
scripts/viewer/download-viewer-models-catalog.sh <target-dir> [--force]
|
||||
|
||||
Downloads catalog.json and all catalog-referenced Blob assets from VIEWER_VERCEL_BLOB_PREFIX.
|
||||
|
||||
Options:
|
||||
--force Replace <target-dir> if it already exists.
|
||||
-h, --help Show this help.`;
|
||||
}
|
||||
|
||||
function parseArgs(argv) {
|
||||
let targetDir = "";
|
||||
let force = false;
|
||||
for (const arg of argv) {
|
||||
if (arg === "-h" || arg === "--help") {
|
||||
return { help: true };
|
||||
}
|
||||
if (arg === "--force") {
|
||||
force = true;
|
||||
continue;
|
||||
}
|
||||
if (!targetDir) {
|
||||
targetDir = arg;
|
||||
continue;
|
||||
}
|
||||
throw new Error(`Unexpected argument: ${arg}`);
|
||||
}
|
||||
if (!targetDir) {
|
||||
throw new Error("Missing target directory.");
|
||||
}
|
||||
return { targetDir, force };
|
||||
}
|
||||
|
||||
function catalogUrlFromPrefix(prefix) {
|
||||
const url = new URL(prefix);
|
||||
const prefixPath = url.pathname.replace(/^\/+|\/+$/g, "");
|
||||
url.pathname = `/${[prefixPath, "catalog.json"].filter(Boolean).join("/")}`;
|
||||
url.search = "";
|
||||
url.hash = "";
|
||||
return url;
|
||||
}
|
||||
|
||||
function fileRefForBlobUrl(rawUrl, prefixUrl) {
|
||||
const assetUrl = new URL(rawUrl, prefixUrl);
|
||||
if (assetUrl.origin !== prefixUrl.origin) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const prefixPath = prefixUrl.pathname.replace(/\/+$/g, "");
|
||||
const assetPath = assetUrl.pathname;
|
||||
let relativePath = "";
|
||||
if (!prefixPath || prefixPath === "/") {
|
||||
relativePath = assetPath.replace(/^\/+/, "");
|
||||
} else if (assetPath.startsWith(`${prefixPath}/`)) {
|
||||
relativePath = assetPath.slice(prefixPath.length + 1);
|
||||
}
|
||||
|
||||
const decoded = decodeURIComponent(relativePath);
|
||||
const normalized = path.posix.normalize(decoded.replace(/\\/g, "/").replace(/^\/+/, ""));
|
||||
if (!normalized || normalized === "." || normalized.startsWith("../")) {
|
||||
return "";
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function collectBlobDownloads(catalog, prefixUrl) {
|
||||
const downloads = new Map();
|
||||
function visit(value) {
|
||||
if (Array.isArray(value)) {
|
||||
for (const item of value) {
|
||||
visit(item);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!value || typeof value !== "object") {
|
||||
return;
|
||||
}
|
||||
for (const [key, child] of Object.entries(value)) {
|
||||
if (typeof child === "string" && (key === "url" || key.endsWith("Url"))) {
|
||||
const fileRef = fileRefForBlobUrl(child, prefixUrl);
|
||||
if (fileRef && fileRef !== "catalog.json") {
|
||||
downloads.set(fileRef, new URL(child, prefixUrl).toString());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
visit(child);
|
||||
}
|
||||
}
|
||||
visit(catalog);
|
||||
return [...downloads.entries()]
|
||||
.map(([fileRef, url]) => ({ fileRef, url }))
|
||||
.sort((a, b) => a.fileRef.localeCompare(b.fileRef));
|
||||
}
|
||||
|
||||
function destinationPath(targetDir, fileRef) {
|
||||
const normalized = path.posix.normalize(String(fileRef || "").replace(/\\/g, "/").replace(/^\/+/, ""));
|
||||
if (!normalized || normalized === "." || normalized.startsWith("../")) {
|
||||
throw new Error(`Unsafe catalog path: ${fileRef}`);
|
||||
}
|
||||
const resolved = path.resolve(targetDir, ...normalized.split("/"));
|
||||
if (!resolved.startsWith(`${targetDir}${path.sep}`)) {
|
||||
throw new Error(`Catalog path escapes target directory: ${fileRef}`);
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
|
||||
async function fetchChecked(url) {
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to download ${url}: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
async function downloadFile(url, filePath) {
|
||||
const response = await fetchChecked(url);
|
||||
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
||||
const tmpPath = `${filePath}.download`;
|
||||
await pipeline(Readable.fromWeb(response.body), createWriteStream(tmpPath));
|
||||
await fs.rename(tmpPath, filePath);
|
||||
}
|
||||
|
||||
function prefixUrlFromEnv() {
|
||||
try {
|
||||
return new URL(process.env.VIEWER_VERCEL_BLOB_PREFIX);
|
||||
} catch {
|
||||
throw new Error("VIEWER_VERCEL_BLOB_PREFIX must be a full public Vercel Blob URL for downloads.");
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const options = parseArgs(process.argv.slice(2));
|
||||
if (options.help) {
|
||||
console.log(usage());
|
||||
return;
|
||||
}
|
||||
|
||||
const prefixUrl = prefixUrlFromEnv();
|
||||
const catalogUrl = catalogUrlFromPrefix(prefixUrl);
|
||||
const targetDir = path.resolve(options.targetDir);
|
||||
if (targetDir === path.parse(targetDir).root) {
|
||||
throw new Error("Refusing to use filesystem root as target directory.");
|
||||
}
|
||||
|
||||
try {
|
||||
await fs.lstat(targetDir);
|
||||
if (!options.force) {
|
||||
throw new Error(`Target directory already exists: ${targetDir}. Pass --force to replace it.`);
|
||||
}
|
||||
await fs.rm(targetDir, { recursive: true, force: true });
|
||||
} catch (error) {
|
||||
if (error?.code !== "ENOENT") {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
await fs.mkdir(targetDir, { recursive: true });
|
||||
|
||||
console.log(`Downloading ${catalogUrl}`);
|
||||
const catalogResponse = await fetchChecked(catalogUrl);
|
||||
const catalog = await catalogResponse.json();
|
||||
const downloads = collectBlobDownloads(catalog, prefixUrl);
|
||||
await fs.writeFile(
|
||||
path.join(targetDir, "catalog.json"),
|
||||
`${JSON.stringify(catalog, null, 2)}\n`
|
||||
);
|
||||
|
||||
for (const download of downloads) {
|
||||
console.log(`Downloading ${download.fileRef}`);
|
||||
await downloadFile(download.url, destinationPath(targetDir, download.fileRef));
|
||||
}
|
||||
console.log(`Downloaded catalog and ${downloads.length} assets to ${targetDir}`);
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error?.message || String(error));
|
||||
process.exit(1);
|
||||
});
|
||||
NODE
|
||||
+294
@@ -0,0 +1,294 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SOURCE_REPO_ROOT="$(git -C "$SCRIPT_DIR/../.." rev-parse --show-toplevel)"
|
||||
DEFAULT_TARGET="../cad-viewer"
|
||||
TARGET_ARG="$DEFAULT_TARGET"
|
||||
TARGET_SET=0
|
||||
DRY_RUN=0
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/viewer/sync-cad-viewer-repo.sh [--dry-run] [target-relative-dir]
|
||||
|
||||
Copies the CAD Viewer source repo layout into a separate standalone cad-viewer
|
||||
git checkout. The target path is resolved relative to this text-to-cad repo.
|
||||
|
||||
Default target:
|
||||
../cad-viewer
|
||||
|
||||
What gets copied:
|
||||
viewer/* -> target root
|
||||
packages/cadjs/* -> target/packages/cadjs
|
||||
packages/cadpy/* -> target/packages/cadpy
|
||||
|
||||
The target checkout must already exist and must be the root of a separate git
|
||||
repo. Everything in the target root is deleted before copying, except .git.
|
||||
|
||||
Options:
|
||||
--dry-run Print what would be overwritten without changing files.
|
||||
-h, --help Show this help.
|
||||
EOF
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--dry-run)
|
||||
DRY_RUN=1
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
if [ "$#" -gt 0 ]; then
|
||||
if [ "$TARGET_SET" -eq 1 ]; then
|
||||
echo "Target path was provided more than once." >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
fi
|
||||
TARGET_ARG="$1"
|
||||
TARGET_SET=1
|
||||
shift
|
||||
fi
|
||||
break
|
||||
;;
|
||||
-*)
|
||||
echo "Unknown option: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
if [ "$TARGET_SET" -eq 1 ]; then
|
||||
echo "Target path was provided more than once." >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
fi
|
||||
TARGET_ARG="$1"
|
||||
TARGET_SET=1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
echo "Unexpected extra arguments: $*" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
case "$TARGET_ARG" in
|
||||
/*)
|
||||
echo "Target must be a relative path; got: $TARGET_ARG" >&2
|
||||
exit 2
|
||||
;;
|
||||
"")
|
||||
echo "Target path must not be empty." >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
require_command() {
|
||||
if ! command -v "$1" >/dev/null 2>&1; then
|
||||
echo "$1 is required." >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
require_path() {
|
||||
local path_to_check="$1"
|
||||
local label="$2"
|
||||
if [ ! -e "$path_to_check" ]; then
|
||||
echo "Missing $label: $path_to_check" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
require_command git
|
||||
require_command node
|
||||
require_command rsync
|
||||
|
||||
VIEWER_DIR="$SOURCE_REPO_ROOT/viewer"
|
||||
CADJS_DIR="$SOURCE_REPO_ROOT/packages/cadjs"
|
||||
CADPY_DIR="$SOURCE_REPO_ROOT/packages/cadpy"
|
||||
TARGET_INPUT="$SOURCE_REPO_ROOT/$TARGET_ARG"
|
||||
|
||||
require_path "$VIEWER_DIR/package.json" "viewer package"
|
||||
require_path "$CADJS_DIR/package.json" "cadjs package"
|
||||
require_path "$CADPY_DIR/pyproject.toml" "cadpy package"
|
||||
|
||||
if [ ! -d "$TARGET_INPUT" ]; then
|
||||
echo "Target directory does not exist: $TARGET_INPUT" >&2
|
||||
echo "Create or clone the standalone cad-viewer repo first." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TARGET_DIR="$(cd "$TARGET_INPUT" && pwd -P)"
|
||||
SOURCE_REPO_ROOT="$(cd "$SOURCE_REPO_ROOT" && pwd -P)"
|
||||
TARGET_GIT_ROOT="$(git -C "$TARGET_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
|
||||
|
||||
if [ -z "$TARGET_GIT_ROOT" ]; then
|
||||
echo "Target is not inside a git repository: $TARGET_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TARGET_GIT_ROOT="$(cd "$TARGET_GIT_ROOT" && pwd -P)"
|
||||
|
||||
if [ "$TARGET_GIT_ROOT" != "$TARGET_DIR" ]; then
|
||||
echo "Target must be the root of its own git repo." >&2
|
||||
echo "Target: $TARGET_DIR" >&2
|
||||
echo "Git root: $TARGET_GIT_ROOT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TARGET_DIR" = "$SOURCE_REPO_ROOT" ]; then
|
||||
echo "Refusing to overwrite the source repo." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TARGET_DIR" = "$VIEWER_DIR" ] || [ "$TARGET_DIR" = "$CADJS_DIR" ] || [ "$TARGET_DIR" = "$CADPY_DIR" ]; then
|
||||
echo "Refusing to overwrite a source directory: $TARGET_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RSYNC_EXCLUDES=(
|
||||
--exclude node_modules
|
||||
--exclude dist
|
||||
--exclude dist-verify
|
||||
--exclude .vite
|
||||
--exclude .next
|
||||
--exclude .next-build
|
||||
--exclude .next-dev
|
||||
--exclude .next-verify
|
||||
--exclude .vercel
|
||||
--exclude coverage
|
||||
--exclude tmp
|
||||
--exclude .pytest_cache
|
||||
--exclude __pycache__
|
||||
--exclude '*.pyc'
|
||||
--exclude '*.pyo'
|
||||
--exclude .DS_Store
|
||||
--include '.env.example'
|
||||
--include '.env.*.example'
|
||||
--exclude '.env'
|
||||
--exclude '.env.*'
|
||||
)
|
||||
|
||||
echo "Source: $SOURCE_REPO_ROOT"
|
||||
echo "Target: $TARGET_DIR"
|
||||
echo ""
|
||||
echo "This will delete everything in the target root except .git, then copy viewer/, packages/cadjs, and packages/cadpy."
|
||||
|
||||
if [ "$DRY_RUN" -eq 1 ]; then
|
||||
echo ""
|
||||
echo "Dry run only. Target entries that would be removed:"
|
||||
find "$TARGET_DIR" -mindepth 1 -maxdepth 1 ! -name .git -print | sort
|
||||
echo ""
|
||||
echo "Dry run only. Copy plan:"
|
||||
echo " $VIEWER_DIR/ -> $TARGET_DIR/"
|
||||
echo " $CADJS_DIR/ -> $TARGET_DIR/packages/cadjs/"
|
||||
echo " $CADPY_DIR/ -> $TARGET_DIR/packages/cadpy/"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
find "$TARGET_DIR" -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
|
||||
|
||||
rsync -a "${RSYNC_EXCLUDES[@]}" "$VIEWER_DIR/" "$TARGET_DIR/"
|
||||
mkdir -p "$TARGET_DIR/packages"
|
||||
rsync -a "${RSYNC_EXCLUDES[@]}" "$CADJS_DIR/" "$TARGET_DIR/packages/cadjs/"
|
||||
rsync -a "${RSYNC_EXCLUDES[@]}" "$CADPY_DIR/" "$TARGET_DIR/packages/cadpy/"
|
||||
|
||||
node --input-type=module - "$TARGET_DIR" <<'NODE'
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const targetRoot = process.argv[2];
|
||||
|
||||
function readJson(relativePath) {
|
||||
return JSON.parse(fs.readFileSync(path.join(targetRoot, relativePath), "utf8"));
|
||||
}
|
||||
|
||||
function writeJson(relativePath, value) {
|
||||
fs.writeFileSync(path.join(targetRoot, relativePath), `${JSON.stringify(value, null, 2)}\n`);
|
||||
}
|
||||
|
||||
function replaceText(relativePath, replacements) {
|
||||
const filePath = path.join(targetRoot, relativePath);
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return;
|
||||
}
|
||||
let text = fs.readFileSync(filePath, "utf8");
|
||||
for (const [from, to] of replacements) {
|
||||
text = text.split(from).join(to);
|
||||
}
|
||||
fs.writeFileSync(filePath, text);
|
||||
}
|
||||
|
||||
const packageJson = readJson("package.json");
|
||||
packageJson.dependencies = {
|
||||
...packageJson.dependencies,
|
||||
cadjs: "file:./packages/cadjs",
|
||||
};
|
||||
if (packageJson.scripts) {
|
||||
delete packageJson.scripts["runtime:bundle"];
|
||||
delete packageJson.scripts["runtime:check"];
|
||||
}
|
||||
writeJson("package.json", packageJson);
|
||||
|
||||
const lockPath = path.join(targetRoot, "package-lock.json");
|
||||
if (fs.existsSync(lockPath)) {
|
||||
const lock = readJson("package-lock.json");
|
||||
const rootPackage = lock.packages?.[""];
|
||||
if (rootPackage?.dependencies) {
|
||||
rootPackage.dependencies.cadjs = "file:./packages/cadjs";
|
||||
}
|
||||
if (lock.packages?.["../packages/cadjs"]) {
|
||||
lock.packages["packages/cadjs"] = lock.packages["../packages/cadjs"];
|
||||
delete lock.packages["../packages/cadjs"];
|
||||
}
|
||||
if (lock.packages?.["node_modules/cadjs"]) {
|
||||
lock.packages["node_modules/cadjs"].resolved = "packages/cadjs";
|
||||
}
|
||||
writeJson("package-lock.json", lock);
|
||||
}
|
||||
|
||||
const pathReplacements = [
|
||||
["file:../packages/cadjs", "file:./packages/cadjs"],
|
||||
["../packages/cadjs", "packages/cadjs"],
|
||||
["../packages/cadpy", "packages/cadpy"],
|
||||
["../.venv/bin/python -m pip install -e packages/cadpy", "python -m pip install -e packages/cadpy"],
|
||||
["npm --prefix viewer run upload:blob", "npm run upload:blob"],
|
||||
["npm run build\nnpm run runtime:check", "npm run build"],
|
||||
[
|
||||
"\nWhen changing Viewer source that feeds the cad-viewer skill runtime, refresh the\ngenerated runtime from the repository root:\n\n```bash\nscripts/bundle/bundle-skill.sh cad-viewer\nscripts/bundle/bundle-skill.sh cad-viewer --check\n```\n",
|
||||
"\n",
|
||||
],
|
||||
[
|
||||
"The generated cad-viewer skill runtime\nbundles `cadpy` under `packages/cadpy` and does not need the repository\nroot.",
|
||||
"The standalone checkout keeps `cadpy` under `packages/cadpy` so local\nregeneration can discover it without the source workbench.",
|
||||
],
|
||||
];
|
||||
replaceText("README.md", pathReplacements);
|
||||
replaceText("docs/backend.md", pathReplacements);
|
||||
|
||||
const gitignorePath = path.join(targetRoot, ".gitignore");
|
||||
if (fs.existsSync(gitignorePath)) {
|
||||
const gitignore = fs.readFileSync(gitignorePath, "utf8");
|
||||
if (!/^\.venv$/mu.test(gitignore)) {
|
||||
fs.writeFileSync(gitignorePath, `${gitignore.replace(/\s*$/u, "\n")}.venv\n`);
|
||||
}
|
||||
}
|
||||
NODE
|
||||
|
||||
echo ""
|
||||
echo "Synced standalone CAD Viewer checkout:"
|
||||
echo " $TARGET_DIR"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " cd \"$TARGET_DIR\""
|
||||
echo " npm install"
|
||||
echo " npm run test"
|
||||
echo " npm run build"
|
||||
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
DEFAULT_VIEWER_VERCEL_BLOB_PREFIX="models"
|
||||
|
||||
function usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
BLOB_READ_WRITE_TOKEN=<token> scripts/viewer/upload-viewer-models-catalog.sh [directory] [upload options]
|
||||
|
||||
Uploads the models catalog and CAD Viewer-supported assets to Vercel Blob.
|
||||
The uploader excludes mechbench/, mechbench2/, 7dof_arm/, and Python source
|
||||
files by default.
|
||||
|
||||
Environment:
|
||||
BLOB_READ_WRITE_TOKEN Vercel Blob read/write token.
|
||||
VIEWER_VERCEL_BLOB_READ_WRITE_TOKEN Alternate Vercel Blob read/write token.
|
||||
VIEWER_ASSET_BACKEND Optional. Defaults to vercel-blob.
|
||||
|
||||
Blob prefix:
|
||||
models Script-defined upload prefix for this branch.
|
||||
|
||||
Options are passed through to npm --prefix viewer run upload:blob.
|
||||
If no directory is passed, models/ is uploaded.
|
||||
Use --skip-existing to reuse matching remote catalog assets, and
|
||||
--fetch-missing-lfs to download only the Git LFS objects needed for new or
|
||||
changed uploads.
|
||||
EOF
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "${BLOB_READ_WRITE_TOKEN:-}" ] && [ -z "${VIEWER_VERCEL_BLOB_READ_WRITE_TOKEN:-}" ]; then
|
||||
echo "Set BLOB_READ_WRITE_TOKEN or VIEWER_VERCEL_BLOB_READ_WRITE_TOKEN before uploading to Vercel Blob." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export VIEWER_ASSET_BACKEND="${VIEWER_ASSET_BACKEND:-vercel-blob}"
|
||||
export VIEWER_VERCEL_BLOB_PREFIX="$DEFAULT_VIEWER_VERCEL_BLOB_PREFIX"
|
||||
|
||||
UPLOAD_DIR="$REPO_ROOT/models"
|
||||
if [ "$#" -gt 0 ] && [[ "${1:-}" != --* ]]; then
|
||||
UPLOAD_DIR="$1"
|
||||
shift
|
||||
fi
|
||||
|
||||
echo "Uploading viewer models catalog to Blob prefix: $VIEWER_VERCEL_BLOB_PREFIX"
|
||||
|
||||
npm --prefix "$REPO_ROOT/viewer" run upload:blob -- \
|
||||
"$UPLOAD_DIR" \
|
||||
"$@"
|
||||
Reference in New Issue
Block a user