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; + } +}