|
| 1 | +// Generated on 2016-11-11 using generator-mendix 2.0.1 :: git+https://github.com/mendix/generator-mendix.git |
| 2 | +/*jshint -W069,-W097*/ |
| 3 | +"use strict"; |
| 4 | + |
| 5 | +// In case you seem to have trouble starting Mendix through `gulp modeler`, you might have to set the path to the Mendix application, otherwise leave both values as they are |
| 6 | +var MODELER_PATH = null; |
| 7 | +var MODELER_ARGS = "/file:{path}"; |
| 8 | + |
| 9 | +/******************************************************************************** |
| 10 | + * Do not edit anything below, unless you know what you are doing |
| 11 | + ********************************************************************************/ |
| 12 | +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 | + |
| 23 | +var pkg = require("./package.json"), |
| 24 | + paths = widgetBuilderHelper.generatePaths(pkg), |
| 25 | + xmlversion = widgetBuilderHelper.xmlversion; |
| 26 | + |
| 27 | +gulp.task("default", function() { |
| 28 | + gulp.watch("./src/**/*", ["compress"]); |
| 29 | + gulp.watch("./src/**/*.js", ["copy:js"]); |
| 30 | +}); |
| 31 | + |
| 32 | +gulp.task("clean", function () { |
| 33 | + return del([ |
| 34 | + paths.WIDGET_TEST_DEST, |
| 35 | + paths.WIDGET_DIST_DEST |
| 36 | + ], { force: true }); |
| 37 | +}); |
| 38 | + |
| 39 | +gulp.task("compress", ["clean"], function () { |
| 40 | + return gulp.src("src/**/*") |
| 41 | + .pipe(zip(pkg.name + ".mpk")) |
| 42 | + .pipe(gulp.dest(paths.TEST_WIDGETS_FOLDER)) |
| 43 | + .pipe(gulp.dest("dist")); |
| 44 | +}); |
| 45 | + |
| 46 | +gulp.task("copy:js", function () { |
| 47 | + return gulp.src(["./src/**/*.js"]) |
| 48 | + .pipe(newer(paths.TEST_WIDGETS_DEPLOYMENT_FOLDER)) |
| 49 | + .pipe(gulp.dest(paths.TEST_WIDGETS_DEPLOYMENT_FOLDER)); |
| 50 | +}); |
| 51 | + |
| 52 | +gulp.task("version:xml", function () { |
| 53 | + return gulp.src(paths.PACKAGE_XML) |
| 54 | + .pipe(xmlversion(argv.n)) |
| 55 | + .pipe(gulp.dest("./src/")); |
| 56 | +}); |
| 57 | + |
| 58 | +gulp.task("version:json", function () { |
| 59 | + return gulp.src("./package.json") |
| 60 | + .pipe(gulpif(typeof argv.n !== "undefined", jsonTransform(function(data) { |
| 61 | + data.version = argv.n; |
| 62 | + return data; |
| 63 | + }, 2))) |
| 64 | + .pipe(gulp.dest("./")); |
| 65 | +}); |
| 66 | + |
| 67 | +gulp.task("icon", function (cb) { |
| 68 | + var icon = (typeof argv.file !== "undefined") ? argv.file : "./icon.png"; |
| 69 | + console.log("\nUsing this file to create a base64 string: " + gutil.colors.cyan(icon)); |
| 70 | + gulp.src(icon) |
| 71 | + .pipe(intercept(function (file) { |
| 72 | + 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"); |
| 73 | + cb(); |
| 74 | + })); |
| 75 | +}); |
| 76 | + |
| 77 | +gulp.task("folders", function () { |
| 78 | + paths.showPaths(); return; |
| 79 | +}); |
| 80 | + |
| 81 | +gulp.task("modeler", function (cb) { |
| 82 | + widgetBuilderHelper.runmodeler(MODELER_PATH, MODELER_ARGS, paths.TEST_PATH, cb); |
| 83 | +}); |
| 84 | + |
| 85 | +gulp.task("build", ["compress"]); |
| 86 | +gulp.task("version", ["version:xml", "version:json"]); |
0 commit comments