// 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. import {Collection, Schematic} from '@angular-devkit/schematics'; import {SchematicsProvider} from "./schematicsProvider"; import {SchematicCommand} from "@angular/cli/models/schematic-command"; import {getWorkspaceDetails} from "@angular/cli/utilities/project" const schematicsProvider: Promise = (async function () { let workspace = await getWorkspaceDetails() let command = new (SchematicCommand as any)({workspace: workspace}, null, null); let {listSchematicNames} = (await command.createWorkflow({interactive: false})).engineHost; let defaultSchematicCollection = await command.getDefaultSchematicCollection() return { getCollection(collectionName: string): Collection { return command.getCollection(collectionName); }, listSchematics(collection): string[] { return listSchematicNames(collection.description) }, getSchematic(collection: Collection, schematicName: string, allowPrivate?: boolean): Schematic { return command.getSchematic(collection, schematicName, allowPrivate); }, getDefaultSchematicCollection() { return defaultSchematicCollection; } } })() export = schematicsProvider;