neex 0.1.4 → 0.1.5

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 CHANGED
@@ -6,7 +6,7 @@
6
6
  </picture>
7
7
  </a>
8
8
 
9
- # Neex v0.1.2
9
+ # Neex v0.1.5
10
10
 
11
11
  ### 🚀 Neex: The Modern Build System for Polyrepo-in-Monorepo Architecture
12
12
 
@@ -20,7 +20,7 @@
20
20
 
21
21
  next + express = neex 🌱
22
22
 
23
- Neex is a modern build system designed to bridge the gap between polyrepo and monorepo architectures. It provides powerful script execution capabilities with features like parallel processing, colored output, and intelligent build orchestration. Whether you're managing a complex monorepo or coordinating multiple repositories, neex makes your development workflow more efficient and visually organized.
23
+ Neex is a modern build system and script runner designed for **Polyrepo-in-Monorepo** architectures, but powerful enough for any project. It simplifies managing and running multiple scripts across your project, whether they are microservices, frontend applications, or build tasks. Neex offers robust features like parallel and sequential execution, live-reloading for development (`watch`), optimized server running (`servers`), and even basic process management (`pm2`-like commands), all aimed at making your development workflow more efficient, organized, and visually clear.
24
24
 
25
25
  ## ✨ Key Features
26
26
 
@@ -34,7 +34,24 @@ Neex is a modern build system designed to bridge the gap between polyrepo and mo
34
34
  - 🤫 **Flexible Display** - Control prefixes, timing, and output visibility
35
35
  - 🧰 **Node.js API** - Programmatic usage in your applications
36
36
 
37
- ## Quick Start
37
+ ## 🚀 Installation
38
+
39
+ Install Neex globally to use it anywhere, or locally in your project.
40
+
41
+ ```bash
42
+ # Global install
43
+ npm install -g neex
44
+
45
+ # Local install
46
+ npm install --save-dev neex # npm
47
+ yarn add --dev neex # yarn
48
+ pnpm add --save-dev neex # pnpm
49
+ bun add --dev neex # bun
50
+ ```
51
+
52
+ When installed locally, you can run Neex commands using `npx neex ...` or by adding them to your `package.json` scripts.
53
+
54
+ ## 🖥️ Usage
38
55
 
39
56
  ```bash
40
57
  # Global install
@@ -49,35 +66,147 @@ bun add -D neex # bun
49
66
 
50
67
  ## 🖥️ Usage
51
68
 
52
- ### Commands
69
+ ### Core Commands
70
+
71
+ Neex provides several commands to manage and run your scripts:
72
+
73
+ - **`runx <commands...>`** (alias: `px`, *default command*)
74
+ - Runs specified commands in **parallel** by default.
75
+ - Use the `-q` or `--sequential` flag to run them sequentially.
76
+ - Ideal for build steps, tests, or any tasks that can run concurrently.
77
+
78
+ - **`run <commands...>`** (alias: `s`)
79
+ - Runs specified commands **sequentially**.
80
+ - Useful for tasks that depend on the completion of previous ones (e.g., build then deploy).
53
81
 
54
- - `runx` (alias: `p`) - Run in **parallel** (default)
55
- - `run` (alias: `s`) - Run **sequentially**
82
+ - **`servers <commands...>`** (alias: `srv`)
83
+ - Optimized for running multiple development **servers** (e.g., backend API, frontend app) in parallel.
84
+ - Provides grouped and clear output for each server, making it easy to monitor logs.
85
+ - Detects and displays server ports and URLs.
56
86
 
57
- ### Examples
87
+ - **`watch <commands...>`** (alias: `w`)
88
+ - Runs commands and **watches for file changes** to automatically restart them (Nodemon-like functionality).
89
+ - Highly configurable with options for watched paths, ignored patterns, extensions, and restart delays.
90
+ - Perfect for development workflows where you need instant feedback on code changes.
91
+
92
+ - **Process Management Commands**
93
+ - Neex provides built-in process management capabilities, similar to PM2, for long-running applications. These commands operate directly under `neex`:
94
+ - **`start <script_path_or_command> [--name <name>] [--watch] [-- <args...>]`**: Start a new process.
95
+ - **`stop <name_or_id>`**: Stop a running process.
96
+ - **`restart <name_or_id>`**: Restart a running process.
97
+ - **`delete <name_or_id>`**: Stop and delete a process from the list.
98
+ - **`list`** (aliases: `ls`, `status`): List all managed processes.
99
+ - **`logs [name_or_id] [--lines <number>] [--follow]`**: Display logs for a specific process or all if no ID is given.
100
+ - **`monit`**: Launch a monitoring interface for all managed processes.
101
+ - **`save`**: Save the current list of running processes.
102
+ - **`resurrect`**: Restart processes that were previously saved.
103
+ - **`startup`**: Generate a sample startup script (e.g., for systemd).
104
+
105
+ ### General Command Examples
58
106
 
59
107
  ```bash
