You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- 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
14
12
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>
18
14
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:
22
16
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>
24
23
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.
> 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`.
30
30
31
-
- Add Type definitions for Apps Script
31
+
# New project setup
32
32
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
+
```
36
49
37
-
- Add ts_lib
50
+
## Additional Steps for Wykies Library
51
+
52
+
-[ ] Add ts_lib
38
53
- Part of wykies
39
54
40
55
```sh
@@ -47,55 +62,13 @@ npm i -S @types/google-apps-script
- (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
-
namespaceMyLib {
65
-
exportfunction 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
-
86
65
# Converting an existing Javascript (JS) project to TypeScript (TS)
87
66
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)
0 commit comments