UNPKG

office-addin-project

Version:

Provides project wide commands to an Office Addin Project

57 lines 3.19 kB
"use strict"; // 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()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.convert = convert; const inquirer_1 = __importDefault(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(options) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c, _d, _e; try { const manifestPath = (_a = options.manifest) !== null && _a !== void 0 ? _a : "./manifest.xml"; const backupPath = (_b = options.backup) !== null && _b !== void 0 ? _b : "./backup.zip"; const projectPath = (_c = options.project) !== null && _c !== void 0 ? _c : ""; const devPreview = (_d = options.preview) !== null && _d !== void 0 ? _d : false; const shouldContinue = (_e = options.confirm) !== null && _e !== void 0 ? _e : (yield asksForUserConfirmation()); if (shouldContinue) { yield (0, convert_1.convertProject)(manifestPath, backupPath, projectPath, devPreview); 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); } }); } function asksForUserConfirmation() { return __awaiter(this, void 0, void 0, function* () { const answers = yield inquirer_1.default.prompt({ 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 Office applications.\nWould you like to continue?`, name: "didUserConfirm", type: "confirm", }); return answers.didUserConfirm; }); } //# sourceMappingURL=commands.js.map