From 134ecef8120f255ca679ef19758a2ab6e2aae1ba Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 10 Sep 2018 15:10:07 +0200 Subject: [PATCH 1/2] feat(ng-add): add x-prompts to install schematics * Recently the Angular CLI project introduced prompt support for schematics. Even though they seem to not run when using `7.0.0-beta.2` of the CLI, we should already ship the simple prompts for the `ng add` command. * Renames the `/schematics/install` folder to `/schematics/ng-add`. (this makes it consistent with the actual schematic name and other packages that ship the `ng-add` schematic (e.g. `@angular/elements`) --- src/lib/schematics/collection.json | 4 ++-- .../{install => ng-add}/fonts/head-element.ts | 0 .../{install => ng-add}/fonts/material-fonts.ts | 0 .../{install => ng-add}/fonts/project-index-html.ts | 0 .../{install => ng-add}/gestures/hammerjs-import.ts | 0 src/lib/schematics/{install => ng-add}/index.spec.ts | 2 +- src/lib/schematics/{install => ng-add}/index.ts | 0 src/lib/schematics/{install => ng-add}/schema.json | 10 ++++++---- src/lib/schematics/{install => ng-add}/schema.ts | 0 .../{install => ng-add}/theming/custom-theme.ts | 0 .../schematics/{install => ng-add}/theming/theming.ts | 0 .../schematics/{install => ng-add}/version-names.ts | 0 12 files changed, 9 insertions(+), 7 deletions(-) rename src/lib/schematics/{install => ng-add}/fonts/head-element.ts (100%) rename src/lib/schematics/{install => ng-add}/fonts/material-fonts.ts (100%) rename src/lib/schematics/{install => ng-add}/fonts/project-index-html.ts (100%) rename src/lib/schematics/{install => ng-add}/gestures/hammerjs-import.ts (100%) rename src/lib/schematics/{install => ng-add}/index.spec.ts (99%) rename src/lib/schematics/{install => ng-add}/index.ts (100%) rename src/lib/schematics/{install => ng-add}/schema.json (74%) rename src/lib/schematics/{install => ng-add}/schema.ts (100%) rename src/lib/schematics/{install => ng-add}/theming/custom-theme.ts (100%) rename src/lib/schematics/{install => ng-add}/theming/theming.ts (100%) rename src/lib/schematics/{install => ng-add}/version-names.ts (100%) diff --git a/src/lib/schematics/collection.json b/src/lib/schematics/collection.json index 58ef352854a9..e12c574a0493 100644 --- a/src/lib/schematics/collection.json +++ b/src/lib/schematics/collection.json @@ -5,8 +5,8 @@ // Adds Angular Material to an application without changing any templates "ng-add": { "description": "Adds Angular Material to the application without affecting any templates", - "factory": "./install", - "schema": "./install/schema.json", + "factory": "./ng-add/index", + "schema": "./ng-add/schema.json", "aliases": ["material-shell", "install"] }, // Create a dashboard component diff --git a/src/lib/schematics/install/fonts/head-element.ts b/src/lib/schematics/ng-add/fonts/head-element.ts similarity index 100% rename from src/lib/schematics/install/fonts/head-element.ts rename to src/lib/schematics/ng-add/fonts/head-element.ts diff --git a/src/lib/schematics/install/fonts/material-fonts.ts b/src/lib/schematics/ng-add/fonts/material-fonts.ts similarity index 100% rename from src/lib/schematics/install/fonts/material-fonts.ts rename to src/lib/schematics/ng-add/fonts/material-fonts.ts diff --git a/src/lib/schematics/install/fonts/project-index-html.ts b/src/lib/schematics/ng-add/fonts/project-index-html.ts similarity index 100% rename from src/lib/schematics/install/fonts/project-index-html.ts rename to src/lib/schematics/ng-add/fonts/project-index-html.ts diff --git a/src/lib/schematics/install/gestures/hammerjs-import.ts b/src/lib/schematics/ng-add/gestures/hammerjs-import.ts similarity index 100% rename from src/lib/schematics/install/gestures/hammerjs-import.ts rename to src/lib/schematics/ng-add/gestures/hammerjs-import.ts diff --git a/src/lib/schematics/install/index.spec.ts b/src/lib/schematics/ng-add/index.spec.ts similarity index 99% rename from src/lib/schematics/install/index.spec.ts rename to src/lib/schematics/ng-add/index.spec.ts index bb82c1883c64..2330a901eaab 100644 --- a/src/lib/schematics/install/index.spec.ts +++ b/src/lib/schematics/ng-add/index.spec.ts @@ -9,7 +9,7 @@ import {collectionPath, createTestApp} from '../test-setup/test-app'; import {getWorkspace, WorkspaceProject} from '@schematics/angular/utility/config'; import {normalize} from '@angular-devkit/core'; -describe('material-install-schematic', () => { +describe('ng-add schematic', () => { let runner: SchematicTestRunner; let appTree: Tree; diff --git a/src/lib/schematics/install/index.ts b/src/lib/schematics/ng-add/index.ts similarity index 100% rename from src/lib/schematics/install/index.ts rename to src/lib/schematics/ng-add/index.ts diff --git a/src/lib/schematics/install/schema.json b/src/lib/schematics/ng-add/schema.json similarity index 74% rename from src/lib/schematics/install/schema.json rename to src/lib/schematics/ng-add/schema.json index 4188ae29dac3..451843b1264d 100644 --- a/src/lib/schematics/install/schema.json +++ b/src/lib/schematics/ng-add/schema.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/schema", - "id": "SchematicsMaterialInstall", - "title": "Material Install Options Schema", + "id": "angular-material-ng-add", + "title": "Angular Material ng-add schematic", "type": "object", "properties": { "project": { @@ -19,12 +19,14 @@ "theme": { "enum": ["indigo-pink", "deeppurple-amber", "pink-bluegrey", "purple-green", "custom"], "default": "indigo-pink", - "description": "The theme to apply" + "description": "The theme to apply", + "x-prompt": "What theme would you like to generate?" }, "gestures": { "type": "boolean", "default": true, - "description": "Whether gesture support should be set up or not." + "description": "Whether gesture support should be set up or not.", + "x-prompt": "Would you like to set up gesture support?" } }, "required": [] diff --git a/src/lib/schematics/install/schema.ts b/src/lib/schematics/ng-add/schema.ts similarity index 100% rename from src/lib/schematics/install/schema.ts rename to src/lib/schematics/ng-add/schema.ts diff --git a/src/lib/schematics/install/theming/custom-theme.ts b/src/lib/schematics/ng-add/theming/custom-theme.ts similarity index 100% rename from src/lib/schematics/install/theming/custom-theme.ts rename to src/lib/schematics/ng-add/theming/custom-theme.ts diff --git a/src/lib/schematics/install/theming/theming.ts b/src/lib/schematics/ng-add/theming/theming.ts similarity index 100% rename from src/lib/schematics/install/theming/theming.ts rename to src/lib/schematics/ng-add/theming/theming.ts diff --git a/src/lib/schematics/install/version-names.ts b/src/lib/schematics/ng-add/version-names.ts similarity index 100% rename from src/lib/schematics/install/version-names.ts rename to src/lib/schematics/ng-add/version-names.ts From aa4eb90d0d64c0e4f7cc9e7ce8a36a721b66c52f Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 10 Sep 2018 16:59:30 +0200 Subject: [PATCH 2/2] Address comments --- src/lib/schematics/ng-add/schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/schematics/ng-add/schema.json b/src/lib/schematics/ng-add/schema.json index 451843b1264d..5a3dcbd66529 100644 --- a/src/lib/schematics/ng-add/schema.json +++ b/src/lib/schematics/ng-add/schema.json @@ -20,13 +20,13 @@ "enum": ["indigo-pink", "deeppurple-amber", "pink-bluegrey", "purple-green", "custom"], "default": "indigo-pink", "description": "The theme to apply", - "x-prompt": "What theme would you like to generate?" + "x-prompt": "Enter a prebuilt theme name, or \"custom\" for a custom theme:" }, "gestures": { "type": "boolean", "default": true, "description": "Whether gesture support should be set up or not.", - "x-prompt": "Would you like to set up gesture support?" + "x-prompt": "Set up HammerJS for gesture recognition?" } }, "required": []