Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ClaspとTypescriptで Google Apps Scriptを動かす / serv...
Search
Hidetaka Okamoto
January 25, 2020
Programming
0
89
ClaspとTypescriptで Google Apps Scriptを動かす / serverlesskobe20200125
Serverless Meetup Kobe vol1 2020/01/25
#serverlesskobe
Hidetaka Okamoto
January 25, 2020
Tweet
Share
More Decks by Hidetaka Okamoto
See All by Hidetaka Okamoto
OpenAI APIで API Changelogを要約してみた話 / chatgpt-osaka-1
hideokamoto
0
460
コミュニティ運営から 中の人に変わって感じたこと
hideokamoto
0
53
Developerが Developer Advocateになった話 / dev-rel-meetup-tokyo-71
hideokamoto
0
270
Jamstack開発者のための App Runner入門
hideokamoto
1
420
WordPressでの webサイト制作2022 / ngk2022s
hideokamoto
0
380
JavaScript(TypeScript)で メディアサイトを インフラから構築する方法 / jsconf-jp-2021
hideokamoto
2
4k
AWS上でStripeを利用したアプリをより安全にデプロイする方法 /jaws-pankration-2021
hideokamoto
1
170
Shifter Headlessと Headless WordPressの紹介
hideokamoto
0
1.6k
Stripe & Next.js + AWS Amplify で会員 + 定期課金機能 / JP_Stripes20210903
hideokamoto
7
3k
Other Decks in Programming
See All in Programming
Jakarta EE meets AI
ivargrimstad
0
600
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
Remix on Hono on Cloudflare Workers
yusukebe
1
280
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
Contemporary Test Cases
maaretp
0
130
Macとオーディオ再生 2024/11/02
yusukeito
0
370
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
Featured
See All Featured
Adopting Sorbet at Scale
ufuk
73
9.1k
Done Done
chrislema
181
16k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Designing Experiences People Love
moore
138
23k
For a Future-Friendly Web
brad_frost
175
9.4k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Building Adaptive Systems
keathley
38
2.3k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
The World Runs on Bad Software
bkeepers
PRO
65
11k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Gamification - CAS2011
davidbonilla
80
5k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
Transcript
ClaspͱTypescriptͰ Google Apps ScriptΛಈ͔͢ Serverless Meetup Kobe vol1 2020/01/25 #serverlesskobe
About: Hidetaka Okamoto גࣜձࣾσδλϧΩϡʔϒ "MFYB$IBNQJPOT 3FBDU5ZQF4DSJQU"84 #serverlesskobe
About: Hidetaka Okamoto גࣜձࣾσδλϧΩϡʔϒ "MFYB$IBNQJPOT 3FBDU5ZQF4DSJQU"84 #serverlesskobe
#serverlesskobe
Agenda Γ͔ͨͬͨ͜ͱ (PPHMF"QQT4DSJQUͷίʔυΛϩʔΧϧͰ։ൃ͢Δ 5ZQF4DSJQUΛͬͯ։ൃΛΑΓศརʹ͢Δ ͓ΘΓʹ #serverlesskobe
Agenda Γ͔ͨͬͨ͜ͱ (PPHMF"QQT4DSJQUͷίʔυΛϩʔΧϧͰ։ൃ͢Δ 5ZQF4DSJQUΛͬͯ։ൃΛΑΓศརʹ͢Δ ͓ΘΓʹ #serverlesskobe
Γ͔ͨͬͨ͜ͱ ؆୯ͳCPUʢ-*/&PS"MFYBΛఆʣ (PPHMFΧϨϯμʔͷ༧ఆՃΛτϦΨʔʹ͢Δ มߋ͞Εͨ༰Λνϟοτ76*Ͱ௨͢Δ ͍׳Εͨ5ZQF4DSJQUΛ͍͍ͨ #serverlesskobe
࣮ͨ͠ͷ (PPHMF"QQT4DSJQUͰ࣮ (PPHMFΧϨϯμʔΛτϦΨʔʹ࣮ߦ -*/&ͷ.FTTBHF"1*ʹ1045ϦΫΤετ #serverlesskobe
Agenda Γ͔ͨͬͨ͜ͱ (PPHMF"QQT4DSJQUͷίʔυΛϩʔΧϧͰ։ൃ͢Δ 5ZQF4DSJQUΛͬͯ։ൃΛΑΓศརʹ͢Δ ͓ΘΓʹ #serverlesskobe
GOOGLE APPS SCRIPT HTTPS://DEVELOPERS.GOOGLE.COM/APPS-SCRIPT?HL=JA #serverlesskobe
• Google͕ఏڙ͢ΔFaaS • 6ఔͷScript͕࣮ߦՄೳ • ੍ݶࣄ߲G Suite Planґଘ • script.google.comͰཧ
• GUIͰίʔυΛฤूՄೳ • Google Appsͱͷੑ #serverlesskobe
• Google͕ఏڙ͢ΔFaaS • 6ఔͷScript͕࣮ߦՄೳ • ੍ݶࣄ߲G Suite Planґଘ • script.google.comͰཧ
• GUIͰίʔυΛฤूՄೳ • Google Appsͱͷੑ #serverlesskobe
GUI্Ͱ࣮ɾཧͨ͘͠ͳ͍ʂ #serverlesskobe
npm I -g @google/ clasp C ommand L ine A
pps S cript P roject #serverlesskobe
claspͱ (PPHMF͕ϦϦʔε͍ͯ͠Δ("4͚$-*πʔϧ σϓϩΠෳɺεςʔλεͷ֬ೝͳͲͷૢ࡞͕Մೳ DMBTQMPHJOͰϩάΠϯ͢ΔͱɺDMBTQSDKTPOʹೝূใΛه ("4Λ։ൃ͢ΔͳΒ$MBTQҰʢඪຊʣ #serverlesskobe
Google Apps Script APIΛ༗ޮԽ͓ͯ͘͠ https://script.google.com/home/usersettings #serverlesskobe
$ clasp loginͰ ϩάΠϯը໘͕ ্ཱ͕ͪΔ #serverlesskobe
͍Ζ͍Ζͱݖݶ ཁٻ͞ΕΔ Serverless Framework͕ AdministratorAccessཁٻ͢Δͷʹ ͍ۙΑ͏ͳҹ #serverlesskobe
$ cat ~/.clasprc.json tokenͳͲ࿙Β͞ͳ͍Α͏ʹҙ͢Δ #serverlesskobe
$ clasp createͰϓϩδΣΫτΛ࡞͢Δ https://github.com/google/clasp#create #serverlesskobe
createޙʹpullͰ entrypointΛऔಘ Code.jsʹίʔυΛॻ͍ͯ push͢ΕOK #serverlesskobe
claspͰͰ͖Δ͜ͱʢҰ෦ʣ DMBTQQVTIͰσϓϩΠ DMBTQWFSTJPOlzͰόʔδϣϯઃఆ DMBTQWFSTJPOTͰόʔδϣϯҰཡऔಘ DMBTQMPHTͰ࣮ߦϩάͷදࣔʢGSPN4UBDL%SJWFSʣ #serverlesskobe
claspΛͬͯϩʔΧϧͰGAS։ൃ ެࣜπʔϧͷ҆৺ײ όʔδϣχϯά$MPOFͳͲ͋Γखް͍ ("4ͳΒͰϓϩύςΟʹ͍ͭͯࣗྗͰௐΔඞཁ͋Γ ͠ΐ͏͖͡ΊΜͲ͍͘͞ #serverlesskobe
Agenda Γ͔ͨͬͨ͜ͱ (PPHMF"QQT4DSJQUͷίʔυΛϩʔΧϧͰ։ൃ͢Δ 5ZQF4DSJQUΛͬͯ։ൃΛΑΓศརʹ͢Δ ͓ΘΓʹ #serverlesskobe
ͳͥTypeScriptΛ͍͍ͨͷ͔ (PPHMF"QQT͔Β͘Δσʔλͷܕ͕Γ͍ͨ ("4Ͱར༻Ͱ͖ΔάϩʔόϧมܥΛΓ͍ͨ ("4ʹ'FUDI"QQTଓܥͷಠࣗมɾΫϥε͕ଟ͋Δ Կ͕͋Δͷ͔ɺͲ͏͍͍͑ͷ͔ΛάάΓͨ͘ͳ͍ ܕ͕ͳ͍··ॻ͍ͨࣗͷίʔυΛ৴༻Ͱ͖ͳ͍ #serverlesskobe
claspTypeScript ϑϨϯυϦʔ #serverlesskobe
ܕใͷऔಘɿnpm install --save @types/google-apps-script #serverlesskobe
Clasp push࣌ʹτϥϯεύΠϧͯ͘͠ΕΔͷͰɺͦͷ··pushͰ͖Δ #serverlesskobe
Google AppsܥͷAPIʹର͢Δೖྗิڧྗ #serverlesskobe
GoogleΧϨϯμʔ͔ΒͷΠϕϯτσʔλΛܗ͢Δαϯϓϧ #serverlesskobe
LINEͷMessage APIܦ༝ͰϝοηʔδΛૹ৴͢Δαϯϓϧ #serverlesskobe
Claspͷҙ 3FRVJSFJNQPSUΘͳ͍ʢ͏ͳΒXFCQBDLͳͲͰϏϧυʣ ॏ͍ͨ4%,ΛCVOEMF͢ΔͱΞοϓϩʔυͰ͖ͳ͍͜ͱ͕͋Δ -*/&4%,͕μϝͩͬͨͷͰ1045PS"1*(8ՃͰରԠͨ͠ (PPHMFͷυΩϡϝϯτͷάάϥϏϦςΟ͕͍ ʮ("4ͰۀޮԽʂʯܥهࣄʹຒΕͯΔͷͰݕࡧͭΒ͍ #serverlesskobe
ݸਓతGAS(Clasp)͍ॴ (PPHMFܥαʔϏεͷΠϕϯτϒϦοδͱͯ͠ͷ("4 "84ͷΠϕϯτ&WFOU#SJEHF(PPHMF"QQT("4 ۩ମతͳॲཧܥΛ୲͏"1*'BB4Λ༻ҙ͢Δ ("4ͰΠϕϯτσʔλΛཧͯ͠ɺॲཧܥʹ͚͛ͭΔ (PPHMF"QQTܥͷσʔλऩूʹઐ೦͢ΔͷҰͭ #serverlesskobe
Agenda Γ͔ͨͬͨ͜ͱ (PPHMF"QQT4DSJQUͷίʔυΛϩʔΧϧͰ։ൃ͢Δ 5ZQF4DSJQUΛͬͯ։ൃΛΑΓศརʹ͢Δ ͓ΘΓʹ #serverlesskobe
͓ΘΓʹ (PPHMF"QQTܥΛτϦΨʔʹ͢ΔͳΒ("4 (PPHMF"QQT4DSJQU $MBTQΛ͑ϩʔΧϧͰॻ͍ͨίʔυΛσϓϩΠͰ͖Δ 5ZQF4DSJQUͰͷ࣮؆୯ ͨͩ͠༰ྔ੍ݶ͕͋ΔͷͰ%JTQBDIFSҎ্ͷ༻్ผ'BB4Λ #serverlesskobe