11/* global require, process, console */
22
3- const fs = require ( "fs" ) ;
3+ import fs from "fs" ;
44const host = process . argv [ 2 ] ;
55const manifestType = process . argv [ 3 ] ;
6+ const projectName = process . argv [ 4 ] ;
7+ const appId = process . argv [ 5 ] ;
68const hosts = [ "excel" , "onenote" , "outlook" , "powerpoint" , "project" , "word" ] ;
7- const path = require ( "path" ) ;
8- const util = require ( "util" ) ;
9+ import path from "path" ;
10+ import util from "util" ;
11+ import { OfficeAddinManifest } from "office-addin-manifest" ;
912const testPackages = [
1013 "@types/mocha" ,
1114 "@types/node" ,
@@ -132,7 +135,7 @@ async function deleteSupportFiles() {
132135 await unlinkFileAsync ( "LICENSE" ) ;
133136 await unlinkFileAsync ( "README.md" ) ;
134137 await unlinkFileAsync ( "SECURITY.md" ) ;
135- await unlinkFileAsync ( "./convertToSingleHost.js " ) ;
138+ await unlinkFileAsync ( "./convertToSingleHost.mjs " ) ;
136139 await unlinkFileAsync ( ".npmrc" ) ;
137140 await unlinkFileAsync ( "package-lock.json" ) ;
138141}
@@ -238,18 +241,23 @@ async function modifyProjectForJSONManifest() {
238241 * @param host The host to support.
239242 */
240243modifyProjectForSingleHost ( host ) . catch ( ( err ) => {
241- console . error ( `Error: ${ err instanceof Error ? err . message : err } ` ) ;
244+ console . error ( `Error modifying for single host : ${ err instanceof Error ? err . message : err } ` ) ;
242245 process . exitCode = 1 ;
243246} ) ;
244247
248+ let manifestPath = "manifest.xml" ;
249+
245250if ( ( host !== "outlook" ) || ( manifestType !== "json" ) ) {
246251 // Remove things that are only relevant to JSON manifest
247252 deleteJSONManifestRelatedFiles ( ) ;
248253 updatePackageJsonForXMLManifest ( ) ;
249254} else {
255+ manifestPath = "manifest.json" ;
250256 modifyProjectForJSONManifest ( ) . catch ( ( err ) => {
251- console . error ( `Error: ${ err instanceof Error ? err . message : err } ` ) ;
257+ console . error ( `Error modifying for JSON manifest : ${ err instanceof Error ? err . message : err } ` ) ;
252258 process . exitCode = 1 ;
253259 } ) ;
254- }
260+ } ;
261+
262+ OfficeAddinManifest . modifyManifestFile ( manifestPath , projectName , appId ) ;
255263
0 commit comments