-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generate types.json #2127
generate types.json #2127
Conversation
42b977e
to
969e50b
Compare
import { dirname } from 'path'; | ||
|
||
// Get the filename from the URL | ||
const __filename = fileURLToPath(import.meta.url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I did not know one could do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM!
scripts/generate_js_definitions.sh
Outdated
@@ -41,6 +41,7 @@ else | |||
npm install # in case things have changed | |||
npm run fetch:local | |||
npm run build | |||
npm run build:types-json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems redundant since build:types-json
is now part of the postbuild
script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it because I was unsure. I'm not seeing where postbuild
gets called. Do you know what it's for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way npm scripts work, any script that starts with "pre" or "post" runs before/after the main script of the same name. So "postbuild" automatically runs after "build".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two notes about where the output publishes
@@ -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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need to copy the file to the dist directory to make sure that it is published in the npm api-augment package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generate.mjs
output goes to dist/json/types.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see it now. I misread the output and didn't see it when I built it locally. Sorry about that!
run: npm run build | ||
run: | | ||
npm run build | ||
npm run build:types-json | ||
working-directory: js/api-augment | ||
- name: Upload Dist Dir | ||
uses: actions/upload-artifact@v4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds it to the artifacts for the workflow, but if we want to include it as an artifact as part of the release, we need to update these two steps to include it:
Publish Release Candidate on GitHub
Publish Full Release on GitHub
Codecov ReportAll modified and coverable lines are covered by tests ✅ |
1de7a2f
to
defb05f
Compare
Goal
The goal of this PR is to generate a types.json file to help with being on Subscan et al.
Closes #2062
Checklist
make js
Verify
make js
, which replicates the two needed steps run in CI.cd js/api-augment/dist
, this should exist:json/types.json
types.json
should look like the following, so that it would be included in the tarball if you runnpm pack
: