diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..08856d9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,44 @@ +############################### +# Git Line Endings # +############################### + +# Set default behaviour to automatically normalize line endings. +* text=auto + +# Force batch scripts to always use CRLF line endings so that if a repo is accessed +# in Windows via a file share from Linux, the scripts will work. +*.{cmd,[cC][mM][dD]} text eol=crlf +*.{bat,[bB][aA][tT]} text eol=crlf + +# Force bash scripts to always use LF line endings so that if a repo is accessed +# in Unix via a file share from Windows, the scripts will work. +*.sh text eol=lf + +############################### +# Git Large File System (LFS) # +############################### + +# Archives +*.7z filter=lfs diff=lfs merge=lfs -text +*.br filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text + +# Documents +*.pdf filter=lfs diff=lfs merge=lfs -text + +# Images +*.gif filter=lfs diff=lfs merge=lfs -text +*.ico filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.psd filter=lfs diff=lfs merge=lfs -text +*.webp filter=lfs diff=lfs merge=lfs -text + +# Fonts +*.woff2 filter=lfs diff=lfs merge=lfs -text + +# Other +*.exe filter=lfs diff=lfs merge=lfs -text \ No newline at end of file diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml new file mode 100644 index 0000000..6c3f21e --- /dev/null +++ b/.github/workflows/npm.yml @@ -0,0 +1,22 @@ +name: NPM +on: + pull_request: + branches: + - main + push: + branches: + - main + +jobs: + publish: + name: Publishing + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: denoland/setup-deno@v1.1.0 + with: + deno-version: v1.x # Run with latest stable Deno. + + - name: Build and Test NPM Package + run: deno run -A scripts/build_npm.ts ${{ github.ref }} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ce21a75..660fd6d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -32,5 +32,20 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} # Generated by GitHub. path-to-lcov: cov.lcov + - name: Build NPM Package + run: deno run -A scripts/build_npm.ts ${{ github.ref }} + + - uses: actions/setup-node@v2 + with: + node-version: "16.x" + registry-url: "https://registry.npmjs.org" + + - name: Publish NPM Package + run: | + cd npm + npm publish --access=public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Clear README Image Cache run: deno run --unstable --allow-net ./scripts/clear-readme-cache.ts \ No newline at end of file diff --git a/.gitignore b/.gitignore index 40b878d..62806ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ -node_modules/ \ No newline at end of file +node_modules/ +npm/ +cov/ +cov.lcov \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d379fc7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Michael Tyson + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index dd27db4..36c9958 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,21 @@ [![deno land](https://badgen.net/github/release/myty/dispatch-queue?color=green&label=deno.land)](https://deno.land/x/dispatch_queue) [![Coverage Status](https://badgen.net/coveralls/c/github/myty/dispatch-queue?color=green)](https://coveralls.io/github/myty/dispatch-queue?branch=main) -A deno and npm dispatch queue with the ability to configure multiple queue -processors. +A dispatch queue with the ability to configure multiple queue processors. ## Installation +### Node.js + +```bash +# npm +npm install --save @myty/dispatch-queue +# yarn +yarn add @myty/dispatch-queue +# pnpm +pnpm install --save @myty/dispatch-queue +``` + ### Deno ```bash diff --git a/scripts/build_npm.ts b/scripts/build_npm.ts new file mode 100644 index 0000000..bf36489 --- /dev/null +++ b/scripts/build_npm.ts @@ -0,0 +1,31 @@ +import { build, emptyDir } from "https://deno.land/x/dnt@0.30.0/mod.ts"; + +await emptyDir("./npm"); + +await build({ + entryPoints: ["./mod.ts"], + outDir: "./npm", + test: false, + shims: {}, + compilerOptions: { + lib: ["es2018", "dom"], + }, + package: { + name: "@myty/dispatch-queue", + version: Deno.args[0].substring("refs/tags/v".length), + description: + "A dispatch queue with the ability to configure multiple queue processors.", + license: "MIT", + repository: { + type: "git", + url: "git+https://github.com/myty/dispatch-queue.git", + }, + bugs: { + url: "https://github.com/myty/dispatch-queue/issues", + }, + }, +}); + +// post build steps +Deno.copyFileSync("LICENSE", "npm/LICENSE"); +Deno.copyFileSync("README.md", "npm/README.md"); diff --git a/tests/deps.ts b/tests/deps.ts index bef9fb5..c4d65a1 100644 --- a/tests/deps.ts +++ b/tests/deps.ts @@ -12,7 +12,10 @@ export { } from "https://deno.land/std@0.158.0/testing/asserts.ts"; export { assertSpyCall, + assertSpyCalls, + returnsNext, spy, + stub, } from "https://deno.land/std@0.158.0/testing/mock.ts"; -export type { Spy } from "https://deno.land/std@0.158.0/testing/mock.ts"; +export type { Spy, Stub } from "https://deno.land/std@0.158.0/testing/mock.ts"; export { Deferred } from "https://deno.land/x/deferred@v1.0.1/mod.ts"; diff --git a/tests/dispatch-queue.test.ts b/tests/dispatch-queue.test.ts index 33830de..b9b4e4d 100644 --- a/tests/dispatch-queue.test.ts +++ b/tests/dispatch-queue.test.ts @@ -3,24 +3,22 @@ import { assert, assertExists, assertSpyCall, + assertSpyCalls, beforeEach, Deferred, delay, describe, it, + returnsNext, Spy, spy, + Stub, + stub, } from "./deps.ts"; import { DispatchQueue } from "../src/dispatch-queue.ts"; import { DispatchQueueEvents } from "../src/events/events.ts"; import { DispatchQueueWorkerErrorEvent } from "../src/events/worker-error-event.ts"; -import { - assertSpyCalls, - returnsNext, - Stub, - stub, -} from "https://deno.land/std@0.158.0/testing/mock.ts"; import { Queue } from "../src/queue.ts"; import { DispatchQueueRuntimeErrorEvent } from "../src/events/runtime-error-event.ts";