Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Update development files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelte Lagendijk committed Apr 18, 2016
1 parent 949f04e commit ed41b92
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 33 deletions.
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ test/javasource/
test/deployment/
test/.classpath
test/.project
test/theme/
test/userlib/
test/.classpath
test/.project
*.launch
*.tmp
*.lock
.idea/

*DS_Store*
dist/

node_modules/
.editorconfig
*DS_Store*
.vscode/
*.bak
22 changes: 22 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// Enforcing
"curly" : false,
"forin" : false,
"latedef" : "nofunc",
"newcap" : true,
"quotmark" : "double",
"eqeqeq" : true,
"undef" : true,
"globals" : {
"mendix" : false,
"mx" : false
},

// Relaxing
"laxbreak" : true,

// Environments
"browser" : true,
"devel" : true,
"dojo" : true
}
90 changes: 60 additions & 30 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
// Generated on 2016-01-06 using generator-mendix 1.2.0 :: http://github.com/git+https://github.com/mendix/generator-mendix.git
// Generated on 2016-04-18 using generator-mendix 1.3.3 :: git+https://github.com/mendix/generator-mendix.git
/*jshint -W069*/
/*global module*/
"use strict";

// In case you seem to have trouble starting Mendix through `grunt start-mendix`, you might have to set the path to the Mendix application.
// If it works, leave MODELER_PATH at null
var MODELER_PATH = null;
var MODELER_ARGS = "/file:{path}";

/********************************************************************************
* Do not edit anything below, unless you know what you are doing
********************************************************************************/

var path = require("path"),
mendixApp = require("node-mendix-modeler-path"),
base64 = require("node-base64-image"),
Expand All @@ -13,21 +22,35 @@ var path = require("path"),
renderOpts: { pretty: true, indent: " ", newline: "\n" },
xmldec: { standalone: null, encoding: "utf-8" }
}),
shelljs = require("shelljs");

// In case you seem to have trouble starting Mendix through `grunt start-mendix`, you might have to set the path to the Mendix application.
// If it works, leave MODELER_PATH at null
var MODELER_PATH = null;
var MODELER_ARGS = "/file:{path}";

// In case you have a different path to the test project (currently in ./test/Test.mpr) point TEST_PATH to the Test-project (full path). Otherwise, leave at null
var TEST_PATH = path.join(shelljs.pwd(), "./test/TreeviewDemo.mpr");
shelljs = require("shelljs"),
pkg = require("./package.json");

var TEST_PATH = path.join(shelljs.pwd(), "/test/Test.mpr");
var WIDGET_XML = path.join(shelljs.pwd(), "/src/", pkg.name, "/", pkg.name + ".xml");
var PACKAGE_XML = path.join(shelljs.pwd(), "/src/package.xml");
var TEST_WIDGETS_FOLDER = path.join(shelljs.pwd(), "./test/widgets");
var TEST_WIDGETS_DEPLOYMENT_FOLDER = path.join(shelljs.pwd(), "./test/deployment/web/widgets");

/**
* If you want to use a custom folder for the test project, make sure these are added to package.json:
* "paths": {
* "testProjectFolder": "./test/",
* "testProjectFileName": "Test.mpr"
* },
* You can test it by running: `grunt folders`
**/

if (pkg.paths && pkg.paths.testProjectFolder && pkg.paths.testProjectFileName) {
var folder = pkg.paths.testProjectFolder;
if (folder.indexOf(".") === 0) {
folder = path.join(shelljs.pwd(), folder);
}
TEST_PATH = path.join(folder, pkg.paths.testProjectFileName);
TEST_WIDGETS_FOLDER = path.join(folder, "/widgets");
TEST_WIDGETS_DEPLOYMENT_FOLDER = path.join(folder, "/deployment/web/widgets");
}

