Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 68d9ec8

Browse files
author
Jelte Lagendijk
committed
Update development files && check MX6
1 parent 0d95e2d commit 68d9ec8

7 files changed

Lines changed: 249 additions & 10 deletions

File tree

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 4
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ test/.project
66
*.tmp
77
*.lock
88
.idea/
9+
10+
node_modules/

Gruntfile.js

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
// Generated on 2015-12-29 using generator-mendix 1.1.0 :: https://github.com/mendix/generator-mendix
2+
/*jshint -W069*/
3+
/*global module*/
4+
"use strict";
5+
6+
var path = require("path"),
7+
mendixApp = require("node-mendix-modeler-path"),
8+
base64 = require("node-base64-image"),
9+
semver = require("semver"),
10+
xml2js = require("xml2js"),
11+
parser = new xml2js.Parser(),
12+
builder = new xml2js.Builder({
13+
renderOpts: { pretty: true, indent: " ", newline: "\n" },
14+
xmldec: { standalone: null, encoding: "utf-8" }
15+
}),
16+
shelljs = require("shelljs");
17+
18+
// In case you seem to have trouble starting Mendix through `grunt start-mendix`, you might have to set the path to the Mendix application.
19+
// If it works, leave MODELER_PATH at null
20+
var MODELER_PATH = null;
21+
var MODELER_ARGS = "/file:{path}";
22+
23+
// 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
24+
var TEST_PATH = null;
25+
// Use this example if you want to point it to a different subfolder and specific Test project Name:
26+
// var TEST_PATH = path.join(shelljs.pwd(), "./<custom folder>/<Custom Test Project Name>.mpr");
27+
28+
module.exports = function (grunt) {
29+
var pkg = grunt.file.readJSON("package.json");
30+
var widgetXml = path.join(shelljs.pwd(), "/src/", pkg.name, "/", pkg.name + ".xml");
31+
var packageXml = path.join(shelljs.pwd(), "/src/package.xml");
32+
33+
grunt.initConfig({
34+
watch: {
35+
autoDeployUpdate: {
36+
"files": [ "./src/**/*" ],
37+
"tasks": [ "compress", "newer:copy" ],
38+
options: {
39+
debounceDelay: 250,
40+
livereload: true
41+
}
42+
}
43+
},
44+
compress: {
45+
makezip: {
46+
options: {
47+
archive: "./dist/" + pkg.name + ".mpk",
48+
mode: "zip"
49+
},
50+
files: [{
51+
expand: true,
52+
date: new Date(),
53+
store: false,
54+
cwd: "./src",
55+
src: ["**/*"]
56+
}]
57+
}
58+
},
59+
copy: {
60+
deployment: {
61+
files: [
62+
{ dest: "./test/deployment/web/widgets", cwd: "./src/", src: ["**/*"], expand: true }
63+
]
64+
},
65+
mpks: {
66+
files: [
67+
{ dest: "./test/widgets", cwd: "./dist/", src: [ pkg.name + ".mpk"], expand: true }
68+
]
69+
}
70+
},
71+
clean: {
72+
build: [
73+
"./dist/" + pkg.name + "/*",
74+
"./test/deployment/web/widgets/" + pkg.name + "/*",
75+
"./test/widgets/" + pkg.name + ".mpk"
76+
]
77+
}
78+
});
79+
80+
grunt.loadNpmTasks("grunt-contrib-compress");
81+
grunt.loadNpmTasks("grunt-contrib-clean");
82+
grunt.loadNpmTasks("grunt-contrib-watch");
83+
grunt.loadNpmTasks("grunt-contrib-copy");
84+
grunt.loadNpmTasks("grunt-newer");
85+
86+
grunt.registerTask("start-modeler", function () {
87+
var done = this.async(),
88+
testProjectPath = TEST_PATH !== null ? TEST_PATH : path.join(shelljs.pwd(), "/test/Test.mpr");
89+
90+
if (MODELER_PATH !== null || (mendixApp.err === null && mendixApp.output !== null && mendixApp.output.cmd && mendixApp.output.arg)) {
91+
grunt.util.spawn({
92+
cmd: MODELER_PATH || mendixApp.output.cmd,
93+
args: [
94+
(MODELER_PATH !== null ? MODELER_ARGS : mendixApp.output.arg).replace("{path}", testProjectPath)
95+
]
96+
}, function () {
97+
done();
98+
});
99+
} else {
100+
console.error("Cannot start Modeler, see error:");
101+
console.log(mendixApp.err);
102+
done();
103+
}
104+
});
105+
106+
grunt.registerTask("version", function (version) {
107+
var done = this.async();
108+
if (!grunt.file.exists(packageXml)) {
109+
grunt.log.error("Cannot find " + packageXml);
110+
return done();
111+
}
112+
113+
var xml = grunt.file.read(packageXml);
114+
parser.parseString(xml, function (err, res) {
115+
if (err) {
116+
grunt.log.error(err);
117+
return done();
118+
}
119+
if (res.package.clientModule[0]["$"]["version"]) {
120+
var currentVersion = res.package.clientModule[0]["$"]["version"];
121+
if (!version) {
122+
grunt.log.writeln("\nCurrent version is " + currentVersion);
123+
grunt.log.writeln("Set new version by running 'grunt version:x.y.z'");
124+
done();
125+
} else {
126+
if (!semver.valid(version) || !semver.satisfies(version, ">= 1.0.0")) {
127+
grunt.log.error("\nPlease provide a valid version that is higher than 1.0.0. Current version: " + currentVersion);
128+
done();
129+
} else {
130+
res.package.clientModule[0]["$"]["version"] = version;
131+
pkg.version = version;
132+
var xmlString = builder.buildObject(res);
133+
grunt.file.write(packageXml, xmlString);
134+
grunt.file.write("package.json", JSON.stringify(pkg, null, 2));
135+
done();
136+
}
137+
}
138+
} else {
139+
grunt.log.error("Cannot find current version number");
140+
}
141+
});
142+
143+
});
144+
145+
grunt.registerTask("generate-icon", function () {
146+
var iconPath = path.join(shelljs.pwd(), "/icon.png"),
147+
options = {localFile: true, string: true},
148+
done = this.async();
149+
150+
grunt.log.writeln("Processing icon");
151+
152+
if (!grunt.file.exists(iconPath) || !grunt.file.exists(widgetXml)) {
153+
grunt.log.error("can\'t generate icon");
154+
return done();
155+
}
156+
157+
base64.base64encoder(iconPath, options, function (err, image) {
158+
if (!err) {
159+
var xmlOld = grunt.file.read(widgetXml);
160+
parser.parseString(xmlOld, function (err, result) {
161+
if (!err) {
162+
if (result && result.widget && result.widget.icon) {
163+
result.widget.icon[0] = image;
164+
}
165+
var xmlString = builder.buildObject(result);
166+
grunt.file.write(widgetXml, xmlString);
167+
done();
168+
}
169+
});
170+
} else {
171+
grunt.log.error("can\'t generate icon");
172+
return done();
173+
}
174+
});
175+
});
176+
177+
grunt.registerTask("start-mendix", [ "start-modeler" ]);
178+
179+
grunt.registerTask(
180+
"default",
181+
"Watches for changes and automatically creates an MPK file, as well as copying the changes to your deployment folder",
182+
[ "watch" ]
183+
);
184+
185+
grunt.registerTask(
186+
"clean build",
187+
"Compiles all the assets and copies the files to the build directory.",
188+
[ "clean", "compress", "copy" ]
189+
);
190+
191+
grunt.registerTask(
192+
"build",
193+
[ "clean build" ]
194+
);
195+
};

