From d5a97c2cbcec2cad1d2bf83b3d98fe624fcae1ef Mon Sep 17 00:00:00 2001 From: Courtney Owen Date: Wed, 22 Jan 2020 12:06:04 -0800 Subject: [PATCH] Add Outlook host for Single-Sign-On - Make supported hosts data-driven by projectProperties.json --- src/app/config/projectProperties.json | 70 ++++++++++++++++++++------- src/app/config/projectsJsonData.ts | 12 ++--- src/app/index.ts | 6 +-- 3 files changed, 59 insertions(+), 29 deletions(-) diff --git a/src/app/config/projectProperties.json b/src/app/config/projectProperties.json index 13682e78..1db3684a 100644 --- a/src/app/config/projectProperties.json +++ b/src/app/config/projectProperties.json @@ -13,7 +13,14 @@ "branch": "yo-office", "prerelease": "yo-office-prerelease" } - } + }, + "supportedHosts": [ + "Excel", + "Onenote", + "Outlook", + "Powerpoint", + "Project", + "Word"] }, "angular": { "displayname": "Office Add-in Task Pane project using Angular framework", @@ -28,7 +35,15 @@ "branch": "yo-office", "prerelease": "yo-office-prerelease" } - } + }, + "supportedHosts": [ + "Excel", + "Onenote", + "Outlook", + "Powerpoint", + "Project", + "Word" + ] }, "react": { "displayname": "Office Add-in Task Pane project using React framework", @@ -43,7 +58,15 @@ "branch": "yo-office", "prerelease": "yo-office-prerelease" } - } + }, + "supportedHosts": [ + "Excel", + "Onenote", + "Outlook", + "Powerpoint", + "Project", + "Word" + ] }, "single-sign-on": { "displayname": "Office Add-in Task Pane project supporting single sign-on", @@ -58,7 +81,13 @@ "branch": "yo-office", "prerelease": "yo-office-prerelease" } - } + }, + "supportedHosts": [ + "Excel", + "Outlook", + "Powerpoint", + "Word" + ] }, "manifest": { "displayname": "Office Add-in project containing the manifest only", @@ -66,7 +95,15 @@ "manifestonly": { "repository": "" } - } + }, + "supportedHosts": [ + "Excel", + "Onenote", + "Outlook", + "Powerpoint", + "Project", + "Word" + ] }, "excel-functions": { "displayname": "Excel Custom Functions Add-in project", @@ -81,33 +118,30 @@ "branch": "yo-office", "prerelease": "yo-office-prerelease" } - } + }, + "supportedHosts": [ + "Excel" + ] } }, "hostTypes": { "excel": { - "displayname": "Excel", - "repository": "" + "displayname": "Excel" }, "onenote": { - "displayname": "OneNote", - "repository": "" + "displayname": "OneNote" }, "outlook": { - "displayname": "Outlook", - "repository": "" + "displayname": "Outlook" }, "powerpoint": { - "displayname": "PowerPoint", - "repository": "" + "displayname": "PowerPoint" }, "project": { - "displayname": "Project", - "repository": "" + "displayname": "Project" }, "word": { - "displayname": "Word", - "repository": "" + "displayname": "Word" } } } \ No newline at end of file diff --git a/src/app/config/projectsJsonData.ts b/src/app/config/projectsJsonData.ts index ab8e55cf..a83ca65e 100644 --- a/src/app/config/projectsJsonData.ts +++ b/src/app/config/projectsJsonData.ts @@ -49,15 +49,11 @@ export default class projectsJsonData { return this.m_projectJsonData.projectTypes[_.toLower(projectType)].templates.javascript != undefined && this.m_projectJsonData.projectTypes[_.toLower(projectType)].templates.typescript != undefined; } - getHostTemplateNames(isSsoProject: boolean) { + getHostTemplateNames(projectType: string) { let hosts: string[] = []; - for (let key in this.m_projectJsonData.hostTypes) { - if (isSsoProject) { - if (key === 'excel' || key === 'word' || key === 'powerpoint') { - hosts.push(this.m_projectJsonData.hostTypes[key].displayname); - } - } else { - hosts.push(this.m_projectJsonData.hostTypes[key].displayname); + for (let key in this.m_projectJsonData.projectTypes) { + if (key === projectType) { + hosts = this.m_projectJsonData.projectTypes[key].supportedHosts; } } return hosts; diff --git a/src/app/index.ts b/src/app/index.ts index 32dcdb8e..0638c4fa 100755 --- a/src/app/index.ts +++ b/src/app/index.ts @@ -41,8 +41,8 @@ module.exports = yo.extend({ /* Setup the generator */ constructor: function () { if (parseInt(process.version.slice(1, process.version.indexOf('.'))) % 2 == 1) { - console.log(yosay('generator-office does not support your version of Node. Please switch to the latest LTS version of Node.')); - this._exitProcess(); + console.log(yosay('generator-office does not support your version of Node. Please switch to the latest LTS version of Node.')); + this._exitProcess(); } yo.apply(this, arguments); @@ -206,7 +206,7 @@ module.exports = yo.extend({ message: 'Which Office client application would you like to support?', type: 'list', default: 'Excel', - choices: jsonData.getHostTemplateNames(isSsoProject).map(host => ({ name: host, value: host })), + choices: jsonData.getHostTemplateNames(answerForProjectType.projectType).map(host => ({ name: host, value: host })), when: (this.options.host == null || this.options.host != null && !jsonData.isValidInput(this.options.host, true /* isHostParam */)) && !isExcelFunctionsProject }];