# TypeScript Development Tips

### ⭐ Things to Note When Developing in TypeScript

When developing with TypeScript, you must put the **Script** keyword in front of the **App, Map, Player,** or **Widget** keywords.

```jsx
// When developing in JavaScript
App.sayToAll("Hello World!");

// When developing in TypeScript
ScriptApp.sayToAll("Hello World!");
```

### 1. Install **node.js**

{% hint style="info" %}
Visit <https://nodejs.org/en/> to download and install node.js.

We recommend installing the LTS version, which is the most stable version.
{% endhint %}

<div align="left"><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FHpO6kInIORtdzx2IpV5g%2FUntitled.png?alt=media&#x26;token=073c52a4-2de4-4b62-932c-c3bcbd8a39e0" alt=""><figcaption></figcaption></figure></div>

### 2. Create the Project Folder

A sample project for developing in ZEP Script can be downloaded through the CLI.

The CLI can be run from the terminal for MacOS, Windows PowerShell in windows, or the terminal environment provided since Windows 11.

> **Running PowerShell on Windows**
>
> **Shift + right-click** in the empty space of the folder in which main.js is located.
>
> Choose **`Open PowerShell window here`** or **`Open command window here`**.
>
> ![](https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2Fi3DZ47jPxi91gyQC90Eh%2FUntitled%201.png?alt=media\&token=851ea288-723f-47bf-8bf8-eadbd257c427)
>
> A **Windows PowerShell** or **Command Prompt** window will launch as follows:
>
> ![](https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2Fw6DDP66kd2tdmiQCT2yx%2Fimage_\(3\).png?alt=media\&token=ea317433-1636-4009-a016-3c76e51a7d47)

Enter the command to create the project folder as follows:

```bash
npx zep-script init MyZepApp --npm
```

<div align="left"><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FxbYRW0W9lpVb58l8tAYf%2FUntitled%202.png?alt=media&#x26;token=3e2814b2-1ed3-4303-887e-407791c6aeba" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FF0KP3ZvJN8oEcKJfsvh4%2FUntitled%203.png?alt=media&#x26;token=eed0e7c3-c44f-444c-9546-7da3a766b92b" alt=""><figcaption></figcaption></figure></div>

If the message `Project {Folder Name} initialized successfully` is displayed as seen above, the environment for developing **ZEP Script** with TypeScript is now ready.

### 3. Browse the Folder Structure

If you go to the created project folder, you can see the files as follows:

The **res** folder is an abbreviation of "**resources"** and is where you put images or html files needed for the app.

<div align="left"><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FM721mnhoa5q0LZn5PsPP%2FUntitled%204.png?alt=media&#x26;token=22a3c098-576b-4634-8093-ceeea72dbddd" alt=""><figcaption></figcaption></figure></div>

The **main.ts** file created here is where you write the app development code.

This **main.ts** file contains sample code as seen below. You can refer to this code for development.

<div align="left"><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FURetlMo5rr4v9QfwngNW%2FUntitled%205.png?alt=media&#x26;token=02b6d7fa-b324-41c4-ad26-6b32609a3a93" alt=""><figcaption></figcaption></figure></div>

With the exception of the **main.ts file and res folder,** the remaining files and folders are configuration files for developing ZEP Script with TypeScript, and you do not need to modify them separately during development.

### 4. Create a JavaScript Build

Since **ZEP Script** can only be executed through JavaScript, it must go through a build process that converts TypeScript to JavaScript.

Open a command window in the folder where the **main.js** file is located and enter the following command to create a new build.

```bash
npx zep-script build
```

<div align="left"><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2F8E0GeejivB5plT2RizjT%2FUntitled%206.png?alt=media&#x26;token=0c0dd825-8c86-46f5-b13d-3a27c84f2265" alt=""><figcaption></figcaption></figure></div>

If the build is created successfully, you can see that a folder named **dist** has been created.

The **dist** folder contains the **main.js** file that was created by converting the TypeScript code written in the **main.ts** into JavaScript.

<div align="left"><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FHTsNSYNdoipwx7UQxSeH%2FUntitled%207.png?alt=media&#x26;token=87bf0e3d-dcf3-4145-9009-5fb2f3b27375" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2Fe8YWEQ5Hgdao4EHwAMJQ%2FUntitled%208.png?alt=media&#x26;token=8c3edcc2-7720-4805-b3e5-c4ee4f55aa36" alt=""><figcaption></figcaption></figure></div>

