diff --git a/.gitignore b/.gitignore index 86b0e6417..54f7cd559 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,6 @@ node_modules .DS_Store -components/oc.json -components/base-component-handlebars/_package -components/base-component-jade/_package \ No newline at end of file +src/components/oc.json +src/components/base-component-handlebars/_package +src/components/base-component-jade/_package \ No newline at end of file diff --git a/.npmignore b/.npmignore index 5a4acfe10..d2e04cd30 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,5 @@ -grunt-tasks +tasks test -.jshintrc .travis.yml appveyor.yml Gruntfile.js \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index d7feeb2b9..4f8a5a512 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,17 +2,11 @@ var _ = require('underscore'); -var customTasks = { - build: require('./grunt-tasks/support/task-build'), - generateCliDoc: require('./grunt-tasks/support/task-generate-cli-doc'), - version: require('./grunt-tasks/support/task-version') -}; - module.exports = function(grunt){ var taskObject = { pkg: grunt.file.readJSON('package.json') }; - grunt.file.expand('grunt-tasks/*.js', '!grunt-tasks/_*.js').forEach(function(file) { + grunt.file.expand('tasks/*.js', '!tasks/_*.js').forEach(function(file) { var name = file.split('/'); name = name[name.length - 1].replace('.js', ''); var task = require('./' + file); @@ -40,8 +34,4 @@ module.exports = function(grunt){ 'gitadd:changelog', 'gitcommit:changelog' ]); - - grunt.registerTask('build', 'Builds and minifies the oc-client component', customTasks.build(grunt, taskObject)); - grunt.registerTask('generate-cli-doc', 'Automatically updates the cli.md file', customTasks.generateCliDoc); - grunt.registerTask('version', 'Does the version upgrade', customTasks.version(grunt, taskObject)); }; diff --git a/grunt-tasks/support/task-generate-cli-doc.js b/grunt-tasks/support/task-generate-cli-doc.js deleted file mode 100644 index 4f8baa1d9..000000000 --- a/grunt-tasks/support/task-generate-cli-doc.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var fs = require('fs-extra'); -var path = require('path'); - -var commandsParser = require('./cli-commands-parser'); - -module.exports = function(){ - - var parsed = commandsParser.parse(), - data = fs.readFileSync(path.join(__dirname, 'cli-template.md'), 'utf8'), - newFileData = data.replace('[commands-shortlist]', parsed.commandList).replace('[commands-detailed]', parsed.detailedCommandList); - - fs.writeFileSync(path.join(__dirname, '../../docs/cli.md'), newFileData); -}; \ No newline at end of file diff --git a/grunt-tasks/support/task-version.js b/grunt-tasks/support/task-version.js deleted file mode 100644 index 45068c872..000000000 --- a/grunt-tasks/support/task-version.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -var fs = require('fs-extra'); -var path = require('path'); -var semver = require('semver'); - -module.exports = function(grunt, taskObject){ - return function(versionType){ - - taskObject.pkg.version = semver.inc(taskObject.pkg.version, versionType); - grunt.config.set('version', taskObject.pkg.version); - - grunt.log.ok('Package version upgrading to: ' + taskObject.pkg.version); - - fs.writeJsonSync(path.join(__dirname, '../../package.json'), taskObject.pkg, {spaces: 2}); - - grunt.task.run([ - 'test-local-silent', - 'generate-cli-doc', - 'build', - 'git-stage' - ]); - }; -}; \ No newline at end of file diff --git a/src/components/oc-client/_package/package.json b/src/components/oc-client/_package/package.json index 99ea0ae8c..f77321317 100644 --- a/src/components/oc-client/_package/package.json +++ b/src/components/oc-client/_package/package.json @@ -1 +1 @@ -{"name":"oc-client","description":"The OpenComponents client-side javascript client","version":"0.30.3","repository":"https://github.com/opentable/oc/tree/master/components/oc-client","author":"Matteo Figus ","oc":{"container":false,"renderInfo":false,"minify":false,"parameters":{},"files":{"template":{"type":"handlebars","hashKey":"bb774de6a2b7280c2b66103bd36d7e708a1b7541","src":"template.js"},"static":["src"],"dataProvider":{"type":"node.js","hashKey":"ffb0e43eaf72f55fa13dc1e7262019c14c3dfc81","src":"server.js"}},"version":"0.30.3","packaged":true,"date":1461936963577}} +{"name":"oc-client","description":"The OpenComponents client-side javascript client","version":"0.30.3","repository":"https://github.com/opentable/oc/tree/master/components/oc-client","author":"Matteo Figus ","oc":{"container":false,"renderInfo":false,"minify":false,"parameters":{},"files":{"template":{"type":"handlebars","hashKey":"bb774de6a2b7280c2b66103bd36d7e708a1b7541","src":"template.js"},"static":["src"],"dataProvider":{"type":"node.js","hashKey":"ffb0e43eaf72f55fa13dc1e7262019c14c3dfc81","src":"server.js"}},"version":"0.30.3","packaged":true,"date":1461939548142}} diff --git a/grunt-tasks/support/task-build.js b/tasks/build.js similarity index 80% rename from grunt-tasks/support/task-build.js rename to tasks/build.js index 85fe7e6c9..0d9f2191b 100644 --- a/grunt-tasks/support/task-build.js +++ b/tasks/build.js @@ -5,13 +5,15 @@ var fs = require('fs-extra'); var path = require('path'); var uglifyJs = require('uglify-js'); -module.exports = function(grunt, taskObject){ +var packageJson = require('../package'); - return function(){ +module.exports = function(grunt){ + + grunt.registerTask('build', 'Builds and minifies the oc-client component', function(){ var done = this.async(), - version = taskObject.pkg.version, - clientComponentDir = '../../src/components/oc-client/', + version = packageJson.version, + clientComponentDir = '../src/components/oc-client/', licenseRow = '/*! OpenComponents client v{0} | (c) 2015-{1} OpenTable, Inc. | {2} */', licenseLink = 'https://github.com/opentable/oc/tree/master/src/components/oc-client/LICENSES', license = format(licenseRow, version, new Date().getFullYear(), licenseLink), @@ -32,14 +34,14 @@ module.exports = function(grunt, taskObject){ fs.writeFileSync(path.join(__dirname, clientComponentDir, 'src/oc-client.min.js'), compressedCode); fs.writeFileSync(path.join(__dirname, clientComponentDir, 'src/oc-client.min.map'), compressed.map); - fs.writeFileSync(path.join(__dirname, '../../client/src/oc-client.min.js'), compressedCode); + fs.writeFileSync(path.join(__dirname, '../client/src/oc-client.min.js'), compressedCode); - var Local = require('../../src/cli/domain/local'), + var Local = require('../src/cli/domain/local'), local = new Local({ logger: { log: grunt.log.writeln }}); local.package(path.join(__dirname, clientComponentDir), function(err, res){ grunt.log[!!err ? 'error' : 'ok'](!!err ? err : 'Client has been built and packaged'); done(); }); - }; + }); }; \ No newline at end of file diff --git a/grunt-tasks/changelog.js b/tasks/changelog.js similarity index 100% rename from grunt-tasks/changelog.js rename to tasks/changelog.js diff --git a/tasks/generate-cli-doc.js b/tasks/generate-cli-doc.js new file mode 100644 index 000000000..482e01d03 --- /dev/null +++ b/tasks/generate-cli-doc.js @@ -0,0 +1,18 @@ +'use strict'; + +var fs = require('fs-extra'); +var path = require('path'); + +var commandsParser = require('./support/cli-commands-parser'); + +module.exports = function(grunt){ + + grunt.registerTask('generate-cli-doc', 'Automatically updates the cli.md file', function(){ + + var parsed = commandsParser.parse(), + data = fs.readFileSync(path.join(__dirname, 'support/cli-template.md'), 'utf8'), + newFileData = data.replace('[commands-shortlist]', parsed.commandList).replace('[commands-detailed]', parsed.detailedCommandList); + + fs.writeFileSync(path.join(__dirname, '../docs/cli.md'), newFileData); + }); +}; \ No newline at end of file diff --git a/grunt-tasks/gitadd.js b/tasks/gitadd.js similarity index 100% rename from grunt-tasks/gitadd.js rename to tasks/gitadd.js diff --git a/grunt-tasks/gitcommit.js b/tasks/gitcommit.js similarity index 100% rename from grunt-tasks/gitcommit.js rename to tasks/gitcommit.js diff --git a/grunt-tasks/gittag.js b/tasks/gittag.js similarity index 100% rename from grunt-tasks/gittag.js rename to tasks/gittag.js diff --git a/grunt-tasks/jshint.js b/tasks/jshint.js similarity index 91% rename from grunt-tasks/jshint.js rename to tasks/jshint.js index e3a0e6b55..44577bfed 100644 --- a/grunt-tasks/jshint.js +++ b/tasks/jshint.js @@ -2,7 +2,7 @@ module.exports = { options: { - jshintrc: 'grunt-tasks/support/.jshintrc', + jshintrc: 'tasks/support/.jshintrc', ignores: [ 'node_modules', 'client/src/oc-client.min.js', diff --git a/grunt-tasks/karma.js b/tasks/karma.js similarity index 100% rename from grunt-tasks/karma.js rename to tasks/karma.js diff --git a/grunt-tasks/mochaTest.js b/tasks/mochaTest.js similarity index 100% rename from grunt-tasks/mochaTest.js rename to tasks/mochaTest.js diff --git a/grunt-tasks/support/.jshintrc b/tasks/support/.jshintrc similarity index 100% rename from grunt-tasks/support/.jshintrc rename to tasks/support/.jshintrc diff --git a/grunt-tasks/support/cli-commands-parser.js b/tasks/support/cli-commands-parser.js similarity index 100% rename from grunt-tasks/support/cli-commands-parser.js rename to tasks/support/cli-commands-parser.js diff --git a/grunt-tasks/support/cli-template.md b/tasks/support/cli-template.md similarity index 100% rename from grunt-tasks/support/cli-template.md rename to tasks/support/cli-template.md diff --git a/tasks/version.js b/tasks/version.js new file mode 100644 index 000000000..074caf8e2 --- /dev/null +++ b/tasks/version.js @@ -0,0 +1,27 @@ +'use strict'; + +var fs = require('fs-extra'); +var path = require('path'); +var semver = require('semver'); + +var packageJson = require('../package'); + +module.exports = function(grunt, taskObject){ + + grunt.registerTask('version', 'Does the version upgrade', function(versionType){ + + packageJson.version = semver.inc(packageJson.version, versionType); + grunt.config.set('version', packageJson.version); + + grunt.log.ok('Package version upgrading to: ' + packageJson.version); + + fs.writeJsonSync(path.join(__dirname, '../package.json'), packageJson, {spaces: 2}); + + grunt.task.run([ + 'test-local-silent', + 'generate-cli-doc', + 'build', + 'git-stage' + ]); + }); +}; \ No newline at end of file