module.exports = function (grunt) {
var pkg = grunt.file.readJSON("package.json");
var widgetXml = path.join(shelljs.pwd(), "/src/", pkg.name, "/", pkg.name + ".xml");
var packageXml = path.join(shelljs.pwd(), "/src/package.xml");

grunt.initConfig({
watch: {
autoDeployUpdate: {
Expand Down Expand Up @@ -57,20 +80,18 @@ module.exports = function (grunt) {
copy: {
deployment: {
files: [
{ dest: "./test/deployment/web/widgets", cwd: "./src/", src: ["**/*"], expand: true }
{ dest: TEST_WIDGETS_DEPLOYMENT_FOLDER, cwd: "./src/", src: ["**/*"], expand: true }
]
},
mpks: {
files: [
{ dest: "./test/widgets", cwd: "./dist/", src: [ pkg.name + ".mpk"], expand: true }
{ dest: TEST_WIDGETS_FOLDER, cwd: "./dist/", src: [ pkg.name + ".mpk"], expand: true }
]
}
},
clean: {
build: [
"./dist/" + pkg.name + "/*",
"./test/deployment/web/widgets/" + pkg.name + "/*",
"./test/widgets/" + pkg.name + ".mpk"
path.join(shelljs.pwd(), "dist", pkg.name, "/*")
]
}
});
Expand All @@ -82,14 +103,12 @@ module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-newer");

grunt.registerTask("start-modeler", function () {
var done = this.async(),
testProjectPath = TEST_PATH !== null ? TEST_PATH : path.join(shelljs.pwd(), "/test/Test.mpr");

var done = this.async();
if (MODELER_PATH !== null || (mendixApp.err === null && mendixApp.output !== null && mendixApp.output.cmd && mendixApp.output.arg)) {
grunt.util.spawn({
cmd: MODELER_PATH || mendixApp.output.cmd,
args: [
(MODELER_PATH !== null ? MODELER_ARGS : mendixApp.output.arg).replace("{path}", testProjectPath)
(MODELER_PATH !== null ? MODELER_ARGS : mendixApp.output.arg).replace("{path}", TEST_PATH)
]
}, function () {
done();
Expand All @@ -103,12 +122,12 @@ module.exports = function (grunt) {

grunt.registerTask("version", function (version) {
var done = this.async();
if (!grunt.file.exists(packageXml)) {
grunt.log.error("Cannot find " + packageXml);
if (!grunt.file.exists(PACKAGE_XML)) {
grunt.log.error("Cannot find " + PACKAGE_XML);
return done();
}

var xml = grunt.file.read(packageXml);
var xml = grunt.file.read(PACKAGE_XML);
parser.parseString(xml, function (err, res) {
if (err) {
grunt.log.error(err);
Expand All @@ -128,7 +147,7 @@ module.exports = function (grunt) {
res.package.clientModule[0]["$"]["version"] = version;
pkg.version = version;
var xmlString = builder.buildObject(res);
grunt.file.write(packageXml, xmlString);
grunt.file.write(PACKAGE_XML, xmlString);
grunt.file.write("package.json", JSON.stringify(pkg, null, 2));
done();
}
Expand All @@ -147,21 +166,21 @@ module.exports = function (grunt) {

grunt.log.writeln("Processing icon");

if (!grunt.file.exists(iconPath) || !grunt.file.exists(widgetXml)) {
if (!grunt.file.exists(iconPath) || !grunt.file.exists(WIDGET_XML)) {
grunt.log.error("can\'t generate icon");
return done();
}

base64.base64encoder(iconPath, options, function (err, image) {
if (!err) {
var xmlOld = grunt.file.read(widgetXml);
var xmlOld = grunt.file.read(WIDGET_XML);
parser.parseString(xmlOld, function (err, result) {
if (!err) {
if (result && result.widget && result.widget.icon) {
result.widget.icon[0] = image;
}
var xmlString = builder.buildObject(result);
grunt.file.write(widgetXml, xmlString);
grunt.file.write(WIDGET_XML, xmlString);
done();
}
});
Expand All @@ -172,6 +191,17 @@ module.exports = function (grunt) {
});
});

grunt.registerTask("folders", function () {
var done = this.async();
grunt.log.writeln("\nShowing file paths that Grunt will use. You can edit the package.json accordingly\n");
grunt.log.writeln("TEST_PATH: ", TEST_PATH);
grunt.log.writeln("WIDGET_XML: ", WIDGET_XML);
grunt.log.writeln("PACKAGE_XML: ", PACKAGE_XML);
grunt.log.writeln("TEST_WIDGETS_FOLDER: ", TEST_WIDGETS_FOLDER);
grunt.log.writeln("TEST_WIDGETS_DEPLOYMENT_FOLDER: ", TEST_WIDGETS_DEPLOYMENT_FOLDER);
return done();
});

grunt.registerTask("start-mendix", [ "start-modeler" ]);

grunt.registerTask(
Expand Down
Binary file modified dist/TreeView.mpk
Binary file not shown.
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
"name": "TreeView",
"version": "4.1.0",
"description": "",
"license": "",
"author": "",
"private": true,
"dependencies": {},
"dependencies": {
},
"devDependencies": {
"grunt": "0.4.5",
"grunt-contrib-clean": "^0.6.0",
Expand All @@ -20,7 +23,12 @@
"engines": {
"node": ">=0.12.0"
},
"generatorVersion": "1.3.3",
"paths": {
"testProjectFolder": "./test/",
"testProjectFileName": "Test.mpr"
},
"scripts": {
"test": "grunt test"
}
}
}
Binary file modified test/widgets/TreeView.mpk
Binary file not shown.

0 comments on commit ed41b92

Please sign in to comment.