-
Notifications
You must be signed in to change notification settings - Fork 1
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
JSDoc, deno.jsonc
, return type tweaks; prep for JSR.io publish test
#8
Changes from all commits
91d1ac8
cfb79cb
e8b5d2e
6f2c8a2
aee7d2a
2cf5a97
29ba701
20990bf
98310e9
8103faf
0ca5441
beecd36
ad8e619
2aec1d9
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,16 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write # The OIDC ID token is used for authentication with JSR. | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: npx jsr publish |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# deno-slack-protocols | ||
|
||
[![codecov](https://codecov.io/gh/slackapi/deno-slack-protocols/graph/badge.svg?token=SR0MMXTQRW)](https://codecov.io/gh/slackapi/deno-slack-protocols) | ||
|
||
This library is a utility for use by Slack's next-generation application | ||
platform, focused on remixable units of functionality encapsulated as ephemeral | ||
functions. It implements the rules for communication (i.e. the protocol) between | ||
[Slack CLI][cli] and any Slack app development SDKs. | ||
|
||
This is separate from the [deno-slack-hooks][hooks] project, which implements | ||
the various APIs encapsulating work delegation from the CLI to the SDK. The | ||
[deno-slack-hooks][hooks] project implements the API, which uses this library | ||
under the hood. | ||
|
||
## Requirements | ||
|
||
This library requires a recent (at least 1.44) version of | ||
[deno](https://deno.land). | ||
|
||
## Running Tests | ||
|
||
If you make changes to this repo, or just want to make sure things are working | ||
as desired, you can run: | ||
|
||
deno task test | ||
|
||
To get a full test coverage report, run: | ||
|
||
deno task test:coverage | ||
|
||
--- | ||
|
||
### Getting Help | ||
|
||
We welcome contributions from everyone! Please check out our | ||
[Contributor's Guide](https://github.com/slackapi/deno-slack-protocols/blob/main/.github/CONTRIBUTING.md) | ||
for how to contribute in a helpful and collaborative way. | ||
|
||
[cli]: https://github.com/slackapi/slack-cli | ||
[hooks]: https://github.com/slackapi/deno-slack-hooks |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,39 @@ | ||
{ | ||
"$schema": "https://deno.land/x/deno/cli/schemas/config-file.v1.json", | ||
"name": "@slack/protocols", | ||
"version": "0.0.2-pre.2", | ||
"exports": { | ||
".": "./src/mod.ts", | ||
"./mock": "./src/mock.ts", | ||
"./types": "./src/types.ts" | ||
}, | ||
"fmt": { | ||
"files": { | ||
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. The |
||
"include": ["src", "docs", "README.md"] | ||
}, | ||
"options": { | ||
"semiColons": true, | ||
"indentWidth": 2, | ||
"lineWidth": 80, | ||
"proseWrap": "always", | ||
"singleQuote": false, | ||
"useTabs": false | ||
} | ||
"include": ["src", "docs", "README.md"], | ||
"semiColons": true, | ||
"indentWidth": 2, | ||
"lineWidth": 80, | ||
"proseWrap": "always", | ||
"singleQuote": false, | ||
"useTabs": false | ||
}, | ||
"imports": { | ||
"@std/assert": "jsr:@std/assert@^0.226.0", | ||
"@std/cli": "jsr:@std/cli@^0.224.6", | ||
"@std/testing": "jsr:@std/testing@^0.225.1" | ||
}, | ||
"lint": { | ||
"files": { | ||
"include": ["src"] | ||
} | ||
"include": ["src"] | ||
}, | ||
"test": { | ||
"files": { | ||
"include": ["src/tests.ts"] | ||
} | ||
"lock": false, | ||
"publish": { | ||
"exclude": ["mod.ts", "mock.ts", "types.ts", ".github", ".vscode"] | ||
}, | ||
"tasks": { | ||
"test": "deno fmt --check && deno lint && deno test --allow-read --allow-net", | ||
"generate-lcov": "rm -rf .coverage && deno test --reporter=dot --allow-read --allow-net --coverage=.coverage && deno coverage --exclude=fixtures --exclude=test --lcov --output=lcov.info .coverage", | ||
"test:coverage": "deno task generate-lcov && deno coverage --exclude=fixtures --exclude=test .coverage src" | ||
"generate-lcov": "rm -rf .coverage && deno test --allow-read --allow-net --coverage=.coverage && deno coverage --exclude=fixtures --exclude=test --lcov --output=lcov.info .coverage", | ||
"test:coverage": "deno task generate-lcov && deno coverage --detailed --exclude=fixtures --exclude=test .coverage src" | ||
}, | ||
"test": { | ||
"include": ["src/tests.ts"] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// This file only exists as a 'shim' for deno.land, as this package was | ||
// previously published to deno.land to only include the contents of the `./src` | ||
// subdirectory. | ||
export * from './src/mock.ts'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// This file only exists as a 'shim' for deno.land, as this package was | ||
// previously published to deno.land to only include the contents of the `./src` | ||
// subdirectory. | ||
export * from './src/mod.ts'; |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { parse } from "./deps.ts"; | ||
import { parseArgs } from "@std/cli/parse-args"; | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import type { Protocol } from "./types.ts"; | ||
|
||
// List of slack-cli communication protocols supported | ||
|
@@ -13,10 +13,9 @@ const SUPPORTED_NAMED_PROTOCOLS = [ | |
* and the CLI reads both stdout and stderr and combines them to interpret the hook response. | ||
* This simplistic protocol has inherent limitations: cannot log diagnostic info! | ||
* @param args command-line arguments passed to this process | ||
* @returns {Protocol} | ||
*/ | ||
export const BaseProtocol = function (args: string[]): Protocol { | ||
const { manifest: manifestOnly = false } = parse(args); | ||
const { manifest: manifestOnly = false } = parseArgs(args); | ||
// If the particular hook invocation is requesting for manifest generation, we ensure any logging is a no-op, | ||
// so as to not litter stdout with logging - and confuse the CLI's manifest JSON payload parsing. | ||
const loggerMethod = manifestOnly ? () => {} : console.log; | ||
|
@@ -32,9 +31,12 @@ export const BaseProtocol = function (args: string[]): Protocol { | |
/** | ||
* Protocol implementation that only uses stdout, but uses message boundaries to differentiate between | ||
* diagnostic information and hook responses. | ||
* @param args command-line arguments passed to this process | ||
*/ | ||
export const MessageBoundaryProtocol = function (args: string[]): Protocol { | ||
const { boundary } = parse( | ||
export const MessageBoundaryProtocol = function ( | ||
args: string[], | ||
): Required<Pick<Protocol, "getCLIFlags">> & Protocol { | ||
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. The base |
||
const { boundary } = parseArgs( | ||
args, | ||
); | ||
if (!boundary) throw new Error("no boundary argument provided!"); | ||
|
@@ -62,10 +64,9 @@ const PROTOCOL_MAP = { | |
* Based on the arguments provided by the CLI to the SDK hook process, returns an appropriate Protocol interface | ||
* for communicating with the CLI over the specified protocol. | ||
* @param args string[] An array of strings representing the command-line flags/arguments passed to the hook | ||
* @returns Protocol An object implementing the Protocol interface | ||
*/ | ||
export const getProtocolInterface = function (args: string[]): Protocol { | ||
const { protocol: protocolRequestedByCLI } = parse( | ||
const { protocol: protocolRequestedByCLI } = parseArgs( | ||
args, | ||
); | ||
if (protocolRequestedByCLI) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// This file only exists as a 'shim' for deno.land, as this package was | ||
// previously published to deno.land to only include the contents of the `./src` | ||
// subdirectory. | ||
export * from './src/types.ts'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this export implementation 💯