build: preparing to publish (part 2)
fixed imports, package.json files, improved package generation for certain packages, and more (i'm too lazy to describe all the magic that i've done)
This commit is contained in:
parent
ae2dbcf03f
commit
280c9f51aa
31 changed files with 310 additions and 134 deletions
15
package.json
15
package.json
|
@ -9,17 +9,10 @@
|
|||
"test": "lerna run test",
|
||||
"build": "lerna run build",
|
||||
"lint": "eslint packages/**/*.ts",
|
||||
"format": "prettier --write packages/**/*.ts"
|
||||
"format": "prettier --write packages/**/*.ts",
|
||||
"publish-all": "node scripts/publish.js all"
|
||||
},
|
||||
"dependencies": {
|
||||
"big-integer": "1.6.48",
|
||||
"buffer": "^6.0.3",
|
||||
"debug": "^4.3.1",
|
||||
"es6-symbol": "^3.1.3",
|
||||
"events": "3.2.0",
|
||||
"file-type": "^16.2.0",
|
||||
"leemon": "6.2.0",
|
||||
"pako": "2.0.2",
|
||||
"node-gyp": "^8.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -47,7 +40,9 @@
|
|||
"ts-node": "^9.1.1",
|
||||
"typedoc": "^0.20.28",
|
||||
"typescript": "^4.1.3",
|
||||
"nyc": "^15.1.0"
|
||||
"nyc": "^15.1.0",
|
||||
"glob": "^7.1.7",
|
||||
"rimraf": "^3.0.2"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@mtcute/client",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"description": "High-level API over @mtcute/core",
|
||||
"author": "Alisa Sireneva <me@tei.su>",
|
||||
"license": "MIT",
|
||||
|
@ -12,9 +12,13 @@
|
|||
"build": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mtcute/tl": "^0.0.0",
|
||||
"@mtcute/core": "^0.0.0",
|
||||
"@mtcute/file-id": "^0.0.0",
|
||||
"eager-async-pool": "^1.0.0"
|
||||
"@types/node": "^15.12.1",
|
||||
"@mtcute/tl": "~1.129.0",
|
||||
"@mtcute/core": "^1.0.0",
|
||||
"@mtcute/file-id": "^1.0.0",
|
||||
"eager-async-pool": "^1.0.0",
|
||||
"file-type": "^16.2.0",
|
||||
"big-integer": "1.6.48",
|
||||
"debug": "^4.3.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { TelegramClient } from '../../client'
|
||||
import { InputPeerLike } from '../../types'
|
||||
import { tl } from '@mtcute/tl'
|
||||
import { computeSrpParams } from '@mtcute/core/dist'
|
||||
import { computeSrpParams } from '@mtcute/core'
|
||||
|
||||
/**
|
||||
* Request a callback answer from a bot,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { TelegramClient } from '../../client'
|
||||
import { tl } from '@mtcute/tl'
|
||||
import { StickerSet } from '../../types'
|
||||
import { fileIdToInputDocument, tdFileId } from '../../../../file-id'
|
||||
import { fileIdToInputDocument, tdFileId } from '@mtcute/file-id'
|
||||
|
||||
/**
|
||||
* Delete a sticker from a sticker set
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { TelegramClient } from '../../client'
|
||||
import { fileIdToInputDocument, tdFileId } from '../../../../file-id'
|
||||
import { fileIdToInputDocument, tdFileId } from '@mtcute/file-id'
|
||||
import { tl } from '@mtcute/tl'
|
||||
import { StickerSet } from '../../types'
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { TelegramClient } from '../../client'
|
||||
import { MaybeArray } from '@mtcute/core'
|
||||
import { tl } from '@mtcute/tl'
|
||||
import { fileIdToInputPhoto } from '../../../../file-id'
|
||||
import { fileIdToInputPhoto } from '@mtcute/file-id'
|
||||
|
||||
/**
|
||||
* Delete your own profile photos
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { makeInspectable } from '@mtcute/client/src/types/utils'
|
||||
import { makeInspectable } from '../utils'
|
||||
import { tl } from '@mtcute/tl'
|
||||
import { PeerType, User, UsersIndex } from '../peers'
|
||||
import { TelegramClient } from '../../client'
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { MaybeDynamic, Message, MtCuteError } from '../types'
|
||||
import { BigInteger } from 'big-integer'
|
||||
import { randomBytes } from '@mtcute/core/src/utils/buffer-utils'
|
||||
import { bufferToBigInt } from '@mtcute/core/src/utils/bigint-utils'
|
||||
import { randomBytes, bufferToBigInt } from '@mtcute/core'
|
||||
import { tl } from '@mtcute/tl'
|
||||
|
||||
export const EMPTY_BUFFER = Buffer.alloc(0)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@mtcute/core",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"description": "Core functions and base MTProto client",
|
||||
"author": "Alisa Sireneva <me@tei.su>",
|
||||
"license": "MIT",
|
||||
|
@ -12,10 +12,19 @@
|
|||
"docs": "npx typedoc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mtcute/tl": "^0.0.0"
|
||||
"@types/events": "^3.0.0",
|
||||
"@mtcute/tl": "~1.129.0",
|
||||
"leemon": "6.2.0",
|
||||
"pako": "2.0.2",
|
||||
"big-integer": "1.6.48",
|
||||
"debug": "^4.3.1",
|
||||
"events": "3.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ws": "^7.4.1",
|
||||
"ws": "^7.4.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/node": "^15.12.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { tl } from '@mtcute/tl'
|
||||
import { MaybeAsync } from '../../types/utils'
|
||||
import { ICryptoProvider } from '../../utils/crypto'
|
||||
import EventEmitter from 'events'
|
||||
|
||||
export enum TransportState {
|
||||
/**
|
||||
|
@ -23,25 +24,16 @@ export enum TransportState {
|
|||
}
|
||||
|
||||
/**
|
||||
* Interface declaring a transport to connect to Telegram with.
|
||||
* Is usually extended from `EventEmitter` to provide on/once
|
||||
* Interface implementing a transport to interact with Telegram servers.
|
||||
*
|
||||
* Events:
|
||||
* - `ready` event is emitted once connection has been established: `() => void`
|
||||
* - `close` event is emitted once connection has been closed: `() => void`
|
||||
* - `error` event is event is emitted when there was some error
|
||||
* (either mtproto related or network related): `(error: Error) => void`
|
||||
* - `message` event is emitted when a mtproto message is received: `(message: Buffer) => void`
|
||||
*/
|
||||
export interface ICuteTransport {
|
||||
/** ready event is emitted once connection has been established */
|
||||
on(event: 'ready', handler: () => void): this
|
||||
once(event: 'ready', handler: () => void): this
|
||||
/** close event is emitted once connection has been closed */
|
||||
on(event: 'close', handler: () => void): this
|
||||
once(event: 'close', handler: () => void): this
|
||||
/** error event is emitted when there was some error (either mtproto related or network related) */
|
||||
on(event: 'error', handler: (error: Error) => void): this
|
||||
once(event: 'error', handler: (error: Error) => void): this
|
||||
/** message event is emitted when a mtproto message is received */
|
||||
on(event: 'message', handler: (message: Buffer) => void): this
|
||||
once(event: 'message', handler: (message: Buffer) => void): this
|
||||
/** used to clean up a transport to be able to recycle them */
|
||||
removeAllListeners(): void
|
||||
|
||||
export interface ICuteTransport extends EventEmitter {
|
||||
/** returns current state */
|
||||
state(): TransportState
|
||||
/** returns current DC. should return null if state == IDLE */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { EventEmitter } from 'events'
|
||||
import EventEmitter from 'events'
|
||||
import { PacketCodec } from './abstract'
|
||||
import { ICryptoProvider } from '../../utils/crypto'
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ import { ForgeCryptoProvider } from './forge-crypto'
|
|||
export * from './abstract'
|
||||
export * from './password'
|
||||
|
||||
export { NodeCryptoProvider, ForgeCryptoProvider }
|
||||
|
||||
export let defaultCryptoProviderFactory: CryptoProviderFactory
|
||||
if (nodeCrypto) {
|
||||
defaultCryptoProviderFactory = () => new NodeCryptoProvider()
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
{
|
||||
"name": "@mtcute/crypto-node",
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"description": "Native crypto implementation for NodeJS",
|
||||
"main": "src/index.ts",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build-ts": "tsc",
|
||||
"build:dev": "node-gyp -j 16 build --debug",
|
||||
"build": "node-gyp configure && node-gyp -j 16 build && tsc",
|
||||
"install": "node-gyp configure && node-gyp -j 16 build",
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { NodeCryptoProvider } from '@mtcute/core/src/utils/crypto/node-crypto'
|
||||
import { IEncryptionScheme } from '@mtcute/core'
|
||||
import { ige256_decrypt, ige256_encrypt } from '../native'
|
||||
import { NodeCryptoProvider, IEncryptionScheme } from '@mtcute/core'
|
||||
import { ige256_decrypt, ige256_encrypt } from './native'
|
||||
|
||||
/**
|
||||
* Crypto provider for NodeJS that uses a native extension to improve
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "@mtcute/crypto",
|
||||
"private": true,
|
||||
"version": "0.0.0"
|
||||
"version": "1.0.0"
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@mtcute/dispatcher",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"description": "Updates dispatcher and bot framework for @mtcute/client",
|
||||
"author": "Alisa Sireneva <me@tei.su>",
|
||||
"license": "MIT",
|
||||
|
@ -12,8 +12,10 @@
|
|||
"build": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mtcute/tl": "^0.0.0",
|
||||
"@mtcute/core": "^0.0.0",
|
||||
"@mtcute/client": "^0.0.0"
|
||||
"@mtcute/tl": "~1.129.0",
|
||||
"@mtcute/core": "^1.0.0",
|
||||
"@mtcute/client": "^1.0.0",
|
||||
"es6-symbol": "^3.1.3",
|
||||
"debug": "^4.3.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@mtcute/file-id",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"description": "Support for TDLib and Bot API file ID for MTCute",
|
||||
"author": "Alisa Sireneva <me@tei.su>",
|
||||
"license": "MIT",
|
||||
|
@ -12,7 +12,8 @@
|
|||
"build": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mtcute/tl": "^0.0.0",
|
||||
"@mtcute/core": "^0.0.0"
|
||||
"@mtcute/tl": "~1.129.0",
|
||||
"@mtcute/core": "^1.0.0",
|
||||
"big-integer": "1.6.48"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@mtcute/html-parser",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"description": "HTML entities parser for MTCute",
|
||||
"author": "Alisa Sireneva <me@tei.su>",
|
||||
"license": "MIT",
|
||||
|
@ -13,11 +13,11 @@
|
|||
"docs": "npx typedoc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mtcute/tl": "^0.0.0",
|
||||
"@mtcute/tl": "~1.129.0",
|
||||
"htmlparser2": "^6.0.1",
|
||||
"big-integer": "^1.6.48"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mtcute/client": "^0.0.0"
|
||||
"@mtcute/client": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@mtcute/http-proxy",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"description": "HTTP(S) proxy support for MTCute",
|
||||
"author": "Alisa Sireneva <me@tei.su>",
|
||||
"license": "MIT",
|
||||
|
@ -12,6 +12,7 @@
|
|||
"build": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mtcute/core": "^0.0.0"
|
||||
"@mtcute/core": "^1.0.0",
|
||||
"debug": "^4.3.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@mtcute/markdown-parser",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"description": "Markdown entities parser for MTCute",
|
||||
"author": "Alisa Sireneva <me@tei.su>",
|
||||
"license": "MIT",
|
||||
|
@ -13,10 +13,10 @@
|
|||
"docs": "npx typedoc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mtcute/tl": "^0.0.0",
|
||||
"@mtcute/tl": "~1.129.0",
|
||||
"big-integer": "^1.6.48"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mtcute/client": "^0.0.0"
|
||||
"@mtcute/client": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@mtcute/mtproxy",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"description": "MTProto proxy (MTProxy) support for MTCute",
|
||||
"author": "Alisa Sireneva <me@tei.su>",
|
||||
"license": "MIT",
|
||||
|
@ -12,6 +12,7 @@
|
|||
"build": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mtcute/core": "^0.0.0"
|
||||
"@mtcute/core": "^1.0.0",
|
||||
"big-integer": "1.6.48"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ export namespace NodeTelegramClient {
|
|||
* You can pass a file name as a simple string,
|
||||
* which will be passed directly to `SqliteStorage`
|
||||
*
|
||||
* Defaults to in-memory SQLite storage.
|
||||
* Defaults to SQLite storage in `session.db` file in
|
||||
* current working directory
|
||||
*/
|
||||
storage?: BaseTelegramClient.Options['storage'] | string
|
||||
}
|
||||
|
@ -46,7 +47,7 @@ export class NodeTelegramClient extends TelegramClient {
|
|||
storage:
|
||||
typeof opts.storage === 'string'
|
||||
? new SqliteStorage(opts.storage)
|
||||
: opts.storage ?? new SqliteStorage(':memory:'),
|
||||
: opts.storage ?? new SqliteStorage('session.db'),
|
||||
})
|
||||
|
||||
this.registerParseMode(new HtmlMessageEntityParser())
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@mtcute/node",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"description": "Meta-package for Node JS",
|
||||
"author": "Alisa Sireneva <me@tei.su>",
|
||||
"license": "MIT",
|
||||
|
@ -12,11 +12,11 @@
|
|||
"build": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mtcute/client": "^0.0.0",
|
||||
"@mtcute/sqlite": "^0.0.0",
|
||||
"@mtcute/markdown-parser": "^0.0.0",
|
||||
"@mtcute/html-parser": "^0.0.0",
|
||||
"@mtcute/dispatcher": "^0.0.0",
|
||||
"@mtcute/crypto-node": "^0.0.0"
|
||||
"@mtcute/client": "^1.0.0",
|
||||
"@mtcute/sqlite": "^1.0.0",
|
||||
"@mtcute/markdown-parser": "^1.0.0",
|
||||
"@mtcute/html-parser": "^1.0.0",
|
||||
"@mtcute/dispatcher": "^1.0.0",
|
||||
"@mtcute/crypto-node": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@mtcute/socks-proxy",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"description": "SOCKS4/5 proxy support for MTCute",
|
||||
"author": "Alisa Sireneva <me@tei.su>",
|
||||
"license": "MIT",
|
||||
|
@ -12,7 +12,8 @@
|
|||
"build": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mtcute/core": "^0.0.0",
|
||||
"ip6": "^0.2.6"
|
||||
"@mtcute/core": "^1.0.0",
|
||||
"ip6": "^0.2.6",
|
||||
"debug": "^4.3.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@mtcute/sqlite",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"description": "SQLite-based storage for MTCute",
|
||||
"author": "Alisa Sireneva <me@tei.su>",
|
||||
"license": "MIT",
|
||||
|
@ -12,9 +12,11 @@
|
|||
"build": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mtcute/core": "^0.0.0",
|
||||
"@mtcute/tl": "^0.0.0",
|
||||
"better-sqlite3": "^7.4.0"
|
||||
"@mtcute/core": "^1.0.0",
|
||||
"@mtcute/tl": "~1.129.0",
|
||||
"better-sqlite3": "^7.4.0",
|
||||
"big-integer": "1.6.48",
|
||||
"debug": "^4.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/sqlite3": "^3.1.7",
|
||||
|
|
|
@ -8,8 +8,15 @@ Generated from TL layer **129** (last updated on 31.05.2021).
|
|||
|
||||
This package contains JSON schema, type declarations, binary (de-)serialization, errors, RSA keys and helper functions.
|
||||
|
||||
Package patch version is always TL schema layer number, so version `1.0.42` means that this version was generated from
|
||||
TL layer 42.
|
||||
Package's minor version is always TL schema layer number,
|
||||
so version `1.42.0` means that this version was generated from TL layer 42.
|
||||
|
||||
> ⚠️ **Warning**: Always use strict or tilde constraint to ensure
|
||||
> the same schema is used.
|
||||
>
|
||||
> I.e. use `"@mtcute/tl": "~1.42.0"` or `"@mtcute/tl": "1.42.0"`
|
||||
> instead of `"@mtcute/tl": "^1.42.0"`, since the former would also
|
||||
> match `1.43.0, 1.44.0, ...` and will probably break your build or runtime
|
||||
|
||||
- JSON schema, types, binary (de-)serialization and helper functions are generated directly from `.tl` files that are
|
||||
automatically fetched from [TDesktop repository](https://github.com/telegramdesktop/tdesktop/).
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@mtcute/tl",
|
||||
"version": "0.0.0",
|
||||
"version": "1.129.0",
|
||||
"description": "TL schema used for MTCute",
|
||||
"main": "index.js",
|
||||
"author": "Alisa Sireneva <me@tei.su>",
|
||||
|
@ -16,7 +16,7 @@
|
|||
"big-integer": "^1.6.48"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mtcute/core": "^0.0.0",
|
||||
"@mtcute/core": "^1.0.0",
|
||||
"cheerio": "^1.0.0-rc.5",
|
||||
"eager-async-pool": "^1.0.0",
|
||||
"csv-parser": "^3.0.0",
|
||||
|
|
|
@ -1,19 +1,156 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const glob = require('glob')
|
||||
const cp = require('child_process')
|
||||
const rimraf = require('rimraf')
|
||||
|
||||
function publishSinglePackage(name) {
|
||||
let dir = path.join(__dirname, '../packages', name)
|
||||
|
||||
if (name !== 'tl') {
|
||||
// tl package is already generated ready to publish
|
||||
|
||||
console.log('[i] Building %s', name)
|
||||
// cleanup dist folder
|
||||
rimraf.sync(path.join(dir, 'dist'))
|
||||
|
||||
if (name === 'tl') {
|
||||
// create package by copying all the needed files
|
||||
const files = [
|
||||
'binary/reader.d.ts',
|
||||
'binary/reader.js',
|
||||
'binary/rsa-keys.d.ts',
|
||||
'binary/rsa-keys.js',
|
||||
'binary/writer.d.ts',
|
||||
'binary/writer.js',
|
||||
'errors.d.ts',
|
||||
'errors.js',
|
||||
'index.d.ts',
|
||||
'index.js',
|
||||
'raw-errors.json',
|
||||
'raw-schema.d.ts',
|
||||
'raw-schema.json',
|
||||
'package.json',
|
||||
'README.md',
|
||||
]
|
||||
|
||||
fs.mkdirSync(path.join(dir, 'dist/binary'), { recursive: true })
|
||||
|
||||
for (const f of files) {
|
||||
fs.copyFileSync(path.join(dir, f), path.join(dir, 'dist', f))
|
||||
}
|
||||
} else {
|
||||
// build ts
|
||||
cp.execSync('yarn run build', {
|
||||
cp.execSync(
|
||||
'yarn run ' + (name === 'crypto-node' ? 'build-ts' : 'build'),
|
||||
{
|
||||
cwd: dir,
|
||||
stdio: 'inherit',
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
// remove reference comments
|
||||
for (const f of glob.sync(path.join(dir, 'dist/**/*.d.ts'))) {
|
||||
let content = fs.readFileSync(f, 'utf8')
|
||||
let changed = false
|
||||
|
||||
if (content.indexOf('/// <reference types="node" />') !== -1) {
|
||||
changed = true
|
||||
content = content.replace('/// <reference types="node" />', '')
|
||||
}
|
||||
|
||||
if (content.match(/@mtcute\/[a-z]+\/src/)) {
|
||||
changed = true
|
||||
content = content.replace(/(@mtcute\/[a-z]+)\/src/g, '$1')
|
||||
}
|
||||
|
||||
if (content.trim().match(/^export {};?$/)) {
|
||||
// no public exports, we can safely remove this module
|
||||
changed = false
|
||||
fs.unlinkSync(f)
|
||||
}
|
||||
|
||||
if (changed) fs.writeFileSync(f, content)
|
||||
}
|
||||
|
||||
// replace /src/ imports
|
||||
for (const f of glob.sync(path.join(dir, 'dist/**/*.js'))) {
|
||||
let content = fs.readFileSync(f, 'utf8')
|
||||
let changed = false
|
||||
|
||||
if (content.match(/@mtcute\/[a-z]+\/src/)) {
|
||||
changed = true
|
||||
content = content.replace(/(@mtcute\/[a-z]+)\/src/g, '$1')
|
||||
}
|
||||
|
||||
if (changed) fs.writeFileSync(f, content)
|
||||
}
|
||||
|
||||
if (name === 'client') {
|
||||
// make TelegramClient a class, not an interface
|
||||
const content = fs.readFileSync(
|
||||
path.join(dir, 'dist/client.d.ts'),
|
||||
'utf8'
|
||||
)
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(dir, 'dist/client.d.ts'),
|
||||
content.replace(
|
||||
'export interface TelegramClient',
|
||||
'export class TelegramClient'
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
if (name === 'crypto-node') {
|
||||
// copy native sources and binding.gyp file
|
||||
|
||||
fs.mkdirSync(path.join(dir, 'dist/lib'), { recursive: true })
|
||||
fs.mkdirSync(path.join(dir, 'dist/crypto'), { recursive: true })
|
||||
|
||||
const bindingGyp = fs.readFileSync(
|
||||
path.join(dir, 'binding.gyp'),
|
||||
'utf8'
|
||||
)
|
||||
fs.writeFileSync(
|
||||
path.join(dir, 'dist/binding.gyp'),
|
||||
bindingGyp
|
||||
// replace paths to crypto
|
||||
.replace(/"\.\.\/crypto/g, '"crypto')
|
||||
)
|
||||
|
||||
for (const f of fs.readdirSync(path.join(dir, 'lib'))) {
|
||||
const content = fs.readFileSync(
|
||||
path.join(dir, 'lib', f),
|
||||
'utf8'
|
||||
)
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(dir, 'dist/lib', f),
|
||||
content
|
||||
// replace paths to crypto
|
||||
.replace(
|
||||
/#include "\.\.\/\.\.\/crypto/g,
|
||||
'#include "../crypto'
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
for (const f of fs.readdirSync(path.join(dir, '../crypto'))) {
|
||||
fs.copyFileSync(
|
||||
path.join(dir, '../crypto', f),
|
||||
path.join(dir, 'dist/crypto', f)
|
||||
)
|
||||
}
|
||||
|
||||
const nativeJs = fs.readFileSync(
|
||||
path.join(dir, 'dist/native.js'),
|
||||
'utf8'
|
||||
)
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(dir, 'dist/native.js'),
|
||||
nativeJs.replace(/'\.\.\/build/g, "'./build")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// copy package.json, replacing private with false
|
||||
const packJson = JSON.parse(
|
||||
|
@ -31,6 +168,16 @@ function publishSinglePackage(name) {
|
|||
JSON.stringify(packJson, null, 4)
|
||||
)
|
||||
|
||||
// copy tsconfig
|
||||
try {
|
||||
fs.copyFileSync(
|
||||
path.join(__dirname, '../tsconfig.json'),
|
||||
path.join(dir, 'dist/tsconfig.json')
|
||||
)
|
||||
} catch (e) {
|
||||
if (e.code !== 'ENOENT') throw e
|
||||
}
|
||||
|
||||
// copy readme
|
||||
try {
|
||||
fs.copyFileSync(
|
||||
|
@ -42,20 +189,17 @@ function publishSinglePackage(name) {
|
|||
}
|
||||
|
||||
dir = path.join(dir, 'dist')
|
||||
}
|
||||
|
||||
console.log('[i] Publishing %s', name)
|
||||
|
||||
// publish to npm
|
||||
// cp.execSync('npm publish', {
|
||||
// cwd: ,
|
||||
// })
|
||||
cp.execSync('yarn publish', {
|
||||
cwd: dir,
|
||||
stdio: 'inherit',
|
||||
})
|
||||
}
|
||||
|
||||
const LOCAL = [
|
||||
'crypto',
|
||||
'tl-reference'
|
||||
]
|
||||
const LOCAL = ['crypto']
|
||||
|
||||
if (require.main === module) {
|
||||
const arg = process.argv[2]
|
||||
|
@ -65,7 +209,7 @@ if (require.main === module) {
|
|||
}
|
||||
|
||||
if (arg === 'all') {
|
||||
for (const f of fs.readdirSync(path.join('../packages'))) {
|
||||
for (const f of fs.readdirSync(path.join(__dirname, '../packages'))) {
|
||||
if (LOCAL.indexOf(f) > -1) continue
|
||||
|
||||
publishSinglePackage(f)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { convertTlToJson } = require('../../tl/scripts/generate-schema')
|
||||
const { convertTlToJson } = require('../../packages/tl/scripts/generate-schema')
|
||||
const fetch = require('node-fetch')
|
||||
const qs = require('querystring')
|
||||
const { convertToArrays } = require('./prepare-data')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const {
|
||||
convertTlToJson,
|
||||
convertJsonToTl,
|
||||
} = require('../../tl/scripts/generate-schema')
|
||||
} = require('../../packages/tl/scripts/generate-schema')
|
||||
const fetch = require('node-fetch')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
|
30
yarn.lock
30
yarn.lock
|
@ -1115,6 +1115,11 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd"
|
||||
integrity sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==
|
||||
|
||||
"@types/events@^3.0.0":
|
||||
version "3.0.0"
|
||||
resolved "http://localhost:4873/@types%2fevents/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
|
||||
integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==
|
||||
|
||||
"@types/integer@*":
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/integer/-/integer-4.0.0.tgz#3b778715df72d2cf8ba73bad27bd9d830907f944"
|
||||
|
@ -1152,6 +1157,11 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.22.tgz#0d29f382472c4ccf3bd96ff0ce47daf5b7b84b18"
|
||||
integrity sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw==
|
||||
|
||||
"@types/node@^15.12.1":
|
||||
version "15.12.1"
|
||||
resolved "http://localhost:4873/@types%2fnode/-/node-15.12.1.tgz#9b60797dee1895383a725f828a869c86c6caa5c2"
|
||||
integrity sha512-zyxJM8I1c9q5sRMtVF+zdd13Jt6RU4r4qfhTd7lQubyThvLfx6yYekWSQjGCGV2Tkecgxnlpl/DNlb6Hg+dmEw==
|
||||
|
||||
"@types/normalize-package-data@^2.4.0":
|
||||
version "2.4.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
|
||||
|
@ -1635,14 +1645,6 @@ buffer@^5.5.0:
|
|||
base64-js "^1.3.1"
|
||||
ieee754 "^1.1.13"
|
||||
|
||||
buffer@^6.0.3:
|
||||
version "6.0.3"
|
||||
resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
|
||||
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
|
||||
dependencies:
|
||||
base64-js "^1.3.1"
|
||||
ieee754 "^1.2.1"
|
||||
|
||||
builtins@^1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/builtins/-/builtins-1.0.3.tgz#cb94faeb61c8696451db36534e1422f94f0aee88"
|
||||
|
@ -3086,6 +3088,18 @@ glob@7.1.6, glob@^7.0.0, glob@^7.1.1, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6:
|
|||
once "^1.3.0"
|
||||
path-is-absolute "^1.0.0"
|
||||
|
||||
glob@^7.1.7:
|
||||
version "7.1.7"
|
||||
resolved "http://localhost:4873/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90"
|
||||
integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==
|
||||
dependencies:
|
||||
fs.realpath "^1.0.0"
|
||||
inflight "^1.0.4"
|
||||
inherits "2"
|
||||
minimatch "^3.0.4"
|
||||
once "^1.3.0"
|
||||
path-is-absolute "^1.0.0"
|
||||
|
||||
globals@^11.1.0:
|
||||
version "11.12.0"
|
||||
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
|
||||
|
|
Loading…
Reference in a new issue