@enactprotocol/shared 1.2.13 → 2.0.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 +44 -0
- package/package.json +16 -58
- package/src/config.ts +476 -0
- package/src/constants.ts +36 -0
- package/src/execution/command.ts +314 -0
- package/src/execution/index.ts +73 -0
- package/src/execution/runtime.ts +308 -0
- package/src/execution/types.ts +379 -0
- package/src/execution/validation.ts +508 -0
- package/src/index.ts +237 -30
- package/src/manifest/index.ts +36 -0
- package/src/manifest/loader.ts +187 -0
- package/src/manifest/parser.ts +173 -0
- package/src/manifest/validator.ts +309 -0
- package/src/paths.ts +108 -0
- package/src/registry.ts +219 -0
- package/src/resolver.ts +345 -0
- package/src/types/index.ts +30 -0
- package/src/types/manifest.ts +255 -0
- package/src/types.ts +5 -188
- package/src/utils/fs.ts +281 -0
- package/src/utils/logger.ts +270 -59
- package/src/utils/version.ts +304 -36
- package/tests/config.test.ts +515 -0
- package/tests/execution/command.test.ts +317 -0
- package/tests/execution/validation.test.ts +384 -0
- package/tests/fixtures/invalid-tool.yaml +4 -0
- package/tests/fixtures/valid-tool.md +62 -0
- package/tests/fixtures/valid-tool.yaml +40 -0
- package/tests/index.test.ts +8 -0
- package/tests/manifest/loader.test.ts +291 -0
- package/tests/manifest/parser.test.ts +345 -0
- package/tests/manifest/validator.test.ts +394 -0
- package/tests/manifest-types.test.ts +358 -0
- package/tests/paths.test.ts +153 -0
- package/tests/registry.test.ts +231 -0
- package/tests/resolver.test.ts +272 -0
- package/tests/utils/fs.test.ts +388 -0
- package/tests/utils/logger.test.ts +480 -0
- package/tests/utils/version.test.ts +390 -0
- package/tsconfig.json +12 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/dist/LocalToolResolver.d.ts +0 -84
- package/dist/LocalToolResolver.js +0 -353
- package/dist/api/enact-api.d.ts +0 -130
- package/dist/api/enact-api.js +0 -428
- package/dist/api/index.d.ts +0 -2
- package/dist/api/index.js +0 -2
- package/dist/api/types.d.ts +0 -103
- package/dist/api/types.js +0 -1
- package/dist/constants.d.ts +0 -7
- package/dist/constants.js +0 -10
- package/dist/core/DaggerExecutionProvider.d.ts +0 -169
- package/dist/core/DaggerExecutionProvider.js +0 -1029
- package/dist/core/DirectExecutionProvider.d.ts +0 -23
- package/dist/core/DirectExecutionProvider.js +0 -406
- package/dist/core/EnactCore.d.ts +0 -162
- package/dist/core/EnactCore.js +0 -597
- package/dist/core/NativeExecutionProvider.d.ts +0 -9
- package/dist/core/NativeExecutionProvider.js +0 -16
- package/dist/core/index.d.ts +0 -3
- package/dist/core/index.js +0 -3
- package/dist/exec/index.d.ts +0 -3
- package/dist/exec/index.js +0 -3
- package/dist/exec/logger.d.ts +0 -11
- package/dist/exec/logger.js +0 -57
- package/dist/exec/validate.d.ts +0 -5
- package/dist/exec/validate.js +0 -167
- package/dist/index.d.ts +0 -21
- package/dist/index.js +0 -25
- package/dist/lib/enact-direct.d.ts +0 -150
- package/dist/lib/enact-direct.js +0 -159
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.js +0 -1
- package/dist/security/index.d.ts +0 -3
- package/dist/security/index.js +0 -3
- package/dist/security/security.d.ts +0 -23
- package/dist/security/security.js +0 -137
- package/dist/security/sign.d.ts +0 -103
- package/dist/security/sign.js +0 -666
- package/dist/security/verification-enforcer.d.ts +0 -53
- package/dist/security/verification-enforcer.js +0 -204
- package/dist/services/McpCoreService.d.ts +0 -98
- package/dist/services/McpCoreService.js +0 -124
- package/dist/services/index.d.ts +0 -1
- package/dist/services/index.js +0 -1
- package/dist/types.d.ts +0 -132
- package/dist/types.js +0 -3
- package/dist/utils/config.d.ts +0 -111
- package/dist/utils/config.js +0 -342
- package/dist/utils/env-loader.d.ts +0 -54
- package/dist/utils/env-loader.js +0 -270
- package/dist/utils/help.d.ts +0 -36
- package/dist/utils/help.js +0 -248
- package/dist/utils/index.d.ts +0 -7
- package/dist/utils/index.js +0 -7
- package/dist/utils/logger.d.ts +0 -35
- package/dist/utils/logger.js +0 -75
- package/dist/utils/silent-monitor.d.ts +0 -67
- package/dist/utils/silent-monitor.js +0 -242
- package/dist/utils/timeout.d.ts +0 -5
- package/dist/utils/timeout.js +0 -23
- package/dist/utils/version.d.ts +0 -4
- package/dist/utils/version.js +0 -35
- package/dist/web/env-manager-server.d.ts +0 -29
- package/dist/web/env-manager-server.js +0 -367
- package/dist/web/index.d.ts +0 -1
- package/dist/web/index.js +0 -1
- package/src/LocalToolResolver.ts +0 -424
- package/src/api/enact-api.ts +0 -604
- package/src/api/index.ts +0 -2
- package/src/api/types.ts +0 -114
- package/src/core/DaggerExecutionProvider.ts +0 -1357
- package/src/core/DirectExecutionProvider.ts +0 -484
- package/src/core/EnactCore.ts +0 -847
- package/src/core/index.ts +0 -3
- package/src/exec/index.ts +0 -3
- package/src/exec/logger.ts +0 -63
- package/src/exec/validate.ts +0 -238
- package/src/lib/enact-direct.ts +0 -254
- package/src/lib/index.ts +0 -1
- package/src/services/McpCoreService.ts +0 -201
- package/src/services/index.ts +0 -1
- package/src/utils/config.ts +0 -438
- package/src/utils/env-loader.ts +0 -370
- package/src/utils/help.ts +0 -257
- package/src/utils/index.ts +0 -7
- package/src/utils/silent-monitor.ts +0 -328
- package/src/utils/timeout.ts +0 -26
- package/src/web/env-manager-server.ts +0 -465
- package/src/web/index.ts +0 -1
- package/src/web/static/app.js +0 -663
- package/src/web/static/index.html +0 -117
- package/src/web/static/style.css +0 -291
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime silent operation monitor for MCP server
|
|
3
|
-
* This utility can be used to ensure the MCP server remains silent during operation
|
|
4
|
-
*/
|
|
5
|
-
interface SilentOperationMonitor {
|
|
6
|
-
startMonitoring(): void;
|
|
7
|
-
stopMonitoring(): SilentOperationReport;
|
|
8
|
-
isCurrentlyMonitoring(): boolean;
|
|
9
|
-
getViolations(): string[];
|
|
10
|
-
}
|
|
11
|
-
interface SilentOperationReport {
|
|
12
|
-
violations: string[];
|
|
13
|
-
consoleOutputDetected: string[];
|
|
14
|
-
processExitAttempts: number;
|
|
15
|
-
readlineUsageDetected: boolean;
|
|
16
|
-
duration: number;
|
|
17
|
-
timestamp: string;
|
|
18
|
-
}
|
|
19
|
-
declare class McpSilentOperationMonitor implements SilentOperationMonitor {
|
|
20
|
-
private isMonitoring;
|
|
21
|
-
private violations;
|
|
22
|
-
private consoleOutput;
|
|
23
|
-
private processExitAttempts;
|
|
24
|
-
private readlineUsageDetected;
|
|
25
|
-
private startTime;
|
|
26
|
-
private originalConsoleLog;
|
|
27
|
-
private originalConsoleError;
|
|
28
|
-
private originalConsoleWarn;
|
|
29
|
-
private originalConsoleInfo;
|
|
30
|
-
private originalProcessExit;
|
|
31
|
-
private originalStdoutWrite;
|
|
32
|
-
private originalStderrWrite;
|
|
33
|
-
getOriginalConsoleError(): typeof console.error;
|
|
34
|
-
constructor();
|
|
35
|
-
startMonitoring(): void;
|
|
36
|
-
stopMonitoring(): SilentOperationReport;
|
|
37
|
-
isCurrentlyMonitoring(): boolean;
|
|
38
|
-
getViolations(): string[];
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Global monitor instance
|
|
42
|
-
*/
|
|
43
|
-
declare const globalMonitor: McpSilentOperationMonitor;
|
|
44
|
-
/**
|
|
45
|
-
* Decorator to ensure a function operates silently
|
|
46
|
-
*/
|
|
47
|
-
export declare function ensureSilent<T extends (...args: any[]) => any>(fn: T): T;
|
|
48
|
-
/**
|
|
49
|
-
* Higher-order function to wrap MCP tool handlers for silent operation
|
|
50
|
-
*/
|
|
51
|
-
export declare function silentMcpTool<T extends (...args: any[]) => Promise<any>>(handler: T): T;
|
|
52
|
-
/**
|
|
53
|
-
* Utility to check if environment is properly configured for silent operation
|
|
54
|
-
*/
|
|
55
|
-
export declare function validateSilentEnvironment(): {
|
|
56
|
-
valid: boolean;
|
|
57
|
-
issues: string[];
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Logger specifically for MCP silent operation monitoring
|
|
61
|
-
*/
|
|
62
|
-
export declare const silentLogger: {
|
|
63
|
-
logViolation: (violation: string) => void;
|
|
64
|
-
logReport: (report: SilentOperationReport) => void;
|
|
65
|
-
};
|
|
66
|
-
export { globalMonitor, McpSilentOperationMonitor };
|
|
67
|
-
export type { SilentOperationMonitor, SilentOperationReport };
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime silent operation monitor for MCP server
|
|
3
|
-
* This utility can be used to ensure the MCP server remains silent during operation
|
|
4
|
-
*/
|
|
5
|
-
class McpSilentOperationMonitor {
|
|
6
|
-
// Public getters for original methods
|
|
7
|
-
getOriginalConsoleError() {
|
|
8
|
-
return this.originalConsoleError;
|
|
9
|
-
}
|
|
10
|
-
constructor() {
|
|
11
|
-
this.isMonitoring = false;
|
|
12
|
-
this.violations = [];
|
|
13
|
-
this.consoleOutput = [];
|
|
14
|
-
this.processExitAttempts = 0;
|
|
15
|
-
this.readlineUsageDetected = false;
|
|
16
|
-
this.startTime = 0;
|
|
17
|
-
// Store original methods
|
|
18
|
-
this.originalConsoleLog = console.log;
|
|
19
|
-
this.originalConsoleError = console.error;
|
|
20
|
-
this.originalConsoleWarn = console.warn;
|
|
21
|
-
this.originalConsoleInfo = console.info;
|
|
22
|
-
this.originalProcessExit = process.exit;
|
|
23
|
-
this.originalStdoutWrite = process.stdout.write;
|
|
24
|
-
this.originalStderrWrite = process.stderr.write;
|
|
25
|
-
}
|
|
26
|
-
startMonitoring() {
|
|
27
|
-
if (this.isMonitoring) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
this.isMonitoring = true;
|
|
31
|
-
this.violations = [];
|
|
32
|
-
this.consoleOutput = [];
|
|
33
|
-
this.processExitAttempts = 0;
|
|
34
|
-
this.readlineUsageDetected = false;
|
|
35
|
-
this.startTime = Date.now();
|
|
36
|
-
// Hook console methods
|
|
37
|
-
console.log = (...args) => {
|
|
38
|
-
const message = args.join(" ");
|
|
39
|
-
this.consoleOutput.push(`[LOG] ${message}`);
|
|
40
|
-
this.violations.push(`Console.log called: ${message}`);
|
|
41
|
-
};
|
|
42
|
-
console.error = (...args) => {
|
|
43
|
-
const message = args.join(" ");
|
|
44
|
-
this.consoleOutput.push(`[ERROR] ${message}`);
|
|
45
|
-
this.violations.push(`Console.error called: ${message}`);
|
|
46
|
-
};
|
|
47
|
-
console.warn = (...args) => {
|
|
48
|
-
const message = args.join(" ");
|
|
49
|
-
this.consoleOutput.push(`[WARN] ${message}`);
|
|
50
|
-
this.violations.push(`Console.warn called: ${message}`);
|
|
51
|
-
};
|
|
52
|
-
console.info = (...args) => {
|
|
53
|
-
const message = args.join(" ");
|
|
54
|
-
this.consoleOutput.push(`[INFO] ${message}`);
|
|
55
|
-
this.violations.push(`Console.info called: ${message}`);
|
|
56
|
-
};
|
|
57
|
-
// Hook process.exit
|
|
58
|
-
process.exit = ((code) => {
|
|
59
|
-
this.processExitAttempts++;
|
|
60
|
-
this.violations.push(`Process.exit called with code: ${code}`);
|
|
61
|
-
throw new Error(`Process exit intercepted: ${code}`);
|
|
62
|
-
});
|
|
63
|
-
// Hook stdout/stderr
|
|
64
|
-
process.stdout.write = ((chunk, ...args) => {
|
|
65
|
-
if (typeof chunk === "string" && chunk.trim()) {
|
|
66
|
-
this.consoleOutput.push(`[STDOUT] ${chunk}`);
|
|
67
|
-
this.violations.push(`Process.stdout.write called: ${chunk.substring(0, 100)}...`);
|
|
68
|
-
}
|
|
69
|
-
return true;
|
|
70
|
-
});
|
|
71
|
-
process.stderr.write = ((chunk, ...args) => {
|
|
72
|
-
if (typeof chunk === "string" && chunk.trim()) {
|
|
73
|
-
this.consoleOutput.push(`[STDERR] ${chunk}`);
|
|
74
|
-
this.violations.push(`Process.stderr.write called: ${chunk.substring(0, 100)}...`);
|
|
75
|
-
}
|
|
76
|
-
return true;
|
|
77
|
-
});
|
|
78
|
-
// Hook readline (if it gets required)
|
|
79
|
-
const originalRequire = require;
|
|
80
|
-
const monitor = this;
|
|
81
|
-
global.require = function (id) {
|
|
82
|
-
if (id === "readline" || id.includes("readline")) {
|
|
83
|
-
monitor.readlineUsageDetected = true;
|
|
84
|
-
monitor.violations.push("Readline module usage detected");
|
|
85
|
-
}
|
|
86
|
-
return originalRequire.apply(this, arguments);
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
stopMonitoring() {
|
|
90
|
-
if (!this.isMonitoring) {
|
|
91
|
-
throw new Error("Monitor is not currently running");
|
|
92
|
-
}
|
|
93
|
-
// Restore original methods
|
|
94
|
-
console.log = this.originalConsoleLog;
|
|
95
|
-
console.error = this.originalConsoleError;
|
|
96
|
-
console.warn = this.originalConsoleWarn;
|
|
97
|
-
console.info = this.originalConsoleInfo;
|
|
98
|
-
process.exit = this.originalProcessExit;
|
|
99
|
-
process.stdout.write = this.originalStdoutWrite;
|
|
100
|
-
process.stderr.write = this.originalStderrWrite;
|
|
101
|
-
// Restore require
|
|
102
|
-
global.require = require;
|
|
103
|
-
this.isMonitoring = false;
|
|
104
|
-
return {
|
|
105
|
-
violations: [...this.violations],
|
|
106
|
-
consoleOutputDetected: [...this.consoleOutput],
|
|
107
|
-
processExitAttempts: this.processExitAttempts,
|
|
108
|
-
readlineUsageDetected: this.readlineUsageDetected,
|
|
109
|
-
duration: Date.now() - this.startTime,
|
|
110
|
-
timestamp: new Date().toISOString(),
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
isCurrentlyMonitoring() {
|
|
114
|
-
return this.isMonitoring;
|
|
115
|
-
}
|
|
116
|
-
getViolations() {
|
|
117
|
-
return [...this.violations];
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Global monitor instance
|
|
122
|
-
*/
|
|
123
|
-
const globalMonitor = new McpSilentOperationMonitor();
|
|
124
|
-
/**
|
|
125
|
-
* Decorator to ensure a function operates silently
|
|
126
|
-
*/
|
|
127
|
-
export function ensureSilent(fn) {
|
|
128
|
-
return ((...args) => {
|
|
129
|
-
const wasMonitoring = globalMonitor.isCurrentlyMonitoring();
|
|
130
|
-
if (!wasMonitoring) {
|
|
131
|
-
globalMonitor.startMonitoring();
|
|
132
|
-
}
|
|
133
|
-
try {
|
|
134
|
-
const result = fn(...args);
|
|
135
|
-
// Handle both sync and async functions
|
|
136
|
-
if (result && typeof result.then === "function") {
|
|
137
|
-
return result.finally(() => {
|
|
138
|
-
if (!wasMonitoring) {
|
|
139
|
-
const report = globalMonitor.stopMonitoring();
|
|
140
|
-
if (report.violations.length > 0) {
|
|
141
|
-
throw new Error(`Silent operation violated: ${report.violations.join(", ")}`);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
if (!wasMonitoring) {
|
|
148
|
-
const report = globalMonitor.stopMonitoring();
|
|
149
|
-
if (report.violations.length > 0) {
|
|
150
|
-
throw new Error(`Silent operation violated: ${report.violations.join(", ")}`);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return result;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
if (!wasMonitoring && globalMonitor.isCurrentlyMonitoring()) {
|
|
158
|
-
globalMonitor.stopMonitoring();
|
|
159
|
-
}
|
|
160
|
-
throw error;
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Higher-order function to wrap MCP tool handlers for silent operation
|
|
166
|
-
*/
|
|
167
|
-
export function silentMcpTool(handler) {
|
|
168
|
-
return (async (...args) => {
|
|
169
|
-
const monitor = new McpSilentOperationMonitor();
|
|
170
|
-
monitor.startMonitoring();
|
|
171
|
-
try {
|
|
172
|
-
const result = await handler(...args);
|
|
173
|
-
const report = monitor.stopMonitoring();
|
|
174
|
-
if (report.violations.length > 0) {
|
|
175
|
-
// Log violations using the original console methods for debugging
|
|
176
|
-
globalMonitor.getOriginalConsoleError()("🚨 MCP Tool Handler Violations:", report.violations);
|
|
177
|
-
// In production, you might want to return an error response instead of throwing
|
|
178
|
-
if (process.env.NODE_ENV === "production") {
|
|
179
|
-
return {
|
|
180
|
-
content: [
|
|
181
|
-
{
|
|
182
|
-
type: "text",
|
|
183
|
-
text: "Internal error: Silent operation requirements violated",
|
|
184
|
-
},
|
|
185
|
-
],
|
|
186
|
-
isError: true,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return result;
|
|
191
|
-
}
|
|
192
|
-
catch (error) {
|
|
193
|
-
const report = monitor.stopMonitoring();
|
|
194
|
-
if (report.violations.length > 0) {
|
|
195
|
-
globalMonitor.getOriginalConsoleError()("🚨 MCP Tool Handler Violations during error:", report.violations);
|
|
196
|
-
}
|
|
197
|
-
throw error;
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Utility to check if environment is properly configured for silent operation
|
|
203
|
-
*/
|
|
204
|
-
export function validateSilentEnvironment() {
|
|
205
|
-
const issues = [];
|
|
206
|
-
// Check environment variables
|
|
207
|
-
if (process.env.CI !== "true") {
|
|
208
|
-
issues.push('CI environment variable not set to "true"');
|
|
209
|
-
}
|
|
210
|
-
if (process.env.ENACT_SKIP_INTERACTIVE !== "true") {
|
|
211
|
-
issues.push('ENACT_SKIP_INTERACTIVE not set to "true"');
|
|
212
|
-
}
|
|
213
|
-
if (process.env.DEBUG === "true" || process.env.VERBOSE === "true") {
|
|
214
|
-
issues.push("DEBUG or VERBOSE environment variables are enabled");
|
|
215
|
-
}
|
|
216
|
-
// Check if we're in a TTY (which might indicate interactive mode)
|
|
217
|
-
if (process.stdin.isTTY) {
|
|
218
|
-
issues.push("Process is running in TTY mode (potentially interactive)");
|
|
219
|
-
}
|
|
220
|
-
return {
|
|
221
|
-
valid: issues.length === 0,
|
|
222
|
-
issues,
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Logger specifically for MCP silent operation monitoring
|
|
227
|
-
*/
|
|
228
|
-
export const silentLogger = {
|
|
229
|
-
logViolation: (violation) => {
|
|
230
|
-
// Use stderr directly to bypass any console mocking
|
|
231
|
-
process.stderr.write(`[SILENT-VIOLATION] ${new Date().toISOString()}: ${violation}\n`);
|
|
232
|
-
},
|
|
233
|
-
logReport: (report) => {
|
|
234
|
-
if (report.violations.length > 0) {
|
|
235
|
-
process.stderr.write(`[SILENT-REPORT] ${report.timestamp}: ${report.violations.length} violations in ${report.duration}ms\n`);
|
|
236
|
-
report.violations.forEach((violation) => {
|
|
237
|
-
process.stderr.write(` - ${violation}\n`);
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
},
|
|
241
|
-
};
|
|
242
|
-
export { globalMonitor, McpSilentOperationMonitor };
|
package/dist/utils/timeout.d.ts
DELETED
package/dist/utils/timeout.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// src/utils/timeout.ts - Shared timeout parsing utility
|
|
2
|
-
/**
|
|
3
|
-
* Parse timeout string to milliseconds
|
|
4
|
-
* Supports formats like "30s", "5m", "2h"
|
|
5
|
-
*/
|
|
6
|
-
export function parseTimeout(timeout) {
|
|
7
|
-
const match = timeout.match(/^(\d+)([smh])$/);
|
|
8
|
-
if (!match) {
|
|
9
|
-
return 30000; // Default 30 seconds
|
|
10
|
-
}
|
|
11
|
-
const value = parseInt(match[1]);
|
|
12
|
-
const unit = match[2];
|
|
13
|
-
switch (unit) {
|
|
14
|
-
case "s":
|
|
15
|
-
return value * 1000;
|
|
16
|
-
case "m":
|
|
17
|
-
return value * 60 * 1000;
|
|
18
|
-
case "h":
|
|
19
|
-
return value * 60 * 60 * 1000;
|
|
20
|
-
default:
|
|
21
|
-
return 30000; // Default fallback
|
|
22
|
-
}
|
|
23
|
-
}
|
package/dist/utils/version.d.ts
DELETED
package/dist/utils/version.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// src/utils/version.ts
|
|
2
|
-
import pc from "picocolors";
|
|
3
|
-
import { readFileSync } from "fs";
|
|
4
|
-
import { join, dirname } from "path";
|
|
5
|
-
import { fileURLToPath } from "url";
|
|
6
|
-
/**
|
|
7
|
-
* Displays the CLI version with nice formatting
|
|
8
|
-
*/
|
|
9
|
-
export function showVersion() {
|
|
10
|
-
let version = "0.0.1-dev";
|
|
11
|
-
try {
|
|
12
|
-
// Try to get version from environment first (for npm scripts)
|
|
13
|
-
if (process.env.npm_package_version) {
|
|
14
|
-
version = process.env.npm_package_version;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
// When running as installed binary, read from package.json
|
|
18
|
-
// Go up from shared/dist/utils/version.js to find package.json
|
|
19
|
-
const currentFile = typeof __filename !== 'undefined' ? __filename : fileURLToPath(import.meta.url);
|
|
20
|
-
const sharedDir = dirname(dirname(dirname(currentFile)));
|
|
21
|
-
const packageJsonPath = join(sharedDir, 'package.json');
|
|
22
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
23
|
-
version = packageJson.version;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
// Fall back to default version if anything fails
|
|
28
|
-
version = "1.0.14";
|
|
29
|
-
}
|
|
30
|
-
const versionText = `v${version}`;
|
|
31
|
-
console.error(`
|
|
32
|
-
${pc.bold("Enact CLI")} ${pc.cyan(versionText)}
|
|
33
|
-
${pc.dim("A tool to create and publish enact documents.")}
|
|
34
|
-
`);
|
|
35
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
interface PackageEnvInfo {
|
|
2
|
-
namespace: string;
|
|
3
|
-
path: string;
|
|
4
|
-
variables: Record<string, string>;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Get all package namespaces with environment variables
|
|
8
|
-
*/
|
|
9
|
-
declare function getAllPackageNamespaces(): Promise<PackageEnvInfo[]>;
|
|
10
|
-
/**
|
|
11
|
-
* Get environment variables for a specific package namespace
|
|
12
|
-
*/
|
|
13
|
-
declare function getPackageEnvVars(namespace: string): Promise<Record<string, string>>;
|
|
14
|
-
/**
|
|
15
|
-
* Set environment variable for a package namespace
|
|
16
|
-
*/
|
|
17
|
-
declare function setPackageEnvVar(namespace: string, key: string, value: string): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Delete environment variable for a package namespace
|
|
20
|
-
*/
|
|
21
|
-
declare function deletePackageEnvVar(namespace: string, key: string): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* Start the web server
|
|
24
|
-
*/
|
|
25
|
-
export declare function startEnvManagerServer(port?: number): Promise<{
|
|
26
|
-
server: any;
|
|
27
|
-
port: number;
|
|
28
|
-
}>;
|
|
29
|
-
export { getAllPackageNamespaces, getPackageEnvVars, setPackageEnvVar, deletePackageEnvVar, };
|