Skip to content

Commit

Permalink
Merge pull request #62 from tktcorporation/dev
Browse files Browse the repository at this point in the history
dev
  • Loading branch information
tktcorporation committed Feb 4, 2024
2 parents 4ff7169 + 1c6859f commit 83295f4
Show file tree
Hide file tree
Showing 25 changed files with 548 additions and 128 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ yarn-error.log*
# dev debug
debug/photos/**/*.html
debug/photos/**/VRChat*wrld*
debug/photos/**/VRChat_*x*.png
debug/photos/**/*.txt

# local env files
Expand Down
48 changes: 17 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,31 @@
# 作業計画
## α
* [x] log file の取得
* log file dir を指定できる
* log file dir から files を読み取って world id と timestamp を取り出す
* [x] ボタンクリックで指定したフォルダ内に固定のファイルを生成できるように
* [x] VRChat の写真 dir を取得できるように
* [x] 指定した dir にファイル生成
* [x] 月ごとに仕分けしてファイル生成できるように
* [x] package アップグレード
* [x] unused export を怒る lint
* UI と導線整備
* [ ] わかりやすいオンボーディング
* E2E テスト

## β
* [x] VRChatLog のライフサイクルを調べる
* ログはいつ消えるの?
* 定期実行できるようにする

## やらなくてもいいかも
* 今日はどこで何枚写真を撮った、を出す?


# 動作確認済み開発環境
* GitHub Codespaces

# Installation
## Development
* install all dependencies
```bash
$ yarn
```

Clone this repo and install all dependencies
`yarn` or `npm install`
* generate files for local debug
```bash
$ yarn setup:debug
```

## Development
start development server
```bash
$ yarn dev
```

`yarn dev` or `npm run dev`
* Codespaces を利用している場合
* `port 6080` をブラウザで開き、password `vscode` を入力することで仮想ウィンドウが立ち上がる

* `port 6080` をブラウザで開き、password `vscode` を入力することで仮想ウィンドウが立ち上がる
### Note
* electron background 側の hotreload が効かないのでつらみ

## Build

`yarn build` or `npm run build`
`yarn build`

## Publish

Expand Down
52 changes: 52 additions & 0 deletions debug/cleanDevFiles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# スクリプトがエラーに遭遇した場合に終了し、未定義の変数を参照した場合にも終了
set -eu

# 引数の解析
skip_confirmation=false
while getopts "y" opt; do
case $opt in
y)
skip_confirmation=true
;;
\?)
echo "無効なオプション: -$OPTARG" >&2
exit 1
;;
esac
done

# スクリプトのディレクトリを取得
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"

delete_file_path="$script_dir/photos"
delete_file_names=(
# このツールで作成するJoin記録用の画像ファイル
"VRChat*wrld*.png"
# VRChatで写真を撮ったときに作成される画像ファイル
# (開発環境では `genDevFiles.sh` で作成する`)
"VRChat_*x*.png"
)

# まず対象の確認
for delete_file_name in "${delete_file_names[@]}"; do
find $delete_file_path -name $delete_file_name
done

# 確認
# -y がついていた場合は確認をスキップ
if [ "$skip_confirmation" = false ]; then
read -p "削除しますか? [y/N]: " yn
case "$yn" in
[yY]*) ;;
*) echo "終了します" ; exit 1 ;;
esac
fi

# 削除
for delete_file_name in "${delete_file_names[@]}"; do
find $delete_file_path -name $delete_file_name -delete
done

echo "削除しました"
45 changes: 45 additions & 0 deletions debug/genDevFiles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# スクリプトがエラーに遭遇した場合に終了し、未定義の変数を参照した場合にも終了
set -eu

# スクリプトのディレクトリを取得
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"

# コピー元のファイル(スクリプトの場所からの相対パス)
source_file="$script_dir/VRChat_2023-10-01_03-01-18.551_2560x1440_sample.png"

