From ec96e8335b961db923b3b1e9c2a13edf067bddb8 Mon Sep 17 00:00:00 2001 From: Georg Fischer Date: Tue, 30 Aug 2016 21:48:44 +0200 Subject: [PATCH] add npm script support, update readme accordingly, update grund dependencies --- build/Gruntfile.js => Gruntfile.js | 80 +++++++++++++++--------------- README.md | 17 +++++-- build/package.json | 14 ------ package.json | 36 ++++++++++++++ 4 files changed, 90 insertions(+), 57 deletions(-) rename build/Gruntfile.js => Gruntfile.js (67%) delete mode 100644 build/package.json create mode 100644 package.json diff --git a/build/Gruntfile.js b/Gruntfile.js similarity index 67% rename from build/Gruntfile.js rename to Gruntfile.js index 5b1566a..32ac792 100644 --- a/build/Gruntfile.js +++ b/Gruntfile.js @@ -10,9 +10,9 @@ module.exports = function( grunt ) { options: { name: 'lib/almond', include: 'glitcher', - baseUrl: '../scripts/', - mainConfigFile: '../scripts/glitcher.js', - out: '../production/glitcher.min.js', + baseUrl: 'scripts/', + mainConfigFile: 'scripts/glitcher.js', + out: 'production/glitcher.min.js', wrap: true } } @@ -22,7 +22,7 @@ module.exports = function( grunt ) { cssmin: { production: { files: { - '../production/glitcher.min.css': [ '../styles/glitcher.css' ] + 'production/glitcher.min.css': [ 'styles/glitcher.css' ] } } }, @@ -37,14 +37,14 @@ module.exports = function( grunt ) { }, files: [ { expand: true, - cwd: '../', + cwd: './', src: 'images/icon/*.svg', - dest: '../production/' + dest: 'production/' }, { expand: true, - cwd: '../', + cwd: './', src: 'images/logos/*.svg', - dest: '../production/' + dest: 'production/' } ] } }, @@ -68,17 +68,17 @@ module.exports = function( grunt ) { }, production: { files: [ - { src: '../serviceworker.js', dest: '../production/serviceworker.min.js' }, - { src: '../scripts/workers/glitchworker.js', dest: '../production/glitchworker.min.js' }, + { src: 'serviceworker.js', dest: 'production/serviceworker.min.js' }, + { src: 'scripts/workers/glitchworker.js', dest: 'production/glitchworker.min.js' }, { src: [ - '../scripts/lib/localforage.nopromises.js', - '../scripts/lib/md5.js', - '../scripts/workers/storageworker.js' - ], dest: '../production/storageworker.min.js' }, + 'scripts/lib/localforage.nopromises.js', + 'scripts/lib/md5.js', + 'scripts/workers/storageworker.js' + ], dest: 'production/storageworker.min.js' }, { src: [ - '../scripts/lib/localforage.nopromises.js', - '../scripts/workers/settingsworker.js' - ], dest: '../production/settingsworker.min.js' } + 'scripts/lib/localforage.nopromises.js', + 'scripts/workers/settingsworker.js' + ], dest: 'production/settingsworker.min.js' } ] } }, @@ -88,39 +88,39 @@ module.exports = function( grunt ) { productionTextBasedFiles: { options: { processContent: updateContent }, files: [ - { src: '../index.html', dest: '../production/index.html' }, - { src: '../manifest.json', dest: '../production/manifest.json' }, - { src: '../.gitignore', dest: '../production/.gitignore' }, - { src: '../LICENSE', dest: '../production/LICENSE' }, + { src: 'index.html', dest: 'production/index.html' }, + { src: 'manifest.json', dest: 'production/manifest.json' }, + { src: '.gitignore', dest: 'production/.gitignore' }, + { src: 'LICENSE', dest: 'production/LICENSE' }, { expand: true, - cwd: '../', + cwd: './', src: [ 'lang/*.json' ], - dest: '../production/' + dest: 'production/' }, // copying these files 'in place' to apply updateContent function // that updates some of the paths in the minified files - { src: '../production/glitcher.min.js', dest: '../production/glitcher.min.js' }, - { src: '../production/serviceworker.min.js', dest: '../production/serviceworker.min.js' }, - { src: '../production/storageworker.min.js', dest: '../production/storageworker.min.js' }, - { src: '../production/settingsworker.min.js', dest: '../production/settingsworker.min.js' }, - { src: '../production/glitcher.min.css', dest: '../production/glitcher.min.css' } + { src: 'production/glitcher.min.js', dest: 'production/glitcher.min.js' }, + { src: 'production/serviceworker.min.js', dest: 'production/serviceworker.min.js' }, + { src: 'production/storageworker.min.js', dest: 'production/storageworker.min.js' }, + { src: 'production/settingsworker.min.js', dest: 'production/settingsworker.min.js' }, + { src: 'production/glitcher.min.css', dest: 'production/glitcher.min.css' } ] }, productionBinaryFiles: { files: [ { expand: true, - cwd: '../', + cwd: './', src: [ 'images/*.jpg' ], - dest: '../production/' + dest: 'production/' }, { expand: true, - cwd: '../', + cwd: './', src: [ 'images/logos/*.png' ], - dest: '../production/' + dest: 'production/' }, - { src: '../favicon.ico', dest: '../production/favicon.ico' } ] + { src: 'favicon.ico', dest: 'production/favicon.ico' } ] } }, @@ -151,7 +151,7 @@ module.exports = function( grunt ) { removeScriptTypeAttributes: true }, files: [ { - src: '../production/index.html', dest: '../production/index.html' + src: 'production/index.html', dest: 'production/index.html' } ] } }, @@ -159,7 +159,7 @@ module.exports = function( grunt ) { // replace javscript and css paths when copying files function updateContent ( content, path ) { - if ( path === '../index.html' ) { + if ( path === 'index.html' ) { content = content .replace( 'styles/glitcher.css', 'glitcher.min.css' ) .replace( 'scripts/lib/require.js', 'glitcher.min.js' ) @@ -167,14 +167,14 @@ module.exports = function( grunt ) { .replace( "scriptEl.setAttribute( 'data-main', 'scripts/glitcher.js' );", '' ); } - if ( path === '../production/glitcher.min.js' ) { + if ( path === 'production/glitcher.min.js' ) { content = content .replace( 'scripts/workers/glitchworker.js', 'glitchworker.min.js' ) .replace( 'scripts/workers/storageworker.js', 'storageworker.min.js' ) .replace( 'scripts/workers/settingsworker.js', 'settingsworker.min.js' ); } - if ( path === '../production/serviceworker.min.js' ) { + if ( path === 'production/serviceworker.min.js' ) { content = content .replace( /v\d+(.?\d*)+::/g, 'b' + Date.now() + '::' ) // 'v1.0.1::'' -> 'b{timestamp}' .replace( 'styles/glitcher.css', 'glitcher.min.css' ) @@ -184,15 +184,15 @@ module.exports = function( grunt ) { .replace( 'scripts/workers/settingsworker.js', 'settingsworker.min.js' ); } - if ( path === '../production/storageworker.min.js' || '../production/settingsworker.min.js' ) { + if ( path === 'production/storageworker.min.js' || 'production/settingsworker.min.js' ) { content = content.replace( /,importScripts\(.*\),/, ',' ); // replaces importScripts } - if ( path === '../production/glitcher.min.css' ) { + if ( path === 'production/glitcher.min.css' ) { content = content.replace( /\.\.\/images\//gi, 'images/' ); // replaces importScripts } - if ( path === '../manifest.json' ) { + if ( path === 'manifest.json' ) { content = content.replace( 'serviceworker.js', 'serviceworker.min.js' ); } diff --git a/README.md b/README.md index deed959..8f2ac8f 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,19 @@ build script --- the build script takes care of concatenating and minifying all scripts and styles. it uses [gruntjs](http://gruntjs.com/). -please make sure that both [nodejs](http://nodejs.org/) and grunt-cli are [set up properly](http://gruntjs.com/getting-started) on your machine. +please make sure that both [nodejs](http://nodejs.org/) and [npm](http://npmjs.com) are set up properly] on your machine. -run ```npm install``` from within the ```build/``` folder to install the dependencies of the build script. +run ```npm install``` to install the dependencies of the build script. + +to build, run ```npm run build``` the optimized files will get copied to the ```production/``` folder. + +missing somehing? +--- + +found a bug? missing a feature? instructions unclear? are you using this tool in an interesting project? maybe have a look at the [issues](../../issues), open a pull request and let me know. thanks! + +most importantly +--- + +thank you for taking a look at this repo. have a great day :) -to build, run ```grunt production``` from within the ```build/``` folder. the optimized files will get copied to the ```production/``` folder. diff --git a/build/package.json b/build/package.json deleted file mode 100644 index 7e775ec..0000000 --- a/build/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "distort-grid-build", - "version": "0.0.1", - "devDependencies": { - "grunt": "~0.4.1", - "grunt-contrib-copy": "~0.4.1", - "grunt-contrib-cssmin": "~0.6.1", - "grunt-contrib-htmlmin": "~0.6.0", - "grunt-contrib-imagemin": "~0.3.0", - "grunt-contrib-requirejs": "~0.4.1", - "grunt-contrib-uglify": "^0.11.0", - "grunt-svgmin": "^3.1.0" - } -} diff --git a/package.json b/package.json new file mode 100644 index 0000000..81810bb --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "jpg-glitch", + "version": "1.0.1", + "devDependencies": { + "grunt": "^1.0.1", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-cssmin": "^1.0.1", + "grunt-contrib-htmlmin": "^2.0.0", + "grunt-contrib-imagemin": "^1.0.1", + "grunt-contrib-requirejs": "^1.0.0", + "grunt-contrib-uglify": "^2.0.0", + "grunt-svgmin": "^3.3.0" + }, + "scripts": { + "build": "grunt" + }, + "description": "glitch images with jpg encoding", + "repository": { + "type": "git", + "url": "git+https://github.com/snorpey/jpg-glitch.git" + }, + "keywords": [ + "glitch", + "jpg", + "image manipulation", + "image processing", + "image", + "jpeg" + ], + "author": "georg fischer", + "license": "MIT", + "bugs": { + "url": "https://github.com/snorpey/jpg-glitch/issues" + }, + "homepage": "http://snorpey.github.io/jpg-glitch/" +}