From 976b200d31d5d74d615325e4b6cbf00f77738a6f Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Tue, 14 Aug 2018 19:56:38 +0200 Subject: [PATCH 01/17] [muzi] add flow type check to react-swift-player :fist: --- .babelrc | 2 +- .flowconfig | 11 +++++++++++ package-lock.json | 6 ++++++ package.json | 6 +++++- 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .flowconfig diff --git a/.babelrc b/.babelrc index 3174932..ffc05e0 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,3 @@ { - "presets": ["es2015", "react", "stage-0"] + "presets": ["es2015", "react", "stage-0", "flow"] } \ No newline at end of file diff --git a/.flowconfig b/.flowconfig new file mode 100644 index 0000000..1fed445 --- /dev/null +++ b/.flowconfig @@ -0,0 +1,11 @@ +[ignore] + +[include] + +[libs] + +[lints] + +[options] + +[strict] diff --git a/package-lock.json b/package-lock.json index 801054e..47cee5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4571,6 +4571,12 @@ "integrity": "sha1-2uRqnXj74lKSJYzB54CkHZXAN4I=", "dev": true }, + "flow-bin": { + "version": "0.78.0", + "resolved": "https://registry.npmjs.org/flow-bin/-/flow-bin-0.78.0.tgz", + "integrity": "sha512-LV55tE+ItkC9HQAbEK+VxpBe54Ryp/dj4q9KmqDIfhV7mtP+hbvc/1AUf/AaWFIve3eURO0cxoGN4ZQQ3o2HTg==", + "dev": true + }, "follow-redirects": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.1.tgz", diff --git a/package.json b/package.json index d9a1bbc..5088eaf 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,9 @@ "build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/", "watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive", "up-version": "npm version major --force --message \"[ci skip] up version for release\"", - "precommit": "lint-staged" + "flow": "flow", + "precommit": "lint-staged", + "prepublish": "npm run build" }, "lint-staged": { "src/**/*.js": [ @@ -99,6 +101,7 @@ "babel-jest": "20.0.3", "babel-loader": "7.1.2", "babel-preset-es2015": "^6.24.1", + "babel-preset-flow": "^6.23.0", "babel-preset-react": "^6.24.1", "babel-preset-react-app": "^3.1.0", "babel-preset-stage-0": "^6.24.1", @@ -119,6 +122,7 @@ "eslint-plugin-react": "7.4.0", "extract-text-webpack-plugin": "3.0.2", "file-loader": "1.1.5", + "flow-bin": "^0.78.0", "fs-extra": "3.0.1", "html-webpack-plugin": "2.29.0", "husky": "^0.14.3", From 9421f075a8d945295d7a15ff433d48a75c7a00b6 Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Tue, 14 Aug 2018 21:11:24 +0200 Subject: [PATCH 02/17] [muzi] refactor slideInterval to be set by state and adding flow type checking :fist: --- package.json | 1 + src/components/react-swift-slider/Slider.js | 66 ++++++++++--------- .../react-swift-slider/types/Slide.Type.js | 12 ++++ .../react-swift-slider/types/Slider.Types.js | 23 +++++++ 4 files changed, 70 insertions(+), 32 deletions(-) create mode 100644 src/components/react-swift-slider/types/Slide.Type.js create mode 100644 src/components/react-swift-slider/types/Slider.Types.js diff --git a/package.json b/package.json index 5088eaf..94509fd 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive", "up-version": "npm version major --force --message \"[ci skip] up version for release\"", "flow": "flow", + "flow-test": "npm-run-all -p flow test", "precommit": "lint-staged", "prepublish": "npm run build" }, diff --git a/src/components/react-swift-slider/Slider.js b/src/components/react-swift-slider/Slider.js index 314f511..ec89317 100755 --- a/src/components/react-swift-slider/Slider.js +++ b/src/components/react-swift-slider/Slider.js @@ -1,23 +1,42 @@ -import React, { Component } from "react"; -import PropTypes from "prop-types"; -import "./assets/sass/react-swift-slider.css"; +// @flow +import * as React from "react"; +import "./assets/sass/react-swift-slider.css"; +import type { SliderProps, SliderState } from "./types/Slider.Types"; import Slide from "./Slide"; import Control from "./Control"; import Dot from "./Dot"; -export default class Slider extends Component { - constructor(props) { - super(props); - this.state = { - currentSlide: 0 - }; - this.slideInterval = setInterval(this.nextSlide, this.props.interval); +type Props = SliderProps; +type State = SliderState; + +export default class Slider extends React.Component { + static defaultProps = { + height: 450, + activeDotColor: "#e8784e", + interval: 5000, + dotColor: "#909192", + showDots: true, + enableNextAndPrev: true + }; + + state: State = { + currentSlide: 0 + }; + + componentDidMount() { + this.setState({ + slideInterval: setInterval(this.nextSlide, this.props.interval) + }); } + resetInterval = () => { - clearInterval(this.slideInterval); - this.slideInterval = setInterval(this.nextSlide, this.props.interval); + clearInterval(this.state.slideInterval); + this.setState({ + slideInterval: setInterval(this.nextSlide, this.props.interval) + }); }; + nextSlide = () => { if (this.state.currentSlide === this.props.data.length - 1) { this.setState({ @@ -43,12 +62,14 @@ export default class Slider extends Component { }); this.resetInterval(); }; - goToSlide = idx => { + + goToSlide = (idx: number) => { this.setState({ currentSlide: idx }); this.resetInterval(); }; + render() { const { data, @@ -99,22 +120,3 @@ export default class Slider extends Component { ); } } - -Slider.propTypes = { - data: PropTypes.array.isRequired, - height: PropTypes.number, - interval: PropTypes.number, - activeDotColor: PropTypes.string, - dotColor: PropTypes.string, - showDots: PropTypes.bool, - enableNextAndPrev: PropTypes.bool -}; - -Slider.defaultProps = { - height: 450, - activeDotColor: "#e8784e", - interval: 5000, - dotColor: "#909192", - showDots: true, - enableNextAndPrev: true -}; diff --git a/src/components/react-swift-slider/types/Slide.Type.js b/src/components/react-swift-slider/types/Slide.Type.js new file mode 100644 index 0000000..f6819c3 --- /dev/null +++ b/src/components/react-swift-slider/types/Slide.Type.js @@ -0,0 +1,12 @@ +// @flow + +/** + * Created by Muzikayise Flynn Buthelezi (zuluCoda) on 2018/08/14. + * Copyright mfbproject.co.za - muzi@mfbproject.co.za + * Copyright zulucoda - mfbproject + */ + +export type Slide = {| + id: string, + src: string +|}; diff --git a/src/components/react-swift-slider/types/Slider.Types.js b/src/components/react-swift-slider/types/Slider.Types.js new file mode 100644 index 0000000..6920bb2 --- /dev/null +++ b/src/components/react-swift-slider/types/Slider.Types.js @@ -0,0 +1,23 @@ +// @flow +/** + * Created by Muzikayise Flynn Buthelezi (zuluCoda) on 2018/08/14. + * Copyright mfbproject.co.za - muzi@mfbproject.co.za + * Copyright zulucoda - mfbproject + */ + +import type { Slide } from "./Slide.Type"; + +export type SliderProps = {| + data: Array, + height: number, + activeDotColor: string, + interval: number, + dotColor: string, + showDots: boolean, + enableNextAndPrev: boolean +|}; + +export type SliderState = {| + currentSlide: number, + slideInterval?: IntervalID +|}; From d3aa3aeeac36d702ed68b26c3a7818e903e2e2d7 Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Tue, 14 Aug 2018 21:18:32 +0200 Subject: [PATCH 03/17] [muzi] adding flow type checking to Slide :fist: --- src/components/react-swift-slider/Slide.js | 17 +++++++---------- .../react-swift-slider/types/Slide.Type.js | 5 +++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/components/react-swift-slider/Slide.js b/src/components/react-swift-slider/Slide.js index 35872b3..a4eee82 100755 --- a/src/components/react-swift-slider/Slide.js +++ b/src/components/react-swift-slider/Slide.js @@ -1,8 +1,12 @@ -import React, { Component } from "react"; -import PropTypes from "prop-types"; +// @flow + +import * as React from "react"; +import type { SlideProps } from "./types/Slide.Type"; import "./assets/sass/react-swift-slide.css"; -class Slide extends Component { +type Props = SlideProps; + +export default class Slide extends React.Component { render() { const { src, active } = this.props; const selectedClass = active @@ -16,10 +20,3 @@ class Slide extends Component { ); } } - -Slide.propTypes = { - src: PropTypes.string.isRequired, - active: PropTypes.bool.isRequired -}; - -export default Slide; diff --git a/src/components/react-swift-slider/types/Slide.Type.js b/src/components/react-swift-slider/types/Slide.Type.js index f6819c3..d736a9c 100644 --- a/src/components/react-swift-slider/types/Slide.Type.js +++ b/src/components/react-swift-slider/types/Slide.Type.js @@ -10,3 +10,8 @@ export type Slide = {| id: string, src: string |}; + +export type SlideProps = {| + src: string, + active: boolean +|}; From 31e99edde764a284d369d7c9696824746e1afb5a Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Tue, 14 Aug 2018 21:39:47 +0200 Subject: [PATCH 04/17] [muzi] adding flow type checking to Dot component :fist: --- src/components/react-swift-slider/Dot.js | 28 +++++++++++-------- src/components/react-swift-slider/Slide.js | 2 +- .../react-swift-slider/types/Dot.Types.js | 17 +++++++++++ .../types/{Slide.Type.js => Slide.Types.js} | 7 +++-- .../react-swift-slider/types/Slider.Types.js | 7 +++-- .../react-swift-slider/types/Types.js | 12 ++++++++ 6 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 src/components/react-swift-slider/types/Dot.Types.js rename src/components/react-swift-slider/types/{Slide.Type.js => Slide.Types.js} (74%) create mode 100644 src/components/react-swift-slider/types/Types.js diff --git a/src/components/react-swift-slider/Dot.js b/src/components/react-swift-slider/Dot.js index f4967d1..297ba5c 100755 --- a/src/components/react-swift-slider/Dot.js +++ b/src/components/react-swift-slider/Dot.js @@ -1,13 +1,19 @@ -import React from "react"; +// @flow +import * as React from "react"; +import type { DotProps } from "./types/Dot.Types"; import "./assets/sass/react-swift-dot.css"; -const Dot = ({ active, onClick, idx, activeDotColor, dotColor }) => { - return ( -
  • onClick(idx)} - style={{ background: active ? activeDotColor : dotColor }} - className="swift-slider-dot" - /> - ); -}; -export default Dot; +type Props = DotProps; + +export default class Dot extends React.Component { + render() { + const { active, onClick, idx, activeDotColor, dotColor } = this.props; + return ( +
  • onClick(idx)} + style={{ background: active ? activeDotColor : dotColor }} + className="swift-slider-dot" + /> + ); + } +} diff --git a/src/components/react-swift-slider/Slide.js b/src/components/react-swift-slider/Slide.js index a4eee82..806d75b 100755 --- a/src/components/react-swift-slider/Slide.js +++ b/src/components/react-swift-slider/Slide.js @@ -1,7 +1,7 @@ // @flow import * as React from "react"; -import type { SlideProps } from "./types/Slide.Type"; +import type { SlideProps } from "./types/Slide.Types"; import "./assets/sass/react-swift-slide.css"; type Props = SlideProps; diff --git a/src/components/react-swift-slider/types/Dot.Types.js b/src/components/react-swift-slider/types/Dot.Types.js new file mode 100644 index 0000000..aa58b67 --- /dev/null +++ b/src/components/react-swift-slider/types/Dot.Types.js @@ -0,0 +1,17 @@ +// @flow + +/** + * Created by Muzikayise Flynn Buthelezi (zuluCoda) on 2018/08/14. + * Copyright mfbproject.co.za - muzi@mfbproject.co.za + * Copyright zulucoda - mfbproject + */ + +import type { Active, ActiveDotColor, DotColor } from "./Types"; + +export type DotProps = { + activeDotColor: ActiveDotColor, + dotColor: DotColor, + active: Active, + onClick: Function, + idx: number +}; diff --git a/src/components/react-swift-slider/types/Slide.Type.js b/src/components/react-swift-slider/types/Slide.Types.js similarity index 74% rename from src/components/react-swift-slider/types/Slide.Type.js rename to src/components/react-swift-slider/types/Slide.Types.js index d736a9c..d4330c2 100644 --- a/src/components/react-swift-slider/types/Slide.Type.js +++ b/src/components/react-swift-slider/types/Slide.Types.js @@ -5,13 +5,14 @@ * Copyright mfbproject.co.za - muzi@mfbproject.co.za * Copyright zulucoda - mfbproject */ +import type { Active, Src } from "./Types"; export type Slide = {| id: string, - src: string + src: Src |}; export type SlideProps = {| - src: string, - active: boolean + src: Src, + active: Active |}; diff --git a/src/components/react-swift-slider/types/Slider.Types.js b/src/components/react-swift-slider/types/Slider.Types.js index 6920bb2..503be39 100644 --- a/src/components/react-swift-slider/types/Slider.Types.js +++ b/src/components/react-swift-slider/types/Slider.Types.js @@ -5,14 +5,15 @@ * Copyright zulucoda - mfbproject */ -import type { Slide } from "./Slide.Type"; +import type { ActiveDotColor, DotColor } from "./Types"; +import type { Slide } from "./Slide.Types"; export type SliderProps = {| data: Array, height: number, - activeDotColor: string, + activeDotColor: ActiveDotColor, interval: number, - dotColor: string, + dotColor: DotColor, showDots: boolean, enableNextAndPrev: boolean |}; diff --git a/src/components/react-swift-slider/types/Types.js b/src/components/react-swift-slider/types/Types.js new file mode 100644 index 0000000..06007f8 --- /dev/null +++ b/src/components/react-swift-slider/types/Types.js @@ -0,0 +1,12 @@ +// @flow + +/** + * Created by Muzikayise Flynn Buthelezi (zuluCoda) on 2018/08/14. + * Copyright mfbproject.co.za - muzi@mfbproject.co.za + * Copyright zulucoda - mfbproject + */ + +export type Src = string; +export type Active = boolean; +export type ActiveDotColor = string; +export type DotColor = string; From e13d0da5d33dad66a399e75fa4fd945514368863 Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Tue, 14 Aug 2018 21:59:58 +0200 Subject: [PATCH 05/17] [muzi] adding flow type checking on Control component :fist: --- src/components/react-swift-slider/Control.js | 25 ++++++++++++------- src/components/react-swift-slider/Dot.js | 1 + src/components/react-swift-slider/Slider.js | 6 ++--- .../react-swift-slider/types/Control.Types.js | 15 +++++++++++ .../react-swift-slider/types/Slider.Types.js | 1 + .../react-swift-slider/types/Types.js | 1 + 6 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 src/components/react-swift-slider/types/Control.Types.js diff --git a/src/components/react-swift-slider/Control.js b/src/components/react-swift-slider/Control.js index 2c218e8..e3f612e 100755 --- a/src/components/react-swift-slider/Control.js +++ b/src/components/react-swift-slider/Control.js @@ -1,16 +1,23 @@ -import React from "react"; +// @flow + +import * as React from "react"; +import type { ControlProps } from "./types/Control.Types"; import "./assets/sass/react-swift-control.css"; + export const DIRECTION = { prev: "prev", next: "next" }; -const Control = ({ onPressNext, onPressPrev, direction }) => { - if (direction === DIRECTION.prev) { - return
    ; - } else { - return
    ; - } -}; +type Props = ControlProps; -export default Control; +export default class Control extends React.Component { + render() { + const { onPressNext, onPressPrev, direction } = this.props; + if (direction === DIRECTION.prev) { + return
    ; + } else { + return
    ; + } + } +} diff --git a/src/components/react-swift-slider/Dot.js b/src/components/react-swift-slider/Dot.js index 297ba5c..c877353 100755 --- a/src/components/react-swift-slider/Dot.js +++ b/src/components/react-swift-slider/Dot.js @@ -1,4 +1,5 @@ // @flow + import * as React from "react"; import type { DotProps } from "./types/Dot.Types"; import "./assets/sass/react-swift-dot.css"; diff --git a/src/components/react-swift-slider/Slider.js b/src/components/react-swift-slider/Slider.js index ec89317..d1998fb 100755 --- a/src/components/react-swift-slider/Slider.js +++ b/src/components/react-swift-slider/Slider.js @@ -4,7 +4,7 @@ import * as React from "react"; import "./assets/sass/react-swift-slider.css"; import type { SliderProps, SliderState } from "./types/Slider.Types"; import Slide from "./Slide"; -import Control from "./Control"; +import Control, { DIRECTION } from "./Control"; import Dot from "./Dot"; type Props = SliderProps; @@ -107,12 +107,12 @@ export default class Slider extends React.Component { "" )} {enableNextAndPrev ? ( - + ) : ( "" )} {enableNextAndPrev ? ( - + ) : ( "" )} diff --git a/src/components/react-swift-slider/types/Control.Types.js b/src/components/react-swift-slider/types/Control.Types.js new file mode 100644 index 0000000..e51ac18 --- /dev/null +++ b/src/components/react-swift-slider/types/Control.Types.js @@ -0,0 +1,15 @@ +// @flow + +/** + * Created by Muzikayise Flynn Buthelezi (zuluCoda) on 2018/08/14. + * Copyright mfbproject.co.za - muzi@mfbproject.co.za + * Copyright zulucoda - mfbproject + */ + +import type { Direction } from "./Types"; + +export type ControlProps = {| + onPressNext?: Function, + onPressPrev?: Function, + direction: Direction +|}; diff --git a/src/components/react-swift-slider/types/Slider.Types.js b/src/components/react-swift-slider/types/Slider.Types.js index 503be39..38313e5 100644 --- a/src/components/react-swift-slider/types/Slider.Types.js +++ b/src/components/react-swift-slider/types/Slider.Types.js @@ -1,4 +1,5 @@ // @flow + /** * Created by Muzikayise Flynn Buthelezi (zuluCoda) on 2018/08/14. * Copyright mfbproject.co.za - muzi@mfbproject.co.za diff --git a/src/components/react-swift-slider/types/Types.js b/src/components/react-swift-slider/types/Types.js index 06007f8..b988adb 100644 --- a/src/components/react-swift-slider/types/Types.js +++ b/src/components/react-swift-slider/types/Types.js @@ -10,3 +10,4 @@ export type Src = string; export type Active = boolean; export type ActiveDotColor = string; export type DotColor = string; +export type Direction = "prev" | "next"; From 439d577aa5722cc5734b1bf78bec41a55df1900b Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Tue, 14 Aug 2018 22:06:02 +0200 Subject: [PATCH 06/17] [muzi] adding default empy array so that component does not crash when rended without data :fist: --- src/components/react-swift-slider/Slider.js | 1 + src/components/react-swift-slider/tests/slider.spec.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/components/react-swift-slider/Slider.js b/src/components/react-swift-slider/Slider.js index d1998fb..d7d5dc4 100755 --- a/src/components/react-swift-slider/Slider.js +++ b/src/components/react-swift-slider/Slider.js @@ -12,6 +12,7 @@ type State = SliderState; export default class Slider extends React.Component { static defaultProps = { + data: [], height: 450, activeDotColor: "#e8784e", interval: 5000, diff --git a/src/components/react-swift-slider/tests/slider.spec.js b/src/components/react-swift-slider/tests/slider.spec.js index 9b79b26..e3e0372 100644 --- a/src/components/react-swift-slider/tests/slider.spec.js +++ b/src/components/react-swift-slider/tests/slider.spec.js @@ -7,6 +7,7 @@ import React from "react"; import { shallow, mount } from "enzyme"; import Slider from "../Slider"; import { JSDOM } from "jsdom"; +import Slide from "../Slide"; const { document } = new JSDOM("").window; global.document = document; @@ -42,6 +43,10 @@ describe("Slider - Unit Test", () => { expect(wrapper.find(".swift-slider-slides").length).toEqual(1); }); + it("should NOT crash when rendered without data being set", () => { + shallow(); + }); + it("should go to position 4 when on the first slide when clicking on next", () => { const wrapper = mount(); expect(wrapper.state().currentSlide).toEqual(0); From 9bebe1140c46d64f9b3fbeb3e80d5a995c7f2e5c Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Tue, 14 Aug 2018 22:29:46 +0200 Subject: [PATCH 07/17] [muzi] excluded type files from coverage :fist: --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 94509fd..171314e 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "build-js": "node scripts/build.js", "start": "npm-run-all -p watch-css start-js", "build": "npm-run-all -p build-css build-js", - "lib": "babel src/components --out-dir lib --copy-files && rm -rf lib/react-swift-slider/tests", - "test": "node scripts/test.js --env=jsdom --coverage --collectCoverageFrom=src/components/**/*.js", + "lib": "babel src/components --out-dir lib --copy-files && rm -rf lib/react-swift-slider/tests && rm -rf lib/react-swift-slider/types", + "test": "node scripts/test.js --env=jsdom --coverage --collectCoverageFrom=src/components/**/*.js --collectCoverageFrom=!src/components/react-swift-slider/types/*.js", "prettier": "node_modules/.bin/prettier --write src/**/*.js", "coveralls": "cat ./coverage/lcov.info | node node_modules/.bin/coveralls", "build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/", From 8f7ac53f6eef413d15f288b73daa1ddb2d68c187 Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Tue, 14 Aug 2018 22:30:42 +0200 Subject: [PATCH 08/17] [muzi] new updates, with fixed interval using state and using flow type checking in code :fist: --- lib/react-swift-slider/Control.js | 46 ++++++++++++---- lib/react-swift-slider/Dot.js | 61 ++++++++++++++------ lib/react-swift-slider/Slide.js | 21 ++----- lib/react-swift-slider/Slider.js | 92 ++++++++++++++----------------- 4 files changed, 126 insertions(+), 94 deletions(-) diff --git a/lib/react-swift-slider/Control.js b/lib/react-swift-slider/Control.js index 5c83ead..bfaf76f 100755 --- a/lib/react-swift-slider/Control.js +++ b/lib/react-swift-slider/Control.js @@ -5,29 +5,53 @@ Object.defineProperty(exports, "__esModule", { }); exports.DIRECTION = undefined; +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + var _react = require("react"); -var _react2 = _interopRequireDefault(_react); +var React = _interopRequireWildcard(_react); require("./assets/sass/react-swift-control.css"); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var DIRECTION = exports.DIRECTION = { prev: "prev", next: "next" }; -var Control = function Control(_ref) { - var onPressNext = _ref.onPressNext, - onPressPrev = _ref.onPressPrev, - direction = _ref.direction; +var Control = function (_React$Component) { + _inherits(Control, _React$Component); - if (direction === DIRECTION.prev) { - return _react2.default.createElement("div", { className: "swift-slider-prev", onClick: onPressPrev }); - } else { - return _react2.default.createElement("div", { className: "swift-slider-next", onClick: onPressNext }); + function Control() { + _classCallCheck(this, Control); + + return _possibleConstructorReturn(this, (Control.__proto__ || Object.getPrototypeOf(Control)).apply(this, arguments)); } -}; + + _createClass(Control, [{ + key: "render", + value: function render() { + var _props = this.props, + onPressNext = _props.onPressNext, + onPressPrev = _props.onPressPrev, + direction = _props.direction; + + if (direction === DIRECTION.prev) { + return React.createElement("div", { className: "swift-slider-prev", onClick: onPressPrev }); + } else { + return React.createElement("div", { className: "swift-slider-next", onClick: onPressNext }); + } + } + }]); + + return Control; +}(React.Component); exports.default = Control; \ No newline at end of file diff --git a/lib/react-swift-slider/Dot.js b/lib/react-swift-slider/Dot.js index 104cd5e..e6c9c6e 100755 --- a/lib/react-swift-slider/Dot.js +++ b/lib/react-swift-slider/Dot.js @@ -4,27 +4,52 @@ Object.defineProperty(exports, "__esModule", { value: true }); +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + var _react = require("react"); -var _react2 = _interopRequireDefault(_react); +var React = _interopRequireWildcard(_react); require("./assets/sass/react-swift-dot.css"); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var Dot = function Dot(_ref) { - var active = _ref.active, - _onClick = _ref.onClick, - idx = _ref.idx, - activeDotColor = _ref.activeDotColor, - dotColor = _ref.dotColor; - - return _react2.default.createElement("li", { - onClick: function onClick() { - return _onClick(idx); - }, - style: { background: active ? activeDotColor : dotColor }, - className: "swift-slider-dot" - }); -}; +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var Dot = function (_React$Component) { + _inherits(Dot, _React$Component); + + function Dot() { + _classCallCheck(this, Dot); + + return _possibleConstructorReturn(this, (Dot.__proto__ || Object.getPrototypeOf(Dot)).apply(this, arguments)); + } + + _createClass(Dot, [{ + key: "render", + value: function render() { + var _props = this.props, + active = _props.active, + _onClick = _props.onClick, + idx = _props.idx, + activeDotColor = _props.activeDotColor, + dotColor = _props.dotColor; + + return React.createElement("li", { + onClick: function onClick() { + return _onClick(idx); + }, + style: { background: active ? activeDotColor : dotColor }, + className: "swift-slider-dot" + }); + } + }]); + + return Dot; +}(React.Component); + exports.default = Dot; \ No newline at end of file diff --git a/lib/react-swift-slider/Slide.js b/lib/react-swift-slider/Slide.js index 608375f..9bb0dd3 100755 --- a/lib/react-swift-slider/Slide.js +++ b/lib/react-swift-slider/Slide.js @@ -8,15 +8,11 @@ var _createClass = function () { function defineProperties(target, props) { for var _react = require("react"); -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require("prop-types"); - -var _propTypes2 = _interopRequireDefault(_propTypes); +var React = _interopRequireWildcard(_react); require("./assets/sass/react-swift-slide.css"); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -24,8 +20,8 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var Slide = function (_Component) { - _inherits(Slide, _Component); +var Slide = function (_React$Component) { + _inherits(Slide, _React$Component); function Slide() { _classCallCheck(this, Slide); @@ -41,7 +37,7 @@ var Slide = function (_Component) { active = _props.active; var selectedClass = active ? "swift-slider-slide swift-slider-active" : "swift-slider-slide"; - return _react2.default.createElement("li", { + return React.createElement("li", { className: selectedClass, style: { backgroundImage: "url(" + src + ")" } }); @@ -49,11 +45,6 @@ var Slide = function (_Component) { }]); return Slide; -}(_react.Component); - -Slide.propTypes = { - src: _propTypes2.default.string.isRequired, - active: _propTypes2.default.bool.isRequired -}; +}(React.Component); exports.default = Slide; \ No newline at end of file diff --git a/lib/react-swift-slider/Slider.js b/lib/react-swift-slider/Slider.js index fc91bab..114667c 100755 --- a/lib/react-swift-slider/Slider.js +++ b/lib/react-swift-slider/Slider.js @@ -8,11 +8,7 @@ var _createClass = function () { function defineProperties(target, props) { for var _react = require("react"); -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require("prop-types"); - -var _propTypes2 = _interopRequireDefault(_propTypes); +var React = _interopRequireWildcard(_react); require("./assets/sass/react-swift-slider.css"); @@ -30,26 +26,36 @@ var _Dot2 = _interopRequireDefault(_Dot); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var Slider = function (_Component) { - _inherits(Slider, _Component); +var Slider = function (_React$Component) { + _inherits(Slider, _React$Component); - function Slider(props) { - _classCallCheck(this, Slider); + function Slider() { + var _ref; - var _this = _possibleConstructorReturn(this, (Slider.__proto__ || Object.getPrototypeOf(Slider)).call(this, props)); + var _temp, _this, _ret; - _this.resetInterval = function () { - clearInterval(_this.slideInterval); - _this.slideInterval = setInterval(_this.nextSlide, _this.props.interval); - }; + _classCallCheck(this, Slider); - _this.nextSlide = function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Slider.__proto__ || Object.getPrototypeOf(Slider)).call.apply(_ref, [this].concat(args))), _this), _this.state = { + currentSlide: 0 + }, _this.resetInterval = function () { + clearInterval(_this.state.slideInterval); + _this.setState({ + slideInterval: setInterval(_this.nextSlide, _this.props.interval) + }); + }, _this.nextSlide = function () { if (_this.state.currentSlide === _this.props.data.length - 1) { _this.setState({ currentSlide: 0 @@ -60,9 +66,7 @@ var Slider = function (_Component) { currentSlide: _this.state.currentSlide + 1 }); _this.resetInterval(); - }; - - _this.prevSlide = function () { + }, _this.prevSlide = function () { if (_this.state.currentSlide === 0) { _this.setState({ currentSlide: _this.props.data.length - 1 @@ -73,23 +77,22 @@ var Slider = function (_Component) { currentSlide: _this.state.currentSlide - 1 }); _this.resetInterval(); - }; - - _this.goToSlide = function (idx) { + }, _this.goToSlide = function (idx) { _this.setState({ currentSlide: idx }); _this.resetInterval(); - }; - - _this.state = { - currentSlide: 0 - }; - _this.slideInterval = setInterval(_this.nextSlide, _this.props.interval); - return _this; + }, _temp), _possibleConstructorReturn(_this, _ret); } _createClass(Slider, [{ + key: "componentDidMount", + value: function componentDidMount() { + this.setState({ + slideInterval: setInterval(this.nextSlide, this.props.interval) + }); + } + }, { key: "render", value: function render() { var _this2 = this; @@ -102,25 +105,25 @@ var Slider = function (_Component) { showDots = _props.showDots, enableNextAndPrev = _props.enableNextAndPrev; - return _react2.default.createElement( + return React.createElement( "div", { className: "swift-slider-container" }, - _react2.default.createElement( + React.createElement( "ul", { className: "swift-slider-slides", style: { height: height } }, data.map(function (item, i) { - return _react2.default.createElement(_Slide2.default, { + return React.createElement(_Slide2.default, { active: i === _this2.state.currentSlide, src: item.src, key: item.id }); }) ), - showDots ? _react2.default.createElement( + showDots ? React.createElement( "ul", { className: "swift-slider-dots" }, data.map(function (item, i) { - return _react2.default.createElement(_Dot2.default, { + return React.createElement(_Dot2.default, { activeDotColor: activeDotColor, dotColor: dotColor, key: i, @@ -130,33 +133,22 @@ var Slider = function (_Component) { }); }) ) : "", - enableNextAndPrev ? _react2.default.createElement(_Control2.default, { onPressPrev: this.prevSlide, direction: "prev" }) : "", - enableNextAndPrev ? _react2.default.createElement(_Control2.default, { onPressNext: this.nextSlide, direction: "next" }) : "" + enableNextAndPrev ? React.createElement(_Control2.default, { onPressPrev: this.prevSlide, direction: _Control.DIRECTION.prev }) : "", + enableNextAndPrev ? React.createElement(_Control2.default, { onPressNext: this.nextSlide, direction: _Control.DIRECTION.next }) : "" ); } }]); return Slider; -}(_react.Component); - -exports.default = Slider; - - -Slider.propTypes = { - data: _propTypes2.default.array.isRequired, - height: _propTypes2.default.number, - interval: _propTypes2.default.number, - activeDotColor: _propTypes2.default.string, - dotColor: _propTypes2.default.string, - showDots: _propTypes2.default.bool, - enableNextAndPrev: _propTypes2.default.bool -}; +}(React.Component); Slider.defaultProps = { + data: [], height: 450, activeDotColor: "#e8784e", interval: 5000, dotColor: "#909192", showDots: true, enableNextAndPrev: true -}; \ No newline at end of file +}; +exports.default = Slider; \ No newline at end of file From f4a822d191db5cd0d9df545f1cd3e21e0e4cb154 Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Tue, 14 Aug 2018 22:50:46 +0200 Subject: [PATCH 09/17] [muzi] adding prop-types back to warn users when they try to use without correct props :fist: --- lib/react-swift-slider/Slider.js | 17 ++++++++++++++++- src/components/react-swift-slider/Slider.js | 11 +++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/react-swift-slider/Slider.js b/lib/react-swift-slider/Slider.js index 114667c..a9f99ee 100755 --- a/lib/react-swift-slider/Slider.js +++ b/lib/react-swift-slider/Slider.js @@ -12,6 +12,10 @@ var React = _interopRequireWildcard(_react); require("./assets/sass/react-swift-slider.css"); +var _propTypes = require("prop-types"); + +var _propTypes2 = _interopRequireDefault(_propTypes); + var _Slide = require("./Slide"); var _Slide2 = _interopRequireDefault(_Slide); @@ -151,4 +155,15 @@ Slider.defaultProps = { showDots: true, enableNextAndPrev: true }; -exports.default = Slider; \ No newline at end of file +exports.default = Slider; + + +Slider.propTypes = { + data: _propTypes2.default.array.isRequired, + height: _propTypes2.default.number, + interval: _propTypes2.default.number, + activeDotColor: _propTypes2.default.string, + dotColor: _propTypes2.default.string, + showDots: _propTypes2.default.bool, + enableNextAndPrev: _propTypes2.default.bool +}; \ No newline at end of file diff --git a/src/components/react-swift-slider/Slider.js b/src/components/react-swift-slider/Slider.js index d7d5dc4..395fc25 100755 --- a/src/components/react-swift-slider/Slider.js +++ b/src/components/react-swift-slider/Slider.js @@ -2,6 +2,7 @@ import * as React from "react"; import "./assets/sass/react-swift-slider.css"; +import PropTypes from "prop-types"; import type { SliderProps, SliderState } from "./types/Slider.Types"; import Slide from "./Slide"; import Control, { DIRECTION } from "./Control"; @@ -121,3 +122,13 @@ export default class Slider extends React.Component { ); } } + +Slider.propTypes = { + data: PropTypes.array.isRequired, + height: PropTypes.number, + interval: PropTypes.number, + activeDotColor: PropTypes.string, + dotColor: PropTypes.string, + showDots: PropTypes.bool, + enableNextAndPrev: PropTypes.bool +}; From 60deb93944f49b1c473cbe023e34bb4e319e560e Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Wed, 15 Aug 2018 18:13:25 +0200 Subject: [PATCH 10/17] [muzi] adding config to travis-ci to up-version and push back to PR after successful build :fist: --- .travis.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.travis.yml b/.travis.yml index 38ee3ea..057b434 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,15 @@ script: - npm run build after_script: # Upload coverage reports - COVERALLS_REPO_TOKEN=$coveralls_repo_token npm run coveralls + +after_success: | + if [ -n "$GITHUB_API_KEY" ]; then + git checkout $TRAVIS_PULL_REQUEST + npm run up-version + git -c user.name='travis' -c user.email='travis' + git push origin $TRAVIS_PULL_REQUEST + fi + notifications: email: on_success: change From 26240e1de2e222b0706b196b4d29eca29d64f0e3 Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Wed, 15 Aug 2018 18:48:12 +0200 Subject: [PATCH 11/17] [muzi] adding script to commit to github from travis-ci :fist: --- .travis.yml | 11 +++----- travis-ci-git-commit.sh | 62 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 travis-ci-git-commit.sh diff --git a/.travis.yml b/.travis.yml index 057b434..6c3a0e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,13 +10,10 @@ script: after_script: # Upload coverage reports - COVERALLS_REPO_TOKEN=$coveralls_repo_token npm run coveralls -after_success: | - if [ -n "$GITHUB_API_KEY" ]; then - git checkout $TRAVIS_PULL_REQUEST - npm run up-version - git -c user.name='travis' -c user.email='travis' - git push origin $TRAVIS_PULL_REQUEST - fi +after_success: + - npm run up-version + - ./travis-ci-git-commit.sh + notifications: email: diff --git a/travis-ci-git-commit.sh b/travis-ci-git-commit.sh new file mode 100644 index 0000000..fa70641 --- /dev/null +++ b/travis-ci-git-commit.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# function to make a commit on a branch in a Travis CI build +# be sure to avoid creating a Travis CI fork bomb +# see https://github.com/travis-ci/travis-ci/issues/1701 +function travis-branch-commit() { + local head_ref branch_ref + head_ref=$(git rev-parse HEAD) + if [[ $? -ne 0 || ! $head_ref ]]; then + err "failed to get HEAD reference" + return 1 + fi + branch_ref=$(git rev-parse "$TRAVIS_BRANCH") + if [[ $? -ne 0 || ! $branch_ref ]]; then + err "failed to get $TRAVIS_BRANCH reference" + return 1 + fi + if [[ $head_ref != $branch_ref ]]; then + msg "HEAD ref ($head_ref) does not match $TRAVIS_BRANCH ref ($branch_ref)" + msg "someone may have pushed new commits before this build cloned the repo" + return 0 + fi + if ! git checkout "$TRAVIS_BRANCH"; then + err "failed to checkout $TRAVIS_BRANCH" + return 1 + fi + + if ! git add --all .; then + err "failed to add modified files to git index" + return 1 + fi + # make Travis CI skip this build + if ! git commit -m "Travis CI update [ci skip]"; then + err "failed to commit updates" + return 1 + fi + # add to your .travis.yml: `branches\n except:\n - "/\\+travis\\d+$/"\n` + local git_tag=SOME_TAG_TRAVIS_WILL_NOT_BUILD+travis$TRAVIS_BUILD_NUMBER + if ! git tag "$git_tag" -m "Generated tag from Travis CI build $TRAVIS_BUILD_NUMBER"; then + err "failed to create git tag: $git_tag" + return 1 + fi + local remote=origin + if [[ $GITHUB_API_KEY ]]; then + remote=https://$GITHUB_API_KEY@github.com/$TRAVIS_REPO_SLUG + fi + if [[ $TRAVIS_BRANCH != master ]]; then + msg "not pushing updates to branch $TRAVIS_BRANCH" + return 0 + fi + if ! git push --quiet --follow-tags "$remote" "$TRAVIS_BRANCH" > /dev/null 2>&1; then + err "failed to push git changes" + return 1 + fi +} + +function msg() { + echo "travis-commit: $*" +} + +function err() { + msg "$*" 1>&2 +} \ No newline at end of file From 01b1d98a377e34843ed053c1102a34ed5dfe490c Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Wed, 15 Aug 2018 18:58:32 +0200 Subject: [PATCH 12/17] [muzi] call travis-branch-commit() --- travis-ci-git-commit.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/travis-ci-git-commit.sh b/travis-ci-git-commit.sh index fa70641..79a8036 100644 --- a/travis-ci-git-commit.sh +++ b/travis-ci-git-commit.sh @@ -59,4 +59,6 @@ function msg() { function err() { msg "$*" 1>&2 -} \ No newline at end of file +} + +travis-branch-commit \ No newline at end of file From a2cf20b94be1512a427c9d93040839a065c84b44 Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Wed, 15 Aug 2018 19:05:07 +0200 Subject: [PATCH 13/17] [muzi] give permission to commit script :fist: --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 6c3a0e3..adb1c2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,10 @@ node_js: cache: directories: - node_modules + +before_script: + - chmod +x travis-ci-git-commit.sh + script: - npm test - npm run build From fd4e6b34873a1eb13a38dabf6050d45eeab6a2e4 Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Wed, 15 Aug 2018 19:11:45 +0200 Subject: [PATCH 14/17] [muzi] no need to compare head_ref :fist: --- travis-ci-git-commit.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/travis-ci-git-commit.sh b/travis-ci-git-commit.sh index 79a8036..679565a 100644 --- a/travis-ci-git-commit.sh +++ b/travis-ci-git-commit.sh @@ -14,11 +14,11 @@ function travis-branch-commit() { err "failed to get $TRAVIS_BRANCH reference" return 1 fi - if [[ $head_ref != $branch_ref ]]; then - msg "HEAD ref ($head_ref) does not match $TRAVIS_BRANCH ref ($branch_ref)" - msg "someone may have pushed new commits before this build cloned the repo" - return 0 - fi + #if [[ $head_ref != $branch_ref ]]; then + # msg "HEAD ref ($head_ref) does not match $TRAVIS_BRANCH ref ($branch_ref)" + # msg "someone may have pushed new commits before this build cloned the repo" + # return 0 + #fi if ! git checkout "$TRAVIS_BRANCH"; then err "failed to checkout $TRAVIS_BRANCH" return 1 From 3fd7901ffcf244084842db5b4128765be00771ad Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Wed, 15 Aug 2018 19:32:52 +0200 Subject: [PATCH 15/17] [muzi] adding debug info :fist: --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index adb1c2a..f2b7903 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,9 @@ after_script: # Upload coverage reports after_success: - npm run up-version + - git status + - git branch + - echo $TRAVIS_BRANCH - ./travis-ci-git-commit.sh From f58d0a4490a92c2699b7f5b187ff5dd698b4b5bd Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Wed, 15 Aug 2018 19:39:13 +0200 Subject: [PATCH 16/17] [muzi] update permissions :fist: --- travis-ci-git-commit.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) mode change 100644 => 100755 travis-ci-git-commit.sh diff --git a/travis-ci-git-commit.sh b/travis-ci-git-commit.sh old mode 100644 new mode 100755 index 679565a..79a8036 --- a/travis-ci-git-commit.sh +++ b/travis-ci-git-commit.sh @@ -14,11 +14,11 @@ function travis-branch-commit() { err "failed to get $TRAVIS_BRANCH reference" return 1 fi - #if [[ $head_ref != $branch_ref ]]; then - # msg "HEAD ref ($head_ref) does not match $TRAVIS_BRANCH ref ($branch_ref)" - # msg "someone may have pushed new commits before this build cloned the repo" - # return 0 - #fi + if [[ $head_ref != $branch_ref ]]; then + msg "HEAD ref ($head_ref) does not match $TRAVIS_BRANCH ref ($branch_ref)" + msg "someone may have pushed new commits before this build cloned the repo" + return 0 + fi if ! git checkout "$TRAVIS_BRANCH"; then err "failed to checkout $TRAVIS_BRANCH" return 1 From 21bc965d6e8156547ea4578f82e176dc2fe81513 Mon Sep 17 00:00:00 2001 From: "Muzikayise Flynn Buthelezi (zulucoda)" Date: Wed, 15 Aug 2018 19:39:56 +0200 Subject: [PATCH 17/17] [muzi] remove before_script command :fist: --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index f2b7903..2e1f370 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,6 @@ cache: directories: - node_modules -before_script: - - chmod +x travis-ci-git-commit.sh - script: - npm test - npm run build