imcp 0.0.4 → 0.0.6
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 +3 -4
- package/dist/cli/commands/install.js +2 -0
- package/dist/cli/commands/list.js +1 -0
- package/dist/cli/index.js +1 -2
- package/dist/core/ConfigurationLoader.d.ts +32 -0
- package/dist/core/ConfigurationLoader.js +213 -0
- package/dist/core/ConfigurationProvider.d.ts +2 -3
- package/dist/core/ConfigurationProvider.js +13 -182
- package/dist/core/InstallationService.d.ts +8 -0
- package/dist/core/InstallationService.js +124 -96
- package/dist/core/RequirementService.d.ts +1 -1
- package/dist/core/RequirementService.js +5 -9
- package/dist/core/constants.js +14 -1
- package/dist/core/installers/BaseInstaller.d.ts +5 -4
- package/dist/core/installers/BaseInstaller.js +17 -28
- package/dist/core/installers/ClientInstaller.js +134 -43
- package/dist/core/installers/CommandInstaller.d.ts +1 -0
- package/dist/core/installers/CommandInstaller.js +3 -0
- package/dist/core/installers/GeneralInstaller.d.ts +1 -0
- package/dist/core/installers/GeneralInstaller.js +3 -0
- package/dist/core/installers/InstallerFactory.d.ts +9 -7
- package/dist/core/installers/InstallerFactory.js +10 -8
- package/dist/core/installers/NpmInstaller.d.ts +1 -0
- package/dist/core/installers/NpmInstaller.js +3 -0
- package/dist/core/installers/PipInstaller.d.ts +6 -3
- package/dist/core/installers/PipInstaller.js +21 -8
- package/dist/core/installers/RequirementInstaller.d.ts +4 -3
- package/dist/core/installers/clients/ClientInstaller.d.ts +23 -0
- package/dist/core/installers/clients/ClientInstaller.js +573 -0
- package/dist/core/installers/clients/ExtensionInstaller.d.ts +26 -0
- package/dist/core/installers/clients/ExtensionInstaller.js +149 -0
- package/dist/core/installers/index.d.ts +8 -6
- package/dist/core/installers/index.js +8 -6
- package/dist/core/installers/requirements/BaseInstaller.d.ts +59 -0
- package/dist/core/installers/requirements/BaseInstaller.js +168 -0
- package/dist/core/installers/requirements/CommandInstaller.d.ts +37 -0
- package/dist/core/installers/requirements/CommandInstaller.js +173 -0
- package/dist/core/installers/requirements/GeneralInstaller.d.ts +33 -0
- package/dist/core/installers/requirements/GeneralInstaller.js +86 -0
- package/dist/core/installers/requirements/InstallerFactory.d.ts +54 -0
- package/dist/core/installers/requirements/InstallerFactory.js +97 -0
- package/dist/core/installers/requirements/NpmInstaller.d.ts +26 -0
- package/dist/core/installers/requirements/NpmInstaller.js +128 -0
- package/dist/core/installers/requirements/PipInstaller.d.ts +28 -0
- package/dist/core/installers/requirements/PipInstaller.js +128 -0
- package/{src/core/installers/RequirementInstaller.ts → dist/core/installers/requirements/RequirementInstaller.d.ts} +33 -38
- package/dist/core/installers/requirements/RequirementInstaller.js +3 -0
- package/dist/core/types.d.ts +4 -1
- package/dist/services/ServerService.js +1 -1
- package/dist/utils/githubUtils.d.ts +11 -0
- package/dist/utils/githubUtils.js +88 -0
- package/dist/utils/osUtils.d.ts +17 -0
- package/dist/utils/osUtils.js +184 -0
- package/dist/web/public/css/modal.css +97 -3
- package/dist/web/public/index.html +21 -2
- package/dist/web/public/js/modal.js +177 -28
- package/dist/web/public/js/serverCategoryDetails.js +12 -10
- package/dist/web/public/js/serverCategoryList.js +62 -12
- package/dist/web/public/modal.html +27 -13
- package/package.json +1 -1
- package/src/cli/commands/install.ts +4 -2
- package/src/cli/commands/list.ts +1 -0
- package/src/cli/index.ts +1 -1
- package/src/core/ConfigurationLoader.ts +251 -0
- package/src/core/ConfigurationProvider.ts +13 -195
- package/src/core/InstallationService.ts +140 -106
- package/src/core/RequirementService.ts +5 -10
- package/src/core/constants.ts +15 -1
- package/src/core/installers/{ClientInstaller.ts → clients/ClientInstaller.ts} +157 -51
- package/src/core/installers/clients/ExtensionInstaller.ts +162 -0
- package/src/core/installers/index.ts +9 -7
- package/src/core/installers/{BaseInstaller.ts → requirements/BaseInstaller.ts} +10 -118
- package/src/core/installers/{CommandInstaller.ts → requirements/CommandInstaller.ts} +7 -3
- package/src/core/installers/{GeneralInstaller.ts → requirements/GeneralInstaller.ts} +6 -2
- package/src/core/installers/{InstallerFactory.ts → requirements/InstallerFactory.ts} +11 -9
- package/src/core/installers/{NpmInstaller.ts → requirements/NpmInstaller.ts} +7 -4
- package/src/core/installers/{PipInstaller.ts → requirements/PipInstaller.ts} +26 -10
- package/src/core/installers/requirements/RequirementInstaller.ts +41 -0
- package/src/core/types.ts +4 -1
- package/src/services/ServerService.ts +1 -1
- package/src/utils/githubUtils.ts +103 -0
- package/src/utils/osUtils.ts +206 -15
- package/src/web/public/css/modal.css +97 -3
- package/src/web/public/index.html +21 -2
- package/src/web/public/js/modal.js +177 -28
- package/src/web/public/js/serverCategoryDetails.js +12 -10
- package/src/web/public/js/serverCategoryList.js +62 -12
- package/src/web/public/modal.html +27 -13
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { BaseInstaller } from './BaseInstaller.js';
|
|
2
|
+
import { handleGitHubRelease } from '../../../utils/githubUtils.js';
|
|
3
|
+
/**
|
|
4
|
+
* Installer implementation for general requirements (type 'other')
|
|
5
|
+
* This installer handles requirements that don't fit into specific package manager categories
|
|
6
|
+
*/
|
|
7
|
+
export class GeneralInstaller extends BaseInstaller {
|
|
8
|
+
/**
|
|
9
|
+
* Check if this installer can handle the given requirement type
|
|
10
|
+
* @param requirement The requirement to check
|
|
11
|
+
* @returns True if this installer can handle the requirement
|
|
12
|
+
*/
|
|
13
|
+
canHandle(requirement) {
|
|
14
|
+
return requirement.type === 'other';
|
|
15
|
+
}
|
|
16
|
+
supportCheckUpdates() {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Check if the requirement is already installed
|
|
21
|
+
* For general installers, we can't easily check if something is installed
|
|
22
|
+
* without specific knowledge of the requirement, so we always return false
|
|
23
|
+
*
|
|
24
|
+
* @param requirement The requirement to check
|
|
25
|
+
* @returns The status of the requirement
|
|
26
|
+
*/
|
|
27
|
+
async checkInstallation(requirement) {
|
|
28
|
+
// For general installers, we can't easily check if something is installed
|
|
29
|
+
// So we'll always return not installed, and the actual installation will check
|
|
30
|
+
return {
|
|
31
|
+
name: requirement.name,
|
|
32
|
+
type: 'other',
|
|
33
|
+
installed: false,
|
|
34
|
+
inProgress: false
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Install the general requirement
|
|
39
|
+
* For type 'other', this doesn't actually install anything, but downloads
|
|
40
|
+
* or locates the asset and returns the path for the caller to use
|
|
41
|
+
*
|
|
42
|
+
* @param requirement The requirement to install
|
|
43
|
+
* @returns The status of the installation, including the install path in updateInfo
|
|
44
|
+
*/
|
|
45
|
+
async install(requirement) {
|
|
46
|
+
try {
|
|
47
|
+
// For type 'other', a registry must be specified
|
|
48
|
+
if (!requirement.registry) {
|
|
49
|
+
throw new Error('Registry must be specified for requirement type "other"');
|
|
50
|
+
}
|
|
51
|
+
let installPath;
|
|
52
|
+
if (requirement.registry.githubRelease) {
|
|
53
|
+
const result = await handleGitHubRelease(requirement, requirement.registry.githubRelease);
|
|
54
|
+
installPath = result.resolvedPath;
|
|
55
|
+
}
|
|
56
|
+
else if (requirement.registry.artifacts) {
|
|
57
|
+
installPath = await this.handleArtifactsRegistry(requirement, requirement.registry.artifacts);
|
|
58
|
+
}
|
|
59
|
+
else if (requirement.registry.local) {
|
|
60
|
+
installPath = await this.handleLocalRegistry(requirement, requirement.registry.local);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw new Error('Invalid registry configuration');
|
|
64
|
+
}
|
|
65
|
+
// For general installer, we just return the path to the downloaded/located file
|
|
66
|
+
// The actual installation mechanism would depend on the specific requirement
|
|
67
|
+
return {
|
|
68
|
+
name: requirement.name,
|
|
69
|
+
type: 'other',
|
|
70
|
+
installed: true,
|
|
71
|
+
version: requirement.version,
|
|
72
|
+
inProgress: false,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
return {
|
|
77
|
+
name: requirement.name,
|
|
78
|
+
type: 'other',
|
|
79
|
+
installed: false,
|
|
80
|
+
error: error instanceof Error ? error.message : String(error),
|
|
81
|
+
inProgress: false
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=GeneralInstaller.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../types.js';
|
|
2
|
+
import { RequirementInstaller } from './RequirementInstaller.js';
|
|
3
|
+
import { exec } from 'child_process';
|
|
4
|
+
/**
|
|
5
|
+
* Factory for creating the appropriate installer for a requirement
|
|
6
|
+
*/
|
|
7
|
+
export declare class InstallerFactory {
|
|
8
|
+
private installers;
|
|
9
|
+
private readonly execPromise;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new InstallerFactory
|
|
12
|
+
* @param execPromise Function to execute commands
|
|
13
|
+
*/
|
|
14
|
+
constructor(execPromise: (command: string) => Promise<{
|
|
15
|
+
stdout: string;
|
|
16
|
+
stderr: string;
|
|
17
|
+
}>);
|
|
18
|
+
/**
|
|
19
|
+
* Register default installers for npm, pip, and general requirements
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
private registerDefaultInstallers;
|
|
23
|
+
/**
|
|
24
|
+
* Register a custom installer
|
|
25
|
+
* @param installer The installer to register
|
|
26
|
+
*/
|
|
27
|
+
registerInstaller(installer: RequirementInstaller): void;
|
|
28
|
+
/**
|
|
29
|
+
* Get the appropriate installer for a requirement
|
|
30
|
+
* @param requirement The requirement to get an installer for
|
|
31
|
+
* @returns The appropriate installer, or undefined if none found
|
|
32
|
+
*/
|
|
33
|
+
getInstaller(requirement: RequirementConfig): RequirementInstaller | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Install a requirement using the appropriate installer
|
|
36
|
+
* @param requirement The requirement to install
|
|
37
|
+
* @param options Installation options including python environment
|
|
38
|
+
* @returns The installation status
|
|
39
|
+
*/
|
|
40
|
+
install(requirement: RequirementConfig, options?: ServerInstallOptions): Promise<RequirementStatus>;
|
|
41
|
+
/**
|
|
42
|
+
* Check the installation status of a requirement
|
|
43
|
+
* @param requirement The requirement to check
|
|
44
|
+
* @param options Installation options including python environment
|
|
45
|
+
* @returns The installation status
|
|
46
|
+
*/
|
|
47
|
+
checkInstallation(requirement: RequirementConfig, options?: ServerInstallOptions): Promise<RequirementStatus>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a new InstallerFactory with default settings
|
|
51
|
+
* @param execPromise Optional function to execute commands
|
|
52
|
+
* @returns A new InstallerFactory
|
|
53
|
+
*/
|
|
54
|
+
export declare const createInstallerFactory: (execPromise?: typeof exec.__promisify__) => InstallerFactory;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { NpmInstaller } from './NpmInstaller.js';
|
|
2
|
+
import { PipInstaller } from './PipInstaller.js';
|
|
3
|
+
import { CommandInstaller } from './CommandInstaller.js';
|
|
4
|
+
import { GeneralInstaller } from './GeneralInstaller.js';
|
|
5
|
+
import { exec } from 'child_process';
|
|
6
|
+
import util from 'util';
|
|
7
|
+
/**
|
|
8
|
+
* Factory for creating the appropriate installer for a requirement
|
|
9
|
+
*/
|
|
10
|
+
export class InstallerFactory {
|
|
11
|
+
installers = [];
|
|
12
|
+
execPromise;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new InstallerFactory
|
|
15
|
+
* @param execPromise Function to execute commands
|
|
16
|
+
*/
|
|
17
|
+
constructor(execPromise) {
|
|
18
|
+
this.execPromise = execPromise;
|
|
19
|
+
this.registerDefaultInstallers();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Register default installers for npm, pip, and general requirements
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
registerDefaultInstallers() {
|
|
26
|
+
this.registerInstaller(new NpmInstaller(this.execPromise));
|
|
27
|
+
this.registerInstaller(new PipInstaller(this.execPromise));
|
|
28
|
+
this.registerInstaller(new CommandInstaller(this.execPromise));
|
|
29
|
+
this.registerInstaller(new GeneralInstaller(this.execPromise));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Register a custom installer
|
|
33
|
+
* @param installer The installer to register
|
|
34
|
+
*/
|
|
35
|
+
registerInstaller(installer) {
|
|
36
|
+
this.installers.push(installer);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get the appropriate installer for a requirement
|
|
40
|
+
* @param requirement The requirement to get an installer for
|
|
41
|
+
* @returns The appropriate installer, or undefined if none found
|
|
42
|
+
*/
|
|
43
|
+
getInstaller(requirement) {
|
|
44
|
+
// Validate that if registry is empty, type must not be 'other'
|
|
45
|
+
if (!requirement.registry && requirement.type === 'other') {
|
|
46
|
+
throw new Error('Registry must be specified for requirement type "other"');
|
|
47
|
+
}
|
|
48
|
+
return this.installers.find(installer => installer.canHandle(requirement));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Install a requirement using the appropriate installer
|
|
52
|
+
* @param requirement The requirement to install
|
|
53
|
+
* @param options Installation options including python environment
|
|
54
|
+
* @returns The installation status
|
|
55
|
+
*/
|
|
56
|
+
async install(requirement, options) {
|
|
57
|
+
const installer = this.getInstaller(requirement);
|
|
58
|
+
if (!installer) {
|
|
59
|
+
return {
|
|
60
|
+
name: requirement.name,
|
|
61
|
+
type: requirement.type,
|
|
62
|
+
installed: false,
|
|
63
|
+
error: `No installer found for requirement type '${requirement.type}'`,
|
|
64
|
+
inProgress: false
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return await installer.install(requirement, options);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Check the installation status of a requirement
|
|
71
|
+
* @param requirement The requirement to check
|
|
72
|
+
* @param options Installation options including python environment
|
|
73
|
+
* @returns The installation status
|
|
74
|
+
*/
|
|
75
|
+
async checkInstallation(requirement, options) {
|
|
76
|
+
const installer = this.getInstaller(requirement);
|
|
77
|
+
if (!installer) {
|
|
78
|
+
return {
|
|
79
|
+
name: requirement.name,
|
|
80
|
+
type: requirement.type,
|
|
81
|
+
installed: false,
|
|
82
|
+
error: `No installer found for requirement type '${requirement.type}'`,
|
|
83
|
+
inProgress: false
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return await installer.checkInstallation(requirement, options);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Create a new InstallerFactory with default settings
|
|
91
|
+
* @param execPromise Optional function to execute commands
|
|
92
|
+
* @returns A new InstallerFactory
|
|
93
|
+
*/
|
|
94
|
+
export const createInstallerFactory = (execPromise = util.promisify(exec)) => {
|
|
95
|
+
return new InstallerFactory(execPromise);
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=InstallerFactory.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RequirementConfig, RequirementStatus } from '../../types.js';
|
|
2
|
+
import { BaseInstaller } from './BaseInstaller.js';
|
|
3
|
+
/**
|
|
4
|
+
* Installer implementation for NPM packages
|
|
5
|
+
*/
|
|
6
|
+
export declare class NpmInstaller extends BaseInstaller {
|
|
7
|
+
/**
|
|
8
|
+
* Check if this installer can handle the given requirement type
|
|
9
|
+
* @param requirement The requirement to check
|
|
10
|
+
* @returns True if this installer can handle the requirement
|
|
11
|
+
*/
|
|
12
|
+
canHandle(requirement: RequirementConfig): boolean;
|
|
13
|
+
supportCheckUpdates(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Check if the NPM package is already installed
|
|
16
|
+
* @param requirement The requirement to check
|
|
17
|
+
* @returns The status of the requirement
|
|
18
|
+
*/
|
|
19
|
+
checkInstallation(requirement: RequirementConfig): Promise<RequirementStatus>;
|
|
20
|
+
/**
|
|
21
|
+
* Install the NPM package
|
|
22
|
+
* @param requirement The requirement to install
|
|
23
|
+
* @returns The status of the installation
|
|
24
|
+
*/
|
|
25
|
+
install(requirement: RequirementConfig): Promise<RequirementStatus>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { BaseInstaller } from './BaseInstaller.js';
|
|
2
|
+
import { compareVersions } from '../../../utils/versionUtils.js';
|
|
3
|
+
import { handleGitHubRelease } from '../../../utils/githubUtils.js';
|
|
4
|
+
/**
|
|
5
|
+
* Installer implementation for NPM packages
|
|
6
|
+
*/
|
|
7
|
+
export class NpmInstaller extends BaseInstaller {
|
|
8
|
+
/**
|
|
9
|
+
* Check if this installer can handle the given requirement type
|
|
10
|
+
* @param requirement The requirement to check
|
|
11
|
+
* @returns True if this installer can handle the requirement
|
|
12
|
+
*/
|
|
13
|
+
canHandle(requirement) {
|
|
14
|
+
return requirement.type === 'npm';
|
|
15
|
+
}
|
|
16
|
+
supportCheckUpdates() {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Check if the NPM package is already installed
|
|
21
|
+
* @param requirement The requirement to check
|
|
22
|
+
* @returns The status of the requirement
|
|
23
|
+
*/
|
|
24
|
+
async checkInstallation(requirement) {
|
|
25
|
+
try {
|
|
26
|
+
const { stdout } = await this.execPromise(`npm list -g ${requirement.name} --json`);
|
|
27
|
+
const pkgInfo = JSON.parse(stdout);
|
|
28
|
+
const installedVersion = pkgInfo?.dependencies?.[requirement.name]?.version;
|
|
29
|
+
return {
|
|
30
|
+
name: requirement.name,
|
|
31
|
+
type: 'npm',
|
|
32
|
+
installed: !!installedVersion,
|
|
33
|
+
version: installedVersion,
|
|
34
|
+
inProgress: false
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return {
|
|
39
|
+
name: requirement.name,
|
|
40
|
+
type: 'npm',
|
|
41
|
+
installed: false,
|
|
42
|
+
error: error instanceof Error ? error.message : String(error),
|
|
43
|
+
inProgress: false
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Install the NPM package
|
|
49
|
+
* @param requirement The requirement to install
|
|
50
|
+
* @returns The status of the installation
|
|
51
|
+
*/
|
|
52
|
+
async install(requirement) {
|
|
53
|
+
try {
|
|
54
|
+
const status = await this.checkInstallation(requirement);
|
|
55
|
+
if (status.installed && status.version && compareVersions(status.version, requirement.version) === 0) {
|
|
56
|
+
return status;
|
|
57
|
+
}
|
|
58
|
+
let resolvedVersion = requirement.version;
|
|
59
|
+
// If no registry is specified, use standard npm installation
|
|
60
|
+
if (!requirement.registry) {
|
|
61
|
+
const { stderr } = await this.execPromise(`npm install -g ${requirement.name}@${requirement.version}`);
|
|
62
|
+
if (stderr && !stderr.includes('added')) {
|
|
63
|
+
throw new Error(stderr);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Handle different registry types
|
|
68
|
+
let packageSource;
|
|
69
|
+
if (requirement.registry.githubRelease) {
|
|
70
|
+
const result = await handleGitHubRelease(requirement, requirement.registry.githubRelease);
|
|
71
|
+
packageSource = result.resolvedPath;
|
|
72
|
+
resolvedVersion = result.resolvedVersion;
|
|
73
|
+
}
|
|
74
|
+
else if (requirement.registry.artifacts) {
|
|
75
|
+
// For npm with artifacts, configure npm to use the specified registry URL
|
|
76
|
+
const registryUrl = requirement.registry.artifacts.registryUrl;
|
|
77
|
+
await this.execPromise(`npm config set registry ${registryUrl}`);
|
|
78
|
+
// Now install the package with the configured registry
|
|
79
|
+
const { stderr } = await this.execPromise(`npm install -g ${requirement.name}@${requirement.version}`);
|
|
80
|
+
if (stderr && !stderr.includes('added')) {
|
|
81
|
+
// Reset the registry to the default npm registry
|
|
82
|
+
await this.execPromise('npm config set registry https://registry.npmjs.org/');
|
|
83
|
+
throw new Error(stderr);
|
|
84
|
+
}
|
|
85
|
+
// Reset the registry to the default npm registry
|
|
86
|
+
await this.execPromise('npm config set registry https://registry.npmjs.org/');
|
|
87
|
+
return {
|
|
88
|
+
name: requirement.name,
|
|
89
|
+
type: 'npm',
|
|
90
|
+
installed: true,
|
|
91
|
+
version: requirement.version,
|
|
92
|
+
inProgress: false
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
else if (requirement.registry.local) {
|
|
96
|
+
packageSource = await this.handleLocalRegistry(requirement, requirement.registry.local);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
throw new Error('Invalid registry configuration');
|
|
100
|
+
}
|
|
101
|
+
// Install from the package source
|
|
102
|
+
const { stderr } = await this.execPromise(`npm install -g "${packageSource}"`);
|
|
103
|
+
if (stderr && !stderr.includes('added')) {
|
|
104
|
+
const status = await this.checkInstallation(requirement);
|
|
105
|
+
if (!status.installed)
|
|
106
|
+
throw new Error(stderr);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
name: requirement.name,
|
|
111
|
+
type: 'npm',
|
|
112
|
+
installed: true,
|
|
113
|
+
version: resolvedVersion,
|
|
114
|
+
inProgress: false
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
return {
|
|
119
|
+
name: requirement.name,
|
|
120
|
+
type: 'npm',
|
|
121
|
+
installed: false,
|
|
122
|
+
error: error instanceof Error ? error.message : String(error),
|
|
123
|
+
inProgress: false
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=NpmInstaller.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../types.js';
|
|
2
|
+
import { BaseInstaller } from './BaseInstaller.js';
|
|
3
|
+
/**
|
|
4
|
+
* Installer implementation for Python packages using pip
|
|
5
|
+
*/
|
|
6
|
+
export declare class PipInstaller extends BaseInstaller {
|
|
7
|
+
private getPythonCommand;
|
|
8
|
+
private getPipCommand;
|
|
9
|
+
/**
|
|
10
|
+
* Check if this installer can handle the given requirement type
|
|
11
|
+
* @param requirement The requirement to check
|
|
12
|
+
* @returns True if this installer can handle the requirement
|
|
13
|
+
*/
|
|
14
|
+
canHandle(requirement: RequirementConfig): boolean;
|
|
15
|
+
supportCheckUpdates(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Check if the Python package is already installed
|
|
18
|
+
* @param requirement The requirement to check
|
|
19
|
+
* @returns The status of the requirement
|
|
20
|
+
*/
|
|
21
|
+
checkInstallation(requirement: RequirementConfig, options?: ServerInstallOptions): Promise<RequirementStatus>;
|
|
22
|
+
/**
|
|
23
|
+
* Install the Python package
|
|
24
|
+
* @param requirement The requirement to install
|
|
25
|
+
* @returns The status of the installation
|
|
26
|
+
*/
|
|
27
|
+
install(requirement: RequirementConfig, options?: ServerInstallOptions): Promise<RequirementStatus>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { BaseInstaller } from './BaseInstaller.js';
|
|
2
|
+
import { handleGitHubRelease } from '../../../utils/githubUtils.js';
|
|
3
|
+
/**
|
|
4
|
+
* Installer implementation for Python packages using pip
|
|
5
|
+
*/
|
|
6
|
+
export class PipInstaller extends BaseInstaller {
|
|
7
|
+
getPythonCommand(options) {
|
|
8
|
+
return options?.settings?.pythonEnv || 'python';
|
|
9
|
+
}
|
|
10
|
+
getPipCommand(options) {
|
|
11
|
+
const pythonCmd = this.getPythonCommand(options);
|
|
12
|
+
return `${pythonCmd} -m pip`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Check if this installer can handle the given requirement type
|
|
16
|
+
* @param requirement The requirement to check
|
|
17
|
+
* @returns True if this installer can handle the requirement
|
|
18
|
+
*/
|
|
19
|
+
canHandle(requirement) {
|
|
20
|
+
return requirement.type === 'pip';
|
|
21
|
+
}
|
|
22
|
+
supportCheckUpdates() {
|
|
23
|
+
/// temporarily disabling update check for pip as not able to get which pip of python is being used
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Check if the Python package is already installed
|
|
28
|
+
* @param requirement The requirement to check
|
|
29
|
+
* @returns The status of the requirement
|
|
30
|
+
*/
|
|
31
|
+
async checkInstallation(requirement, options) {
|
|
32
|
+
try {
|
|
33
|
+
const pipCmd = this.getPipCommand(options);
|
|
34
|
+
const { stdout, stderr } = await this.execPromise(`${pipCmd} show ${requirement.name}`);
|
|
35
|
+
// If we get an output and no error, the package is installed
|
|
36
|
+
const installed = stdout.includes(requirement.name);
|
|
37
|
+
const versionMatch = stdout.match(/Version: (.+)/);
|
|
38
|
+
const installedVersion = versionMatch ? versionMatch[1] : undefined;
|
|
39
|
+
return {
|
|
40
|
+
name: requirement.name,
|
|
41
|
+
type: 'pip',
|
|
42
|
+
installed,
|
|
43
|
+
version: installedVersion,
|
|
44
|
+
inProgress: false
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
return {
|
|
49
|
+
name: requirement.name,
|
|
50
|
+
type: 'pip',
|
|
51
|
+
installed: false,
|
|
52
|
+
error: error instanceof Error ? error.message : String(error),
|
|
53
|
+
inProgress: false
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Install the Python package
|
|
59
|
+
* @param requirement The requirement to install
|
|
60
|
+
* @returns The status of the installation
|
|
61
|
+
*/
|
|
62
|
+
async install(requirement, options) {
|
|
63
|
+
try {
|
|
64
|
+
const status = await this.checkInstallation(requirement, options);
|
|
65
|
+
if (status.installed) {
|
|
66
|
+
return status;
|
|
67
|
+
}
|
|
68
|
+
const pipCmd = this.getPipCommand(options);
|
|
69
|
+
// If no registry is specified, use standard pip installation
|
|
70
|
+
if (!requirement.registry) {
|
|
71
|
+
// Standard pip installation
|
|
72
|
+
const { stderr } = await this.execPromise(`${pipCmd} install ${requirement.name}==${requirement.version}`);
|
|
73
|
+
if (stderr && stderr.toLowerCase().includes('error')) {
|
|
74
|
+
throw new Error(stderr);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// Handle different registry types
|
|
79
|
+
let packageSource;
|
|
80
|
+
if (requirement.registry.githubRelease) {
|
|
81
|
+
const result = await handleGitHubRelease(requirement, requirement.registry.githubRelease);
|
|
82
|
+
packageSource = result.resolvedPath;
|
|
83
|
+
// Install from the downloaded wheel or tar.gz file
|
|
84
|
+
const { stderr } = await this.execPromise(`${pipCmd} install "${packageSource}"`);
|
|
85
|
+
if (stderr && stderr.toLowerCase().includes('error')) {
|
|
86
|
+
throw new Error(stderr);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (requirement.registry.artifacts) {
|
|
90
|
+
const registryUrl = requirement.registry.artifacts.registryUrl;
|
|
91
|
+
// Install using the custom index URL
|
|
92
|
+
const { stderr } = await this.execPromise(`${pipCmd} install ${requirement.name}==${requirement.version} --index-url ${registryUrl}`);
|
|
93
|
+
if (stderr && stderr.toLowerCase().includes('error')) {
|
|
94
|
+
throw new Error(stderr);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (requirement.registry.local) {
|
|
98
|
+
packageSource = await this.handleLocalRegistry(requirement, requirement.registry.local);
|
|
99
|
+
// Install from the local path
|
|
100
|
+
const { stderr } = await this.execPromise(`${pipCmd} install "${packageSource}"`);
|
|
101
|
+
if (stderr && stderr.toLowerCase().includes('error')) {
|
|
102
|
+
throw new Error(stderr);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
throw new Error('Invalid registry configuration');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
name: requirement.name,
|
|
111
|
+
type: 'pip',
|
|
112
|
+
installed: true,
|
|
113
|
+
version: requirement.version,
|
|
114
|
+
inProgress: false
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
return {
|
|
119
|
+
name: requirement.name,
|
|
120
|
+
type: 'pip',
|
|
121
|
+
installed: false,
|
|
122
|
+
error: error instanceof Error ? error.message : String(error),
|
|
123
|
+
inProgress: false
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=PipInstaller.js.map
|
|
@@ -1,38 +1,33 @@
|
|
|
1
|
-
import { RequirementConfig, RequirementStatus } from '
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
* @
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*/
|
|
35
|
-
checkForUpdates(requirement: RequirementConfig, currentStatus: RequirementStatus): Promise<RequirementStatus>;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Note: Do not re-export implementations from here to avoid circular dependencies
|
|
1
|
+
import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for requirement installers.
|
|
4
|
+
* Implementations should handle specific requirement types.
|
|
5
|
+
*/
|
|
6
|
+
export interface RequirementInstaller {
|
|
7
|
+
/**
|
|
8
|
+
* Check if this installer can handle the given requirement type
|
|
9
|
+
* @param requirement The requirement to check
|
|
10
|
+
* @returns True if this installer can handle the requirement
|
|
11
|
+
*/
|
|
12
|
+
canHandle(requirement: RequirementConfig): boolean;
|
|
13
|
+
supportCheckUpdates(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Install the requirement
|
|
16
|
+
* @param requirement The requirement to install
|
|
17
|
+
* @returns The status of the installation
|
|
18
|
+
*/
|
|
19
|
+
install(requirement: RequirementConfig, options?: ServerInstallOptions): Promise<RequirementStatus>;
|
|
20
|
+
/**
|
|
21
|
+
* Check if the requirement is already installed
|
|
22
|
+
* @param requirement The requirement to check
|
|
23
|
+
* @returns The status of the requirement
|
|
24
|
+
*/
|
|
25
|
+
checkInstallation(requirement: RequirementConfig, options?: ServerInstallOptions): Promise<RequirementStatus>;
|
|
26
|
+
/**
|
|
27
|
+
* Check if updates are available for the requirement
|
|
28
|
+
* @param requirement The requirement to check
|
|
29
|
+
* @param currentStatus The current status of the requirement
|
|
30
|
+
* @returns The status of the requirement with update information
|
|
31
|
+
*/
|
|
32
|
+
checkForUpdates(requirement: RequirementConfig, currentStatus: RequirementStatus): Promise<RequirementStatus>;
|
|
33
|
+
}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -64,6 +64,8 @@ export interface ServerInstallOptions {
|
|
|
64
64
|
env?: Record<string, string>;
|
|
65
65
|
targetClients?: string[];
|
|
66
66
|
requirements?: RequirementConfig[];
|
|
67
|
+
args?: string[];
|
|
68
|
+
settings?: Record<string, any>;
|
|
67
69
|
}
|
|
68
70
|
export interface UpdateRequirementOptions {
|
|
69
71
|
requirementName: string;
|
|
@@ -86,6 +88,7 @@ export interface DependencyConfig {
|
|
|
86
88
|
requirements?: Array<{
|
|
87
89
|
name: string;
|
|
88
90
|
version: string;
|
|
91
|
+
order?: number;
|
|
89
92
|
}>;
|
|
90
93
|
mcpServers?: Array<{
|
|
91
94
|
name: string;
|
|
@@ -115,7 +118,7 @@ export interface RegistryConfig {
|
|
|
115
118
|
}
|
|
116
119
|
export interface RequirementConfig {
|
|
117
120
|
name: string;
|
|
118
|
-
type: 'npm' | 'pip' | 'command' | 'other';
|
|
121
|
+
type: 'npm' | 'pip' | 'command' | 'extension' | 'other';
|
|
119
122
|
alias?: string;
|
|
120
123
|
version: string;
|
|
121
124
|
registry?: RegistryConfig;
|
|
@@ -71,7 +71,7 @@ export class ServerService {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
// Check for updates
|
|
74
|
-
const updatedStatus = await requirementService.checkRequirementForUpdates(requirement);
|
|
74
|
+
const updatedStatus = await requirementService.checkRequirementForUpdates(requirement, currentStatus);
|
|
75
75
|
// If update information is found, update the configuration
|
|
76
76
|
if (updatedStatus.availableUpdate && serverCategory.name) {
|
|
77
77
|
await configProvider.updateRequirementStatus(serverCategory.name, requirement.name, updatedStatus);
|