diff --git a/.github/workflows/npm-release.yml b/.github/workflows/npm-release.yml deleted file mode 100644 index 1d1b8464f..000000000 --- a/.github/workflows/npm-release.yml +++ /dev/null @@ -1,46 +0,0 @@ -# This workflow will install Deno then run Deno lint and test. -# For more information see: https://github.com/denoland/setup-deno - -name: Release to NPM - -on: - push: - tags: - - "effection-v*" - -permissions: - contents: read - -jobs: - release: - runs-on: ubuntu-latest - - steps: - - name: checkout - uses: actions/checkout@v4 - - - name: setup deno - uses: denoland/setup-deno@v2 - with: - deno-version: v2.x - - - name: Get Version - id: vars - run: echo ::set-output name=version::$(echo ${{github.ref_name}} | sed 's/^effection-v//') - - - name: Setup Node - uses: actions/setup-node@v2 - with: - node-version: 14.x - registry-url: https://registry.npmjs.com - - - name: Build - run: deno task build:npm $NPM_VERSION - env: - NPM_VERSION: ${{steps.vars.outputs.version}} - - - name: Publish - run: npm publish --access=public - working-directory: ./build/npm - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..fbdde1228 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,64 @@ +name: Publish + +on: + push: + tags: + - "effection-v*" + +permissions: + contents: read + id-token: write + +jobs: + publish-npm: + runs-on: ubuntu-latest + + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: setup deno + uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + + - name: Get Version + id: vars + run: echo ::set-output name=version::$(echo ${{github.ref_name}} | sed 's/^effection-v//') + + - name: Setup Node + uses: actions/setup-node@v4.1.0 + with: + node-version: 18.x + registry-url: https://registry.npmjs.com + + - name: Build NPM + run: deno task build:npm ${{steps.vars.outputs.version}} + + - name: Publish NPM + run: npm publish --access=public + working-directory: ./build/npm + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} + + publish-jsr: + runs-on: ubuntu-latest + + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: setup deno + uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + + - name: Get Version + id: vars + run: echo ::set-output name=version::$(echo ${{github.ref_name}} | sed 's/^effection-v//') + + - name: Build JSR + run: deno task build:jsr ${{steps.vars.outputs.version}} + + - name: Publish JSR + run: npx jsr publish --allow-dirty diff --git a/.gitignore b/.gitignore index 0e1ef1b42..7883eb9be 100755 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ # Local Netlify folder .netlify -/build/ +/build/ \ No newline at end of file diff --git a/deno.json b/deno.json index 03923ed9f..258719283 100644 --- a/deno.json +++ b/deno.json @@ -1,8 +1,15 @@ { + "name": "@effection/effection", + "exports": "./mod.ts", + "license": "ISC", + "publish": { + "include": ["lib", "mod.ts", "README.md"] + }, "lock": false, "tasks": { "test": "deno test --allow-run=deno", "test:node": "deno task build:npm 0.0.0 && node test/main/node.mjs hello world", + "build:jsr": "deno run -A tasks/build-jsr.ts", "build:npm": "deno run -A tasks/build-npm.ts" }, "lint": { diff --git a/lib/deps.ts b/lib/deps.ts index d9aa97de8..94593c8db 100644 --- a/lib/deps.ts +++ b/lib/deps.ts @@ -1,2 +1,2 @@ -export { assert } from "https://deno.land/std@0.158.0/testing/asserts.ts"; -export * from "https://deno.land/x/continuation@0.1.5/mod.ts"; +export { assert } from "jsr:@std/assert@1.0.10"; +export * from "jsr:@frontside/continuation@0.1.6"; diff --git a/lib/each.ts b/lib/each.ts index 61ccc5eb8..5e969e223 100644 --- a/lib/each.ts +++ b/lib/each.ts @@ -65,7 +65,7 @@ export function each(stream: Stream): Operation> { }; } -each.next = function next() { +each.next = function next(): Operation { return { name: "each.next()", *[Symbol.iterator]() { diff --git a/lib/ensure.ts b/lib/ensure.ts index b10266102..ccaaea27a 100644 --- a/lib/ensure.ts +++ b/lib/ensure.ts @@ -1,4 +1,4 @@ -import { Operation } from "./types.ts"; +import type { Operation } from "./types.ts"; import { resource } from "./instructions.ts"; /** diff --git a/lib/lift.ts b/lib/lift.ts index 9bdab566a..bca175abe 100644 --- a/lib/lift.ts +++ b/lib/lift.ts @@ -1,5 +1,5 @@ import { shift } from "./deps.ts"; -import { type Operation } from "./types.ts"; +import type { Operation } from "./types.ts"; /** * Convert a simple function into an {@link Operation} diff --git a/lib/main.ts b/lib/main.ts index 119350042..29321db96 100644 --- a/lib/main.ts +++ b/lib/main.ts @@ -1,5 +1,5 @@ import { createContext } from "./context.ts"; -import { type Operation } from "./types.ts"; +import type { Operation } from "./types.ts"; import { action } from "./instructions.ts"; import { run } from "./run.ts"; import { call } from "./call.ts"; diff --git a/lib/run/value.ts b/lib/run/value.ts index a493fbbf3..ac20b6613 100644 --- a/lib/run/value.ts +++ b/lib/run/value.ts @@ -1,5 +1,5 @@ import { type Computation, reset } from "../deps.ts"; -import { type Resolve } from "../types.ts"; +import type { Resolve } from "../types.ts"; import { shiftSync } from "../shift-sync.ts"; export function* createValue(): Computation<[Resolve, Computation]> { diff --git a/lib/signal.ts b/lib/signal.ts index db72ebe9b..5f9101afa 100644 --- a/lib/signal.ts +++ b/lib/signal.ts @@ -3,6 +3,7 @@ import type { Stream, Subscription } from "./types.ts"; import { createQueue, type Queue } from "./queue.ts"; import { resource } from "./instructions.ts"; import { createContext } from "./context.ts"; +import type { Context } from "./types.ts"; /** * Convert plain JavaScript function calls into a {@link Stream} that can @@ -81,7 +82,7 @@ export interface Signal extends Stream { * } * ``` */ -export const SignalQueueFactory = createContext( +export const SignalQueueFactory: Context = createContext( "Signal.createQueue", createQueue, ); diff --git a/tasks/build-jsr.ts b/tasks/build-jsr.ts new file mode 100644 index 000000000..98b178d9b --- /dev/null +++ b/tasks/build-jsr.ts @@ -0,0 +1,9 @@ +import jsonDeno from "../deno.json" with { type: "json" }; + +await Deno.writeTextFile( + new URL("../deno.json", import.meta.url), + JSON.stringify({ + ...jsonDeno, + version: Deno.env.get("VERSION"), + }), +); diff --git a/tasks/build-npm.ts b/tasks/build-npm.ts index 5b2ab9361..529938c6b 100644 --- a/tasks/build-npm.ts +++ b/tasks/build-npm.ts @@ -1,7 +1,4 @@ -import { - build, - emptyDir, -} from "https://deno.land/x/dnt@0.36.0/mod.ts?pin=v123"; +import { build, emptyDir } from "jsr:@deno/dnt@0.41.3"; const outDir = "./build/npm"; @@ -21,7 +18,7 @@ await build({ test: false, typeCheck: false, compilerOptions: { - lib: ["esnext", "dom"], + lib: ["ESNext", "DOM"], target: "ES2020", sourceMap: true, }, @@ -31,8 +28,8 @@ await build({ version, description: "Structured concurrency and effects for JavaScript", license: "ISC", + author: "engineering@frontside.com", repository: { - author: "engineering@frontside.com", type: "git", url: "git+https://github.com/thefrontside/effection.git", }, diff --git a/test/resource.test.ts b/test/resource.test.ts index a3b48f3db..ed5a14ba0 100644 --- a/test/resource.test.ts +++ b/test/resource.test.ts @@ -1,5 +1,12 @@ import { describe, expect, it } from "./suite.ts"; -import { Operation, resource, run, sleep, spawn, suspend } from "../mod.ts"; +import { + type Operation, + resource, + run, + sleep, + spawn, + suspend, +} from "../mod.ts"; type State = { status: string };