@@ -22,11 +22,10 @@ import {
2222import { NodeJsSyncHost , ProcessOutput , createConsoleLogger } from '@angular-devkit/core/node' ;
2323import {
2424 DryRunEvent ,
25- SchematicEngine ,
2625 UnsuccessfulWorkflowExecution ,
2726 formats ,
2827} from '@angular-devkit/schematics' ;
29- import { NodeModulesEngineHost , NodeWorkflow , validateOptionsWithSchema } from '@angular-devkit/schematics/tools' ;
28+ import { NodeWorkflow , validateOptionsWithSchema } from '@angular-devkit/schematics/tools' ;
3029import * as inquirer from 'inquirer' ;
3130import * as minimist from 'minimist' ;
3231
@@ -64,12 +63,10 @@ export interface MainOptions {
6463}
6564
6665
67- function _listSchematics ( collectionName : string , logger : logging . Logger ) {
66+ function _listSchematics ( workflow : NodeWorkflow , collectionName : string , logger : logging . Logger ) {
6867 try {
69- const engineHost = new NodeModulesEngineHost ( ) ;
70- const engine = new SchematicEngine ( engineHost ) ;
71- const collection = engine . createCollection ( collectionName ) ;
72- logger . info ( engine . listSchematicNames ( collection ) . join ( '\n' ) ) ;
68+ const collection = workflow . engine . createCollection ( collectionName ) ;
69+ logger . info ( collection . listSchematicNames ( ) . join ( '\n' ) ) ;
7370 } catch ( error ) {
7471 logger . fatal ( error . message ) ;
7572
@@ -140,18 +137,8 @@ export async function main({
140137 collection : collectionName ,
141138 schematic : schematicName ,
142139 } = parseSchematicName ( argv . _ . shift ( ) || null ) ;
143- const isLocalCollection = collectionName . startsWith ( '.' ) || collectionName . startsWith ( '/' ) ;
144-
145- /** If the user wants to list schematics, we simply show all the schematic names. */
146- if ( argv [ 'list-schematics' ] ) {
147- return _listSchematics ( collectionName , logger ) ;
148- }
149140
150- if ( ! schematicName ) {
151- logger . info ( getUsage ( ) ) ;
152-
153- return 1 ;
154- }
141+ const isLocalCollection = collectionName . startsWith ( '.' ) || collectionName . startsWith ( '/' ) ;
155142
156143 /** Gather the arguments for later use. */
157144 const debug : boolean = argv . debug === null ? isLocalCollection : argv . debug ;
@@ -171,6 +158,17 @@ export async function main({
171158 resolvePaths : [ process . cwd ( ) , __dirname ] ,
172159 } ) ;
173160
161+ /** If the user wants to list schematics, we simply show all the schematic names. */
162+ if ( argv [ 'list-schematics' ] ) {
163+ return _listSchematics ( workflow , collectionName , logger ) ;
164+ }
165+
166+ if ( ! schematicName ) {
167+ logger . info ( getUsage ( ) ) ;
168+
169+ return 1 ;
170+ }
171+
174172 registry . addPostTransform ( schema . transforms . addUndefinedDefaults ) ;
175173 workflow . engineHost . registerOptionsTransform ( validateOptionsWithSchema ( registry ) ) ;
176174
0 commit comments