From 175814228ac367ddf924a785dcbc7de5c86beec6 Mon Sep 17 00:00:00 2001 From: mikuto Date: Thu, 13 Nov 2025 18:09:49 +0900 Subject: [PATCH] =?UTF-8?q?fix:=E6=AD=A3=E3=81=97=E3=81=8F=E3=83=88?= =?UTF-8?q?=E3=83=A9=E3=83=B3=E3=82=B9=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E5=95=8F?= =?UTF-8?q?=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 11 +++++++ esbuild.js | 7 ++-- src/App.ts | 63 ------------------------------------ src/main.ts | 40 +++++++++++++++++------ 4 files changed, 47 insertions(+), 74 deletions(-) delete mode 100644 src/App.ts diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5869f89..e57593b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -27,6 +27,17 @@ jobs: - name: Build TypeScript run: npm run build + - name: Verify build output + run: | + echo "📁 dist フォルダの内容:" + ls -la dist/ + echo "" + echo "📄 appsscript.json の内容:" + cat dist/appsscript.json + echo "" + echo "📊 main.js のサイズ:" + wc -c dist/main.js + - name: Setup clasp credentials env: CLASPRC_JSON: ${{ secrets.CLASPRC_JSON }} diff --git a/esbuild.js b/esbuild.js index d7aada9..37025d0 100644 --- a/esbuild.js +++ b/esbuild.js @@ -1,5 +1,4 @@ import esbuild from 'esbuild'; -import { GasPlugin } from 'esbuild-gas-plugin'; import { copyFileSync, mkdirSync } from 'fs'; // distフォルダを作成(存在しない場合) @@ -14,7 +13,11 @@ esbuild bundle: true, minify: true, outfile: './dist/main.js', - plugins: [GasPlugin], + format: 'iife', + globalName: '__bundle__', + footer: { + js: 'function onEdit(e){__bundle__.onEdit(e)}', + }, }) .then(() => { console.log('✅ Build succeeded!'); diff --git a/src/App.ts b/src/App.ts deleted file mode 100644 index 39c700d..0000000 --- a/src/App.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { getApplicationFromRow } from './application'; -import { sendDiscordNotification } from './discord'; - -/** - * スプレッドシートに行が追加されたときのトリガー - */ -export const onEdit = (e: GoogleAppsScript.Events.SheetsOnEdit) => { - try { - const range = e.range; - const sheet = range.getSheet(); - const row = range.getRow(); - - // ヘッダー行(1行目)は無視 - if (row <= 1) { - return; - } - - // 申請情報を取得 - const application = getApplicationFromRow(sheet, row); - - if (!application) { - Logger.log(`行${row}: 申請情報が不完全のため通知をスキップ`); - return; - } - - // Discord通知を送信 - sendDiscordNotification(application); - Logger.log(`行${row}: 通知送信完了`); - } catch (error) { - Logger.log(`エラー: ${error}`); - throw error; - } -}; - -/** - * テスト用: 手動で通知を送信 - */ -export const testNotification = () => { - const ss = SpreadsheetApp.getActiveSpreadsheet(); - const sheet = ss.getActiveSheet(); - - // アクティブセルの行で通知テスト - const activeRow = sheet.getActiveCell().getRow(); - - if (activeRow <= 1) { - SpreadsheetApp.getUi().alert('データ行(2行目以降)を選択してください'); - return; - } - - const application = getApplicationFromRow(sheet, activeRow); - - if (!application) { - SpreadsheetApp.getUi().alert('申請情報が取得できませんでした'); - return; - } - - try { - sendDiscordNotification(application); - SpreadsheetApp.getUi().alert('通知送信成功!Discordを確認してください。'); - } catch (error) { - SpreadsheetApp.getUi().alert(`エラー: ${error}`); - } -}; diff --git a/src/main.ts b/src/main.ts index 47256a9..afa95ae 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,11 +1,33 @@ -import { onEdit, testNotification } from './App'; +import { getApplicationFromRow } from './application'; +import { sendDiscordNotification } from './discord'; -interface Global { - onEdit: typeof onEdit; - testNotification: typeof testNotification; -} -declare const global: Global; +/** + * スプレッドシートに行が追加されたときのトリガー + */ +export function onEdit(e: GoogleAppsScript.Events.SheetsOnEdit) { + try { + const range = e.range; + const sheet = range.getSheet(); + const row = range.getRow(); + + // ヘッダー行(1行目)は無視 + if (row <= 1) { + return; + } + + // 申請情報を取得 + const application = getApplicationFromRow(sheet, row); -// entryPoints -global.onEdit = onEdit; -global.testNotification = testNotification; + if (!application) { + Logger.log(`行${row}: 申請情報が不完全のため通知をスキップ`); + return; + } + + // Discord通知を送信 + sendDiscordNotification(application); + Logger.log(`行${row}: 通知送信完了`); + } catch (error) { + Logger.log(`エラー: ${error}`); + throw error; + } +}