@reximo/cli 0.1.0-alpha.1

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 ADDED
@@ -0,0 +1,111 @@
1
+ # `@reximo/cli`
2
+
3
+ Public CLI package for Reximo.
4
+
5
+ - package-local scripts for `build`, `lint`, `test`, `typecheck`, and `verify`
6
+ - a checked-in `bin/` launcher that works in the workspace and in the packed tarball
7
+ - command wiring separated from config loading and future API-client concerns
8
+ - config resolution that can grow into authenticated API commands without breaking the CLI surface
9
+
10
+ The current commands are intentionally small, but the package layout is prepared for expansion.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install -g @reximo/cli
16
+ ```
17
+
18
+ ## Local usage
19
+
20
+ ```bash
21
+ pnpm reximo:cli:dev -- hello
22
+ pnpm reximo:cli:dev -- info --json
23
+ pnpm reximo:cli:build
24
+ pnpm reximo:cli:pack
25
+ ```
26
+
27
+ - `pnpm reximo:cli:dev -- ...` runs the CLI directly from TypeScript source with `tsx` for the fastest local development loop.
28
+ - `pnpm reximo:cli:build` compiles the package into `dist/packages/reximo-cli` using the Nx build target.
29
+ - `pnpm reximo:cli:pack` runs `npm pack --dry-run` against the built package in `dist/` so you can inspect the exact tarball contents that would be published to npm without actually publishing anything.
30
+
31
+ ## Commands
32
+
33
+ - `reximo hello`
34
+ - `reximo hello --name <name>`
35
+ - `reximo info`
36
+ - `reximo config show`
37
+ - `reximo --help`
38
+
39
+ ## Configuration
40
+
41
+ Configuration resolves in this order:
42
+
43
+ 1. environment variables
44
+ 2. config file
45
+ 3. built-in defaults
46
+
47
+ Supported environment variables:
48
+
49
+ - `REXIMO_API_BASE_URL`
50
+ - `REXIMO_TOKEN`
51
+ - `REXIMO_PROFILE`
52
+ - `REXIMO_CONFIG`
53
+
54
+ Default config path:
55
+
56
+ ```text
57
+ ~/.reximo/config.json
58
+ ```
59
+
60
+ Example config file:
61
+
62
+ ```json
63
+ {
64
+ "profile": "default",
65
+ "profiles": {
66
+ "default": {
67
+ "apiBaseUrl": "https://api.reximo.example",
68
+ "token": "redacted"
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ ## Release checks
75
+
76
+ ```bash
77
+ pnpm --dir packages/reximo-cli verify
78
+ pnpm --dir packages/reximo-cli pack:dry-run
79
+ ```
80
+
81
+ ## Release flow
82
+
83
+ Use the root release scripts so versioning, tagging, and publishing stay aligned with the monorepo build output.
84
+
85
+ Preview the next version without changing files:
86
+
87
+ ```bash
88
+ pnpm reximo:cli:version -- --bump alpha --dry-run
89
+ ```
90
+
91
+ Apply a version bump:
92
+
93
+ ```bash
94
+ pnpm reximo:cli:version -- --bump alpha
95
+ pnpm reximo:cli:version -- 0.1.0
96
+ ```
97
+
98
+ Recommended release sequence:
99
+
100
+ 1. Run `pnpm reximo:cli:version -- --bump alpha` or set an explicit version.
101
+ 2. Commit the version change.
102
+ 3. Run `pnpm reximo:cli:release` to verify, build, pack, and create the git tag.
103
+ 4. Run `pnpm reximo:cli:publish` to publish from `dist/packages/reximo-cli`.
104
+
105
+ Release behavior:
106
+
107
+ - git tag format: `reximo-cli-v<version>`
108
+ - prerelease npm dist-tag: `alpha`
109
+ - stable npm dist-tag: `latest`
110
+ - release scripts refuse to run on a dirty worktree
111
+ - publish always runs from `dist/packages/reximo-cli`, not from the source package directory
package/bin/reximo.js ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('node:fs');
4
+ const path = require('node:path');
5
+ const { spawnSync } = require('node:child_process');
6
+
7
+ const builtCliPath = path.join(__dirname, '..', 'src', 'cli.js');
8
+
9
+ if (fs.existsSync(builtCliPath)) {
10
+ require(builtCliPath);
11
+ return;
12
+ }
13
+
14
+ const sourceCliPath = path.join(__dirname, '..', 'src', 'cli.ts');
15
+
16
+ if (fs.existsSync(sourceCliPath)) {
17
+ const pnpmCommand = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm';
18
+ const result = spawnSync(pnpmCommand, ['exec', 'tsx', sourceCliPath, ...process.argv.slice(2)], {
19
+ stdio: 'inherit'
20
+ });
21
+
22
+ process.exitCode = result.status ?? 1;
23
+ return;
24
+ }
25
+
26
+ console.error(
27
+ 'Unable to locate the Reximo CLI entrypoint. Build the package or reinstall dependencies.'
28
+ );
29
+ process.exitCode = 1;
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@reximo/cli",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "Command-line interface for Reximo.",
5
+ "type": "commonjs",
6
+ "license": "ISC",
7
+ "author": "MiviaLabs",
8
+ "main": "./src/index.js",
9
+ "types": "./src/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./src/index.d.ts",
13
+ "require": "./src/index.js"
14
+ }
15
+ },
16
+ "bin": {
17
+ "reximo": "bin/reximo.js"
18
+ },
19
+ "files": [
20
+ "bin",
21
+ "src",
22
+ "README.md"
23
+ ],
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+ssh://git@github.com/MiviaLabs/reximo-monorepo.git",
27
+ "directory": "packages/reximo-cli"
28
+ },
29
+ "homepage": "https://github.com/MiviaLabs/reximo-monorepo/tree/main/packages/reximo-cli",
30
+ "bugs": {
31
+ "url": "https://github.com/MiviaLabs/reximo-monorepo/issues"
32
+ },
33
+ "keywords": [
34
+ "reximo",
35
+ "cli",
36
+ "enterprise",
37
+ "api"
38
+ ],
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "engines": {
43
+ "node": ">=20.0.0"
44
+ },
45
+ "sideEffects": false,
46
+ "scripts": {
47
+ "build": "pnpm -C ../.. exec nx build reximo-cli",
48
+ "dev": "pnpm exec tsx src/cli.ts",
49
+ "lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint src --ext .ts",
50
+ "pack:dry-run": "pnpm run build && cd ../../dist/packages/reximo-cli && npm pack --dry-run",
51
+ "test": "pnpm exec tsx --test src/**/*.test.ts",
52
+ "typecheck": "tsc --noEmit",
53
+ "verify": "pnpm run lint && pnpm run typecheck && pnpm run test"
54
+ },
55
+ "dependencies": {
56
+ "commander": "^14.0.3"
57
+ }
58
+ }
package/src/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/src/cli.js ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const run_cli_1 = require("./lib/run-cli");
5
+ void (0, run_cli_1.runCli)(process.argv.slice(2)).then((exitCode) => {
6
+ if (exitCode !== 0) {
7
+ process.exitCode = exitCode;
8
+ }
9
+ });
10
+ //# sourceMappingURL=cli.js.map
package/src/cli.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../../packages/reximo-cli/src/cli.ts"],"names":[],"mappings":";;;AAEA,2CAAuC;AAEvC,KAAK,IAAA,gBAAM,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IACnD,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC9B,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ResolvedConfig } from '../lib/config';
2
+ export type ReximoClient = {
3
+ isConfigured(): boolean;
4
+ describeTarget(): {
5
+ apiBaseUrl: string | null;
6
+ hasToken: boolean;
7
+ profile: string;
8
+ };
9
+ };
10
+ export declare function createReximoClient(config: ResolvedConfig): ReximoClient;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createReximoClient = createReximoClient;
4
+ function createReximoClient(config) {
5
+ return {
6
+ isConfigured() {
7
+ return Boolean(config.apiBaseUrl);
8
+ },
9
+ describeTarget() {
10
+ return {
11
+ apiBaseUrl: config.apiBaseUrl,
12
+ hasToken: Boolean(config.token),
13
+ profile: config.profile
14
+ };
15
+ }
16
+ };
17
+ }
18
+ //# sourceMappingURL=reximo-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reximo-client.js","sourceRoot":"","sources":["../../../../../packages/reximo-cli/src/client/reximo-client.ts"],"names":[],"mappings":";;AAWA,gDAaC;AAbD,SAAgB,kBAAkB,CAAC,MAAsB;IACvD,OAAO;QACL,YAAY;YACV,OAAO,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACpC,CAAC;QACD,cAAc;YACZ,OAAO;gBACL,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
package/src/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { runCli, type CliDependencies } from './lib/run-cli';
2
+ export { loadResolvedConfig, getDefaultConfigPath, type LoadResolvedConfigOptions, type ResolvedConfig } from './lib/config';
3
+ export { createReximoClient, type ReximoClient } from './client/reximo-client';
package/src/index.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createReximoClient = exports.getDefaultConfigPath = exports.loadResolvedConfig = exports.runCli = void 0;
4
+ var run_cli_1 = require("./lib/run-cli");
5
+ Object.defineProperty(exports, "runCli", { enumerable: true, get: function () { return run_cli_1.runCli; } });
6
+ var config_1 = require("./lib/config");
7
+ Object.defineProperty(exports, "loadResolvedConfig", { enumerable: true, get: function () { return config_1.loadResolvedConfig; } });
8
+ Object.defineProperty(exports, "getDefaultConfigPath", { enumerable: true, get: function () { return config_1.getDefaultConfigPath; } });
9
+ var reximo_client_1 = require("./client/reximo-client");
10
+ Object.defineProperty(exports, "createReximoClient", { enumerable: true, get: function () { return reximo_client_1.createReximoClient; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/reximo-cli/src/index.ts"],"names":[],"mappings":";;;AAAA,yCAA6D;AAApD,iGAAA,MAAM,OAAA;AACf,uCAKsB;AAJpB,4GAAA,kBAAkB,OAAA;AAClB,8GAAA,oBAAoB,OAAA;AAItB,wDAA+E;AAAtE,mHAAA,kBAAkB,OAAA"}
@@ -0,0 +1,26 @@
1
+ export type LoadResolvedConfigOptions = {
2
+ env?: NodeJS.ProcessEnv;
3
+ homeDirectory?: string;
4
+ };
5
+ export declare const enum ConfigSource {
6
+ Env = "env",
7
+ Config = "config",
8
+ Default = "default",
9
+ Unset = "unset"
10
+ }
11
+ export type ResolvedConfig = {
12
+ profile: string;
13
+ configPath: string;
14
+ configFileFound: boolean;
15
+ apiBaseUrl: string | null;
16
+ token: string | null;
17
+ sources: {
18
+ profile: ConfigSource;
19
+ apiBaseUrl: ConfigSource;
20
+ token: ConfigSource;
21
+ configPath: ConfigSource.Env | ConfigSource.Default;
22
+ };
23
+ };
24
+ export declare function getDefaultConfigPath(homeDirectory?: string): string;
25
+ export declare function loadResolvedConfig(options?: LoadResolvedConfigOptions): ResolvedConfig;
26
+ export declare function redactToken(token: string | null, includeSensitive: boolean): string | null;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDefaultConfigPath = getDefaultConfigPath;
4
+ exports.loadResolvedConfig = loadResolvedConfig;
5
+ exports.redactToken = redactToken;
6
+ const tslib_1 = require("tslib");
7
+ const node_fs_1 = require("node:fs");
8
+ const node_os_1 = require("node:os");
9
+ const node_path_1 = tslib_1.__importDefault(require("node:path"));
10
+ function getDefaultConfigPath(homeDirectory = (0, node_os_1.homedir)()) {
11
+ return node_path_1.default.join(homeDirectory, '.reximo', 'config.json');
12
+ }
13
+ function readConfigFile(configPath) {
14
+ if (!(0, node_fs_1.existsSync)(configPath)) {
15
+ return {};
16
+ }
17
+ const raw = (0, node_fs_1.readFileSync)(configPath, 'utf8');
18
+ const parsed = JSON.parse(raw);
19
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
20
+ throw new Error(`Invalid Reximo config at ${configPath}. Expected a JSON object.`);
21
+ }
22
+ return parsed;
23
+ }
24
+ function getProfileConfig(configFile, profile) {
25
+ return configFile.profiles?.[profile] ?? {};
26
+ }
27
+ function resolveValueSource(valueFromEnv, valueFromConfig) {
28
+ if (valueFromEnv) {
29
+ return "env" /* ConfigSource.Env */;
30
+ }
31
+ if (valueFromConfig) {
32
+ return "config" /* ConfigSource.Config */;
33
+ }
34
+ return "unset" /* ConfigSource.Unset */;
35
+ }
36
+ function loadResolvedConfig(options = {}) {
37
+ const env = options.env ?? process.env;
38
+ const configPathFromEnv = env['REXIMO_CONFIG'];
39
+ const configPath = configPathFromEnv ?? getDefaultConfigPath(options.homeDirectory);
40
+ const configFileFound = (0, node_fs_1.existsSync)(configPath);
41
+ const configFile = readConfigFile(configPath);
42
+ const profileFromEnv = env['REXIMO_PROFILE'];
43
+ const profile = profileFromEnv ?? configFile.profile ?? 'default';
44
+ const profileConfig = getProfileConfig(configFile, profile);
45
+ const apiBaseUrlFromEnv = env['REXIMO_API_BASE_URL'];
46
+ const tokenFromEnv = env['REXIMO_TOKEN'];
47
+ return {
48
+ profile,
49
+ configPath,
50
+ configFileFound,
51
+ apiBaseUrl: apiBaseUrlFromEnv ?? profileConfig.apiBaseUrl ?? null,
52
+ token: tokenFromEnv ?? profileConfig.token ?? null,
53
+ sources: {
54
+ profile: profileFromEnv
55
+ ? "env" /* ConfigSource.Env */
56
+ : configFile.profile
57
+ ? "config" /* ConfigSource.Config */
58
+ : "default" /* ConfigSource.Default */,
59
+ apiBaseUrl: resolveValueSource(apiBaseUrlFromEnv, profileConfig.apiBaseUrl),
60
+ token: resolveValueSource(tokenFromEnv, profileConfig.token),
61
+ configPath: configPathFromEnv ? "env" /* ConfigSource.Env */ : "default" /* ConfigSource.Default */
62
+ }
63
+ };
64
+ }
65
+ function redactToken(token, includeSensitive) {
66
+ if (!token) {
67
+ return null;
68
+ }
69
+ return includeSensitive ? token : '***redacted***';
70
+ }
71
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../packages/reximo-cli/src/lib/config.ts"],"names":[],"mappings":";;AAwCA,oDAEC;AAoCD,gDA6BC;AAED,kCAMC;;AAnHD,qCAAmD;AACnD,qCAAkC;AAClC,kEAA6B;AAsC7B,SAAgB,oBAAoB,CAAC,aAAa,GAAG,IAAA,iBAAO,GAAE;IAC5D,OAAO,mBAAI,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,cAAc,CAAC,UAAkB;IACxC,IAAI,CAAC,IAAA,oBAAU,EAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,GAAG,GAAG,IAAA,sBAAY,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAe,CAAC;IAE7C,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CAAC,4BAA4B,UAAU,2BAA2B,CAAC,CAAC;IACrF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,gBAAgB,CAAC,UAAsB,EAAE,OAAe;IAC/D,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,kBAAkB,CACzB,YAAgC,EAChC,eAAmC;IAEnC,IAAI,YAAY,EAAE,CAAC;QACjB,oCAAwB;IAC1B,CAAC;IAED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AC,8BAAkB,CAAC,qCAAqB;SACxE;KACF,CAAC;AACJ,CAAC;AAED,SAAgB,WAAW,CAAC,KAAoB,EAAE,gBAAyB;IACzE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC;AACrD,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const enum OutputMode {
2
+ Text = "text",
3
+ Json = "json"
4
+ }
5
+ export type Writable = Pick<typeof process.stdout, 'write'>;
6
+ export declare function writeLine(stream: Writable, message?: string): void;
7
+ export declare function writeJson(stream: Writable, value: unknown): void;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeLine = writeLine;
4
+ exports.writeJson = writeJson;
5
+ function writeLine(stream, message = '') {
6
+ stream.write(`${message}\n`);
7
+ }
8
+ function writeJson(stream, value) {
9
+ stream.write(`${JSON.stringify(value, null, 2)}\n`);
10
+ }
11
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../../../../packages/reximo-cli/src/lib/output.ts"],"names":[],"mappings":";;AAOA,8BAEC;AAED,8BAEC;AAND,SAAgB,SAAS,CAAC,MAAgB,EAAE,OAAO,GAAG,EAAE;IACtD,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED,SAAgB,SAAS,CAAC,MAAgB,EAAE,KAAc;IACxD,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type Writable } from './output';
2
+ export type CliDependencies = {
3
+ stdout: Writable;
4
+ stderr: Writable;
5
+ env?: NodeJS.ProcessEnv;
6
+ homeDirectory?: string;
7
+ };
8
+ export declare function runCli(args: string[], dependencies?: CliDependencies): Promise<number>;
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runCli = runCli;
4
+ const tslib_1 = require("tslib");
5
+ const node_process_1 = tslib_1.__importDefault(require("node:process"));
6
+ const commander_1 = require("commander");
7
+ const config_1 = require("./config");
8
+ const output_1 = require("./output");
9
+ const package_json_1 = tslib_1.__importDefault(require("../../package.json"));
10
+ const reximo_client_1 = require("../client/reximo-client");
11
+ function normalizeArgs(args) {
12
+ return args[0] === '--' ? args.slice(1) : args;
13
+ }
14
+ function toRuntimeDependencies(dependencies) {
15
+ return {
16
+ stdout: dependencies?.stdout ?? node_process_1.default.stdout,
17
+ stderr: dependencies?.stderr ?? node_process_1.default.stderr,
18
+ env: dependencies?.env ?? node_process_1.default.env,
19
+ homeDirectory: dependencies?.homeDirectory ?? node_process_1.default.env['HOME'] ?? node_process_1.default.cwd()
20
+ };
21
+ }
22
+ function getOutputMode(command) {
23
+ const opts = command.optsWithGlobals();
24
+ return opts.json ? "json" /* OutputMode.Json */ : "text" /* OutputMode.Text */;
25
+ }
26
+ function renderConfigSummary(config, includeSensitive) {
27
+ return {
28
+ profile: config.profile,
29
+ configPath: config.configPath,
30
+ configFileFound: config.configFileFound,
31
+ apiBaseUrl: config.apiBaseUrl,
32
+ token: (0, config_1.redactToken)(config.token, includeSensitive),
33
+ sources: config.sources
34
+ };
35
+ }
36
+ function writeResult(command, dependencies, textLines, jsonValue) {
37
+ if (getOutputMode(command) === "json" /* OutputMode.Json */) {
38
+ (0, output_1.writeJson)(dependencies.stdout, jsonValue);
39
+ return;
40
+ }
41
+ for (const line of textLines) {
42
+ (0, output_1.writeLine)(dependencies.stdout, line);
43
+ }
44
+ }
45
+ function createProgram(dependencies) {
46
+ const configOptions = {
47
+ env: dependencies.env,
48
+ homeDirectory: dependencies.homeDirectory
49
+ };
50
+ const program = new commander_1.Command();
51
+ program
52
+ .name('reximo')
53
+ .description('Command-line interface for Reximo.')
54
+ .version(package_json_1.default.version)
55
+ .showHelpAfterError()
56
+ .option('--json', 'Emit machine-readable JSON output')
57
+ .configureOutput({
58
+ writeOut: (message) => {
59
+ dependencies.stdout.write(message);
60
+ },
61
+ writeErr: (message) => {
62
+ dependencies.stderr.write(message);
63
+ }
64
+ });
65
+ program
66
+ .command('hello')
67
+ .description('Print a greeting to validate the CLI entrypoint.')
68
+ .option('--name <name>', 'Name to include in the greeting')
69
+ .action(function action(options) {
70
+ const greeting = options.name ? `Hello, ${options.name}.` : 'Hello from @reximo/cli.';
71
+ writeResult(this, dependencies, [greeting], {
72
+ command: 'hello',
73
+ greeting
74
+ });
75
+ });
76
+ program
77
+ .command('info')
78
+ .description('Show package and runtime information for diagnostics.')
79
+ .action(function action() {
80
+ const config = (0, config_1.loadResolvedConfig)(configOptions);
81
+ const client = (0, reximo_client_1.createReximoClient)(config);
82
+ writeResult(this, dependencies, [
83
+ `${package_json_1.default.name} ${package_json_1.default.version}`,
84
+ `Node: ${node_process_1.default.version}`,
85
+ `Platform: ${node_process_1.default.platform}/${node_process_1.default.arch}`,
86
+ `Profile: ${config.profile}`,
87
+ `API base URL: ${config.apiBaseUrl ?? '(not configured)'}`,
88
+ `Token configured: ${config.token ? 'yes' : 'no'}`
89
+ ], {
90
+ command: 'info',
91
+ package: {
92
+ name: package_json_1.default.name,
93
+ version: package_json_1.default.version
94
+ },
95
+ runtime: {
96
+ node: node_process_1.default.version,
97
+ platform: node_process_1.default.platform,
98
+ arch: node_process_1.default.arch
99
+ },
100
+ config: {
101
+ profile: config.profile,
102
+ apiBaseUrl: config.apiBaseUrl,
103
+ configuredForApi: client.isConfigured(),
104
+ hasToken: Boolean(config.token)
105
+ }
106
+ });
107
+ });
108
+ const configCommand = program
109
+ .command('config')
110
+ .description('Inspect resolved CLI configuration.');
111
+ configCommand
112
+ .command('show')
113
+ .description('Show the resolved CLI configuration.')
114
+ .option('--include-sensitive', 'Include sensitive values such as the configured token')
115
+ .action(function action(options) {
116
+ const config = (0, config_1.loadResolvedConfig)(configOptions);
117
+ writeResult(this, dependencies, [
118
+ `Profile: ${config.profile}`,
119
+ `Config path: ${config.configPath}`,
120
+ `Config file found: ${config.configFileFound ? 'yes' : 'no'}`,
121
+ `API base URL: ${config.apiBaseUrl ?? '(not configured)'}`,
122
+ `Token: ${(0, config_1.redactToken)(config.token, Boolean(options.includeSensitive)) ?? '(not configured)'}`
123
+ ], {
124
+ command: 'config.show',
125
+ config: renderConfigSummary(config, Boolean(options.includeSensitive))
126
+ });
127
+ });
128
+ return program;
129
+ }
130
+ async function runCli(args, dependencies) {
131
+ const runtimeDependencies = toRuntimeDependencies(dependencies);
132
+ const program = createProgram(runtimeDependencies);
133
+ const normalizedArgs = normalizeArgs(args);
134
+ const finalArgs = normalizedArgs.length === 0 ? ['--help'] : normalizedArgs;
135
+ program.exitOverride();
136
+ try {
137
+ await program.parseAsync(finalArgs, { from: 'user' });
138
+ return 0;
139
+ }
140
+ catch (error) {
141
+ if (error instanceof commander_1.CommanderError) {
142
+ return error.exitCode;
143
+ }
144
+ (0, output_1.writeLine)(runtimeDependencies.stderr, error instanceof Error ? error.message : String(error));
145
+ return 1;
146
+ }
147
+ }
148
+ //# sourceMappingURL=run-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-cli.js","sourceRoot":"","sources":["../../../../../packages/reximo-cli/src/lib/run-cli.ts"],"names":[],"mappings":";;AAgLA,wBAmBC;;AAnMD,wEAAmC;AAEnC,yCAAoD;AAEpD,qCAA2F;AAC3F,qCAA2E;AAC3E,8EAA6C;AAC7C,2DAA6D;AAe7D,SAAS,aAAa,CAAC,IAAc;IACnC,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACjD,CAAC;AAED,SAAS,qBAAqB,CAAC,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