UI for Zipcoin Blue

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const tslib_1 = require("tslib");
  4. const path = require("path");
  5. const chalk_1 = require("chalk");
  6. const guards_1 = require("../guards");
  7. const http_1 = require("./http");
  8. const fs_1 = require("@ionic/cli-framework/utils/fs");
  9. exports.STARTER_BASE_URL = 'https://d2ql0qc7j8u4b2.cloudfront.net';
  10. function isProjectNameValid(name) {
  11. return name !== '.';
  12. }
  13. exports.isProjectNameValid = isProjectNameValid;
  14. /**
  15. * If project only contains files generated by GH, it’s safe.
  16. * We also special case IJ-based products .idea because it integrates with CRA:
  17. * https://github.com/facebookincubator/create-react-app/pull/368#issuecomment-243446094
  18. */
  19. function isSafeToCreateProjectIn(root) {
  20. return tslib_1.__awaiter(this, void 0, void 0, function* () {
  21. const validFiles = [
  22. '.DS_Store', 'Thumbs.db', '.git', '.gitignore', '.idea', 'README.md', 'LICENSE'
  23. ];
  24. const entries = yield fs_1.fsReadDir(root);
  25. return entries.every(file => {
  26. return validFiles.indexOf(file) >= 0;
  27. });
  28. });
  29. }
  30. exports.isSafeToCreateProjectIn = isSafeToCreateProjectIn;
  31. function getStarterTemplateText(templateList) {
  32. let headerLine = chalk_1.default.bold(`Ionic Starter templates`);
  33. let formattedTemplateList = getStarterTemplateTextList(templateList);
  34. return `
  35. ${headerLine}
  36. ${formattedTemplateList.join(`
  37. `)}
  38. `;
  39. }
  40. exports.getStarterTemplateText = getStarterTemplateText;
  41. function getStarterTemplateTextList(templateList) {
  42. return templateList.map(({ name, type, description }) => {
  43. let templateName = chalk_1.default.green(name);
  44. return `${templateName} ${Array(20 - name.length).join(chalk_1.default.dim('.'))} ${chalk_1.default.bold(type)} ${description}`;
  45. });
  46. }
  47. exports.getStarterTemplateTextList = getStarterTemplateTextList;
  48. function getHelloText() {
  49. return `
  50. ${chalk_1.default.bold('♬ ♫ ♬ ♫ Your Ionic app is ready to go! ♬ ♫ ♬ ♫')}
  51. ${chalk_1.default.bold('Run your app in the browser (great for initial development):')}
  52. ${chalk_1.default.green('ionic serve')}
  53. ${chalk_1.default.bold('Install the DevApp to easily test on iOS and Android')}
  54. ${chalk_1.default.green('https://bit.ly/ionic-dev-app')}
  55. ${chalk_1.default.bold('Run on a device or simulator:')}
  56. ${chalk_1.default.green('ionic cordova run ios')}
  57. ${chalk_1.default.bold('Test and share your app on a device with the Ionic View app:')}
  58. https://ionicframework.com/products/view
  59. `;
  60. }
  61. exports.getHelloText = getHelloText;
  62. function readStarterManifest(p) {
  63. return tslib_1.__awaiter(this, void 0, void 0, function* () {
  64. try {
  65. const manifest = yield fs_1.fsReadJsonFile(p);
  66. if (!guards_1.isStarterManifest(manifest)) {
  67. throw new Error(`${p} is not a valid starter manifest.`);
  68. }
  69. return manifest;
  70. }
  71. catch (e) {
  72. if (e === fs_1.ERROR_FILE_NOT_FOUND) {
  73. throw new Error(`${p} not found`);
  74. }
  75. else if (e === fs_1.ERROR_FILE_INVALID_JSON) {
  76. throw new Error(`${p} is not valid JSON.`);
  77. }
  78. throw e;
  79. }
  80. });
  81. }
  82. exports.readStarterManifest = readStarterManifest;
  83. function updatePackageJsonForCli(projectRoot, appName) {
  84. return tslib_1.__awaiter(this, void 0, void 0, function* () {
  85. const filePath = path.resolve(projectRoot, 'package.json');
  86. try {
  87. const jsonStructure = yield fs_1.fsReadJsonFile(filePath);
  88. jsonStructure['name'] = appName;
  89. jsonStructure['version'] = '0.0.1';
  90. jsonStructure['description'] = 'An Ionic project';
  91. yield fs_1.fsWriteJsonFile(filePath, jsonStructure, { encoding: 'utf8' });
  92. }
  93. catch (e) {
  94. if (e === fs_1.ERROR_FILE_NOT_FOUND) {
  95. throw new Error(`${filePath} not found`);
  96. }
  97. else if (e === fs_1.ERROR_FILE_INVALID_JSON) {
  98. throw new Error(`${filePath} is not valid JSON.`);
  99. }
  100. throw e;
  101. }
  102. });
  103. }
  104. exports.updatePackageJsonForCli = updatePackageJsonForCli;
  105. function getStarterList(config) {
  106. return tslib_1.__awaiter(this, void 0, void 0, function* () {
  107. const { req } = yield http_1.createRequest(config, 'get', `${exports.STARTER_BASE_URL}/starters.json`);
  108. const res = yield req;
  109. // TODO: typecheck
  110. return res.body;
  111. });
  112. }
  113. exports.getStarterList = getStarterList;
  114. exports.STARTER_TEMPLATES = [
  115. {
  116. name: 'tabs',
  117. type: 'ionic-angular',
  118. description: 'A starting project with a simple tabbed interface',
  119. archive: `${exports.STARTER_BASE_URL}/ionic-angular-official-tabs.tar.gz`,
  120. },
  121. {
  122. name: 'blank',
  123. type: 'ionic-angular',
  124. description: 'A blank starter project',
  125. archive: `${exports.STARTER_BASE_URL}/ionic-angular-official-blank.tar.gz`,
  126. },
  127. {
  128. name: 'sidemenu',
  129. type: 'ionic-angular',
  130. description: 'A starting project with a side menu with navigation in the content area',
  131. archive: `${exports.STARTER_BASE_URL}/ionic-angular-official-sidemenu.tar.gz`,
  132. },
  133. {
  134. name: 'super',
  135. type: 'ionic-angular',
  136. description: 'A starting project complete with pre-built pages, providers and best practices for Ionic development.',
  137. archive: `${exports.STARTER_BASE_URL}/ionic-angular-official-super.tar.gz`,
  138. },
  139. {
  140. name: 'conference',
  141. type: 'ionic-angular',
  142. description: 'A project that demonstrates a realworld application',
  143. archive: `https://github.com/ionic-team/ionic-conference-app/archive/master.tar.gz`,
  144. strip: true,
  145. },
  146. {
  147. name: 'tutorial',
  148. type: 'ionic-angular',
  149. description: 'A tutorial based project that goes along with the Ionic documentation',
  150. archive: `${exports.STARTER_BASE_URL}/ionic-angular-official-tutorial.tar.gz`,
  151. },
  152. {
  153. name: 'aws',
  154. type: 'ionic-angular',
  155. description: 'AWS Mobile Hub Starter',
  156. archive: `${exports.STARTER_BASE_URL}/ionic-angular-official-aws.tar.gz`,
  157. },
  158. {
  159. name: 'tabs',
  160. type: 'ionic1',
  161. description: 'A starting project for Ionic using a simple tabbed interface',
  162. archive: `${exports.STARTER_BASE_URL}/ionic1-official-tabs.tar.gz`,
  163. },
  164. {
  165. name: 'blank',
  166. type: 'ionic1',
  167. description: 'A blank starter project for Ionic',
  168. archive: `${exports.STARTER_BASE_URL}/ionic1-official-blank.tar.gz`,
  169. },
  170. {
  171. name: 'sidemenu',
  172. type: 'ionic1',
  173. description: 'A starting project for Ionic using a side menu with navigation in the content area',
  174. archive: `${exports.STARTER_BASE_URL}/ionic1-official-sidemenu.tar.gz`,
  175. },
  176. {
  177. name: 'maps',
  178. type: 'ionic1',
  179. description: 'An Ionic starter project using Google Maps and a side menu',
  180. archive: `${exports.STARTER_BASE_URL}/ionic1-official-maps.tar.gz`,
  181. },
  182. ];