Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
yoshikouki authored Aug 30, 2024
0 parents commit b0a906c
Showing 45 changed files with 2,844 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions"
# Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'daily'
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Continuous Integration

on:
pull_request:
push:
branches:
- main

jobs:
ci-web:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: bun install

- name: Run Lint and Format
run: bun lint

- name: Run tests
run: bun test

- name: Run build
run: bun run build
28 changes: 28 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'Dependabot: Update bun.lockb'

on:
pull_request:
paths:
- "package.json"

permissions:
contents: write

jobs:
update-bun-lockb:
name: "Update bun.lockb"
if: github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- uses: oven-sh/setup-bun@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- run: |
bun install
git add bun.lockb
git config --global user.name 'dependabot[bot]'
git config --global user.email 'dependabot[bot]@users.noreply.github.com'
git commit --amend --no-edit
git push --force
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["biomejs.biome"]
}
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "biomejs.biome",
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit",
"source.organizeImports.biome": "explicit"
},
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"workbench.editor.customLabels.patterns": {
"**/{index,page,actions,hooks,components,utils,types,functions}.{js,ts,jsx,tsx,mjs,mts}": "${dirname}/${filename}"
},
"cSpell.words": []
}
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# honon

Template for Next.js + Hono

## Getting Started

First, run the development server:

```bash
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
87 changes: 87 additions & 0 deletions bin/generate-logo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// biome-ignore lint/style/useNodejsImportProtocol: <explanation>
import { parseArgs } from "util";
import { renderLogoSVG } from "@/app/logo.svg/logo";
import sharp from "sharp";

const DEFAULT_CONFIG = {
DEFAULT_INPUT: "./public/logo.webp",
DEFAULT_OUTPUT: "./public/logo.webp",
DEFAULT_QUALITY: 80,
};

const parseArguments = () => {
const {
values: { input, output, quality, ...optionalArguments },
} = parseArgs({
args: Bun.argv,
options: {
input: {
type: "string",
short: "i",
default: DEFAULT_CONFIG.DEFAULT_INPUT,
},
output: {
type: "string",
short: "o",
default: DEFAULT_CONFIG.DEFAULT_OUTPUT,
},
quality: {
type: "string",
short: "q",
default: DEFAULT_CONFIG.DEFAULT_QUALITY.toString(),
},
debug: {
type: "boolean",
default: false,
},
},
strict: true,
allowPositionals: true,
});
if (!(input && output && quality)) {
throw new Error("No logo path provided.");
}
return {
input,
output,
quality: Number.parseInt(quality, 10),
...optionalArguments,
};
};

const confirmOverwrite = async (filePath: string): Promise<boolean> => {
console.log(`🆙 File already exists: ${filePath}`, 33); // Yellow
process.stdout.write("Are you sure you want to overwrite? (y/n): ");
for await (const line of console) {
if (line.toLowerCase().trim() === "y") {
return true;
}
return false;
}
return false;
};

const convertToWebP = async (string: string, quality: number) => {
const { data: buffer, info } = await sharp(Buffer.from(string))
.webp({ quality })
.toBuffer({ resolveWithObject: true });
return { buffer, info };
};

const main = async () => {
const { output: outputPath, quality } = parseArguments();

const svgString = await renderLogoSVG();
const file = Bun.file(outputPath, { type: "text/xml" });
if ((await file.exists()) && !(await confirmOverwrite(outputPath))) {
console.log("Logo file not written.");
return;
}

const { buffer, info } = await convertToWebP(svgString, quality);
Bun.write(file, buffer);
console.log(`✅ Logo file written to ${outputPath}.`);
console.log(info);
};

main();
39 changes: 39 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"organizeImports": {
"enabled": true
},
"formatter": {
"indentStyle": "space",
"ignore": []
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"nursery": { "useSortedClasses": "warn" },
"correctness": {
"noUnusedImports": "warn",
"noUnusedVariables": "warn"
}
}
},
"css": {
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true
},
"parser": {
"cssModules": true
}
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
}
}
Binary file added bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[test]
17 changes: 17 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/app/globals.css",
"baseColor": "stone",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
9 changes: 9 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
reactCompiler: true,
ppr: true,
},
};

export default nextConfig;
41 changes: 41 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "honon",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "bun --bun x next dev --turbo",
"build": "bun --bun x next build",
"start": "bun --bun x next start",
"lint": "bunx @biomejs/biome check .",
"format": "bunx @biomejs/biome check --write .",
"format:unsafe": "bunx @biomejs/biome check --write --unsafe .",
"update:all": "bun update --latest"
},
"dependencies": {
"@radix-ui/react-slot": "^1.1.0",
"babel-plugin-react-compiler": "^0.0.0-experimental-e68eda9-20240829",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"hono": "^4.5.9",
"lucide-react": "^0.436.0",
"next": "^15.0.0-rc.0",
"next-auth": "^5.0.0-beta.20",
"next-themes": "^0.3.0",
"react": "^19.0.0-rc-a19a8ab4-20240829",
"react-dom": "^19.0.0-rc-a19a8ab4-20240829",
"satori": "^0.10.14",
"swr": "^2.2.5",
"tailwind-merge": "^2.5.2",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@types/bun": "^1.1.8",
"@types/node": "^22.5.1",
"@types/react": "npm:types-react@^19.0.0-alpha.3",
"@types/react-dom": "npm:types-react-dom@^19.0.0-alpha.3",
"postcss": "^8.4.41",
"tailwindcss": "^3.4.10",
"typescript": "^5.5.4"
}
}
8 changes: 8 additions & 0 deletions postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
tailwindcss: {},
},
};

export default config;
Binary file added public/fonts/Inter-Black.ttf
Binary file not shown.
Binary file added public/icon-192x192.webp
Binary file not shown.
Binary file added public/icon-512x512.webp
Binary file not shown.
Binary file added public/logo-no-padding.webp
Binary file not shown.
Binary file added public/logo.webp
Binary file not shown.
19 changes: 19 additions & 0 deletions src/app/api/[[...route]]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { app as server } from "@/server";
import { Hono } from "hono";
import { handle } from "hono/vercel";

const app = new Hono().basePath("/api");

app.route("/", server);

export const GET = handle(app);
export const POST = handle(app);
export const PUT = handle(app);
export const PATCH = handle(app);
export const DELETE = handle(app);
export const HEAD = handle(app);
export const OPTIONS = handle(app);

// Build error: Attempt to export a nullable value for "TextDecoderStream"
// ref: https://github.com/oven-sh/bun/issues/5648
// export const runtime = "edge";
22 changes: 22 additions & 0 deletions src/app/client-component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use client";

import { client } from "@/server/client";
import useSWR from "swr";

export const ClientComponent = () => {
const request = client.time;
const { data, isLoading, error } = useSWR(
request.$url().pathname,
async () => {
const res = await request.$get();
return await res.json();
},
);

if (isLoading) return <div>Loading...</div>;
if (error) {
return <div className="text-2xl tabular-nums">Error</div>;
}

return <div className="text-2xl tabular-nums">C: {data?.message}</div>;
};
Binary file added src/app/favicon.ico
Binary file not shown.
Loading

0 comments on commit b0a906c

Please sign in to comment.