(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define([], factory);
	else if(typeof exports === 'object')
		exports["tauri"] = factory();
	else
		root["tauri"] = factory();
})(global, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./src/api/dependency-manager/index.ts");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./src/api/dependency-manager/cargo-commands.ts":
/*!******************************************************!*\
  !*** ./src/api/dependency-manager/cargo-commands.ts ***!
  \******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.update = exports.install = void 0;
var types_1 = __webpack_require__(/*! ./types */ "./src/api/dependency-manager/types.ts");
var util_1 = __webpack_require__(/*! ./util */ "./src/api/dependency-manager/util.ts");
var get_script_version_1 = __importDefault(__webpack_require__(/*! ../../helpers/get-script-version */ "./src/helpers/get-script-version.ts"));
var logger_1 = __importDefault(__webpack_require__(/*! ../../helpers/logger */ "./src/helpers/logger.ts"));
var cross_spawn_1 = __webpack_require__(/*! cross-spawn */ "cross-spawn");
var inquirer_1 = __importDefault(__webpack_require__(/*! inquirer */ "inquirer"));
var log = logger_1.default('dependency:cargo-commands');
var dependencies = ['tauri-bundler'];
function manageDependencies(managementType) {
    return __awaiter(this, void 0, void 0, function () {
        var installedDeps, updatedDeps, _i, dependencies_1, dependency, currentVersion, latestVersion, inquired, result;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    installedDeps = [];
                    updatedDeps = [];
                    _i = 0, dependencies_1 = dependencies;
                    _a.label = 1;
                case 1:
                    if (!(_i < dependencies_1.length)) return [3 /*break*/, 9];
                    dependency = dependencies_1[_i];
                    currentVersion = get_script_version_1.default('cargo', [dependency]);
                    if (!(currentVersion === null)) return [3 /*break*/, 2];
                    log("Installing " + dependency + "...");
                    cross_spawn_1.sync('cargo', ['install', dependency]);
                    installedDeps.push(dependency);
                    return [3 /*break*/, 8];
                case 2:
                    if (!(managementType === types_1.ManagementType.Update)) return [3 /*break*/, 7];
                    return [4 /*yield*/, util_1.getCrateLatestVersion(dependency)];
                case 3:
                    latestVersion = _a.sent();
                    if (!util_1.semverLt(currentVersion, latestVersion)) return [3 /*break*/, 5];
                    return [4 /*yield*/, inquirer_1.default.prompt([{
                                type: 'confirm',
                                name: 'answer',
                                message: "[CARGO COMMANDS] \"" + dependency + "\" latest version is " + latestVersion + ". Do you want to update?",
                                default: false
                            }])];
                case 4:
                    inquired = _a.sent();
                    if (inquired.answer) {
                        cross_spawn_1.sync('cargo', ['install', dependency, '--force']);
                        updatedDeps.push(dependency);
                    }
                    return [3 /*break*/, 6];
                case 5:
                    log("\"" + dependency + "\" is up to date");
                    _a.label = 6;
                case 6: return [3 /*break*/, 8];
                case 7:
                    log("\"" + dependency + "\" is already installed");
                    _a.label = 8;
                case 8:
                    _i++;
                    return [3 /*break*/, 1];
                case 9:
                    result = new Map();
                    result.set(types_1.ManagementType.Install, installedDeps);
                    result.set(types_1.ManagementType.Update, updatedDeps);
                    return [2 /*return*/, result];
            }
        });
    });
}
function install() {
    return __awaiter(this, void 0, void 0, function () {
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, manageDependencies(types_1.ManagementType.Install)];
                case 1: return [2 /*return*/, _a.sent()];
            }
        });
    });
}
exports.install = install;
function update() {
    return __awaiter(this, void 0, void 0, function () {
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, manageDependencies(types_1.ManagementType.Update)];
                case 1: return [2 /*return*/, _a.sent()];
            }
        });
    });
}
exports.update = update;


/***/ }),

/***/ "./src/api/dependency-manager/cargo-crates.ts":
/*!****************************************************!*\
  !*** ./src/api/dependency-manager/cargo-crates.ts ***!
  \****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __spreadArrays = (this && this.__spreadArrays) || function () {
    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
    for (var r = Array(s), k = 0, i = 0; i < il; i++)
        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
            r[k] = a[j];
    return r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.update = exports.install = void 0;
var spawn_1 = __webpack_require__(/*! ./../../helpers/spawn */ "./src/helpers/spawn.ts");
var types_1 = __webpack_require__(/*! ./types */ "./src/api/dependency-manager/types.ts");
var util_1 = __webpack_require__(/*! ./util */ "./src/api/dependency-manager/util.ts");
var logger_1 = __importDefault(__webpack_require__(/*! ../../helpers/logger */ "./src/helpers/logger.ts"));
var app_paths_1 = __webpack_require__(/*! ../../helpers/app-paths */ "./src/helpers/app-paths.ts");
var fs_1 = __webpack_require__(/*! fs */ "fs");
var toml_1 = __importDefault(__webpack_require__(/*! @tauri-apps/toml */ "@tauri-apps/toml"));
var inquirer_1 = __importDefault(__webpack_require__(/*! inquirer */ "inquirer"));
var log = logger_1.default('dependency:crates');
var dependencies = ['tauri'];
function readToml(tomlPath) {
    if (fs_1.existsSync(tomlPath)) {
        var manifest = fs_1.readFileSync(tomlPath).toString();
        return toml_1.default.parse(manifest);
    }
    return null;
}
function dependencyDefinition(version) {
    return { version: version.substring(0, version.lastIndexOf('.')) };
}
function manageDependencies(managementType) {
    return __awaiter(this, void 0, void 0, function () {
        var installedDeps, updatedDeps, result, manifest, lockPath, lock, _loop_1, _i, dependencies_1, dependency;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    installedDeps = [];
                    updatedDeps = [];
                    result = new Map();
                    manifest = readToml(app_paths_1.resolve.tauri('Cargo.toml'));
                    if (manifest === null) {
                        log('Cargo.toml not found. Skipping crates check...');
                        return [2 /*return*/, result];
                    }
                    lockPath = app_paths_1.resolve.tauri('Cargo.lock');
                    if (!fs_1.existsSync(lockPath)) {
                        spawn_1.spawnSync('cargo', ['generate-lockfile'], app_paths_1.tauriDir);
                    }
                    lock = readToml(lockPath);
                    _loop_1 = function (dependency) {
                        var lockPackages, manifestDep, currentVersion, latestVersion, latestVersion, inquired;
                        return __generator(this, function (_a) {
                            switch (_a.label) {
                                case 0:
                                    lockPackages = lock ? lock.package.filter(function (pkg) { return pkg.name === dependency; }) : [];
                                    manifestDep = manifest.dependencies[dependency];
                                    currentVersion = lockPackages.length === 1
                                        ? lockPackages[0].version
                                        : (typeof manifestDep === 'string' ? manifestDep : manifestDep === null || manifestDep === void 0 ? void 0 : manifestDep.version);
                                    if (!(currentVersion === undefined)) return [3 /*break*/, 2];
                                    log("Installing " + dependency + "...");
                                    return [4 /*yield*/, util_1.getCrateLatestVersion(dependency)
                                        // eslint-disable-next-line security/detect-object-injection
                                    ];
                                case 1:
                                    latestVersion = _a.sent();
                                    // eslint-disable-next-line security/detect-object-injection
                                    manifest.dependencies[dependency] = dependencyDefinition(latestVersion);
                                    installedDeps.push(dependency);
                                    return [3 /*break*/, 8];
                                case 2:
                                    if (!(managementType === types_1.ManagementType.Update)) return [3 /*break*/, 7];
                                    return [4 /*yield*/, util_1.getCrateLatestVersion(dependency)];
                                case 3:
                                    latestVersion = _a.sent();
                                    if (!util_1.semverLt(currentVersion, latestVersion)) return [3 /*break*/, 5];
                                    return [4 /*yield*/, inquirer_1.default.prompt([{
                                                type: 'confirm',
                                                name: 'answer',
                                                message: "[CRATES] \"" + dependency + "\" latest version is " + latestVersion + ". Do you want to update?",
                                                default: false
                                            }])];
                                case 4:
                                    inquired = _a.sent();
                                    if (inquired.answer) {
                                        log("Updating " + dependency + "...");
                                        // eslint-disable-next-line security/detect-object-injection
                                        manifest.dependencies[dependency] = dependencyDefinition(latestVersion);
                                        updatedDeps.push(dependency);
                                    }
                                    return [3 /*break*/, 6];
                                case 5:
                                    log("\"" + dependency + "\" is up to date");
                                    _a.label = 6;
                                case 6: return [3 /*break*/, 8];
                                case 7:
                                    log("\"" + dependency + "\" is already installed");
                                    _a.label = 8;
                                case 8: return [2 /*return*/];
                            }
                        });
                    };
                    _i = 0, dependencies_1 = dependencies;
                    _a.label = 1;
                case 1:
                    if (!(_i < dependencies_1.length)) return [3 /*break*/, 4];
                    dependency = dependencies_1[_i];
                    return [5 /*yield**/, _loop_1(dependency)];
                case 2:
                    _a.sent();
                    _a.label = 3;
                case 3:
                    _i++;
                    return [3 /*break*/, 1];
                case 4:
                    if (installedDeps.length || updatedDeps.length) {
                        fs_1.writeFileSync(app_paths_1.resolve.tauri('Cargo.toml'), toml_1.default.stringify(manifest));
                    }
                    if (updatedDeps.length) {
                        if (!fs_1.existsSync(app_paths_1.resolve.tauri('Cargo.lock'))) {
                            spawn_1.spawnSync('cargo', ['generate-lockfile'], app_paths_1.tauriDir);
                        }
                        spawn_1.spawnSync('cargo', __spreadArrays(['update', '--aggressive'], updatedDeps.reduce(function (initialValue, dep) { return __spreadArrays(initialValue, ['-p', dep]); }, [])), app_paths_1.tauriDir);
                    }
                    result.set(types_1.ManagementType.Install, installedDeps);
                    result.set(types_1.ManagementType.Update, updatedDeps);
                    return [2 /*return*/, result];
            }
        });
    });
}
function install() {
    return __awaiter(this, void 0, void 0, function () {
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, manageDependencies(types_1.ManagementType.Install)];
                case 1: return [2 /*return*/, _a.sent()];
            }
        });
    });
}
exports.install = install;
function update() {
    return __awaiter(this, void 0, void 0, function () {
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, manageDependencies(types_1.ManagementType.Update)];
                case 1: return [2 /*return*/, _a.sent()];
            }
        });
    });
}
exports.update = update;


