-
Notifications
You must be signed in to change notification settings - Fork 25
docs: add validate-conditions.ts script #784
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env npx tsx | ||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||
| * Validates conditions.json against the TACo SDK schemas | ||||||||||||||||||||||||||||||||||||
| * This helps identify client-side validation errors vs server-side errors | ||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||
| * Usage: tsx scripts/validate-conditions.ts [path/to/conditions.json] | ||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| import * as fs from 'fs'; | ||||||||||||||||||||||||||||||||||||
| import * as path from 'path'; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| import { ConditionExpression } from '../src/conditions/condition-expr'; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| async function main() { | ||||||||||||||||||||||||||||||||||||
| const conditionsPath = path.resolve(process.argv[2] ?? 'conditions.json'); | ||||||||||||||||||||||||||||||||||||
| console.log(`Loading conditions from: ${conditionsPath}`); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const conditionsJson = fs.readFileSync(conditionsPath, 'utf-8'); | ||||||||||||||||||||||||||||||||||||
| const conditionsObj = JSON.parse(conditionsJson); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| console.log('\nConditions loaded:'); | ||||||||||||||||||||||||||||||||||||
| console.log(JSON.stringify(conditionsObj, null, 2)); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+23
|
||||||||||||||||||||||||||||||||||||
| console.log('\n--- Validating with TACo SDK ---\n'); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+18
to
+26
|
||||||||||||||||||||||||||||||||||||
| const conditionsJson = fs.readFileSync(conditionsPath, 'utf-8'); | |
| const conditionsObj = JSON.parse(conditionsJson); | |
| console.log('\nConditions loaded:'); | |
| console.log(JSON.stringify(conditionsObj, null, 2)); | |
| console.log('\n--- Validating with TACo SDK ---\n'); | |
| try { | |
| try { | |
| const conditionsJson = fs.readFileSync(conditionsPath, 'utf-8'); | |
| const conditionsObj = JSON.parse(conditionsJson); | |
| console.log('\nConditions loaded:'); | |
| console.log(JSON.stringify(conditionsObj, null, 2)); | |
| console.log('\n--- Validating with TACo SDK ---\n'); |
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.
| console.log('\nParsed condition type:', expr.condition.conditionType); | |
| console.log('\nParsed condition type:', expr.condition.value.conditionType); |
Copilot
AI
Apr 29, 2026
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.
If main() rejects, main().catch(console.error) logs the error but does not set a failing exit code, so CI/consumers will see a successful exit even though validation didn’t run. Set process.exitCode = 1 (or call process.exit(1)) in this catch handler after logging.
| main().catch(console.error); | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exitCode = 1; | |
| }); |
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 hashbang
#!/usr/bin/env npx tsxis not a valid/portable shebang: most kernels pass everything after/usr/bin/envas a single argument, soenvwill look for an executable literally named"npx tsx"and the script won’t be runnable when invoked directly. Consider either removing the shebang (since the documented invocation is viapnpm tsx ...) or switching to a portable form like usingenv -Sto split arguments (and ensuring the repo’s supported platforms include it).