Constructors

Methods

  • Download Google docs and sheets to local JSON files.

    graphics google:get-docs config.json

    Description
    Fetch data from Google docs and sheets

    Usage
    $ graphics google:get-docs <conf> [options]

    Options
    -s, --skip Skip docs whose data don't validate (as opposed to throwing an error)
    -h, --help Displays this message

    Your config file should be in the following format that includes the ID from the Google doc or sheet and the path to where you'd like data from those docs to be written to locally. All paths should be relative to the current working directory when the script runs.

    {
    "docs": {
    "path/to/where/you/want/data.json": "XXXX_Google_doc_ID_XXXX"
    },
    "sheets": {
    "path/to/where/you/want/other/data.json": "XXXX_Google_sheet_ID_XXXX"
    }
    }

    To find the ID of you doc or sheet, look for a long string of random characters in the URL of the file in Google Drive. You can find it between https://.../d/< DOC ID HERE >/edit. For example:

    https://docs.google.com/spreadsheets/d/1h1O8jPScxrUg-xmolKGSPzaePgyG3zbBkAWiijEpi0c/edit

    You may also specify a path to a JSON schema, which will be used to validate your data:

    {
    "docs": {
    "path/to/where/you/want/data.json": {
    "id": "XXXX_Google_doc_ID_XXXX",
    "schema": "path/to/a/json/schema.json"
    },
    },
    "sheets": {
    "path/to/where/you/want/other/data.json": "XXXX_Google_sheet_ID_XXXX"
    }
    }

    Validation errors will cause the script to throw an error and quit. Alternatively, you can pass the --skip flag, which will continue getting other sheets and docs data specified in your conf as long as they are valid.

    Parameters

    • configPath: string

      Path to config file

    • opts: {
          skip: boolean;
      } = ...

      Options

      • skip: boolean

    Returns Promise<void>

  • Create JSON schema for all the data from your docs and sheets and then update your config file so the schema will be checked for any future data you pull with GoogleClient.getGoogleDocs.

    Use this command once you're ready to lock in your data for publishing, and you can be sure the structure of your data will never change as a result of a malformed Google doc or sheet.

    graphics google:lock-docs config.json

    Description
    Create JSON schemas for your Google docs

    Usage
    $ graphics google:lock-docs <conf> [options]

    Options
    -h, --help Displays this message

    Parameters

    • conf: string

      Config file path

    Returns Promise<void>