Skip to content

Commit bc9d242

Browse files
committed
feat(sidekick): Support for clean option in Sidekick when executing local builds
* Expose cleanNativeApp method for Sidekick * Fix run, deploy and build commands when clean option is specified * Fix help of build and deploy commands
1 parent 27e937b commit bc9d242

File tree

7 files changed

+24
-3
lines changed

7 files changed

+24
-3
lines changed

docs/man_pages/project/testing/build-android.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Builds the project for Android and produces an APK that you can manually deploy
1313

1414
### Options
1515
* `--compileSdk` - Sets the Android SDK that will be used to build the project.
16+
* `--clean` - If set, forces rebuilding the native application.
1617
* `--release` - If set, produces a release build. Otherwise, produces a debug build. When set, you must also specify the `--key-store-*` options.
1718
* `--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.
1819
* `--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.

docs/man_pages/project/testing/deploy.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Prepares, builds and deploys the project to a connected physical or virtual devi
2121

2222
### Options<% if(isMacOS) { %> for Android<% } %>
2323
* `--device` - Deploys the project on the specified connected physical or virtual device.
24+
* `--clean` - If set, forces rebuilding the native application.
2425
* `--release` - If set, produces a release build. Otherwise, produces a debug build. When set, you must also specify the `--key-store-*` options.
2526
* `--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.
2627
* `--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.

lib/commands/build.ts

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export class BuildCommandBase extends BundleBase {
2626
};
2727

2828
await this.$platformService.preparePlatform(platformInfo);
29-
this.$options.clean = true;
3029
const buildConfig: IBuildConfig = {
3130
buildForDevice: this.$options.forDevice,
3231
projectDir: this.$options.path,

lib/common

Submodule common updated 1 file

lib/definitions/project.d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,16 @@ interface ILocalBuildService {
167167
* @return {Promise<string>} Path to the build output.
168168
*/
169169
build(platform: string, platformBuildOptions: IPlatformBuildData, platformTemplate?: string): Promise<string>;
170+
/**
171+
* Removes build artifacts specific to the platform
172+
* @param {ICleanNativeAppData} data Data describing the clean app process
173+
* @returns {void}
174+
*/
175+
cleanNativeApp(data: ICleanNativeAppData): Promise<void>;
170176
}
171177

178+
interface ICleanNativeAppData extends IProjectDir, IPlatform { }
179+
172180
interface IPlatformProjectService extends NodeJS.EventEmitter {
173181
getPlatformData(projectData: IProjectData): IPlatformData;
174182
validate(projectData: IProjectData): Promise<void>;

lib/services/local-build-service.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ export class LocalBuildService extends EventEmitter implements ILocalBuildServic
66
constructor(private $projectData: IProjectData,
77
private $mobileHelper: Mobile.IMobileHelper,
88
private $errors: IErrors,
9-
private $platformService: IPlatformService) {
9+
private $platformsData: IPlatformsData,
10+
private $platformService: IPlatformService,
11+
private $projectDataService: IProjectDataService) {
1012
super();
1113
}
1214

@@ -41,6 +43,12 @@ export class LocalBuildService extends EventEmitter implements ILocalBuildServic
4143
await attachAwaitDetach(BUILD_OUTPUT_EVENT_NAME, this.$platformService, handler, this.$platformService.buildPlatform(platform, platformBuildOptions, this.$projectData));
4244
return this.$platformService.lastOutputPath(platform, platformBuildOptions, this.$projectData);
4345
}
46+
47+
public async cleanNativeApp(data: ICleanNativeAppData): Promise<void> {
48+
const projectData = this.$projectDataService.getProjectData(data.projectDir);
49+
const platformData = this.$platformsData.getPlatformData(data.platform, projectData);
50+
await platformData.platformProjectService.cleanProject(platformData.projectRoot, projectData);
51+
}
4452
}
4553

4654
$injector.register("localBuildService", LocalBuildService);

lib/services/platform-service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,10 @@ export class PlatformService extends EventEmitter implements IPlatformService {
388388
});
389389

390390
const platformData = this.$platformsData.getPlatformData(platform, projectData);
391+
if (buildConfig.clean) {
392+
await platformData.platformProjectService.cleanProject(platformData.projectRoot, projectData);
393+
}
394+
391395
const handler = (data: any) => {
392396
this.emit(constants.BUILD_OUTPUT_EVENT_NAME, data);
393397
this.$logger.printInfoMessageOnSameLine(data.data.toString());

0 commit comments

Comments
 (0)