feat(tl/codegen): made generate-errors emit errors list as a json file
This commit is contained in:
parent
cdd01d43fc
commit
dd6e90bef6
2 changed files with 6 additions and 0 deletions
1
packages/tl/errors.json
Normal file
1
packages/tl/errors.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,8 @@
|
||||||
const { createWriter, snakeToCamel, camelToPascal } = require('./common')
|
const { createWriter, snakeToCamel, camelToPascal } = require('./common')
|
||||||
const fetch = require('node-fetch')
|
const fetch = require('node-fetch')
|
||||||
const csvParser = require('csv-parser')
|
const csvParser = require('csv-parser')
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
const ts = createWriter('../errors.d.ts')
|
const ts = createWriter('../errors.d.ts')
|
||||||
const js = createWriter('../errors.js')
|
const js = createWriter('../errors.js')
|
||||||
|
@ -110,6 +112,9 @@ export declare class RpcError extends Error {
|
||||||
}`)
|
}`)
|
||||||
baseErrors.forEach((it) => (it.base = true))
|
baseErrors.forEach((it) => (it.base = true))
|
||||||
const allErrors = [...baseErrors, ...csv]
|
const allErrors = [...baseErrors, ...csv]
|
||||||
|
|
||||||
|
fs.writeFileSync(path.join(__dirname, '../errors.json'), JSON.stringify(allErrors))
|
||||||
|
|
||||||
allErrors.forEach((err) => {
|
allErrors.forEach((err) => {
|
||||||
let hasArgument =
|
let hasArgument =
|
||||||
err.description && err.description.match(/{([a-z_]+)}/i)
|
err.description && err.description.match(/{([a-z_]+)}/i)
|
||||||
|
|
Loading…
Reference in a new issue