Skip to content

Cherry-pick "fix android with webpack" from master #2930

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
Jun 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ NativeScript CLI Changelog
* [Fixed #2892](https://github.com/NativeScript/nativescript-cli/issues/2892): Not copying the CFBundleURLTypes from the plist file to the project
* [Fixed #2916](https://github.com/NativeScript/nativescript-cli/issues/2916): If no device or emulator is attached `tns debug android` kills the commandline process and doesn't start an emulator
* [Fixed #2923](https://github.com/NativeScript/nativescript-cli/issues/2923): Fix asking for user email on postinstall
* [Fixed #2929](https://github.com/NativeScript/nativescript-cli/issues/2929): Android release builds with webpack disregards plugin's gradle dependencies.


3.1.0 (2017, June 22)
Expand Down
2 changes: 2 additions & 0 deletions lib/definitions/plugins.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ interface IPluginsService {
*/
getDependenciesFromPackageJson(projectDir: string): IPackageJsonDepedenciesResult;
validate(platformData: IPlatformData, projectData: IProjectData): Promise<void>;
preparePluginNativeCode(pluginData: IPluginData, platform: string, projectData: IProjectData): Promise<void>;
convertToPluginData(cacheData: any, projectDir: string): IPluginData;
}

interface IPackageJsonDepedenciesResult {
Expand Down
19 changes: 17 additions & 2 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export class PlatformService extends EventEmitter implements IPlatformService {
private $npm: INodePackageManager,
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $projectChangesService: IProjectChangesService,
private $analyticsService: IAnalyticsService) {
private $analyticsService: IAnalyticsService,
private $nodeModulesDependenciesBuilder: INodeModulesDependenciesBuilder) {
super();
}

Expand Down Expand Up @@ -223,13 +224,17 @@ export class PlatformService extends EventEmitter implements IPlatformService {
let platformData = this.$platformsData.getPlatformData(platform, projectData);
await this.$pluginsService.validate(platformData, projectData);

const bundle = appFilesUpdaterOptions.bundle;

await this.ensurePlatformInstalled(platform, platformTemplate, projectData, config);
let changesInfo = this.$projectChangesService.checkForChanges(platform, projectData, { bundle: appFilesUpdaterOptions.bundle, release: appFilesUpdaterOptions.release, provision: config.provision });
let changesInfo = this.$projectChangesService.checkForChanges(platform, projectData, { bundle, release: appFilesUpdaterOptions.release, provision: config.provision });

this.$logger.trace("Changes info in prepare platform:", changesInfo);

if (changesInfo.hasChanges) {
await this.cleanProject(platform, appFilesUpdaterOptions, platformData, projectData);
}
if (changesInfo.hasChanges || bundle) {
await this.preparePlatformCore(platform, appFilesUpdaterOptions, projectData, config, changesInfo, filesToSync);
this.$projectChangesService.savePrepareInfo(platform, projectData);
} else {
Expand Down Expand Up @@ -302,6 +307,16 @@ export class PlatformService extends EventEmitter implements IPlatformService {

if (!changesInfo || changesInfo.modulesChanged) {
await this.copyTnsModules(platform, projectData);
} else if (appFilesUpdaterOptions.bundle) {
let dependencies = this.$nodeModulesDependenciesBuilder.getProductionDependencies(projectData.projectDir);
for (let dependencyKey in dependencies) {
const dependency = dependencies[dependencyKey];
let isPlugin = !!dependency.nativescript;
if (isPlugin) {
let pluginData = this.$pluginsService.convertToPluginData(dependency, projectData.projectDir);
await this.$pluginsService.preparePluginNativeCode(pluginData, platform, projectData);
}
}
}

let directoryPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
Expand Down
4 changes: 2 additions & 2 deletions lib/services/plugins-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class PluginsService implements IPluginsService {
this.$projectFilesManager.processPlatformSpecificFiles(pluginScriptsDestinationPath, platform);
}

private async preparePluginNativeCode(pluginData: IPluginData, platform: string, projectData: IProjectData): Promise<void> {
public async preparePluginNativeCode(pluginData: IPluginData, platform: string, projectData: IProjectData): Promise<void> {
let platformData = this.$platformsData.getPlatformData(platform, projectData);

pluginData.pluginPlatformsFolderPath = (_platform: string) => path.join(pluginData.fullPath, "platforms", _platform);
Expand Down Expand Up @@ -228,7 +228,7 @@ export class PluginsService implements IPluginsService {
};
}

private convertToPluginData(cacheData: any, projectDir: string): IPluginData {
public convertToPluginData(cacheData: any, projectDir: string): IPluginData {
let pluginData: any = {};
pluginData.name = cacheData.name;
pluginData.version = cacheData.version;
Expand Down
1 change: 1 addition & 0 deletions test/platform-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ function createTestInjector() {
testInjector.register("injector", testInjector);
testInjector.register("hooksService", stubs.HooksServiceStub);
testInjector.register("staticConfig", StaticConfigLib.StaticConfig);
testInjector.register("nodeModulesDependenciesBuilder", {});
testInjector.register('platformService', PlatformServiceLib.PlatformService);
testInjector.register('errors', ErrorsNoFailStub);
testInjector.register('logger', stubs.LoggerStub);
Expand Down
1 change: 1 addition & 0 deletions test/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function createTestInjector() {
testInjector.register('platformService', PlatformServiceLib.PlatformService);
testInjector.register('errors', stubs.ErrorsStub);
testInjector.register('logger', stubs.LoggerStub);
testInjector.register("nodeModulesDependenciesBuilder", {});
testInjector.register('npmInstallationManager', stubs.NpmInstallationManagerStub);
testInjector.register('projectData', stubs.ProjectDataStub);
testInjector.register('platformsData', stubs.PlatformsDataStub);
Expand Down