Skip to content

Commit

Permalink
Merge pull request #501 from narumincho/dev-dev
Browse files Browse the repository at this point in the history
デスクトップアプリなど
  • Loading branch information
narumincho authored Sep 7, 2022
2 parents 819d199 + cf5a93b commit 5736ff5
Show file tree
Hide file tree
Showing 28 changed files with 2,616 additions and 1,005 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/desktop_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# https://minerva.mamansoft.net/Notes/GitHub+Actions%E3%81%A7Rust%E3%82%92cross+compile%E3%83%93%E3%83%AB%E3%83%89 を参考にした
name: Desktop Build

on: workflow_dispatch

jobs:
build:
name: Release binary
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: hibou
asset_name: hibou-x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: hibou
asset_name: hibou-x86_64-unknown-linux-musl
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: hibou.exe
asset_name: hibou-x86_64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: hibou
asset_name: hibou-x86_64-apple-darwin

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- run: cd ./desktop
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- uses: Swatinem/rust-cache@v1

- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target ${{ matrix.target }} --all-features --verbose
- name: Upload binaries to release
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
tag: ${{ github.ref }}
overwrite: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ tsconfig.tsbuildinfo
/.vercel/

.vercel
/databaseSetupSecret.ts
/databaseMigrationSecret.ts
target/
9 changes: 6 additions & 3 deletions client/hook/useDefinyApp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as d from "../../localData";
import * as indexedDB from "../indexedDB";
import * as zodType from "../../common/zodType";
import { AddMessage, useNotification } from "./useNotification";
import { ReactElement, useCallback, useEffect, useMemo, useState } from "react";
import type { TypePartIdAndMessage } from "../../core/TypePartIdAndMessage";
Expand Down Expand Up @@ -398,7 +399,7 @@ export const useDefinyApp = (): UseDefinyAppResult => {
}
verifyingAccountTokenAndGetAccount(
setLogInState,
accountToken,
accountToken as unknown as d.AccountToken,
accountDict.setLoaded,
addMessage
);
Expand Down Expand Up @@ -764,7 +765,7 @@ const verifyingAccountTokenAndGetAccount = (
setLogInState(d.LogInState.Guest);
return;
}
indexedDB.setAccountToken(accountToken);
indexedDB.setAccountToken(accountToken as unknown as zodType.AccountToken);
addMessage({
text: `「${response.value.value.name}」としてログインしました`,
type: "success",
Expand Down Expand Up @@ -794,7 +795,9 @@ const verifyingAccountTokenAndGetAccountFromCodeAndState = (
setLogInState(d.LogInState.Guest);
return;
}
indexedDB.setAccountToken(response.value.value.accountToken);
indexedDB.setAccountToken(
response.value.value.accountToken as unknown as zodType.AccountToken
);
addMessage({
text: `「${response.value.value.account.name}」としてログインしました`,
type: "success",
Expand Down
5 changes: 5 additions & 0 deletions client/ui/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export const Button = React.memo(
},
font: "inherit",
borderRadius: 16,
"&:disabled": {
cursor: "not-allowed",
backgroundColor: "#000",
borderRadius: 0,
},
},
props.style
)}
Expand Down
2 changes: 2 additions & 0 deletions client/ui/OneLineTextEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ export const OneLineTextEditor: React.FC<{
onChange: ((value: string) => void) | undefined;
id: string;
style?: CSSObject | undefined;
placeholder?: string | undefined;
}> = React.memo((props) => (
<input
type="text"
value={props.value}
placeholder={props.placeholder}
className={css(
{
padding: 8,
Expand Down
6 changes: 6 additions & 0 deletions common/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ const zodTypeLocationToPathList = (location: zodType.Location): string => {
return "/create-account";
case "local-project":
return "/local-project";
case "create-project":
return "/create-project";
case "setting":
return "/setting";
case "dev":
return "dev";
}
};

Expand Down
23 changes: 13 additions & 10 deletions common/zodType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export const Location = z.union([
}),
z.object({ type: z.literal("create-account") }),
z.object({ type: z.literal("local-project") }),
z.object({ type: z.literal("create-project") }),
z.object({ type: z.literal("setting") }),
z.object({ type: z.literal("dev") }),
]);

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

export const defaultLanguage: Language = "english";

export const PreAccountToken = z
.string()
.length(64) as unknown as z.Schema<PreAccountToken>;
export const PreAccountToken = z.string().length(64).brand<"PreAccountToken">();

export type PreAccountToken = string & { _preAccountToken: never };
export type PreAccountToken = z.TypeOf<typeof PreAccountToken>;

export const AccountToken = z
.string()
.length(64) as unknown as z.Schema<AccountToken>;
export const AccountToken = z.string().length(64).brand<"AccountToken">();

export type AccountToken = string & { _accountToken: never };
export type AccountToken = z.TypeOf<typeof AccountToken>;

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

export type AccountId = bigint & { _accountId: never };
export type AccountId = z.TypeOf<typeof AccountId>;

export const ProjectId = z.string().min(1).brand<"ProjectId">();

export type ProjectId = z.TypeOf<typeof ProjectId>;

export const LogInByCodeAndStatePayload = z.union([
z.object({ type: z.literal("notGeneratedState") }),
Expand Down
6 changes: 3 additions & 3 deletions components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from "react";
import * as zodType from "../common/zodType";
import { Image } from "./Image";
import { Link } from "./Link";
import { UseAccountTokenResult } from "../hooks/useAccountToken";
import type { UseDefinyAppResult } from "../client/hook/useDefinyApp";
Expand Down Expand Up @@ -129,16 +128,17 @@ const SettingLink: React.FC<{
}}
language={props.language}
// 後に設定に変更する
location={{ type: "home" }}
location={{ type: "setting" }}
>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
css={{
width: 32,
height: 32,
borderRadius: "50%",
}}
alt="設定"
src=""
src={account?.data?.imageUrl}
/>
<div>{account?.data?.name ?? "..."}</div>
</Link>
Expand Down
19 changes: 19 additions & 0 deletions components/ProjectCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as React from "react";
import { ProjectId } from "../common/zodType";
import { trpc } from "../hooks/trpc";

export const ProjectCard = (props: {
readonly projectId: ProjectId;
}): React.ReactElement => {
const project = trpc.useQuery(["getProjectById", props.projectId]);
switch (project.status) {
case "error":
return <div>error...</div>;
case "idle":
return <div>....</div>;
case "loading":
return <div>..</div>;
case "success":
return <div>{project.data?.name}</div>;
}
};
12 changes: 12 additions & 0 deletions databaseMigration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { getFaunaClient, migration } from "./functions/faunadb-interface";
import { faunaServerKey } from "./databaseMigrationSecret";

/**
* tsconfig.json の `exclude` から `databaseMigration.ts` を外して実行する必要あり
*/
export const main = async (): Promise<void> => {
await migration(getFaunaClient(faunaServerKey));
console.log("マイグレーション完了!");
};

main();
8 changes: 0 additions & 8 deletions databaseSetup.ts

This file was deleted.

Loading

1 comment on commit 5736ff5

@vercel
Copy link

@vercel vercel bot commented on 5736ff5 Sep 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

definy – ./

definy.vercel.app
definy-narumincho.vercel.app
definy-git-main-narumincho.vercel.app

Please sign in to comment.