office-addin-manifest
Advanced tools
Comparing version 1.6.1 to 1.6.2
// copyright (c) Microsoft Corporation. All rights reserved. | ||
// licensed under the MIT license. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toAddInType = exports.parseAddInTypes = exports.parseAddInType = exports.getAddInTypes = exports.getAddInTypeForManifestOfficeAppType = exports.AddInType = void 0; | ||
const office_addin_usage_data_1 = require("office-addin-usage-data"); | ||
@@ -5,0 +6,0 @@ /** |
@@ -13,5 +13,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validate = exports.modify = exports.info = void 0; | ||
const chalk_1 = require("chalk"); | ||
const office_addin_cli_1 = require("office-addin-cli"); | ||
const manifestInfo = require("./manifestInfo"); | ||
const manifestInfo_1 = require("./manifestInfo"); | ||
const validate_1 = require("./validate"); | ||
@@ -29,3 +30,3 @@ const defaults_1 = require("./defaults"); | ||
try { | ||
const manifest = yield manifestInfo.readManifestFile(manifestPath); | ||
const manifest = yield manifestInfo_1.OfficeAddinManifest.readManifestFile(manifestPath); | ||
logManifestInfo(manifestPath, manifest); | ||
@@ -126,3 +127,3 @@ defaults_1.usageDataObject.reportSuccess("info"); | ||
const displayName = getCommandOptionString(command.displayName); | ||
const manifest = yield manifestInfo.modifyManifestFile(manifestPath, guid, displayName); | ||
const manifest = yield manifestInfo_1.OfficeAddinManifest.modifyManifestFile(manifestPath, guid, displayName); | ||
logManifestInfo(manifestPath, manifest); | ||
@@ -129,0 +130,0 @@ defaults_1.usageDataObject.reportSuccess("modify"); |
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.usageDataObject = void 0; | ||
const usageData = require("office-addin-usage-data"); | ||
@@ -5,0 +6,0 @@ // Usage data defaults |
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
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 __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./addInTypes")); | ||
__export(require("./manifestInfo")); | ||
__export(require("./officeApp")); | ||
__export(require("./validate")); | ||
__export(require("./xml")); | ||
__exportStar(require("./addInTypes"), exports); | ||
__exportStar(require("./manifestInfo"), exports); | ||
__exportStar(require("./officeApp"), exports); | ||
__exportStar(require("./validate"), exports); | ||
__exportStar(require("./xml"), exports); | ||
//# sourceMappingURL=main.js.map |
@@ -24,4 +24,6 @@ declare class DefaultSettings { | ||
} | ||
export declare function modifyManifestFile(manifestPath: string, guid?: string, displayName?: string): Promise<ManifestInfo>; | ||
export declare function readManifestFile(manifestPath: string): Promise<ManifestInfo>; | ||
export declare namespace OfficeAddinManifest { | ||
function modifyManifestFile(manifestPath: string, guid?: string, displayName?: string): Promise<ManifestInfo>; | ||
function readManifestFile(manifestPath: string): Promise<ManifestInfo>; | ||
} | ||
export {}; |
@@ -13,2 +13,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OfficeAddinManifest = exports.ManifestInfo = void 0; | ||
const fs = require("fs"); | ||
@@ -27,138 +28,141 @@ const util = require("util"); | ||
exports.ManifestInfo = ManifestInfo; | ||
function parseManifest(xml) { | ||
const manifest = new ManifestInfo(); | ||
const officeApp = xml.OfficeApp; | ||
if (officeApp) { | ||
const defaultSettingsXml = xmlMethods.getXmlElement(officeApp, "DefaultSettings"); | ||
manifest.id = xmlMethods.getXmlElementValue(officeApp, "Id"); | ||
manifest.allowSnapshot = xmlMethods.getXmlElementValue(officeApp, "AllowSnapshot"); | ||
manifest.alternateId = xmlMethods.getXmlElementValue(officeApp, "AlternateId"); | ||
manifest.appDomains = xmlMethods.getXmlElementsValue(officeApp, "AppDomains", "AppDomain"); | ||
manifest.defaultLocale = xmlMethods.getXmlElementValue(officeApp, "DefaultLocale"); | ||
manifest.description = xmlMethods.getXmlElementAttributeValue(officeApp, "Description"); | ||
manifest.displayName = xmlMethods.getXmlElementAttributeValue(officeApp, "DisplayName"); | ||
manifest.highResolutionIconUrl = xmlMethods.getXmlElementAttributeValue(officeApp, "HighResolutionIconUrl"); | ||
manifest.hosts = xmlMethods.getXmlElementsAttributeValue(officeApp, "Hosts", "Host", "Name"); | ||
manifest.iconUrl = xmlMethods.getXmlElementAttributeValue(officeApp, "IconUrl"); | ||
manifest.officeAppType = xmlMethods.getXmlAttributeValue(officeApp, "xsi:type"); | ||
manifest.permissions = xmlMethods.getXmlElementValue(officeApp, "Permissions"); | ||
manifest.providerName = xmlMethods.getXmlElementValue(officeApp, "ProviderName"); | ||
manifest.supportUrl = xmlMethods.getXmlElementAttributeValue(officeApp, "SupportUrl"); | ||
manifest.version = xmlMethods.getXmlElementValue(officeApp, "Version"); | ||
if (defaultSettingsXml) { | ||
const defaultSettings = new DefaultSettings(); | ||
defaultSettings.requestedHeight = xmlMethods.getXmlElementValue(defaultSettingsXml, "RequestedHeight"); | ||
defaultSettings.requestedWidth = xmlMethods.getXmlElementValue(defaultSettingsXml, "RequestedWidth"); | ||
defaultSettings.sourceLocation = xmlMethods.getXmlElementAttributeValue(defaultSettingsXml, "SourceLocation"); | ||
manifest.defaultSettings = defaultSettings; | ||
var OfficeAddinManifest; | ||
(function (OfficeAddinManifest) { | ||
function parseManifest(xml) { | ||
const manifest = new ManifestInfo(); | ||
const officeApp = xml.OfficeApp; | ||
if (officeApp) { | ||
const defaultSettingsXml = xmlMethods.getXmlElement(officeApp, "DefaultSettings"); | ||
manifest.id = xmlMethods.getXmlElementValue(officeApp, "Id"); | ||
manifest.allowSnapshot = xmlMethods.getXmlElementValue(officeApp, "AllowSnapshot"); | ||
manifest.alternateId = xmlMethods.getXmlElementValue(officeApp, "AlternateId"); | ||
manifest.appDomains = xmlMethods.getXmlElementsValue(officeApp, "AppDomains", "AppDomain"); | ||
manifest.defaultLocale = xmlMethods.getXmlElementValue(officeApp, "DefaultLocale"); | ||
manifest.description = xmlMethods.getXmlElementAttributeValue(officeApp, "Description"); | ||
manifest.displayName = xmlMethods.getXmlElementAttributeValue(officeApp, "DisplayName"); | ||
manifest.highResolutionIconUrl = xmlMethods.getXmlElementAttributeValue(officeApp, "HighResolutionIconUrl"); | ||
manifest.hosts = xmlMethods.getXmlElementsAttributeValue(officeApp, "Hosts", "Host", "Name"); | ||
manifest.iconUrl = xmlMethods.getXmlElementAttributeValue(officeApp, "IconUrl"); | ||
manifest.officeAppType = xmlMethods.getXmlAttributeValue(officeApp, "xsi:type"); | ||
manifest.permissions = xmlMethods.getXmlElementValue(officeApp, "Permissions"); | ||
manifest.providerName = xmlMethods.getXmlElementValue(officeApp, "ProviderName"); | ||
manifest.supportUrl = xmlMethods.getXmlElementAttributeValue(officeApp, "SupportUrl"); | ||
manifest.version = xmlMethods.getXmlElementValue(officeApp, "Version"); | ||
if (defaultSettingsXml) { | ||
const defaultSettings = new DefaultSettings(); | ||
defaultSettings.requestedHeight = xmlMethods.getXmlElementValue(defaultSettingsXml, "RequestedHeight"); | ||
defaultSettings.requestedWidth = xmlMethods.getXmlElementValue(defaultSettingsXml, "RequestedWidth"); | ||
defaultSettings.sourceLocation = xmlMethods.getXmlElementAttributeValue(defaultSettingsXml, "SourceLocation"); | ||
manifest.defaultSettings = defaultSettings; | ||
} | ||
} | ||
return manifest; | ||
} | ||
return manifest; | ||
} | ||
function modifyManifestFile(manifestPath, guid, displayName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let manifestData = {}; | ||
if (manifestPath) { | ||
if (guid === undefined && displayName === undefined) { | ||
throw new Error("You need to specify something to change in the manifest."); | ||
} | ||
else { | ||
try { | ||
manifestData = yield modifyManifestXml(manifestPath, guid, displayName); | ||
yield writeManifestData(manifestPath, manifestData); | ||
let output = yield readManifestFile(manifestPath); | ||
defaults_1.usageDataObject.reportSuccess("modifyManifestFile()"); | ||
return output; | ||
function modifyManifestFile(manifestPath, guid, displayName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let manifestData = {}; | ||
if (manifestPath) { | ||
if (guid === undefined && displayName === undefined) { | ||
throw new Error("You need to specify something to change in the manifest."); | ||
} | ||
catch (err) { | ||
defaults_1.usageDataObject.reportException("modifyManifestFile()", err); | ||
throw err; | ||
else { | ||
try { | ||
manifestData = yield modifyManifestXml(manifestPath, guid, displayName); | ||
yield writeManifestData(manifestPath, manifestData); | ||
let output = yield readManifestFile(manifestPath); | ||
defaults_1.usageDataObject.reportSuccess("modifyManifestFile()"); | ||
return output; | ||
} | ||
catch (err) { | ||
defaults_1.usageDataObject.reportException("modifyManifestFile()", err); | ||
throw err; | ||
} | ||
} | ||
} | ||
} | ||
else { | ||
throw new Error(`Please provide the path to the manifest file.`); | ||
} | ||
}); | ||
} | ||
exports.modifyManifestFile = modifyManifestFile; | ||
function modifyManifestXml(manifestPath, guid, displayName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const manifestXml = yield readXmlFromManifestFile(manifestPath); | ||
setModifiedXmlData(manifestXml.OfficeApp, guid, displayName); | ||
return manifestXml; | ||
} | ||
catch (err) { | ||
throw new Error(`Unable to modify xml data for manifest file: ${manifestPath}. \n${err}`); | ||
} | ||
}); | ||
} | ||
function parseXmlAsync(xmlString, manifestPath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return new Promise(function (resolve, reject) { | ||
xml2js.parseString(xmlString, function (parseError, xml) { | ||
if (parseError) { | ||
reject(new Error(`Unable to parse the manifest file: ${manifestPath}. \n${parseError}`)); | ||
} | ||
else { | ||
resolve(xml); | ||
} | ||
else { | ||
throw new Error(`Please provide the path to the manifest file.`); | ||
} | ||
}); | ||
} | ||
OfficeAddinManifest.modifyManifestFile = modifyManifestFile; | ||
function modifyManifestXml(manifestPath, guid, displayName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const manifestXml = yield readXmlFromManifestFile(manifestPath); | ||
setModifiedXmlData(manifestXml.OfficeApp, guid, displayName); | ||
return manifestXml; | ||
} | ||
catch (err) { | ||
throw new Error(`Unable to modify xml data for manifest file: ${manifestPath}. \n${err}`); | ||
} | ||
}); | ||
} | ||
function parseXmlAsync(xmlString, manifestPath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return new Promise(function (resolve, reject) { | ||
xml2js.parseString(xmlString, function (parseError, xml) { | ||
if (parseError) { | ||
reject(new Error(`Unable to parse the manifest file: ${manifestPath}. \n${parseError}`)); | ||
} | ||
else { | ||
resolve(xml); | ||
} | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
function readManifestFile(manifestPath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (manifestPath) { | ||
const xml = yield readXmlFromManifestFile(manifestPath); | ||
const manifest = parseManifest(xml); | ||
return manifest; | ||
} | ||
else { | ||
throw new Error(`Please provide the path to the manifest file.`); | ||
} | ||
}); | ||
} | ||
exports.readManifestFile = readManifestFile; | ||
function readXmlFromManifestFile(manifestPath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const fileData = yield readFileAsync(manifestPath, { | ||
encoding: "utf8", | ||
} | ||
function readManifestFile(manifestPath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (manifestPath) { | ||
const xml = yield readXmlFromManifestFile(manifestPath); | ||
const manifest = parseManifest(xml); | ||
return manifest; | ||
} | ||
else { | ||
throw new Error(`Please provide the path to the manifest file.`); | ||
} | ||
}); | ||
const xml = yield parseXmlAsync(fileData, manifestPath); | ||
return xml; | ||
}); | ||
} | ||
function setModifiedXmlData(xml, guid, displayName) { | ||
if (typeof guid !== "undefined") { | ||
if (!guid || guid === "random") { | ||
guid = uuid_1.v4(); | ||
} | ||
xmlMethods.setXmlElementValue(xml, "Id", guid); | ||
} | ||
if (typeof displayName !== "undefined") { | ||
xmlMethods.setXmlElementAttributeValue(xml, "DisplayName", displayName); | ||
OfficeAddinManifest.readManifestFile = readManifestFile; | ||
function readXmlFromManifestFile(manifestPath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const fileData = yield readFileAsync(manifestPath, { | ||
encoding: "utf8", | ||
}); | ||
const xml = yield parseXmlAsync(fileData, manifestPath); | ||
return xml; | ||
}); | ||
} | ||
} | ||
function writeManifestData(manifestPath, manifestData) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let xml; | ||
try { | ||
// Generate xml for the manifest data. | ||
const builder = new xml2js.Builder(); | ||
xml = builder.buildObject(manifestData); | ||
function setModifiedXmlData(xml, guid, displayName) { | ||
if (typeof guid !== "undefined") { | ||
if (!guid || guid === "random") { | ||
guid = uuid_1.v4(); | ||
} | ||
xmlMethods.setXmlElementValue(xml, "Id", guid); | ||
} | ||
catch (err) { | ||
throw new Error(`Unable to generate xml for the manifest.\n${err}`); | ||
if (typeof displayName !== "undefined") { | ||
xmlMethods.setXmlElementAttributeValue(xml, "DisplayName", displayName); | ||
} | ||
try { | ||
// Write the xml back to the manifest file. | ||
yield writeFileAsync(manifestPath, xml); | ||
} | ||
catch (err) { | ||
throw new Error(`Unable to write to file. ${manifestPath} \n${err}`); | ||
} | ||
}); | ||
} | ||
} | ||
function writeManifestData(manifestPath, manifestData) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let xml; | ||
try { | ||
// Generate xml for the manifest data. | ||
const builder = new xml2js.Builder(); | ||
xml = builder.buildObject(manifestData); | ||
} | ||
catch (err) { | ||
throw new Error(`Unable to generate xml for the manifest.\n${err}`); | ||
} | ||
try { | ||
// Write the xml back to the manifest file. | ||
yield writeFileAsync(manifestPath, xml); | ||
} | ||
catch (err) { | ||
throw new Error(`Unable to write to file. ${manifestPath} \n${err}`); | ||
} | ||
}); | ||
} | ||
})(OfficeAddinManifest = exports.OfficeAddinManifest || (exports.OfficeAddinManifest = {})); | ||
//# sourceMappingURL=manifestInfo.js.map |
// copyright (c) Microsoft Corporation. All rights reserved. | ||
// licensed under the MIT license. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toOfficeApp = exports.parseOfficeApps = exports.parseOfficeApp = exports.getOfficeAppsForManifestHosts = exports.getOfficeApps = exports.getOfficeAppNames = exports.getOfficeAppName = exports.getOfficeAppForManifestHost = exports.OfficeApp = void 0; | ||
/** | ||
@@ -5,0 +6,0 @@ * The Office apps which can host Office Add-ins. |
@@ -13,2 +13,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateManifest = exports.ManifestValidation = exports.ManifestValidationReport = exports.ManifestValidationProduct = exports.ManifestValidationIssue = exports.ManifestValidationDetails = void 0; | ||
const fs_1 = require("fs"); | ||
@@ -41,3 +42,3 @@ const node_fetch_1 = require("node-fetch"); | ||
// read the manifest file to ensure the file path is valid | ||
yield manifestInfo_1.readManifestFile(manifestPath); | ||
yield manifestInfo_1.OfficeAddinManifest.readManifestFile(manifestPath); | ||
const stream = yield fs_1.createReadStream(manifestPath); | ||
@@ -44,0 +45,0 @@ let response; |
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setXmlElementValue = exports.setXmlElementAttributeValue = exports.getXmlElementValue = exports.getXmlElementsValue = exports.getXmlElementsAttributeValue = exports.getXmlElements = exports.getXmlElementAttributeValue = exports.getXmlElement = exports.getXmlAttributeValue = void 0; | ||
/** | ||
@@ -5,0 +6,0 @@ * Given an xml element, returns the value of the attribute with the specified name. |
{ | ||
"name": "office-addin-manifest", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"description": "Read and modify Office Add-in manifest files.", | ||
@@ -28,4 +28,4 @@ "main": "./lib/main.js", | ||
"node-fetch": "^2.6.1", | ||
"office-addin-cli": "^1.2.1", | ||
"office-addin-usage-data": "^1.3.1", | ||
"office-addin-cli": "^1.2.2", | ||
"office-addin-usage-data": "^1.3.2", | ||
"path": "^0.12.7", | ||
@@ -47,6 +47,6 @@ "uuid": "^8.3.2", | ||
"mocha": "^8.4.0", | ||
"office-addin-lint": "^1.3.1", | ||
"office-addin-lint": "^1.3.2", | ||
"rimraf": "^3.0.2", | ||
"ts-node": "^8.8.1", | ||
"typescript": "^3.8.3", | ||
"ts-node": "^10.1.0", | ||
"typescript": "^4.3.5", | ||
"validator": "^10.11.0" | ||
@@ -62,3 +62,3 @@ }, | ||
"prettier": "office-addin-prettier-config", | ||
"gitHead": "5da0ff995ed59746d6a61f1db670bab5a0d22cc2" | ||
"gitHead": "3a515b6898ad78ac44bae555a5d5c21283d7f347" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
73640
1170
Updatedoffice-addin-cli@^1.2.2