I had cloned an app script with this terminal command
clasp clone <scriptId>
to this folder:
.../desktop/AppsScriptProjects
and the files were downloaded to the folder
.../desktop/AppsScriptProjects/AppsScriptName
but now, I want to create a new Apps Script.
I navigated back to:
.../desktop/AppsScriptProjects
and executed:
clasp create "Test Project"
but I got the error:
Nested clasp projects are not supported.
What am I doing wrong?
Version Info:
OS: Mac Os (Mojave)
Node: v10.15.3
Clasp: 2.1.0
When I run ls -a
on the directory that I intend to create a new apps script and all I got was :
. ..
The issue is that clasp create <words>
creates a project in the current directory, with the script project name <words>
, and no files other than appsscript.json
and .clasp.json
.
Even when given a --rootDir <folder name>
argument, the project is created in the current directory. This is the same behavior as clasp clone
, in that the clone is performed to the current directory.
So:
$ cd ~/clasp_projects
$ clasp create "project 1"
Clone which script? (Use arrow keys)
Clone which script? standalone
Created new standalone script <...>
$ ls -a
./ ../ .clasp.json appsscript.json
If you had instead supplied a root directory too:
$ cd ~/clasp_projects
$ mkdir "project 1"
$ clasp create "project 1" --rootDir "project 1"
Clone which script? (Use arrow keys)
Clone which script? standalone
Created new standalone script <...>
$ ls -a
./ ../ .clasp.json appsscript.json 'project 1'/
$ ls -a "project 1"
./ ../
not much would be different.
For both cases, your current directory would now have a .clasp.json
file, indicating to clasp that this is a clasp-associated repo and corresponds to a single Apps Script project. In your case, you have the following directory structure:
AppsScriptProjects/
`--- AppsScriptName/
|--- .clasp.json
|--- appsscript.json
|--- myscript.js
...
When you attempt to invoke clasp create "Test Project"
from AppsScriptProjects/
, you are telling clasp to create this structure:
AppsScriptProjects/
|--- AppsScriptName/
| |--- .clasp.json
| |--- appsscript.json
| |--- myscript.js
| ...
|--- .clasp.json
`--- appsscript.json
Instead of the above approaches, create & cd into "Test Project/"
:
$ cd AppsScriptProjects
$ mkdir "Test Project"
$ cd "Test Project"
$ clasp create
...
which will then yield
AppsScriptProjects/
|--- AppsScriptName/
| |--- .clasp.json
| |--- appsscript.json
| |--- myscript.js
| ...
`--- Test Project/
|--- .clasp.json
`--- appsscript.json
In short: clasp
works with your current directory. It does not create projects in child directories. While it can create project files in child directories, the project directory (in which you can find .clasp.json
) is the directory in which you invoked clasp
.