@stacksolo/cli 0.1.0 → 0.1.2

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 CHANGED
@@ -1,6 +1,19 @@
1
1
  # @stacksolo/cli
2
2
 
3
- Command-line tool for deploying GCP infrastructure. Designed for solo developers who want to ship fast without managing complex cloud configurations.
3
+ A command-line tool for deploying apps to Google Cloud. Designed for solo developers who want to ship fast without managing complex cloud configurations.
4
+
5
+ ## What does it do?
6
+
7
+ StackSolo takes your code and a simple config file, then handles all the cloud setup for you:
8
+ - Creates Cloud Functions for your backend
9
+ - Sets up load balancers to route traffic
10
+ - Hosts your frontend on Cloud Storage
11
+ - Manages databases and caches
12
+ - Handles all the networking automatically
13
+
14
+ You focus on writing code. StackSolo handles the infrastructure.
15
+
16
+ ---
4
17
 
5
18
  ## Installation
6
19
 
@@ -10,38 +23,205 @@ npm install -g @stacksolo/cli
10
23
 
11
24
  ## Prerequisites
12
25
 
13
- - Node.js 18+
14
- - [Terraform CLI](https://developer.hashicorp.com/terraform/install) installed
15
- - [Google Cloud CLI](https://cloud.google.com/sdk/docs/install) installed and authenticated
26
+ Before using StackSolo, you need:
27
+
28
+ 1. **Node.js 18 or newer**
29
+ ```bash
30
+ node --version # Should show v18.x.x or higher
31
+ ```
32
+
33
+ 2. **Terraform CLI** - This is the tool that actually creates cloud resources
34
+ ```bash
35
+ # macOS
36
+ brew install terraform
37
+
38
+ # Or download from: https://developer.hashicorp.com/terraform/install
39
+ ```
40
+
41
+ 3. **Google Cloud CLI** - For authenticating with GCP
42
+ ```bash
43
+ # macOS
44
+ brew install google-cloud-sdk
45
+
46
+ # Or download from: https://cloud.google.com/sdk/docs/install
47
+ ```
48
+
49
+ 4. **Authenticate with Google Cloud**
50
+ ```bash
51
+ gcloud auth login
52
+ gcloud auth application-default login
53
+ ```
54
+
55
+ ---
16
56
 
17
57
  ## Quick Start
18
58
 
59
+ ### Step 1: Initialize a new project
60
+
19
61
  ```bash
20
- # Initialize a new project
21
62
  stacksolo init
63
+ ```
64
+
65
+ This creates a `.stacksolo/stacksolo.config.json` file with your project settings.
22
66
 
23
- # Deploy infrastructure
67
+ ### Step 2: Add your code
68
+
69
+ Create a function at `functions/api/index.ts`:
70
+
71
+ ```typescript
72
+ import * as functions from '@google-cloud/functions-framework';
73
+
74
+ functions.http('api', (req, res) => {
75
+ res.json({ message: 'Hello from StackSolo!' });
76
+ });
77
+ ```
78
+
79
+ ### Step 3: Deploy to GCP
80
+
81
+ ```bash
24
82
  stacksolo deploy
83
+ ```
84
+
85
+ That's it! Your API is now live on Google Cloud.
86
+
87
+ ---
88
+
89
+ ## Commands
90
+
91
+ ### `stacksolo init`
92
+
93
+ Creates a new StackSolo project in the current directory.
94
+
95
+ **What it does:**
96
+ 1. Asks you some questions about your project
97
+ 2. Creates a `.stacksolo/stacksolo.config.json` file
98
+ 3. Registers the project in your global registry
99
+
100
+ **Example:**
101
+ ```bash
102
+ cd my-project
103
+ stacksolo init
104
+ ```
105
+
106
+ ---
107
+
108
+ ### `stacksolo deploy`
109
+
110
+ Deploys your infrastructure to Google Cloud.
111
+
112
+ **What it does:**
113
+ 1. Reads your config file
114
+ 2. Generates Terraform code
115
+ 3. Runs Terraform to create resources
116
+ 4. Shows you the URLs when done
117
+
118
+ **Example:**
119
+ ```bash
120
+ stacksolo deploy
121
+ ```
122
+
123
+ **Flags:**
124
+ - `--dry-run` - Show what would be deployed without actually deploying
125
+
126
+ ---
127
+
128
+ ### `stacksolo destroy`
129
+
130
+ Deletes all resources created by StackSolo.
131
+
132
+ **What it does:**
133
+ 1. Runs Terraform destroy
134
+ 2. Removes all cloud resources
135
+ 3. Cleans up local state
136
+
137
+ **Example:**
138
+ ```bash
139
+ stacksolo destroy
140
+ ```
141
+
142
+ **Warning:** This permanently deletes your infrastructure. Any data stored in databases or storage buckets will be lost.
143
+
144
+ ---
145
+
146
+ ### `stacksolo status`
25
147
 
26
- # Check status
148
+ Shows the current state of your deployment.
149
+
150
+ **What it does:**
151
+ 1. Reads the Terraform state
152
+ 2. Shows what resources exist
153
+ 3. Shows URLs for your services
154
+
155
+ **Example:**
156
+ ```bash
27
157
  stacksolo status
28
158
  ```
29
159
 
30
- ## Commands
160
+ ---
161
+
162
+ ### `stacksolo list`
163
+
164
+ Lists all StackSolo projects on your computer.
165
+
166
+ **What it does:**
167
+ 1. Reads from your global registry (`~/.stacksolo/registry.db`)
168
+ 2. Shows project names and paths
169
+
170
+ **Example:**
171
+ ```bash
172
+ # List all projects
173
+ stacksolo list
174
+
175
+ # Show details for a specific project
176
+ stacksolo list my-app
177
+ ```
178
+
179
+ ---
180
+
181
+ ### `stacksolo dev`
182
+
183
+ Starts a local development environment using Kubernetes.
184
+
185
+ **What it does:**
186
+ 1. Generates Kubernetes manifests from your config
187
+ 2. Starts a local K8s cluster (using Docker Desktop or minikube)
188
+ 3. Runs Firebase emulators for Firestore, Auth, and Pub/Sub
189
+ 4. Sets up port forwarding so you can access your services
190
+
191
+ **Example:**
192
+ ```bash
193
+ stacksolo dev
194
+ ```
195
+
196
+ **Flags:**
197
+ - `--no-emulators` - Skip starting Firebase emulators
198
+ - `--health` - Check the health of running services
199
+ - `--ports` - Show port forwarding status
200
+ - `--restart [service]` - Restart a specific service or all services
201
+ - `--service-names` - List available service names
202
+
203
+ ---
204
+
205
+ ### `stacksolo scaffold`
206
+
207
+ Generates starter code and local dev files from your config.
31
208
 
32
- | Command | Description |
33
- |---------|-------------|
34
- | `stacksolo init` | Initialize a new StackSolo project with GCP setup |
35
- | `stacksolo deploy` | Deploy infrastructure using CDKTF/Terraform |
36
- | `stacksolo destroy` | Tear down deployed infrastructure |
37
- | `stacksolo status` | Show deployment status |
38
- | `stacksolo list` | List all registered projects |
39
- | `stacksolo dev` | Start local K8s development environment |
40
- | `stacksolo scaffold` | Generate local dev environment from config |
209
+ **What it does:**
210
+ 1. Creates function/container boilerplate
211
+ 2. Generates `.env.local` with environment variables
212
+ 3. Creates `lib/env.ts` for type-safe env access
213
+ 4. Sets up Kubernetes manifests for local dev
214
+
215
+ **Example:**
216
+ ```bash
217
+ stacksolo scaffold
218
+ ```
219
+
220
+ ---
41
221
 
42
222
  ## Project Configuration
43
223
 
44
- StackSolo uses a JSON configuration file at `.stacksolo/stacksolo.config.json`:
224
+ StackSolo uses a JSON config file at `.stacksolo/stacksolo.config.json`. Here's a simple example:
45
225
 
46
226
  ```json
47
227
  {
@@ -50,47 +230,75 @@ StackSolo uses a JSON configuration file at `.stacksolo/stacksolo.config.json`:
50
230
  "gcpProjectId": "my-gcp-project",
51
231
  "region": "us-central1"
52
232
  },
53
- "networks": {
54
- "main": {
55
- "functions": {
56
- "api": {
57
- "runtime": "nodejs20",
58
- "entryPoint": "api",
59
- "sourceDir": "functions/api"
60
- }
61
- }
233
+ "networks": [{
234
+ "name": "main",
235
+ "functions": [{
236
+ "name": "api",
237
+ "runtime": "nodejs20",
238
+ "entryPoint": "api"
239
+ }],
240
+ "loadBalancer": {
241
+ "name": "gateway",
242
+ "routes": [
243
+ { "path": "/*", "functionName": "api" }
244
+ ]
62
245
  }
63
- }
246
+ }]
64
247
  }
65
248
  ```
66
249
 
250
+ ### What each part means:
251
+
252
+ - **project.name** - A name for your project (used in resource naming)
253
+ - **project.gcpProjectId** - Your Google Cloud project ID
254
+ - **project.region** - Where to deploy (e.g., `us-central1`, `europe-west1`)
255
+ - **networks** - Groups of related resources
256
+ - **functions** - Serverless functions (your backend code)
257
+ - **loadBalancer** - Routes traffic to your functions
258
+
259
+ For detailed config options, see the [GCP CDKTF Plugin docs](../plugins/gcp-cdktf/README.md).
260
+
261
+ ---
262
+
67
263
  ## Supported Resources
68
264
 
69
- - **Cloud Functions (Gen2)** - Serverless functions with automatic scaling
70
- - **Cloud Run** - Containerized applications
71
- - **Cloud Storage** - Object storage buckets
72
- - **Pub/Sub** - Message queuing
73
- - **VPC Networks** - Private networking with connectors
74
- - **Load Balancers** - Global HTTP(S) load balancing
75
- - **Firestore** - NoSQL database
265
+ StackSolo can create these Google Cloud resources:
266
+
267
+ | Resource | What it's for |
268
+ |----------|---------------|
269
+ | **Cloud Functions (Gen2)** | Serverless backend code that scales automatically |
270
+ | **Cloud Run** | Containerized apps with more control than Functions |
271
+ | **Cloud Storage** | File storage (also hosts static websites) |
272
+ | **Pub/Sub** | Message queues for async processing |
273
+ | **VPC Networks** | Private networking between your services |
274
+ | **Load Balancers** | Route traffic to multiple backends |
275
+ | **Firestore** | NoSQL database |
276
+
277
+ ---
76
278
 
77
279
  ## Local Development
78
280
 
79
- StackSolo includes a local Kubernetes development environment:
281
+ StackSolo includes a local Kubernetes environment that mirrors production:
80
282
 
81
283
  ```bash
82
- # Start local dev with emulators
83
284
  stacksolo dev
84
285
  ```
85
286
 
86
287
  This creates a local K8s cluster with:
87
- - Firebase emulators (Firestore, Auth, Pub/Sub)
88
- - Hot-reloading for your functions
89
- - Service mesh for inter-service calls
288
+ - **Firebase emulators** - Fake versions of Firestore, Auth, and Pub/Sub
289
+ - **Hot-reloading** - Your code updates automatically when you save
290
+ - **Service mesh** - Services can call each other just like in production
291
+ - **Environment variables** - Same env vars as production
292
+
293
+ ### Why Kubernetes locally?
294
+
295
+ Using K8s locally means your dev environment works exactly like production. No more "it works on my machine" problems.
296
+
297
+ ---
90
298
 
91
299
  ## Runtime Package
92
300
 
93
- For environment detection and service-to-service calls in your functions:
301
+ When writing your function code, use the `@stacksolo/runtime` package for environment detection and service calls:
94
302
 
95
303
  ```bash
96
304
  npm install @stacksolo/runtime
@@ -99,33 +307,85 @@ npm install @stacksolo/runtime
99
307
  ```typescript
100
308
  import { env, firestore, services } from '@stacksolo/runtime';
101
309
 
102
- // Environment detection
310
+ // Check if running locally or in production
103
311
  if (env.isLocal) {
104
312
  console.log('Running with emulators');
105
313
  }
106
314
 
107
- // Auto-configured Firestore client
315
+ // Auto-configured Firestore client (uses emulator locally)
108
316
  const db = firestore();
317
+ const users = await db.collection('users').get();
109
318
 
110
- // Call other services
319
+ // Call another service in your stack
111
320
  const response = await services.call('api', '/users');
112
321
  ```
113
322
 
114
- ## Global Registry
323
+ See the [Runtime package docs](../runtime/README.md) for more details.
115
324
 
116
- StackSolo maintains a registry of all your projects at `~/.stacksolo/registry.db`:
325
+ ---
326
+
327
+ ## Global Project Registry
328
+
329
+ StackSolo keeps track of all your projects in a local database at `~/.stacksolo/registry.db`. This lets you:
330
+
331
+ - Switch between projects easily
332
+ - See all your StackSolo projects in one place
333
+ - Access project info from any directory
117
334
 
118
335
  ```bash
119
336
  # List all projects
120
337
  stacksolo list
121
338
 
122
- # Register current project
339
+ # Register the current directory as a project
123
340
  stacksolo register
124
341
 
125
- # View project details
342
+ # View details about a specific project
126
343
  stacksolo list my-app
127
344
  ```
128
345
 
346
+ ---
347
+
348
+ ## Typical Workflow
349
+
350
+ Here's how most developers use StackSolo:
351
+
352
+ 1. **Start a new project:**
353
+ ```bash
354
+ mkdir my-app && cd my-app
355
+ stacksolo init
356
+ ```
357
+
358
+ 2. **Write your code:**
359
+ ```bash
360
+ # Create your function
361
+ mkdir -p functions/api
362
+ # ... write code ...
363
+ ```
364
+
365
+ 3. **Develop locally:**
366
+ ```bash
367
+ stacksolo scaffold # Generate boilerplate
368
+ stacksolo dev # Start local environment
369
+ ```
370
+
371
+ 4. **Deploy to production:**
372
+ ```bash
373
+ stacksolo deploy
374
+ ```
375
+
376
+ 5. **Check status:**
377
+ ```bash
378
+ stacksolo status
379
+ ```
380
+
381
+ 6. **Make changes and redeploy:**
382
+ ```bash
383
+ # ... edit code ...
384
+ stacksolo deploy
385
+ ```
386
+
387
+ ---
388
+
129
389
  ## Links
130
390
 
131
391
  - [Documentation](https://stacksolo.dev)