Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import fs from 'fs'; |
| 2 | import path from 'path'; |
| 3 | import { fileURLToPath } from 'url'; |
| 4 | import semver from 'semver'; |
| 5 | |
| 6 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 7 | const corePkgPackageJson = path.resolve(__dirname, '../packages/core/package.json'); |
| 8 | const providersDir = path.resolve(__dirname, '../packages/providers'); |
| 9 | |
| 10 | const corePkg = JSON.parse(fs.readFileSync(corePkgPackageJson, 'utf-8')); |
| 11 | const coreVersion = corePkg.version; |
| 12 | |
| 13 | const providerDirs = fs.readdirSync(providersDir).filter(name => { |
| 14 | const fullPath = path.resolve(providersDir, name); |
| 15 | return fs.existsSync(path.join(fullPath, 'package.json')); |
| 16 | }); |
| 17 | |
| 18 | let hasError = false; |
| 19 | |
| 20 | for (const dir of providerDirs) { |
| 21 | const pkgPath = path.resolve(providersDir, dir, 'package.json'); |
| 22 | const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8')); |
| 23 | |
| 24 | const peerDeps = pkg.peerDependencies || {}; |
| 25 | const declaredCoreVersion = peerDeps['@composio/core']; |
| 26 | |
| 27 | if (!declaredCoreVersion) { |
| 28 | console.error(`[ERROR] Provider ${dir} does not declare @composio/core as a peerDependency`); |
| 29 | hasError = true; |
| 30 | continue; |
| 31 | } |
| 32 | |
| 33 | if (!semver.satisfies(coreVersion, declaredCoreVersion)) { |
| 34 | console.error( |
| 35 | `[ERROR] Provider ${dir} declares incompatible core version range: ${declaredCoreVersion} (current: ${coreVersion})` |
| 36 | ); |
| 37 | hasError = true; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | if (hasError) { |
| 42 | process.exit(1); |
| 43 | } else { |
| 44 | console.log('✅ All providers declare compatible @composio/core peerDependencies.'); |
| 45 | } |