@tsed/cli-core 6.0.0-alpha.9 → 6.0.0-beta.2

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 (150) hide show
  1. package/lib/esm/CliCore.js +7 -12
  2. package/lib/esm/decorators/command.js +0 -1
  3. package/lib/esm/decorators/index.js +0 -1
  4. package/lib/esm/decorators/on.js +0 -1
  5. package/lib/esm/decorators/onAdd.js +0 -1
  6. package/lib/esm/decorators/onExec.js +0 -1
  7. package/lib/esm/decorators/onPostInstall.js +0 -1
  8. package/lib/esm/decorators/onPrompt.js +0 -1
  9. package/lib/esm/domains/CliError.js +0 -1
  10. package/lib/esm/domains/CommandStoreKeys.js +0 -1
  11. package/lib/esm/index.js +0 -1
  12. package/lib/esm/interfaces/CliDefaultOptions.js +0 -1
  13. package/lib/esm/interfaces/CommandMetadata.js +0 -1
  14. package/lib/esm/interfaces/CommandParameters.js +0 -1
  15. package/lib/esm/interfaces/CommandProvider.js +0 -1
  16. package/lib/esm/interfaces/PackageJson.js +0 -1
  17. package/lib/esm/interfaces/ProjectPreferences.js +0 -1
  18. package/lib/esm/interfaces/Tasks.js +0 -1
  19. package/lib/esm/interfaces/index.js +0 -1
  20. package/lib/esm/packageManagers/PackageManagersModule.js +3 -4
  21. package/lib/esm/packageManagers/index.js +0 -1
  22. package/lib/esm/packageManagers/supports/BaseManager.js +1 -5
  23. package/lib/esm/packageManagers/supports/BunManager.js +0 -1
  24. package/lib/esm/packageManagers/supports/NpmManager.js +0 -1
  25. package/lib/esm/packageManagers/supports/PNpmManager.js +0 -1
  26. package/lib/esm/packageManagers/supports/YarnBerryManager.js +0 -1
  27. package/lib/esm/packageManagers/supports/YarnManager.js +0 -1
  28. package/lib/esm/services/CliConfiguration.js +0 -1
  29. package/lib/esm/services/CliDockerComposeYaml.js +7 -15
  30. package/lib/esm/services/CliExeca.js +0 -1
  31. package/lib/esm/services/CliFs.js +0 -1
  32. package/lib/esm/services/CliHooks.js +5 -9
  33. package/lib/esm/services/CliHttpClient.js +6 -7
  34. package/lib/esm/services/CliHttpLogClient.js +2 -6
  35. package/lib/esm/services/CliLoadFile.js +3 -10
  36. package/lib/esm/services/CliPackageJson.js +4 -2
  37. package/lib/esm/services/CliPlugins.js +10 -30
  38. package/lib/esm/services/CliProxyAgent.js +11 -19
  39. package/lib/esm/services/CliRunScript.js +3 -8
  40. package/lib/esm/services/CliService.js +30 -49
  41. package/lib/esm/services/CliYaml.js +5 -7
  42. package/lib/esm/services/NpmRegistryClient.js +5 -7
  43. package/lib/esm/services/ProjectPackageJson.js +23 -24
  44. package/lib/esm/services/Renderer.js +5 -15
  45. package/lib/esm/services/index.js +0 -1
  46. package/lib/esm/utils/coerce.js +0 -1
  47. package/lib/esm/utils/createInjector.js +11 -12
  48. package/lib/esm/utils/createTasksRunner.js +1 -2
  49. package/lib/esm/utils/getCommandMetadata.js +1 -2
  50. package/lib/esm/utils/getTemplateDirectory.js +0 -1
  51. package/lib/esm/utils/hbs/array.js +0 -1
  52. package/lib/esm/utils/hbs/collection.js +0 -1
  53. package/lib/esm/utils/hbs/comparison.js +0 -1
  54. package/lib/esm/utils/hbs/index.js +0 -1
  55. package/lib/esm/utils/hbs/object.js +0 -1
  56. package/lib/esm/utils/hbs/switch.js +0 -1
  57. package/lib/esm/utils/index.js +0 -1
  58. package/lib/esm/utils/isValidVersion.js +0 -1
  59. package/lib/esm/utils/loadPlugins.js +16 -16
  60. package/lib/esm/utils/logToCurl.js +0 -1
  61. package/lib/esm/utils/mapCommanderArgs.js +0 -1
  62. package/lib/esm/utils/mapCommanderOptions.js +4 -2
  63. package/lib/esm/utils/parseOption.js +0 -1
  64. package/lib/esm/utils/patchCommander.js +0 -1
  65. package/lib/esm/utils/renderer/insertAfter.js +0 -1
  66. package/lib/esm/utils/renderer/insertImport.js +0 -1
  67. package/lib/esm/utils/resolveConfiguration.js +0 -1
  68. package/lib/esm/utils/streamToObservable.js +0 -1
  69. package/lib/types/packageManagers/PackageManagersModule.d.ts +1 -1
  70. package/lib/types/services/CliExeca.d.ts +6 -5
  71. package/lib/types/services/CliHooks.d.ts +0 -2
  72. package/lib/types/services/CliPackageJson.d.ts +2 -1
  73. package/lib/types/services/CliPlugins.d.ts +2 -2
  74. package/lib/types/services/CliProxyAgent.d.ts +4 -3
  75. package/lib/types/services/CliRunScript.d.ts +0 -2
  76. package/lib/types/services/CliService.d.ts +4 -5
  77. package/lib/types/services/ProjectPackageJson.d.ts +2 -4
  78. package/lib/types/services/Renderer.d.ts +3 -4
  79. package/lib/types/utils/getCommandMetadata.d.ts +2 -2
  80. package/lib/types/utils/loadPlugins.d.ts +1 -2
  81. package/lib/types/utils/mapCommanderOptions.d.ts +1 -1
  82. package/package.json +10 -11
  83. package/lib/esm/CliCore.js.map +0 -1
  84. package/lib/esm/decorators/command.js.map +0 -1
  85. package/lib/esm/decorators/index.js.map +0 -1
  86. package/lib/esm/decorators/on.js.map +0 -1
  87. package/lib/esm/decorators/onAdd.js.map +0 -1
  88. package/lib/esm/decorators/onExec.js.map +0 -1
  89. package/lib/esm/decorators/onPostInstall.js.map +0 -1
  90. package/lib/esm/decorators/onPrompt.js.map +0 -1
  91. package/lib/esm/domains/CliError.js.map +0 -1
  92. package/lib/esm/domains/CommandStoreKeys.js.map +0 -1
  93. package/lib/esm/index.js.map +0 -1
  94. package/lib/esm/interfaces/CliDefaultOptions.js.map +0 -1
  95. package/lib/esm/interfaces/CommandMetadata.js.map +0 -1
  96. package/lib/esm/interfaces/CommandParameters.js.map +0 -1
  97. package/lib/esm/interfaces/CommandProvider.js.map +0 -1
  98. package/lib/esm/interfaces/PackageJson.js.map +0 -1
  99. package/lib/esm/interfaces/ProjectPreferences.js.map +0 -1
  100. package/lib/esm/interfaces/Tasks.js.map +0 -1
  101. package/lib/esm/interfaces/index.js.map +0 -1
  102. package/lib/esm/packageManagers/PackageManagersModule.js.map +0 -1
  103. package/lib/esm/packageManagers/index.js.map +0 -1
  104. package/lib/esm/packageManagers/supports/BaseManager.js.map +0 -1
  105. package/lib/esm/packageManagers/supports/BunManager.js.map +0 -1
  106. package/lib/esm/packageManagers/supports/NpmManager.js.map +0 -1
  107. package/lib/esm/packageManagers/supports/PNpmManager.js.map +0 -1
  108. package/lib/esm/packageManagers/supports/YarnBerryManager.js.map +0 -1
  109. package/lib/esm/packageManagers/supports/YarnManager.js.map +0 -1
  110. package/lib/esm/services/CliConfiguration.js.map +0 -1
  111. package/lib/esm/services/CliDockerComposeYaml.js.map +0 -1
  112. package/lib/esm/services/CliExeca.js.map +0 -1
  113. package/lib/esm/services/CliFs.js.map +0 -1
  114. package/lib/esm/services/CliHooks.js.map +0 -1
  115. package/lib/esm/services/CliHttpClient.js.map +0 -1
  116. package/lib/esm/services/CliHttpLogClient.js.map +0 -1
  117. package/lib/esm/services/CliLoadFile.js.map +0 -1
  118. package/lib/esm/services/CliPackageJson.js.map +0 -1
  119. package/lib/esm/services/CliPlugins.js.map +0 -1
  120. package/lib/esm/services/CliProxyAgent.js.map +0 -1
  121. package/lib/esm/services/CliRunScript.js.map +0 -1
  122. package/lib/esm/services/CliService.js.map +0 -1
  123. package/lib/esm/services/CliYaml.js.map +0 -1
  124. package/lib/esm/services/NpmRegistryClient.js.map +0 -1
  125. package/lib/esm/services/ProjectPackageJson.js.map +0 -1
  126. package/lib/esm/services/Renderer.js.map +0 -1
  127. package/lib/esm/services/index.js.map +0 -1
  128. package/lib/esm/utils/coerce.js.map +0 -1
  129. package/lib/esm/utils/createInjector.js.map +0 -1
  130. package/lib/esm/utils/createTasksRunner.js.map +0 -1
  131. package/lib/esm/utils/getCommandMetadata.js.map +0 -1
  132. package/lib/esm/utils/getTemplateDirectory.js.map +0 -1
  133. package/lib/esm/utils/hbs/array.js.map +0 -1
  134. package/lib/esm/utils/hbs/collection.js.map +0 -1
  135. package/lib/esm/utils/hbs/comparison.js.map +0 -1
  136. package/lib/esm/utils/hbs/index.js.map +0 -1
  137. package/lib/esm/utils/hbs/object.js.map +0 -1
  138. package/lib/esm/utils/hbs/switch.js.map +0 -1
  139. package/lib/esm/utils/index.js.map +0 -1
  140. package/lib/esm/utils/isValidVersion.js.map +0 -1
  141. package/lib/esm/utils/loadPlugins.js.map +0 -1
  142. package/lib/esm/utils/logToCurl.js.map +0 -1
  143. package/lib/esm/utils/mapCommanderArgs.js.map +0 -1
  144. package/lib/esm/utils/mapCommanderOptions.js.map +0 -1
  145. package/lib/esm/utils/parseOption.js.map +0 -1
  146. package/lib/esm/utils/patchCommander.js.map +0 -1
  147. package/lib/esm/utils/renderer/insertAfter.js.map +0 -1
  148. package/lib/esm/utils/renderer/insertImport.js.map +0 -1
  149. package/lib/esm/utils/resolveConfiguration.js.map +0 -1
  150. package/lib/esm/utils/streamToObservable.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { __decorate, __metadata } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { classOf } from "@tsed/core";
3
- import { Constant, DIContext, getContext, Inject, Injectable, InjectorService, Provider, runInContext } from "@tsed/di";
3
+ import { $emit, configuration, constant, destroyInjector, DIContext, getContext, inject, Injectable, injector, logger, Provider, runInContext } from "@tsed/di";
4
4
  import { Argument, Command } from "commander";
5
5
  import Inquirer from "inquirer";
6
6
  // @ts-ignore
@@ -10,16 +10,20 @@ import { CommandStoreKeys } from "../domains/CommandStoreKeys.js";
10
10
  import { PackageManagersModule } from "../packageManagers/index.js";
11
11
  import { createSubTasks, createTasksRunner } from "../utils/createTasksRunner.js";
12
12
  import { getCommandMetadata } from "../utils/getCommandMetadata.js";
13
+ import { mapCommanderOptions } from "../utils/index.js";
13
14
  import { mapCommanderArgs } from "../utils/mapCommanderArgs.js";
14
- import { mapCommanderOptions } from "../utils/mapCommanderOptions.js";
15
15
  import { parseOption } from "../utils/parseOption.js";
16
16
  import { CliHooks } from "./CliHooks.js";
17
17
  import { ProjectPackageJson } from "./ProjectPackageJson.js";
18
18
  Inquirer.registerPrompt("autocomplete", inquirer_autocomplete_prompt);
