Skip to content

Latest commit

 

History

History

dev

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Contributor documentation

You want to contribute to google-docs-mustaches? Great!

First, you can follow the Getting started guide.

Ready to code? Check out the Ready to code section to find available tools and resources to improve your contributor experience.

Getting started

In order to start using google-docs-mustaches, you will need to follow those 6 quick steps:

  1. Install the project
  2. Create a Google App project
  3. Create an OAuth key
  4. Enable the Drive and Docs APIs
  5. Generate a token
  6. Create your Docs template
  7. Run the playground

Install the project

Before doing anything, install the project with the following commands:

git clone https://github.com/errorname/google-docs-mustaches
cd google-docs-mustaches
npm install
npm run build

Create a Google App project

Go to the New Project setup page. Write the name of your app.

Once the creation is complete, use the selector on the top left of the page to select your newly created app.

Create an OAuth key

Go to the Oauth consent screen and fill in with the name of your app.

Go to the Credentials page. Click on "Create Credentials", choose "OAuth Client ID", select "Other" and validate with a name for your new key.

Finally, by clicking on the arrow icon on the right of the table, download the credentials and put the JSON file at dev/credentials.json

Enable the APIs

Go to those APIs and click "Enable"

Note: Google may need a few minutes to propagate the action into their systems. Wait a couple of minutes and retry.

Generate a token

Execute the following command:

npm run token

Go the URL given, authenticate with your Google account, and copy the given code.

Paste the code in the console. You now have a new token available for your project!

Note: If you need to regenerate a token, remove the generated dev/token.json file and re-execute the command.

Create your Docs template

In Google Drive, create a new Docs file and write the following:

Hello {{ firstname }} {{ lastname | uppercase }}!

You have {{ accounts[0].money }}€ in you account...

In the URL, retrieve the ID of the file

https://docs.google.com/document/d/[THE-ID-OF-THE-FILE]/edit

Create a new folder where your interpolated files will be put and also retrieve the id

https://drive.google.com/drive/u/0/folders/[THE-ID-OF-THE-FOLDER]

Run the playground

Copy-paste the dev/playground.js.sample file:

cp dev/playground.js.sample dev/playground.js

In the playground.js file, replace with the ids of the template file and destination folders with yours.

You are now ready to interpolate your first mustaches:

npm run playground

You now have an interpolated file in your folder!

Have fun! 🚀

Ready to code

Since you now have a working playground, check out the list of available commands and resources to help you code on this project!

Available commands

Command Notes
npm run build  This project uses Typescript, so you need to transpile into Javascript to run it. (Auto retranspile: npm run build -- -w)
npm run test  Run Jest for the tests. This command will also give you the code coverage of your tests.
npm run lint Run eslint to check for lint issues.
npm run lint:fix Run eslint to fix lint issues.
npm run prettier:write Run Prettier to prettify the files.
npm run prettier:check Run Prettier to check against prettier rules.
npm run token Generate a new OAuth token and write it in dev/token.json
npm run playground Run the dev/playground.js file

Resources