← Back to SKILL.md1#!/usr/bin/env bash2#3# Run create-nx-workspace against every CNW template, non-interactively.4#5# Each template clones into its own subdirectory under an output base dir, so6# no two runs collide ("The directory '<name>' already exists" -> CnwError7# DIRECTORY_EXISTS). Existing per-template dirs are removed before each run so8# the script is idempotent.9#10# Usage:11# ./run-all-templates.sh [OUTPUT_DIR]12#13# Env:14# CNW_VERSION create-nx-workspace version/tag (default: latest)15# ONLY space-separated subset of template repos to run16#17# Examples:18# ./run-all-templates.sh19# CNW_VERSION=22.7.0 ./run-all-templates.sh /tmp/cnw-out20# ONLY="nextjs-template react-template" ./run-all-templates.sh21 22set -uo pipefail23 24CNW_VERSION="${CNW_VERSION:-latest}"25OUTPUT_DIR="${1:-$PWD/cnw-runs-$(date +%Y%m%d-%H%M%S)}"26 27# Template GitHub repos under the nrwl org. --template requires the full28# nrwl/<repo> form except for the 4 shorthands (empty/react/angular/typescript).29# Listing the full repo name for all keeps it uniform.30TEMPLATES=(31 empty-template32 typescript-template33 react-template34 angular-template35 react-mfe-template36 nextjs-template37 nestjs-template38 express-api-template39 astro-starlight-template40 remotion-template41 tanstack-start-template42 tanstack-ai-template43)44 45if [ -n "${ONLY:-}" ]; then46 # shellcheck disable=SC220647 TEMPLATES=($ONLY)48fi49 50mkdir -p "$OUTPUT_DIR"51cd "$OUTPUT_DIR" || exit 152 53echo "CNW version : $CNW_VERSION"54echo "Output dir : $OUTPUT_DIR"55echo "Templates : ${#TEMPLATES[@]}"56echo57 58declare -a PASS=()59declare -a FAIL=()60 61for repo in "${TEMPLATES[@]}"; do62 # workspace name = repo without the -template suffix (valid npm pkg name)63 name="${repo%-template}"64 target="$OUTPUT_DIR/$name"65 66 echo "=================================================================="67 echo ">> $repo -> $name"68 echo "=================================================================="69 70 # avoid DIRECTORY_EXISTS: clear any prior run for this template71 rm -rf "$target"72 73 CI=true npx --yes "create-nx-workspace@${CNW_VERSION}" "$name" \74 --template "nrwl/$repo" \75 --nxCloud=skip \76 --no-interactive77 78 if [ $? -eq 0 ] && [ -d "$target" ]; then79 PASS+=("$repo")80 echo "OK: $repo"81 else82 FAIL+=("$repo")83 echo "FAILED: $repo"84 fi85 echo86done87 88echo "=================================================================="89echo "SUMMARY"90echo "=================================================================="91echo "Passed (${#PASS[@]}): ${PASS[*]:-none}"92echo "Failed (${#FAIL[@]}): ${FAIL[*]:-none}"93echo "Output: $OUTPUT_DIR"94 95[ ${#FAIL[@]} -eq 0 ]96