Skip to content

Commit a3c16ef

Browse files
author
Jelte Lagendijk
committed
Add development files
1 parent 5ea6e97 commit a3c16ef

File tree

4 files changed

+291
-3
lines changed

4 files changed

+291
-3
lines changed

.gitignore

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@ test/javasource/
22
test/deployment/
33
test/.classpath
44
test/.project
5-
test/Test.mpr.lock
6-
*.mws
5+
test/theme/
6+
test/userlib/
7+
test/.classpath
8+
test/.project
79
*.launch
810
*.tmp
911
*.lock
12+
.idea/
13+
14+
dist/
15+
16+
node_modules/
17+
.editorconfig
18+
*DS_Store*
19+
.vscode/
1020
*.bak
11-
.idea/

.jshintrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
// Enforcing
3+
"curly" : false,
4+
"forin" : false,
5+
"latedef" : "nofunc",
6+
"newcap" : true,
7+
"quotmark" : "double",
8+
"eqeqeq" : true,
9+
"undef" : true,
10+
"globals" : {
11+
"mendix" : false,
12+
"mx" : false
13+
},
14+
15+
// Relaxing
16+
"laxbreak" : true,
17+
18+
// Environments
19+
"browser" : true,
20+
"devel" : true,
21+
"dojo" : true
22+
}

Gruntfile.js

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

package.json

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

0 commit comments

Comments
 (0)