@catladder/cli 3.32.0 → 3.33.0

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/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "3.32.0",
56
+ "version": "3.33.0",
57
57
  "scripts": {
58
58
  "lint": "eslint \"src/**/*.ts\"",
59
59
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
@@ -1,21 +1,27 @@
1
1
  import { getProjectConfig } from "../../config/getProjectConfig";
2
2
  import { printVariables } from "./printVariables";
3
3
  import type { Choice } from "./types";
4
+ import { printVerboseBanner } from "./verboseBanner";
4
5
  import { writeDotEnvFiles } from "./writeDotEnvFiles";
5
6
  import { writeDTsFiles } from "./writeEnvDTs";
6
7
  import {
7
- FileWriter,
8
8
  createCatenvContext,
9
9
  generatePipelineFiles,
10
10
  } from "@catladder/pipeline";
11
11
 
12
- export default async (choice?: Choice) => {
12
+ type Options = {
13
+ verbose?: boolean;
14
+ };
15
+ export default async (choice?: Choice, options?: Options) => {
13
16
  const config = await getProjectConfig();
14
17
  if (!config) {
15
18
  return;
16
19
  }
17
20
 
18
21
  const context = createCatenvContext(config);
22
+ if (options?.verbose) {
23
+ printVerboseBanner();
24
+ }
19
25
 
20
26
  await Promise.all([
21
27
  generatePipelineFiles(context, config.pipelineType ?? "gitlab"),
@@ -0,0 +1,33 @@
1
+ import {
2
+ getEnvironment,
3
+ getProjectConfig,
4
+ } from "../../config/getProjectConfig";
5
+
6
+ export const printVerboseBanner = async () => {
7
+ const config = await getProjectConfig();
8
+ if (!config) {
9
+ return;
10
+ }
11
+
12
+ const allCompontsWithPorts = await Promise.all(
13
+ Object.keys(config.components).map(async (componentName) => {
14
+ const environment = await getEnvironment("local", componentName);
15
+ const port = environment.envVars.PORT;
16
+ if (!port) {
17
+ return null;
18
+ }
19
+ return `${componentName}: http://localhost:${port}`;
20
+ }),
21
+ ).then((lines) => lines.filter(Boolean));
22
+
23
+ const lines = [
24
+ "catenv",
25
+ "-------",
26
+ "running on:",
27
+ "",
28
+ ...allCompontsWithPorts,
29
+ ];
30
+ for (const line of lines) {
31
+ console.log(line);
32
+ }
33
+ };
package/src/catenv.ts CHANGED
@@ -9,12 +9,16 @@ if (args.some((arg) => helpFlags.includes(arg))) {
9
9
  const docLink =
10
10
  "https://git.panter.ch/catladder/catladder/-/blob/main/docs/1_VARS.md";
11
11
  console.log(
12
- `\nUsage: catenv [env|env:component]\n\nEnv variable and catenv documentation:\n${docLink}`,
12
+ `\nUsage: catenv [env|env:component] [-v|--verbose]\n\nEnv variable and catenv documentation:\n${docLink}`,
13
13
  );
14
14
  process.exit(0);
15
15
  }
16
16
 
17
- catenv(args[0] ? parseChoice(args[0]) : null).then(() => {
17
+ const verbose = args.some((arg) => arg === "-v" || arg === "--verbose");
18
+ // choise arg is deprecated and will be removed in the future
19
+ const choiceArg = args.find((arg) => arg !== "-v" && arg !== "--verbose");
20
+
21
+ catenv(choiceArg ? parseChoice(choiceArg) : null, { verbose }).then(() => {
18
22
  // we have to exit manually, because we have some file watches
19
23
  process.exit();
20
24
  });