Outlook_Addin_LLM/node_modules/office-addin-project/lib/commands.js

54 lines
2.9 KiB
JavaScript
Raw Normal View History

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.convert = void 0;
const inquirer = require("inquirer");
const office_addin_usage_data_1 = require("office-addin-usage-data");
const defaults_1 = require("./defaults");
const convert_1 = require("./convert");
function convert(command) {
var _a, _b, _c, _d;
return __awaiter(this, void 0, void 0, function* () {
try {
const manifestPath = (_a = command.manifest) !== null && _a !== void 0 ? _a : "./manifest.xml";
const backupPath = (_b = command.backup) !== null && _b !== void 0 ? _b : "./backup.zip";
const projectPath = (_c = command.project) !== null && _c !== void 0 ? _c : "";
const shouldContinue = (_d = command.confirm) !== null && _d !== void 0 ? _d : yield asksForUserConfirmation();
if (shouldContinue) {
yield (0, convert_1.convertProject)(manifestPath, backupPath, projectPath);
defaults_1.usageDataObject.reportSuccess("convert", { result: "Project converted" });
}
else {
defaults_1.usageDataObject.reportSuccess("convert", {
result: "Conversion cancelled",
});
}
}
catch (err) {
defaults_1.usageDataObject.reportException("convert", err);
(0, office_addin_usage_data_1.logErrorMessage)(err);
}
});
}
exports.convert = convert;
function asksForUserConfirmation() {
return __awaiter(this, void 0, void 0, function* () {
const question = {
message: `This command will convert your current xml manifest to a json manifest and then proceed to upgrade your project dependencies to ensure compatibility with the new project structure.\nHowever, in order for this newly updated project to function correctly you must be using a compatible version of Outlook.\nWould you like to continue?`,
name: "didUserConfirm",
type: "confirm",
};
const answers = yield inquirer.prompt([question]);
return answers.didUserConfirm;
});
}
//# sourceMappingURL=commands.js.map