Skip to content

santiment/google-spreadsheet-addon

Repository files navigation

google-spreadsheet-addon

Contains the source code of the SANsheets google spreadsheet add-on.

Table of contents

Usage

Development

The project is based on clasp and gas-local to enable local development and testing. Most of the Google functions has been mocked in order to work locally, check gas_mock for reference. The src directory contains the source code that will be pushed to the google apps webeditor. Changing code directly in the webeditor is not recommended apart from debugging because it will get wiped out next time someone pushes.

Prerequisites

  • node.js >= 6.3.0
  • npm
  • npx : if your npm installation is old and you don't have npx, install it with: sudo npm i -g npx

Installation

Install dependencies:

$ npm install

Structure

The structure of the project consists of the following files:

Queries

They can be found in the src/api/queries folder. All the queries, sent to the API can be seen here.

Functions

Found in the src/functions folder. Here lie all of the functions, connecting the google sheet functions and the API queries.

Sheet Functions

Found in the src/ folder. There are 2 files, one under the name of sheetFunctions.js and the other one being generatedSheetFunctions.js, the former having all the functions, using APIs different from getMetric, the latter having those who do not. The second file is generated, using the getMetricGenerator.js.

Generators

All of the generators are found in the src/generators folder. By generator, we mean two things actually - one is the scripts, that generate the file contents, the other - the script generating the generatedSheetFunctions.js file, using the file content generators.

Running tests

You can run the whole tests suite with:

$ npm test

Unit tests only:

$ npm run test:unit

Running integration tests

Integration tests only:

$ npm run test:integration

Standart template tests

For creating the test files for standart-template metrics:

$ npm run test:generate

If you want to exclude a function from being automatically generated (the template doesn't apply to that function), then you should add it in the getMetricTestGenerator.js file, in the IGNORED_FUNCTIONS array

Also, if the metric is a daily one, it should be added to the LIST_OF_DAILY_METRICS array in the same file.

Running tests in docker container

Run the test suite in a docker container. Build the image:

$ docker build -f Dockerfile-test -t google-spreadsheet-addon-tests .

and then run the tests:

$ docker run -t google-spreadsheet-addon-tests

Generate documentation

$ npm run docs

Pushing to the webeditor

You first need to log into clasp:

  $ npx clasp login

Push changes:

$ npm run push