Initial commit

This commit is contained in:
zhongjin
2020-06-13 18:34:34 +08:00
commit 52aaa9f15d
655 changed files with 96796 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
## Grunt tasks list
These are the tasks(\*) we provide:
- [x] ```grunt publish_s3``` => publish CARTO.js library in S3 (you need secret keys).
- [x] ```grunt clean``` => clean temporary and dist folders.
- [x] ```grunt invalidate``` => invalidate library files through fastly.
- [x] ```grunt test``` => run library test suite in the console (it will generate a SpecRunner.html file in test folder).
- ```grunt test -d``` => if you need to print failing tests.
- ```grunt test -f``` => if you need to know where was the problem.
- [x] ```grunt build``` => generate library in dist folder.
- [X] ```grunt build:js``` => create uncompressed javascript files in dist (useful for developing)
- [X] ```grunt build:css``` => create uncompressed stylesheets files in dist (useful for developing)
Dev tasks are as useful while in development, watches files and updates the bundles accordingly:
- [x] ```grunt dev:js``` => only JS
- [x] ```grunt dev:css``` => only CSS
- [x] ```grunt dev``` => both JS and CSS
*Remember to install all the things you need, check main README.md, how to build section.
+45
View File
@@ -0,0 +1,45 @@
module.exports = {
'src-specs': {
src: [
'test/fail-tests-if-have-errors-in-src.js',
'test/spec/api/**/*',
'test/spec/core/**/*',
'test/spec/dataviews/**/*',
'test/spec/util/**/*',
'test/spec/geo/**/*',
'test/spec/ui/**/*',
'test/spec/vis/**/*',
'test/spec/windshaft/**/*',
'test/spec/windshaft-integration/**/*',
'test/spec/analysis/**/*',
'test/spec/engine.spec.js',
// not actually used anywhere in cartodb.js, only for editor?
// TODO can be (re)moved?
'!test/spec/ui/common/tabpane.spec.js'
],
dest: '<%= tmp %>/src-specs.js',
options: {
transform: [
['babelify', {
presets: ['env'],
plugins: ['transform-object-rest-spread']
}]
],
require: [ 'camshaft-reference/versions/0.59.4/reference.json:./versions/0.59.4/reference.json' ]
}
},
cartodb: {
src: [
'src/cartodb.js'
],
exclude: [
'src/api/v4/'
],
dest: '<%= dist %>/internal/cartodb.uncompressed.js',
options: {
require: [ 'camshaft-reference/versions/0.59.4/reference.json:./versions/0.59.4/reference.json' ]
}
}
};
+34
View File
@@ -0,0 +1,34 @@
var bundles = require('./_browserify-bundles');
module.exports = {
task: function () {
var cfg = {};
for (var name in bundles) {
var bundle = bundles[name];
cfg[name] = {
src: bundle.src,
dest: bundle.dest,
options: {
watch: '<%= doWatchify %>',
browserifyOptions: {
debug: true // to generate source-maps
}
}
};
var opts = bundle.options;
if (opts) {
if (opts.external) cfg[name].options.external = opts.external;
if (opts.require) cfg[name].options.require = opts.require;
if (opts.transform) cfg[name].options.transform = opts.transform;
var bOpts = bundle.options.browserifyOptions;
if (bOpts) {
if (bOpts.standalone) cfg[name].options.browserifyOptions.standalone = bOpts.standalone;
}
}
}
return cfg;
}
};
+21
View File
@@ -0,0 +1,21 @@
/**
* Clean grunt task for CARTO.js
*
*/
module.exports = {
task: function() {
return {
dist_internal: {
files: [{
dot: true,
src: [
'.sass-cache',
'.tmp',
'<%= dist %>/internal',
'!<%= dist %>/.git*'
]
}]
}
}
}
}
+15
View File
@@ -0,0 +1,15 @@
module.exports = {
task: function() {
return {
themes: {
options: {},
files: {
// CARTO.js CSSs (themes?)
'<%= dist %>/internal/themes/css/cartodb.css': [
'.tmp/scss/**/*.css'
]
}
}
}
}
}
+21
View File
@@ -0,0 +1,21 @@
/**
* Connect grunt task for CARTO.js website
*
*/
module.exports = {
task: function() {
return {
server: {
options: {
port: 9001,
livereload: 35730,
open: true,
hostname: '0.0.0.0', // to be able to access the server not only from localhost
base: {
path: '.'
}
}
}
}
}
}
+12
View File
@@ -0,0 +1,12 @@
module.exports = {
task: function () {
return {
fonts: {
expand: true,
cwd: 'node_modules/cartoassets/src/fonts/',
src: [ '**/*.{eot,ttf,woff,svg}' ],
dest: '<%= dist %>/internal/themes/fonts'
}
};
}
};
+28
View File
@@ -0,0 +1,28 @@
/**
* Css lint grunt task for CARTO.js
*
*/
module.exports = {
task: function() {
return {
dist: {
options: {
check: 'gzip'
}
},
themes: {
options: {
banner: '/* CartoDB.css minified version: <%= version %> */',
check: 'gzip'
},
files: {
'<%= dist %>/internal/themes/css/cartodb.css': ['<%= dist %>/internal/themes/css/cartodb.css']
}
}
}
}
}
+24
View File
@@ -0,0 +1,24 @@
var bundles = require('./_browserify-bundles');
// Extracts inlined source map from files (browserify bundles in this case).
// Expected to be run after browserify task
exports.task = function() {
var files = {};
for (var bundleName in bundles) {
if (!/tmp|specs/.test(bundleName)) {
var bundleDest = bundles[bundleName].dest;
var mapDest = bundleDest.replace('.js', '.map');
files[mapDest] = bundleDest;
}
}
return {
bundle: {
options: {
strict: true // fail task if sourcemaps are missing
},
files: files
}
};
};
+21
View File
@@ -0,0 +1,21 @@
/**
* Fastly invalidation grunt task for CARTO.js
*
*/
module.exports = {
task: function() {
return {
options: {
key: '<%= secrets.FASTLY_API_KEY %>'
},
dist: {
options: {
purgeAll: true,
serviceId: '<%= secrets.FASTLY_CARTODB_SERVICE %>'
}
},
}
}
}
+21
View File
@@ -0,0 +1,21 @@
/**
* Image minifier grunt task for CARTO.js
*
*/
module.exports = {
task: function() {
return {
distImages: {
options: {
progressive: true
},
files: [{
expand: true,
cwd: 'themes/img',
src: [ '**/*.{png,jpg,gif,svg}' ],
dest: '<%= dist %>/internal/themes/img'
}]
}
}
}
}
+32
View File
@@ -0,0 +1,32 @@
var _ = require('underscore');
var defaultOptions = {
keepRunner: true,
summary: true,
display: 'short',
vendor: [
// Load & install the source-map-support lib (get proper stack traces from inlined source-maps)
'node_modules/source-map-support/browser-source-map-support.js',
'test/install-source-map-support.js',
'http://maps.googleapis.com/maps/api/js?key=AIzaSyA4KzmztukvT7C49NSlzWkz75Xg3J_UyFI&v=3.32',
'node_modules/jasmine-ajax/lib/mock-ajax.js',
'node_modules/leaflet/dist/leaflet-src.js'
],
helpers: 'test/helpers/SpecHelper.js'
};
/**
* Jasmine grunt task for CARTO.js tests
* https://github.com/gruntjs/grunt-contrib-jasmine#options
* Load order: vendor, helpers, source, specs,
*/
module.exports = {
'cartodb-src': {
src: [], // actual src files are require'd in the *.spec.js files
options: _.defaults({
outfile: 'test/SpecRunner-src.html',
specs: '<%= tmp %>/src-specs.js',
'--web-security': 'no'
}, defaultOptions)
}
};
+68
View File
@@ -0,0 +1,68 @@
var semver = require('semver');
/**
* S3 upload grunt task for CARTO.js
*
*/
module.exports = {
task: function(version) {
var tasks = {
options: {
accessKeyId: "<%= secrets.AWS_USER_S3_KEY %>",
secretAccessKey: "<%= secrets.AWS_USER_S3_SECRET %>",
bucket: "<%= secrets.AWS_S3_BUCKET %>",
dryRun: false
}
};
var major = semver.major(version);
var minor = semver.minor(version);
var patch = semver.patch(version);
var prerelease = semver.prerelease(version);
if (prerelease) {
/**
* Publish prerelease URLs
*/
var base = 'carto.js/v' + major + '.' + minor + '.' + patch + '-';
if (prerelease[0]) { // alpha, beta, rc
tasks['js-prerelease'] = createTask(base + prerelease[0]);
}
if (prerelease[1]) { // number
tasks['js-prerelease-number'] = createTask(base + prerelease[0] + '.' + prerelease[1]);
}
} else {
/**
* Publish release URLs
*/
tasks['js-major'] = createTask('carto.js/v' + major);
tasks['js-minor'] = createTask('carto.js/v' + major + '.' + minor);
tasks['js-patch'] = createTask('carto.js/v' + major + '.' + minor + '.' + patch);
}
function createTask(dest) {
return {
options: {
overwrite: true,
cache: false,
gzip: true,
headers: {
ContentType: 'application/x-javascript'
}
},
files: [
{
action: 'upload',
expand: true,
cwd: 'dist/public',
src: '*.js',
dest: dest
}
]
};
}
return tasks;
}
}
+29
View File
@@ -0,0 +1,29 @@
/**
* SCSS grunt task for CARTO.js
*
*/
module.exports = {
task: function () {
return {
dist: {
options: {
sourceMap: false,
outputStyle: 'compressed',
includePaths: [
'node_modules/cartoassets/src/scss'
]
},
files: [{
expand: true,
src: [
'node_modules/cartoassets/src/scss/entry.scss',
'themes/scss/entry.scss'
],
dest: '.tmp/scss',
ext: '.css'
}]
}
};
}
};
+29
View File
@@ -0,0 +1,29 @@
var bundles = require('./_browserify-bundles');
/**
* Manger-compressor for CARTO.js ES6+ compliant
*
*/
module.exports = {
task: function() {
var cfg = {};
for (var bundleName in bundles) {
if (!/tmp|specs/.test(bundleName)) {
var files = {};
var src = bundles[bundleName].dest;
var uglifiedDest = src.replace('.uncompressed', '');
files[uglifiedDest] = src;
cfg[bundleName] = {
options: {
sourceMap: true
},
files: files
}
}
}
return cfg;
}
}
+24
View File
@@ -0,0 +1,24 @@
/**
* Add banner for CARTO.jss
*
*/
module.exports = {
task: function() {
var cfg = {
options: {
position: 'top',
banner: [
'// CartoDB.js version: <%= version %>',
'// sha: <%= gitinfo.local.branch.current.SHA %>',
].join('\n')
},
files: {
src: [
'<%= dist %>/internal/cartodb.uncompressed.js',
'<%= dist %>/internal/cartodb.js'
]
}
};
return cfg;
}
}
+27
View File
@@ -0,0 +1,27 @@
/**
* Watch grunt task for CARTO.js
*
*/
module.exports = {
task: function () {
return {
scss: {
files: ['themes/scss/**/*.scss'],
tasks: ['sass', 'concat:themes', 'cssmin:themes'],
options: {
spawn: false,
livereload: 35730
}
},
livereload: {
options: {
livereload: '<%= connect.server.options.livereload %>'
},
files: [
'.tmp/css/**/*.css',
'<%= dist %>/internal/themes/css/cartodb.css'
]
}
};
}
};