@catladder/cli 1.27.0 → 1.29.1

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
@@ -16,7 +16,7 @@
16
16
  "catladder": "./bin/catladder"
17
17
  },
18
18
  "dependencies": {
19
- "@catladder/pipeline": "1.27.0",
19
+ "@catladder/pipeline": "1.29.1",
20
20
  "@kubernetes/client-node": "^0.16.2",
21
21
  "child-process-promise": "^2.2.1",
22
22
  "command-exists-promise": "^2.0.2",
@@ -55,5 +55,5 @@
55
55
  "eslint": "^8.7.0",
56
56
  "typescript": "^4.5.4"
57
57
  },
58
- "version": "1.27.0"
58
+ "version": "1.29.1"
59
59
  }
@@ -14,21 +14,29 @@ const getCurrentComponentName = async (
14
14
 
15
15
  const sanitizeEnvVarName = (name: string) => name.replace(/[\s\-.]+/g, "_");
16
16
 
17
- const getAllVariablesToPrint = async (config: Config) => {
17
+ const getAllVariablesToPrint = async (
18
+ config: Config,
19
+ choice?: {
20
+ env?: string;
21
+ componentName?: string;
22
+ }
23
+ ) => {
24
+ const env = choice?.env ?? "local";
18
25
  const { components } = config;
19
26
 
20
- const currentComponent = await getCurrentComponentName(components);
27
+ const currentComponent =
28
+ choice?.componentName ?? (await getCurrentComponentName(components));
21
29
 
22
30
  let variables = {};
23
31
  if (currentComponent) {
24
- variables = await getEnvVars(null, "local", currentComponent);
32
+ variables = await getEnvVars(null, env, currentComponent);
25
33
  } else {
26
34
  // when in a monorep and not in a subapp, merge all env vars.
27
35
  // this is not 100% correct, but better than not exporting any vars at all
28
36
  // so we also add prefixed variants
29
37
  variables = await Object.keys(components).reduce(
30
38
  async (acc, componentName) => {
31
- const subappvars = await getEnvVars(null, "local", componentName);
39
+ const subappvars = await getEnvVars(null, env, componentName);
32
40
  return {
33
41
  ...(await acc),
34
42
  ...subappvars,
@@ -46,13 +54,12 @@ const getAllVariablesToPrint = async (config: Config) => {
46
54
  }
47
55
  return variables;
48
56
  };
49
- export default async () => {
57
+ export default async (choice?: { env?: string; componentName?: string }) => {
50
58
  const config = await getProjectConfig();
51
59
  if (!config) {
52
60
  return;
53
61
  }
54
-
55
- const variables = await getAllVariablesToPrint(config);
62
+ const variables = await getAllVariablesToPrint(config, choice);
56
63
 
57
64
  console.log(
58
65
  Object.entries(variables)
package/src/catenv.ts CHANGED
@@ -1,7 +1,11 @@
1
1
  import catenv from "./apps/catenv/catenv";
2
- import { $ } from "zx";
2
+ import { $, argv } from "zx";
3
+ import { parseChoice } from "./config/getProjectConfig";
4
+
5
+ const choice = argv._[0] ? parseChoice(argv._[0]) : null;
6
+
3
7
  $.verbose = false;
4
- catenv().then(() => {
8
+ catenv(choice).then(() => {
5
9
  // we have to exit manually, because we have some file watches
6
10
  process.exit();
7
11
  });
@@ -60,7 +60,7 @@ export const getProjectComponents = async () => {
60
60
  };
61
61
 
62
62
  export const parseChoice = (envComponent: string) => {
63
- const [env, componentName] = envComponent.split(":");
63
+ const [env, componentName] = envComponent.split(":").map((x) => x || null);
64
64
  return { env, componentName };
65
65
  };
66
66