Clasp: Clasp can't seem to see bound script projects

Created on 4 Jun 2018  路  11Comments  路  Source: google/clasp

Expected Behavior

clasp list should show all of my script projects, including those bound to G Drive documents like spreadsheets.

Actual Behavior

clasp list doesn't show bound script projects.

The FileSubmission project is owned by someone else and shared with me.

image

Steps to Reproduce the Problem

  1. Create a spreadsheet document in the G Drive of the same account you're logged into Clasp with.
  2. Add a script project to the spreadsheet.
  3. clasp list

Specifications

  • Node version 10.3.0
  • Clasp version 1.3.1
  • Windows 10 x64 v 1803
API support needed feature request

Most helpful comment

That documentation isn't entirely correct. You can also get to bound scripts from https://script.google.com.

Interacting with bound scripts using clasp does work, but the URL method of getting the script ID is unreliable. If you open your script project from https://script.google.com, it's likely fine. However, if you open it from Tools -> Script editor in the bound document, the URL doesn't match the expected format.

Expected: https://script.google.com/d/<SCRIPT_ID>/edit

Actual: https://script.google.com/macros/d/<MYSTERY_ID>/edit

The only sure way of getting the right value is from File -> Project properties -> Info -> Script ID.

All 11 comments

I think we're currently limited by the API on this one.

  • clasp list uses the Drive API

    • which maybe can't detect bounded scripts?

  • The Apps Script API doesn't have a method for listing projects.

Let me know if you see the scripts with the "Try this API" function on this page:
https://developers.google.com/drive/api/v3/reference/files/list

Query:
https://github.com/google/clasp/blob/master/src/commands.ts#L157

No dice. :cry: All that gets returned is the document it's bound to:

{
  "kind": "drive#file",
  "id": "<snip>",
  "name": "XP Logbook",
  "mimeType": "application/vnd.google-apps.spreadsheet"
}

Just to be sure, I grepped the output for application/vnd.google-apps.script, but nothing.

I am also interested in container (bound) scripts and I was looking for a way to automate it with clasp.

https://developers.google.com/apps-script/guides/bound

"Creating a bound script

To create a bound script, open a Google Sheets, Docs, or Forms file, then select Tools > Script editor. To reopen the script in the future, do the same thing. Because bound scripts do not appear in Google Drive, that menu is the only way to find or open the script."

I have looked into Google Sheet API, Google Drive API and Google App Scripts API for a way to get the container (bound) script id but I have not found anything.

That documentation isn't entirely correct. You can also get to bound scripts from https://script.google.com.

Interacting with bound scripts using clasp does work, but the URL method of getting the script ID is unreliable. If you open your script project from https://script.google.com, it's likely fine. However, if you open it from Tools -> Script editor in the bound document, the URL doesn't match the expected format.

Expected: https://script.google.com/d/<SCRIPT_ID>/edit

Actual: https://script.google.com/macros/d/<MYSTERY_ID>/edit

The only sure way of getting the right value is from File -> Project properties -> Info -> Script ID.

@ShowMeBillyJo Can you file an issue against the Drive API so the team can eventually implement this?

https://issuetracker.google.com/issues/new?component=191650&template=824106

Then please update the above issue comment with a link to the bug.

If anyone could create an issue with the above link, and then comment, that would be very helpful to make progress on this bug.

Work-around for existing projects:

As @ShowMeBillyJo mentioned, you can get the correct script ID from https://script.google.com. Then I used this ID to replace the one in my .clasp.json file, and it seems to be working.

To be clear, you can clone bound scripts, but just not list them.

Example:

clasp clone "https://script.google.com/d/fWc1OG320D82xo5wYVfqivevzZEItbPP3v7l1eh7XQTEm3vZe3YZpjwuD/edit"

Source for Drive List:

https://github.com/google/clasp/blob/master/src/commands/list.ts#L25

Have someone Issue a feature request? I did not found any.
If so, them link here.

Have someone Issue a feature request? I did not found any.
If so, them link here.

Nobody has filed a FR yet.

Now issued an Feature Request to Drive Api.
(https://issuetracker.google.com/issues/139438152)

I ask to include scripts projetcs inside Docs, etc. in drive.file.list

I also suggest to make this files external and make then only linked to Script projects.
In that way, one Project could to linked to many Forms, Docs, etc. and may be one file be linked to many script projects. Leaving the need to make Addons.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tehhowch picture tehhowch  路  3Comments

grant picture grant  路  4Comments

nmccready picture nmccready  路  5Comments

imthenachoman picture imthenachoman  路  3Comments

labnol picture labnol  路  4Comments