Skip to content

Commit 40d5b56

Browse files
committed
feat: introduce controller for each command
1 parent 66cfacf commit 40d5b56

File tree

71 files changed

+1651
-2452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1651
-2452
lines changed

PublicAPI.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Public API
32
==
43

lib/bootstrap.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,32 @@ $injector.require("projectNameService", "./services/project-name-service");
3333
$injector.require("tnsModulesService", "./services/tns-modules-service");
3434

3535
$injector.require("platformsData", "./platforms-data");
36-
$injector.require("platformService", "./services/platform-service");
3736
$injector.require("addPlatformService", "./services/platform/add-platform-service");
38-
$injector.require("buildPlatformService", "./services/platform/build-platform-service");
39-
$injector.require("preparePlatformService", "./services/platform/prepare-platform-service");
37+
$injector.require("buildInfoFileService", "./services/build-info-file-service");
38+
$injector.require("prepareNativePlatformService", "./services/platform/prepare-native-platform-service");
4039
$injector.require("platformValidationService", "./services/platform/platform-validation-service");
4140
$injector.require("platformCommandsService", "./services/platform/platform-commands-service");
42-
$injector.require("platformWatcherService", "./services/platform/platform-watcher-service");
4341

4442
$injector.require("buildArtefactsService", "./services/build-artefacts-service");
4543

4644
$injector.require("deviceDebugAppService", "./services/device/device-debug-app-service");
4745
$injector.require("deviceInstallAppService", "./services/device/device-install-app-service");
4846
$injector.require("deviceRefreshAppService", "./services/device/device-refresh-app-service");
4947

50-
$injector.require("workflowDataService", "./services/workflow/workflow-data-service");
5148
$injector.require("runOnDevicesDataService", "./services/run-on-devices-data-service");
49+
5250
$injector.require("runOnDevicesEmitter", "./run-on-devices-emitter");
51+
$injector.require("previewAppEmitter", "./preview-app-emitter");
5352

54-
$injector.require("mainController", "./controllers/main-controller");
53+
$injector.require("addPlatformController", "./controllers/add-platform-controller");
54+
$injector.require("prepareController", "./controllers/prepare-controller");
55+
$injector.require("buildController", "./controllers/build-controller");
56+
$injector.require("deployOnDevicesController", "./controllers/deploy-on-devices-controller");
5557
$injector.require("runOnDevicesController", "./controllers/run-on-devices-controller");
58+
$injector.require("previewAppController", "./controllers/preview-app-controller");
59+
60+
$injector.require("prepareDataService", "./services/prepare-data-service");
61+
$injector.require("buildDataService", "./services/build-data-service");
5662

5763
$injector.require("liveSyncServiceResolver", "./resolvers/livesync-service-resolver");
5864

lib/commands/appstore-upload.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import * as path from "path";
22
import { StringCommandParameter } from "../common/command-params";
3-
import { BuildPlatformService } from "../services/platform/build-platform-service";
4-
import { WorkflowDataService } from "../services/workflow/workflow-data-service";
5-
import { MainController } from "../controllers/main-controller";
3+
import { BuildController } from "../controllers/build-controller";
4+
import { IOSBuildData } from "../data/build-data";
65

76
export class PublishIOS implements ICommand {
87
public allowedParameters: ICommandParameter[] = [new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector),
@@ -16,10 +15,8 @@ export class PublishIOS implements ICommand {
1615
private $options: IOptions,
1716
private $prompter: IPrompter,
1817
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
19-
private $mainController: MainController,
20-
private $platformValidationService: IPlatformValidationService,
21-
private $buildPlatformService: BuildPlatformService,
22-
private $workflowDataService: WorkflowDataService
18+
private $buildController: BuildController,
19+
private $platformValidationService: IPlatformValidationService
2320
) {
2421
this.$projectData.initializeProjectData();
2522
}
@@ -59,11 +56,12 @@ export class PublishIOS implements ICommand {
5956
// As we need to build the package for device
6057
this.$options.forDevice = true;
6158

62-
const { nativePlatformData, buildPlatformData } = this.$workflowDataService.createWorkflowData(platform, this.$projectData.projectDir, this.$options);
63-
ipaFilePath = await this.$buildPlatformService.buildPlatform(nativePlatformData, this.$projectData, buildPlatformData);
59+
const buildData = new IOSBuildData(this.$projectData.projectDir, platform, this.$options);
60+
ipaFilePath = await this.$buildController.prepareAndBuildPlatform(buildData);
6461
} else {
6562
this.$logger.info("No .ipa, mobile provision or certificate set. Perfect! Now we'll build .xcarchive and let Xcode pick the distribution certificate and provisioning profile for you when exporting .ipa for AppStore submission.");
66-
ipaFilePath = await this.$mainController.buildPlatform(platform, this.$projectData.projectDir, { ...this.$options, buildForAppStore: true });
63+
const buildData = new IOSBuildData(this.$projectData.projectDir, platform, { ...this.$options, buildForAppStore: true });
64+
ipaFilePath = await this.$buildController.prepareAndBuildPlatform(buildData);
6765
this.$logger.info(`Export at: ${ipaFilePath}`);
6866
}
6967
}

lib/commands/build.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
import { ANDROID_RELEASE_BUILD_ERROR_MESSAGE, AndroidAppBundleMessages } from "../constants";
22
import { ValidatePlatformCommandBase } from "./command-base";
3-
import { MainController } from "../controllers/main-controller";
3+
import { BuildController } from "../controllers/build-controller";
4+
import { BuildDataService } from "../services/build-data-service";
45

56
export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
67
constructor($options: IOptions,
78
protected $errors: IErrors,
89
$projectData: IProjectData,
910
$platformsData: IPlatformsData,
1011
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
11-
protected $mainController: MainController,
12+
protected $buildController: BuildController,
1213
$platformValidationService: IPlatformValidationService,
1314
private $bundleValidatorHelper: IBundleValidatorHelper,
15+
private $buildDataService: BuildDataService,
1416
protected $logger: ILogger) {
1517
super($options, $platformsData, $platformValidationService, $projectData);
1618
this.$projectData.initializeProjectData();
1719
}
1820

21+
public dashedOptions = {
22+
watch: { type: OptionType.Boolean, default: false, hasSensitiveValue: false },
23+
};
24+
1925
public async executeCore(args: string[]): Promise<string> {
2026
const platform = args[0].toLowerCase();
21-
const outputPath = await this.$mainController.buildPlatform(platform, this.$projectData.projectDir, this.$options);
27+
const buildData = this.$buildDataService.getBuildData(this.$projectData.projectDir, platform, this.$options);
28+
const outputPath = await this.$buildController.prepareAndBuildPlatform(buildData);
2229

2330
return outputPath;
2431
}
@@ -57,11 +64,12 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
5764
$projectData: IProjectData,
5865
$platformsData: IPlatformsData,
5966
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
60-
$mainController: MainController,
67+
$buildController: BuildController,
6168
$platformValidationService: IPlatformValidationService,
6269
$bundleValidatorHelper: IBundleValidatorHelper,
63-
$logger: ILogger) {
64-
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $mainController, $platformValidationService, $bundleValidatorHelper, $logger);
70+
$logger: ILogger,
71+
$buildDataService: BuildDataService) {
72+
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $buildController, $platformValidationService, $bundleValidatorHelper, $buildDataService, $logger);
6573
}
6674

6775
public async execute(args: string[]): Promise<void> {
@@ -92,12 +100,13 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
92100
$projectData: IProjectData,
93101
$platformsData: IPlatformsData,
94102
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
95-
$mainController: MainController,
103+
$buildController: BuildController,
96104
$platformValidationService: IPlatformValidationService,
97105
$bundleValidatorHelper: IBundleValidatorHelper,
98106
protected $androidBundleValidatorHelper: IAndroidBundleValidatorHelper,
107+
$buildDataService: BuildDataService,
99108
protected $logger: ILogger) {
100-
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $mainController, $platformValidationService, $bundleValidatorHelper, $logger);
109+
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $buildController, $platformValidationService, $bundleValidatorHelper, $buildDataService, $logger);
101110
}
102111

