imcp 0.1.7 → 0.1.8-dev
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/cli/commands/install.js +1 -106
- package/dist/cli/commands/install.js.map +1 -0
- package/dist/cli/commands/list.js +1 -90
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/pull.js +1 -16
- package/dist/cli/commands/pull.js.map +1 -0
- package/dist/cli/commands/serve.js +1 -33
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/uninstall.js +1 -46
- package/dist/cli/commands/uninstall.js.map +1 -0
- package/dist/cli/index.js +1 -65
- package/dist/cli/index.js.map +1 -0
- package/dist/core/installers/clients/BaseClientInstaller.js +1 -282
- package/dist/core/installers/clients/BaseClientInstaller.js.map +1 -0
- package/dist/core/installers/clients/ClientInstaller.js +1 -163
- package/dist/core/installers/clients/ClientInstaller.js.map +1 -0
- package/dist/core/installers/clients/ClientInstallerFactory.js +1 -36
- package/dist/core/installers/clients/ClientInstallerFactory.js.map +1 -0
- package/dist/core/installers/clients/ClineInstaller.js +1 -30
- package/dist/core/installers/clients/ClineInstaller.js.map +1 -0
- package/dist/core/installers/clients/ExtensionInstaller.js +1 -151
- package/dist/core/installers/clients/ExtensionInstaller.js.map +1 -0
- package/dist/core/installers/clients/GithubCopilotInstaller.js +1 -68
- package/dist/core/installers/clients/GithubCopilotInstaller.js.map +1 -0
- package/dist/core/installers/clients/MSRooCodeInstaller.js +1 -28
- package/dist/core/installers/clients/MSRooCodeInstaller.js.map +1 -0
- package/dist/core/installers/index.js +1 -8
- package/dist/core/installers/index.js.map +1 -0
- package/dist/core/installers/requirements/BaseInstaller.js +1 -56
- package/dist/core/installers/requirements/BaseInstaller.js.map +1 -0
- package/dist/core/installers/requirements/CommandInstaller.js +1 -213
- package/dist/core/installers/requirements/CommandInstaller.js.map +1 -0
- package/dist/core/installers/requirements/GeneralInstaller.js +1 -126
- package/dist/core/installers/requirements/GeneralInstaller.js.map +1 -0
- package/dist/core/installers/requirements/InstallerFactory.js +1 -99
- package/dist/core/installers/requirements/InstallerFactory.js.map +1 -0
- package/dist/core/installers/requirements/NpmInstaller.js +1 -235
- package/dist/core/installers/requirements/NpmInstaller.js.map +1 -0
- package/dist/core/installers/requirements/NugetInstaller.js +1 -188
- package/dist/core/installers/requirements/NugetInstaller.js.map +1 -0
- package/dist/core/installers/requirements/PipInstaller.js +1 -192
- package/dist/core/installers/requirements/PipInstaller.js.map +1 -0
- package/dist/core/installers/requirements/RequirementInstaller.js +1 -2
- package/dist/core/installers/requirements/RequirementInstaller.js.map +1 -0
- package/dist/core/loaders/ConfigurationLoader.js +1 -256
- package/dist/core/loaders/ConfigurationLoader.js.map +1 -0
- package/dist/core/loaders/ConfigurationProvider.js +1 -383
- package/dist/core/loaders/ConfigurationProvider.js.map +1 -0
- package/dist/core/loaders/InstallOperationManager.js +1 -310
- package/dist/core/loaders/InstallOperationManager.js.map +1 -0
- package/dist/core/loaders/ServerSchemaLoader.js +1 -108
- package/dist/core/loaders/ServerSchemaLoader.js.map +1 -0
- package/dist/core/loaders/ServerSchemaProvider.js +1 -89
- package/dist/core/loaders/ServerSchemaProvider.js.map +1 -0
- package/dist/core/loaders/SystemSettingsManager.js +1 -256
- package/dist/core/loaders/SystemSettingsManager.js.map +1 -0
- package/dist/core/metadatas/constants.js +1 -100
- package/dist/core/metadatas/constants.js.map +1 -0
- package/dist/core/metadatas/recordingConstants.js +1 -46
- package/dist/core/metadatas/recordingConstants.js.map +1 -0
- package/dist/core/metadatas/types.js +1 -15
- package/dist/core/metadatas/types.js.map +1 -0
- package/dist/core/onboard/FeedOnboardService.js +1 -422
- package/dist/core/onboard/FeedOnboardService.js.map +1 -0
- package/dist/core/onboard/OnboardProcessor.js +1 -333
- package/dist/core/onboard/OnboardProcessor.js.map +1 -0
- package/dist/core/onboard/OnboardStatus.js +1 -9
- package/dist/core/onboard/OnboardStatus.js.map +1 -0
- package/dist/core/onboard/OnboardStatusManager.js +1 -360
- package/dist/core/onboard/OnboardStatusManager.js.map +1 -0
- package/dist/core/validators/FeedValidator.js +1 -133
- package/dist/core/validators/FeedValidator.js.map +1 -0
- package/dist/core/validators/IServerValidator.js +1 -1
- package/dist/core/validators/IServerValidator.js.map +1 -0
- package/dist/core/validators/SSEServerValidator.js +1 -38
- package/dist/core/validators/SSEServerValidator.js.map +1 -0
- package/dist/core/validators/ServerValidatorFactory.js +1 -44
- package/dist/core/validators/ServerValidatorFactory.js.map +1 -0
- package/dist/core/validators/StdioServerValidator.js +1 -281
- package/dist/core/validators/StdioServerValidator.js.map +1 -0
- package/dist/index.js +1 -18
- package/dist/index.js.map +1 -0
- package/dist/services/InstallationService.js +1 -81
- package/dist/services/InstallationService.js.map +1 -0
- package/dist/services/MCPManager.js +1 -197
- package/dist/services/MCPManager.js.map +1 -0
- package/dist/services/RequirementService.js +1 -548
- package/dist/services/RequirementService.js.map +1 -0
- package/dist/services/ServerService.js +1 -127
- package/dist/services/ServerService.js.map +1 -0
- package/dist/services/TelemetryService.js +1 -53
- package/dist/services/TelemetryService.js.map +1 -0
- package/dist/utils/UpdateCheckTracker.js +1 -79
- package/dist/utils/UpdateCheckTracker.js.map +1 -0
- package/dist/utils/adoUtils.js +1 -254
- package/dist/utils/adoUtils.js.map +1 -0
- package/dist/utils/clientUtils.js +1 -65
- package/dist/utils/clientUtils.js.map +1 -0
- package/dist/utils/feedUtils.js +1 -28
- package/dist/utils/feedUtils.js.map +1 -0
- package/dist/utils/githubAuth.js +1 -177
- package/dist/utils/githubAuth.js.map +1 -0
- package/dist/utils/githubUtils.js +1 -125
- package/dist/utils/githubUtils.js.map +1 -0
- package/dist/utils/logger.js +1 -176
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/macroExpressionUtils.js +1 -93
- package/dist/utils/macroExpressionUtils.js.map +1 -0
- package/dist/utils/osUtils.js +1 -664
- package/dist/utils/osUtils.js.map +1 -0
- package/dist/utils/versionUtils.js +1 -101
- package/dist/utils/versionUtils.js.map +1 -0
- package/dist/web/contract/serverContract.js +1 -1
- package/dist/web/contract/serverContract.js.map +1 -0
- package/dist/web/public/js/api.js +2 -132
- package/dist/web/public/js/api.js.map +1 -0
- package/dist/web/public/js/detailsWidget.js +2 -264
- package/dist/web/public/js/detailsWidget.js.map +1 -0
- package/dist/web/public/js/flights/flights.js +2 -127
- package/dist/web/public/js/flights/flights.js.map +1 -0
- package/dist/web/public/js/modal/index.js +2 -52
- package/dist/web/public/js/modal/index.js.map +1 -0
- package/dist/web/public/js/modal/installModal.js +2 -162
- package/dist/web/public/js/modal/installModal.js.map +1 -0
- package/dist/web/public/js/modal/installation.js +2 -266
- package/dist/web/public/js/modal/installation.js.map +1 -0
- package/dist/web/public/js/modal/loadingModal.js +2 -182
- package/dist/web/public/js/modal/loadingModal.js.map +1 -0
- package/dist/web/public/js/modal/modalSetup.js +2 -595
- package/dist/web/public/js/modal/modalSetup.js.map +1 -0
- package/dist/web/public/js/modal/modalUtils.js +2 -37
- package/dist/web/public/js/modal/modalUtils.js.map +1 -0
- package/dist/web/public/js/modal/versionUtils.js +2 -20
- package/dist/web/public/js/modal/versionUtils.js.map +1 -0
- package/dist/web/public/js/modal.js +2 -42
- package/dist/web/public/js/modal.js.map +1 -0
- package/dist/web/public/js/notifications.js +2 -137
- package/dist/web/public/js/notifications.js.map +1 -0
- package/dist/web/public/js/onboard/formProcessor.js +2 -1037
- package/dist/web/public/js/onboard/formProcessor.js.map +1 -0
- package/dist/web/public/js/onboard/index.js +2 -374
- package/dist/web/public/js/onboard/index.js.map +1 -0
- package/dist/web/public/js/onboard/publishHandler.js +2 -172
- package/dist/web/public/js/onboard/publishHandler.js.map +1 -0
- package/dist/web/public/js/onboard/state.js +2 -76
- package/dist/web/public/js/onboard/state.js.map +1 -0
- package/dist/web/public/js/onboard/templates.js +2 -342
- package/dist/web/public/js/onboard/templates.js.map +1 -0
- package/dist/web/public/js/onboard/uiHandlers.js +2 -1076
- package/dist/web/public/js/onboard/uiHandlers.js.map +1 -0
- package/dist/web/public/js/onboard/validationHandlers.js +2 -493
- package/dist/web/public/js/onboard/validationHandlers.js.map +1 -0
- package/dist/web/public/js/serverCategoryDetails.js +2 -364
- package/dist/web/public/js/serverCategoryDetails.js.map +1 -0
- package/dist/web/public/js/serverCategoryList.js +2 -241
- package/dist/web/public/js/serverCategoryList.js.map +1 -0
- package/dist/web/public/js/settings.js +2 -314
- package/dist/web/public/js/settings.js.map +1 -0
- package/dist/web/server.js +1 -404
- package/dist/web/server.js.map +1 -0
- package/package.json +8 -2
- package/.github/ISSUE_TEMPLATE/JitAccess.yml +0 -28
- package/.github/acl/access.yml +0 -20
- package/.github/compliance/inventory.yml +0 -5
- package/.github/policies/jit.yml +0 -19
- package/.github/workflows/build.yml +0 -28
- package/.roo/rules-code/rules.md +0 -88
- package/dist/cli/commands/start.d.ts +0 -2
- package/dist/cli/commands/start.js +0 -32
- package/dist/cli/commands/sync.d.ts +0 -2
- package/dist/cli/commands/sync.js +0 -17
- package/dist/core/ConfigurationLoader.d.ts +0 -32
- package/dist/core/ConfigurationLoader.js +0 -236
- package/dist/core/ConfigurationProvider.d.ts +0 -35
- package/dist/core/ConfigurationProvider.js +0 -375
- package/dist/core/InstallationService.d.ts +0 -50
- package/dist/core/InstallationService.js +0 -350
- package/dist/core/MCPManager.d.ts +0 -28
- package/dist/core/MCPManager.js +0 -188
- package/dist/core/RequirementService.d.ts +0 -40
- package/dist/core/RequirementService.js +0 -110
- package/dist/core/ServerSchemaLoader.d.ts +0 -11
- package/dist/core/ServerSchemaLoader.js +0 -43
- package/dist/core/ServerSchemaProvider.d.ts +0 -17
- package/dist/core/ServerSchemaProvider.js +0 -120
- package/dist/core/constants.d.ts +0 -47
- package/dist/core/constants.js +0 -94
- package/dist/core/installers/BaseInstaller.d.ts +0 -74
- package/dist/core/installers/BaseInstaller.js +0 -253
- package/dist/core/installers/ClientInstaller.d.ts +0 -23
- package/dist/core/installers/ClientInstaller.js +0 -564
- package/dist/core/installers/CommandInstaller.d.ts +0 -37
- package/dist/core/installers/CommandInstaller.js +0 -173
- package/dist/core/installers/GeneralInstaller.d.ts +0 -33
- package/dist/core/installers/GeneralInstaller.js +0 -85
- package/dist/core/installers/InstallerFactory.d.ts +0 -54
- package/dist/core/installers/InstallerFactory.js +0 -97
- package/dist/core/installers/NpmInstaller.d.ts +0 -26
- package/dist/core/installers/NpmInstaller.js +0 -127
- package/dist/core/installers/PipInstaller.d.ts +0 -28
- package/dist/core/installers/PipInstaller.js +0 -127
- package/dist/core/installers/RequirementInstaller.d.ts +0 -33
- package/dist/core/installers/RequirementInstaller.js +0 -3
- package/dist/core/types.d.ts +0 -166
- package/dist/core/types.js +0 -16
- package/dist/services/InstallRequestValidator.d.ts +0 -21
- package/dist/services/InstallRequestValidator.js +0 -99
- package/dist/web/public/js/modal/installHandler.js +0 -227
- package/dist/web/public/js/modal/loadingUI.js +0 -74
- package/dist/web/public/js/modal/messageQueue.js +0 -112
- package/dist/web/public/js/modal/modalUI.js +0 -214
- package/dist/web/public/js/modal/version.js +0 -20
- package/dist/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +0 -370
- package/docs/ONBOARDING_PAGE_DESIGN.md +0 -260
- package/docs/Telemetry.md +0 -136
- package/memory-bank/activeContext.md +0 -26
- package/memory-bank/decisionLog.md +0 -91
- package/memory-bank/productContext.md +0 -41
- package/memory-bank/progress.md +0 -35
- package/memory-bank/systemPatterns.md +0 -10
- package/src/cli/commands/install.ts +0 -139
- package/src/cli/commands/list.ts +0 -113
- package/src/cli/commands/pull.ts +0 -16
- package/src/cli/commands/serve.ts +0 -39
- package/src/cli/commands/uninstall.ts +0 -64
- package/src/cli/index.ts +0 -82
- package/src/core/installers/clients/BaseClientInstaller.ts +0 -341
- package/src/core/installers/clients/ClientInstaller.ts +0 -222
- package/src/core/installers/clients/ClientInstallerFactory.ts +0 -43
- package/src/core/installers/clients/ClineInstaller.ts +0 -35
- package/src/core/installers/clients/ExtensionInstaller.ts +0 -165
- package/src/core/installers/clients/GithubCopilotInstaller.ts +0 -79
- package/src/core/installers/clients/MSRooCodeInstaller.ts +0 -32
- package/src/core/installers/index.ts +0 -11
- package/src/core/installers/requirements/BaseInstaller.ts +0 -85
- package/src/core/installers/requirements/CommandInstaller.ts +0 -231
- package/src/core/installers/requirements/GeneralInstaller.ts +0 -133
- package/src/core/installers/requirements/InstallerFactory.ts +0 -114
- package/src/core/installers/requirements/NpmInstaller.ts +0 -271
- package/src/core/installers/requirements/NugetInstaller.ts +0 -203
- package/src/core/installers/requirements/PipInstaller.ts +0 -207
- package/src/core/installers/requirements/RequirementInstaller.ts +0 -42
- package/src/core/loaders/ConfigurationLoader.ts +0 -298
- package/src/core/loaders/ConfigurationProvider.ts +0 -462
- package/src/core/loaders/InstallOperationManager.ts +0 -367
- package/src/core/loaders/ServerSchemaLoader.ts +0 -117
- package/src/core/loaders/ServerSchemaProvider.ts +0 -99
- package/src/core/loaders/SystemSettingsManager.ts +0 -278
- package/src/core/metadatas/constants.ts +0 -122
- package/src/core/metadatas/recordingConstants.ts +0 -65
- package/src/core/metadatas/types.ts +0 -202
- package/src/core/onboard/FeedOnboardService.ts +0 -501
- package/src/core/onboard/OnboardProcessor.ts +0 -356
- package/src/core/onboard/OnboardStatus.ts +0 -60
- package/src/core/onboard/OnboardStatusManager.ts +0 -416
- package/src/core/validators/FeedValidator.ts +0 -135
- package/src/core/validators/IServerValidator.ts +0 -21
- package/src/core/validators/SSEServerValidator.ts +0 -43
- package/src/core/validators/ServerValidatorFactory.ts +0 -51
- package/src/core/validators/StdioServerValidator.ts +0 -313
- package/src/index.ts +0 -44
- package/src/services/InstallationService.ts +0 -102
- package/src/services/MCPManager.ts +0 -249
- package/src/services/RequirementService.ts +0 -627
- package/src/services/ServerService.ts +0 -161
- package/src/services/TelemetryService.ts +0 -59
- package/src/utils/UpdateCheckTracker.ts +0 -86
- package/src/utils/adoUtils.ts +0 -293
- package/src/utils/clientUtils.ts +0 -72
- package/src/utils/feedUtils.ts +0 -31
- package/src/utils/githubAuth.ts +0 -212
- package/src/utils/githubUtils.ts +0 -164
- package/src/utils/logger.ts +0 -195
- package/src/utils/macroExpressionUtils.ts +0 -104
- package/src/utils/osUtils.ts +0 -700
- package/src/utils/versionUtils.ts +0 -114
- package/src/web/contract/serverContract.ts +0 -74
- package/src/web/public/css/detailsWidget.css +0 -235
- package/src/web/public/css/modal.css +0 -757
- package/src/web/public/css/notifications.css +0 -101
- package/src/web/public/css/onboard.css +0 -107
- package/src/web/public/css/serverCategoryList.css +0 -120
- package/src/web/public/css/serverDetails.css +0 -139
- package/src/web/public/index.html +0 -359
- package/src/web/public/js/api.js +0 -132
- package/src/web/public/js/detailsWidget.js +0 -264
- package/src/web/public/js/flights/flights.js +0 -127
- package/src/web/public/js/modal/index.js +0 -52
- package/src/web/public/js/modal/installModal.js +0 -162
- package/src/web/public/js/modal/installation.js +0 -266
- package/src/web/public/js/modal/loadingModal.js +0 -182
- package/src/web/public/js/modal/modalSetup.js +0 -595
- package/src/web/public/js/modal/modalUtils.js +0 -37
- package/src/web/public/js/modal/versionUtils.js +0 -20
- package/src/web/public/js/modal.js +0 -42
- package/src/web/public/js/notifications.js +0 -137
- package/src/web/public/js/onboard/formProcessor.js +0 -1037
- package/src/web/public/js/onboard/index.js +0 -374
- package/src/web/public/js/onboard/publishHandler.js +0 -172
- package/src/web/public/js/onboard/state.js +0 -76
- package/src/web/public/js/onboard/templates.js +0 -342
- package/src/web/public/js/onboard/uiHandlers.js +0 -1076
- package/src/web/public/js/onboard/validationHandlers.js +0 -493
- package/src/web/public/js/serverCategoryDetails.js +0 -364
- package/src/web/public/js/serverCategoryList.js +0 -241
- package/src/web/public/js/settings.js +0 -314
- package/src/web/public/modal.html +0 -84
- package/src/web/public/onboard.html +0 -296
- package/src/web/public/settings.html +0 -135
- package/src/web/public/styles.css +0 -277
- package/src/web/server.ts +0 -478
- package/tsconfig.json +0 -18
- package/wiki/Installation.md +0 -3
- package/wiki/Publish.md +0 -3
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { fileURLToPath } from 'url';
|
|
3
|
-
import { Logger } from '../utils/logger.js';
|
|
4
|
-
import { ServerSchema, ServerSchemaProvider } from '../core/loaders/ServerSchemaProvider.js';
|
|
5
|
-
import {
|
|
6
|
-
MCPServerCategory,
|
|
7
|
-
ServerInstallOptions,
|
|
8
|
-
ServerCategoryListOptions,
|
|
9
|
-
ServerOperationResult,
|
|
10
|
-
ServerUninstallOptions,
|
|
11
|
-
FeedConfiguration,
|
|
12
|
-
OperationStatus as CoreOperationStatus
|
|
13
|
-
} from '../core/metadatas/types.js';
|
|
14
|
-
import { mcpManager } from './MCPManager.js';
|
|
15
|
-
import { OperationStatus } from '../core/onboard/OnboardStatus.js';
|
|
16
|
-
|
|
17
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* ServerService provides a unified interface for server management operations.
|
|
21
|
-
* This layer handles business logic that's shared between the CLI and web interface.
|
|
22
|
-
*/
|
|
23
|
-
export class ServerService {
|
|
24
|
-
/**
|
|
25
|
-
* Lists available MCP servers based on the provided options
|
|
26
|
-
*/
|
|
27
|
-
async listServerCategories(options: ServerCategoryListOptions = {}): Promise<MCPServerCategory[]> {
|
|
28
|
-
return mcpManager.listServerCategories(options);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Gets a server by name
|
|
33
|
-
*/
|
|
34
|
-
async getServerCategory(categoryName: string): Promise<MCPServerCategory | undefined> {
|
|
35
|
-
const serverCategories = await this.listServerCategories();
|
|
36
|
-
const serverCategory = serverCategories.find(s => s.name === categoryName);
|
|
37
|
-
return serverCategory;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Gets the schema for a specific server in a category
|
|
42
|
-
*/
|
|
43
|
-
async getServerSchema(categoryName: string, serverName: string): Promise<ServerSchema | undefined> {
|
|
44
|
-
try {
|
|
45
|
-
const provider = ServerSchemaProvider.getInstance();
|
|
46
|
-
const serverMcpConfig = await mcpManager.getServerMcpConfig(categoryName, serverName);
|
|
47
|
-
return await provider.getSchema(categoryName, serverMcpConfig?.schemas || `${serverName}.json`);
|
|
48
|
-
} catch (error) {
|
|
49
|
-
Logger.error(`Failed to get schema for server ${serverName} in category ${categoryName}:`, error);
|
|
50
|
-
throw error;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Installs a specific mcp tool for a server.
|
|
56
|
-
*/
|
|
57
|
-
async installMcpServer(
|
|
58
|
-
category: string,
|
|
59
|
-
serverName: string,
|
|
60
|
-
options: ServerInstallOptions = {}
|
|
61
|
-
): Promise<ServerOperationResult> {
|
|
62
|
-
Logger.debug(`Installing MCP server: ${JSON.stringify({ category, serverName, options })}`);
|
|
63
|
-
try {
|
|
64
|
-
const result = await mcpManager.installServer(category, serverName, options);
|
|
65
|
-
Logger.debug(`Installation result: ${JSON.stringify(result)}`);
|
|
66
|
-
return result;
|
|
67
|
-
} catch (error) {
|
|
68
|
-
Logger.error(`Failed to install MCP server: ${serverName}`, error);
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Uninstall MCP server from specified client targets
|
|
75
|
-
* @param category The server category
|
|
76
|
-
* @param serverName The server name to uninstall
|
|
77
|
-
* @param options Uninstall options including target clients and data removal flags
|
|
78
|
-
*/
|
|
79
|
-
async uninstallMcpServer(
|
|
80
|
-
category: string,
|
|
81
|
-
serverName: string,
|
|
82
|
-
options: ServerUninstallOptions = {}
|
|
83
|
-
): Promise<ServerOperationResult> {
|
|
84
|
-
Logger.debug(`Uninstalling MCP server: ${JSON.stringify({ category, serverName, options })}`);
|
|
85
|
-
try {
|
|
86
|
-
const result = await mcpManager.uninstallServer(category, serverName, options);
|
|
87
|
-
Logger.debug(`Uninstallation result: ${JSON.stringify(result)}`);
|
|
88
|
-
return result;
|
|
89
|
-
} catch (error) {
|
|
90
|
-
Logger.error(`Failed to uninstall MCP server: ${serverName}`, error);
|
|
91
|
-
throw error;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Validates server names
|
|
97
|
-
*/
|
|
98
|
-
async validateServerName(category: string, names: string | string[]): Promise<boolean> {
|
|
99
|
-
const serverNames = Array.isArray(names) ? names : [names];
|
|
100
|
-
Logger.debug(`Validating server names: ${JSON.stringify({ category, names: serverNames })}`);
|
|
101
|
-
|
|
102
|
-
// Check if category exists in feeds
|
|
103
|
-
const feedConfig = await mcpManager.getFeedConfiguration(category);
|
|
104
|
-
if (!feedConfig) {
|
|
105
|
-
Logger.debug(`Validation failed: Category "${category}" not found in feeds`);
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Check if all servers exist in the category's mcpServers
|
|
110
|
-
const invalidServers = serverNames.filter(name =>
|
|
111
|
-
!feedConfig.mcpServers.some(server => server.name === name)
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
if (invalidServers.length > 0) {
|
|
115
|
-
Logger.debug(`Validation failed: Servers "${invalidServers.join(', ')}" not found in category "${category}"`);
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Formats success/error messages for operations
|
|
124
|
-
*/
|
|
125
|
-
formatOperationResults(results: ServerOperationResult[]): {
|
|
126
|
-
success: boolean;
|
|
127
|
-
messages: string[];
|
|
128
|
-
} {
|
|
129
|
-
return {
|
|
130
|
-
success: results.every(r => r.success),
|
|
131
|
-
messages: results.map(r => r.message).filter((m): m is string => m !== undefined)
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Syncs MCP server configurations from remote feed source
|
|
137
|
-
*/
|
|
138
|
-
async syncFeeds(): Promise<void> {
|
|
139
|
-
return mcpManager.syncFeeds();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Onboards a new feed configuration
|
|
144
|
-
* @param config Feed configuration to onboard
|
|
145
|
-
*/
|
|
146
|
-
async onboardFeed(config: FeedConfiguration): Promise<OperationStatus & { feedConfiguration?: FeedConfiguration }> {
|
|
147
|
-
try {
|
|
148
|
-
const result = await mcpManager.onboardFeed(config);
|
|
149
|
-
// Log based on the operation status, e.g., if it's pending or succeeded.
|
|
150
|
-
// The actual "success" of onboarding is a multi-step process (PR creation, merge).
|
|
151
|
-
Logger.log(`Feed onboarding process for '${config.name}' initiated with status: ${result.status}, ID: ${result.onboardingId}`);
|
|
152
|
-
return result;
|
|
153
|
-
} catch (error) {
|
|
154
|
-
Logger.error(`Failed to initiate feed onboarding for '${config.name}':`, error);
|
|
155
|
-
throw error; // Or return a specific error status object
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// Export a singleton instance
|
|
161
|
-
export const serverService = new ServerService();
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import * as appInsights from 'applicationinsights';
|
|
2
|
-
|
|
3
|
-
export class TelemetryService {
|
|
4
|
-
private static client: appInsights.TelemetryClient | null = null;
|
|
5
|
-
private static readonly instrumentationKey = 'InstrumentationKey=c5fc06c7-a96c-4d80-9aff-bc9c933db0d1';
|
|
6
|
-
|
|
7
|
-
static {
|
|
8
|
-
// Initialize Application Insights
|
|
9
|
-
try {
|
|
10
|
-
const client = new appInsights.TelemetryClient(TelemetryService.instrumentationKey);
|
|
11
|
-
client.config.disableAppInsights = false;
|
|
12
|
-
client.config.maxBatchSize = 250;
|
|
13
|
-
client.context.tags[client.context.keys.cloudRole] = 'imcp';
|
|
14
|
-
TelemetryService.client = client;
|
|
15
|
-
console.log('Application Insights initialized');
|
|
16
|
-
} catch (error) {
|
|
17
|
-
console.error('Failed to initialize Application Insights:', error);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static trackEvent(name: string, properties?: { [key: string]: string }): void {
|
|
22
|
-
if (!this.client) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
this.client.trackEvent({ name, properties });
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static trackException(error: Error, properties?: { [key: string]: string }): void {
|
|
29
|
-
if (!this.client) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
this.client.trackException({ exception: error, properties });
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static trackTrace(message: string, properties?: { [key: string]: string }): void {
|
|
36
|
-
if (!this.client) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
this.client.trackTrace({ message, properties });
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static trackMetric(name: string, value: number): void {
|
|
43
|
-
if (!this.client) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
this.client.trackMetric({ name, value });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static flush(): Promise<void> {
|
|
50
|
-
return new Promise((resolve) => {
|
|
51
|
-
if (!this.client) {
|
|
52
|
-
resolve();
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
this.client.flush();
|
|
56
|
-
resolve();
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility class to track update check operations in progress
|
|
3
|
-
* Provides thread-safe access to check status with proper locking
|
|
4
|
-
*/
|
|
5
|
-
export class UpdateCheckTracker {
|
|
6
|
-
private static instance: UpdateCheckTracker;
|
|
7
|
-
|
|
8
|
-
// Map to track operations in progress (key -> inProgress)
|
|
9
|
-
private operationsInProgress: Map<string, boolean> = new Map();
|
|
10
|
-
|
|
11
|
-
// Lock for thread safety when checking/updating the in-progress map
|
|
12
|
-
private operationsLock: Promise<void> = Promise.resolve();
|
|
13
|
-
|
|
14
|
-
private constructor() { }
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Get the singleton instance of the tracker
|
|
18
|
-
*/
|
|
19
|
-
public static getInstance(): UpdateCheckTracker {
|
|
20
|
-
if (!UpdateCheckTracker.instance) {
|
|
21
|
-
UpdateCheckTracker.instance = new UpdateCheckTracker();
|
|
22
|
-
}
|
|
23
|
-
return UpdateCheckTracker.instance;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Execute an operation with a lock to ensure thread safety
|
|
28
|
-
* @param operation The operation to execute
|
|
29
|
-
* @returns The result of the operation
|
|
30
|
-
* @private
|
|
31
|
-
*/
|
|
32
|
-
private async withLock<T>(operation: () => Promise<T>): Promise<T> {
|
|
33
|
-
const current = this.operationsLock;
|
|
34
|
-
let resolve: () => void;
|
|
35
|
-
this.operationsLock = new Promise<void>(r => resolve = r);
|
|
36
|
-
try {
|
|
37
|
-
await current;
|
|
38
|
-
return await operation();
|
|
39
|
-
} finally {
|
|
40
|
-
resolve!();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Check if an operation can be started and mark it as in progress if so
|
|
46
|
-
* @param key The key to identify the operation
|
|
47
|
-
* @returns True if the operation can be started, false if already in progress
|
|
48
|
-
*/
|
|
49
|
-
async startOperation(key: string): Promise<boolean> {
|
|
50
|
-
return await this.withLock(async () => {
|
|
51
|
-
if (!this.operationsInProgress.get(key)) {
|
|
52
|
-
this.operationsInProgress.set(key, true);
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Mark an operation as complete
|
|
61
|
-
* @param key The key to identify the operation
|
|
62
|
-
*/
|
|
63
|
-
async endOperation(key: string): Promise<void> {
|
|
64
|
-
try {
|
|
65
|
-
await this.withLock(async () => {
|
|
66
|
-
this.operationsInProgress.set(key, false);
|
|
67
|
-
});
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.error(`Failed to end operation for key: ${key}`, error);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Check if an operation is in progress
|
|
75
|
-
* @param key The key to identify the operation
|
|
76
|
-
* @returns True if the operation is in progress
|
|
77
|
-
*/
|
|
78
|
-
async isOperationInProgress(key: string): Promise<boolean> {
|
|
79
|
-
return await this.withLock(async () => {
|
|
80
|
-
return !!this.operationsInProgress.get(key);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Export a singleton instance
|
|
86
|
-
export const updateCheckTracker = UpdateCheckTracker.getInstance();
|
package/src/utils/adoUtils.ts
DELETED
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
import { RequirementConfig, RegistryConfig } from '../core/metadatas/types.js';
|
|
2
|
-
import { SETTINGS_DIR } from '../core/metadatas/constants.js';
|
|
3
|
-
import { Logger } from './logger.js';
|
|
4
|
-
import { exec, execSync } from 'child_process';
|
|
5
|
-
import util from 'util';
|
|
6
|
-
import fs from 'fs/promises';
|
|
7
|
-
import path from 'path';
|
|
8
|
-
import { isToolInstalled } from './osUtils.js'; // Assuming this can be adapted or a similar check is fine
|
|
9
|
-
|
|
10
|
-
const execAsync = util.promisify(exec);
|
|
11
|
-
|
|
12
|
-
export interface AdoArtifactResult {
|
|
13
|
-
type: 'npm' | 'pip';
|
|
14
|
-
package: string;
|
|
15
|
-
registryUrl: string;
|
|
16
|
-
folderPath?: string; // Only for npm
|
|
17
|
-
version: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Sets up the NPM credential provider.
|
|
22
|
-
* Installs @microsoft/artifacts-npm-credprovider if not already installed.
|
|
23
|
-
* @private
|
|
24
|
-
*/
|
|
25
|
-
async function _setupNpmCredentialProvider(): Promise<void> {
|
|
26
|
-
Logger.debug('Setting up NPM credential provider...');
|
|
27
|
-
const credProviderCommand = 'artifacts-npm-credprovider';
|
|
28
|
-
|
|
29
|
-
// Check if artifacts-npm-credprovider is installed by trying to get its version or a known command.
|
|
30
|
-
// A more robust check might involve checking a specific version or path.
|
|
31
|
-
let installed = false;
|
|
32
|
-
try {
|
|
33
|
-
// Attempt to get help output as a basic check for presence
|
|
34
|
-
const { stdout, stderr } = await execAsync(`${credProviderCommand} --help`);
|
|
35
|
-
Logger.debug(`${credProviderCommand} --help stdout: ${stdout}`);
|
|
36
|
-
if (stderr) Logger.debug(`${credProviderCommand} --help stderr: ${stderr}`);
|
|
37
|
-
installed = true;
|
|
38
|
-
Logger.debug(`${credProviderCommand} appears to be installed.`);
|
|
39
|
-
} catch (e) {
|
|
40
|
-
Logger.debug(`${credProviderCommand} not found or --help failed, attempting installation. Error: ${e}`);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (!installed) {
|
|
44
|
-
Logger.log(`Installing @microsoft/artifacts-npm-credprovider...`);
|
|
45
|
-
try {
|
|
46
|
-
const installCommand = `npm install -g @microsoft/artifacts-npm-credprovider --registry https://pkgs.dev.azure.com/mseng/226da8e7-b1c0-4167-9678-53f461e07706/_packaging/AzureArtifacts/npm/registry/`;
|
|
47
|
-
const { stdout: installStdout, stderr: installStderr } = await execAsync(installCommand);
|
|
48
|
-
Logger.debug(`@microsoft/artifacts-npm-credprovider install stdout: ${installStdout}`);
|
|
49
|
-
if (installStderr) Logger.debug(`@microsoft/artifacts-npm-credprovider install stderr: ${installStderr}`);
|
|
50
|
-
Logger.log('@microsoft/artifacts-npm-credprovider installed successfully.');
|
|
51
|
-
} catch (error) {
|
|
52
|
-
Logger.error('Failed to install @microsoft/artifacts-npm-credprovider', error);
|
|
53
|
-
throw new Error(`Failed to install @microsoft/artifacts-npm-credprovider: ${error instanceof Error ? error.message : String(error)}`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Installs pip requirements: keyring and artifacts-keyring.
|
|
60
|
-
* @param pythonCommand The python command to use (e.g., 'python' or 'python3').
|
|
61
|
-
* @private
|
|
62
|
-
*/
|
|
63
|
-
async function _installPipRequirements(pythonCommand: string): Promise<void> {
|
|
64
|
-
Logger.debug(`Installing pip requirements: keyring, artifacts-keyring using ${pythonCommand}`);
|
|
65
|
-
try {
|
|
66
|
-
const command = `${pythonCommand} -m pip install keyring artifacts-keyring`;
|
|
67
|
-
const { stdout, stderr } = await execAsync(command);
|
|
68
|
-
Logger.debug(`pip install keyring artifacts-keyring stdout: ${stdout}`);
|
|
69
|
-
if (stderr) Logger.debug(`pip install keyring artifacts-keyring stderr: ${stderr}`);
|
|
70
|
-
Logger.log('Successfully installed keyring and artifacts-keyring.');
|
|
71
|
-
} catch (error) {
|
|
72
|
-
Logger.error('Failed to install pip requirements (keyring, artifacts-keyring)', error);
|
|
73
|
-
throw new Error(`Failed to install pip requirements: ${error instanceof Error ? error.message : String(error)}`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Configures NPM authentication for Azure DevOps Artifacts in a specified directory.
|
|
79
|
-
* This includes setting up the credential provider, creating an .npmrc file,
|
|
80
|
-
* and running the credential provider.
|
|
81
|
-
* @param execPromise The promise-based exec function.
|
|
82
|
-
* @param registry The Azure DevOps artifacts registry configuration.
|
|
83
|
-
* @param directoryPath The directory where .npmrc will be created and commands will be executed.
|
|
84
|
-
* @private
|
|
85
|
-
*/
|
|
86
|
-
async function _configureNpmAdoAuthInDirectory(
|
|
87
|
-
execPromise: (command: string, options?: { cwd?: string; env?: NodeJS.ProcessEnv }) => Promise<{ stdout: string; stderr: string }>,
|
|
88
|
-
registry: RegistryConfig['artifacts'],
|
|
89
|
-
directoryPath: string
|
|
90
|
-
): Promise<void> {
|
|
91
|
-
if (!registry || !registry.registryUrl || !registry.registryName) {
|
|
92
|
-
throw new Error('Registry name and URL are required for NPM ADO auth configuration.');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
await _setupNpmCredentialProvider();
|
|
96
|
-
|
|
97
|
-
const npmrcContent = `@${registry.registryName}:registry=${registry.registryUrl}\nalways-auth=true`;
|
|
98
|
-
const npmrcPath = path.join(directoryPath, '.npmrc');
|
|
99
|
-
await fs.writeFile(npmrcPath, npmrcContent.trim());
|
|
100
|
-
Logger.debug(`Created/Updated .npmrc file at: ${npmrcPath}`);
|
|
101
|
-
|
|
102
|
-
const env = { ...process.env, NUGET_CREDENTIALPROVIDER_VSTS_TOKENTYPE: 'SelfDescribing' };
|
|
103
|
-
Logger.debug(`Running artifacts-npm-credprovider in ${directoryPath}`);
|
|
104
|
-
const { stdout: credProviderStdout, stderr: credProviderStderr } = await execPromise('artifacts-npm-credprovider', { cwd: directoryPath, env });
|
|
105
|
-
Logger.debug(`artifacts-npm-credprovider stdout: ${credProviderStdout}`);
|
|
106
|
-
if (credProviderStderr) Logger.debug(`artifacts-npm-credprovider stderr: ${credProviderStderr}`);
|
|
107
|
-
Logger.log(`Successfully ran artifacts-npm-credprovider in ${directoryPath}`);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Handles fetching and setting up an Azure DevOps artifact.
|
|
112
|
-
* @param requirement The requirement configuration.
|
|
113
|
-
* @param registry The Azure DevOps artifacts registry configuration.
|
|
114
|
-
* @param pythonCommand Optional Python command (e.g., 'python', 'python3') for pip operations.
|
|
115
|
-
* @param targetDir Optional target directory for npm artifact setup. If not provided, a default will be used.
|
|
116
|
-
* @returns A promise that resolves with the artifact details.
|
|
117
|
-
*/
|
|
118
|
-
export async function handleArtifact(
|
|
119
|
-
requirement: RequirementConfig,
|
|
120
|
-
registry: RegistryConfig['artifacts'],
|
|
121
|
-
pythonCommand: string = 'python', // Default to 'python' if not provided
|
|
122
|
-
targetDir?: string // Optional target directory for npm
|
|
123
|
-
): Promise<AdoArtifactResult> {
|
|
124
|
-
if (!registry) {
|
|
125
|
-
throw new Error('Azure DevOps artifacts registry configuration is required.');
|
|
126
|
-
}
|
|
127
|
-
Logger.debug(`Handling ADO artifact for requirement: ${requirement.name}, type: ${requirement.type}`);
|
|
128
|
-
|
|
129
|
-
if (requirement.type === 'npm') {
|
|
130
|
-
if (!registry.registryName || !registry.registryUrl) {
|
|
131
|
-
throw new Error('Registry name and URL are required for NPM source in Azure DevOps artifacts.');
|
|
132
|
-
}
|
|
133
|
-
const requirementDir = targetDir || path.join(SETTINGS_DIR, 'requirements', requirement.name, requirement.version);
|
|
134
|
-
await fs.mkdir(requirementDir, { recursive: true });
|
|
135
|
-
Logger.debug(`Ensured directory for npm requirement: ${requirementDir}`);
|
|
136
|
-
|
|
137
|
-
try {
|
|
138
|
-
await _configureNpmAdoAuthInDirectory(execAsync, registry, requirementDir);
|
|
139
|
-
Logger.log(`Successfully configured ADO NPM auth for ${requirement.name} in ${requirementDir}`);
|
|
140
|
-
|
|
141
|
-
const version = requirement.version.includes('latest') ? 'latest' : requirement.version;
|
|
142
|
-
return {
|
|
143
|
-
folderPath: requirementDir,
|
|
144
|
-
type: 'npm',
|
|
145
|
-
package: `@${registry.registryName}/${requirement.name}`,
|
|
146
|
-
registryUrl: registry.registryUrl,
|
|
147
|
-
version: version
|
|
148
|
-
};
|
|
149
|
-
} catch (error) {
|
|
150
|
-
Logger.error(`Failed to configure ADO NPM auth for ${requirement.name} in ${requirementDir}`, error);
|
|
151
|
-
throw new Error(`ADO NPM auth configuration failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
} else if (requirement.type === 'pip') {
|
|
155
|
-
if (!registry.registryUrl) {
|
|
156
|
-
throw new Error('Registry URL are required for PIP source in Azure DevOps artifacts.');
|
|
157
|
-
}
|
|
158
|
-
await _installPipRequirements(pythonCommand);
|
|
159
|
-
|
|
160
|
-
const packageName = requirement.version.toLowerCase().includes('latest')
|
|
161
|
-
? `${requirement.name} --upgrade`
|
|
162
|
-
: `${requirement.name}==${requirement.version}`;
|
|
163
|
-
|
|
164
|
-
Logger.log(`Pip requirement ${packageName} configured with registry ${registry.registryUrl}`);
|
|
165
|
-
return {
|
|
166
|
-
type: 'pip',
|
|
167
|
-
package: packageName,
|
|
168
|
-
registryUrl: registry.registryUrl,
|
|
169
|
-
version: requirement.version
|
|
170
|
-
};
|
|
171
|
-
} else {
|
|
172
|
-
throw new Error(`Unsupported requirement type for ADO artifact: ${requirement.type}`);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Get the latest version of an artifact from Azure DevOps.
|
|
178
|
-
* This is a simplified implementation and might require further enhancements for robust authentication and error handling.
|
|
179
|
-
* @param execPromise The promise-based exec function.
|
|
180
|
-
* @param requirement The requirement configuration.
|
|
181
|
-
* @param registry The Azure DevOps artifacts registry configuration.
|
|
182
|
-
* @param options Optional server install options (e.g., for pythonCommand).
|
|
183
|
-
* @returns The latest version string, or undefined if not found or an error occurs.
|
|
184
|
-
*/
|
|
185
|
-
export async function getArtifactLatestVersion(
|
|
186
|
-
requirement: RequirementConfig,
|
|
187
|
-
registry: RegistryConfig['artifacts'],
|
|
188
|
-
options?: import('../core/metadatas/types.js').ServerInstallOptions, // Added import for ServerInstallOptions
|
|
189
|
-
targetDir?: string // Optional target directory for npm
|
|
190
|
-
): Promise<string | undefined> {
|
|
191
|
-
if (!registry || !registry.registryUrl) {
|
|
192
|
-
Logger.error('ADO Artifact registry URL is missing for fetching latest version.');
|
|
193
|
-
return undefined;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
Logger.debug(`Attempting to fetch latest version for ADO artifact: ${requirement.name} of type ${requirement.type}`);
|
|
197
|
-
|
|
198
|
-
if (requirement.type === 'npm') {
|
|
199
|
-
if (!registry.registryName) { // Ensure registryName is present
|
|
200
|
-
Logger.error('NPM ADO Artifact registry name is missing for fetching latest version.');
|
|
201
|
-
return undefined;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const requirementDir = targetDir || path.join(SETTINGS_DIR, 'requirements', requirement.name, requirement.version);
|
|
205
|
-
|
|
206
|
-
try {
|
|
207
|
-
await fs.mkdir(requirementDir, { recursive: true });
|
|
208
|
-
Logger.debug(`Ensured directory for NPM ADO version check: ${requirementDir}`);
|
|
209
|
-
|
|
210
|
-
// Configure auth within the requirementDir
|
|
211
|
-
await _configureNpmAdoAuthInDirectory(execAsync, registry, requirementDir);
|
|
212
|
-
Logger.log(`Successfully configured ADO NPM auth for version check of ${requirement.name} in ${requirementDir}`);
|
|
213
|
-
|
|
214
|
-
const fullPackageName = `@${registry.registryName}/${requirement.name}`;
|
|
215
|
-
const command = `npm view ${fullPackageName} version --registry ${registry.registryUrl}`;
|
|
216
|
-
Logger.debug(`Executing for NPM ADO latest version: ${command} in ${requirementDir}`);
|
|
217
|
-
|
|
218
|
-
const { stdout, stderr } = await execAsync(command, { cwd: requirementDir });
|
|
219
|
-
|
|
220
|
-
if (stderr && !stdout.trim()) {
|
|
221
|
-
Logger.error(`Error fetching NPM ADO version for ${fullPackageName} via npm view: ${stderr}`);
|
|
222
|
-
return undefined;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const version = stdout.trim();
|
|
226
|
-
if (version) {
|
|
227
|
-
Logger.debug(`Found latest NPM ADO version for ${fullPackageName}: ${version}`);
|
|
228
|
-
return version;
|
|
229
|
-
} else {
|
|
230
|
-
Logger.log(`Could not parse latest NPM version from ADO for ${fullPackageName} from output: '${stdout}'`);
|
|
231
|
-
return undefined;
|
|
232
|
-
}
|
|
233
|
-
} catch (error) {
|
|
234
|
-
Logger.error(`Exception fetching latest NPM version from ADO for ${requirement.name} in ${requirementDir}: ${error instanceof Error ? error.message : String(error)}`);
|
|
235
|
-
return undefined;
|
|
236
|
-
}
|
|
237
|
-
} else if (requirement.type === 'pip') {
|
|
238
|
-
try {
|
|
239
|
-
const pythonCmd = options?.settings?.pythonEnv as string || 'python';
|
|
240
|
-
const pipCmd = `${pythonCmd} -m pip`;
|
|
241
|
-
|
|
242
|
-
// Ensure keyring and artifacts-keyring are installed.
|
|
243
|
-
// This is usually handled by `handleArtifact` during install.
|
|
244
|
-
// For a standalone version check, we might need to ensure they exist.
|
|
245
|
-
// Consider calling _installPipRequirements(pythonCmd) if necessary, but it has side effects.
|
|
246
|
-
// For now, assume they are present if ADO pip artifacts are being used.
|
|
247
|
-
|
|
248
|
-
const command = `${pipCmd} index versions ${requirement.name} --extra-index-url ${registry.registryUrl}`;
|
|
249
|
-
Logger.debug(`Executing for Pip ADO latest version: ${command}`);
|
|
250
|
-
const { stdout, stderr } = await execAsync(command);
|
|
251
|
-
|
|
252
|
-
if (stderr && !stdout.trim()) { // If there's stderr and no significant stdout, it's likely an error
|
|
253
|
-
Logger.error(`Error fetching Pip ADO version for ${requirement.name}: ${stderr}`);
|
|
254
|
-
return undefined;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// Parse output like:
|
|
258
|
-
// mypackage (1.0.0)
|
|
259
|
-
// Available versions: 1.0.0, 0.9.0
|
|
260
|
-
// LATEST: 1.0.0
|
|
261
|
-
// Or:
|
|
262
|
-
// mypackage
|
|
263
|
-
// VERSIONS: 1.0.0, 0.9.0
|
|
264
|
-
// Latest: 1.0.0
|
|
265
|
-
const latestMatch = stdout.match(/(?:LATEST|Latest):\s*([^\s]+)/);
|
|
266
|
-
if (latestMatch && latestMatch[1]) {
|
|
267
|
-
Logger.debug(`Found latest Pip ADO version via LATEST line: ${latestMatch[1]}`);
|
|
268
|
-
return latestMatch[1];
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// Fallback: try to parse from "Available versions" or "VERSIONS"
|
|
272
|
-
const versionsMatch = stdout.match(/(?:Available versions|VERSIONS):\s*([^\n]+)/);
|
|
273
|
-
if (versionsMatch && versionsMatch[1]) {
|
|
274
|
-
const versions = versionsMatch[1].split(',').map(v => v.trim()).filter(v => v);
|
|
275
|
-
if (versions.length > 0) {
|
|
276
|
-
// This is a naive approach, assumes the first listed is relevant or latest.
|
|
277
|
-
// Proper sorting (e.g. semver) would be better.
|
|
278
|
-
Logger.debug(`Found Pip ADO versions: ${versions.join(', ')}. Taking the first one: ${versions[0]}`);
|
|
279
|
-
return versions[0];
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
Logger.log(`Could not parse latest Pip version from ADO for ${requirement.name} from output: ${stdout}`); // Changed Logger.warn to Logger.log
|
|
284
|
-
return undefined;
|
|
285
|
-
} catch (error) {
|
|
286
|
-
Logger.error(`Exception fetching latest Pip version from ADO for ${requirement.name}: ${error instanceof Error ? error.message : String(error)}`);
|
|
287
|
-
return undefined;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
Logger.log(`getArtifactLatestVersion not implemented for type '${requirement.type}' or encountered an issue.`); // Changed Logger.warn to Logger.log
|
|
292
|
-
return undefined;
|
|
293
|
-
}
|
package/src/utils/clientUtils.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import extractZipModule from 'extract-zip';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Extract a zip file to a directory
|
|
7
|
-
* @param zipPath The path to the zip file
|
|
8
|
-
* @param options Extraction options
|
|
9
|
-
* @returns A promise that resolves when extraction is complete
|
|
10
|
-
*/
|
|
11
|
-
export async function extractZipFile(zipPath: string, options: { dir: string }): Promise<void> {
|
|
12
|
-
try {
|
|
13
|
-
// Try to use extract-zip if available
|
|
14
|
-
if (typeof extractZipModule === 'function') {
|
|
15
|
-
return await extractZipModule(zipPath, options);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Fallback to Node.js built-in unzipper
|
|
19
|
-
const fs = require('fs');
|
|
20
|
-
const unzipper = require('unzipper');
|
|
21
|
-
|
|
22
|
-
await fs.promises.mkdir(options.dir, { recursive: true });
|
|
23
|
-
|
|
24
|
-
return new Promise<void>((resolve, reject) => {
|
|
25
|
-
fs.createReadStream(zipPath)
|
|
26
|
-
.pipe(unzipper.Extract({ path: options.dir }))
|
|
27
|
-
.on('close', resolve)
|
|
28
|
-
.on('error', reject);
|
|
29
|
-
});
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.error(`Error extracting zip: ${error instanceof Error ? error.message : String(error)}`);
|
|
32
|
-
throw new Error(`Failed to extract zip file ${zipPath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Reads a JSON file and parses its content
|
|
39
|
-
* @param filePath Path to the JSON file
|
|
40
|
-
* @param createIfNotExist Whether to create the file if it doesn't exist
|
|
41
|
-
* @returns The parsed JSON content
|
|
42
|
-
*/
|
|
43
|
-
import stripJsonComments from 'strip-json-comments';
|
|
44
|
-
|
|
45
|
-
export async function readJsonFile(filePath: string, createIfNotExist = false): Promise<any> {
|
|
46
|
-
try {
|
|
47
|
-
// Ensure directory exists
|
|
48
|
-
if (createIfNotExist) {
|
|
49
|
-
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const content = await fs.readFile(filePath, 'utf8');
|
|
53
|
-
// Remove comments and trailing commas from JSON content
|
|
54
|
-
const sanitizedContent = stripJsonComments(content).replace(/,(\s*[}\]])/g, '$1');
|
|
55
|
-
return JSON.parse(sanitizedContent);
|
|
56
|
-
} catch (error) {
|
|
57
|
-
if ((error as NodeJS.ErrnoException).code === 'ENOENT' && createIfNotExist) {
|
|
58
|
-
return {};
|
|
59
|
-
}
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Writes content to a JSON file
|
|
66
|
-
* @param filePath Path to the JSON file
|
|
67
|
-
* @param content Content to write to the file
|
|
68
|
-
*/
|
|
69
|
-
export async function writeJsonFile(filePath: string, content: any): Promise<void> {
|
|
70
|
-
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
71
|
-
await fs.writeFile(filePath, JSON.stringify(content, null, 2), 'utf8');
|
|
72
|
-
}
|