@codemieai/code 0.0.20 → 0.0.21
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/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
- package/dist/agents/core/BaseAgentAdapter.js +13 -10
- package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
- package/dist/cli/commands/doctor/checks/NpmCheck.d.ts.map +1 -1
- package/dist/cli/commands/doctor/checks/NpmCheck.js +5 -5
- package/dist/cli/commands/doctor/checks/NpmCheck.js.map +1 -1
- package/dist/cli/commands/uninstall.d.ts.map +1 -1
- package/dist/cli/commands/uninstall.js +2 -3
- package/dist/cli/commands/uninstall.js.map +1 -1
- package/dist/env/types.d.ts +2 -0
- package/dist/env/types.d.ts.map +1 -1
- package/dist/env/types.js.map +1 -1
- package/dist/frameworks/plugins/bmad.plugin.d.ts +3 -2
- package/dist/frameworks/plugins/bmad.plugin.d.ts.map +1 -1
- package/dist/frameworks/plugins/bmad.plugin.js +29 -12
- package/dist/frameworks/plugins/bmad.plugin.js.map +1 -1
- package/dist/metrics/MetricsOrchestrator.d.ts +2 -0
- package/dist/metrics/MetricsOrchestrator.d.ts.map +1 -1
- package/dist/metrics/MetricsOrchestrator.js +3 -0
- package/dist/metrics/MetricsOrchestrator.js.map +1 -1
- package/dist/metrics/core/SyncStateManager.d.ts.map +1 -1
- package/dist/metrics/core/SyncStateManager.js +3 -4
- package/dist/metrics/core/SyncStateManager.js.map +1 -1
- package/dist/metrics/sync/aggregator.js +1 -0
- package/dist/metrics/sync/aggregator.js.map +1 -1
- package/dist/metrics/sync/types.d.ts +1 -0
- package/dist/metrics/sync/types.d.ts.map +1 -1
- package/dist/metrics/types.d.ts +1 -0
- package/dist/metrics/types.d.ts.map +1 -1
- package/dist/providers/plugins/sso/sso.http-client.d.ts +33 -0
- package/dist/providers/plugins/sso/sso.http-client.d.ts.map +1 -1
- package/dist/providers/plugins/sso/sso.http-client.js +80 -3
- package/dist/providers/plugins/sso/sso.http-client.js.map +1 -1
- package/dist/providers/plugins/sso/sso.models.d.ts +6 -2
- package/dist/providers/plugins/sso/sso.models.d.ts.map +1 -1
- package/dist/providers/plugins/sso/sso.models.js +18 -4
- package/dist/providers/plugins/sso/sso.models.js.map +1 -1
- package/dist/providers/plugins/sso/sso.setup-steps.d.ts.map +1 -1
- package/dist/providers/plugins/sso/sso.setup-steps.js +55 -4
- package/dist/providers/plugins/sso/sso.setup-steps.js.map +1 -1
- package/dist/utils/config-loader.d.ts.map +1 -1
- package/dist/utils/config-loader.js +2 -0
- package/dist/utils/config-loader.js.map +1 -1
- package/dist/utils/errors.d.ts +25 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +64 -0
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/npm.d.ts +116 -0
- package/dist/utils/npm.d.ts.map +1 -0
- package/dist/utils/npm.js +180 -0
- package/dist/utils/npm.js.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,SAAS,EAAE,MAAM;CAI9B;AAED,qBAAa,sBAAuB,SAAQ,YAAY;gBAC1C,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAI9C;AAED,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAI7C;AAED,qBAAa,iBAAkB,SAAQ,YAAY;gBACrC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAIzC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKtD"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,SAAS,EAAE,MAAM;CAI9B;AAED,qBAAa,sBAAuB,SAAQ,YAAY;gBAC1C,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAI9C;AAED,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAI7C;AAED,qBAAa,iBAAkB,SAAQ,YAAY;gBACrC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAIzC;AAED;;GAEG;AACH,oBAAY,YAAY;IACtB,aAAa,kBAAkB;IAC/B,gBAAgB,qBAAqB;IACrC,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,YAAY;IAG/B,IAAI,EAAE,YAAY;IAClB,aAAa,CAAC,EAAE,KAAK;gBAF5B,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,YAAY,EAClB,aAAa,CAAC,EAAE,KAAK,YAAA;CAK/B;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,QAAQ,CA6CvE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKtD"}
|
package/dist/utils/errors.js
CHANGED
|
@@ -34,6 +34,70 @@ export class PathSecurityError extends CodeMieError {
|
|
|
34
34
|
this.name = 'PathSecurityError';
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* npm error codes for categorizing failures
|
|
39
|
+
*/
|
|
40
|
+
export var NpmErrorCode;
|
|
41
|
+
(function (NpmErrorCode) {
|
|
42
|
+
NpmErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
43
|
+
NpmErrorCode["PERMISSION_ERROR"] = "PERMISSION_ERROR";
|
|
44
|
+
NpmErrorCode["NOT_FOUND"] = "NOT_FOUND";
|
|
45
|
+
NpmErrorCode["TIMEOUT"] = "TIMEOUT";
|
|
46
|
+
NpmErrorCode["UNKNOWN"] = "UNKNOWN";
|
|
47
|
+
})(NpmErrorCode || (NpmErrorCode = {}));
|
|
48
|
+
/**
|
|
49
|
+
* Custom error class for npm operations
|
|
50
|
+
*/
|
|
51
|
+
export class NpmError extends CodeMieError {
|
|
52
|
+
code;
|
|
53
|
+
originalError;
|
|
54
|
+
constructor(message, code, originalError) {
|
|
55
|
+
super(message);
|
|
56
|
+
this.code = code;
|
|
57
|
+
this.originalError = originalError;
|
|
58
|
+
this.name = 'NpmError';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Parse npm error from exec failure and create appropriate NpmError
|
|
63
|
+
* @param error - The caught error from exec
|
|
64
|
+
* @param context - Context message (e.g., "Failed to install package-name")
|
|
65
|
+
* @returns Parsed NpmError with appropriate error code
|
|
66
|
+
*/
|
|
67
|
+
export function parseNpmError(error, context) {
|
|
68
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
69
|
+
const lowerMessage = errorMessage.toLowerCase();
|
|
70
|
+
// Detect error type from message patterns
|
|
71
|
+
let code = NpmErrorCode.UNKNOWN;
|
|
72
|
+
let hint = '';
|
|
73
|
+
// Timeout (check first - most specific)
|
|
74
|
+
if (lowerMessage.includes('timed out')) {
|
|
75
|
+
code = NpmErrorCode.TIMEOUT;
|
|
76
|
+
hint = 'Operation timed out. Try increasing the timeout or check your connection.';
|
|
77
|
+
}
|
|
78
|
+
// Permission errors
|
|
79
|
+
else if (lowerMessage.includes('eacces') || lowerMessage.includes('eperm')) {
|
|
80
|
+
code = NpmErrorCode.PERMISSION_ERROR;
|
|
81
|
+
hint =
|
|
82
|
+
'Try running with elevated permissions (sudo on Unix) or check directory permissions.';
|
|
83
|
+
}
|
|
84
|
+
// Package not found (check before network errors to prioritize 404)
|
|
85
|
+
else if (lowerMessage.includes('404') ||
|
|
86
|
+
lowerMessage.includes('e404')) {
|
|
87
|
+
code = NpmErrorCode.NOT_FOUND;
|
|
88
|
+
hint = 'Verify the package name and version are correct.';
|
|
89
|
+
}
|
|
90
|
+
// Network errors
|
|
91
|
+
else if (lowerMessage.includes('enotfound') ||
|
|
92
|
+
lowerMessage.includes('etimedout') ||
|
|
93
|
+
lowerMessage.includes('eai_again') ||
|
|
94
|
+
lowerMessage.includes('network')) {
|
|
95
|
+
code = NpmErrorCode.NETWORK_ERROR;
|
|
96
|
+
hint = 'Check your internet connection and npm registry configuration.';
|
|
97
|
+
}
|
|
98
|
+
const fullMessage = hint ? `${context}: ${errorMessage}\nHint: ${hint}` : `${context}: ${errorMessage}`;
|
|
99
|
+
return new NpmError(fullMessage, code, error instanceof Error ? error : undefined);
|
|
100
|
+
}
|
|
37
101
|
/**
|
|
38
102
|
* Extracts error message from unknown error type
|
|
39
103
|
* @param error - The caught error (unknown type)
|
package/dist/utils/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,YAAY;IAClD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;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AAI,GAAG,YAAY,CAAC,aAAa,CAAC;QAClC,IAAI,GAAG,gEAAgE,CAAC;IAC1E,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,YAAY,WAAW,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,YAAY,EAAE,CAAC;IAExG,OAAO,IAAI,QAAQ,CACjB,WAAW,EACX,IAAI,EACJ,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAC3C,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NPM utility wrapper for consistent npm operations
|
|
3
|
+
*
|
|
4
|
+
* Provides type-safe API for common npm operations with:
|
|
5
|
+
* - Consistent timeout management
|
|
6
|
+
* - Specialized error handling
|
|
7
|
+
* - Comprehensive logging
|
|
8
|
+
* - Cross-platform support
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Base options for npm operations
|
|
12
|
+
*/
|
|
13
|
+
export interface NpmOptions {
|
|
14
|
+
/** Working directory for npm command */
|
|
15
|
+
cwd?: string;
|
|
16
|
+
/** Environment variables */
|
|
17
|
+
env?: Record<string, string>;
|
|
18
|
+
/** Operation timeout in milliseconds */
|
|
19
|
+
timeout?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Options for npm install operations
|
|
23
|
+
*/
|
|
24
|
+
export interface NpmInstallOptions extends NpmOptions {
|
|
25
|
+
/** Package version (e.g., '1.0.0', 'latest') */
|
|
26
|
+
version?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Options for npx run operations
|
|
30
|
+
*/
|
|
31
|
+
export interface NpxRunOptions extends NpmOptions {
|
|
32
|
+
/** Enable interactive mode for user prompts */
|
|
33
|
+
interactive?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Install a package globally via npm
|
|
37
|
+
*
|
|
38
|
+
* @param packageName - Package name to install (e.g., 'typescript')
|
|
39
|
+
* @param options - Installation options
|
|
40
|
+
* @throws {NpmError} If installation fails
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* // Install latest version
|
|
45
|
+
* await installGlobal('typescript');
|
|
46
|
+
*
|
|
47
|
+
* // Install specific version
|
|
48
|
+
* await installGlobal('typescript', { version: '5.0.0' });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function installGlobal(packageName: string, options?: NpmInstallOptions): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Uninstall a package globally via npm
|
|
54
|
+
*
|
|
55
|
+
* @param packageName - Package name to uninstall
|
|
56
|
+
* @param options - Uninstallation options
|
|
57
|
+
* @throws {NpmError} If uninstallation fails
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* await uninstallGlobal('typescript');
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function uninstallGlobal(packageName: string, options?: NpmOptions): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Check if a package is installed globally
|
|
67
|
+
*
|
|
68
|
+
* @param packageName - Package name to check
|
|
69
|
+
* @param options - Check options
|
|
70
|
+
* @returns True if package is installed globally, false otherwise
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const isInstalled = await listGlobal('typescript');
|
|
75
|
+
* if (isInstalled) {
|
|
76
|
+
* console.log('TypeScript is installed');
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function listGlobal(packageName: string, options?: NpmOptions): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Get npm version
|
|
83
|
+
*
|
|
84
|
+
* @param options - Version check options
|
|
85
|
+
* @returns npm version string, or null if npm not found
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const version = await getVersion();
|
|
90
|
+
* if (version) {
|
|
91
|
+
* console.log(`npm version: ${version}`);
|
|
92
|
+
* } else {
|
|
93
|
+
* console.log('npm not installed');
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function getVersion(options?: NpmOptions): Promise<string | null>;
|
|
98
|
+
/**
|
|
99
|
+
* Run a command via npx
|
|
100
|
+
*
|
|
101
|
+
* @param command - Command to run (e.g., 'create-react-app')
|
|
102
|
+
* @param args - Command arguments
|
|
103
|
+
* @param options - Execution options
|
|
104
|
+
* @throws {NpmError} If execution fails
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* // Run with interactive mode
|
|
109
|
+
* await npxRun('create-react-app', ['my-app'], { interactive: true });
|
|
110
|
+
*
|
|
111
|
+
* // Run with custom timeout
|
|
112
|
+
* await npxRun('eslint', ['src/'], { timeout: 60000 });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare function npxRun(command: string, args?: string[], options?: NpxRunOptions): Promise<void>;
|
|
116
|
+
//# sourceMappingURL=npm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm.d.ts","sourceRoot":"","sources":["../../src/utils/npm.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C,+CAA+C;IAC/C,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA0Bf;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,UAAU,CAC9B,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,OAAO,CAAC,CAiBlB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,UAAU,CAC9B,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgBxB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,MAAM,CAC1B,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,MAAM,EAAO,EACnB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAmBf"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NPM utility wrapper for consistent npm operations
|
|
3
|
+
*
|
|
4
|
+
* Provides type-safe API for common npm operations with:
|
|
5
|
+
* - Consistent timeout management
|
|
6
|
+
* - Specialized error handling
|
|
7
|
+
* - Comprehensive logging
|
|
8
|
+
* - Cross-platform support
|
|
9
|
+
*/
|
|
10
|
+
import { exec } from './exec.js';
|
|
11
|
+
import { logger } from './logger.js';
|
|
12
|
+
/**
|
|
13
|
+
* Install a package globally via npm
|
|
14
|
+
*
|
|
15
|
+
* @param packageName - Package name to install (e.g., 'typescript')
|
|
16
|
+
* @param options - Installation options
|
|
17
|
+
* @throws {NpmError} If installation fails
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Install latest version
|
|
22
|
+
* await installGlobal('typescript');
|
|
23
|
+
*
|
|
24
|
+
* // Install specific version
|
|
25
|
+
* await installGlobal('typescript', { version: '5.0.0' });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export async function installGlobal(packageName, options = {}) {
|
|
29
|
+
const packageSpec = options.version ? `${packageName}@${options.version}` : packageName;
|
|
30
|
+
const timeout = options.timeout ?? 120000; // 2 minutes default
|
|
31
|
+
logger.info(`Installing ${packageSpec} globally...`);
|
|
32
|
+
try {
|
|
33
|
+
const execOptions = {
|
|
34
|
+
cwd: options.cwd,
|
|
35
|
+
env: options.env,
|
|
36
|
+
timeout
|
|
37
|
+
};
|
|
38
|
+
const result = await exec('npm', ['install', '-g', packageSpec], execOptions);
|
|
39
|
+
if (result.code !== 0) {
|
|
40
|
+
throw new Error(`npm install exited with code ${result.code}: ${result.stderr || result.stdout}`);
|
|
41
|
+
}
|
|
42
|
+
logger.success(`${packageSpec} installed successfully`);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
const { parseNpmError } = await import('./errors.js');
|
|
46
|
+
throw parseNpmError(error, `Failed to install ${packageSpec}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Uninstall a package globally via npm
|
|
51
|
+
*
|
|
52
|
+
* @param packageName - Package name to uninstall
|
|
53
|
+
* @param options - Uninstallation options
|
|
54
|
+
* @throws {NpmError} If uninstallation fails
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* await uninstallGlobal('typescript');
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export async function uninstallGlobal(packageName, options = {}) {
|
|
62
|
+
const timeout = options.timeout ?? 30000; // 30 seconds default
|
|
63
|
+
logger.info(`Uninstalling ${packageName} globally...`);
|
|
64
|
+
try {
|
|
65
|
+
const execOptions = {
|
|
66
|
+
cwd: options.cwd,
|
|
67
|
+
env: options.env,
|
|
68
|
+
timeout
|
|
69
|
+
};
|
|
70
|
+
const result = await exec('npm', ['uninstall', '-g', packageName], execOptions);
|
|
71
|
+
if (result.code !== 0) {
|
|
72
|
+
throw new Error(`npm uninstall exited with code ${result.code}: ${result.stderr || result.stdout}`);
|
|
73
|
+
}
|
|
74
|
+
logger.success(`${packageName} uninstalled successfully`);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
const { parseNpmError } = await import('./errors.js');
|
|
78
|
+
throw parseNpmError(error, `Failed to uninstall ${packageName}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Check if a package is installed globally
|
|
83
|
+
*
|
|
84
|
+
* @param packageName - Package name to check
|
|
85
|
+
* @param options - Check options
|
|
86
|
+
* @returns True if package is installed globally, false otherwise
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const isInstalled = await listGlobal('typescript');
|
|
91
|
+
* if (isInstalled) {
|
|
92
|
+
* console.log('TypeScript is installed');
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export async function listGlobal(packageName, options = {}) {
|
|
97
|
+
const timeout = options.timeout ?? 5000; // 5 seconds default
|
|
98
|
+
try {
|
|
99
|
+
const execOptions = {
|
|
100
|
+
cwd: options.cwd,
|
|
101
|
+
env: options.env,
|
|
102
|
+
timeout
|
|
103
|
+
};
|
|
104
|
+
const result = await exec('npm', ['list', '-g', packageName], execOptions);
|
|
105
|
+
// Exit code 0 = installed, 1 = not found, >1 = error
|
|
106
|
+
return result.code === 0;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// If exec throws, treat as not installed (unless it's a real error)
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get npm version
|
|
115
|
+
*
|
|
116
|
+
* @param options - Version check options
|
|
117
|
+
* @returns npm version string, or null if npm not found
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* const version = await getVersion();
|
|
122
|
+
* if (version) {
|
|
123
|
+
* console.log(`npm version: ${version}`);
|
|
124
|
+
* } else {
|
|
125
|
+
* console.log('npm not installed');
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export async function getVersion(options = {}) {
|
|
130
|
+
const timeout = options.timeout ?? 5000; // 5 seconds default
|
|
131
|
+
try {
|
|
132
|
+
const execOptions = {
|
|
133
|
+
cwd: options.cwd,
|
|
134
|
+
env: options.env,
|
|
135
|
+
timeout
|
|
136
|
+
};
|
|
137
|
+
const result = await exec('npm', ['--version'], execOptions);
|
|
138
|
+
const match = result.stdout.match(/\d+\.\d+\.\d+/);
|
|
139
|
+
return match ? match[0] : null;
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Run a command via npx
|
|
147
|
+
*
|
|
148
|
+
* @param command - Command to run (e.g., 'create-react-app')
|
|
149
|
+
* @param args - Command arguments
|
|
150
|
+
* @param options - Execution options
|
|
151
|
+
* @throws {NpmError} If execution fails
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* // Run with interactive mode
|
|
156
|
+
* await npxRun('create-react-app', ['my-app'], { interactive: true });
|
|
157
|
+
*
|
|
158
|
+
* // Run with custom timeout
|
|
159
|
+
* await npxRun('eslint', ['src/'], { timeout: 60000 });
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
export async function npxRun(command, args = [], options = {}) {
|
|
163
|
+
const timeout = options.timeout ?? 300000; // 5 minutes default (download + execution)
|
|
164
|
+
logger.info(`Running npx ${command} ${args.join(' ')}...`);
|
|
165
|
+
try {
|
|
166
|
+
const execOptions = {
|
|
167
|
+
cwd: options.cwd,
|
|
168
|
+
env: options.env,
|
|
169
|
+
timeout,
|
|
170
|
+
interactive: options.interactive
|
|
171
|
+
};
|
|
172
|
+
await exec('npx', [command, ...args], execOptions);
|
|
173
|
+
logger.success(`npx ${command} completed successfully`);
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
const { parseNpmError } = await import('./errors.js');
|
|
177
|
+
throw parseNpmError(error, `Failed to run npx ${command}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=npm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm.js","sourceRoot":"","sources":["../../src/utils/npm.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAe,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA8BrC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,WAAmB,EACnB,UAA6B,EAAE;IAE/B,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;IACxF,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC,oBAAoB;IAE/D,MAAM,CAAC,IAAI,CAAC,cAAc,WAAW,cAAc,CAAC,CAAC;IAErD,IAAI,CAAC;QACH,MAAM,WAAW,GAAgB;YAC/B,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,GAAG,EAAE,OAAO,CA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code",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "Unified AI coding assistant CLI - Manage Claude Code, Codex, Gemini & custom agents. Multi-provider support (OpenAI, Azure, LiteLLM, SSO). Built-in LangGraph agent with file operations & git integration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"lint-staged": {
|
|
47
47
|
"*.ts": [
|
|
48
|
-
"eslint --max-warnings=0",
|
|
48
|
+
"eslint --max-warnings=0 --no-warn-ignored",
|
|
49
49
|
"vitest related --run"
|
|
50
50
|
],
|
|
51
51
|
"package.json": [
|