snapshot of https://github.com/tldraw/tldraw.git (main, 2026-09-23; blobs > 131072B omitted)
Some checks failed
Deploy analytics worker / Deploy analytics worker to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
i18n upload strings / Upload latest strings (push) Failing after 1s
Deploy bemo / Deploy bemo to ${{ (github.ref == 'refs/heads/bemo-production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
Deploy grafana resources / ${{ github.event_name == 'push' && 'Deploy grafana resources' || 'Validate grafana resources (dry run)' }} (push) Failing after 0s
End to end tests (dotcom) / Check for relevant changes (push) Failing after 0s
End to end tests (examples) / Check for relevant changes (push) Failing after 0s
End to end tests (mermaid readability) / Check for relevant changes (push) Failing after 1s
End to end tests (perf) / Check for relevant changes (push) Failing after 0s
Publish editor extensions / Publish editor extensions (push) Failing after 1s
Publish SDK packages / Remove the publish-packages label (push) Has been skipped
Checks / Tests & checks (push) Has been cancelled
Checks / Build all projects (push) Has been cancelled
Deploy templates / Deploy templates (push) Has been cancelled
End to end tests (dotcom) / End to end tests (dotcom) (push) Has been cancelled
End to end tests (mermaid readability) / End to end tests (mermaid readability) (push) Has been cancelled
End to end tests (perf) / End to end tests (perf) (push) Has been cancelled
Deploy .com / Deploy dotcom to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Has been cancelled
End to end tests (examples) / End to end tests (examples) (push) Has been cancelled
Publish SDK packages / Publish SDK packages (push) Has been cancelled
Publish SDK packages / Tell user released version (push) Has been cancelled
Publish SDK packages / Publishes code templates to separate repositories (push) Has been cancelled
Publish SDK packages / Deploys the template demos with the new SDK version (push) Has been cancelled

This commit is contained in:
upstream-mirror
2026-09-23 16:12:52 +05:00
commit a774ac673a
4541 changed files with 770499 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
import { existsSync, readFileSync } from 'fs'
import { readFile, writeFile as writeFileUnchecked } from 'fs/promises'
import { dirname, join, relative } from 'path'
import { fileURLToPath } from 'url'
import json5 from 'json5'
import { format } from 'oxfmt'
import { nicelog } from './nicelog'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
export const REPO_ROOT = join(__dirname, '../../..')
const _rootPackageJsonPath = join(REPO_ROOT, 'package.json')
if (!existsSync(_rootPackageJsonPath)) {
throw new Error('expected to find package.json in REPO_ROOT')
}
const _rootPackageJson = JSON.parse(readFileSync(_rootPackageJsonPath, 'utf8'))
if (_rootPackageJson['name'] !== '@tldraw/monorepo') {
throw new Error('expected to find @tldraw/monorepo in REPO_ROOT package.json')
}
export async function readJsonIfExists(file: string) {
const fileContents = await readFileIfExists(file)
if (fileContents === null) {
return null
}
return json5.parse(fileContents)
}
export async function readFileIfExists(file: string) {
try {
return await readFile(file, 'utf8')
} catch {
return null
}
}
const oxfmtConfig = json5.parse(readFileSync(join(REPO_ROOT, '.oxfmtrc.json'), 'utf8'))
export async function writeCodeFile(
generator: string | null,
language: 'typescript' | 'javascript',
filePath: string,
code: string
) {
const source = generator
? `
// This file is automatically generated by ${generator}.
// Do not edit manually. Or do, I'm a comment, not a cop.
${code}
`
: code
const ext = language === 'typescript' ? 'ts' : 'js'
const result = await format(`file.${ext}`, source, oxfmtConfig)
await writeStringFile(filePath, result.code)
}
export async function writeStringFile(filePath: string, contents: string) {
await writeFile(filePath, Buffer.from(contents, 'utf-8'))
}
export async function writeFile(filePath: string, contents: Buffer) {
if (process.env.CI && !process.env.ALLOW_REFRESH_ASSETS_CHANGES) {
let existingContents: Buffer | null = null
try {
existingContents = await readFile(filePath)
} catch {
// Ignore
}
if (existingContents && !existingContents.equals(contents)) {
nicelog(
`Asset file ${relative(
REPO_ROOT,
filePath
)} has changed. Please run this script again and commit the changes.`
)
nicelog('Contents before:')
nicelog(existingContents.toString('utf-8'))
nicelog('\nContents after:')
nicelog(contents.toString('utf-8'))
process.exit(1)
}
}
await writeFileUnchecked(filePath, contents, 'utf-8')
}
export async function writeJsonFile(filePath: string, contents: unknown) {
await writeStringFile(filePath, JSON.stringify(contents, null, '\t') + '\n')
}