60
- # Parallel execution (default)
61
- neex p "echo Task 1" "echo Task 2" "echo Task 3"
108
+ # Parallel execution (default behavior for runx)
109
+ neex runx "npm run build:api" "npm run build:frontend" "npm run lint"
110
+ # Alias for parallel
111
+ neex px "npm run test:unit" "npm run test:integration"
62
112
 
63
113
  # Sequential execution
64
- neex s "echo Step 1" "echo Step 2" "echo Step 3"
114
+ neex run "npm run clean" "npm run build" "npm run deploy"
115
+ # Alias for sequential
116
+ neex s "echo First" "echo Second" "echo Third"
117
+
118
+ # Run 'runx' commands sequentially using the -q flag
119
+ neex runx -q "npm run step1" "npm run step2"
120
+ ```
121
+
122
+ ### `servers` Command Examples
123
+
124
+ ```bash
125
+ # Start frontend and backend development servers
126
+ neex servers "cd frontend && npm start" "cd backend && npm start"
65
127
 
66
- # Parallel with sequential flag
67
- neex p -q "echo Step 1" "echo Step 2" "echo Step 3"
128
+ # Group output for better readability
129
+ neex servers --group-output "npm run dev:service-a" "npm run dev:service-b"
68
130
  ```
69
131
 
70
- ### 🛠️ Options
132
+ ### `watch` Command Examples
133
+
134
+ ```bash
135
+ # Watch for changes in './src' and restart 'npm run build'
136
+ neex watch "npm run build" -w ./src
137
+
138
+ # Watch for .ts file changes in 'services/' and restart two commands, ignoring 'node_modules'
139
+ neex watch "npm run start:service1" "npm run start:service2" -w services/ -e ts -i node_modules/**
71
140
 
72
- | Flag | Alias | Description | Default |
73
- |------|-------|-------------|----------|
74
- | `--no-color` | `-c` | Disable colors | `false` |
75
- | `--no-timing` | `-t` | Hide timing | `false` |
76
- | `--no-prefix` | `-p` | Hide prefixes | `false` |
77
- | `--stop-on-error` | `-s` | Stop on failure | `false` |
78
- | `--no-output` | `-o` | Hide all output | `false` |
79
- | `--max-parallel` | `-m` | Max parallel tasks | CPU count |
80
- | `--sequential` | `-q` | Force sequential | `false` |
141
+ # Clear console on restart and set a delay
142
+ neex watch "node server.js" --clear --delay 1500
143
+ ```
144
+
145
+ ### Process Management Command Examples
146
+
147
+ ```bash
148
+ # Start a Node.js app and give it a name
149
+ neex start server.js --name my-app
150
+
151
+ # Start an app and watch for file changes
152
+ neex start api/index.js --name my-api --watch
153
+
154
+ # List all running processes managed by neex
155
+ neex list
156
+
157
+ # View logs for 'my-app'
158
+ neex logs my-app
159
+
160
+ # Stop 'my-api'
161
+ neex stop my-api
162
+
163
+ # Restart 'my-app'
164
+ neex restart my-app
165
+
166
+ # Delete 'my-api' from neex management
167
+ neex delete my-api
168
+ ```
169
+
170
+ ### 🛠️ Global Options (for `run`, `runx`, `servers`)
171
+
172
+ These options can be used with `run`, `runx`, and `servers` commands:
173
+
174
+ | Flag | Alias | Description | Default |
175
+ |--------------------------|-------|---------------------------------------------------|----------------|
176
+ | `--no-color` | `-c` | Disable colored output | `true` (color on) |
177
+ | `--no-timing` | `-t` | Hide timing information for each command | `true` (timing on) |
178
+ | `--no-prefix` | `-p` | Hide command prefix in output | `true` (prefix on) |
179
+ | `--stop-on-error` | `-s` | Stop all further execution if a command fails | `false` |
180
+ | `--no-output` | `-o` | Hide all `stdout` and `stderr` from commands | `true` (output on) |
181
+ | `--minimal` | | Use minimal output format (less verbose) | `false` |
182
+ | `--max-parallel <number>`| | Maximum number of commands to run in parallel | CPU count |
183
+ | `--sequential` | `-q` | (For `runx`) Run commands sequentially instead of parallel | `false` |
184
+ | `--retry <count>` | | Number of times to retry a failed command | `0` |
185
+ | `--retry-delay <ms>` | | Delay in milliseconds between retries | `1000` |
186
+ | `--group-output` | `-g` | (For `servers`) Group output by server | `false` |
187
+
188
+ ### `watch` Command Options
189
+
190
+ | Flag | Alias | Description | Default |
191
+ |-----------------------------|-------|------------------------------------------------------|--------------------------------------------|
192
+ | `--watch <paths...>` | `-w` | Paths/glob patterns to watch | `['./']` |
193
+ | `--ignore <patterns...>` | `-i` | Paths/glob patterns to ignore | `['node_modules/**', '.git/**', ...]` |
194
+ | `--ext <extensions...>` | `-e` | File extensions to watch | `['js', 'mjs', 'json', 'ts', 'tsx', 'jsx']`|
195
+ | `--delay <ms>` | `-d` | Delay in milliseconds before restarting after a change | `1000` |
196
+ | `--clear` | | Clear console on restart | `false` |
197
+ | `--verbose` | | Show verbose output from the watcher | `false` |
198
+ | `--signal <signal>` | | Signal to send to processes on restart | `SIGTERM` |
199
+ | *Global options also apply* | | `no-color`, `no-timing`, etc. | |
200
+
201
+ ### `start` Command Options
202
+
203
+ | Flag | Description | Default |
204
+ |-----------------------------|--------------------------------------------------|-----------|
205
+ | `--name <name>` | Specify a name for the process | Script name |
206
+ | `--watch` | Enable file watching and auto-restart | `false` |
207
+ | `--ignore-watch <paths...>` | Paths/patterns to ignore when watching | |
208
+ | `--watch-delay <ms>` | Delay for watch restarts | `1000` |
209
+ | `-- <args...>` | Arguments to pass to the script | |
81
210
 
82
211
 
83
212
  ### Advanced Example
@@ -115,17 +244,38 @@ async function main() {
115
244
  }
116
245
  ```
117
246
 
118
- ### API Options
247
+ ### API Options (`RunOptions`)
248
+
249
+ When using Neex programmatically, you can pass an options object to the `run` function:
119
250
 
120
251
  ```typescript
121
- interface RunOptions {
122
- parallel?: boolean; // Run in parallel (default: true)
123
- maxParallel?: number; // Max parallel processes (default: CPU count)
124
- color?: boolean; // Enable colors (default: true)
125
- prefix?: boolean; // Show command prefix (default: true)
126
- showTiming?: boolean; // Show timing info (default: true)
127
- printOutput?: boolean; // Show command output (default: true)
128
- stopOnError?: boolean; // Stop on failure (default: false)
252
+ export interface RunOptions {
253
+ // Run in parallel or sequentially
254
+ parallel: boolean;
255
+ // Maximum number of parallel processes (default: CPU count)
256
+ maxParallel?: number;
257
+ // Show command output (default: true)
258
+ printOutput: boolean;
259
+ // Color output (default: true)
260
+ color: boolean;
261
+ // Show timing information (default: true)
262
+ showTiming: boolean;
263
+ // Show command prefix (default: true)
264
+ prefix: boolean;
265
+ // Stop on error (default: false)
266
+ stopOnError: boolean;
267
+ // Use minimal output format (default: false)
268
+ minimalOutput: boolean;
269
+ // Group output by command (default: false, mainly for server mode)
270
+ groupOutput: boolean;
271
+ // Use server mode formatting (default: false)
272
+ isServerMode: boolean;
273
+ // Number of times to retry a failed command (default: 0)
274
+ retry?: number;
275
+ // Delay in milliseconds between retries (default: 1000)
276
+ retryDelay?: number;
277
+ // Callback to register a cleanup function, called on SIGINT/SIGTERM
278
+ registerCleanup?: (cleanupFn: () => void) => void;
129
279
  }
130
280
  ```
131
281
 
@@ -141,17 +291,54 @@ steps:
141
291
  run: neex p -s -m 4 "npm run lint" "npm test" "npm run e2e"
142
292
  ```
143
293
 
144
- ## 💡 Real-world Examples
294
+ ## 💡 Real-world Scenarios & `package.json` Integration
295
+
296
+ Neex shines when integrated into your `package.json` scripts.
297
+
298
+ **Example `package.json` scripts:**
299
+
300
+ ```json
301
+ {
302
+ "scripts": {
303
+ "dev:frontend": "cd packages/frontend && npm run dev",
304
+ "dev:backend": "cd packages/api && npm run dev",
305
+ "dev": "neex servers \"npm run dev:frontend\" \"npm run dev:backend\" --group-output",
306
+
307
+ "build:ui": "cd packages/ui-library && npm run build",
308
+ "build:app": "cd packages/main-app && npm run build",
309
+ "build": "neex runx \"npm run build:ui\" \"npm run build:app\"",
310
+
311
+ "test": "neex runx -s \"npm run test:unit\" \"npm run test:e2e\"",
312
+ "test:unit": "jest",
313
+ "test:e2e": "playwright test",
314
+
315
+ "lint": "eslint .",
316
+ "format": "prettier --write .",
317
+ "check-all": "neex p \"npm run lint\" \"npm run format -- --check\" \"npm run test\"",
318
+
319
+ "start:prod": "neex pm2 start dist/server.js --name my-prod-app",
320
+ "watch:build": "neex watch \"npm run build:app\" -w packages/main-app/src -e ts,tsx"
321
+ }
322
+ }
323
+ ```
324
+
325
+ **Running these scripts:**
145
326
 
146
327
  ```bash
147
- # Dev servers
148
- neex p "cd frontend && npm dev" "cd api && npm dev"
328
+ # Start all development servers with grouped output
329
+ npm run dev
330
+
331
+ # Build UI library and main application in parallel
332
+ npm run build
333
+
334
+ # Run linters, format check, and all tests in parallel
335
+ npm run check-all
149
336
 
150
- # Monorepo build
151
- neex p -m 2 "npm run build:ui" "npm run build:api"
337
+ # Start the production application using neex's pm2
338
+ npm run start:prod
152
339
 
153
- # Deploy pipeline
154
- neex s -s "npm test" "npm run build" "npm run deploy"
340
+ # Watch for changes in the main app's src and rebuild it
341
+ npm run watch:build
155
342
  ```
156
343
 
157
344
  ## 🤝 Contributing
package/dist/src/cli.js CHANGED
@@ -81,8 +81,8 @@ function cli() {
81
81
  // runx command: parallel execution by default (with alias 'p'), can run sequentially with -q
82
82
  program
83
83
  .command('runx <commands...>', { isDefault: true })
84
- .alias('p')
85
- .description('Run commands in parallel (default) or sequentially with -q. Alias: p')
84
+ .alias('px')
85
+ .description('Run commands in parallel (default) or sequentially with -q. Alias: px')
86
86
  .option('-c, --no-color', 'Disable colored output')
87
87
  .option('-t, --no-timing', 'Hide timing information')
88
88
  .option('-p, --no-prefix', 'Hide command prefix')
@@ -221,10 +221,9 @@ function cli() {
221
221
  process.exit(1);
222
222
  }
223
223
  });
224
- // PM2-like process management commands
225
- const pm2Group = program.command('pm2').description('Process management commands (PM2 alternative)');
224
+ // Process management commands
226
225
  // Start command
227
- pm2Group
226
+ program
228
227
  .command('start <script>')
229
228
  .description('Start a new process')
230
229
  .option('-n, --name <name>', 'Process name')
@@ -270,7 +269,7 @@ function cli() {
270
269
  }
271
270
  });
272
271
  // Stop command
273
- pm2Group
272
+ program
274
273
  .command('stop <id>')
275
274
  .description('Stop a process')
276
275
  .action(async (id) => {
@@ -299,7 +298,7 @@ function cli() {
299
298
  }
300
299
  });
301
300
  // Restart command
302
- pm2Group
301
+ program
303
302
  .command('restart <id>')
304
303
  .description('Restart a process')
305
304
  .action(async (id) => {
@@ -328,7 +327,7 @@ function cli() {
328
327
  }
329
328
  });
330
329
  // Delete command
331
- pm2Group
330
+ program
332
331
  .command('delete <id>')
333
332
  .description('Delete a process')
334
333
  .action(async (id) => {
@@ -357,7 +356,7 @@ function cli() {
357
356
  }
358
357
  });
359
358
  // List/Status command
360
- pm2Group
359
+ program
361
360
  .command('list')
362
361
  .alias('status')
363
362
  .alias('ls')
@@ -403,7 +402,7 @@ function cli() {
403
402
  }
404
403
  });
405
404
  // Logs command
406
- pm2Group
405
+ program
407
406
  .command('logs [id]')
408
407
  .description('Show process logs')
409
408
  .option('-f, --follow', 'Follow log output')
@@ -442,7 +441,7 @@ function cli() {
442
441
  }
443
442
  });
444
443
  // Save command
445
- pm2Group
444
+ program
446
445
  .command('save')
447
446
  .description('Save current process list')
448
447
  .action(async () => {
@@ -465,7 +464,7 @@ function cli() {
465
464
  }
466
465
  });
467
466
  // Startup command (placeholder for system startup configuration)
468
- pm2Group
467
+ program
469
468
  .command('startup')
470
469
  .description('Generate startup script')
471
470
  .action(() => {
@@ -492,7 +491,7 @@ WantedBy=multi-user.target
492
491
  `));
493
492
  });
494
493
  // Resurrect command (start saved processes)
495
- pm2Group
494
+ program
496
495
  .command('resurrect')
497
496
  .description('Resurrect previously saved processes')
498
497
  .action(async () => {
@@ -527,7 +526,7 @@ WantedBy=multi-user.target
527
526
  }
528
527
  });
529
528
  // Monit command (monitoring interface)
530
- pm2Group
529
+ program
531
530
  .command('monit')
532
531
  .description('Launch monitoring interface')
533
532
  .action(async () => {
package/feet.txt ADDED
@@ -0,0 +1,16 @@
1
+
2
+ نمیشه توی این cli که ترکیب nodemon cuncurently pm2 هست بهش یک قابلیت اضافه کنم که یک چیز شبیه به nginx باشه که اگر بدونی هنگام دیپلوی بهینه pm2 با nginx استفاده میکنن منم میخوام وقتی neex دارن توی حالت production به عنوان pm2 ازش استفاده میکنن یک چیزی باشه که توی پروژه های شبیه به nginx درونی در neex که وظیفه نقش: وب سرور معکوس (Reverse Proxy)
3
+
4
+ کارهایی که NGINX انجام می‌دهد:
5
+
6
+ مدیریت درخواست‌ها به پورت 80 یا 443 (HTTP/HTTPS)
7
+
8
+ به طور پیش‌فرض، اپلیکیشن‌های Node روی پورت‌هایی مثل 3000 یا 5000 کار می‌کنند. NGINX روی پورت‌های استاندارد (مثل 80 برای HTTP) گوش می‌دهد و درخواست‌ها را به اپلیکیشن Node فوروارد می‌کند. لود بالانسینگ (در صورت نیاز)
9
+
10
+ اگر چند نسخه از اپلیکیشن را اجرا کرده‌اید (مثلاً با PM2 در حالت cluster)، NGINX می‌تواند بین آن‌ها توزیع بار انجام دهد.
11
+
12
+ سرویس‌دهی فایل‌های استاتیک
13
+
14
+ مثلاً فایل‌های HTML، CSS، JS یا تصاویر می‌توانند مستقیماً از طریق NGINX سرو شوند بدون درگیر کردن Node.js.
15
+
16
+ مثال کانفیگ ساده در /etc/nginx/sites-available/default: این توی پروژه های neex انجام بده این یک جوری حرفه ای بهش اضافه کن تا به خوبی اتوماتیک این داشته باشه neex
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neex",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "The Modern Build System for Polyrepo-in-Monorepo Architecture",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",