@catladder/cli 2.10.2 → 3.0.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.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEnvConfig = void 0;
4
- const utils_1 = require("../utils");
4
+ const lodash_1 = require("lodash");
5
5
  const getEnvConfig = (config, componentName, env) => {
6
6
  var _a, _b;
7
7
  const defaultConfig = config.components[componentName];
@@ -13,7 +13,19 @@ const getEnvConfig = (config, componentName, env) => {
13
13
  // env is disabled, still return the default config
14
14
  return defaultConfig;
15
15
  }
16
- return (0, utils_1.mergeWithMergingArrays)(defaultConfig, envCustomizations);
16
+ /**
17
+ * env config is merged with default. Arrays are not merged.
18
+ * you can customize this by providing a function that takes the default value as argument
19
+ */
20
+ return (0, lodash_1.mergeWith)({}, defaultConfig, envCustomizations, (defaultValue, customValue) => {
21
+ // check if custom value is a function (and default is not),
22
+ // we currently don't have config options that are functions, but we might in the future
23
+ if (typeof customValue === "function" &&
24
+ typeof defaultValue !== "function") {
25
+ return customValue(defaultValue);
26
+ }
27
+ return undefined;
28
+ });
17
29
  };
18
30
  exports.getEnvConfig = getEnvConfig;
19
31
  //# sourceMappingURL=getEnvConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getEnvConfig.js","sourceRoot":"","sources":["../../../../../pipeline/src/context/getEnvConfig.ts"],"names":[],"mappings":";;;AAEA,oCAAkD;AAE3C,MAAM,YAAY,GAAG,CAC1B,MAAc,EACd,aAAqB,EACrB,GAAW,EACa,EAAE;;IAC1B,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACvD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,aAAa,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,iBAAiB,GAAG,MAAA,MAAA,aAAa,CAAC,GAAG,0CAAG,GAAG,CAAC,mCAAI,EAAE,CAAC;IACzD,IAAI,iBAAiB,KAAK,KAAK,EAAE,CAAC;QAChC,mDAAmD;QACnD,OAAO,aAAa,CAAC;IACvB,CAAC;IACD,OAAO,IAAA,8BAAsB,EAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;AAClE,CAAC,CAAC;AAhBW,QAAA,YAAY,gBAgBvB"}
1
+ {"version":3,"file":"getEnvConfig.js","sourceRoot":"","sources":["../../../../../pipeline/src/context/getEnvConfig.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAG5B,MAAM,YAAY,GAAG,CAC1B,MAAc,EACd,aAAqB,EACrB,GAAW,EACa,EAAE;;IAC1B,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACvD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,aAAa,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,iBAAiB,GAAG,MAAA,MAAA,aAAa,CAAC,GAAG,0CAAG,GAAG,CAAC,mCAAI,EAAE,CAAC;IACzD,IAAI,iBAAiB,KAAK,KAAK,EAAE,CAAC;QAChC,mDAAmD;QACnD,OAAO,aAAa,CAAC;IACvB,CAAC;IACD;;;OAGG;IACH,OAAO,IAAA,kBAAS,EACd,EAAE,EACF,aAAa,EACb,iBAAiB,EACjB,CAAC,YAAY,EAAE,WAAW,EAAE,EAAE;QAC5B,4DAA4D;QAC5D,wFAAwF;QACxF,IACE,OAAO,WAAW,KAAK,UAAU;YACjC,OAAO,YAAY,KAAK,UAAU,EAClC,CAAC;YACD,OAAO,WAAW,CAAC,YAAY,CAAC,CAAC;QACnC,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AApCW,QAAA,YAAY,gBAoCvB"}
@@ -73,6 +73,10 @@ export type DevLocalEnvConfig = {
73
73
  vars?: EnvVars;
74
74
  port?: number;
75
75
  };
76
+ type AddOverrideFunction<T> = {
77
+ [K in keyof T]: T[K] | ((defaultValue: T[K]) => T[K]) | (T[K] extends Record<string, unknown> | undefined ? AddOverrideFunction<T[K]> : never);
78
+ };
79
+ type EnvConfigWithOverride<E extends EnvType = EnvType> = AddOverrideFunction<EnvConfig<E>>;
76
80
  export type EnvConfig<E extends EnvType = EnvType> = {
77
81
  /**
78
82
  * type of the env (stage, prod, review, dev)
@@ -84,18 +88,18 @@ export type EnvConfig<E extends EnvType = EnvType> = {
84
88
  host?: string;
85
89
  } & PartialDeep<DefaultEnvConfig>;
86
90
  export type EnvConfigWithComponent = EnvConfig<EnvType> & ComponentConfig;
87
- export type CustomEnv = EnvConfig & {
91
+ export type CustomEnv = EnvConfigWithOverride & {
88
92
  type: EnvType;
89
93
  };
90
94
  export type Env<C extends ConfigProps = never> = {
91
95
  /**
92
96
  * local is a special env that is only used in local development
93
97
  */
94
- local?: DevLocalEnvConfig;
95
- dev?: EnvConfig<"dev"> | false;
96
- stage?: EnvConfig<"stage"> | false;
97
- review?: EnvConfig<"review"> | false;
98
- prod?: EnvConfig<"prod"> | false;
98
+ local?: AddOverrideFunction<DevLocalEnvConfig>;
99
+ dev?: EnvConfigWithOverride<"dev"> | false;
100
+ stage?: EnvConfigWithOverride<"stage"> | false;
101
+ review?: EnvConfigWithOverride<"review"> | false;
102
+ prod?: EnvConfigWithOverride<"prod"> | false;
99
103
  } & Record<C["CustomEnvs"], CustomEnv> & Record<string, any>;
100
104
  export type ComponentConfig<C extends ConfigProps = never> = {
101
105
  /**
@@ -178,3 +182,4 @@ export type Config<C extends ConfigProps = never> = {
178
182
  */
179
183
  runnerVariables?: Record<string, string>;
180
184
  };
185
+ export {};