/***/ }),

/***/ "./src/api/dependency-manager/index.ts":
/*!*********************************************!*\
  !*** ./src/api/dependency-manager/index.ts ***!
  \*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var logger_1 = __importDefault(__webpack_require__(/*! ../../helpers/logger */ "./src/helpers/logger.ts"));
var rust = __importStar(__webpack_require__(/*! ./rust */ "./src/api/dependency-manager/rust.ts"));
var cargoCommands = __importStar(__webpack_require__(/*! ./cargo-commands */ "./src/api/dependency-manager/cargo-commands.ts"));
var cargoCrates = __importStar(__webpack_require__(/*! ./cargo-crates */ "./src/api/dependency-manager/cargo-crates.ts"));
var npmPackages = __importStar(__webpack_require__(/*! ./npm-packages */ "./src/api/dependency-manager/npm-packages.ts"));
var log = logger_1.default('dependency:manager');
module.exports = {
    installDependencies: function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        log('Installing missing dependencies...');
                        rust.install();
                        return [4 /*yield*/, cargoCommands.install()];
                    case 1:
                        _a.sent();
                        return [4 /*yield*/, cargoCrates.install()];
                    case 2:
                        _a.sent();
                        return [4 /*yield*/, npmPackages.install()];
                    case 3:
                        _a.sent();
                        return [2 /*return*/];
                }
            });
        });
    },
    updateDependencies: function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        log('Updating dependencies...');
                        rust.update();
                        return [4 /*yield*/, cargoCommands.update()];
                    case 1:
                        _a.sent();
                        return [4 /*yield*/, cargoCrates.update()];
                    case 2:
                        _a.sent();
                        return [4 /*yield*/, npmPackages.update()];
                    case 3:
                        _a.sent();
                        return [2 /*return*/];
                }
            });
        });
    }
};


/***/ }),

