test(e2e-deno): populate packages from upstream
This commit is contained in:
parent
a2cdc73735
commit
b1b79e2ab1
12 changed files with 107 additions and 46 deletions
|
@ -69,7 +69,7 @@ case "$method" in
|
|||
if [ -d .jsr-data ]; then
|
||||
# clean up data from previous runs
|
||||
docker compose down
|
||||
rm -rf .jsr-data
|
||||
sudo rm -rf .jsr-data
|
||||
fi
|
||||
mkdir .jsr-data
|
||||
./cli.sh start
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
"devDependencies": {
|
||||
"@commitlint/cli": "17.6.5",
|
||||
"@commitlint/config-conventional": "17.6.5",
|
||||
"@teidesu/slow-types-compiler": "1.0.2",
|
||||
"@teidesu/slow-types-compiler": "1.1.0",
|
||||
"@types/node": "20.10.0",
|
||||
"@types/ws": "8.5.4",
|
||||
"@typescript-eslint/eslint-plugin": "6.4.0",
|
||||
|
|
|
@ -1 +1,12 @@
|
|||
module.exports = () => ({ buildCjs: false })
|
||||
module.exports = ({ outDir, fs, jsr }) => ({
|
||||
buildCjs: false,
|
||||
final() {
|
||||
if (jsr) {
|
||||
// jsr doesn't support symlinks, so we need to copy the files manually
|
||||
const real = fs.realpathSync(`${outDir}/common-internals-web`)
|
||||
fs.unlinkSync(`${outDir}/common-internals-web`)
|
||||
// console.log(real)
|
||||
fs.cpSync(real, `${outDir}/common-internals-web`, { recursive: true })
|
||||
}
|
||||
},
|
||||
})
|
||||
|
|
|
@ -87,7 +87,8 @@ export class TelegramClient extends TelegramClientBase {
|
|||
this._rl = createInterface({
|
||||
// eslint-disable-next-line
|
||||
input: Readable.fromWeb(Deno.stdin.readable as any),
|
||||
output: Writable.fromWeb(Deno.stdout.writable),
|
||||
// eslint-disable-next-line
|
||||
output: Writable.fromWeb(Deno.stdout.writable as any),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* eslint-disable no-restricted-globals */
|
||||
import { Buffer } from 'node:buffer'
|
||||
import { createCipheriv, createHash, createHmac, pbkdf2 } from 'node:crypto'
|
||||
import { deflateSync, gunzipSync } from 'node:zlib'
|
||||
|
||||
import { BaseCryptoProvider, IAesCtr, ICryptoProvider, IEncryptionScheme } from '@mtcute/core/utils.js'
|
||||
import { getWasmUrl, ige256Decrypt, ige256Encrypt, initSync } from '@mtcute/wasm'
|
||||
|
||||
// node:crypto is properly implemented in deno, so we can just use it
|
||||
// largely just copy-pasting from @mtcute/node
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import EventEmitter from 'events'
|
||||
import EventEmitter from 'node:events'
|
||||
|
||||
import { IntermediatePacketCodec, IPacketCodec, ITelegramTransport, MtcuteError, TransportState } from '@mtcute/core'
|
||||
import { BasicDcOption, ICryptoProvider, Logger } from '@mtcute/core/utils.js'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/// <reference lib="WebWorker" />
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||
import { setPlatform } from '@mtcute/core/platform.js'
|
||||
import {
|
||||
ClientMessageHandler,
|
||||
|
@ -19,6 +20,10 @@ export type { TelegramWorkerOptions, TelegramWorkerPortOptions, WorkerCustomMeth
|
|||
|
||||
let _registered = false
|
||||
|
||||
// thanks deno for this awesome lack of typings
|
||||
declare const WorkerGlobalScope: any
|
||||
declare const self: any
|
||||
|
||||
export class TelegramWorker<T extends WorkerCustomMethods> extends TelegramWorkerBase<T> {
|
||||
registerWorker(handler: WorkerMessageHandler): RespondFn {
|
||||
if (_registered) {
|
||||
|
@ -31,7 +36,7 @@ export class TelegramWorker<T extends WorkerCustomMethods> extends TelegramWorke
|
|||
const respond: RespondFn = self.postMessage.bind(self)
|
||||
|
||||
// eslint-disable-next-line
|
||||
self.addEventListener('message', (message) => handler((message as any).data, respond))
|
||||
self.addEventListener('message', (message: any) => handler(message.data, respond))
|
||||
|
||||
return respond
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference lib="dom" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
import { BaseStorageDriver, MtUnsupportedError } from '@mtcute/core'
|
||||
|
||||
import { txToPromise } from './utils.js'
|
||||
|
@ -117,7 +115,8 @@ export class IdbStorageDriver extends BaseStorageDriver {
|
|||
db.createObjectStore(`${REPO_VERSION_PREFIX}${repo}:${targetVer}`)
|
||||
}
|
||||
|
||||
for (const key of db.objectStoreNames) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
for (const key of db.objectStoreNames as any as string[]) {
|
||||
if (!key.startsWith(REPO_VERSION_PREFIX)) continue
|
||||
const [, repo, version] = key.split(':')
|
||||
|
||||
|
@ -144,7 +143,7 @@ export class IdbStorageDriver extends BaseStorageDriver {
|
|||
this._pendingWrites = []
|
||||
this._pendingWritesOses = new Set()
|
||||
|
||||
const tx = this.db.transaction(oses, 'readwrite')
|
||||
const tx = this.db.transaction([...oses], 'readwrite')
|
||||
|
||||
const osMap = new Map<string, IDBObjectStore>()
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/// <reference lib="dom" />
|
||||
/// <reference lib="webworker" />
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { setPlatform } from '@mtcute/core/platform.js'
|
||||
import {
|
||||
ClientMessageHandler,
|
||||
|
@ -20,6 +19,11 @@ export type { TelegramWorkerOptions, TelegramWorkerPortOptions, WorkerCustomMeth
|
|||
|
||||
let _registered = false
|
||||
|
||||
// thanks deno for this awesome lack of typings
|
||||
declare const WorkerGlobalScope: any
|
||||
declare const SharedWorkerGlobalScope: any
|
||||
declare const self: any
|
||||
|
||||
export class TelegramWorker<T extends WorkerCustomMethods> extends TelegramWorkerBase<T> {
|
||||
registerWorker(handler: WorkerMessageHandler): RespondFn {
|
||||
if (_registered) {
|
||||
|
@ -37,7 +41,7 @@ export class TelegramWorker<T extends WorkerCustomMethods> extends TelegramWorke
|
|||
}
|
||||
}
|
||||
|
||||
self.onconnect = (event) => {
|
||||
self.onconnect = (event: MessageEvent) => {
|
||||
const port = event.ports[0]
|
||||
connections.push(port)
|
||||
|
||||
|
@ -93,7 +97,7 @@ export class TelegramWorker<T extends WorkerCustomMethods> extends TelegramWorke
|
|||
const respond: RespondFn = self.postMessage.bind(self)
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||
self.addEventListener('message', (message) => handler(message.data, respond))
|
||||
self.addEventListener('message', (message: MessageEvent) => handler(message.data, respond))
|
||||
|
||||
return respond
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ importers:
|
|||
specifier: 17.6.5
|
||||
version: 17.6.5
|
||||
'@teidesu/slow-types-compiler':
|
||||
specifier: 1.0.2
|
||||
version: 1.0.2(typescript@5.4.3)
|
||||
specifier: 1.1.0
|
||||
version: 1.1.0(typescript@5.4.3)
|
||||
'@types/node':
|
||||
specifier: 20.10.0
|
||||
version: 20.10.0
|
||||
|
@ -1467,8 +1467,8 @@ packages:
|
|||
/@sinclair/typebox@0.27.8:
|
||||
resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==}
|
||||
|
||||
/@teidesu/slow-types-compiler@1.0.2(typescript@5.4.3):
|
||||
resolution: {integrity: sha512-N0e3J/My4t405V5qD2kr6xXwLMlaB+el7bdYKLXJ2yyrLN1eAx4elf6qkeRTF4xy0GoiWrS0gKS0RZfddSOw1w==}
|
||||
/@teidesu/slow-types-compiler@1.1.0(typescript@5.4.3):
|
||||
resolution: {integrity: sha512-+WUHSKh56B32Jk5aJgXf07E2EOkMX1yilvgKLKBCJPFAJZ4xeo1U5aDu3wwHX3lrFl7AiVGXUP+FfuHy8X43BA==}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
typescript: ^5.0.0
|
||||
|
@ -1476,6 +1476,7 @@ packages:
|
|||
arg: 5.0.2
|
||||
dedent: 1.5.3
|
||||
eager-async-pool: 1.0.0
|
||||
glob: 10.3.12
|
||||
gunzip-maybe: 1.4.2
|
||||
semver: 7.6.0
|
||||
tar-stream: 3.1.7
|
||||
|
@ -3739,6 +3740,18 @@ packages:
|
|||
path-scurry: 1.10.1
|
||||
dev: true
|
||||
|
||||
/glob@10.3.12:
|
||||
resolution: {integrity: sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg==}
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
foreground-child: 3.1.1
|
||||
jackspeak: 2.3.6
|
||||
minimatch: 9.0.3
|
||||
minipass: 7.0.4
|
||||
path-scurry: 1.10.2
|
||||
dev: true
|
||||
|
||||
/glob@7.2.0:
|
||||
resolution: {integrity: sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==}
|
||||
dependencies:
|
||||
|
@ -4607,6 +4620,11 @@ packages:
|
|||
get-func-name: 2.0.2
|
||||
dev: true
|
||||
|
||||
/lru-cache@10.2.2:
|
||||
resolution: {integrity: sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==}
|
||||
engines: {node: 14 || >=16.14}
|
||||
dev: true
|
||||
|
||||
/lru-cache@6.0.0:
|
||||
resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}
|
||||
engines: {node: '>=10'}
|
||||
|
@ -4852,6 +4870,11 @@ packages:
|
|||
resolution: {integrity: sha512-MzWSV5nYVT7mVyWCwn2o7JH13w2TBRmmSqSRCKzTw+lmft9X4z+3wjvs06Tzijo5z4W/kahUCDpRXTF+ZrmF/w==}
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
|
||||
/minipass@7.0.4:
|
||||
resolution: {integrity: sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==}
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
dev: true
|
||||
|
||||
/minizlib@2.1.2:
|
||||
resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==}
|
||||
engines: {node: '>= 8'}
|
||||
|
@ -5303,6 +5326,14 @@ packages:
|
|||
lru-cache: 9.1.2
|
||||
minipass: 6.0.2
|
||||
|
||||
/path-scurry@1.10.2:
|
||||
resolution: {integrity: sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA==}
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
dependencies:
|
||||
lru-cache: 10.2.2
|
||||
minipass: 7.0.4
|
||||
dev: true
|
||||
|
||||
/path-type@4.0.0:
|
||||
resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==}
|
||||
engines: {node: '>=8'}
|
||||
|
|
|
@ -433,6 +433,8 @@ if (buildConfig.buildTs && !IS_JSR) {
|
|||
|
||||
for (const [name, decl_] of Object.entries(nodeSpecificApis)) {
|
||||
if (fileContent.includes(name)) {
|
||||
if (name === 'Buffer' && fileContent.includes('node:buffer')) continue
|
||||
|
||||
changed = true
|
||||
const isType = Array.isArray(decl_) && decl_[0] === 'type'
|
||||
const decl = isType ? decl_[1] : decl_
|
||||
|
@ -547,6 +549,34 @@ if (IS_JSR) {
|
|||
),
|
||||
)
|
||||
|
||||
if (process.env.E2E) {
|
||||
// populate dependencies, if any
|
||||
const depsToPopulate = []
|
||||
|
||||
for (const dep of Object.values(importMap)) {
|
||||
if (!dep.startsWith('jsr:')) continue
|
||||
if (dep.startsWith('jsr:@mtcute/')) continue
|
||||
depsToPopulate.push(dep.slice(4))
|
||||
}
|
||||
|
||||
if (depsToPopulate.length) {
|
||||
console.log('[i] Populating %d dependencies...', depsToPopulate.length)
|
||||
cp.spawnSync('pnpm', [
|
||||
'exec',
|
||||
'slow-types-compiler',
|
||||
'populate',
|
||||
'--downstream',
|
||||
process.env.JSR_URL,
|
||||
'--token',
|
||||
process.env.JSR_TOKEN,
|
||||
'--unstable-create-via-api',
|
||||
...depsToPopulate,
|
||||
], {
|
||||
stdio: 'inherit',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
console.log('[i] Processing with slow-types-compiler...')
|
||||
const project = stc.createProject()
|
||||
stc.processPackage(project, denoJson)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const cp = require('child_process')
|
||||
const stc = require('@teidesu/slow-types-compiler')
|
||||
|
||||
const IS_JSR = process.env.JSR === '1'
|
||||
const MAIN_REGISTRY = IS_JSR ? 'http://jsr.test/' : 'https://registry.npmjs.org'
|
||||
|
@ -54,30 +55,6 @@ async function checkVersion(name, version) {
|
|||
return fetchRetry(url).then((r) => r.status === 200)
|
||||
}
|
||||
|
||||
async function jsrMaybeCreatePackage(name) {
|
||||
// check if the package even exists
|
||||
const packageMeta = await fetchRetry(`${REGISTRY}api/scopes/mtcute/packages/${name}`)
|
||||
|
||||
if (packageMeta.status === 404) {
|
||||
console.error('[i] %s does not exist, creating..', name)
|
||||
|
||||
const create = await fetchRetry(`${REGISTRY}api/scopes/mtcute/packages`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Cookie: `token=${process.env.JSR_TOKEN}`,
|
||||
},
|
||||
body: JSON.stringify({ package: name }),
|
||||
})
|
||||
|
||||
if (create.status !== 200) {
|
||||
throw new Error(`Failed to create package: ${create.statusText} ${await create.text()}`)
|
||||
}
|
||||
} else if (packageMeta.status !== 200) {
|
||||
throw new Error(`Failed to check package: ${packageMeta.statusText} ${await packageMeta.text()}`)
|
||||
}
|
||||
}
|
||||
|
||||
async function publishSinglePackage(name) {
|
||||
let packageDir = path.join(__dirname, '../packages', name)
|
||||
|
||||
|
@ -110,7 +87,11 @@ async function publishSinglePackage(name) {
|
|||
return
|
||||
}
|
||||
} else if (IS_JSR && process.env.JSR_TOKEN) {
|
||||
await jsrMaybeCreatePackage(name)
|
||||
await stc.jsrMaybeCreatePackage({
|
||||
name: `@mtcute/${name}`,
|
||||
token: process.env.JSR_TOKEN,
|
||||
registry: REGISTRY,
|
||||
})
|
||||
}
|
||||
|
||||
if (IS_JSR) {
|
||||
|
@ -157,7 +138,6 @@ function listPackages() {
|
|||
.map((d) => d.slice(8))
|
||||
}
|
||||
|
||||
const stc = require('@teidesu/slow-types-compiler')
|
||||
packages = stc.determinePublishOrder(map)
|
||||
console.log('[i] Publishing order:', packages.join(', '))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue