fix: find correct apk name when --release passed#3419
Conversation
rosen-vladimirov
left a comment
There was a problem hiding this comment.
Using $options in service will make it unusable when CLI is used as a library. In this case, this will break local release builds in Sidekick, as the $options is not populated when CLI is not used on the command line.
Instead of using $options, the getDeviceBuildOutputPath should accept the build configuration. This requires changing the deviceBuildOutputPath to become a method and to be recalculated based on the passed options. The only place where deviceBuildOutputPath is used is here - you can directly pass the buildConfig object to the method.
|
@rosen-vladimirov thank's for explaining. Will fix it shortly. |
| } | ||
|
|
||
| public async shouldInstall(device: Mobile.IDevice, projectData: IProjectData, outputPath?: string): Promise<boolean> { | ||
| public async shouldInstall(device: Mobile.IDevice, projectData: IProjectData, release: boolean, outputPath?: string): Promise<boolean> { |
There was a problem hiding this comment.
release param is not used in method
There was a problem hiding this comment.
my bad, thank you
| const platformData = this.$platformsData.getPlatformData(platform, projectData); | ||
| const deviceBuildInfo: IBuildInfo = await this.getDeviceBuildInfo(device, projectData); | ||
| const localBuildInfo = this.getBuildInfo(platform, platformData, { buildForDevice: !device.isEmulator }, outputPath); | ||
| const localBuildInfo = this.getBuildInfo(platform, platformData, { buildForDevice: !device.isEmulator, release: false }, outputPath); |
|
|
||
| interface IBuildForDevice { | ||
| buildForDevice: boolean; | ||
| release: boolean; |
There was a problem hiding this comment.
The idea of IBuildForDevice interface is to be used whenever buildForDevice option is required.
Instead of using the IBuildForDevice interface, I suggest creating a new one that extends both IBuildForDevice and IRelease. The other option is to rename the current one, as the current properties are not required only for IBuildForDevice implementation.
| * @returns {Promise<boolean>} true indicates that the application should be installed. | ||
| */ | ||
| shouldInstall(device: Mobile.IDevice, projectData: IProjectData, outputPath?: string): Promise<boolean>; | ||
| shouldInstall(device: Mobile.IDevice, projectData: IProjectData, release: boolean, outputPath?: string): Promise<boolean>; |
There was a problem hiding this comment.
It's a bad practice to use boolean parameters.
There was a problem hiding this comment.
Why is it a bad practice to use boolean parameters? Please elaborate.
There was a problem hiding this comment.
Passing boolean as an argument makes the call to the method unreadable.
For the current case, when you call the method, you'll write:
await this.$platformService.shouldInstall(deviceInstance, projectData, false);You have no idea what does this false do. When you try to read the flow of the code, you cannot tell why the value false is passed. In such cases it is recommended to pass object with boolean property, for example:
shouldInstall(device: Mobile.IDevice, projectData: IProjectData, buildOptions: IRelease, outputPath?: string): Promise<boolean>;and the call will be:
await this.$platformService.shouldInstall(deviceInstance, projectData, { release: false });This way there's no need to read the implementation of the method.
There was a problem hiding this comment.
@rosen-vladimirov thanks, I can see now why using a boolean parameter could be bad.
| * @returns {Promise<boolean>} true indicates that the application should be installed. | ||
| */ | ||
| shouldInstall(device: Mobile.IDevice, projectData: IProjectData, outputPath?: string): Promise<boolean>; | ||
| shouldInstall(device: Mobile.IDevice, projectData: IProjectData, release: boolean, outputPath?: string): Promise<boolean>; |
There was a problem hiding this comment.
Passing boolean as an argument makes the call to the method unreadable.
For the current case, when you call the method, you'll write:
await this.$platformService.shouldInstall(deviceInstance, projectData, false);You have no idea what does this false do. When you try to read the flow of the code, you cannot tell why the value false is passed. In such cases it is recommended to pass object with boolean property, for example:
shouldInstall(device: Mobile.IDevice, projectData: IProjectData, buildOptions: IRelease, outputPath?: string): Promise<boolean>;and the call will be:
await this.$platformService.shouldInstall(deviceInstance, projectData, { release: false });This way there's no need to read the implementation of the method.
| normalizedPlatformName: string; | ||
| appDestinationDirectoryPath: string; | ||
| deviceBuildOutputPath: string; | ||
| deviceBuildOutputPath(options: IRelease): string; |
There was a problem hiding this comment.
I believe we should rename this property to getDeviceBuildOutputPath as it is a better name for method.
|
|
||
| interface IBuildForDevice { | ||
| buildForDevice: boolean; | ||
| release: boolean; |
There was a problem hiding this comment.
The idea of IBuildForDevice interface is to be used whenever buildForDevice option is required.
Instead of using the IBuildForDevice interface, I suggest creating a new one that extends both IBuildForDevice and IRelease. The other option is to rename the current one, as the current properties are not required only for IBuildForDevice implementation.
| } | ||
|
|
||
| public async shouldInstall(device: Mobile.IDevice, projectData: IProjectData, outputPath?: string): Promise<boolean> { | ||
| public async shouldInstall(device: Mobile.IDevice, projectData: IProjectData, isRelease: IRelease, outputPath?: string): Promise<boolean> { |
There was a problem hiding this comment.
I suggest to reuse IBuildConfig interface as we pass here buildConfig https://github.com/NativeScript/nativescript-cli/pull/3419/files#diff-513fe963f5d821a1cdb167ea91d70f1cR335
There was a problem hiding this comment.
What will changing the interface from IRelease to IBuildConfig achieve?
There was a problem hiding this comment.
We discussed and agreed to use IRelease interface, only isRelease name sounds like a boolean variable and suggest to rename it to release: IRelease
rosen-vladimirov
left a comment
There was a problem hiding this comment.
After green build
7204eed to
40f5074
Compare
problem
The CLI can't find
.apkfile to install on passed--releaseoption. Read more in this issuesolution
respect
--releaseoption when generating apk find path