/***/ "./src/api/dependency-manager/npm-packages.ts":
/*!****************************************************!*\
  !*** ./src/api/dependency-manager/npm-packages.ts ***!
  \****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.update = exports.install = void 0;
var types_1 = __webpack_require__(/*! ./types */ "./src/api/dependency-manager/types.ts");
var util_1 = __webpack_require__(/*! ./util */ "./src/api/dependency-manager/util.ts");
var logger_1 = __importDefault(__webpack_require__(/*! ../../helpers/logger */ "./src/helpers/logger.ts"));
var app_paths_1 = __webpack_require__(/*! ../../helpers/app-paths */ "./src/helpers/app-paths.ts");
var inquirer_1 = __importDefault(__webpack_require__(/*! inquirer */ "inquirer"));
var fs_1 = __webpack_require__(/*! fs */ "fs");
var log = logger_1.default('dependency:npm-packages');
var dependencies = ['tauri'];
function manageDependencies(managementType) {
    return __awaiter(this, void 0, void 0, function () {
        var installedDeps, updatedDeps, _i, dependencies_1, dependency, currentVersion, latestVersion, inquired, result;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    installedDeps = [];
                    updatedDeps = [];
                    if (!fs_1.existsSync(app_paths_1.resolve.app('package.json'))) return [3 /*break*/, 9];
                    _i = 0, dependencies_1 = dependencies;
                    _a.label = 1;
                case 1:
                    if (!(_i < dependencies_1.length)) return [3 /*break*/, 9];
                    dependency = dependencies_1[_i];
                    return [4 /*yield*/, util_1.getNpmPackageVersion(dependency)];
                case 2:
                    currentVersion = _a.sent();
                    if (!(currentVersion === null)) return [3 /*break*/, 3];
                    log("Installing " + dependency + "...");
                    util_1.installNpmPackage(dependency);
                    installedDeps.push(dependency);
                    return [3 /*break*/, 8];
                case 3:
                    if (!(managementType === types_1.ManagementType.Update)) return [3 /*break*/, 7];
                    latestVersion = util_1.getNpmLatestVersion(dependency);
                    if (!util_1.semverLt(currentVersion, latestVersion)) return [3 /*break*/, 5];
                    return [4 /*yield*/, inquirer_1.default.prompt([{
                                type: 'confirm',
                                name: 'answer',
                                message: "[NPM]: \"" + dependency + "\" latest version is " + latestVersion + ". Do you want to update?",
                                default: false
                            }])];
                case 4:
                    inquired = _a.sent();
                    if (inquired.answer) {
                        log("Updating " + dependency + "...");
                        util_1.updateNpmPackage(dependency);
                        updatedDeps.push(dependency);
                    }
                    return [3 /*break*/, 6];
                case 5:
                    log("\"" + dependency + "\" is up to date");
                    _a.label = 6;
                case 6: return [3 /*break*/, 8];
                case 7:
                    log("\"" + dependency + "\" is already installed");
                    _a.label = 8;
                case 8:
                    _i++;
                    return [3 /*break*/, 1];
                case 9:
                    result = new Map();
                    result.set(types_1.ManagementType.Install, installedDeps);
                    result.set(types_1.ManagementType.Update, updatedDeps);
                    return [2 /*return*/, result];
            }
        });
    });
}
function install() {
    return __awaiter(this, void 0, void 0, function () {
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, manageDependencies(types_1.ManagementType.Install)];
                case 1: return [2 /*return*/, _a.sent()];
            }
        });
    });
}
exports.install = install;
function update() {
    return __awaiter(this, void 0, void 0, function () {
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, manageDependencies(types_1.ManagementType.Update)];
                case 1: return [2 /*return*/, _a.sent()];
            }
        });
    });
}
exports.update = update;


/***/ }),

