From 6ab3a818410cfdaf9a99925d54b48429601c8f2d Mon Sep 17 00:00:00 2001 From: Austin Date: Mon, 4 Jun 2018 10:22:03 -0500 Subject: [PATCH 1/3] fix(schematics): add parse5 dep --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 1210a712e0e9..a56f7cad66a8 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "rxjs": "6.0.0", "systemjs": "0.19.43", "tsickle": "^0.27.2", + "parse5": "^5.0.0", "tslib": "^1.9.0", "zone.js": "^0.8.26" }, From 05fde4612fbe6125abd79683ba773499b78a207e Mon Sep 17 00:00:00 2001 From: Austin Date: Fri, 15 Jun 2018 10:28:01 -0500 Subject: [PATCH 2/3] chore: pr feedback --- package.json | 4 +++- src/lib/schematics/utils/html.ts | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c46b589b82ff..251ed8436212 100644 --- a/package.json +++ b/package.json @@ -38,10 +38,12 @@ "rxjs": "6.0.0", "systemjs": "0.19.43", "tsickle": "^0.27.2", - "parse5": "^5.0.0", "tslib": "^1.9.0", "zone.js": "^0.8.26" }, + "optionalDependencies": { + "parse5": "^5.0.0" + }, "devDependencies": { "@angular-devkit/core": "^0.5.12", "@angular-devkit/schematics": "^0.5.12", diff --git a/src/lib/schematics/utils/html.ts b/src/lib/schematics/utils/html.ts index 0ae50b07ca25..a721fd0b895d 100644 --- a/src/lib/schematics/utils/html.ts +++ b/src/lib/schematics/utils/html.ts @@ -10,6 +10,10 @@ import {Project} from './devkit-utils/config'; * @param src the src path of the html file to parse */ export function getHeadTag(host: Tree, src: string) { + if (!parse5) { + throw new SchematicsException('parse5 depedency not found! Please install parse5 from npm to continue.'); + } + const document = parse5.parse(src, {locationInfo: true}) as parse5.AST.Default.Document; From d0b91208d05e26a2a6d4ae10109ca20fe533c8d6 Mon Sep 17 00:00:00 2001 From: Austin Date: Sun, 24 Jun 2018 08:40:23 -0500 Subject: [PATCH 3/3] chore: nit --- src/lib/schematics/install/index.ts | 7 ++++++- src/lib/schematics/utils/html.ts | 4 ---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lib/schematics/install/index.ts b/src/lib/schematics/install/index.ts index 649047033629..4539cfc7513d 100644 --- a/src/lib/schematics/install/index.ts +++ b/src/lib/schematics/install/index.ts @@ -1,4 +1,4 @@ -import {chain, noop, Rule, Tree, SchematicContext} from '@angular-devkit/schematics'; +import {chain, noop, Rule, Tree, SchematicContext, SchematicsException} from '@angular-devkit/schematics'; import {NodePackageInstallTask} from '@angular-devkit/schematics/tasks'; import {addModuleImportToRootModule, getStylesPath} from '../utils/ast'; import {InsertChange} from '../utils/devkit-utils/change'; @@ -8,6 +8,7 @@ import {angularVersion, materialVersion} from '../utils/lib-versions'; import {addPackageToPackageJson} from '../utils/package'; import {Schema} from './schema'; import {addThemeToAppStyles} from './theming'; +import * as parse5 from 'parse5'; /** @@ -17,6 +18,10 @@ import {addThemeToAppStyles} from './theming'; * - Adds Browser Animation to app.momdule */ export default function(options: Schema): Rule { + if (!parse5) { + throw new SchematicsException('parse5 depedency not found! Please install parse5 from npm to continue.'); + } + return chain([ options && options.skipPackageJson ? noop() : addMaterialToPackageJson(), addThemeToAppStyles(options), diff --git a/src/lib/schematics/utils/html.ts b/src/lib/schematics/utils/html.ts index a721fd0b895d..0ae50b07ca25 100644 --- a/src/lib/schematics/utils/html.ts +++ b/src/lib/schematics/utils/html.ts @@ -10,10 +10,6 @@ import {Project} from './devkit-utils/config'; * @param src the src path of the html file to parse */ export function getHeadTag(host: Tree, src: string) { - if (!parse5) { - throw new SchematicsException('parse5 depedency not found! Please install parse5 from npm to continue.'); - } - const document = parse5.parse(src, {locationInfo: true}) as parse5.AST.Default.Document;