Skip to content

Commit

Permalink
generate types.json
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonwells committed Oct 4, 2024
1 parent ba31a73 commit f272602
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion js/api-augment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"prepackage": "cp CONTRIBUTING.md README.md ../../LICENSE ./dist",
"prebuild": "npm run generate",
"build": "tsc -p ./tsconfig.types.json && tsc -p ./tsconfig.cjs.json && tsc -p ./tsconfig.esm.json",
"postbuild": "npm run package",
"build:types-json": "node scripts/generate.mjs",
"postbuild": "npm run package && npm run build:types-json",
"fetch:local": "curl -H \"Content-Type: application/json\" -d '{\"id\":\"1\", \"jsonrpc\":\"2.0\", \"method\": \"state_getMetadata\", \"params\":[]}' http://localhost:9944 -o ./metadata.json",
"generate:defs": "node --import=tsx/esm node_modules/.bin/polkadot-types-from-defs --package @frequency-chain/api-augment --input ./interfaces --endpoint ./metadata.json",
"generate:meta": "node --import=tsx/esm node_modules/.bin/polkadot-types-from-chain --package @frequency-chain/api-augment --endpoint ./metadata.json --output ./interfaces",
Expand Down
19 changes: 19 additions & 0 deletions js/api-augment/scripts/generate.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { types } from '../dist/esm/index.js';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { dirname } from 'path';

// Get the filename from the URL
const __filename = fileURLToPath(import.meta.url);
// Get the directory name from the filename
const __dirname = dirname(__filename);
const outdir = path.join(__dirname,"../dist/json/");

fs.mkdirSync( outdir, { recursive: true});

fs.writeFileSync(
path.join(outdir, "types.json"),
JSON.stringify(types, null, 4)
);

0 comments on commit f272602

Please sign in to comment.