unoverse 0.1.55 → 0.1.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,25 +35,83 @@ cmd_deploy() {
35
35
  pick_option "DigitalOcean" "AWS"
36
36
  [ "$PICKED" = "1" ] && cloud=aws || cloud=digitalocean
37
37
  echo ""
38
- cmd_ground "$([ "$cloud" = "aws" ] && echo aws || echo do)" || {
38
+ # An existing tfvars is PROGRESS, not a conflict: the previous run wrote it. Only
39
+ # a missing file needs the ground; either way the flow continues below.
40
+ if [ -f "$ROOT/infra/$cloud/terraform.tfvars" ]; then
41
+ ok "Using your existing infra/$cloud/terraform.tfvars"
42
+ else
43
+ cmd_ground "$([ "$cloud" = "aws" ] && echo aws || echo do)" || {
44
+ echo ""
45
+ info "Once that is sorted, run ${BOLD}unoverse deploy${NC} again. It picks up right here."
46
+ echo ""
47
+ exit 1
48
+ }
49
+ fi
50
+ echo ""
51
+ ok "Your $cloud ground is prefilled ${DIM}(infra/$cloud/terraform.tfvars)${NC}"
52
+
53
+ # FILL THE BLANKS OURSELVES. Every FILL_ME the universe already knows (.env from
54
+ # setup) is copied in silently; only genuine unknowns are asked. Hand-copying
55
+ # values between our own files is not a step a developer should ever see.
56
+ local tfv="$ROOT/infra/$cloud/terraform.tfvars"
57
+ _tf_put() { # key value — safe replacement via node (values may hold sed specials)
58
+ node -e 'const fs=require("fs");const[f,k,v]=process.argv.slice(1);let s=fs.readFileSync(f,"utf8");s=s.replace(new RegExp("^"+k+"(\\s*)=\\s*\"FILL_ME\"","m"),k+"$1= "+JSON.stringify(v));fs.writeFileSync(f,s)' "$tfv" "$1" "$2"
59
+ }
60
+ _tf_fill() { # key envname prompt
61
+ local key="$1" envname="$2" prompt="$3" val
62
+ grep -q "^${key}[[:space:]]*=[[:space:]]*\"FILL_ME\"" "$tfv" 2>/dev/null || return 0
63
+ val=$(grep "^${envname}=" "$ROOT/.env" 2>/dev/null | head -1 | cut -d= -f2-)
64
+ if [ -n "$val" ]; then
65
+ _tf_put "$key" "$val"
66
+ ok "$key ${DIM}from your .env${NC}"
67
+ else
68
+ read -r -p " $prompt: " val
69
+ [ -n "$val" ] && _tf_put "$key" "$val"
70
+ fi
71
+ }
72
+ echo ""
73
+ _tf_fill docr_token DOCR_TOKEN "Registry access token (from your Unoverse admin)"
74
+ _tf_fill openai_api_key OPENAI_API_KEY "OPENAI_API_KEY (powers the platform's AI)"
75
+ if grep -q '^auth_issuer[[:space:]]*=[[:space:]]*"FILL_ME"' "$tfv" 2>/dev/null; then
76
+ local env_auth
77
+ env_auth=$(grep "^AUTH_ISSUER=" "$ROOT/.env" 2>/dev/null | cut -d= -f2-)
78
+ if [ -z "$env_auth" ]; then
79
+ echo ""
80
+ info "A deployed universe requires a login. Local auth-off does not deploy"
81
+ info "${DIM}(Auth0 or any OIDC provider; the issuer looks like https://your-tenant.auth0.com)${NC}"
82
+ fi
83
+ fi
84
+ _tf_fill auth_issuer AUTH_ISSUER "AUTH_ISSUER"
85
+ _tf_fill auth_client_id AUTH_CLIENT_ID "AUTH_CLIENT_ID"
86
+
87
+ if grep -q "FILL_ME" "$tfv" 2>/dev/null; then
39
88
  echo ""
40
- info "Once that is sorted, run ${BOLD}unoverse deploy${NC} again. It picks up right here."
89
+ warn "Some values are still blank in ${BOLD}infra/$cloud/terraform.tfvars${NC} fill them, then:"
90
+ info " cd infra/$cloud && terraform init && terraform apply"
91
+ info " cd ../.. && unoverse deploy"
41
92
  echo ""
42
93
  exit 1
43
- }
44
- echo ""
45
- ok "Your $cloud ground is prefilled ${DIM}(infra/$cloud/terraform.tfvars)${NC}"
94
+ fi
95
+ ok "terraform.tfvars is complete"
96
+
97
+ # PROVISION FROM RIGHT HERE, if wanted. terraform apply prints its plan and asks
98
+ # for its own explicit yes — creating billable infrastructure stays a deliberate,
99
+ # visible act, it just no longer requires leaving the flow.
46
100
  echo ""
47
- local step=1
48
- if grep -q "FILL_ME" "$ROOT/infra/$cloud/terraform.tfvars" 2>/dev/null; then
49
- info "$step. Fill in each FILL_ME value: ${BOLD}infra/$cloud/terraform.tfvars${NC}"
50
- step=$((step+1))
101
+ local REPLY
102
+ read -r -p " Provision now? terraform runs here and shows its plan first. [Y/n] " REPLY
103
+ if [[ "$REPLY" =~ ^[Nn]$ ]]; then
104
+ info "When ready: cd infra/$cloud && terraform init && terraform apply && cd ../.. && unoverse deploy"
105
+ exit 0
51
106
  fi
52
- info "$step. ${BOLD}cd infra/$cloud && terraform init && terraform apply${NC} ${DIM}creates the server (billable)${NC}"
53
- step=$((step+1))
54
- info "$step. ${BOLD}cd ../.. && unoverse deploy${NC} ${DIM}ships the platform onto it${NC}"
107
+ command -v terraform >/dev/null 2>&1 || { fail "terraform is not installed"; info " brew install terraform"; exit 1; }
108
+ terraform -chdir="$ROOT/infra/$cloud" init -input=false >/dev/null 2>&1 || { fail "terraform init failed"; exit 1; }
109
+ terraform -chdir="$ROOT/infra/$cloud" apply || { fail "apply did not complete. Re-run: unoverse deploy"; exit 1; }
110
+ echo ""
111
+ ok "Infrastructure is up. Shipping the platform onto it..."
55
112
  echo ""
56
- exit 0
113
+ cmd_deploy init
114
+ return $?
57
115
  fi
58
116
 
59
117
  # Read deploy target from .env.production
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unoverse",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "description": "The Unoverse front door — create a Studio project, a universe, or a client app, and launch Studio.",
5
5
  "license": "SEE LICENSE IN README.md",
6
6
  "type": "module",