import { getWorkspace } from '@schematics/angular/utility/config';
import { apply, url, move, MergeStrategy, mergeWith, template, chain } from '@angular-devkit/schematics';
import { normalize, strings } from '@angular-devkit/core';
export function lcuForm(options) {
    return (host, context) => {
        setupOptions(host, options);
        const workspace = getWorkspace(host);
        var project = workspace.projects[options.project];
        const targetPath = normalize(project.root + '/src/');
        const solutionSource = apply(url('./files/src'), [
            template(Object.assign(Object.assign({}, strings), options)),
            move(targetPath),
        ]);
        // const docsSource = apply(url('./files/docs'), [
        //   template({
        //     ...strings,
        //     ...options,
        //   }),
        //   move('./docs'),
        // ]);
        return chain([
            mergeWith(solutionSource, MergeStrategy.Default),
        ]);
    };
}
function setupOptions(host, options) {
    var lcuFile = host.get('lcu.json');
    var lcuJson = lcuFile ? JSON.parse(lcuFile.content.toString('utf8')) : {};
    const workspace = getWorkspace(host);
    options.scope = lcuJson.templates.scope;
    options.workspace = lcuJson.templates.workspace;
    options.project = options.project ? options.project :
        workspace.defaultProject ? workspace.defaultProject : Object.keys(workspace.projects)[0];
    options.name = options.name;
    return host;
}
//# sourceMappingURL=index.js.map