commandmate 0.1.7 → 0.1.8
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/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/1.pack +0 -0
- package/.next/cache/webpack/client-production/2.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack.old +0 -0
- package/.next/cache/webpack/edge-server-production/0.pack +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/app-paths-manifest.json +3 -3
- package/.next/server/functions-config-manifest.json +1 -1
- package/.next/server/middleware-manifest.json +5 -5
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/trace +5 -5
- package/dist/cli/commands/start.d.ts +2 -0
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +10 -8
- package/dist/cli/commands/status.d.ts +2 -0
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +11 -4
- package/dist/cli/commands/stop.d.ts +2 -0
- package/dist/cli/commands/stop.d.ts.map +1 -1
- package/dist/cli/commands/stop.js +7 -4
- package/dist/cli/types/index.d.ts +8 -0
- package/dist/cli/types/index.d.ts.map +1 -1
- package/dist/cli/types/index.js +14 -0
- package/dist/cli/utils/daemon.d.ts +3 -0
- package/dist/cli/utils/daemon.d.ts.map +1 -1
- package/dist/cli/utils/daemon.js +34 -2
- package/dist/cli/utils/env-setup.d.ts +19 -1
- package/dist/cli/utils/env-setup.d.ts.map +1 -1
- package/dist/cli/utils/env-setup.js +45 -3
- package/package.json +2 -1
- /package/.next/static/{3jNZMmFnQhc5G7met-OU4 → KtDmF-FzoCLvoKXEcXyU-}/_buildManifest.js +0 -0
- /package/.next/static/{3jNZMmFnQhc5G7met-OU4 → KtDmF-FzoCLvoKXEcXyU-}/_ssgManifest.js +0 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Start Command
|
|
3
3
|
* Issue #96: npm install CLI support
|
|
4
|
+
* Issue #125: Use getEnvPath and getPidFilePath for correct path resolution
|
|
4
5
|
* Start CommandMate server
|
|
5
6
|
*/
|
|
6
7
|
import { StartOptions } from '../types';
|
|
7
8
|
/**
|
|
8
9
|
* Execute start command
|
|
10
|
+
* Issue #125: Use getEnvPath and getPidFilePath for correct path resolution
|
|
9
11
|
*/
|
|
10
12
|
export declare function startCommand(options: StartOptions): Promise<void>;
|
|
11
13
|
//# sourceMappingURL=start.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/start.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/start.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,YAAY,EAA6B,MAAM,UAAU,CAAC;AASnE;;;GAGG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAyHvE"}
|
|
@@ -2,34 +2,36 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Start Command
|
|
4
4
|
* Issue #96: npm install CLI support
|
|
5
|
+
* Issue #125: Use getEnvPath and getPidFilePath for correct path resolution
|
|
5
6
|
* Start CommandMate server
|
|
6
7
|
*/
|
|
7
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
9
|
exports.startCommand = startCommand;
|
|
9
10
|
const fs_1 = require("fs");
|
|
10
11
|
const child_process_1 = require("child_process");
|
|
11
|
-
const path_1 = require("path");
|
|
12
12
|
const types_1 = require("../types");
|
|
13
13
|
const logger_1 = require("../utils/logger");
|
|
14
14
|
const daemon_1 = require("../utils/daemon");
|
|
15
15
|
const security_logger_1 = require("../utils/security-logger");
|
|
16
16
|
const paths_1 = require("../utils/paths");
|
|
17
|
+
const env_setup_1 = require("../utils/env-setup");
|
|
17
18
|
const logger = new logger_1.CLILogger();
|
|
18
|
-
const PID_FILE = (0, path_1.join)(process.cwd(), '.commandmate.pid');
|
|
19
19
|
/**
|
|
20
20
|
* Execute start command
|
|
21
|
+
* Issue #125: Use getEnvPath and getPidFilePath for correct path resolution
|
|
21
22
|
*/
|
|
22
23
|
async function startCommand(options) {
|
|
23
24
|
try {
|
|
24
|
-
// Check for .env file
|
|
25
|
-
const envPath = (0,
|
|
25
|
+
// Issue #125: Check for .env file at correct location
|
|
26
|
+
const envPath = (0, env_setup_1.getEnvPath)();
|
|
27
|
+
const pidFilePath = (0, env_setup_1.getPidFilePath)();
|
|
26
28
|
if (!(0, fs_1.existsSync)(envPath)) {
|
|
27
|
-
logger.error(
|
|
29
|
+
logger.error(`.env file not found at ${envPath}`);
|
|
28
30
|
logger.info('Run "commandmate init" to create a configuration file');
|
|
29
31
|
process.exit(types_1.ExitCode.CONFIG_ERROR);
|
|
30
32
|
return;
|
|
31
33
|
}
|
|
32
|
-
const daemonManager = new daemon_1.DaemonManager(
|
|
34
|
+
const daemonManager = new daemon_1.DaemonManager(pidFilePath);
|
|
33
35
|
// Daemon mode
|
|
34
36
|
if (options.daemon) {
|
|
35
37
|
// Check if already running
|
|
@@ -59,7 +61,7 @@ async function startCommand(options) {
|
|
|
59
61
|
process.exit(types_1.ExitCode.SUCCESS);
|
|
60
62
|
}
|
|
61
63
|
catch (error) {
|
|
62
|
-
const message =
|
|
64
|
+
const message = (0, types_1.getErrorMessage)(error);
|
|
63
65
|
logger.error(`Failed to start daemon: ${message}`);
|
|
64
66
|
(0, security_logger_1.logSecurityEvent)({
|
|
65
67
|
timestamp: new Date().toISOString(),
|
|
@@ -107,7 +109,7 @@ async function startCommand(options) {
|
|
|
107
109
|
});
|
|
108
110
|
}
|
|
109
111
|
catch (error) {
|
|
110
|
-
const message =
|
|
112
|
+
const message = (0, types_1.getErrorMessage)(error);
|
|
111
113
|
logger.error(`Start failed: ${message}`);
|
|
112
114
|
(0, security_logger_1.logSecurityEvent)({
|
|
113
115
|
timestamp: new Date().toISOString(),
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Status Command
|
|
3
3
|
* Issue #96: npm install CLI support
|
|
4
|
+
* Issue #125: Use getPidFilePath and load .env for correct settings display
|
|
4
5
|
* Display CommandMate server status
|
|
5
6
|
*/
|
|
6
7
|
/**
|
|
7
8
|
* Execute status command
|
|
9
|
+
* Issue #125: Use getPidFilePath and load .env for correct settings display
|
|
8
10
|
*/
|
|
9
11
|
export declare function statusCommand(): Promise<void>;
|
|
10
12
|
//# sourceMappingURL=status.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/status.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/status.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAoDnD"}
|
|
@@ -2,22 +2,29 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Status Command
|
|
4
4
|
* Issue #96: npm install CLI support
|
|
5
|
+
* Issue #125: Use getPidFilePath and load .env for correct settings display
|
|
5
6
|
* Display CommandMate server status
|
|
6
7
|
*/
|
|
7
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
9
|
exports.statusCommand = statusCommand;
|
|
9
|
-
const
|
|
10
|
+
const dotenv_1 = require("dotenv");
|
|
10
11
|
const types_1 = require("../types");
|
|
11
12
|
const logger_1 = require("../utils/logger");
|
|
12
13
|
const daemon_1 = require("../utils/daemon");
|
|
14
|
+
const env_setup_1 = require("../utils/env-setup");
|
|
13
15
|
const logger = new logger_1.CLILogger();
|
|
14
|
-
const PID_FILE = (0, path_1.join)(process.cwd(), '.commandmate.pid');
|
|
15
16
|
/**
|
|
16
17
|
* Execute status command
|
|
18
|
+
* Issue #125: Use getPidFilePath and load .env for correct settings display
|
|
17
19
|
*/
|
|
18
20
|
async function statusCommand() {
|
|
19
21
|
try {
|
|
20
|
-
|
|
22
|
+
// Issue #125: Get PID file path and load .env for correct settings
|
|
23
|
+
const pidFilePath = (0, env_setup_1.getPidFilePath)();
|
|
24
|
+
const envPath = (0, env_setup_1.getEnvPath)();
|
|
25
|
+
// Load .env so getStatus() can access correct CM_PORT and CM_BIND values
|
|
26
|
+
(0, dotenv_1.config)({ path: envPath });
|
|
27
|
+
const daemonManager = new daemon_1.DaemonManager(pidFilePath);
|
|
21
28
|
const status = await daemonManager.getStatus();
|
|
22
29
|
console.log('');
|
|
23
30
|
console.log('CommandMate Status');
|
|
@@ -48,7 +55,7 @@ async function statusCommand() {
|
|
|
48
55
|
process.exit(types_1.ExitCode.SUCCESS);
|
|
49
56
|
}
|
|
50
57
|
catch (error) {
|
|
51
|
-
const message =
|
|
58
|
+
const message = (0, types_1.getErrorMessage)(error);
|
|
52
59
|
logger.error(`Status check failed: ${message}`);
|
|
53
60
|
process.exit(types_1.ExitCode.UNEXPECTED_ERROR);
|
|
54
61
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Stop Command
|
|
3
3
|
* Issue #96: npm install CLI support
|
|
4
|
+
* Issue #125: Use getPidFilePath for correct path resolution
|
|
4
5
|
* Stop CommandMate server
|
|
5
6
|
*/
|
|
6
7
|
import { StopOptions } from '../types';
|
|
7
8
|
/**
|
|
8
9
|
* Execute stop command
|
|
10
|
+
* Issue #125: Use getPidFilePath for correct path resolution
|
|
9
11
|
*/
|
|
10
12
|
export declare function stopCommand(options: StopOptions): Promise<void>;
|
|
11
13
|
//# sourceMappingURL=stop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stop.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/stop.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"stop.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/stop.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAA6B,MAAM,UAAU,CAAC;AAQlE;;;GAGG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAyErE"}
|
|
@@ -2,23 +2,26 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Stop Command
|
|
4
4
|
* Issue #96: npm install CLI support
|
|
5
|
+
* Issue #125: Use getPidFilePath for correct path resolution
|
|
5
6
|
* Stop CommandMate server
|
|
6
7
|
*/
|
|
7
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
9
|
exports.stopCommand = stopCommand;
|
|
9
|
-
const path_1 = require("path");
|
|
10
10
|
const types_1 = require("../types");
|
|
11
11
|
const logger_1 = require("../utils/logger");
|
|
12
12
|
const daemon_1 = require("../utils/daemon");
|
|
13
13
|
const security_logger_1 = require("../utils/security-logger");
|
|
14
|
+
const env_setup_1 = require("../utils/env-setup");
|
|
14
15
|
const logger = new logger_1.CLILogger();
|
|
15
|
-
const PID_FILE = (0, path_1.join)(process.cwd(), '.commandmate.pid');
|
|
16
16
|
/**
|
|
17
17
|
* Execute stop command
|
|
18
|
+
* Issue #125: Use getPidFilePath for correct path resolution
|
|
18
19
|
*/
|
|
19
20
|
async function stopCommand(options) {
|
|
20
21
|
try {
|
|
21
|
-
|
|
22
|
+
// Issue #125: Get PID file path from correct location
|
|
23
|
+
const pidFilePath = (0, env_setup_1.getPidFilePath)();
|
|
24
|
+
const daemonManager = new daemon_1.DaemonManager(pidFilePath);
|
|
22
25
|
// Check if running
|
|
23
26
|
if (!(await daemonManager.isRunning())) {
|
|
24
27
|
const status = await daemonManager.getStatus();
|
|
@@ -69,7 +72,7 @@ async function stopCommand(options) {
|
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
catch (error) {
|
|
72
|
-
const message =
|
|
75
|
+
const message = (0, types_1.getErrorMessage)(error);
|
|
73
76
|
logger.error(`Stop failed: ${message}`);
|
|
74
77
|
(0, security_logger_1.logSecurityEvent)({
|
|
75
78
|
timestamp: new Date().toISOString(),
|
|
@@ -139,4 +139,12 @@ export interface ConfirmOptions {
|
|
|
139
139
|
/** Default value if user presses Enter (true = Y, false = N) */
|
|
140
140
|
default?: boolean;
|
|
141
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Extract error message from unknown error
|
|
144
|
+
* Issue #125: DRY - centralized error message extraction
|
|
145
|
+
*
|
|
146
|
+
* @param error - Unknown error object
|
|
147
|
+
* @returns Error message string
|
|
148
|
+
*/
|
|
149
|
+
export declare function getErrorMessage(error: unknown): string;
|
|
142
150
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,oBAAY,QAAQ;IAClB,OAAO,IAAI;IACX,gBAAgB,IAAI;IACpB,YAAY,IAAI;IAChB,YAAY,IAAI;IAChB,WAAW,IAAI;IACf,gBAAgB,KAAK;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uCAAuC;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C;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,oCAAoC;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;CAC7C;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKtD"}
|
package/dist/cli/types/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.ExitCode = void 0;
|
|
8
|
+
exports.getErrorMessage = getErrorMessage;
|
|
8
9
|
/**
|
|
9
10
|
* Exit codes for CLI commands
|
|
10
11
|
* NTH-4: DRY - centralized exit code definitions
|
|
@@ -18,3 +19,16 @@ var ExitCode;
|
|
|
18
19
|
ExitCode[ExitCode["STOP_FAILED"] = 4] = "STOP_FAILED";
|
|
19
20
|
ExitCode[ExitCode["UNEXPECTED_ERROR"] = 99] = "UNEXPECTED_ERROR";
|
|
20
21
|
})(ExitCode || (exports.ExitCode = ExitCode = {}));
|
|
22
|
+
/**
|
|
23
|
+
* Extract error message from unknown error
|
|
24
|
+
* Issue #125: DRY - centralized error message extraction
|
|
25
|
+
*
|
|
26
|
+
* @param error - Unknown error object
|
|
27
|
+
* @returns Error message string
|
|
28
|
+
*/
|
|
29
|
+
function getErrorMessage(error) {
|
|
30
|
+
if (error instanceof Error) {
|
|
31
|
+
return error.message;
|
|
32
|
+
}
|
|
33
|
+
return String(error);
|
|
34
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Daemon Process Manager
|
|
3
3
|
* Issue #96: npm install CLI support
|
|
4
|
+
* Issue #125: Added .env loading and security warnings
|
|
4
5
|
* SF-1: SRP - Process management only (PID handling delegated to PidManager)
|
|
5
6
|
*/
|
|
6
7
|
import { DaemonStatus, StartOptions } from '../types';
|
|
@@ -9,9 +10,11 @@ import { DaemonStatus, StartOptions } from '../types';
|
|
|
9
10
|
*/
|
|
10
11
|
export declare class DaemonManager {
|
|
11
12
|
private pidManager;
|
|
13
|
+
private logger;
|
|
12
14
|
constructor(pidFilePath: string);
|
|
13
15
|
/**
|
|
14
16
|
* Start daemon process
|
|
17
|
+
* Issue #125: Load .env file and add security warnings
|
|
15
18
|
* @returns Process ID of the started daemon
|
|
16
19
|
* @throws Error if already running
|
|
17
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/daemon.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"daemon.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/daemon.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAMtD;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,MAAM,CAAY;gBAEd,WAAW,EAAE,MAAM;IAK/B;;;;;OAKG;IACG,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IA8EnD;;;;OAIG;IACG,IAAI,CAAC,KAAK,GAAE,OAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IA8BpD;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IA6B/C;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAInC;;OAEG;YACW,WAAW;CAiB1B"}
|
package/dist/cli/utils/daemon.js
CHANGED
|
@@ -2,23 +2,30 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Daemon Process Manager
|
|
4
4
|
* Issue #96: npm install CLI support
|
|
5
|
+
* Issue #125: Added .env loading and security warnings
|
|
5
6
|
* SF-1: SRP - Process management only (PID handling delegated to PidManager)
|
|
6
7
|
*/
|
|
7
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
9
|
exports.DaemonManager = void 0;
|
|
9
10
|
const child_process_1 = require("child_process");
|
|
11
|
+
const dotenv_1 = require("dotenv");
|
|
10
12
|
const pid_manager_1 = require("./pid-manager");
|
|
11
13
|
const paths_1 = require("./paths");
|
|
14
|
+
const env_setup_1 = require("./env-setup");
|
|
15
|
+
const logger_1 = require("./logger");
|
|
12
16
|
/**
|
|
13
17
|
* Daemon manager for background server process
|
|
14
18
|
*/
|
|
15
19
|
class DaemonManager {
|
|
16
20
|
pidManager;
|
|
21
|
+
logger;
|
|
17
22
|
constructor(pidFilePath) {
|
|
18
23
|
this.pidManager = new pid_manager_1.PidManager(pidFilePath);
|
|
24
|
+
this.logger = new logger_1.CLILogger();
|
|
19
25
|
}
|
|
20
26
|
/**
|
|
21
27
|
* Start daemon process
|
|
28
|
+
* Issue #125: Load .env file and add security warnings
|
|
22
29
|
* @returns Process ID of the started daemon
|
|
23
30
|
* @throws Error if already running
|
|
24
31
|
*/
|
|
@@ -32,11 +39,36 @@ class DaemonManager {
|
|
|
32
39
|
const npmScript = options.dev ? 'dev' : 'start';
|
|
33
40
|
// Use package installation directory, not current working directory
|
|
34
41
|
const packageRoot = (0, paths_1.getPackageRoot)();
|
|
35
|
-
//
|
|
36
|
-
const
|
|
42
|
+
// Issue #125: Load .env file from correct location
|
|
43
|
+
const envPath = (0, env_setup_1.getEnvPath)();
|
|
44
|
+
const envResult = (0, dotenv_1.config)({ path: envPath });
|
|
45
|
+
// Handle .env loading errors with fallback (Stage 2 review: MF-2)
|
|
46
|
+
if (envResult.error) {
|
|
47
|
+
this.logger.warn(`Failed to load .env file at ${envPath}: ${envResult.error.message}`);
|
|
48
|
+
this.logger.info('Continuing with existing environment variables');
|
|
49
|
+
}
|
|
50
|
+
// Build environment by merging process.env with .env values
|
|
51
|
+
const env = {
|
|
52
|
+
...process.env,
|
|
53
|
+
...(envResult.parsed || {}),
|
|
54
|
+
};
|
|
55
|
+
// Command line options override .env values
|
|
37
56
|
if (options.port) {
|
|
38
57
|
env.CM_PORT = String(options.port);
|
|
39
58
|
}
|
|
59
|
+
// Issue #125: Security warnings for external access (Stage 4 review: MF-2)
|
|
60
|
+
const bindAddress = env.CM_BIND || '127.0.0.1';
|
|
61
|
+
const authToken = env.CM_AUTH_TOKEN;
|
|
62
|
+
const port = env.CM_PORT || '3000';
|
|
63
|
+
if (bindAddress === '0.0.0.0') {
|
|
64
|
+
this.logger.warn('WARNING: Server is accessible from external networks (CM_BIND=0.0.0.0)');
|
|
65
|
+
if (!authToken) {
|
|
66
|
+
this.logger.warn('SECURITY WARNING: No authentication token configured. External access is not recommended without CM_AUTH_TOKEN.');
|
|
67
|
+
this.logger.info('Run "commandmate init" to configure a secure authentication token.');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Log startup with accurate settings (Stage 4 review: MF-2)
|
|
71
|
+
this.logger.info(`Starting server at http://${bindAddress}:${port}`);
|
|
40
72
|
// Spawn detached process
|
|
41
73
|
const child = (0, child_process_1.spawn)('npm', ['run', npmScript], {
|
|
42
74
|
cwd: packageRoot,
|
|
@@ -33,13 +33,31 @@ export declare function isGlobalInstall(): boolean;
|
|
|
33
33
|
* @returns Path to .env file
|
|
34
34
|
*/
|
|
35
35
|
export declare function getEnvPath(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Resolve path securely by resolving symlinks and verifying within allowed directory
|
|
38
|
+
* Issue #125: Path traversal protection (OWASP A01:2021 - Broken Access Control)
|
|
39
|
+
*
|
|
40
|
+
* @param targetPath - The path to resolve and verify
|
|
41
|
+
* @param allowedBaseDir - The base directory that targetPath must be within
|
|
42
|
+
* @returns The resolved real path
|
|
43
|
+
* @throws Error if path resolves outside allowed directory
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveSecurePath(targetPath: string, allowedBaseDir: string): string;
|
|
36
46
|
/**
|
|
37
47
|
* Get the config directory path
|
|
38
48
|
* Issue #119: Returns ~/.commandmate for global, cwd for local
|
|
49
|
+
* Issue #125: Added symlink resolution for security (path traversal protection)
|
|
39
50
|
*
|
|
40
|
-
* @returns Path to config directory
|
|
51
|
+
* @returns Path to config directory (absolute, with symlinks resolved)
|
|
41
52
|
*/
|
|
42
53
|
export declare function getConfigDir(): string;
|
|
54
|
+
/**
|
|
55
|
+
* Get the PID file path based on install type
|
|
56
|
+
* Issue #125: DRY principle - centralized PID file path resolution
|
|
57
|
+
*
|
|
58
|
+
* @returns Path to PID file (uses getConfigDir for consistency)
|
|
59
|
+
*/
|
|
60
|
+
export declare function getPidFilePath(): string;
|
|
43
61
|
/**
|
|
44
62
|
* Sanitize input by removing control characters
|
|
45
63
|
* SF-SEC-3: Input sanitization
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-setup.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/env-setup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"env-setup.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/env-setup.ts"],"names":[],"m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 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
exports.EnvSetup = exports.DEFAULT_ROOT_DIR = exports.ENV_DEFAULTS = void 0;
|
|
9
9
|
exports.isGlobalInstall = isGlobalInstall;
|
|
10
10
|
exports.getEnvPath = getEnvPath;
|
|
11
|
+
exports.resolveSecurePath = resolveSecurePath;
|
|
11
12
|
exports.getConfigDir = getConfigDir;
|
|
13
|
+
exports.getPidFilePath = getPidFilePath;
|
|
12
14
|
exports.sanitizeInput = sanitizeInput;
|
|
13
15
|
exports.sanitizePath = sanitizePath;
|
|
14
16
|
exports.validatePort = validatePort;
|
|
@@ -67,17 +69,57 @@ function getEnvPath() {
|
|
|
67
69
|
// Local install - use current working directory
|
|
68
70
|
return (0, path_1.join)(process.cwd(), '.env');
|
|
69
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Resolve path securely by resolving symlinks and verifying within allowed directory
|
|
74
|
+
* Issue #125: Path traversal protection (OWASP A01:2021 - Broken Access Control)
|
|
75
|
+
*
|
|
76
|
+
* @param targetPath - The path to resolve and verify
|
|
77
|
+
* @param allowedBaseDir - The base directory that targetPath must be within
|
|
78
|
+
* @returns The resolved real path
|
|
79
|
+
* @throws Error if path resolves outside allowed directory
|
|
80
|
+
*/
|
|
81
|
+
function resolveSecurePath(targetPath, allowedBaseDir) {
|
|
82
|
+
const realPath = (0, fs_1.realpathSync)(targetPath);
|
|
83
|
+
const realBaseDir = (0, fs_1.realpathSync)(allowedBaseDir);
|
|
84
|
+
if (!realPath.startsWith(realBaseDir)) {
|
|
85
|
+
throw new Error(`Path traversal detected: ${targetPath} resolves outside of ${allowedBaseDir}`);
|
|
86
|
+
}
|
|
87
|
+
return realPath;
|
|
88
|
+
}
|
|
70
89
|
/**
|
|
71
90
|
* Get the config directory path
|
|
72
91
|
* Issue #119: Returns ~/.commandmate for global, cwd for local
|
|
92
|
+
* Issue #125: Added symlink resolution for security (path traversal protection)
|
|
73
93
|
*
|
|
74
|
-
* @returns Path to config directory
|
|
94
|
+
* @returns Path to config directory (absolute, with symlinks resolved)
|
|
75
95
|
*/
|
|
76
96
|
function getConfigDir() {
|
|
77
97
|
if (isGlobalInstall()) {
|
|
78
|
-
|
|
98
|
+
const configDir = (0, path_1.join)((0, os_1.homedir)(), '.commandmate');
|
|
99
|
+
// Verify config directory is within home directory (security check)
|
|
100
|
+
// Only validate if the directory exists (it may not exist yet during init)
|
|
101
|
+
if ((0, fs_1.existsSync)(configDir)) {
|
|
102
|
+
const realPath = (0, fs_1.realpathSync)(configDir);
|
|
103
|
+
const realHome = (0, fs_1.realpathSync)((0, os_1.homedir)());
|
|
104
|
+
if (!realPath.startsWith(realHome)) {
|
|
105
|
+
throw new Error(`Security error: Config directory ${configDir} is outside home directory`);
|
|
106
|
+
}
|
|
107
|
+
return realPath;
|
|
108
|
+
}
|
|
109
|
+
return configDir;
|
|
79
110
|
}
|
|
80
|
-
|
|
111
|
+
// Local install - resolve symlinks in cwd
|
|
112
|
+
const cwd = process.cwd();
|
|
113
|
+
return (0, fs_1.realpathSync)(cwd);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get the PID file path based on install type
|
|
117
|
+
* Issue #125: DRY principle - centralized PID file path resolution
|
|
118
|
+
*
|
|
119
|
+
* @returns Path to PID file (uses getConfigDir for consistency)
|
|
120
|
+
*/
|
|
121
|
+
function getPidFilePath() {
|
|
122
|
+
return (0, path_1.join)(getConfigDir(), '.commandmate.pid');
|
|
81
123
|
}
|
|
82
124
|
/**
|
|
83
125
|
* Sanitize input by removing control characters
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commandmate",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Git worktree management with Claude CLI and tmux sessions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"better-sqlite3": "^12.4.1",
|
|
42
42
|
"commander": "^14.0.2",
|
|
43
43
|
"date-fns": "^4.1.0",
|
|
44
|
+
"dotenv": "^17.2.3",
|
|
44
45
|
"gray-matter": "^4.0.3",
|
|
45
46
|
"http-proxy": "^1.18.1",
|
|
46
47
|
"isomorphic-dompurify": "^2.35.0",
|
|
File without changes
|
|
File without changes
|