@tdk-landscape/tdk-cli-core 1.3.111 → 1.3.113
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 +1 -0
- package/README.md +20 -1
- package/cli/dist/commands/eject.js +49 -20
- package/cli/package.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,7 @@ Notable changes to the `tdk` CLI. Versions match [npm](https://www.npmjs.com/pac
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
- `tdk eject` no longer claims files it does not create or prints a command that cannot work. It still writes only `EJECTED.md` (no file is copied, moved or generated; the Tiltfile and engine stay in git-ignored `.tdk/.tdk-out/`, and the per-service Compose files, golden-layer Dockerfile and Traefik file only exist after Tilt has run). `EJECTED.md` no longer lists them under "Keep" and says the Tiltfile still reads `.tdk/project.json` and the `service.json` files. `Next: tilt up` (which finds no Tiltfile at the project root) is replaced by `tilt up -f .tdk/.tdk-out/Tiltfile -- --focus=<stack>`, the form `tdk up` runs. A project that already has an `EJECTED.md` keeps its old text (the file is never overwritten) and is now told so. `--dry-run` headings read `Generated files, left where they are (git-ignored):` and `Files written:`. A command that exports plain Compose files and Dockerfiles does not exist. Fixes #610.
|
|
7
8
|
- `tdk config regenerate` now restores a root `.tiltignore` that TDK wrote (it carries the `SYSTEM-GENERATED BY TDK CLI` header) and that was edited by hand, and prints `Restored: .tiltignore → project root (hand edits discarded)`. Before, it only copied the file when none existed, so `tdk config verify` kept failing with `Out of sync: .tiltignore (run 'tdk config regenerate')` after the advice was followed. A root `.tiltignore` without the header is still never overwritten, and plain `tdk project --yes` still does not overwrite an existing one. Docs: `docs/adopt-tdk.md` now quotes the current `tdk doctor` unknown-field wording.
|
|
8
9
|
- `tdk doctor` now checks the project's own resource configs for duplicates. Two resources with the same `appName` fail (`Duplicate resource names`, naming both `service.json` paths): the name becomes the Compose service and Traefik router, so they collide, and before nothing reported it. Two backend, mcp or routed bring-your-own resources on the same `port` give a warning, not a failure (`Duplicate resource ports`): service ports are not published on the host and each service has its own container, so the pair can run, but it is usually a copied `service.json`. Frontends, workers, libraries and a missing `port` are ignored. Fixes #76.
|
|
9
10
|
- `tdk doctor` no longer fails with `N resources without a package.json` for a bring-your-own resource. A bring-your-own resource (`--image`, `--dockerfile` or `buildContext`) is a plain container: its image is pulled or built from its own Dockerfile, never from the generated Dockerfile that copies a `package.json`, so the check was a false positive that made `tdk doctor` (and CI recipes that gate on it) exit non-zero right after wrapping an existing service. Backend, frontend, worker, migrator, mcp, library and sdk resources without a `package.json` still fail; Python, Go and Rust backends were already exempt. The other doctor checks were run on a project with only bring-your-own resources and report nothing. Fixes #599.
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ English | [简体中文](README-zh_cn.md) | [繁體中文](README-zh_tw.md) | [
|
|
|
15
15
|
|
|
16
16
|
TDK CLI starts your services on your laptop. It is not a deploy and not a Compose file: define each service in `service.json`, then run `tdk up`. No Kubernetes is needed on the machine.
|
|
17
17
|
|
|
18
|
-
Stability: 1.x local dev.
|
|
18
|
+
Stability: 1.x local dev. Write `service.json`; TDK generates the local runtime files. See [what TDK writes](docs/generated-files.md) and how to check for drift. Core CLI is MIT and needs no key. Premium is optional.
|
|
19
19
|
|
|
20
20
|
Docker runs the containers. Tilt watches services and live-updates containers while you code. TDK CLI writes the configuration Tilt uses. Production deployment stays with Helm, Argo CD, or Kustomize.
|
|
21
21
|
|
|
@@ -39,6 +39,24 @@ curl http://api.shop.localhost/api/orders-api/health
|
|
|
39
39
|
|
|
40
40
|
*Scaffolding a backend and frontend, then listing the stack.*
|
|
41
41
|
|
|
42
|
+
### What TDK writes for a frontend
|
|
43
|
+
|
|
44
|
+
You maintain `service.json`; TDK generates the local runtime files. A frontend such as `services/store/storefront-web` has files like these after generation:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
services/store/storefront-web/
|
|
48
|
+
├── service.json # your service definition
|
|
49
|
+
└── .autogenerated/ # TDK writes these files
|
|
50
|
+
├── nginx.autogenerated.conf # serves the build and routes API requests
|
|
51
|
+
├── Dockerfile.app.autogenerated # local app image
|
|
52
|
+
├── .env.frontend.autogenerated # local frontend environment
|
|
53
|
+
├── vite.config.frontend.autogenerated.ts
|
|
54
|
+
├── tsconfig.autogenerated.json
|
|
55
|
+
└── api-client.ts # generated API client
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
You do not need to write the nginx config, Dockerfile, or a `docker-compose.yml` for this local stack. `tdk up` uses Docker and Tilt to start it. The [generated-files guide](docs/generated-files.md) lists the other outputs and explains how regeneration and drift checks work.
|
|
59
|
+
|
|
42
60
|

|
|
43
61
|
|
|
44
62
|
If Helm, Compose, or your existing Tilt setup already gives you a working local environment, keep using it. TDK CLI is for engineers managing several services who want a clear local service contract and one command to start the stack.
|
|
@@ -79,6 +97,7 @@ curl -fsSL https://tdk-landscape.github.io/install.sh | sh
|
|
|
79
97
|
- [Pilot scorecard](docs/pilot-scorecard.md)
|
|
80
98
|
- [Bring-your-own resources](docs/byo.md)
|
|
81
99
|
- [Configuration and editor schemas](docs/configuration.md)
|
|
100
|
+
- [Generated service files and drift checks](docs/generated-files.md)
|
|
82
101
|
- [Runnable one-backend example](examples/one-backend/README.md)
|
|
83
102
|
- [Runnable Python backend example](examples/one-backend-python/README.md)
|
|
84
103
|
- [Full multi-service example](examples/tdk-example/README.md)
|
|
@@ -5,25 +5,44 @@ import { Command } from "commander";
|
|
|
5
5
|
import { confirmOrCancel } from "../utils/command-helpers.js";
|
|
6
6
|
import { runCommand } from "../utils/errors.js";
|
|
7
7
|
import { findProjectRoot } from "../utils/paths.js";
|
|
8
|
+
// Same location `tdk up` hands to Tilt (see getTiltfilePath in utils/tilt.ts), relative to the project root.
|
|
9
|
+
export const TILTFILE_RELATIVE_PATH = ".tdk/.tdk-out/Tiltfile";
|
|
10
|
+
export const TILT_UP_COMMAND = `tilt up -f ${TILTFILE_RELATIVE_PATH} -- --focus=<stack>`;
|
|
8
11
|
export const EJECTED_CONTENT = `# Ejected from TDK
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
\`tdk eject\` wrote this file and nothing else. It did not copy, move or generate anything, and it did
|
|
14
|
+
not remove TDK. What exists is what TDK had already generated, and that is still TDK-owned output.
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
- Tiltfile
|
|
14
|
-
- Dockerfiles
|
|
15
|
-
- compose files TDK wrote
|
|
16
|
-
- Traefik / proxy config TDK wrote
|
|
16
|
+
## Where the generated files are
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- service
|
|
18
|
+
- \`.tdk/.tdk-out/\` holds the Tiltfile and the engine it loads (\`tdk-cli-ext/\`). It is git-ignored.
|
|
19
|
+
\`tdk config regenerate\` rewrites the master files in it.
|
|
20
|
+
- The per-service Compose files (\`services/<stack>/<name>/.autogenerated/\`), the golden-layer
|
|
21
|
+
Dockerfile and the Traefik file (\`.tdk/.tdk-out/\`) are written by Tilt when it runs, not by
|
|
22
|
+
\`tdk eject\`. Until Tilt has run they do not exist. They are git-ignored too.
|
|
23
|
+
- Your own Dockerfiles, \`service.json\` files and source code are untouched.
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
## Running the stack without the tdk CLI
|
|
26
|
+
|
|
27
|
+
There is no Tiltfile at the project root, so a plain \`tilt up\` does not find one. TDK runs:
|
|
28
|
+
|
|
29
|
+
${TILT_UP_COMMAND}
|
|
30
|
+
|
|
31
|
+
from the project root (\`<stack>\` is a stack name under \`services/\`; without \`--focus\` the Tiltfile
|
|
32
|
+
falls back to its default phase). The Tiltfile still reads \`.tdk/project.json\` and the
|
|
33
|
+
\`service.json\` files, so those must stay. \`tdk up\` also does steps before Tilt starts (it chooses
|
|
34
|
+
host ports and exports them to Tilt); running Tilt by hand skips them.
|
|
35
|
+
|
|
36
|
+
## Cleaning up
|
|
37
|
+
|
|
38
|
+
Optional to delete later: this file, and \`.tdk/\` plus the \`service.json\` files if you stop using TDK.
|
|
39
|
+
Deleting them also removes what the Tiltfile needs.
|
|
40
|
+
|
|
41
|
+
To go back to TDK: install it and run \`tdk config regenerate\`.
|
|
23
42
|
`;
|
|
24
43
|
export const ejectCommand = new Command("eject")
|
|
25
|
-
.description("
|
|
26
|
-
.option("--dry-run", "List generated files without changing the project", false)
|
|
44
|
+
.description("Write EJECTED.md describing the generated Tilt files (copies and generates nothing; they stay in .tdk/.tdk-out/)")
|
|
45
|
+
.option("--dry-run", "List the generated files and what would be written, without changing the project", false)
|
|
27
46
|
.option("--yes", "Skip the confirmation prompt", false)
|
|
28
47
|
.action(async (options) => {
|
|
29
48
|
await runCommand(async () => {
|
|
@@ -48,15 +67,19 @@ export const ejectCommand = new Command("eject")
|
|
|
48
67
|
throw new Error("Generated Tilt files are missing. Run `tdk project --yes` before ejecting.");
|
|
49
68
|
}
|
|
50
69
|
const rootTiltfile = join(projectRoot, "Tiltfile");
|
|
51
|
-
|
|
52
|
-
files.push("Tiltfile");
|
|
70
|
+
const userTiltfile = existsSync(rootTiltfile) ? ["Tiltfile"] : [];
|
|
53
71
|
const ejectedPath = join(projectRoot, "EJECTED.md");
|
|
54
72
|
const willCreate = existsSync(ejectedPath) ? [] : ["EJECTED.md"];
|
|
55
73
|
if (options.dryRun) {
|
|
56
|
-
console.log("
|
|
74
|
+
console.log("Generated files, left where they are (git-ignored):");
|
|
57
75
|
for (const path of files)
|
|
58
76
|
console.log(` ${path}`);
|
|
59
|
-
|
|
77
|
+
if (userTiltfile.length > 0) {
|
|
78
|
+
console.log("Root Tiltfile, left where it is (not generated, not git-ignored):");
|
|
79
|
+
for (const path of userTiltfile)
|
|
80
|
+
console.log(` ${path}`);
|
|
81
|
+
}
|
|
82
|
+
console.log("Files written:");
|
|
60
83
|
for (const path of willCreate)
|
|
61
84
|
console.log(` ${path}`);
|
|
62
85
|
if (willCreate.length === 0)
|
|
@@ -64,13 +87,19 @@ export const ejectCommand = new Command("eject")
|
|
|
64
87
|
return;
|
|
65
88
|
}
|
|
66
89
|
if (!options.yes &&
|
|
67
|
-
!(await confirmOrCancel("
|
|
90
|
+
!(await confirmOrCancel("Write EJECTED.md? (Generated files stay in .tdk/.tdk-out/; nothing is copied or moved.)"))) {
|
|
68
91
|
return;
|
|
69
92
|
}
|
|
70
|
-
if (
|
|
93
|
+
if (existsSync(ejectedPath)) {
|
|
94
|
+
console.log(chalk.green("EJECTED.md already exists and was left unchanged. Nothing was copied, moved or generated."));
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
71
97
|
writeFileSync(ejectedPath, EJECTED_CONTENT, { flag: "wx" });
|
|
72
|
-
|
|
73
|
-
|
|
98
|
+
console.log(chalk.green("Wrote EJECTED.md. Nothing was copied, moved or generated."));
|
|
99
|
+
}
|
|
100
|
+
console.log("Generated files stay in .tdk/.tdk-out/ (git-ignored) and still need TDK inputs.");
|
|
101
|
+
console.log(`Run from the project root: ${TILT_UP_COMMAND}`);
|
|
102
|
+
console.log("Replace <stack> with a stack name under services/, or omit --focus to use the Tiltfile's default phase.");
|
|
74
103
|
console.log("Read EJECTED.md");
|
|
75
104
|
});
|
|
76
105
|
});
|
package/cli/package.json
CHANGED