From 1359c7b2c54418603115beb50747486d8aa60661 Mon Sep 17 00:00:00 2001 From: Vahagn Khachatryan Date: Fri, 21 Dec 2018 16:29:41 +0000 Subject: [PATCH] grunt-init grunt-init-commonjs --force --- .gitignore | 1 + .jshintrc | 14 ++++++++ Gruntfile.js | 80 ++++++++++++++++++++++++++++++++++++++++++ LICENSE-MIT | 22 ++++++++++++ README.md | 63 +++++++++++++++++++++++++++++---- lib/.jshintrc | 13 +++++++ lib/gragir.js.js | 17 +++++++++ package.json | 39 ++++++++++++++++++++ test/gragir.js_test.js | 36 +++++++++++++++++++ 9 files changed, 279 insertions(+), 6 deletions(-) create mode 100644 .gitignore create mode 100644 .jshintrc create mode 100644 Gruntfile.js create mode 100644 LICENSE-MIT create mode 100644 lib/.jshintrc create mode 100644 lib/gragir.js.js create mode 100644 package.json create mode 100644 test/gragir.js_test.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2ccbe46 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/node_modules/ diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..8c86fc7 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,14 @@ +{ + "curly": true, + "eqeqeq": true, + "immed": true, + "latedef": true, + "newcap": true, + "noarg": true, + "sub": true, + "undef": true, + "unused": true, + "boss": true, + "eqnull": true, + "node": true +} diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..bec9c41 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,80 @@ +'use strict'; + +module.exports = function(grunt) { + + // Project configuration. + grunt.initConfig({ + // Metadata. + pkg: grunt.file.readJSON('package.json'), + banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + + '<%= grunt.template.today("yyyy-mm-dd") %>\n' + + '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + + '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + + ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n', + // Task configuration. + concat: { + options: { + banner: '<%= banner %>', + stripBanners: true + }, + dist: { + src: ['lib/<%= pkg.name %>.js'], + dest: 'dist/<%= pkg.name %>.js' + }, + }, + uglify: { + options: { + banner: '<%= banner %>' + }, + dist: { + src: '<%= concat.dist.dest %>', + dest: 'dist/<%= pkg.name %>.min.js' + }, + }, + nodeunit: { + files: ['test/**/*_test.js'] + }, + jshint: { + options: { + jshintrc: '.jshintrc' + }, + gruntfile: { + src: 'Gruntfile.js' + }, + lib: { + options: { + jshintrc: 'lib/.jshintrc' + }, + src: ['lib/**/*.js'] + }, + test: { + src: ['test/**/*.js'] + }, + }, + watch: { + gruntfile: { + files: '<%= jshint.gruntfile.src %>', + tasks: ['jshint:gruntfile'] + }, + lib: { + files: '<%= jshint.lib.src %>', + tasks: ['jshint:lib', 'nodeunit'] + }, + test: { + files: '<%= jshint.test.src %>', + tasks: ['jshint:test', 'nodeunit'] + }, + }, + }); + + // These plugins provide necessary tasks. + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-nodeunit'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-watch'); + + // Default task. + grunt.registerTask('default', ['jshint', 'nodeunit', 'concat', 'uglify']); + +}; diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..2a10d8c --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,22 @@ +Copyright (c) 2018 Vahagn Khachatryan + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 7b32084..7a7afa7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,57 @@ -#Gragir.JS -Gragir (Armenian: գրագիր) - per google translate: writer. -գիր (gir) - from Old Armenian գիր (gir). From Proto-Indo-European *wēr-, from *wer- (“to cut, scratch, tear, sketch an outline”). - -This is an experimental javascript library to generate EPUB v3 books right -from the browser. \ No newline at end of file +# gragir.js + +EPUB v3 generator. + +## Getting Started +### On the server +Install the module with: `npm install gragir.js` + +```javascript +var gragir_js = require('gragir.js'); +gragir_js.awesome(); // "awesome" +``` + +### In the browser +Download the [production version][min] or the [development version][max]. + +[min]: https://raw.github.com/KhachatryanVahagn/gragir.js/master/dist/gragir.js.min.js +[max]: https://raw.github.com/KhachatryanVahagn/gragir.js/master/dist/gragir.js.js + +In your web page: + +```html + + +``` + +In your code, you can attach gragir.js's methods to any object. + +```html + + + +``` + +## Documentation +_(Coming soon)_ + +## Examples +_(Coming soon)_ + +## Contributing +In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/). + +_Also, please don't edit files in the "dist" subdirectory as they are generated via Grunt. You'll find source code in the "lib" subdirectory!_ + +## Release History +_(Nothing yet)_ + +## License +Copyright (c) 2018 Vahagn Khachatryan +Licensed under the MIT license. diff --git a/lib/.jshintrc b/lib/.jshintrc new file mode 100644 index 0000000..9ed4773 --- /dev/null +++ b/lib/.jshintrc @@ -0,0 +1,13 @@ +{ + "curly": true, + "eqeqeq": true, + "immed": true, + "latedef": true, + "newcap": true, + "noarg": true, + "sub": true, + "undef": true, + "boss": true, + "eqnull": true, + "predef": ["exports"] +} diff --git a/lib/gragir.js.js b/lib/gragir.js.js new file mode 100644 index 0000000..746d6b3 --- /dev/null +++ b/lib/gragir.js.js @@ -0,0 +1,17 @@ +/* + * gragir.js + * https://github.com/vishap/gragir.js + * + * Copyright (c) 2018 Vahagn Khachatryan + * Licensed under the MIT license. + */ + +(function(exports) { + + 'use strict'; + + exports.awesome = function() { + return 'awesome'; + }; + +}(typeof exports === 'object' && exports || this)); diff --git a/package.json b/package.json new file mode 100644 index 0000000..c9c1208 --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "gragir.js", + "description": "EPUB v3 generator.", + "version": "0.1.0", + "homepage": "https://github.com/vishap/gragir.js", + "author": { + "name": "Vahagn Khachatryan", + "email": "vahagn.khachatryan@gmail.com" + }, + "repository": { + "type": "git", + "url": "https://github.com/vishap/gragir.js.git" + }, + "bugs": { + "url": "https://github.com/vishap/gragir.js/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://github.com/vishap/gragir.js/blob/master/LICENSE-MIT" + } + ], + "main": "lib/gragir.js", + "engines": { + "node": "10.14.2" + }, + "scripts": { + "test": "grunt nodeunit" + }, + "devDependencies": { + "grunt-contrib-concat": "~0.3.0", + "grunt-contrib-uglify": "~0.2.0", + "grunt-contrib-jshint": "~0.6.0", + "grunt-contrib-nodeunit": "~0.2.0", + "grunt-contrib-watch": "~0.4.0", + "grunt": "~0.4.5" + }, + "keywords": [] +} \ No newline at end of file diff --git a/test/gragir.js_test.js b/test/gragir.js_test.js new file mode 100644 index 0000000..5e17ddf --- /dev/null +++ b/test/gragir.js_test.js @@ -0,0 +1,36 @@ +'use strict'; + +var gragir_js = require('../lib/gragir.js.js'); + +/* + ======== A Handy Little Nodeunit Reference ======== + https://github.com/caolan/nodeunit + + Test methods: + test.expect(numAssertions) + test.done() + Test assertions: + test.ok(value, [message]) + test.equal(actual, expected, [message]) + test.notEqual(actual, expected, [message]) + test.deepEqual(actual, expected, [message]) + test.notDeepEqual(actual, expected, [message]) + test.strictEqual(actual, expected, [message]) + test.notStrictEqual(actual, expected, [message]) + test.throws(block, [error], [message]) + test.doesNotThrow(block, [error], [message]) + test.ifError(value) +*/ + +exports['awesome'] = { + setUp: function(done) { + // setup here + done(); + }, + 'no args': function(test) { + test.expect(1); + // tests here + test.equal(gragir_js.awesome(), 'awesome', 'should be awesome.'); + test.done(); + } +};