@@ -95,7 +95,7 @@ async function updatePackageJsonForSingleHost(host) {
9595 }
9696 } ) ;
9797
98- // Write updated json to file
98+ // Write updated JSON to file
9999 await writeFileAsync ( packageJson , JSON . stringify ( content , null , 2 ) ) ;
100100}
101101
@@ -137,19 +137,14 @@ async function deleteSupportFiles() {
137137 await unlinkFileAsync ( "package-lock.json" ) ;
138138}
139139
140- async function deleteUnifiedManifestRelatedFiles ( ) {
140+ async function deleteJSONManifestRelatedFiles ( ) {
141141 await unlinkFileAsync ( "manifest.json" ) ;
142- await unlinkFileAsync ( "unified-manifest-webpack.config.js" ) ;
143142 await unlinkFileAsync ( "assets/color.png" ) ;
144143 await unlinkFileAsync ( "assets/outline.png" ) ;
145- await unlinkFileAsync ( ".vscode/unified-manifest-launch.json" ) ;
146- await unlinkFileAsync ( ".vscode/unified-manifest-tasks.json" ) ;
147144}
148145
149146async function deleteXMLManifestRelatedFiles ( ) {
150147 await unlinkFileAsync ( "webpack.config.js" ) ;
151- await unlinkFileAsync ( ".vscode/launch.json" ) ;
152- await unlinkFileAsync ( ".vscode/tasks.json" ) ;
153148 await unlinkFileAsync ( "manifest.xml" ) ;
154149}
155150
@@ -158,15 +153,15 @@ async function updatePackageJsonForXMLManifest() {
158153 const data = await readFileAsync ( packageJson , "utf8" ) ;
159154 let content = JSON . parse ( data ) ;
160155
161- // Remove scripts that are only used with unified manifest
156+ // Remove scripts that are only used with JSON manifest
162157 delete content . scripts [ "signin" ] ;
163158 delete content . scripts [ "signout" ] ;
164159
165- // Write updated json to file
160+ // Write updated JSON to file
166161 await writeFileAsync ( packageJson , JSON . stringify ( content , null , 2 ) ) ;
167162}
168163
169- async function updatePackageJsonForUnifiedManifest ( ) {
164+ async function updatePackageJsonForJSONManifest ( ) {
170165 const packageJson = `./package.json` ;
171166 const data = await readFileAsync ( packageJson , "utf8" ) ;
172167 let content = JSON . parse ( data ) ;
@@ -183,26 +178,59 @@ async function updatePackageJsonForUnifiedManifest() {
183178 content . scripts . stop = "office-addin-debugging stop manifest.json" ;
184179 content . scripts . validate = "office-addin-manifest validate manifest.json" ;
185180
186- // Write updated json to file
181+ // Write updated JSON to file
187182 await writeFileAsync ( packageJson , JSON . stringify ( content , null , 2 ) ) ;
188183}
189184
190- async function renameManifestTypeSpecificFiles ( ) {
191- const webpackConfigContent = await readFileAsync ( `./unified-manifest-webpack.config.js` , "utf8" ) ;
192- await writeFileAsync ( `./webpack.config.js` , webpackConfigContent ) ;
193- await unlinkFileAsync ( "unified-manifest-webpack.config.js" ) ;
194- const launchJsonContent = await readFileAsync ( `./.vscode/unified-manifest-launch.json` , "utf8" ) ;
195- await writeFileAsync ( `./.vscode/launch.json` , launchJsonContent ) ;
196- await unlinkFileAsync ( ".vscode/unified-manifest-launch.json" ) ;
197- const tasksJsonContent = await readFileAsync ( `./.vscode/unified-manifest-tasks.json` , "utf8" ) ;
198- await writeFileAsync ( `./.vscode/tasks.json` , tasksJsonContent ) ;
199- await unlinkFileAsync ( ".vscode/unified-manifest-tasks.json" ) ;
185+ async function updateTasksJsonFileForJSONManifest ( ) {
186+ const tasksJson = `.vscode/tasks.json` ;
187+ const data = await readFileAsync ( tasksJson , "utf8" ) ;
188+ let content = JSON . parse ( data ) ;
189+
190+ content . tasks . forEach ( function ( task ) {
191+ if ( task . label . startsWith ( "Build" ) ) {
192+ task . dependsOn = [ "Install" ] ;
193+ } ;
194+ if ( task . label === "Debug: Outlook Desktop" ) {
195+ task . script = "start" ;
196+ task . dependsOn = [ "Check OS" , "Install" ] ;
197+ }
198+ } ) ;
199+
200+ const checkOSTask = {
201+ label : "Check OS" ,
202+ type : "shell" ,
203+ windows : {
204+ command : "echo 'Sideloading in Outlook on Windows is supported'"
205+ } ,
206+ linux : {
207+ command : "echo 'Sideloading on Linux is not supported' && exit 1"
208+ } ,
209+ osx : {
210+ command : "echo 'Sideloading in Outlook on Mac is not supported' && exit 1"
211+ } ,
212+ presentation : {
213+ clear : true ,
214+ panel : "dedicated"
215+ }
216+ } ;
217+
218+ content . tasks . push ( checkOSTask ) ;
219+ await writeFileAsync ( tasksJson , JSON . stringify ( content , null , 2 ) ) ;
220+ }
221+
222+ async function updateWebpackConfigForJSONManifest ( ) {
223+ const webPack = `webpack.config.js` ;
224+ const webPackContent = await readFileAsync ( webPack , "utf8" ) ;
225+ const updatedContent = webPackContent . replace ( ".xml" , ".json" ) ;
226+ await writeFileAsync ( webPack , updatedContent ) ;
200227}
201228
202- async function modifyProjectForUnifiedManifest ( ) {
203- await updatePackageJsonForUnifiedManifest ( ) ;
229+ async function modifyProjectForJSONManifest ( ) {
230+ await updatePackageJsonForJSONManifest ( ) ;
231+ await updateWebpackConfigForJSONManifest ( ) ;
232+ await updateTasksJsonFileForJSONManifest ( ) ;
204233 await deleteXMLManifestRelatedFiles ( ) ;
205- await renameManifestTypeSpecificFiles ( ) ;
206234}
207235
208236/**
@@ -214,12 +242,12 @@ modifyProjectForSingleHost(host).catch((err) => {
214242 process . exitCode = 1 ;
215243} ) ;
216244
217- if ( ( host !== "outlook" ) || ( manifestType !== "unified " ) ) {
218- // Remove things that are only relevant to unified manifest
219- deleteUnifiedManifestRelatedFiles ( ) ;
245+ if ( ( host !== "outlook" ) || ( manifestType !== "json " ) ) {
246+ // Remove things that are only relevant to JSON manifest
247+ deleteJSONManifestRelatedFiles ( ) ;
220248 updatePackageJsonForXMLManifest ( ) ;
221249} else {
222- modifyProjectForUnifiedManifest ( ) . catch ( ( err ) => {
250+ modifyProjectForJSONManifest ( ) . catch ( ( err ) => {
223251 console . error ( `Error: ${ err instanceof Error ? err . message : err } ` ) ;
224252 process . exitCode = 1 ;
225253 } ) ;
0 commit comments