Skip to content

Formatting #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
/hooks
/out
.idea
*.iml
*.iml
dist
120 changes: 72 additions & 48 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
module.exports = function(grunt) {
module.exports = function (grunt) {

var fs = require("fs");
var path = require("path");
const fs = require("fs");
const path = require("path");

var WEB_SERVER_HOST = "test.cloudcms.com";
var WEB_SERVER_PORT = 8000;
var WEB_SERVER_BASE_PATH = ".";
const WEB_SERVER_HOST = "0.0.0.0";
const WEB_SERVER_PORT = 8000;
const WEB_SERVER_BASE_PATH = ".";

var PROXY_HOST = "test.cloudcms.com";
var PROXY_PORT = 8080;
var PROXY_TIMEOUT = 5 * 60 * 1000;
const PROXY_HOST = "test.cloudcms.net";
const PROXY_PORT = 8080;
const PROXY_TIMEOUT = 5 * 60 * 1000;

grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-connect-proxy');
grunt.loadNpmTasks('grunt-closure-compiler');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-aws-s3');
grunt.loadNpmTasks('grunt-invalidate-cloudfront');
grunt.loadNpmTasks('grunt-release');
grunt.loadNpmTasks('grunt-bumpup');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-terser');

// register one or more task lists (you should ALWAYS have a "default" task list)
grunt.registerTask('test', ['configureProxies:testing', 'connect:testing', 'qunit']);
grunt.registerTask('test', ['configureProxies:testing' ,'connect:testing', 'qunit']);
grunt.registerTask('web', ['configureProxies:standalone', 'connect:standalone']);
grunt.registerTask('closure', ['closure-compiler']);
grunt.registerTask('cdn', ['aws_s3:clean_version', 'aws_s3:clean_latest', 'aws_s3:publish_version', 'aws_s3:publish_latest', 'invalidate_cloudfront:production_version', 'invalidate_cloudfront:production_latest']);
grunt.registerTask('bump', ['bumpup', 'writeVersionProperties']);
grunt.registerTask('clean-package-compress', ['exec:antClean', 'exec:antPackage', 'terser']);

var pkg = grunt.file.readJSON('package.json');
const pkg = grunt.file.readJSON('package.json');

// aws configuration
var awsConfig = {
let awsConfig = {
cloudfrontDistributionIds: []
};
try {
Expand All @@ -39,56 +42,54 @@ module.exports = function(grunt) {
}

// github configuration
var githubConfig = {};
let githubConfig = {};
try {
githubConfig = grunt.file.readJSON("../settings/__github.json");
} catch (e) {
}
catch (e) {}

process.env.GITHUB_USERNAME = githubConfig.username;
process.env.GITHUB_PASSWORD = githubConfig.password;

var name = "gitana-javascript-driver";
const name = "gitana-javascript-driver";

// injects a proxy into the middleware stack
var middleware = function(connect, options)
{
// default
var middlewares = [];
var directory = options.directory || options.base[options.base.length - 1];
middleware = function (connect, options) {

// Setup the proxy
const middlewares = [require('grunt-connect-proxy/lib/utils').proxyRequest];

// Serve static files.
if (!Array.isArray(options.base)) {
options.base = [options.base];
}
options.base.forEach(function(base) {
// Serve static files.
middlewares.push(connect.static(base));
});

// Make directory browse-able.
const directory = options.directory || options.base[options.base.length - 1];
middlewares.push(connect.directory(directory));

// push our proxy logic ahead on the middlewares
var proxy = require('grunt-connect-proxy/lib/utils').proxyRequest;
middlewares.unshift(proxy);


return middlewares;
};

grunt.registerTask("writeVersionProperties", "Writes a version.properties file for ant to pick up", function() {
grunt.registerTask("writeVersionProperties", "Writes a version.properties file for ant to pick up", function () {

var pkg = grunt.file.readJSON('package.json');
var version = pkg.version;
const pkg = grunt.file.readJSON('package.json');
const version = pkg.version;

grunt.file.delete("version.properties");
fs.writeFileSync("version.properties", "version=" + version);
});

// applies some cosmetic spacing
grunt.event.on('qunit.begin', function (url) {
grunt.event.on('qunit.begin', function () {
grunt.log.ok("");
});

// config
grunt.initConfig({
grunt.config.init({

"qunit": {
"all": {
Expand Down Expand Up @@ -127,6 +128,7 @@ module.exports = function(grunt) {
},
"testing": {
"options": {
"logger": "dev",
"base": WEB_SERVER_BASE_PATH,
"hostname": WEB_SERVER_HOST,
"port": WEB_SERVER_PORT,
Expand All @@ -148,20 +150,20 @@ module.exports = function(grunt) {
},

"jshint": {
"gitana": {
"options": {
"multistr": true,
"scripturl": true,
"laxcomma": true,
"-W069": true, // "['variable'] is better written in dot notation
"-W041": true, // "Use '===' to compare with null or 0
"-W004": true, // duplicate variables
"-W014": true, // line breaking +
"-W065": true, // radix
"-W083": true // functions in loops
},
src: ["js/gitana/**/*.js"]
}
"options": {
"multistr": true,
"scripturl": true,
"laxcomma": true,
"-W069": true, // "["constiable"] is better written in dot notation
"-W041": true, // "Use "===" to compare with null or 0
"-W004": true, // duplicate constiables
"-W014": true, // line breaking +
"-W065": true, // radix
"-W083": true, // functions in loops
"esversion": 6
},
all: ["js/gitana/**/*.js"]

},

"closure-compiler": {
Expand Down Expand Up @@ -298,6 +300,28 @@ module.exports = function(grunt) {
"passwordVar": "GITHUB_PASSWORD"
}
}
},
"exec": {
"antClean": {
"command": "ant clean"
},
"antPackage": {
"command": "ant package"
}
},
"terser": {
"options": {
"compress": {
"passes": 3
},
"ecma": 6,
"output": {
"beautify": false
},
"toplevel": true,
"module": true
},
"./dist/gitana.min.js": ["./js/gitana/**/*.js"]
}

});
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ This will install the latest versions of Grunt and all Grunt and Node.js depende
Then, to build, run the following:

````
ant clean package
grunt clean-package-compress
````

This will produce the latest <code>gitana.js</code> and <code>gitana.min.js</code> files in your <code>dist</code>
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gitana",
"description": "Gitana JavaScript Driver for Cloud CMS",
"version": "1.0.305",
"version": "1.0.307",
"main": "dist/gitana.js",
"license": "Apache-2.0",
"keywords": [
Expand Down
21 changes: 1 addition & 20 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
<property name="prep.dir" value="${build.dir}/prep"/>
<property name="package.dir" value="${build.dir}/package"/>

<property name="yui-compressor" value="${project.dir}/tool/yuicompressor-2.4.7.jar"/>

<!-- load version info from file -->
<property file="version.properties"/>

Expand Down Expand Up @@ -314,24 +312,7 @@

</target>

<target name="compress" description="Compress the javascript" depends="concat-js">
<echo>Compressing Javascript...</echo>
<apply executable="java" parallel="false" dest="${build.dir}/package">
<fileset dir="${build.dir}/package">
<include name="**/*.js"/>
<exclude name="**/*-min.js"/>
<exclude name="**/*.min.js"/>
</fileset>
<arg line="-jar"/>
<arg path="${yui-compressor}"/>
<arg line="-o"/>
<targetfile/>
<srcfile/>
<mapper type="glob" from="*.js" to="*.min.js"/>
</apply>
</target>

<target name="package" depends="clean,concat-js,compress">
<target name="package" depends="clean,concat-js">
<mkdir dir="dist"/>
<copy todir="dist">
<fileset dir="${package.dir}/js">
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gitana",
"version": "1.0.305",
"version": "1.0.307",
"main": [
"dist/gitana.js"
],
Expand Down
Loading