UI for Zipcoin Blue

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const tslib_1 = require("tslib");
  4. const chalk_1 = require("chalk");
  5. const command_1 = require("@ionic/cli-utils/lib/command");
  6. const serve_1 = require("@ionic/cli-utils/lib/serve");
  7. let DocsCommand = class DocsCommand extends command_1.Command {
  8. run(inputs, options) {
  9. return tslib_1.__awaiter(this, void 0, void 0, function* () {
  10. const { isSuperAgentError } = yield Promise.resolve().then(() => require('@ionic/cli-utils/guards'));
  11. const { createRequest } = yield Promise.resolve().then(() => require('@ionic/cli-utils/lib/http'));
  12. const browser = options['browser'] ? String(options['browser']) : undefined;
  13. const opn = yield Promise.resolve().then(() => require('opn'));
  14. const docsHomepage = 'https://ionicframework.com/docs';
  15. let url = docsHomepage;
  16. const project = this.env.project.directory ? yield this.env.project.load() : undefined;
  17. if (project) {
  18. if (project.type === 'ionic1') {
  19. url = 'https://ionicframework.com/docs/v1/';
  20. }
  21. else if (project.type === 'ionic-angular') {
  22. url = 'https://ionicframework.com/docs/api'; // TODO: can know framework version, HEAD request, etc
  23. }
  24. }
  25. try {
  26. const { req } = yield createRequest(this.env.config, 'head', url);
  27. yield req;
  28. }
  29. catch (e) {
  30. if (isSuperAgentError(e)) {
  31. if (e.response.status === 404) {
  32. this.env.log.warn(`Docs not found for your specific version of Ionic. Directing you to latest docs.`);
  33. opn(`${docsHomepage}/api`, { wait: false });
  34. return;
  35. }
  36. }
  37. throw e;
  38. }
  39. yield opn(url, { app: browser, wait: false });
  40. this.env.log.ok('Launched Ionic docs in your browser!');
  41. });
  42. }
  43. };
  44. DocsCommand = tslib_1.__decorate([
  45. command_1.CommandMetadata({
  46. name: 'docs',
  47. type: 'global',
  48. description: 'Open the Ionic documentation website',
  49. options: [
  50. {
  51. name: 'browser',
  52. description: `Specifies the browser to use (${serve_1.BROWSERS.map(b => chalk_1.default.green(b)).join(', ')})`,
  53. aliases: ['w'],
  54. advanced: true,
  55. },
  56. ],
  57. })
  58. ], DocsCommand);
  59. exports.DocsCommand = DocsCommand;