Skip to content

Commit 8239611

Browse files
author
Osama Mohammad Najjar
authored
Merge pull request #10 from mendix/bugfix/imageNode-undefined-mx7
Bugfix/image node undefined mx7
2 parents ad67fbf + d747461 commit 8239611

11 files changed

Lines changed: 192 additions & 128 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ test/.project
1212
.idea/
1313

1414
dist/
15+
build/
1516

1617
node_modules/
1718
.editorconfig

Gulpfile.js

Lines changed: 96 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,79 +10,121 @@ var MODELER_ARGS = "/file:{path}";
1010
* Do not edit anything below, unless you know what you are doing
1111
********************************************************************************/
1212
var gulp = require("gulp"),
13-
zip = require("gulp-zip"),
14-
del = require("del"),
15-
newer = require("gulp-newer"),
16-
gutil = require("gulp-util"),
17-
gulpif = require("gulp-if"),
18-
jsonTransform = require("gulp-json-transform"),
19-
intercept = require("gulp-intercept"),
20-
argv = require("yargs").argv,
21-
widgetBuilderHelper = require("widgetbuilder-gulp-helper"),
22-
jsValidate = require("gulp-jsvalidate");
13+
zip = require("gulp-zip"),
14+
del = require("del"),
15+
newer = require("gulp-newer"),
16+
gutil = require("gulp-util"),
17+
gulpif = require("gulp-if"),
18+
jsonTransform = require("gulp-json-transform"),
19+
intercept = require("gulp-intercept"),
20+
argv = require("yargs").argv,
21+
widgetBuilderHelper = require("widgetbuilder-gulp-helper"),
22+
jsValidate = require("gulp-jsvalidate"),
23+
minify = require("gulp-minify"),
24+
fs = require("fs-extra"),
25+
del = require("del");
2326

2427
var pkg = require("./package.json"),
25-
paths = widgetBuilderHelper.generatePaths(pkg),
26-
xmlversion = widgetBuilderHelper.xmlversion;
28+
paths = widgetBuilderHelper.generatePaths(pkg),
29+
xmlversion = widgetBuilderHelper.xmlversion;
2730

2831
gulp.task("default", function() {
29-
gulp.watch("./src/**/*", ["compress"]);
30-
gulp.watch("./src/**/*.js", ["copy:js"]);
32+
gulp.watch("./src/**/*", [ "compress" ]);
33+
gulp.watch("./src/**/*.js", [ "copy:js" ]);
3134
});
3235

