astro-tractstack 2.0.0-rc.4 → 2.0.0-rc.6
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.
- package/README.md +226 -97
- package/bin/create-tractstack.js +101 -39
- package/dist/index.js +8 -0
- package/package.json +2 -2
- package/templates/brand/og.png +0 -0
- package/templates/brand/oglogo.png +0 -0
- package/templates/css/frontend.css +1 -3519
- package/templates/src/components/edit/PanelSwitch.tsx +3 -8
- package/templates/src/layouts/Layout.astro +3 -3
- package/templates/src/pages/[...slug].astro +1 -1
- package/templates/src/pages/context/[...contextSlug].astro +1 -1
- package/templates/src/utils/helpers.ts +1 -0
- package/utils/inject-files.ts +8 -0
package/README.md
CHANGED
|
@@ -1,53 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# TractStack v2
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Redeeming the web from boring experiences**
|
|
4
4
|
|
|
5
|
-
by [At Risk Media](https://atriskmedia.com)
|
|
5
|
+
Free web press by [At Risk Media](https://atriskmedia.com)
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Epistemic Hypermedia Server
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
TractStack is a new species of web platform that makes it possible for millions of websites to adapt to each visitor instead of showing everyone the same thing. It's an **adaptive website builder** that creates fast, beautiful, SEO-ready, and accessible websites that respond intelligently to user behavior.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Built on [Astro](https://astro.build/) with [HTMX](https://htmx.org/) and a [Golang](https://go.dev/) backend, TractStack uses SQLite by default with optional [Turso](https://app.turso.tech/) cloud database support.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
## Key Features
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
For production deployment you'll need to prepare your server.
|
|
15
|
+
- **Adaptive Content**: Websites that dynamically respond to visitor behavior
|
|
16
|
+
- **Multi-tenant Architecture**: Host multiple sites from a single installation
|
|
17
|
+
- **Built-in CMS**: StoryKeep content management system
|
|
18
|
+
- **Real-time Updates**: Server-sent events and HTMX for dynamic interactions
|
|
19
|
+
- **Production Ready**: SSL certificates, nginx integration, systemd services
|
|
20
|
+
- **Zero Config Database**: Works out of the box with SQLite3
|
|
22
21
|
|
|
23
22
|
## Quick Install
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
### One-Line Installer
|
|
26
25
|
|
|
27
26
|
```bash
|
|
28
27
|
curl -fsSL https://get.tractstack.com | bash
|
|
29
28
|
```
|
|
30
29
|
|
|
31
|
-
This
|
|
30
|
+
This automatically installs both the Go backend and creates a new Astro project with TractStack integration.
|
|
31
|
+
|
|
32
|
+
### Installation Options
|
|
33
|
+
|
|
34
|
+
- `--quick` - Development setup in user directory (no sudo required)
|
|
35
|
+
- `--prod --domain=yourdomain.com` - Production single-tenant
|
|
36
|
+
- `--multi --domain=yourdomain.com` - Production multi-tenant hosting
|
|
37
|
+
- `--dedicated SITE_ID --domain=yourdomain.com` - Isolated dedicated instance
|
|
32
38
|
|
|
33
39
|
## Manual Installation
|
|
34
40
|
|
|
35
41
|
**Prerequisites:**
|
|
36
42
|
|
|
37
|
-
- Node.js
|
|
38
|
-
- pnpm
|
|
39
|
-
- Go 1.
|
|
43
|
+
- Node.js 20+
|
|
44
|
+
- pnpm (recommended) or npm
|
|
45
|
+
- Go 1.22+
|
|
40
46
|
- Git
|
|
41
47
|
|
|
42
|
-
###
|
|
43
|
-
|
|
44
|
-
**Linux:** Full native support - follow the steps below exactly as written.
|
|
45
|
-
|
|
46
|
-
**macOS:** Full native support - follow the steps below exactly as written. The installation works the same as Linux.
|
|
47
|
-
|
|
48
|
-
### Step 1: Install and run the Go backend
|
|
49
|
-
|
|
50
|
-
**Linux/macOS:**
|
|
48
|
+
### Step 1: Install Go Backend
|
|
51
49
|
|
|
52
50
|
```bash
|
|
53
51
|
mkdir -p ~/t8k/src
|
|
@@ -57,14 +55,9 @@ cd tractstack-go
|
|
|
57
55
|
echo "GO_BACKEND_PATH=$HOME/t8k/t8k-go-server/" > .env
|
|
58
56
|
echo "GIN_MODE=release" >> .env
|
|
59
57
|
go build -o tractstack-go ./cmd/tractstack-go
|
|
60
|
-
./tractstack-go
|
|
61
58
|
```
|
|
62
59
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
### Step 2: Create your Astro frontend
|
|
66
|
-
|
|
67
|
-
**Linux/macOS:**
|
|
60
|
+
### Step 2: Create Astro Frontend
|
|
68
61
|
|
|
69
62
|
```bash
|
|
70
63
|
cd ~/t8k
|
|
@@ -73,104 +66,240 @@ cd my-tractstack
|
|
|
73
66
|
pnpm add astro-tractstack@latest
|
|
74
67
|
echo "PRIVATE_GO_BACKEND_PATH=$HOME/t8k/t8k-go-server/" > .env
|
|
75
68
|
npx create-tractstack
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Step 3: Start Development
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Terminal 1: Go backend
|
|
75
|
+
cd ~/t8k/src/tractstack-go
|
|
76
|
+
./tractstack-go
|
|
77
|
+
|
|
78
|
+
# Terminal 2: Astro frontend
|
|
79
|
+
cd ~/t8k/src/my-tractstack
|
|
76
80
|
pnpm dev
|
|
77
81
|
```
|
|
78
82
|
|
|
79
|
-
|
|
83
|
+
Visit https://127.0.0.1:4321 to access your site and activate your Story Keep (CMS).
|
|
80
84
|
|
|
81
|
-
|
|
85
|
+
## Installation Types
|
|
82
86
|
|
|
83
|
-
|
|
87
|
+
### Development (Quick Install)
|
|
84
88
|
|
|
85
|
-
|
|
89
|
+
- Local setup in `~/t8k/`
|
|
90
|
+
- No sudo required
|
|
91
|
+
- Perfect for development and testing
|
|
92
|
+
- SQLite database included
|
|
86
93
|
|
|
87
|
-
|
|
88
|
-
2. Get your database URL and auth token
|
|
89
|
-
3. Activate your database during site init
|
|
94
|
+
### Production Single-Tenant
|
|
90
95
|
|
|
91
|
-
|
|
96
|
+
- System-wide installation at `/home/t8k/`
|
|
97
|
+
- SSL certificates via Let's Encrypt
|
|
98
|
+
- nginx reverse proxy
|
|
99
|
+
- systemd services for automatic startup
|
|
100
|
+
- PM2 process management
|
|
92
101
|
|
|
93
|
-
|
|
102
|
+
### Production Multi-Tenant
|
|
94
103
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
104
|
+
- Same as single-tenant plus:
|
|
105
|
+
- Wildcard domain support (`*.yourdomain.com`)
|
|
106
|
+
- Tenant management at `/sandbox/register`
|
|
107
|
+
- Multiple isolated websites from one installation
|
|
99
108
|
|
|
100
|
-
|
|
109
|
+
### Dedicated Instance
|
|
101
110
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
- Completely separate installation per site
|
|
112
|
+
- Own source code, binaries, and data
|
|
113
|
+
- Maximum isolation and customization
|
|
114
|
+
- Perfect for agencies managing multiple clients
|
|
106
115
|
|
|
107
|
-
|
|
108
|
-
- Frontend: http://localhost:4321
|
|
109
|
-
- StoryKeep (CMS): http://localhost:4321/storykeep
|
|
116
|
+
## Project Structure
|
|
110
117
|
|
|
111
|
-
|
|
118
|
+
```
|
|
119
|
+
~/t8k/ # Development install
|
|
120
|
+
├── src/
|
|
121
|
+
│ ├── tractstack-go/ # Go backend source
|
|
122
|
+
│ │ └── tractstack-go # Compiled binary
|
|
123
|
+
│ └── my-tractstack/ # Astro frontend
|
|
124
|
+
│ ├── src/
|
|
125
|
+
│ │ ├── components/ # Custom components
|
|
126
|
+
│ │ ├── pages/ # Astro pages
|
|
127
|
+
│ │ └── custom/ # Your customizations
|
|
128
|
+
│ └── astro.config.mjs
|
|
129
|
+
└── t8k-go-server/ # Backend data storage
|
|
130
|
+
├── config/
|
|
131
|
+
│ ├── t8k/
|
|
132
|
+
│ │ └── tenants.json # Tenant registry
|
|
133
|
+
│ └── default/ # Default tenant config
|
|
134
|
+
│ ├── env.json # Core configuration
|
|
135
|
+
│ ├── brand.json # Site branding
|
|
136
|
+
│ ├── knownResources.json # Resource tracking
|
|
137
|
+
│ ├── tailwindWhitelist.json # CSS optimization
|
|
138
|
+
│ └── media/ # Media files
|
|
139
|
+
│ ├── images/
|
|
140
|
+
│ └── css/
|
|
141
|
+
├── db/
|
|
142
|
+
│ └── default/
|
|
143
|
+
│ └── tractstack.db # SQLite database
|
|
144
|
+
└── log/
|
|
145
|
+
├── system.log
|
|
146
|
+
├── tenant.log
|
|
147
|
+
└── database.log
|
|
148
|
+
```
|
|
112
149
|
|
|
113
|
-
|
|
150
|
+
### Production Structure
|
|
114
151
|
|
|
115
|
-
|
|
116
|
-
2. **Build and deploy the Astro frontend** with `pnpm build`
|
|
117
|
-
3. **Configure your database** connection
|
|
118
|
-
4. **Set up SSL/TLS** for your domain
|
|
152
|
+
Production installations live at `/home/t8k/` with the same structure plus:
|
|
119
153
|
|
|
120
|
-
|
|
154
|
+
```
|
|
155
|
+
/home/t8k/
|
|
156
|
+
├── bin/
|
|
157
|
+
│ └── tractstack-go # Production binary
|
|
158
|
+
├── etc/
|
|
159
|
+
│ ├── letsencrypt/ # SSL certificates
|
|
160
|
+
│ ├── pm2/ # PM2 configs
|
|
161
|
+
│ └── t8k-ports.conf # Port allocations
|
|
162
|
+
├── scripts/
|
|
163
|
+
│ └── t8k-concierge.sh # Build automation
|
|
164
|
+
└── state/ # Build queue
|
|
165
|
+
```
|
|
121
166
|
|
|
122
167
|
## Multi-Tenant Features
|
|
123
168
|
|
|
124
|
-
TractStack
|
|
169
|
+
TractStack v2 includes powerful multi-tenant capabilities:
|
|
125
170
|
|
|
126
|
-
|
|
171
|
+
- **Tenant Registration**: Self-service tenant creation at `/sandbox/register`
|
|
172
|
+
- **Domain Routing**: Automatic subdomain routing (`tenant.yourdomain.com`)
|
|
173
|
+
- **Isolated Data**: Each tenant has separate databases and media
|
|
174
|
+
- **Capacity Management**: Configurable tenant limits
|
|
175
|
+
- **Email Activation**: Automated tenant activation emails
|
|
176
|
+
|
|
177
|
+
## SSL Certificate Management
|
|
178
|
+
|
|
179
|
+
### Cloudflare DNS (Automated)
|
|
180
|
+
|
|
181
|
+
Create `/root/.secrets/certbot/cloudflare.ini`:
|
|
127
182
|
|
|
183
|
+
```ini
|
|
184
|
+
dns_cloudflare_api_token = YOUR_API_TOKEN_HERE
|
|
128
185
|
```
|
|
129
|
-
## Project Structure
|
|
130
186
|
|
|
131
|
-
|
|
187
|
+
Certificates are obtained automatically during installation.
|
|
188
|
+
|
|
189
|
+
### Manual DNS Verification
|
|
190
|
+
|
|
191
|
+
Without Cloudflare, the installer guides you through manual DNS TXT record verification.
|
|
192
|
+
|
|
193
|
+
## Service Management
|
|
132
194
|
|
|
133
|
-
|
|
195
|
+
### Main Installation
|
|
134
196
|
|
|
197
|
+
```bash
|
|
198
|
+
# Status
|
|
199
|
+
sudo systemctl status tractstack-go
|
|
200
|
+
sudo -u t8k pm2 status astro-main
|
|
201
|
+
|
|
202
|
+
# Restart
|
|
203
|
+
sudo systemctl restart tractstack-go
|
|
204
|
+
sudo -u t8k pm2 restart astro-main
|
|
205
|
+
|
|
206
|
+
# Logs
|
|
207
|
+
sudo journalctl -u tractstack-go -f
|
|
208
|
+
sudo -u t8k pm2 logs astro-main
|
|
135
209
|
```
|
|
136
210
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
│ │ └── ...
|
|
147
|
-
└── t8k-go-server/ # Backend data storage
|
|
148
|
-
├── config/
|
|
149
|
-
│ ├── t8k/
|
|
150
|
-
│ │ └── tenants.json # Source of truth
|
|
151
|
-
│ └── default/ # Default tenant config
|
|
152
|
-
│ └── env.json # Critical config
|
|
153
|
-
│ └── brand.json # Personalization
|
|
154
|
-
│ └── media/ # Tenant media files
|
|
155
|
-
├── db/
|
|
156
|
-
│ └── default/
|
|
157
|
-
│ └── tractstack.db # SQLite database
|
|
158
|
-
└── log/
|
|
159
|
-
├── system.log
|
|
160
|
-
├── tenant.log
|
|
161
|
-
├── database.log
|
|
162
|
-
└── ...
|
|
211
|
+
### Dedicated Instances
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
# Replace SITE_ID with your site identifier
|
|
215
|
+
sudo systemctl status tractstack-go@SITE_ID
|
|
216
|
+
sudo -u t8k pm2 status astro-SITE_ID
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Build System
|
|
163
220
|
|
|
221
|
+
The build concierge processes automated builds via CSV files in `/home/t8k/state/`:
|
|
222
|
+
|
|
223
|
+
```csv
|
|
224
|
+
type=main,tenant=default,command=build
|
|
225
|
+
type=dedicated,site=SITE_ID,command=build
|
|
164
226
|
```
|
|
165
227
|
|
|
228
|
+
The system automatically:
|
|
229
|
+
|
|
230
|
+
1. Pulls latest code from Git
|
|
231
|
+
2. Builds Go backend and Astro frontend
|
|
232
|
+
3. Extracts Tailwind CSS optimizations
|
|
233
|
+
4. Restarts services
|
|
234
|
+
5. Cleans up processed files
|
|
235
|
+
|
|
236
|
+
## Database Options
|
|
237
|
+
|
|
238
|
+
### SQLite (Default)
|
|
239
|
+
|
|
240
|
+
- Zero configuration required
|
|
241
|
+
- Perfect for most websites
|
|
242
|
+
- Automatic backups and maintenance
|
|
243
|
+
- Scales to hundreds of thousands of visitors
|
|
244
|
+
|
|
245
|
+
### Turso Cloud Database
|
|
246
|
+
|
|
247
|
+
- Distributed SQLite with global replication
|
|
248
|
+
- Configure during site initialization
|
|
249
|
+
- Seamless scaling for high-traffic sites
|
|
250
|
+
- Built-in analytics and monitoring
|
|
251
|
+
|
|
252
|
+
## Development Workflow
|
|
253
|
+
|
|
254
|
+
1. **Edit Content**: Use StoryKeep CMS at `/storykeep`
|
|
255
|
+
2. **Customize Design**: Modify components in `src/custom/`
|
|
256
|
+
3. **Add Features**: Create CodeHooks for dynamic functionality
|
|
257
|
+
4. **Test Changes**: Hot reloading with `pnpm dev`
|
|
258
|
+
5. **Deploy**: Automated builds handle production updates
|
|
259
|
+
|
|
260
|
+
## API Integration
|
|
261
|
+
|
|
262
|
+
TractStack provides RESTful APIs for:
|
|
263
|
+
|
|
264
|
+
- Content management
|
|
265
|
+
- User analytics
|
|
266
|
+
- Belief tracking (visitor preferences)
|
|
267
|
+
- Multi-tenant operations
|
|
268
|
+
- Media handling
|
|
269
|
+
|
|
270
|
+
## Uninstalling
|
|
271
|
+
|
|
272
|
+
**For Production installations**, the uninstall script is located at `/home/t8k/scripts/`:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
sudo /home/t8k/scripts/t8k-uninstall.sh
|
|
166
276
|
```
|
|
167
277
|
|
|
168
|
-
|
|
278
|
+
**For Quick install (development)**, the script is in:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
sudo ~/t8k/src/tractstack-go/pkg/scripts/t8k-uninstall.sh
|
|
282
|
+
```
|
|
169
283
|
|
|
170
|
-
##
|
|
284
|
+
## Support & Documentation
|
|
171
285
|
|
|
172
|
-
|
|
286
|
+
- **Documentation**: https://tractstack.org
|
|
287
|
+
- **GitHub Issues**: https://github.com/AtRiskMedia/tractstack-go/issues
|
|
288
|
+
- **Email Support**: hello@tractstack.com
|
|
289
|
+
- **Community**: Join discussions about adaptive web experiences
|
|
173
290
|
|
|
174
291
|
## License
|
|
175
292
|
|
|
176
|
-
Functional Source License
|
|
293
|
+
**Functional Source License (FSL)** - Commercial use encouraged!
|
|
294
|
+
|
|
295
|
+
The only restriction is no re-selling TractStack as-a-service. Perfect for:
|
|
296
|
+
|
|
297
|
+
- Agency client projects
|
|
298
|
+
- Corporate websites
|
|
299
|
+
- Personal projects
|
|
300
|
+
- Open source contributions
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
_TractStack v2 - Making the web adaptive, one site at a time_
|
|
305
|
+
_Made with ❤️ by [At Risk Media](https://atriskmedia.com)_
|
package/bin/create-tractstack.js
CHANGED
|
@@ -29,7 +29,7 @@ function detectPackageManager() {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// Parse existing .env file
|
|
32
|
-
function
|
|
32
|
+
function getEnvState() {
|
|
33
33
|
const defaults = {
|
|
34
34
|
goBackend: 'http://localhost:8080',
|
|
35
35
|
tenantId: 'default',
|
|
@@ -37,8 +37,15 @@ function parseExistingEnv() {
|
|
|
37
37
|
enableMultiTenant: false,
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
const found = {
|
|
41
|
+
goBackend: false,
|
|
42
|
+
tenantId: false,
|
|
43
|
+
goBackendPath: false,
|
|
44
|
+
enableMultiTenant: false,
|
|
45
|
+
};
|
|
46
|
+
|
|
40
47
|
if (!existsSync('.env')) {
|
|
41
|
-
return defaults;
|
|
48
|
+
return { envDefaults: defaults, envState: found };
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
try {
|
|
@@ -50,7 +57,6 @@ function parseExistingEnv() {
|
|
|
50
57
|
if (line && !line.startsWith('#')) {
|
|
51
58
|
const [key, ...valueParts] = line.split('=');
|
|
52
59
|
if (key && valueParts.length > 0) {
|
|
53
|
-
// Remove surrounding quotes and trim
|
|
54
60
|
let value = valueParts.join('=').trim();
|
|
55
61
|
if (
|
|
56
62
|
(value.startsWith('"') && value.endsWith('"')) ||
|
|
@@ -64,18 +70,26 @@ function parseExistingEnv() {
|
|
|
64
70
|
});
|
|
65
71
|
|
|
66
72
|
return {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
envDefaults: {
|
|
74
|
+
goBackend: envVars.PUBLIC_GO_BACKEND || defaults.goBackend,
|
|
75
|
+
tenantId: envVars.PUBLIC_TENANTID || defaults.tenantId,
|
|
76
|
+
goBackendPath:
|
|
77
|
+
envVars.PRIVATE_GO_BACKEND_PATH || defaults.goBackendPath,
|
|
78
|
+
enableMultiTenant:
|
|
79
|
+
envVars.ENABLE_MULTI_TENANT === 'true' || defaults.enableMultiTenant,
|
|
80
|
+
},
|
|
81
|
+
envState: {
|
|
82
|
+
goBackend: !!envVars.PUBLIC_GO_BACKEND,
|
|
83
|
+
tenantId: !!envVars.PUBLIC_TENANTID,
|
|
84
|
+
goBackendPath: !!envVars.PRIVATE_GO_BACKEND_PATH,
|
|
85
|
+
enableMultiTenant: !!envVars.ENABLE_MULTI_TENANT,
|
|
86
|
+
},
|
|
73
87
|
};
|
|
74
88
|
} catch (error) {
|
|
75
89
|
console.log(
|
|
76
90
|
kleur.yellow('⚠️ Found .env file but could not parse it, using defaults')
|
|
77
91
|
);
|
|
78
|
-
return defaults;
|
|
92
|
+
return { envDefaults: defaults, envState: found };
|
|
79
93
|
}
|
|
80
94
|
}
|
|
81
95
|
|
|
@@ -141,7 +155,7 @@ ${kleur.bold('Examples:')}
|
|
|
141
155
|
}
|
|
142
156
|
|
|
143
157
|
// Parse existing .env values
|
|
144
|
-
const envDefaults =
|
|
158
|
+
const { envDefaults, envState } = getEnvState();
|
|
145
159
|
const hasExistingEnv = existsSync('.env');
|
|
146
160
|
|
|
147
161
|
if (hasExistingEnv) {
|
|
@@ -152,9 +166,11 @@ ${kleur.bold('Examples:')}
|
|
|
152
166
|
);
|
|
153
167
|
}
|
|
154
168
|
|
|
155
|
-
//
|
|
156
|
-
const
|
|
157
|
-
|
|
169
|
+
// Build prompts array conditionally - only prompt for values not in .env
|
|
170
|
+
const promptQuestions = [];
|
|
171
|
+
|
|
172
|
+
if (!envState.goBackend) {
|
|
173
|
+
promptQuestions.push({
|
|
158
174
|
type: 'text',
|
|
159
175
|
name: 'goBackend',
|
|
160
176
|
message: 'TractStack Go backend URL:',
|
|
@@ -167,21 +183,46 @@ ${kleur.bold('Examples:')}
|
|
|
167
183
|
return 'Please enter a valid URL';
|
|
168
184
|
}
|
|
169
185
|
},
|
|
170
|
-
}
|
|
171
|
-
|
|
186
|
+
});
|
|
187
|
+
} else {
|
|
188
|
+
console.log(
|
|
189
|
+
kleur.green(`✓ Using Go backend URL: ${envDefaults.goBackend}`)
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (!envState.enableMultiTenant && !enableMultiTenant) {
|
|
194
|
+
promptQuestions.push({
|
|
172
195
|
type: 'confirm',
|
|
173
196
|
name: 'enableMultiTenant',
|
|
174
197
|
message: 'Enable multi-tenant functionality?',
|
|
175
198
|
initial: enableMultiTenant || envDefaults.enableMultiTenant,
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
199
|
+
});
|
|
200
|
+
} else {
|
|
201
|
+
const willEnable = enableMultiTenant || envDefaults.enableMultiTenant;
|
|
202
|
+
console.log(
|
|
203
|
+
kleur.green(
|
|
204
|
+
`✓ Multi-tenant functionality: ${willEnable ? 'enabled' : 'disabled'}`
|
|
205
|
+
)
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Only prompt for tenantId if multi-tenant will be enabled and tenantId not in .env
|
|
210
|
+
const willEnableMultiTenant =
|
|
211
|
+
enableMultiTenant || envDefaults.enableMultiTenant;
|
|
212
|
+
if (willEnableMultiTenant && !envState.tenantId) {
|
|
213
|
+
promptQuestions.push({
|
|
214
|
+
type: 'text',
|
|
179
215
|
name: 'tenantId',
|
|
180
216
|
message: 'Tenant ID:',
|
|
181
217
|
initial: envDefaults.tenantId,
|
|
182
218
|
validate: (value) => value.length > 0 || 'Tenant ID is required',
|
|
183
|
-
}
|
|
184
|
-
|
|
219
|
+
});
|
|
220
|
+
} else if (willEnableMultiTenant) {
|
|
221
|
+
console.log(kleur.green(`✓ Using Tenant ID: ${envDefaults.tenantId}`));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (!envState.goBackendPath) {
|
|
225
|
+
promptQuestions.push({
|
|
185
226
|
type: 'text',
|
|
186
227
|
name: 'goBackendPath',
|
|
187
228
|
message: 'TractStack Go backend path:',
|
|
@@ -192,37 +233,58 @@ ${kleur.bold('Examples:')}
|
|
|
192
233
|
}
|
|
193
234
|
return true;
|
|
194
235
|
},
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
236
|
+
});
|
|
237
|
+
} else {
|
|
238
|
+
console.log(
|
|
239
|
+
kleur.green(`✓ Using Go backend path: ${envDefaults.goBackendPath}`)
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Always ask about examples (not stored in .env)
|
|
244
|
+
promptQuestions.push({
|
|
245
|
+
type: 'confirm',
|
|
246
|
+
name: 'includeExamples',
|
|
247
|
+
message:
|
|
248
|
+
'Include CodeHook examples? (custom components, collections route)',
|
|
249
|
+
initial: includeExamples,
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
// Run prompts only if there are questions
|
|
253
|
+
const responses =
|
|
254
|
+
promptQuestions.length > 0 ? await prompts(promptQuestions) : {};
|
|
255
|
+
|
|
256
|
+
// Merge responses with env defaults for final values
|
|
257
|
+
const finalResponses = {
|
|
258
|
+
goBackend: responses.goBackend || envDefaults.goBackend,
|
|
259
|
+
enableMultiTenant:
|
|
260
|
+
responses.enableMultiTenant ??
|
|
261
|
+
(enableMultiTenant || envDefaults.enableMultiTenant),
|
|
262
|
+
tenantId: responses.tenantId || envDefaults.tenantId,
|
|
263
|
+
goBackendPath: responses.goBackendPath || envDefaults.goBackendPath,
|
|
264
|
+
includeExamples: responses.includeExamples ?? includeExamples,
|
|
265
|
+
};
|
|
204
266
|
|
|
205
|
-
if (!
|
|
206
|
-
console.log(kleur.red('\n
|
|
267
|
+
if (!finalResponses.goBackend) {
|
|
268
|
+
console.log(kleur.red('\n✗ Setup cancelled.'));
|
|
207
269
|
process.exit(1);
|
|
208
270
|
}
|
|
209
271
|
|
|
210
272
|
// Use existing tenantId if multi-tenant is disabled
|
|
211
|
-
const finalTenantId =
|
|
212
|
-
?
|
|
273
|
+
const finalTenantId = finalResponses.enableMultiTenant
|
|
274
|
+
? finalResponses.tenantId
|
|
213
275
|
: envDefaults.tenantId;
|
|
214
276
|
|
|
215
277
|
if (!finalTenantId) {
|
|
216
|
-
console.log(kleur.red('\n
|
|
278
|
+
console.log(kleur.red('\n✗ Setup cancelled - Tenant ID is required.'));
|
|
217
279
|
process.exit(1);
|
|
218
280
|
}
|
|
219
281
|
|
|
220
282
|
// Create .env file
|
|
221
283
|
const envContent = `# TractStack Configuration
|
|
222
|
-
PUBLIC_GO_BACKEND="${
|
|
284
|
+
PUBLIC_GO_BACKEND="${finalResponses.goBackend}"
|
|
223
285
|
PUBLIC_TENANTID="${finalTenantId}"
|
|
224
|
-
PRIVATE_GO_BACKEND_PATH="${
|
|
225
|
-
${
|
|
286
|
+
PRIVATE_GO_BACKEND_PATH="${finalResponses.goBackendPath.endsWith('/') ? finalResponses.goBackendPath : finalResponses.goBackendPath + '/'}"
|
|
287
|
+
ENABLE_MULTI_TENANT="${finalResponses.enableMultiTenant ? 'true' : 'false'}"
|
|
226
288
|
`;
|
|
227
289
|
|
|
228
290
|
try {
|
|
@@ -547,7 +609,7 @@ export default defineConfig({
|
|
|
547
609
|
console.log(` • Custom components and CodeHooks`);
|
|
548
610
|
}
|
|
549
611
|
|
|
550
|
-
console.log('\n📚 Documentation: https://tractstack.org
|
|
612
|
+
console.log('\n📚 Documentation: https://tractstack.org');
|
|
551
613
|
}
|
|
552
614
|
|
|
553
615
|
main().catch(console.error);
|
package/dist/index.js
CHANGED
|
@@ -1499,6 +1499,14 @@ async function w(t, e, c) {
|
|
|
1499
1499
|
src: t("../templates/brand/static.jpg"),
|
|
1500
1500
|
dest: "public/static.jpg"
|
|
1501
1501
|
},
|
|
1502
|
+
{
|
|
1503
|
+
src: t("../templates/brand/og.png"),
|
|
1504
|
+
dest: "public/brand/og.png"
|
|
1505
|
+
},
|
|
1506
|
+
{
|
|
1507
|
+
src: t("../templates/brand/oglogo.png"),
|
|
1508
|
+
dest: "public/brand/oglogo.png"
|
|
1509
|
+
},
|
|
1502
1510
|
{
|
|
1503
1511
|
src: t("../templates/brand/favicon.ico"),
|
|
1504
1512
|
dest: "public/brand/favicon.ico"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-tractstack",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
4
|
-
"description": "Astro integration for TractStack -
|
|
3
|
+
"version": "2.0.0-rc.6",
|
|
4
|
+
"description": "Astro integration for TractStack - redeeming the web from boring experiences",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"exports": {
|
|
Binary file
|
|
Binary file
|