Skip to content

Commit

Permalink
fix android with webpack (#2925)
Browse files Browse the repository at this point in the history
  • Loading branch information
PanayotCankov authored Jun 27, 2017
1 parent fb869c0 commit 7f9c201
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
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

0 comments on commit 7f9c201

Please sign in to comment.