33const fs = require ( "fs" ) ;
44const path = require ( "path" ) ;
55const util = require ( "util" ) ;
6- const manifest = require ( "office-addin-manifest " ) ;
6+ const childProcess = require ( "child_process " ) ;
77
88const host = process . argv [ 2 ] ;
99const manifestType = process . argv [ 3 ] ;
@@ -68,7 +68,7 @@ async function updatePackageJsonForSingleHost(host) {
6868 const packageJson = `./package.json` ;
6969 const data = await readFileAsync ( packageJson , "utf8" ) ;
7070 let content = JSON . parse ( data ) ;
71-
71+
7272 // Update 'config' section in package.json to use selected host
7373 content . config [ "app_to_debug" ] = host ;
7474
@@ -77,10 +77,7 @@ async function updatePackageJsonForSingleHost(host) {
7777
7878 // Remove scripts that are unrelated to the selected host
7979 Object . keys ( content . scripts ) . forEach ( function ( key ) {
80- if (
81- key === "convert-to-single-host" ||
82- key === "start:desktop:outlook"
83- ) {
80+ if ( key === "convert-to-single-host" || key === "start:desktop:outlook" ) {
8481 delete content . scripts [ key ] ;
8582 }
8683 } ) ;
@@ -98,7 +95,7 @@ async function updatePackageJsonForSingleHost(host) {
9895 delete content . devDependencies [ key ] ;
9996 }
10097 } ) ;
101-
98+
10299 // Write updated JSON to file
103100 await writeFileAsync ( packageJson , JSON . stringify ( content , null , 2 ) ) ;
104101}
@@ -159,7 +156,7 @@ async function updatePackageJsonForXMLManifest() {
159156 // Remove scripts that are only used with JSON manifest
160157 delete content . scripts [ "signin" ] ;
161158 delete content . scripts [ "signout" ] ;
162-
159+
163160 // Write updated JSON to file
164161 await writeFileAsync ( packageJson , JSON . stringify ( content , null , 2 ) ) ;
165162}
@@ -176,11 +173,11 @@ async function updatePackageJsonForJSONManifest() {
176173 }
177174 } ) ;
178175
179- // Change manifest file name extension
176+ // Change manifest file name extension
180177 content . scripts . start = "office-addin-debugging start manifest.json" ;
181178 content . scripts . stop = "office-addin-debugging stop manifest.json" ;
182179 content . scripts . validate = "office-addin-manifest validate manifest.json" ;
183-
180+
184181 // Write updated JSON to file
185182 await writeFileAsync ( packageJson , JSON . stringify ( content , null , 2 ) ) ;
186183}
@@ -192,30 +189,30 @@ async function updateTasksJsonFileForJSONManifest() {
192189
193190 content . tasks . forEach ( function ( task ) {
194191 if ( task . label . startsWith ( "Build" ) ) {
195- task . dependsOn = [ "Install" ] ;
196- } ;
192+ task . dependsOn = [ "Install" ] ;
193+ }
197194 if ( task . label === "Debug: Outlook Desktop" ) {
198195 task . script = "start" ;
199- task . dependsOn = [ "Check OS" , "Install" ] ;
196+ task . dependsOn = [ "Check OS" , "Install" ] ;
200197 }
201198 } ) ;
202-
203- const checkOSTask = {
199+
200+ const checkOSTask = {
204201 label : "Check OS" ,
205202 type : "shell" ,
206203 windows : {
207- command : "echo 'Sideloading in Outlook on Windows is supported'"
204+ command : "echo 'Sideloading in Outlook on Windows is supported'" ,
208205 } ,
209206 linux : {
210- command : "echo 'Sideloading on Linux is not supported' && exit 1"
207+ command : "echo 'Sideloading on Linux is not supported' && exit 1" ,
211208 } ,
212209 osx : {
213- command : "echo 'Sideloading in Outlook on Mac is not supported' && exit 1"
210+ command : "echo 'Sideloading in Outlook on Mac is not supported' && exit 1" ,
214211 } ,
215212 presentation : {
216213 clear : true ,
217- panel : "dedicated"
218- }
214+ panel : "dedicated" ,
215+ } ,
219216 } ;
220217
221218 content . tasks . push ( checkOSTask ) ;
@@ -247,7 +244,7 @@ modifyProjectForSingleHost(host).catch((err) => {
247244
248245let manifestPath = "manifest.xml" ;
249246
250- if ( ( host !== "outlook" ) || ( manifestType !== "json" ) ) {
247+ if ( host !== "outlook" || manifestType !== "json" ) {
251248 // Remove things that are only relevant to JSON manifest
252249 deleteJSONManifestRelatedFiles ( ) ;
253250 updatePackageJsonForXMLManifest ( ) ;
@@ -257,12 +254,20 @@ if ((host !== "outlook") || (manifestType !== "json")) {
257254 console . error ( `Error modifying for JSON manifest: ${ err instanceof Error ? err . message : err } ` ) ;
258255 process . exitCode = 1 ;
259256 } ) ;
260- } ;
257+ }
261258
262259if ( projectName ) {
263260 if ( ! appId ) {
264261 appId = "random" ;
265262 }
266- manifest . OfficeAddinManifest . modifyManifestFile ( manifestPath , appId , projectName ) ;
263+
264+ // Modify the manifest to include the name and id of the project
265+ const cmdLine = `npx office-addin-manifest modify ${ manifestPath } -g ${ appId } -d ${ projectName } ` ;
266+ childProcess . exec ( cmdLine , ( error , stdout ) => {
267+ if ( error ) {
268+ Promise . reject ( stdout ) ;
269+ } else {
270+ Promise . resolve ( ) ;
271+ }
272+ } ) ;
267273}
268-
0 commit comments