Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mobile セットアップ #243

Merged
merged 8 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/mobile-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: mobile / check

on:
push:
paths:
- "mobile/**"
- ".github/workflows/mobile-check.yml"

defaults:
run:
working-directory: ./mobile

jobs:
biome:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Biome
uses: biomejs/setup-biome@v2
with:
version: "1.9.2"
- name: Run Biome
run: biome ci .

tsc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('./bun.lockb') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: bun install --frozen-lockfile
- run: bun run typecheck

# unit-test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: oven-sh/setup-bun@v2
# with:
# bun-version: latest
# - name: Cache node_modules
# id: cache-node-modules
# uses: actions/cache@v4
# with:
# path: node_modules
# key: ${{ runner.os }}-node_modules-${{ hashFiles('./bun.lockb') }}
# - name: Install dependencies
# if: steps.cache-node-modules.outputs.cache-hit != 'true'
# run: bun install --frozen-lockfile
# - run: bun run test:unit

# db-test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: oven-sh/setup-bun@v2
# with:
# bun-version: latest
# - name: Cache node_modules
# id: cache-node-modules
# uses: actions/cache@v4
# with:
# path: node_modules
# key: ${{ runner.os }}-node_modules-${{ hashFiles('./bun.lockb') }}
# - name: Install dependencies
# if: steps.cache-node-modules.outputs.cache-hit != 'true'
# run: bun install --frozen-lockfile
# - run: bun run test:db
53 changes: 53 additions & 0 deletions .github/workflows/mobile-cloudflare-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: mobile / preview

on:
push:
branches:
- main
paths:
- "mobile/**"
- ".github/workflows/mobile-cloudflare-merge.yml"

defaults:
run:
working-directory: ./mobile

permissions:
contents: read
deployments: write

jobs:
build_and_deploy:
name: Deploy to Cloudflare Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('./bun.lockb') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: bun install --frozen-lockfile
- run: bun run build
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: cafeore-2024
directory: build/client
# Optional: Enable this if you want to have GitHub Deployments triggered
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
# Optional: Switch what branch you are publishing to.
# By default this will be the branch which triggered this workflow
# branch: main
# Optional: Change the working directory
workingDirectory: mobile
# Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta`
wranglerVersion: '3'
51 changes: 51 additions & 0 deletions .github/workflows/mobile-cloudflare-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: mobile / preview

on:
pull_request:
paths:
- "mobile/**"
- ".github/workflows/mobile-cloudflare-preview.yml"

defaults:
run:
working-directory: ./mobile

permissions:
contents: read
deployments: write

jobs:
build_and_deploy:
name: Deploy to Cloudflare Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('./bun.lockb') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: bun install --frozen-lockfile
- run: bun run build
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: cafeore-2024
directory: build/client
# Optional: Enable this if you want to have GitHub Deployments triggered
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
# Optional: Switch what branch you are publishing to.
# By default this will be the branch which triggered this workflow
# branch: main
# Optional: Change the working directory
workingDirectory: mobile
# Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta`
wranglerVersion: '3'
2 changes: 1 addition & 1 deletion .github/workflows/pos-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
paths:
- "pos/**"
- ".github/workflows/check.yml"
- ".github/workflows/pos-check.yml"

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pos-firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- main
paths:
- "pos/**"
- ".github/workflows/firebase-hosting-merge.yml"
- ".github/workflows/pos-firebase-hosting-merge.yml"

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pos-firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:
paths:
- "pos/**"
- ".github/workflows/firebase-hosting-pull-request.yml"
- ".github/workflows/pos-firebase-hosting-pull-request.yml"

defaults:
run:
Expand Down
Binary file modified bun.lockb
Binary file not shown.
8 changes: 8 additions & 0 deletions mobile/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules

/.cache
/build
.env
.dev.vars

.wrangler
47 changes: 47 additions & 0 deletions mobile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Welcome to Remix + Cloudflare!

- 📖 [Remix docs](https://remix.run/docs)
- 📖 [Remix Cloudflare docs](https://remix.run/guides/vite#cloudflare)

## Development

Run the dev server:

```sh
npm run dev
```

To run Wrangler:

```sh
npm run build
npm run start
```

## Typegen

Generate types for your Cloudflare bindings in `wrangler.toml`:

```sh
npm run typegen
```

You will need to rerun typegen whenever you make changes to `wrangler.toml`.

## Deployment

First, build your app for production:

```sh
npm run build
```

Then, deploy your app to Cloudflare Pages:

```sh
npm run deploy
```

## Styling

This template comes with [Tailwind CSS](https://tailwindcss.com/) already configured for a simple default starting experience. You can use whatever css framework you prefer. See the [Vite docs on css](https://vitejs.dev/guide/features.html#css) for more information.
18 changes: 18 additions & 0 deletions mobile/app/entry.client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* By default, Remix will handle hydrating your app on the client for you.
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
* For more information, see https://remix.run/file-conventions/entry.client
*/

import { RemixBrowser } from "@remix-run/react";
import { StrictMode, startTransition } from "react";
import { hydrateRoot } from "react-dom/client";

startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<RemixBrowser />
</StrictMode>,
);
});
44 changes: 44 additions & 0 deletions mobile/app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* By default, Remix will handle generating the HTTP Response for you.
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
* For more information, see https://remix.run/file-conventions/entry.server
*/

import type { AppLoadContext, EntryContext } from "@remix-run/cloudflare";
import { RemixServer } from "@remix-run/react";
import { isbot } from "isbot";
import { renderToReadableStream } from "react-dom/server";

export default async function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
// This is ignored so we can keep it in the template for visibility. Feel
// free to delete this parameter in your app if you're not using it!
// eslint-disable-next-line @typescript-eslint/no-unused-vars
loadContext: AppLoadContext,
) {
const body = await renderToReadableStream(
<RemixServer context={remixContext} url={request.url} />,
{
signal: request.signal,
onError(error: unknown) {
// Log streaming rendering errors from inside the shell
console.error(error);
// biome-ignore lint: lint/style/noParameterAssign
responseStatusCode = 500;
},
},
);

if (isbot(request.headers.get("user-agent") || "")) {
await body.allReady;
}

responseHeaders.set("Content-Type", "text/html");
return new Response(body, {
headers: responseHeaders,
status: responseStatusCode,
});
}
45 changes: 45 additions & 0 deletions mobile/app/root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { LinksFunction } from "@remix-run/cloudflare";
import {
Links,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from "@remix-run/react";

import "./tailwind.css";

export const links: LinksFunction = () => [
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
{
rel: "preconnect",
href: "https://fonts.gstatic.com",
crossOrigin: "anonymous",
},
{
rel: "stylesheet",
href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",
},
];

export function Layout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
</head>
<body>
{children}
<ScrollRestoration />
<Scripts />
</body>
</html>
);
}

export default function App() {
return <Outlet />;
}
Loading
Loading