@cenk1cenk2/oclif-common 6.4.12 → 6.4.13

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.
@@ -5,12 +5,10 @@ import { Help } from "@oclif/core";
5
5
 
6
6
  //#region src/hooks/not-found.hook.ts
7
7
  const notFoundHook = async (opts) => {
8
- const app = await CliModule.create(CliModule.forMinimum());
9
- const logger = await app.resolve(LoggerService);
8
+ const logger = await (await CliModule.create(CliModule.forMinimum())).resolve(LoggerService);
10
9
  logger.error("Command not found. Take a look at help. You can also use --[h]elp flag for subcommands.");
11
10
  logger.direct("");
12
- const help = new Help(opts.config);
13
- await help.showHelp(["--all"]);
11
+ await new Help(opts.config).showHelp(["--all"]);
14
12
  opts.context.exit(127);
15
13
  };
16
14
 
@@ -73,7 +73,7 @@ let ConfigService = class ConfigService$1 {
73
73
  const env = typeof definition === "string" ? await this.parser.read(definition) : definition;
74
74
  this.logger.trace("Environment variable extensions read: %o", definition);
75
75
  const iter = async (obj, parent) => {
76
- const data = await Promise.all(Object.entries(obj).map(async ([key, value]) => {
76
+ return (await Promise.all(Object.entries(obj).map(async ([key, value]) => {
77
77
  const location = [...parent ?? [], key];
78
78
  if (typeof value === "string") return [{
79
79
  key: location,
@@ -85,18 +85,15 @@ let ConfigService = class ConfigService$1 {
85
85
  extensions = await iter(value[ConfigEnvKeys.ELEMENT], [...location, ConfigEnvKeys.ELEMENT]);
86
86
  this.logger.trace("Expanding location to elements: %s -> %s", location, extensions.map((extension) => extension.key.join(".")).join(", "));
87
87
  }
88
- if (ConfigEnvKeys.NAME in value && ConfigEnvKeys.PARSER in value) {
89
- const variable = [{
90
- key: location,
91
- env: value[ConfigEnvKeys.NAME],
92
- parser: value[ConfigEnvKeys.PARSER],
93
- extensions
94
- }];
95
- return variable;
96
- } else return iter(value, location);
88
+ if (ConfigEnvKeys.NAME in value && ConfigEnvKeys.PARSER in value) return [{
89
+ key: location,
90
+ env: value[ConfigEnvKeys.NAME],
91
+ parser: value[ConfigEnvKeys.PARSER],
92
+ extensions
93
+ }];
94
+ else return iter(value, location);
97
95
  }
98
- }));
99
- return data.flatMap((d) => d).filter(Boolean);
96
+ }))).flatMap((d) => d).filter(Boolean);
100
97
  };
101
98
  const parsed = await iter(env);
102
99
  const cb = (config$1, variable, data) => {
@@ -110,15 +107,14 @@ let ConfigService = class ConfigService$1 {
110
107
  return op.set(config$1, variable.key, data);
111
108
  };
112
109
  parsed.forEach((variable) => {
113
- let data;
114
- data = process.env[variable.env];
110
+ let data = process.env[variable.env];
115
111
  if (data) config = cb(config, variable, data);
116
112
  if (variable.extensions && variable.extensions.length > 0) {
117
113
  const timeout = 6e4;
118
114
  const startedAt = Date.now();
119
115
  for (let i = 0; i < Infinity; i++) {
120
116
  if (Date.now() - startedAt > timeout) throw new Error(`Timed-out in ${timeout}ms while looking for element environment variables.`);
121
- const extensions = variable.extensions.map((extension) => {
117
+ if (variable.extensions.map((extension) => {
122
118
  const clone = JSON.parse(JSON.stringify(extension));
123
119
  clone.env = clone.env.replace(ConfigEnvKeys.ELEMENT_REPLACER, i.toString());
124
120
  clone.key[clone.key.findIndex((value) => value === ConfigEnvKeys.ELEMENT)] = i.toString();
@@ -129,8 +125,7 @@ let ConfigService = class ConfigService$1 {
129
125
  }
130
126
  config = cb(config, clone, data);
131
127
  return true;
132
- }).filter(Boolean);
133
- if (extensions.length === 0) {
128
+ }).filter(Boolean).length === 0) {
134
129
  this.logger.trace("No more extensions for environment variables: %s -> %d", variable.key.join("."), i);
135
130
  break;
136
131
  }
@@ -30,16 +30,14 @@ let FileSystemService = class FileSystemService$1 {
30
30
  }
31
31
  async read(file) {
32
32
  try {
33
- const raw = await this.extra.readFile(file, "utf-8");
34
- return raw;
33
+ return await this.extra.readFile(file, "utf-8");
35
34
  } catch (e) {
36
35
  throw new Error(`Error while reading file from "${file}": ${e.message}`);
37
36
  }
38
37
  }
39
38
  readSync(file) {
40
39
  try {
41
- const raw = this.extra.readFileSync(file, "utf-8");
42
- return raw;
40
+ return this.extra.readFileSync(file, "utf-8");
43
41
  } catch (e) {
44
42
  throw new Error(`Error while reading file from "${file}": ${e.message}`);
45
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cenk1cenk2/oclif-common",
3
- "version": "6.4.12",
3
+ "version": "6.4.13",
4
4
  "description": "Oclif common package for oclif2 projects.",
5
5
  "repository": "https://gitlab.kilic.dev/libraries/oclif-tools",
6
6
  "type": "module",
@@ -49,7 +49,7 @@
49
49
  "dependencies": {
50
50
  "@nestjs/common": "^11.1.6",
51
51
  "@nestjs/core": "^11.1.6",
52
- "@oxc-project/runtime": "^0.86.0",
52
+ "@oxc-project/runtime": "^0.87.0",
53
53
  "deepmerge": "^4.3.1",
54
54
  "object-path-immutable": "^4.1.2",
55
55
  "reflect-metadata": "^0.2.1",
@@ -57,7 +57,7 @@
57
57
  },
58
58
  "devDependencies": {
59
59
  "@listr2/manager": "^3.0.3",
60
- "@oclif/core": "^4.5.2",
60
+ "@oclif/core": "^4.5.3",
61
61
  "@types/fs-extra": "^11.0.4",
62
62
  "@types/through": "^0.0.33",
63
63
  "@types/update-notifier": "^6.0.8",