-
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1029 from streamich/bump-build-target
Bump build target
- Loading branch information
Showing
65 changed files
with
868 additions
and
3,698 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
|
||
jobs: | ||
gh-pages: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: yarn | ||
- run: yarn install --frozen-lockfile | ||
- run: yarn typedoc | ||
- run: yarn coverage | ||
- run: yarn build:pages | ||
- name: Publish to gh-pages | ||
uses: peaceiris/actions-gh-pages@v4 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./gh-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Mirror | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
|
||
jobs: | ||
mirror: | ||
name: Push To Gitlab | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Push To Gitlab | ||
env: | ||
token: ${{ secrets.GITLAB_TOKEN }} | ||
run: | | ||
git config user.name "streamich" | ||
git config user.email "[email protected]" | ||
git remote add mirror "https://oauth2:${token}@gitlab.com/streamich/memfs.git" | ||
git push mirror master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,9 +50,9 @@ | |
"demo/runkit.js" | ||
], | ||
"scripts": { | ||
"build": "tsc -p .", | ||
"build": "tsc -p . && rimraf --glob lib/__tests__ 'lib/**/__tests__'", | ||
"build:webfs": "NODE_ENV=production webpack --config ./src/webfs/webpack.config.js", | ||
"clean": "rimraf lib types", | ||
"clean": "rimraf lib types typedocs gh-pages coverage", | ||
"demo:crud-and-cas": "webpack serve --config ./demo/crud-and-cas/webpack.config.js", | ||
"demo:fsa-to-node-sync-tests": "webpack serve --config ./demo/fsa-to-node-sync-tests/webpack.config.js", | ||
"demo:fsa-to-node-zipfile": "webpack serve --config ./demo/fsa-to-node-zipfile/webpack.config.js", | ||
|
@@ -66,7 +66,10 @@ | |
"test:watch": "jest --watch", | ||
"tslint": "tslint \"src/**/*.ts\" -t verbose", | ||
"typecheck": "tsc -p .", | ||
"watch": "watch \"npm run build\" ./src" | ||
"watch": "watch \"npm run build\" ./src", | ||
"coverage": "yarn test --collectCoverage", | ||
"typedoc": "npx [email protected] --tsconfig tsconfig.json", | ||
"build:pages": "npx [email protected] gh-pages && mkdir -p gh-pages && cp -r typedocs/* gh-pages && cp -r coverage gh-pages/coverage" | ||
}, | ||
"commitlint": { | ||
"extends": [ | ||
|
@@ -121,13 +124,17 @@ | |
} | ||
}, | ||
"dependencies": { | ||
"@jsonjoy.com/json-pack": "^1.0.2", | ||
"@jsonjoy.com/util": "^1.1.0", | ||
"sonic-forest": "^1.0.0", | ||
"tslib": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@semantic-release/changelog": "^6.0.1", | ||
"@semantic-release/git": "^10.0.1", | ||
"@semantic-release/npm": "^9.0.1", | ||
"@types/jest": "^29.0.0", | ||
"@types/mime": "^3.0.0", | ||
"@types/node": "^10.17.60", | ||
"app-root-path": "^3.1.0", | ||
"assert": "^2.0.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,18 @@ | ||
import { hashToLocation } from './util'; | ||
import type { CasApi, CasGetOptions } from '../cas/types'; | ||
import type { CrudApi, CrudResourceInfo } from '../crud/types'; | ||
import { CrudCasBase } from './CrudCasBase'; | ||
import type { CrudApi } from '../crud/types'; | ||
|
||
export interface CrudCasOptions { | ||
hash: (blob: Uint8Array) => Promise<string>; | ||
} | ||
|
||
const normalizeErrors = async <T>(code: () => Promise<T>): Promise<T> => { | ||
try { | ||
return await code(); | ||
} catch (error) { | ||
if (error && typeof error === 'object') { | ||
switch (error.name) { | ||
case 'ResourceNotFound': | ||
case 'CollectionNotFound': | ||
throw new DOMException(error.message, 'BlobNotFound'); | ||
} | ||
} | ||
throw error; | ||
} | ||
}; | ||
const hashEqual = (h1: string, h2: string) => h1 === h2; | ||
|
||
export class CrudCas implements CasApi { | ||
export class CrudCas extends CrudCasBase<string> { | ||
constructor( | ||
protected readonly crud: CrudApi, | ||
protected readonly options: CrudCasOptions, | ||
) {} | ||
|
||
public readonly put = async (blob: Uint8Array): Promise<string> => { | ||
const digest = await this.options.hash(blob); | ||
const [collection, resource] = hashToLocation(digest); | ||
await this.crud.put(collection, resource, blob); | ||
return digest; | ||
}; | ||
|
||
public readonly get = async (hash: string, options?: CasGetOptions): Promise<Uint8Array> => { | ||
const [collection, resource] = hashToLocation(hash); | ||
return await normalizeErrors(async () => { | ||
const blob = await this.crud.get(collection, resource); | ||
if (!options?.skipVerification) { | ||
const digest = await this.options.hash(blob); | ||
if (hash !== digest) throw new DOMException('Blob contents does not match hash', 'Integrity'); | ||
} | ||
return blob; | ||
}); | ||
}; | ||
|
||
public readonly del = async (hash: string, silent?: boolean): Promise<void> => { | ||
const [collection, resource] = hashToLocation(hash); | ||
await normalizeErrors(async () => { | ||
return await this.crud.del(collection, resource, silent); | ||
}); | ||
}; | ||
|
||
public readonly info = async (hash: string): Promise<CrudResourceInfo> => { | ||
const [collection, resource] = hashToLocation(hash); | ||
return await normalizeErrors(async () => { | ||
return await this.crud.info(collection, resource); | ||
}); | ||
}; | ||
) { | ||
super(crud, options.hash, hashToLocation, hashEqual); | ||
} | ||
} |
Oops, something went wrong.