File tree 8 files changed +63
-6
lines changed
8 files changed +63
-6
lines changed Original file line number Diff line number Diff line change 1
1
# suikoden-election-2020-spreadsheet
2
+
2
3
Spreadsheet (Suikoden election 2020)
3
4
4
5
# GAS Template
6
+
5
7
A GAS template is powered by [ howdy39/gas-clasp-starter: A starter template for Google Apps Script by clasp] ( https://github.com/howdy39/gas-clasp-starter )
6
8
7
- # 手順
9
+ # 環境構築手順
10
+
8
11
- あらかじめ ` $ clasp login ` を行って ` ~/.clasprc.json ` を作っておく必要がある
9
12
- ` .clasp.sample.json ` をもとにして ` .clasp.json ` を作成する
10
13
- ` "scriptId" ` の値には、スクリプトページの URL の以下の部分の値を設定する
@@ -14,7 +17,21 @@ A GAS template is powered by [howdy39/gas-clasp-starter: A starter template for
14
17
- つまりスプレッドシートごとにリポジトリを作る必要がある
15
18
- 開発用と本番用の場合はこの限りではない
16
19
20
+ # 開発手順
21
+
22
+ - ` webpack.config.js ` のエンドポイントに合わせて、コードを書く
23
+ - これを書いている時点では ` src/index.ts ` にごりごり書く
24
+ - ビルドしてできるファイルは ` bundle.js ` の一つになる
25
+ - ` $ yarn build ` で ` dist/ ` 配下にビルド成果が生成される
26
+ - ` $ clasp push ` で push されるのはこの ` dist/ ` 配下のファイルになる
27
+ - 現在の ` $ yarn build ` を実行すると、ビルド前に ` dist/ ` は削除される
28
+ - 現在の ` webpack.config.js ` では ` src/*.ts ` がトランスパイル対象になる
29
+ - ` package.json ` の ` scripts ` と ` webpack.config.js ` は自分用に修正していった方がいい
30
+ - デフォルトの ` scripts ` は自分にあっていないためリネームしてある
31
+ - ` sample/ ` 配下には ` gas-clasp-starter ` に含まれているサンプルコードを配置してある
32
+
17
33
# 参考
34
+
18
35
- [ howdy39/gas-clasp-starter: A starter template for Google Apps Script by clasp] ( https://github.com/howdy39/gas-clasp-starter )
19
36
- [ Google Apps Script をローカル環境で快適に開発するためのテンプレートを作りました - Qiita] ( https://qiita.com/howdy39/items/0e799a9bfc1d3bccf6e5 )
20
- - [ 5分で作るclaspを使ったGoogle Apps Scriptの開発環境 - Qiita] ( https://qiita.com/suin/items/b264092eab3ce553f16a )
37
+ - [ 5 分で作る clasp を使った Google Apps Script の開発環境 - Qiita] ( https://qiita.com/suin/items/b264092eab3ce553f16a )
Original file line number Diff line number Diff line change 4
4
"description" : " " ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
7
- "lint" : " eslint --fix src/**/*.ts" ,
7
+ "default:lint" : " eslint --fix src/**/*.ts" ,
8
+ "default:build" : " npm run lint && npm run test && rimraf dist && webpack && cpx src/appsscript.json dist && cpx \" src/**/*.html\" dist" ,
9
+ "default:push" : " npm run build && clasp push" ,
8
10
"test" : " jest" ,
9
- "build" : " npm run lint && npm run test && rimraf dist && webpack && cpx src/appsscript.json dist && cpx \" src/**/*.html\" dist" ,
10
- "push" : " npm run build && clasp push"
11
+ "build" : " rimraf dist && webpack && cpx src/appsscript.json dist"
11
12
},
12
13
"repository" : {
13
14
"type" : " git" ,
Original file line number Diff line number Diff line change
1
+ import { SheetService } from './sheet.service' ;
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ declare let global : any ;
5
+
6
+ global . createNewFile = ( ) : void => {
7
+ const ss = SheetService . createInitialFile ( 'New file' ) ;
8
+ ss . getRange ( 'A2' ) . setValue ( 'Happy gas!' ) ;
9
+ } ;
Original file line number Diff line number Diff line change
1
+ function debugFunction ( ) : void {
2
+ console . log ( 'Hello, debugFunction!' )
3
+ }
4
+
5
+ debugFunction ( )
Original file line number Diff line number Diff line change
1
+ import Spreadsheet = GoogleAppsScript . Spreadsheet . Spreadsheet ;
2
+ import { getDayFormat } from './util' ;
3
+
4
+ export class SheetService {
5
+ static createInitialFile ( prefix : string ) : Spreadsheet {
6
+ const fileName = `${ prefix } ${ getDayFormat ( ) } ` ;
7
+ const ss = SpreadsheetApp . create ( fileName ) ;
8
+ const range = ss . getRange ( 'A1' ) ;
9
+ range . setValue ( 'Hello, clasp!' ) ;
10
+ return ss ;
11
+ }
12
+ }
Original file line number Diff line number Diff line change
1
+ export const getDayFormat = ( date = new Date ( ) ) : string => {
2
+ const year = date . getFullYear ( ) ;
3
+ const month = date . getMonth ( ) + 1 ;
4
+ const day = date . getDate ( ) ;
5
+ return `${ year } -${ month } -${ day } ` ;
6
+ } ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "timeZone" : " Asia/Tokyo" ,
3
+ "dependencies" : {
4
+ },
5
+ "exceptionLogging" : " STACKDRIVER" ,
6
+ "runtimeVersion" : " V8"
7
+ }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ module.exports = {
12
12
module : {
13
13
rules : [
14
14
{
15
- test : / \. t s $ / ,
15
+ test : / \s r c \/ .t s $ / ,
16
16
use : 'ts-loader' ,
17
17
} ,
18
18
] ,
You can’t perform that action at this time.
0 commit comments