From 8986017184f5cde65f916109e7bce26ab4c8ec88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Matall=C3=ADn?= Date: Tue, 25 Apr 2017 16:11:02 +0200 Subject: [PATCH] split compass sass --- Gruntfile.js | 789 +++++++++++++++------------- config.rb | 2 +- lib/build/files/browserify_files.js | 5 - lib/build/files/css_files.js | 3 - lib/build/tasks/clean.js | 40 +- lib/build/tasks/compass.js | 11 +- lib/build/tasks/copy.js | 540 ++++++++----------- lib/build/tasks/manifest.js | 2 - lib/build/tasks/sass.js | 43 ++ package.json | 3 +- 10 files changed, 706 insertions(+), 732 deletions(-) create mode 100644 lib/build/tasks/sass.js diff --git a/Gruntfile.js b/Gruntfile.js index 50185e66aa..28416e0e6d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -48,425 +48,484 @@ function isRunningTask (taskName, grunt) { /** * CartoDB UI assets generation */ - module.exports = function(grunt) { + if (timer) timer.init(grunt); - if (timer) timer.init(grunt); - - var environment = grunt.option('environment') || DEVELOPMENT; - grunt.log.writeln('Environment: ' + environment); + var environment = grunt.option('environment') || DEVELOPMENT; + grunt.log.writeln('Environment: ' + environment); - var runningTasks = grunt.cli.tasks; - if (runningTasks.length === 0) { - grunt.log.writeln('Running default task.'); - } else { - grunt.log.writeln('Running tasks: ' + runningTasks); - } + var runningTasks = grunt.cli.tasks; + if (runningTasks.length === 0) { + grunt.log.writeln('Running default task.'); + } else { + grunt.log.writeln('Running tasks: ' + runningTasks); + } - function preFlight(requiredNodeVersion, requiredNpmVersion, logFn) { - function checkVersion(cmd, versionRange, name, logFn) { - grunt.log.writeln('Required ' + name + ' version: ' + versionRange); - require("child_process").exec(cmd, function (error, stdout, stderr) { - var err = null; - if (error) { - err = 'failed to check version for ' + name; - } else { - var installed = semver.clean(stdout); - if (!semver.satisfies(installed, versionRange)) { - err = 'Installed ' + name + ' version does not match with required [' + versionRange + "] Installed: " + installed; - } - } - if (err) { - grunt.log.fail(err); + function preFlight(requiredNodeVersion, requiredNpmVersion, logFn) { + function checkVersion(cmd, versionRange, name, logFn) { + grunt.log.writeln('Required ' + name + ' version: ' + versionRange); + require("child_process").exec(cmd, function (error, stdout, stderr) { + var err = null; + if (error) { + err = 'failed to check version for ' + name; + } else { + var installed = semver.clean(stdout); + if (!semver.satisfies(installed, versionRange)) { + err = 'Installed ' + name + ' version does not match with required [' + versionRange + "] Installed: " + installed; } - logFn && logFn(err ? new Error(err): null); - }); - } - checkVersion('node -v', requiredNodeVersion, 'node', logFn); - checkVersion('npm -v', requiredNpmVersion, 'npm', logFn); - } - - var mustCheckNodeVersion = grunt.option('no-node-checker'); - if (!mustCheckNodeVersion) { - preFlight(REQUIRED_NODE_VERSION, REQUIRED_NPM_VERSION, logVersionsError); - grunt.log.writeln(''); + } + if (err) { + grunt.log.fail(err); + } + logFn && logFn(err ? new Error(err): null); + }); } + // checkVersion('node -v', requiredNodeVersion, 'node', logFn); + // checkVersion('npm -v', requiredNpmVersion, 'npm', logFn); + } - var dependenciesWithDifferentVersion = shrinkwrapDependencies.checkDependenciesVersion( - require('./npm-shrinkwrap-010.json'), - require('./npm-shrinkwrap-69.json'), - SHRINKWRAP_MODULES_TO_VALIDATE - ); - if (dependenciesWithDifferentVersion.length > 0) { - grunt.log.fail("############### /!\\ CAUTION /!\\ #################"); - grunt.log.fail("Dependencies with different version in shrinkwraps for node 0.10 and node 6.9.2 found."); - grunt.log.fail(JSON.stringify(dependenciesWithDifferentVersion, null, 4)); - grunt.log.fail("#################################################"); - process.exit(1); - } + var mustCheckNodeVersion = grunt.option('no-node-checker'); + if (!mustCheckNodeVersion) { + preFlight(REQUIRED_NODE_VERSION, REQUIRED_NPM_VERSION, logVersionsError); + grunt.log.writeln(''); + } - var duplicatedModules = shrinkwrapDependencies.checkDuplicatedDependencies(require('./npm-shrinkwrap.json'), SHRINKWRAP_MODULES_TO_VALIDATE); - if (duplicatedModules.length > 0) { - grunt.log.fail("############### /!\\ CAUTION /!\\ #################"); - grunt.log.fail("Duplicated dependencies found in npm-shrinkwrap.json file."); - grunt.log.fail(JSON.stringify(duplicatedModules, null, 4)); - grunt.log.fail("#################################################"); - process.exit(1); - } + var dependenciesWithDifferentVersion = shrinkwrapDependencies.checkDependenciesVersion( + require('./npm-shrinkwrap-010.json'), + require('./npm-shrinkwrap-69.json'), + SHRINKWRAP_MODULES_TO_VALIDATE + ); + if (dependenciesWithDifferentVersion.length > 0) { + grunt.log.fail("############### /!\\ CAUTION /!\\ #################"); + grunt.log.fail("Dependencies with different version in shrinkwraps for node 0.10 and node 6.9.2 found."); + grunt.log.fail(JSON.stringify(dependenciesWithDifferentVersion, null, 4)); + grunt.log.fail("#################################################"); + process.exit(1); + } - var ROOT_ASSETS_DIR = './public/assets/'; - var ASSETS_DIR = './public/assets/<%= pkg.version %>'; + var duplicatedModules = shrinkwrapDependencies.checkDuplicatedDependencies(require('./npm-shrinkwrap.json'), SHRINKWRAP_MODULES_TO_VALIDATE); + if (duplicatedModules.length > 0) { + grunt.log.fail("############### /!\\ CAUTION /!\\ #################"); + grunt.log.fail("Duplicated dependencies found in npm-shrinkwrap.json file."); + grunt.log.fail(JSON.stringify(duplicatedModules, null, 4)); + grunt.log.fail("#################################################"); + process.exit(1); + } - // use grunt --environment production - var env = './config/grunt_' + environment + '.json'; - grunt.log.writeln('env: ' + env); - if (grunt.file.exists(env)) { - env = grunt.file.readJSON(env) - } else { - throw grunt.util.error(env +' file is missing! See '+ env +'.sample for how it should look like'); - } + var ROOT_ASSETS_DIR = './public/assets/'; + var ASSETS_DIR = './public/assets/<%= pkg.version %>'; - var aws = {}; - if (grunt.file.exists('./lib/build/grunt-aws.json')) { - aws = grunt.file.readJSON('./lib/build/grunt-aws.json'); - } + /** + * `grunt --environment=production` + */ + var env = './config/grunt_' + environment + '.json'; + grunt.log.writeln('env: ' + env); - // Project configuration. - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - aws: aws, - env: env, + if (grunt.file.exists(env)) { + env = grunt.file.readJSON(env) + } else { + throw grunt.util.error(env +' file is missing! See '+ env +'.sample for how it should look like'); + } - assets_dir: ASSETS_DIR, - root_assets_dir: ROOT_ASSETS_DIR, + var aws = {}; + if (grunt.file.exists('./lib/build/grunt-aws.json')) { + aws = grunt.file.readJSON('./lib/build/grunt-aws.json'); + } - // Concat task - concat: require('./lib/build/tasks/concat').task(), + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + aws: aws, + env: env, - // JST generation task - jst: require('./lib/build/tasks/jst').task(), + assets_dir: ASSETS_DIR, + root_assets_dir: ROOT_ASSETS_DIR, - // Compass files generation - compass: require('./lib/build/tasks/compass').task(), + // Concat task + concat: require('./lib/build/tasks/concat').task(), - // Copy assets (stylesheets, javascripts, images...) - copy: require('./lib/build/tasks/copy').task(grunt), + // JST generation task + jst: require('./lib/build/tasks/jst').task(), - // Watch actions - watch: require('./lib/build/tasks/watch.js').task(), + // Compass files generation + compass: require('./lib/build/tasks/compass').task(), - // Clean folders before other tasks - clean: require('./lib/build/tasks/clean').task(), + // Copy assets (stylesheets, javascripts, images...) + copy: require('./lib/build/tasks/copy').task(grunt), - jasmine: jasmineCfg, + // Watch actions + watch: require('./lib/build/tasks/watch.js').task(), - s3: require('./lib/build/tasks/s3.js').task(), + // Clean folders before other tasks + clean: require('./lib/build/tasks/clean').task(), - exorcise: require('./lib/build/tasks/exorcise.js').task(), + jasmine: jasmineCfg, - uglify: require('./lib/build/tasks/uglify.js').task(), + s3: require('./lib/build/tasks/s3.js').task(), - browserify: require('./lib/build/tasks/browserify.js').task(), + exorcise: require('./lib/build/tasks/exorcise.js').task(), - connect: require('./lib/build/tasks/connect.js').task(), + uglify: require('./lib/build/tasks/uglify.js').task(), - availabletasks: require('./lib/build/tasks/availabletasks.js').task() - }); + browserify: require('./lib/build/tasks/browserify.js').task(), - // $ grunt availabletasks - grunt.loadNpmTasks('grunt-available-tasks'); + connect: require('./lib/build/tasks/connect.js').task(), - // Load Grunt tasks - require('load-grunt-tasks')(grunt, { - pattern: ['grunt-*', '@*/grunt-*', '!grunt-timer'] - }); + availabletasks: require('./lib/build/tasks/availabletasks.js').task(), - require('./lib/build/tasks/manifest').register(grunt, ASSETS_DIR); + sass: require('./lib/build/tasks/sass.js').task() + }); - // builds cdb - grunt.registerTask('cdb', "builds cartodb.js", function() { - var done = this.async(); - require("child_process").exec('make update_cdb', function (error, stdout, stderr) { - if (error) { - grunt.log.fail('cartodb.js not updated (due to '+ stdout +", "+ stderr +")"); - } else { - grunt.log.ok('cartodb.js updated'); - } - done(); - }); - }); + /** + * `grunt availabletasks` + */ + grunt.loadNpmTasks('grunt-available-tasks'); - grunt.registerTask('invalidate', "invalidate cache", function() { - var done = this.async(); - var url = require('url'); - var https = require('https'); - - var options = url.parse(grunt.template.process('https://api.fastly.com/service/<%= aws.FASTLY_CARTODB_SERVICE %>/purge_all')); - options['method'] = 'POST'; - options['headers'] = { - 'Fastly-Key': aws.FASTLY_API_KEY, - 'Content-Length': '0' //Disables chunked encoding - }; - console.log(options); - - https.request(options, function(response) { - if(response.statusCode == 200) { - grunt.log.ok('CDN invalidated (fastly)'); - } else { - grunt.log.error('CDN not invalidated (fastly), code: ' + response.statusCode) - } - done(); - }).on('error', function(e) { - grunt.log.error('CDN not invalidated (fastly)'); - done(); - }).end(); - }); + // Load Grunt tasks + require('load-grunt-tasks')(grunt, { + pattern: ['grunt-*', '@*/grunt-*', '!grunt-timer'] + }); - grunt.registerTask('config', "generates assets config for current configuration", function() { - // Set assets url for static assets in our app - var config = grunt.template.process("cdb.config.set('assets_url', '<%= env.http_path_prefix %>/assets/<%= pkg.version %>');"); - config += grunt.template.process("\nconsole.log('cartodbui v<%= pkg.version %>');"); - grunt.file.write("lib/build/app_config.js", config); - }); + require('./lib/build/tasks/manifest').register(grunt, ASSETS_DIR); - grunt.registerTask('check_release', "checks release can be done", function() { - if (environment === DEVELOPMENT) { - grunt.log.error("you can't release running development environment"); - return false; - } - grunt.log.ok("************************************************"); - grunt.log.ok(" you are going to deploy to " + env ); - grunt.log.ok("************************************************"); - }); + grunt.registerTask('invalidate', 'invalidate cache', function() { + var done = this.async(); + var url = require('url'); + var https = require('https'); - grunt.event.on('watch', function(action, filepath, subtask) { - // configure copy vendor to only run on changed file - var cfg = grunt.config.get('copy.vendor'); - if (filepath.indexOf(cfg.cwd) !== -1) { - grunt.config('copy.vendor.src', filepath.replace(cfg.cwd, '')); - } else { - grunt.config('copy.vendor.src', []); - } + var options = url.parse(grunt.template.process('https://api.fastly.com/service/<%= aws.FASTLY_CARTODB_SERVICE %>/purge_all')); + options['method'] = 'POST'; + options['headers'] = { + 'Fastly-Key': aws.FASTLY_API_KEY, + 'Content-Length': '0' // Disables chunked encoding + }; + console.log(options); - var builderFiles = [ - 'js_core_cartodb3', - 'js_client_cartodb3', - 'js_test_spec_core_cartodb3', - 'js_test_spec_client_cartodb3' - ]; - var otherFiles = [ - 'app', - 'js_core_cartodb', - 'js_client_cartodb', - 'js_test_jasmine_core_cartodb3', - 'js_test_jasmine_client_cartodb3' - ]; - - var COPY_PATHS = []; - if (subtask === 'js_affected') { - COPY_PATHS = COPY_PATHS.concat(builderFiles); + https.request(options, function(response) { + if(response.statusCode == 200) { + grunt.log.ok('CDN invalidated (fastly)'); } else { - COPY_PATHS = COPY_PATHS.concat(otherFiles).concat(builderFiles); + grunt.log.error('CDN not invalidated (fastly), code: ' + response.statusCode) } + done(); + }).on('error', function(e) { + grunt.log.error('CDN not invalidated (fastly)'); + done(); + }).end(); + }); + + grunt.registerTask('config', 'generates assets config for current configuration', function() { + // Set assets url for static assets in our app + var config = grunt.template.process("cdb.config.set('assets_url', '<%= env.http_path_prefix %>/assets/<%= pkg.version %>');"); + config += grunt.template.process("\nconsole.log('cartodbui v<%= pkg.version %>');"); + grunt.file.write("lib/build/app_config.js", config); + }); + + grunt.registerTask('check_release', 'checks release can be done', function() { + if (environment === DEVELOPMENT) { + grunt.log.error("you can't release running development environment"); + return false; + } - // configure copy paths to only run on changed files - for (var j = 0, m = COPY_PATHS.length; j < m; ++j) { - var copy_path = COPY_PATHS[j]; - var files = grunt.config.get('copy.' + copy_path + '.files'); - for (var i = 0, l = files.length; i < l; ++i) { - var cfg = grunt.config.get('copy.' + copy_path + '.files.' + i); - if (filepath.indexOf(cfg.cwd) !== -1) { - grunt.config('copy.' + copy_path + '.files.' + i + '.src', filepath.replace(cfg.cwd, '')); - } else { - grunt.config('copy.' + copy_path + '.files.' + i + '.src', []); - } - } - } - }); + grunt.log.ok("************************************************"); + grunt.log.ok(" you are going to deploy to " + env ); + grunt.log.ok("************************************************"); + }); - grunt.registerTask('setConfig', 'Set a config property', function(name, val) { - grunt.config.set(name, val); - }); + grunt.event.on('watch', function(action, filepath, subtask) { + // Configure copy vendor to only run on changed file + var cfg = grunt.config.get('copy.vendor'); + if (filepath.indexOf(cfg.cwd) !== -1) { + grunt.config('copy.vendor.src', filepath.replace(cfg.cwd, '')); + } else { + grunt.config('copy.vendor.src', []); + } - // still have to use this custom task because registerCmdTask outputs tons of warnings like: - // path/to/some/ignored/files:0:0: File ignored because of your .eslintignore file. Use --no-ignore to override. - grunt.registerTask('lint', 'lint source files', function () { - var done = this.async(); - require('child_process').exec('(git diff --name-only --relative; git diff origin/master.. --name-only --relative) | grep \'\\.js\\?$\' | xargs node_modules/.bin/semistandard', function (error, stdout, stderr) { - if (error) { - grunt.log.fail(error); + var builderFiles = [ + 'js_cartodb3', + 'js_test_spec_cartodb3' + ]; + var otherFiles = [ + 'app', + 'js_cartodb', + 'js_test_jasmine_cartodb3' + ]; + + var COPY_PATHS = []; + if (subtask === 'js_affected') { + COPY_PATHS = COPY_PATHS.concat(builderFiles); + } else { + COPY_PATHS = COPY_PATHS.concat(otherFiles).concat(builderFiles); + } - // Filter out lines that are ignored, - // e.g. "src/foobar.js:0:0: File ignored because of your .eslintignore file. Use --no-ignore to override." - grunt.log.fail(stdout.replace(/.+--no-ignore.+(\r?\n|\r)/g, '')); - grunt.fail.warn('try `node_modules/.bin/semistandard --format src/filename.js` to auto-format code (you might still need to fix some things manually).'); + // Configure copy paths to only run on changed files + for (var j = 0, m = COPY_PATHS.length; j < m; ++j) { + var copy_path = COPY_PATHS[j]; + var files = grunt.config.get('copy.' + copy_path + '.files'); + for (var i = 0, l = files.length; i < l; ++i) { + var cfg = grunt.config.get('copy.' + copy_path + '.files.' + i); + if (filepath.indexOf(cfg.cwd) !== -1) { + grunt.config('copy.' + copy_path + '.files.' + i + '.src', filepath.replace(cfg.cwd, '')); } else { - grunt.log.ok('All linted files OK!'); - grunt.log.writelns('>> Note that files listed in .eslintignore are not linted'); + grunt.config('copy.' + copy_path + '.files.' + i + '.src', []); } - done(); - }); - }); - - grunt.registerTask('pre_client', [ - 'copy:locale_core', - 'copy:locale_client', - 'copy:js_core_cartodb', - 'copy:js_client_cartodb', - 'copy:js_core_cartodb3', - 'copy:js_client_cartodb3', - 'copy:js_test_spec_core_cartodb3', - 'copy:js_test_spec_client_cartodb3', - 'copy:js_test_jasmine_core_cartodb3', - 'copy:js_test_jasmine_client_cartodb3' - ]); - - grunt.registerTask('js', ['cdb', 'pre_client', 'run_browserify', 'concat:js', 'jst']); - grunt.registerTask('pre_default', ['clean', 'config', 'js']); - grunt.registerTask('test', '(CI env) Re-build JS files and run all tests. For manual testing use `grunt jasmine` directly', [ - 'pre_default', - 'jasmine:cartodbui', - 'jasmine:cartodb3', - 'lint' - ]); - grunt.registerTask('editor3', [ - 'browserify:vendor_editor3', - 'browserify:common_editor3', - 'browserify:editor3', - 'browserify:public_editor3' - ]); - grunt.registerTask('css_editor_3', [ - 'copy:cartofonts', - 'copy:iconfont', - 'copy:cartoassets', - 'copy:perfect_scrollbar', - 'copy:colorpicker', - 'copy:deep_insights', - 'copy:cartodbjs_v4' - ]); - grunt.registerTask('css', ['copy:vendor', 'css_editor_3', 'copy:app', 'compass', 'concat:css']); - grunt.registerTask('default', ['pre_default', 'css', 'manifest']); - grunt.registerTask('minimize', ['default', 'copy:js', 'exorcise', 'uglify']); - grunt.registerTask('release', ['check_release', 'minimize', 's3', 'invalidate']); - grunt.registerTask('build-jasmine-specrunners', _ - .chain(jasmineCfg) - .keys() - .map(function (name) { - return ['jasmine', name, 'build'].join(':'); - }) - .value()); - grunt.registerTask('dev', 'Typical task for frontend development (watch JS/CSS changes)', [ - 'setConfig:env.browserify_watch:true', - 'run_browserify', - 'build-jasmine-specrunners', - 'connect:server', - 'run_watch:builder_specs=false']); - - grunt.registerTask('sourcemaps', - 'generate sourcemaps, to be used w/ trackjs.com for bughunting', [ - 'setConfig:assets_dir:./tmp/sourcemaps', - 'config', - 'js', - 'copy:js', - 'exorcise', - 'uglify' - ]); - - grunt.registerTask('run_watch', 'All watch tasks except those that watch spec changes', function (option) { - if (option === 'builder_specs=false') { - delete grunt.config.data.watch.js_test_spec_core_cartodb3; - delete grunt.config.data.watch.js_test_spec_client_cartodb3; - delete grunt.config.data.watch.js_test_jasmine_core_cartodb3; - delete grunt.config.data.watch.js_test_jasmine_client_cartodb3; - delete grunt.config.data.watch.js_affected; } - grunt.task.run('watch'); - }); - - grunt.registerTask('run_browserify', 'Browserify task with options', function (option) { - var skipAllSpecs = false; - var skipBuilderSpecs = false; - - if (environment !== DEVELOPMENT) { - grunt.log.writeln('Skipping all specs generation by browserify because not in development environment.'); - skipAllSpecs = true; - } else if (!isRunningTask('test', grunt)) { + } + }); + + grunt.registerTask('css', [ + 'copy:vendor', + 'copy:app', + 'compass', + 'sass', + // TODO: migrate mixins to postcss + // 'postcss', + 'concat:css' + ]); + + grunt.registerTask('run_browserify', 'Browserify task with options', function (option) { + var skipEditor = false; + var skipBuilder = false; + var skipAllSpecs = false; + var skipEditorSpecs = false; + var skipBuilderSpecs = false; + + if (environment === DEVELOPMENT) { + if (!isRunningTask('test', grunt)) { grunt.log.writeln('Skipping only Builder specs generation by browserify because we are not running the `test` task.'); skipBuilderSpecs = true; } - if (skipAllSpecs) { - delete grunt.config.data.browserify['test_specs_for_browserify_modules']; - delete grunt.config.data.browserify['cartodb3-specs']; - } else if (skipBuilderSpecs) { - delete grunt.config.data.browserify['cartodb3-specs']; + if (option === 'builder') { + grunt.log.writeln('Skipping Editor assets and specs generation by browserify because we are running the `dev` task.'); + skipEditor = true; + skipEditorSpecs = true; + } else { + grunt.log.writeln('Skipping Builder assets generation by browserify because we are running the `dev` task later.'); + skipBuilder = true; } + } else { + grunt.log.writeln('Skipping all specs generation by browserify because not in development environment.'); + skipAllSpecs = true; + } - grunt.task.run('browserify'); - }); + if (skipEditor) { + delete grunt.config.data.browserify['explore']; + delete grunt.config.data.browserify['user_feed']; + delete grunt.config.data.browserify['account']; + delete grunt.config.data.browserify['confirmation']; + delete grunt.config.data.browserify['editor']; + delete grunt.config.data.browserify['dashboard']; + delete grunt.config.data.browserify['keys']; + delete grunt.config.data.browserify['new_public_table']; + delete grunt.config.data.browserify['organization']; + delete grunt.config.data.browserify['public_dashboard']; + delete grunt.config.data.browserify['data_library']; + delete grunt.config.data.browserify['public_map']; + delete grunt.config.data.browserify['mobile_apps']; + } - grunt.registerTask('copy_builder', 'Multitask with all the tasks responsible for copying builder files.', [ - 'copy:locale_core', - 'copy:locale_client', - 'copy:js_core_cartodb3', - 'copy:js_client_cartodb3', - 'copy:js_test_spec_core_cartodb3', - 'copy:js_test_spec_client_cartodb3' - ]); + if (skipBuilder) { + delete grunt.config.data.browserify['vendor_editor3']; + delete grunt.config.data.browserify['common_editor3']; + delete grunt.config.data.browserify['dataset']; + delete grunt.config.data.browserify['editor3']; + delete grunt.config.data.browserify['public_editor3']; + } - // Affected specs section - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + if (skipAllSpecs) { + delete grunt.config.data.browserify['test_specs_for_browserify_modules']; + delete grunt.config.data.browserify['cartodb3-specs']; + } else if (skipEditorSpecs) { + delete grunt.config.data.browserify['test_specs_for_browserify_modules']; + } else if (skipBuilderSpecs) { + delete grunt.config.data.browserify['cartodb3-specs']; + } - grunt.registerTask('affected', 'Generate only affected specs', function () { - requireWebpackTask().affected.call(this, grunt); - }); + grunt.task.run('browserify'); + }); - grunt.registerTask('bootstrap_webpack_builder_specs', 'Create the webpack compiler', function () { - requireWebpackTask().bootstrap.call(this, 'builder_specs', grunt); - }); + grunt.registerTask('cdb', 'builds cartodb.js', function() { + var done = this.async(); - grunt.registerTask('webpack:builder_specs', 'Webpack compilation task for builder specs', function () { - requireWebpackTask().compile.call(this, 'builder_specs'); + require('child_process').exec('make update_cdb', function (error, stdout, stderr) { + if (error) { + grunt.log.fail('cartodb.js not updated (due to '+ stdout + ', ' + stderr + ')'); + } else { + grunt.log.ok('cartodb.js updated'); + } + done(); }); - - /** - * `grunt affected_specs` compile Builder specs using only affected ones by the current branch. - * `grunt affected_specs --specs=all` compile all Builder specs. - */ - grunt.registerTask('affected_specs', 'Build only specs affected by changes in current branch', [ - 'copy_builder', - 'affected', - 'bootstrap_webpack_builder_specs', - 'webpack:builder_specs', - 'jasmine:affected:build', - 'connect:specs', - 'watch:js_affected' - ]); - - // / Affected specs section - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** - * Delegate task to commandline. - * @param {String} name - If taskname starts with npm it's run a npm script (i.e. `npm run foobar` - * @param {Object} d - d as in data - * @param {Array} d.args - arguments to pass to the d.cmd - * @param {String} [d.cmd = process.execPath] - * @param {String} [d.desc = ''] - description - * @param {...string} args space-separated arguments passed to the cmd - */ - function registerCmdTask (name, opts) { - opts = _.extend({ - cmd: process.execPath, - desc: '', - args: [] - }, opts); - grunt.registerTask(name, opts.desc, function () { - // adapted from http://stackoverflow.com/a/24796749 - var done = this.async(); - grunt.util.spawn({ - cmd: opts.cmd, - args: opts.args, - opts: { stdio: 'inherit' } - }, done); - }); + }); + + grunt.registerTask('copy_builder', 'Multitask with all the tasks responsible for copying builder files.', [ + 'copy:locale', + 'copy:js_cartodb3', + 'copy:js_test_spec_cartodb3' + ]); + + grunt.registerTask('js', [ + 'cdb', + 'copy_builder', + 'copy:js_cartodb', + 'copy:js_test_jasmine_cartodb3', + 'run_browserify', + 'concat:js', + 'jst' + ]); + + grunt.registerTask('prepare', [ + 'clean', + 'config', + 'js' + ]); + + /** + * `grunt` default task to compile Editor assets, builder assets will be compiled by `grunt dev` task. + * `grunt --environment=production` default task to compile Builder and Editor assets. + */ + grunt.registerTask('default', [ + 'prepare', + 'css', + 'manifest' + ]); + + grunt.registerTask('run_watch', 'All watch tasks except those that watch spec changes', function (option) { + if (option === 'builder_specs=false') { + delete grunt.config.data.watch.js_test_spec_cartodb3; + delete grunt.config.data.watch.js_test_jasmine_cartodb3; + delete grunt.config.data.watch.js_affected; } - }; + grunt.task.run('watch'); + }); + + grunt.registerTask('build-jasmine-specrunners', _.chain(jasmineCfg) + .keys() + .map(function (name) { + return ['jasmine', name, 'build'].join(':'); + }) + .value()); + + grunt.registerTask('setConfig', 'Set a config property', function(name, val) { + grunt.config.set(name, val); + }); + + /** + * `grunt dev` compile and watch Builder assets. + */ + grunt.registerTask('dev', 'Frontend development task (watch JS/CSS changes)', [ + 'setConfig:env.browserify_watch:true', + 'run_browserify:builder', + 'build-jasmine-specrunners', + // 'connect:server', + // 'run_watch:builder_specs=false' + ]); + + // still have to use this custom task because registerCmdTask outputs tons of warnings like: + // path/to/some/ignored/files:0:0: File ignored because of your .eslintignore file. Use --no-ignore to override. + grunt.registerTask('lint', 'lint source files', function () { + var done = this.async(); + require('child_process').exec('(git diff --name-only --relative; git diff origin/master.. --name-only --relative) | grep \'\\.js\\?$\' | xargs node_modules/.bin/semistandard', function (error, stdout, stderr) { + if (error) { + grunt.log.fail(error); + + // Filter out lines that are ignored, + // e.g. "src/foobar.js:0:0: File ignored because of your .eslintignore file. Use --no-ignore to override." + grunt.log.fail(stdout.replace(/.+--no-ignore.+(\r?\n|\r)/g, '')); + grunt.fail.warn('try `node_modules/.bin/semistandard --format src/filename.js` to auto-format code (you might still need to fix some things manually).'); + } else { + grunt.log.ok('All linted files OK!'); + grunt.log.writelns('>> Note that files listed in .eslintignore are not linted'); + } + done(); + }); + }); + + /** + * `grunt test` + */ + grunt.registerTask('test', '(CI env) Re-build JS files and run all tests. For manual testing use `grunt jasmine` directly', [ + 'prepare', + 'jasmine:cartodbui', + 'jasmine:cartodb3', + 'lint' + ]); + + grunt.registerTask('sourcemaps', 'generate sourcemaps, to be used w/ trackjs.com for bughunting', [ + 'setConfig:assets_dir:./tmp/sourcemaps', + 'config', + 'js', + 'copy:js', + 'exorcise', + 'uglify' + ]); + + grunt.registerTask('minimize', [ + 'default', + 'copy:js', + 'exorcise', + 'uglify' + ]); + + /** + * `grunt release` + */ + grunt.registerTask('release', [ + 'check_release', + 'minimize', + 's3', + 'invalidate' + ]); + + grunt.registerTask('affected', 'Generate only affected specs', function () { + requireWebpackTask().affected.call(this, grunt); + }); + + grunt.registerTask('bootstrap_webpack_builder_specs', 'Create the webpack compiler', function () { + requireWebpackTask().bootstrap.call(this, 'builder_specs', grunt); + }); + + grunt.registerTask('webpack:builder_specs', 'Webpack compilation task for builder specs', function () { + requireWebpackTask().compile.call(this, 'builder_specs'); + }); + + /** + * `grunt affected_specs` compile Builder specs using only affected ones by the current branch. + * `grunt affected_specs --specs=all` compile all Builder specs. + */ + grunt.registerTask('affected_specs', 'Build only specs affected by changes in current branch', [ + 'copy_builder', + 'affected', + 'bootstrap_webpack_builder_specs', + 'webpack:builder_specs', + 'jasmine:affected:build', + 'connect:specs', + 'watch:js_affected' + ]); + + /** + * Delegate task to command line. + * @param {String} name - If taskname starts with npm it's run a npm script (i.e. `npm run foobar` + * @param {Object} d - d as in data + * @param {Array} d.args - arguments to pass to the d.cmd + * @param {String} [d.cmd = process.execPath] + * @param {String} [d.desc = ''] - description + * @param {...string} args space-separated arguments passed to the cmd + */ + function registerCmdTask (name, opts) { + opts = _.extend({ + cmd: process.execPath, + desc: '', + args: [] + }, opts); + grunt.registerTask(name, opts.desc, function () { + // adapted from http://stackoverflow.com/a/24796749 + var done = this.async(); + grunt.util.spawn({ + cmd: opts.cmd, + args: opts.args, + opts: { stdio: 'inherit' } + }, done); + }); + } +}; diff --git a/config.rb b/config.rb index 833c23080e..91afaafcfb 100644 --- a/config.rb +++ b/config.rb @@ -4,7 +4,7 @@ # Set this to the root of your project when deployed: http_path = "/" css_dir = "dist/css" -sass_dir = "tmp/sass/" +sass_dir = "tmp/sass/editor" images_dir = "app/assets/images/" #javascripts_dir = "lib/assets/javascripts" diff --git a/lib/build/files/browserify_files.js b/lib/build/files/browserify_files.js index 8943f3f1a6..7c7950ee74 100644 --- a/lib/build/files/browserify_files.js +++ b/lib/build/files/browserify_files.js @@ -124,7 +124,6 @@ module.exports = { ] } }, - common_editor3: { src: editor3Bundles.common.map(require.resolve), dest: '<%= assets_dir %>/javascripts/common_editor3.js', @@ -138,7 +137,6 @@ module.exports = { ] } }, - dataset: { src: [ 'lib/assets/javascripts/cartodb3/dataset.js' @@ -148,7 +146,6 @@ module.exports = { external: editor3Bundles.vendor.concat(editor3Bundles.common) } }, - editor3: { src: [ 'lib/assets/javascripts/cartodb3/editor.js' @@ -158,7 +155,6 @@ module.exports = { external: editor3Bundles.vendor.concat(editor3Bundles.common) } }, - public_editor3: { src: [ 'lib/assets/javascripts/cartodb3/public_editor.js' @@ -171,7 +167,6 @@ module.exports = { ] } }, - 'cartodb3-specs': { src: [ 'lib/build/source-map-support.js', diff --git a/lib/build/files/css_files.js b/lib/build/files/css_files.js index acfdf16263..4d4762618a 100644 --- a/lib/build/files/css_files.js +++ b/lib/build/files/css_files.js @@ -1,7 +1,5 @@ - var css_files; module.exports = css_files = { - cdb: [ '<%= assets_dir %>/stylesheets/map/leaflet.css', '<%= assets_dir %>/stylesheets/vendor/cartodb.css' @@ -224,7 +222,6 @@ module.exports = css_files = { api_keys: [ '<%= assets_dir %>/stylesheets/api_keys/*.css' ] - }; var _all_css = []; diff --git a/lib/build/tasks/clean.js b/lib/build/tasks/clean.js index 48911a3e27..e21f809e23 100644 --- a/lib/build/tasks/clean.js +++ b/lib/build/tasks/clean.js @@ -1,23 +1,21 @@ +/** + * Clean task config + */ - /** - * Clean task config - */ - - exports.task = function() { - - return { - options: { - force: true - }, - src: [ - "lib/build/app_config.js", - ".sass-cache", - "tmp/sass", - "<%= assets_dir %>", - ".grunt", - "lib/assets/javascripts/cartodb3", - "lib/assets/test/{spec,jasmine}/cartodb3", - "lib/assets/locale" - ] - } +exports.task = function() { + return { + options: { + force: true + }, + dist: [ + '.grunt', + '.sass-cache', + 'tmp/sass', + 'lib/build/app_config.js', + '<%= assets_dir %>', + 'lib/assets/javascripts/cartodb3', + 'lib/assets/test/{spec,jasmine}/cartodb3', + 'lib/assets/locale' + ] } +} diff --git a/lib/build/tasks/compass.js b/lib/build/tasks/compass.js index 36481b9b9e..bc133e31e4 100644 --- a/lib/build/tasks/compass.js +++ b/lib/build/tasks/compass.js @@ -7,19 +7,10 @@ exports.task = function () { dist: { options: { importPath: [ - 'tmp/sass/common', 'tmp/sass/cartoassets' ], - sassDir: 'tmp/sass', + sassDir: 'tmp/sass/editor', cssDir: '<%= assets_dir %>/stylesheets', - specify: [ - 'tmp/sass/**/*.scss', - '!tmp/sass/deep-insights/**/*.scss', - 'tmp/sass/deep-insights/main.scss', - 'tmp/sass/deep-insights/entry.scss', - '!tmp/sass/cartodbjs_v4/**/*.scss', - 'tmp/sass/cartodbjs_v4/entry.scss' - ], fontsDir: '<%= assets_dir %>/fonts', httpFontsPath: '<%= env.http_path_prefix %>/assets/<%= pkg.version %>/fonts', diff --git a/lib/build/tasks/copy.js b/lib/build/tasks/copy.js index d2d95560fd..8ee78c6293 100644 --- a/lib/build/tasks/copy.js +++ b/lib/build/tasks/copy.js @@ -1,47 +1,45 @@ - - /** - * Copy task config - */ - - exports.task = function (grunt) { - - return { - - // Vendor stylesheets - - vendor: { - expand: true, - cwd: 'vendor/assets/stylesheets/', - src: ['**/*.css'], - dest: 'tmp/sass/vendor/', - rename: function (dest, src) { - return dest + src.replace(/\.css$/, '.scss'); - }, - options: { - // Change all routes from img to asset version path - process: function (content, srcpath) { - // return content.replace(/\.\.\/img/gi,"/assets/<%= pkg.version %>/images/themes"); - var path = grunt.template.process('<%= env.http_path_prefix %>/assets/<%= pkg.version %>/images/themes'); - return content.replace(/\.\.\/img/gi, path); - } +/** + * Copy task config + */ + +exports.task = function (grunt) { + return { + vendor: { + expand: true, + cwd: 'vendor/assets/stylesheets/', + src: ['**/*.css'], + dest: 'tmp/sass/vendor/', + rename: function (dest, src) { + return dest + src.replace(/\.css$/, '.scss'); + }, + options: { + // Change all routes from img to asset version path + process: function (content, srcpath) { + // return content.replace(/\.\.\/img/gi,"/assets/<%= pkg.version %>/images/themes"); + var path = grunt.template.process('<%= env.http_path_prefix %>/assets/<%= pkg.version %>/images/themes'); + return content.replace(/\.\.\/img/gi, path); } - }, + } + }, - cartoassets: { + app: { + files: [{ + expand: true, + dot: true, + cwd: 'node_modules/cartoassets/src/fonts', + src: '**/*.*', + dest: '<%= assets_dir %>/fonts/' + }, { expand: true, cwd: 'node_modules/cartoassets/src/scss/', src: '**/*.scss', dest: 'tmp/sass/cartoassets/' - }, - - perfect_scrollbar: { + }, { expand: true, cwd: 'node_modules/perfect-scrollbar/src/css/', src: '*.scss', dest: 'tmp/sass/deep-insights/' - }, - - colorpicker: { + }, { expand: true, cwd: 'node_modules/bootstrap-colorpicker/dist/css/', src: 'bootstrap-colorpicker.css', @@ -49,310 +47,204 @@ rename: function (dest, src) { return dest + src.replace(/\.css$/, '.scss'); } - }, - - deep_insights: { + }, { expand: true, cwd: 'node_modules/cartodb-deep-insights.js/themes/scss', src: '**/*.scss', dest: 'tmp/sass/deep-insights/' - }, - - cartodbjs_v4: { + }, { expand: true, cwd: 'node_modules/cartodb.js/themes/scss', src: '**/*.scss', dest: 'tmp/sass/cartodbjs_v4/' - }, - - iconfont: { + }, { + // TODO: remove editor expand: true, - cwd: 'node_modules/cartoassets/src/scss/', - src: 'cdb-icon-font.scss', - dest: 'tmp/sass/common/' - }, + cwd: 'app/assets/stylesheets/editor', + src: ['**/*.css.scss', '**/*.scss'], + dest: 'tmp/sass/editor/', + rename: function (dest, src) { + return dest + src.replace(/\.css.scss$/, '.scss'); + } + }, { + // TODO: remove editor + expand: true, + cwd: 'app/assets/stylesheets/builder', + src: ['**/*.scss'], + dest: 'tmp/sass/builder/', + rename: function (dest, src) { + return dest + src.replace(/\.css.scss$/, '.scss'); + } + }, { + expand: true, + cwd: 'lib/assets/javascripts/cdb/themes/css/', + src: ['cartodb.css'], + dest: '<%= assets_dir %>/stylesheets/tmp/embeds/', + rename: function (dest, src) { + return dest + src.replace(/\.css$/, '.scss'); + } + }, { + // Client stylesheets + expand: true, + cwd: 'app/assets/client/stylesheets/', + src: [ + '**/*.css.scss', + '**/*.scss' + ], + dest: 'tmp/sass/client/', + rename: function (dest, src) { + return dest + src.replace(/\.css.scss$/, '.scss'); + } + }, { + expand: true, + cwd: 'app/assets/images/', + src: ['**/*'], + dest: '<%= assets_dir %>/images/' + }, { + // Some images should be placed in a unversioned folder + expand: true, + cwd: 'app/assets/images/', + src: ['avatars/**/*', 'alphamarker.png', 'google-maps-basemap-icons/*'], + dest: '<%= root_assets_dir %>/unversioned/images/' + }, { + // CARTO.js images + expand: true, + cwd: 'lib/assets/javascripts/cdb/themes/img/', + src: ['**/*'], + dest: '<%= assets_dir %>/images/themes/' + }, { + // Fonts + expand: true, + cwd: 'app/assets/fonts/', + src: ['*.{svg,ttf,eot,woff,woff2}'], + dest: '<%= assets_dir %>/fonts/' + }, { + // Client fonts + expand: true, + cwd: 'app/assets/client/fonts/', + src: ['*.{svg,ttf,eot,woff,woff2}'], + dest: '<%= assets_dir %>/fonts/' + }, { + // Flash + expand: true, + cwd: 'app/assets/flash/', + src: ['**/*'], + dest: '<%= assets_dir %>/flash/' + }, { + // Favicons + expand: true, + cwd: 'public/favicons/', + src: ['**/*'], + dest: '<%= assets_dir %>/favicons/' + }, { + // Client favicons + expand: true, + cwd: 'app/assets/client/favicons/', + src: ['**/*'], + dest: '<%= assets_dir %>/favicons/' + }] + }, + + css_tests: { + expand: true, + cwd: 'lib/assets/test/lib/jasmine-1.3.1/', + src: ['**/*.css'], + dest: 'tmp/sass/specs/', + rename: function (dest, src) { + return dest + src.replace(/\.css$/, '.scss'); + } + }, - cartofonts: { - files: [{ + js_cartodb: { + files: [ + { expand: true, - dot: true, - cwd: 'node_modules/cartoassets/src/fonts', - src: '**/*.*', - dest: '<%= assets_dir %>/fonts/' - }] - }, - - app: { - - files: [ - - /** - * Stylesheets - */ - // App stylesheets - { - expand: true, - cwd: 'app/assets/stylesheets/', - src: ['**/*.css.scss', '**/*.scss'], - dest: 'tmp/sass/', - rename: function (dest, src) { - return dest + src.replace(/\.css.scss$/, '.scss'); - } - }, - - // Vendor stylesheets - { - expand: true, - cwd: 'vendor/assets/stylesheets/', - src: ['**/*.css.scss', '**/*.scss'], - dest: 'tmp/sass/', - rename: function (dest, src) { - return dest + src.replace(/\.css.scss$/, '.scss'); - } - }, - - // Jasmine stylesheets - { - expand: true, - cwd: 'lib/assets/test/lib/jasmine-1.3.1/', - src: ['**/*.css'], - dest: 'tmp/sass/specs/', - rename: function (dest, src) { - return dest + src.replace(/\.css$/, '.scss'); - } - }, - - // Embed stylesheets - { - expand: true, - cwd: 'lib/assets/javascripts/cdb/themes/css/', - src: ['cartodb.css'], - dest: '<%= assets_dir %>/stylesheets/tmp/embeds/', - rename: function (dest, src) { - return dest + src.replace(/\.css$/, '.scss'); - } - }, - - // Client stylesheets - { - expand: true, - cwd: 'app/assets/client/stylesheets/', - src: [ - '**/*.css.scss', - '**/*.scss' - ], - dest: 'tmp/sass/client/', - rename: function (dest, src) { - return dest + src.replace(/\.css.scss$/, '.scss'); - } - }, - - /** - * Images - */ - - // public images - { - expand: true, - cwd: 'app/assets/images/', - src: ['**/*'], - dest: '<%= assets_dir %>/images/' - }, - - // some images should be placed in a unversioned folder - { - expand: true, - cwd: 'app/assets/images/', - src: ['avatars/**/*', 'alphamarker.png', 'google-maps-basemap-icons/*'], - dest: '<%= root_assets_dir %>/unversioned/images/' - }, - - // CartoDB.js images - { - expand: true, - cwd: 'lib/assets/javascripts/cdb/themes/img/', - src: ['**/*'], - dest: '<%= assets_dir %>/images/themes/' - }, - - /** - * Fonts - */ - - { - expand: true, - cwd: 'app/assets/fonts/', - src: ['*.{svg,ttf,eot,woff,woff2}'], - dest: '<%= assets_dir %>/fonts/' - }, - - { - expand: true, - cwd: 'vendor/assets/fonts/', - src: ['*.{svg,ttf,eot,woff,woff2}'], - dest: '<%= assets_dir %>/fonts/' - }, - - // client fonts - { - expand: true, - cwd: 'app/assets/client/fonts/', - src: ['*.{svg,ttf,eot,woff,woff2}'], - dest: '<%= assets_dir %>/fonts/' - }, - - /** - * Flash - */ - - { - expand: true, - cwd: 'app/assets/flash/', - src: ['**/*'], - dest: '<%= assets_dir %>/flash/' - }, - - /** - * Favicons - */ - - { - expand: true, - cwd: 'public/favicons/', - src: ['**/*'], - dest: '<%= assets_dir %>/favicons/' - }, - - // client Favicons - { - expand: true, - cwd: 'app/assets/client/favicons/', - src: ['**/*'], - dest: '<%= assets_dir %>/favicons/' - } - ] - }, - - js_core_cartodb: { - files: [ - { - expand: true, - cwd: 'lib/assets/core/javascripts/cartodb/organization/', - src: ['**/*'], - dest: 'lib/assets/javascripts/cartodb/organization/' - } - ] - }, - - js_client_cartodb: { - files: [ - { - expand: true, - cwd: 'lib/assets/client/javascripts/cartodb/organization/', - src: ['**/*'], - dest: 'lib/assets/javascripts/cartodb/organization/' - } - ] - }, - - js_core_cartodb3: { - files: [ - { - expand: true, - cwd: 'lib/assets/core/javascripts/cartodb3/', - src: ['**/*'], - dest: 'lib/assets/javascripts/cartodb3/' - } - ] - }, - - js_client_cartodb3: { - files: [ - { - expand: true, - cwd: 'lib/assets/client/javascripts/cartodb3/', - src: ['**/*'], - dest: 'lib/assets/javascripts/cartodb3/' - } - ] - }, - - js_test_spec_core_cartodb3: { - files: [ - { - expand: true, - cwd: 'lib/assets/core/test/spec/cartodb3/', - src: ['**/*'], - dest: 'lib/assets/test/spec/cartodb3/' - } - ] - }, - - js_test_jasmine_core_cartodb3: { - files: [ - { - expand: true, - cwd: 'lib/assets/core/test/jasmine/cartodb3/', - src: ['**/*'], - dest: 'lib/assets/test/jasmine/cartodb3/' - } - ] - }, - - js_test_spec_client_cartodb3: { - files: [ - { - expand: true, - cwd: 'lib/assets/client/test/spec/cartodb3/', - src: ['**/*'], - dest: 'lib/assets/test/spec/cartodb3/' - } - ] - }, + cwd: 'lib/assets/core/javascripts/cartodb/organization/', + src: ['**/*'], + dest: 'lib/assets/javascripts/cartodb/organization/' + } , { + expand: true, + cwd: 'lib/assets/client/javascripts/cartodb/organization/', + src: ['**/*'], + dest: 'lib/assets/javascripts/cartodb/organization/' + } + ] + }, - js_test_jasmine_client_cartodb3: { - files: [ - { - expand: true, - cwd: 'lib/assets/client/test/jasmine/cartodb3/', - src: ['**/*'], - dest: 'lib/assets/test/jasmine/cartodb3/' - } - ] - }, + js_cartodb3: { + files: [ + { + expand: true, + cwd: 'lib/assets/core/javascripts/cartodb3/', + src: ['**/*'], + dest: 'lib/assets/javascripts/cartodb3/' + }, { + expand: true, + cwd: 'lib/assets/client/javascripts/cartodb3/', + src: ['**/*'], + dest: 'lib/assets/javascripts/cartodb3/' + } + ] + }, - locale_core: { - files: [ - { - expand: true, - cwd: 'lib/assets/core/locale/', - src: ['**/*'], - dest: 'lib/assets/locale/' - } - ] - }, + js_test_spec_cartodb3: { + files: [ + { + expand: true, + cwd: 'lib/assets/core/test/spec/cartodb3/', + src: ['**/*'], + dest: 'lib/assets/test/spec/cartodb3/' + } , { + expand: true, + cwd: 'lib/assets/client/test/spec/cartodb3/', + src: ['**/*'], + dest: 'lib/assets/test/spec/cartodb3/' + } + ] + }, - locale_client: { - files: [ - { - expand: true, - cwd: 'lib/assets/client/locale/', - src: ['**/*'], - dest: 'lib/assets/locale/' - } - ] - }, + js_test_jasmine_cartodb3: { + files: [ + { + expand: true, + cwd: 'lib/assets/core/test/jasmine/cartodb3/', + src: ['**/*'], + dest: 'lib/assets/test/jasmine/cartodb3/' + } , { + expand: true, + cwd: 'lib/assets/client/test/jasmine/cartodb3/', + src: ['**/*'], + dest: 'lib/assets/test/jasmine/cartodb3/' + } + ] + }, - js: { - files: [{ + locale: { + files: [ + { expand: true, - cwd: '<%= assets_dir %>/javascripts/', - src: ['**/*.js'], - dest: '<%= assets_dir %>/javascripts/', - rename: function (dest, src) { - return dest + src.replace(/\.js$/, '.uncompressed.js'); - } - }] - } - }; + cwd: 'lib/assets/core/locale/', + src: ['**/*'], + dest: 'lib/assets/locale/' + }, { + expand: true, + cwd: 'lib/assets/client/locale/', + src: ['**/*'], + dest: 'lib/assets/locale/' + } + ] + }, + + js: { + files: [{ + expand: true, + cwd: '<%= assets_dir %>/javascripts/', + src: ['**/*.js'], + dest: '<%= assets_dir %>/javascripts/', + rename: function (dest, src) { + return dest + src.replace(/\.js$/, '.uncompressed.js'); + } + }] + } }; +}; diff --git a/lib/build/tasks/manifest.js b/lib/build/tasks/manifest.js index 578bfb00c2..fce3e663db 100644 --- a/lib/build/tasks/manifest.js +++ b/lib/build/tasks/manifest.js @@ -1,6 +1,4 @@ - module.exports = { - task: function() { return {} }, diff --git a/lib/build/tasks/sass.js b/lib/build/tasks/sass.js new file mode 100644 index 0000000000..2356dda5f5 --- /dev/null +++ b/lib/build/tasks/sass.js @@ -0,0 +1,43 @@ +/** + * Compass task config + */ + +exports.task = function () { + return { + options: { + sourceMap: true, + sourceMapEmbed: true, + sourceMapContents: true, + includePaths: [ + 'tmp/sass/cartoassets/' + ] + }, + dist: { + files: [{ + expand: true, + cwd: 'tmp/sass/builder/', + src: [ + '**/*.scss' + ], + dest: '<%= assets_dir %>/stylesheets', + ext: '.css' + }, { + expand: true, + cwd: 'tmp/sass/', + src: [ + '**/*.scss', + '!builder/**/*', + '!editor/**/*', + // TODO: this can be achieved prepending the asstes with _ + '!deep-insights/**/*.scss', + 'deep-insights/main.scss', + 'deep-insights/entry.scss', + '!cartodbjs_v4/**/*.scss', + 'cartodbjs_v4/entry.scss' + ], + dest: '<%= assets_dir %>/stylesheets', + ext: '.css' + }] + }, + }; +}; diff --git a/package.json b/package.json index b2b5714101..95fb3c6587 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cartodb-ui", - "version": "4.6.81", + "version": "4.6.81.11962.02", "description": "CARTO UI frontend", "repository": { "type": "git", @@ -69,6 +69,7 @@ "grunt-contrib-watch": "1.0.0", "grunt-exorcise": "2.1.0", "grunt-postcss": "0.5.5", + "grunt-sass": "^2.0.0", "grunt-timer": "0.3.3", "jasmine": "2.5.2", "jasmine-ajax": "git://github.com/nobuti/jasmine-ajax.git#master",