UI for Zipcoin Blue

utils.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 fs_1 = require("@ionic/cli-framework/utils/fs");
  7. function getIonic1Version(env) {
  8. return tslib_1.__awaiter(this, void 0, void 0, function* () {
  9. const { prettyPath } = yield Promise.resolve().then(() => require('../utils/format'));
  10. const ionicVersionFilePath = path.resolve(env.project.directory, 'www', 'lib', 'ionic', 'version.json'); // TODO
  11. const bowerJsonPath = path.resolve(env.project.directory, 'bower.json');
  12. try {
  13. try {
  14. const ionicVersionJson = yield fs_1.fsReadJsonFile(ionicVersionFilePath);
  15. return ionicVersionJson['version'];
  16. }
  17. catch (e) {
  18. env.log.warn(`Error with ${chalk_1.default.bold(prettyPath(ionicVersionFilePath))} file: ${e}, trying ${chalk_1.default.bold(prettyPath(bowerJsonPath))}.`);
  19. const bowerJson = yield env.project.loadBowerJson();
  20. let ionicEntry = bowerJson.dependencies && typeof bowerJson.dependencies['ionic'] === 'string' ? bowerJson.dependencies['ionic'] : undefined;
  21. if (!ionicEntry) {
  22. ionicEntry = bowerJson.devDependencies && typeof bowerJson.devDependencies['ionic'] === 'string' ? bowerJson.devDependencies['ionic'] : undefined;
  23. }
  24. if (!ionicEntry) {
  25. return;
  26. }
  27. const m = ionicEntry.match(/.+#(.+)/);
  28. if (m && m[1]) {
  29. return m[1];
  30. }
  31. }
  32. }
  33. catch (e) {
  34. env.log.error(`Error with ${chalk_1.default.bold(prettyPath(bowerJsonPath))} file: ${e}`);
  35. }
  36. });
  37. }
  38. exports.getIonic1Version = getIonic1Version;