Replace remaining grunt tasks with npm scripts
This commit is contained in:
parent
cde282d4f1
commit
0c5598a0fc
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,5 +4,4 @@ npm*
|
|||
test/lib/
|
||||
dist/
|
||||
openpgp.store/
|
||||
doc/
|
||||
.nyc_output/
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
module.exports = {
|
||||
plugins: ['plugins/markdown']
|
||||
plugins: ['plugins/markdown'],
|
||||
markdown: {
|
||||
idInHeadings: true
|
||||
}
|
||||
};
|
||||
|
|
|
@ -39,7 +39,7 @@ matrix:
|
|||
- node_js: "9"
|
||||
|
||||
before_script:
|
||||
- npm install -g grunt-cli codeclimate-test-reporter browserstack-runner
|
||||
- npm install -g codeclimate-test-reporter browserstack-runner
|
||||
script:
|
||||
- $TRAVIS_BUILD_DIR/travis.sh
|
||||
install: npm install
|
||||
|
|
163
Gruntfile.js
163
Gruntfile.js
|
@ -1,163 +0,0 @@
|
|||
module.exports = function(grunt) {
|
||||
|
||||
const version = grunt.option('release');
|
||||
const fs = require('fs');
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
nyc: {
|
||||
cover: {
|
||||
options: {
|
||||
include: ['dist/**'],
|
||||
reporter: ['text-summary'],
|
||||
reportDir: 'coverage'
|
||||
},
|
||||
cmd: false,
|
||||
args: ['grunt', 'mochaTest'],
|
||||
sourceMap: true
|
||||
},
|
||||
report: {
|
||||
options: {
|
||||
reporter: 'text'
|
||||
}
|
||||
}
|
||||
},
|
||||
jsbeautifier: {
|
||||
files: ['src/**/*.js'],
|
||||
options: {
|
||||
indent_size: 2,
|
||||
preserve_newlines: true,
|
||||
keep_array_indentation: false,
|
||||
keep_function_indentation: false,
|
||||
wrap_line_length: 120
|
||||
}
|
||||
},
|
||||
eslint: {
|
||||
target: ['src/**/*.js', './Gruntfile.js', './eslintrc.js', 'test/crypto/**/*.js'],
|
||||
options: {
|
||||
configFile: '.eslintrc.js',
|
||||
fix: !!grunt.option('fix')
|
||||
}
|
||||
},
|
||||
jsdoc: {
|
||||
dist: {
|
||||
src: ['README.md', 'src'],
|
||||
options: {
|
||||
configure: '.jsdocrc.js',
|
||||
destination: 'doc',
|
||||
recurse: true
|
||||
}
|
||||
}
|
||||
},
|
||||
mochaTest: {
|
||||
unittests: {
|
||||
options: {
|
||||
reporter: 'spec',
|
||||
timeout: 120000,
|
||||
grep: lightweight ? 'lightweight' : undefined
|
||||
},
|
||||
src: ['test/unittests.js']
|
||||
}
|
||||
},
|
||||
copy: {
|
||||
browsertest: {
|
||||
expand: true,
|
||||
flatten: true,
|
||||
cwd: 'node_modules/',
|
||||
src: ['mocha/mocha.css', 'mocha/mocha.js'],
|
||||
dest: 'test/lib/'
|
||||
},
|
||||
openpgp_compat: {
|
||||
expand: true,
|
||||
cwd: 'dist/',
|
||||
src: ['*.js'],
|
||||
dest: 'dist/compat/'
|
||||
},
|
||||
openpgp_lightweight: {
|
||||
expand: true,
|
||||
cwd: 'dist/',
|
||||
src: ['*.js'],
|
||||
dest: 'dist/lightweight/'
|
||||
},
|
||||
indutny_elliptic: {
|
||||
expand: true,
|
||||
flatten: true,
|
||||
src: ['./node_modules/elliptic/dist/elliptic.min.js'],
|
||||
dest: 'dist/lightweight/'
|
||||
}
|
||||
},
|
||||
clean: {
|
||||
dist: ['dist/'],
|
||||
js: ['dist/*.js']
|
||||
},
|
||||
connect: {
|
||||
dev: {
|
||||
options: {
|
||||
port: 3001,
|
||||
base: '.',
|
||||
keepalive: true
|
||||
}
|
||||
},
|
||||
test: {
|
||||
options: {
|
||||
port: 3000,
|
||||
base: '.'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Load the plugin(s)
|
||||
grunt.loadNpmTasks('grunt-text-replace');
|
||||
grunt.loadNpmTasks('grunt-jsbeautifier');
|
||||
grunt.loadNpmTasks('grunt-jsdoc');
|
||||
grunt.loadNpmTasks('gruntify-eslint');
|
||||
grunt.loadNpmTasks('grunt-mocha-test');
|
||||
grunt.loadNpmTasks('grunt-contrib-copy');
|
||||
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||
grunt.loadNpmTasks('grunt-contrib-connect');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-simple-nyc');
|
||||
|
||||
grunt.registerTask('set_version', function() {
|
||||
if (!version) {
|
||||
throw new Error('You must specify the version: "--release=1.0.0"');
|
||||
}
|
||||
|
||||
patchFile({
|
||||
fileName: 'package.json',
|
||||
version: version
|
||||
});
|
||||
|
||||
patchFile({
|
||||
fileName: 'package-lock.json',
|
||||
version: version
|
||||
});
|
||||
|
||||
patchFile({
|
||||
fileName: 'bower.json',
|
||||
version: version
|
||||
});
|
||||
});
|
||||
|
||||
function patchFile(options) {
|
||||
const path = './' + options.fileName;
|
||||
//eslint-disable-next-line
|
||||
const file = require(path);
|
||||
|
||||
if (options.version) {
|
||||
file.version = options.version;
|
||||
}
|
||||
//eslint-disable-next-line
|
||||
fs.writeFileSync(path, JSON.stringify(file, null, 2) + '\n');
|
||||
}
|
||||
|
||||
// Build tasks
|
||||
grunt.registerTask('version', ['replace:openpgp']);
|
||||
grunt.registerTask('documentation', ['jsdoc']);
|
||||
grunt.registerTask('default', ['build']);
|
||||
// Test/Dev tasks
|
||||
grunt.registerTask('test', ['eslint', 'mochaTest']);
|
||||
grunt.registerTask('coverage', ['nyc']);
|
||||
grunt.registerTask('browsertest', ['build', 'browserify:unittests', 'copy:browsertest', 'connect:test', 'watch']);
|
||||
};
|
|
@ -563,9 +563,9 @@ To create your own build of the library, just run the following command after cl
|
|||
|
||||
npm install && npm test
|
||||
|
||||
For debugging browser errors, you can open `test/unittests.html` in a browser or, after running the following command, open [`http://localhost:3000/test/unittests.html`](http://localhost:3000/test/unittests.html):
|
||||
For debugging browser errors, you can run `npm start` and open [`http://localhost:8080/test/unittests.html`](http://localhost:8080/test/unittests.html) in a browser, or run the following command:
|
||||
|
||||
grunt browsertest
|
||||
npm run browsertest
|
||||
|
||||
### How do I get involved?
|
||||
|
||||
|
|
2082
package-lock.json
generated
2082
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
|
@ -32,8 +32,12 @@
|
|||
"scripts": {
|
||||
"build": "rollup --config --sourcemap",
|
||||
"prepare": "npm run build",
|
||||
"test": "grunt test",
|
||||
"lint": "eslint src"
|
||||
"test": "mocha --timeout 120000 test/unittests.js",
|
||||
"start": "http-server",
|
||||
"browsertest": "npm start -- -o test/unittests.html",
|
||||
"coverage": "nyc npm test",
|
||||
"lint": "eslint 'src/**/*.js' 'test/crypto/**/*.js'",
|
||||
"docs": "jsdoc --configure .jsdocrc.js --destination docs --recurse README.md src"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mattiasbuelens/web-streams-adapter": "0.1.0-alpha.5",
|
||||
|
@ -53,18 +57,9 @@
|
|||
"eslint-config-airbnb-base": "^12.1.0",
|
||||
"eslint-plugin-chai-friendly": "^0.5.0",
|
||||
"eslint-plugin-import": "^2.8.0",
|
||||
"grunt": "^1.1.0",
|
||||
"grunt-contrib-clean": "~1.1.0",
|
||||
"grunt-contrib-connect": "~1.0.2",
|
||||
"grunt-contrib-copy": "~1.0.0",
|
||||
"grunt-contrib-watch": "^1.1.0",
|
||||
"grunt-jsbeautifier": "^0.2.13",
|
||||
"grunt-jsdoc": "^2.2.1",
|
||||
"grunt-mocha-test": "^0.13.3",
|
||||
"grunt-simple-nyc": "^3.0.1",
|
||||
"grunt-text-replace": "~0.4.0",
|
||||
"gruntify-eslint": "^4.0.0",
|
||||
"hash.js": "^1.1.3",
|
||||
"http-server": "^0.12.3",
|
||||
"jsdoc": "^3.6.4",
|
||||
"mocha": "^5.0.0",
|
||||
"nyc": "^14.1.1",
|
||||
"pako": "^1.0.6",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenPGPJS Unit Tests</title>
|
||||
<link rel="stylesheet" href="lib/mocha.css" />
|
||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
|
||||
|
||||
<!-- libs -->
|
||||
<script>
|
||||
|
@ -13,7 +13,7 @@
|
|||
document.write('<script src="../dist/openpgp.js"><\/script>');
|
||||
}
|
||||
</script>
|
||||
<script src="lib/mocha.js"></script>
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script>
|
||||
mocha.setup('bdd');
|
||||
mocha.timeout(240000);
|
||||
|
|
Loading…
Reference in New Issue
Block a user