diff --git a/src/app/config/projectProperties.json b/src/app/config/projectProperties.json index 1ba7a5d0..f43b1408 100644 --- a/src/app/config/projectProperties.json +++ b/src/app/config/projectProperties.json @@ -23,17 +23,17 @@ "Project", "Word"] }, - "angular": { - "displayname": "Office Add-in Task Pane project using Angular framework", + "react": { + "displayname": "Office Add-in Task Pane project using React framework", "manifestPath": "manifest.xml", "templates": { "javascript": { - "repository": "https://github.com/OfficeDev/Office-Addin-TaskPane-Angular-JS", + "repository": "https://github.com/OfficeDev/Office-Addin-TaskPane-React-JS", "branch": "yo-office", "prerelease": "yo-office-prerelease" }, "typescript": { - "repository": "https://github.com/OfficeDev/Office-Addin-TaskPane-Angular", + "repository": "https://github.com/OfficeDev/Office-Addin-TaskPane-React", "branch": "yo-office", "prerelease": "yo-office-prerelease" } @@ -47,17 +47,17 @@ "Word" ] }, - "react": { - "displayname": "Office Add-in Task Pane project using React framework", + "angular": { + "displayname": "Office Add-in Task Pane project using Angular framework", "manifestPath": "manifest.xml", "templates": { "javascript": { - "repository": "https://github.com/OfficeDev/Office-Addin-TaskPane-React-JS", + "repository": "https://github.com/OfficeDev/Office-Addin-TaskPane-Angular-JS", "branch": "yo-office", "prerelease": "yo-office-prerelease" }, "typescript": { - "repository": "https://github.com/OfficeDev/Office-Addin-TaskPane-React", + "repository": "https://github.com/OfficeDev/Office-Addin-TaskPane-Angular", "branch": "yo-office", "prerelease": "yo-office-prerelease" } @@ -71,25 +71,27 @@ "Word" ] }, - "manifest": { - "displayname": "Office Add-in project containing the manifest only", + "excel-functions-shared": { + "displayname": "Excel Custom Functions using a Shared Runtime", "manifestPath": "manifest.xml", "templates": { - "manifestonly": { - "repository": "" + "javascript": { + "repository": "https://github.com/OfficeDev/Excel-Custom-Functions-JS", + "branch": "shared-runtime-yo-office", + "prerelease": "shared-runtime-yo-office-prerelease" + }, + "typescript": { + "repository": "https://github.com/OfficeDev/Excel-Custom-Functions", + "branch": "shared-runtime-yo-office", + "prerelease": "shared-runtime-yo-office-prerelease" } }, "supportedHosts": [ - "Excel", - "Onenote", - "Outlook", - "Powerpoint", - "Project", - "Word" + "Excel" ] }, "excel-functions": { - "displayname": "Excel Custom Functions Add-in project", + "displayname": "Excel Custom Functions using a JavaScript-only Runtime", "manifestPath": "manifest.xml", "templates": { "javascript": { @@ -120,6 +122,23 @@ "supportedHosts": [ "Outlook" ] + }, + "manifest": { + "displayname": "Office Add-in project containing the manifest only", + "manifestPath": "manifest.xml", + "templates": { + "manifestonly": { + "repository": "" + } + }, + "supportedHosts": [ + "Excel", + "Onenote", + "Outlook", + "Powerpoint", + "Project", + "Word" + ] } }, "hostTypes": { diff --git a/src/app/index.ts b/src/app/index.ts index 32d2b2a1..283590d5 100755 --- a/src/app/index.ts +++ b/src/app/index.ts @@ -29,6 +29,7 @@ let language; const manifest = 'manifest'; const sso = 'single-sign-on'; const typescript = `TypeScript`; +let jsonData; let usageDataObject: usageData.OfficeAddinUsageData; const usageDataOptions: usageData.IUsageDataOptions = { @@ -138,7 +139,7 @@ module.exports = class extends yo { usageDataOptions.usageDataLevel = usageData.readUsageDataLevel(usageDataOptions.groupName); } - const jsonData = new projectsJsonData(this.templatePath()); + jsonData = new projectsJsonData(this.templatePath()); let isManifestProject = false; let isExcelFunctionsProject = false; @@ -286,14 +287,26 @@ module.exports = class extends yo { _configureProject(answerForProjectType, answerForScriptType, answerForHost, answerForName, isManifestProject, isExcelFunctionsProject): void { try { + const projType = _.toLower(this.options.projectType) || _.toLower(answerForProjectType.projectType) + this.project = { folder: this.options.output || answerForName.name || this.options.name, + host: answerForHost.host + ? answerForHost.host + : this.options.host + ? this.options.host + : jsonData?.getHostTemplateNames(projType)[0], name: this.options.name || answerForName.name, - host: this.options.host || answerForHost.host, - projectType: _.toLower(this.options.projectType) || _.toLower(answerForProjectType.projectType), + projectType: projType, + scriptType: answerForScriptType.scriptType + ? answerForScriptType.scriptType + : this.options.ts + ? typescript + : this.options.js + ? javascript + : jsonData?.getSupportedScriptTypes(projType)[0], isManifestOnly: isManifestProject, isExcelFunctionsProject: isExcelFunctionsProject, - scriptType: answerForScriptType.scriptType ? answerForScriptType.scriptType : this.options.ts ? typescript : javascript }; /* Set folder if to output param if specified */ @@ -307,13 +320,8 @@ module.exports = class extends yo { this.project.projectInternalName = _.kebabCase(this.project.name); this.project.projectDisplayName = this.project.name; this.project.projectId = uuidv4(); - if (this.project.projectType === excelCustomFunctions) { - this.project.host = 'Excel'; - this.project.hostInternalName = 'Excel'; - } - else { - this.project.hostInternalName = this.project.host; - } + this.project.hostInternalName = this.project.host; + this.destinationRoot(this.project.folder); process.chdir(this._destinationRoot); this.env.cwd = this._destinationRoot; @@ -425,10 +433,12 @@ module.exports = class extends yo { this.log(`NOTE: ${chalk.bgGreen('Arguments')} must be specified in the order below, and ${chalk.bgMagenta('Options')} must follow ${chalk.bgGreen('Arguments')}.\n`); this.log(` ${chalk.bgGreen('projectType')}:Specifies the type of project to create. Valid project types include:`); this.log(` ${chalk.yellow('angular:')} Creates an Office add-in using Angular framework.`); - this.log(` ${chalk.yellow('excel-functions:')} Creates an Office add-in for Excel custom functions. Must specify 'Excel' as host parameter.`); + this.log(` ${chalk.yellow('excel-functions-shared:')} Creates an Office add-in for Excel custom functions using a Shared Runtime.`); + this.log(` ${chalk.yellow('excel-functions:')} Creates an Office add-in for Excel custom functions using a JavaScript-only Runtime.`); this.log(` ${chalk.yellow('jquery:')} Creates an Office add-in using Jquery framework.`); this.log(` ${chalk.yellow('manifest:')} Creates an only the manifest file for an Office add-in.`); this.log(` ${chalk.yellow('react:')} Creates an Office add-in using React framework.\n`); + this.log(` ${chalk.yellow('teams-manifest:')} Creates Outlook Add-in with Teams Manifest (Developer preview).\n`); this.log(` ${chalk.bgGreen('name')}:Specifies the name for the project that will be created.\n`); this.log(` ${chalk.bgGreen('host')}:Specifies the host app in the add-in manifest.`); this.log(` ${chalk.yellow('excel:')} Creates an Office add-in for Excel. Valid hosts include:`); diff --git a/src/test/convert-to-single-host.ts b/src/test/convert-to-single-host.ts index 561cead6..07834cc8 100644 --- a/src/test/convert-to-single-host.ts +++ b/src/test/convert-to-single-host.ts @@ -207,93 +207,93 @@ describe('Office-Add-Taskpane-React-Ts project', () => { }); }); -// Test to verify converting a project to a single host -// for SSO Typescript project using Excel host -describe('Office-Add-Taskpane-SSO-TS project', () => { - const expectedFiles = [ - packageJsonFile, - manifestFile, - '.ENV', - 'src/taskpane/taskpane.ts', - 'src/taskpane/taskpane.html', - 'src/taskpane/taskpane.css', - 'src/helpers/fallbackauthdialog.html', - 'src/helpers/fallbackauthdialog.ts', - 'src/helpers/fallbackauthhelper.ts', - 'src/helpers/ssoauthhelper.ts' +// // Test to verify converting a project to a single host +// // for SSO Typescript project using Excel host +// describe('Office-Add-Taskpane-SSO-TS project', () => { +// const expectedFiles = [ +// packageJsonFile, +// manifestFile, +// '.ENV', +// 'src/taskpane/taskpane.ts', +// 'src/taskpane/taskpane.html', +// 'src/taskpane/taskpane.css', +// 'src/helpers/fallbackauthdialog.html', +// 'src/helpers/fallbackauthdialog.ts', +// 'src/helpers/fallbackauthhelper.ts', +// 'src/helpers/ssoauthhelper.ts' - ] - const unexpectedFiles = [ - 'src/taskpane/excel.ts', - 'src/taskpane/word.ts', - 'src/taskpane/powerpoint.ts', - 'manifest.excel.xml', - 'manifest.word.xml', - 'manifest.powerpoint.xml' - ] - const answers = { - projectType: "single-sign-on", - scriptType: "TypeScript", - name: "SSOTypeScriptProject", - host: hosts[0] - }; +// ] +// const unexpectedFiles = [ +// 'src/taskpane/excel.ts', +// 'src/taskpane/word.ts', +// 'src/taskpane/powerpoint.ts', +// 'manifest.excel.xml', +// 'manifest.word.xml', +// 'manifest.powerpoint.xml' +// ] +// const answers = { +// projectType: "single-sign-on", +// scriptType: "TypeScript", +// name: "SSOTypeScriptProject", +// host: hosts[0] +// }; - describe('Office-Add-Taskpane-SSO-TS project', () => { - before((done) => { - helpers.run(path.join(__dirname, '../app')).withOptions({ 'test': true }).withPrompts(answers).on('end', done); - }); +// describe('Office-Add-Taskpane-SSO-TS project', () => { +// before((done) => { +// helpers.run(path.join(__dirname, '../app')).withOptions({ 'test': true }).withPrompts(answers).on('end', done); +// }); - it('creates expected files', (done) => { - assert.file(expectedFiles); - assert.noFile(unexpectedFiles); - assert.noFile(unexpectedManifestFiles); - done(); - }); - }); -}); +// it('creates expected files', (done) => { +// assert.file(expectedFiles); +// assert.noFile(unexpectedFiles); +// assert.noFile(unexpectedManifestFiles); +// done(); +// }); +// }); +// }); -// Test to verify converting a project to a single host -// for SSO JavaScript project using PowerPoint host -describe('Office-Add-Taskpane-SSO-JS project', () => { - const expectedFiles = [ - packageJsonFile, - manifestFile, - '.ENV', - 'src/taskpane/taskpane.js', - 'src/taskpane/taskpane.html', - 'src/taskpane/taskpane.css', - 'src/helpers/documenthelper.js', - 'src/helpers/fallbackauthdialog.html', - 'src/helpers/fallbackauthdialog.js', - 'src/helpers/fallbackauthhelper.js', - 'src/helpers/ssoauthhelper.js' +// // Test to verify converting a project to a single host +// // for SSO JavaScript project using PowerPoint host +// describe('Office-Add-Taskpane-SSO-JS project', () => { +// const expectedFiles = [ +// packageJsonFile, +// manifestFile, +// '.ENV', +// 'src/taskpane/taskpane.js', +// 'src/taskpane/taskpane.html', +// 'src/taskpane/taskpane.css', +// 'src/helpers/documenthelper.js', +// 'src/helpers/fallbackauthdialog.html', +// 'src/helpers/fallbackauthdialog.js', +// 'src/helpers/fallbackauthhelper.js', +// 'src/helpers/ssoauthhelper.js' - ] - const unexpectedFiles = [ - 'src/taskpane/excel.js', - 'src/taskpane/word.js', - 'src/taskpane/powerpoint.js', - 'manifest.excel.xml', - 'manifest.word.xml', - 'manifest.powerpoint.xml' - ] - const answers = { - projectType: "single-sign-on", - scriptType: "JavaScript", - name: "SSOJavaScriptProject", - host: hosts[3] - }; +// ] +// const unexpectedFiles = [ +// 'src/taskpane/excel.js', +// 'src/taskpane/word.js', +// 'src/taskpane/powerpoint.js', +// 'manifest.excel.xml', +// 'manifest.word.xml', +// 'manifest.powerpoint.xml' +// ] +// const answers = { +// projectType: "single-sign-on", +// scriptType: "JavaScript", +// name: "SSOJavaScriptProject", +// host: hosts[3] +// }; - describe('Office-Add-Taskpane-SSO-JS project', () => { - before((done) => { - helpers.run(path.join(__dirname, '../app')).withOptions({ 'test': true }).withPrompts(answers).on('end', done); - }); +// describe('Office-Add-Taskpane-SSO-JS project', () => { +// before((done) => { +// helpers.run(path.join(__dirname, '../app')).withOptions({ 'test': true }).withPrompts(answers).on('end', done); +// }); - it('creates expected files', (done) => { - assert.file(expectedFiles); - assert.noFile(unexpectedFiles); - assert.noFile(unexpectedManifestFiles); - done(); - }); - }); -}); +// it('creates expected files', (done) => { +// assert.file(expectedFiles); +// assert.noFile(unexpectedFiles); +// assert.noFile(unexpectedManifestFiles); +// done(); +// }); +// }); +// });