Skip to content

Commit

Permalink
chore: upgrade to codegouv/react-dsfr (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
revolunet authored Feb 9, 2024
1 parent c830f70 commit 214bdcf
Show file tree
Hide file tree
Showing 114 changed files with 41,881 additions and 26,480 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "14"
node-version: "20"
- shell: bash
run: |
cd report
Expand Down
4 changes: 2 additions & 2 deletions report/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ runs:
steps:
- uses: actions/setup-node@v3
with:
node-version: "14"
node-version: "20"
- name: Build
id: build
shell: bash
Expand All @@ -35,7 +35,7 @@ runs:
cd www
yarn
export NODE_OPTIONS=--max-old-space-size=8192 # prevents heap out of memory ?
CI=false yarn build && yarn export
CI=false yarn build
# prevent gh-pages jekyll build
touch out/.nojekyll
# save report in workspace for artifact
Expand Down
3 changes: 0 additions & 3 deletions report/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
"dependencies": {
"@actions/core": "^1.6.0",
"@octokit/core": "^3.5.1",
"file-util-git-history": "^3.1.0",
"lodash.omit": "^4.5.0",
"lodash.pick": "^4.4.0",
"nodegit": "^0.27.0",
"yaml": "^1.10.2"
},
"scripts": {
Expand All @@ -29,7 +27,6 @@
"@types/lodash.pick": "^4.4.6",
"@types/node": "^16.11.13",
"@types/node-fetch": "^2.5.12",
"@types/nodegit": "^0.27.6",
"babel-eslint": "^10.1.0",
"eslint": "^8.0.0",
"jest": "^27.4.5",
Expand Down
18 changes: 9 additions & 9 deletions report/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const core = require("@actions/core");

const { getUrls, writeFile, getConfig } = require("./utils");
const generateUrlReport = require("./generateUrlReport");
const generateTrends = require("./trends");
//const generateTrends = require("./trends");

const DASHLORD_REPO_PATH = process.env.DASHLORD_REPO_PATH || ".";

Expand Down Expand Up @@ -43,15 +43,15 @@ const generateJsons = async () => {
JSON.stringify(report, null, 2)
);

core.info(`generate trends.json`);
const trends = await generateTrends(DASHLORD_REPO_PATH, report);
// core.info(`generate trends.json`);
// const trends = await generateTrends(DASHLORD_REPO_PATH, report);

core.info(`write trends.json`);
// copy dashlord trends.json for the website
writeFile(
path.join(__dirname, "..", "www", "src", "trends.json"),
JSON.stringify(trends, null, 2)
);
// core.info(`write trends.json`);
// // copy dashlord trends.json for the website
// writeFile(
// path.join(__dirname, "..", "www", "src", "trends.json"),
// JSON.stringify(trends, null, 2)
// );
};

module.exports = {
Expand Down
2 changes: 2 additions & 0 deletions report/src/summary/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ Object {
"trackersGrade": "A",
"uptime": 99.909,
"uptimeGrade": "A",
"zapCount": 7,
"zapGrade": "D",
}
`;
2 changes: 2 additions & 0 deletions report/src/summary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const tools = {
sonarcloud: (report) => require("./sonarcloud")(report),
/** @param {DsFrReport} report */
dsfr: (report) => require("./dsfr")(report),
/** @param {ZapReport} report */
zap: (report) => require("./zap")(report),
};

/**
Expand Down
2 changes: 2 additions & 0 deletions report/src/summary/nmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const getGradeOpenPorts = (count) => {
return count > 2 ? "F" : "A";
};

//todo: improve

/** @param {NmapReport} report */
const summary = (report) => {
if (report) {
Expand Down
30 changes: 30 additions & 0 deletions report/src/summary/zap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
*
* @param {ZapReportSiteAlert} row
*/
const getGrade = (row) =>
({
0: "A", // info
1: "B", // low
2: "D", // medium
3: "F", // high
}[row.riskcode] || "A");

/** @param {ZapReport} report */
const summary = (report) => {
if (report && report.site && report.site.length) {
const alerts = report.site[0].alerts || [];
const maxCritic =
(alerts.length &&
alerts.sort((a, b) => b.riskcode.localeCompare(a.riskcode))[0]) ||
null;
if (maxCritic) {
return {
zapCount: alerts.filter((a) => a.riskcode !== "0").length,
zapGrade: getGrade(maxCritic),
};
}
}
};

module.exports = summary;
2 changes: 1 addition & 1 deletion report/www/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dashlord report website

This is a Next.js static website that produces the Dashlord report based on some input data.
This is a Next.js static website that produces the DashLord report based on some input data.

The data is generated with the `@socialgouv/dashlord-actions/report` action.

Expand Down
23 changes: 0 additions & 23 deletions report/www/jest.config.js

This file was deleted.

6 changes: 0 additions & 6 deletions report/www/jest.setup.js

This file was deleted.

12 changes: 12 additions & 0 deletions report/www/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@

const BASE_PATH = process.env.NEXT_PUBLIC_BASE_PATH || "";

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
output: "export",
trailingSlash: true, // without this, issues with some nested paths and static exports
basePath: BASE_PATH,
webpack: (config) => {
config.module.rules.push({
test: /\.(woff2|webmanifest)$/,
type: "asset/resource",
});

return config;
},
transpilePackages: ["@codegouvfr/react-dsfr", "tss-react"],
};

module.exports = nextConfig;
68 changes: 39 additions & 29 deletions report/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,59 @@
"description": "Reporting website for DashLord actions",
"private": true,
"license": "Apache-2.0",
"homepage": "https://socialgouv.github.io/dashlord-fabrique",
"homepage": "https://github.com/socialgouv/dashlord-actions",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"export": "next export",
"build:export": "yarn build && yarn export",
"test": "jest"
"test": "vitest",
"predev": "only-include-used-icons",
"prebuild": "only-include-used-icons"
},
"dependencies": {
"@dataesr/react-dsfr": "^2.5.0",
"@socialgouv/matomo-next": "^1.2.2",
"@testing-library/user-event": "^13.5.0",
"country-flag-icons": "^1.4.20",
"@codegouvfr/react-dsfr": "^1.2.2",
"@emotion/react": "^11.11.3",
"@emotion/server": "^11.11.0",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.15.6",
"@mui/material": "^5.15.6",
"@mui/x-data-grid": "^6.19.2",
"@socialgouv/matomo-next": "^1.8.0",
"country-flag-icons": "^1.5.9",
"date-fns": "^2.28.0",
"lodash.orderby": "^4.6.0",
"lodash.uniq": "^4.5.0",
"lodash.uniqby": "^4.7.0",
"next": "12.2.6",
"next": "^14.1.0",
"rc-tooltip": "^5.1.1",
"react": "17.0.2",
"react-base-table": "^1.13.0",
"react-d3-speedometer": "^1.0.1",
"react-dom": "17.0.2",
"react": "^18.2.0",
"react-d3-speedometer": "^1.1.0",
"react-dom": "^18.2.0",
"react-feather": "^2.0.9",
"react-vertical-timeline-component": "^3.5.2",
"recharts": "^2.1.8",
"sass": "^1.49.4"
"react-markdown": "^9.0.1",
"react-vertical-timeline-component": "^3.6.0",
"recharts": "^2.11.0",
"sass": "^1.70.0",
"tss-react": "^4.9.3"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@types/lodash.orderby": "^4.6.6",
"@types/lodash.uniq": "^4.5.6",
"@types/node": "^14",
"@types/react": "17.0.69",
"eslint": "8.19.0",
"eslint-config-next": "12.2.6",
"eslint-plugin-testing-library": "^5.0.5",
"jest": "^27.4.7",
"react-test-renderer": "^17.0.2",
"typescript": "4.7.4"
"@testing-library/react": "^14.1.2",
"@testing-library/user-event": "^14.5.2",
"@types/lodash.orderby": "^4.6.9",
"@types/lodash.uniq": "^4.5.9",
"@types/node": "^20.11.10",
"@types/react": "^18.2.48",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/ui": "^1.2.2",
"eslint": "8.56.0",
"eslint-config-next": "14.1.0",
"eslint-plugin-testing-library": "^6.2.0",
"next-router-mock": "^0.9.11",
"react-test-renderer": "^18.2.0",
"typescript": "5.3.3",
"vite-tsconfig-paths": "^4.3.1",
"vitest": "^1.2.2"
},
"version": "1.1.0"
}
}
9 changes: 5 additions & 4 deletions report/www/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import dashlordConfig from '@/config.json';
import type { NextPage } from "next";
import Head from "next/head";

const PageIntro: NextPage = () => {
import dashlordConfig from "@/config.json";

const Page404: NextPage = () => {
return (
<>
<Head>
<title>{dashlordConfig.title} - Page non trouvée</title>
<title>Page non trouvée - {dashlordConfig.title}</title>
</Head>
<br />
<br />
Expand All @@ -23,4 +24,4 @@ const PageIntro: NextPage = () => {
);
};

export default PageIntro;
export default Page404;
Loading

0 comments on commit 214bdcf

Please sign in to comment.