-
Notifications
You must be signed in to change notification settings - Fork 12
chore: update to latests Deno and CLI standards #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
a9c51cd
41958f0
291c5c5
559d88c
22b5ec8
0ed095e
aec5231
1520a46
0623db0
9f7b933
67da947
8bf6ed6
ddec837
925d328
73bb20e
b36d6ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Please see the documentation for all configuration options: | ||
| # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||
|
|
||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: "github-actions" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "monthly" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📣 For sample apps this is an interesting choice that seems helpful for the current maintenance requirements across all projects of @slack-samples. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| apps.dev.json | ||
| cache/ | ||
| config.json | ||
WilliamBergamin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changes to this file might be reverted from automations of slack-samples/sample-app-configurations but I realize the changed Either before or after this pull request we should update these workflows! 🤖
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rambling now, but if we do expect these files to diverge I think it'd be best to remove paths that don't exist within a specific sample and perhaps revisit the I'm also noticing sections in the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yess I agree 💯 and I was also thinking of updating slack-samples/sample-app-configurations to use imports rather then import maps |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,6 @@ | |
| "workflows" | ||
| ] | ||
| }, | ||
| "importMap": "import_map.json", | ||
| "lint": { | ||
| "include": [ | ||
| "datastores", | ||
|
|
@@ -28,6 +27,12 @@ | |
| }, | ||
| "lock": false, | ||
| "tasks": { | ||
| "test": "deno fmt --check && deno lint && deno test --allow-read --allow-none" | ||
| "test": "deno fmt --check && deno lint && deno test --allow-read -- --allow-none" | ||
| }, | ||
| "imports": { | ||
| "deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.15.0/", | ||
| "deno-slack-api/": "https://deno.land/x/deno_slack_api@2.8.0/", | ||
| "@std/testing": "jsr:@std/testing@^1.0.12", | ||
| "@std/assert": "jsr:@std/assert@^1" | ||
|
||
| } | ||
| } | ||
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import { type Stub, stub } from "@std/testing/mock"; | ||
|
|
||
| interface StubRequestHandler { | ||
| assertion: (req: Request) => void | Promise<void>; | ||
WilliamBergamin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| response: Response; | ||
| } | ||
|
|
||
| export class UnmatchedRequestError extends Error { | ||
| request: Request; | ||
|
|
||
| constructor(request: Request) { | ||
| const method = request.method; | ||
| const url = request.url; | ||
| const headers = JSON.stringify(Object.fromEntries([...request.headers])); | ||
|
|
||
| super(`No stub found for ${method} ${url}\nHeaders: ${headers}`); | ||
| this.name = "UnmatchedRequestError"; | ||
| this.request = request; | ||
| } | ||
| } | ||
|
|
||
| export class StubFetch { | ||
| private stubs: Map<string, StubRequestHandler> = new Map(); | ||
| private stubFetchInstance: Stub | null = null; | ||
|
|
||
| constructor() { | ||
| this.install(); | ||
| } | ||
|
|
||
| stub(stubRequestHandler: StubRequestHandler): StubRequestHandler { | ||
| this.stubs.set(stubRequestHandler.assertion.toString(), stubRequestHandler); | ||
| return stubRequestHandler; | ||
| } | ||
|
|
||
| removeStub(stubRequestHandler: StubRequestHandler): boolean { | ||
| const assertionKey = stubRequestHandler.assertion.toString(); | ||
| if (assertionKey in this.stubs) { | ||
| return this.stubs.delete(assertionKey); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| install(): Stub { | ||
| this.stubFetchInstance = stub( | ||
| globalThis, | ||
| "fetch", | ||
| async (url: string | URL | Request, options?: RequestInit) => { | ||
| const request = url instanceof Request | ||
| ? url | ||
| : new Request(url, options); | ||
|
|
||
| for (const stubRequestHandler of this.stubs.values()) { | ||
| try { | ||
| // Clone the request for each assertion attempt to ensures the body can be read multiple times | ||
| const assertionResult = stubRequestHandler.assertion( | ||
| request.clone(), | ||
| ); | ||
|
|
||
| if (assertionResult instanceof Promise) { | ||
| await assertionResult; | ||
| } | ||
|
|
||
| return Promise.resolve(stubRequestHandler.response.clone()); | ||
| } catch (_error) { | ||
| // do nothing | ||
| } | ||
| } | ||
|
|
||
| throw new UnmatchedRequestError(request); | ||
| }, | ||
| ); | ||
|
|
||
| return this.stubFetchInstance; | ||
| } | ||
|
|
||
| restore(): void { | ||
| if (this.stubFetchInstance) { | ||
| this.stubFetchInstance.restore(); | ||
| this.stubFetchInstance = null; | ||
| } | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🪓 |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { Trigger } from "deno-slack-sdk/types.ts"; | ||
| import type { Trigger } from "deno-slack-sdk/types.ts"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👁️🗨️ Good catch! |
||
| import { | ||
| TriggerContextData, | ||
| TriggerEventTypes, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.