Skip to content

Commit

Permalink
Rename the JSON file in the web-feature package to data.json (#1470)
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
foolip authored Jul 19, 2024
1 parent 49da860 commit 09507c2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion packages/web-features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/web-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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=."
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
8 changes: 4 additions & 4 deletions scripts/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 09507c2

Please sign in to comment.