Skip to content

Commit 497c00c

Browse files
fix: upgrade graph toolkit one productivity hub sample to use vite to eliminate security warning (#1625)
* fix: upgrade graph toolkit one productivity hub sample to use vite to eliminate security warning * docs: update readme
1 parent 062831b commit 497c00c

File tree

6 files changed

+55
-14
lines changed

6 files changed

+55
-14
lines changed

graph-toolkit-one-productivity-hub/.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"background": {
7676
"activeOnStart": true,
7777
"beginsPattern": ".*",
78-
"endsPattern": "Compiled|Failed|compiled|failed"
78+
"endsPattern": "Compiled|Failed|compiled|failed|ready in|Local:"
7979
}
8080
}
8181
}

graph-toolkit-one-productivity-hub/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ One Productivity Hub sample shows you how to build a tab for viewing your calend
2626

2727
## Prerequisite to use this sample
2828

29-
- [Node.js](https://nodejs.org/) version 16, 18
29+
- [Node.js](https://nodejs.org/) version 20, 22
3030
- A Microsoft 365 tenant in which you have permission to upload Teams apps. You can get a free Microsoft 365 developer tenant by joining the [Microsoft 365 developer program](https://developer.microsoft.com/en-us/microsoft-365/dev-program).
3131
- [Microsoft 365 Agents Toolkit Visual Studio Code Extension](https://aka.ms/teams-toolkit) version 5.0.0 and higher or [Microsoft 365 Agents Toolkit CLI](https://aka.ms/teams-toolkit-cli)
3232

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
<!doctype html>
12
<html lang="en">
23
<head>
3-
<meta charset="utf-8" />
4+
<meta charset="UTF-8" />
45
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
5-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<link rel="icon" href="/favicon.ico" />
67
<link
78
rel="stylesheet"
89
href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/11.0.0/css/fabric.min.css"
910
/>
1011
<title>Microsoft Teams Tab</title>
1112
</head>
12-
1313
<body>
1414
<noscript>You need to enable JavaScript to run this app.</noscript>
1515
<div id="root"></div>
16+
<script type="module" src="/src/index.jsx"></script>
1617
</body>
1718
</html>

graph-toolkit-one-productivity-hub/package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "one-productivity-hub",
33
"version": "0.1.0",
44
"engines": {
5-
"node": "16 || 18"
5+
"node": "20 || 22"
66
},
77
"private": true,
88
"dependencies": {
@@ -18,17 +18,18 @@
1818
"react": "^18.2.0",
1919
"react-csv": "^2.2.2",
2020
"react-dom": "^18.2.0",
21-
"react-router-dom": "^6.8.0",
22-
"react-scripts": "^5.0.1"
21+
"react-router-dom": "^6.8.0"
2322
},
2423
"devDependencies": {
25-
"env-cmd": "^10.1.0"
24+
"@vitejs/plugin-react": "^4.7.0",
25+
"env-cmd": "^10.1.0",
26+
"vite": "^6.3.6"
2627
},
2728
"scripts": {
2829
"dev:teamsfx": "env-cmd --silent -f .localConfigs npm run start",
29-
"start": "react-scripts start",
30-
"build": "react-scripts build",
31-
"eject": "react-scripts eject",
30+
"start": "vite",
31+
"build": "vite build",
32+
"preview": "vite preview",
3233
"test": "echo \"Error: no test specified\" && exit 1"
3334
},
3435
"eslintConfig": {
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
const env = import.meta.env;
2+
13
const config = {
2-
initiateLoginEndpoint: process.env.REACT_APP_START_LOGIN_PAGE_URL,
3-
clientId: process.env.REACT_APP_CLIENT_ID,
4+
initiateLoginEndpoint:
5+
env.REACT_APP_START_LOGIN_PAGE_URL || env.VITE_START_LOGIN_PAGE_URL,
6+
clientId: env.REACT_APP_CLIENT_ID || env.VITE_CLIENT_ID,
47
};
58

69
export default config;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import fs from "node:fs";
2+
import { defineConfig, loadEnv } from "vite";
3+
import react from "@vitejs/plugin-react";
4+
5+
export default defineConfig(({ mode }) => {
6+
const env = loadEnv(mode, process.cwd(), "");
7+
const useHttps = env.HTTPS === "true";
8+
const certFile = env.SSL_CRT_FILE;
9+
const keyFile = env.SSL_KEY_FILE;
10+
11+
let https = false;
12+
if (useHttps) {
13+
if (certFile && keyFile && fs.existsSync(certFile) && fs.existsSync(keyFile)) {
14+
https = {
15+
cert: fs.readFileSync(certFile),
16+
key: fs.readFileSync(keyFile),
17+
};
18+
} else {
19+
https = true;
20+
}
21+
}
22+
23+
return {
24+
plugins: [react()],
25+
envPrefix: ["VITE_", "REACT_APP_"],
26+
server: {
27+
host: env.HOST || "localhost",
28+
port: Number(env.PORT || 53000),
29+
strictPort: true,
30+
https,
31+
},
32+
build: {
33+
outDir: "build",
34+
},
35+
};
36+
});

0 commit comments

Comments
 (0)