From 175a5caf376000995d0d0cc54edffe6ae2918a35 Mon Sep 17 00:00:00 2001 From: leokun <leokun@leokundeMac-Pro.local> Date: Sat, 2 Nov 2024 21:33:48 +0800 Subject: [PATCH] release --- .github/workflows/main.yml | 34 -------------------- .github/workflows/publish.yml | 7 +---- README.md | 59 ++--------------------------------- package.json | 21 ++----------- preparepublishnpm.sh | 2 -- 5 files changed, 7 insertions(+), 116 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 570ed45..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: CI -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] -jobs: - detectonly: - name: Detect use of .only - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Detect use of .only - run: | - grep -rq --include '*.spec.js' \.only\( . && echo 'You have .only() in your tests!' && exit 1 - exit 0 - asyncify: - name: Asyncify - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Default - run: | - sh setup.sh - git clone https://github.com/emscripten-core/emsdk.git - cd emsdk - ./emsdk install latest - ./emsdk activate latest - cd .. - source ./emsdk/emsdk_env.sh - cd emscriptenbuild - ./build.sh Release-async - cd .. - set -e diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 93e1814..fa4c633 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,9 +16,6 @@ jobs: registry-url: 'https://registry.npmjs.org' - name: Default run: | - npm install - npx playwright install-deps - npx playwright install sh setup.sh git clone https://github.com/emscripten-core/emsdk.git cd emsdk @@ -27,12 +24,10 @@ jobs: cd .. source ./emsdk/emsdk_env.sh cd emscriptenbuild - ./build.sh Release ./build.sh Release-async cd .. set -e - npm run test - export VERSION=`npm view wasm-git dist-tags.latest` + export VERSION=`npm view wasm-git-browser dist-tags.latest` export NEWVERSION=`node -p "require('./package.json').version"` echo $VERSION $NEWVERSION ./preparepublishnpm.sh diff --git a/README.md b/README.md index 884949b..247a5ec 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,5 @@ -Wasm-git -======== -(Wasm should be pronounced like `awesome` starting with a `W` ). -![](https://github.com/petersalomonsen/wasm-git/actions/workflows/main.yml/badge.svg) - -GIT for nodejs and the browser using [libgit2](https://libgit2.org/) compiled to WebAssembly with [Emscripten](https://emscripten.org). - -The main purpose of bringing git to the browser, is to enable storage of web application data locally in the users web browser, with the option to synchronize with a remote server. - -# Demo in the browser - -A simple demo in the browser can be found at: - -https://wasm-git.petersalomonsen.com/ - -**Please do not abuse, this is open for you to test and see the proof of concept** - -The sources for the demo can be found in the [githttpserver](https://github.com/petersalomonsen/githttpserver) project. It shows basic operations like cloning, edit files, add and commit, push and pull. - -# Demo videos - -Videos showing example applications using wasm-git can bee seen in [this playlist](https://www.youtube.com/watch?v=1Hqy7cVkygU&list=PLv5wm4YuO4Iyx00ifs6xUwIRSFnBI8GZh). Wasm-git is used for local and offline storage of web application data, and for syncing with a remote server. - -# Examples - -Wasm-git packages are built in two variants: Synchronuous and Asynchronuous. To run the sync version in the browser, a [webworker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) is needed. This is because of the use of synchronous http requests and long running operations that would block if running on the main thread. The sync version has the smallest binary, but need extra client code to communicate with the web worker. When using the sync version in nodejs [worker_threads](https://nodejs.org/api/worker_threads.html) are used, with [Atomics](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics) to exchange data between threads. - -The async version use [Emscripten Asyncify](https://emscripten.org/docs/porting/asyncify.html), which allows calling the Wasm-git functions with `async` / `await`. It can also run from the main thread in the browser. Asyncify increase the binary size because of instrumentation to unwind and rewind WebAssembly state, but makes it possible to have simple client code without exchanging data with worker threads like in the sync version. - -Examples of using Wasm-git can be found in the tests: - -- [test](./test/) for NodeJS -- [test-browser](./test-browser/) for the sync version in the browser with a web worker -- [test-browser-async](./test-browser-async/)] for the async version in the browser - -The examples shows importing the `lg2.js` / `lg2-async.js` modules from the local build, but you may also access these from releases available at public CDNs. - -# Building and developing - -The [Github actions test pipeline](./.github/workflows/main.yml) shows all the commands needed to install dependencies, build the packages and run the tests. - -Another option is loading the repository into a github codespace, where the configuration in [.devcontainer](./.devcontainer) folder will be used to install dependencies and set up a full development environment. - -# Emscripten fixes that were needed for making Wasm-git work - -As part of being able to compile libgit2 to WebAssembly and run it in a Javascript environment, some fixes to [Emscripten](https://emscripten.org/) were needed. - -Here are the Pull Requests that resolved the issues identified when the first version was developed: - -- https://github.com/emscripten-core/emscripten/pull/10095 -- https://github.com/emscripten-core/emscripten/pull/10526 -- https://github.com/emscripten-core/emscripten/pull/10782 - -for using with `NODEFS` you'll also need https://github.com/emscripten-core/emscripten/pull/10669 - -All of these pull requests are merged to emscripten master as of 2020-03-29. +built for the browser with [wasm-git](https://github.com/petersalomonsen/wasm-git) +<br/> +[issues](https://github.com/petersalomonsen/wasm-git/issues/16) diff --git a/package.json b/package.json index 76b2d31..553cc4e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { - "name": "wasm-git", + "name": "wasm-git-browser", "version": "0.0.13", + "main": "lg2_async.js", "type": "module", "author": { "name": "Peter Salomonsen", @@ -10,24 +11,8 @@ "url": "https://github.com/petersalomonsen/wasm-git" }, "files": [ - "lg2.js", - "lg2.wasm", "lg2_async.js", "lg2_async.wasm", "README.md" - ], - "scripts": { - "test": "mocha test/**/*.spec.js", - "test-browser": "wtr test-browser/**/*.spec.js", - "test-browser-watch": "wtr test-browser/**/*.spec.js --watch", - "test-browser-async": "wtr test-browser-async/**/*.spec.js", - "patch-version": "npm --no-git-tag-version version patch" - }, - "devDependencies": { - "@web/test-runner": "^0.18.2", - "@web/test-runner-playwright": "^0.11.0", - "cgi": "^0.3.1", - "chai": "^4.3.7", - "mocha": "^10.2.0" - } + ] } diff --git a/preparepublishnpm.sh b/preparepublishnpm.sh index 872454d..1c26545 100755 --- a/preparepublishnpm.sh +++ b/preparepublishnpm.sh @@ -1,8 +1,6 @@ #!/bin/bash set -e echo "copy lg2.wasm and lg2.js from build folder" -cp emscriptenbuild/libgit2/examples/lg2.wasm . -cp emscriptenbuild/libgit2/examples/lg2.js . cp emscriptenbuild/libgit2/examples/lg2_async.wasm . cp emscriptenbuild/libgit2/examples/lg2_async.js . echo "publish --dry-run (run npm publish to finalize)"