Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

buildToolsJarHelper.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.runBuildtoolsCommand = exports.fetchBuildtoolsJar = void 0;
  4. const fs = require("fs-extra");
  5. const os = require("os");
  6. const path = require("path");
  7. const spawn = require("cross-spawn");
  8. const downloadUtils = require("../downloadUtils");
  9. const error_1 = require("../error");
  10. const logger_1 = require("../logger");
  11. const rimraf = require("rimraf");
  12. const utils = require("../utils");
  13. const JAR_CACHE_DIR = process.env.FIREBASE_CRASHLYTICS_BUILDTOOLS_PATH ||
  14. path.join(os.homedir(), ".cache", "firebase", "crashlytics", "buildtools");
  15. const JAR_VERSION = "2.9.2";
  16. const JAR_URL = `https://dl.google.com/android/maven2/com/google/firebase/firebase-crashlytics-buildtools/${JAR_VERSION}/firebase-crashlytics-buildtools-${JAR_VERSION}.jar`;
  17. async function fetchBuildtoolsJar() {
  18. if (process.env.CRASHLYTICS_LOCAL_JAR) {
  19. return process.env.CRASHLYTICS_LOCAL_JAR;
  20. }
  21. const jarPath = path.join(JAR_CACHE_DIR, `crashlytics-buildtools-${JAR_VERSION}.jar`);
  22. if (fs.existsSync(jarPath)) {
  23. logger_1.logger.debug(`Buildtools Jar already downloaded at ${jarPath}`);
  24. return jarPath;
  25. }
  26. if (fs.existsSync(JAR_CACHE_DIR)) {
  27. logger_1.logger.debug(`Deleting Jar cache at ${JAR_CACHE_DIR} because the CLI was run with a newer Jar version`);
  28. rimraf.sync(JAR_CACHE_DIR);
  29. }
  30. utils.logBullet("Downloading crashlytics-buildtools.jar to " + jarPath);
  31. utils.logBullet("For open source licenses used by this command, look in the META-INF directory in the buildtools.jar file");
  32. const tmpfile = await downloadUtils.downloadToTmp(JAR_URL);
  33. fs.mkdirSync(JAR_CACHE_DIR, { recursive: true });
  34. fs.copySync(tmpfile, jarPath);
  35. return jarPath;
  36. }
  37. exports.fetchBuildtoolsJar = fetchBuildtoolsJar;
  38. function runBuildtoolsCommand(jarFile, args, debug) {
  39. var _a;
  40. const fullArgs = ["-jar", jarFile, ...args, "-clientName", "firebase-cli;crashlytics-buildtools"];
  41. const outputs = spawn.sync("java", fullArgs, {
  42. stdio: debug ? "inherit" : "pipe",
  43. });
  44. if (outputs.status !== 0) {
  45. if (!debug) {
  46. utils.logWarning(((_a = outputs.stdout) === null || _a === void 0 ? void 0 : _a.toString()) || "An unknown error occurred");
  47. }
  48. throw new error_1.FirebaseError(`java command failed with args: ${fullArgs}`);
  49. }
  50. }
  51. exports.runBuildtoolsCommand = runBuildtoolsCommand;