Skip to content

Commit 022c1b0

Browse files
chore: remove commandsServiceProvider
The `commandsServiceProvider` has been used when code was shared between AppBuilder CLI and NativeScript CLI. At the moment, we do not share the code with any other library, so we can safely remove the `commandsServiceProvider` as it is not used in NativeScript CLI.
1 parent ef591fe commit 022c1b0

File tree

8 files changed

+0
-49
lines changed

8 files changed

+0
-49
lines changed

lib/bootstrap.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ $injector.requireCommand("package-manager|get", "./commands/package-manager-get"
8686

8787
$injector.require("packageInstallationManager", "./package-installation-manager");
8888
$injector.require("dynamicHelpProvider", "./dynamic-help-provider");
89-
$injector.require("commandsServiceProvider", "./providers/commands-service-provider");
9089

9190
$injector.require("deviceLogProvider", "./common/mobile/device-log-provider");
9291
$injector.require("projectFilesProvider", "./providers/project-files-provider");

lib/common/definitions/commands-service.d.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ interface ICommandsService {
66
completeCommand(): Promise<boolean>;
77
}
88

9-
interface ICommandsServiceProvider {
10-
dynamicCommandsPrefix: string;
11-
getDynamicCommands(): Promise<string[]>;
12-
generateDynamicCommands(): Promise<void>;
13-
registerDynamicSubCommands(): void;
14-
}
15-
169
/**
1710
* Describes the command data.
1811
*/

lib/common/services/commands-service.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ export class CommandsService implements ICommandsService {
1616
return _.last(this.commands);
1717
}
1818

19-
private areDynamicSubcommandsRegistered = false;
2019
private commands: ICommandData[] = [];
2120

2221
constructor(private $analyticsSettingsService: IAnalyticsSettingsService,
23-
private $commandsServiceProvider: ICommandsServiceProvider,
2422
private $errors: IErrors,
2523
private $hooksService: IHooksService,
2624
private $injector: IInjector,
@@ -110,10 +108,6 @@ export class CommandsService implements ICommandsService {
110108
this.$options.validateOptions(command ? command.dashedOptions : null);
111109
}
112110

113-
if (!this.areDynamicSubcommandsRegistered) {
114-
this.$commandsServiceProvider.registerDynamicSubCommands();
115-
this.areDynamicSubcommandsRegistered = true;
116-
}
117111
return this.canExecuteCommand(commandName, commandArguments);
118112
}
119113

@@ -161,11 +155,6 @@ export class CommandsService implements ICommandsService {
161155

162156
this.$errors.fail("Unable to execute command '%s'. Use '$ %s %s --help' for help.", beautifiedName, this.$staticConfig.CLIENT_NAME.toLowerCase(), beautifiedName);
163157
return false;
164-
} else if (!isDynamicCommand && _.startsWith(commandName, this.$commandsServiceProvider.dynamicCommandsPrefix)) {
165-
if (_.some(await this.$commandsServiceProvider.getDynamicCommands())) {
166-
await this.$commandsServiceProvider.generateDynamicCommands();
167-
return await this.canExecuteCommand(commandName, commandArguments, true);
168-
}
169158
}
170159

171160
const commandInfo = {

lib/common/test/unit-tests/services/help-service.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ const createTestInjector = (opts?: { isProjectTypeResult: boolean; isPlatformRes
4242
injector.register("opener", {
4343
open(target: string, appname?: string): void {/* mock */ }
4444
});
45-
injector.register("commandsServiceProvider", {
46-
getDynamicCommands: (): Promise<string[]> => {
47-
return Promise.resolve(<string[]>[]);
48-
}
49-
});
5045

5146
injector.register("fs", {
5247
exists: (filePath: string) => false

lib/providers/commands-service-provider.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

test/npm-support.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ function createTestInjector(): IInjector {
7373
testInjector.register("yarn", YarnLib.YarnPackageManager);
7474
testInjector.register("childProcess", ChildProcessLib.ChildProcess);
7575
testInjector.register("projectFilesManager", ProjectFilesManagerLib.ProjectFilesManager);
76-
testInjector.register("commandsServiceProvider", {
77-
registerDynamicSubCommands: () => { /* intentionally left blank */ }
78-
});
7976
testInjector.register("preparePlatformNativeService", PreparePlatformNativeService);
8077
testInjector.register("preparePlatformJSService", PreparePlatformJSService);
8178
testInjector.register("pluginVariablesService", {});

test/platform-commands.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ function createTestInjector() {
116116
testInjector.registerCommand("platform|update", PlatformUpdateCommandLib.UpdatePlatformCommand);
117117
testInjector.registerCommand("platform|clean", PlatformCleanCommandLib.CleanCommand);
118118
testInjector.register("resources", {});
119-
testInjector.register("commandsServiceProvider", {
120-
registerDynamicSubCommands: () => { /* intentionally left blank */ }
121-
});
122119
testInjector.register("commandsService", {
123120
tryExecuteCommand: () => { /* intentionally left blank */ }
124121
});

test/plugins-service.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ function createTestInjector() {
7575
trackOptions: () => Promise.resolve(null)
7676
});
7777
testInjector.register("commandsService", CommandsService);
78-
testInjector.register("commandsServiceProvider", {
79-
registerDynamicSubCommands: () => { /* intentionally empty body */ }
80-
});
8178
testInjector.register("hostInfo", HostInfo);
8279
testInjector.register("projectHelper", ProjectHelper);
8380

0 commit comments

Comments
 (0)