@tdk-landscape/tdk-cli-core 1.3.102 → 1.3.104
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 +11 -9
- package/cli/dist/cli.js +2 -0
- package/cli/dist/commands/import.js +39 -0
- package/cli/dist/utils/service-manifest.js +1 -0
- package/cli/package.json +1 -1
- package/discovery/manifest/loading.star +6 -1
- package/engine/schemas/service-schema.json +4 -0
- package/engine/topologies/platform/docker/compose/compose.star +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# TDK CLI — start services on your laptop
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@tdk-landscape/tdk-cli-core)
|
|
4
|
+
[](https://packagephobia.com/result?p=@tdk-landscape/tdk-cli-core)
|
|
5
|
+
[](https://packagephobia.com/result?p=@tdk-landscape/tdk-cli-core)
|
|
6
|
+
[](https://github.com/tdk-landscape/tdk-cli-core/actions/workflows/ci.yml)
|
|
7
|
+
[](https://github.com/tdk-landscape/tdk-cli-core/actions/workflows/quickstart-e2e.yml)
|
|
8
|
+
[](https://github.com/tdk-landscape/tdk-cli-core/actions/workflows/erp-scale-e2e.yml)
|
|
9
|
+
[](https://github.com/tdk-landscape/tdk-cli-core/actions/workflows/examples-e2e.yml)
|
|
10
|
+
[](https://snyk.io/test/github/tdk-landscape/tdk-cli-core)
|
|
11
|
+
[](https://socket.dev/npm/package/@tdk-landscape/tdk-cli-core/overview)
|
|
12
|
+
[](LICENSE)
|
|
13
|
+
|
|
3
14
|
English | [简体中文](README-zh_cn.md) | [繁體中文](README-zh_tw.md) | [日本語](README-ja.md) | [한국어](README-ko.md)
|
|
4
15
|
|
|
5
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.
|
|
@@ -34,15 +45,6 @@ If Helm, Compose, or your existing Tilt setup already gives you a working local
|
|
|
34
45
|
|
|
35
46
|
See [how TDK CLI works alongside Helm](https://tdk-landscape.github.io/tdk-website/docs/with-helm/), the [service schema](engine/schemas/service-schema.json), and the [project configuration schema](engine/schemas/project-schema.json).
|
|
36
47
|
|
|
37
|
-
[](https://www.npmjs.com/package/@tdk-landscape/tdk-cli-core)
|
|
38
|
-
[](https://github.com/tdk-landscape/tdk-cli-core/actions/workflows/ci.yml)
|
|
39
|
-
[](https://github.com/tdk-landscape/tdk-cli-core/actions/workflows/quickstart-e2e.yml)
|
|
40
|
-
[](https://github.com/tdk-landscape/tdk-cli-core/actions/workflows/erp-scale-e2e.yml)
|
|
41
|
-
[](https://github.com/tdk-landscape/tdk-cli-core/actions/workflows/examples-e2e.yml)
|
|
42
|
-
[](https://snyk.io/test/github/tdk-landscape/tdk-cli-core)
|
|
43
|
-
[](https://socket.dev/npm/package/@tdk-landscape/tdk-cli-core/overview)
|
|
44
|
-
[](LICENSE)
|
|
45
|
-
|
|
46
48
|
## Installation
|
|
47
49
|
|
|
48
50
|
Install the CLI from npm (requires Node.js 22.12+) or use the prebuilt binary (no Node.js or Bun required):
|
package/cli/dist/cli.js
CHANGED
|
@@ -8,6 +8,7 @@ import { doctorCommand } from "./commands/doctor.js";
|
|
|
8
8
|
import { downCommand } from "./commands/down.js";
|
|
9
9
|
import { ejectCommand } from "./commands/eject.js";
|
|
10
10
|
import { showHelp } from "./commands/help.js";
|
|
11
|
+
import { importCommand } from "./commands/import.js";
|
|
11
12
|
import { maintainersCommand } from "./commands/maintainers.js";
|
|
12
13
|
import { networksCommand } from "./commands/networks.js";
|
|
13
14
|
import { projectCommand } from "./commands/project.js";
|
|
@@ -46,6 +47,7 @@ program.addCommand(projectsCommand);
|
|
|
46
47
|
program.addCommand(upCommand);
|
|
47
48
|
program.addCommand(downCommand);
|
|
48
49
|
program.addCommand(ejectCommand);
|
|
50
|
+
program.addCommand(importCommand);
|
|
49
51
|
program.addCommand(statusCommand);
|
|
50
52
|
program.addCommand(stackCommand);
|
|
51
53
|
program.addCommand(resourceCommand);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
/**
|
|
4
|
+
* The importer lives in its own repo so detectors can ship without a CLI release. Until it is
|
|
5
|
+
* published to npm it is run from git; `TDK_IMPORT_PACKAGE` overrides the package spec.
|
|
6
|
+
*/
|
|
7
|
+
export const IMPORT_PACKAGE = "github:tdk-landscape/tdk-import";
|
|
8
|
+
export function importInvocation(args, env = process.env, platform = process.platform) {
|
|
9
|
+
const pkg = env.TDK_IMPORT_PACKAGE || IMPORT_PACKAGE;
|
|
10
|
+
return {
|
|
11
|
+
command: platform === "win32" ? "npx.cmd" : "npx",
|
|
12
|
+
args: ["--yes", pkg, ...args],
|
|
13
|
+
shell: platform === "win32",
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** Runs tdk-import with the caller's terminal and resolves to its exit code. */
|
|
17
|
+
export function runImport(args, spawnFn = spawn) {
|
|
18
|
+
const invocation = importInvocation(args);
|
|
19
|
+
return new Promise((resolve) => {
|
|
20
|
+
const child = spawnFn(invocation.command, invocation.args, {
|
|
21
|
+
stdio: "inherit",
|
|
22
|
+
shell: invocation.shell,
|
|
23
|
+
});
|
|
24
|
+
child.on("error", (err) => {
|
|
25
|
+
console.error(`tdk import: could not run npx (${err.message}). Install Node.js/npm and retry.`);
|
|
26
|
+
resolve(127);
|
|
27
|
+
});
|
|
28
|
+
child.on("close", (code) => resolve(code ?? 1));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export const importCommand = new Command("import")
|
|
32
|
+
.description("Import the services a directory describes (runs tdk-import)")
|
|
33
|
+
.argument("[args...]", "Passed to tdk-import: [dir] --dry-run --yes --force --only <ids>")
|
|
34
|
+
.allowUnknownOption()
|
|
35
|
+
.helpOption(false)
|
|
36
|
+
.action(async (args) => {
|
|
37
|
+
process.exitCode = await runImport(args);
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=import.js.map
|
package/cli/package.json
CHANGED
|
@@ -233,7 +233,12 @@ def _apply_manifest_defaults(manifest, resource_path):
|
|
|
233
233
|
# Validate custom dockerfile exists if specified
|
|
234
234
|
if 'dockerfile' in result:
|
|
235
235
|
custom_dockerfile = result['dockerfile']
|
|
236
|
-
|
|
236
|
+
# With a bring-your-own buildContext the dockerfile is relative to that context.
|
|
237
|
+
build_context = result.get('buildContext')
|
|
238
|
+
if build_context and build_context != '.':
|
|
239
|
+
dockerfile_path = resource_path + '/' + build_context + '/' + custom_dockerfile
|
|
240
|
+
else:
|
|
241
|
+
dockerfile_path = resource_path + '/' + custom_dockerfile
|
|
237
242
|
# BUG FIX: Run check from project root since Tilt may run from .tdk/.tdk-out/
|
|
238
243
|
project_root = os.environ.get('TDK_PROJECT_ROOT', '')
|
|
239
244
|
if project_root:
|
|
@@ -162,6 +162,10 @@
|
|
|
162
162
|
"description": "Custom Dockerfile path relative to resource directory. Optional for bring-your-own type.",
|
|
163
163
|
"type": "string"
|
|
164
164
|
},
|
|
165
|
+
"buildContext": {
|
|
166
|
+
"description": "Docker build context for a bring-your-own resource, relative to the resource directory. Defaults to the resource directory. When set, dockerfile is relative to this context.",
|
|
167
|
+
"type": "string"
|
|
168
|
+
},
|
|
165
169
|
"exposeViaProxy": {
|
|
166
170
|
"description": "Whether this bring-your-own resource receives a Traefik route. Defaults to true.",
|
|
167
171
|
"type": "boolean"
|
|
@@ -207,6 +207,12 @@ def _generate_single_backend_entry(resource_path, resource_name, res, manifest,
|
|
|
207
207
|
# context instead of the project root used by generated TDK apps.
|
|
208
208
|
context_prefix = '/'.join(['..'] * (len(resource_path.split('/')) + 1))
|
|
209
209
|
build_context = context_prefix + '/' + full_resource_path
|
|
210
|
+
# `buildContext` (relative to the service directory) moves the context
|
|
211
|
+
# to the source tree an imported Dockerfile lives in; `dockerfile` is then
|
|
212
|
+
# relative to that context, as in Compose.
|
|
213
|
+
custom_context = manifest.get('buildContext')
|
|
214
|
+
if custom_context and custom_context != '.':
|
|
215
|
+
build_context = build_context + '/' + custom_context
|
|
210
216
|
dockerfile = manifest.get('dockerfile', 'Dockerfile')
|
|
211
217
|
if dockerfile.startswith('./'):
|
|
212
218
|
dockerfile = dockerfile[2:]
|