-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: nicer error when no auth to Hop
- Loading branch information
Showing
6 changed files
with
62 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import ts from 'typescript'; | ||
import {createReadStream} from 'node:fs'; | ||
import {json} from 'node:stream/consumers'; | ||
|
||
const tsconfig = (await json(createReadStream('./tsconfig.json'))) as { | ||
compilerOptions: ts.CompilerOptions; | ||
}; | ||
|
||
const program = ts.createProgram(['./src/index.ts'], { | ||
...ts.getDefaultCompilerOptions(), | ||
...tsconfig.compilerOptions, | ||
moduleResolution: ts.ModuleResolutionKind.NodeNext, | ||
module: ts.ModuleKind.NodeNext, | ||
}); | ||
|
||
const printer = ts.createPrinter(); | ||
const hop = program.getSourceFile('./src/hop.ts'); | ||
|
||
if (!hop) { | ||
throw new Error('Could not find Hop class file!'); | ||
} | ||
|
||
const node = hop.forEachChild(node => { | ||
if (ts.isClassDeclaration(node)) { | ||
return node; | ||
} | ||
}); | ||
|
||
if (!node) { | ||
throw new Error('Could not find Hop class!'); | ||
} | ||
|
||
const members = node.members.filter(ts.isPropertyDeclaration); | ||
|
||
const identifiers = members | ||
.map(member => member.name) | ||
.filter(Boolean) | ||
.filter(ts.isIdentifier); | ||
|
||
for (const identifier of identifiers) { | ||
console.log(printer.printNode(ts.EmitHint.IdentifierName, identifier, hop)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"main": "../../dist/utils/zod/index.js", | ||
"module": "../../dist/utils/zod/index.mjs", | ||
"types": "../../dist/utils/zod/index.d.ts" | ||
} | ||
"main": "../../dist/utils/zod/index.js", | ||
"module": "../../dist/utils/zod/index.mjs", | ||
"types": "../../dist/utils/zod/index.d.ts" | ||
} |
d2617bb
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.
Successfully deployed to the following URLs:
hop-js – ./
hop-js.vercel.app
hop-js-git-master-onehop.vercel.app
hop-js-onehop.vercel.app
js.hop.io