103112
public async execute(args: string[]): Promise<void> {

lib/commands/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class DeployOnDeviceCommand extends ValidatePlatformCommandBase implement
2121

2222
public async execute(args: string[]): Promise<void> {
2323
const platform = args[0].toLowerCase();
24-
await this.$deployCommandHelper.deploy(platform, <any>{ release: true });
24+
await this.$deployCommandHelper.deploy(platform);
2525
}
2626

2727
public async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> {

lib/commands/prepare.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
import { ValidatePlatformCommandBase } from "./command-base";
2-
import { MainController } from "../controllers/main-controller";
2+
import { PrepareController } from "../controllers/prepare-controller";
3+
import { PrepareDataService } from "../services/prepare-data-service";
34

45
export class PrepareCommand extends ValidatePlatformCommandBase implements ICommand {
56
public allowedParameters = [this.$platformCommandParameter];
67

8+
public dashedOptions = {
9+
watch: { type: OptionType.Boolean, default: false, hasSensitiveValue: false },
10+
};
11+
712
constructor($options: IOptions,
8-
private $mainController: MainController,
13+
private $prepareController: PrepareController,
914
$platformValidationService: IPlatformValidationService,
1015
$projectData: IProjectData,
1116
private $platformCommandParameter: ICommandParameter,
12-
$platformsData: IPlatformsData) {
17+
$platformsData: IPlatformsData,
18+
private $prepareDataService: PrepareDataService) {
1319
super($options, $platformsData, $platformValidationService, $projectData);
1420
this.$projectData.initializeProjectData();
1521
}
1622

1723
public async execute(args: string[]): Promise<void> {
1824
const platform = args[0];
1925

20-
await this.$mainController.preparePlatform(platform, this.$projectData.projectDir, this.$options);
26+
const prepareData = this.$prepareDataService.getPrepareData(this.$projectData.projectDir, platform, this.$options);
27+
await this.$prepareController.preparePlatform(prepareData);
2128
}
2229

2330
public async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> {

lib/commands/preview.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DEVICE_LOG_EVENT_NAME } from "../common/constants";
2+
import { PreviewAppController } from "../controllers/preview-app-controller";
23

34
export class PreviewCommand implements ICommand {
45
public allowedParameters: ICommandParameter[] = [];
@@ -8,7 +9,7 @@ export class PreviewCommand implements ICommand {
89
private $bundleValidatorHelper: IBundleValidatorHelper,
910
private $errors: IErrors,
1011
private $logger: ILogger,
11-
private $previewAppLiveSyncService: IPreviewAppLiveSyncService,
12+
private $previewAppController: PreviewAppController,
1213
private $networkConnectivityValidator: INetworkConnectivityValidator,
1314
private $projectData: IProjectData,
1415
private $options: IOptions,
@@ -24,7 +25,7 @@ export class PreviewCommand implements ICommand {
2425
this.$logger.info(message);
2526
});
2627

27-
await this.$previewAppLiveSyncService.initialize({
28+
await this.$previewAppController.preview({
2829
projectDir: this.$projectData.projectDir,
2930
useHotModuleReload: this.$options.hmr,
3031
env: this.$options.env

lib/common/mobile/mobile-core/devices-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
604604
public getPlatformsFromDeviceDescriptors(deviceDescriptors: ILiveSyncDeviceInfo[]): string[] {
605605
const platforms = _(deviceDescriptors)
606606
.map(device => this.getDeviceByIdentifier(device.identifier))
607-
.map(device => device.deviceInfo.platform)
607+
.map(device => device.deviceInfo.platform.toLowerCase())
608608
.uniq()
609609
.value();
610610

lib/common/services/hooks-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class HooksService implements IHooksService {
8484
results.push(await this.executeHooksInDirectory(hooksDirectory, hookName, hookArguments));
8585
}
8686
} catch (err) {
87-
this.$logger.trace("Failed during hook execution.");
87+
this.$logger.trace(`Failed during hook execution ${hookName}.`);
8888
this.$errors.failWithoutHelp(err.message || err);
8989
}
9090

lib/common/services/livesync/sync-batch.ts

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

0 commit comments

Comments
 (0)