Skip to content

Commit 3e44606

Browse files
committed
feat: introduce workflowDataService in order to handle the creation of all data related objects in one place
1 parent e295df8 commit 3e44606

40 files changed

+1417
-1003
lines changed

lib/bootstrap.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ $injector.require("platformValidationService", "./services/platform/platform-val
4242
$injector.require("platformCommandsService", "./services/platform/platform-commands-service");
4343
$injector.require("platformWatcherService", "./services/platform/platform-watcher-service");
4444

45+
$injector.require("deviceInstallationService", "./services/device/device-installation-service");
46+
$injector.require("deviceRestartApplicationService", "./services/device/device-restart-application-service");
47+
4548
$injector.require("platformWorkflowService", "./services/workflow/platform-workflow-service");
46-
$injector.require("deviceWorkflowService", "./services/workflow/device-workflow-service");
47-
$injector.require("runWorkflowService", "./services/workflow/run-workflow-service");
49+
$injector.require("workflowDataService", "./services/workflow/workflow-data-service");
4850
$injector.require("bundleWorkflowService", "./services/bundle-workflow-service");
4951

50-
$injector.require("platformWorkflowDataFactory", "./factory/platform-workflow-data-factory");
51-
5252
$injector.require("buildArtefactsService", "./services/build-artefacts-service");
5353

5454
$injector.require("debugDataService", "./services/debug-data-service");

lib/commands/appstore-upload.ts

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,28 @@ export class PublishIOS implements ICommand {
1414
private $prompter: IPrompter,
1515
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
1616
private $platformValidationService: IPlatformValidationService,
17-
private $platformBuildService: IPlatformBuildService,
18-
private $xcodebuildService: IXcodebuildService) {
17+
// private $platformBuildService: IPlatformBuildService,
18+
// private $xcodebuildService: IXcodebuildService
19+
) {
1920
this.$projectData.initializeProjectData();
2021
}
2122

22-
private get $platformsData(): IPlatformsData {
23-
return this.$injector.resolve("platformsData");
24-
}
23+
// private get $platformsData(): IPlatformsData {
24+
// return this.$injector.resolve("platformsData");
25+
// }
2526

2627
// This property was introduced due to the fact that the $platformService dependency
2728
// ultimately tries to resolve the current project's dir and fails if not executed from within a project
28-
private get $platformService(): IPlatformService {
29-
return this.$injector.resolve("platformService");
30-
}
29+
// private get $platformService(): IPlatformService {
30+
// return this.$injector.resolve("platformService");
31+
// }
3132

3233
public async execute(args: string[]): Promise<void> {
3334
let username = args[0];
3435
let password = args[1];
3536
const mobileProvisionIdentifier = args[2];
3637
const codeSignIdentity = args[3];
37-
let ipaFilePath = this.$options.ipa ? path.resolve(this.$options.ipa) : null;
38+
const ipaFilePath = this.$options.ipa ? path.resolve(this.$options.ipa) : null;
3839

3940
if (!username) {
4041
username = await this.$prompter.getString("Apple ID", { allowEmpty: false });
@@ -55,40 +56,45 @@ export class PublishIOS implements ICommand {
5556
this.$options.release = true;
5657

5758
if (!ipaFilePath) {
58-
const platform = this.$devicePlatformsConstants.iOS;
59+
// const platform = this.$devicePlatformsConstants.iOS;
5960
// No .ipa path provided, build .ipa on out own.
60-
const preparePlatformData: IPreparePlatformData = {
61-
release: this.$options.release,
62-
useHotModuleReload: false,
63-
env: this.$options.env,
64-
};
65-
const buildConfig: IBuildConfig = {
66-
projectDir: this.$options.path,
67-
release: this.$options.release,
68-
device: this.$options.device,
69-
provision: this.$options.provision,
70-
teamId: this.$options.teamId,
71-
buildForDevice: true,
72-
iCloudContainerEnvironment: this.$options.iCloudContainerEnvironment,
73-
mobileProvisionIdentifier,
74-
codeSignIdentity
75-
};
76-
77-
const platformData = this.$platformsData.getPlatformData(platform, this.$projectData);
78-
79-
if (mobileProvisionIdentifier || codeSignIdentity) {
80-
this.$logger.info("Building .ipa with the selected mobile provision and/or certificate.");
81-
// This is not very correct as if we build multiple targets we will try to sign all of them using the signing identity here.
82-
await this.$platformService.preparePlatform(platformData, this.$projectData, preparePlatformData);
83-
await this.$platformBuildService.buildPlatform(platformData, this.$projectData, buildConfig);
84-
ipaFilePath = this.$platformService.lastOutputPath(platform, buildConfig, this.$projectData);
85-
} else {
86-
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.");
87-
await this.$platformService.preparePlatform(platformData, this.$projectData, preparePlatformData);
88-
89-
ipaFilePath = await this.$xcodebuildService.buildForAppStore(platformData, this.$projectData, buildConfig);
90-
this.$logger.info(`Export at: ${ipaFilePath}`);
91-
}
61+
// const platformWorkflowData = {
62+
// release: this.$options.release,
63+
// useHotModuleReload: false,
64+
// env: this.$options.env,
65+
// platformParam: platform,
66+
// signingOptions: {
67+
// teamId: this.$options.teamId,
68+
// provision: this.$options.provision
69+
// }
70+
// };
71+
// const buildConfig: IBuildConfig = {
72+
// projectDir: this.$options.path,
73+
// release: this.$options.release,
74+
// device: this.$options.device,
75+
// provision: this.$options.provision,
76+
// teamId: this.$options.teamId,
77+
// buildForDevice: true,
78+
// iCloudContainerEnvironment: this.$options.iCloudContainerEnvironment,
79+
// mobileProvisionIdentifier,
80+
// codeSignIdentity
81+
// };
82+
83+
// const platformData = this.$platformsData.getPlatformData(platform, this.$projectData);
84+
85+
// if (mobileProvisionIdentifier || codeSignIdentity) {
86+
// this.$logger.info("Building .ipa with the selected mobile provision and/or certificate.");
87+
// // This is not very correct as if we build multiple targets we will try to sign all of them using the signing identity here.
88+
// await this.$platformService.preparePlatform(platformData, this.$projectData, platformWorkflowData);
89+
// await this.$platformBuildService.buildPlatform(platformData, this.$projectData, buildConfig);
90+
// ipaFilePath = this.$platformService.lastOutputPath(platform, buildConfig, this.$projectData);
91+
// } else {
92+
// 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.");
93+
// await this.$platformService.preparePlatform(platformData, this.$projectData, platformWorkflowData);
94+
95+
// ipaFilePath = await this.$xcodebuildService.buildForAppStore(platformData, this.$projectData, buildConfig);
96+
// this.$logger.info(`Export at: ${ipaFilePath}`);
97+
// }
9298
}
9399

94100
await this.$itmsTransporterService.upload({

lib/commands/build.ts

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
77
$projectData: IProjectData,
88
$platformsData: IPlatformsData,
99
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
10-
protected $platformWorkflowDataFactory: IPlatformWorkflowDataFactory,
11-
private $platformWorkflowService: IPlatformWorkflowService,
10+
protected $platformWorkflowService: IPlatformWorkflowService,
1211
$platformValidationService: IPlatformValidationService,
1312
private $bundleValidatorHelper: IBundleValidatorHelper,
1413
protected $logger: ILogger) {
@@ -18,26 +17,7 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
1817

1918
public async executeCore(args: string[]): Promise<string> {
2019
const platform = args[0].toLowerCase();
21-
22-
const buildConfig: IBuildConfig = {
23-
buildForDevice: this.$options.forDevice,
24-
iCloudContainerEnvironment: this.$options.iCloudContainerEnvironment,
25-
projectDir: this.$options.path,
26-
clean: this.$options.clean,
27-
teamId: this.$options.teamId,
28-
device: this.$options.device,
29-
provision: this.$options.provision,
30-
release: this.$options.release,
31-
keyStoreAlias: this.$options.keyStoreAlias,
32-
keyStorePath: this.$options.keyStorePath,
33-
keyStoreAliasPassword: this.$options.keyStoreAliasPassword,
34-
keyStorePassword: this.$options.keyStorePassword,
35-
androidBundle: this.$options.aab
36-
};
37-
38-
const platformData = this.$platformsData.getPlatformData(platform, this.$projectData);
39-
const workflowData = this.$platformWorkflowDataFactory.createPlatformWorkflowData(platform, this.$options);
40-
const outputPath = await this.$platformWorkflowService.buildPlatform(platformData, this.$projectData, workflowData, buildConfig);
20+
const outputPath = await this.$platformWorkflowService.buildPlatform(platform, this.$projectData.projectDir, this.$options);
4121

4222
return outputPath;
4323
}
@@ -76,12 +56,11 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
7656
$projectData: IProjectData,
7757
$platformsData: IPlatformsData,
7858
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
79-
$platformWorkflowDataFactory: IPlatformWorkflowDataFactory,
8059
$platformWorkflowService: IPlatformWorkflowService,
8160
$platformValidationService: IPlatformValidationService,
8261
$bundleValidatorHelper: IBundleValidatorHelper,
8362
$logger: ILogger) {
84-
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformWorkflowDataFactory, $platformWorkflowService, $platformValidationService, $bundleValidatorHelper, $logger);
63+
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformWorkflowService, $platformValidationService, $bundleValidatorHelper, $logger);
8564
}
8665

8766
public async execute(args: string[]): Promise<void> {
@@ -112,13 +91,12 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
11291
$projectData: IProjectData,
11392
$platformsData: IPlatformsData,
11493
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
115-
$platformWorkflowDataFactory: IPlatformWorkflowDataFactory,
11694
$platformWorkflowService: IPlatformWorkflowService,
11795
$platformValidationService: IPlatformValidationService,
11896
$bundleValidatorHelper: IBundleValidatorHelper,
11997
protected $androidBundleValidatorHelper: IAndroidBundleValidatorHelper,
12098
protected $logger: ILogger) {
121-
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformWorkflowDataFactory, $platformWorkflowService, $platformValidationService, $bundleValidatorHelper, $logger);
99+
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformWorkflowService, $platformValidationService, $bundleValidatorHelper, $logger);
122100
}
123101

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

lib/commands/prepare.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export class PrepareCommand extends ValidatePlatformCommandBase implements IComm
44
public allowedParameters = [this.$platformCommandParameter];
55

66
constructor($options: IOptions,
7-
private $platformWorkflowDataFactory: IPlatformWorkflowDataFactory,
87
private $platformWorkflowService: IPlatformWorkflowService,
98
$platformValidationService: IPlatformValidationService,
109
$projectData: IProjectData,
@@ -16,10 +15,8 @@ export class PrepareCommand extends ValidatePlatformCommandBase implements IComm
1615

1716
public async execute(args: string[]): Promise<void> {
1817
const platform = args[0];
19-
const platformData = this.$platformsData.getPlatformData(platform, this.$projectData);
20-
const workflowData = this.$platformWorkflowDataFactory.createPlatformWorkflowData(platform, this.$options);
2118

22-
await this.$platformWorkflowService.preparePlatform(platformData, this.$projectData, workflowData);
19+
await this.$platformWorkflowService.preparePlatform(platform, this.$projectData.projectDir, this.$options);
2320
}
2421

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

lib/common/definitions/mobile.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,7 @@ declare module Mobile {
983983
buildDevicePath(...args: string[]): string;
984984
correctDevicePath(filePath: string): string;
985985
isiOSTablet(deviceName: string): boolean;
986+
getDeviceFileContent(device: Mobile.IDevice, deviceFilePath: string, projectData: IProjectData): Promise<string>;
986987
}
987988

988989
interface IEmulatorHelper {

lib/common/mobile/mobile-helper.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import * as helpers from "../helpers";
2+
import * as shell from "shelljs";
3+
import * as temp from "temp";
24

35
export class MobileHelper implements Mobile.IMobileHelper {
46
private static DEVICE_PATH_SEPARATOR = "/";
57

68
constructor(private $errors: IErrors,
9+
private $fs: IFileSystem,
710
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants) { }
811

912
public get platformNames(): string[] {
@@ -58,5 +61,24 @@ export class MobileHelper implements Mobile.IMobileHelper {
5861
public isiOSTablet(deviceName: string): boolean {
5962
return deviceName && deviceName.toLowerCase().indexOf("ipad") !== -1;
6063
}
64+
65+
public async getDeviceFileContent(device: Mobile.IDevice, deviceFilePath: string, projectData: IProjectData): Promise<string> {
66+
temp.track();
67+
const uniqueFilePath = temp.path({ suffix: ".tmp" });
68+
const platform = device.deviceInfo.platform.toLowerCase();
69+
try {
70+
await device.fileSystem.getFile(deviceFilePath, projectData.projectIdentifiers[platform], uniqueFilePath);
71+
} catch (e) {
72+
return null;
73+
}
74+
75+
if (this.$fs.exists(uniqueFilePath)) {
76+
const text = this.$fs.readText(uniqueFilePath);
77+
shell.rm(uniqueFilePath);
78+
return text;
79+
}
80+
81+
return null;
82+
}
6183
}
6284
$injector.register("mobileHelper", MobileHelper);

lib/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ export const POST_INSTALL_COMMAND_NAME = "post-install-cli";
139139
export const ANDROID_RELEASE_BUILD_ERROR_MESSAGE = "When producing a release build, you need to specify all --key-store-* options.";
140140
export const CACACHE_DIRECTORY_NAME = "_cacache";
141141

142+
export const FILES_CHANGE_EVENT_NAME = "filesChangeEventData";
143+
export const INITIAL_SYNC_EVENT_NAME = "initialSyncEventData";
144+
142145
export class DebugCommandErrors {
143146
public static UNABLE_TO_USE_FOR_DEVICE_AND_EMULATOR = "The options --for-device and --emulator cannot be used simultaneously. Please use only one of them.";
144147
public static NO_DEVICES_EMULATORS_FOUND_FOR_OPTIONS = "Unable to find device or emulator for specified options.";

lib/declarations.d.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,8 @@ interface IBuildArtefactsService {
10621062
}
10631063

10641064
interface IPlatformAddService {
1065-
addPlatform(addPlatformData: IAddPlatformData, projectData: IProjectData): Promise<void>;
1065+
addPlatform(projectData: IProjectData, addPlatformData: any): Promise<void>;
1066+
addPlatformIfNeeded(platformData: IPlatformData, projectData: IProjectData, addPlatformData: any): Promise<void>;
10661067
}
10671068

10681069
interface IPlatformCommandsService {
@@ -1079,10 +1080,4 @@ interface IAddPlatformData {
10791080
platformParam: string;
10801081
frameworkPath?: string;
10811082
nativePrepare?: INativePrepare;
1082-
}
1083-
1084-
interface IPlatformBuildService {
1085-
buildPlatform(platformData: IPlatformData, projectData: IProjectData, buildConfig: IBuildConfig): Promise<string>;
1086-
saveBuildInfoFile(platformData: IPlatformData, projectData: IProjectData, buildInfoFileDirname: string): void;
1087-
getBuildInfoFromFile(platformData: IPlatformData, buildConfig: IBuildConfig, buildOutputPath?: string): IBuildInfo;
1088-
}
1083+
}

lib/definitions/livesync.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,10 @@ declare global {
264264
getLiveSyncDeviceDescriptors(projectDir: string): ILiveSyncDeviceInfo[];
265265
}
266266

267+
// TODO: Rename this interface and change method's definition
267268
interface ILiveSyncService2 {
268-
fullSync(device: Mobile.IDevice, deviceBuildInfoDescriptor: ILiveSyncDeviceInfo, projectData: IProjectData, liveSyncInfo: ILiveSyncInfo): Promise<ILiveSyncResultInfo>;
269+
syncInitialDataOnDevice(device: Mobile.IDevice, deviceBuildInfoDescriptor: ILiveSyncDeviceInfo, projectData: IProjectData, liveSyncInfo: ILiveSyncInfo): Promise<ILiveSyncResultInfo>;
270+
syncChangedDataOnDevice(device: Mobile.IDevice, filesToSync: string[], liveSyncDeviceInfo: ILiveSyncDeviceInfo, projectData: IProjectData, liveSyncInfo: ILiveSyncInfo): Promise<ILiveSyncResultInfo>;
269271
}
270272

271273
/**
@@ -359,7 +361,6 @@ declare global {
359361
filesToRemove: string[];
360362
filesToSync: string[];
361363
isReinstalled: boolean;
362-
syncAllFiles: boolean;
363364
liveSyncDeviceInfo: ILiveSyncDeviceInfo;
364365
hmrData: IPlatformHmrData;
365366
force?: boolean;

0 commit comments

Comments
 (0)