Skip to content

Commit

Permalink
fix(app): put public files in out dir for app export (passportxyz#1312)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianHymer authored May 26, 2023
1 parent ea2bace commit c9db67a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"version": "1.0.0",
"scripts": {
"start": "NEXT_PUBLIC_GIT_COMMIT_HASH=$(git rev-parse --short HEAD) next dev -p 3000",
"export": "NEXT_PUBLIC_GIT_COMMIT_HASH=$(git rev-parse --short HEAD) next build && next export && ts-node ./scripts/postBuild.ts",
"build": "NEXT_PUBLIC_GIT_COMMIT_HASH=$(git rev-parse --short HEAD) next build && ts-node ./scripts/postBuild.ts",
"export": "NEXT_PUBLIC_GIT_COMMIT_HASH=$(git rev-parse --short HEAD) next build && next export && ts-node ./scripts/postBuild.ts out",
"build": "NEXT_PUBLIC_GIT_COMMIT_HASH=$(git rev-parse --short HEAD) next build && ts-node ./scripts/postBuild.ts public",
"prod-start": "NEXT_PUBLIC_GIT_COMMIT_HASH=$(git rev-parse --short HEAD) next start",
"clean": "rimraf node_modules && rimraf .next",
"lint": "next lint && prettier --check .",
Expand Down
13 changes: 9 additions & 4 deletions app/scripts/postBuild.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import dotenv from "dotenv";
import { writeFileSync } from "fs";
import { join } from "path";
import { keccak256, toUtf8Bytes } from "ethers";

import { PlatformGroupSpec, platforms } from "@gitcoin/passport-platforms";

const args = process.argv.slice(2);
const [outputDirectory] = args;
if (!outputDirectory) {
throw new Error("No output directory specified");
}

dotenv.config();

type StampData = {
Expand Down Expand Up @@ -70,7 +75,7 @@ const platformsData = Object.entries(platforms).reduce((data, [id, platform]) =>
];
}, [] as PlatformData[]);

const outPath = join(__dirname, "..", "public", "stampMetadata.json");
console.log(`Saving platform info to JSON file at ${outPath}`);
const outputPath = join(outputDirectory, "stampMetadata.json");
console.log(`Saving platform info to JSON file at ${outputPath}`);

writeFileSync(outPath, JSON.stringify(platformsData));
writeFileSync(outputPath, JSON.stringify(platformsData));

0 comments on commit c9db67a

Please sign in to comment.