Skip to content

Commit

Permalink
Merge pull request #947 from thefrontside/tm/publish-jsr
Browse files Browse the repository at this point in the history
Publish v4 to JSR
  • Loading branch information
taras authored Dec 22, 2024
2 parents b9e4eff + 9c4c36f commit 60b27e0
Show file tree
Hide file tree
Showing 41 changed files with 165 additions and 99 deletions.
46 changes: 0 additions & 46 deletions .github/workflows/npm-release.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 --token=${{secrets.JSR_TOKEN}}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

# Local Netlify folder
.netlify
/build/
/build/
9 changes: 8 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
{
"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:npm": "deno run -A tasks/build-npm.ts",
"bench": "deno run -A tasks/bench.ts"
"bench": "deno run -A tasks/bench.ts",
"build:jsr": "deno run -A tasks/build-jsr.ts"
},
"lint": {
"rules": {
Expand Down
2 changes: 1 addition & 1 deletion lib/action.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Err, Ok } from "./result.ts";
import { Effect, Operation } from "./types.ts";
import type { Effect, Operation } from "./types.ts";

interface Resolver<T> {
(resolve: (value: T) => void, reject: (error: Error) => void): () => void;
Expand Down
2 changes: 1 addition & 1 deletion lib/call.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { constant } from "./constant.ts";
import { action } from "./action.ts";
import { Operation } from "./types.ts";
import type { Operation } from "./types.ts";

/**
* A uniform integration type representing anything that can be evaluated
Expand Down
4 changes: 2 additions & 2 deletions lib/callcc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { lift } from "./lift.ts";
import { Err, Ok, Result, unbox } from "./result.ts";
import { Operation } from "./types.ts";
import { Err, Ok, type Result, unbox } from "./result.ts";
import type { Operation } from "./types.ts";
import { withResolvers } from "./with-resolvers.ts";
import { spawn } from "./spawn.ts";
import { encapsulate } from "./task.ts";
Expand Down
2 changes: 1 addition & 1 deletion lib/context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Context, Effect, Operation, Scope } from "./types.ts";
import type { Context, Effect, Operation, Scope } from "./types.ts";
import { Ok } from "./result.ts";
import { Do } from "./do.ts";

Expand Down
2 changes: 1 addition & 1 deletion lib/contexts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext } from "./context.ts";
import { Coroutine, Scope } from "./types.ts";
import type { Coroutine, Scope } from "./types.ts";

export const Routine = createContext<Coroutine<unknown>>(
"@effection/coroutine",
Expand Down
2 changes: 1 addition & 1 deletion lib/coroutine.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Generation } from "./contexts.ts";
import { ReducerContext } from "./reducer.ts";
import { Ok } from "./result.ts";
import { Coroutine, Operation, Scope, Subscriber } from "./types.ts";
import type { Coroutine, Operation, Scope, Subscriber } from "./types.ts";

export interface CoroutineOptions<T> {
scope: Scope;
Expand Down
4 changes: 2 additions & 2 deletions lib/do.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Result } from "./result.ts";
import { Effect, Operation } from "./types.ts";
import type { Result } from "./result.ts";
import type { Effect, Operation } from "./types.ts";

/**
* Perform a single Effect as an Operation
Expand Down
4 changes: 2 additions & 2 deletions lib/drain.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Result } from "./result.ts";
import { Subscriber } from "./types.ts";
import type { Result } from "./result.ts";
import type { Subscriber } from "./types.ts";

export function drain<T>(end: (result: Result<T>) => void): Subscriber<T> {
return (next) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/each.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function each<T>(stream: Stream<T, unknown>): Operation<Iterable<T>> {
};
}

each.next = function next() {
each.next = function next(): Operation<void> {
return {
name: "each.next()",
*[Symbol.iterator]() {
Expand Down
2 changes: 1 addition & 1 deletion lib/ensure.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Operation } from "./types.ts";
import type { Operation } from "./types.ts";
import { resource } from "./resource.ts";

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/lazy-promise.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Err, Ok, Result } from "./result.ts";
import { Err, Ok, type Result } from "./result.ts";

type PromiseWithResolvers<T> = ReturnType<typeof Promise.withResolvers<T>>;

Expand Down
2 changes: 1 addition & 1 deletion lib/lift.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { action } from "./action.ts";
import { type Operation } from "./types.ts";
import type { Operation } from "./types.ts";

/**
* Convert a simple function into an {@link Operation}
Expand Down
2 changes: 1 addition & 1 deletion lib/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext } from "./context.ts";
import { type Operation } from "./types.ts";
import type { Operation } from "./types.ts";
import { callcc } from "./callcc.ts";
import { run } from "./run.ts";
import { useScope } from "./scope.ts";
Expand Down
2 changes: 1 addition & 1 deletion lib/race.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { spawn } from "./spawn.ts";
import { encapsulate, trap } from "./task.ts";
import type { Operation, Task, Yielded } from "./types.ts";
import { withResolvers } from "./with-resolvers.ts";
import { Err, Ok, Result } from "./result.ts";
import { Err, Ok, type Result } from "./result.ts";
//import { useScope } from "./scope.ts";
//import { transfer } from "./scope.ts";

Expand Down
4 changes: 2 additions & 2 deletions lib/reducer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContext } from "./context.ts";
import { Err, Ok, Result } from "./result.ts";
import { Coroutine, Subscriber } from "./types.ts";
import { Err, Ok, type Result } from "./result.ts";
import type { Coroutine, Subscriber } from "./types.ts";

export class Reducer {
reducing = false;
Expand Down
2 changes: 1 addition & 1 deletion lib/resource.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { suspend } from "./suspend.ts";
import { spawn } from "./spawn.ts";
import { Operation } from "./types.ts";
import type { Operation } from "./types.ts";
import { trap } from "./task.ts";
import { Ok } from "./result.ts";
import { useCoroutine } from "./coroutine.ts";
Expand Down
2 changes: 1 addition & 1 deletion lib/run.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Operation, Task } from "./types.ts";
import type { Operation, Task } from "./types.ts";

import { global } from "./scope.ts";

Expand Down
13 changes: 11 additions & 2 deletions lib/scope.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { Children, Generation } from "./contexts.ts";
import { Context, Effect, Future, Operation, Scope, Task } from "./types.ts";
import type {
Context,
Effect,
Future,
Operation,
Scope,
Task,
} from "./types.ts";
import { Err, Ok, unbox } from "./result.ts";
import { createTask } from "./task.ts";

export const [global] = createScopeInternal();
const scope: [ScopeInternal, () => Operation<void>] = createScopeInternal();

export const global = scope[0];

export function createScope(
parent: Scope = global,
Expand Down
3 changes: 2 additions & 1 deletion lib/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Stream, Subscription } from "./types.ts";
import { createQueue, type Queue } from "./queue.ts";
import { resource } from "./resource.ts";
import { createContext } from "./context.ts";
import type { Context } from "./types.ts";

/**
* Convert plain JavaScript function calls into a {@link Stream} that can
Expand Down Expand Up @@ -81,7 +82,7 @@ export interface Signal<T, TClose> extends Stream<T, TClose> {
* }
* ```
*/
export const SignalQueueFactory = createContext(
export const SignalQueueFactory: Context<typeof createQueue> = createContext(
"Signal.createQueue",
createQueue,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/sleep.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Operation } from "./types.ts";
import type { Operation } from "./types.ts";
import { action } from "./action.ts";

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/spawn.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Ok } from "./result.ts";
import { ScopeInternal } from "./scope.ts";
import { createTask, NewTask } from "./task.ts";
import type { ScopeInternal } from "./scope.ts";
import { createTask, type NewTask } from "./task.ts";
import type { Effect, Operation, Task } from "./types.ts";

export function* spawn<T>(op: () => Operation<T>): Operation<Task<T>> {
Expand Down
2 changes: 1 addition & 1 deletion lib/suspend.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { action } from "./action.ts";
import { Operation } from "./types.ts";
import type { Operation } from "./types.ts";

export function suspend(): Operation<void> {
return action(() => () => {}, "suspend");
Expand Down
4 changes: 2 additions & 2 deletions lib/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Routine } from "./contexts.ts";
import { createCoroutine } from "./coroutine.ts";
import { drain } from "./drain.ts";
import { lazyPromise, lazyPromiseWithResolvers } from "./lazy-promise.ts";
import { Just, Maybe, Nothing } from "./maybe.ts";
import { Err, Ok, Result, unbox } from "./result.ts";
import { Just, type Maybe, Nothing } from "./maybe.ts";
import { Err, Ok, type Result, unbox } from "./result.ts";
import { createScopeInternal, type ScopeInternal } from "./scope.ts";
import type { Coroutine, Operation, Resolve, Scope, Task } from "./types.ts";
import { withResolvers } from "./with-resolvers.ts";
Expand Down
2 changes: 1 addition & 1 deletion lib/with-resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Err, Ok, Result } from "./result.ts";
import { Err, Ok, type Result } from "./result.ts";
import { action } from "./action.ts";
import type { Operation } from "./types.ts";

Expand Down
6 changes: 3 additions & 3 deletions tasks/bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import {
createQueue,
each,
main,
Operation,
type Operation,
spawn,
Task,
type Task,
withResolvers,
} from "../mod.ts";
import { useWorker } from "./bench/worker.ts";
import scenarios from "./bench/scenarios.ts";
import {
import type {
BenchmarkDoneEvent,
BenchmarkOptions,
BenchmarkWorkerEvent,
Expand Down
2 changes: 1 addition & 1 deletion tasks/bench/scenarios/effection.events.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { scenario } from "./scenario.ts";
import { each, on, Operation, sleep, spawn } from "../../../mod.ts";
import { each, on, type Operation, sleep, spawn } from "../../../mod.ts";

await scenario("effection.events", start);

Expand Down
2 changes: 1 addition & 1 deletion tasks/bench/scenarios/effection.recursion.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { call, Operation } from "../../../mod.ts";
import { call, type Operation } from "../../../mod.ts";
import { scenario } from "./scenario.ts";

await scenario("effection.recursion", recurse);
Expand Down
2 changes: 1 addition & 1 deletion tasks/bench/scenarios/rxjs.events.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fromEvent, Observable, Subject, takeUntil } from "npm:rxjs";
import { scenario } from "./scenario.ts";
import { action, Operation, sleep, spawn } from "../../../mod.ts";
import { action, type Operation, sleep, spawn } from "../../../mod.ts";

await scenario("rxjs.events", run);

Expand Down
2 changes: 1 addition & 1 deletion tasks/bench/scenarios/rxjs.recursion.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defer, from, Observable, repeat } from "npm:rxjs";
import { scenario } from "./scenario.ts";
import { action, Operation } from "../../../mod.ts";
import { action, type Operation } from "../../../mod.ts";

await scenario("rxjs.recursion", run);

Expand Down
Loading

0 comments on commit 60b27e0

Please sign in to comment.