Skip to content

Instantly share code, notes, and snippets.

@mark05e
Last active June 4, 2022 21:58
Show Gist options
  • Save mark05e/ac30a8099de2ce72b0dc894896206ab2 to your computer and use it in GitHub Desktop.
Save mark05e/ac30a8099de2ce72b0dc894896206ab2 to your computer and use it in GitHub Desktop.

Clasp Notes

.clasp.json

{
	"scriptId":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
	"rootDir":"src"
}

scriptID can be found by opening up the script editor and then select Project Settings > IDs

rootDir is optional - depends on where you place the code.

IMPORTANT: This file needs to be placed inside the location where the code for a specific appscript instance lives.

NPM installation notes

Depending on how clasp is installed, we can execute it directly by typing in clasp or prefixing npx on the clasp command

eg:

clasp status //installed globally
npx clasp status //installed inside a project

Important commands

Command Description
clasp login Perform login on the clasp command-line

Make sure to enable API access
clasp clone Clones the script project

- Clone using scriptID
clasp clone "15ImUCpyi1Jsd8yF8Z6wey_7cw793CymWTLxOqwMka3P1CzE5hQun6qiC"

- Clone using script/editor URL
clasp clone "https://script.google.com/d/15ImUCpyi1Jsd8yF8Z6wey_7cw793CymWTLxOqwMka3P1CzE5hQun6qiC/edit"

- Clone to a sub directory
clasp clone "15ImUCpyi1Jsd8yF8Z6wey_7cw793CymWTLxOqwMka3P1CzE5hQun6qiC" --rootDir ./src
clasp push Write local files to appscript

- Upload current cloned project directory
clasp push

-Upload subdirectory that contains the project
clasp push -P "src"
clasp open Opens the current project in the browser

References

Written with StackEdit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment