Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
89c5f6c
WIP
Fatme Apr 25, 2019
fb47b68
refactor: refactor platform add, platform prepare and platform build …
Fatme Apr 27, 2019
e295df8
feat: introduce initialSync workflow
Fatme Apr 28, 2019
3e44606
feat: introduce workflowDataService in order to handle the creation o…
Fatme May 1, 2019
68187de
chore: remove platform-workflow-service
Fatme May 1, 2019
eb52dd9
chore: add preparePlatformService and remove platformJSService and pl…
Fatme May 3, 2019
faaf337
refactor: refactor refreshApplication service
Fatme May 3, 2019
0e4109b
refactor: refactor bundleWorkflowService to mainController
Fatme May 3, 2019
73ee306
chore: rename deviceInstallAppService and deviceRefreshAppService so …
Fatme May 3, 2019
22f594e
refactor: introduce separate run-on-devices-controller
Fatme May 4, 2019
64427e9
refactor: extract debug specific logic to separate service
Fatme May 4, 2019
f2caa9d
chore: emit runOnDeviceStopperEvent
Fatme May 4, 2019
2b8d62c
feat: add env support to webpackCompilerService
Fatme May 4, 2019
042a043
feat: add support for fallbackFiles + hmr mode
Fatme May 5, 2019
e85daf7
fix: fix deploy command
Fatme May 5, 2019
046d6e9
fix: remove unneeded interfaces
Fatme May 5, 2019
f5f0836
feat: stop webpack and native watchers on stopRunOnDevices()
Fatme May 5, 2019
ed8410a
feat: remove preview-sync hook and integrate preview command to work …
Fatme May 5, 2019
29d7ad9
fix: remove livesyncService
Fatme May 5, 2019
4a9c967
fix: fix typo error in debugggingEnabled
Fatme May 5, 2019
2410493
fix: fix mainController tests, delete test/livesync-service and move …
Fatme May 5, 2019
666044d
refactor: refactor the prepare-platform tests
Fatme May 6, 2019
6ba3274
test: fix unit tests
Fatme May 6, 2019
762fcd6
fix: build the platform when there are native changes on initial sync…
Fatme May 8, 2019
6769a81
chore: fix lint errors
Fatme May 8, 2019
e6c7f98
chore: fix show the log needed from preview tests
Fatme May 9, 2019
66cfacf
fix: fix the initial sync to preview app
Fatme May 9, 2019
40d5b56
feat: introduce controller for each command
Fatme May 14, 2019
4fc6b8e
fix: rename platformsData to platformsDataService
Fatme May 15, 2019
297814e
fix: fix PR comments
Fatme May 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions PublicAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,6 @@ interface IDebugData {
*/
applicationIdentifier: string;

/**
* Path to .app built for iOS Simulator.
*/
pathToAppPackage?: string;

/**
* The name of the application, for example `MyProject`.
*/
Expand Down
38 changes: 29 additions & 9 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,32 @@ $injector.require("projectTemplatesService", "./services/project-templates-servi
$injector.require("projectNameService", "./services/project-name-service");
$injector.require("tnsModulesService", "./services/tns-modules-service");

$injector.require("platformsData", "./platforms-data");
$injector.require("platformService", "./services/platform-service");
$injector.require("preparePlatformJSService", "./services/prepare-platform-js-service");
$injector.require("preparePlatformNativeService", "./services/prepare-platform-native-service");
$injector.require("platformsDataService", "./services/platforms-data-service");
$injector.require("addPlatformService", "./services/platform/add-platform-service");
$injector.require("buildInfoFileService", "./services/build-info-file-service");
$injector.require("prepareNativePlatformService", "./services/platform/prepare-native-platform-service");
$injector.require("platformValidationService", "./services/platform/platform-validation-service");

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

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

$injector.require("runEmitter", "./emitters/run-emitter");
$injector.require("previewAppEmitter", "./emitters/preview-app-emitter");

$injector.require("platformController", "./controllers/platform-controller");
$injector.require("prepareController", "./controllers/prepare-controller");
$injector.require("buildController", "./controllers/build-controller");
$injector.require("deployController", "./controllers/deploy-controller");
$injector.require("runController", "./controllers/run-controller");
$injector.require("previewAppController", "./controllers/preview-app-controller");

$injector.require("prepareDataService", "./services/prepare-data-service");
$injector.require("buildDataService", "./services/build-data-service");

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

$injector.require("debugDataService", "./services/debug-data-service");
$injector.requirePublicClass("debugService", "./services/debug-service");
Expand All @@ -47,8 +69,6 @@ $injector.requirePublic("analyticsSettingsService", "./services/analytics-settin
$injector.require("analyticsService", "./services/analytics/analytics-service");
$injector.require("googleAnalyticsProvider", "./services/analytics/google-analytics-provider");

$injector.require("emulatorSettingsService", "./services/emulator-settings-service");

$injector.require("platformCommandParameter", "./platform-command-param");
$injector.requireCommand("create", "./commands/create-project");
$injector.requireCommand("generate", "./commands/generate");
Expand All @@ -66,8 +86,6 @@ $injector.requireCommand("debug|ios", "./commands/debug");
$injector.requireCommand("debug|android", "./commands/debug");

$injector.requireCommand("prepare", "./commands/prepare");
$injector.requireCommand("clean-app|ios", "./commands/clean-app");
$injector.requireCommand("clean-app|android", "./commands/clean-app");
$injector.requireCommand("build|ios", "./commands/build");
$injector.requireCommand("build|android", "./commands/build");
$injector.requireCommand("deploy", "./commands/deploy");
Expand Down Expand Up @@ -134,10 +152,10 @@ $injector.require("bundleValidatorHelper", "./helpers/bundle-validator-helper");
$injector.require("androidBundleValidatorHelper", "./helpers/android-bundle-validator-helper");
$injector.require("liveSyncCommandHelper", "./helpers/livesync-command-helper");
$injector.require("deployCommandHelper", "./helpers/deploy-command-helper");
$injector.require("platformCommandHelper", "./helpers/platform-command-helper");
$injector.require("optionsTracker", "./helpers/options-track-helper");

$injector.requirePublicClass("localBuildService", "./services/local-build-service");
$injector.requirePublicClass("liveSyncService", "./services/livesync/livesync-service");
$injector.require("LiveSyncSocket", "./services/livesync/livesync-socket");
$injector.requirePublicClass("androidLivesyncTool", "./services/livesync/android-livesync-tool");
$injector.require("androidLiveSyncService", "./services/livesync/android-livesync-service");
Expand Down Expand Up @@ -201,3 +219,5 @@ $injector.require("testInitializationService", "./services/test-initialization-s

$injector.require("networkConnectivityValidator", "./helpers/network-connectivity-validator");
$injector.requirePublic("cleanupService", "./services/cleanup-service");

$injector.require("webpackCompilerService", "./services/webpack/webpack-compiler-service");
13 changes: 7 additions & 6 deletions lib/commands/add-platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ export class AddPlatformCommand extends ValidatePlatformCommandBase implements I
public allowedParameters: ICommandParameter[] = [];

constructor($options: IOptions,
$platformService: IPlatformService,
private $platformCommandHelper: IPlatformCommandHelper,
$platformValidationService: IPlatformValidationService,
$projectData: IProjectData,
$platformsData: IPlatformsData,
$platformsDataService: IPlatformsDataService,
private $errors: IErrors) {
super($options, $platformsData, $platformService, $projectData);
super($options, $platformsDataService, $platformValidationService, $projectData);
this.$projectData.initializeProjectData();
}

public async execute(args: string[]): Promise<void> {
await this.$platformService.addPlatforms(args, this.$projectData, this.$options, this.$options.frameworkPath);
await this.$platformCommandHelper.addPlatforms(args, this.$projectData, this.$options.frameworkPath);
}

public async canExecute(args: string[]): Promise<ICanExecuteCommandOutput> {
Expand All @@ -23,9 +24,9 @@ export class AddPlatformCommand extends ValidatePlatformCommandBase implements I

let canExecute = true;
for (const arg of args) {
this.$platformService.validatePlatform(arg, this.$projectData);
this.$platformValidationService.validatePlatform(arg, this.$projectData);

if (!this.$platformService.isPlatformSupportedForOS(arg, this.$projectData)) {
if (!this.$platformValidationService.isPlatformSupportedForOS(arg, this.$projectData)) {
this.$errors.fail(`Applications for platform ${arg} can not be built on this OS`);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/commands/appstore-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ export class ListiOSApps implements ICommand {
private $logger: ILogger,
private $projectData: IProjectData,
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $platformService: IPlatformService,
private $platformValidationService: IPlatformValidationService,
private $errors: IErrors,
private $prompter: IPrompter) {
this.$projectData.initializeProjectData();
}

public async execute(args: string[]): Promise<void> {
if (!this.$platformService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) {
if (!this.$platformValidationService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) {
this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`);
}

Expand Down
66 changes: 17 additions & 49 deletions lib/commands/appstore-upload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as path from "path";
import { StringCommandParameter } from "../common/command-params";
import { BuildController } from "../controllers/build-controller";
import { IOSBuildData } from "../data/build-data";

export class PublishIOS implements ICommand {
public allowedParameters: ICommandParameter[] = [new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector),
Expand All @@ -13,20 +15,12 @@ export class PublishIOS implements ICommand {
private $options: IOptions,
private $prompter: IPrompter,
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $xcodebuildService: IXcodebuildService) {
private $buildController: BuildController,
private $platformValidationService: IPlatformValidationService
) {
this.$projectData.initializeProjectData();
}

private get $platformsData(): IPlatformsData {
return this.$injector.resolve("platformsData");
}

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

public async execute(args: string[]): Promise<void> {
let username = args[0];
let password = args[1];
Expand All @@ -51,50 +45,24 @@ export class PublishIOS implements ICommand {
}

this.$options.release = true;
const platform = this.$devicePlatformsConstants.iOS.toLowerCase();

if (!ipaFilePath) {
const platform = this.$devicePlatformsConstants.iOS;
// No .ipa path provided, build .ipa on out own.
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = {
bundle: !!this.$options.bundle,
release: this.$options.release,
useHotModuleReload: false
};
const platformInfo: IPreparePlatformInfo = {
platform,
appFilesUpdaterOptions,
projectData: this.$projectData,
config: this.$options,
env: this.$options.env
};
const buildConfig: IBuildConfig = {
projectDir: this.$options.path,
release: this.$options.release,
device: this.$options.device,
provision: this.$options.provision,
teamId: this.$options.teamId,
buildForDevice: true,
iCloudContainerEnvironment: this.$options.iCloudContainerEnvironment,
mobileProvisionIdentifier,
codeSignIdentity
};

if (mobileProvisionIdentifier || codeSignIdentity) {
this.$logger.info("Building .ipa with the selected mobile provision and/or certificate.");
// This is not very correct as if we build multiple targets we will try to sign all of them using the signing identity here.
await this.$platformService.preparePlatform(platformInfo);
await this.$platformService.buildPlatform(platform, buildConfig, this.$projectData);
ipaFilePath = this.$platformService.lastOutputPath(platform, buildConfig, this.$projectData);
} else {
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.");
await this.$platformService.preparePlatform(platformInfo);

const platformData = this.$platformsData.getPlatformData(platform, this.$projectData);
this.$logger.info("Building .ipa with the selected mobile provision and/or certificate.");

const exportPath = await this.$xcodebuildService.buildForAppStore(platformData, this.$projectData, buildConfig);
this.$logger.info("Export at: " + exportPath);
// As we need to build the package for device
this.$options.forDevice = true;

ipaFilePath = exportPath;
const buildData = new IOSBuildData(this.$projectData.projectDir, platform, this.$options);
ipaFilePath = await this.$buildController.prepareAndBuild(buildData);
} else {
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.");
const buildData = new IOSBuildData(this.$projectData.projectDir, platform, { ...this.$options, buildForAppStore: true });
ipaFilePath = await this.$buildController.prepareAndBuild(buildData);
this.$logger.info(`Export at: ${ipaFilePath}`);
}
}

Expand All @@ -107,7 +75,7 @@ export class PublishIOS implements ICommand {
}

public async canExecute(args: string[]): Promise<boolean> {
if (!this.$platformService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) {
if (!this.$platformValidationService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) {
this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`);
}

Expand Down
77 changes: 26 additions & 51 deletions lib/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,31 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
constructor($options: IOptions,
protected $errors: IErrors,
$projectData: IProjectData,
$platformsData: IPlatformsData,
$platformsDataService: IPlatformsDataService,
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
$platformService: IPlatformService,
protected $buildController: IBuildController,
$platformValidationService: IPlatformValidationService,
private $bundleValidatorHelper: IBundleValidatorHelper,
private $buildDataService: IBuildDataService,
protected $logger: ILogger) {
super($options, $platformsData, $platformService, $projectData);
super($options, $platformsDataService, $platformValidationService, $projectData);
this.$projectData.initializeProjectData();
}

public dashedOptions = {
watch: { type: OptionType.Boolean, default: false, hasSensitiveValue: false },
};

public async executeCore(args: string[]): Promise<string> {
const platform = args[0].toLowerCase();
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = {
bundle: !!this.$options.bundle,
release: this.$options.release,
useHotModuleReload: this.$options.hmr
};
const platformInfo: IPreparePlatformInfo = {
platform,
appFilesUpdaterOptions,
projectData: this.$projectData,
config: this.$options,
env: this.$options.env
};

await this.$platformService.preparePlatform(platformInfo);
const buildConfig: IBuildConfig = {
buildForDevice: this.$options.forDevice,
iCloudContainerEnvironment: this.$options.iCloudContainerEnvironment,
projectDir: this.$options.path,
clean: this.$options.clean,
teamId: this.$options.teamId,
device: this.$options.device,
provision: this.$options.provision,
release: this.$options.release,
keyStoreAlias: this.$options.keyStoreAlias,
keyStorePath: this.$options.keyStorePath,
keyStoreAliasPassword: this.$options.keyStoreAliasPassword,
keyStorePassword: this.$options.keyStorePassword,
androidBundle: this.$options.aab
};

const outputPath = await this.$platformService.buildPlatform(platform, buildConfig, this.$projectData);

if (this.$options.copyTo) {
this.$platformService.copyLastOutput(platform, this.$options.copyTo, buildConfig, this.$projectData);
} else {
this.$logger.info(`The build result is located at: ${outputPath}`);
}
const buildData = this.$buildDataService.getBuildData(this.$projectData.projectDir, platform, this.$options);
const outputPath = await this.$buildController.prepareAndBuild(buildData);

return outputPath;
}

protected validatePlatform(platform: string): void {
if (!this.$platformService.isPlatformSupportedForOS(platform, this.$projectData)) {
if (!this.$platformValidationService.isPlatformSupportedForOS(platform, this.$projectData)) {
this.$errors.fail(`Applications for platform ${platform} can not be built on this OS`);
}

Expand All @@ -78,7 +49,7 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
return false;
}

const result = await this.$platformService.validateOptions(this.$options.provision, this.$options.teamId, this.$projectData, platform);
const result = await this.$platformValidationService.validateOptions(this.$options.provision, this.$options.teamId, this.$projectData, platform);
return result;
}
}
Expand All @@ -89,16 +60,18 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
constructor(protected $options: IOptions,
$errors: IErrors,
$projectData: IProjectData,
$platformsData: IPlatformsData,
$platformsDataService: IPlatformsDataService,
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
$platformService: IPlatformService,
$buildController: IBuildController,
$platformValidationService: IPlatformValidationService,
$bundleValidatorHelper: IBundleValidatorHelper,
$logger: ILogger) {
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformService, $bundleValidatorHelper, $logger);
$logger: ILogger,
$buildDataService: IBuildDataService) {
super($options, $errors, $projectData, $platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $bundleValidatorHelper, $buildDataService, $logger);
}

public async execute(args: string[]): Promise<void> {
await this.executeCore([this.$platformsData.availablePlatforms.iOS]);
await this.executeCore([this.$devicePlatformsConstants.iOS.toLowerCase()]);
}

public async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> {
Expand All @@ -123,17 +96,19 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
constructor(protected $options: IOptions,
protected $errors: IErrors,
$projectData: IProjectData,
$platformsData: IPlatformsData,
platformsDataService: IPlatformsDataService,
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
$platformService: IPlatformService,
$buildController: IBuildController,
$platformValidationService: IPlatformValidationService,
$bundleValidatorHelper: IBundleValidatorHelper,
protected $androidBundleValidatorHelper: IAndroidBundleValidatorHelper,
$buildDataService: IBuildDataService,
protected $logger: ILogger) {
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformService, $bundleValidatorHelper, $logger);
super($options, $errors, $projectData, platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $bundleValidatorHelper, $buildDataService, $logger);
}

public async execute(args: string[]): Promise<void> {
await this.executeCore([this.$platformsData.availablePlatforms.Android]);
await this.executeCore([this.$devicePlatformsConstants.Android.toLowerCase()]);

if (this.$options.aab) {
this.$logger.info(AndroidAppBundleMessages.ANDROID_APP_BUNDLE_DOCS_MESSAGE);
Expand Down
Loading