index.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 schematics_2 = require("@angular-devkit/schematics");
  19. const workspace_1 = require("@schematics/angular/utility/workspace");
  20. const fs_1 = require("fs");
  21. const bootPageHTML = `<!-- NG-ZORRO -->
  22. <a href="https://github.com/NG-ZORRO/ng-zorro-antd" target="_blank" style="display: flex;align-items: center;justify-content: center;height: 100%;width: 100%;">
  23. <img height="300" alt="logo" src="https://img.alicdn.com/tfs/TB1X.qJJgHqK1RjSZFgXXa7JXXa-89-131.svg">
  24. </a>`;
  25. function default_1(options) {
  26. return (host, context) => __awaiter(this, void 0, void 0, function* () {
  27. const workspace = yield (0, workspace_1.getWorkspace)(host);
  28. const project = (0, schematics_1.getProjectFromWorkspace)(workspace, options.project);
  29. const appHTMLFile = `${project.sourceRoot}/app/app.component.html`;
  30. const buffer = host.read(appHTMLFile);
  31. if (!buffer) {
  32. context.logger.error(`Could not find the project ${appHTMLFile} file inside of the ` + `workspace config`);
  33. return (0, schematics_2.noop)();
  34. }
  35. if ((0, fs_1.existsSync)(appHTMLFile)) {
  36. const stat = (0, fs_1.statSync)(appHTMLFile);
  37. if (stat.mtimeMs === stat.ctimeMs) {
  38. host.overwrite(appHTMLFile, bootPageHTML);
  39. }
  40. }
  41. else {
  42. host.overwrite(appHTMLFile, bootPageHTML);
  43. }
  44. return (0, schematics_2.noop)();
  45. });
  46. }
  47. //# sourceMappingURL=index.js.map