diff --git a/packages/angular/pwa/pwa/index.ts b/packages/angular/pwa/pwa/index.ts index 4558eb42b5..4d79a1fe63 100644 --- a/packages/angular/pwa/pwa/index.ts +++ b/packages/angular/pwa/pwa/index.ts @@ -9,6 +9,7 @@ import { Path, join } from '@angular-devkit/core'; import { Rule, SchematicContext, + SchematicsException, Tree, apply, branchAndMerge, @@ -36,6 +37,9 @@ export default function (options: PwaOptions): Rule { return (host: Tree, context: SchematicContext) => { const workspace = getWorkspace(host); const project = workspace.projects[options.project]; + if (project.projectType !== 'application') { + throw new SchematicsException(`PWA requires a project type of "application".`); + } const assetPath = join(project.root as Path, 'src', 'assets'); diff --git a/packages/schematics/angular/app-shell/index.ts b/packages/schematics/angular/app-shell/index.ts index 4911bb18d5..99077dd185 100644 --- a/packages/schematics/angular/app-shell/index.ts +++ b/packages/schematics/angular/app-shell/index.ts @@ -144,6 +144,9 @@ function validateProject(options: AppShellOptions): Rule { const routerOutletCheckRegex = /([\s\S]*?)<\/router\-outlet>/; const clientProject = getClientProject(host, options); + if (clientProject.projectType !== 'application') { + throw new SchematicsException(`App shell requires a project type of "application".`); + } const componentPath = getBootstrapComponentPath(host, clientProject); const tmpl = getComponentTemplateInfo(host, componentPath); const template = getComponentTemplate(host, componentPath, tmpl); diff --git a/packages/schematics/angular/service-worker/index.ts b/packages/schematics/angular/service-worker/index.ts index 0845a3009f..ba6276bd90 100644 --- a/packages/schematics/angular/service-worker/index.ts +++ b/packages/schematics/angular/service-worker/index.ts @@ -232,6 +232,9 @@ export default function (options: ServiceWorkerOptions): Rule { if (!project) { throw new SchematicsException(`Invalid project name (${options.project})`); } + if (project.projectType !== 'application') { + throw new SchematicsException(`Service worker requires a project type of "application".`); + } const templateSource = apply(url('./files'), [ template({...options}), diff --git a/packages/schematics/angular/universal/index.ts b/packages/schematics/angular/universal/index.ts index 2293b35ad0..8b0a2ec08e 100644 --- a/packages/schematics/angular/universal/index.ts +++ b/packages/schematics/angular/universal/index.ts @@ -205,6 +205,9 @@ function getTsConfigOutDir(host: Tree, architect: experimental.workspace.Workspa export default function (options: UniversalOptions): Rule { return (host: Tree, context: SchematicContext) => { const clientProject = getClientProject(host, options); + if (clientProject.projectType !== 'application') { + throw new SchematicsException(`Universal requires a project type of "application".`); + } const clientArchitect = getClientArchitect(host, options); const outDir = getTsConfigOutDir(host, clientArchitect); const tsConfigExtends = basename(clientArchitect.build.options.tsConfig);