19
19
  let CliService = class CliService {
20
20
  constructor() {
21
+ this.reinstallAfterRun = constant("project.reinstallAfterRun", false);
21
22
  this.program = new Command();
22
- this.reinstallAfterRun = false;
23
+ this.pkg = constant("pkg", { version: "1.0.0" });
24
+ this.hooks = inject(CliHooks);
25
+ this.projectPkg = inject(ProjectPackageJson);
26
+ this.packageManagers = inject(PackageManagersModule);
23
27
  this.commands = new Map();
24
28
  }
25
29
  /**
@@ -40,7 +44,7 @@ let CliService = class CliService {
40
44
  */
41
45
  runLifecycle(cmdName, data = {}, $ctx) {
42
46
  return runInContext($ctx, async () => {
43
- await this.injector.emit("$loadPackageJson");
47
+ await $emit("$loadPackageJson");
44
48
  data = await this.beforePrompt(cmdName, data);
45
49
  $ctx.set("data", data);
46
50
  data = await this.prompt(cmdName, data);
@@ -54,12 +58,12 @@ let CliService = class CliService {
54
58
  await this.exec(cmdName, data, $ctx);
55
59
  }
56
60
  catch (er) {
57
- await this.injector.emit("$onFinish", er);
58
- await this.injector.destroy();
61
+ await $emit("$onFinish", er);
62
+ await destroyInjector();
59
63
  throw er;
60
64
  }
61
- await this.injector.emit("$onFinish");
62
- await this.injector.destroy();
65
+ await $emit("$onFinish");
66
+ await destroyInjector();
63
67
  }
64
68
  async exec(cmdName, data, $ctx) {
65
69
  const initialTasks = await this.getTasks(cmdName, data);
@@ -83,7 +87,7 @@ let CliService = class CliService {
83
87
  */
84
88
  async beforePrompt(cmdName, ctx = {}) {
85
89
  const provider = this.commands.get(cmdName);
86
- const instance = this.injector.get(provider.useClass);
90
+ const instance = inject(provider.useClass);
87
91
  const verbose = ctx.verbose;
88
92
  if (instance.$beforePrompt) {
89
93
  ctx = await instance.$beforePrompt(JSON.parse(JSON.stringify(ctx)));
@@ -98,7 +102,7 @@ let CliService = class CliService {
98
102
  */
99
103
  async prompt(cmdName, ctx = {}) {
100
104
  const provider = this.commands.get(cmdName);
101
- const instance = this.injector.get(provider.useClass);
105
+ const instance = inject(provider.useClass);
102
106
  if (instance.$prompt) {
103
107
  const questions = [
104
108
  ...(await instance.$prompt(ctx)),
@@ -121,7 +125,7 @@ let CliService = class CliService {
121
125
  async getTasks(cmdName, data) {
122
126
  const $ctx = getContext();
123
127
  const provider = this.commands.get(cmdName);
124
- const instance = this.injector.get(provider.token);
128
+ const instance = inject(provider.token);
125
129
  data = this.mapData(cmdName, data, $ctx);
126
130
  if (instance.$beforeExec) {
127
131
  await instance.$beforeExec(data);
@@ -130,7 +134,7 @@ let CliService = class CliService {
130
134
  }
131
135
  async getPostInstallTasks(cmdName, data) {
132
136
  const provider = this.commands.get(cmdName);
133
- const instance = this.injector.get(provider.useClass);
137
+ const instance = inject(provider.useClass);
134
138
  data = this.mapData(cmdName, data, getContext());
135
139
  return [
136
140
  ...(instance.$postInstall ? await instance.$postInstall(data) : []),
@@ -144,10 +148,10 @@ let CliService = class CliService {
144
148
  return this.commands.get(name).command;
145
149
  }
146
150
  let cmd = this.program.command(name);
147
- const onAction = (...commanderArgs) => {
151
+ const onAction = (commandName) => {
148
152
  const [, ...rawArgs] = cmd.args;
149
- const mappedArgs = mapCommanderArgs(args, commanderArgs);
150
- const allOpts = mapCommanderOptions(this.program.commands);
153
+ const mappedArgs = mapCommanderArgs(args, this.program.args.filter((arg) => commandName === arg));
154
+ const allOpts = mapCommanderOptions(commandName, this.program.commands);
151
155
  const data = {
152
156
  ...allOpts,
153
157
  verbose: !!this.program.opts().verbose,
@@ -157,15 +161,15 @@ let CliService = class CliService {
157
161
  };
158
162
  const $ctx = new DIContext({
159
163
  id: v4(),
160
- injector: this.injector,
161
- logger: this.injector.logger,
162
- level: this.injector.logger.level,
164
+ injector: injector(),
165
+ logger: logger(),
166
+ level: logger().level,
163
167
  maxStackSize: 0,
164
168
  platform: "CLI"
165
169
  });
166
170
  $ctx.set("data", data);
167
171
  $ctx.set("command", metadata);
168
- this.injector.settings.set("command.metadata", metadata);
172
+ configuration().set("command.metadata", metadata);
169
173
  return this.runLifecycle(name, data, $ctx);
170
174
  };
171
175
  if (alias) {
@@ -180,21 +184,23 @@ let CliService = class CliService {
180
184
  return cmd;
181
185
  }
182
186
  load() {
183
- this.injector.getProviders("command").forEach((provider) => this.build(provider));
187
+ injector()
188
+ .getProviders("command")
189
+ .forEach((provider) => this.build(provider));
184
190
  }
185
191
  mapData(cmdName, data, $ctx) {
186
192
  const provider = this.commands.get(cmdName);
187
- const instance = this.injector.get(provider.useClass);
193
+ const instance = inject(provider.useClass);
188
194
  const verbose = data.verbose;
189
195
  if (instance.$mapContext) {
190
196
  data = instance.$mapContext(JSON.parse(JSON.stringify(data)));
191
197
  data.verbose = verbose;
192
198
  }
193
199
  if (data.verbose) {
194
- this.injector.logger.level = "debug";
200
+ logger().level = "debug";
195
201
  }
196
202
  else {
197
- this.injector.logger.level = "info";
203
+ logger().level = "info";
198
204
  }
199
205
  data.bindLogger = $ctx.get("command").bindLogger;
200
206
  $ctx.set("data", data);
@@ -249,32 +255,7 @@ let CliService = class CliService {
249
255
  }, cmd);
250
256
  }
251
257
  };
252
- __decorate([
253
- Constant("project.reinstallAfterRun", false),
254
- __metadata("design:type", Object)
255
- ], CliService.prototype, "reinstallAfterRun", void 0);
256
- __decorate([
257
- Constant("pkg", { version: "1.0.0" }),
258
- __metadata("design:type", Object)
259
- ], CliService.prototype, "pkg", void 0);
260
- __decorate([
261
- Inject(),
262
- __metadata("design:type", InjectorService)
263
- ], CliService.prototype, "injector", void 0);
264
- __decorate([
265
- Inject(),
266
- __metadata("design:type", CliHooks)
267
- ], CliService.prototype, "hooks", void 0);
268
- __decorate([
269
- Inject(),
270
- __metadata("design:type", ProjectPackageJson)
271
- ], CliService.prototype, "projectPkg", void 0);
272
- __decorate([
273
- Inject(PackageManagersModule),
274
- __metadata("design:type", PackageManagersModule)
275
- ], CliService.prototype, "packageManagers", void 0);
276
258
  CliService = __decorate([
277
259
  Injectable()
278
260
  ], CliService);
279
261
  export { CliService };
280
- //# sourceMappingURL=CliService.js.map
@@ -1,8 +1,11 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import { Inject, Injectable } from "@tsed/di";
1
+ import { __decorate } from "tslib";
2
+ import { inject, Injectable } from "@tsed/di";
3
3
  import JsYaml from "js-yaml";
4
4
  import { CliFs } from "./CliFs.js";
5
5
  let CliYaml = class CliYaml {
6
+ constructor() {
7
+ this.fs = inject(CliFs);
8
+ }
6
9
  async read(path) {
7
10
  const content = await this.fs.readFile(path, { encoding: "utf8" });
8
11
  return JsYaml.load(content);
@@ -12,12 +15,7 @@ let CliYaml = class CliYaml {
12
15
  return this.fs.writeFile(path, content, { encoding: "utf8" });
13
16
  }
14
17
  };
15
- __decorate([
16
- Inject(),
17
- __metadata("design:type", CliFs)
18
- ], CliYaml.prototype, "fs", void 0);
19
18
  CliYaml = __decorate([
20
19
  Injectable()
21
20
  ], CliYaml);
22
21
  export { CliYaml };
23
- //# sourceMappingURL=CliYaml.js.map
@@ -1,6 +1,6 @@
1
1
  var NpmRegistryClient_1;
2
- import { __decorate, __metadata } from "tslib";
3
- import { Inject, Injectable } from "@tsed/di";
2
+ import { __decorate } from "tslib";
3
+ import { inject, Injectable } from "@tsed/di";
4
4
  import registry_url from "registry-url";
5
5
  import url from "url";
6
6
  import { CliHttpClient } from "./CliHttpClient.js";
@@ -15,6 +15,9 @@ export function addSuffix(pattern, suffix) {
15
15
  }
16
16
  export const SCOPE_SEPARATOR = "%2f";
17
17
  let NpmRegistryClient = NpmRegistryClient_1 = class NpmRegistryClient {
18
+ constructor() {
19
+ this.httpClient = inject(CliHttpClient);
20
+ }
18
21
  static escapeName(name) {
19
22
  // scoped packages contain slashes and the npm registry expects them to be escaped
20
23
  return name.replace("/", SCOPE_SEPARATOR);
@@ -106,12 +109,7 @@ let NpmRegistryClient = NpmRegistryClient_1 = class NpmRegistryClient {
106
109
  };
107
110
  }
108
111
  };
109
- __decorate([
110
- Inject(CliHttpClient),
111
- __metadata("design:type", CliHttpClient)
112
- ], NpmRegistryClient.prototype, "httpClient", void 0);
113
112
  NpmRegistryClient = NpmRegistryClient_1 = __decorate([
114
113
  Injectable()
115
114
  ], NpmRegistryClient);
116
115
  export { NpmRegistryClient };
117
- //# sourceMappingURL=NpmRegistryClient.js.map
@@ -1,6 +1,6 @@
1
- import { __decorate, __metadata, __param } from "tslib";
1
+ import { __decorate, __metadata } from "tslib";
2
2
  import { getValue, setValue } from "@tsed/core";
3
- import { Configuration, Injectable } from "@tsed/di";
3
+ import { configuration, constant, inject, Injectable } from "@tsed/di";
4
4
  import { dirname, join } from "path";
5
5
  import { readPackageUpSync } from "read-pkg-up";
6
6
  import { isValidVersion } from "../utils/isValidVersion.js";
@@ -29,11 +29,10 @@ function mapPackages(deps) {
29
29
  }, { valid: {}, invalid: {} });
30
30
  }
31
31
  let ProjectPackageJson = class ProjectPackageJson {
32
- constructor(configuration, fs) {
33
- this.configuration = configuration;
34
- this.fs = fs;
32
+ constructor() {
35
33
  this.rewrite = false;
36
34
  this.reinstall = false;
35
+ this.fs = inject(CliFs);
37
36
  this.setRaw({
38
37
  name: "",
39
38
  version: "1.0.0",
@@ -48,10 +47,10 @@ let ProjectPackageJson = class ProjectPackageJson {
48
47
  return join(this.dir, "package.json");
49
48
  }
50
49
  get dir() {
51
- return String(this.configuration.project?.rootDir);
50
+ return String(constant("project.rootDir"));
52
51
  }
53
52
  set dir(dir) {
54
- this.configuration.project.rootDir = dir;
53
+ configuration().project.rootDir = dir;
55
54
  this.read();
56
55
  }
57
56
  get name() {
@@ -83,7 +82,7 @@ let ProjectPackageJson = class ProjectPackageJson {
83
82
  };
84
83
  }
85
84
  get preferences() {
86
- return this.raw[this.configuration.name];
85
+ return this.raw[constant("name")];
87
86
  }
88
87
  $loadPackageJson() {
89
88
  return this.read();
@@ -97,11 +96,12 @@ let ProjectPackageJson = class ProjectPackageJson {
97
96
  return this;
98
97
  }
99
98
  setRaw(pkg) {
100
- const projectPreferences = this.configuration.defaultProjectPreferences;
101
- const preferences = getValue(pkg, this.configuration.name);
99
+ const config = configuration();
100
+ const projectPreferences = config.defaultProjectPreferences;
101
+ const preferences = getValue(pkg, config.name);
102
102
  this.raw = {
103
103
  ...pkg,
104
- [this.configuration.name]: {
104
+ [config.name]: {
105
105
  ...(projectPreferences && projectPreferences(pkg)),
106
106
  ...preferences
107
107
  }
@@ -150,7 +150,7 @@ let ProjectPackageJson = class ProjectPackageJson {
150
150
  return this;
151
151
  }
152
152
  setPreference(key, value) {
153
- setValue(this.raw, `${this.configuration.name}.${key}`, value);
153
+ setValue(this.raw, `${constant("name")}.${key}`, value);
154
154
  this.rewrite = true;
155
155
  return;
156
156
  }
@@ -212,7 +212,7 @@ let ProjectPackageJson = class ProjectPackageJson {
212
212
  refresh() {
213
213
  this.reinstall = false;
214
214
  this.rewrite = false;
215
- const cwd = this.configuration.get("project.rootDir");
215
+ const cwd = constant("project.rootDir");
216
216
  const pkgPath = join(String(cwd), "package.json");
217
217
  const pkg = this.fs.readJsonSync(pkgPath, { encoding: "utf8" });
218
218
  pkg.scripts = {
@@ -227,17 +227,18 @@ let ProjectPackageJson = class ProjectPackageJson {
227
227
  ...this.raw.devDependencies,
228
228
  ...pkg.devDependencies
229
229
  };
230
- pkg[this.configuration.name] = {
231
- ...this.raw[this.configuration.name],
232
- ...pkg[this.configuration.name]
230
+ const name = constant("name");
231
+ pkg[name] = {
232
+ ...this.raw[name],
233
+ ...pkg[name]
233
234
  };
234
235
  this.raw = pkg;
235
236
  return this;
236
237
  }
237
238
  getPackageJson() {
238
- const cwd = this.configuration.get("project.rootDir");
239
- const disableReadUpPkg = this.configuration.get("command.metadata.disableReadUpPkg");
240
- const name = this.configuration.get("name");
239
+ const cwd = constant("project.rootDir");
240
+ const disableReadUpPkg = constant("command.metadata.disableReadUpPkg");
241
+ const name = constant("name");
241
242
  const pkgPath = join(String(cwd), "package.json");
242
243
  const fileExists = this.fs.exists(pkgPath);
243
244
  if (!disableReadUpPkg && !fileExists) {
@@ -246,14 +247,14 @@ let ProjectPackageJson = class ProjectPackageJson {
246
247
  });
247
248
  if (result && result.path) {
248
249
  const pkgPath = dirname(result.path);
249
- this.configuration.set("project.root", pkgPath);
250
+ configuration().set("project.root", pkgPath);
250
251
  const pkg = this.fs.readJsonSync(result.path, { encoding: "utf8" });
251
252
  return { ...this.getEmptyPackageJson(name), ...pkg };
252
253
  }
253
254
  }
254
255
  if (disableReadUpPkg && fileExists) {
255
256
  const pkg = this.fs.readJsonSync(pkgPath, { encoding: "utf8" });
256
- this.configuration.set("project.root", pkgPath);
257
+ configuration().set("project.root", pkgPath);
257
258
  return { ...this.getEmptyPackageJson(name), ...pkg };
258
259
  }
259
260
  return this.getEmptyPackageJson(name);
@@ -271,8 +272,6 @@ let ProjectPackageJson = class ProjectPackageJson {
271
272
  };
272
273
  ProjectPackageJson = __decorate([
273
274
  Injectable({}),
274
- __param(0, Configuration()),
275
- __metadata("design:paramtypes", [Object, CliFs])
275
+ __metadata("design:paramtypes", [])
276
276
  ], ProjectPackageJson);
277
277
  export { ProjectPackageJson };
278
- //# sourceMappingURL=ProjectPackageJson.js.map
@@ -1,7 +1,7 @@
1
- import { __decorate, __metadata } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import "../utils/hbs/index.js";
3
3
  import { isString } from "@tsed/core";
4
- import { Configuration, Constant, Inject, Injectable } from "@tsed/di";
4
+ import { Configuration, constant, inject, Injectable } from "@tsed/di";
5
5
  import { normalizePath } from "@tsed/normalize-path";
6
6
  import Consolidate from "consolidate";
7
7
  import fs from "fs-extra";
@@ -14,7 +14,10 @@ import { insertImport } from "../utils/renderer/insertImport.js";
14
14
  import { CliFs } from "./CliFs.js";
15
15
  export class Renderer {
16
16
  constructor() {
17
+ this.templateDir = constant("templateDir", "");
18
+ this.fs = inject(CliFs);
17
19
  this.cache = new Set();
20
+ this.configuration = inject(Configuration);
18
21
  }
19
22
  async loadPartials(cwd) {
20
23
  if (this.cache.has(cwd)) {
@@ -131,18 +134,6 @@ export class Renderer {
131
134
  return { output, templateDir, rootDir };
132
135
  }
133
136
  }
134
- __decorate([
135
- Constant("templateDir"),
136
- __metadata("design:type", String)
137
- ], Renderer.prototype, "templateDir", void 0);
138
- __decorate([
139
- Inject(),
140
- __metadata("design:type", CliFs)
141
- ], Renderer.prototype, "fs", void 0);
142
- __decorate([
143
- Configuration(),
144
- __metadata("design:type", Object)
145
- ], Renderer.prototype, "configuration", void 0);
146
137
  let RootRendererService = class RootRendererService extends Renderer {
147
138
  get rootDir() {
148
139
  return this.configuration.project?.rootDir;
@@ -170,4 +161,3 @@ ScriptsRendererService = __decorate([
170
161
  Injectable()
171
162
  ], ScriptsRendererService);
172
163
  export { ScriptsRendererService };
173
- //# sourceMappingURL=Renderer.js.map
@@ -13,4 +13,3 @@ export * from "./CliYaml.js";
13
13
  export * from "./NpmRegistryClient.js";
14
14
  export * from "./ProjectPackageJson.js";
15
15
  export * from "./Renderer.js";
16
- //# sourceMappingURL=index.js.map
@@ -13,4 +13,3 @@ export function coerce(value) {
13
13
  }
14
14
  return value;
15
15
  }
16
- //# sourceMappingURL=coerce.js.map
@@ -1,4 +1,4 @@
1
- import { InjectorService } from "@tsed/di";
1
+ import { injector, InjectorService } from "@tsed/di";
2
2
  import { Logger } from "@tsed/logger";
3
3
  import { CliConfiguration } from "../services/CliConfiguration.js";
4
4
  import { ProjectPackageJson } from "../services/ProjectPackageJson.js";
@@ -11,19 +11,19 @@ function createConfiguration(injector) {
11
11
  return injector.invoke(CliConfiguration);
12
12
  }
13
13
  export function createInjector(settings = {}) {
14
- const injector = new InjectorService();
15
- injector.settings = createConfiguration(injector);
16
- logger = injector.logger = new Logger(settings.name || "CLI");
17
- injector.addProvider(ProjectPackageJson);
18
- injector.settings.set(settings);
14
+ const inj = injector();
15
+ inj.settings = createConfiguration(inj);
16
+ logger = inj.logger = new Logger(settings.name || "CLI");
17
+ inj.addProvider(ProjectPackageJson);
18
+ inj.settings.set(settings);
19
19
  /* istanbul ignore next */
20
- if (injector.settings.env === "test") {
21
- injector.logger.stop();
20
+ if (inj.settings.env === "test") {
21
+ inj.logger.stop();
22
22
  }
23
23
  else {
24
24
  /* istanbul ignore next */
25
- injector.logger.level = injector.settings.logger?.level || "warn";
26
- injector.logger.appenders
25
+ inj.logger.level = inj.settings.logger?.level || "warn";
26
+ inj.logger.appenders
27
27
  .set("stdout", {
28
28
  type: "stdout",
29
29
  layout: {
@@ -41,6 +41,5 @@ export function createInjector(settings = {}) {
41
41
  levels: ["trace", "fatal", "error", "warn"]
42
42
  });
43
43
  }
44
- return injector;
44
+ return inj;
45
45
  }
46
- //# sourceMappingURL=createInjector.js.map
@@ -19,7 +19,7 @@ function getOptions({ bindLogger = true, ...ctx }) {
19
19
  renderer: useRawRenderer ? VerboseRenderer : DefaultRenderer,
20
20
  rendererOptions: useRawRenderer && bindLogger
21
21
  ? {
22
- logger: CustomLogger
22
+ logger: new CustomLogger()
23
23
  }
24
24
  : undefined
25
25
  };
@@ -38,4 +38,3 @@ export function createSubTasks(tasks, opts) {
38
38
  export function createTasksRunner(tasks, ctx) {
39
39
  return createTasks(tasks, ctx).run(ctx);
40
40
  }
41
- //# sourceMappingURL=createTasksRunner.js.map
@@ -1,4 +1,4 @@
1
- import { Store, Type } from "@tsed/core";
1
+ import { Store } from "@tsed/core";
2
2
  import { CommandStoreKeys } from "../domains/CommandStoreKeys.js";
3
3
  export function getCommandMetadata(token) {
4
4
  const { name, alias, args = {}, allowUnknownOption, description, options = {}, enableFeatures, disableReadUpPkg, bindLogger = true, ...opts } = Store.from(token)?.get(CommandStoreKeys.COMMAND);
@@ -15,4 +15,3 @@ export function getCommandMetadata(token) {
15
15
  ...opts
16
16
  };
17
17
  }
18
- //# sourceMappingURL=getCommandMetadata.js.map
@@ -6,4 +6,3 @@ export function getTemplateDirectory(cwd) {
6
6
  });
7
7
  return join(dirname(path), "templates");
8
8
  }
9
- //# sourceMappingURL=getTemplateDirectory.js.map
@@ -513,4 +513,3 @@ helpers.unique = function (array) {
513
513
  return arr.indexOf(item) === index;
514
514
  });
515
515
  };
516
- //# sourceMappingURL=array.js.map
@@ -58,4 +58,3 @@ helpers.iterate = function (collection, options) {
58
58
  }
59
59
  return options.inverse(this);
60
60
  };
61
- //# sourceMappingURL=collection.js.map
@@ -429,4 +429,3 @@ helpers.unlessLteq = function (a, b, options) {
429
429
  }
430
430
  return util.value(a > b, this, options);
431
431
  };
432
- //# sourceMappingURL=comparison.js.map
@@ -9,4 +9,3 @@ handlebars.registerHelper(object);
9
9
  handlebars.registerHelper(collection);
10
10
  handlebars.registerHelper(comparison);
11
11
  handlebars.registerHelper(switchHelpers);
12
- //# sourceMappingURL=index.js.map
@@ -234,4 +234,3 @@ helpers.pick = function (props, context, options) {
234
234
  * deprecated in a future release
235
235
  */
236
236
  helpers.stringify = helpers.JSONstringify;
237
- //# sourceMappingURL=object.js.map
@@ -8,4 +8,3 @@ helpers.case = function (value, options) {
8
8
  return options.fn(this);
9
9
  }
10
10
  };
11
- //# sourceMappingURL=switch.js.map
@@ -8,4 +8,3 @@ export * from "./mapCommanderArgs.js";
8
8
  export * from "./mapCommanderOptions.js";
9
9
  export * from "./parseOption.js";
10
10
  export * from "./resolveConfiguration.js";
11
- //# sourceMappingURL=index.js.map
@@ -3,4 +3,3 @@ export function isValidVersion(version) {
3
3
  version = version.replace(/[~>=<]/gi, "");
4
4
  return !!semver.valid(version);
5
5
  }
6
- //# sourceMappingURL=isValidVersion.js.map
@@ -1,40 +1,40 @@
1
- import { GlobalProviders, InjectorService } from "@tsed/di";
1
+ import { GlobalProviders, injector, logger } from "@tsed/di";
2
2
  import chalk from "chalk";
3
3
  import figures from "figures";
4
4
  import { CliFs } from "../services/CliFs.js";
5
5
  import { ProjectPackageJson } from "../services/ProjectPackageJson.js";
6
6
  const all = (promises) => Promise.all(promises);
7
- export async function loadPlugins(injector) {
8
- const name = injector.settings.get("name");
9
- const rootDir = injector.settings.get("project.rootDir");
10
- const projectPackageJson = injector.invoke(ProjectPackageJson);
11
- const fs = injector.invoke(CliFs);
7
+ export async function loadPlugins() {
8
+ const $inj = injector();
9
+ const name = $inj.settings.get("name");
10
+ const rootDir = $inj.settings.get("project.rootDir");
11
+ const projectPackageJson = $inj.invoke(ProjectPackageJson);
12
+ const fs = $inj.invoke(CliFs);
12
13
  const promises = Object.keys(projectPackageJson.allDependencies)
13
14
  .filter((mod) => mod.startsWith(`@${name}/cli-plugin`) || mod.includes(`${name}-cli-plugin`))
14
15
  .map(async (mod) => {
15
16
  try {
16
17
  const { default: plugin } = await fs.importModule(mod, rootDir);
17
- if (!injector.has(plugin)) {
18
+ if (!$inj.has(plugin)) {
18
19
  const provider = GlobalProviders.get(plugin)?.clone();
19
20
  if (provider?.imports.length) {
20
21
  await all(provider.imports.map(async (token) => {
21
- injector.add(token, GlobalProviders.get(token)?.clone());
22
- if (injector.settings.get("loaded")) {
23
- await injector.invoke(token);
22
+ $inj.add(token, GlobalProviders.get(token)?.clone());
23
+ if ($inj.settings.get("loaded")) {
24
+ await $inj.invoke(token);
24
25
  }
25
26
  }));
26
27
  }
27
- injector.add(plugin, provider);
28
- if (injector.settings.get("loaded")) {
29
- await injector.invoke(plugin);
28
+ $inj.add(plugin, provider);
29
+ if ($inj.settings.get("loaded")) {
30
+ await $inj.invoke(plugin);
30
31
  }
31
32
  }
32
- injector.logger.info(chalk.green(figures.tick), mod, "module loaded");
33
+ logger().info(chalk.green(figures.tick), mod, "module loaded");
33
34
  }
34
35
  catch (er) {
35
- injector.logger.warn(chalk.red(figures.cross), "Fail to load plugin", mod);
36
+ logger().warn(chalk.red(figures.cross), "Fail to load plugin", mod);
36
37
  }
37
38
  });
38
39
  await all(promises);
39
40
  }
40
- //# sourceMappingURL=loadPlugins.js.map
@@ -11,4 +11,3 @@ export function logToCurl({ url, method, params, query, data, headers = {} }) {
11
11
  curl += Object.entries(headers).reduce((curlHeaders, [key, value]) => `${curlHeaders} -H '${key}: ${value}'`, "");
12
12
  return curl;
13
13
  }
14
- //# sourceMappingURL=logToCurl.js.map
@@ -33,4 +33,3 @@ export function mapCommanderArgs(args, commandArgs) {
33
33
  };
34
34
  }, {});
35
35
  }
36
- //# sourceMappingURL=mapCommanderArgs.js.map
@@ -1,6 +1,9 @@
1
- export function mapCommanderOptions(commands) {
1
+ export function mapCommanderOptions(commandName, commands) {
2
2
  const options = {};
3
3
  commands.forEach((command) => {
4
+ if (command.name() !== commandName) {
5
+ return;
6
+ }
4
7
  Object.entries(command.opts())
5
8
  .filter(([key]) => !key.startsWith("_") && !["commands", "options", "parent", "rawArgs", "args"].includes(key))
6
9
  .forEach(([key, value]) => {
@@ -9,4 +12,3 @@ export function mapCommanderOptions(commands) {
9
12
  });
10
13
  return options;
11
14
  }
12
- //# sourceMappingURL=mapCommanderOptions.js.map
@@ -21,4 +21,3 @@ export function parseOption(value, options) {
21
21
  }
22
22
  return value;
23
23
  }
24
- //# sourceMappingURL=parseOption.js.map
@@ -51,4 +51,3 @@ Command.prototype.helpInformation = function help() {
51
51
  .replace(/\[(\w+)]/gi, `[${chalk.cyan("$1")}]`) +
52
52
  "\n");
53
53
  };
54
- //# sourceMappingURL=patchCommander.js.map