Skip to content

Commit

Permalink
Revert "Remove diff-server from the JS SDK (#120)"
Browse files Browse the repository at this point in the history
This reverts commit 409d4ee.
  • Loading branch information
aboodman committed Oct 2, 2020
1 parent 456293f commit c29b8f4
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/perf.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:

- run: npm ci
- run: npm run build --if-present
- run: git restore --quiet bin/diff-server

# Run benchmark and stores the output to a file
- name: Run benchmark
Expand Down
2 changes: 1 addition & 1 deletion HACKING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Getting binary dependencies

`npm install` automatically downloads the correct version of the wasm bundle.
`npm install` automatically downloads the correct version of the wasm bundle and `diff-server`.

# Building against a dev version of repc

Expand Down
3 changes: 3 additions & 0 deletions bin/diff-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node
console.error('diff-server: Failed to install correctly');
process.exit(1);
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
"build": "tsc && rm -rf out/wasm && mkdir out/wasm && cp -R src/wasm/* out/wasm",
"build:watch": "tsc --watch",
"build:cjs": "tsc --outDir out.cjs --module CommonJS && rm -rf out.cjs/wasm && mkdir out.cjs/wasm && cp -R src/wasm/* out.cjs/wasm",
"start:diff-server": "bin/diff-server --db=/tmp/diffs serve",
"postinstall": "rm -f node_modules/fetch-mock/esm/client.d.ts && tool/get-deps.sh",
"prepublishOnly": "npm run lint && npm run test && rm -rf out && npm run build && rm -rf out.cjs && npm run build:cjs",
"prepublishOnly": "tool/validate-binaries-for-publish.js && npm run lint && npm run test && rm -rf out && npm run build && rm -rf out.cjs && npm run build:cjs",
"perf": "node perf/runner.mjs"
},
"bin": {
"diff-server": "bin/diff-server"
},
"devDependencies": {
"@esm-bundle/chai": "^4.1.5",
"@types/mocha": "^8.0.3",
Expand Down
8 changes: 7 additions & 1 deletion tool/get-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ REPC_VERSION='v0.9.0'
exit
fi

# Diff server is a public interface. We *do* maintain backward compat.
# We download the latest release.
echo "Fetching diff-server..."
URL="https://github.com/rocicorp/diff-server/releases/latest/download/diffs-$PLATFORM"
curl -L -f $URL > bin/diff-server
chmod u+x bin/diff-server

echo "Fetching repc..."
mkdir -p bin
URL="https://github.com/rocicorp/repc/releases/download/$REPC_VERSION/repc.zip"
curl -L -f $URL > bin/repc.zip
cd bin
Expand Down
27 changes: 27 additions & 0 deletions tool/validate-binaries-for-publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env node
'use strict';

// This file is used to ensure that we are not trying to publish the downloaded
// binaries.

const {existsSync, statSync} = require('fs');
const {join} = require('path');

function validateFile(name) {
const p = join(__dirname, '..', 'bin', name);
if (!existsSync(p)) {
console.error(`${name} does not exist`);
process.exit(1);
}

// If it exists, make sure that this is not the compiled binary.
const stat = statSync(p);
if (stat.size > 10000) {
console.error(
`${name} looks too large. Has it been replaced by the binary?`,
);
process.exit(1);
}
}

validateFile('diff-server');

2 comments on commit c29b8f4

@vercel
Copy link

@vercel vercel bot commented on c29b8f4 Oct 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on c29b8f4 Oct 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.