/***/ "./src/api/dependency-manager/rust.ts":
/*!********************************************!*\
  !*** ./src/api/dependency-manager/rust.ts ***!
  \********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.update = exports.install = void 0;
var types_1 = __webpack_require__(/*! ./types */ "./src/api/dependency-manager/types.ts");
var spawn_1 = __webpack_require__(/*! ../../helpers/spawn */ "./src/helpers/spawn.ts");
var get_script_version_1 = __importDefault(__webpack_require__(/*! ../../helpers/get-script-version */ "./src/helpers/get-script-version.ts"));
var logger_1 = __importDefault(__webpack_require__(/*! ../../helpers/logger */ "./src/helpers/logger.ts"));
var fs_1 = __webpack_require__(/*! fs */ "fs");
var path_1 = __webpack_require__(/*! path */ "path");
var os_1 = __webpack_require__(/*! os */ "os");
var https_1 = __importDefault(__webpack_require__(/*! https */ "https"));
var log = logger_1.default('dependency:rust');
function download(url, dest) {
    return __awaiter(this, void 0, void 0, function () {
        var file;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    file = fs_1.createWriteStream(dest);
                    return [4 /*yield*/, new Promise(function (resolve, reject) {
                            https_1.default.get(url, function (response) {
                                response.pipe(file);
                                file.on('finish', function () {
                                    file.close();
                                    resolve();
                                });
                            }).on('error', function (err) {
                                fs_1.unlinkSync(dest);
                                reject(err.message);
                            });
                        })];
                case 1: return [2 /*return*/, _a.sent()];
            }
        });
    });
}
;
function installRustup() {
    if (os_1.platform() === 'win32') {
        return spawn_1.spawnSync('powershell', [path_1.resolve(__dirname, '../../scripts/rustup-init.exe')], process.cwd());
    }
    return spawn_1.spawnSync('/bin/sh', [path_1.resolve(__dirname, '../../scripts/rustup-init.sh')], process.cwd());
}
function manageDependencies(managementType) {
    if (get_script_version_1.default('rustup') === null) {
        log('Installing rustup...');
        installRustup();
    }
    if (managementType === types_1.ManagementType.Update) {
        spawn_1.spawnSync('rustup', ['update'], process.cwd());
    }
}
function install() {
    return manageDependencies(types_1.ManagementType.Install);
}
exports.install = install;
function update() {
    return manageDependencies(types_1.ManagementType.Update);
}
exports.update = update;


/***/ }),

/***/ "./src/api/dependency-manager/types.ts":
/*!*********************************************!*\
  !*** ./src/api/dependency-manager/types.ts ***!
  \*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ManagementType = void 0;
var ManagementType;
(function (ManagementType) {
    ManagementType[ManagementType["Install"] = 0] = "Install";
    ManagementType[ManagementType["Update"] = 1] = "Update";
})(ManagementType = exports.ManagementType || (exports.ManagementType = {}));


/***/ }),

/***/ "./src/api/dependency-manager/util.ts":
/*!********************************************!*\
  !*** ./src/api/dependency-manager/util.ts ***!
  \********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.semverLt = exports.padVersion = exports.updateNpmPackage = exports.installNpmPackage = exports.getNpmPackageVersion = exports.getNpmLatestVersion = exports.getCrateLatestVersion = void 0;
var https_1 = __importDefault(__webpack_require__(/*! https */ "https"));
var spawn_1 = __webpack_require__(/*! ../../helpers/spawn */ "./src/helpers/spawn.ts");
var cross_spawn_1 = __webpack_require__(/*! cross-spawn */ "cross-spawn");
var app_paths_1 = __webpack_require__(/*! ../../helpers/app-paths */ "./src/helpers/app-paths.ts");
var fs_1 = __webpack_require__(/*! fs */ "fs");
var semver_1 = __importDefault(__webpack_require__(/*! semver */ "semver"));
var BASE_URL = 'https://docs.rs/crate/';
function getCrateLatestVersion(crateName) {
    return __awaiter(this, void 0, void 0, function () {
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
                        var url = "" + BASE_URL + crateName;
                        https_1.default.get(url, function (res) {
                            if (res.statusCode !== 302 || !res.headers.location) {
                                reject(res);
                            }
                            else {
                                var version = res.headers.location.replace(url + '/', '');
                                resolve(version);
                            }
                        });
                    })];
                case 1: return [2 /*return*/, _a.sent()];
            }
        });
    });
}
exports.getCrateLatestVersion = getCrateLatestVersion;
function getNpmLatestVersion(packageName) {
    var child = cross_spawn_1.sync('npm', ['show', packageName, 'version'], { cwd: app_paths_1.appDir });
    return String(child.output[1]).replace('\n', '');
}
exports.getNpmLatestVersion = getNpmLatestVersion;
function getNpmPackageVersion(packageName) {
    return __awaiter(this, void 0, void 0, function () {
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, new Promise(function (resolve) {
                        var child = cross_spawn_1.sync('npm', ['list', packageName, 'version', '--depth', '0'], { cwd: app_paths_1.appDir });
                        var output = String(child.output[1]);
                        // eslint-disable-next-line security/detect-non-literal-regexp
                        var matches = new RegExp(packageName + '@(\\S+)', 'g').exec(output);
                        if (matches === null || matches === void 0 ? void 0 : matches[1]) {
                            resolve(matches[1]);
                        }
                        else {
                            resolve(null);
                        }
                    })];
                case 1: return [2 /*return*/, _a.sent()];
            }
        });
    });
}
exports.getNpmPackageVersion = getNpmPackageVersion;
function installNpmPackage(packageName) {
    var usesYarn = fs_1.existsSync(app_paths_1.resolve.app('yarn.lock'));
    if (usesYarn) {
        spawn_1.spawnSync('yarn', ['add', packageName], app_paths_1.appDir);
    }
    else {
        spawn_1.spawnSync('npm', ['install', packageName], app_paths_1.appDir);
    }
}
exports.installNpmPackage = installNpmPackage;
function updateNpmPackage(packageName) {
    var usesYarn = fs_1.existsSync(app_paths_1.resolve.app('yarn.lock'));
    if (usesYarn) {
        spawn_1.spawnSync('yarn', ['upgrade', packageName, '--latest'], app_paths_1.appDir);
    }
    else {
        spawn_1.spawnSync('npm', ['install', packageName + "@latest"], app_paths_1.appDir);
    }
}
exports.updateNpmPackage = updateNpmPackage;
function padVersion(version) {
    var _a;
    var count = ((_a = version.match(/\./g)) !== null && _a !== void 0 ? _a : []).length;
    while (count < 2) {
        count++;
        version += '.0';
    }
    return version;
}
exports.padVersion = padVersion;
function semverLt(first, second) {
    return semver_1.default.lt(padVersion(first), padVersion(second));
}
exports.semverLt = semverLt;


