npm package: @levimc-lse/scaffold
Description: A utility for assisting in the development of Legacy Script Engine plugins.
Author: leoweyr
Latest version: 1.0.0

# Legacy Script Engine Scaffold

#### English | [简体中文](README-zh_cn.md)

A utility for assisting in the development of Legacy Script Engine plugins, supporting a native development experience on the Node.js platform.

> Only TypeScript projects are supported at the moment.

## 📦 Prepare

It is a non-intrusive tool, meaning it does not require any mandatory files to be kept in your project. However, it is recommended to add it as a development dependency to your environment for convenient usage:

```bash
npm install @levimc-lse/scaffold --save-dev
```

## 🚀 Usage

### Generate manifest.json for the Legacy Script Engine plugin

```bash
npx lses manifest
```

### Package the Legacy Script Engine plugin

```bash
npx lses pack
```

### Deploy the Legacy Script Engine plugin package to the LeviLamina server by path

```bash
npx lses deploy-path <path> [options]
```

| Argument | Description                                   | Type   |
|----------|-----------------------------------------------|--------|
| `<path>` | Specific LeviLamina server working directory. | String |

| Option                             | Description                      | Type    | Default |
|------------------------------------| -------------------------------- | ------- | ------- |
| `-h, --host <remote-host>`         | Remote Windows OpenSSH host.     | String  |         |
| `-P, --port <remote-port>`         | Remote Windows OpenSSH port.     | Integer | 22      |
| `-u, --username <remote-username>` | Remote Windows OpenSSH username. | String  |         |
| `-p, --password <remote-password>` | Remote Windows OpenSSH password. | String  |         |

### Launch a LeviLamina server as a debugger

```bash
npx lses debug <path> <name> [options]
```

| Argument | Description                                   | Type   |
| -------- | --------------------------------------------- | ------ |
| `<path>` | Specific LeviLamina server working directory. | String |
| `<name>` | Alias name for the debugger instance.         | String |

| Option                             | Description                      | Type    | Default |
|------------------------------------| -------------------------------- | ------- | ------- |
| `-h, --host <remote-host>`         | Remote Windows OpenSSH host.     | String  |         |
| `-P, --port <remote-port>`         | Remote Windows OpenSSH port.     | Integer | 22      |
| `-u, --username <remote-username>` | Remote Windows OpenSSH username. | String  |         |
| `-p, --password <remote-password>` | Remote Windows OpenSSH password. | String  |         |

### Deploy the Legacy Script Engine plugin package to the LeviLamina server debugger instance

> 💡  **Key Feature**
>
> Compared to `npx lses deploy-path`, this deployment method automatically hot reloads the plugin.

```bash
npx lses deploy-debug <debugger-name>
```

| Argument          | Description                                        | Type   |
|-------------------| -------------------------------------------------- | ------ |
| `<debugger-name>` | Specific LeviLamina server debugger instance name. | String |


## ❗ Important

1. The `main` configuration entry file in package.json should be relative to the project's working directory, <font color="red">not the directory of the Legacy Script Engine plugin package.</font> 

   For example, in a TypeScript project where index.ts is defined as the entry point in source code and the TypeScript compiler is configured via tsconfig.json to emit to the build directory named dist, you should set the `main` field in package.json to `dist/index.js`. 

   This ensures that the `entry` field in the manifest.json generated by `npx lses manifest` can be correctly identified and located by LeviLamina.

2. Ensure that the corresponding LeviLamina server debugger instance exists before using `npx lses deploy-debug`, so need to launch it first using `npx lses debug`.