Skip to content

Commit 68187de

Browse files
committed
chore: remove platform-workflow-service
1 parent 3e44606 commit 68187de

File tree

9 files changed

+39
-78
lines changed

9 files changed

+39
-78
lines changed

lib/bootstrap.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ $injector.require("platformWatcherService", "./services/platform/platform-watche
4545
$injector.require("deviceInstallationService", "./services/device/device-installation-service");
4646
$injector.require("deviceRestartApplicationService", "./services/device/device-restart-application-service");
4747

48-
$injector.require("platformWorkflowService", "./services/workflow/platform-workflow-service");
4948
$injector.require("workflowDataService", "./services/workflow/workflow-data-service");
5049
$injector.require("bundleWorkflowService", "./services/bundle-workflow-service");
5150

lib/commands/build.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { ANDROID_RELEASE_BUILD_ERROR_MESSAGE, AndroidAppBundleMessages } from "../constants";
22
import { ValidatePlatformCommandBase } from "./command-base";
3+
import { BundleWorkflowService } from "../services/bundle-workflow-service";
34

45
export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
56
constructor($options: IOptions,
67
protected $errors: IErrors,
78
$projectData: IProjectData,
89
$platformsData: IPlatformsData,
910
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
10-
protected $platformWorkflowService: IPlatformWorkflowService,
11+
protected $bundleWorkflowService: BundleWorkflowService,
1112
$platformValidationService: IPlatformValidationService,
1213
private $bundleValidatorHelper: IBundleValidatorHelper,
1314
protected $logger: ILogger) {
@@ -17,7 +18,7 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
1718

1819
public async executeCore(args: string[]): Promise<string> {
1920
const platform = args[0].toLowerCase();
20-
const outputPath = await this.$platformWorkflowService.buildPlatform(platform, this.$projectData.projectDir, this.$options);
21+
const outputPath = await this.$bundleWorkflowService.buildPlatform(platform, this.$projectData.projectDir, this.$options);
2122

2223
return outputPath;
2324
}
@@ -56,11 +57,11 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
5657
$projectData: IProjectData,
5758
$platformsData: IPlatformsData,
5859
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
59-
$platformWorkflowService: IPlatformWorkflowService,
60+
$bundleWorkflowService: BundleWorkflowService,
6061
$platformValidationService: IPlatformValidationService,
6162
$bundleValidatorHelper: IBundleValidatorHelper,
6263
$logger: ILogger) {
63-
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformWorkflowService, $platformValidationService, $bundleValidatorHelper, $logger);
64+
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $bundleWorkflowService, $platformValidationService, $bundleValidatorHelper, $logger);
6465
}
6566

6667
public async execute(args: string[]): Promise<void> {
@@ -91,12 +92,12 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
9192
$projectData: IProjectData,
9293
$platformsData: IPlatformsData,
9394
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
94-
$platformWorkflowService: IPlatformWorkflowService,
95+
$bundleWorkflowService: BundleWorkflowService,
9596
$platformValidationService: IPlatformValidationService,
9697
$bundleValidatorHelper: IBundleValidatorHelper,
9798
protected $androidBundleValidatorHelper: IAndroidBundleValidatorHelper,
9899
protected $logger: ILogger) {
99-
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformWorkflowService, $platformValidationService, $bundleValidatorHelper, $logger);
100+
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $bundleWorkflowService, $platformValidationService, $bundleValidatorHelper, $logger);
100101
}
101102

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

lib/commands/prepare.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { ValidatePlatformCommandBase } from "./command-base";
2+
import { BundleWorkflowService } from "../services/bundle-workflow-service";
23

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

