Skip to content

Separate native and JS prepare code #3116

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 2 commits into from
Nov 2, 2017
Merged

Conversation

nadyaA
Copy link
Contributor

@nadyaA nadyaA commented Sep 12, 2017

Create interfaces to separate the prepare functionality in js and native parts.
Ensure better isolation and encapsulation of project preparation process.

Merge after telerik/mobile-cli-lib#1018

#2968


interface IPreparePlatformNativeService extends IPreparePlatformService {

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line please

preparePlatform(platform: string, platformData: IPlatformData, appFilesUpdaterOptions: IAppFilesUpdaterOptions, projectData: IProjectData, platformSpecificData: IPlatformSpecificData, changesInfo?: IProjectChangesInfo, filesToSync?: Array<String>, projectFilesConfig?: IProjectFilesConfig): Promise<void>;
}

interface IPreparePlatformJSService extends IPreparePlatformService {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the purpose of the empty interfaces?

import { AppFilesUpdater } from "./app-files-updater";
import { EventEmitter } from "events";

export class PreparePlatformService extends EventEmitter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you extend EventEmitter, there's no emit anywhere in the services?

super($fs, $xmlValidator);
}

public async addPlatform(platformData: IPlatformData, frameworkDir: string, installedVersion: string, projectData: IProjectData, config: IPlatformOptions, platformTemplate: string, ): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comma after platformTemplate: string is incorrect

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the code is extracted from already existing one, but this method has too many parameters. Can you pass an object instead

@Mitko-Kerezov Mitko-Kerezov force-pushed the natanasova/prepare-service branch 5 times, most recently from bd17fd6 to 9495236 Compare October 23, 2017 06:18
@Mitko-Kerezov
Copy link
Contributor

Ping @nadyaA @rosen-vladimirov @TsvetanMilanov with some additional implementation

Copy link
Contributor Author

@nadyaA nadyaA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job! 👍 I cannot approve it as I am co-author.

* @param {IDeployPlatformOptions} deployOptions Various options that can manage the deploy operation.
* @param {IProjectData} projectData DTO with information about the project.
* @param {IAddPlatformCoreOptions} config Options required for project preparation/creation.
* @param {IDeployPlatformInfo} deployInfo Options required for project preparation.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there could be better definition for this interface as it is called deploy smth and nothing about deployment is said in the definition 🤔

@@ -293,15 +255,35 @@ export class PlatformService extends EventEmitter implements IPlatformService {

/* Hooks are expected to use "filesToSync" parameter, as to give plugin authors additional information about the sync process.*/
@helpers.hook('prepare')
private async preparePlatformCore(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, projectData: IProjectData, platformSpecificData: IPlatformSpecificData, changesInfo?: IProjectChangesInfo, filesToSync?: Array<String>, nativePrepare?: INativePrepare): Promise<void> {
private async preparePlatformCore(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, projectData: IProjectData, platformSpecificData: IPlatformSpecificData, env: Object, changesInfo?: IProjectChangesInfo, filesToSync?: string[], nativePrepare?: INativePrepare): Promise<void> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding new mandatory parameter changes method signature - is this okay with people using the hook?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this should be fine, people using the hook, use the name, for example hookArgs.filesToSync: https://github.com/NativeScript/nativescript-dev-sass/blob/master/lib/after-prepare.js#L17

@@ -15,6 +15,7 @@ export class Options extends commonOptionsLibPath.OptionsBase {
forDevice: { type: OptionType.Boolean },
provision: { type: OptionType.Object },
client: { type: OptionType.Boolean, default: true },
env: { type: OptionType.Object },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about uglify?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uglify will be passed as a regular options - --env.uglify, we've agreed with @sis0k0 on that behavior

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same applies for --env.snapshot

@rosen-vladimirov
Copy link
Contributor

run ci

Create interfaces to separate the prepare functionality in js and native parts.
Ensure better isolation and encapsulation of project preparation process.
@Mitko-Kerezov Mitko-Kerezov force-pushed the natanasova/prepare-service branch from 9495236 to 681512a Compare November 2, 2017 12:10
* Extract all code that webpack needs to replace into a single method
* Introduce a hook (`prepareJSApp`) for that method so it can be replaced
* Add additional check for when not to delete `App_Resources` directory when preparing JS so that whenever preparing natively we don't copy all the files twice
@Mitko-Kerezov Mitko-Kerezov force-pushed the natanasova/prepare-service branch from 681512a to 1dd1398 Compare November 2, 2017 14:36
@Mitko-Kerezov Mitko-Kerezov merged commit 8048869 into master Nov 2, 2017
@Mitko-Kerezov Mitko-Kerezov deleted the natanasova/prepare-service branch November 2, 2017 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants