Git Product home page Git Product logo

clasp's Introduction

Clasp

build status Coverage Status npm Version npm Downloads

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

clasp

To get started, try out the codelab!

You can also try clasp in Gitpod, a one-click online IDE for GitHub:

Open in Gitpod

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

πŸ”· Write Apps Script in TypeScript: Write your Apps Script projects using TypeScript features:

  • Arrow functions
  • Optional structural typing
  • Classes
  • Type inference
  • Interfaces
  • And more…

➑️ Run Apps Script: Execute your Apps Script from the command line. Features:

  • Instant deployment.
  • Suggested functions Autocomplete (Fuzzy)
  • Easily add custom Google OAuth scopes
  • And more…

- V8 support take advantage of the performance boost of Chrome JavaScript engine:

  • Every ES2019 features (except ES modules)
  • Edit your appsscript.json manifest to choose between the Rhino and V8 engines
  • Typescript users should update their tsconfig.json with the "target": "ES2019" compiler option

Install

First download clasp:

npm install -g @google/clasp

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

Enable Apps Script API

Commands

The following command provide basic Apps Script project management.

Note: Most of them require you to clasp login and clasp create/clone before using the rest of the commands.

clasp

Advanced Commands

NOTE: These commands require you to add your Project ID.

Clasp Run

NOTE: This command requires you to bring your own Google API credentials.

Reference

Login

Logs the user in. Saves the client credentials to a .clasprc.json file.

Options

  • --no-localhost: Do not run a local server, manually enter code instead.
  • --creds <file>: Use custom credentials used for clasp run. Saves a .clasprc.json file to current working directory. This file should be private!
  • --status: Print who you are currently logged in as, if anyone.

Examples

  • clasp login --no-localhost
  • clasp login --creds creds.json
  • clasp login --status

Logout

Logs out the user by deleting client credentials.

Examples

  • clasp logout

Create

Creates a new script project. Prompts the user for the script type if not specified.

Options

  • --type [docs/sheets/slides/forms]: If specified, creates a new add-on attached to a Document, Spreadsheet, Presentation, or Form. If --parentId is specified, this value is ignored.
  • --title <title>: A project title.
  • --rootDir <dir>: Local directory in which clasp will store your project files. If not specified, clasp will default to the current directory.
  • --parentId <id>: A project parent Id.
    • The Drive ID of a parent file that the created script project is bound to. This is usually the ID of a Google Doc, Google Sheet, Google Form, or Google Slides file. If not set, a standalone script project is created.
    • i.e. https://docs.google.com/presentation/d/{id}/edit

Examples

  • clasp create
  • clasp create --type standalone (default)
  • clasp create --type docs
  • clasp create --type sheets
  • clasp create --type slides
  • clasp create --type forms
  • clasp create --type webapp
  • clasp create --type api
  • clasp create --title "My Script"
  • clasp create --rootDir ./dist
  • clasp create --parentId "1D_Gxyv*****************************NXO7o"

These options can be combined like so:

  • clasp create --title "My Script" --parentId "1D_Gxyv*****************************NXO7o" --rootDir ./dist

Clone

Clones the script project from script.google.com.

Options

  • scriptId | scriptURL: The script ID or script URL to clone.
  • --versionNumber <number>: The version of the script to clone.
  • --rootDir <dir>: Local directory in which clasp will store your project files. If not specified, clasp will default to the current directory.

Examples

  • clasp clone "15ImUCpyi1Jsd8yF8Z6wey_7cw793CymWTLxOqwMka3P1CzE5hQun6qiC"
  • clasp clone "https://script.google.com/d/15ImUCpyi1Jsd8yF8Z6wey_7cw793CymWTLxOqwMka3P1CzE5hQun6qiC/edit"
  • clasp clone "15ImUCpyi1Jsd8yF8Z6wey_7cw793CymWTLxOqwMka3P1CzE5hQun6qiC" --rootDir ./src

Pull

Fetches a project from either a provided or saved script ID. Updates local files with Apps Script project.

Options

  • --versionNumber <number>: The version number of the project to retrieve.

Examples

  • clasp pull
  • clasp pull --versionNumber 23

Push

Force writes all local files to script.google.com.

Warning: Google scripts APIs do not currently support atomic nor per file operations. Thus the push command always replaces the whole content of the online project with the files being pushed.

Ignores files:

  • That start with a .
  • That don't have an accepted file extension
  • That are ignored (filename matches a glob pattern in the .claspignore file)

Options

  • -f --force: Forcibly overwrites the remote manifest.
  • -w --watch: Watches local file changes. Pushes files every few seconds.

Examples

  • clasp push
  • clasp push -f
  • clasp push --watch

Status

Lists files that will be written to the server on push.

Ignores files:

  • That start with a .
  • That don't have an accepted file extension
  • That are ignored (filename matches a glob pattern in the ignore file)

Options

  • --json: Show status in JSON form.

Examples

  • clasp status
  • clasp status --json

Open

Opens the current directory's clasp project on script.google.com. Provide a scriptId to open a different script. Can also open web apps.

Options

  • [scriptId]: The optional script project to open.
  • --webapp: Open web application in a browser.
  • --creds: Open the URL to create credentials.
  • --addon: List parent IDs and open the URL of the first one.
  • --deploymentId <id>: Use custom deployment ID with --webapp.

Examples

  • clasp open
  • clasp open "15ImUCpyi1Jsd8yF8Z6wey_7cw793CymWTLxOqwMka3P1CzE5hQun6qiC"
  • clasp open --webapp
  • clasp open --creds
  • clasp open --addon
  • clasp open --webapp --deploymentId abcd1234

Deployments

List deployments of a script.

Examples

  • clasp deployments

Deploy

Creates a version and deploys a script. The response gives the deployment ID and the version of the deployment.

For web apps, each deployment has a unique URL. To update/redeploy an existing deployment, provide the deployment ID.

Options

  • -V <version> --versionNumber <version>: The project version to deploy at.
  • -d <description> --description <description>: The deployment description.
  • -i <id> --deploymentId <id>: The deployment ID to redeploy.

Examples

  • clasp deploy (create new deployment and new version)
  • clasp deploy --versionNumber 4 (create new deployment)
  • clasp deploy --description "Updates sidebar logo." (deploy with description)
  • clasp deploy --deploymentId abcd1234 (redeploy and create new version)
  • clasp deploy -V 7 -d "Updates sidebar logo." -i abdc1234

Undeploy

Undeploys a deployment of a script.

Options

  • [deploymentId]: An optional deployment ID.
  • -a --all: Undeploy all deployments.

Examples

  • clasp undeploy (undeploy the last deployment.)
  • clasp undeploy "123"
  • clasp undeploy --all

Version

Creates an immutable version of the script.

Options

  • description: description The description of the script version.

Examples

  • clasp version
  • clasp version "Bump the version."

Versions

List versions of a script.

Examples

  • clasp versions

List

Lists your most recent Apps Script projects.

Examples

  • clasp list: Prints helloworld1 – xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...

Advanced Commands

NOTE: These commands require Project ID/credentials setup (see below).

Logs

Prints out most recent the StackDriver logs. These are logs from console.log, not Logger.log.

Options

  • --json: Output logs in json format.
  • --open: Open StackDriver logs in a browser.
  • --setup: Setup StackDriver logs.
  • --watch: Retrieves the newest logs every 5 seconds.
  • --simplified: Removes timestamps from the logs.

Examples

clasp logs
ERROR Sat Apr 07 2019 10:58:31 GMT-0700 (PDT) myFunction      my log error
INFO  Sat Apr 07 2019 10:58:31 GMT-0700 (PDT) myFunction      info message
  • clasp logs --json
  • clasp logs --open
  • clasp logs --watch
  • clasp logs --simplified

Run

Remotely executes an Apps Script function.

The complete step-by-step information on how to use clasp run is available here: Run
Below is a short summary:

  1. Log in with your credentials (clasp login --creds creds.json), see: Run - Prerequisites
  2. Deploy the Script as an API executable (Easiest done via GUI at the moment).
  3. Enable any APIs that are used by the script, see: Run - Function with Scopes
  4. Have the following in your appsscript.json. Be sure it's pushed:
"executionApi": {
  "access": "ANYONE"
}

Options

  • <functionName>: The name of the function in the script that you want to run.
  • --nondev: If true, runs the function in non-devMode.
  • -p <paramString> --params <paramString>: A JSON string array of parameters to pass to the function

Examples

  • clasp run 'sendEmail'
  • clasp run 'addOptions' -p '["string", 123, {"test": "for"}, true]'

List/Enable/Disable Google APIs

List available APIs. Enables and disables Google APIs.

List APIs

Lists Google APIs that can be enabled as Advanced Services.

  • clasp apis
  • clasp apis list

Enable/Disable APIs

Enables or disables APIs with the Google Cloud project. These APIs are used via services like GmailApp and Advanced Services like BigQuery.

The API name can be found using clasp apis list.

  • clasp apis enable drive
  • clasp apis disable drive

Open APIs Console

Open the Google Cloud Console where you can view and manage API access.

  • clasp apis --open

Help

Displays the help function.

Examples

  • clasp
  • clasp help

Setting

Update .clasp.json settings file.

If settingKey is omitted it prints the current settings. If newValue is omitted it returns the current setting value.

Options

  • settingKey: settingKey The key in .clasp.json you want to change
  • newValue: newValue The new value for the setting

Examples

  • clasp setting
  • clasp setting scriptId
  • clasp setting scriptId new-id

Guides

Ignore File (.claspignore)

Like .gitignore, .claspignore allows you to ignore files that you do not wish to not upload on clasp push. Steps:

  1. Create a file called .claspignore in your project's root directory.
  2. Add patterns to be excluded from clasp push. Note: The .claspignore patterns are applied by multimatch, which is different from .gitignore, especially for directories. To ignore a directory, use syntax like **/node_modules/**.

A sample .claspignore ignoring everything except the manifest and build/main.js:

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

Note: The .claspignore patterns are applied relative from the rootDir.

If no .claspignore is specified, a default set of patterns is applied. This default set will only consider the appsscript.json manifest and any JavaScript, TypeScript and .html source files within the rootDir folder. Child folders other than .git and node_modules are processed.

# ignore all files…
**/**

# except the extensions…
!appsscript.json
!**/*.gs
!**/*.js
!**/*.ts
!**/*.html

# ignore even valid files if in…
.git/**
node_modules/**

Project Settings File (.clasp.json)

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. Example .clasp.json:

{
  "scriptId": "",
  "rootDir": "build/",
  "projectId": "project-id-xxxxxxxxxxxxxxxxxxx",
  "fileExtension": "ts",
  "filePushOrder": ["file1.ts", "file2.ts"]
}

The following configuration values can be used:

scriptId (required)

Specifies the id of the Google Script project that clasp will target.

  1. Open script url.
  2. File > Project properties > Script ID

rootDir (optional)

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

projectId (optional)

Specifies the id of the Google Cloud Platform project that clasp will target. You must associate Google Script project with Google Cloud Platform beforehand.

  1. Run clasp open.
  2. Click Resources > Cloud Platform project....
  3. Specify the project ID project-id-xxxxxxxxxxxxxxxxxxx.

Even if you do not set this manually, clasp will ask this via a prompt to you at the required time.

fileExtension (optional)

Specifies the file extension for local script files in your Apps Script project.

filePushOrder (optional)

Specifies the files that should be pushed first, useful for scripts that rely on order of execution. All other files are pushed after this list of files.

Troubleshooting

NodeJS Version

The library requires NodeJS version >= 12.20.0.

You can check your version of NodeJS with this command.

node -v

You can use these commands to upgrade NodeJS if necessary (not on Windows):

npm install -g npm # Update npm and npx
npx n latest # use the n package to update node

Using a Proxy

Clasp supports proxies via the Google APIs Node Module. See "Using a Proxy" and this discussion for details on how to use the proxy. This requires using the environment variables HTTP_PROXY / HTTPS_PROXY.

README Badge

Using clasp for your project? Add a README badge to show it off: clasp

[![clasp](https://img.shields.io/badge/built%20with-clasp-4285f4.svg)](https://github.com/google/clasp)

Develop clasp

See the develop guide for instructions on how to build clasp. It's not that hard!

Contributing

The main purpose of this tool is to enable local Apps Script development. If you have a core feature or use-case you'd like to see, find a GitHub issue or create a detailed proposal of the use-case. PRs are very welcome! See the issues (especially good first issue and help wanted).

How to Submit a Pull Request

  1. Look over the test cases in test/test.ts, try cases that the PR may affect.
  2. Run gts linter: npm run lint.
  3. Submit a pull request after testing your feature to make sure it works.

⚑ Powered by the Apps Script API.

clasp's People

Contributors

aandis avatar abetomo avatar archerscript avatar arjun-rao avatar aurelienshz avatar campionfellin avatar cruzdanilo avatar dependabot[bot] avatar diminishedprime avatar fossamagna avatar grant avatar jeanremidelteil avatar jondcallahan avatar kalmi avatar kenchan0130 avatar laughdonor avatar mainmode1 avatar msembinelli avatar nirazul avatar oshliaer avatar piotaixr avatar popgoesthewza avatar prprhyt avatar release-please[bot] avatar shouichi avatar sqrrrl avatar takanakahiko avatar tetra2000 avatar tricknotes avatar wilt00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clasp's Issues

Tag your Releases

Expected Behavior

All releases on npm are tagged and in sync with git.

Actual Behavior

Tags are severely lagging and or not tagged on github.

This is important in tracking down bugs and stable versions.

Support proxy network

To use proxy network, like http(s) or socks5, I use http_proxy and https_proxy environment variable that are supported by many tools. Currently, clasp can't work in proxy environment, for example clasp login and clasp clone.

Allow manifest, file list via CLI

Currently the file set to upload in the push command is automatically determined. It would be helpful to be able to specify files (both manifest and js) via the command line as well.

The particular use case is to be able to deploy different configurations -- e.g. in test mode I want to use an alternate manifest with execution API enabled, tests bundled, etc. while in prod mode I want to skip all that. This is particularly important for libraries where we don't want to have long-lived deployments, but may want to temporarily deploy as executable or web app for purposes of running tests and don't want to package code that is only used for resting.. Same can be used for add-ons and other things where we'd like to keep test code & configuration somewhat isolated.

My ideal is to have commands in package.json like:

"scripts": {
"push-test": "clasp push --env=test appsscript.test.json test/.js src/.js"
"push-prod": "clasp push --env=prod appscript.prod.json src/**.js",
...
}

Many CLIs allow specifying files via command line -- tsc, babel, jshint, etc.. all allow specifying which files to operate on as args. Typescript is also very close to what is being asked for. By default, it'll pick up all *.ts files as is the current behavior of clasp. But that can be overridden by explicitly providing a list of globs as args.

`clasp push` changes the execution order of script files in Apps Script projects

Expected Behavior

clasp push should retain the order of the script files in the Apps Script Editor not just visually but also in terms of order of execution.

Actual Behavior

clasp push re-orders the files so that they are executed in alphabetical order even though visually they retain the expected order in the sidebar of the editor. This bug is hazardous to projects that rely on script files to execute as listed in the Apps Script editor.

Steps to Reproduce the Problem

  1. Create a stand-alone script project

  2. In that project create 6 script files in sequence and name them Z, Y, X, C, B and A; each with a Logger.log() that logs their respective names.
    screenshot_1

  3. Create a 7th script file and add the following function:
    screenshot_2

  4. Run that function from the menu bar Run>Run function>runTest and then view the logs View>Logs and you will get the following:
    screenshot_3

  5. Open your terminal and use clasp clone [PROJECT-FILE-ID] and then clasp push from the command line (project file id omitted from screenshot):
    screenshot_4

  6. Then run the test function again and then view the logs and you'll see the following:
    screenshot_5

The execution order of the scripts (though visually correct in the editor's sidebar) is changed to run in alphabetical order!

This bug wreaked havoc on one of my projects before I found it. I would love for clasp to be a part of my development workflow but that won't happen until this issue is resolved.

Specifications

  • Node version - v6.11.0
  • Clasp Version - 3.10.10
  • OS - Windows

View Stackdriver logs

Expected Behavior

clasp logs
(DEBUG) {foo:42} – myFunction [2018-02-21T16:08:06.364Z]
clasp logs --json
[{
  "jsonPayload": {foo:42},
  ...
}, {...}]

Views StackDriver logs (console.log).

Actual Behavior

Command doesn't exist yet.

Notes

Example Stackdriver API result

{
  "insertId": "13oj0ajfyb6tdx",
  "jsonPayload": {foo:42},
  "labels": {…},
  "logName": "projects/project-id-4088669541713651222/logs/script.googleapis.com%2Fconsole_logs",
  "receiveTimestamp": "2018-02-21T16:08:07.370458993Z",
  "resource": {
    "labels": {
      "function_name": "myFunction",
      "invocation_type": "editor",
      "project_id": "project-id-4088669541713651222",
    },
    "type": "app_script_function"
  },
  "severity": "DEBUG",
  "timestamp": "2018-02-21T16:08:06.364Z",
}

Please πŸ‘ if you'd like this feature.

Add possibility to store login by project

Feature request
I have a company project using clasp and a private one. When I'm switching projects, I need to change my clasp login inbetween.
If possible, it'd be nice to store a separate login projectwise instead of a global clasp login.

Don't overwrite appsscript.json on create

Noticed that create does a fetch of the newly created project and overwrites any local files. In some cases that's undesirable (e.g. clone a project from git, create a new project before pushing code.) Would be helpful to skip the fetch if current directory looks like a valid project (e.g. appsscript.json present)

Empty files have "undefined" as contents

Expected Behavior

Empty gs files in apps script should be empty on local filesystem

Actual Behavior

Local file contains "undefined"

Steps to Reproduce the Problem

  1. create an empty gs file in apps script
  2. clasp clone the apps script project
  3. observe that the local file contains "undefined"

Specifications

  • Node version (node -v): 5.8.0
  • Version (npm list | grep clasp): Unknown but from bbf93d7
  • OS (Mac/Linux/Windows): Linux

Add better default `clasp` message.

Currently, the command clasp with no arguments does not print anything.
We should print the output of clasp -h as the default command (clasp).

The last time I checked, the isDefault argument didn't work for npmjs.com/commander. See if we can make it work now.

Add shell functionality (`clasp run`)

Since clasp is running authorised, it would be nice if it could leverage the execution api to add a shell functionality.

Looking at firebase's Cloudfunctions where the shell is a powerfull tool.

Better error message when .claspignore is incorrect

Expected Behavior

Show this:

Push failed. Errors:
Invalid value at 'files[3].type' (TYPE_ENUM), "SUO"
Files to push were:
└─ Code.js
└─ appsscript.json
└─ index.html
└─ node_modules\dateformat\.vs\node-dateformat\v15\.suo
└─ script.js.html
└─ style.css.html

Actual Behavior

instead of this:

Push failed. Errors:
Invalid value at 'files[3].type' (TYPE_ENUM), "SUO"

PR forthcoming

Install fails on Ubuntu 16.04

After having an issue with the install on mac (#3), I gave my other machine a go.

I ran npm i @google/clasp -g per the installation instructions and got a npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules' (full output below). I then ran sudo npm i @google/clasp -g and got npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/resolve-384a17c1' -> '/usr/lib/node_modules/@google/clasp/node_modules/resolve' (full output also below).


Error output from npm i @google/clasp -g:

npm WARN checkPermissions Missing write access to /usr/lib/node_modules
/usr/lib
└─┬ @google/[email protected]
  β”œβ”€β”¬ [email protected]
  β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”‚ └─┬ [email protected]
  β”‚ β”‚ β”‚ β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”‚ β”‚   β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”‚   β”‚ └── [email protected]
  β”‚ β”‚ β”‚ β”‚   β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”‚   β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”‚   β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”‚ β”‚   β”‚ └── [email protected]
  β”‚ β”‚ β”‚ β”‚   └── [email protected]
  β”‚ β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ └─┬ [email protected]
  β”‚ β”‚   └─┬ [email protected]
  β”‚ β”‚     └── [email protected]
  β”‚ └─┬ [email protected]
  β”‚   └── [email protected]
  β”œβ”€β”€ [email protected]
  β”œβ”€β”€ [email protected]
  β”œβ”€β”¬ [email protected]
  β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ └── [email protected]
  β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ └── [email protected]
  β”‚ β”œβ”€β”€ [email protected]
  β”‚ └── [email protected]
  β”œβ”€β”¬ [email protected]
  β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ └─┬ [email protected]
  β”‚ β”‚   └── [email protected]
  β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ └─┬ [email protected]
  β”‚ β”‚   └── [email protected]
  β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”œβ”€β”€ [email protected]
  β”‚ └── [email protected]
  β”œβ”€β”¬ [email protected]
  β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ └─┬ [email protected]
  β”‚ β”‚ β”‚   └─┬ [email protected]
  β”‚ β”‚ β”‚     └─┬ [email protected]
  β”‚ β”‚ β”‚       β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚       β”‚ └── [email protected]
  β”‚ β”‚ β”‚       └─┬ [email protected]
  β”‚ β”‚ β”‚         β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚         β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”‚         β”‚ └─┬ [email protected]
  β”‚ β”‚ β”‚         β”‚   └── [email protected]
  β”‚ β”‚ β”‚         └── [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ └─┬ [email protected]
  β”‚ β”‚ β”‚   └── [email protected]
  β”‚ β”‚ └─┬ [email protected]
  β”‚ β”‚   └── [email protected]
  β”‚ └─┬ [email protected]
  β”‚   β”œβ”€β”¬ [email protected]
  β”‚   β”‚ └── [email protected]
  β”‚   └── [email protected]
  β”œβ”€β”€ [email protected]
  β”œβ”€β”€ [email protected]
  β”œβ”€β”¬ [email protected]
  β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ └── [email protected]
  β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”‚ └── [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚ └─┬ [email protected]
  β”‚ β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”œβ”€β”¬ [email protected]
  β”‚ β”‚   β”‚ └── [email protected]
  β”‚ β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”œβ”€β”¬ [email protected]
  β”‚ β”‚   β”‚ └── [email protected]
  β”‚ β”‚   β”œβ”€β”¬ [email protected]
  β”‚ β”‚   β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚   β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”‚ β”‚ └── [email protected]
  β”‚ β”‚   β”‚ └── [email protected]
  β”‚ β”‚   β”œβ”€β”¬ [email protected]
  β”‚ β”‚   β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚   β”‚ β”‚ └── [email protected]
  β”‚ β”‚   β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”‚ └── [email protected]
  β”‚ β”‚   β”œβ”€β”¬ [email protected]
  β”‚ β”‚   β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”‚ β”œβ”€β”¬ [email protected]
  β”‚ β”‚   β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”‚ β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”‚ β”‚ └─┬ [email protected]
  β”‚ β”‚   β”‚ β”‚   └── [email protected]
  β”‚ β”‚   β”‚ └─┬ [email protected]
  β”‚ β”‚   β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”‚   └── [email protected]
  β”‚ β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”œβ”€β”¬ [email protected]
  β”‚ β”‚   β”‚ └── [email protected]
  β”‚ β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   β”œβ”€β”¬ [email protected]
  β”‚ β”‚   β”‚ └── [email protected]
  β”‚ β”‚   β”œβ”€β”€ [email protected]
  β”‚ β”‚   └── [email protected]
  β”‚ └── [email protected]
  β”œβ”€β”¬ [email protected]
  β”‚ └── [email protected]
  β”œβ”€β”€ [email protected]
  β”œβ”€β”¬ [email protected]
  β”‚ β”œβ”€β”€ [email protected]
  β”‚ └─┬ [email protected]
  β”‚   └── [email protected]
  β”œβ”€β”€ [email protected]
  β”œβ”€β”€ [email protected]
  β”œβ”€β”¬ [email protected]
  β”‚ β”œβ”€β”€ [email protected]
  β”‚ β”œβ”€β”€ [email protected]
  β”‚ └─┬ [email protected]
  β”‚   └── [email protected]
  β”œβ”€β”€ [email protected]
  β”œβ”€β”¬ [email protected]
  β”‚ └─┬ [email protected]
  β”‚   └─┬ [email protected]
  β”‚     β”œβ”€β”€ [email protected]
  β”‚     └── [email protected]
  β”œβ”€β”€ [email protected]
  └─┬ [email protected]
    β”œβ”€β”€ [email protected]
    └── [email protected]

npm ERR! Linux 4.4.0-43-Microsoft
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "i" "@google/clasp" "-g"
npm ERR! node v6.11.4
npm ERR! npm  v3.10.10
npm ERR! path /usr/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR!     at Error (native)
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/whitecoop/npm-debug.log

Error output from sudo npm i @google/clasp -g:

/usr/lib
└── (empty)

npm ERR! Linux 4.4.0-43-Microsoft
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "i" "@google/clasp" "-g"
npm ERR! node v6.11.4
npm ERR! npm  v3.10.10
npm ERR! path /usr/lib/node_modules/.staging/resolve-384a17c1
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename

npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/resolve-384a17c1' -> '/usr/lib/node_modules/@google/clasp/node_modules/resolve'
npm ERR!     at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
npm ERR!     at /usr/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:264:29npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/resolve-384a17c1' -> '/usr/lib/node_modules/@google/clasp/node_modules/resolve'
npm ERR!     at Error (native)
npm ERR!  { Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/resolve-384a17c1' -> '/usr/lib/node_modules/@google/clasp/node_modules/resolve'
npm ERR!     at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
npm ERR!     at /usr/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:264:29npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/resolve-384a17c1' -> '/usr/lib/node_modules/@google/clasp/node_modules/resolve'
npm ERR!     at Error (native) parent: '@google/clasp' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/whitecoop/npm-debug.log
npm ERR! code 1

Here's a gist with the full contents of npm-debug.log (which, based on the numbering in the file, I'm assuming is just from the sudo npm i @google/clasp -g command): https://gist.github.com/whitecoop/75531aa876f5437b6c0c61e188a61f04

Remove fs write warning when fetching

There's a warning showing when fetching a project:

Warning: (node:46497) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
Node version: v9.0.0
Fix: In fetchProject, use a proper callback:

            fs.writeFile(`./${filePath}`, file.source, (err) => {
              if (err) console.error(err);
            });

Error retrieving access token: Error: invalid_grant

I'm getting an odd error when trying to call clasp login. I'm successfully logged in and redirected but clasp is claiming an invalid token. I've also tried a few different accounts.

Steps to Reproduce the Problem

  1. clasp login
  2. allow the right account
  3. login successful return to terminal.
  4. Error retrieving access token: Error: invalid_grant

Specifications

  • Node version: 8.9.2
  • Version (npm list | grep clasp):

⟩ npm list -g | grep clasp
β”œβ”€β”¬ @google/[email protected]

  • OS mac

Clasp deploy doesn't update the deployed version with Google Apps Script Web App

Expected Behavior

Perhaps I'm misunderstanding, but from the readme I'd thought that clasp deploy would allow me to publish a new version of a Web App (in this case bound to a google sheet).

I'd expected the workflow to be as follows:

  1. clasp version "My new version"

Created version xx.

  1. clasp deploy xx

yyyyyyyyyyyyyyyyy @XX

  1. clasp open
    browser opens to newly published version "xx"

Actual Behaviour

The version is created as expected, but the web app Project Version remains at the last deployed version not the version used with clasp deploy. To actually deploy it I have to go into the Script Editor then Publish > Deploy as Web App and then select the version "xx"

Related Issues

This seems related to #43, however that issue specifically relates to Chrome store apps and this is a Web App which the comments on that issue suggest should be supported.

Error: Request contains an invalid argument

Expected Behavior

Push code to script project

Actual Behavior

Request fails on clasp push:
Push failed. Errors:
Request contains an invalid argument.

Steps to Reproduce the Problem

My current project directory looks like:
-a---- 14.02.2018 13:15 73 .clasp.json
-a---- 02.03.2018 16:14 48 .claspignore
-a---- 02.03.2018 16:19 1172 appsscript.json

Push should defenetly work, there is not an issue with "ignoring" some files.

Specifications

  • Node version (node -v): v6.11.3
  • Version (npm list | grep clasp): +-- @google/[email protected]
  • OS (Mac/Linux/Windows): windows 10

UPD: there was a typo in appscript.json :/

TypeError: console.err is not a function

clasp/index.js

Line 417 in 4cf4cc9

console.err(err);

This has logged an error in terminal(see below). Should be console.error() instead?

TypeError: console.err is not a function
at fs.writeFile (/usr/local/lib/node_modules/@google/clasp/index.js:417:23)
at /usr/local/lib/node_modules/@google/clasp/node_modules/graceful-fs/graceful-fs.js:43:10
at FSReqWrap.oncomplete (fs.js:135:15)

Multiple project push

Expected Behavior

Abiliy pushing a project to multiple destination over add anoder id in '.clasp.json'

Actual Behavior

Steps to Reproduce the Problem

Specifications

  • Node version (node -v)
  • Version (npm list | grep clasp):
  • OS (Mac/Linux/Windows)

clasp status: List files that are updated by push/pull

Expected Behavior

Running clasp status shows a list of files/directories that will be synced with script.google.com when using clasp push and clasp pull.

Proposed Example:

$ clasp status
Tracked by clasp:
.
β”œβ”€β”€ Code.js
β”œβ”€β”€ appsscript.json
└── html
    β”œβ”€β”€ Template.html
    └── javascript.html
1 directory, 4 files

Untracked:
.
└── node_modules/

The directory listing is similar to the tree command in linux or mac (via homebrew) that can be implemented using something like tree-cli

Untracked files can be picked up based on listing in .claspignore much like the way .gitignore works.

Support options to specify dotfiles

Please support options to specify dotfiles. e.g: .clasp.json, .clasprc.json.

I would like to switch enviroment to deploy. eg: development, production...
So, If I can specify dotfiles by clasp's options, it is very useful.

Possible to specify directory for push / pull ?

Expected Behavior

I have my source files in an src directory, but do some transpiling which outputs the files to a build directory. Is it possible to specify a directory to push files from?

Actual Behavior

Files are pushed and pulled from the root of the repo

Specifications

  • Node version (node -v): any
  • Version (npm list | grep clasp): 1.0.7
  • OS (Mac/Linux/Windows): Mac

node.js - DeprecationWarning [DEP0013]

First of all: Thank you for this project, this is a godsend! I really like the idea of google AppScript but it's just a pain to develop without a proper IDE.

Upon trying it out, I've come upon a deprecation warning when cloning a project with node 8.9.3:

Cloned 4 files.
└─ Main.gs
(node:4835) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
└─ Api.gs
(node:4835) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
└─ Format.gs
(node:4835) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
└─ appsscript.json
(node:4835) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.

The warning relates to this Deprecation.

I've looked at the code but it seems that I'd have to dig into one of the dependencies. So for the time being, I'm just placing it here if anyone else stumbles upon it.

Do not rename .gs files to .js before pushing

Expected Behavior

When using : clasp push
a file named: Code.gs is still named Code.gs (locally, i'm not talking about remote)

Actual Behavior

When using : clasp push
a file named: Code.gs is renamed to Code.js

The project files should not be changed by the pushing operation.
Any preparation to the push operation should be done by the tool, without affecting project files.

Steps to Reproduce the Problem

  1. use clasp push with *.gs files

Specifications

  • Version (npm list | grep clasp): 1.1.5
  • OS (Mac/Linux/Windows): all ?

Structure code: use the SAME structure char '/' for both window and other OS

Expected Behavior

The structure separator char should always be the same ('/') not depending on the OS you are running CLASP.

On script.google.com:

  • tests/slides.js
  • tests/sheets.js

locally:

  • tests/
    • slides.js
    • sheets.js

Actual Behavior

On Windows:

On script.google.com:

  • tests\slides.js
  • tests\sheets.js

locally on window:

  • tests/
    • slides.js
    • sheets.js

Steps to Reproduce the Problem

  1. On a computer with windows
  2. push your clasp project to a script file
  3. open the project on script.google.com

Specifications

  • OS (Windows)

Better Debug Logging

Optional debug logging would go a long way in figuring out what is going on in the clasp API when things do not work as expected. A very common practice in the node community is to utilize debug. If you want to gain lazy logging please have a look at debug-fabulous (shameless plug).

Expected Behavior

export DEBUG="@google/clasp*"

@google/clasp:getProjectSettings oh hi I am a debug statement

To turn on useful optional log messages.

Actual Behavior

Only errors are logged.

Examples

https://github.com/gulp-sourcemaps/gulp-sourcemaps/blob/master/src/debug.js#L1

https://github.com/gulp-sourcemaps/gulp-sourcemaps/blob/master/src/init/index.js#L49

Install on mac fails

I'm running MacOS 10.11.6.

I ran the install with npm i @google/clasp -g. After the install clasp -h output -bash: clasp: command not found.

I then tried sudo npm i @google/clasp -g and got the same result.

I also restarted my terminal after both installs.

Looks like a path thing, but I haven't dug further. node -v gives v5.4.0 and npm -v gives v3.3.12

gcp-metadata module not found

Expected Behavior

no error?

Actual Behavior

Module not found error

Error: Cannot find module 'gcp-metadata'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._load (module.js:482:25)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/@google/clasp/node_modules/google-auth-library/build/src/auth/googleauth.js:55:19)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)

Steps to Reproduce the Problem

  1. Ran npm install -g @google/clasp
  2. Any clasp command issues same error

Specifications

  • Node version (node -v): 9.4
  • Version (npm list -g | grep clasp): 1.1.1
  • OS (Mac/Linux/Windows): mac 10.13

Feature Request - Additions to CLI UI

@grant
Would you be open to adding some stying to the CLI like Firebase CLI?
If so, it would be great to be involved!

image

I have some suggestions using the same NPM packages that are used in the Firebase CLI.

Firstly is to add something to make the main clasp text stand out using figlet.js (possibly something like the images below but other suggestions are welcome):
clasp-cli

Second is to add some styling to errors and user input with chalk and Inquirer.js. An example of this might be to ask the user to set a name for otherwise undefined projects or to get them to select deployment versions. Similar to the Firebase CLI and Webpack CLI.

Thanks πŸ‘

clasp deploy does not publish a new version of a Google Docs add-on

I might be misunderstanding the term "deployment" in the context of this CLI. I expect that when I deploy a new version of my add-on, it would publish a new version of the add-on.

Expected Behavior

That clasp deploy {version} would publish a new version of my Google docs add-on.

Actual Behavior

After running the above command and test out the published add-on, I don't see the changes in the version used above.

Steps to Reproduce the Problem

  1. Publish an add-on with initial functionality
  2. Make some noticeable changes to the add-on (so that you know if it gets published)
  3. Use clasp push to get your changes into your Google script
  4. Use clasp version and clasp deploy {version} to deploy your changes
  5. Test out add-on to see the published changes

Specifications

  • Node version (node -v): v8.9.4
  • Version (npm list | grep clasp): 1.1.1
  • OS (Mac/Linux/Windows): Windows

A new tab is opened when `clasp open` is executed

Expected Behavior

When I run clasp open, I want you to refresh the tab if there is a previously opened tab.

Actual Behavior

Another tab opens.
That behavior makes it hard to tell which is the latest code.

Steps to Reproduce the Problem

  1. invoke: clasp open
  2. invoke: clasp open

Specifications

  • Node version (node -v): v8.9.3
  • Version (npm list | grep clasp): 1.0.7
  • OS (Mac/Linux/Windows): Mac

"Error: Request contains an invalid argument" on push and deploy

Expected Behavior

Push code to script project

Actual Behavior

Request fails on clasp push and on clasp redeploy. Redeploy has a more verbose error report:

    at new RequestError (/usr/lib/node_modules/@google/clasp/node_modules/google-auth-library/lib/transporters.js:34:42)
    at Request._callback (/usr/lib/node_modules/@google/clasp/node_modules/google-auth-library/lib/transporters.js:96:27)
    at Request.self.callback (/usr/lib/node_modules/@google/clasp/node_modules/request/request.js:186:22)
    at Request.emit (events.js:159:13)
    at Request.<anonymous> (/usr/lib/node_modules/@google/clasp/node_modules/request/request.js:1163:10)
    at Request.emit (events.js:159:13)
    at IncomingMessage.<anonymous> (/usr/lib/node_modules/@google/clasp/node_modules/request/request.js:1085:12)
    at Object.onceWrapper (events.js:254:19)
    at IncomingMessage.emit (events.js:164:20)
    at endReadableNT (_stream_readable.js:1062:12)
  code: 400,
  errors:
   [ { message: 'Request contains an invalid argument.',
       domain: 'global',
       reason: 'badRequest' } ] }

The auth library fails, so i tried logging back in and out and into another account to no avail

Steps to Reproduce the Problem

  1. My current project directory looks like:
β”œβ”€β”€ appsscript.json  
β”œβ”€β”€ build  
β”œβ”€β”€ node_modules  
β”œβ”€β”€ package.json  
β”œβ”€β”€ package-lock.json  
β”œβ”€β”€ README.md  
└── src  

With src and build as directories. The main apps script in my project is called build/Main.gs and should be pushed from the build directory.
2. My build system is currently just using babel to transpile syntax and perform a simple bundle of the src directory.
Besides that, I don't know what's out of the ordinary with my project. My Google account is personal, not organizational, so the auth issues don't come from that....

Specifications

  • Node version (node -v): v9.3.0
  • Version (npm list | grep clasp): @google/[email protected]
  • OS (Mac/Linux/Windows): Windows 10, WSL running Ubuntu 16.04

clasp push hangs

Expected Behavior

Times out and or have a debugging capability from #65 to figure out why it is hanging.

Actual Behavior

❯ clasp push
\ Pushing files...   

Goes on forever

Offline Error Messages

If a user executes the clasp push command while the network is silently down, the following errors are shown. Can the script check for network connection before proceeding?

Push failed. Errors:
(node:67970) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
    at /Users/labnol/digitalinspiration/node_modules/@google/clasp/index.js:587:46
    at /Users/labnol/digitalinspiration/node_modules/google-auth-library/build/src/auth/oauth2client.js:396:24
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
(node:67970) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:67970) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

[email protected]

For the next version of clasp, I'd like to make it ridiculously simple and easy to use the tool.
Let's use features of modern CLIs.

Features

  • clasp/clasp push --watch (watches project file changes, pushes and logs updates)
  • clasp list #93 (requires Drive Scope)
  • clasp run foo #11 (define deployment name?)
  • clasp clone <scriptID> (autocomplete #69)
  • clasp logs #46
  • Optional Typescript Support #77 (Types / No Types)
    • Create a conversion guide (ex)
  • Autocomplete (vorpal) (example)
    • tab complete
    • select options

These updates will require a major version update (v2).

Docs

  • Update docs with all options for all commands
  • Add examples of ignoring files
    • clasp status?
  • Add a better way to version npm/git versions

Social

  • Blog (ex)
  • Video
  • Tweet

.claspignore fails **/node_modules/**

Expected Behavior

**/node_modules/**
**/**

Ignores all files in node_modules .

Actual Behavior

 follow-redirects options { protocol: 'https:',
  maxRedirects: 21,
  maxBodyLength: 10485760,
  path: '/v1/projects/SCRUBBED/content',
  method: 'put',
  headers:
   { Accept: 'application/json, text/plain, */*',
     'Content-Type': 'application/json;charset=utf-8',
     Authorization: 'Bearer SCRUBBED',
     'User-Agent': 'google-api-nodejs-client/1.3.1',
     'Content-Length': 3879 },
  agent: undefined,
  auth: undefined,
  hostname: 'script.googleapis.com',
  port: null,
  nativeProtocols:
   { 'http:':
      { _connectionListener: [Function: connectionListener],
        METHODS: [Array],
        STATUS_CODES: [Object],
        Agent: [Object],
        ClientRequest: [Object],
        globalAgent: [Object],
        IncomingMessage: [Object],
        OutgoingMessage: [Object],
        Server: [Object],
        ServerResponse: [Object],
        createServer: [Function: createServer],
        get: [Function: get],
        request: [Function: request] },
     'https:':
      { Server: [Object],
        createServer: [Function: createServer],
        globalAgent: [Object],
        Agent: [Object],
        request: [Function: request],
        get: [Function: get] } } } +0ms
Push failed. Errors:
Invalid value at 'files[2].type' (TYPE_ENUM), "D"

node_modules/fsevents/build/Release/.deps/Release/.node.d Is getting picked up with the following error.

Added logging to clasp produces:

{ name: 'node_modules/fsevents/build/Release/.deps/Release/.node.d' }
{ name: 'node_modules/fsevents/build/Release/.deps/Release/.node',
  type: 'D',
....}

from adding:

if (getAPIFileType(name) && !anymatch(ignorePatterns, name)) {
                                                nonIgnoredFilePaths.push(name);
                                                var file = {
                                                    name: formattedName,
                                                    type: getAPIFileType(name),
                                                    source: contents[i] //the file contents
                                                };
                                                console.log({name});
                                                console.log(file);
                                                return file;
                                            }

Only ignore which did work:

node_modules/**
node_modules/fsevents/build/Release/.deps/Release/.node.d
**/**

Specifications

  • Node version (node -v) : v8.9.4
  • Version (npm list | grep clasp): "@google/[email protected]"
  • OS (Mac/Linux/Windows): MAC

Maybe you guys should update or drop anymatch?

clasp push β€”watch

Add an option to watch local file changes and clasp push on file change.

clasp push β€”-watch

Use: https://www.npmjs.com/package/node-watch
Something like:

const watch = require('node-watch');
getProjectSettings().then(({ scriptId, rootDir }: ProjectSettings) => {
  watch(rootDir, { recursive: true }, (e, name) => {
    console.log(`${name} changed. Pushing...`);
    // Push...
    console.log('Pushed');
  });
}

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.