Skip to content

Commit 9f3b19a

Browse files
committed
review changes
1 parent 87c9790 commit 9f3b19a

File tree

5 files changed

+68
-297
lines changed

5 files changed

+68
-297
lines changed

.vscode/tasks.json

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
2-
// See https://go.microsoft.com/fwlink/?LinkId=733558
3-
// for the documentation about the tasks.json format
42
"version": "2.0.0",
53
"tasks": [
64
{
@@ -34,37 +32,38 @@
3432
"script": "start:desktop -- --app excel",
3533
"presentation": {
3634
"clear": true,
37-
"panel": "dedicated",
35+
"panel": "dedicated"
3836
},
3937
"problemMatcher": []
4038
},
4139
{
42-
"label": "Debug: Outlook Desktop",
40+
"label": "Debug: PowerPoint Desktop",
4341
"type": "npm",
44-
"script": "start:desktop -- --app outlook",
42+
"script": "start:desktop -- --app powerpoint",
4543
"presentation": {
4644
"clear": true,
47-
"panel": "dedicated",
45+
"panel": "dedicated"
4846
},
4947
"problemMatcher": []
5048
},
5149
{
52-
"label": "Debug: PowerPoint Desktop",
50+
"label": "Debug: Word Desktop",
5351
"type": "npm",
54-
"script": "start:desktop -- --app powerpoint",
52+
"script": "start:desktop -- --app word",
5553
"presentation": {
5654
"clear": true,
57-
"panel": "dedicated",
55+
"panel": "dedicated"
5856
},
5957
"problemMatcher": []
6058
},
59+
6160
{
62-
"label": "Debug: Word Desktop",
61+
"label": "Debug: Outlook Desktop",
6362
"type": "npm",
64-
"script": "start:desktop -- --app word",
63+
"script": "start:desktop -- --app outlook",
6564
"presentation": {
6665
"clear": true,
67-
"panel": "dedicated",
66+
"panel": "dedicated"
6867
},
6968
"problemMatcher": []
7069
},
@@ -125,6 +124,6 @@
125124
"panel": "dedicated"
126125
},
127126
"problemMatcher": []
128-
},
127+
}
129128
]
130129
}

.vscode/unified-manifest-launch.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

.vscode/unified-manifest-tasks.json

Lines changed: 0 additions & 127 deletions
This file was deleted.

convertToSingleHost.js

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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

149146
async 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

Comments
 (0)