/***/ }),

/***/ "./src/helpers/app-paths.ts":
/*!**********************************!*\
  !*** ./src/helpers/app-paths.ts ***!
  \**********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolve = exports.tauriDir = exports.appDir = void 0;
var fs_1 = __webpack_require__(/*! fs */ "fs");
var path_1 = __webpack_require__(/*! path */ "path");
var logger_1 = __importDefault(__webpack_require__(/*! ./logger */ "./src/helpers/logger.ts"));
var chalk_1 = __importDefault(__webpack_require__(/*! chalk */ "chalk"));
var warn = logger_1.default('tauri', chalk_1.default.red);
function resolvePath(basePath, dir) {
    return dir && path_1.isAbsolute(dir)
        ? dir
        : path_1.resolve(basePath, dir);
}
var getAppDir = function () {
    var dir = process.cwd();
    var count = 0;
    // only go up three folders max
    while (dir.length > 0 && !dir.endsWith(path_1.sep) && count <= 2) {
        if (fs_1.existsSync(path_1.join(dir, 'src-tauri', 'tauri.conf.json'))) {
            return dir;
        }
        count++;
        dir = path_1.normalize(path_1.join(dir, '..'));
    }
    warn('Couldn\'t find recognize the current folder as a part of a Tauri project');
    process.exit(1);
};
var appDir = getAppDir();
exports.appDir = appDir;
var tauriDir = path_1.resolve(appDir, 'src-tauri');
exports.tauriDir = tauriDir;
var resolveDir = {
    app: function (dir) { return resolvePath(appDir, dir); },
    tauri: function (dir) { return resolvePath(tauriDir, dir); }
};
exports.resolve = resolveDir;


/***/ }),

/***/ "./src/helpers/get-script-version.ts":
/*!*******************************************!*\
  !*** ./src/helpers/get-script-version.ts ***!
  \*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __spreadArrays = (this && this.__spreadArrays) || function () {
    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
    for (var r = Array(s), k = 0, i = 0; i < il; i++)
        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
            r[k] = a[j];
    return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var cross_spawn_1 = __webpack_require__(/*! cross-spawn */ "cross-spawn");
function getVersion(command, args) {
    if (args === void 0) { args = []; }
    try {
        var child = cross_spawn_1.sync(command, __spreadArrays(args, ['--version']));
        if (child.status === 0) {
            var output = String(child.output[1]);
            return output.replace(/\n/g, '');
        }
        return null;
    }
    catch (err) {
        return null;
    }
}
exports.default = getVersion;


/***/ }),