67
constructor($options: IOptions,
7-
private $platformWorkflowService: IPlatformWorkflowService,
8+
private $bundleWorkflowService: BundleWorkflowService,
89
$platformValidationService: IPlatformValidationService,
910
$projectData: IProjectData,
1011
private $platformCommandParameter: ICommandParameter,
@@ -16,7 +17,7 @@ export class PrepareCommand extends ValidatePlatformCommandBase implements IComm
1617
public async execute(args: string[]): Promise<void> {
1718
const platform = args[0];
1819

19-
await this.$platformWorkflowService.preparePlatform(platform, this.$projectData.projectDir, this.$options);
20+
await this.$bundleWorkflowService.preparePlatform(platform, this.$projectData.projectDir, this.$options);
2021
}
2122

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

lib/declarations.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,9 @@ interface INetworkConnectivityValidator {
10281028
}
10291029

10301030
interface IBundleWorkflowService {
1031-
start(projectDir: string, deviceDescriptors: ILiveSyncDeviceInfo[], liveSyncInfo: ILiveSyncInfo): Promise<void>;
1031+
preparePlatform(platform: string, projectDir: string, options: IOptions): Promise<void>;
1032+
buildPlatform(platform: string, projectDir: string, options: IOptions): Promise<string>;
1033+
runPlatform(projectDir: string, deviceDescriptors: ILiveSyncDeviceInfo[], liveSyncInfo: ILiveSyncInfo): Promise<void>;
10321034
}
10331035

10341036
interface IPlatformValidationService {

lib/helpers/livesync-command-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
128128
force: this.$options.force
129129
};
130130

131-
await this.$bundleWorkflowService.start(this.$projectData.projectDir, deviceDescriptors, liveSyncInfo);
131+
await this.$bundleWorkflowService.runPlatform(this.$projectData.projectDir, deviceDescriptors, liveSyncInfo);
132132

133133
// const remainingDevicesToSync = devices.map(d => d.deviceInfo.identifier);
134134
// this.$liveSyncService.on(LiveSyncEvents.liveSyncStopped, (data: { projectDir: string, deviceIdentifier: string }) => {

lib/services/bundle-workflow-service.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import { INITIAL_SYNC_EVENT_NAME, FILES_CHANGE_EVENT_NAME } from "../constants";
22
import { WorkflowDataService } from "./workflow/workflow-data-service";
33

4-
// import * as path from "path";
5-
// import * as constants from "../constants";
6-
74
const deviceDescriptorPrimaryKey = "identifier";
85

9-
// TODO: Rename this class to RunWorkflowService
106
export class BundleWorkflowService implements IBundleWorkflowService {
117
private liveSyncProcessesInfo: IDictionary<any> = {};
128

@@ -17,23 +13,33 @@ export class BundleWorkflowService implements IBundleWorkflowService {
1713
private $errors: IErrors,
1814
private $injector: IInjector,
1915
private $mobileHelper: Mobile.IMobileHelper,
20-
// private $fs: IFileSystem,
2116
private $logger: ILogger,
22-
// private $platformAddService: IPlatformAddService,
17+
private $platformService: IPlatformService,
2318
private $platformAddService: IPlatformAddService,
2419
private $platformBuildService: IPlatformBuildService,
2520
private $platformWatcherService: IPlatformWatcherService,
2621
private $pluginsService: IPluginsService,
2722
private $projectDataService: IProjectDataService,
2823
private $workflowDataService: WorkflowDataService
29-
// private $projectChangesService: IProjectChangesService
3024
) { }
3125

32-
// processInfo[projectDir] = {
33-
// deviceDescriptors, nativeFilesWatcher, jsFilesWatcher
34-
// }
26+
public async preparePlatform(platform: string, projectDir: string, options: IOptions): Promise<void> {
27+
const { nativePlatformData, projectData, addPlatformData, preparePlatformData } = this.$workflowDataService.createWorkflowData(platform, projectDir, options);
28+
29+
await this.$platformAddService.addPlatformIfNeeded(nativePlatformData, projectData, addPlatformData);
30+
await this.$platformService.preparePlatform(nativePlatformData, projectData, preparePlatformData);
31+
}
32+
33+
public async buildPlatform(platform: string, projectDir: string, options: IOptions): Promise<string> {
34+
const { nativePlatformData, projectData, buildPlatformData } = this.$workflowDataService.createWorkflowData(platform, projectDir, options);
35+
36+
await this.preparePlatform(platform, projectDir, options);
37+
const result = await this.$platformBuildService.buildPlatform(nativePlatformData, projectData, buildPlatformData);
38+
39+
return result;
40+
}
3541

36-
public async start(projectDir: string, deviceDescriptors: ILiveSyncDeviceInfo[], liveSyncInfo: ILiveSyncInfo): Promise<void> {
42+
public async runPlatform(projectDir: string, deviceDescriptors: ILiveSyncDeviceInfo[], liveSyncInfo: ILiveSyncInfo): Promise<void> {
3743
const projectData = this.$projectDataService.getProjectData(projectDir);
3844
await this.initializeSetup(projectData);
3945

@@ -81,21 +87,16 @@ export class BundleWorkflowService implements IBundleWorkflowService {
8187

8288
private async syncInitialDataOnDevice(device: Mobile.IDevice, deviceDescriptor: ILiveSyncDeviceInfo, projectData: IProjectData, liveSyncInfo: ILiveSyncInfo): Promise<void> {
8389
const { nativePlatformData: platformData, buildPlatformData } = this.$workflowDataService.createWorkflowData(device.deviceInfo.platform, projectData.projectDir, liveSyncInfo);
90+
8491
const outputPath = deviceDescriptor.outputPath || platformData.getBuildOutputPath(buildPlatformData);
8592
const packageFilePath = await this.$platformBuildService.buildPlatformIfNeeded(platformData, projectData, buildPlatformData, outputPath);
8693

8794
await this.$deviceInstallationService.installOnDeviceIfNeeded(device, platformData, projectData, buildPlatformData, packageFilePath, outputPath);
8895

8996
// TODO: Consider to improve this
9097
const platformLiveSyncService = this.getLiveSyncService(platformData.platformNameLowerCase);
91-
const liveSyncResultInfo = await platformLiveSyncService.fullSync({
92-
projectData,
93-
device,
94-
useHotModuleReload: liveSyncInfo.useHotModuleReload,
95-
watch: !liveSyncInfo.skipWatcher,
96-
force: liveSyncInfo.force,
97-
liveSyncDeviceInfo: deviceDescriptor
98-
});
98+
const { force, useHotModuleReload, skipWatcher } = liveSyncInfo;
99+
const liveSyncResultInfo = await platformLiveSyncService.fullSync({ force, useHotModuleReload, projectData, device, watch: !skipWatcher, liveSyncDeviceInfo: deviceDescriptor });
99100

100101
await this.$deviceRestartApplicationService.restartOnDevice(deviceDescriptor, projectData, liveSyncResultInfo, platformLiveSyncService);
101102
}

lib/services/workflow/platform-workflow-service.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +0,0 @@
1-
interface IPlatformWorkflowService {
2-
preparePlatform(platform: string, projectDir: string, options: IOptions): Promise<void>;
3-
buildPlatform(platform: string, projectDir: string, options: IOptions): Promise<string>;
4-
}
5-
6-
interface IDeviceWorkflowService {
7-
}
8-
9-
interface IAdditionalWorkflowOptions {
10-
platformParam?: string;
11-
nativePrepare?: INativePrepare;
12-
}

test/services/bundle-workflow-service.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Yok } from "../../lib/common/yok";
22
import { BundleWorkflowService } from "../../lib/services/bundle-workflow-service";
33
import { assert } from "chai";
4-
import { PlatformWorkflowService } from "../../lib/services/workflow/platform-workflow-service";
54

65
const deviceMap: IDictionary<any> = {
76
myiOSDevice: {
@@ -42,7 +41,7 @@ function createTestInjector(): IInjector {
4241
emit: () => ({}),
4342
startWatcher: () => ({})
4443
}));
45-
injector.register("platformWorkflowService", PlatformWorkflowService);
44+
injector.register("bundleWorkflowService", BundleWorkflowService);
4645
injector.register("pluginsService", ({}));
4746
injector.register("projectDataService", ({
4847
getProjectData: () => ({
@@ -102,7 +101,7 @@ describe("BundleWorkflowService", () => {
102101
};
103102

104103
const bundleWorkflowService: IBundleWorkflowService = injector.resolve("bundleWorkflowService");
105-
await bundleWorkflowService.start(projectDir, [iOSDeviceDescriptor], liveSyncInfo);
104+
await bundleWorkflowService.runPlatform(projectDir, [iOSDeviceDescriptor], liveSyncInfo);
106105

107106
assert.isTrue(isStartWatcherCalled);
108107
});
@@ -130,13 +129,13 @@ describe("BundleWorkflowService", () => {
130129
const injector = createTestInjector();
131130

132131
const actualAddedPlatforms: IPlatformData[] = [];
133-
const platformAddService: IPlatformAddService = injector.resolve("platformWorkflowService");
132+
const platformAddService: IPlatformAddService = injector.resolve("bundleWorkflowService");
134133
platformAddService.addPlatformIfNeeded = async (platformData: IPlatformData) => {
135134
actualAddedPlatforms.push(platformData);
136135
};
137136

138137
const bundleWorkflowService: IBundleWorkflowService = injector.resolve("bundleWorkflowService");
139-
await bundleWorkflowService.start(projectDir, testCase.connectedDevices, liveSyncInfo);
138+
await bundleWorkflowService.runPlatform(projectDir, testCase.connectedDevices, liveSyncInfo);
140139

141140
assert.deepEqual(actualAddedPlatforms.map(pData => pData.platformNameLowerCase), testCase.expectedAddedPlatforms);
142141
});
@@ -148,7 +147,7 @@ describe("BundleWorkflowService", () => {
148147
beforeEach(() => {
149148
injector = createTestInjector();
150149

151-
const platformAddService: IPlatformAddService = injector.resolve("platformWorkflowService");
150+
const platformAddService: IPlatformAddService = injector.resolve("bundleWorkflowService");
152151
platformAddService.addPlatformIfNeeded = async () => { return; };
153152

154153
const platformBuildService: IPlatformBuildService = injector.resolve("platformBuildService");

0 commit comments

Comments
 (0)