### 5. Create a Compressed File

To distribute an app created with ZEP Script, you need to create a zip file that contains the main.js file and the images and html files to be used in the app.

Open a command window in the root of your project’s folder and enter the following command to create a compressed file.

```powershell
npx zep-script archive
```

<div align="left"><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2Fbb0L5HX4ZpudVOow0gho%2FUntitled%209.png?alt=media&#x26;token=f2928247-4f0b-4e0c-a368-79b15869eeaf" alt=""><figcaption></figcaption></figure></div>

If the compression process was successful, you can check that a compressed file has been created in the folder as follows:

<div align="left"><figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FEw5S9XfnxV6eSXZeMe1G%2FUntitled%2010.png?alt=media&#x26;token=b89f0692-c4ff-4116-ae88-18c35556ad0f" alt=""><figcaption></figcaption></figure></div>

Finally, after creating the zip file, you’re ready to deploy the app.<br>

### 6. Deploy a Project

1. **Deploy on a website**

You can deploy your app by uploading the zip file created above.

Refer to the [ZEP Script Deployment Guide](https://docs.zep.us/zep-script/zep-script-guide/zep-script-development-guide/zep-script-deployment-guide) and distribute your app!

&#x20; &#x20;

&#x20; **2. Deploy using CLI**

You can deploy the zip file created by using CLI.

Open the zep-script.json file in the project folder and run the app to upload.

(Make sure to create the zep-script.json file.)

<figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FcQrZxGhZXkbv5In9xQtA%2Fimage.png?alt=media&#x26;token=25b75d83-b78d-4fb2-9100-3737135ace15" alt=""><figcaption></figcaption></figure>

```json
{
    "appId": "Zjkgoj",  // app ID
    "name": "Template", // app name
    "description": "Template application" , // app description
    "type": "normal" // app type( "normal" or "minigame" or "sidebar" )
}
```

⭐ appID: Enter the ID of the app to upload.

* To change an existing app, access <https://zep.us/me/apps/>, select an app to upload, and then enter the text appended to apps/ in the address bar. (E.g., "Zjkgoj" for the reference image below)

<figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FQIuCpyDAcpwtlUz9Ai0T%2Fimage.png?alt=media&#x26;token=8010b9ec-329b-4bc5-8cb1-83ab9bb4cf16" alt=""><figcaption></figcaption></figure>

Once set, run PowerShell in the project folder path and enter a command for deployment as below.

```powershell
npm run deploy or npx zep-script publish
```

When the email input section appears below, enter the email address of the account that owns the app to be deployed.

![](https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FsEk4KxbNnfIf7nR5mR06%2Fimage.png?alt=media\&token=d69c472d-8d1c-4aa1-9bb2-db891482a653)

When you see the message saying, **Sending login code to your email**, go to the mailbox of the email you entered above. Check the verification code and enter it to the command window to start deploying.

<figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FjlV6qmlGuxweAfcqaEPM%2Fimage.png?alt=media&#x26;token=aca8a05b-37b9-4f8f-ad56-7210748cd22a" alt=""><figcaption></figcaption></figure>

The deploy process is complete when a green checkmark appears on the left of **Publishing…** as shown below.

<figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FsdCGzMhc9zA3hGnbWgXD%2Fimage.png?alt=media&#x26;token=b19f7d45-0d90-4f2b-a72a-8120409d3a13" alt=""><figcaption></figcaption></figure>

You can see your app has been deployed in the [My Apps](https://zep.us/me/apps) page as described above in the **zep-script.json** file.

<figure><img src="https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FsfyKzCNjVu8dxNH8SF8u%2Fimage.png?alt=media&#x26;token=5a05ca5b-b003-4488-afe6-dbde445a178f" alt=""><figcaption></figcaption></figure>

For more information about the library, please refer to the contents of the GitHub repository below.\
[zep-script-sdk/packages/zep-script-cli at main · zep-us/zep-script-sdk](https://github.com/zep-us/zep-script-sdk/tree/main/packages/zep-script-cli)
