Skip to content

Commit

Permalink
Dependency updates. ESLint and import sort order style changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kitschpatrol committed Sep 7, 2024
1 parent e50232d commit 45644d1
Show file tree
Hide file tree
Showing 19 changed files with 197 additions and 173 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"yargs": "^17.7.2"
},
"devDependencies": {
"@kitschpatrol/shared-config": "^4.7.2",
"@kitschpatrol/shared-config": "^4.7.5",
"@sindresorhus/slugify": "^2.2.1",
"@tldraw/assets": "2.4.6",
"@types/express": "^4.17.21",
Expand Down
286 changes: 156 additions & 130 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/build-cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import iifePlugin from './plugins/esbuild-plugin-iife'
import esbuild from 'esbuild'
import iifePlugin from './plugins/esbuild-plugin-iife'

await esbuild.build({
bundle: true,
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-lib.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import iifePlugin from './plugins/esbuild-plugin-iife'
import esbuild from 'esbuild'
import iifePlugin from './plugins/esbuild-plugin-iife'

await esbuild.build({
bundle: true,
Expand Down
1 change: 1 addition & 0 deletions scripts/plugins/esbuild-plugin-iife.extensions.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare module '*?iife' {
// eslint-disable-next-line @typescript-eslint/naming-convention
const content: string
export default content
}
8 changes: 4 additions & 4 deletions src/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node

import { version } from '../../package.json'
import { type TldrawOpenOptions, type TldrawOpenResult, tldrawOpen } from '../lib/tldraw-open'
import { type TldrawFormat, tldrawToImage } from '../lib/tldraw-to-image'
import log from '../lib/utilities/log'
import chalk from 'chalk'
import plur from 'plur'
import yargs from 'yargs'
import { hideBin } from 'yargs/helpers'
import { version } from '../../package.json'
import { tldrawOpen, type TldrawOpenOptions, type TldrawOpenResult } from '../lib/tldraw-open'
import { type TldrawFormat, tldrawToImage } from '../lib/tldraw-to-image'
import log from '../lib/utilities/log'

const yargsInstance = yargs(hideBin(process.argv))

Expand Down
4 changes: 2 additions & 2 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { type TldrawOpenOptions, type TldrawOpenResult, tldrawOpen } from './tldraw-open'
export { type TldrawFormat, type TldrawToImageOptions, tldrawToImage } from './tldraw-to-image'
export { tldrawOpen, type TldrawOpenOptions, type TldrawOpenResult } from './tldraw-open'
export { type TldrawFormat, tldrawToImage, type TldrawToImageOptions } from './tldraw-to-image'
export { tldrawToShareUrl } from './tldraw-to-share-url'
export { default as log } from './utilities/log'
6 changes: 2 additions & 4 deletions src/lib/local-tldraw-server.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import log from './utilities/log'
import express from 'express'
import getPort from 'get-port'
import { type Server } from 'node:http'
import { type AddressInfo } from 'node:net'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import log from './utilities/log'

export default class LocalTldrawServer {
private server?: Server

constructor(private readonly tldrData?: string) {
this.tldrData = tldrData
}
constructor(private readonly tldrData?: string) {}

close(): void {
if (!this.server) throw new Error('Server not started')
Expand Down
16 changes: 7 additions & 9 deletions src/lib/tldraw-controller.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Note special inline IIFE import, see ./plugins/esbuild-plugin-iife.ts
import getImageInlineScript from './inline/get-image?iife'
import getTldrInlineScript from './inline/get-tldr?iife'
import setTldrInlineScript from './inline/set-tldr?iife'
import type { TldrawToImageOptions } from './tldraw-to-image'
import log from './utilities/log'
import type { Browser, Page } from 'puppeteer'
import slugify from '@sindresorhus/slugify'
import * as cheerio from 'cheerio'
import fs from 'node:fs/promises'
import path from 'node:path'
import puppeteer from 'puppeteer'
import type { Browser, Page } from 'puppeteer'
import { base64ToString, base64ToUint8Array, stringToBase64 } from 'uint8array-extras'
import untildify from 'untildify'
import type { TldrawToImageOptions } from './tldraw-to-image'
import getImageInlineScript from './inline/get-image?iife'
import getTldrInlineScript from './inline/get-tldr?iife'
import setTldrInlineScript from './inline/set-tldr?iife'
import log from './utilities/log'

type TlPage = {
frames: TlFrame[]
Expand All @@ -32,9 +32,7 @@ export default class TldrawController {
private isEmpty?: boolean
private browser?: Browser

constructor(private readonly href: string) {
this.href = href
}
constructor(private readonly href: string) {}

private get isLocal(): boolean {
return this.href.startsWith('http://localhost')
Expand Down
10 changes: 5 additions & 5 deletions src/lib/tldraw-open.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import LocalTldrawServer from './local-tldraw-server'
import { tldrawToImage } from './tldraw-to-image'
import { tldrawToShareUrl } from './tldraw-to-share-url'
import log from './utilities/log'
import { validatePathOrUrl } from './validation'
import { nanoid } from 'nanoid'
import { type ChildProcess } from 'node:child_process'
import fs from 'node:fs/promises'
import os from 'node:os'
import { URL } from 'node:url'
import open from 'open'
import LocalTldrawServer from './local-tldraw-server'
import { tldrawToImage } from './tldraw-to-image'
import { tldrawToShareUrl } from './tldraw-to-share-url'
import log from './utilities/log'
import { validatePathOrUrl } from './validation'

const tldrawOpenDefaultOptions = {
location: 'remote',
Expand Down
6 changes: 3 additions & 3 deletions src/lib/tldraw-to-image.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from 'node:fs/promises'
import path from 'node:path'
import prettyMilliseconds from 'pretty-ms'
import LocalTldrawServer from './local-tldraw-server'
import TldrawController from './tldraw-controller'
import log from './utilities/log'
import { validatePathOrUrl } from './validation'
import fs from 'node:fs/promises'
import path from 'node:path'
import prettyMilliseconds from 'pretty-ms'

// Essentially TLExportType + 'tldr'

Expand Down
1 change: 1 addition & 0 deletions src/lib/utilities/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import chalk from 'chalk'

const isNode = process?.versions?.node !== undefined

// eslint-disable-next-line @typescript-eslint/naming-convention
const log = {
verbose: false,

Expand Down
2 changes: 1 addition & 1 deletion src/lib/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function validatePathOrUrl(
validFileExtensions?: string[]
validHostnames?: string[]
} = {},
): URL | string {
): string | URL {
const { requireFileExistence, validFileExtensions, validHostnames } = options

if (URL.canParse(pathOrUrl)) {
Expand Down
6 changes: 3 additions & 3 deletions src/tldraw/app.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import './index.css'
/* eslint-disable @typescript-eslint/naming-convention */
import { getAssetUrls } from '@tldraw/assets/selfHosted'
import { useState } from 'react'
import { type Editor, type TLStore, Tldraw, parseTldrawJsonFile } from 'tldraw'
import { type Editor, parseTldrawJsonFile, Tldraw, type TLStore } from 'tldraw'
import './index.css'

// Can't get this to work
// import { getAssetUrlsByImport } from '@tldraw/assets/imports'
Expand Down Expand Up @@ -50,7 +50,7 @@ export default function App() {
console.error(`Couldn't parse tldr file: ${String(parseFileResult.error.type)}`)
}
})
.catch((error) => {
.catch((error: unknown) => {
console.error("Couldn't fetch data:", error)
})
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/tldraw/main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention */
import App from './app.tsx'
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './app.tsx'

ReactDOM.createRoot(document.querySelector('#root')!).render(
<React.StrictMode>
Expand Down
4 changes: 2 additions & 2 deletions test/api-stability.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { tldrawToImage, tldrawToShareUrl } from '../dist/lib'
import { expectFileToExist } from './utilities/file'
import fs from 'node:fs/promises'
import { describe, expect, it, vi } from 'vitest'
import { tldrawToImage, tldrawToShareUrl } from '../dist/lib'
import { expectFileToExist } from './utilities/file'

const cleanUp = true

Expand Down
6 changes: 3 additions & 3 deletions test/tldr-to-image.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Note this tests the dist build, because of the IIFE inlining from esbuild
import { log, tldrawToImage } from '../dist/lib'
import { expectFileToBeValid, getStyleElementCount } from './utilities/file'
import { expectSingleLine } from './utilities/string'
import { nanoid } from 'nanoid'
import { mkdirSync, rmSync } from 'node:fs'
import fs from 'node:fs/promises'
import os from 'node:os'
import path from 'node:path'
import stripAnsi from 'strip-ansi'
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
import { log, tldrawToImage } from '../dist/lib'
import { expectFileToBeValid, getStyleElementCount } from './utilities/file'
import { expectSingleLine } from './utilities/string'

const cleanUp = true
const tldrTestFilePath = './test/assets/valid/2024-01-test-sketch-basic.tldr'
Expand Down
4 changes: 2 additions & 2 deletions test/url-to-image.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Note this tests the dist build, because of the iife inlining from esbuild
import { tldrawToImage } from '../dist/lib'
import { expectFileToBeValid } from './utilities/file'
import { nanoid } from 'nanoid'
import { mkdirSync, rmSync } from 'node:fs'
import { expect, it } from 'vitest'
import { tldrawToImage } from '../dist/lib'
import { expectFileToBeValid } from './utilities/file'

const cleanUp = true
const tldrawTestUrl = 'https://www.tldraw.com/s/v2_c_9nMYBwT8UQ99RGDWfGr8H'
Expand Down
2 changes: 1 addition & 1 deletion test/validation.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Note this tests the src implementation, because it's not exported
import { validatePathOrUrl } from '../src/lib/validation'
import { expect, it } from 'vitest'
import { validatePathOrUrl } from '../src/lib/validation'

const validationOptions = {
requireFileExistence: true,
Expand Down

0 comments on commit 45644d1

Please sign in to comment.