-
-
Notifications
You must be signed in to change notification settings - Fork 197
Allow local builds when {N} CLI is required as a library #2574
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
3c1cb0c
to
d56e0b6
Compare
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'm unable to prepare a project:
$ tns create app2
$ tns prepare ios
Validating before-prepare arguments.
Hook completed
Preparing project...
TypeError: Cannot read property 'projectName' of undefined
at IOSProjectService.getXcodeprojPath (/Users/vladimirov/Work/nativescript-cli/lib/services/ios-project-service.ts:696:78)
at IOSProjectService.getPbxProjPath (/Users/vladimirov/Work/nativescript-cli/lib/services/ios-project-service.ts:725:24)
at IOSProjectService.createPbxProj (/Users/vladimirov/Work/nativescript-cli/lib/services/ios-project-service.ts:729:39)
at IOSProjectService.<anonymous> (/Users/vladimirov/Work/nativescript-cli/lib/services/ios-project-service.ts:576:21)
at Generator.next (<anonymous>)
at <anonymous> (/Users/vladimirov/Work/nativescript-cli/lib/services/ios-project-service.js:7:65)
at __awaiter (/Users/vladimirov/Work/nativescript-cli/lib/services/ios-project-service.js:3:12)
at IOSProjectService.prepareProject (/Users/vladimirov/Work/nativescript-cli/lib/services/ios-project-service.js:528:16)
at PlatformService.<anonymous> (/Users/vladimirov/Work/nativescript-cli/lib/services/platform-service.ts:255:45)
at Generator.next (<anonymous>)
I'm unable to build as well:
tns build ios
Executing before-prepare hook from /Users/vladimirov/Work/nativescript-cli/scratch/app2/hooks/before-prepare/nativescript-dev-android-snapshot.js
Preparing project...
Cannot read property 'projectName' of undefined
lib/services/platform-service.ts
Outdated
} | ||
} | ||
@exportedPromise("platformService") | ||
public async build(platform: string, platformBuildOptions: IPlatformBuildData, platformTemplate?: string): Promise<void> { |
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 happened with the idea to place this method in a separate file, for example buildService
or localBuildService
.
We can $injector
resolve it only in the lib bootstrap. I imagine public API like:
require("nativescript").localBuildService.build("android", null);
require("nativescript").cloudBuildService.build("android", null);
lib/services/platform-service.ts
Outdated
@exportedPromise("platformService") | ||
public async build(platform: string, platformBuildOptions: IPlatformBuildData, platformTemplate?: string): Promise<void> { | ||
this.$projectData.initializeProjectData(platformBuildOptions.projectDir); | ||
await this.preparePlatform(platform, platformBuildOptions, platformTemplate, this.$projectData); |
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 think we can delete platformTemplate option. It's not used by our customers. The only usage is for our NativeScript developer app. As far as I remember, @TomaNikolov told me that we can safely remove it.
However we can handle this in a separate PR until we are sure we do not need this option.
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.
Given that there are this many changes already I'd personally prefer a separate PR
lib/services/platform-service.ts
Outdated
} | ||
|
||
private getBuildOutputPath(platform: string, platformData: IPlatformData, buildConfig?: IBuildConfig): string { | ||
let buildForDevice = buildConfig ? buildConfig.buildForDevice : this.$options.forDevice; | ||
private getBuildOutputPath(platform: string, platformData: IPlatformData, buildForDevice: boolean): 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.
Maybe you do not want to pass the whole build config, but passing boolean is not my favorite option. I would change the type of buildConfig to object, instead of IBuildConfig:
private getBuildOutputPath(platform: string, platformData: IPlatformData, buildConfig?: { buildForDevice: boolean }): string {
As per the question why passing boolean variable is not a great idea, I would like to remind you for your first PR in our CLIs:
Icenium/icenium-cli#672
lib/services/platform-service.ts
Outdated
return !localBuildInfo || !deviceBuildInfo || deviceBuildInfo.buildTime !== localBuildInfo.buildTime; | ||
} | ||
|
||
public async installApplication(device: Mobile.IDevice): Promise<void> { | ||
public async installApplication(device: Mobile.IDevice, release: boolean, projectData: IProjectData): Promise<void> { |
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 once again... not a merge stopper, but calling the method with:
installApplication(androidDevice, false, projectData);
Makes me curious what does this false do there...
lib/services/platform-service.ts
Outdated
} catch (e) { | ||
return null; | ||
} | ||
} | ||
|
||
private getBuildInfo(platform: string, platformData: IPlatformData, buildConfig: IBuildConfig): IBuildInfo { | ||
let buildInfoFilePath = this.getBuildOutputPath(platform, platformData, buildConfig); | ||
private getBuildInfo(platform: string, platformData: IPlatformData, buildForDevice: boolean): IBuildInfo { |
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.
again
private getBuildInfo(platform: string, platformData: IPlatformData, buildConfig?: { buildForDevice: boolean }): IBuildInfo {
clean: this.$options.clean, | ||
device: this.$options.device, | ||
release: this.$options.release, | ||
emulator: this.$options.emulator, |
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.
instead of setting the value of this.$options.emulator
to true, shouldn't we just set the emulator option here to true?
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 decided to reuse the variable 😇
lib/commands/plugin/update-plugin.ts
Outdated
pluginNames = installedPlugins.map(p => p.name); | ||
} | ||
|
||
for (let p of pluginNames) { | ||
await this.$pluginsService.remove(p); | ||
await this.$pluginsService.add(p); | ||
await this.$pluginsService.remove(p, this.$projectData); |
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.
can you please rename p
to plugin
or pluginName
. p
could be anything and it really disturbs me.
lib/declarations.ts
Outdated
interface INativeScriptDeviceLiveSyncService extends IDeviceLiveSyncServiceBase { | ||
/** | ||
* Refreshes the application's content on a device | ||
*/ |
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.
lib/declarations.ts
Outdated
/** | ||
* Removes specified files from a connected device | ||
*/ | ||
removeFiles(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[], projectId: string): Promise<void>; |
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.
lib/options.ts
Outdated
@@ -41,7 +40,7 @@ export class Options extends commonOptionsLibPath.OptionsBase { | |||
chrome: { type: OptionType.Boolean }, | |||
clean: { type: OptionType.Boolean }, | |||
watch: { type: OptionType.Boolean, default: true } | |||
}, | |||
}, |
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 ?
be043b4
to
c9dcae2
Compare
Includes: * Get rid of $projectData dependency in services * Introduce new service for calling build when required as a library * Emit build output when necessary
c9dcae2
to
f8f29e4
Compare
Ping @rosen-vladimirov fixed comments and rebased |
run ci |
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 no more than 3 failing QAs tests!
And please monitor the jenkins through the day for possible failures.
Also you should add the localBuildService
in the public api tests here: https://github.com/NativeScript/nativescript-cli/blob/master/test/nativescript-cli-lib.ts#L17
Aand information in PublicAPI.md please
f8f29e4
to
a5360b1
Compare
build
method inplatformService
which enables building when {N} CLI is requiredPing @rosen-vladimirov @TsvetanMilanov