Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"access": "public"
},
"scripts": {
"build": "tsc -p tsconfig.json && mkdir -p dist/src && cp src/schemas.trust-*.json dist/src/",
"build": "tsc -p tsconfig.json && node scripts/copy-schemas.mjs",
"test": "node --test dist/test/receipt.test.js dist/test/trust.test.js",
"pretest": "npm run build",
"example:basic": "node dist/examples/basic-agent.js",
Expand Down
19 changes: 19 additions & 0 deletions scripts/copy-schemas.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { copyFile, mkdir, readdir } from 'node:fs/promises';
import path from 'node:path';

const sourceDir = 'src';
const destinationDir = path.join('dist', 'src');
const schemaPattern = /^schemas\.trust-.*\.json$/;

await mkdir(destinationDir, { recursive: true });

const sourceEntries = await readdir(sourceDir, { withFileTypes: true });
const schemaFiles = sourceEntries
.filter((entry) => entry.isFile() && schemaPattern.test(entry.name))
.map((entry) => entry.name);

await Promise.all(
schemaFiles.map((fileName) =>
copyFile(path.join(sourceDir, fileName), path.join(destinationDir, fileName)),
),
);
Loading