Skip to content

Commit

Permalink
feat: checking the plugin is installed and display the result (#3660)
Browse files Browse the repository at this point in the history
* update discord link

* checking the plugin is installed and display the result

---------

Co-authored-by: Odilitime <janesmith@airmail.cc>
  • Loading branch information
v1xingyue and odilitime authored Feb 25, 2025
1 parent 6181eff commit a4cb8cd
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions packages/cli/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
#!/usr/bin/env node

const { execSync } = require('child_process')
const pathUtil = require('path')
const fs = require('fs')
const { Command } = require('commander')

const program = new Command()
const { version } = require('./package.json')


const pluginPkgPath = (pluginRepo) => {
const parts = pluginRepo.split('/')
const elizaOSroot = pathUtil.resolve(__dirname, '../..')
const pkgPath = elizaOSroot + '/packages/' + parts[1]
return pkgPath
}

const isPluginInstalled = (pluginRepo) => {
const pkgPath = pluginPkgPath(pluginRepo)
const packageJsonPath = pkgPath + '/package.json'
return fs.existsSync(packageJsonPath)
}

program
.name('elizaos')
.description('elizaOS CLI - Manage your plugins')
Expand All @@ -21,6 +35,8 @@ async function getPlugins() {
return await resp.json();
}



plugins
.command('list')
.alias('l')
Expand All @@ -36,7 +52,7 @@ plugins

console.info("\nAvailable plugins:")
for (const plugin of pluginNames) {
console.info(` ${plugin}`)
console.info(` ${isPluginInstalled(plugins[plugin]) ? '✅' : ' '} ${plugin} `)
}
console.info("")
} catch (error) {
Expand All @@ -59,7 +75,7 @@ plugins
return
}

const plugins = await getPlugins()

const repoData = plugins[plugin]?.split(':')
if (!repoData) {
console.error('Plugin', plugin, 'not found')
Expand Down

0 comments on commit a4cb8cd

Please sign in to comment.