Skip to content

Commit

Permalink
feat!: publish as esm-only
Browse files Browse the repository at this point in the history
Following on from the conversation in ipld/ipld#224 this converts this repo to use the latest aegir with Unified CI.

1. Remove all dev deps apart from `aegir`
1. Run the `npx aegir check-project` command to update project config
1. Remove non-Unified-CI github actions
1. Update imports to import from `src/index.js` instead of `ipld-garbage`
1. Rename `test/*.js` to `test/*.spec.js` so aegir can find them
1. Update `tsconfig.json` to extend config from `aegir`
1. Remove `"main"` and other unused fields from `package.json`
1. Use `chai` from `aegir` pre-configured with plugins we use
1. Fixes everything the linter complains about
1. Upgrades multiformats to 10.x.x

This will need a follow up PR to `protocol/.github` to add this repo to the Unified CI [config file](https://github.com/protocol/.github/blob/master/configs/js.json) so it'll get
automated config updates in the future.

Apologies that this PR is so noisy, most of it is from the `check-project` command
  • Loading branch information
achingbrain committed Oct 18, 2022
1 parent 81dab8c commit 292e4c8
Show file tree
Hide file tree
Showing 14 changed files with 376 additions and 152 deletions.
23 changes: 9 additions & 14 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'daily'
commit-message:
prefix: 'chore'
include: 'scope'
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'daily'
commit-message:
prefix: 'chore'
include: 'scope'
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
commit-message:
prefix: "deps"
prefix-development: "deps(dev)"
8 changes: 8 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Automerge
on: [ pull_request ]

jobs:
automerge:
uses: protocol/.github/.github/workflows/automerge.yml@master
with:
job: 'automerge'
145 changes: 145 additions & 0 deletions .github/workflows/js-test-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: test & maybe release
on:
push:
branches:
- master # with #262 - ${{{ github.default_branch }}}
pull_request:
branches:
- master # with #262 - ${{{ github.default_branch }}}

jobs:

check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present lint
- run: npm run --if-present dep-check

test-node:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [16]
fail-fast: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:node
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: node

test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:chrome
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: chrome

test-chrome-webworker:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:chrome-webworker
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: chrome-webworker

test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:firefox
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: firefox

test-firefox-webworker:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:firefox-webworker
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: firefox-webworker

test-electron-main:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npx xvfb-maybe npm run --if-present test:electron-main
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: electron-main

test-electron-renderer:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npx xvfb-maybe npm run --if-present test:electron-renderer
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: electron-renderer

release:
needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master' # with #262 - 'refs/heads/${{{ github.default_branch }}}'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- uses: ipfs/aegir/actions/docker-login@master
with:
docker-token: ${{ secrets.DOCKER_TOKEN }}
docker-username: ${{ secrets.DOCKER_USERNAME }}
- run: npm run --if-present release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist/
node_modules/
coverage/
.coverage
package-lock.json
15 changes: 3 additions & 12 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
Copyright 2020 Rod Vagg
This project is dual licensed under MIT and Apache-2.0.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
MIT: https://www.opensource.org/licenses/mit
Apache-2.0: https://www.apache.org/licenses/license-2.0
5 changes: 5 additions & 0 deletions LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
19 changes: 19 additions & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The MIT License (MIT)

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.
54 changes: 37 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
# ipld-garbage
# ipld-garbage <!-- omit in toc -->

Generate garbage objects conformant with the [IPLD Data Model](https://docs.ipld.io/#the-data-model). Useful for fuzzing.
[![codecov](https://img.shields.io/codecov/c/github/achingbrain/js-ipld-garbage.svg?style=flat-square)](https://codecov.io/gh/achingbrain/js-ipld-garbage)
[![CI](https://img.shields.io/github/workflow/status/achingbrain/js-ipld-garbage/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/js-ipld-garbage/actions/workflows/js-test-and-release.yml)

> Garbage data generator for the IPLD Data Model
## Table of contents <!-- omit in toc -->

- [Install](#install)
- [API](#api)
- [`options`](#options)
- [License](#license)
- [Contribute](#contribute)

## Install

```console
$ npm i ipld-garbage
```

Based on [substack's "garbage"](https://github.com/substack/node-garbage).

Expand All @@ -12,8 +29,8 @@ Where `count` determines the approximate target number of bytes a garbage object

### `options`

* `options.weights` an object with properties matching the IPLD data model types (see below) with numbers (>= `0`) that will weight randomness selection. Default: `{ list: 1, map: 1, string: 1, bytes: 1, boolean: 1, integer: 1, float: 1, null: 1, CID: 1 }`.
* `options.initialWeights` an object, similar to `options.weights`, that only applies to the initial object. Subsequent object creation will use `options.weights`. This allows for weighting of the container object to be more typical of IPLD data, which is typically some kind of map or list. Default `{ list: 10, map: 10, string: 1, bytes: 1, boolean: 1, integer: 1, float: 1, null: 1, CID: 1 }`.
- `options.weights` an object with properties matching the IPLD data model types (see below) with numbers (>= `0`) that will weight randomness selection. Default: `{ list: 1, map: 1, string: 1, bytes: 1, boolean: 1, integer: 1, float: 1, null: 1, CID: 1 }`.
- `options.initialWeights` an object, similar to `options.weights`, that only applies to the initial object. Subsequent object creation will use `options.weights`. This allows for weighting of the container object to be more typical of IPLD data, which is typically some kind of map or list. Default `{ list: 10, map: 10, string: 1, bytes: 1, boolean: 1, integer: 1, float: 1, null: 1, CID: 1 }`.

Where you provide a custom `weights`, it will override `initialWeights`. e.g. `{ weights: { float: 0 } }` will result in no floats at all, even for the initial object.

Expand All @@ -39,22 +56,25 @@ Might yield:

All IPLD Data Model types are within range for random creation, including top-level returns (a single call to `garbage()` might just return a `null`):

* null
* boolean
* integer
* float
* string
* bytes
* list
* map
* CID
- null
- boolean
- integer
- float
- string
- bytes
- list
- map
- CID

Use `import { toString } from 'ipld-garbage/to-string'` to import a function that can turn an object returned by `garbage()` to a JavaScript string. This may be useful for generating a fixed set of test fixtures rather than relying on randomness during each run.

## License and Copyright
## License

Licensed under either of

Copyright 2020 Rod Vagg
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
## Contribute

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

0 comments on commit 292e4c8

Please sign in to comment.