Skip to content

Commit

Permalink
fix: provider.get issue when command provider is registered
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Jul 8, 2023
1 parent 0f84bb5 commit 41c2b3c
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 102 deletions.
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -47,10 +47,10 @@
"dependencies": {
"@samverschueren/stream-to-observable": "0.3.1",
"@tsed/components-scan": ">=7.14.2",
"@tsed/normalize-path": ">=7.14.2",
"@tsed/core": ">=7.14.2",
"@tsed/di": ">=7.14.2",
"@tsed/logger": ">=6.2.1",
"@tsed/normalize-path": ">=7.14.2",
"any-observable": "0.5.1",
"axios": "0.26.1",
"chalk": "4.1.0",
Expand Down Expand Up @@ -78,19 +78,20 @@
"devDependencies": {
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@swc/core": "^1.3.61",
"@swc/helpers": "^0.5.1",
"@swc/jest": "^0.2.26",
"@tsed/markdown-it-symbols": "3.20.4",
"@tsed/monorepo-utils": "1.23.0",
"@tsed/ts-doc": "^4.1.0",
"@types/jest": "28.1.7",
"@types/node": "18.7.8",
"@typescript-eslint/eslint-plugin": "^5.33.1",
"@typescript-eslint/parser": "^5.33.1",
"@swc/core": "^1.3.61",
"@swc/helpers": "^0.5.1",
"@swc/jest": "^0.2.26",
"concurrently": "7.6.0",
"coveralls": "3.1.1",
"cross-env": "7.0.3",
"entities": "1.1.2",
"eslint": "8.22.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-jest": "27.1.6",
Expand All @@ -115,7 +116,6 @@
"typescript": "4.9.5",
"vue-analytics": "5.22.1",
"vuepress": "1.9.7",
"entities": "1.1.2",
"vuepress-theme-tsed": "3.19.5"
},
"directories": {
Expand Down
6 changes: 3 additions & 3 deletions packages/cli-core/jest.config.js
Expand Up @@ -9,10 +9,10 @@ module.exports = {
},
coverageThreshold: {
global: {
statements: 71.23,
branches: 72.81,
statements: 71.15,
branches: 72.9,
functions: 48.9,
lines: 71.23
lines: 71.15
}
},
};
6 changes: 3 additions & 3 deletions packages/cli-core/src/decorators/command.ts
@@ -1,8 +1,8 @@
import {useDecorators, StoreSet} from "@tsed/core";
import {StoreSet, useDecorators} from "@tsed/core";
import {Injectable} from "@tsed/di";
import {CommandStoreKeys} from "../domains/CommandStoreKeys";
import {CommandParameters} from "../interfaces/CommandParameters";
import {registerCommand} from "../registries/CommandRegistry";

export function Command(options: CommandParameters): ClassDecorator {
return useDecorators(registerCommand, StoreSet(CommandStoreKeys.COMMAND, options)) as any;
return useDecorators(Injectable({type: "command"}), StoreSet(CommandStoreKeys.COMMAND, options)) as any;
}
11 changes: 0 additions & 11 deletions packages/cli-core/src/registries/CommandRegistry.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/cli-core/src/services/CliService.ts
Expand Up @@ -6,7 +6,6 @@ import {v4} from "uuid";
import {CommandStoreKeys} from "../domains/CommandStoreKeys";
import {CommandProvider} from "../interfaces/CommandProvider";
import {CommandArg, CommandOptions} from "../interfaces/CommandParameters";
import {PROVIDER_TYPE_COMMAND} from "../registries/CommandRegistry";
import {createSubTasks, createTasksRunner} from "../utils/createTasksRunner";
import {getCommandMetadata} from "../utils/getCommandMetadata";
import {mapCommanderArgs} from "../utils/mapCommanderArgs";
Expand Down Expand Up @@ -238,7 +237,7 @@ export class CliService {
}

private load() {
this.injector.getProviders(PROVIDER_TYPE_COMMAND).forEach((provider) => this.build(provider));
this.injector.getProviders("command").forEach((provider) => this.build(provider));
}

private mapData(cmdName: string, data: any, $ctx: DIContext) {
Expand Down

0 comments on commit 41c2b3c

Please sign in to comment.