How to deploy
Install clasp. Open a terminal anywhere, and run:
npm i @google/clasp -g
Log into clasp. Open a terminal anywhere, and run:
Integrate Sketch-n-Script in a Doc for testing
Create a Google Doc. Open
Tools > Script editor. Give the project a
NAMEand save it. The files in this project template will soon be overriden.
File > Project propertiesand copy the Script ID value.
Pull a fresh clone of Sketch-n-Script and then
clasp clone NAME.
The last step will create a starter skeleton
git checkout Code.jsto revert to the version from
Create a file
.clasp.jsonthat contains the the following:
XXXby the Script ID obtained above.
Try making a change to
Code.js(e.g. change the string argument to
.setSetTile'). Then runclasp push`.
If asked for confirmation, enter
You might have to go to https://script.google.com/home/usersettings to activate the Script API (change it from Off to On), and then re-run
Refresh your script page from the browser, or run
clasp opento open the script in a new browser window.
Run > Run function > onOpen. Accept the permissions. A menu appears under the
Add-onmenu, click it, then
Startto open the side bar.
(I had trouble with the previous step: Instead, I:) Open
Run > Test as add-on...and then picke a Doc on which to test
NAME. Then, from inside that Doc, go to
Add-ons > NAME > Startto launch the add-on.
Now the add-on is working for this script.
Developing the Sketch-n-Script add-on
You can develop the add-on locally or in the online script editor. To push changes made locally, run
To pull changes made online, run
/!\ Be careful if you make changes locally AND online. The last two commands will overwrite each other's file.
If you made changes both locally and online, do the following.
git stash clasp pull git stash pop clasp push
So that now the changes have been merged and are in sync. Remember to commit any meaningful changes.
/!\ Always pull your online changes locally before merging other branches locally.
If you don't want that clasp push some files or folders, note that
clasp ignores files
- That start with a .
- That don't have an accepted file extension
- That are ignored (filename matches a glob pattern in the
Working with typescript files
If running the first time, install the necessary dependencies:
Typescripts files are located in
add-on folder, run
npm run compile
npm run test
Publishing the add-on (for authors only)
- Make sure all changes are pushed online.
- Make sure
.clasp.jsonis referring to the correct script ID.
- Go to File > Manage version, enter a name for this version, and click on "Save a new version", then "Ok"
- In the online interface for the script editor, go to: Publish > Deploy as a Google Docs add-on. On the top right, select the name of the version you just saved. Click Update published project. It will lead you to the developer tools where you can update the documentation.
Pull requests welcome!
More instructions about the clasp command line can be found here: https://codelabs.developers.google.com/codelabs/clasp/