dist/BooleanSlider.mpk

-415 Bytes
Binary file not shown.

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "BooleanSlider",
3+
"version": "1.4.0",
4+
"description": "",
5+
"private": true,
6+
"dependencies": {},
7+
"devDependencies": {
8+
"grunt": "0.4.5",
9+
"grunt-contrib-clean": "^0.6.0",
10+
"grunt-contrib-compress": "^0.14.0",
11+
"grunt-contrib-copy": "^0.8.2",
12+
"grunt-contrib-watch": "^0.6.1",
13+
"grunt-newer": "^1.1.1",
14+
"node-base64-image": "^0.1.0",
15+
"shelljs": "^0.5.3",
16+
"xml2js": "^0.4.15",
17+
"semver": "^5.1.0",
18+
"node-mendix-modeler-path": "https://github.com/JelteMX/node-mendix-modeler-path/archive/v1.0.0.tar.gz"
19+
},
20+
"repository": {
21+
"type": "git",
22+
"url": "http://github.com/mendix/BooleanSlider"
23+
},
24+
"engines": {
25+
"node": ">=0.12.0"
26+
},
27+
"scripts": {
28+
"test": "grunt test"
29+
}
30+
}

src/package.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="BooleanSlider" version="1.3" xmlns="http://www.mendix.com/clientModule/1.0/">
4-
<widgetFiles>
5-
<widgetFile path="BooleanSlider/BooleanSlider.xml"/>
6-
</widgetFiles>
7-
<files>
8-
<file path="BooleanSlider/widget/"/>
9-
</files>
10-
</clientModule>
11-
</package>
3+
<clientModule name="BooleanSlider" version="1.4.0" xmlns="http://www.mendix.com/clientModule/1.0/">
4+
<widgetFiles>
5+
<widgetFile path="BooleanSlider/BooleanSlider.xml"/>
6+
</widgetFiles>
7+
<files>
8+
<file path="BooleanSlider/widget/"/>
9+
</files>
10+
</clientModule>
11+
</package>

test/widgets/BooleanSlider.mpk

3 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)