33-
gulp.task("clean", function () {
34-
return del([
35-
paths.WIDGET_TEST_DEST,
36-
paths.WIDGET_DIST_DEST
37-
], { force: true });
36+
gulp.task("clean", function() {
37+
return del([ paths.WIDGET_TEST_DEST, paths.WIDGET_DIST_DEST ], {
38+
force : true,
39+
});
3840
});
3941

40-
gulp.task("compress", ["clean"], function () {
41-
return gulp.src("src/**/*")
42-
.pipe(zip(pkg.name + ".mpk"))
43-
.pipe(gulp.dest(paths.TEST_WIDGETS_FOLDER))
44-
.pipe(gulp.dest("dist"));
42+
gulp.task("compress", [ "clean" ], function() {
43+
return gulp
44+
.src("src/**/*")
45+
.pipe(zip(pkg.name + ".mpk"))
46+
.pipe(gulp.dest(paths.TEST_WIDGETS_FOLDER))
47+
.pipe(gulp.dest("dist"));
4548
});
4649

47-
gulp.task("copy:js", function () {
48-
return gulp.src(["./src/**/*.js"])
49-
.pipe(jsValidate())
50-
.pipe(newer(paths.TEST_WIDGETS_DEPLOYMENT_FOLDER))
51-
.pipe(gulp.dest(paths.TEST_WIDGETS_DEPLOYMENT_FOLDER));
50+
gulp.task("copy:js", function() {
51+
return gulp
52+
.src([ "./src/**/*.js" ])
53+
.pipe(jsValidate())
54+
.pipe(newer(paths.TEST_WIDGETS_DEPLOYMENT_FOLDER))
55+
.pipe(gulp.dest(paths.TEST_WIDGETS_DEPLOYMENT_FOLDER));
5256
});
5357

54-
gulp.task("version:xml", function () {
55-
return gulp.src(paths.PACKAGE_XML)
56-
.pipe(xmlversion(argv.n))
57-
.pipe(gulp.dest("./src/"));
58+
gulp.task("version:xml", function() {
59+
return gulp.src(paths.PACKAGE_XML).pipe(xmlversion(argv.n)).pipe(gulp.dest("./src/"));
5860
});
5961

60-
gulp.task("version:json", function () {
61-
return gulp.src("./package.json")
62-
.pipe(gulpif(typeof argv.n !== "undefined", jsonTransform(function(data) {
63-
data.version = argv.n;
64-
return data;
65-
}, 2)))
66-
.pipe(gulp.dest("./"));
62+
gulp.task("version:json", function() {
63+
return gulp
64+
.src("./package.json")
65+
.pipe(
66+
gulpif(
67+
typeof argv.n !== "undefined",
68+
jsonTransform(function(data) {
69+
data.version = argv.n;
70+
return data;
71+
}, 2),
72+
),
73+
)
74+
.pipe(gulp.dest("./"));
6775
});
6876

69-
gulp.task("icon", function (cb) {
70-
var icon = (typeof argv.file !== "undefined") ? argv.file : "./icon.png";
71-
console.log("\nUsing this file to create a base64 string: " + gutil.colors.cyan(icon));
72-
gulp.src(icon)
73-
.pipe(intercept(function (file) {
74-
console.log("\nCopy the following to your " + pkg.name + ".xml (after description):\n\n" + gutil.colors.cyan("<icon>") + file.contents.toString("base64") + gutil.colors.cyan("<\/icon>") + "\n");
75-
cb();
76-
}));
77+
gulp.task("icon", function(cb) {
78+
var icon = typeof argv.file !== "undefined" ? argv.file : "./icon.png";
79+
console.log("\nUsing this file to create a base64 string: " + gutil.colors.cyan(icon));
80+
gulp.src(icon).pipe(
81+
intercept(function(file) {
82+
console.log(
83+
"\nCopy the following to your " +
84+
pkg.name +
85+
".xml (after description):\n\n" +
86+
gutil.colors.cyan("<icon>") +
87+
file.contents.toString("base64") +
88+
gutil.colors.cyan("</icon>") +
89+
"\n",
90+
);
91+
cb();
92+
}),
93+
);
7794
});
7895

79-
gulp.task("folders", function () {
80-
paths.showPaths(); return;
96+
gulp.task("folders", function() {
97+
paths.showPaths();
98+
return;
8199
});
82100

83-
gulp.task("modeler", function (cb) {
84-
widgetBuilderHelper.runmodeler(MODELER_PATH, MODELER_ARGS, paths.TEST_PATH, cb);
101+
gulp.task("modeler", function(cb) {
102+
widgetBuilderHelper.runmodeler(MODELER_PATH, MODELER_ARGS, paths.TEST_PATH, cb);
85103
});
86104

87-
gulp.task("build", ["compress"]);
88-
gulp.task("version", ["version:xml", "version:json"]);
105+
gulp.task("build:prod", function() {
106+
try {
107+
del.sync("build/**", {force: true}); // cleanup buid dir
108+
fs.copySync("src", "build"); // copy everthing
109+
gulp
110+
.src([ "src/**/*.js" ]) // overwrite .js files with the minified ones.
111+
.pipe(
112+
minify({
113+
ext : {
114+
min : ".js",
115+
},
116+
noSource : true,
117+
mangle : true,
118+
}),
119+
)
120+
.pipe(gulp.dest("build"));
121+
return gulp
122+
.src("build/**/*")
123+
.pipe(zip(pkg.name + ".mpk"))
124+
.pipe(gulp.dest(paths.TEST_WIDGETS_FOLDER))
125+
.pipe(gulp.dest("build"))
126+
.pipe(gulp.dest("dist"));
127+
} catch (e) {
128+
console.error(e);
129+
}
130+
});

dist/DynamicImageViewer-5.7.0.mpk

-1.36 MB
Binary file not shown.

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
{
22
"name": "DynamicImage",
3-
"version": "5.0.0",
3+
"version": "5.0.1",
44
"description": "",
55
"license": "",
66
"author": "",
77
"private": true,
88
"dependencies": {},
99
"devDependencies": {
10-
"del": "^2.2.2",
10+
"del": "^3.0.0",
11+
"fs-extra": "^7.0.1",
1112
"gulp": "^3.9.1",
1213
"gulp-if": "^2.0.1",
1314
"gulp-intercept": "^0.1.0",
1415
"gulp-json-transform": "^0.4.2",
16+
"gulp-jsvalidate": "^3.0.0",
17+
"gulp-minify": "^0.0.15",
1518
"gulp-newer": "^1.3.0",
1619
"gulp-util": "^3.0.7",
1720
"gulp-zip": "^3.2.0",
18-
"gulp-jsvalidate": "^3.0.0",
1921
"widgetbuilder-gulp-helper": "https://github.com/JelteMX/widgetbuilder-gulp-helper/archive/1.0.1.tar.gz",
2022
"yargs": "^6.0.0"
2123
},
@@ -29,9 +31,10 @@
2931
},
3032
"scripts": {
3133
"build": "node ./node_modules/gulp/bin/gulp build",
34+
"build:prod": "node ./node_modules/gulp/bin/gulp build:prod",
3235
"version": "node ./node_modules/gulp/bin/gulp version",
3336
"icon": "node ./node_modules/gulp/bin/gulp icon",
3437
"folders": "node ./node_modules/gulp/bin/gulp folders",
3538
"modeler": "node ./node_modules/gulp/bin/gulp modeler"
3639
}
37-
}
40+
}

0 commit comments

Comments
 (0)