Skip to content

Commit 11772b5

Browse files
committed
Update instructions for new clasp template
1 parent 83693ce commit 11772b5

2 files changed

Lines changed: 42 additions & 79 deletions

File tree

-460 Bytes
Binary file not shown.

content/misc/clasp/index.md

Lines changed: 42 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,55 @@
11
+++
22
title='CLASP'
33
date = 2023-04-17
4-
updated = 2026-05-07
4+
updated = 2026-05-08
55
taxonomies = { tags = ["Misc"] }
66
aliases=["/git/new-clasp"]
77
+++
88

9-
# New project setup
9+
{{ enable_checkboxes() }}
1010

11-
- Create new git repo (see [instructions](@/git/new_repo.md) if needed)
12-
- Create Scripts project (On Google Scripts, Sheets, etc.)
13-
- Clone Scripts Project into repo folder using clasp
11+
# Setup
1412

15-
```sh
16-
clasp clone <scriptID>
17-
```
13+
If this is your first time using clasp or first time on a new computer the best instructions to get started can be found in the Readme of the project it self at <https://github.com/google/clasp>
1814

19-
- Copy Hook and .gitignore from template
20-
folder `repos/zTemplates/clasp/CopyContentsToProjectRoot/` or create folder to copy from
21-
using [this zip file](CopyContentsToProjectRoot.tar.xz).
15+
In particular you will need:
2216

23-
## Steps if using TypeScript (TS)
17+
- To install [Node.js](https://nodejs.org/en/download/)
18+
- To install clasp
19+
```sh
20+
npm install -g @google/clasp
21+
```
22+
- And the enable the to use the Google Apps Script API: <https://script.google.com/home/usersettings>
2423

25-
This version is was based on the then version of <https://developers.google.com/apps-script/guides/typescript> which linked out to https://github.com/google/clasp/blob/master/docs/typescript.md but they no longer provide typescript. See excerpt from the github [readme][drop_clasp_typescript] below.
24+
# How to use
2625

27-
> #### [Drop typescript support][drop_clasp_typescript]
28-
>
29-
> Clasp no longer transpiles typescript code. For typescript projects, use typescript with a bundler like Rollup to transform code prior to pushing with clasp.
26+
- Once everything has been setup (ie. both [Setup](@/misc/clasp/index.md#setup) and [New project setup](@/misc/clasp/index.md#new-project-setup) are completed)
27+
- Edit your code inside of the `src` folder then use `npm run deploy` to upload to the cloud
28+
- See other commands in `package.json`
29+
- You can use clasp normally as the `rootDir` is set but you need to bundle the typescript first so you would need to use `npm run build`.
3030

31-
- Add Type definitions for Apps Script
31+
# New project setup
3232

33-
```sh
34-
npm i -S @types/google-apps-script
35-
```
33+
- [ ] Create new git repo from the [template repo](template_repo) (big green button on top right)
34+
- [ ] Create Google Apps Script project (On Standalone, Sheets, etc.)
35+
- [ ] Clone Scripts Project into an **EMPTY FOLDER** using clasp (We won't be keeping this folder we just need two files from the clone)
36+
```sh
37+
clasp clone <scriptID>
38+
```
39+
- [ ]Copy/Move `.clasp.json` and `appsscript.json` into the root of the repo created from the template.
40+
- [ ] You may delete the temporary folder at this point
41+
- [ ] Edit `.clasp.json` to set the `rootDir` to `dist`
42+
```json
43+
"rootDir": "dist",
44+
```
45+
- [ ] Install npm dependencies
46+
```sh
47+
npm install
48+
```
3649

37-
- Add ts_lib
50+
## Additional Steps for Wykies Library
51+
52+
- [ ] Add ts_lib
3853
- Part of wykies
3954

4055
```sh
@@ -47,55 +62,13 @@ npm i -S @types/google-apps-script
4762
git submodule add git@github.com:wykies/ts_lib.git
4863
```
4964

50-
- (Optional) Use the following command to push and watch the ts files. Watch is not required.
51-
52-
```sh
53-
clasp push --watch
54-
```
55-
56-
### TypeScript Modules, exports and imports
57-
58-
Original Source was: https://github.com/google/clasp/blob/master/docs/typescript.md#the-namespace-statement-workaround but they are [dropping typescript support][drop_clasp_typescript].
59-
60-
Instead of normal imports use the following as import is not supported in GAS
61-
62-
```ts
63-
// module.ts
64-
namespace MyLib {
65-
export function foo() {
66-
}
67-
68-
function bar() {
69-
} // this function can only be addressed from within the `MyLib` namespace
70-
}
71-
```
72-
73-
```ts
74-
// anyFiles.ts
75-
MyLib.foo(); // address a namespace's exported content directly
76-
```
77-
78-
## Steps if using Javascript (JS)
79-
80-
- Add js_lib
81-
82-
```sh
83-
git submodule add ../js_lib.git
84-
```
85-
8665
# Converting an existing Javascript (JS) project to TypeScript (TS)
8766

88-
- Copy over from template to update ignore and hooks [last step in new](@/misc/clasp/index.md#new-project-setup)
89-
- Remove `js_lib` if in use see [removal instructions for submodule](@/git/submodules.md#remove-a-submodule)
90-
- Change all `.js` files to `.ts` files
91-
- Follow normal instructions from [New TS project](@/misc/clasp/index.md#steps-if-using-typescript-ts)
92-
93-
# Useful Commands
94-
95-
- `clasp clone <scriptID>` [Clone an existing project](https://developers.google.com/apps-script/guides/clasp#clone_an_existing_project)
96-
- `clasp pull` [Download a script project](https://developers.google.com/apps-script/guides/clasp#download_a_script_project)
97-
- `clasp push` [Upload a script project](https://developers.google.com/apps-script/guides/clasp#upload_a_script_project)
98-
- `clasp open` [Open the project in the Apps Script editor](https://developers.google.com/apps-script/guides/clasp#open_the_project_in_the_editor)
67+
- [ ] Move files into a directory called `src`
68+
- [ ] Remove `js_lib` if in use see [removal instructions for submodule](@/git/submodules.md#remove-a-submodule)
69+
- [ ] Change all `.js` files to `.ts` files
70+
- [ ] Download
71+
- [ ] Follow normal instructions from [New TS project](@/misc/clasp/index.md##additional-steps-for-wykies-library)
9972

10073
# Ignore files
10174

@@ -124,14 +97,4 @@ Uses [multimatch](https://github.com/sindresorhus/multimatch)
12497
js_lib/**
12598
```
12699

127-
# Installation
128-
129-
Source: <https://developers.google.com/apps-script/guides/clasp#installation>
130-
131-
First install Install [Node.js](https://nodejs.org/en/download/)
132-
133-
```sh
134-
npm install @google/clasp -g
135-
```
136-
137-
[drop_clasp_typescript]: https://github.com/google/clasp#drop-typescript-support
100+
[template_repo]: https://github.com/c-git/clasp_minimal_typescript

0 commit comments

Comments
 (0)