diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 426e85d9b..792fb20f7 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -81,9 +81,10 @@ jobs: run: | npm run cli init -- -p ../logto --db postgres://postgres:postgres@localhost:5432/postgres --no-oc --du ../logto.tar.gz - - name: Add mock connectors + - name: Check and add mock connectors working-directory: tests run: | + npm run cli connector list -- -p ../logto | grep OFFICIAL npm run cli connector add @logto/connector-mock-sms @logto/connector-mock-email @logto/connector-mock-standard-email @logto/connector-mock-social -- -p ../logto - name: Run Logto diff --git a/.scripts/package.sh b/.scripts/package.sh index 200151eb9..445dbf9fd 100755 --- a/.scripts/package.sh +++ b/.scripts/package.sh @@ -18,6 +18,9 @@ packages/**/*.config.js packages/**/*.config.ts packages/**/tsconfig*.json \ ! -path '**/node_modules/**' \ -prune -exec rm -rf {} + +# Add official connectors +pnpm cli connector add --official -p . + echo Tar cd .. tar -czf /tmp/logto.tar.gz logto diff --git a/packages/cli/src/commands/connector/utils.ts b/packages/cli/src/commands/connector/utils.ts index 0ef1311aa..b05dc7103 100644 --- a/packages/cli/src/commands/connector/utils.ts +++ b/packages/cli/src/commands/connector/utils.ts @@ -4,7 +4,7 @@ import fs from 'fs/promises'; import path from 'path'; import { promisify } from 'util'; -import { assert, conditionalString } from '@silverhand/essentials'; +import { assert, conditionalString, trySafe } from '@silverhand/essentials'; import chalk from 'chalk'; import { got } from 'got'; import inquirer from 'inquirer'; @@ -105,8 +105,13 @@ export const isOfficialConnector = (packageName: string) => export const getConnectorPackagesFrom = async (instancePath?: string) => { const directory = getConnectorDirectory(await inquireInstancePath(instancePath)); + const packages = await trySafe(getConnectorPackagesFromDirectory(directory)); - return getConnectorPackagesFromDirectory(directory); + if (!packages || packages.length === 0) { + throw new Error('No connector found'); + } + + return packages; }; export const addConnectors = async (instancePath: string, packageNames: string[]) => {