-
-
Notifications
You must be signed in to change notification settings - Fork 196
fix: find correct apk name when --release passed #3419
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
lib/services/platform-service.ts
Outdated
@@ -431,15 +431,15 @@ export class PlatformService extends EventEmitter implements IPlatformService { | |||
this.$fs.writeJson(buildInfoFile, buildInfo); | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
release
param is not used in method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad, thank you
lib/services/platform-service.ts
Outdated
const platform = device.deviceInfo.platform; | ||
if (!(await device.applicationManager.isApplicationInstalled(projectData.projectId))) { | ||
return true; | ||
} | ||
|
||
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be release: release
lib/definitions/project.d.ts
Outdated
@@ -140,6 +140,7 @@ interface IPlatformProjectServiceBase { | |||
|
|||
interface IBuildForDevice { | |||
buildForDevice: boolean; | |||
release: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extends IRelease
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
lib/definitions/platform.d.ts
Outdated
@@ -76,7 +76,7 @@ interface IPlatformService extends NodeJS.EventEmitter { | |||
* @param {string} @optional outputPath Directory containing build information and artifacts. | |||
* @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bad practice to use boolean
parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it a bad practice to use boolean
parameters? Please elaborate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rosen-vladimirov thanks, I can see now why using a boolean parameter could be bad.
lib/definitions/platform.d.ts
Outdated
@@ -76,7 +76,7 @@ interface IPlatformService extends NodeJS.EventEmitter { | |||
* @param {string} @optional outputPath Directory containing build information and artifacts. | |||
* @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
lib/definitions/platform.d.ts
Outdated
@@ -255,7 +255,7 @@ interface IPlatformData { | |||
projectRoot: string; | |||
normalizedPlatformName: string; | |||
appDestinationDirectoryPath: string; | |||
deviceBuildOutputPath: string; | |||
deviceBuildOutputPath(options: IRelease): string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we should rename this property to getDeviceBuildOutputPath
as it is a better name for method.
lib/definitions/project.d.ts
Outdated
@@ -140,6 +140,7 @@ interface IPlatformProjectServiceBase { | |||
|
|||
interface IBuildForDevice { | |||
buildForDevice: boolean; | |||
release: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
lib/services/platform-service.ts
Outdated
@@ -431,15 +431,15 @@ export class PlatformService extends EventEmitter implements IPlatformService { | |||
this.$fs.writeJson(buildInfoFile, buildInfo); | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will changing the interface from IRelease
to IBuildConfig
achieve?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed and agreed to use IRelease
interface, only isRelease
name sounds like a boolean variable and suggest to rename it to release: IRelease
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After green build
7204eed
to
40f5074
Compare
problem
The CLI can't find
.apk
file to install on passed--release
option. Read more in this issuesolution
respect
--release
option when generating apk find path