index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. /**
  3. * Use of this source code is governed by an MIT-style license that can be
  4. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  5. */
  6. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  7. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  8. return new (P || (P = Promise))(function (resolve, reject) {
  9. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  10. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  11. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  12. step((generator = generator.apply(thisArg, _arguments || [])).next());
  13. });
  14. };
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. exports.default = default_1;
  17. const schematics_1 = require("@angular/cdk/schematics");
  18. const core_1 = require("@angular-devkit/core");
  19. const schematics_2 = require("@angular-devkit/schematics");
  20. const schema_1 = require("@schematics/angular/application/schema");
  21. const workspace_1 = require("@schematics/angular/utility/workspace");
  22. const root_module_1 = require("../../utils/root-module");
  23. function default_1(options) {
  24. return (host) => __awaiter(this, void 0, void 0, function* () {
  25. const workspace = yield (0, workspace_1.getWorkspace)(host);
  26. const project = (0, schematics_1.getProjectFromWorkspace)(workspace, options.project);
  27. const mainFile = (0, schematics_1.getProjectMainFile)(project);
  28. const prefix = options.prefix || project.prefix;
  29. const style = options.style || schema_1.Style.Css;
  30. if ((0, schematics_1.isStandaloneApp)(host, mainFile)) {
  31. return (0, schematics_2.chain)([
  32. (0, schematics_2.mergeWith)((0, schematics_2.apply)((0, schematics_2.url)('./standalone/src'), [
  33. (0, schematics_2.applyTemplates)(Object.assign(Object.assign({ prefix,
  34. style }, core_1.strings), options)),
  35. (0, schematics_2.move)(project.sourceRoot),
  36. (0, schematics_2.forEach)((fileEntry) => {
  37. if (host.exists(fileEntry.path)) {
  38. host.overwrite(fileEntry.path, fileEntry.content);
  39. }
  40. return fileEntry;
  41. })
  42. ]), schematics_2.MergeStrategy.Overwrite)
  43. ]);
  44. }
  45. else {
  46. return (0, schematics_2.chain)([
  47. (0, schematics_2.mergeWith)((0, schematics_2.apply)((0, schematics_2.url)('./files/src'), [
  48. (0, schematics_2.applyTemplates)(Object.assign(Object.assign({ prefix,
  49. style }, core_1.strings), options)),
  50. (0, schematics_2.move)(project.sourceRoot),
  51. (0, schematics_2.forEach)((fileEntry) => {
  52. if (host.exists(fileEntry.path)) {
  53. host.overwrite(fileEntry.path, fileEntry.content);
  54. }
  55. return fileEntry;
  56. })
  57. ]), schematics_2.MergeStrategy.Overwrite),
  58. (0, root_module_1.addModule)('AppRoutingModule', './app-routing.module', options.project)
  59. ]);
  60. }
  61. });
  62. }
  63. //# sourceMappingURL=index.js.map