Icard/angular-clarity-master(work.../node_modules/@schematics/angular/utility/generate-from-files.js

38 lines
6.0 KiB
JavaScript

"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateFromFiles = void 0;
const schematics_1 = require("@angular-devkit/schematics");
const parse_name_1 = require("./parse-name");
const validation_1 = require("./validation");
const workspace_1 = require("./workspace");
function generateFromFiles(options, extraTemplateValues = {}) {
return async (host) => {
options.path ?? (options.path = await (0, workspace_1.createDefaultPath)(host, options.project));
options.prefix ?? (options.prefix = '');
options.flat ?? (options.flat = true);
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
options.name = parsedPath.name;
options.path = parsedPath.path;
(0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
const templateFilesDirectory = options.templateFilesDirectory ?? './files';
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(templateFilesDirectory), [
options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
(0, schematics_1.applyTemplates)({
...schematics_1.strings,
...options,
...extraTemplateValues,
}),
(0, schematics_1.move)(parsedPath.path + (options.flat ? '' : '/' + schematics_1.strings.dasherize(options.name))),
]);
return (0, schematics_1.chain)([(0, schematics_1.mergeWith)(templateSource)]);
};
}
exports.generateFromFiles = generateFromFiles;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhdGUtZnJvbS1maWxlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3NjaGVtYXRpY3MvYW5ndWxhci91dGlsaXR5L2dlbmVyYXRlLWZyb20tZmlsZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7R0FNRzs7O0FBRUgsMk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