Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .babelrc

This file was deleted.

13 changes: 0 additions & 13 deletions .eslintrc

This file was deleted.

27 changes: 16 additions & 11 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,33 @@ name: Node.js Package
on:
release:
types: [created]
pull_request:
branches: [master]

jobs:
build:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

we might need to add a PR-time test run as well, for additional checks?

Add a pull_request: trigger that runs npm ci && npm test (CI=true) before this merges. Everything below is untested until that happens.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 10
node-version: 24
- run: npm ci
- run: npm test
env:
CI: true

publish:
if: github.event_name == 'release'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 10
- run: |
npm config set //npm.pkg.github.com/:always-auth true
npm config set //npm.pkg.github.com/:_authToken \${GITHUB_TOKEN}
npm ci
npm publish
node-version: 24
registry-url: https://npm.pkg.github.com
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v5.7.0
24
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

253 changes: 92 additions & 161 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,161 +1,92 @@
module.exports = function (grunt) {
'use strict';
// Project configuration.
var saucekey = process.env.saucekey;

if (!saucekey) {
console.warn('Unable to load Saucelabs key');
}

grunt.initConfig({
jade: {
release: {
files: {
'tests/index.html': ['tests/views/index.jade']
}
}
},

clean: ['tests/index.html'],

connect: {
server: {
options: {
base: '.',
port: 9999
}
}
},

'saucelabs-mocha': {
all: {
options: {
username: process.env.sauceuser,
key: saucekey,
testname: 'db.js',
tags: ['master'],
urls: ['http://127.0.0.1:9999/tests/index.html'],
public: !!process.env.TRAVIS_JOB_ID,
build: process.env.TRAVIS_JOB_ID,
browsers: [/* {
browserName: 'firefox',
platform: 'Windows 2012',
version: '17'
}, {
browserName: 'internet explorer',
platform: 'Windows 2012',
version: '10'
}, */
{
browserName: 'chrome',
platform: 'Windows 2008'
}]
},
onTestComplete: function (result, callback) {
console.dir(result);
}
}
},

karma: {
options: {
configFile: 'karma.conf.js'
},
ci: {
singleRun: true,
browsers: ['PhantomJS']
},
dev: {
singleRun: false,
browsers: ['PhantomJS']
},
'dev-single': {
singleRun: true,
browsers: ['PhantomJS']
}
},

eslint: {
target: ['src/db.js', 'src/test-worker.js']
},

babel: {
options: {
sourceMap: true
},
dist: {
files: {
'dist/db.js': 'src/db.js',
'tests/test-worker.js': 'src/test-worker.js'
}
}
},

browserify: {
dist: {
files: {
'dist/db.js': 'dist/db.js'
},
options: {
browserifyOptions: {
standalone: 'db'
}
}
}
},

uglify: {
options: {
sourceMap: true,
sourceMapIncludeSources: true
},
dbjs: {
options: {
sourceMapIn: 'dist/db.js.map' // input sourcemap from a previous compilation
},
files: {
'dist/db.min.js': ['dist/db.js']
}
},
testworker: {
options: {
sourceMapIn: 'tests/test-worker.js.map' // input sourcemap from a previous compilation
},
files: {
'tests/test-worker.js': ['tests/test-worker.js']
}
}
}
});

// load all grunt tasks
require('matchdep').filterDev(['grunt-*', '!grunt-cli']).forEach(grunt.loadNpmTasks);

grunt.registerTask('forever', function () {
this.async();
});

var devJobs = ['eslint', 'babel', 'browserify', 'uglify', 'clean', 'jade'];
var karmaJobs = devJobs.slice();
if (process.env.TRAVIS_JOB_ID) {
karmaJobs.push('karma:ci');
} else {
karmaJobs.push('karma:dev-single');
}

grunt.registerTask('dev', devJobs);
grunt.registerTask('phantom', karmaJobs);
grunt.registerTask('test', function () {
var testJobs = karmaJobs.concat('connect');
if (saucekey && !process.env.TRAVIS_PULL_REQUEST) {
console.info('adding Saucelabs integration');
testJobs.push('saucelabs-mocha');
}
grunt.task.run(testJobs);
});
grunt.registerTask('default', 'test');
grunt.registerTask('test:local', function () {
grunt.task.run(devJobs);
grunt.task.run('connect:server:keepalive');
});
};
module.exports = function (grunt) {
'use strict';

grunt.initConfig({
clean: ['dist/db.js', 'dist/db.js.map', 'tests/test-worker.js', 'tests/test-worker.js.map'],

connect: {
server: {
options: {
base: '.',
port: 9999
}
}
},

karma: {
options: {
configFile: 'karma.conf.js'
},
ci: {
singleRun: true,
browsers: ['ChromeHeadlessCI']
},
dev: {
singleRun: false,
browsers: ['ChromeHeadless']
},
'dev-single': {
singleRun: true,
browsers: ['ChromeHeadless']
}
},

babel: {
options: {
sourceMap: true
},
dist: {
files: {
'dist/db.js': 'src/db.js',
'tests/test-worker.js': 'src/test-worker.js'
}
}
},

browserify: {
dist: {
files: {
'dist/db.js': 'dist/db.js'
},
options: {
browserifyOptions: {
standalone: 'db'
}
}
}
},

uglify: {
options: {
sourceMap: true,
sourceMapIncludeSources: true
},
dbjs: {
options: {
sourceMapIn: 'dist/db.js.map'
},
files: {
'dist/db.min.js': ['dist/db.js']
}
}
}
});

require('matchdep').filterDev(['grunt-*', '!grunt-cli']).forEach(grunt.loadNpmTasks);

var devJobs = ['babel', 'browserify', 'uglify'];
var karmaJobs = devJobs.slice();
if (process.env.CI) {
karmaJobs.push('karma:ci');
} else {
karmaJobs.push('karma:dev-single');
}

grunt.registerTask('dev', devJobs);
grunt.registerTask('test', karmaJobs.concat('connect'));
grunt.registerTask('default', 'test');
grunt.registerTask('test:local', function () {
grunt.task.run(devJobs);
grunt.task.run('connect:server:keepalive');
});
};
22 changes: 6 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -628,24 +628,14 @@ library.

# Contributor notes

- `npm install` to install all the dependencies
Requires **Node.js 24+** (see the `engines` field in `package.json`).

In browser:
- `npm install` — install all dependencies. On the first install, Puppeteer downloads a pinned Chrome for Testing build used to run the test suite.
- `npm test` — build (`babel` → `browserify` → `uglify`) and run the full Karma test suite in headless Chrome. Set `CI=true` to match the CI configuration (adds `--no-sandbox`).
- `npm run grunt dev` — run only the build steps without executing tests.
- `npm run grunt test:local` — build, then start a static server at `http://localhost:9999/` so you can load the mocha harness in a regular browser for interactive debugging.

- `npm run grunt test:local` to run the mocha server
- Open (`http://localhost:9999/tests`)[] to run the mocha tests

In Node.js:

- `npm test`

or to avoid Saucelabs if set up:

- `npm run grunt phantom`

or to also avoid PhantomJS:

- `npm run grunt dev`
The test toolchain uses Karma 6 + Mocha 10 + Chai 4 + Puppeteer-bundled Chromium; there is no longer any dependency on PhantomJS, Saucelabs, or Jade. CI runs on GitHub Actions against Node.js 24.

# License

Expand Down
5 changes: 5 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
["@babel/preset-env", { "targets": { "esmodules": true } }]
]
}
Loading
Loading