@cenk1cenk2/oclif-common 3.0.4 → 3.1.0-beta.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.
Files changed (2) hide show
  1. package/dist/index.js +34 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -647,13 +647,18 @@ var ConfigService = class {
647
647
  if (typeof value === "string") {
648
648
  return [{ key: location, env: value }];
649
649
  } else if (typeof value === "object") {
650
- if ("__name" in value && "__format" in value) {
650
+ const extras = [];
651
+ if ("__element" /* ELEMENT */ in value) {
652
+ extras.push(await iter(value, [...location, "__element" /* ELEMENT */]));
653
+ }
654
+ if ("__name" /* NAME */ in value && "__format" /* PARSER */ in value) {
651
655
  return [
652
656
  {
653
657
  key: location,
654
- env: value.__name,
655
- parser: value.__format
656
- }
658
+ env: value["__name" /* NAME */],
659
+ parser: value["__format" /* PARSER */]
660
+ },
661
+ ...extras
657
662
  ];
658
663
  } else {
659
664
  return iter(value, location);
@@ -678,10 +683,31 @@ var ConfigService = class {
678
683
  throw e;
679
684
  }
680
685
  }
681
- config = import_object_path_immutable.default.update(config, variable.key, () => {
682
- this.logger.trace("Overwriting config with environment variable: %s -> %s", variable.key.join("."), variable.env);
683
- return data;
684
- });
686
+ if (variable.key.includes("__element" /* ELEMENT */)) {
687
+ const timeout = 6e4;
688
+ const startedAt = Date.now();
689
+ for (let i = 0; i < Infinity; i++) {
690
+ if (Date.now() - startedAt > timeout) {
691
+ throw new Error(`Timed-out in ${timeout}ms while looking for element environment variables.`);
692
+ }
693
+ data = process.env[variable.env.replace("${i}", i.toString())];
694
+ if (!data) {
695
+ this.logger.trace("No more variable available: %s -> %d", variable.env, i);
696
+ break;
697
+ }
698
+ const clone = JSON.parse(JSON.stringify(variable.key));
699
+ clone[clone.findIndex("__element" /* ELEMENT */)] = i;
700
+ config = import_object_path_immutable.default.update(config, clone, () => {
701
+ this.logger.trace("Overwriting config with element environment variable: %s -> %s", clone.join("."), variable.env);
702
+ return data;
703
+ });
704
+ }
705
+ } else {
706
+ config = import_object_path_immutable.default.update(config, variable.key, () => {
707
+ this.logger.trace("Overwriting config with environment variable: %s -> %s", variable.key.join("."), variable.env);
708
+ return data;
709
+ });
710
+ }
685
711
  })
686
712
  );
687
713
  return config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cenk1cenk2/oclif-common",
3
- "version": "3.0.4",
3
+ "version": "3.1.0-beta.1",
4
4
  "description": "Oclif common package for oclif2 projects.",
5
5
  "repository": "https://gitlab.kilic.dev/libraries/oclif-tools",
6
6
  "author": {