Skip to content

Commit f8a471c

Browse files
authored
Feature/update clasp (#106)
* update to @google/[email protected] - Add npm run open command - Update readme to explain how to add existing script and document which works with npm run open - Remove npm run setup:use-id command
1 parent 405cf20 commit f8a471c

File tree

3 files changed

+2842
-1090
lines changed

3 files changed

+2842
-1090
lines changed

README.md

+36-32
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,21 @@ Alternatively, you can use an existing Google Spreadsheet and Script file instea
104104
<details>
105105
<summary>See instructions here for using an existing project.</summary>
106106

107-
1. Copy your existing script project's `scriptId`. You can find it by opening your spreadsheet, selecting **Tools > Script Editor** from the menubar, then **File > Project properties**.
108-
109-
2. Run the command below using your project's `scriptId`:
107+
You will need to update the `.clasp.json` file in the root of this project with the following three key/value pairs:
108+
109+
```json
110+
{
111+
"scriptId": "1PY037hPcy................................................",
112+
"parentId": ["1Df30......................................."],
113+
"rootDir": "./dist"
114+
}
115+
```
110116

111-
```bash
112-
npm run setup:use-id your_script_id_here
113-
```
117+
- `scriptId`: Your existing script project's `scriptId`. You can find it by opening your spreadsheet, selecting **Tools > Script Editor** from the menubar, then **File > Project properties**, and it will be listed as "Script ID".
114118

115-
This command will add the existing project's `scriptId` to your`.clasp.json` file. See [here](https://github.com/google/clasp#setting) for working with `clasp`.
119+
- `parentId`: An array with a single string, the ID of the parent file (spreadsheet, doc, etc.) that the script project is bound to. You can get this ID from the url, where the format is usually `https://docs.google.com/spreadsheets/d/{id}/edit`. This allows you to run `npm run open` and open your file directly from the command line.
116120

117-
<img width="100%" src="https://i.imgur.com/VYl3JHx.gif">
121+
- `rootDir`: This should always be `"./dist"`, i.e. the local build folder that is used to store project files.
118122

119123
</details>
120124

@@ -132,7 +136,7 @@ npm run deploy
132136

133137
The deploy command will build all necessary files using production settings, including all server code (Google Apps Script code), client code (React bundle), and config files. All bundled files will be outputted to the `dist/` folder, then pushed to the Google Apps Script project.
134138

135-
Now open Google Sheets and navigate to your new spreadsheet (e.g. the file "My React Project"). Make sure to refresh the page if you already had it open. You will now see a new menu item appear containing your app!
139+
Now open Google Sheets and navigate to your new spreadsheet (e.g. the file "My React Project"). You can also run `npm run open`. Make sure to refresh the page if you already had it open. You will now see a new menu item appear containing your app!
136140

137141
<img width="100%" src="https://i.imgur.com/W7UkEpv.gif">
138142

@@ -148,34 +152,34 @@ There are two steps to getting started: installing a certificate (first time onl
148152

149153
1. Generating a certificate for local development <a name = "generatingcerts"></a>
150154

151-
Install the mkcert package:
155+
Install the mkcert package:
152156

153-
```bash
154-
# mac:
155-
$ brew install mkcert
157+
```bash
158+
# mac:
159+
brew install mkcert
156160

157-
# windows:
158-
$ choco install mkcert
159-
```
161+
# windows:
162+
choco install mkcert
163+
```
160164

161-
[More install options here.](https://github.com/FiloSottile/mkcert#installation)
165+
[More install options here.](https://github.com/FiloSottile/mkcert#installation)
162166

163-
Then run the mkcert install script:
167+
Then run the mkcert install script:
164168

165-
```bash
166-
$ mkcert -install
167-
```
169+
```bash
170+
mkcert -install
171+
```
168172

169-
Create the certs in your repo:
173+
Create the certs in your repo:
170174

171-
```
172-
npm run setup:https
173-
```
175+
```
176+
npm run setup:https
177+
```
174178

175179
2. Now you're ready to start:
176-
```bash
177-
npm run start
178-
```
180+
```bash
181+
npm run start
182+
```
179183

180184
The start command will create and deploy a development build, and serve your local files.
181185

@@ -200,17 +204,17 @@ You will need to use the "standalone" version of React DevTools since our React
200204

201205
1. In your repo install the React DevTools package as a dev dependency:
202206

203-
```bash
204-
npm install -D react-devtools
205-
```
207+
```bash
208+
npm install -D react-devtools
209+
```
206210

207211
2. In a new terminal window run `npx react-devtools` to launch the DevTools standalone app.
208212

209213
3. Add `<script src="http://localhost:8097"></script>` to the top of your `<head>` in your React app, e.g. in the [index.html](https://github.com/enuchi/React-Google-Apps-Script/blob/e73e51e56e99903885ef8dd5525986f99038d8bf/src/client/dialog-demo-bootstrap/index.html) file in the sample Bootstrap app.
210214

211215
4. Deploy your app (`npm run deploy:dev`) and you should see DevTools tool running and displaying your app hierarchy.
212216

213-
<img width="100%" src="https://user-images.githubusercontent.com/31550519/110273600-ee9eae80-7f9a-11eb-9796-31353b47dfa8.gif">
217+
<img width="100%" src="https://user-images.githubusercontent.com/31550519/110273600-ee9eae80-7f9a-11eb-9796-31353b47dfa8.gif">
214218

215219
5. Don't forget to remove the `<script>` tag before deploying to production.
216220

0 commit comments

Comments
 (0)