@simplens/onboard 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +331 -214
- package/dist/__tests__/env-config.test.d.ts +2 -0
- package/dist/__tests__/env-config.test.d.ts.map +1 -0
- package/dist/__tests__/env-config.test.js +23 -0
- package/dist/__tests__/env-config.test.js.map +1 -0
- package/dist/__tests__/infra-prompts.test.d.ts +2 -0
- package/dist/__tests__/infra-prompts.test.d.ts.map +1 -0
- package/dist/__tests__/infra-prompts.test.js +43 -0
- package/dist/__tests__/infra-prompts.test.js.map +1 -0
- package/dist/__tests__/infra.test.d.ts +2 -0
- package/dist/__tests__/infra.test.d.ts.map +1 -0
- package/dist/__tests__/infra.test.js +14 -0
- package/dist/__tests__/infra.test.js.map +1 -0
- package/dist/__tests__/nginx.test.d.ts +2 -0
- package/dist/__tests__/nginx.test.d.ts.map +1 -0
- package/dist/__tests__/nginx.test.js +16 -0
- package/dist/__tests__/nginx.test.js.map +1 -0
- package/dist/env-config.d.ts +27 -12
- package/dist/env-config.d.ts.map +1 -1
- package/dist/env-config.js +258 -141
- package/dist/env-config.js.map +1 -1
- package/dist/index.js +341 -71
- package/dist/index.js.map +1 -1
- package/dist/infra.d.ts +17 -14
- package/dist/infra.d.ts.map +1 -1
- package/dist/infra.js +265 -176
- package/dist/infra.js.map +1 -1
- package/dist/plugins.d.ts +5 -10
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +75 -44
- package/dist/plugins.js.map +1 -1
- package/dist/services.d.ts +1 -23
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +47 -62
- package/dist/services.js.map +1 -1
- package/dist/templates.d.ts +3 -2
- package/dist/templates.d.ts.map +1 -1
- package/dist/templates.js +203 -198
- package/dist/templates.js.map +1 -1
- package/dist/types/domain.d.ts +2 -0
- package/dist/types/domain.d.ts.map +1 -1
- package/dist/ui.d.ts +45 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +93 -0
- package/dist/ui.js.map +1 -0
- package/dist/utils/logger.d.ts +1 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +32 -7
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +66 -2
- package/dist/utils.js.map +1 -1
- package/dist/validators.d.ts +1 -52
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +10 -57
- package/dist/validators.js.map +1 -1
- package/package.json +3 -5
- package/src/__tests__/env-config.test.ts +28 -0
- package/src/__tests__/errors.test.ts +187 -187
- package/src/__tests__/infra-prompts.test.ts +54 -0
- package/src/__tests__/infra.test.ts +15 -0
- package/src/__tests__/utils.test.ts +142 -142
- package/src/__tests__/validators.test.ts +195 -195
- package/src/config/constants.ts +86 -86
- package/src/config/index.ts +1 -1
- package/src/env-config.ts +455 -320
- package/src/index.ts +534 -203
- package/src/infra.ts +404 -300
- package/src/plugins.ts +221 -190
- package/src/services.ts +175 -190
- package/src/templates.ts +209 -203
- package/src/types/domain.ts +129 -127
- package/src/types/errors.ts +173 -173
- package/src/types/index.ts +2 -2
- package/src/ui.ts +91 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/logger.ts +144 -118
- package/src/utils.ts +183 -105
- package/src/validators.ts +145 -192
- package/tsconfig.json +18 -18
- package/vitest.config.ts +22 -20
package/README.md
CHANGED
|
@@ -1,214 +1,331 @@
|
|
|
1
|
-
# @simplens/onboard
|
|
2
|
-
|
|
3
|
-
> CLI tool to setup SimpleNS instances on any linux/amd64 and windows machine
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
`@simplens/onboard` is an interactive CLI tool that guides you through setting up a complete SimpleNS (Simple Notification System) instance on your local machine or server. It handles infrastructure provisioning, environment configuration, plugin installation, and service orchestration.
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
- ✅ **Prerequisite Validation** - Checks Docker installation and availability
|
|
12
|
-
- 🏗️ **Infrastructure Setup** - Deploy MongoDB, Kafka, Redis, Loki, Grafana with one command
|
|
13
|
-
- 🐧 **OS-Aware Configuration** - Automatically detects and configures for Windows, Linux, or macOS
|
|
14
|
-
- ⚙️ **Smart Environment Config** - Default or interactive mode for environment variables
|
|
15
|
-
- 🔌 **Plugin Management** - Browse and install official SimpleNS plugins
|
|
16
|
-
- 🚀 **Service Orchestration** - Automatic health checks and sequential service startup
|
|
17
|
-
- 📊 **Service Dashboard** - View all running services and their access URLs
|
|
18
|
-
|
|
19
|
-
## Prerequisites
|
|
20
|
-
|
|
21
|
-
- **Docker** - Docker Desktop (Windows/Mac) or Docker Engine (Linux)
|
|
22
|
-
- **Node.js** - Version 18 or higher
|
|
23
|
-
- **NPX** - Comes with npm 5.2+
|
|
24
|
-
|
|
25
|
-
## Installation
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
# Run directly with npx (recommended)
|
|
29
|
-
npx @simplens/onboard
|
|
30
|
-
|
|
31
|
-
# Or install globally
|
|
32
|
-
npm install -g @simplens/onboard
|
|
33
|
-
simplens-onboard
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Usage
|
|
37
|
-
|
|
38
|
-
### Basic Setup (Application Services Only)
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
npx @simplens/onboard
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
This will:
|
|
45
|
-
- Validate prerequisites
|
|
46
|
-
- Generate `docker-compose.yaml` for app services
|
|
47
|
-
- Configure environment variables (default mode)
|
|
48
|
-
- Prompt for plugin selection
|
|
49
|
-
- Optionally start services
|
|
50
|
-
|
|
51
|
-
### Full Setup (Infrastructure + Application)
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
npx @simplens/onboard --infra
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Includes everything from basic setup plus:
|
|
58
|
-
- Interactive infrastructure service selection (MongoDB, Kafka, Redis, etc.)
|
|
59
|
-
- Generate `docker-compose.infra.yaml`
|
|
60
|
-
- OS-specific host configuration (handles Linux compatibility)
|
|
61
|
-
- Auto-configured connection URLs for infra services
|
|
62
|
-
|
|
63
|
-
### Interactive Environment Configuration
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
npx @simplens/onboard --env interactive
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Prompts for every environment variable instead of using defaults.
|
|
70
|
-
|
|
71
|
-
### Custom Target Directory
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
npx @simplens/onboard --infra --dir /path/to/setup
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
- `
|
|
119
|
-
- `
|
|
120
|
-
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
-
|
|
131
|
-
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
#
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
1
|
+
# @simplens/onboard
|
|
2
|
+
|
|
3
|
+
> CLI tool to setup SimpleNS instances on any linux/amd64 and windows machine
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@simplens/onboard` is an interactive CLI tool that guides you through setting up a complete SimpleNS (Simple Notification System) instance on your local machine or server. It handles infrastructure provisioning, environment configuration, plugin installation, and service orchestration.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- ✅ **Prerequisite Validation** - Checks Docker installation and availability
|
|
12
|
+
- 🏗️ **Infrastructure Setup** - Deploy MongoDB, Kafka, Redis, Loki, Grafana with one command
|
|
13
|
+
- 🐧 **OS-Aware Configuration** - Automatically detects and configures for Windows, Linux, or macOS
|
|
14
|
+
- ⚙️ **Smart Environment Config** - Default or interactive mode for environment variables
|
|
15
|
+
- 🔌 **Plugin Management** - Browse and install official SimpleNS plugins
|
|
16
|
+
- 🚀 **Service Orchestration** - Automatic health checks and sequential service startup
|
|
17
|
+
- 📊 **Service Dashboard** - View all running services and their access URLs
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
- **Docker** - Docker Desktop (Windows/Mac) or Docker Engine (Linux)
|
|
22
|
+
- **Node.js** - Version 18 or higher
|
|
23
|
+
- **NPX** - Comes with npm 5.2+
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Run directly with npx (recommended)
|
|
29
|
+
npx @simplens/onboard
|
|
30
|
+
|
|
31
|
+
# Or install globally
|
|
32
|
+
npm install -g @simplens/onboard
|
|
33
|
+
simplens-onboard
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
### Basic Setup (Application Services Only)
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx @simplens/onboard
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This will:
|
|
45
|
+
- Validate prerequisites
|
|
46
|
+
- Generate `docker-compose.yaml` for app services
|
|
47
|
+
- Configure environment variables (default mode)
|
|
48
|
+
- Prompt for plugin selection
|
|
49
|
+
- Optionally start services
|
|
50
|
+
|
|
51
|
+
### Full Setup (Infrastructure + Application)
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx @simplens/onboard --infra
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Includes everything from basic setup plus:
|
|
58
|
+
- Interactive infrastructure service selection (MongoDB, Kafka, Redis, etc.)
|
|
59
|
+
- Generate `docker-compose.infra.yaml`
|
|
60
|
+
- OS-specific host configuration (handles Linux compatibility)
|
|
61
|
+
- Auto-configured connection URLs for infra services
|
|
62
|
+
|
|
63
|
+
### Interactive Environment Configuration
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npx @simplens/onboard --env interactive
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Prompts for every environment variable instead of using defaults.
|
|
70
|
+
|
|
71
|
+
### Custom Target Directory
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx @simplens/onboard --infra --dir /path/to/setup
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Non-Interactive Setup (Full Mode)
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Complete setup with all options via CLI (no prompts)
|
|
81
|
+
npx @simplens/onboard --full --infra mongo kafka kafka-ui redis nginx --env default --base-path /dashboard --plugin @simplens/mock @simplens/nodemailer-gmail
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This mode:
|
|
85
|
+
- Requires `--full` flag to enable non-interactive mode
|
|
86
|
+
- Requires `--env <mode>` to specify environment mode
|
|
87
|
+
- **Auto-generates secure credentials** for NS_API_KEY, AUTH_SECRET, and ADMIN_PASSWORD
|
|
88
|
+
- **Auto-generates placeholder credentials** for plugins
|
|
89
|
+
- All other options are optional with sensible defaults
|
|
90
|
+
- Services are not auto-started (use `docker-compose up -d` manually)
|
|
91
|
+
|
|
92
|
+
**⚠️ IMPORTANT**: Auto-generated credentials are **NOT secure for production**. After setup completes, you **must** update the following in your `.env` file:
|
|
93
|
+
- `NS_API_KEY` - API authentication key
|
|
94
|
+
- `AUTH_SECRET` - Session secret for dashboard
|
|
95
|
+
- `ADMIN_PASSWORD` - Dashboard admin password
|
|
96
|
+
- Plugin credentials (if any plugins were installed)
|
|
97
|
+
|
|
98
|
+
The CLI will display a security notice with all credentials that need to be updated.
|
|
99
|
+
|
|
100
|
+
## Command Options
|
|
101
|
+
|
|
102
|
+
| Option | Description | Default |
|
|
103
|
+
|--------|-------------|---------|
|
|
104
|
+
| `--full` | Non-interactive mode - all options via CLI, no prompts | `false` |
|
|
105
|
+
| `--infra [services...]` | Infrastructure services: `mongo`, `kafka`, `kafka-ui`, `redis`, `nginx`, `loki`, `grafana` | `false` |
|
|
106
|
+
| `--env <mode>` | Environment setup mode: `default` or `interactive` | Prompted |
|
|
107
|
+
| `--dir <path>` | Target directory for setup files | Current directory |
|
|
108
|
+
| `--base-path <path>` | Dashboard base path (example: `/dashboard`) | Empty (root) |
|
|
109
|
+
| `--plugin [plugins...]` | Plugins to install (e.g., `@simplens/mock @simplens/nodemailer-gmail`) | Prompted |
|
|
110
|
+
| `--no-output` | Suppress all console output (silent mode) | `false` |
|
|
111
|
+
|
|
112
|
+
### Valid Infrastructure Services
|
|
113
|
+
|
|
114
|
+
- `mongo` - MongoDB database
|
|
115
|
+
- `kafka` - Apache Kafka message queue
|
|
116
|
+
- `kafka-ui` - Kafka UI dashboard
|
|
117
|
+
- `redis` - Redis cache
|
|
118
|
+
- `nginx` - Nginx reverse proxy
|
|
119
|
+
- `loki` - Loki log aggregation
|
|
120
|
+
- `grafana` - Grafana observability dashboard
|
|
121
|
+
|
|
122
|
+
## Workflow
|
|
123
|
+
|
|
124
|
+
1. **Prerequisites Check**
|
|
125
|
+
- Validates Docker installation
|
|
126
|
+
- Checks Docker daemon status
|
|
127
|
+
- Detects operating system
|
|
128
|
+
|
|
129
|
+
2. **Infrastructure Setup** (if `--infra` flag is used)
|
|
130
|
+
- Select infrastructure services
|
|
131
|
+
- Auto-detect host configuration (Linux-aware)
|
|
132
|
+
- Generate `docker-compose.infra.yaml`
|
|
133
|
+
- Auto-include Nginx when `BASE_PATH` is non-empty
|
|
134
|
+
- Nginx is disabled entirely when `BASE_PATH` is empty
|
|
135
|
+
|
|
136
|
+
3. **Environment Configuration**
|
|
137
|
+
- Load defaults from `.env.example`
|
|
138
|
+
- Auto-fill infra connection URLs
|
|
139
|
+
- Ask for `BASE_PATH` first and reuse it throughout setup
|
|
140
|
+
- Prompt for critical values (API keys, passwords)
|
|
141
|
+
- Generate `.env` file
|
|
142
|
+
|
|
143
|
+
4. **Plugin Installation**
|
|
144
|
+
- Fetch official plugins from registry
|
|
145
|
+
- Interactive multi-select
|
|
146
|
+
- Generate `simplens.config.yaml`
|
|
147
|
+
- Extract and prompt for plugin credentials
|
|
148
|
+
- Append credentials to `.env`
|
|
149
|
+
|
|
150
|
+
5. **Service Orchestration**
|
|
151
|
+
- Optionally start infrastructure services
|
|
152
|
+
- Wait for health checks
|
|
153
|
+
- Start application services
|
|
154
|
+
- Display service URLs and status
|
|
155
|
+
|
|
156
|
+
## Generated Files
|
|
157
|
+
|
|
158
|
+
- `docker-compose.infra.yaml` - Infrastructure services (if `--infra` used)
|
|
159
|
+
- `docker-compose.yaml` - Application services
|
|
160
|
+
- `.env` - Environment variables and credentials
|
|
161
|
+
- `simplens.config.yaml` - Plugin configuration
|
|
162
|
+
|
|
163
|
+
## Service URLs
|
|
164
|
+
|
|
165
|
+
After successful setup, access these URLs:
|
|
166
|
+
|
|
167
|
+
- **API Server**: http://localhost:3000
|
|
168
|
+
- **API Health**: http://localhost:3000/health
|
|
169
|
+
- **Dashboard**: http://localhost:3002
|
|
170
|
+
- **Kafka UI**: http://localhost:8080 (if Kafka selected)
|
|
171
|
+
- **Grafana**: http://localhost:3001 (if Grafana selected)
|
|
172
|
+
|
|
173
|
+
## Examples
|
|
174
|
+
|
|
175
|
+
### Minimal Setup
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Basic setup with defaults (interactive)
|
|
179
|
+
npx @simplens/onboard
|
|
180
|
+
|
|
181
|
+
# Select plugins when prompted
|
|
182
|
+
# Choose "Start services" at the end
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Full Production Setup
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Infrastructure + interactive env config
|
|
189
|
+
npx @simplens/onboard --infra --env interactive
|
|
190
|
+
|
|
191
|
+
# Select all infrastructure services
|
|
192
|
+
# Provide production credentials
|
|
193
|
+
# Start services immediately
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Development Setup in Custom Directory
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# Setup in specific directory
|
|
200
|
+
npx @simplens/onboard --infra --dir ~/simplens-dev
|
|
201
|
+
|
|
202
|
+
# Select only MongoDB, Kafka, Redis
|
|
203
|
+
# Use default env values
|
|
204
|
+
# Start services for testing
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Complete Non-Interactive Setup
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Full automated setup with specific services and plugins
|
|
211
|
+
npx @simplens/onboard \
|
|
212
|
+
--full \
|
|
213
|
+
--infra mongo kafka kafka-ui redis nginx \
|
|
214
|
+
--env default \
|
|
215
|
+
--base-path /dashboard \
|
|
216
|
+
--plugin @simplens/mock @simplens/nodemailer-gmail \
|
|
217
|
+
--dir ./my-simplens-setup
|
|
218
|
+
|
|
219
|
+
# No prompts - everything configured via CLI
|
|
220
|
+
# Services not auto-started in full mode
|
|
221
|
+
# Start manually with: docker-compose up -d
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### CI/CD Pipeline Setup
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Minimal non-interactive setup for CI/CD
|
|
228
|
+
npx @simplens/onboard \
|
|
229
|
+
--full \
|
|
230
|
+
--env default \
|
|
231
|
+
--dir /app/simplens
|
|
232
|
+
|
|
233
|
+
# Then start services in CI:
|
|
234
|
+
cd /app/simplens
|
|
235
|
+
docker-compose up -d
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Silent Mode (No Console Output)
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# Complete setup with no console output (useful for scripting/automation)
|
|
242
|
+
npx @simplens/onboard \
|
|
243
|
+
--full \
|
|
244
|
+
--no-output \
|
|
245
|
+
--infra mongo kafka redis \
|
|
246
|
+
--env default \
|
|
247
|
+
--dir /app/simplens
|
|
248
|
+
|
|
249
|
+
# Exit code indicates success (0) or failure (non-zero)
|
|
250
|
+
# All setup is performed silently in background
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Note**: `--no-output` suppresses all console output including banners, progress steps, and warnings. Use with `--full` mode for completely automated setup. Errors are still logged to stderr.
|
|
254
|
+
|
|
255
|
+
## Troubleshooting
|
|
256
|
+
|
|
257
|
+
### Docker Not Running
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
❌ Docker daemon is not running.
|
|
261
|
+
Please start Docker Desktop or Docker daemon.
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Solution**: Start Docker Desktop (Windows/Mac) or `sudo systemctl start docker` (Linux)
|
|
265
|
+
|
|
266
|
+
### Updating Auto-Generated Credentials (Full Mode)
|
|
267
|
+
|
|
268
|
+
When using `--full` mode, credentials are auto-generated. To update them:
|
|
269
|
+
|
|
270
|
+
1. Open the `.env` file in your setup directory
|
|
271
|
+
2. Replace the auto-generated values:
|
|
272
|
+
```bash
|
|
273
|
+
# Before (auto-generated)
|
|
274
|
+
NS_API_KEY=sk_AbCdEf123456...
|
|
275
|
+
AUTH_SECRET=XyZ789...
|
|
276
|
+
ADMIN_PASSWORD=AdminRaNdOm123...
|
|
277
|
+
|
|
278
|
+
# After (secure values)
|
|
279
|
+
NS_API_KEY=your_secure_api_key_here
|
|
280
|
+
AUTH_SECRET=your_secure_session_secret_here
|
|
281
|
+
ADMIN_PASSWORD=YourSecurePassword123!
|
|
282
|
+
```
|
|
283
|
+
3. For plugin credentials, update the values at the end of the `.env` file
|
|
284
|
+
4. Restart services: `docker-compose restart`
|
|
285
|
+
|
|
286
|
+
**Tip**: Generate secure random values with:
|
|
287
|
+
```bash
|
|
288
|
+
# Linux/Mac
|
|
289
|
+
openssl rand -base64 32
|
|
290
|
+
|
|
291
|
+
# PowerShell (Windows)
|
|
292
|
+
[Convert]::ToBase64String((1..32 | ForEach-Object { Get-Random -Minimum 0 -Maximum 256 }))
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Plugin Installation Failed
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
❌ Failed to generate plugin configuration
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Solution**:
|
|
302
|
+
- Check internet connection
|
|
303
|
+
- Verify plugin package name
|
|
304
|
+
- Try installing plugins manually with `@simplens/config-gen`
|
|
305
|
+
|
|
306
|
+
## Development
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
# Clone repository
|
|
310
|
+
cd packages/onboard
|
|
311
|
+
|
|
312
|
+
# Install dependencies
|
|
313
|
+
npm install
|
|
314
|
+
|
|
315
|
+
# Build TypeScript
|
|
316
|
+
npm run build
|
|
317
|
+
|
|
318
|
+
# Test locally
|
|
319
|
+
npm link
|
|
320
|
+
simplens-onboard --help
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## License
|
|
324
|
+
|
|
325
|
+
ISC
|
|
326
|
+
|
|
327
|
+
## Support
|
|
328
|
+
|
|
329
|
+
For issues and questions:
|
|
330
|
+
- GitHub Issues: [SimpleNS Core Issues](https://github.com/SimpleNotificationSystem/simplens-core/issues)
|
|
331
|
+
- Documentation: [SimpleNS Docs](https://simplens.vercel.app)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-config.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/env-config.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { normalizeBasePath, validateBasePath } from '../env-config.js';
|
|
3
|
+
describe('env-config base path helpers', () => {
|
|
4
|
+
it('accepts empty base path for root', () => {
|
|
5
|
+
expect(validateBasePath('')).toBe(true);
|
|
6
|
+
});
|
|
7
|
+
it('accepts a single segment path', () => {
|
|
8
|
+
expect(validateBasePath('/dashboard')).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
it('accepts nested path segments', () => {
|
|
11
|
+
expect(validateBasePath('/admin/v1')).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
it('rejects path without leading slash', () => {
|
|
14
|
+
expect(validateBasePath('dashboard')).not.toBe(true);
|
|
15
|
+
});
|
|
16
|
+
it('rejects trailing slash path', () => {
|
|
17
|
+
expect(validateBasePath('/dashboard/')).not.toBe(true);
|
|
18
|
+
});
|
|
19
|
+
it('trims whitespace during normalization', () => {
|
|
20
|
+
expect(normalizeBasePath(' /dashboard ')).toBe('/dashboard');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=env-config.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-config.test.js","sourceRoot":"","sources":["../../src/__tests__/env-config.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEvE,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC1C,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QACxC,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACrC,MAAM,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACpC,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC1C,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACnC,MAAM,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC7C,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra-prompts.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/infra-prompts.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
// Mock @clack/prompts
|
|
3
|
+
vi.mock('@clack/prompts', () => ({
|
|
4
|
+
multiselect: vi.fn(),
|
|
5
|
+
spinner: vi.fn(() => ({
|
|
6
|
+
start: vi.fn(),
|
|
7
|
+
stop: vi.fn(),
|
|
8
|
+
error: vi.fn(),
|
|
9
|
+
message: vi.fn(),
|
|
10
|
+
})),
|
|
11
|
+
}));
|
|
12
|
+
// Mock the ui.js module
|
|
13
|
+
vi.mock('../ui.js', () => ({
|
|
14
|
+
handleCancel: vi.fn(),
|
|
15
|
+
}));
|
|
16
|
+
import { multiselect } from '@clack/prompts';
|
|
17
|
+
import { promptInfraServicesWithBasePath } from '../infra.js';
|
|
18
|
+
describe('promptInfraServicesWithBasePath', () => {
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
vi.clearAllMocks();
|
|
21
|
+
});
|
|
22
|
+
it('includes nginx when allowNginx is true', async () => {
|
|
23
|
+
const mockMultiselect = vi.mocked(multiselect);
|
|
24
|
+
mockMultiselect.mockResolvedValue(['mongo', 'redis', 'nginx']);
|
|
25
|
+
const result = await promptInfraServicesWithBasePath({ allowNginx: true });
|
|
26
|
+
// Should include nginx in options
|
|
27
|
+
const callArgs = mockMultiselect.mock.calls[0][0];
|
|
28
|
+
const values = callArgs.options.map((o) => o.value);
|
|
29
|
+
expect(values).toContain('nginx');
|
|
30
|
+
expect(result).toContain('nginx');
|
|
31
|
+
});
|
|
32
|
+
it('excludes nginx when allowNginx is false', async () => {
|
|
33
|
+
const mockMultiselect = vi.mocked(multiselect);
|
|
34
|
+
mockMultiselect.mockResolvedValue(['mongo', 'redis']);
|
|
35
|
+
const result = await promptInfraServicesWithBasePath({ allowNginx: false });
|
|
36
|
+
// Should NOT include nginx in options
|
|
37
|
+
const callArgs = mockMultiselect.mock.calls[0][0];
|
|
38
|
+
const values = callArgs.options.map((o) => o.value);
|
|
39
|
+
expect(values).not.toContain('nginx');
|
|
40
|
+
expect(result).not.toContain('nginx');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=infra-prompts.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra-prompts.test.js","sourceRoot":"","sources":["../../src/__tests__/infra-prompts.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE9D,sBAAsB;AACtB,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7B,WAAW,EAAE,EAAE,CAAC,EAAE,EAAE;IACpB,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;QAClB,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;QACd,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;QACb,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;QACd,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE;KACnB,CAAC,CAAC;CACN,CAAC,CAAC,CAAC;AAEJ,wBAAwB;AACxB,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;IACvB,YAAY,EAAE,EAAE,CAAC,EAAE,EAAE;CACxB,CAAC,CAAC,CAAC;AAEJ,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAE9D,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC7C,UAAU,CAAC,GAAG,EAAE;QACZ,EAAE,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACpD,MAAM,eAAe,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC/C,eAAe,CAAC,iBAAiB,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAE/D,MAAM,MAAM,GAAG,MAAM,+BAA+B,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAE3E,kCAAkC;QAClC,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAQ,CAAC;QACzD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACzD,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAElC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,eAAe,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC/C,eAAe,CAAC,iBAAiB,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAEtD,MAAM,MAAM,GAAG,MAAM,+BAA+B,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QAE5E,sCAAsC;QACtC,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAQ,CAAC;QACzD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACzD,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAEtC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/infra.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { buildAppComposeContent } from '../infra.js';
|
|
3
|
+
describe('infra app compose generation', () => {
|
|
4
|
+
it('does not include nginx when disabled', () => {
|
|
5
|
+
const compose = buildAppComposeContent(false);
|
|
6
|
+
expect(compose).not.toContain(' nginx:');
|
|
7
|
+
});
|
|
8
|
+
it('includes nginx service when enabled', () => {
|
|
9
|
+
const compose = buildAppComposeContent(true);
|
|
10
|
+
expect(compose).toContain(' nginx:');
|
|
11
|
+
expect(compose).toContain('./nginx.conf:/etc/nginx/conf.d/default.conf:ro');
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=infra.test.js.map
|