From a855f50ec41159e8237a35967371645fdd229ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20J=C3=A4genstedt?= Date: Fri, 19 Jul 2024 15:25:18 +0200 Subject: [PATCH] Rename the JSON file in the web-feature package to data.json This is so that we can use the same filename in the NPM release and the GitHub release. (index.json would be weird in a GitHub release.) --- .github/workflows/pull_request.yml | 2 +- .gitignore | 2 +- packages/web-features/index.ts | 2 +- packages/web-features/package.json | 4 ++-- scripts/build.ts | 2 +- scripts/release.ts | 8 ++++---- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 11a6c3e7683..c576605be43 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -18,7 +18,7 @@ jobs: - run: npm ci - run: npm run build - name: Pretty print built JSON - run: jq . packages/web-features/index.json + run: jq . packages/web-features/data.json test: runs-on: ubuntu-latest steps: diff --git a/.gitignore b/.gitignore index 099fb722a49..52e4271dfe3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,5 @@ packages/compute-baseline/dist/ packages/web-features/index.d.ts packages/**/LICENSE.txt packages/web-features/types.ts -index.json +data.json index.js diff --git a/packages/web-features/index.ts b/packages/web-features/index.ts index ae95fc9dbed..0abbfd05f4e 100644 --- a/packages/web-features/index.ts +++ b/packages/web-features/index.ts @@ -3,7 +3,7 @@ import { fileURLToPath } from "node:url"; import { WebFeaturesData } from "./types"; -const jsonPath = fileURLToPath(new URL("./index.json", import.meta.url)); +const jsonPath = fileURLToPath(new URL("./data.json", import.meta.url)); const { features, groups, snapshots } = JSON.parse( readFileSync(jsonPath, { encoding: "utf-8" }), ) as WebFeaturesData; diff --git a/packages/web-features/package.json b/packages/web-features/package.json index 1ff4f8b742b..072722d90f0 100644 --- a/packages/web-features/package.json +++ b/packages/web-features/package.json @@ -11,13 +11,13 @@ "main": "index.js", "exports": { ".": "./index.js", - "./index.json": "./index.json" + "./data.json": "./data.json" }, "types": "./index.d.ts", "files": [ "index.d.ts", "index.js", - "index.json" + "data.json" ], "scripts": { "prepare": "tsc && rm types.js && tsup ./index.ts --dts-only --format=esm --out-dir=." diff --git a/scripts/build.ts b/scripts/build.ts index fae23a6d8e0..472de2bcd88 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -21,7 +21,7 @@ function buildPackage() { const json = stringify(data); // TODO: Validate the resulting JSON against a schema. - const path = new URL("index.json", packageDir); + const path = new URL("data.json", packageDir); fs.writeFileSync(path, json); for (const file of filesToCopy) { fs.copyFileSync(new URL(file, rootDir), new URL(file, packageDir)); diff --git a/scripts/release.ts b/scripts/release.ts index a57cc46b530..cefa50466d5 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -311,12 +311,12 @@ function diffJson(from: string = "latest", to?: string): string { temporaryDir, "node_modules", "web-features", - "index.json", + "data.json", ); const prettyJson = execSync(`jq . "${pkgJson}"`, { encoding: "utf-8", }); - const fp = join(temporaryDir, `index.${version}.json`); + const fp = join(temporaryDir, `data.${version}.json`); writeFileSync(fp, prettyJson); return fp; } @@ -327,11 +327,11 @@ function diffJson(from: string = "latest", to?: string): string { return pkgToJsonFile(to); } else { build(); - const preparedJson = join(packages["web-features"], "index.json"); + const preparedJson = join(packages["web-features"], "data.json"); const prettyPreparedJson = execSync(`jq . "${preparedJson}"`, { encoding: "utf-8", }); - const fp = join(temporaryDir, "index.HEAD.json"); + const fp = join(temporaryDir, "data.HEAD.json"); writeFileSync(fp, prettyPreparedJson); return fp; }