Skip to content

Commit

Permalink
rebase: main
Browse files Browse the repository at this point in the history
  • Loading branch information
fenos committed Feb 5, 2024
2 parents 37db04f + a896d25 commit 2aacf2e
Show file tree
Hide file tree
Showing 73 changed files with 2,312 additions and 271 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
5 changes: 5 additions & 0 deletions .changeset/bright-zebras-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tus/server': minor
---

Support async `namingFunction`
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["demo", "test"]
}
5 changes: 5 additions & 0 deletions .changeset/pretty-fishes-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tus/utils': minor
---

Introduce @tus/utils for code sharing between packages
8 changes: 8 additions & 0 deletions .changeset/stale-bobcats-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@tus/file-store': minor
'@tus/gcs-store': minor
'@tus/s3-store': minor
'@tus/server': minor
---

Add new @tus/utils dependency to replace @tus/server peer dependency
6 changes: 6 additions & 0 deletions .github/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ yarn install || corepack yarn install
This means running `yarn build` in the root will build all packages in parallel.
The same goes for `lint` and `format`.

## Changesets

We use [changesets](https://github.com/changesets/changesets) to manage versioning, changelogs and publishing.
This means when you contribute a PR you have to run `yarn changeset` to indicate the semver bump you are making
and to add a changelog entry.

## Tests

You can run tests for individual packages by running a Yarn workspace command.
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: release

on: workflow_dispatch

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Decrypt keyfile
run: ./.github/scripts/decrypt_secret.sh
env:
KEYFILE_PASSPHRASE: ${{secrets.KEYFILE_PASSPHRASE}}

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*

- name: Install dependencies
run: corepack yarn install

- name: Build
run: corepack yarn build

- name: Run linters
run: corepack yarn lint

- name: Run tests
run: corepack yarn test
env:
AWS_BUCKET: ${{secrets.AWS_BUCKET}}
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
AWS_REGION: ${{secrets.AWS_REGION}}

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: corepack yarn release:local
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
"demo:s3": "yarn workspace demo start:s3",
"lint": "turbo run lint",
"format": "turbo run format",
"test": "turbo run test --concurrency 1"
"test": "turbo run test",
"release": "gh workflow run release",
"release:local": "turbo run build && changesets publish"
},
"devDependencies": {
"@changesets/cli": "^2.27.1",
"eslint": "^8.56.0",
"eslint-config-custom": "workspace:*",
"eslint-plugin-prettier": "^4.2.1",
Expand Down
48 changes: 0 additions & 48 deletions packages/file-store/configstores/FileConfigstore.ts

This file was deleted.

36 changes: 0 additions & 36 deletions packages/file-store/configstores/MemoryConfigstore.ts

This file was deleted.

40 changes: 0 additions & 40 deletions packages/file-store/configstores/RedisConfigstore.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/file-store/configstores/Types.ts

This file was deleted.

10 changes: 6 additions & 4 deletions packages/file-store/configstores/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export {FileConfigstore} from './FileConfigstore'
export {MemoryConfigstore} from './MemoryConfigstore'
export {RedisConfigstore} from './RedisConfigstore'
export {Configstore} from './Types'
export {
FileKvStore as FileConfigstore,
MemoryKvStore as MemoryConfigstore,
RedisKvStore as RedisConfigstore,
KvStore as Configstore,
} from '@tus/utils'
4 changes: 2 additions & 2 deletions packages/file-store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import http from 'node:http'
import debug from 'debug'

import {Configstore, FileConfigstore} from './configstores'
import {DataStore, Upload, ERRORS} from '@tus/server'
import {DataStore, Upload, ERRORS} from '@tus/utils'

export * from './configstores'

Expand Down Expand Up @@ -48,7 +48,7 @@ export class FileStore extends DataStore {
* Ensure the directory exists.
*/
private checkOrCreateDirectory() {
fs.mkdir(this.directory, MASK, (error) => {
fs.mkdir(this.directory, {mode: MASK, recursive: true}, (error) => {
if (error && error.code !== IGNORED_MKDIR_ERROR) {
throw error
}
Expand Down
5 changes: 1 addition & 4 deletions packages/file-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"test": "mocha test.ts --exit --extension ts --require ts-node/register"
},
"dependencies": {
"@tus/utils": "workspace:*",
"debug": "^4.3.4"
},
"devDependencies": {
"@tus/server": "workspace:^",
"@types/debug": "^4.1.12",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.5",
Expand All @@ -34,9 +34,6 @@
"should": "^13.2.3",
"typescript": "^5.3.3"
},
"peerDependencies": {
"@tus/server": "workspace:^"
},
"optionalDependencies": {
"@redis/client": "^1.5.13"
},
Expand Down
10 changes: 6 additions & 4 deletions packages/file-store/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ import path from 'node:path'
import sinon from 'sinon'

import {FileStore, FileConfigstore} from './'
import {Upload} from '@tus/server'
import {Upload} from '@tus/utils'

import * as shared from '../../test/stores.test'

const fixturesPath = path.resolve('../', '../', 'test', 'fixtures')
const storePath = path.resolve('../', '../', 'test', 'output')
const storePath = path.resolve('../', '../', 'test', 'output', 'file-store')

async function cleanup() {
await fsProm.rm(storePath, {recursive: true})
await fsProm.mkdir(storePath)
if (fs.existsSync(storePath)) {
await fsProm.rm(storePath, {recursive: true})
await fsProm.mkdir(storePath)
}
}

describe('FileStore', function () {
Expand Down
3 changes: 1 addition & 2 deletions packages/gcs-store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import stream from 'node:stream'
import http from 'node:http'
import debug from 'debug'

import {ERRORS, TUS_RESUMABLE} from '@tus/server'
import {Upload, DataStore} from '@tus/server'
import {ERRORS, TUS_RESUMABLE, Upload, DataStore} from '@tus/utils'

const log = debug('tus-node-server:stores:gcsstore')

Expand Down
4 changes: 2 additions & 2 deletions packages/gcs-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"test": "mocha test.ts --timeout 30000 --exit --extension ts --require ts-node/register"
},
"dependencies": {
"@tus/utils": "workspace:*",
"debug": "^4.3.4"
},
"devDependencies": {
Expand All @@ -36,8 +37,7 @@
"typescript": "^5.3.3"
},
"peerDependencies": {
"@google-cloud/storage": "*",
"@tus/server": "workspace:^"
"@google-cloud/storage": "*"
},
"engines": {
"node": ">=16"
Expand Down
2 changes: 1 addition & 1 deletion packages/gcs-store/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as shared from '../../test/stores.test'
import {Storage} from '@google-cloud/storage'

const fixturesPath = path.resolve('../', '../', 'test', 'fixtures')
const storePath = path.resolve('../', '../', 'test', 'output')
const storePath = path.resolve('../', '../', 'test', 'output', 'gcs-store')

describe('GCSStore', () => {
before(function () {
Expand Down
2 changes: 0 additions & 2 deletions packages/s3-store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ The ideal value for `maxConcurrentPartUploads` varies based on your `partSize` a

- **Bandwidth Considerations**: It's important to note that if your upload bandwidth to S3 is a limiting factor, increasing `maxConcurrentPartUploads` won’t lead to higher throughput. Instead, it will result in additional resource consumption without proportional gains in transfer speed.

- If you run multiple instances of TusServer you can share a Semaphore instance with the `maxConcurrentPartUploads: new Semaphore(10)` option.

## Extensions

The tus protocol supports optional [extensions][]. Below is a table of the supported extensions in `@tus/s3-store`.
Expand Down
Loading

0 comments on commit 2aacf2e

Please sign in to comment.