From 395852bdff00f0dfda299ad1d35ed1bee0386d9c Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Tue, 14 Sep 2021 20:56:56 +0200 Subject: [PATCH 01/10] chore: switch to gh actions (#175) Test on gh actions, publish RC on change to master. --- .github/workflows/release.yml | 35 ++++++ .github/workflows/test.yml | 90 ++++++++++++++++ .travis.yml | 102 ------------------ packages/ipfs-unixfs-importer/package.json | 3 +- .../test/chunker-rabin.spec.js | 9 ++ 5 files changed, 136 insertions(+), 103 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..6c080b17 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +name: deploy +on: + push: + branches: + - master + +jobs: + publish-rc: + runs-on: ubuntu-latest + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup node + uses: actions/setup-node@v2 + with: + node-version: 16 + - name: configure Git User + run: | + git config --global user.email "actions@github.com" + git config --global user.name "@$GITHUB_ACTOR" + - name: Authenticate with Registry + run: | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc + npm whoami + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: release + run: npm run release:rc -- --yes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..65d3ba5b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,90 @@ +name: ci +on: + pull_request: + branches: + - master + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + - run: npm install + - run: npm run build + - run: npm run lint + - run: npm run depcheck -- -- -- -p + - run: npm run depcheck -- -- -- -- --unused + test-node: + needs: check + runs-on: ${{ matrix.os }} + name: test ${{ matrix.project }} node ${{ matrix.node }} ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + node: [16] + project: + - ipfs-unixfs + - ipfs-unixfs-exporter + - ipfs-unixfs-importer + fail-fast: true + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + - run: npm install + - run: npm run build + - run: npm run test -- --scope=${{ matrix.project }} -- -- --cov -t node + test-browser: + needs: check + runs-on: ubuntu-latest + name: test ${{ matrix.project }} ${{ matrix.browser }} ${{ matrix.type }} + strategy: + matrix: + project: + - ipfs-unixfs + - ipfs-unixfs-exporter + - ipfs-unixfs-importer + browser: + - chromium + - firefox + type: + - browser + - webworker + fail-fast: true + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + - run: npm install + - run: npm run build + - run: npm run test -- --scope=${{ matrix.project }} -- -- -t ${{ matrix.type }} -- --browser ${{ matrix.browser }} + test-electron: + needs: check + runs-on: ubuntu-latest + name: test ${{ matrix.project }} ${{ matrix.type }} + strategy: + matrix: + project: + - ipfs-unixfs + - ipfs-unixfs-exporter + - ipfs-unixfs-importer + type: + - electron-main + - electron-renderer + fail-fast: true + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + - run: npm install + - run: npm run build + - run: npx lerna link # use publishConfig.directory + - uses: GabrielBB/xvfb-action@v1 + with: + run: npm run test -- --scope=${{ matrix.project }} -- -- -t ${{ matrix.type }} --bail -f ./dist/cjs/node-test/*.spec.js diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5ac5ceaf..00000000 --- a/.travis.yml +++ /dev/null @@ -1,102 +0,0 @@ -language: node_js -cache: npm -dist: focal - -branches: - only: - - master - - /^release\/.*$/ - -services: - - xvfb - -stages: - - check - - test - - cov - - release - -node_js: - - 'lts/*' - - 'node' - -os: - - linux - - osx - - windows - -before_install: - # prevents windows error: npm ERR! ... git-sh-setup: file not found - - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then export PATH=/c/PROGRA~1/Git/usr/bin:/c/PROGRA~1/Git/mingw64/libexec/git-core:$PATH ; fi - # upgrading npm on travis/windows/node 14 is completely broken - - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then export NODE_INSTALL_DIR=`npm prefix -g` ; fi - - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then mv $NODE_INSTALL_DIR/node_modules $NODE_INSTALL_DIR/node_modules_old ; fi - - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then mkdir $NODE_INSTALL_DIR/node_modules ; fi - - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then rm -f $NODE_INSTALL_DIR/npm $NODE_INSTALL_DIR/npm.cmd $NODE_INSTALL_DIR/npm.ps1 $NODE_INSTALL_DIR/npx $NODE_INSTALL_DIR/npx.cmd $NODE_INSTALL_DIR/npx.ps1 ; fi - # workspaces require npm 7 or above - - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then node $NODE_INSTALL_DIR/node_modules_old/npm/bin/npm-cli.js i -g npm@latest ; fi - - if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then npm install -g npm@latest ; fi - # allow windows to run scripts with node 14 and npm 7 (may not be necessary when node 14 is no longer lts) - - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then npm config set script-shell c:/PROGRA~1/Git/bin/bash.exe ; fi - -before_script: npm run build -script: npx nyc -s npm run test -- -- -- -t node --bail -after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov - -jobs: - include: - - stage: check - name: linting - script: - - npm run lint - - - stage: check - name: dep-check (production deps) - script: - - npm run depcheck -- $RUN_SINCE -- -- -p - - - stage: check - name: dep-check (unused deps) - script: - - npm run depcheck -- $RUN_SINCE -- -- -- --unused - - - stage: test - name: chrome - addons: - chrome: stable - script: npm run test -- -- -- -t browser - - - stage: test - name: chrome webworker - addons: - chrome: stable - script: npm run test -- -- -- -t webworker - - - stage: test - name: firefox - addons: - firefox: latest - script: npm run test -- -- -- -t browser --browsers FirefoxHeadless - - - stage: test - name: firefox webworker - addons: - firefox: latest - script: npm run test -- -- -- -t webworker --browsers FirefoxHeadless - - - stage: test - name: electron main - script: - - npx lerna link # use publishConfig.directory - - npm run test -- -- -- -t electron-main -f dist/cjs/node-test/*js - - - stage: release - # only run on changes to master - if: branch = master AND type = push AND fork = false - name: release rc - script: - - echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc - - npm run release:rc -- --yes - -notifications: - email: false diff --git a/packages/ipfs-unixfs-importer/package.json b/packages/ipfs-unixfs-importer/package.json index 80a7c65b..2a5fbe9c 100644 --- a/packages/ipfs-unixfs-importer/package.json +++ b/packages/ipfs-unixfs-importer/package.json @@ -49,7 +49,8 @@ "nyc": "^15.0.0", "readable-stream": "^3.6.0", "rimraf": "^3.0.2", - "util": "^0.12.3" + "util": "^0.12.3", + "wherearewe": "^1.0.0" }, "dependencies": { "@ipld/dag-pb": "^2.0.2", diff --git a/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js b/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js index 9b7f09f9..990f7336 100644 --- a/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js +++ b/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js @@ -7,12 +7,21 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { concat as uint8ArrayConcat } from 'uint8arrays/concat' import asAsyncIterable from './helpers/as-async-iterable.js' import defaultOptions from '../src/options.js' +import { isElectronRenderer } from 'wherearewe' const rawFile = new Uint8Array(Math.pow(2, 20)).fill(1) describe('chunker: rabin', function () { this.timeout(30000) + if (isElectronRenderer) { + it('Does not work on the electron renderer thread - https://github.com/hugomrdias/rabin-wasm/issues/127', function () { + this.skip() + }) + + return + } + it('chunks non flat buffers', async () => { const b1 = new Uint8Array(2 * 256) const b2 = new Uint8Array(1 * 256) From f8f0ca3c460d0ecb606bfdb349de613c12dd8879 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 14 Sep 2021 20:59:20 +0200 Subject: [PATCH 02/10] chore: install and build before publishing rc --- .github/workflows/release.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c080b17..120a0bc2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,7 +29,10 @@ jobs: env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - name: release - run: npm run release:rc -- --yes + run: | + npm install + npm run build + npm run release:rc -- --yes env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} From e298f03e18f4433cf630e3fea5bc9343dce1af3d Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 14 Sep 2021 21:03:04 +0200 Subject: [PATCH 03/10] chore: remove extra action lines --- .github/workflows/release.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 120a0bc2..8070af76 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,17 +18,16 @@ jobs: uses: actions/setup-node@v2 with: node-version: 16 - - name: configure Git User + - name: Configure Git User run: | git config --global user.email "actions@github.com" git config --global user.name "@$GITHUB_ACTOR" - name: Authenticate with Registry run: | echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc - npm whoami env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: release + - name: Release run: | npm install npm run build From 2fb905a167ee0d68466be3e36500115194fb6c0d Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 14 Sep 2021 23:55:20 +0200 Subject: [PATCH 04/10] chore: ignore commits from actions --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8070af76..1168f5b1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,7 @@ on: jobs: publish-rc: runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.author.name, 'Github Actions')" env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -21,7 +22,7 @@ jobs: - name: Configure Git User run: | git config --global user.email "actions@github.com" - git config --global user.name "@$GITHUB_ACTOR" + git config --global user.name "Github Actions" - name: Authenticate with Registry run: | echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc From 07f244ad23ebfd11e5310ab83aee19d8cd006dfa Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 15 Sep 2021 08:01:17 +0200 Subject: [PATCH 05/10] chore: update job names --- .github/workflows/release.yml | 5 +++-- .github/workflows/test.yml | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1168f5b1..16b1a2c9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,11 +1,12 @@ -name: deploy +name: Release RC on: push: branches: - master jobs: - publish-rc: + release-rc: + name: Release RC runs-on: ubuntu-latest if: "!contains(github.event.head_commit.author.name, 'Github Actions')" env: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 65d3ba5b..b3625189 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: ci +name: Test on: pull_request: branches: @@ -6,6 +6,7 @@ on: jobs: check: + name: Check runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -20,7 +21,7 @@ jobs: test-node: needs: check runs-on: ${{ matrix.os }} - name: test ${{ matrix.project }} node ${{ matrix.node }} ${{ matrix.os }} + name: Test ${{ matrix.project }} node ${{ matrix.node }} ${{ matrix.os }} strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] @@ -41,7 +42,7 @@ jobs: test-browser: needs: check runs-on: ubuntu-latest - name: test ${{ matrix.project }} ${{ matrix.browser }} ${{ matrix.type }} + name: Test ${{ matrix.project }} ${{ matrix.browser }} ${{ matrix.type }} strategy: matrix: project: @@ -66,7 +67,7 @@ jobs: test-electron: needs: check runs-on: ubuntu-latest - name: test ${{ matrix.project }} ${{ matrix.type }} + name: Test ${{ matrix.project }} ${{ matrix.type }} strategy: matrix: project: From 273a141b5ee3805bd0ef2dc8ed7870f8c6c8a820 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Fri, 17 Dec 2021 09:04:31 +0100 Subject: [PATCH 06/10] docs: update readmes (#188) Use ESM in docs and remove references to ipld and replace with blockstores. --- packages/ipfs-unixfs-exporter/README.md | 38 +++++++++++++------------ packages/ipfs-unixfs-importer/README.md | 30 ++++++++++--------- packages/ipfs-unixfs/README.md | 4 +-- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/packages/ipfs-unixfs-exporter/README.md b/packages/ipfs-unixfs-exporter/README.md index 7199bcb5..5ad2df74 100644 --- a/packages/ipfs-unixfs-exporter/README.md +++ b/packages/ipfs-unixfs-exporter/README.md @@ -21,13 +21,13 @@ - [Usage](#usage) - [Example](#example) - [API](#api) - - [`exporter(cid, ipld, options)`](#exportercid-ipld-options) + - [`exporter(cid, blockstore, options)`](#exportercid-blockstore-options) - [UnixFSEntry](#unixfsentry) - [Raw entries](#raw-entries) - [CBOR entries](#cbor-entries) - [`entry.content({ offset, length })`](#entrycontent-offset-length-) - - [`walkPath(cid, ipld)`](#walkpathcid-ipld) - - [`recursive(cid, ipld)`](#recursivecid-ipld) + - [`walkPath(cid, blockstore)`](#walkpathcid-blockstore) + - [`recursive(cid, blockstore)`](#recursivecid-blockstore) - [Contribute](#contribute) - [License](#license) @@ -43,21 +43,24 @@ ```js // import a file and export it again -const { importer } = require('ipfs-unixfs-importer') -const { exporter } = require('ipfs-unixfs-exporter') +import { importer } from 'ipfs-unixfs-importer' +import { exporter } from 'ipfs-unixfs-exporter' +import { MemoryBlockstore } from 'blockstore-core/memory' +// Should contain the blocks we are trying to export +const blockstore = new MemoryBlockstore() const files = [] for await (const file of importer([{ path: '/foo/bar.txt', content: new Uint8Array([0, 1, 2, 3]) -}], ipld)) { +}], blockstore)) { files.push(file) } console.info(files[0].cid) // Qmbaz -const entry = await exporter(files[0].cid, ipld) +const entry = await exporter(files[0].cid, blockstore) console.info(entry.cid) // Qmqux console.info(entry.path) // Qmbaz/foo/bar.txt @@ -80,12 +83,12 @@ console.info(bytes) // 0, 1, 2, 3 #### API ```js -const { exporter } = require('ipfs-unixfs-exporter') +import { exporter } from 'ipfs-unixfs-exporter' ``` -### `exporter(cid, ipld, options)` +### `exporter(cid, blockstore, options)` -Uses the given [ipld](https://github.com/ipld/js-ipld) instance to fetch an IPFS node by it's CID. +Uses the given [blockstore][] instance to fetch an IPFS node by it's CID. Returns a Promise which resolves to a `UnixFSEntry`. @@ -202,32 +205,32 @@ for await (const entry of dir.content({ // `entries` contains the first 5 files/directories in the directory ``` -### `walkPath(cid, ipld)` +### `walkPath(cid, blockstore)` `walkPath` will return an async iterator that yields entries for all segments in a path: ```javascript -const { walkPath } = require('ipfs-unixfs-exporter') +import { walkPath } from 'ipfs-unixfs-exporter' const entries = [] -for await (const entry of walkPath('Qmfoo/foo/bar/baz.txt', ipld)) { +for await (const entry of walkPath('Qmfoo/foo/bar/baz.txt', blockstore)) { entries.push(entry) } // entries contains 4x `entry` objects ``` -### `recursive(cid, ipld)` +### `recursive(cid, blockstore)` `recursive` will return an async iterator that yields all entries beneath a given CID or IPFS path, as well as the containing directory. ```javascript -const { recursive } = require('ipfs-unixfs-exporter') +import { recursive } from 'ipfs-unixfs-exporter' const entries = [] -for await (const child of recursive('Qmfoo/foo/bar', ipld)) { +for await (const child of recursive('Qmfoo/foo/bar', blockstore)) { entries.push(entry) } @@ -235,9 +238,8 @@ for await (const child of recursive('Qmfoo/foo/bar', ipld)) { ``` [dag API]: https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md -[ipld-resolver instance]: https://github.com/ipld/js-ipld-resolver +[blockstore]: https://github.com/ipfs/js-ipfs-interfaces/tree/master/packages/interface-blockstore#readme [UnixFS]: https://github.com/ipfs/specs/tree/master/unixfs -[pull-stream]: https://www.npmjs.com/package/pull-stream ## Contribute diff --git a/packages/ipfs-unixfs-importer/README.md b/packages/ipfs-unixfs-importer/README.md index 525cd8ab..0697cf25 100644 --- a/packages/ipfs-unixfs-importer/README.md +++ b/packages/ipfs-unixfs-importer/README.md @@ -18,7 +18,7 @@ - [Usage](#usage) - [Example](#example) - [API](#api) - - [const stream = importer(source, ipld [, options])](#const-stream--importersource-ipld--options) + - [const stream = importer(source, blockstore [, options])](#const-stream--importersource-blockstore--options) - [Overriding internals](#overriding-internals) - [Contribute](#contribute) - [License](#license) @@ -45,7 +45,11 @@ Let's create a little directory to import: And write the importing logic: ```js -const { importer } = require('ipfs-unixfs-importer') +import { importer } from 'ipfs-unixfs-importer' +import { MemoryBlockstore } from 'blockstore-core/memory' + +// Where the blocks will be stored +const blockstore = new MemoryBlockstore() // Import path /tmp/foo/bar const source = [{ @@ -56,9 +60,7 @@ const source = [{ content: fs.createReadStream(file2) }] -// You need to create and pass an ipld-resolve instance -// https://github.com/ipld/js-ipld-resolver -for await (const entry of importer(source, ipld, options)) { +for await (const entry of importer(source, blockstore, options)) { console.info(entry) } ``` @@ -91,10 +93,10 @@ When run, metadata about DAGNodes in the created tree is printed until the root: #### API ```js -const { importer } = require('ipfs-unixfs-importer') +import { importer } from 'ipfs-unixfs-importer' ``` -#### const stream = importer(source, ipld [, options]) +#### const stream = importer(source, blockstore [, options]) The `importer` function returns an async iterator takes a source async iterator that yields objects of the form: @@ -109,9 +111,9 @@ The `importer` function returns an async iterator takes a source async iterator `stream` will output file info objects as files get stored in IPFS. When stats on a node are emitted they are guaranteed to have been written. -`ipld` is an instance of the [`IPLD Resolver`](https://github.com/ipld/js-ipld-resolver) +`blockstore` is an instance of a [blockstore][] -The input's file paths and directory structure will be preserved in the [`dag-pb`](https://github.com/ipld/js-ipld-dag-pb) created nodes. +The input's file paths and directory structure will be preserved in the [`dag-pb`](https://github.com/ipld/js-dag-pb) created nodes. `options` is an JavaScript option that might include the following keys: @@ -150,20 +152,20 @@ Several aspects of the importer are overridable by specifying functions as part - It should yield `Buffer` objects constructed from the `source` or throw an `Error` - `chunker` (function): Optional function that supports the signature `async function * (source, options)` where `source` is an async generator and `options` is an options object - It should yield `Buffer` objects. -- `bufferImporter` (function): Optional function that supports the signature `async function * (entry, ipld, options)` - - This function should read `Buffer`s from `source` and persist them using `ipld.put` or similar +- `bufferImporter` (function): Optional function that supports the signature `async function * (entry, blockstore, options)` + - This function should read `Buffer`s from `source` and persist them using `blockstore.put` or similar - `entry` is the `{ path, content }` entry, where `entry.content` is an async generator that yields Buffers - It should yield functions that return a Promise that resolves to an object with the properties `{ cid, unixfs, size }` where `cid` is a [CID], `unixfs` is a [UnixFS] entry and `size` is a `Number` that represents the serialized size of the [IPLD] node that holds the buffer data. - Values will be pulled from this generator in parallel - the amount of parallelisation is controlled by the `blockWriteConcurrency` option (default: 10) -- `dagBuilder` (function): Optional function that supports the signature `async function * (source, ipld, options)` +- `dagBuilder` (function): Optional function that supports the signature `async function * (source, blockstore, options)` - This function should read `{ path, content }` entries from `source` and turn them into DAGs - It should yield a `function` that returns a `Promise` that resolves to `{ cid, path, unixfs, node }` where `cid` is a `CID`, `path` is a string, `unixfs` is a UnixFS entry and `node` is a `DAGNode`. - Values will be pulled from this generator in parallel - the amount of parallelisation is controlled by the `fileImportConcurrency` option (default: 50) -- `treeBuilder` (function): Optional function that supports the signature `async function * (source, ipld, options)` +- `treeBuilder` (function): Optional function that supports the signature `async function * (source, blockstore, options)` - This function should read `{ cid, path, unixfs, node }` entries from `source` and place them in a directory structure - It should yield an object with the properties `{ cid, path, unixfs, size }` where `cid` is a `CID`, `path` is a string, `unixfs` is a UnixFS entry and `size` is a `Number`. -[ipld-resolver instance]: https://github.com/ipld/js-ipld-resolver +[blockstore]: https://github.com/ipfs/js-ipfs-interfaces/tree/master/packages/interface-blockstore#readme [UnixFS]: https://github.com/ipfs/specs/tree/master/unixfs [IPLD]: https://github.com/ipld/js-ipld [CID]: https://github.com/multiformats/js-cid diff --git a/packages/ipfs-unixfs/README.md b/packages/ipfs-unixfs/README.md index d7ca41e3..2b2b759f 100644 --- a/packages/ipfs-unixfs/README.md +++ b/packages/ipfs-unixfs/README.md @@ -47,7 +47,7 @@ The UnixFS spec can be found inside the [ipfs/specs repository](http://github.co ### Use in Node.js ```JavaScript -var { UnixFS } = require('ipfs-unixfs') +import { UnixFS } from 'ipfs-unixfs' ``` ### Use in a browser with browserify, webpack or any other bundler @@ -55,7 +55,7 @@ var { UnixFS } = require('ipfs-unixfs') The code published to npm that gets loaded on require is in fact a ES5 transpiled version with the right shims added. This means that you can require it and use with your favourite bundler without having to adjust asset management process. ```JavaScript -var { UnixFS } = require('ipfs-unixfs') +import { UnixFS } from 'ipfs-unixfs' ``` ### Use in a browser Using a script tag From f5d3a670e163632913229a1b75ec12a2d6847326 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Fri, 4 Feb 2022 19:09:14 +0000 Subject: [PATCH 07/10] fix: do not add metadata to leaves (#193) When an imported file is big enough to need leaf nodes, and that file is imported with metadata, we should only add that metadata to the root of the file DAG and not to every leaf in the graph. --- .../test/importer.spec.js | 28 +++++++++++++++++++ .../src/dag-builder/file/buffer-importer.js | 4 +-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/packages/ipfs-unixfs-exporter/test/importer.spec.js b/packages/ipfs-unixfs-exporter/test/importer.spec.js index 28dd168b..ce1c4e06 100644 --- a/packages/ipfs-unixfs-exporter/test/importer.spec.js +++ b/packages/ipfs-unixfs-exporter/test/importer.spec.js @@ -1045,6 +1045,34 @@ strategies.forEach((strategy) => { const node2 = await exporter(entries[1].cid, block) expect(node2).to.have.nested.property('unixfs.mode', 0o0755) }) + + it('should only add metadata to the root node of a file', async () => { + this.timeout(60 * 1000) + + const mtime = { secs: 5000, nsecs: 0 } + + const entries = await all(importer([{ + path: '/foo/file1.txt', + content: asAsyncIterable(bigFile), + mtime + }], block)) + + const root = await exporter(entries[0].cid, block) + expect(root).to.have.deep.nested.property('unixfs.mtime', mtime) + + if (root.node instanceof Uint8Array) { + throw new Error('Root node was not large enough to have children') + } + + const child = await exporter(root.node.Links[0].Hash, block) + + if (child.type !== 'file') { + throw new Error('Child node was wrong type') + } + + expect(child).to.have.property('unixfs') + expect(child).to.not.have.nested.property('unixfs.mtime') + }) }) }) diff --git a/packages/ipfs-unixfs-importer/src/dag-builder/file/buffer-importer.js b/packages/ipfs-unixfs-importer/src/dag-builder/file/buffer-importer.js index abfcf676..44f64a47 100644 --- a/packages/ipfs-unixfs-importer/src/dag-builder/file/buffer-importer.js +++ b/packages/ipfs-unixfs-importer/src/dag-builder/file/buffer-importer.js @@ -30,9 +30,7 @@ async function * bufferImporter (file, block, options) { } else { unixfs = new UnixFS({ type: options.leafType, - data: buffer, - mtime: file.mtime, - mode: file.mode + data: buffer }) buffer = dagPb.encode({ From 9a699082fcfc6f14304628f7c49d47c55b089745 Mon Sep 17 00:00:00 2001 From: Yusef Napora Date: Tue, 12 Apr 2022 12:32:23 -0400 Subject: [PATCH 08/10] fix: don't split paths on `^` characters (#192) * fix: don't split paths on `^` characters * chore: add unit tests for toPathComponents util fn * chore: fix lint issues --- .../src/utils/to-path-components.js | 2 +- .../ipfs-unixfs-importer/test/utils.spec.js | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 packages/ipfs-unixfs-importer/test/utils.spec.js diff --git a/packages/ipfs-unixfs-importer/src/utils/to-path-components.js b/packages/ipfs-unixfs-importer/src/utils/to-path-components.js index 085a53b6..26835e7a 100644 --- a/packages/ipfs-unixfs-importer/src/utils/to-path-components.js +++ b/packages/ipfs-unixfs-importer/src/utils/to-path-components.js @@ -2,7 +2,7 @@ const toPathComponents = (path = '') => { // split on / unless escaped with \ return (path .trim() - .match(/([^\\^/]|\\\/)+/g) || []) + .match(/([^\\/]|\\\/)+/g) || []) .filter(Boolean) } diff --git a/packages/ipfs-unixfs-importer/test/utils.spec.js b/packages/ipfs-unixfs-importer/test/utils.spec.js new file mode 100644 index 00000000..3943bae6 --- /dev/null +++ b/packages/ipfs-unixfs-importer/test/utils.spec.js @@ -0,0 +1,25 @@ +/* eslint-env mocha */ + +import { expect } from 'aegir/utils/chai.js' +import toPathComponents from '../src/utils/to-path-components.js' + +describe('toPathComponents', () => { + it('splits on unescaped "/" characters', () => { + const path = 'foo/bar/baz' + const components = toPathComponents(path) + expect(components.length).to.eq(3) + }) + + it('does not split on escaped "/" characters', () => { + const path = 'foo\\/bar/baz' + const components = toPathComponents(path) + expect(components.length).to.eq(2) + }) + + // see https://github.com/ipfs/js-ipfs-unixfs/issues/177 for context + it('does not split on "^" characters', () => { + const path = 'foo/bar^baz^^qux' + const components = toPathComponents(path) + expect(components.length).to.eq(2) + }) +}) From 99386e61979214e8ef79915800a6ed7154938342 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Tue, 26 Apr 2022 08:12:46 +0100 Subject: [PATCH 09/10] chore: switch to auto-release (#208) Reconfigures project to use semantic-release for releases --- .github/dependabot.yml | 2 +- .github/workflows/automerge.yml | 8 + .github/workflows/js-test-and-release.yml | 152 +++++++++++++ .github/workflows/release.yml | 39 ---- .github/workflows/test.yml | 91 -------- LICENSE | 24 +-- LICENSE-APACHE | 5 + LICENSE-MIT | 19 ++ lerna.json | 11 +- package.json | 74 +++---- packages/ipfs-unixfs-exporter/LICENSE | 24 +-- packages/ipfs-unixfs-exporter/LICENSE-APACHE | 5 + packages/ipfs-unixfs-exporter/LICENSE-MIT | 19 ++ packages/ipfs-unixfs-exporter/package.json | 196 +++++++++++++---- .../src/resolvers/unixfs-v1/content/file.js | 2 +- .../src/resolvers/unixfs-v1/index.js | 2 +- .../test/exporter-subtree.spec.js | 2 +- .../test/exporter.spec.js | 24 +-- .../test/importer.spec.js | 6 +- packages/ipfs-unixfs-importer/LICENSE | 24 +-- packages/ipfs-unixfs-importer/LICENSE-APACHE | 5 + packages/ipfs-unixfs-importer/LICENSE-MIT | 19 ++ packages/ipfs-unixfs-importer/package.json | 202 ++++++++++++++---- .../test/builder-only-hash.spec.js | 2 +- .../test/chunker-rabin.spec.js | 4 +- packages/ipfs-unixfs/LICENSE | 23 +- packages/ipfs-unixfs/LICENSE-APACHE | 5 + packages/ipfs-unixfs/LICENSE-MIT | 19 ++ packages/ipfs-unixfs/package.json | 184 ++++++++++++---- .../ipfs-unixfs/test/unixfs-format.spec.js | 4 +- 30 files changed, 779 insertions(+), 417 deletions(-) create mode 100644 .github/workflows/automerge.yml create mode 100644 .github/workflows/js-test-and-release.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/test.yml create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-MIT create mode 100644 packages/ipfs-unixfs-exporter/LICENSE-APACHE create mode 100644 packages/ipfs-unixfs-exporter/LICENSE-MIT create mode 100644 packages/ipfs-unixfs-importer/LICENSE-APACHE create mode 100644 packages/ipfs-unixfs-importer/LICENSE-MIT create mode 100644 packages/ipfs-unixfs/LICENSE-APACHE create mode 100644 packages/ipfs-unixfs/LICENSE-MIT diff --git a/.github/dependabot.yml b/.github/dependabot.yml index de46e326..290ad028 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,5 +4,5 @@ updates: directory: "/" schedule: interval: daily - time: "11:00" + time: "10:00" open-pull-requests-limit: 10 diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 00000000..d57c2a02 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,8 @@ +name: Automerge +on: [ pull_request ] + +jobs: + automerge: + uses: protocol/.github/.github/workflows/automerge.yml@master + with: + job: 'automerge' diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml new file mode 100644 index 00000000..8630dc5c --- /dev/null +++ b/.github/workflows/js-test-and-release.yml @@ -0,0 +1,152 @@ +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@v2 + - uses: actions/setup-node@v2 + 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@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:node + - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + with: + directory: ./.nyc_output + flags: node + + test-chrome: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:chrome + - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + with: + directory: ./.nyc_output + flags: chrome + + test-chrome-webworker: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:chrome-webworker + - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + with: + directory: ./.nyc_output + flags: chrome-webworker + + test-firefox: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:firefox + - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + with: + directory: ./.nyc_output + flags: firefox + + test-firefox-webworker: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:firefox-webworker + - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + with: + directory: ./.nyc_output + flags: firefox-webworker + + test-electron-main: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + 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@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + with: + directory: ./.nyc_output + flags: electron-main + + test-electron-renderer: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + 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@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + with: + directory: ./.nyc_output + 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@v2 + with: + fetch-depth: 0 + - uses: actions/setup-node@v2 + 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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 16b1a2c9..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Release RC -on: - push: - branches: - - master - -jobs: - release-rc: - name: Release RC - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.author.name, 'Github Actions')" - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Setup node - uses: actions/setup-node@v2 - with: - node-version: 16 - - name: Configure Git User - run: | - git config --global user.email "actions@github.com" - git config --global user.name "Github Actions" - - name: Authenticate with Registry - run: | - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Release - run: | - npm install - npm run build - npm run release:rc -- --yes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index b3625189..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: Test -on: - pull_request: - branches: - - master - -jobs: - check: - name: Check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 16 - - run: npm install - - run: npm run build - - run: npm run lint - - run: npm run depcheck -- -- -- -p - - run: npm run depcheck -- -- -- -- --unused - test-node: - needs: check - runs-on: ${{ matrix.os }} - name: Test ${{ matrix.project }} node ${{ matrix.node }} ${{ matrix.os }} - strategy: - matrix: - os: [windows-latest, ubuntu-latest, macos-latest] - node: [16] - project: - - ipfs-unixfs - - ipfs-unixfs-exporter - - ipfs-unixfs-importer - fail-fast: true - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node }} - - run: npm install - - run: npm run build - - run: npm run test -- --scope=${{ matrix.project }} -- -- --cov -t node - test-browser: - needs: check - runs-on: ubuntu-latest - name: Test ${{ matrix.project }} ${{ matrix.browser }} ${{ matrix.type }} - strategy: - matrix: - project: - - ipfs-unixfs - - ipfs-unixfs-exporter - - ipfs-unixfs-importer - browser: - - chromium - - firefox - type: - - browser - - webworker - fail-fast: true - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 16 - - run: npm install - - run: npm run build - - run: npm run test -- --scope=${{ matrix.project }} -- -- -t ${{ matrix.type }} -- --browser ${{ matrix.browser }} - test-electron: - needs: check - runs-on: ubuntu-latest - name: Test ${{ matrix.project }} ${{ matrix.type }} - strategy: - matrix: - project: - - ipfs-unixfs - - ipfs-unixfs-exporter - - ipfs-unixfs-importer - type: - - electron-main - - electron-renderer - fail-fast: true - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 16 - - run: npm install - - run: npm run build - - run: npx lerna link # use publishConfig.directory - - uses: GabrielBB/xvfb-action@v1 - with: - run: npm run test -- --scope=${{ matrix.project }} -- -- -t ${{ matrix.type }} --bail -f ./dist/cjs/node-test/*.spec.js diff --git a/LICENSE b/LICENSE index b7cf9f52..20ce483c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,22 +1,4 @@ -The MIT License (MIT) - -Copyright (c) 2016 David Dias - -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. +This project is dual licensed under MIT and Apache-2.0. +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/LICENSE-APACHE @@ -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. diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/LICENSE-MIT @@ -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. diff --git a/lerna.json b/lerna.json index bf001c38..aa6d0004 100644 --- a/lerna.json +++ b/lerna.json @@ -1,21 +1,12 @@ { - "lerna": "3.22.1", + "lerna": "4.0.0", "packages": [ "packages/*" ], "version": "independent", "command": { - "bootstrap": { - "hoist": true - }, "run": { "stream": true - }, - "publish": { - "message": "chore: publish", - "conventionalCommits": true, - "createRelease": "github", - "verifyAccess": false } } } diff --git a/package.json b/package.json index ceedff02..93cb3cdc 100644 --- a/package.json +++ b/package.json @@ -2,59 +2,39 @@ "name": "js-ipfs-unixfs", "version": "1.0.0", "description": "JS implementation of the IPFS UnixFS", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs-unixfs#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs-unixfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs-unixfs/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "private": true, "scripts": { - "reset": "lerna run clean && rimraf packages/*/node_modules node_modules packages/*/package-lock.json package-lock.json", - "test": "lerna run test", - "coverage": "lerna run coverage", - "prepare": "lerna run prepare", + "reset": "lerna run clean && rimraf ./node_modules ./package-lock.json packages/*/node_modules packages/*/package-lock.json packages/*/dist", + "test": "lerna run --concurrency 1 test -- --", + "test:node": "lerna run --concurrency 1 test:node -- --", + "test:chrome": "lerna run --concurrency 1 test:chrome -- --", + "test:chrome-webworker": "lerna --concurrency 1 run test:chrome-webworker -- --", + "test:firefox": "lerna run --concurrency 1 test:firefox -- --", + "test:firefox-webworker": "lerna run --concurrency 1 test:firefox-webworker -- --", + "test:electron-main": "lerna run --concurrency 1 test:electron-main -- --", + "test:electron-renderer": "lerna run --concurrency 1 test:electron-renderer -- --", "build": "lerna run build", - "clean": "lerna run clean", "lint": "lerna run lint", - "depcheck": "lerna run depcheck", - "release": "npm run update-contributors && lerna publish", - "release:rc": "lerna publish --canary --preid rc --dist-tag next", - "update-contributors": "aegir release --lint=false --test=false --bump=false --build=false --changelog=false --commit=false --tag=false --push=false --ghrelease=false --docs=false --publish=false" + "dep-check": "lerna run dep-check", + "release": "lerna exec --concurrency 1 -- semantic-release -e semantic-release-monorepo" }, - "devDependencies": { + "dependencies": { "lerna": "^4.0.0" }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs-unixfs.git" - }, - "private": true, - "contributors": [ - "achingbrain ", - "David Dias ", - "Friedel Ziegelmayer ", - "Stephen Whitmore ", - "Alan Shaw ", - "Pedro Teixeira ", - "nginnever ", - "Volker Mische ", - "Hugo Dias ", - "Vasco Santos ", - "Richard Schneider ", - "Dan Ordille ", - "ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ ", - "JGAntunes ", - "Marcin Rataj ", - "Richard Littauer ", - "SahidMiller ", - "Mithgol ", - "Irakli Gozalishvili ", - "Arpit Agarwal ", - "Hector Sanjuan ", - "Francisco Baio Dias ", - "Diogo Silva ", - "jbenet ", - "Bernard Mordan " - ], "workspaces": [ "packages/*" - ], - "engines": { - "node": ">=14.0.0", - "npm": ">=7.0.0" - } + ] } diff --git a/packages/ipfs-unixfs-exporter/LICENSE b/packages/ipfs-unixfs-exporter/LICENSE index b7cf9f52..20ce483c 100644 --- a/packages/ipfs-unixfs-exporter/LICENSE +++ b/packages/ipfs-unixfs-exporter/LICENSE @@ -1,22 +1,4 @@ -The MIT License (MIT) - -Copyright (c) 2016 David Dias - -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. +This project is dual licensed under MIT and Apache-2.0. +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/ipfs-unixfs-exporter/LICENSE-APACHE b/packages/ipfs-unixfs-exporter/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/ipfs-unixfs-exporter/LICENSE-APACHE @@ -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. diff --git a/packages/ipfs-unixfs-exporter/LICENSE-MIT b/packages/ipfs-unixfs-exporter/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/ipfs-unixfs-exporter/LICENSE-MIT @@ -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. diff --git a/packages/ipfs-unixfs-exporter/package.json b/packages/ipfs-unixfs-exporter/package.json index 256cc8a7..6170862f 100644 --- a/packages/ipfs-unixfs-exporter/package.json +++ b/packages/ipfs-unixfs-exporter/package.json @@ -2,51 +2,175 @@ "name": "ipfs-unixfs-exporter", "version": "7.0.6", "description": "JavaScript implementation of the UnixFs exporter used by IPFS", - "leadMaintainer": "Alex Potsides ", - "main": "src/index.js", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs-unixfs/tree/master/packages/ipfs-unixfs-exporter#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs-unixfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs-unixfs/issues" + }, + "keywords": [ + "IPFS" + ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "browser": { - "fs": false + "types": "types/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "types/*", + "types/src/*" + ], + "types/*": [ + "types/*", + "types/src/*" + ] + } + }, + "files": [ + "*", + "!**/*.tsbuildinfo", + "!**/browser-test", + "!**/node-test" + ], + "exports": { + ".": { + "import": "./src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "chore", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Trivial Changes" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + [ + "@semantic-release/npm", + { + "pkgRoot": "dist" + } + ], + "@semantic-release/github", + "@semantic-release/git" + ] }, "scripts": { "prepare": "aegir build --no-bundle && cp -R types dist", "pretest": "aegir build --esm-tests", "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:firefox": "aegir test -t browser -- --browser firefox", "build": "aegir build && cp -R types dist", "preleaseOnly": "npx json -I -f dist/package.json -e this.types='\"src/index.d.ts\"'", "clean": "rimraf ./dist", "lint": "aegir ts -p check && aegir lint", "coverage": "nyc -s npm run test -t node && nyc report --reporter=html", - "depcheck": "aegir dep-check -i @types/mocha -i @types/sinon -i nyc -i abort-controller -i rimraf -i copy -i util -i crypto-browserify -i events -i readable-stream -i interface-blockstore" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs-unixfs.git" - }, - "keywords": [ - "IPFS" - ], - "license": "MIT", - "bugs": { - "url": "https://github.com/ipfs/js-ipfs-unixfs/issues" - }, - "engines": { - "node": ">=14.0.0", - "npm": ">=6.0.0" + "dep-check": "aegir dep-check -i @types/mocha -i @types/sinon -i nyc -i abort-controller -i rimraf -i copy -i util -i crypto-browserify -i events -i readable-stream -i interface-blockstore", + "release": "semantic-release" }, - "homepage": "https://github.com/ipfs/js-ipfs-unixfs#readme", - "publishConfig": { - "directory": "dist" + "dependencies": { + "@ipld/dag-cbor": "^6.0.4", + "@ipld/dag-pb": "^2.0.2", + "@multiformats/murmur3": "^1.0.3", + "err-code": "^3.0.1", + "hamt-sharding": "^2.0.0", + "interface-blockstore": "^1.0.0", + "ipfs-unixfs": "^6.0.0", + "it-last": "^1.0.5", + "multiformats": "^9.4.2", + "uint8arrays": "^3.0.0" }, "devDependencies": { "@types/mocha": "^8.2.1", "@types/sinon": "^10.0.0", "abort-controller": "^3.0.0", - "aegir": "^35.0.1", + "aegir": "^36.2.3", "copy": "^0.3.2", "crypto-browserify": "^3.12.0", "events": "^3.3.0", - "ipfs-unixfs-importer": "^9.0.6", + "ipfs-unixfs-importer": "^9.0.0", "it-all": "^1.0.5", "it-buffer-stream": "^2.0.0", "it-first": "^1.0.6", @@ -58,23 +182,11 @@ "sinon": "^11.1.1", "util": "^0.12.3" }, - "dependencies": { - "@ipld/dag-cbor": "^6.0.4", - "@ipld/dag-pb": "^2.0.2", - "@multiformats/murmur3": "^1.0.3", - "err-code": "^3.0.1", - "hamt-sharding": "^2.0.0", - "interface-blockstore": "^1.0.0", - "ipfs-unixfs": "^6.0.6", - "it-last": "^1.0.5", - "multiformats": "^9.4.2", - "uint8arrays": "^3.0.0" + "browser": { + "fs": false }, - "types": "types/src/index.d.ts", - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } + "main": "src/index.js", + "publishConfig": { + "directory": "dist" } } diff --git a/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.js b/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.js index 6c95e5fd..ce020c21 100644 --- a/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.js +++ b/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.js @@ -41,7 +41,7 @@ async function * emitBytes (blockstore, node, start, end, streamPosition = 0, op try { file = UnixFS.unmarshal(node.Data) - } catch (err) { + } catch (/** @type {any} */ err) { throw errCode(err, 'ERR_NOT_UNIXFS') } diff --git a/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.js b/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.js index cdb79de3..1da18e6c 100644 --- a/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.js +++ b/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.js @@ -59,7 +59,7 @@ const unixFsResolver = async (cid, name, path, toResolve, resolve, depth, blocks try { unixfs = UnixFS.unmarshal(node.Data) - } catch (err) { + } catch (/** @type {any} */ err) { // non-UnixFS dag-pb node? It could happen. throw errCode(err, 'ERR_NOT_UNIXFS') } diff --git a/packages/ipfs-unixfs-exporter/test/exporter-subtree.spec.js b/packages/ipfs-unixfs-exporter/test/exporter-subtree.spec.js index eb0b99d9..55119885 100644 --- a/packages/ipfs-unixfs-exporter/test/exporter-subtree.spec.js +++ b/packages/ipfs-unixfs-exporter/test/exporter-subtree.spec.js @@ -95,7 +95,7 @@ describe('exporter subtree', () => { try { await exporter(`${imported.cid}/doesnotexist`, block) - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_NOT_FOUND') } }) diff --git a/packages/ipfs-unixfs-exporter/test/exporter.spec.js b/packages/ipfs-unixfs-exporter/test/exporter.spec.js index b9d45a4a..9c1de742 100644 --- a/packages/ipfs-unixfs-exporter/test/exporter.spec.js +++ b/packages/ipfs-unixfs-exporter/test/exporter.spec.js @@ -587,7 +587,7 @@ describe('exporter', () => { length }) throw new Error('Should not have got this far') - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.message).to.equal('Length must be greater than or equal to 0') expect(err.code).to.equal('ERR_INVALID_PARAMS') } @@ -606,7 +606,7 @@ describe('exporter', () => { offset }) throw new Error('Should not have got this far') - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.message).to.equal('Offset must be greater than or equal to 0') expect(err.code).to.equal('ERR_INVALID_PARAMS') } @@ -625,7 +625,7 @@ describe('exporter', () => { offset }) throw new Error('Should not have got this far') - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.message).to.equal('Offset must be less than the file size') expect(err.code).to.equal('ERR_INVALID_PARAMS') } @@ -689,7 +689,7 @@ describe('exporter', () => { offset: -1 }) throw new Error('Should not have got this far') - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.message).to.contain('Offset must be greater than or equal to 0') expect(err.code).to.equal('ERR_INVALID_PARAMS') } @@ -730,7 +730,7 @@ describe('exporter', () => { offset: 2, length: -1 }) - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.message).to.contain('Length must be greater than or equal to 0') expect(err.code).to.equal('ERR_INVALID_PARAMS') } @@ -742,7 +742,7 @@ describe('exporter', () => { file: Uint8Array.from([0, 1, 2, 3, 4]), offset: 200 }) - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.message).to.contain('Offset must be less than the file size') expect(err.code).to.equal('ERR_INVALID_PARAMS') } @@ -821,7 +821,7 @@ describe('exporter', () => { try { await exporter(hash, block) - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_NOT_FOUND') } }) @@ -967,7 +967,7 @@ describe('exporter', () => { try { await exporter(`${cid}/baz`, block) - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_NO_PROP') } }) @@ -994,7 +994,7 @@ describe('exporter', () => { try { await exporter(`${cid}`, block) - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_NO_RESOLVER') } }) @@ -1006,7 +1006,7 @@ describe('exporter', () => { try { await exporter(`${cid}/lol`, block) - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_NOT_FOUND') } }) @@ -1021,7 +1021,7 @@ describe('exporter', () => { try { await exporter(dagpbCid, block) - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_NOT_UNIXFS') } }) @@ -1055,7 +1055,7 @@ describe('exporter', () => { try { await all(exported.content()) - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_NOT_UNIXFS') } }) diff --git a/packages/ipfs-unixfs-exporter/test/importer.spec.js b/packages/ipfs-unixfs-exporter/test/importer.spec.js index ce1c4e06..2639f570 100644 --- a/packages/ipfs-unixfs-exporter/test/importer.spec.js +++ b/packages/ipfs-unixfs-exporter/test/importer.spec.js @@ -381,7 +381,7 @@ strategies.forEach((strategy) => { content: 7 }], block, options)) throw new Error('No error was thrown') - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_INVALID_CONTENT') } }) @@ -398,7 +398,7 @@ strategies.forEach((strategy) => { } }], block, options)) throw new Error('No error was thrown') - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_INVALID_CONTENT') } }) @@ -670,7 +670,7 @@ strategies.forEach((strategy) => { await block.get(file.cid) throw new Error('No error was thrown') - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_NOT_FOUND') } }) diff --git a/packages/ipfs-unixfs-importer/LICENSE b/packages/ipfs-unixfs-importer/LICENSE index b7cf9f52..20ce483c 100644 --- a/packages/ipfs-unixfs-importer/LICENSE +++ b/packages/ipfs-unixfs-importer/LICENSE @@ -1,22 +1,4 @@ -The MIT License (MIT) - -Copyright (c) 2016 David Dias - -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. +This project is dual licensed under MIT and Apache-2.0. +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/ipfs-unixfs-importer/LICENSE-APACHE b/packages/ipfs-unixfs-importer/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/ipfs-unixfs-importer/LICENSE-APACHE @@ -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. diff --git a/packages/ipfs-unixfs-importer/LICENSE-MIT b/packages/ipfs-unixfs-importer/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/ipfs-unixfs-importer/LICENSE-MIT @@ -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. diff --git a/packages/ipfs-unixfs-importer/package.json b/packages/ipfs-unixfs-importer/package.json index 2a5fbe9c..a28ba538 100644 --- a/packages/ipfs-unixfs-importer/package.json +++ b/packages/ipfs-unixfs-importer/package.json @@ -2,55 +2,153 @@ "name": "ipfs-unixfs-importer", "version": "9.0.6", "description": "JavaScript implementation of the UnixFs importer used by IPFS", - "leadMaintainer": "Alex Potsides ", - "main": "src/index.js", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs-unixfs/tree/master/packages/ipfs-unixfs-importer#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs-unixfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs-unixfs/issues" + }, + "keywords": [ + "IPFS" + ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "browser": { - "fs": false + "types": "types/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "types/*", + "types/src/*" + ], + "types/*": [ + "types/*", + "types/src/*" + ] + } + }, + "files": [ + "*", + "!**/*.tsbuildinfo", + "!**/browser-test", + "!**/node-test" + ], + "exports": { + ".": { + "import": "./src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "chore", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Trivial Changes" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + [ + "@semantic-release/npm", + { + "pkgRoot": "dist" + } + ], + "@semantic-release/github", + "@semantic-release/git" + ] }, "scripts": { "prepare": "aegir build --no-bundle && cp -R types dist", "pretest": "aegir build --esm-tests", "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:firefox": "aegir test -t browser -- --browser firefox", "build": "aegir build && cp -R types dist", "preleaseOnly": "npx json -I -f dist/package.json -e this.types='\"src/index.d.ts\"'", "clean": "rimraf ./dist", "lint": "aegir ts -p check && aegir lint", "coverage": "nyc -s npm run test -t node && nyc report --reporter=html", - "depcheck": "aegir dep-check -i @types/mocha -i nyc -i rimraf -i copy -i util -i crypto-browserify -i events -i readable-stream -i assert" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs-unixfs.git" - }, - "keywords": [ - "IPFS" - ], - "license": "MIT", - "bugs": { - "url": "https://github.com/ipfs/js-ipfs-unixfs/issues" - }, - "engines": { - "node": ">=14.0.0", - "npm": ">=6.0.0" - }, - "homepage": "https://github.com/ipfs/js-ipfs-unixfs#readme", - "publishConfig": { - "directory": "dist" - }, - "devDependencies": { - "@types/mocha": "^8.2.1", - "aegir": "^35.0.1", - "assert": "^2.0.0", - "copy": "^0.3.2", - "crypto-browserify": "^3.12.0", - "events": "^3.3.0", - "it-buffer-stream": "^2.0.0", - "nyc": "^15.0.0", - "readable-stream": "^3.6.0", - "rimraf": "^3.0.2", - "util": "^0.12.3", - "wherearewe": "^1.0.0" + "de-pcheck": "aegir dep-check -i @types/mocha -i nyc -i rimraf -i copy -i util -i crypto-browserify -i events -i readable-stream -i assert", + "release": "semantic-release" }, "dependencies": { "@ipld/dag-pb": "^2.0.2", @@ -59,7 +157,7 @@ "err-code": "^3.0.1", "hamt-sharding": "^2.0.0", "interface-blockstore": "^1.0.0", - "ipfs-unixfs": "^6.0.6", + "ipfs-unixfs": "^6.0.0", "it-all": "^1.0.5", "it-batch": "^1.0.8", "it-first": "^1.0.6", @@ -69,11 +167,25 @@ "rabin-wasm": "^0.1.4", "uint8arrays": "^3.0.0" }, - "types": "types/src/index.d.ts", - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } + "devDependencies": { + "@types/mocha": "^8.2.1", + "aegir": "^36.2.3", + "assert": "^2.0.0", + "copy": "^0.3.2", + "crypto-browserify": "^3.12.0", + "events": "^3.3.0", + "it-buffer-stream": "^2.0.0", + "nyc": "^15.0.0", + "readable-stream": "^3.6.0", + "rimraf": "^3.0.2", + "util": "^0.12.3", + "wherearewe": "^1.0.0" + }, + "browser": { + "fs": false + }, + "main": "src/index.js", + "publishConfig": { + "directory": "dist" } } diff --git a/packages/ipfs-unixfs-importer/test/builder-only-hash.spec.js b/packages/ipfs-unixfs-importer/test/builder-only-hash.spec.js index 6891d1be..b5dd9167 100644 --- a/packages/ipfs-unixfs-importer/test/builder-only-hash.spec.js +++ b/packages/ipfs-unixfs-importer/test/builder-only-hash.spec.js @@ -25,7 +25,7 @@ describe('builder: onlyHash', () => { await block.get((await nodes[0]()).cid) throw new Error('Should have errored') - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_NOT_FOUND') } }) diff --git a/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js b/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js index 990f7336..e10e85f0 100644 --- a/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js +++ b/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js @@ -96,7 +96,7 @@ describe('chunker: rabin', function () { try { await all(chunker(asAsyncIterable([]), opts)) throw new Error('Should have thrown') - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_INVALID_MIN_CHUNK_SIZE') } }) @@ -111,7 +111,7 @@ describe('chunker: rabin', function () { // @ts-expect-error invalid opts await all(chunker(asAsyncIterable([]), opts)) throw new Error('Should have thrown') - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_INVALID_AVG_CHUNK_SIZE') } }) diff --git a/packages/ipfs-unixfs/LICENSE b/packages/ipfs-unixfs/LICENSE index bb9cf402..20ce483c 100644 --- a/packages/ipfs-unixfs/LICENSE +++ b/packages/ipfs-unixfs/LICENSE @@ -1,21 +1,4 @@ -The MIT License (MIT) +This project is dual licensed under MIT and Apache-2.0. -Copyright (c) 2016 David Dias - -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. +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/ipfs-unixfs/LICENSE-APACHE b/packages/ipfs-unixfs/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/ipfs-unixfs/LICENSE-APACHE @@ -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. diff --git a/packages/ipfs-unixfs/LICENSE-MIT b/packages/ipfs-unixfs/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/ipfs-unixfs/LICENSE-MIT @@ -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. diff --git a/packages/ipfs-unixfs/package.json b/packages/ipfs-unixfs/package.json index 77ce63fd..910fed22 100644 --- a/packages/ipfs-unixfs/package.json +++ b/packages/ipfs-unixfs/package.json @@ -2,11 +2,141 @@ "name": "ipfs-unixfs", "version": "6.0.6", "description": "JavaScript implementation of IPFS' unixfs (a Unix FileSystem representation on top of a MerkleDAG)", - "leadMaintainer": "Alex Potsides ", - "main": "src/index.js", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs-unixfs/tree/master/packages/ipfs-unixfs#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs-unixfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs-unixfs/issues" + }, + "keywords": [ + "IPFS" + ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "browser": { - "fs": false + "types": "types/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "types/*", + "types/src/*" + ], + "types/*": [ + "types/*", + "types/src/*" + ] + } + }, + "files": [ + "*", + "!**/*.tsbuildinfo", + "!**/browser-test", + "!**/node-test" + ], + "exports": { + ".": { + "import": "./src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + }, + "ignorePatterns": [ + "src/unixfs.d.ts" + ] + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "chore", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Trivial Changes" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + [ + "@semantic-release/npm", + { + "pkgRoot": "dist" + } + ], + "@semantic-release/github", + "@semantic-release/git" + ] }, "scripts": { "prepare": "aegir build --no-bundle && cp -R types dist", @@ -14,34 +144,23 @@ "prepare:proto-types": "pbts -o src/unixfs.d.ts src/unixfs.js", "pretest": "aegir build --esm-tests", "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:firefox": "aegir test -t browser -- --browser firefox", "build": "aegir build && cp -R types dist", "clean": "rimraf ./dist", "lint": "aegir ts -p check && aegir lint", "coverage": "nyc -s aegir test -t node && nyc report --reporter=html", - "depcheck": "aegir dep-check -i mkdirp -i @types/mocha -i nyc -i npm-run-all -i copy -i util" + "dep-check": "aegir dep-check -i mkdirp -i @types/mocha -i nyc -i npm-run-all -i copy -i util", + "release": "semantic-release" }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs-unixfs.git" - }, - "keywords": [ - "IPFS" - ], - "license": "MIT", - "bugs": { - "url": "https://github.com/ipfs/js-ipfs-unixfs/issues" - }, - "engines": { - "node": ">=14.0.0", - "npm": ">=6.0.0" - }, - "homepage": "https://github.com/ipfs/js-ipfs-unixfs#readme", - "publishConfig": { - "directory": "dist" + "dependencies": { + "err-code": "^3.0.1", + "protobufjs": "^6.10.2" }, "devDependencies": { "@types/mocha": "^8.2.1", - "aegir": "^35.0.1", + "aegir": "^36.2.3", "copy": "^0.3.2", "mkdirp": "^1.0.4", "npm-run-all": "^4.1.5", @@ -49,18 +168,11 @@ "uint8arrays": "^3.0.0", "util": "^0.12.3" }, - "dependencies": { - "err-code": "^3.0.1", - "protobufjs": "^6.10.2" + "browser": { + "fs": false }, - "types": "types/src/index.d.ts", - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - }, - "ignorePatterns": [ - "src/unixfs.d.ts" - ] + "main": "src/index.js", + "publishConfig": { + "directory": "dist" } } diff --git a/packages/ipfs-unixfs/test/unixfs-format.spec.js b/packages/ipfs-unixfs/test/unixfs-format.spec.js index 7714282f..1dbca2c1 100644 --- a/packages/ipfs-unixfs/test/unixfs-format.spec.js +++ b/packages/ipfs-unixfs/test/unixfs-format.spec.js @@ -393,7 +393,7 @@ describe('unixfs-format', () => { new UnixFS({ type: 'bananas' }) - } catch (err) { + } catch (/** @type {any} */ err) { expect(err).to.have.property('code', 'ERR_INVALID_TYPE') done() } @@ -405,7 +405,7 @@ describe('unixfs-format', () => { try { entry.marshal() - } catch (err) { + } catch (/** @type {any} */ err) { expect(err).to.have.property('code', 'ERR_INVALID_TYPE') done() } From 26e3839f2ef9ece6dd7137776c4f8129095881c2 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 26 Apr 2022 08:31:19 +0000 Subject: [PATCH 10/10] chore(release): 6.0.7 [skip ci] ## [ipfs-unixfs-v6.0.7](https://github.com/ipfs/js-ipfs-unixfs/compare/ipfs-unixfs-v6.0.6...ipfs-unixfs-v6.0.7) (2022-04-26) ### Trivial Changes * switch to auto-release ([#208](https://github.com/ipfs/js-ipfs-unixfs/issues/208)) ([99386e6](https://github.com/ipfs/js-ipfs-unixfs/commit/99386e61979214e8ef79915800a6ed7154938342)) * update readmes ([#188](https://github.com/ipfs/js-ipfs-unixfs/issues/188)) ([273a141](https://github.com/ipfs/js-ipfs-unixfs/commit/273a141b5ee3805bd0ef2dc8ed7870f8c6c8a820)) --- packages/ipfs-unixfs/CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/ipfs-unixfs/CHANGELOG.md b/packages/ipfs-unixfs/CHANGELOG.md index f2f23162..4aaecedc 100644 --- a/packages/ipfs-unixfs/CHANGELOG.md +++ b/packages/ipfs-unixfs/CHANGELOG.md @@ -1,3 +1,11 @@ +## [ipfs-unixfs-v6.0.7](https://github.com/ipfs/js-ipfs-unixfs/compare/ipfs-unixfs-v6.0.6...ipfs-unixfs-v6.0.7) (2022-04-26) + + +### Trivial Changes + +* switch to auto-release ([#208](https://github.com/ipfs/js-ipfs-unixfs/issues/208)) ([99386e6](https://github.com/ipfs/js-ipfs-unixfs/commit/99386e61979214e8ef79915800a6ed7154938342)) +* update readmes ([#188](https://github.com/ipfs/js-ipfs-unixfs/issues/188)) ([273a141](https://github.com/ipfs/js-ipfs-unixfs/commit/273a141b5ee3805bd0ef2dc8ed7870f8c6c8a820)) + # Change Log All notable changes to this project will be documented in this file.