@tdk-landscape/tdk-cli-core 1.3.107 → 1.3.108

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.
@@ -4,7 +4,7 @@ import { Command } from "commander";
4
4
  import { readProjectConfig } from "../generator/template-engine.js";
5
5
  import { getStackEmoji } from "../utils/constants.js";
6
6
  import { createDiscoveryContext } from "../utils/discovery-context.js";
7
- import { logVerbose, requireProjectRoot } from "../utils/errors.js";
7
+ import { errorFactories, logVerbose, requireProjectRoot } from "../utils/errors.js";
8
8
  import { colorizeByStatus, DEFAULT_BOX_WIDTH, formatBoxLine, formatPadded, getStatusIcon, printBoxedHeader, } from "../utils/formatting.js";
9
9
  import { readSavedHostPortPlan } from "../utils/host-port-config.js";
10
10
  import { createHostPortPlan } from "../utils/host-port-plan.js";
@@ -12,6 +12,7 @@ import { createMachineEnvelope, writeMachineError } from "../utils/machine-outpu
12
12
  import { findProjectRoot } from "../utils/paths.js";
13
13
  import { checkPortStatus } from "../utils/port-assignment.js";
14
14
  import { isApiServiceType } from "../utils/resource-kind.js";
15
+ import { stackExists } from "../utils/services.js";
15
16
  import { isValidPort, sanitizeForShell } from "../utils/validation.js";
16
17
  import { findOnPath } from "../utils/which.js";
17
18
  function execSafe(command, args, options = {}) {
@@ -169,10 +170,16 @@ export const networksCommand = new Command("networks")
169
170
  if (!projectRoot) {
170
171
  throw new Error("Could not find project root (no .tdk/project.json found)");
171
172
  }
173
+ const discovery = createDiscoveryContext();
174
+ if (options.stack && !stackExists(options.stack, discovery.resources)) {
175
+ const error = errorFactories.stackNotFound(options.stack);
176
+ if (options.json || options.jsonLegacy)
177
+ throw error;
178
+ error.exit();
179
+ }
172
180
  const savedPlan = readSavedHostPortPlan(projectRoot);
173
181
  const hostPortPlan = savedPlan ?? (await createHostPortPlan());
174
182
  const httpPort = hostPortPlan.ingressHttp;
175
- const discovery = createDiscoveryContext();
176
183
  const baseDomain = determineDefaultDomain();
177
184
  const bareDomain = baseDomain.replace(/^(app|api)\./, "");
178
185
  const appDomain = `app.${bareDomain}`;
@@ -1,10 +1,11 @@
1
1
  import chalk from "chalk";
2
2
  import { Command } from "commander";
3
3
  import { createDiscoveryContext } from "../utils/discovery-context.js";
4
- import { requireProjectRoot, runCommand } from "../utils/errors.js";
4
+ import { errorFactories, requireProjectRoot, runCommand } from "../utils/errors.js";
5
5
  import { formatCount, showAllSatisfyCondition, showDetail, showEmptyState, showStep, } from "../utils/formatting.js";
6
6
  import { createMachineEnvelope, writeMachineError } from "../utils/machine-output.js";
7
7
  import { findProjectRoot } from "../utils/paths.js";
8
+ import { stackExists } from "../utils/services.js";
8
9
  export const resourcesCommand = new Command("resources")
9
10
  .description("List all resources (services) in the project")
10
11
  .option("-v, --verbose", "Show detailed information about each resource", false)
@@ -23,6 +24,12 @@ export const resourcesCommand = new Command("resources")
23
24
  requireProjectRoot();
24
25
  }
25
26
  const discovery = createDiscoveryContext();
27
+ if (options.stack && !stackExists(options.stack, discovery.resources)) {
28
+ const error = errorFactories.stackNotFound(options.stack);
29
+ if (options.json)
30
+ writeMachineError(error);
31
+ error.exit();
32
+ }
26
33
  const withoutStackFilter = options.noStack || options.stack === false;
27
34
  let resources = discovery.resources;
28
35
  if (options.stack) {
@@ -204,9 +204,9 @@ export function getResourcesForStack(stackName) {
204
204
  const allResources = discoverResources();
205
205
  return allResources.filter((r) => r.stack === stackName);
206
206
  }
207
- export function stackExists(stackName) {
208
- const resources = getResourcesForStack(stackName);
209
- return resources.length > 0;
207
+ export function stackExists(stackName, resources) {
208
+ const resourcesToSearch = resources ?? discoverResources();
209
+ return resourcesToSearch.some((resource) => resource.stack === stackName);
210
210
  }
211
211
  /**
212
212
  * Cache TTL in milliseconds
package/cli/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tdk-cli-internal",
3
3
  "private": true,
4
- "version": "1.3.107",
4
+ "version": "1.3.108",
5
5
  "description": "TDK CLI — start services on your laptop.",
6
6
  "keywords": [
7
7
  "tdk",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tdk-landscape/tdk-cli-core",
3
- "version": "1.3.107",
3
+ "version": "1.3.108",
4
4
  "description": "TDK CLI — start services on your laptop.",
5
5
  "homepage": "https://tdk-landscape.github.io/tdk-website",
6
6
  "repository": {