feat(tl): generate diff file for simpler update flow
primarily for my own use
This commit is contained in:
parent
416b3d9ef9
commit
71b39d6f53
3 changed files with 16 additions and 1 deletions
2
packages/tl/.gitignore
vendored
2
packages/tl/.gitignore
vendored
|
@ -4,3 +4,5 @@ errors.d.ts
|
||||||
errors.js
|
errors.js
|
||||||
binary/reader.js
|
binary/reader.js
|
||||||
binary/writer.js
|
binary/writer.js
|
||||||
|
|
||||||
|
diff.json
|
||||||
|
|
|
@ -6,6 +6,7 @@ export const DESCRIPTIONS_YAML_FILE = join(
|
||||||
'../data/descriptions.yaml'
|
'../data/descriptions.yaml'
|
||||||
)
|
)
|
||||||
export const API_SCHEMA_JSON_FILE = join(__dirname, '../api-schema.json')
|
export const API_SCHEMA_JSON_FILE = join(__dirname, '../api-schema.json')
|
||||||
|
export const API_SCHEMA_DIFF_JSON_FILE = join(__dirname, '../diff.json')
|
||||||
export const MTP_SCHEMA_JSON_FILE = join(__dirname, '../mtp-schema.json')
|
export const MTP_SCHEMA_JSON_FILE = join(__dirname, '../mtp-schema.json')
|
||||||
export const ERRORS_JSON_FILE = join(__dirname, '../raw-errors.json')
|
export const ERRORS_JSON_FILE = join(__dirname, '../raw-errors.json')
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {
|
||||||
TlEntry,
|
TlEntry,
|
||||||
TlFullSchema,
|
TlFullSchema,
|
||||||
writeTlEntryToString,
|
writeTlEntryToString,
|
||||||
|
generateTlSchemasDifference,
|
||||||
} from '@mtcute/tl-utils'
|
} from '@mtcute/tl-utils'
|
||||||
import { readdir, readFile, writeFile } from 'fs/promises'
|
import { readdir, readFile, writeFile } from 'fs/promises'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
|
@ -25,6 +26,7 @@ import {
|
||||||
TDLIB_SCHEMA,
|
TDLIB_SCHEMA,
|
||||||
COREFORK_DOMAIN,
|
COREFORK_DOMAIN,
|
||||||
BLOGFORK_DOMAIN,
|
BLOGFORK_DOMAIN,
|
||||||
|
API_SCHEMA_DIFF_JSON_FILE,
|
||||||
} from './constants'
|
} from './constants'
|
||||||
import { fetchRetry } from './utils'
|
import { fetchRetry } from './utils'
|
||||||
import {
|
import {
|
||||||
|
@ -32,7 +34,7 @@ import {
|
||||||
fetchDocumentation,
|
fetchDocumentation,
|
||||||
getCachedDocumentation,
|
getCachedDocumentation,
|
||||||
} from './documentation'
|
} from './documentation'
|
||||||
import { packTlSchema } from './schema'
|
import { packTlSchema, unpackTlSchema } from "./schema";
|
||||||
import { bumpVersion } from '../../../scripts/version'
|
import { bumpVersion } from '../../../scripts/version'
|
||||||
|
|
||||||
const README_MD_FILE = join(__dirname, '../README.md')
|
const README_MD_FILE = join(__dirname, '../README.md')
|
||||||
|
@ -313,6 +315,16 @@ async function main() {
|
||||||
|
|
||||||
await overrideInt53(resultSchema)
|
await overrideInt53(resultSchema)
|
||||||
|
|
||||||
|
console.log('Writing diff to file...')
|
||||||
|
const oldSchema = unpackTlSchema(JSON.parse(await readFile(API_SCHEMA_JSON_FILE, 'utf8')))
|
||||||
|
await writeFile(
|
||||||
|
API_SCHEMA_DIFF_JSON_FILE,
|
||||||
|
JSON.stringify({
|
||||||
|
layer: [oldSchema[1], resultLayer],
|
||||||
|
diff: generateTlSchemasDifference(oldSchema[0], resultSchema),
|
||||||
|
}, null, 4)
|
||||||
|
)
|
||||||
|
|
||||||
console.log('Writing result to file...')
|
console.log('Writing result to file...')
|
||||||
await writeFile(
|
await writeFile(
|
||||||
API_SCHEMA_JSON_FILE,
|
API_SCHEMA_JSON_FILE,
|
||||||
|
|
Loading…
Reference in a new issue