Skip to content

feat(sidekick): Support clean option when executing local builds in Sidekick #3386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2018
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
1 change: 1 addition & 0 deletions docs/man_pages/project/testing/build-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Builds the project for Android and produces an APK that you can manually deploy

### Options
* `--compileSdk` - Sets the Android SDK that will be used to build the project.
* `--clean` - If set, forces rebuilding the native application.
* `--release` - If set, produces a release build. Otherwise, produces a debug build. When set, you must also specify the `--key-store-*` options.
* `--key-store-path` - Specifies the file path to the keystore file (P12) which you want to use to code sign your APK. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options.
* `--key-store-password` - Provides the password for the keystore file specified with `--key-store-path`. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options.
Expand Down
1 change: 1 addition & 0 deletions docs/man_pages/project/testing/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Prepares, builds and deploys the project to a connected physical or virtual devi

### Options<% if(isMacOS) { %> for Android<% } %>
* `--device` - Deploys the project on the specified connected physical or virtual device.
* `--clean` - If set, forces rebuilding the native application.
* `--release` - If set, produces a release build. Otherwise, produces a debug build. When set, you must also specify the `--key-store-*` options.
* `--key-store-path` - Specifies the file path to the keystore file (P12) which you want to use to code sign your APK. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options.
* `--key-store-password` - Provides the password for the keystore file specified with `--key-store-path`. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options.
Expand Down
1 change: 0 additions & 1 deletion lib/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export class BuildCommandBase extends BundleBase {
};

await this.$platformService.preparePlatform(platformInfo);
this.$options.clean = true;
const buildConfig: IBuildConfig = {
buildForDevice: this.$options.forDevice,
projectDir: this.$options.path,
Expand Down
2 changes: 1 addition & 1 deletion lib/common
Submodule common updated 1 files
+2 −5 helpers.ts
8 changes: 8 additions & 0 deletions lib/definitions/project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,16 @@ interface ILocalBuildService {
* @return {Promise<string>} Path to the build output.
*/
build(platform: string, platformBuildOptions: IPlatformBuildData, platformTemplate?: string): Promise<string>;
/**
* Removes build artifacts specific to the platform
* @param {ICleanNativeAppData} data Data describing the clean app process
* @returns {void}
*/
cleanNativeApp(data: ICleanNativeAppData): Promise<void>;
}

interface ICleanNativeAppData extends IProjectDir, IPlatform { }

interface IPlatformProjectService extends NodeJS.EventEmitter {
getPlatformData(projectData: IProjectData): IPlatformData;
validate(projectData: IProjectData): Promise<void>;
Expand Down
10 changes: 9 additions & 1 deletion lib/services/local-build-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export class LocalBuildService extends EventEmitter implements ILocalBuildServic
constructor(private $projectData: IProjectData,
private $mobileHelper: Mobile.IMobileHelper,
private $errors: IErrors,
private $platformService: IPlatformService) {
private $platformsData: IPlatformsData,
private $platformService: IPlatformService,
private $projectDataService: IProjectDataService) {
super();
}

Expand Down Expand Up @@ -41,6 +43,12 @@ export class LocalBuildService extends EventEmitter implements ILocalBuildServic
await attachAwaitDetach(BUILD_OUTPUT_EVENT_NAME, this.$platformService, handler, this.$platformService.buildPlatform(platform, platformBuildOptions, this.$projectData));
return this.$platformService.lastOutputPath(platform, platformBuildOptions, this.$projectData);
}

public async cleanNativeApp(data: ICleanNativeAppData): Promise<void> {
const projectData = this.$projectDataService.getProjectData(data.projectDir);
const platformData = this.$platformsData.getPlatformData(data.platform, projectData);
await platformData.platformProjectService.cleanProject(platformData.projectRoot, projectData);
}
}

$injector.register("localBuildService", LocalBuildService);
4 changes: 4 additions & 0 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ export class PlatformService extends EventEmitter implements IPlatformService {
});

const platformData = this.$platformsData.getPlatformData(platform, projectData);
if (buildConfig.clean) {
await platformData.platformProjectService.cleanProject(platformData.projectRoot, projectData);
}

const handler = (data: any) => {
this.emit(constants.BUILD_OUTPUT_EVENT_NAME, data);
this.$logger.printInfoMessageOnSameLine(data.data.toString());
Expand Down