@tdk-landscape/tdk-cli-core 1.3.14
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 +293 -0
- package/bin/tdk.js +14 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +64 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/completion.d.ts +3 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +294 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +220 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +176 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/down.d.ts +3 -0
- package/dist/commands/down.d.ts.map +1 -0
- package/dist/commands/down.js +32 -0
- package/dist/commands/down.js.map +1 -0
- package/dist/commands/help.d.ts +2 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +130 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/networks.d.ts +3 -0
- package/dist/commands/networks.d.ts.map +1 -0
- package/dist/commands/networks.js +260 -0
- package/dist/commands/networks.js.map +1 -0
- package/dist/commands/project.d.ts +3 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +360 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/commands/projects.d.ts +3 -0
- package/dist/commands/projects.d.ts.map +1 -0
- package/dist/commands/projects.js +71 -0
- package/dist/commands/projects.js.map +1 -0
- package/dist/commands/resource.d.ts +69 -0
- package/dist/commands/resource.d.ts.map +1 -0
- package/dist/commands/resource.js +572 -0
- package/dist/commands/resource.js.map +1 -0
- package/dist/commands/resources.d.ts +3 -0
- package/dist/commands/resources.d.ts.map +1 -0
- package/dist/commands/resources.js +73 -0
- package/dist/commands/resources.js.map +1 -0
- package/dist/commands/stack.d.ts +3 -0
- package/dist/commands/stack.d.ts.map +1 -0
- package/dist/commands/stack.js +103 -0
- package/dist/commands/stack.js.map +1 -0
- package/dist/commands/stacks.d.ts +3 -0
- package/dist/commands/stacks.d.ts.map +1 -0
- package/dist/commands/stacks.js +43 -0
- package/dist/commands/stacks.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +71 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/ui.d.ts +3 -0
- package/dist/commands/ui.d.ts.map +1 -0
- package/dist/commands/ui.js +446 -0
- package/dist/commands/ui.js.map +1 -0
- package/dist/commands/up.d.ts +3 -0
- package/dist/commands/up.d.ts.map +1 -0
- package/dist/commands/up.js +149 -0
- package/dist/commands/up.js.map +1 -0
- package/dist/commands/upgrade.d.ts +3 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +454 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/commands/version.d.ts +3 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +9 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/components/Accessible.d.ts +8 -0
- package/dist/components/Accessible.d.ts.map +1 -0
- package/dist/components/Accessible.js +10 -0
- package/dist/components/Accessible.js.map +1 -0
- package/dist/components/BaseTooltip.d.ts +4 -0
- package/dist/components/BaseTooltip.d.ts.map +1 -0
- package/dist/components/BaseTooltip.js +28 -0
- package/dist/components/BaseTooltip.js.map +1 -0
- package/dist/components/DetailPanel.d.ts +4 -0
- package/dist/components/DetailPanel.d.ts.map +1 -0
- package/dist/components/DetailPanel.js +18 -0
- package/dist/components/DetailPanel.js.map +1 -0
- package/dist/components/FileTree.d.ts +4 -0
- package/dist/components/FileTree.d.ts.map +1 -0
- package/dist/components/FileTree.js +47 -0
- package/dist/components/FileTree.js.map +1 -0
- package/dist/components/ResourceSelectInput.d.ts +4 -0
- package/dist/components/ResourceSelectInput.d.ts.map +1 -0
- package/dist/components/ResourceSelectInput.js +7 -0
- package/dist/components/ResourceSelectInput.js.map +1 -0
- package/dist/components/ResourceTable.d.ts +4 -0
- package/dist/components/ResourceTable.d.ts.map +1 -0
- package/dist/components/ResourceTable.js +18 -0
- package/dist/components/ResourceTable.js.map +1 -0
- package/dist/components/TabBar.d.ts +4 -0
- package/dist/components/TabBar.d.ts.map +1 -0
- package/dist/components/TabBar.js +17 -0
- package/dist/components/TabBar.js.map +1 -0
- package/dist/components/Tooltip.d.ts +12 -0
- package/dist/components/Tooltip.d.ts.map +1 -0
- package/dist/components/Tooltip.js +12 -0
- package/dist/components/Tooltip.js.map +1 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +8 -0
- package/dist/components/index.js.map +1 -0
- package/dist/config/platform-standards.d.ts +159 -0
- package/dist/config/platform-standards.d.ts.map +1 -0
- package/dist/config/platform-standards.js +181 -0
- package/dist/config/platform-standards.js.map +1 -0
- package/dist/generator/extension-fetch.d.ts +9 -0
- package/dist/generator/extension-fetch.d.ts.map +1 -0
- package/dist/generator/extension-fetch.js +153 -0
- package/dist/generator/extension-fetch.js.map +1 -0
- package/dist/generator/template-engine.d.ts +60 -0
- package/dist/generator/template-engine.d.ts.map +1 -0
- package/dist/generator/template-engine.js +416 -0
- package/dist/generator/template-engine.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +236 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +17 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/cache.d.ts +19 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +64 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/command-helpers.d.ts +17 -0
- package/dist/utils/command-helpers.d.ts.map +1 -0
- package/dist/utils/command-helpers.js +48 -0
- package/dist/utils/command-helpers.js.map +1 -0
- package/dist/utils/constants.d.ts +50 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +100 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/discovery-context.d.ts +4 -0
- package/dist/utils/discovery-context.d.ts.map +1 -0
- package/dist/utils/discovery-context.js +39 -0
- package/dist/utils/discovery-context.js.map +1 -0
- package/dist/utils/docker.d.ts +3 -0
- package/dist/utils/docker.d.ts.map +1 -0
- package/dist/utils/docker.js +13 -0
- package/dist/utils/docker.js.map +1 -0
- package/dist/utils/env-validator.d.ts +15 -0
- package/dist/utils/env-validator.d.ts.map +1 -0
- package/dist/utils/env-validator.js +95 -0
- package/dist/utils/env-validator.js.map +1 -0
- package/dist/utils/errors.d.ts +28 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +127 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/file-helpers.d.ts +14 -0
- package/dist/utils/file-helpers.d.ts.map +1 -0
- package/dist/utils/file-helpers.js +45 -0
- package/dist/utils/file-helpers.js.map +1 -0
- package/dist/utils/formatting.d.ts +30 -0
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/utils/formatting.js +164 -0
- package/dist/utils/formatting.js.map +1 -0
- package/dist/utils/paths.d.ts +3 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +41 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/port-assignment.d.ts +6 -0
- package/dist/utils/port-assignment.d.ts.map +1 -0
- package/dist/utils/port-assignment.js +75 -0
- package/dist/utils/port-assignment.js.map +1 -0
- package/dist/utils/project-features.d.ts +23 -0
- package/dist/utils/project-features.d.ts.map +1 -0
- package/dist/utils/project-features.js +98 -0
- package/dist/utils/project-features.js.map +1 -0
- package/dist/utils/project-templates.d.ts +7 -0
- package/dist/utils/project-templates.d.ts.map +1 -0
- package/dist/utils/project-templates.js +24 -0
- package/dist/utils/project-templates.js.map +1 -0
- package/dist/utils/resource-features.d.ts +28 -0
- package/dist/utils/resource-features.d.ts.map +1 -0
- package/dist/utils/resource-features.js +148 -0
- package/dist/utils/resource-features.js.map +1 -0
- package/dist/utils/services.d.ts +18 -0
- package/dist/utils/services.d.ts.map +1 -0
- package/dist/utils/services.js +291 -0
- package/dist/utils/services.js.map +1 -0
- package/dist/utils/stack-features.d.ts +22 -0
- package/dist/utils/stack-features.d.ts.map +1 -0
- package/dist/utils/stack-features.js +13 -0
- package/dist/utils/stack-features.js.map +1 -0
- package/dist/utils/tar.d.ts +7 -0
- package/dist/utils/tar.d.ts.map +1 -0
- package/dist/utils/tar.js +21 -0
- package/dist/utils/tar.js.map +1 -0
- package/dist/utils/tilt.d.ts +18 -0
- package/dist/utils/tilt.d.ts.map +1 -0
- package/dist/utils/tilt.js +77 -0
- package/dist/utils/tilt.js.map +1 -0
- package/dist/utils/validation.d.ts +9 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +49 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +72 -0
- package/templates/.tiltignore.hbs +73 -0
- package/templates/TILT_RESOURCE_DEFAULTS.star.hbs +221 -0
- package/templates/TILT_TECH_STACK.star.hbs +150 -0
- package/templates/Tiltfile.hbs +295 -0
- package/templates/spec.master.hbs +186 -0
package/README.md
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# 🚀 TDK CLI
|
|
2
|
+
|
|
3
|
+
> **T**ilt **D**evelopment **K**it - All-in-one local development platform for microservices
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@tdk/cli)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 🎯 What is TDK?
|
|
11
|
+
|
|
12
|
+
TDK CLI organizes your microservices using a clear **Project-Stack-Resource (PSR)** hierarchy:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
📁 Project (1 per repo)
|
|
16
|
+
├── ⚙️ TILT_RESOURCE_DEFAULTS.star # Ports, health checks, memory
|
|
17
|
+
├── 🔧 TILT_TECH_STACK.star # Bun, Vite, Prisma, NATS
|
|
18
|
+
│
|
|
19
|
+
└── 📦 Stacks (deployment groups)
|
|
20
|
+
├── 🔐 api-stack
|
|
21
|
+
│ ├── ⚡ api-backend # Resource
|
|
22
|
+
│ └── 🎨 web-frontend # Resource
|
|
23
|
+
│
|
|
24
|
+
└── 📅 worker-stack
|
|
25
|
+
├── ⚡ worker-backend # Resource
|
|
26
|
+
└── 🎨 web-frontend # Resource
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 📦 Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install -g @tdk/cli
|
|
35
|
+
# or
|
|
36
|
+
bun install -g @tdk/cli
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🏗️ Project-Stack-Resource Commands
|
|
42
|
+
|
|
43
|
+
### 🌍 Project Level
|
|
44
|
+
|
|
45
|
+
Initialize your project with master configuration files:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# 🆕 Initialize project (creates master configs)
|
|
49
|
+
tdk project
|
|
50
|
+
|
|
51
|
+
# 📊 Check project info and config status
|
|
52
|
+
tdk projects # Overview
|
|
53
|
+
|
|
54
|
+
tdk projects --check # ✅ CI validation (exit 0/1)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Creates:**
|
|
58
|
+
- ⚙️ `TILT_RESOURCE_DEFAULTS.star` — Platform config (ports 3000-4999, health checks, memory limits)
|
|
59
|
+
- 🔧 `TILT_TECH_STACK.star` — Tech stack lock (Bun v1.2, Vite v5, Prisma v7, NATS v2)
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
### 📦 Stack Level
|
|
64
|
+
|
|
65
|
+
Organize resources into deployment groups:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# 📋 List all stacks
|
|
69
|
+
tdk stacks
|
|
70
|
+
tdk stacks --services # 🔍 Include resources in each stack
|
|
71
|
+
|
|
72
|
+
# 🗂️ Organize resources into stacks (interactive)
|
|
73
|
+
tdk stack api
|
|
74
|
+
tdk stack order
|
|
75
|
+
|
|
76
|
+
# ▶️ Start/stop a stack
|
|
77
|
+
tdk up api # 🚀 Start api stack
|
|
78
|
+
tdk down # ⏹️ Stop all services
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### ⚡ Resource Level
|
|
84
|
+
|
|
85
|
+
Create and manage individual services:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# 📋 List all resources
|
|
89
|
+
tdk resources
|
|
90
|
+
tdk resources --stack api # 🔍 Filter by stack
|
|
91
|
+
tdk resources --no-stack # ⚠️ Show unassigned only
|
|
92
|
+
tdk resources --ports # 🔌 Show port assignments
|
|
93
|
+
|
|
94
|
+
# 🆕 Create new resource (interactive)
|
|
95
|
+
tdk resource my-api --type backend --stack api
|
|
96
|
+
tdk resource my-app --type frontend --stack api
|
|
97
|
+
tdk resource my-worker --type worker --stack background
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Creates:**
|
|
101
|
+
- 📄 `service.json` — Auto-assigned port from master config
|
|
102
|
+
- 📦 `package.json` — Scripts, dependencies (Hono/Vite/Biome)
|
|
103
|
+
- ⚙️ `tsconfig.json` — TypeScript configuration
|
|
104
|
+
- 🐳 `Dockerfile` — Multi-stage build with health checks
|
|
105
|
+
- 💻 `src/` — Starter code (Hono for backend, React for frontend)
|
|
106
|
+
- 🧪 `tests/` — Vitest test file
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 🔄 Lifecycle Commands
|
|
111
|
+
|
|
112
|
+
| Command | Description | Example |
|
|
113
|
+
|---------|-------------|---------|
|
|
114
|
+
| `tdk up` | 🚀 Start all services | `tdk up` |
|
|
115
|
+
| `tdk up <stack>` | 🚀 Start a stack | `tdk up api` |
|
|
116
|
+
| `tdk up <resource>` | 🚀 Start specific resource | `tdk up api-backend` |
|
|
117
|
+
| `tdk down` | ⏹️ Stop all services | `tdk down` |
|
|
118
|
+
| `tdk status` | 📊 Show resource status | `tdk status` |
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## 🛠️ Utility Commands
|
|
123
|
+
|
|
124
|
+
| Command | Description |
|
|
125
|
+
|---------|-------------|
|
|
126
|
+
| `tdk ui` | 🎨 Interactive terminal UI |
|
|
127
|
+
| `tdk doctor` | 🔍 Check environment (Docker, Bun, Tilt, ports) |
|
|
128
|
+
| `tdk version` | ℹ️ Show version |
|
|
129
|
+
| `tdk --help` | ❓ Show help |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 🚀 Quick Start Workflow
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# 1️⃣ Initialize project
|
|
137
|
+
cd my-project
|
|
138
|
+
tdk project
|
|
139
|
+
|
|
140
|
+
# 2️⃣ Create resources
|
|
141
|
+
tdk resource api-api --type backend --stack api
|
|
142
|
+
# → Creates service.json with port 4000
|
|
143
|
+
# → Generates src/index.ts with Hono starter
|
|
144
|
+
# → Creates Dockerfile, tests/, package.json
|
|
145
|
+
|
|
146
|
+
tdk resource api-app --type frontend --stack api
|
|
147
|
+
# → Creates service.json with port 3000
|
|
148
|
+
# → Generates React starter with Vite
|
|
149
|
+
|
|
150
|
+
# 3️⃣ Install dependencies
|
|
151
|
+
cd api-api && bun install
|
|
152
|
+
cd ../api-app && bun install
|
|
153
|
+
|
|
154
|
+
# 4️⃣ Start development
|
|
155
|
+
tdk up api
|
|
156
|
+
|
|
157
|
+
# 5️⃣ Check status
|
|
158
|
+
tdk status
|
|
159
|
+
tdk resources --stack api
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## 📊 PSR Command Matrix
|
|
165
|
+
|
|
166
|
+
| Level | 🔨 Create/Action | 📋 List |
|
|
167
|
+
|-------|------------------|---------|
|
|
168
|
+
| **🌍 Project** | `tdk project` | `tdk projects` |
|
|
169
|
+
| **📦 Stack** | `tdk stack` | `tdk stacks` |
|
|
170
|
+
| **⚡ Resource** | `tdk resource` | `tdk resources` |
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 🎨 Resource Types
|
|
175
|
+
|
|
176
|
+
| Type | Port Range | Template | Use Case |
|
|
177
|
+
|------|------------|----------|----------|
|
|
178
|
+
| `backend` | 4000-4999 | 🏎️ Hono API | REST APIs, microservices |
|
|
179
|
+
| `frontend` | 3000-3999 | ⚛️ React + Vite | Web apps, dashboards |
|
|
180
|
+
| `worker` | (optional) | 🔧 Background worker | Queue processors, jobs |
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 🔒 Deterministic Operations
|
|
185
|
+
|
|
186
|
+
Use `Determinism` in your Tiltfile for reproducible builds:
|
|
187
|
+
|
|
188
|
+
```starlark
|
|
189
|
+
load('ext://tdk-cli', 'Determinism')
|
|
190
|
+
|
|
191
|
+
# Deterministic file discovery (sorted results)
|
|
192
|
+
files = Determinism.deterministic_find('./services', 'service.json')
|
|
193
|
+
|
|
194
|
+
# Deterministic service discovery
|
|
195
|
+
services = Determinism.deterministic_resource_discovery(['services/product'])
|
|
196
|
+
|
|
197
|
+
# Check deterministic mode
|
|
198
|
+
if Determinism.is_deterministic_mode():
|
|
199
|
+
print("✅ Running in deterministic mode")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## 🔍 Environment Validation
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
🔧 tdk doctor
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Checks for:
|
|
211
|
+
- ✅ Docker daemon running
|
|
212
|
+
- ✅ Bun runtime installed (v1.2+)
|
|
213
|
+
- ✅ Tilt CLI available
|
|
214
|
+
- ✅ Required ports free
|
|
215
|
+
- ✅ Tiltfile present
|
|
216
|
+
- ✅ Master config files exist
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## 📁 Project Structure
|
|
221
|
+
|
|
222
|
+
After `tdk project` + `tdk resource`:
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
my-project/
|
|
226
|
+
├── ⚙️ TILT_RESOURCE_DEFAULTS.star
|
|
227
|
+
├── 🔧 TILT_TECH_STACK.star
|
|
228
|
+
├── 📄 Tiltfile
|
|
229
|
+
│
|
|
230
|
+
├── services/
|
|
231
|
+
│ └── api/
|
|
232
|
+
│ ├── api-api/ # 🆕 Created by tdk resource
|
|
233
|
+
│ │ ├── service.json # Port 4000, stack: api
|
|
234
|
+
│ │ ├── package.json
|
|
235
|
+
│ │ ├── tsconfig.json
|
|
236
|
+
│ │ ├── Dockerfile
|
|
237
|
+
│ │ ├── src/
|
|
238
|
+
│ │ │ └── index.ts # Hono starter
|
|
239
|
+
│ │ └── tests/
|
|
240
|
+
│ │ └── api-api.test.ts
|
|
241
|
+
│ │
|
|
242
|
+
│ └── api-app/ # 🆕 Created by tdk resource
|
|
243
|
+
│ ├── service.json # Port 3000, stack: api
|
|
244
|
+
│ ├── package.json
|
|
245
|
+
│ ├── tsconfig.json
|
|
246
|
+
│ ├── Dockerfile
|
|
247
|
+
│ ├── index.html
|
|
248
|
+
│ └── src/
|
|
249
|
+
│ ├── main.tsx
|
|
250
|
+
│ └── App.tsx
|
|
251
|
+
│
|
|
252
|
+
└── workers/
|
|
253
|
+
└── notification-worker/ # 🆕 Created by tdk resource
|
|
254
|
+
└── ...
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## 🆘 Getting Help
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# General help
|
|
263
|
+
tdk --help
|
|
264
|
+
|
|
265
|
+
# Command help
|
|
266
|
+
tdk resource --help
|
|
267
|
+
tdk stack --help
|
|
268
|
+
tdk up --help
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## 📚 Documentation
|
|
274
|
+
|
|
275
|
+
- [Main Documentation](https://github.com/tdk-landscape/tdk-cli/tree/main/docs)
|
|
276
|
+
- [Architecture](https://github.com/tdk-landscape/tdk-cli/tree/main/engine/docs)
|
|
277
|
+
- [Tilt Extension](https://github.com/tdk-landscape/tdk-cli#using-as-tilt-extension)
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## 📝 License
|
|
282
|
+
|
|
283
|
+
MIT © [TDK Landscape](https://github.com/tdk-landscape)
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
<div align="center">
|
|
288
|
+
|
|
289
|
+
**[⬆️ Back to Top](#-tdk-cli)**
|
|
290
|
+
|
|
291
|
+
Made with 💚 for developers who ship
|
|
292
|
+
|
|
293
|
+
</div>
|
package/bin/tdk.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
|
|
9
|
+
const cliPath = join(__dirname, "..", "dist", "cli.js");
|
|
10
|
+
|
|
11
|
+
import(cliPath).catch((err) => {
|
|
12
|
+
console.error("Failed to start TDK:", err);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
});
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import pkg from "../package.json" with { type: "json" };
|
|
5
|
+
import { completionCommand } from "./commands/completion.js";
|
|
6
|
+
import { configCommand } from "./commands/config.js";
|
|
7
|
+
import { doctorCommand } from "./commands/doctor.js";
|
|
8
|
+
import { downCommand } from "./commands/down.js";
|
|
9
|
+
import { showHelp } from "./commands/help.js";
|
|
10
|
+
import { networksCommand } from "./commands/networks.js";
|
|
11
|
+
import { projectCommand } from "./commands/project.js";
|
|
12
|
+
import { projectsCommand } from "./commands/projects.js";
|
|
13
|
+
import { resourceCommand } from "./commands/resource.js";
|
|
14
|
+
import { resourcesCommand } from "./commands/resources.js";
|
|
15
|
+
import { stackCommand } from "./commands/stack.js";
|
|
16
|
+
import { stacksCommand } from "./commands/stacks.js";
|
|
17
|
+
import { statusCommand } from "./commands/status.js";
|
|
18
|
+
import { uiCommand } from "./commands/ui.js";
|
|
19
|
+
import { upCommand } from "./commands/up.js";
|
|
20
|
+
import { upgradeCommand } from "./commands/upgrade.js";
|
|
21
|
+
import { versionCommand } from "./commands/version.js";
|
|
22
|
+
const program = new Command();
|
|
23
|
+
program
|
|
24
|
+
.name("tdk")
|
|
25
|
+
.description("Tilt Development Kit - Project/Stack/Resource management")
|
|
26
|
+
.version(pkg.version, "-v, --version", "Display version number")
|
|
27
|
+
.option("--verbose", "Enable verbose output", false)
|
|
28
|
+
.configureOutput({
|
|
29
|
+
outputError: (str, write) => write(chalk.red(str)),
|
|
30
|
+
writeOut: (str) => process.stdout.write(str),
|
|
31
|
+
writeErr: (str) => process.stderr.write(str),
|
|
32
|
+
});
|
|
33
|
+
program.helpCommand("help [command]", "Show colorful help").on("--help", () => {
|
|
34
|
+
showHelp();
|
|
35
|
+
process.exit(0);
|
|
36
|
+
});
|
|
37
|
+
program.addHelpText("before", "");
|
|
38
|
+
program.addCommand(stacksCommand);
|
|
39
|
+
program.addCommand(resourcesCommand);
|
|
40
|
+
program.addCommand(projectsCommand);
|
|
41
|
+
program.addCommand(upCommand);
|
|
42
|
+
program.addCommand(downCommand);
|
|
43
|
+
program.addCommand(statusCommand);
|
|
44
|
+
program.addCommand(stackCommand);
|
|
45
|
+
program.addCommand(resourceCommand);
|
|
46
|
+
program.addCommand(projectCommand);
|
|
47
|
+
program.addCommand(configCommand);
|
|
48
|
+
program.addCommand(uiCommand);
|
|
49
|
+
program.addCommand(versionCommand);
|
|
50
|
+
program.addCommand(doctorCommand);
|
|
51
|
+
program.addCommand(completionCommand);
|
|
52
|
+
program.addCommand(upgradeCommand);
|
|
53
|
+
program.addCommand(networksCommand);
|
|
54
|
+
// Default: show help if no command provided
|
|
55
|
+
if (process.argv.length === 2) {
|
|
56
|
+
showHelp();
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
if (process.argv.length === 3 && ["-h", "--help", "help"].includes(process.argv[2])) {
|
|
60
|
+
showHelp();
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
program.parse();
|
|
64
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuNpC,eAAO,MAAM,iBAAiB,SAgF1B,CAAC"}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
const BASH_COMPLETION = `# TDK CLI Bash Completion
|
|
7
|
+
_tdk_completions() {
|
|
8
|
+
local cur prev opts
|
|
9
|
+
COMPREPLY=()
|
|
10
|
+
cur="\${COMP_WORDS[COMP_CWORD]}"
|
|
11
|
+
prev="\${COMP_WORDS[COMP_CWORD-1]}"
|
|
12
|
+
|
|
13
|
+
# Main commands
|
|
14
|
+
local commands="project projects stack stacks resource resources up down status ui doctor version completion help upgrade"
|
|
15
|
+
|
|
16
|
+
# Options for specific commands
|
|
17
|
+
case "\${prev}" in
|
|
18
|
+
tdk)
|
|
19
|
+
COMPREPLY=( $(compgen -W "\${commands}" -- \${cur}) )
|
|
20
|
+
return 0
|
|
21
|
+
;;
|
|
22
|
+
up)
|
|
23
|
+
# Complete with stack names and resource names
|
|
24
|
+
local stacks=$(tdk stacks 2>/dev/null | grep '^ -' | sed 's/^ - //' | awk '{print $1}')
|
|
25
|
+
local resources=$(tdk resources 2>/dev/null | grep -E '^[a-z0-9-]+' | awk '{print $1}')
|
|
26
|
+
COMPREPLY=( $(compgen -W "\${stacks} \${resources}" -- \${cur}) )
|
|
27
|
+
return 0
|
|
28
|
+
;;
|
|
29
|
+
stack)
|
|
30
|
+
# Complete with existing stack names
|
|
31
|
+
local stacks=$(tdk stacks 2>/dev/null | grep '^ -' | sed 's/^ - //' | awk '{print $1}')
|
|
32
|
+
COMPREPLY=( $(compgen -W "\${stacks}" -- \${cur}) )
|
|
33
|
+
return 0
|
|
34
|
+
;;
|
|
35
|
+
resource)
|
|
36
|
+
# Suggest common resource names or types
|
|
37
|
+
COMPREPLY=( $(compgen -W "api frontend backend worker --type --stack" -- \${cur}) )
|
|
38
|
+
return 0
|
|
39
|
+
;;
|
|
40
|
+
--type)
|
|
41
|
+
COMPREPLY=( $(compgen -W "backend frontend worker" -- \${cur}) )
|
|
42
|
+
return 0
|
|
43
|
+
;;
|
|
44
|
+
--stack)
|
|
45
|
+
local stacks=$(tdk stacks 2>/dev/null | grep '^ -' | sed 's/^ - //' | awk '{print $1}')
|
|
46
|
+
COMPREPLY=( $(compgen -W "\${stacks}" -- \${cur}) )
|
|
47
|
+
return 0
|
|
48
|
+
;;
|
|
49
|
+
esac
|
|
50
|
+
|
|
51
|
+
# Global options
|
|
52
|
+
if [[ \${cur} == -* ]]; then
|
|
53
|
+
local options="--verbose --version --help --force --dry-run"
|
|
54
|
+
COMPREPLY=( $(compgen -W "\${options}" -- \${cur}) )
|
|
55
|
+
return 0
|
|
56
|
+
fi
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
complete -F _tdk_completions tdk
|
|
60
|
+
`;
|
|
61
|
+
const ZSH_COMPLETION = `#compdef tdk
|
|
62
|
+
|
|
63
|
+
# TDK CLI Zsh Completion
|
|
64
|
+
|
|
65
|
+
_tdk() {
|
|
66
|
+
local curcontext="$curcontext" state line
|
|
67
|
+
typeset -A opt_args
|
|
68
|
+
|
|
69
|
+
_arguments -C
|
|
70
|
+
'(-h --help)'{-h,--help}'[Show help]'
|
|
71
|
+
'(-v --version)'{-v,--version}'[Show version]'
|
|
72
|
+
'--verbose[Enable verbose output]'
|
|
73
|
+
'1: :_tdk_commands'
|
|
74
|
+
'*:: :->args'
|
|
75
|
+
|
|
76
|
+
case "$line[1]" in
|
|
77
|
+
up)
|
|
78
|
+
_arguments
|
|
79
|
+
'--verbose[Enable verbose output]'
|
|
80
|
+
'1: :_tdk_stacks_and_resources'
|
|
81
|
+
;;
|
|
82
|
+
stack)
|
|
83
|
+
_arguments
|
|
84
|
+
'--list[List resources without a stack]'
|
|
85
|
+
'1: :_tdk_stacks'
|
|
86
|
+
;;
|
|
87
|
+
stacks)
|
|
88
|
+
_arguments
|
|
89
|
+
'--services[Include resources in each stack]'
|
|
90
|
+
;;
|
|
91
|
+
resource)
|
|
92
|
+
_arguments
|
|
93
|
+
'--type[Resource type]:type:(backend frontend worker)'
|
|
94
|
+
'--stack[Assign to stack]:stack:_tdk_stacks'
|
|
95
|
+
'1:resource name:'
|
|
96
|
+
;;
|
|
97
|
+
resources)
|
|
98
|
+
_arguments
|
|
99
|
+
'--stack[Filter by stack]:stack:_tdk_stacks'
|
|
100
|
+
'--no-stack[Show unassigned only]'
|
|
101
|
+
'--ports[Show port assignments]'
|
|
102
|
+
;;
|
|
103
|
+
projects)
|
|
104
|
+
_arguments
|
|
105
|
+
'--check[Validate master configs]'
|
|
106
|
+
;;
|
|
107
|
+
doctor)
|
|
108
|
+
_arguments
|
|
109
|
+
'--fix[Attempt to fix issues]'
|
|
110
|
+
;;
|
|
111
|
+
upgrade)
|
|
112
|
+
_arguments
|
|
113
|
+
'--force[Force upgrade even if on latest]'
|
|
114
|
+
'--dry-run[Show what would be upgraded]'
|
|
115
|
+
;;
|
|
116
|
+
esac
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
_tdk_commands() {
|
|
120
|
+
local commands=(
|
|
121
|
+
'project:Initialize project with master configs'
|
|
122
|
+
'projects:Show project information'
|
|
123
|
+
'stack:Organize resources into stacks'
|
|
124
|
+
'stacks:List all stacks'
|
|
125
|
+
'resource:Create new resource'
|
|
126
|
+
'resources:List all resources'
|
|
127
|
+
'up:Start services'
|
|
128
|
+
'down:Stop all services'
|
|
129
|
+
'status:Show resource status'
|
|
130
|
+
'ui:Open interactive UI'
|
|
131
|
+
'doctor:Check environment'
|
|
132
|
+
'version:Show version'
|
|
133
|
+
'upgrade:Upgrade TDK CLI'
|
|
134
|
+
'completion:Generate shell completions'
|
|
135
|
+
'help:Show help'
|
|
136
|
+
)
|
|
137
|
+
_describe -t commands 'tdk command' commands
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
_tdk_stacks() {
|
|
141
|
+
local stacks
|
|
142
|
+
stacks=($(tdk stacks 2>/dev/null | grep '^ -' | sed 's/^ - //' | awk '{print $1}'))
|
|
143
|
+
_describe -t stacks 'stack' stacks
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_tdk_resources() {
|
|
147
|
+
local resources
|
|
148
|
+
resources=($(tdk resources 2>/dev/null | grep -E '^[a-z0-9-]+' | awk '{print $1}'))
|
|
149
|
+
_describe -t resources 'resource' resources
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
_tdk_stacks_and_resources() {
|
|
153
|
+
_tdk_stacks
|
|
154
|
+
_tdk_resources
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
compdef _tdk tdk
|
|
158
|
+
`;
|
|
159
|
+
const FISH_COMPLETION = `# TDK CLI Fish Completion
|
|
160
|
+
|
|
161
|
+
# Disable file completions for most commands
|
|
162
|
+
complete -c tdk -f
|
|
163
|
+
|
|
164
|
+
# Main commands
|
|
165
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'project' -d 'Initialize project with master configs'
|
|
166
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'projects' -d 'Show project information'
|
|
167
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'stack' -d 'Organize resources into stacks'
|
|
168
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'stacks' -d 'List all stacks'
|
|
169
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'resource' -d 'Create new resource'
|
|
170
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'resources' -d 'List all resources'
|
|
171
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'up' -d 'Start services'
|
|
172
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'down' -d 'Stop all services'
|
|
173
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'status' -d 'Show resource status'
|
|
174
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'ui' -d 'Open interactive UI'
|
|
175
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'doctor' -d 'Check environment'
|
|
176
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'version' -d 'Show version'
|
|
177
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'upgrade' -d 'Upgrade TDK CLI'
|
|
178
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'completion' -d 'Generate shell completions'
|
|
179
|
+
complete -c tdk -n '__fish_use_subcommand' -a 'help' -d 'Show help'
|
|
180
|
+
|
|
181
|
+
# Global options
|
|
182
|
+
complete -c tdk -s h -l help -d 'Show help'
|
|
183
|
+
complete -c tdk -s v -l version -d 'Show version'
|
|
184
|
+
complete -c tdk -l verbose -d 'Enable verbose output'
|
|
185
|
+
|
|
186
|
+
# Command-specific completions
|
|
187
|
+
# resource command options
|
|
188
|
+
complete -c tdk -n '__fish_seen_subcommand_from resource' -l type -d 'Resource type' -a 'backend frontend worker'
|
|
189
|
+
complete -c tdk -n '__fish_seen_subcommand_from resource' -l stack -d 'Assign to stack' -a '(tdk stacks 2>/dev/null | string match -r "^ - " | string replace " - " "")'
|
|
190
|
+
|
|
191
|
+
# resources command options
|
|
192
|
+
complete -c tdk -n '__fish_seen_subcommand_from resources' -l stack -d 'Filter by stack' -a '(tdk stacks 2>/dev/null | string match -r "^ - " | string replace " - " "")'
|
|
193
|
+
complete -c tdk -n '__fish_seen_subcommand_from resources' -l no-stack -d 'Show unassigned only'
|
|
194
|
+
complete -c tdk -n '__fish_seen_subcommand_from resources' -l ports -d 'Show port assignments'
|
|
195
|
+
|
|
196
|
+
# stack command options
|
|
197
|
+
complete -c tdk -n '__fish_seen_subcommand_from stack' -l list -d 'List resources without a stack'
|
|
198
|
+
|
|
199
|
+
# stacks command options
|
|
200
|
+
complete -c tdk -n '__fish_seen_subcommand_from stacks' -l services -d 'Include resources in each stack'
|
|
201
|
+
|
|
202
|
+
# projects command options
|
|
203
|
+
complete -c tdk -n '__fish_seen_subcommand_from projects' -l check -d 'Validate master configs'
|
|
204
|
+
|
|
205
|
+
# up command completions
|
|
206
|
+
complete -c tdk -n '__fish_seen_subcommand_from up' -a '(tdk stacks 2>/dev/null | string match -r "^ - " | string replace " - " "")'
|
|
207
|
+
complete -c tdk -n '__fish_seen_subcommand_from up' -a '(tdk resources 2>/dev/null | string match -r "^[a-z0-9-]+")'
|
|
208
|
+
|
|
209
|
+
# doctor command options
|
|
210
|
+
complete -c tdk -n '__fish_seen_subcommand_from doctor' -l fix -d 'Attempt to fix issues'
|
|
211
|
+
|
|
212
|
+
# upgrade command options
|
|
213
|
+
complete -c tdk -n '__fish_seen_subcommand_from upgrade' -l force -d 'Force upgrade even if on latest'
|
|
214
|
+
complete -c tdk -n '__fish_seen_subcommand_from upgrade' -l dry-run -d 'Show what would be upgraded'
|
|
215
|
+
`;
|
|
216
|
+
export const completionCommand = new Command("completion")
|
|
217
|
+
.description("Generate shell completion scripts")
|
|
218
|
+
.option("-s, --shell <shell>", "Target shell (bash, zsh, fish)", "bash")
|
|
219
|
+
.option("-o, --output <path>", "Output file path (default: stdout)")
|
|
220
|
+
.option("--install", "Install to shell config automatically")
|
|
221
|
+
.action((options) => {
|
|
222
|
+
const shell = options.shell.toLowerCase();
|
|
223
|
+
let completionScript;
|
|
224
|
+
let filename;
|
|
225
|
+
switch (shell) {
|
|
226
|
+
case "bash":
|
|
227
|
+
completionScript = BASH_COMPLETION;
|
|
228
|
+
filename = "tdk-completion.bash";
|
|
229
|
+
break;
|
|
230
|
+
case "zsh":
|
|
231
|
+
completionScript = ZSH_COMPLETION;
|
|
232
|
+
filename = "_tdk";
|
|
233
|
+
break;
|
|
234
|
+
case "fish":
|
|
235
|
+
completionScript = FISH_COMPLETION;
|
|
236
|
+
filename = "tdk.fish";
|
|
237
|
+
break;
|
|
238
|
+
default:
|
|
239
|
+
console.error(chalk.red(`❌ Unsupported shell: ${shell}`));
|
|
240
|
+
console.log(chalk.gray("Supported shells: bash, zsh, fish"));
|
|
241
|
+
process.exit(1);
|
|
242
|
+
}
|
|
243
|
+
if (options.install) {
|
|
244
|
+
const home = homedir();
|
|
245
|
+
let installPath;
|
|
246
|
+
let installInstructions;
|
|
247
|
+
switch (shell) {
|
|
248
|
+
case "bash": {
|
|
249
|
+
installPath = join(home, ".bash_completion.d", filename);
|
|
250
|
+
const bashDir = join(home, ".bash_completion.d");
|
|
251
|
+
if (!existsSync(bashDir)) {
|
|
252
|
+
mkdirSync(bashDir, { recursive: true });
|
|
253
|
+
}
|
|
254
|
+
installInstructions = `\n# Add to ~/.bashrc:\nsource ~/.bash_completion.d/${filename}`;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
case "zsh": {
|
|
258
|
+
installPath = join(home, ".zsh", "completions", filename);
|
|
259
|
+
const zshDir = join(home, ".zsh", "completions");
|
|
260
|
+
if (!existsSync(zshDir)) {
|
|
261
|
+
mkdirSync(zshDir, { recursive: true });
|
|
262
|
+
}
|
|
263
|
+
installInstructions =
|
|
264
|
+
"\n# Add to ~/.zshrc:\nfpath+=(~/.zsh/completions)\nautoload -U compinit && compinit";
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
case "fish": {
|
|
268
|
+
installPath = join(home, ".config", "fish", "completions", filename);
|
|
269
|
+
const fishDir = join(home, ".config", "fish", "completions");
|
|
270
|
+
if (!existsSync(fishDir)) {
|
|
271
|
+
mkdirSync(fishDir, { recursive: true });
|
|
272
|
+
}
|
|
273
|
+
installInstructions = "\n# Fish completions loaded automatically";
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
default:
|
|
277
|
+
installPath = "";
|
|
278
|
+
installInstructions = "";
|
|
279
|
+
}
|
|
280
|
+
writeFileSync(installPath, completionScript, "utf-8");
|
|
281
|
+
console.log(chalk.green(`✅ Installed ${shell} completion to:`));
|
|
282
|
+
console.log(chalk.cyan(` ${installPath}`));
|
|
283
|
+
console.log(chalk.yellow(installInstructions));
|
|
284
|
+
}
|
|
285
|
+
else if (options.output) {
|
|
286
|
+
writeFileSync(options.output, completionScript, "utf-8");
|
|
287
|
+
console.log(chalk.green(`✅ Written ${shell} completion to:`));
|
|
288
|
+
console.log(chalk.cyan(` ${options.output}`));
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
console.log(completionScript);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
//# sourceMappingURL=completion.js.map
|