|
1 | | -# Rocket.Chat Apps CLI |
2 | | -The Rocket.Chat Apps CLI for interacting with Apps. |
| 1 | +# Rocket.Chat Apps CLI (v2) |
3 | 2 |
|
4 | | -## Getting Started |
5 | | -Extremely simple. |
| 3 | +Modernized `rc-apps` CLI focused on local app development, packaging, deployment, and scaffolding. |
6 | 4 |
|
7 | | -``` |
8 | | -npm install -g @rocket.chat/apps-cli |
9 | | -``` |
| 5 | +## What Changed In v2 |
10 | 6 |
|
11 | | -## Rocket.Chat App Development |
| 7 | +- Legacy implementation is preserved under `legacy/` for reference. |
| 8 | +- Deprecated cloud/marketplace commands were removed from active CLI: |
| 9 | + - `login` |
| 10 | + - `logout` |
| 11 | + - `submit` |
| 12 | +- Modern Node.js baseline (`>=22.0.0`). |
| 13 | +- Lower runtime dependency surface using native Node APIs (`fetch`, `FormData`, `fs/promises`, `util.parseArgs`). |
| 14 | +- Cross-platform path handling improvements (Windows-safe path normalization). |
12 | 15 |
|
13 | | -### Logging Inside an App |
14 | | -Due to limitations of NodeJS's `vm` package we have had to implement a custom logger class. |
15 | | -To make usage of this you can use `this.getLogger()` and then do the normal `console` style logging. |
| 16 | +## Install |
16 | 17 |
|
17 | | -### `rc-apps create` |
| 18 | +```bash |
| 19 | +npm install -g @rocket.chat/apps-cli |
| 20 | +``` |
18 | 21 |
|
19 | | -The development tools provide a command to quickly scaffold a new Rocket.Chat App, simply run `rc-apps create` and a new folder will be created inside the current working directory with a basic App which does nothing but will compile and be packaged in the `dist` folder. |
| 22 | +## Commands |
20 | 23 |
|
21 | | -### App description |
| 24 | +```bash |
| 25 | +rc-apps help |
| 26 | +``` |
22 | 27 |
|
23 | | -The app description file, named `app.json`, contains basic information about the app. You can check the [app-schema.json](https://github.com/RocketChat/Rocket.Chat.Apps-engine/blob/master/src/definition/app-schema.json) file for all the detailed information and fields allowed in the app description file, the basic structure is similar to this: |
| 28 | +### Create App |
24 | 29 |
|
| 30 | +```bash |
| 31 | +rc-apps create [name] [--description <text>] [--author <name>] [--support <urlOrEmail>] [--homepage <url>] [--skip-install] |
25 | 32 | ``` |
26 | | -{ |
27 | | - "id": "5cb9a329-0613-4d39-b20f-cc2cc9175df5", |
28 | | - "name": "App Name", |
29 | | - "nameSlug": "app-name", |
30 | | - "version": "0.0.1", |
31 | | - "requiredApiVersion": "^1.4.0", |
32 | | - "description": "App which provides something very useful for Rocket.Chat users.", |
33 | | - "author": { |
34 | | - "name": "Author Name <author@email.com>", |
35 | | - "support": "Support Url or Email" |
36 | | - }, |
37 | | - "classFile": "main.ts", |
38 | | - "iconFile": "beautiful-app-icon.jpg" |
39 | | -} |
| 33 | + |
| 34 | +### Package App |
| 35 | + |
| 36 | +```bash |
| 37 | +rc-apps package [--project <path>] [--force] [--verbose] [--no-compile] [--experimental-native-compiler] |
40 | 38 | ``` |
41 | 39 |
|
42 | | -### Extending the App class |
| 40 | +- `--no-compile`: package source files directly (no TypeScript compile/bundle). This is intended for manual marketplace review workflows. |
| 41 | +- `--experimental-native-compiler`: keep compile flow but use compiler native mode. |
43 | 42 |
|
44 | | -The basic creation of an App is based on extending the `App` class from the Rocket.Chat Apps _definition_ library. Your class also has to implement the constructor and optionally the `initialize` function, for more details on those check the [App definition documentation](https://rocketchat.github.io/Rocket.Chat.Apps-engine/classes/app.html). |
| 43 | +### Deploy App |
45 | 44 |
|
| 45 | +```bash |
| 46 | +rc-apps deploy [--project <path>] --url <server> [--username <u> --password <p> | --userId <id> --token <t>] |
46 | 47 | ``` |
47 | | -import { |
48 | | - IAppAccessors, |
49 | | - IConfigurationExtend, |
50 | | - IEnvironmentRead, |
51 | | - ILogger, |
52 | | -} from '@rocket.chat/apps-engine/definition/accessors'; |
53 | | -import { App } from '@rocket.chat/apps-engine/definition/App'; |
54 | | -import { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata'; |
55 | | -
|
56 | | -export class TodoListApp extends App { |
57 | | - constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) { |
58 | | - super(info, logger, accessors); |
59 | | - } |
60 | | -
|
61 | | - public async initialize(configurationExtend: IConfigurationExtend, environmentRead: IEnvironmentRead): Promise<void> { |
62 | | - await this.extendConfiguration(configurationExtend, environmentRead); |
63 | | - this.getLogger().log('Hello world from my app'); |
64 | | - } |
65 | | -} |
| 48 | + |
| 49 | +### Watch + Auto Deploy |
| 50 | + |
| 51 | +```bash |
| 52 | +rc-apps watch [--project <path>] --url <server> [auth flags] [--debounce 800] |
66 | 53 | ``` |
67 | 54 |
|
68 | | -### Packaging the app |
| 55 | +### Generate Boilerplate |
69 | 56 |
|
70 | | -Currently the Rocket.Chat servers and Marketplace allow submission of zip files, these files can be created by running `rc-apps package` which packages your app and creates the zip file under `dist` folder. |
| 57 | +```bash |
| 58 | +rc-apps generate endpoint <ClassName> [--path /route] |
| 59 | +rc-apps generate slash-command <ClassName> |
| 60 | +rc-apps generate setting <setting_id> |
| 61 | +``` |
71 | 62 |
|
72 | | -### Uploading the app |
73 | | -For uploading the app you need add to the required parameters in the .rcappsconfig already created in the apps directory. It accepts two types of objects:- |
| 63 | +## Config File |
74 | 64 |
|
75 | | -1. Upload using username, password |
| 65 | +You can store deployment defaults in `.rcappsconfig` inside the app folder: |
76 | 66 |
|
77 | | -``` |
| 67 | +```json |
78 | 68 | { |
79 | | - url: string; |
80 | | - username: string; |
81 | | - password: string; |
| 69 | + "url": "http://localhost:3000", |
| 70 | + "username": "admin", |
| 71 | + "password": "pass", |
| 72 | + "ignoredFiles": [ |
| 73 | + "**/dist/**", |
| 74 | + "**/node_modules/**" |
| 75 | + ] |
82 | 76 | } |
83 | 77 | ``` |
84 | | -2. Upload using personal access token and userId |
85 | 78 |
|
86 | | -``` |
87 | | -{ |
88 | | - url: string; |
89 | | - userId: string; |
90 | | - token: string; |
91 | | -} |
| 79 | +CLI flags override values from this file. |
| 80 | + |
| 81 | +## Development |
| 82 | + |
| 83 | +```bash |
| 84 | +npm install |
| 85 | +npm run build |
| 86 | +npm test |
92 | 87 | ``` |
93 | 88 |
|
94 | | -### Enabling autocomplete for commands |
| 89 | +## Testing Checklist |
95 | 90 |
|
96 | | -To enable autocomplete for the apps cli use the command `rc-apps autocomplete <your-shell-type>` with the shell type as zsh or bash as the supported types. This would provide a step by step instruction to enable shell completion in your preferred shell. |
| 91 | +1. `npm run build` succeeds. |
| 92 | +2. `npm test` succeeds. |
| 93 | +3. On Windows, run `rc-apps package` inside a valid app and confirm zip generation in `dist/`. |
| 94 | +4. Verify `deploy` with both auth modes: |
| 95 | + - username/password |
| 96 | + - userId/token |
| 97 | +5. Verify `watch` redeploys after editing a `.ts` source file. |
0 commit comments