WEB-47394 WEB-43188 WEB-37193 Fix issue with Angular schematics not showing up and...
[idea/contrib.git] / AngularJS / src / ngCli / schematicsProvider90.ts
1 // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 import {Collection, Schematic} from '@angular-devkit/schematics';
3 import {SchematicsProvider} from "./schematicsProvider";
4 import {SchematicCommand} from "@angular/cli/models/schematic-command";
5 import {getWorkspaceDetails} from "@angular/cli/utilities/project"
6
7 const schematicsProvider: Promise<SchematicsProvider> = (async function () {
8   let workspace = await getWorkspaceDetails()
9   let command = new (SchematicCommand as any)({workspace: workspace}, null, null);
10   let {listSchematicNames} = (await command.createWorkflow({interactive: false})).engineHost;
11   let defaultSchematicCollection = await command.getDefaultSchematicCollection()
12
13   return {
14     getCollection(collectionName: string): Collection<any, any> {
15       return command.getCollection(collectionName);
16     },
17     listSchematics(collection): string[] {
18       return listSchematicNames(collection.description)
19     },
20     getSchematic(collection: Collection<any, any>, schematicName: string, allowPrivate?: boolean): Schematic<any, any> {
21       return command.getSchematic(collection, schematicName, allowPrivate);
22     },
23     getDefaultSchematicCollection() {
24       return defaultSchematicCollection;
25     }
26   }
27 })()
28
29 export = schematicsProvider;