From 85948b923d291f948e905231219b0bafd0f90f0c Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Thu, 27 Jul 2023 10:54:53 +0200 Subject: [PATCH] table: generate nicer table --- .github/workflows/test-dev-e2e.yml | 3 +- .github/workflows/test-prod-e2e.yml | 1 + aggregate-update-names.js | 27 ++++++ names.json | 122 ++++++++++++++++++++++++++++ 4 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 aggregate-update-names.js create mode 100644 names.json diff --git a/.github/workflows/test-dev-e2e.yml b/.github/workflows/test-dev-e2e.yml index 38a297cc7..13614bfce 100644 --- a/.github/workflows/test-dev-e2e.yml +++ b/.github/workflows/test-dev-e2e.yml @@ -47,7 +47,8 @@ jobs: jq -ns 'inputs' "$file" | node ../gateway-conformance/aggregate.js 1 > "${new_file}" done - node ../gateway-conformance/aggregate-into-table.js ./aggregates/*.json > ./table.md + node ../gateway-conformance/aggregate-into-table.js ./aggregates/*.json > /tmp/table.md + node ../gateway-conformance/aggregate-update-names.js ../gateway-conformance/names.json /tmp/table.md > ./table.md - name: Set summary if: (failure() || success()) run: cat ./artifacts/table.md >> $GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/.github/workflows/test-prod-e2e.yml b/.github/workflows/test-prod-e2e.yml index 8819deec2..fd5e48e1e 100644 --- a/.github/workflows/test-prod-e2e.yml +++ b/.github/workflows/test-prod-e2e.yml @@ -110,6 +110,7 @@ jobs: done node ../gateway-conformance/aggregate-into-table.js ./aggregates/*.json > ./table.md + node ../gateway-conformance/aggregate-update-names.js ../gateway-conformance/names.json ./table.md > ./table.md - name: Set summary if: (failure() || success()) run: cat ./artifacts/table.md >> $GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/aggregate-update-names.js b/aggregate-update-names.js new file mode 100644 index 000000000..67d0b6a46 --- /dev/null +++ b/aggregate-update-names.js @@ -0,0 +1,27 @@ +const fs = require('fs'); + +const jsonFilePath = process.argv[2]; +const markdownFilePath = process.argv[3]; + +// Check if file paths are provided +if (!jsonFilePath || !markdownFilePath) { + console.error('Both a JSON file path and a Markdown file path must be provided.'); + process.exit(1); +} + +const jsonData = JSON.parse(fs.readFileSync(jsonFilePath, 'utf8')); +const sortedKeys = Object.keys(jsonData).sort((a, b) => b.length - a.length); + +let markdown = fs.readFileSync(markdownFilePath, 'utf8'); + +for (const key of sortedKeys) { + const newName = jsonData[key][1] + ? `[${jsonData[key][0]}](${jsonData[key][1]})` + : jsonData[key][0]; + + const regex = new RegExp(key, 'g'); + markdown = markdown.replace(regex, newName); +} + +// output the new markdown to stdout +fs.writeFileSync(1, markdown); \ No newline at end of file diff --git a/names.json b/names.json new file mode 100644 index 000000000..5fea2b6fe --- /dev/null +++ b/names.json @@ -0,0 +1,122 @@ +{ + "Cors": [ + "Cross-Origin Resource Sharing", + null + ], + "DAgPbConversion": [ + "DAG Protobuf Conversion", + null + ], + "DNSLinkGateway": [ + "DNS Link Gateway", + "https://specs.ipfs.tech/http-gateways/dnslink-gateway/" + ], + "DNSLinkGatewayUnixFSDirectoryListing": [ + "DNS Link Gateway Unix FS Directory Listing", + "https://specs.ipfs.tech/http-gateways/dnslink-gateway/" + ], + "GatewayBlock": [ + "Gateway Block", + null + ], + "GatewayCache": [ + "Gateway Cache", + null + ], + "GatewayCacheWithIPNS": [ + "Gateway Cache with IPNS", + null + ], + "GatewayIPNSRecord": [ + "Gateway IPNS Record", + null + ], + "GatewayJSONCborAndIPNS": [ + "Gateway JSON CBOR and IPNS", + null + ], + "GatewayJsonCbor": [ + "Gateway JSON CBOR", + null + ], + "GatewaySubdomainAndIPNS": [ + "Gateway Subdomain and IPNS", + null + ], + "GatewaySubdomains": [ + "Gateway Subdomains", + null + ], + "GatewaySymlink": [ + "Gateway Symbolic Link", + null + ], + "NativeDag": [ + "Native DAG", + null + ], + "Pathing": [ + "Pathing", + null + ], + "PlainCodec": [ + "Plain Codec", + null + ], + "RedirectsFileSupport": [ + "Redirects File Support", + "https://specs.ipfs.tech/http-gateways/web-redirects-file/" + ], + "RedirectsFileSupportWithDNSLink": [ + "Redirects File Support with DNS Link", + "https://specs.ipfs.tech/http-gateways/web-redirects-file/" + ], + "SubdomainGatewayDNSLinkInlining": [ + "Subdomain Gateway DNS Link Inlining", + null + ], + "Tar": [ + "Tar", + null + ], + "TrustlessCarDagScopeAll": [ + "Trustless Car DAG Scope All", + "https://specs.ipfs.tech/http-gateways/trustless-gateway/" + ], + "TrustlessCarDagScopeBlock": [ + "Trustless Car DAG Scope Block", + "https://specs.ipfs.tech/http-gateways/trustless-gateway/" + ], + "TrustlessCarDagScopeEntity": [ + "Trustless Car DAG Scope Entity", + "https://specs.ipfs.tech/http-gateways/trustless-gateway/" + ], + "TrustlessCarEntityBytes": [ + "Trustless Car Entity Bytes", + "https://specs.ipfs.tech/http-gateways/trustless-gateway/" + ], + "TrustlessCarPathing": [ + "Trustless Car Pathing", + "https://specs.ipfs.tech/http-gateways/trustless-gateway/" + ], + "TrustlessRaw": [ + "Trustless Raw", + "https://specs.ipfs.tech/http-gateways/trustless-gateway/" + ], + "UnixFSDirectoryListing": [ + "Unix FS Directory Listing", + null + ], + "UnixFSDirectoryListingOnSubdomainGateway": [ + "Unix FS Directory Listing on Subdomain Gateway", + null + ], + "conformance-bifrost-gateway": [ + "Bifrost Gateway", + "https://github.com/ipfs/bifrost-gateway" + ], + "conformance-kubo-gateway": [ + "Kubo Gateway", + "https://github.com/ipfs/kubo" + ] +} \ No newline at end of file