Skip to content

Commit 5736ff5

Browse files
authored
Merge pull request #501 from narumincho/dev-dev
デスクトップアプリなど
2 parents 819d199 + cf5a93b commit 5736ff5

28 files changed

+2616
-1005
lines changed

.github/workflows/desktop_build.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# https://minerva.mamansoft.net/Notes/GitHub+Actions%E3%81%A7Rust%E3%82%92cross+compile%E3%83%93%E3%83%AB%E3%83%89 を参考にした
2+
name: Desktop Build
3+
4+
on: workflow_dispatch
5+
6+
jobs:
7+
build:
8+
name: Release binary
9+
strategy:
10+
matrix:
11+
include:
12+
- os: ubuntu-latest
13+
target: x86_64-unknown-linux-gnu
14+
artifact_name: hibou
15+
asset_name: hibou-x86_64-unknown-linux-gnu
16+
- os: ubuntu-latest
17+
target: x86_64-unknown-linux-musl
18+
artifact_name: hibou
19+
asset_name: hibou-x86_64-unknown-linux-musl
20+
- os: windows-latest
21+
target: x86_64-pc-windows-msvc
22+
artifact_name: hibou.exe
23+
asset_name: hibou-x86_64-pc-windows-msvc
24+
- os: macos-latest
25+
target: x86_64-apple-darwin
26+
artifact_name: hibou
27+
asset_name: hibou-x86_64-apple-darwin
28+
29+
runs-on: ${{ matrix.os }}
30+
31+
steps:
32+
- uses: actions/checkout@v2
33+
- run: cd ./desktop
34+
- uses: actions-rs/toolchain@v1
35+
with:
36+
toolchain: stable
37+
override: true
38+
39+
- uses: Swatinem/rust-cache@v1
40+
41+
- name: Build
42+
uses: actions-rs/cargo@v1
43+
with:
44+
use-cross: true
45+
command: build
46+
args: --release --target ${{ matrix.target }} --all-features --verbose
47+
- name: Upload binaries to release
48+
uses: svenstaro/upload-release-action@2.1.1
49+
with:
50+
repo_token: ${{ secrets.GITHUB_TOKEN }}
51+
file: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
52+
asset_name: ${{ matrix.asset_name }}
53+
tag: ${{ github.ref }}
54+
overwrite: true

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ tsconfig.tsbuildinfo
2323
/.vercel/
2424

2525
.vercel
26-
/databaseSetupSecret.ts
26+
/databaseMigrationSecret.ts
27+
target/