/***/ "./src/helpers/logger.ts":
/*!*******************************!*\
  !*** ./src/helpers/logger.ts ***!
  \*******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var chalk_1 = __importDefault(__webpack_require__(/*! chalk */ "chalk"));
var ms_1 = __importDefault(__webpack_require__(/*! ms */ "ms"));
var prevTime;
exports.default = (function (banner, color) {
    if (color === void 0) { color = chalk_1.default.green; }
    return function (msg) {
        var curr = +new Date();
        var diff = curr - (prevTime || curr);
        prevTime = curr;
        if (msg) {
            console.log(
            // TODO: proper typings for color and banner
            // eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-call
            " " + color(String(banner)) + " " + msg + " " + chalk_1.default.green("+" + ms_1.default(diff)));
        }
        else {
            console.log();
        }
    };
});


/***/ }),

/***/ "./src/helpers/spawn.ts":
/*!******************************!*\
  !*** ./src/helpers/spawn.ts ***!
  \******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.spawnSync = exports.spawn = void 0;
var cross_spawn_1 = __importDefault(__webpack_require__(/*! cross-spawn */ "cross-spawn"));
var logger_1 = __importDefault(__webpack_require__(/*! ./logger */ "./src/helpers/logger.ts"));
var chalk_1 = __importDefault(__webpack_require__(/*! chalk */ "chalk"));
var log = logger_1.default('app:spawn');
var warn = logger_1.default('app:spawn', chalk_1.default.red);
/*
  Returns pid, takes onClose
 */
exports.spawn = function (cmd, params, cwd, onClose) {
    log("Running \"" + cmd + " " + params.join(' ') + "\"");
    log();
    // TODO: move to execa?
    var runner = cross_spawn_1.default(cmd, params, {
        stdio: 'inherit',
        cwd: cwd,
        env: process.env
    });
    runner.on('close', function (code) {
        log();
        if (code) {
            // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
            log("Command \"" + cmd + "\" failed with exit code: " + code);
        }
        // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
        onClose && onClose(code, runner.pid);
    });
    return runner.pid;
};
/*
  Returns nothing, takes onFail
 */
exports.spawnSync = function (cmd, params, cwd, onFail) {
    log("[sync] Running \"" + cmd + " " + params.join(' ') + "\"");
    log();
    var runner = cross_spawn_1.default.sync(cmd, params, {
        stdio: 'inherit',
        cwd: cwd
    });
    // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
    if (runner.status || runner.error) {
        warn();
        // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
        warn("\u26A0\uFE0F  Command \"" + cmd + "\" failed with exit code: " + runner.status);
        if (runner.status === null) {
            warn("\u26A0\uFE0F  Please globally install \"" + cmd + "\"");
        }
        // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
        onFail && onFail();
        process.exit(1);
    }
};


/***/ }),

/***/ "@tauri-apps/toml":
/*!***********************************!*\
  !*** external "@tauri-apps/toml" ***!
  \***********************************/
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = require("@tauri-apps/toml");

/***/ }),

/***/ "chalk":
/*!************************!*\
  !*** external "chalk" ***!
  \************************/
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = require("chalk");

/***/ }),

/***/ "cross-spawn":
/*!******************************!*\
  !*** external "cross-spawn" ***!
  \******************************/
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = require("cross-spawn");

/***/ }),

/***/ "fs":
/*!*********************!*\
  !*** external "fs" ***!
  \*********************/
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = require("fs");

/***/ }),

/***/ "https":
/*!************************!*\
  !*** external "https" ***!
  \************************/
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = require("https");

/***/ }),

/***/ "inquirer":
/*!***************************!*\
  !*** external "inquirer" ***!
  \***************************/
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = require("inquirer");

/***/ }),

/***/ "ms":
/*!*********************!*\
  !*** external "ms" ***!
  \*********************/
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = require("ms");

/***/ }),

/***/ "os":
/*!*********************!*\
  !*** external "os" ***!
  \*********************/
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = require("os");

/***/ }),

/***/ "path":
/*!***********************!*\
  !*** external "path" ***!
  \***********************/
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = require("path");

/***/ }),

/***/ "semver":
/*!*************************!*\
  !*** external "semver" ***!
  \*************************/
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = require("semver");

/***/ })

/******/ });
});
//# sourceMappingURL=dependency-manager.js.map