Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm authored and github-actions[bot] committed Feb 7, 2024
1 parent 1ec43a9 commit 1762ec4
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 77 deletions.
48 changes: 24 additions & 24 deletions example/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@
/** @jsxImportSource hono/jsx */
/** @jsxFrag */

import { Button, Framework } from "@wevm/framework";
import { Button, Framework } from '@wevm/framework'

const app = new Framework();
const app = new Framework()

app.frame("/", ({ untrustedData }) => {
const { buttonIndex } = untrustedData || {};
app.frame('/', ({ untrustedData }) => {
const { buttonIndex } = untrustedData || {}
return {
image: (
<div
style={{
backgroundColor: "black",
backgroundSize: "150px 150px",
height: "100%",
width: "100%",
display: "flex",
textAlign: "center",
alignItems: "center",
justifyContent: "center",
flexDirection: "column",
flexWrap: "nowrap",
backgroundColor: 'black',
backgroundSize: '150px 150px',
height: '100%',
width: '100%',
display: 'flex',
textAlign: 'center',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
flexWrap: 'nowrap',
}}
>
<div
style={{
fontSize: 60,
fontStyle: "normal",
letterSpacing: "-0.025em",
color: "white",
fontStyle: 'normal',
letterSpacing: '-0.025em',
color: 'white',
marginTop: 30,
padding: "0 120px",
padding: '0 120px',
lineHeight: 1.4,
whiteSpace: "pre-wrap",
whiteSpace: 'pre-wrap',
}}
>
{typeof buttonIndex === "number"
{typeof buttonIndex === 'number'
? `Button Index: ${buttonIndex}`
: "Welcome!"}
: 'Welcome!'}
</div>
</div>
),
Expand All @@ -48,10 +48,10 @@ app.frame("/", ({ untrustedData }) => {
<Button>Oranges</Button>
</>
),
};
});
}
})

export default {
port: 3001,
fetch: app.fetch,
};
}
96 changes: 48 additions & 48 deletions scripts/preconstruct.ts
Original file line number Diff line number Diff line change
@@ -1,93 +1,93 @@
import fs from "node:fs/promises";
import path from "node:path";
import { glob } from "glob";
import fs from 'node:fs/promises'
import path from 'node:path'
import { glob } from 'glob'

// Symlinks package sources to dist for local development

console.log("Setting up packages for development.");
console.log('Setting up packages for development.')

// Get all package.json files
const packagePaths = await glob("**/package.json", {
ignore: ["**/dist/**", "**/node_modules/**"],
});
const packagePaths = await glob('**/package.json', {
ignore: ['**/dist/**', '**/node_modules/**'],
})

let count = 0;
let count = 0
for (const packagePath of packagePaths) {
type Package = {
bin?: Record<string, string> | undefined;
bin?: Record<string, string> | undefined
exports?:
| Record<string, { types: string; default: string } | string>
| undefined;
name?: string | undefined;
private?: boolean | undefined;
};
const file = Bun.file(packagePath);
const packageJson = (await file.json()) as Package;
| undefined
name?: string | undefined
private?: boolean | undefined
}
const file = Bun.file(packagePath)
const packageJson = (await file.json()) as Package

// Skip private packages
if (packageJson.private) continue;
if (!packageJson.exports) continue;
if (packageJson.private) continue
if (!packageJson.exports) continue

count += 1;
console.log(`${packageJson.name}${path.dirname(packagePath)}`);
count += 1
console.log(`${packageJson.name}${path.dirname(packagePath)}`)

const dir = path.resolve(path.dirname(packagePath));
const dir = path.resolve(path.dirname(packagePath))

// Empty dist directory
const distDirName = "_lib";
const dist = path.resolve(dir, distDirName);
let files: string[] = [];
const distDirName = '_lib'
const dist = path.resolve(dir, distDirName)
let files: string[] = []
try {
files = await fs.readdir(dist);
files = await fs.readdir(dist)
} catch {
await fs.mkdir(dist);
await fs.mkdir(dist)
}

const promises: Promise<void>[] = [];
const promises: Promise<void>[] = []
for (const file of files) {
promises.push(
fs.rm(path.join(dist, file), { recursive: true, force: true }),
);
)
}
await Promise.all(promises);
await Promise.all(promises)

// Link exports to dist locations
for (const [key, exports] of Object.entries(packageJson.exports)) {
// Skip `package.json` exports
if (/package\.json$/.test(key)) continue;
if (/package\.json$/.test(key)) continue

let entries: string[][];
if (typeof exports === "string")
let entries: string[][]
if (typeof exports === 'string')
entries = [
["default", exports],
["types", exports.replace(".js", ".d.ts")],
];
else entries = Object.entries(exports);
['default', exports],
['types', exports.replace('.js', '.d.ts')],
]
else entries = Object.entries(exports)

// Link exports to dist locations
for (const [, value] of entries as [
type: "types" | "default",
type: 'types' | 'default',
value: string,
][]) {
const srcDir = path.resolve(
dir,
path.dirname(value).replace(distDirName, ""),
);
let srcFileName: string;
if (key === ".") srcFileName = "index.tsx";
else srcFileName = path.basename(`${key}.tsx`);
const srcFilePath = path.resolve(srcDir, srcFileName);
path.dirname(value).replace(distDirName, ''),
)
let srcFileName: string
if (key === '.') srcFileName = 'index.tsx'
else srcFileName = path.basename(`${key}.tsx`)
const srcFilePath = path.resolve(srcDir, srcFileName)

const distDir = path.resolve(dir, path.dirname(value));
const distFileName = path.basename(value);
const distFilePath = path.resolve(distDir, distFileName);
const distDir = path.resolve(dir, path.dirname(value))
const distFileName = path.basename(value)
const distFilePath = path.resolve(distDir, distFileName)

await fs.mkdir(distDir, { recursive: true });
await fs.mkdir(distDir, { recursive: true })

// Symlink src to dist file
await fs.symlink(srcFilePath, distFilePath, "file");
await fs.symlink(srcFilePath, distFilePath, 'file')
}
}
}

console.log(`Done. Set up ${count} ${count === 1 ? "package" : "packages"}.`);
console.log(`Done. Set up ${count} ${count === 1 ? 'package' : 'packages'}.`)
8 changes: 4 additions & 4 deletions src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from "vitest";
import { expect, test } from 'vitest'

test("default", () => {
expect(true).toBe(true);
});
test('default', () => {
expect(true).toBe(true)
})
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Window } from 'happy-dom'
import { type Context, Hono } from 'hono'
import { ImageResponse } from 'hono-og'
import { type JSXNode } from 'hono/jsx'
import { Window } from 'happy-dom'
import { jsxRenderer } from 'hono/jsx-renderer'

import {
Expand Down

0 comments on commit 1762ec4

Please sign in to comment.