æ¦è¦
ã¿ãªããããã«ã¡ã¯ããã«ã¹ã¿ãã¯ã¨ã³ã¸ãã¢ã®é«ç¬ @takasehiromichi ã§ãã
ä»åã¯ãVSCodeããGoogle Apps Script ãæä½ããç´ å°ãä½ã£ãã®ã§ãè¨äºã«ãããã¨æãã¾ãã
ã¹ãã¬ããã·ã¼ãã®ä½æ
ä»åç·¨éãããã®ã¯ã¹ãã¬ããã·ã¼ãã®GASãªã®ã§ãã¾ãå ã«ã¹ãã¬ããã·ã¼ããä½æãã¾ãã
空ç½ãã
æ¡å¼µæ©è½ > Apps Script
ç¡é¡ã®ããã¸ã§ã¯ããã§ãã¾ã
ããã¸ã§ã¯ãã®è¨å®ãã
ã¹ã¯ãªããIDãã³ãã¼ãã¦ããã¾ã
VSCodeå´ã®èª¿æ´
ã¾ããnpm init
ãã¾ããEnterãé£æ
package.jsonãã§ãã¾ã
npm i @google/clasp
ãå®è¡
package.jsonã®ã¹ã¯ãªããã調æ´
{ "name": "test", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "clasp": "clasp", "login": "clasp login", "pull": "clasp pull", "push": "clasp push", "deploy": "clasp deploy" }, "author": "", "license": "ISC", "dependencies": { "@google/clasp": "^2.4.2" } }
.clasp.json
ã¨ãããã¡ã¤ã«ãä½æãã¾ãã
{ "scriptId": "1Hc_wC6IJ_1K7pj2_G9ySdT7fYqDXstAKabj5BZKfC1WKq3v_qfPjIoR2" }
VSCodeããæä½
npm run login
ãå®è¡ãã¾ãã
googleã¢ã«ã¦ã³ãã§ãã°ã¤ã³
https://script.google.com/home/usersettings
ã«ã¢ã¯ã»ã¹ããAPIã¢ã¯ã»ã¹ãæå¹ã«ãã¾ã
ãªã¢ã¼ãã®ã½ã¼ã¹ã³ã¼ããæã£ã¦ããæã¯ãnpm run pull
appsscript.json ã¨ãããã¡ã¤ã«ãå¢ãã¦ã¾ãã
{ "timeZone": "Asia/Tokyo", "dependencies": { }, "exceptionLogging": "STACKDRIVER", "runtimeVersion": "V8" }
ã³ã¼ã.js ã¨ãããã¡ã¤ã«ãå¢ãã¦ã¾ãã
function myFunction() { }
ã³ã¼ã.js ã«å¤æ´ãå ãã¾ãã
function myFunction() { console.log("hello"); }
ãªã¢ã¼ãã«ã½ã¼ã¹ã³ã¼ãã渡ãã«ã¯ãnpm run push
ç»é¢ãæ´æ°ããã¨ãå¤æ´ãå ããã½ã¼ã¹ã³ã¼ããåæ ããã¦ãã¾ã
ãããã¤ããã«ã¯ãnpm run deploy
ãããã¤ããã¾ããã
ã¾ã¨ã
ããã§git管çã§ããããã«ãªã£ãã®ã§ãGASãç·¨éãããã¬ãã¥ã¼ãããããã®ã楽ã«ãªãã¾ããã