MCPcopy
hub / github.com/xpf0000/FlyEnv / pickVersion

Method pickVersion

src/main/core/MCPTools.ts:499–523  ·  view source on GitHub ↗

start_service / stop_service / restart_service 的底层:需要一个 version 对象

(flag: string, version?: string)

Source from the content-addressed store, hash-verified

497
498 /** start_service / stop_service / restart_service 的底层:需要一个 version 对象 */
499 private async pickVersion(flag: string, version?: string): Promise<any> {
500 const arr: any[] = await this.rawServiceVersions(flag)
501 if (!Array.isArray(arr) || arr.length === 0) {
502 throw new Error(
503 `No installed version for ${flag}. Use list_online_versions and install_service before start_service.`
504 )
505 }
506 if (version) {
507 const find = arr.find((v) => v?.version === version && v?.enable)
508 if (!find) {
509 throw new Error(
510 `Version ${version} of ${flag} is not installed or not enabled. ` +
511 'Use list_online_versions to inspect available versions and install_service to install one first.'
512 )
513 }
514 return find
515 }
516 const enabled = arr.find((v) => v?.enable)
517 if (!enabled) {
518 throw new Error(
519 `No enabled installed version for ${flag}. Install or enable a version before using start_service.`
520 )
521 }
522 return enabled
523 }
524
525 async startService(flag: string, version?: string): Promise<any> {
526 this.assertLifecycleFlag(flag, 'start')

Callers 3

startServiceMethod · 0.95
stopServiceMethod · 0.95
stopAllServiceMethod · 0.95

Calls 1

rawServiceVersionsMethod · 0.95

Tested by

no test coverage detected