$ npm i -g google-apps-script
- Visit https://script.google.com/home/usersettings and enable the Apps Script API
- Add -f to force reauthentication
- Add -s to show the authentication url instead of opening a webbrowser
$ gas auth [-f][-s]
- Standalone scripts can be referenced by name, container bound script projects must be referenced by projectId.
- You can find a projectId from the url of a details page in My Scripts
$ gas new <projectName>
$ gas clone <projectName|projectId>
- There is an optional filter on projectName
$ gas get projects [filter]
- Gas also supports shared scripts, Team Drives and container bound scripts
- Files in subfolders are mapped to their relative pathname in a project and the other way around
- You can specify to pull or push a single file by adding a filename to the command
- Delete a single remote file by adding -d to the push command
$ gas pull [fileName]
$ gas push [fileName] [-d]
$ gas rename <projectName|projectId> <newProjectName>
- See the last example for some context
$ gas link <projectName|projectId>
$ gas open [projectName|projectId]
$ gas show [projectName|projectId]
$ gas status
$ gas include
$ gas include -s packageName
- Create will always happen in the root of My Drive (for now)
$ gas create project <projectName>
$ gas delete project <projectName|projectId>
$ gas get projects [filter]
$ gas create version [-d description] [-p projectName|projectId]
$ gas get versions [projectName|projectId]
$ gas create deployment [-d description] [-v versionNumber] [-p projectName|projectId]
$ gas get deployments [projectName|projectId]
Configure gas to use .gs as local extension or to use a custom Google OAuth2 client to do the API requests
- How to setup a a custom Google OAuth2 client for gas, from A to Z
- Add -e to export your current config to configFile.json
- Add -i to import a config from configFile.json
- Add -r to reset the config to the default values
$ gas config [-e][-i][-r] [configFile.json]
$ gas new myProject
$ cd myProject
$ gas open
$ gas get projects
$ gas clone myProject
$ cd myProject
$ gas create myProject2
$ mkdir src
$ cd src
$ gas link myProject2
$ gas show
$ gas pull
Gas creates some extra files in a .gas folder. None should be checked into git, so a .gitignore file gets added to your project if there isn't one present yet.
.gasignore has exacly the same purpose and functionality as .gitignore but for the Google Apps Script remote and gets created by default to ignore the node_modules folder.
$ cat .gasignore
That's all (so far).
Suggestions or questions?
Tweet me @MaartenDesnouck or create an issue on github.