owox 0.0.0 → 0.1.0
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 +22 -114
- package/dist/commands/serve.js +20 -28
- package/oclif.manifest.json +1 -1
- package/package.json +5 -3
- package/dist/commands/serve.d.ts +0 -91
- package/dist/index.d.ts +0 -1
package/README.md
CHANGED
|
@@ -6,127 +6,35 @@ A command-line interface for running OWOX Data Marts application. This CLI provi
|
|
|
6
6
|
[](https://npmjs.org/package/owox)
|
|
7
7
|
[](https://npmjs.org/package/owox)
|
|
8
8
|
|
|
9
|
-
<!-- toc -->
|
|
10
9
|
|
|
11
|
-
- [Usage](#usage)
|
|
12
|
-
- [Local Development: npm link](#local-development-npm-link)
|
|
13
|
-
- [Commands](#commands)
|
|
14
|
-
- [FAQ: Understanding the `bin` Folder](#faq-understanding-the-bin-folder)
|
|
15
|
-
<!-- tocstop -->
|
|
16
10
|
|
|
17
|
-
#
|
|
11
|
+
# Quick Start 🚀 (no-code setup)
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
0. **Make sure Node.js ≥ 22.16.0 is installed**
|
|
20
14
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
$ owox serve
|
|
24
|
-
Starting OWOX Data Marts...
|
|
25
|
-
Starting in production mode...
|
|
26
|
-
Starting server on port 3000...
|
|
27
|
-
$ owox --help
|
|
28
|
-
USAGE
|
|
29
|
-
$ owox COMMAND
|
|
30
|
-
...
|
|
31
|
-
```
|
|
15
|
+
If you don't have it installed, [download it here](https://nodejs.org/en/download)
|
|
16
|
+
<sub>(Windows / macOS / Linux installers are all listed there)</sub>
|
|
32
17
|
|
|
33
|
-
|
|
18
|
+
2. **Open your terminal** and run **one** command
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g owox
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
<sub>You’ll see a list of added packages. Some warns are possible — just ignore them.</sub>
|
|
34
24
|
|
|
35
|
-
# Local Development: npm link
|
|
36
25
|
|
|
37
|
-
|
|
26
|
+
3. **Start OWOX Data Marts** locally
|
|
27
|
+
```bash
|
|
28
|
+
owox serve
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
<sub>Expected output:
|
|
32
|
+
🚀 Starting OWOX Data Marts...
|
|
33
|
+
📦 Starting server on port 3000...</sub>
|
|
38
34
|
|
|
39
|
-
|
|
35
|
+
4. **Open** your browser at **http://localhost:3000** and explore! 🎉
|
|
40
36
|
|
|
41
|
-
|
|
37
|
+
---
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
After successfully linking, you can run `owox` commands from any directory:
|
|
48
|
-
|
|
49
|
-
```sh-session
|
|
50
|
-
$ owox serve --port 8080
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## Using `npm unlink -g owox`
|
|
54
|
-
|
|
55
|
-
If you need to remove the global symbolic link to your local `owox` CLI, navigate to the `apps/owox` directory and execute:
|
|
56
|
-
|
|
57
|
-
```sh-session
|
|
58
|
-
$ npm unlink -g owox
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
This will remove the global link, and `owox` will no longer be accessible globally unless re-linked or installed through an npm registry.
|
|
62
|
-
|
|
63
|
-
# Commands
|
|
64
|
-
|
|
65
|
-
<!-- commands -->
|
|
66
|
-
|
|
67
|
-
- [`owox serve`](#owox-serve)
|
|
68
|
-
- [`owox help [COMMAND]`](#owox-help-command)
|
|
69
|
-
|
|
70
|
-
## `owox serve`
|
|
71
|
-
|
|
72
|
-
Start the OWOX Data Marts application in production mode
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
USAGE
|
|
76
|
-
$ owox serve [-p <value>]
|
|
77
|
-
|
|
78
|
-
FLAGS
|
|
79
|
-
-p, --port=<value> [default: 3000] Port number for the application
|
|
80
|
-
|
|
81
|
-
DESCRIPTION
|
|
82
|
-
Start the OWOX Data Marts application in production mode
|
|
83
|
-
|
|
84
|
-
EXAMPLES
|
|
85
|
-
$ owox serve
|
|
86
|
-
$ owox serve --port 8080
|
|
87
|
-
$ owox serve -p 3001
|
|
88
|
-
$ PORT=8080 owox serve
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
_See code: [src/commands/serve.ts](https://github.com/OWOX/owox-data-marts/blob/v0.0.0/src/commands/serve.ts)_
|
|
92
|
-
|
|
93
|
-
## `owox help [COMMAND]`
|
|
94
|
-
|
|
95
|
-
Display help for owox.
|
|
96
|
-
|
|
97
|
-
```
|
|
98
|
-
USAGE
|
|
99
|
-
$ owox help [COMMAND...] [-n]
|
|
100
|
-
|
|
101
|
-
ARGUMENTS
|
|
102
|
-
COMMAND... Command to show help for.
|
|
103
|
-
|
|
104
|
-
FLAGS
|
|
105
|
-
-n, --nested-commands Include all nested commands in the output.
|
|
106
|
-
|
|
107
|
-
DESCRIPTION
|
|
108
|
-
Display help for owox.
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.21/src/commands/help.ts)_
|
|
112
|
-
|
|
113
|
-
<!-- commandsstop -->
|
|
114
|
-
|
|
115
|
-
# FAQ
|
|
116
|
-
|
|
117
|
-
This section explains the purpose of the files located in the `bin` directory of the CLI.
|
|
118
|
-
|
|
119
|
-
### Why are there files in the `bin` folder (`dev.cmd`, `run.js`, `dev.js`, `run.cmd`)? Why do some have a `.cmd` format?
|
|
120
|
-
|
|
121
|
-
The `bin` folder contains the executable entry points for your CLI. Their presence and format are designed to support different operating systems and operational modes (development/production).
|
|
122
|
-
|
|
123
|
-
- **`run.js` (and `run.cmd`)**: These are the primary "production" entry points for your CLI.
|
|
124
|
-
|
|
125
|
-
- **`run.js`**: This is the main executable file for Unix-based systems (Linux, macOS). The `#!/usr/bin/env node` (shebang) line at the beginning tells the operating system to execute this file using Node.js. This file launches the compiled version of your CLI (from the `dist` folder).
|
|
126
|
-
- **`run.cmd`**: This is the equivalent of `run.js` for Windows operating systems. Windows does not understand shebangs, so a separate `.cmd` (or `.bat`) file is required to explicitly instruct the system to execute the Node.js script using the `node` interpreter.
|
|
127
|
-
|
|
128
|
-
- **`dev.js` (and `dev.cmd`)**: These are entry points specifically designed for **development**.
|
|
129
|
-
- **`dev.js`**: This executable file is for Unix-based systems when running in development mode. Notice the shebang line `#!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning`. This allows Node.js to run your TypeScript code **without prior compilation** by using the `ts-node/esm` loader. This significantly speeds up development as you don't need to wait for compilation every time you make changes. The `development: true` flag is passed to `@oclif/core` to enable development-specific features.
|
|
130
|
-
- **`dev.cmd`**: This is the Windows equivalent of `dev.js`, also used for running in development mode with `ts-node/esm`.
|
|
131
|
-
|
|
132
|
-
In summary, the `.cmd` files ensure compatibility with Windows, while the `run` and `dev` pairs provide distinct entry points for the "production-ready" (compiled) CLI version and the active development version (directly from TypeScript source files).
|
|
39
|
+
👉 Ready to contribute or run in development mode?
|
|
40
|
+
Check out [CONTRIBUTING.md](./CONTRIBUTING.md) for advanced setup and CLI commands.
|
package/dist/commands/serve.js
CHANGED
|
@@ -2,7 +2,6 @@ import { Command, Flags } from '@oclif/core';
|
|
|
2
2
|
import { exec, spawn } from 'node:child_process';
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import { createRequire } from 'node:module';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
5
|
import { promisify } from 'node:util';
|
|
7
6
|
const execAsync = promisify(exec);
|
|
8
7
|
const require = createRequire(import.meta.url);
|
|
@@ -44,11 +43,7 @@ export default class Serve extends Command {
|
|
|
44
43
|
const { flags } = await this.parse(Serve);
|
|
45
44
|
this.log('🚀 Starting OWOX Data Marts...');
|
|
46
45
|
this.setupGracefulShutdown();
|
|
47
|
-
const backendPath = this.
|
|
48
|
-
if (!this.isBackendAvailable(backendPath)) {
|
|
49
|
-
this.error('@owox/backend package not found. Please ensure it is installed:\n' +
|
|
50
|
-
'npm install @owox/backend', { exit: 1 });
|
|
51
|
-
}
|
|
46
|
+
const backendPath = this.validateBackendAvailability();
|
|
52
47
|
try {
|
|
53
48
|
await this.killMarkedProcesses();
|
|
54
49
|
await this.startBackend(backendPath, flags.port);
|
|
@@ -90,20 +85,6 @@ export default class Serve extends Command {
|
|
|
90
85
|
const numericPid = Number.parseInt(pid, 10);
|
|
91
86
|
return !Number.isNaN(numericPid) && numericPid > 0 ? numericPid : null;
|
|
92
87
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Gets the path to the backend package
|
|
95
|
-
* @returns The full path to the backend entry point
|
|
96
|
-
*/
|
|
97
|
-
getBackendPath() {
|
|
98
|
-
try {
|
|
99
|
-
// Try to resolve using Node.js module resolution
|
|
100
|
-
return require.resolve('@owox/backend');
|
|
101
|
-
}
|
|
102
|
-
catch {
|
|
103
|
-
// Fallback to node_modules path for ESM compatibility
|
|
104
|
-
return join(this.config.root, 'node_modules', '@owox/backend', 'dist', 'main.js');
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
88
|
/**
|
|
108
89
|
* Handles child process exit events
|
|
109
90
|
* @param code - Exit code
|
|
@@ -138,14 +119,6 @@ export default class Serve extends Command {
|
|
|
138
119
|
const message = error instanceof Error ? error.message : String(error);
|
|
139
120
|
this.error(`Failed to start application: ${message}`, { exit: 1 });
|
|
140
121
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Checks if the backend package is available
|
|
143
|
-
* @param backendPath - Path to the backend entry point
|
|
144
|
-
* @returns True if backend package exists and is accessible
|
|
145
|
-
*/
|
|
146
|
-
isBackendAvailable(backendPath) {
|
|
147
|
-
return existsSync(backendPath);
|
|
148
|
-
}
|
|
149
122
|
/**
|
|
150
123
|
* Kills all processes marked with PROCESS_MARKER
|
|
151
124
|
*/
|
|
@@ -229,6 +202,25 @@ export default class Serve extends Command {
|
|
|
229
202
|
};
|
|
230
203
|
await this.spawnProcess(options);
|
|
231
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Validates that the backend package is available and accessible
|
|
207
|
+
* @returns The resolved path to the backend entry point
|
|
208
|
+
* @throws Error if backend is not available or accessible
|
|
209
|
+
*/
|
|
210
|
+
validateBackendAvailability() {
|
|
211
|
+
let backendPath;
|
|
212
|
+
try {
|
|
213
|
+
backendPath = require.resolve('@owox/backend');
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
this.error('@owox/backend package not found. Please ensure it is installed:\n' +
|
|
217
|
+
'npm install @owox/backend', { exit: 1 });
|
|
218
|
+
}
|
|
219
|
+
if (!existsSync(backendPath)) {
|
|
220
|
+
this.error('@owox/backend entry point not found', { exit: 1 });
|
|
221
|
+
}
|
|
222
|
+
return backendPath;
|
|
223
|
+
}
|
|
232
224
|
/**
|
|
233
225
|
* Waits for processes to cleanup
|
|
234
226
|
*/
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "owox",
|
|
3
3
|
"description": "OWOX Data Marts CLI: Simple command-line interface to start the OWOX Data Marts application with backend and frontend components.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.1.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@oclif/core": "^4",
|
|
14
14
|
"@oclif/plugin-help": "^6",
|
|
15
15
|
"@oclif/plugin-plugins": "^5",
|
|
16
|
-
"@owox/backend": "0.
|
|
16
|
+
"@owox/backend": "0.1.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@eslint/compat": "^1",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
38
38
|
"./bin",
|
|
39
|
-
"./dist",
|
|
39
|
+
"./dist/**/*.js",
|
|
40
40
|
"./oclif.manifest.json"
|
|
41
41
|
],
|
|
42
42
|
"homepage": "https://github.com/OWOX/owox-data-marts",
|
|
@@ -70,6 +70,8 @@
|
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "tsc -b",
|
|
72
72
|
"lint": "eslint",
|
|
73
|
+
"lint:md": "markdownlint-cli2 --config ../../.markdownlint-cli2.mjs",
|
|
74
|
+
"lint:md:fix": "markdownlint-cli2 --config ../../.markdownlint-cli2.mjs --fix",
|
|
73
75
|
"posttest": "npm run lint",
|
|
74
76
|
"prepack": "oclif manifest",
|
|
75
77
|
"prepublishOnly": "npm audit && npm run test && npm run lint",
|
package/dist/commands/serve.d.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
|
-
/**
|
|
3
|
-
* Command to start the OWOX Data Marts application.
|
|
4
|
-
* Requires @owox/backend to be installed.
|
|
5
|
-
*/
|
|
6
|
-
export default class Serve extends Command {
|
|
7
|
-
static description: string;
|
|
8
|
-
static examples: string[];
|
|
9
|
-
static flags: {
|
|
10
|
-
port: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
};
|
|
12
|
-
private childProcess?;
|
|
13
|
-
private isShuttingDown;
|
|
14
|
-
/**
|
|
15
|
-
* Main execution method for the serve command
|
|
16
|
-
*/
|
|
17
|
-
run(): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Attaches event handlers to the child process
|
|
20
|
-
*/
|
|
21
|
-
private attachProcessEventHandlers;
|
|
22
|
-
/**
|
|
23
|
-
* Creates environment variables for the child process
|
|
24
|
-
* @param port - Port number to set in environment
|
|
25
|
-
* @returns Environment variables object
|
|
26
|
-
*/
|
|
27
|
-
private createProcessEnvironment;
|
|
28
|
-
/**
|
|
29
|
-
* Extracts PID from ps command output line
|
|
30
|
-
*/
|
|
31
|
-
private extractPidFromProcessLine;
|
|
32
|
-
/**
|
|
33
|
-
* Gets the path to the backend package
|
|
34
|
-
* @returns The full path to the backend entry point
|
|
35
|
-
*/
|
|
36
|
-
private getBackendPath;
|
|
37
|
-
/**
|
|
38
|
-
* Handles child process exit events
|
|
39
|
-
* @param code - Exit code
|
|
40
|
-
* @param signal - Exit signal
|
|
41
|
-
*/
|
|
42
|
-
private handleProcessExit;
|
|
43
|
-
/**
|
|
44
|
-
* Handles shutdown signals
|
|
45
|
-
* @param signal - The received shutdown signal
|
|
46
|
-
*/
|
|
47
|
-
private handleShutdownSignal;
|
|
48
|
-
/**
|
|
49
|
-
* Handles startup errors
|
|
50
|
-
* @param error - The error that occurred during startup
|
|
51
|
-
*/
|
|
52
|
-
private handleStartupError;
|
|
53
|
-
/**
|
|
54
|
-
* Checks if the backend package is available
|
|
55
|
-
* @param backendPath - Path to the backend entry point
|
|
56
|
-
* @returns True if backend package exists and is accessible
|
|
57
|
-
*/
|
|
58
|
-
private isBackendAvailable;
|
|
59
|
-
/**
|
|
60
|
-
* Kills all processes marked with PROCESS_MARKER
|
|
61
|
-
*/
|
|
62
|
-
private killMarkedProcesses;
|
|
63
|
-
/**
|
|
64
|
-
* Kills a process by PID
|
|
65
|
-
*/
|
|
66
|
-
private killProcess;
|
|
67
|
-
/**
|
|
68
|
-
* Sets up graceful shutdown handlers for system signals
|
|
69
|
-
*/
|
|
70
|
-
private setupGracefulShutdown;
|
|
71
|
-
/**
|
|
72
|
-
* Spawns a child process with the given options
|
|
73
|
-
* @param options - Process spawn options
|
|
74
|
-
*/
|
|
75
|
-
private spawnProcess;
|
|
76
|
-
/**
|
|
77
|
-
* Starts the backend application
|
|
78
|
-
* @param backendPath - Path to the backend entry point
|
|
79
|
-
* @param port - Port number to run the application on
|
|
80
|
-
*/
|
|
81
|
-
private startBackend;
|
|
82
|
-
/**
|
|
83
|
-
* Waits for processes to cleanup
|
|
84
|
-
*/
|
|
85
|
-
private waitForCleanup;
|
|
86
|
-
/**
|
|
87
|
-
* Waits for the child process to complete
|
|
88
|
-
* @returns Promise that resolves when process exits successfully
|
|
89
|
-
*/
|
|
90
|
-
private waitForProcessCompletion;
|
|
91
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { run } from '@oclif/core';
|