Skip to content

Commit

Permalink
table: generate nicer table
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsenta committed Jul 28, 2023
1 parent dcddf02 commit 85948b9
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/test-dev-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .github/workflows/test-prod-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 27 additions & 0 deletions aggregate-update-names.js
Original file line number Diff line number Diff line change
@@ -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);
122 changes: 122 additions & 0 deletions names.json
Original file line number Diff line number Diff line change
@@ -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"
]
}

0 comments on commit 85948b9

Please sign in to comment.