Giter Site home page Giter Site logo

arjun-rao / clasp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from google/clasp

0.0 2.0 0.0 159 KB

Develop Apps Script projects locally.

Home Page: developers.google.com/apps-script/guides/clasp

License: Apache License 2.0

JavaScript 98.61% Shell 1.39%

clasp's Introduction

clasp

Develop Apps Script projects locally using clasp (Command Line Apps Script Projects).

clasp

To get started, try out the codelab!

Install

First download clasp:

npm i @google/clasp -g

Then enable Apps Script API: https://script.google.com/home/usersettings

Features

πŸ—ΊοΈ Develop Locally: clasp allows you to develop your Apps Script projects locally. That means you can check-in your code into source control, collaborate with other developers, and use your favorite tools to develop Apps Script.

πŸ”’ Manage Deployment Versions: Create, update, and view your multiple deployments of your project.

πŸ“ Structure Code: clasp automatically converts your flat project on script.google.com into folders. For example:

  • On script.google.com:
    • tests/slides.gs
    • tests/sheets.gs
  • locally:
    • tests/
      • slides.js
      • sheets.js

Commands

clasp
  • clasp login [--no-localhost]
  • clasp logout
  • clasp create [scriptTitle] [scriptParentId]
  • clasp clone <scriptId>
  • clasp pull
  • clasp push
  • clasp open
  • clasp deployments
  • clasp deploy [version] [description]
  • clasp redeploy <deploymentId> <version> <description>
  • clasp version [description]
  • clasp versions

How To...

Login/Logout

clasp login
clasp logout

Run clasp login --no-localhost to manually enter a code instead of running a local server.

Create a New Apps Script Project

Files in the current directory are added to the project. Optinally provide a script title or parent G Suite doc ID.

clasp create [scriptTitle] [scriptParentId]

Clone an existing project in the current directory

clasp clone <scriptId>

Push/Pull

clasp push # Updates Apps Script project with local files
clasp pull # Updates local files with Apps Script project

Update a Published Project / Deploy

To deploy a project:

  1. Create an immutable version of the Apps Script project using clasp version
  2. Deploy the version using clasp deploy [version]
clasp versions # List versions
clasp version [description] # Create a new version with a description

then deploy...

clasp deploy [version] [description]
clasp undeploy <deploymentId>
clasp deployments # List all deployment IDs

Open the project on script.google.com

clasp open

Ignore Files

Create a file called .claspignore in the root directory of your Apps Script project. Add patterns as if it were a .gitignore, and they will be excluded from clasp push.

A sample .claspignore could look like:

**/**
!build/Main.js
!appsscript.json

This file ignores everything but the manifest and the bundle.

Note: the .claspignore file is parsed with Anymatch, making it match files differently from a typical .gitignore, especially with directories. To ignore a directory, use syntax like **/node_modules/**

Configuration

When running clone or create, a file named .clasp.json is created in the current directory to describe clasp's configuration for the current project. The following configuration values can be used in it.

scriptId (required)

Specifies the id of the Google Script project that clasp will target. It is the part located inbetween /d/ and /edit in your project's URL: https://script.google.com/d/<SCRIPT_ID>/edit.

rootDir (optional)

Specifies the local directory in which clasp will store your project files. If not specified, clasp will default to the current directory.

Troubleshooting

The library requires Node version >= 4.7.4.

node -v # Check Node version
sudo npm install n -g
sudo n latest

Develop

The Apps Script CLI uses TypeScript to provide autocompletion and linting when developing. Use an IDE like Visual Studio Code for TypeScript autocompletion.

Setup

Install tsc: npm install -g typescript

After Making a Change

npm run build;
clasp <command>

Submitting a Pull Request

  1. Look over the test cases in test.sh, try cases that the PR may affect.
  2. Run tslint: npm run lint.
  3. Submit a pull request after testing and linting.

Publish

  1. Build index.js locally. .gitignore/.npmignore will hide js/ts files appropriately.
  2. Bump versions, then publish with: npm publish --access public

⚑ Powered by the Apps Script API.

clasp's People

Contributors

arjun-rao avatar aurelienshz avatar bladechild avatar cwatson88 avatar diminishedprime avatar domoritz avatar grant avatar jeanremidelteil avatar jondcallahan avatar labnol avatar nirazul avatar sqrrrl avatar tbenbrahim avatar thesiti92 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.