diff --git a/.github/workflows/mikeals-workflow.yml b/.github/workflows/mikeals-workflow.yml deleted file mode 100644 index 37d4c64..0000000 --- a/.github/workflows/mikeals-workflow.yml +++ /dev/null @@ -1,51 +0,0 @@ -on: [push, pull_request] -name: Build, Test and maybe Publish -jobs: - test: - name: Build & Test - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - node-version: [12.x, 14.x, 16.x] - steps: - - uses: actions/checkout@v2.4.0 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2.4.1 - with: - node-version: ${{ matrix.node-version }} - - name: Cache node_modules - id: cache-modules - uses: actions/cache@v2.1.7 - with: - path: node_modules - key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }} - - name: Build - if: steps.cache-modules.outputs.cache-hit != 'true' - run: npm install - - name: Test - run: npm_config_yes=true npx best-test@latest - publish: - name: Publish - needs: test - runs-on: ubuntu-latest - if: github.event_name == 'push' && github.ref == 'refs/heads/master' - steps: - - uses: actions/checkout@v2.4.0 - - name: Cache node_modules - id: cache-modules - uses: actions/cache@v2.1.7 - with: - path: node_modules - key: 12.x-${{ runner.OS }}-build-${{ hashFiles('package.json') }} - - name: Build - if: steps.cache-modules.outputs.cache-hit != 'true' - run: npm install - - name: Test - run: npm_config_yes=true npx best-test@latest - - - name: Publish - uses: mikeal/merge-release@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml new file mode 100644 index 0000000..b80a9a5 --- /dev/null +++ b/.github/workflows/test-and-release.yml @@ -0,0 +1,63 @@ +name: Test & Maybe Release +on: [push, pull_request] +jobs: + test: + strategy: + fail-fast: false + matrix: + node: [14.x, 16.x] + os: [macos-latest, ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout Repository + uses: actions/checkout@v2.4.0 + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v2.5.0 + with: + node-version: ${{ matrix.node }} + - name: Install Dependencies + run: | + npm install --no-progress + - name: Run tests + run: | + npm config set script-shell bash + npm run test:ci + - name: Typecheck + uses: gozala/typescript-error-reporter-action@v1.0.8 + release: + name: Release + needs: test + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + steps: + - name: Checkout + uses: actions/checkout@v2.4.0 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v2.5.0 + with: + node-version: 14 + - name: Install dependencies + run: | + npm install --no-progress --no-package-lock --no-save + - name: Build + run: | + npm run build + - name: Install plugins + run: | + npm install \ + @semantic-release/commit-analyzer \ + conventional-changelog-conventionalcommits \ + @semantic-release/release-notes-generator \ + @semantic-release/npm \ + @semantic-release/github \ + @semantic-release/git \ + @semantic-release/changelog \ + --no-progress --no-package-lock --no-save + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npx semantic-release + diff --git a/package.json b/package.json index 53d2fa0..2163b94 100644 --- a/package.json +++ b/package.json @@ -3,66 +3,32 @@ "version": "0.0.0-dev", "description": "Content Addressable aRchive format reader and writer", "main": "car.js", - "type": "module", "types": "./types/car.d.ts", - "directories": { - "test": "test" - }, + "type": "module", "scripts": { + "lint": "standard", "build": "npm run build:js && npm run build:types", "build:js": "ipjs build --tests --main && npm run build:copy", "build:copy": "mkdir -p dist/examples/ && cp -a tsconfig.json *.js *.ts lib test dist/ && cp examples/*.* dist/examples/", "build:types": "tsc --build && mv types dist", - "prepublishOnly": "npm run build", - "publish": "ipjs publish", - "lint": "standard", "test:cjs": "rm -rf dist && npm run build && cp test/go.car dist/cjs/node-test/ && mocha dist/cjs/node-test/test-*.js && mocha dist/cjs/node-test/node-test-*.js && npm run test:cjs:browser", - "test:node": "hundreds mocha test/test-*.js test/node-test-*.js", - "test:cjs:browser": "polendina --cleanup dist/cjs/browser-test/test-*.js", + "test:esm": "rm -rf dist && npm run build && cp test/go.car dist/esm/node-test/ && mocha dist/esm/node-test/test-*.js && mocha dist/esm/node-test/node-test-*.js && npm run test:esm:browser", + "test:node": "c8 --check-coverage --branches 100 --functions 100 --lines 100 mocha test/test-*.js test/node-test-*.js", + "test:cjs:browser": "polendina --page --worker --serviceworker --cleanup dist/cjs/browser-test/test-*.js", + "test:esm:browser": "polendina --page --worker --serviceworker --cleanup dist/esm/browser-test/test-*.js", "test": "npm run lint && npm run test:node && npm run test:cjs && npm run test --prefix examples/", + "test:ci": "npm run lint && npm run test:node && npm run test:esm && npm run test:cjs && npm run test --prefix examples/", "coverage": "c8 --reporter=html --reporter=text mocha test/test-*.js && npx st -d coverage -p 8888", "docs": "jsdoc4readme --readme --description-only lib/reader*.js lib/indexed-reader.js lib/iterator.js lib/indexer.js lib/writer*.js" }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipld/js-car.git" - }, "keywords": [ "car", "ipld", - "ipfs" + "ipfs", + "multiformats" ], "author": "Rod (http://r.va.gg/)", "license": "(Apache-2.0 AND MIT)", - "bugs": { - "url": "https://github.com/ipld/js-car/issues" - }, - "homepage": "https://github.com/ipld/js-car#readme", - "devDependencies": { - "@ipld/dag-pb": "^2.0.0", - "@types/chai": "^4.2.18", - "@types/chai-as-promised": "^7.1.4", - "@types/mocha": "^9.0.0", - "@types/node": "^16.0.0", - "@typescript-eslint/eslint-plugin": "^4.24.0", - "@typescript-eslint/parser": "^4.24.0", - "chai": "^4.3.4", - "chai-as-promised": "^7.1.1", - "hundreds": "^0.0.9", - "ipjs": "^5.0.0", - "ipld-garbage": "^4.0.0", - "jsdoc4readme": "^1.4.0", - "mocha": "^9.0.0", - "polendina": "^1.1.0", - "standard": "^16.0.3", - "typescript": "^4.2.4" - }, - "dependencies": { - "@ipld/dag-cbor": "^6.0.0", - "@types/varint": "^6.0.0", - "multiformats": "^9.0.0", - "varint": "^6.0.0" - }, "exports": { ".": { "browser": "./car-browser.js", @@ -90,6 +56,47 @@ "import": "./lib/writer.js" } }, + "dependencies": { + "@ipld/dag-cbor": "^6.0.15", + "multiformats": "^9.5.4", + "varint": "^6.0.0" + }, + "devDependencies": { + "@ipld/dag-pb": "^2.1.14", + "@types/chai": "^4.3.0", + "@types/chai-as-promised": "^7.1.4", + "@types/mocha": "^9.0.0", + "@types/node": "^16.11.12", + "@types/varint": "^6.0.0", + "@typescript-eslint/eslint-plugin": "^5.6.0", + "@typescript-eslint/parser": "^5.6.0", + "c8": "^7.10.0", + "chai": "^4.3.4", + "chai-as-promised": "^7.1.1", + "ipjs": "^5.2.0", + "ipld-garbage": "^4.0.10", + "jsdoc4readme": "^1.4.0", + "mocha": "^9.1.3", + "polendina": "~2.0.1", + "standard": "^16.0.4", + "typescript": "~4.5.2" + }, + "standard": { + "ignore": [ + "dist" + ] + }, + "directories": { + "test": "test" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ipld/js-car.git" + }, + "bugs": { + "url": "https://github.com/ipld/js-car/issues" + }, + "homepage": "https://github.com/ipld/js-car#readme", "typesVersions": { "*": { "reader": [ @@ -117,5 +124,91 @@ "types/*" ] } + }, + "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" + ] } } diff --git a/test/test-interface.js b/test/test-interface.js index 8fb5f7e..dd71204 100644 --- a/test/test-interface.js +++ b/test/test-interface.js @@ -19,6 +19,6 @@ describe('Interface', () => { it('browser exports', () => { // @ts-ignore - assert.strictEqual(__browser, !!process.browser) + assert.strictEqual(__browser, globalThis.process === undefined) }) })