Skip to content

Commit 6b05fac

Browse files
committed
Merge branch 'master' into yo-office
2 parents 7cf4c6c + 4ebbd72 commit 6b05fac

File tree

11 files changed

+11059
-19893
lines changed

11 files changed

+11059
-19893
lines changed

.vscode/tasks.json

Lines changed: 2 additions & 4 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,7 +32,7 @@
3432
"script": "start:desktop -- --app excel",
3533
"presentation": {
3634
"clear": true,
37-
"panel": "dedicated",
35+
"panel": "dedicated"
3836
},
3937
"problemMatcher": []
4038
},
@@ -95,6 +93,6 @@
9593
"panel": "dedicated"
9694
},
9795
"problemMatcher": []
98-
},
96+
}
9997
]
10098
}

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@ Questions about Office Add-ins development in general should be posted to [Micro
1616

1717
## Join the Microsoft 365 Developer Program
1818

19-
Get a free sandbox, tools, and other resources you need to build solutions for the Microsoft 365 platform.
19+
Join the [Microsoft 365 Developer Program](https://aka.ms/m365devprogram) to get resources and information to help you build solutions for the Microsoft 365 platform, including recommendations tailored to your areas of interest.
2020

21-
- [Free developer sandbox](https://developer.microsoft.com/microsoft-365/dev-program#Subscription) Get a free, renewable 90-day Microsoft 365 E5 developer subscription.
22-
- [Sample data packs](https://developer.microsoft.com/microsoft-365/dev-program#Sample) Automatically configure your sandbox by installing user data and content to help you build your solutions.
23-
- [Access to experts](https://developer.microsoft.com/microsoft-365/dev-program#Experts) Access community events to learn from Microsoft 365 experts.
24-
- [Personalized recommendations](https://developer.microsoft.com/microsoft-365/dev-program#Recommendations) Find developer resources quickly from your personalized dashboard.
21+
You might also qualify for a free developer subscription that's renewable for 90 days and comes configured with sample data; for details, see the [FAQ](https://learn.microsoft.com/office/developer-program/microsoft-365-developer-program-faq#who-qualifies-for-a-microsoft-365-e5-developer-subscription-).
2522

2623
## Additional resources
2724

assets/color.png

1.04 KB
Loading

assets/outline.png

249 Bytes
Loading

convertToSingleHost.js

Lines changed: 138 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
const fs = require("fs");
44
const path = require("path");
55
const util = require("util");
6+
const childProcess = require("child_process");
7+
8+
const manifestType = process.argv[2];
9+
const projectName = process.argv[3];
10+
let appId = process.argv[4];
611
const testPackages = [
712
"@types/mocha",
813
"@types/node",
@@ -18,12 +23,13 @@ const unlinkFileAsync = util.promisify(fs.unlink);
1823
const writeFileAsync = util.promisify(fs.writeFile);
1924

2025
async function removeTestInfraStructure() {
26+
// Delete test folder
2127
deleteFolder(path.resolve(`./test`));
2228

23-
// delete the .github folder
29+
// Delete the .github folder
2430
deleteFolder(path.resolve(`./.github`));
2531

26-
// delete CI/CD pipeline files
32+
// Delete CI/CD pipeline files
2733
deleteFolder(path.resolve(`./.azure-devops`));
2834

2935
await updatePackageJsonFile();
@@ -45,19 +51,19 @@ async function updatePackageJsonFile() {
4551
}
4652
});
4753

48-
// remove test-related packages
54+
// Remove test-related packages
4955
Object.keys(content.devDependencies).forEach(function (key) {
5056
if (testPackages.includes(key)) {
5157
delete content.devDependencies[key];
5258
}
5359
});
5460

55-
// write updated json to file
61+
// Write updated JSON to file
5662
await writeFileAsync(packageJson, JSON.stringify(content, null, 2));
5763
}
5864

5965
async function updateLaunchJsonFile() {
60-
// remove 'Debug Tests' configuration from launch.json
66+
// Remove 'Debug Tests' configuration from launch.json
6167
const launchJson = `.vscode/launch.json`;
6268
const launchJsonContent = await readFileAsync(launchJson, "utf8");
6369
const regex = /(.+{\r?\n.*"name": "Debug (?:UI|Unit) Tests",\r?\n(?:.*\r?\n)*?.*},.*\r?\n)/gm;
@@ -93,10 +99,137 @@ async function deleteSupportFiles() {
9399
await unlinkFileAsync("package-lock.json");
94100
}
95101

102+
async function deleteJSONManifestRelatedFiles() {
103+
await unlinkFileAsync("manifest.json");
104+
await unlinkFileAsync("assets/color.png");
105+
await unlinkFileAsync("assets/outline.png");
106+
}
107+
108+
async function deleteXMLManifestRelatedFiles() {
109+
await unlinkFileAsync("manifest.xml");
110+
}
111+
112+
async function updatePackageJsonForXMLManifest() {
113+
const packageJson = `./package.json`;
114+
const data = await readFileAsync(packageJson, "utf8");
115+
let content = JSON.parse(data);
116+
117+
// Remove scripts that are only used with JSON manifest
118+
delete content.scripts["signin"];
119+
delete content.scripts["signout"];
120+
121+
// Write updated JSON to file
122+
await writeFileAsync(packageJson, JSON.stringify(content, null, 2));
123+
}
124+
125+
async function updatePackageJsonForJSONManifest() {
126+
const packageJson = `./package.json`;
127+
const data = await readFileAsync(packageJson, "utf8");
128+
let content = JSON.parse(data);
129+
130+
// Remove special start scripts
131+
Object.keys(content.scripts).forEach(function (key) {
132+
if (key.includes("start:")) {
133+
delete content.scripts[key];
134+
}
135+
});
136+
137+
// Change manifest file name extension
138+
content.scripts.start = "office-addin-debugging start manifest.json";
139+
content.scripts.stop = "office-addin-debugging stop manifest.json";
140+
content.scripts.validate = "office-addin-manifest validate manifest.json";
141+
142+
// Write updated JSON to file
143+
await writeFileAsync(packageJson, JSON.stringify(content, null, 2));
144+
}
145+
146+
async function updateTasksJsonFileForJSONManifest() {
147+
const tasksJson = `.vscode/tasks.json`;
148+
const data = await readFileAsync(tasksJson, "utf8");
149+
let content = JSON.parse(data);
150+
151+
content.tasks.forEach(function (task) {
152+
if (task.label.startsWith("Build")) {
153+
task.dependsOn = ["Install"];
154+
}
155+
if (task.label === "Debug: Outlook Desktop") {
156+
task.script = "start";
157+
task.dependsOn = ["Check OS", "Install"];
158+
}
159+
});
160+
161+
const checkOSTask = {
162+
label: "Check OS",
163+
type: "shell",
164+
windows: {
165+
command: "echo 'Sideloading in Outlook on Windows is supported'",
166+
},
167+
linux: {
168+
command: "echo 'Sideloading on Linux is not supported' && exit 1",
169+
},
170+
osx: {
171+
command: "echo 'Sideloading in Outlook on Mac is not supported' && exit 1",
172+
},
173+
presentation: {
174+
clear: true,
175+
panel: "dedicated",
176+
},
177+
};
178+
179+
content.tasks.push(checkOSTask);
180+
await writeFileAsync(tasksJson, JSON.stringify(content, null, 2));
181+
}
182+
183+
async function updateWebpackConfigForJSONManifest() {
184+
const webPack = `webpack.config.js`;
185+
const webPackContent = await readFileAsync(webPack, "utf8");
186+
const updatedContent = webPackContent.replace(".xml", ".json");
187+
await writeFileAsync(webPack, updatedContent);
188+
}
189+
190+
async function modifyProjectForJSONManifest() {
191+
await updatePackageJsonForJSONManifest();
192+
await updateWebpackConfigForJSONManifest();
193+
await updateTasksJsonFileForJSONManifest();
194+
await deleteXMLManifestRelatedFiles();
195+
}
196+
197+
96198
/**
97199
* Remove test infrastructure and repo support files from project.
98200
*/
99201
removeTestInfraStructure().catch((err) => {
100202
console.error(`Error: ${err instanceof Error ? err.message : err}`);
101203
process.exitCode = 1;
102204
});
205+
206+
let manifestPath = "manifest.xml";
207+
208+
// Uncomment when template supports JSON manifest
209+
// if (host !== "outlook" || manifestType !== "json") {
210+
// Remove things that are only relevant to JSON manifest
211+
deleteJSONManifestRelatedFiles();
212+
updatePackageJsonForXMLManifest();
213+
// } else {
214+
// manifestPath = "manifest.json";
215+
// modifyProjectForJSONManifest().catch((err) => {
216+
// console.error(`Error modifying for JSON manifest: ${err instanceof Error ? err.message : err}`);
217+
// process.exitCode = 1;
218+
// });
219+
// }
220+
221+
if (projectName) {
222+
if (!appId) {
223+
appId = "random";
224+
}
225+
226+
// Modify the manifest to include the name and id of the project
227+
const cmdLine = `npx office-addin-manifest modify ${manifestPath} -g ${appId} -d ${projectName}`;
228+
childProcess.exec(cmdLine, (error, stdout) => {
229+
if (error) {
230+
Promise.reject(stdout);
231+
} else {
232+
Promise.resolve();
233+
}
234+
});
235+
}

manifest.json

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/OfficeDev/microsoft-teams-app-schema/preview/DevPreview/MicrosoftTeams.schema.json",
3+
"id": "f2b103f1-1ab1-4e1b-8f0b-072aa3d4e19d",
4+
"manifestVersion": "devPreview",
5+
"version": "1.0.0",
6+
"name": {
7+
"short": "Contoso Task Pane Add-in",
8+
"full": "Contoso Task Pane Add-in"
9+
},
10+
"description": {
11+
"short": "A template to get started.",
12+
"full": "This is the template to get started."
13+
},
14+
"developer": {
15+
"name": "Contoso",
16+
"websiteUrl": "https://www.contoso.com",
17+
"privacyUrl": "https://www.contoso.com/privacy",
18+
"termsOfUseUrl": "https://www.contoso.com/servicesagreement"
19+
},
20+
"icons": {
21+
"outline": "assets/outline.png",
22+
"color": "assets/color.png"
23+
},
24+
"accentColor": "#230201",
25+
"localizationInfo": {
26+
"defaultLanguageTag": "en-us",
27+
"additionalLanguages": []
28+
},
29+
"authorization": {
30+
"permissions": {
31+
"resourceSpecific": [
32+
{
33+
"name": "MailboxItem.Read.User",
34+
"type": "Delegated"
35+
}
36+
]
37+
}
38+
},
39+
"validDomains": ["contoso.com"],
40+
"extensions": [
41+
{
42+
"requirements": {
43+
"scopes": ["mail"],
44+
"capabilities": [
45+
{ "name": "Mailbox", "minVersion": "1.3" }
46+
]
47+
},
48+
"runtimes": [
49+
{
50+
"requirements": {
51+
"capabilities": [
52+
{ "name": "Mailbox", "minVersion": "1.3" }
53+
]
54+
},
55+
"id": "TaskPaneRuntime",
56+
"type": "general",
57+
"code": {
58+
"page": "https://localhost:3000/taskpane.html"
59+
},
60+
"lifetime": "short",
61+
"actions": [
62+
{
63+
"id": "TaskPaneRuntimeShow",
64+
"type":"openPage",
65+
"pinnable": false,
66+
"view": "dashboard"
67+
}
68+
]
69+
},
70+
{
71+
"id": "CommandsRuntime",
72+
"type": "general",
73+
"code": {
74+
"page": "https://localhost:3000/commands.html",
75+
"script": "https://localhost:3000/commands.js"
76+
},
77+
"lifetime": "short",
78+
"actions": [
79+
{
80+
"id": "action",
81+
"type": "executeFunction",
82+
"displayName": "action"
83+
}
84+
]
85+
}
86+
],
87+
"ribbons": [
88+
{
89+
"contexts": [
90+
"mailRead"
91+
],
92+
"tabs": [
93+
{
94+
"builtInTabId": "TabDefault",
95+
"groups": [
96+
{
97+
"id": "msgReadGroup",
98+
"label": "Contoso Add-in",
99+
"icons": [
100+
{ "size": 16, "file": "https://localhost:3000/assets/icon-16.png" },
101+
{ "size": 32, "file": "https://localhost:3000/assets/icon-32.png" },
102+
{ "size": 80, "file": "https://localhost:3000/assets/icon-80.png" }
103+
],
104+
"controls": [
105+
{
106+
"id": "msgReadOpenPaneButton",
107+
"type": "button",
108+
"label": "Show Taskpane",
109+
"icons": [
110+
{ "size": 16, "file": "https://localhost:3000/assets/icon-16.png" },
111+
{ "size": 32, "file": "https://localhost:3000/assets/icon-32.png" },
112+
{ "size": 80, "file": "https://localhost:3000/assets/icon-80.png" }
113+
],
114+
"supertip": {
115+
"title": "Show Taskpane",
116+
"description": "Opens a pane displaying all available properties."
117+
},
118+
"actionId": "TaskPaneRuntimeShow"
119+
},
120+
{
121+
"id": "ActionButton",
122+
"type": "button",
123+
"label": "Perform an action",
124+
"icons": [
125+
{ "size": 16, "file": "https://localhost:3000/assets/icon-16.png" },
126+
{ "size": 32, "file": "https://localhost:3000/assets/icon-32.png" },
127+
{ "size": 80, "file": "https://localhost:3000/assets/icon-80.png" }
128+
],
129+
"supertip": {
130+
"title": "Perform an action",
131+
"description": "Perform an action when clicked."
132+
},
133+
"actionId": "action"
134+
}
135+
]
136+
}
137+
]
138+
}
139+
]
140+
}
141+
]
142+
}
143+
]
144+
}
145+

0 commit comments

Comments
 (0)