0

Simply making files in the directory does not add them to the project. Is there a way to make sure they get pushed with the rest of the project, or am I doomed to creating them in the web editor and then pulling?

tehhowch
  • 9,645
  • 4
  • 24
  • 42
J. G.
  • 1,922
  • 1
  • 11
  • 21
  • You can create spreadsheets in apps script. Look at [SpreadsheetApp Class](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app) or the [DriveApp Class](https://developers.google.com/apps-script/reference/drive/drive-app) in the documentation. Spreadsheets aren't really part of a project. The [project](https://developers.google.com/apps-script/guides/projects) just contains gs and html files. If the script is bound to a Spreadsheet then you can open it with SpreadsheetApp.getActive() but when you save a project you're not saving any spreadsheets. – Cooper Jan 29 '19 at 21:54
  • According to the docs (https://github.com/google/clasp#push) they should get pushed just fine, provided they are the correct type. You don't mention the kinds of files you're creating, or what the output of `clasp status` is, so we can't do anything but suggest you help us help you. – tehhowch Jan 29 '19 at 21:59
  • tehhowch; Creating new JS scripts. There isn't a visible file listing I can add them to, and simply having new files in the folder doesn't seem to work. For example I want to make a "test" file that contains functions that test other functions, as it stands now I have to open the project server side, create a new blank script and then pull it again. – J. G. Jan 30 '19 at 00:11
  • Cooper, I want to make more script (gs/js) files not spreadsheets. – J. G. Jan 30 '19 at 00:12
  • 1
    @J.G. I'd say you're actually experiencing this bug: https://github.com/google/clasp/issues/507 https://issuetracker.google.com/123311608 – tehhowch Jan 31 '19 at 20:48

1 Answers1

1

Any .js or .html files in the directory not excluded by the .claspignore file will be pushed to the associated Apps Script project. You can view these files with clasp status.

Official Description:

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

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)

e.g.

$ clasp create
 ...
$ echo 'function foo() { console.log("This is a Stackdriver log"); }' > newFile.js
$ clasp status
Not ignored files:
└─ appsscript.json
└─ newFile.js

Ignored files:
└─ .clasp.json
$ clasp push
└─ appsscript.json
└─ newFile.js
Pushed 2 files.
$ clasp open
Opening script: https://script.google.com/d/..../edit

In the Script Editor, you will observe the files that were pushed by clasp push. If you perform an immediate clasp pull, you will not observe differences in the files (well, perhaps other than LF/CRLF conversions).

if so, the solution is to push a second time before opening the editor.

$ clasp push && clasp push
  ...
$ clasp open
tehhowch
  • 9,645
  • 4
  • 24
  • 42