mirror of
https://github.com/amark/gun.git
synced 2025-11-24 14:35:55 +00:00
Merge branch 'master' of http://github.com/amark/gun
This commit is contained in:
commit
8cd8c4f6fb
39
.github/workflows/ci.yml
vendored
39
.github/workflows/ci.yml
vendored
@ -1,20 +1,23 @@
|
|||||||
name: ci
|
name: ci
|
||||||
|
|
||||||
on: [push, pull_request]
|
on:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
env:
|
env:
|
||||||
project: 'release-node'
|
project: 'gun'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
test:
|
test:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [14.x] # [12.x, 14.x]
|
node-version: [ 14.x ]
|
||||||
os: [ubuntu-latest] #, macos-latest, windows-latest]
|
os: [ ubuntu-latest ]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
|
# checkout the code
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
@ -22,11 +25,13 @@ jobs:
|
|||||||
- name: Version
|
- name: Version
|
||||||
uses: tcurdt/action-verify-version-npm@master
|
uses: tcurdt/action-verify-version-npm@master
|
||||||
|
|
||||||
|
# setup the node version
|
||||||
- name: Setup Node ${{ matrix.node-version }}
|
- name: Setup Node ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
|
# cache node_modules if we can
|
||||||
- name: Cache
|
- name: Cache
|
||||||
id: cache-modules
|
id: cache-modules
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
@ -34,42 +39,24 @@ jobs:
|
|||||||
path: node_modules
|
path: node_modules
|
||||||
key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }}
|
key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }}
|
||||||
|
|
||||||
|
# ottherweise run install
|
||||||
- name: Install
|
- name: Install
|
||||||
if: steps.cache-modules.outputs.cache-hit != 'true'
|
if: steps.cache-modules.outputs.cache-hit != 'true'
|
||||||
run: npm install
|
run: npm install
|
||||||
|
|
||||||
|
# run tests
|
||||||
- name: Test
|
- name: Test
|
||||||
run: npm test
|
run: npm test
|
||||||
|
|
||||||
# create release artifacts to publish as github release
|
# only create a release for tags named 'v*'
|
||||||
# - name: Upload
|
|
||||||
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
|
||||||
# uses: actions/upload-artifact@v2
|
|
||||||
# with:
|
|
||||||
# name: ${{ env.project }}_${{ matrix.os }}_${{ matrix.node-version }}
|
|
||||||
# path: |
|
|
||||||
# !.git
|
|
||||||
# !.github
|
|
||||||
# !node_modules
|
|
||||||
# .
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
||||||
needs: [ test ]
|
needs: [ test ]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
# - name: Download
|
# create github release (which triggers the release workflows)
|
||||||
# uses: actions/download-artifact@v2
|
|
||||||
# with:
|
|
||||||
# path: artifacts
|
|
||||||
# - name: Archives
|
|
||||||
# run: find artifacts -mindepth 1 -maxdepth 1 -exec tar -C {} -cvzf {}.tgz . \;
|
|
||||||
|
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
# with:
|
|
||||||
# files: |
|
|
||||||
# artifacts/*.tgz
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.PAT }}
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||||
|
|||||||
17
.github/workflows/cleanup.yml
vendored
17
.github/workflows/cleanup.yml
vendored
@ -1,17 +0,0 @@
|
|||||||
name: cleanup
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '1 1 * * 1' # once a week clean out old artifacts
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
expire:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
|
|
||||||
- name: Expire Artifacts
|
|
||||||
uses: kolpav/purge-artifacts-action@v1
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
expire-in: 1hour
|
|
||||||
@ -5,7 +5,7 @@ on:
|
|||||||
types: [ published ]
|
types: [ published ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
project: 'release-node'
|
project: 'gun'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
@ -26,10 +26,19 @@ jobs:
|
|||||||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
||||||
|
|
||||||
- name: Tag
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
docker tag ${{ env.project }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.project }}:${GITHUB_REF/refs\/tags\/v/}
|
echo "SHA=$GITHUB_SHA"
|
||||||
docker tag ${{ env.project }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.project }}:latest
|
docker build --build-arg \
|
||||||
|
SHA=$GITHUB_SHA \
|
||||||
|
BUILD_DATE=$(date +'%Y-%m-%d') \
|
||||||
|
VCS_REF=${GITHUB_REF/refs\/tags\/v/} \
|
||||||
|
VCS_URL=$GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} \
|
||||||
|
VERSION=${GITHUB_REF/refs\/tags\/v/} \
|
||||||
|
--label "sha=$GITHUB_SHA" \
|
||||||
|
--tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.project }}:${GITHUB_REF/refs\/tags\/v/} \
|
||||||
|
--tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.project }}:latest \
|
||||||
|
.
|
||||||
|
|
||||||
- name: Push
|
- name: Push
|
||||||
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.project }}
|
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.project }}
|
||||||
29
Dockerfile
29
Dockerfile
@ -1,5 +1,15 @@
|
|||||||
FROM alpine:latest
|
# install packages
|
||||||
# Build-time metadata as defined at http://label-schema.org
|
FROM node:14-alpine as builder
|
||||||
|
RUN mkdir /work
|
||||||
|
WORKDIR /work
|
||||||
|
RUN apk add --no-cache alpine-sdk python
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN mkdir -p node_modules
|
||||||
|
RUN npm ci --only=production
|
||||||
|
|
||||||
|
# fresh image without dev packages
|
||||||
|
FROM node:14-alpine
|
||||||
|
# build-time metadata as defined at http://label-schema.org
|
||||||
ARG BUILD_DATE
|
ARG BUILD_DATE
|
||||||
ARG VCS_REF
|
ARG VCS_REF
|
||||||
ARG VCS_URL
|
ARG VCS_URL
|
||||||
@ -12,15 +22,14 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
|
|||||||
org.label-schema.vendor="The Gun Database Team" \
|
org.label-schema.vendor="The Gun Database Team" \
|
||||||
org.label-schema.version=$VERSION \
|
org.label-schema.version=$VERSION \
|
||||||
org.label-schema.schema-version="1.0"
|
org.label-schema.schema-version="1.0"
|
||||||
# org.label-schema.description="Let it be pulled from Readme.md..." \
|
ARG SHA
|
||||||
WORKDIR /app
|
RUN mkdir /work
|
||||||
|
WORKDIR /work
|
||||||
|
COPY --from=builder /work/node_modules ./node_modules
|
||||||
|
RUN npm rebuild -q
|
||||||
ADD . .
|
ADD . .
|
||||||
ENV NPM_CONFIG_LOGLEVEL warn
|
RUN echo "{ \"sha\": \"$SHA\" }" > version.json
|
||||||
RUN apk update && apk upgrade \
|
RUN cat version.json
|
||||||
&& apk add --no-cache ca-certificates nodejs npm \
|
|
||||||
&& apk add --no-cache --virtual .build-dependencies python2 make g++ git \
|
|
||||||
&& npm install --production=false \
|
|
||||||
&& apk del .build-dependencies && rm -rf /var/cache/* /tmp/npm*
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
EXPOSE 8765
|
EXPOSE 8765
|
||||||
CMD ["npm","start"]
|
CMD ["npm","start"]
|
||||||
|
|||||||
37
README.md
37
README.md
@ -5,11 +5,15 @@
|
|||||||
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Famark%2Fgun?ref=badge_shield)
|
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Famark%2Fgun?ref=badge_shield)
|
||||||
[](http://chat.gun.eco)
|
[](http://chat.gun.eco)
|
||||||
|
|
||||||
**GUN** is an _ecosystem_ of tools that let you build [community run](https://www.nbcnews.com/tech/tech-news/these-technologists-think-internet-broken-so-they-re-building-another-n1030136) and [encrypted applications](https://gun.eco/docs/Cartoon-Cryptography).
|
**GUN** is an [ecosystem](https://gun.eco/docs/Ecosystem) of **tools** that let you build [community run](https://www.nbcnews.com/tech/tech-news/these-technologists-think-internet-broken-so-they-re-building-another-n1030136) and [encrypted applications](https://gun.eco/docs/Cartoon-Cryptography) - like an Open Source Firebase or a Decentralized Dropbox.
|
||||||
|
|
||||||
Currently, [Internet Archive](https://news.ycombinator.com/item?id=17685682) and [HackerNoon](https://www.coindesk.com/hacker-noon-is-storing-content-on-a-blockchain-after-ditching-medium) run GUN in production.
|
The [Internet Archive](https://news.ycombinator.com/item?id=17685682), [HackerNoon](https://www.coindesk.com/hacker-noon-is-storing-content-on-a-blockchain-after-ditching-medium), and [100s of other apps](https://github.com/amark/gun/wiki/awesome-gun) run GUN in-production. GUN is also part of [Twitter's Bluesky](https://blueskycommunity.net/) initiative!
|
||||||
|
|
||||||
Decentralized alternatives to [Zoom](https://www.zdnet.com/article/era-hatches-meething-an-open-source-browser-based-video-conferencing-system/), [Reddit](https://notabug.io/t/whatever/comments/36588a16b9008da4e3f15663c2225e949eca4a15/gpu-bot-test), [Slack](https://iris.to/), [YouTube](https://d.tube/), [Wikipedia](https://news.ycombinator.com/item?id=17685682), etc. have already pushed terabytes of daily P2P traffic on GUN. We are a [friendly community](http://chat.gun.eco/) creating a [free fun future for freedom](https://youtu.be/1HJdrBk3BlE):
|
+ Multiplayer by default with realtime p2p state synchronization!
|
||||||
|
+ Graph data let's you use key/value, tables, documents, videos, & more!
|
||||||
|
+ Local-first, offline, and decentralized with end-to-end encryption.
|
||||||
|
|
||||||
|
Decentralized alternatives to [Zoom](https://www.zdnet.com/article/era-hatches-meething-an-open-source-browser-based-video-conferencing-system/), [Reddit](https://notabug.io/t/whatever/comments/36588a16b9008da4e3f15663c2225e949eca4a15/gpu-bot-test), [Instagram](https://iris.to/), [Slack](https://iris.to/), [YouTube](https://d.tube/), [Stripe](https://twitter.com/marknadal/status/1422717427427647489), [Wikipedia](https://news.ycombinator.com/item?id=17685682), Facebook [Horizon](https://twitter.com/marknadal/status/1424476179189305347) and more have already pushed terabytes of daily P2P traffic on GUN. We are a [friendly community](http://chat.gun.eco/) creating a [free fun future for freedom](https://youtu.be/1HJdrBk3BlE):
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@ -29,15 +33,10 @@ Decentralized alternatives to [Zoom](https://www.zdnet.com/article/era-hatches-m
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
The ecosystem is one nice stack of technologies that looks like this: (names -> use case)
|
|
||||||
|
|
||||||
<div><img width="48%" src="https://gun.eco/see/stack.png"/>
|
|
||||||
<img width="48%" align="right" src="https://gun.eco/see/layers.png"/></div>
|
|
||||||
|
|
||||||
For now, it is best to start with GUN and _just use it_ to learn the basics, since it is _**so easy**_: (**or** want to read more? Skip ahead to the "[What is GUN?](#what-is-gun)" section.)
|
|
||||||
|
|
||||||
## Quickstart
|
## Quickstart
|
||||||
|
|
||||||
|
GUN is *super easy* to get started with:
|
||||||
|
|
||||||
- Try the [interactive tutorial](https://gun.eco/docs/Todo-Dapp) in the browser (**5min** ~ average developer).
|
- Try the [interactive tutorial](https://gun.eco/docs/Todo-Dapp) in the browser (**5min** ~ average developer).
|
||||||
- Or `npm install gun` and run the examples with `cd node_modules/gun && npm start` (**5min** ~ average developer).
|
- Or `npm install gun` and run the examples with `cd node_modules/gun && npm start` (**5min** ~ average developer).
|
||||||
|
|
||||||
@ -80,7 +79,7 @@ gun.get('mark').get('boss').get('name').once(function(data, key){
|
|||||||
|
|
||||||
// traverse a graph of circular references!
|
// traverse a graph of circular references!
|
||||||
gun.get('mark').get('boss').get('slave').once(function(data, key){
|
gun.get('mark').get('boss').get('slave').once(function(data, key){
|
||||||
console.log("Mark is the slave!", data);
|
console.log("Mark is the cat's slave!", data);
|
||||||
});
|
});
|
||||||
|
|
||||||
// add both of them to a table!
|
// add both of them to a table!
|
||||||
@ -93,14 +92,19 @@ gun.get('list').map().once(function(data, key){
|
|||||||
});
|
});
|
||||||
|
|
||||||
// live update the table!
|
// live update the table!
|
||||||
gun.get('list').set({type: "cucumber", goal: "scare cat"});
|
gun.get('list').set({type: "cucumber", goal: "jumping cat"});
|
||||||
```
|
```
|
||||||
|
|
||||||
Want to keep building more? **Jump to [THE DOCUMENTATION](#documentation)!**
|
Want to keep building more? **Jump to [THE DOCUMENTATION](#documentation)!**
|
||||||
|
|
||||||
# What is GUN?
|
# About
|
||||||
|
|
||||||
First & foremost, GUN is **a community of the nicest and most helpful people** out there. So [I want to invite you](https://gitter.im/amark/gun) to come tell us about what **you** are working on & wanting to build (new or old school alike! Just be nice as well.) and ask us your questions directly. :)
|
First & foremost, GUN is **a community of the nicest and most helpful people** out there. So [I want to invite you](http://chat.gun.eco) to come tell us about what **you** are working on & wanting to build (new or old school alike! Just be nice as well.) and ask us your questions directly. :)
|
||||||
|
|
||||||
|
The GUN ecosystem stack is a collection of independent and modular tools covering everything from [CRDT](https://crdt.tech/) [conflict resolution](https://gun.eco/distributed/matters.html), [cryptographic security](https://gun.eco/docs/Cartoon-Cryptography) & [encryption](https://gun.eco/docs/SEA), [radix storage serialization](https://gun.eco/docs/RAD), [mesh networking](https://gun.eco/docs/DAM) & [routing algorithms](https://gun.eco/docs/Routing), to distributed systems [correctness & load testing](https://github.com/gundb/panic-server), CPU scheduled [JSON parser](https://github.com/amark/gun/blob/master/lib/yson.js) to prevent UI lag, and more!
|
||||||
|
|
||||||
|
<div><img width="48%" src="https://gun.eco/see/stack.png"/>
|
||||||
|
<img width="48%" align="right" src="https://gun.eco/see/layers.png"/></div>
|
||||||
|
|
||||||
On that note, let's get some official shout outs covered first:
|
On that note, let's get some official shout outs covered first:
|
||||||
|
|
||||||
@ -134,13 +138,14 @@ Thanks to:
|
|||||||
<a href="http://github.com/bmatusiak">Bradley Matusiak</a>,
|
<a href="http://github.com/bmatusiak">Bradley Matusiak</a>,
|
||||||
<a href="https://github.com/sjuxax">Jeff Cook</a>,
|
<a href="https://github.com/sjuxax">Jeff Cook</a>,
|
||||||
<a href="https://github.com/nmauersberg">Nico</a>,
|
<a href="https://github.com/nmauersberg">Nico</a>,
|
||||||
<a href="https://github.com/ajartille">Aaron Artille</a>
|
<a href="https://github.com/ajartille">Aaron Artille</a>,
|
||||||
|
<a href="https://github.com/timjrobinson">Tim Robinson</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
- Join others in sponsoring code: https://www.patreon.com/gunDB !
|
- Join others in sponsoring code: https://www.patreon.com/gunDB !
|
||||||
- Ask questions: http://stackoverflow.com/questions/tagged/gun ?
|
- Ask questions: http://stackoverflow.com/questions/tagged/gun ?
|
||||||
- Found a bug? Report at: https://github.com/amark/gun/issues ;
|
- Found a bug? Report at: https://github.com/amark/gun/issues ;
|
||||||
- **Need help**? Chat with us: https://gitter.im/amark/gun .
|
- **Need help**? Chat with us: http://chat.gun.eco .
|
||||||
|
|
||||||
### History
|
### History
|
||||||
|
|
||||||
|
|||||||
63
lib/hub.js
63
lib/hub.js
@ -15,38 +15,95 @@ try { chokidar = require('chokidar') } catch (error) {
|
|||||||
* @param {Object} options - https://gun.eco/docs/hub.js#options
|
* @param {Object} options - https://gun.eco/docs/hub.js#options
|
||||||
*/
|
*/
|
||||||
function watch(what, options) {
|
function watch(what, options) {
|
||||||
options = options || { msg: true }
|
options = options ?? { msg: true, hubignore: false }
|
||||||
|
|
||||||
let modifiedPath = (options.file || "");
|
options.msg = options.msg ?? true;
|
||||||
|
options.hubignore = options.hubignore ?? false;
|
||||||
|
|
||||||
|
let modifiedPath = (options.file ?? "");
|
||||||
|
|
||||||
let watcher;
|
let watcher;
|
||||||
try {
|
try {
|
||||||
// Set up the file watcher.
|
|
||||||
|
if (options.hubignore) {
|
||||||
|
|
||||||
|
watcher = chokidar.watch(what, {
|
||||||
|
persistent: true
|
||||||
|
});
|
||||||
|
|
||||||
|
} else if (!options.hubignore) {
|
||||||
|
|
||||||
watcher = chokidar.watch(what, {
|
watcher = chokidar.watch(what, {
|
||||||
ignored: /(^|[\/\\])\../, // ignore dotfiles
|
ignored: /(^|[\/\\])\../, // ignore dotfiles
|
||||||
persistent: true
|
persistent: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
const log = console.log.bind(console);
|
const log = console.log.bind(console);
|
||||||
|
|
||||||
|
let hubignore;
|
||||||
|
|
||||||
// Handle events !
|
// Handle events !
|
||||||
watcher
|
watcher
|
||||||
.on('add', async function(path) {
|
.on('add', async function(path) {
|
||||||
|
|
||||||
|
if (options.hubignore && path.includes('.hubignore')) {
|
||||||
|
|
||||||
|
hubignore = fs.readFileSync(what + '/.hubignore', 'utf-8');
|
||||||
|
|
||||||
|
} else if (!path.includes('.hubignore') && !hubignore?.includes(path.substring(path.lastIndexOf("/") + 1))) {
|
||||||
|
|
||||||
if (options.msg) log(`File ${path} has been added`);
|
if (options.msg) log(`File ${path} has been added`);
|
||||||
|
|
||||||
|
if(path[path.search(/^./gm)] === "/" || ".") {
|
||||||
|
gun.get('hub').get(modifiedPath + path).put(fs.readFileSync(path, 'utf-8'))
|
||||||
|
} else {
|
||||||
gun.get('hub').get(modifiedPath + '/' + path).put(fs.readFileSync(path, 'utf-8'))
|
gun.get('hub').get(modifiedPath + '/' + path).put(fs.readFileSync(path, 'utf-8'))
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if(options.msg) log(`The addition of ${path} has been ignored !`)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.on('change', async function(path) {
|
.on('change', async function(path) {
|
||||||
|
|
||||||
|
if (options.hubignore && path.includes('.hubignore')) {
|
||||||
|
|
||||||
|
hubignore = fs.readFileSync(what + '/.hubignore', 'utf-8');
|
||||||
|
|
||||||
|
} else if (!path.includes('.hubignore') && !hubignore?.includes(path.substring(path.lastIndexOf('/') + 1))) {
|
||||||
|
|
||||||
if (options.msg) log(`File ${path} has been changed`);
|
if (options.msg) log(`File ${path} has been changed`);
|
||||||
gun.get('hub').get(modifiedPath + '/' + path).put(fs.readFileSync(path, 'utf-8'))
|
gun.get('hub').get(modifiedPath + '/' + path).put(fs.readFileSync(path, 'utf-8'))
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if(options.msg) log(`The changes on ${path} has been ignored.`)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.on('unlink', async function (path) {
|
.on('unlink', async function (path) {
|
||||||
|
|
||||||
|
if (options.hubignore && path.includes('.hubignore')) {
|
||||||
|
|
||||||
|
hubignore = fs.readFileSync(what + '/.hubignore', 'utf-8');
|
||||||
|
|
||||||
|
} else if (!path.includes('.hubignore') && !hubignore?.includes(path.substring(path.lastIndexOf('/') + 1))) {
|
||||||
|
|
||||||
if(options.msg) log(`File ${path} has been removed`);
|
if(options.msg) log(`File ${path} has been removed`);
|
||||||
gun.get('hub').get(modifiedPath + '/' + path).put(null)
|
gun.get('hub').get(modifiedPath + '/' + path).put(null)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if(options.msg) log(`The deletion of ${path} has been ignored!`)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
if (options.msg) {
|
if (options.msg) {
|
||||||
watcher
|
watcher
|
||||||
|
|||||||
1
test/hub/.hubignore
Normal file
1
test/hub/.hubignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
/whatever/aws-key.txt
|
||||||
9
test/hub/hub-test.js
Normal file
9
test/hub/hub-test.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// const Gun = require('../..');
|
||||||
|
// const gun = Gun();
|
||||||
|
|
||||||
|
// gun.get('hub').on(data => {
|
||||||
|
// console.log(data['/home/noctisatrae/gun/test/hub/index.html'])
|
||||||
|
// })
|
||||||
|
|
||||||
|
const hub = require('../../lib/hub');
|
||||||
|
hub.watch('/home/noctisatrae/gun/test/hub', {msg: true, hubignore: true})
|
||||||
12
test/hub/index.html
Normal file
12
test/hub/index.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Document</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
2
test/hub/whatever/aws-key.txt
Normal file
2
test/hub/whatever/aws-key.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
I'M A SUPER SECRET KEY WHICH SHALL NOT BE LEAKED
|
||||||
|
FOR YOUR OWN SAKE.
|
||||||
Loading…
x
Reference in New Issue
Block a user