You can develop and test clasp
on your computer by following these steps.
Note:
clasp
uses TypeScript to provide autocompletion and linting when developing. Use an IDE like Visual Studio Code for TypeScript autocompletion.
- Install
tsc
:npm install -g typescript
- Remove your local version of
clasp
:npm uninstall -g @google/clasp
- This will prevent errors when updating
node_modules
.
- This will prevent errors when updating
- Install dependencies:
npm install
npm run build;
clasp <command>
If you're seeing build errors, try deleting node_modules
and building clasp
from scratch:
rm package-lock.json
rm -rf node_modules/
npm run build-fresh
This is what @grant's terminal looks like:
sudo npm run build-fresh
Password:
> @google/[email protected] build-fresh ~/Documents/github/google/clasp
> npm cache clean --force && npm i && npm run build
npm WARN using --force I sure hope you know what you are doing.
up to date in 2.464s
> @google/[email protected] build ~/Documents/github/google/clasp
> tsc --project tsconfig.json && npm i -g --loglevel=error
/usr/local/bin/clasp -> /usr/local/lib/node_modules/@google/clasp/src/index.js
+ @google/[email protected]
updated 1 package in 2.768s
After seeing that message, you're ready to test out clasp
!
clasp
has some unit tests that help detect errors. Build and run tests with these commands:
npm run build;
npm run test
See /tests/ for more information.
- Use
npm run lint
to find common style errors. TravisCI will autodetect these errors too. - Download sort-imports for VSC to automatically sort imports.
- Use
npm run prettier
to make the code pretty.
- Build
index.js
locally..gitignore
/.npmignore
will hide js/ts files appropriately. - Bump version:
npm version [major|minor|patch] -m "Bump version to %s"
- Push to GitHub:
git push --tags
- Publish with:
npm run publish