diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 65fe367..3ad4b81 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,9 +22,17 @@ jobs: with: node-version: 20 - - name: Install dependencies + - name: Install build dependencies run: npm ci + - name: Install functions dependencies + working-directory: functions + run: npm ci + + - name: Build functions + working-directory: functions + run: npm run build:package + - name: Release env: GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }} diff --git a/.releaserc.yml b/.releaserc.yml index e36fa47..3342c42 100644 --- a/.releaserc.yml +++ b/.releaserc.yml @@ -8,6 +8,7 @@ plugins: - - "@semantic-release/github" - - "@semantic-release/git" - assets: + - "functions/lib/**" - "extension.yaml" - "CHANGELOG.md" message: "chore(release): prepare ${nextRelease.version} [skip ci]" diff --git a/functions/integration-tests/extensions/chatkitty.env b/functions/integration-tests/extensions/chatkitty.env index d3e0379..82e7694 100644 --- a/functions/integration-tests/extensions/chatkitty.env +++ b/functions/integration-tests/extensions/chatkitty.env @@ -1,2 +1 @@ CLIENT_ID=afaac908-1db3-4b5c-a7ae-c040b9684403 -CLIENT_SECRET=03e8c3e1-e483-47a6-a225-b05a22e4c523 diff --git a/functions/integration-tests/extensions/chatkitty.secret.local b/functions/integration-tests/extensions/chatkitty.secret.local new file mode 100644 index 0000000..e6d389c --- /dev/null +++ b/functions/integration-tests/extensions/chatkitty.secret.local @@ -0,0 +1 @@ +CLIENT_SECRET=03e8c3e1-e483-47a6-a225-b05a22e4c523 diff --git a/functions/src/index.ts b/functions/src/index.ts index b2caebb..4e2b92a 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -1,4 +1,4 @@ -import * as functions from "firebase-functions"; +import {auth, logger} from "firebase-functions"; import {ChatKitty} from "chatkitty-platform-sdk"; const chatkitty = new ChatKitty({ @@ -6,9 +6,8 @@ const chatkitty = new ChatKitty({ clientSecret: process.env.CLIENT_SECRET as string, }); - export const handleCreateUser = - functions.auth.user().onCreate(async (user) => { + auth.user().onCreate(async (user) => { await chatkitty.Users.checkUserExists(user.uid).catch(async () => { await chatkitty.Users.createUser({ name: user.uid, @@ -16,14 +15,20 @@ export const handleCreateUser = isGuest: true, }); }); + + logger.info(`Successfully created ChatKitty user: ${user.uid}`); }); -export const handleDeleteUser = functions.auth.user().onDelete(async (user) => { +export const handleDeleteUser = auth.user().onDelete(async (user) => { const result = await chatkitty.Users.listUsers(0, 0, undefined, user.uid); const users = result.data._embedded?.users; if (users && users.length > 0) { await chatkitty.Users.deleteUser(users[0].id); + + logger.info(`Successfully deleted ChatKitty user: ${user.uid}`); + } else { + logger.info(`ChatKitty user not found: ${user.uid}`); } });