From b287c4bfbcb27b6a136829735fcc830649ad7f6a Mon Sep 17 00:00:00 2001 From: josdejong Date: Fri, 3 May 2013 22:55:15 +0200 Subject: [PATCH] Replaced ant build script with jake build script. Files moved around. Created package.json and component.json --- .gitignore | 1 + .npmignore | 13 + changelog.txt => HISTORY.md | 3 +- Jakefile.js | 313 + README.md | 24 +- app/chrome/manifest.json | 2 +- app/web/app.css | 2 +- app/web/index.html | 7 +- app/web/test.html | 41 +- build.xml | 197 - component.json | 33 + .../examples => examples}/01_basic_usage.html | 0 .../examples => examples}/02_viewer.html | 0 .../requirejs_demo/requirejs_demo.html | 0 .../requirejs_demo/scripts/main.js | 0 .../requirejs_demo/scripts/require.js | 0 .../css/img => img}/jsoneditor-icons.png | Bin jsoneditor-min.css | 1 + jsoneditor-min.js | 33 + jsoneditor.css | 597 ++ jsoneditor.js | 6039 +++++++++++++++++ package.json | 28 + {jsoneditor => src}/css/contextmenu.css | 0 {jsoneditor => src}/css/img/description.txt | 0 {jsoneditor => src}/css/img/export.sh | 0 src/css/img/jsoneditor-icons.png | Bin 0 -> 14438 bytes .../css/img/jsoneditor-icons.svg | 0 {jsoneditor => src}/css/jsoneditor.css | 0 {jsoneditor => src}/css/menu.css | 0 {jsoneditor => src}/css/searchbox.css | 0 {jsoneditor => src}/js/appendnode.js | 0 {jsoneditor => src}/js/contextmenu.js | 0 src/js/header.js | 32 + {jsoneditor => src}/js/highlighter.js | 0 {jsoneditor => src}/js/history.js | 0 {jsoneditor => src}/js/jsoneditor.js | 0 {jsoneditor => src}/js/module.js | 38 - {jsoneditor => src}/js/node.js | 0 {jsoneditor => src}/js/searchbox.js | 0 {jsoneditor => src}/js/texteditor.js | 0 {jsoneditor => src}/js/treeeditor.js | 0 {jsoneditor => src}/js/util.js | 0 42 files changed, 7139 insertions(+), 265 deletions(-) create mode 100644 .npmignore rename changelog.txt => HISTORY.md (98%) create mode 100644 Jakefile.js delete mode 100644 build.xml create mode 100644 component.json rename {jsoneditor/examples => examples}/01_basic_usage.html (100%) rename {jsoneditor/examples => examples}/02_viewer.html (100%) rename {jsoneditor/examples => examples}/requirejs_demo/requirejs_demo.html (100%) rename {jsoneditor/examples => examples}/requirejs_demo/scripts/main.js (100%) rename {jsoneditor/examples => examples}/requirejs_demo/scripts/require.js (100%) rename {jsoneditor/css/img => img}/jsoneditor-icons.png (100%) create mode 100644 jsoneditor-min.css create mode 100644 jsoneditor-min.js create mode 100644 jsoneditor.css create mode 100644 jsoneditor.js create mode 100644 package.json rename {jsoneditor => src}/css/contextmenu.css (100%) rename {jsoneditor => src}/css/img/description.txt (100%) rename {jsoneditor => src}/css/img/export.sh (100%) create mode 100644 src/css/img/jsoneditor-icons.png rename {jsoneditor => src}/css/img/jsoneditor-icons.svg (100%) rename {jsoneditor => src}/css/jsoneditor.css (100%) rename {jsoneditor => src}/css/menu.css (100%) rename {jsoneditor => src}/css/searchbox.css (100%) rename {jsoneditor => src}/js/appendnode.js (100%) rename {jsoneditor => src}/js/contextmenu.js (100%) create mode 100644 src/js/header.js rename {jsoneditor => src}/js/highlighter.js (100%) rename {jsoneditor => src}/js/history.js (100%) rename {jsoneditor => src}/js/jsoneditor.js (100%) rename {jsoneditor => src}/js/module.js (52%) rename {jsoneditor => src}/js/node.js (100%) rename {jsoneditor => src}/js/searchbox.js (100%) rename {jsoneditor => src}/js/texteditor.js (100%) rename {jsoneditor => src}/js/treeeditor.js (100%) rename {jsoneditor => src}/js/util.js (100%) diff --git a/.gitignore b/.gitignore index b6e637d..3567b39 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea build downloads +node_modules diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..a84c060 --- /dev/null +++ b/.npmignore @@ -0,0 +1,13 @@ +app +build +downloads +jsoneditor +misc +node_modules +test +tools +.idea +component.json +Jakefile.js +.npmignore +.gitignore diff --git a/changelog.txt b/HISTORY.md similarity index 98% rename from changelog.txt rename to HISTORY.md index 90e8f18..2486222 100644 --- a/changelog.txt +++ b/HISTORY.md @@ -1,4 +1,4 @@ -# JSON Editor Online - Changelog +# JSON Editor Online - History http://jsoneditoronline.org @@ -6,6 +6,7 @@ http://jsoneditoronline.org - Unified JSONFormatter and JSONEditor in one editor with a switchable mode. - Urls are navigable now. +- Added jsoneditor to npm and bower. ## 2013-03-11, version 2.1.1 diff --git a/Jakefile.js b/Jakefile.js new file mode 100644 index 0000000..128a5ca --- /dev/null +++ b/Jakefile.js @@ -0,0 +1,313 @@ +/** + * Jake build script + */ +var jake = require('jake'), + path = require('path'), + cleanCss = require('clean-css'), + archiver = require('archiver'), + fs = require('fs'); + +require('jake-utils'); + +// constants +var JSONEDITOR = './jsoneditor.js', + JSONEDITOR_CSS = './jsoneditor.css', + JSONEDITOR_MIN = './jsoneditor-min.js', + JSONEDITOR_CSS_MIN = './jsoneditor-min.css', + BUILD = './build'; + +/** + * default task + */ +desc('Execute all tasks: build, minify, and zip the library and web app'); +task('default', ['clear', 'build', 'minify', 'zip', 'webapp', 'chromeapp'], function () { + console.log('Done'); +}); + +/** + * build the library + */ +desc('Clear the build directory'); +task('clear', function () { + jake.rmRf(BUILD); +}); + +/** + * build the library + */ +desc('Build the library'); +task('build', ['clear'], function () { + // concatenate the javascript files + concat({ + src: [ + './src/js/jsoneditor.js', + './src/js/treeeditor.js', + './src/js/texteditor.js', + './src/js/node.js', + './src/js/appendnode.js', + './src/js/contextmenu.js', + './src/js/history.js', + './src/js/searchbox.js', + './src/js/highlighter.js', + './src/js/util.js', + './src/js/module.js' + ], + dest: JSONEDITOR, + header: read('./src/js/header.js') + '\n' + + '(function () {\n', + separator: '\n', + footer: '\n})();\n' + }); + + // update version number and stuff in the javascript files + replacePlaceholders(JSONEDITOR); + console.log('Created ' + JSONEDITOR); + + // concatenate and stringify the css files + concat({ + src: [ + './src/css/jsoneditor.css', + './src/css/contextmenu.css', + './src/css/menu.css', + './src/css/searchbox.css' + ], + dest: JSONEDITOR_CSS, + separator: '\n' + }); + console.log('Created ' + JSONEDITOR_CSS); + + // minify the css file + write(JSONEDITOR_CSS_MIN, cleanCss.process(String(read(JSONEDITOR_CSS)))); + + // create a folder img and copy the icons + jake.mkdirP('./img'); + jake.cpR('./src/css/img/jsoneditor-icons.png', './img/'); + console.log('Copied jsoneditor-icons.png to ./img/'); +}); + +/** + * minify the library + */ +desc('Minify the library'); +task('minify', ['build'], function () { + // minify javascript + minify({ + src: JSONEDITOR, + dest: JSONEDITOR_MIN, + header: read('./src/js/header.js') + }); + + // update version number and stuff in the javascript files + replacePlaceholders(JSONEDITOR_MIN); + + console.log('Created ' + JSONEDITOR_MIN); +}); + +/** + * zip the library + */ +desc('Zip the library'); +task('zip', ['build', 'minify'], {async: true}, function () { + var zipfolder = BUILD + '/lib'; + var pkg = 'jsoneditor-' + version(); + var zipfile = zipfolder + '/' + pkg + '.zip'; + jake.mkdirP(zipfolder); + + var output = fs.createWriteStream(zipfile); + var archive = archiver('zip'); + + archive.on('error', function(err) { + throw err; + }); + + archive.pipe(output); + + var filelist = new jake.FileList(); + filelist.include([ + 'README.md', + 'NOTICE', + 'LICENSE', + 'HISTORY.md', + JSONEDITOR, + JSONEDITOR_CSS, + JSONEDITOR_MIN, + JSONEDITOR_CSS_MIN, + 'img/*.*', + 'examples/**/*.*' + ]); + var files = filelist.toArray(); + files.forEach(function (file) { + archive.append(fs.createReadStream(file), { + name: pkg + '/' + file + }) + }); + + archive.finalize(function(err, written) { + if (err) { + throw err; + } + + console.log('Zipped ' + zipfile); + complete(); + }); +}); + +/** + * build the web app + */ +desc('Build web app'); +task('webapp', ['build', 'minify'], function () { + var webAppSrc = './app/web/'; + var webApp = BUILD + '/app/web/'; + var webAppLib = webApp + 'lib/'; + var webAppAce = webAppLib + 'ace/'; + var webAppImg = webApp + 'img/'; + var webAppDoc = webApp + 'doc/'; + var appJs = webApp + 'app.js'; + var appCss = webApp + 'app.css'; + var appCssMin = webApp + 'app-min.css'; + var appJsMin = webApp + 'app-min.js'; + + // create directories + // TODO: should be created automatically... + jake.mkdirP(webApp); + jake.mkdirP(webAppLib); + jake.mkdirP(webAppLib + 'ace/'); + jake.mkdirP(webAppLib + 'jsoneditor/'); + jake.mkdirP(webAppLib + 'jsoneditor/img/'); + jake.mkdirP(webAppLib + 'jsonlint/'); + jake.mkdirP(webAppImg); + jake.mkdirP(webAppDoc); + + // concatenate the javascript files + concat({ + src: [ + webAppSrc + 'queryparams.js', + webAppSrc + 'ajax.js', + webAppSrc + 'fileretriever.js', + webAppSrc + 'notify.js', + webAppSrc + 'splitter.js', + webAppSrc + 'app.js' + ], + dest: appJs, + separator: '\n' + }); + + // minify javascript + minify({ + src: appJs, + dest: appJsMin + }); + + // concatenate the css files + concat({ + src: [ + webAppSrc + 'fileretriever.css', + webAppSrc + 'app.css' + ], + dest: appCss, + separator: '\n' + }); + + // minify css file + write(appCssMin, cleanCss.process(String(read(appCss)))); + + // remove non minified javascript and css file + fs.unlinkSync(appJs); + fs.unlinkSync(appCss); + + // copy files + jake.cpR('./README.md', webApp); + jake.cpR('./HISTORY.md', webApp); + jake.cpR('./NOTICE', webApp); + jake.cpR('./LICENSE', webApp); + jake.cpR('./LICENSE', webApp); + jake.cpR(webAppSrc + 'robots.txt', webApp); + jake.cpR(webAppSrc + 'datapolicy.txt', webApp); + jake.cpR(webAppSrc + 'index.html', webApp); + jake.cpR(webAppSrc + 'favicon.ico', webApp); + jake.cpR(webAppSrc + 'fileretriever.php', webApp); + jake.cpR(webAppSrc + 'googlea47c4a0b36d11021.html', webApp); + jake.cpR(webAppSrc + 'img/logo.png', webAppImg); + jake.cpR(webAppSrc + 'img/header_background.png', webAppImg); + jake.cpR(webAppSrc + 'doc/', webAppDoc); + + // update date and verison in index.html + replacePlaceholders(webApp + 'index.html'); + replacePlaceholders(webApp + 'index.html'); // TODO: fix bug in replace, should replace all occurrences + + // concatenate and copy ace files + concat({ + src: [ + webAppSrc + 'lib/ace/ace.js', + webAppSrc + 'lib/ace/mode-json.js', + webAppSrc + 'lib/ace/theme-textmate.js', + webAppSrc + 'lib/ace/theme-jso.js' + ], + dest: webAppAce + 'ace-min.js', + separator: '\n' + }); + jake.cpR(webAppSrc + 'lib/ace/worker-json.js', webAppAce); + + // copy json lint file + jake.cpR(webAppSrc + 'lib/jsonlint/jsonlint.js', webAppLib + 'jsonlint/') + + // copy jsoneditor files + jake.cpR(JSONEDITOR_MIN, webAppLib + 'jsoneditor/'); + jake.cpR(JSONEDITOR_CSS_MIN, webAppLib + 'jsoneditor/'); + jake.cpR('img', webAppLib + 'jsoneditor/'); + +}); + +/** + * build the chrome app + */ +desc('Build chrome app'); +task('chromeapp', {async: true}, function () { + var folder = BUILD + '/app/'; + var file = folder + 'chrome.zip'; + jake.mkdirP(folder); + + var output = fs.createWriteStream(file); + var archive = archiver('zip'); + + archive.on('error', function(err) { + throw err; + }); + + // create a temporary manifest file with version number + var manifestTmp = folder + 'manifest.json.tmp'; + jake.cpR('./app/chrome/manifest.json', manifestTmp); + replacePlaceholders(manifestTmp); + + archive.pipe(output); + archive.append(fs.createReadStream(manifestTmp), {name: 'manifest.json'}); + archive.append(fs.createReadStream('./app/web/img/icon_16.png'), {name: 'icon_16.png'}); + archive.append(fs.createReadStream('./app/web/img/icon_128.png'), {name: 'icon_128.png'}); + + // cleanup temporary manifest file + fs.unlinkSync(manifestTmp); + + archive.finalize(function(err, written) { + if (err) { + throw err; + } + + console.log('Created chrome app ' + file); + complete(); + }); +}); + +/** + * replace version, date, and name placeholders in the provided file + * @param {String} filename + */ +var replacePlaceholders = function (filename) { + replace({ + replacements: [ + {pattern: '@@date', replacement: today()}, + {pattern: '@@version', replacement: version()} + ], + src: filename + }); +}; diff --git a/README.md b/README.md index 83de689..85d342c 100644 --- a/README.md +++ b/README.md @@ -40,13 +40,29 @@ a code editor. - Sourcecode: https://github.com/josdejong/jsoneditoronline/ +### Install + +with npm: + + npm install jsoneditor + +with bower: + + npm install bower + +downloads: + + http://jsoneditoronline.org/downloads/ + + ### Build -The code of the JSON Editor is located in the folder `jsoneditor`. +The code of the JSON Editor is located in the folder `src`. The code for the web application in `app/web`. To build the library from sourcecode, run - ant + jake -in the root of the project. This will generate a folder `build` containing -generated library and web application. +in the root of the project. This will generate the files `jsoneditor.js`, +`jsoneditor.css`, etc., and will create a folder `build` containing the +zipped library and the built web application. diff --git a/app/chrome/manifest.json b/app/chrome/manifest.json index a4a6081..8206ac4 100644 --- a/app/chrome/manifest.json +++ b/app/chrome/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "JSON Editor", - "version": "2.1.1", + "version": "@@version", "description": "JSON Editor is a tool to view, edit, and format JSON. It shows your data in an editable treeview and in a code editor.", "app": { "urls": [ diff --git a/app/web/app.css b/app/web/app.css index e7987e5..a97f5a9 100644 --- a/app/web/app.css +++ b/app/web/app.css @@ -180,7 +180,7 @@ span.header-light { margin: 0 0 15px 0; } -#splitter #toEditor { +#splitter #toTree { margin: 40px 0 0 0 ; } diff --git a/app/web/index.html b/app/web/index.html index 2fae00c..d89c577 100644 --- a/app/web/index.html +++ b/app/web/index.html @@ -37,7 +37,8 @@ Copyright (C) 2011-2013 Jos de Jong, http://jsoneditoronline.org @author Jos de Jong, - @date 2013-03-08 + @version @@version + @date @@date --> @@ -168,9 +169,9 @@