Skip to content

Commit

Permalink
feat: a base for a new web3.storage upload-client (#141)
Browse files Browse the repository at this point in the history
Co-authored-by: Hugo Dias <hugomrdias@gmail.com>
  • Loading branch information
alanshaw and hugomrdias committed Nov 9, 2022
1 parent 44d1df2 commit 72c08d7
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"packages": {
"packages/access": {},
"packages/access-api": {},
"packages/upload-client": {},
"packages/wallet": {},
"packages/store": {}
}
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Client
env:
CI: true
FORCE_COLOR: 1
on:
push:
branches:
- main
paths:
- 'packages/upload-client/**'
- '.github/workflows/client.yml'
- 'pnpm-lock.yaml'
pull_request:
paths:
- 'packages/upload-client/**'
- '.github/workflows/client.yml'
- 'pnpm-lock.yaml'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.3
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'
- run: pnpm install
- run: pnpm -r --filter @web3-storage/upload-client run lint
- run: pnpm -r --filter @web3-storage/upload-client run test
23 changes: 23 additions & 0 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
options:
- access-api
- access
- upload-client
- wallet
environment:
description: 'Environment to deploy'
Expand Down Expand Up @@ -73,3 +74,25 @@ jobs:
- run: pnpm -r --filter @web3-storage/access publish --tag next --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
deploy-upload-client:
runs-on: ubuntu-latest
if: github.event.inputs.package == 'upload-client'
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.3
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
- run: pnpm install
- run: pnpm -r --filter @web3-storage/upload-client build
- run: pnpm -r --filter @web3-storage/upload-client run rc || true # this fails because npm does not support workspace protocol so we force it to exit 0
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'chore(client): Bump client pre release version'
- run: pnpm -r --filter @web3-storage/upload-client publish --tag next --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
21 changes: 20 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
manifest-file: .github/release-please-manifest.json
default-branch: main
release-type: node
publish:
publish-access:
needs: release
if: contains(fromJson(needs.release.outputs.paths_released), 'packages/access')
runs-on: ubuntu-latest
Expand All @@ -40,6 +40,25 @@ jobs:
- run: pnpm -r publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
publish-upload-client:
needs: release
if: contains(fromJson(needs.release.outputs.paths_released), 'packages/upload-client')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.3
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
- run: pnpm install
- run: pnpm -r --filter @web3-storage/upload-client build
- run: pnpm -r publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
pages:
needs: release
if: contains(fromJson(needs.release.outputs.paths_released), 'packages/wallet')
Expand Down
65 changes: 65 additions & 0 deletions packages/upload-client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"name": "@web3-storage/upload-client",
"version": "0.0.0",
"description": "The web3.storage client",
"homepage": "https://github.com/web3-storage/w3protocol/tree/main/packages/upload-client",
"repository": {
"type": "git",
"url": "https://github.com/web3-storage/w3protocol.git",
"directory": "packages/upload-client"
},
"author": "Alan Shaw",
"license": "Apache-2.0 OR MIT",
"type": "module",
"types": "dist/src/index.d.ts",
"main": "src/index.js",
"scripts": {
"lint": "tsc && eslint '**/*.{js,ts}' && prettier --check '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore",
"build": "tsc --build",
"test": "npm run test:node && npm run test:browser",
"test:node": "mocha 'test/**/!(*.browser).test.js' -n experimental-vm-modules -n no-warnings",
"test:browser": "playwright-test 'test/**/!(*.node).test.js'",
"rc": "npm version prerelease --preid rc"
},
"exports": {
".": "./src/index.js"
},
"typesVersions": {
"*": {
"*": [
"dist/*"
]
}
},
"files": [
"src",
"dist/src/**/*.d.ts",
"dist/src/**/*.d.ts.map"
],
"devDependencies": {
"@types/assert": "^1.5.6",
"@types/mocha": "^10.0.0",
"assert": "^2.0.0",
"hd-scripts": "^3.0.2",
"mocha": "^10.1.0",
"playwright-test": "^8.1.1",
"typescript": "^4.8.4"
},
"eslintConfig": {
"extends": [
"./node_modules/hd-scripts/eslint/index.js"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"unicorn/prefer-number-properties": "off"
},
"env": {
"mocha": true
},
"ignorePatterns": [
"dist"
]
}
}
4 changes: 4 additions & 0 deletions packages/upload-client/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Client {}

export default Client
export { Client }
8 changes: 8 additions & 0 deletions packages/upload-client/test/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import assert from 'assert'
import Client from '../src/index.js'

describe('index', function () {
it('should export a client object', () => {
assert(Client)
})
})
10 changes: 10 additions & 0 deletions packages/upload-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"lib": ["ESNext", "DOM"],
"emitDeclarationOnly": true
},
"include": ["src", "scripts", "test", "package.json"],
"exclude": ["**/node_modules/**"]
}
18 changes: 18 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 72c08d7

Please sign in to comment.