Skip to content

Commit

Permalink
Update Readme and add License to dist headers (#34)
Browse files Browse the repository at this point in the history
* Update Readme and add License to dist headers

* .

* .

* .

* .
  • Loading branch information
Eyal-Shalev committed Sep 22, 2021
1 parent bc73cc7 commit b759d3a
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 22 deletions.
35 changes: 22 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
tags:
- v*

env:
BUNDLE_NAME: async_channels

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -57,34 +60,43 @@ jobs:
runs-on: ubuntu-latest
needs: build
env:
BUNDLE_NAME: async_channels
FORMATS: |
es
esm
amd
cjs
iife
umd
system
steps:
# Checkout the project for the LICENSE_HEADER file
- name: Git Checkout
uses: actions/checkout@v2

- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: 14.x

- name: Setup Rollup
run: npm install --global rollup rollup-plugin-terser rollup-plugin-dts typescript
run: npm install --global rollup@^2.57.0 rollup-plugin-terser@^7.0.2 rollup-plugin-dts@^4.0.0 rollup-plugin-license@^2.5.0 typescript

- uses: actions/download-artifact@v2
with:
name: dist
path: dist

# The package.json is needed for the license plugin
- uses: actions/download-artifact@v2
with:
name: github-package-json
path: "."

- name: Create Bundles
run: |
rollup dist/esm/mod.js --file dist/bundle.d.ts --format "es" --plugin dts
for f in $FORMATS; do rollup dist/esm/mod.js --file dist/"$f".bundle.js --format "$f" --name "$BUNDLE_NAME"; done
for f in $FORMATS; do rollup dist/esm/mod.js --file dist/"$f".bundle.min.js --format "$f" --name "$BUNDLE_NAME" --plugin terser; done
rollup dist/esm/mod.js --file "dist/${BUNDLE_NAME}.d.ts" --format "es" --plugin dts --plugin "license={banner: { content: {file: 'LICENSE_HEADER'}, commentStyle: 'ignored'}}"
for f in $FORMATS; do rollup dist/esm/mod.js --file "dist/${BUNDLE_NAME}.$f.js" --format "$f" --name "${BUNDLE_NAME}" --plugin "license={banner: { content: {file: 'LICENSE_HEADER'}, commentStyle: 'ignored'}}"; done
for f in $FORMATS; do rollup dist/esm/mod.js --file "dist/${BUNDLE_NAME}.$f.min.js" --format "$f" --name "${BUNDLE_NAME}" --plugin terser --plugin "license={banner: { content: {file: 'LICENSE_HEADER'}, commentStyle: 'ignored'}}"; done
- uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -184,10 +196,8 @@ jobs:
files: |
LICENSE
README.md
dist/esm
dist/bundle.d.ts
dist/*.bundle.js
dist/*.bundle.min.js
dist/*.js
dist/*.d.ts
- uses: marvinpinto/action-automatic-releases@latest
if: ${{ ! steps.get_version.outputs.IS_PRE }}
Expand All @@ -198,6 +208,5 @@ jobs:
files: |
LICENSE
README.md
dist/esm
dist/*.bundle.js
dist/*.bundle.min.js
dist/*.js
dist/*.d.ts
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.
14 changes: 14 additions & 0 deletions LICENSE_HEADER
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
This file is part of async_channels.

async_channels is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

async_channels is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with async_channels. If not, see <https://www.gnu.org/licenses/>.
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,67 @@
Inspired by `Go` & `Clojure` Channels, `async_channels` provides channels as an
asynchronous communication method between asynchronous functions.

## Installation

### Vanilla JS (CDN)

Import the module from one of the CDNs that mirror
[npmjs.com](https://npmjs.com):

- [skypack/@eyalsh/async_channels](https://skypack.dev/view/@eyalsh/async_channels)
- [unpkg/@eyalsh/async_channels](https://unpkg.com/@eyalsh/async_channels/dist/async_channels.esm.js)

```javascript
import { Channel } from "https://cdn.skypack.dev/@eyalsh/async_channels";
const ch = new Channel();
// ...
```

### Vanilla JS (Download)

A compiled version exists for every major dependency management system in the
[releases section](https://github.com/Eyal-Shalev/async_channels/releases).\
Download one of them and import it

```javascript
import { Channel } from "/path/to/async_channels.esm.js";
const ch = new Channel();
// ...
```

### NPM (ESM)

Released under both npmjs & github packages:

- [npmjs.com:@eyalsh/async_channels](https://www.npmjs.com/package/@eyalsh/async_channels)
- [github.com:@Eyal-Shalev/async_channels](https://github.com/Eyal-Shalev/async_channels/packages/983326)

```javascript
import { Channel } from "@eyalsh/async_channels"; // or "@eyal-shalev/async_channels" for github packages.
const ch = new Channel();
// ...
```

### NPM (CommonJS)

Released under both npmjs & github packages:

- [npmjs.com:@eyalsh/async_channels](https://www.npmjs.com/package/@eyalsh/async_channels)
- [github.com:@Eyal-Shalev/async_channels](https://github.com/Eyal-Shalev/async_channels/packages/983326)

```javascript
const { Channel } = require("@eyalsh/async_channels"); // or "@eyal-shalev/async_channels" for github packages.
const ch = new Channel();
// ...
```

### Deno

```typescript
import { Channel } from "https://deno.land/x/async_channels/mod.ts";
const ch = new Channel<unknown>();
```

## Example

```typescript
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
BroadcastChannel,
Channel,
} from "https://cdn.skypack.dev/@eyalsh/async_channels@^v1.0.0-alpha29";
} from "https://cdn.skypack.dev/@eyalsh/async_channels@^v1.0.0-alpha45";

const input = new Channel();

Expand Down
2 changes: 1 addition & 1 deletion examples/todos-static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
useState,
} from "https://cdn.skypack.dev/pin/preact@v10.5.14-NU6DIzRE0F11UYcL6Ija/mode=imports,min/optimized/preact/hooks.js";
import htm from "https://cdn.skypack.dev/pin/htm@v3.1.0-Lnrl6ooU0xR8YCDnwwW6/mode=imports,min/optimized/htm.js";
import { Channel } from "https://cdn.skypack.dev/@eyalsh/async_channels@^v1.0.0-alpha29";
import { Channel } from "https://cdn.skypack.dev/@eyalsh/async_channels@^v1.0.0-alpha45";

// Initialize htm with Preact
const html = htm.bind(h);
Expand Down
2 changes: 1 addition & 1 deletion scripts/package-json.bash
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "$DIR/.." && deno run --lock-write --lock "$DIR/package-json-lock.json" --import-map "./import_map.json" --allow-env="SCOPE,VERSION" --allow-write="./package.json" "$DIR/package-json.ts"
cd "$DIR/.." && deno run --lock "$DIR/package-json-lock.json" --import-map "./import_map.json" --allow-env="SCOPE,VERSION" --allow-write="./package.json" "$DIR/package-json.ts"
10 changes: 5 additions & 5 deletions scripts/package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const data = {
},
license: "GPL-3.0-only",
author: `Eyal Shalev <eyalsh@gmail.com> (https://github.com/Eyal-Shalev)`,
main: "dist/cjs.bundle.js",
module: "dist/es.bundle.js",
types: "dist/bundle.d.ts",
main: `dist/${name}.cjs.js`,
module: `dist/${name}.esm.js`,
types: `dist/${name}.d.ts`,
type: "module",
repository: {
type: "git",
Expand All @@ -40,8 +40,8 @@ const data = {
},
exports: {
".": {
require: "./dist/cjs.bundle.js",
import: "./dist/es.bundle.js",
require: `./dist/${name}.cjs.js`,
import: `./dist/${name}.esm.js`,
},
},
};
Expand Down

0 comments on commit b759d3a

Please sign in to comment.