diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..b4982c7 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,24 @@ +# Use the Ubtuntu base image +FROM ubuntu:22.04 + +# Download development tools +RUN apt-get update +RUN apt-get install -y curl +RUN apt-get install -y git +RUN apt-get install -y unzip + +# Run the container as a user +RUN useradd -m -s /bin/bash slackdev +RUN chown slackdev /usr/local/bin +USER slackdev + +# Install the project runtime +RUN curl -fsSL https://deno.land/install.sh | sh +RUN export DENO_INSTALL="/home/slackdev/.deno" +RUN export PATH="$DENO_INSTALL/bin:$PATH" + +# Set the working directory +WORKDIR /workspaces + +# Install the Slack CLI +RUN curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s -- -d diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 0000000..4ef3433 --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,35 @@ +# .devcontainer + +A [development container][container] provides a predefined environment with +some tools needed for development, which can be useful in editors such as +[Visual Studio Code][vscode] or remote settings like [Codespaces][codespaces]. + +This specific container packages [the Slack CLI][cli] with the project runtime +and a few development tools. The `Dockerfile` details the container. + +## Editor extensions + +Modifications to an editor can be made with changes to the `devcontainer.json` +file: + +```diff +{ + "customizations": { + "vscode": { + "extensions": [ ++ "GitHub.copilot", + "denoland.vscode-deno", + "ms-azuretools.vscode-docker" + ], ++ "settings": { ++ "terminal.integrated.defaultProfile.linux": "zsh" ++ } + } + } +} +``` + +[codespaces]: https://github.com/features/codespaces +[cli]: https://api.slack.com/automation/cli +[container]: https://containers.dev/ +[vscode]: https://code.visualstudio.com/docs/devcontainers/containers diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..5c881bf --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,13 @@ +{ + "name": "Slack Platform", + "dockerFile": "Dockerfile", + "remoteUser": "slackdev", + "customizations": { + "vscode": { + "extensions": [ + "denoland.vscode-deno", + "ms-azuretools.vscode-docker" + ] + } + } +} diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml new file mode 100644 index 0000000..8c925fa --- /dev/null +++ b/.github/workflows/deno.yml @@ -0,0 +1,34 @@ +name: Deno app build and testing + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + deno: + if: github.repository == 'slack-samples/deno-blank-template' + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Setup repo + uses: actions/checkout@v3 + + - name: Setup Deno + uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + + - name: Verify formatting + run: deno fmt --check + + - name: Run linter + run: deno lint + + - name: Run tests + run: deno task test + + - name: Run type check + run: deno check *.ts diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2aec489 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +dist +package +.DS_Store +.slack/apps.dev.json +.log/ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..91f1016 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,13 @@ +{ + "deno.enable": true, + "deno.lint": true, + "deno.unstable": true, + "deno.suggest.imports.hosts": { + "https://deno.land": false + }, + "[typescript]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "denoland.vscode-deno" + }, + "editor.tabSize": 2 +} diff --git a/assets/default_new_app_icon.png b/assets/default_new_app_icon.png new file mode 100644 index 0000000..812445a Binary files /dev/null and b/assets/default_new_app_icon.png differ diff --git a/deno.jsonc b/deno.jsonc new file mode 100644 index 0000000..56029c4 --- /dev/null +++ b/deno.jsonc @@ -0,0 +1,33 @@ +{ + "$schema": "https://deno.land/x/deno/cli/schemas/config-file.v1.json", + "fmt": { + "include": [ + "README.md", + "datastores", + "external_auth", + "functions", + "manifest.ts", + "triggers", + "types", + "views", + "workflows" + ] + }, + "importMap": "import_map.json", + "lint": { + "include": [ + "datastores", + "external_auth", + "functions", + "manifest.ts", + "triggers", + "types", + "views", + "workflows" + ] + }, + "lock": false, + "tasks": { + "test": "deno fmt --check && deno lint && deno test --allow-read --allow-none" + } +} diff --git a/import_map.json b/import_map.json new file mode 100644 index 0000000..fe1ef6b --- /dev/null +++ b/import_map.json @@ -0,0 +1,6 @@ +{ + "imports": { + "deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.11.0/", + "deno-slack-api/": "https://deno.land/x/deno_slack_api@2.4.0/" + } +} diff --git a/manifest.ts b/manifest.ts new file mode 100644 index 0000000..62b7699 --- /dev/null +++ b/manifest.ts @@ -0,0 +1,11 @@ +import { Manifest } from "deno-slack-sdk/mod.ts"; +import { RegisterMessageWorkflow } from "./workflows/register_message_workflow.ts"; + +export default Manifest({ + name: "success-notification-aggregator", + description: "Consolidates success notifications into a single, reliable report", + icon: "assets/default_new_app_icon.png", + workflows: [RegisterMessageWorkflow], + outgoingDomains: [], + botScopes: ["commands", "chat:write", "chat:write.public"], +}); diff --git a/slack.json b/slack.json new file mode 100644 index 0000000..655963f --- /dev/null +++ b/slack.json @@ -0,0 +1,5 @@ +{ + "hooks": { + "get-hooks": "deno run -q --allow-read --allow-net https://deno.land/x/deno_slack_hooks@1.3.0/mod.ts" + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..d922238 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "moduleResolution": "node", + "resolveJsonModule": true, + "esModuleInterop": true, + "skipLibCheck": true, + "target": "ES2020", + "lib": [ + "dom", + "ES2020" + ], + "allowSyntheticDefaultImports": true, + "module": "ESNext", + "baseUrl": ".", + "paths": { + "*": [ + "node_modules/*", + "workflows/*" + ] + } + } +} diff --git a/workflows/register_message_workflow.ts b/workflows/register_message_workflow.ts new file mode 100644 index 0000000..7cdaa6f --- /dev/null +++ b/workflows/register_message_workflow.ts @@ -0,0 +1,7 @@ +import { DefineWorkflow } from "deno-slack-sdk/mod.ts"; + +export const RegisterMessageWorkflow = DefineWorkflow({ + callback_id: "register_message_workflow", + title: "Register Message", + description: "Add ID to the incoming success notification and register it to Datastore", +});