From 25f8a305926c9d936f1e24788b6e1f74d9523405 Mon Sep 17 00:00:00 2001 From: Acellam Guy Date: Tue, 23 May 2017 16:10:15 +0300 Subject: [PATCH 1/5] Add preview --- Gruntfile.js | 38 ++++++++++++---- package.json | 7 +++ .../widget/PullToRefresh.webmodeler.ts | 12 +++++ src/PullToRefresh/widget/ui/preview.png | Bin 0 -> 1838 bytes webpack.config.js | 43 ++++++++++++++++-- 5 files changed, 86 insertions(+), 14 deletions(-) create mode 100644 src/PullToRefresh/widget/PullToRefresh.webmodeler.ts create mode 100644 src/PullToRefresh/widget/ui/preview.png diff --git a/Gruntfile.js b/Gruntfile.js index 916cdfa..c05e26d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,18 +1,28 @@ "use strict"; +const webpack = require("webpack"); const webpackConfig = require("./webpack.config"); -const webpackConfigRelease = {}; -Object.assign(webpackConfigRelease, webpackConfig, { - devtool: false +const webpackConfigRelease = [ {}, {} ]; +const pluginsWidget = webpackConfig[0].plugins.slice(0); +pluginsWidget.push(new webpack.optimize.UglifyJsPlugin()); +Object.assign(webpackConfigRelease[0], webpackConfig[0], { + devtool: false, + plugins: pluginsWidget +}); +const pluginsPreview = webpackConfig[1].plugins.slice(0); +pluginsPreview.push(new webpack.optimize.UglifyJsPlugin()); +Object.assign(webpackConfigRelease[1], webpackConfig[1], { + devtool: false, + plugins: pluginsPreview }); -module.exports = function (grunt) { - var pkg = grunt.file.readJSON("package.json"); +module.exports = function(grunt) { + const pkg = grunt.file.readJSON("package.json"); grunt.initConfig({ watch: { updateWidgetFiles: { files: [ "./dist/tmp/src/**/*" ], - tasks: [ "webpack:develop", "compress:dist", "copy:distDeployment", "copy:mpk" ], + tasks: [ "webpack:develop", "file_append", "compress:dist", "copy:distDeployment", "copy:mpk" ], options: { debounceDelay: 250, livereload: true @@ -66,7 +76,14 @@ module.exports = function (grunt) { } ] } }, - + file_append: { + addSourceURL: { + files: [ { + append: "\n\n//# sourceURL=PullToRefresh.webmodeler.js\n", + input: "dist/tmp/src/PullToRefresh/widget/PullToRefresh.webmodeler.js" + } ] + } + }, webpack: { develop: webpackConfig, release: webpackConfigRelease @@ -91,18 +108,19 @@ module.exports = function (grunt) { grunt.loadNpmTasks("grunt-contrib-compress"); grunt.loadNpmTasks("grunt-contrib-copy"); grunt.loadNpmTasks("grunt-contrib-watch"); + grunt.loadNpmTasks("grunt-file-append"); grunt.loadNpmTasks("grunt-webpack"); grunt.registerTask("default", [ "clean build", "watch" ]); grunt.registerTask( "clean build", - "Compiles all the assets and copies the files to the dist directory.", - [ "checkDependencies", "clean:build", "webpack:develop", "compress:dist", "copy:mpk" ] + "Compiles all the assets and copies the files to dist build directory.", + [ "checkDependencies", "clean:build", "webpack:develop", "file_append", "compress:dist", "copy:mpk" ] ); grunt.registerTask( "release", "Compiles all the assets and copies the files to the dist directory. Minified without source mapping", - [ "checkDependencies", "clean:build", "webpack:release", "compress:dist", "copy:mpk" ] + [ "checkDependencies", "clean:build", "webpack:release", "file_append", "compress:dist", "copy:mpk" ] ); grunt.registerTask("build", [ "clean build" ]); }; diff --git a/package.json b/package.json index a09bb6b..4634c77 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,8 @@ "devDependencies": { "@types/big.js": "0.0.31", "@types/dojo": "^1.9.35", + "@types/react": "^15.0.16", + "@types/react-dom": "^0.14.23", "check-dependencies": "^1.0.1", "copy-webpack-plugin": "^4.0.1", "css-loader": "^0.27.3", @@ -24,16 +26,21 @@ "grunt-contrib-compress": "^1.4.1", "grunt-contrib-copy": "^1.0.0", "grunt-contrib-watch": "^1.0.0", + "grunt-file-append": "0.0.7", "grunt-newer": "^1.1.1", "grunt-webpack": "^2.0.1", "json-loader": "^0.5.4", "mendix-client": "git+https://github.com/FlockOfBirds/Mendix-client-typing.git", + "raw-loader": "^0.5.1", + "react": "^15.4.2", + "react-dom": "^15.4.2", "source-map-loader": "^0.2.0", "style-loader": "^0.13.2", "ts-loader": "^2.0.1", "tslint": "^4.5.1", "tslint-eslint-rules": "^3.3.0", "typescript": "^2.2.1", + "url-loader": "^0.5.8", "webpack": "^2.2.1", "webpack-dev-server": "^2.2.0" } diff --git a/src/PullToRefresh/widget/PullToRefresh.webmodeler.ts b/src/PullToRefresh/widget/PullToRefresh.webmodeler.ts new file mode 100644 index 0000000..0a43a76 --- /dev/null +++ b/src/PullToRefresh/widget/PullToRefresh.webmodeler.ts @@ -0,0 +1,12 @@ +import { Component, DOM } from "react"; + +declare function require(name: string): string; + +export class preview extends Component<{}, {}> { + + render() { + const image = require("./ui/preview.png"); + + return DOM.img({ src: image }); + } +} diff --git a/src/PullToRefresh/widget/ui/preview.png b/src/PullToRefresh/widget/ui/preview.png new file mode 100644 index 0000000000000000000000000000000000000000..39c9b33f31d8720341b28fa93bd02ca174e69733 GIT binary patch literal 1838 zcmV+}2hsS6P)Px*=t)FDRCodHn|o|ibri?HE#0H-*6z`DPdaeO5C@1NFF^(Y0ga1b&_G0uK!AWz zBZ>k_Fo0+P;SXZ`3m=5U2!^Oc25clcg$XE6d5CUf?)_lzwcEOR&LzXWZo9I3+n@2C zq-p!RkNtk1o_o&uopYv(+H<7?n)D)|?=_+gNCY%6GK!#q(ZI+MkQvrAMgt>5KxSCe z7!8aJ0hwWg%y__u^*Ug3f(gSSf)Np-M_z3!PM0;KxS`E2a}yHGq7hcCpAdr@mmB9R zoYMQGcoTM|$04(z0h>-%prlbBP8LRQ^dd~_s|!jw0a0S9xY%!&P1YhX0!u_HYetFlXQ?UrY6vyQbe$e+gg0mN#LzG-7;eF4 z(i)bAR%M~^J%t0aX_6fWGX{gbPER2-gy-(FVi(zzMTh_P$+h>qm$&c2JxaXzjT7xy zJkp9IWN&^eccOv3kAnihg{f9F()02%8E7`zYKm}RIv2|t!`p)q(IGGsE#5T#P}GR* zn~fklt-1&cM)j3@`2zv7F=m4f(R=KmI_16042K!VDJ}WRiBgm{{hO9drLdkQ zuh#Sa$lt(J1@mmG1>5McA*H~pCra?emD+CW3mK%tGRni8p(HnF=R^`!z}P4T`G|JF zj}Hw;4#gg;vrAD}-#r1v7G=k@I1I4{V`Wx>NKB-;C=Mp$o^WiR77G(??AGO!;gbu! zb1TuIgCr=N^yVDyFQwg+-Xc&^6wGT6Mq>jdn)uOJl~sZpHNEWy?{zpaWhGaAt=a{1 zkPdH*i}smCQ(FgeOPW;M8Yl{8N}>rDDTB{h{&tzL{RK*0G87i}L~o6c@fk|j3qCwu zi4W+dv?vOOC&wE;IVgO5)_b-$A~8&44Cj>y%hHxqv$xdN6oq~Qq7dGIz{K5qoThWA`F-rl;t?Q+_l6?_Hga9)u zISg)!3bP9vMd2bwUFk8hFT9bg6)5!(aE;;qm?VLqMQ?)k+j(q{5f zl?#_EUDD@#nTDWw!z`4@(n-ZNIWXMj!T0W~{Y>tffsQK*=55NqN|7i2A|ZZV2rYbN}xv5`$FoTT0T1J&N-(jr?T>R$(`?geK1l5fnWXUN0xTjHsMs@mzs@ASBdD5`>yTkxOM<;^dVCE#93R5%(KnO{aIFkI;8#CT`# zugsjK;Y4!bYaWUQ6(dv;m2P`?bG1@gW%bx-WGxtiF%=X0>{CxoiE4?EV0f`q9l=(rdoQKhHa9!-?mNn8 zpgx*PsV`XVyiGvjnEw3Av^B!oAIqeD7T3Xv3-$CC;n0ox{#-ubbA$!cxw3uKAyGjo z&qgZbB=_1Z0LajnTl! c5Re)E2R=+U0zs)&b^rhX07*qoM6N<$f{PA&xc~qF literal 0 HcmV?d00001 diff --git a/webpack.config.js b/webpack.config.js index 8767c0a..f6418ce 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,7 +3,7 @@ const path = require("path"); const CopyWebpackPlugin = require("copy-webpack-plugin"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); -module.exports = { +const widgetConfig = { entry: "./src/PullToRefresh/widget/PullToRefresh.ts", output: { path: path.resolve(__dirname, "dist/tmp"), @@ -19,17 +19,26 @@ module.exports = { { test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: "style-loader", use: "css-loader" - }) } + }) }, + { test: /\.(png|jpeg)$/, loader: "url-loader", options: { limit: 8192 } } ] }, devtool: "source-map", externals: [ - "mxui/widget/_WidgetBase", "dojo/_base/declare", "dojo/dom-construct", "dojo/dom", "dojo/dom-class", - "dojo/dom-style" ], + "react", + "react-dom", + "mxui/widget/_WidgetBase", + "dojo/_base/declare", + "dojo/dom-construct", + "dojo/dom", + "dojo/dom-class", + "dojo/dom-style" + ], plugins: [ new CopyWebpackPlugin([ { from: "src/**/*.js" }, { from: "src/**/*.xml" }, + { from: "src/**/*.png" }, { from: "assets/Preview.png", to: "src/PullToRefresh/widget/Preview.png"} ], { copyUnmodified: true @@ -41,3 +50,29 @@ module.exports = { }) ] }; + +const previewConfig = { + entry: "./src/PullToRefresh/widget/PullToRefresh.webmodeler.ts", + output: { + path: path.resolve(__dirname, "dist/tmp"), + filename: "src/PullToRefresh/widget/PullToRefresh.webmodeler.js", + libraryTarget: "commonjs" + }, + resolve: { + extensions: [ ".ts", ".js" ] + }, + module: { + rules: [ + { test: /\.ts$/, use: "ts-loader" }, + { test: /\.css$/, loader: "raw-loader" }, + { test: /\.(png|jpeg)$/, loader: "url-loader", options: { limit: 8192 } } + ] + }, + devtool: "inline-source-map", + externals: [ "react", "react-dom" ], + plugins: [ + new webpack.LoaderOptionsPlugin({ debug: true }) + ] +}; + +module.exports = [ widgetConfig, previewConfig ]; From 174dbf9fc42e18e7546fdf872aa52c589323284c Mon Sep 17 00:00:00 2001 From: Acellam Guy Date: Wed, 24 May 2017 08:36:47 +0300 Subject: [PATCH 2/5] Bump version --- README.md | 2 +- package.json | 2 +- src/package.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 354783d..5e0b01e 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ To set up the development environment, run: Create a folder named `dist` in the project root. -Create a Mendix test project in the dist folder and rename its root folder to `dist/MxTestProject`. Or get the test project from https://github.com/mendixlabs/pull-to-refresh/releases/download/1.0.0/TestPullToRefresh.mpk Changes to the widget code shall be automatically pushed to this test project. +Create a Mendix test project in the dist folder and rename its root folder to `dist/MxTestProject`. Or get the test project from https://github.com/mendixlabs/pull-to-refresh/releases/download/1.0.1/TestPullToRefresh.mpk Changes to the widget code shall be automatically pushed to this test project. To automatically compile, bundle and push code changes to the running test project, run: diff --git a/package.json b/package.json index 4634c77..018cde7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pulltorefresh", "widgetName": "PullToRefresh", - "version": "1.0.0", + "version": "1.0.1", "description": "Use touch on mobile enabling pull down to reload a page", "repository": { "type": "git", diff --git a/src/package.xml b/src/package.xml index bdc940d..4727599 100644 --- a/src/package.xml +++ b/src/package.xml @@ -1,6 +1,6 @@ - + From 0b0f610ab493845ce1c35cbcba6d7a4687ae9d65 Mon Sep 17 00:00:00 2001 From: Acellam Guy Date: Fri, 2 Jun 2017 16:48:16 +0300 Subject: [PATCH 3/5] Add pre-commit --- package.json | 14 +- src/PullToRefresh/widget/PullToRefresh.ts | 212 ++++++++-------- .../widget/PullToRefresh.webmodeler.ts | 1 + .../widget/handlers/PullToRefresh.ts | 13 +- tslint.json | 236 +++++++++++------- 5 files changed, 278 insertions(+), 198 deletions(-) diff --git a/package.json b/package.json index 018cde7..0a5931a 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,15 @@ "widgetName": "PullToRefresh", "version": "1.0.1", "description": "Use touch on mobile enabling pull down to reload a page", + "copyright": "Mendix BV", + "scripts": { + "pretest": "tsc", + "lint": "tslint -c tslint.json '**/*.ts' '**/*.tsx' --exclude '**/node_modules/**'" + }, + "pre-commit": [ + "pretest", + "lint" + ], "repository": { "type": "git", "url": "https://github.com/mendixlabs/pull-to-refresh" @@ -31,14 +40,15 @@ "grunt-webpack": "^2.0.1", "json-loader": "^0.5.4", "mendix-client": "git+https://github.com/FlockOfBirds/Mendix-client-typing.git", + "pre-commit": "^1.2.2", "raw-loader": "^0.5.1", "react": "^15.4.2", "react-dom": "^15.4.2", "source-map-loader": "^0.2.0", "style-loader": "^0.13.2", "ts-loader": "^2.0.1", - "tslint": "^4.5.1", - "tslint-eslint-rules": "^3.3.0", + "tslint": "^5.4.2", + "tslint-eslint-rules": "^4.1.1", "typescript": "^2.2.1", "url-loader": "^0.5.8", "webpack": "^2.2.1", diff --git a/src/PullToRefresh/widget/PullToRefresh.ts b/src/PullToRefresh/widget/PullToRefresh.ts index 6acf88f..a6a9bba 100644 --- a/src/PullToRefresh/widget/PullToRefresh.ts +++ b/src/PullToRefresh/widget/PullToRefresh.ts @@ -1,106 +1,106 @@ -import * as dojoDeclare from "dojo/_base/declare"; -import * as dojoDom from "dojo/dom"; -import * as domConstruct from "dojo/dom-construct"; -import * as WidgetBase from "mxui/widget/_WidgetBase"; - -import { PullToRefresh } from "./handlers/PullToRefresh"; -import "./ui/PullToRefresh.css"; - -class PullToRefreshWrapper extends WidgetBase { - private pullToRefreshText: string; - private releaseToRefreshText: string; - private refreshText: string; - - private pullToRefreshElement: HTMLElement; - private pullToRefresh: PullToRefresh; - private progressId: number; - - postCreate() { - this.onRefresh = this.onRefresh.bind(this); - this.onSyncFailure = this.onSyncFailure.bind(this); - - if (!window.mx.data.synchronizeOffline && !window.mx.data.synchronizeDataWithFiles) { - domConstruct.create("div", { - class: "alert alert-danger", - innerHTML: "The pull to refresh widget is not compatible with this version of Mendix" - }, this.domNode); - } else { - // We share the refresh element across pages. Else the setup and destroy will conflict - this.setUpWidgetDom(); - this.pullToRefresh.setupEvents(); - } - } - - uninitialize(): boolean { - this.pullToRefresh.removeEvents(); - - return true; - } - - private setUpWidgetDom() { - this.pullToRefreshElement = dojoDom.byId("widget-pull-to-refresh"); - if (!this.pullToRefreshElement) { - this.pullToRefreshElement = domConstruct.create("div", { - class: "pull-to-refresh-pull-to-refresh", - id: "widget-pull-to-refresh", - innerHTML: ` -
-
-
-
-
-
- ` - }, document.body, "first"); - } - - this.pullToRefresh = new PullToRefresh({ - mainElement: document.body, - onRefresh: this.onRefresh, - pullToRefreshElement: this.pullToRefreshElement, - pullToRefreshText: this.pullToRefreshText, - refreshText: this.refreshText, - releaseToRefreshText: this.releaseToRefreshText - }); - } - - // Note; this function is hooking into the Mendix private API, this is subject to change without notice! - // Please do not re-use this. The only supported API is publicly documented at - // https://apidocs.mendix.com/7/client/ - private onRefresh(callback: () => void) { - this.progressId = window.mx.ui.showProgress(null, true); - this.pullToRefresh.removeEvents(); - if (window.mx.data.synchronizeOffline) { - window.mx.data.synchronizeOffline({ fast: false }, () => this.onSyncSuccess(callback), this.onSyncFailure); - } else if (window.mx.data.synchronizeDataWithFiles) { - window.mx.data.synchronizeDataWithFiles(() => this.onSyncSuccess(callback), this.onSyncFailure); - } - } - - private onSyncSuccess(callback: () => void) { - window.mx.ui.reload(() => { - if (this.progressId) { - window.mx.ui.hideProgress(this.progressId); - } - this.pullToRefresh.setupEvents(); - if (callback) callback(); - }); - } - - private onSyncFailure() { - if (this.progressId) window.mx.ui.hideProgress(this.progressId); - window.mx.ui.info(window.mx.ui.translate("mxui.sys.UI", "sync_error"), true); - this.pullToRefresh.setupEvents(); - } -} - -// tslint:disable : only-arrow-functions -dojoDeclare("PullToRefresh.widget.PullToRefresh", [ WidgetBase ], function(Source: any) { - const result: any = {}; - for (const property in Source.prototype) { - if (property !== "constructor" && Source.prototype.hasOwnProperty(property)) { - result[property] = Source.prototype[property]; - } - } - return result; -}(PullToRefreshWrapper)); +import * as dojoDeclare from "dojo/_base/declare"; +import * as dojoDom from "dojo/dom"; +import * as domConstruct from "dojo/dom-construct"; +import * as WidgetBase from "mxui/widget/_WidgetBase"; + +import { PullToRefresh } from "./handlers/PullToRefresh"; +import "./ui/PullToRefresh.css"; + +class PullToRefreshWrapper extends WidgetBase { + private pullToRefreshText: string; + private releaseToRefreshText: string; + private refreshText: string; + + private pullToRefreshElement: HTMLElement; + private pullToRefresh: PullToRefresh; + private progressId: number; + + postCreate() { + this.onRefresh = this.onRefresh.bind(this); + this.onSyncFailure = this.onSyncFailure.bind(this); + + if (!window.mx.data.synchronizeOffline && !window.mx.data.synchronizeDataWithFiles) { + domConstruct.create("div", { + class: "alert alert-danger", + innerHTML: "The pull to refresh widget is not compatible with this version of Mendix" + }, this.domNode); + } else { + // We share the refresh element across pages. Else the setup and destroy will conflict + this.setUpWidgetDom(); + this.pullToRefresh.setupEvents(); + } + } + + uninitialize(): boolean { + this.pullToRefresh.removeEvents(); + + return true; + } + + private setUpWidgetDom() { + this.pullToRefreshElement = dojoDom.byId("widget-pull-to-refresh"); + if (!this.pullToRefreshElement) { + this.pullToRefreshElement = domConstruct.create("div", { + class: "pull-to-refresh-pull-to-refresh", + id: "widget-pull-to-refresh", + innerHTML: ` +
+
+
+
+
+
+ ` + }, document.body, "first"); + } + + this.pullToRefresh = new PullToRefresh({ + mainElement: document.body, + onRefresh: this.onRefresh, + pullToRefreshElement: this.pullToRefreshElement, + pullToRefreshText: this.pullToRefreshText, + refreshText: this.refreshText, + releaseToRefreshText: this.releaseToRefreshText + }); + } + + // Note; this function is hooking into the Mendix private API, this is subject to change without notice! + // Please do not re-use this. The only supported API is publicly documented at + // https://apidocs.mendix.com/7/client/ + private onRefresh(callback: () => void) { + this.progressId = window.mx.ui.showProgress(null, true); + this.pullToRefresh.removeEvents(); + if (window.mx.data.synchronizeOffline) { + window.mx.data.synchronizeOffline({ fast: false }, () => this.onSyncSuccess(callback), this.onSyncFailure); + } else if (window.mx.data.synchronizeDataWithFiles) { + window.mx.data.synchronizeDataWithFiles(() => this.onSyncSuccess(callback), this.onSyncFailure); + } + } + + private onSyncSuccess(callback: () => void) { + window.mx.ui.reload(() => { + if (this.progressId) { + window.mx.ui.hideProgress(this.progressId); + } + this.pullToRefresh.setupEvents(); + if (callback) callback(); + }); + } + + private onSyncFailure() { + if (this.progressId) window.mx.ui.hideProgress(this.progressId); + window.mx.ui.info(window.mx.ui.translate("mxui.sys.UI", "sync_error"), true); + this.pullToRefresh.setupEvents(); + } +} + +// tslint:disable : only-arrow-functions +dojoDeclare("PullToRefresh.widget.PullToRefresh", [ WidgetBase ], function(Source: any) { + const result: any = {}; + for (const property in Source.prototype) { + if (property !== "constructor" && Source.prototype.hasOwnProperty(property)) { + result[property] = Source.prototype[property]; + } + } + return result; +}(PullToRefreshWrapper)); diff --git a/src/PullToRefresh/widget/PullToRefresh.webmodeler.ts b/src/PullToRefresh/widget/PullToRefresh.webmodeler.ts index 0a43a76..0e04818 100644 --- a/src/PullToRefresh/widget/PullToRefresh.webmodeler.ts +++ b/src/PullToRefresh/widget/PullToRefresh.webmodeler.ts @@ -2,6 +2,7 @@ import { Component, DOM } from "react"; declare function require(name: string): string; +// tslint:disable-next-line class-name export class preview extends Component<{}, {}> { render() { diff --git a/src/PullToRefresh/widget/handlers/PullToRefresh.ts b/src/PullToRefresh/widget/handlers/PullToRefresh.ts index b235633..9aceefe 100644 --- a/src/PullToRefresh/widget/handlers/PullToRefresh.ts +++ b/src/PullToRefresh/widget/handlers/PullToRefresh.ts @@ -85,8 +85,17 @@ export class PullToRefresh { } private update(nextState: State) { - const { iconElement, textElement, pullToRefreshElement, classPrefix, iconRefreshing, iconArrow, - refreshText, pullToRefreshText, releaseToRefreshText, reloadDistance } = this.settings; + const { + iconElement, + textElement, + pullToRefreshElement, + classPrefix, + iconRefreshing, + iconArrow, + refreshText, + pullToRefreshText, + releaseToRefreshText, + reloadDistance } = this.settings; if (iconElement && textElement && nextState !== this.state ) { if (nextState === "refreshing") { diff --git a/tslint.json b/tslint.json index e7c0265..b99eeb9 100644 --- a/tslint.json +++ b/tslint.json @@ -1,90 +1,150 @@ { - "rulesDirectory": [ "node_modules/tslint-eslint-rules/dist/rules" ], - "extends": "tslint:latest", - "rules": { - "class-name": true, - "comment-format": [ true, "check-space" ], - "eofline": true, - "indent": [ true, "spaces" ], - "member-ordering": [ true, "variables-before-functions" ], - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-console": [ true ], - "no-debugger": true, - "no-duplicate-key": true, - "no-duplicate-variable": true, - "no-eval": true, - "no-inferrable-types": [ true ], - "no-internal-module": true, - "no-shadowed-variable": true, - "no-switch-case-fall-through": true, - "no-trailing-whitespace": true, - "no-unreachable": true, - "no-unused-expression": true, - "no-var-keyword": true, - "one-line": [ - true, - "check-catch", - "check-else", - "check-finally", - "check-open-brace", - "check-whitespace" - ], - "quotemark": [ true, "double" ], - "semicolon": [ true, "always" ], - "triple-equals": [ true, "allow-null-check" ], - "typedef-whitespace": [ - true, { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - } - ], - "variable-name": [ true, "ban-keywords" ], - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-module", - "check-separator", - "check-type" - ], - "interface-name": [ false, "always-prefix" ], - "no-multi-spaces": [ true ], - "no-extra-semi": true, - "no-irregular-whitespace": true, - "no-duplicate-case": true, - "no-control-regex": true, - "no-empty-character-class": true, - "no-ex-assign": true, - "no-extra-boolean-cast": true, - "no-unexpected-multiline": true, - "no-sparse-arrays": true, - "no-regex-spaces": true, - "no-invalid-regexp": true, - "valid-typeof": true, - "array-bracket-spacing": [ true, "always" ], - "block-spacing": [ true, "always" ], - "brace-style": [ - true, - "1tbs", { - "allowSingleLine": true - } - ], - "object-curly-spacing": [ true, "always" ], - "trailing-comma": [ true, { "multiline": "never", "singleline": "never" } ], - "member-access": false, - "no-unused-variable": [ true, "react" ], - "arrow-parens": false, - "curly": false - }, - "jsRules": { - "trailing-comma": [ false ], - "object-literal-sort-keys": false, - "array-bracket-spacing": [ true, "always" ] - } + "rulesDirectory": [ + "node_modules/tslint-eslint-rules/dist/rules" + ], + "extends": "tslint:latest", + "rules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "eofline": true, + "indent": [ + true, + "spaces" + ], + "member-ordering": [ + true, + "variables-before-functions" + ], + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-console": [ + true + ], + "no-debugger": true, + "no-duplicate-variable": true, + "no-eval": true, + "no-inferrable-types": [ + true + ], + "no-internal-module": true, + "no-shadowed-variable": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unused-expression": true, + "no-var-keyword": true, + "one-line": [ + true, + "check-catch", + "check-else", + "check-finally", + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "double" + ], + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "variable-name": [ + true, + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-module", + "check-separator", + "check-type" + ], + "interface-name": [ + false, + "always-prefix" + ], + "no-multi-spaces": [ + true + ], + "no-extra-semi": true, + "no-irregular-whitespace": true, + "no-duplicate-case": true, + "no-control-regex": true, + "no-empty-character-class": true, + "no-ex-assign": true, + "no-extra-boolean-cast": true, + "no-unexpected-multiline": true, + "no-sparse-arrays": true, + "no-regex-spaces": true, + "no-invalid-regexp": true, + "valid-typeof": true, + "array-bracket-spacing": [ + true, + "always" + ], + "block-spacing": [ + true, + "always" + ], + "brace-style": [ + true, + "1tbs", + { + "allowSingleLine": true + } + ], + "object-curly-spacing": [ + true, + "always" + ], + "trailing-comma": [ + true, + { + "multiline": "never", + "singleline": "never" + } + ], + "member-access": false, + "ordered-imports": [ + true, + { + "import-sources-order": "any", + "named-imports-order": "lowercase-last" + } + ], + "curly": false, + "arrow-parens": false, + "linebreak-style": [ true, "LF" ] + }, + "jsRules": { + "trailing-comma": [ + false + ], + "object-literal-sort-keys": false, + "array-bracket-spacing": [ + true, + "always" + ], + "linebreak-style": [ true, "LF" ] + } } From ee9a9b0f883738c1db57ad2a420c2c65b33c170f Mon Sep 17 00:00:00 2001 From: Acellam Guy Date: Fri, 2 Jun 2017 16:50:04 +0300 Subject: [PATCH 4/5] Refactor grunt release by making it DRY --- Gruntfile.js | 25 +++++++++++++------------ README.md | 4 ++-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index c05e26d..7b0b454 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,20 +1,21 @@ "use strict"; const webpack = require("webpack"); const webpackConfig = require("./webpack.config"); -const webpackConfigRelease = [ {}, {} ]; -const pluginsWidget = webpackConfig[0].plugins.slice(0); -pluginsWidget.push(new webpack.optimize.UglifyJsPlugin()); -Object.assign(webpackConfigRelease[0], webpackConfig[0], { - devtool: false, - plugins: pluginsWidget -}); -const pluginsPreview = webpackConfig[1].plugins.slice(0); -pluginsPreview.push(new webpack.optimize.UglifyJsPlugin()); -Object.assign(webpackConfigRelease[1], webpackConfig[1], { - devtool: false, - plugins: pluginsPreview +const webpackConfigRelease = []; + +webpackConfig.forEach(function (currentWebpackConfig) { + const webpackLoaderOptionsPlugin = currentWebpackConfig.plugins.slice(0); + const configRelease = {}; + + webpackLoaderOptionsPlugin.push(new webpack.optimize.UglifyJsPlugin()); + Object.assign(configRelease, currentWebpackConfig, { + devtool: false, + plugins: webpackLoaderOptionsPlugin + }); + webpackConfigRelease.push(configRelease) }); + module.exports = function(grunt) { const pkg = grunt.file.readJSON("package.json"); grunt.initConfig({ diff --git a/README.md b/README.md index 5e0b01e..f1b22fb 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,12 @@ Pull down on mobile to enable page refresh. * Pull to refresh will only work when everything is scrolled to top ## Dependencies -Mendix version 6.10 or up +Mendix version 7.3 or up ## Demo project https://pulltorefresh.mxapps.io -![1](assets/demo.gif) +![1](https://raw.githubusercontent.com/mendixlabs/pull-to-refresh/v1.1.0/assets/demo.gif) ## Usage * Place the widget on a page or layout From 8be426115c59dcaf11614ca6f08dad4bde8c6e3c Mon Sep 17 00:00:00 2001 From: Acellam Guy Date: Wed, 7 Jun 2017 16:49:16 +0300 Subject: [PATCH 5/5] Process review --- .gitattributes | 19 +++++++++++++++++++ README.md | 4 ++-- webpack.config.js | 18 ++++-------------- 3 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..a877e24 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,19 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files you want to always be normalized and converted +# to native line endings on checkout. +*.ts text eol=lf +*.js text eol=lf +*.css text eol=lf +*.scss text eol=lf +*.json text eol=lf +*.xml text eol=lf +*.md text eol=lf +*.gitattributes eol=lf +*.gitignore eol=lf + +# Denote all files that are truly binary and should not be modified. +*.png binary +*.jpg binary +*.gif binary diff --git a/README.md b/README.md index f1b22fb..3fbd30c 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,12 @@ Pull down on mobile to enable page refresh. * Pull to refresh will only work when everything is scrolled to top ## Dependencies -Mendix version 7.3 or up +Mendix version 6.10 or up ## Demo project https://pulltorefresh.mxapps.io -![1](https://raw.githubusercontent.com/mendixlabs/pull-to-refresh/v1.1.0/assets/demo.gif) +![1](https://raw.githubusercontent.com/mendixlabs/pull-to-refresh/v1.0.1/assets/demo.gif) ## Usage * Place the widget on a page or layout diff --git a/webpack.config.js b/webpack.config.js index f6418ce..b7237c5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,10 +8,10 @@ const widgetConfig = { output: { path: path.resolve(__dirname, "dist/tmp"), filename: "src/PullToRefresh/widget/PullToRefresh.js", - libraryTarget: "umd" + libraryTarget: "amd" }, resolve: { - extensions: [ ".ts", ".js", ".json" ] + extensions: [ ".ts" ] }, module: { rules: [ @@ -24,19 +24,9 @@ const widgetConfig = { ] }, devtool: "source-map", - externals: [ - "react", - "react-dom", - "mxui/widget/_WidgetBase", - "dojo/_base/declare", - "dojo/dom-construct", - "dojo/dom", - "dojo/dom-class", - "dojo/dom-style" - ], + externals: [ "react", "react-dom", /^mxui\/|^mendix\/|^dojo\/|^dijit\// ], plugins: [ new CopyWebpackPlugin([ - { from: "src/**/*.js" }, { from: "src/**/*.xml" }, { from: "src/**/*.png" }, { from: "assets/Preview.png", to: "src/PullToRefresh/widget/Preview.png"} @@ -59,7 +49,7 @@ const previewConfig = { libraryTarget: "commonjs" }, resolve: { - extensions: [ ".ts", ".js" ] + extensions: [ ".ts" ] }, module: { rules: [