Skip to content

Commit

Permalink
esbuildを導入してbinディレクトリに出力されるように変更
Browse files Browse the repository at this point in the history
  • Loading branch information
TakuyaIsaki committed Sep 20, 2023
1 parent 20eff6c commit 81bea6d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,6 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*


bin/
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@
## 使い方

[工数入力のページ](https://ssl.jobcan.jp/employee/man-hour-manage)に移動して、F12 で開発者ツールを開き、
自分の普段入力しているプロジェクト id と taskid を取得します。
自分の普段入力しているプロジェクト id と taskid を取得します。(HEADLESS を false にすることでブラウザの実行状況を確認できます)

.env に情報を記入し次のコマンドを実行すると、今月の工数を一括で入力できます。
リリースからプロジェクトをダウンロードして.env に情報を記入する
bin ディレクトリをパスを通すなどして次のコマンドを実行する

## 実行

```bash
./jobcan complete
```

## ビルド

```bash
npm i
./bin/jobcan complete
npm run build
```
7 changes: 0 additions & 7 deletions bin/jobcan

This file was deleted.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"scripts": {
"complete": "ts-node -r tsconfig-paths/register ./src/commands/editManHours.ts",
"build": "esbuild ./src/commands/editManHours.ts --bundle --outfile=./bin/out.js --platform=node && mkdir -p ./bin/ && cp ./public/* .env ./bin/",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
Expand All @@ -14,6 +15,7 @@
"playwright": "^1.38.0"
},
"devDependencies": {
"esbuild": "0.19.3",
"rome": "^12.1.3",
"ts-loader": "^9.4.4",
"tsconfig-paths": "^4.2.0",
Expand Down
13 changes: 13 additions & 0 deletions public/jobcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

################################
# nodeが必要
################################

cd `dirname $0`

if [ $1 = "complete" ]; then
node ./out.js
else
echo "無効なコマンドです"
fi
3 changes: 2 additions & 1 deletion src/commands/editManHours.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ const PASSWORD = process.env.JOBCAN_PASSWORD as string;
//自分のプロジェクトIDとタスクIDを入力
const PROJECT_ID = process.env.JOBCAN_PROJECT_ID as string;
const TASK_ID = process.env.JOBCAN_TASK_ID as string;
const HEADLESS = (process.env.HEADLESS as string) === "true";

//工数を自動入力
(async () => {
const browser = await chromium.launch({ headless: false });
const browser = await chromium.launch({ headless: HEADLESS });
const page = await browser.newPage();
await loginPage(page, EMAIL, PASSWORD);
await completeManHours(page, PROJECT_ID, TASK_ID);
Expand Down

0 comments on commit 81bea6d

Please sign in to comment.