# コピー先のファイル名の配列(スクリプトの場所からの相対パス)
destination_files=(
"./debug/photos/VRChat/2023-10/VRChat_2023-10-08_08-21-44.163_2560x1440.png"
"./debug/photos/VRChat/2023-10/VRChat_2023-10-08_01-19-50.163_2560x1440.png"
"./debug/photos/VRChat/2023-10/VRChat_2023-10-08_01-01-18.551_2560x1440.png"
"./debug/photos/VRChat/2023-10/VRChat_2023-10-08_08-21-47.163_2560x1440.png"
"./debug/photos/VRChat/2023-10/VRChat_2023-10-08_08-21-45.163_2560x1440.png"
"./debug/photos/VRChat/2023-10/VRChat_2023-10-08_01-22-50.163_2560x1440.png"
"./debug/photos/VRChat/2023-10/VRChat_2023-10-08_08-21-41.163_2560x1440.png"
"./debug/photos/VRChat/2023-10/VRChat_2023-10-08_02-01-18.551_2560x1440.png"
"./debug/photos/VRChat/2023-10/VRChat_2023-10-08_00-01-18.551_2560x1440.png"
"./debug/photos/VRChat/2023-10/VRChat_2023-10-01_03-01-18.551_2560x1440.png"
"./debug/photos/VRChat/2023-10/VRChat_2023-10-08_08-21-46.163_2560x1440.png"
"./debug/photos/VRChat/2023-10/VRChat_2023-10-08_08-21-40.163_2560x1440.png"
"./debug/photos/VRChat/2023-10/VRChat_2023-10-08_01-21-50.163_2560x1440.png"
"./debug/photos/VRChat/2023-10/VRChat_2023-10-08_08-21-43.163_2560x1440.png"
"./debug/photos/VRChat/2023-10/VRChat_2023-10-08_08-21-42.163_2560x1440.png"
"./debug/photos/VRChat/2023-11/VRChat_2023-11-08_15-11-42.163_2560x1440.png"
"./debug/photos/VRChat/2023-11/VRChat_2023-11-08_15-12-11.163_2560x1440.png"
)

# 各ファイルにコピー
for dest_file in "${destination_files[@]}"
do
# ファイルが既に存在する場合はスキップ
if [ ! -f "$dest_file" ]; then
cp "$source_file" "$dest_file"
echo "File $dest_file created."
else
echo "File $dest_file already exists, skipping."
fi
done


Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
39 changes: 39 additions & 0 deletions electron/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { EventEmitter } from 'events';
import { initTRPC } from '@trpc/server';
import { observable } from '@trpc/server/observable';
import { stackWithCauses } from 'pony-cause';
import superjson from 'superjson';
import z from 'zod';

// 呼び出し元は集約したい
Expand All @@ -15,6 +16,7 @@ const ee = new EventEmitter();

const t = initTRPC.create({
isServer: true,
transformer: superjson,
});

const logError = (err: Error | string) => {
Expand Down Expand Up @@ -323,6 +325,43 @@ export const router = t.router({
},
);
}),
getVRChatJoinInfoWithVRChatPhotoList: procedure
.input(z.object({ year: z.string(), month: z.string() }))
.query(async (ctx) => {
const result = await service.getVRChatJoinInfoWithVRChatPhotoList({
getVRChatPhotoWithWorldIdAndDate:
service.getVRChatPhotoWithWorldIdAndDate,
})({
year: ctx.input.year,
month: ctx.input.month,
});
const response: {
data: null | ExtractDataTypeFromResult<typeof result>;
error: null | {
code: string;
message: string;
};
} = {
data: null,
error: null,
};
return result.match(
(r) => {
response.data = r;
return response;
},
(error) => {
logError(error);
return {
data: null,
error: {
code: error.name,
message: `写真の読み込みに失敗しました: ${error.message}`,
},
};
},
);
}),
getVRChatPhotoItemData: procedure.input(z.string()).query(async (ctx) => {
const result = await service.getVRChatPhotoItemData(ctx.input);
return result.match(
Expand Down
Loading

0 comments on commit 83295f4

Please sign in to comment.