@tdk-landscape/tdk-cli-core 1.3.75 → 1.3.77
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/CHANGELOG.md +6 -0
- package/README.md +59 -13
- package/cli/bin/tdk.js +22 -2
- package/cli/dist/cli.js +9 -2
- package/cli/dist/commands/completion.js +30 -3
- package/cli/dist/commands/config.js +59 -1
- package/cli/dist/commands/doctor.js +295 -98
- package/cli/dist/commands/eject.js +77 -0
- package/cli/dist/commands/networks.js +17 -4
- package/cli/dist/commands/project.js +28 -5
- package/cli/dist/commands/resource.js +118 -10
- package/cli/dist/commands/up.js +93 -21
- package/cli/dist/commands/upgrade.js +163 -68
- package/cli/dist/generator/template-engine.js +77 -13
- package/cli/dist/types/index.js +6 -1
- package/cli/dist/utils/cold-preflight.js +198 -0
- package/cli/dist/utils/constants.js +4 -0
- package/cli/dist/utils/docker.js +15 -1
- package/cli/dist/utils/doctor-runtime.js +48 -16
- package/cli/dist/utils/doctor-wiring.js +269 -0
- package/cli/dist/utils/errors.js +5 -5
- package/cli/dist/utils/exec-async.js +30 -0
- package/cli/dist/utils/generated-paths.js +49 -0
- package/cli/dist/utils/platform.js +53 -0
- package/cli/dist/utils/port-assignment.js +13 -20
- package/cli/dist/utils/project-templates.js +7 -2
- package/cli/dist/utils/resource-features.js +6 -2
- package/cli/dist/utils/service-manifest.js +73 -0
- package/cli/dist/utils/services.js +8 -1
- package/cli/dist/utils/tar.js +27 -5
- package/cli/dist/utils/tilt-process.js +53 -0
- package/cli/dist/utils/tilt.js +3 -1
- package/cli/dist/utils/which.js +26 -0
- package/cli/dist/utils/windows-doctor.js +175 -0
- package/cli/package.json +1 -1
- package/cli/templates/TILT_RESOURCE_DEFAULTS.star.hbs +1 -2
- package/cli/templates/TILT_TECH_STACK.star.hbs +0 -1
- package/cli/templates/Tiltfile.hbs +24 -4
- package/cli/templates/spec.master.hbs +1 -2
- package/discovery/AGENTS.md +1 -1
- package/discovery/constants.star +2 -2
- package/discovery/discovery_orchestrator.star +2 -2
- package/discovery/manifest/constants.star +1 -1
- package/discovery/manifest/loading.star +7 -3
- package/discovery/registry.star +17 -3
- package/engine/README.md +2 -0
- package/engine/schemas/service-schema.json +47 -21
- package/engine/scripts/generate-manifest.sh +2 -1
- package/engine/topologies/platform/docker/compose/compose.star +37 -5
- package/engine/topologies/tilt/common/utils.star +54 -11
- package/engine/topologies/tilt/manifest/AGENTS.md +1 -1
- package/engine/topologies/tilt/manifest/constants.star +3 -0
- package/engine/topologies/tilt/manifest/schema.star +2 -4
- package/engine/topologies/tilt/manifest/validator.star +1 -1
- package/engine/topologies/tilt/resources/infra-loader.star +14 -3
- package/engine/topologies/tilt/resources/orchestrator/apply_compose_resource_registration.star +15 -11
- package/engine/topologies/tilt/resources/orchestrator/generators/manifest_resource.star +15 -6
- package/examples/tdk-example/LICENSE +21 -0
- package/examples/tdk-example/README.md +23 -0
- package/examples/tdk-example/TILT_SERVICE_DEFAULTS.star +42 -0
- package/examples/tdk-example/TILT_TECH_STACK.star +67 -0
- package/examples/tdk-example/Tiltfile +25 -0
- package/examples/tdk-example/services/platform/messaging/docker-compose.yml +26 -0
- package/examples/tdk-example/services/shop/orders-api/package.json +20 -0
- package/examples/tdk-example/services/shop/orders-api/service.json +14 -0
- package/examples/tdk-example/services/shop/orders-api/src/index.ts +81 -0
- package/examples/tdk-example/services/shop/orders-app/index.html +12 -0
- package/examples/tdk-example/services/shop/orders-app/package.json +20 -0
- package/examples/tdk-example/services/shop/orders-app/public/.gitkeep +0 -0
- package/examples/tdk-example/services/shop/orders-app/service.json +9 -0
- package/examples/tdk-example/services/shop/orders-app/src/main.tsx +9 -0
- package/examples/tdk-example/services/shop/orders-app/src/orders.tsx +67 -0
- package/examples/tdk-example/services/shop/orders-app/src/style.css +15 -0
- package/examples/tdk-example/services/shop/orders-worker/package.json +18 -0
- package/examples/tdk-example/services/shop/orders-worker/service.json +13 -0
- package/examples/tdk-example/services/shop/orders-worker/src/index.ts +33 -0
- package/package.json +2 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "orders-app",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "vite build",
|
|
7
|
+
"dev": "vite --host 0.0.0.0"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@vitejs/plugin-react": "^5.0.4",
|
|
11
|
+
"vite": "^7.1.7",
|
|
12
|
+
"react": "^19.1.1",
|
|
13
|
+
"react-dom": "^19.1.1"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/react": "^19.1.16",
|
|
17
|
+
"@types/react-dom": "^19.1.9",
|
|
18
|
+
"typescript": "^5.9.2"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import "./style.css";
|
|
3
|
+
|
|
4
|
+
type Order = { id: number; item: string; workerSeenAt: string | null };
|
|
5
|
+
const api = `${window.location.protocol}//api.${window.location.hostname.replace(/^app\./, "")}/api/orders`;
|
|
6
|
+
|
|
7
|
+
export function App() {
|
|
8
|
+
const [item, setItem] = useState("coffee");
|
|
9
|
+
const [orders, setOrders] = useState<Order[]>([]);
|
|
10
|
+
const [message, setMessage] = useState("Loading orders…");
|
|
11
|
+
|
|
12
|
+
async function refresh() {
|
|
13
|
+
try {
|
|
14
|
+
const response = await fetch(api);
|
|
15
|
+
const data = (await response.json()) as { orders: Order[] };
|
|
16
|
+
setOrders(data.orders);
|
|
17
|
+
setMessage("API and database are connected");
|
|
18
|
+
} catch {
|
|
19
|
+
setMessage("Waiting for the orders API");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
void refresh();
|
|
25
|
+
const timer = window.setInterval(() => void refresh(), 1500);
|
|
26
|
+
return () => window.clearInterval(timer);
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
async function createOrder(event: React.FormEvent) {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
const response = await fetch(api, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: { "content-type": "application/json" },
|
|
34
|
+
body: JSON.stringify({ item }),
|
|
35
|
+
});
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
setMessage(`Could not create order (${response.status})`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
setMessage("Order saved; waiting for NATS worker observation…");
|
|
41
|
+
await refresh();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<main>
|
|
46
|
+
<p className="eyebrow">TDK · Hono · PostgreSQL · NATS · Vite · Traefik</p>
|
|
47
|
+
<h1>Order desk</h1>
|
|
48
|
+
<p className="status">{message}</p>
|
|
49
|
+
<form onSubmit={createOrder}>
|
|
50
|
+
<label htmlFor="item">What should the worker process?</label>
|
|
51
|
+
<div className="row">
|
|
52
|
+
<input id="item" value={item} onChange={(event) => setItem(event.target.value)} />
|
|
53
|
+
<button type="submit">Create order</button>
|
|
54
|
+
</div>
|
|
55
|
+
</form>
|
|
56
|
+
<h2>Persisted orders</h2>
|
|
57
|
+
<ul>
|
|
58
|
+
{orders.map((order) => (
|
|
59
|
+
<li key={order.id}>
|
|
60
|
+
<span>#{order.id} · {order.item}</span>
|
|
61
|
+
<strong>{order.workerSeenAt ? "Worker observed" : "Queued"}</strong>
|
|
62
|
+
</li>
|
|
63
|
+
))}
|
|
64
|
+
</ul>
|
|
65
|
+
</main>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
:root { font-family: Inter, ui-sans-serif, system-ui, sans-serif; color: #13231e; background: #edf2ee; }
|
|
2
|
+
* { box-sizing: border-box; }
|
|
3
|
+
body { margin: 0; min-width: 320px; }
|
|
4
|
+
main { width: min(720px, calc(100% - 32px)); margin: 12vh auto; padding: 40px; background: white; border: 1px solid #d8e1dc; border-radius: 18px; box-shadow: 0 20px 60px #163c2512; }
|
|
5
|
+
.eyebrow { color: #537363; font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
|
|
6
|
+
h1 { margin: 12px 0; font-size: clamp(38px, 8vw, 64px); letter-spacing: -.06em; }
|
|
7
|
+
.status { color: #587064; }
|
|
8
|
+
label { display: block; margin: 28px 0 8px; font-weight: 650; }
|
|
9
|
+
.row { display: flex; gap: 10px; }
|
|
10
|
+
input { min-width: 0; flex: 1; padding: 12px 14px; border: 1px solid #cad7cf; border-radius: 8px; font: inherit; }
|
|
11
|
+
button { padding: 12px 18px; border: 0; border-radius: 8px; color: white; background: #176447; font: inherit; font-weight: 700; cursor: pointer; }
|
|
12
|
+
h2 { margin-top: 34px; font-size: 18px; }
|
|
13
|
+
ul { display: grid; gap: 8px; padding: 0; list-style: none; }
|
|
14
|
+
li { display: flex; justify-content: space-between; gap: 12px; padding: 12px; background: #f4f7f4; border-radius: 8px; }
|
|
15
|
+
li strong { color: #176447; }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "orders-worker",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "bun build src/index.ts --outdir dist --target bun --packages external",
|
|
7
|
+
"start": "bun run dist/index.js",
|
|
8
|
+
"dev": "bun --watch src/index.ts"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"nats": "^2.29.3",
|
|
12
|
+
"pg": "^8.16.3"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/node": "^20.0.0",
|
|
16
|
+
"@types/pg": "^8.15.5"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://tdk-landscape.github.io/schema.service.json",
|
|
3
|
+
"schemaVersion": 1,
|
|
4
|
+
"appName": "orders-worker",
|
|
5
|
+
"appType": "worker",
|
|
6
|
+
"stack": "shop",
|
|
7
|
+
"port": 4001,
|
|
8
|
+
"featuresEnabled": ["nats"],
|
|
9
|
+
"params": {
|
|
10
|
+
"NATS_URL": "nats://tdk_example_nats:4222"
|
|
11
|
+
},
|
|
12
|
+
"dependsOn": ["orders-api"]
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { connect, type NatsConnection } from "nats";
|
|
2
|
+
import { Pool } from "pg";
|
|
3
|
+
|
|
4
|
+
const databaseUrl = process.env.DATABASE_URL;
|
|
5
|
+
const natsUrl = process.env.NATS_URL ?? "nats://tdk_example_nats:4222";
|
|
6
|
+
if (!databaseUrl) throw new Error("DATABASE_URL is required");
|
|
7
|
+
|
|
8
|
+
const pgUrl = new URL(databaseUrl);
|
|
9
|
+
pgUrl.searchParams.delete("schema");
|
|
10
|
+
const db = new Pool({ connectionString: pgUrl.toString() });
|
|
11
|
+
let nc: NatsConnection | undefined;
|
|
12
|
+
while (!nc) {
|
|
13
|
+
try {
|
|
14
|
+
nc = await connect({ servers: natsUrl });
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error("waiting for NATS", error);
|
|
17
|
+
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const subscription = nc.subscribe("demo.orders.created", { queue: "orders-workers" });
|
|
21
|
+
await nc.flush();
|
|
22
|
+
nc.publish("demo.orders.worker-ready", new Uint8Array());
|
|
23
|
+
console.log("orders-worker subscribed to demo.orders.created");
|
|
24
|
+
|
|
25
|
+
for await (const message of subscription) {
|
|
26
|
+
const id = new TextDecoder().decode(message.data);
|
|
27
|
+
const result = await db.query(
|
|
28
|
+
"UPDATE demo_orders SET worker_seen_at = now() WHERE id = $1 RETURNING id, item",
|
|
29
|
+
[id],
|
|
30
|
+
);
|
|
31
|
+
if (result.rows[0]) console.log(`worker observed order ${id}: ${result.rows[0].item}`);
|
|
32
|
+
else console.error(`worker received unknown order ${id}`);
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tdk-landscape/tdk-cli-core",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.77",
|
|
4
4
|
"description": "Run your whole microservice landscape locally without Kubernetes. Scaffold services and run them with hot reload, built on Tilt.",
|
|
5
5
|
"homepage": "https://tdk-landscape.github.io/tdk-website",
|
|
6
6
|
"repository": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"specs",
|
|
27
27
|
"ext",
|
|
28
28
|
"shared-platform-engineering/docker-templates",
|
|
29
|
+
"examples/tdk-example",
|
|
29
30
|
"cli/bin",
|
|
30
31
|
"cli/dist/**/*.js",
|
|
31
32
|
"cli/templates",
|