Skip to content
Permalink
Browse files

fix(angular): fix adding @ionic/angular when using ng add (#17597)

closes #17596
  • Loading branch information...
ahasall authored and liamdebeasi committed Feb 27, 2019
1 parent 9b3a371 commit 484d92cd50247ede9f5b9bd4859591c9ee684006
Showing with 12 additions and 10 deletions.
  1. +10 −9 angular/src/schematics/add/index.ts
  2. +2 −1 angular/src/schematics/utils/ast.ts
@@ -1,20 +1,20 @@
import {
Rule,
SchematicContext,
SchematicsException,
Tree,
apply,
chain,
mergeWith,
move,
Rule,
SchematicContext,
SchematicsException,
template,
Tree,
url
} from '@angular-devkit/schematics';
import { Path, join } from '@angular-devkit/core';
import { join, Path } from '@angular-devkit/core';
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
import { addPackageToPackageJson } from './../utils/package';
import { addModuleImportToRootModule } from './../utils/ast';
import { addStyle, getWorkspace, addArchitectBuilder } from './../utils/config';
import { addArchitectBuilder, addStyle, getWorkspace } from './../utils/config';
import { Schema as IonAddOptions } from './schema';

function addIonicAngularToPackageJson(): Rule {
@@ -36,10 +36,11 @@ function addIonicAngularToolkitToPackageJson(): Rule {
};
}

function addIonicAngularModuleToAppModule(): Rule {
function addIonicAngularModuleToAppModule(projectSourceRoot): Rule {
return (host: Tree) => {
addModuleImportToRootModule(
host,
projectSourceRoot,
'IonicModule.forRoot()',
'@ionic/angular'
);
@@ -118,14 +119,14 @@ export default function ngAdd(options: IonAddOptions): Rule {

const sourcePath = join(project.root as Path, 'src');
const rootTemplateSource = apply(url('./files/root'), [
template({ ...options }),
template({...options}),
move(sourcePath)
]);
return chain([
// @ionic/angular
addIonicAngularToPackageJson(),
addIonicAngularToolkitToPackageJson(),
addIonicAngularModuleToAppModule(),
addIonicAngularModuleToAppModule(sourcePath),
addIonicBuilder(),
addIonicStyles(),
mergeWith(rootTemplateSource),
@@ -27,12 +27,13 @@ export function getSourceFile(host: Tree, path: string): ts.SourceFile {
*/
export function addModuleImportToRootModule(
host: Tree,
projectSourceRoot,
moduleName: string,
importSrc: string
) {
addModuleImportToModule(
host,
normalize(`src/app/app.module.ts`),
normalize(`${projectSourceRoot}/app/app.module.ts`),
moduleName,
importSrc
);

0 comments on commit 484d92c

Please sign in to comment.
You can’t perform that action at this time.