Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ $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("debugDataService", "./services/debug-data-service");
$injector.requirePublicClass("debugService", "./services/debug-service");
Expand Down
13 changes: 11 additions & 2 deletions lib/commands/appstore-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ export class PublishIOS implements ICommand {
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 };
const platformInfo: IPreparePlatformInfo = {
platform,
appFilesUpdaterOptions,
platformTemplate: this.$options.platformTemplate,
projectData: this.$projectData,
config: this.$options,
env: this.$options.env
};

if (mobileProvisionIdentifier || codeSignIdentity) {
const iOSBuildConfig: IBuildConfig = {
projectDir: this.$options.path,
Expand All @@ -70,12 +79,12 @@ export class PublishIOS implements ICommand {
};
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(platform, appFilesUpdaterOptions, this.$options.platformTemplate, this.$projectData, this.$options);
await this.$platformService.preparePlatform(platformInfo);
await this.$platformService.buildPlatform(platform, iOSBuildConfig, this.$projectData);
ipaFilePath = this.$platformService.lastOutputPath(platform, iOSBuildConfig, 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(platform, appFilesUpdaterOptions, this.$options.platformTemplate, this.$projectData, this.$options);
await this.$platformService.preparePlatform(platformInfo);

const platformData = this.$platformsData.getPlatformData(platform, this.$projectData);
const iOSProjectService = <IOSProjectService>platformData.platformProjectService;
Expand Down
11 changes: 10 additions & 1 deletion lib/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ export class BuildCommandBase {
public async executeCore(args: string[]): Promise<void> {
const platform = args[0].toLowerCase();
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
await this.$platformService.preparePlatform(platform, appFilesUpdaterOptions, this.$options.platformTemplate, this.$projectData, this.$options);
const platformInfo: IPreparePlatformInfo = {
platform,
appFilesUpdaterOptions,
platformTemplate: this.$options.platformTemplate,
projectData: this.$projectData,
config: this.$options,
env: this.$options.env
};

await this.$platformService.preparePlatform(platformInfo);
this.$options.clean = true;
const buildConfig: IBuildConfig = {
buildForDevice: this.$options.forDevice,
Expand Down
12 changes: 11 additions & 1 deletion lib/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ export class DeployOnDeviceCommand implements ICommand {
keyStorePassword: this.$options.keyStorePassword,
keyStorePath: this.$options.keyStorePath
};
return this.$platformService.deployPlatform(args[0], appFilesUpdaterOptions, deployOptions, this.$projectData, this.$options);

const deployPlatformInfo: IDeployPlatformInfo = {
platform: args[0],
appFilesUpdaterOptions,
deployOptions,
projectData: this.$projectData,
config: this.$options,
env: this.$options.env
};

return this.$platformService.deployPlatform(deployPlatformInfo);
}

public async canExecute(args: string[]): Promise<boolean> {
Expand Down
11 changes: 10 additions & 1 deletion lib/commands/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ export class PrepareCommand implements ICommand {

public async execute(args: string[]): Promise<void> {
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
await this.$platformService.preparePlatform(args[0], appFilesUpdaterOptions, this.$options.platformTemplate, this.$projectData, this.$options);
const platformInfo: IPreparePlatformInfo = {
platform: args[0],
appFilesUpdaterOptions,
platformTemplate: this.$options.platformTemplate,
projectData: this.$projectData,
config: this.$options,
env: this.$options.env
};

await this.$platformService.preparePlatform(platformInfo);
}

public async canExecute(args: string[]): Promise<boolean> {
Expand Down
2 changes: 1 addition & 1 deletion lib/common
8 changes: 6 additions & 2 deletions lib/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ interface IPort {
port: Number;
}

interface IOptions extends ICommonOptions, IBundle, IPlatformTemplate, IEmulator, IClean, IProvision, ITeamIdentifier, IAndroidReleaseOptions, INpmInstallConfigurationOptions, IPort {
interface IOptions extends ICommonOptions, IBundle, IPlatformTemplate, IEmulator, IClean, IProvision, ITeamIdentifier, IAndroidReleaseOptions, INpmInstallConfigurationOptions, IPort, IEnvOptions {
all: boolean;
client: boolean;
compileSdk: number;
Expand All @@ -395,11 +395,15 @@ interface IOptions extends ICommonOptions, IBundle, IPlatformTemplate, IEmulator
chrome: boolean;
}

interface IEnvOptions {
env: Object;
}

interface IAndroidBuildOptionsSettings extends IAndroidReleaseOptions, IRelease { }

interface IAppFilesUpdaterOptions extends IBundle, IRelease { }

interface IPlatformBuildData extends IAppFilesUpdaterOptions, IBuildConfig { }
interface IPlatformBuildData extends IAppFilesUpdaterOptions, IBuildConfig, IEnvOptions { }

interface IDeviceEmulator extends IEmulator, IDeviceIdentifier { }

Expand Down
15 changes: 8 additions & 7 deletions lib/definitions/livesync.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ interface ILiveSyncDeviceInfo extends IOptionalOutputPath, IOptionalDebuggingOpt
/**
* Describes a LiveSync operation.
*/
interface ILiveSyncInfo extends IProjectDir {
interface ILiveSyncInfo extends IProjectDir, IEnvOptions {
/**
* Defines if the watcher should be skipped. If not passed, fs.Watcher will be started.
*/
Expand Down Expand Up @@ -145,14 +145,17 @@ interface ILiveSyncBuildInfo extends IIsEmulator, IPlatform {
pathToBuildItem: string;
}

interface IProjectDataComposition {
projectData: IProjectData;
}

/**
* Desribes object that can be passed to ensureLatestAppPackageIsInstalledOnDevice method.
*/
interface IEnsureLatestAppPackageIsInstalledOnDeviceOptions {
interface IEnsureLatestAppPackageIsInstalledOnDeviceOptions extends IProjectDataComposition, IEnvOptions {
device: Mobile.IDevice;
preparedPlatforms: string[];
rebuiltInformation: ILiveSyncBuildInfo[];
projectData: IProjectData;
deviceBuildInfoDescriptor: ILiveSyncDeviceInfo;
settings: ILatestAppPackageInstalledSettings;
liveSyncData?: ILiveSyncInfo;
Expand Down Expand Up @@ -273,8 +276,7 @@ interface IShouldSkipEmitLiveSyncNotification {
interface IAttachDebuggerOptions extends IDebuggingAdditionalOptions, IEnableDebuggingDeviceOptions, IIsEmulator, IPlatform, IOptionalOutputPath {
}

interface ILiveSyncWatchInfo {
projectData: IProjectData;
interface ILiveSyncWatchInfo extends IProjectDataComposition {
filesToRemove: string[];
filesToSync: string[];
isReinstalled: boolean;
Expand All @@ -289,8 +291,7 @@ interface ILiveSyncResultInfo {
useLiveEdit?: boolean;
}

interface IFullSyncInfo {
projectData: IProjectData;
interface IFullSyncInfo extends IProjectDataComposition {
device: Mobile.IDevice;
watch: boolean;
syncAllFiles: boolean;
Expand Down
71 changes: 57 additions & 14 deletions lib/definitions/platform.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,10 @@ interface IPlatformService extends NodeJS.EventEmitter {
* When there are changes to be prepared, it prepares the native project for the specified platform.
* When finishes, prepare saves the .nsprepareinfo file in platform folder.
* This file contains information about current project configuration and allows skipping unnecessary build, deploy and livesync steps.
* @param {string} platform The platform to be prepared.
* @param {IAppFilesUpdaterOptions} appFilesUpdaterOptions Options needed to instantiate AppFilesUpdater class.
* @param {string} platformTemplate The name of the platform template.
* @param {IProjectData} projectData DTO with information about the project.
* @param {IAddPlatformCoreOptions} config Options required for project preparation/creation.
* @param {Array} filesToSync Files about to be synced to device.
* @param {IPreparePlatformInfo} platformInfo Options to control the preparation.
* @returns {boolean} true indicates that the platform was prepared.
*/
preparePlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, filesToSync?: Array<String>, nativePrepare?: INativePrepare): Promise<boolean>;
preparePlatform(platformInfo: IPreparePlatformInfo): Promise<boolean>;

/**
* Determines whether a build is necessary. A build is necessary when one of the following is true:
Expand Down Expand Up @@ -106,14 +101,10 @@ interface IPlatformService extends NodeJS.EventEmitter {
/**
* Executes prepare, build and installOnPlatform when necessary to ensure that the latest version of the app is installed on specified platform.
* - When --clean option is specified it builds the app on every change. If not, build is executed only when there are native changes.
* @param {string} platform The platform to deploy.
* @param {IAppFilesUpdaterOptions} appFilesUpdaterOptions Options needed to instantiate AppFilesUpdater class.
* @param {IDeployPlatformOptions} deployOptions Various options that can manage the deploy operation.
* @param {IProjectData} projectData DTO with information about the project.
* @param {IAddPlatformCoreOptions} config Options required for project preparation/creation.
* @param {IDeployPlatformInfo} deployInfo Options required for project preparation and deployment.
* @returns {void}
*/
deployPlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, deployOptions: IDeployPlatformOptions, projectData: IProjectData, config: IPlatformOptions): Promise<void>;
deployPlatform(deployInfo: IDeployPlatformInfo): Promise<void>;

/**
* Runs the application on specified platform. Assumes that the application is already build and installed. Fails if this is not true.
Expand Down Expand Up @@ -276,9 +267,19 @@ interface IPlatformsData {
getPlatformData(platform: string, projectData: IProjectData): IPlatformData;
}

interface IAppFilesUpdaterOptionsComposition {
appFilesUpdaterOptions: IAppFilesUpdaterOptions;
}

interface IJsNodeModulesData extends IPlatform, IProjectDataComposition, IAppFilesUpdaterOptionsComposition {
absoluteOutputPath: string;
lastModifiedTime: Date;
projectFilesConfig: IProjectFilesConfig;
}

interface INodeModulesBuilder {
prepareNodeModules(absoluteOutputPath: string, platform: string, lastModifiedTime: Date, projectData: IProjectData, projectFilesConfig: IProjectFilesConfig): Promise<void>;
prepareJSNodeModules(absoluteOutputPath: string, platform: string, lastModifiedTime: Date, projectData: IProjectData, projectFilesConfig: IProjectFilesConfig): Promise<void>;
prepareJSNodeModules(jsNodeModulesData: IJsNodeModulesData): Promise<void>;
cleanNodeModules(absoluteOutputPath: string, platform: string): void;
}

Expand All @@ -290,3 +291,45 @@ interface IBuildInfo {
prepareTime: string;
buildTime: string;
}

interface IPlatformDataComposition {
platformData: IPlatformData;
}

interface ICopyAppFilesData extends IProjectDataComposition, IAppFilesUpdaterOptionsComposition, IPlatformDataComposition { }

interface IPreparePlatformService {
addPlatform(info: IAddPlatformInfo): Promise<void>;
preparePlatform(config: IPreparePlatformJSInfo): Promise<void>;
}

interface IAddPlatformInfo extends IProjectDataComposition, IPlatformDataComposition {
frameworkDir: string;
installedVersion: string;
config: IPlatformOptions;
platformTemplate?: string;
}

interface IPreparePlatformJSInfo extends IPreparePlatformCoreInfo, ICopyAppFilesData {
projectFilesConfig?: IProjectFilesConfig;
}

interface IPreparePlatformCoreInfo extends IPreparePlatformInfoBase {
platformSpecificData: IPlatformSpecificData
changesInfo?: IProjectChangesInfo;
}

interface IPreparePlatformInfo extends IPreparePlatformInfoBase, IPlatformConfig, IPlatformTemplate { }

interface IPlatformConfig {
config: IPlatformOptions;
}

interface IPreparePlatformInfoBase extends IPlatform, IAppFilesUpdaterOptionsComposition, IProjectDataComposition, IEnvOptions {
filesToSync?: string[];
nativePrepare?: INativePrepare;
}

interface IDeployPlatformInfo extends IPlatform, IAppFilesUpdaterOptionsComposition, IProjectDataComposition, IPlatformConfig, IEnvOptions {
deployOptions: IDeployPlatformOptions
}
1 change: 1 addition & 0 deletions lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class Options extends commonOptionsLibPath.OptionsBase {
forDevice: { type: OptionType.Boolean },
provision: { type: OptionType.Object },
client: { type: OptionType.Boolean, default: true },
env: { type: OptionType.Object },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about uglify?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uglify will be passed as a regular options - --env.uglify, we've agreed with @sis0k0 on that behavior

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same applies for --env.snapshot

production: { type: OptionType.Boolean },
debugTransport: { type: OptionType.Boolean },
keyStorePath: { type: OptionType.String },
Expand Down
2 changes: 1 addition & 1 deletion lib/services/analytics/analytics-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ export class AnalyticsService extends AnalyticsServiceBase {

constructor(protected $logger: ILogger,
protected $options: IOptions,
protected $processService: IProcessService,
$staticConfig: Config.IStaticConfig,
$prompter: IPrompter,
$userSettingsService: UserSettings.IUserSettingsService,
$analyticsSettingsService: IAnalyticsSettingsService,
$osInfo: IOsInfo,
private $childProcess: IChildProcess,
protected $processService: IProcessService,
private $projectDataService: IProjectDataService,
private $mobileHelper: Mobile.IMobileHelper) {
super($logger, $options, $staticConfig, $processService, $prompter, $userSettingsService, $analyticsSettingsService, $osInfo);
Expand Down
16 changes: 13 additions & 3 deletions lib/services/livesync/livesync-command-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
private $platformsData: IPlatformsData,
private $analyticsService: IAnalyticsService,
private $errors: IErrors) {
this.$analyticsService.setShouldDispose(this.$options.justlaunch || !this.$options.watch);
this.$analyticsService.setShouldDispose(this.$options.justlaunch || !this.$options.watch);
}

public getPlatformsForOperation(platform: string): string[] {
Expand Down Expand Up @@ -74,7 +74,8 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
projectDir: this.$projectData.projectDir,
skipWatcher: !this.$options.watch,
watchAllFiles: this.$options.syncAllFiles,
clean: this.$options.clean
clean: this.$options.clean,
env: this.$options.env
};

await this.$liveSyncService.liveSync(deviceDescriptors, liveSyncInfo);
Expand All @@ -95,7 +96,16 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {

const availablePlatforms = this.getPlatformsForOperation(platform);
for (const currentPlatform of availablePlatforms) {
await this.$platformService.deployPlatform(currentPlatform, this.$options, deployOptions, this.$projectData, this.$options);
const deployPlatformInfo: IDeployPlatformInfo = {
platform: currentPlatform,
appFilesUpdaterOptions: this.$options,
deployOptions,
projectData: this.$projectData,
config: this.$options,
env: this.$options.env
};

await this.$platformService.deployPlatform(deployPlatformInfo);
await this.$platformService.startApplication(currentPlatform, runPlatformOptions, this.$projectData.projectId);
this.$platformService.trackProjectType(this.$projectData);
}
Expand Down
25 changes: 19 additions & 6 deletions lib/services/livesync/livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,21 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
options.preparedPlatforms.push(platform);

const platformSpecificOptions = options.deviceBuildInfoDescriptor.platformSpecificOptions || <IPlatformOptions>{};
await this.$platformService.preparePlatform(platform, {
bundle: false,
release: false,
}, null, options.projectData, platformSpecificOptions, options.modifiedFiles, nativePrepare);
const prepareInfo: IPreparePlatformInfo = {
platform,
appFilesUpdaterOptions: {
bundle: false,
release: false,
},
projectData: options.projectData,
env: options.env,
nativePrepare: nativePrepare,
filesToSync: options.modifiedFiles,
platformTemplate: null,
config: platformSpecificOptions
};

await this.$platformService.preparePlatform(prepareInfo);
}

const buildResult = await this.installedCachedAppPackage(platform, options);
Expand Down Expand Up @@ -447,7 +458,8 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
projectData,
deviceBuildInfoDescriptor,
liveSyncData,
settings
settings,
env: liveSyncData.env
}, { skipNativePrepare: deviceBuildInfoDescriptor.skipNativePrepare });

const liveSyncResultInfo = await this.getLiveSyncService(platform).fullSync({
Expand Down Expand Up @@ -551,7 +563,8 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
projectData,
deviceBuildInfoDescriptor,
settings: latestAppPackageInstalledSettings,
modifiedFiles: allModifiedFiles
modifiedFiles: allModifiedFiles,
env: liveSyncData.env
}, { skipNativePrepare: deviceBuildInfoDescriptor.skipNativePrepare });

const service = this.getLiveSyncService(device.deviceInfo.platform);
Expand Down
Loading