client/hook/useDefinyApp.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as d from "../../localData";
22
import * as indexedDB from "../indexedDB";
3+
import * as zodType from "../../common/zodType";
34
import { AddMessage, useNotification } from "./useNotification";
45
import { ReactElement, useCallback, useEffect, useMemo, useState } from "react";
56
import type { TypePartIdAndMessage } from "../../core/TypePartIdAndMessage";
@@ -398,7 +399,7 @@ export const useDefinyApp = (): UseDefinyAppResult => {
398399
}
399400
verifyingAccountTokenAndGetAccount(
400401
setLogInState,
401-
accountToken,
402+
accountToken as unknown as d.AccountToken,
402403
accountDict.setLoaded,
403404
addMessage
404405
);
@@ -764,7 +765,7 @@ const verifyingAccountTokenAndGetAccount = (
764765
setLogInState(d.LogInState.Guest);
765766
return;
766767
}
767-
indexedDB.setAccountToken(accountToken);
768+
indexedDB.setAccountToken(accountToken as unknown as zodType.AccountToken);
768769
addMessage({
769770
text: `「${response.value.value.name}」としてログインしました`,
770771
type: "success",
@@ -794,7 +795,9 @@ const verifyingAccountTokenAndGetAccountFromCodeAndState = (
794795
setLogInState(d.LogInState.Guest);
795796
return;
796797
}
797-
indexedDB.setAccountToken(response.value.value.accountToken);
798+
indexedDB.setAccountToken(
799+
response.value.value.accountToken as unknown as zodType.AccountToken
800+
);
798801
addMessage({
799802
text: `「${response.value.value.account.name}」としてログインしました`,
800803
type: "success",

client/ui/Button.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ export const Button = React.memo(
2525
},
2626
font: "inherit",
2727
borderRadius: 16,
28+
"&:disabled": {
29+
cursor: "not-allowed",
30+
backgroundColor: "#000",
31+
borderRadius: 0,
32+
},
2833
},
2934
props.style
3035
)}

client/ui/OneLineTextEditor.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ export const OneLineTextEditor: React.FC<{
4444
onChange: ((value: string) => void) | undefined;
4545
id: string;
4646
style?: CSSObject | undefined;
47+
placeholder?: string | undefined;
4748
}> = React.memo((props) => (
4849
<input
4950
type="text"
5051
value={props.value}
52+
placeholder={props.placeholder}
5153
className={css(
5254
{
5355
padding: 8,

common/url.ts

+6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ const zodTypeLocationToPathList = (location: zodType.Location): string => {
6161
return "/create-account";
6262
case "local-project":
6363
return "/local-project";
64+
case "create-project":
65+
return "/create-project";
66+
case "setting":
67+
return "/setting";
68+
case "dev":
69+
return "dev";
6470
}
6571
};
6672

common/zodType.ts

+13-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ export const Location = z.union([
1010
}),
1111
z.object({ type: z.literal("create-account") }),
1212
z.object({ type: z.literal("local-project") }),
13+
z.object({ type: z.literal("create-project") }),
14+
z.object({ type: z.literal("setting") }),
15+
z.object({ type: z.literal("dev") }),
1316
]);
1417

1518
export type Location = Readonly<z.TypeOf<typeof Location>>;
@@ -20,21 +23,21 @@ export type Language = z.TypeOf<typeof Language>;
2023

2124
export const defaultLanguage: Language = "english";
2225

23-
export const PreAccountToken = z
24-
.string()
25-
.length(64) as unknown as z.Schema<PreAccountToken>;
26+
export const PreAccountToken = z.string().length(64).brand<"PreAccountToken">();
2627

27-
export type PreAccountToken = string & { _preAccountToken: never };
28+
export type PreAccountToken = z.TypeOf<typeof PreAccountToken>;
2829

29-
export const AccountToken = z
30-
.string()
31-
.length(64) as unknown as z.Schema<AccountToken>;
30+
export const AccountToken = z.string().length(64).brand<"AccountToken">();
3231

33-
export type AccountToken = string & { _accountToken: never };
32+
export type AccountToken = z.TypeOf<typeof AccountToken>;
3433

35-
export const AccountId = z.bigint() as unknown as z.Schema<AccountId>;
34+
export const AccountId = z.string().min(1).brand<"AccountId">();
3635

37-
export type AccountId = bigint & { _accountId: never };
36+
export type AccountId = z.TypeOf<typeof AccountId>;
37+
38+
export const ProjectId = z.string().min(1).brand<"ProjectId">();
39+
40+
export type ProjectId = z.TypeOf<typeof ProjectId>;
3841

3942
export const LogInByCodeAndStatePayload = z.union([
4043
z.object({ type: z.literal("notGeneratedState") }),

components/Header.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as React from "react";
22
import * as zodType from "../common/zodType";
3-
import { Image } from "./Image";
43
import { Link } from "./Link";
54
import { UseAccountTokenResult } from "../hooks/useAccountToken";
65
import type { UseDefinyAppResult } from "../client/hook/useDefinyApp";
@@ -129,16 +128,17 @@ const SettingLink: React.FC<{
129128
}}
130129
language={props.language}
131130
// 後に設定に変更する
132-
location={{ type: "home" }}
131+
location={{ type: "setting" }}
133132
>
133+
{/* eslint-disable-next-line @next/next/no-img-element */}
134134
<img
135135
css={{
136136
width: 32,
137137
height: 32,
138138
borderRadius: "50%",
139139
}}
140140
alt="設定"
141-
src=""
141+
src={account?.data?.imageUrl}
142142
/>
143143
<div>{account?.data?.name ?? "..."}</div>
144144
</Link>

components/ProjectCard.tsx

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as React from "react";
2+
import { ProjectId } from "../common/zodType";
3+
import { trpc } from "../hooks/trpc";
4+
5+
export const ProjectCard = (props: {
6+
readonly projectId: ProjectId;
7+
}): React.ReactElement => {
8+
const project = trpc.useQuery(["getProjectById", props.projectId]);
9+
switch (project.status) {
10+
case "error":
11+
return <div>error...</div>;
12+
case "idle":
13+
return <div>....</div>;
14+
case "loading":
15+
return <div>..</div>;
16+
case "success":
17+
return <div>{project.data?.name}</div>;
18+
}
19+
};

databaseMigration.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { getFaunaClient, migration } from "./functions/faunadb-interface";
2+
import { faunaServerKey } from "./databaseMigrationSecret";
3+
4+
/**
5+
* tsconfig.json の `exclude` から `databaseMigration.ts` を外して実行する必要あり
6+
*/
7+
export const main = async (): Promise<void> => {
8+
await migration(getFaunaClient(faunaServerKey));
9+
console.log("マイグレーション完了!");
10+
};
11+
12+
main();

databaseSetup.ts

-8
This file was deleted.

0 commit comments

Comments
 (0)