From 08f117c610a309f84522d69d1f3ca91be966bc93 Mon Sep 17 00:00:00 2001 From: Martin Walter Date: Mon, 3 Dec 2018 16:15:44 +0100 Subject: [PATCH 1/9] [QPE-402] First take on build pipeline --- .circleci/config.yml | 94 ++++++++++++++++++ .editorconfig | 10 ++ .eslintrc.js | 63 ++++++++++++ .gitattributes | 12 +++ .gitignore | 6 +- .npmrc | 1 + LICENSE | 22 ++++ PLSmartPivot.qext | 9 -- README.md | 74 +++++++------- assets/qlik-smart-pivot.qext | 16 +++ assets/wbfolder.wbl | 3 + gulpfile.js | 75 ++++++++++++++ karma.conf.js | 43 ++++++++ package.json | 47 +++++++++ Accounts.csv => resources/Accounts.csv | 0 Accounts2.csv => resources/Accounts2.csv | 0 Excel.png => resources/Excel.png | Bin .../P&LSmartPivot_demo.qvf | Bin ... Sense P&LSmart Pivot Extension Manual.pdf | Bin QlikLook.csv => resources/QlikLook.csv | 0 scripts/bump-version.sh | 32 ++++++ scripts/create-release.sh | 10 ++ scripts/get-bumped-version.sh | 7 ++ scripts/get-latest-version.sh | 17 ++++ scripts/install-ghr.sh | 12 +++ settings.js | 13 +++ PLSmartPivot.css => src/PLSmartPivot.css | 0 PLSmartPivot.js => src/PLSmartPivot.js | 0 PLSmartPivot.less => src/PLSmartPivot.less | 0 stylelint.config.js | 35 +++++++ wbfolder.wbl | 3 - webpack.config.js | 63 ++++++++++++ 32 files changed, 619 insertions(+), 48 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 .editorconfig create mode 100644 .eslintrc.js create mode 100644 .npmrc create mode 100644 LICENSE delete mode 100644 PLSmartPivot.qext create mode 100644 assets/qlik-smart-pivot.qext create mode 100644 assets/wbfolder.wbl create mode 100644 gulpfile.js create mode 100644 karma.conf.js create mode 100644 package.json rename Accounts.csv => resources/Accounts.csv (100%) rename Accounts2.csv => resources/Accounts2.csv (100%) rename Excel.png => resources/Excel.png (100%) rename P&LSmartPivot_demo.qvf => resources/P&LSmartPivot_demo.qvf (100%) rename Qlik Sense P&LSmart Pivot Extension Manual.pdf => resources/Qlik Sense P&LSmart Pivot Extension Manual.pdf (100%) rename QlikLook.csv => resources/QlikLook.csv (100%) create mode 100755 scripts/bump-version.sh create mode 100755 scripts/create-release.sh create mode 100755 scripts/get-bumped-version.sh create mode 100755 scripts/get-latest-version.sh create mode 100755 scripts/install-ghr.sh create mode 100644 settings.js rename PLSmartPivot.css => src/PLSmartPivot.css (100%) rename PLSmartPivot.js => src/PLSmartPivot.js (100%) rename PLSmartPivot.less => src/PLSmartPivot.less (100%) create mode 100644 stylelint.config.js delete mode 100644 wbfolder.wbl create mode 100644 webpack.config.js diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..040ea5c --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,94 @@ +version: 2 + +defaults: &defaults + working_directory: ~/qlik-smart-pivot + docker: + - image: circleci/node:stretch + environment: + GITHUB_ORG: "qlik-oss" + GITHUB_REPO: "PLSmartPivot" + PACKAGE_NAME: "qlik-smart-pivot" + +jobs: + test: + docker: + - image: circleci/node:stretch-browsers + steps: + - checkout + - run: + name: Install dependencies + command: npm install + - run: + name: Run tests + command: npm run test-once + + bump-version: + <<: *defaults + steps: + - checkout + - run: + name: Bump version + command: scripts/bump-version.sh $GITHUB_ORG $GITHUB_REPO + - persist_to_workspace: + root: ~/qlik-smart-pivot + paths: + - BUMPED_VERSION + + build: + <<: *defaults + steps: + - checkout + - attach_workspace: + at: ~/qlik-smart-pivot + - run: + name: Install dependencies + command: npm install + - run: + name: Build and package + command: | + export VERSION=$(scripts/get-bumped-version.sh) + echo "Version: ${VERSION}" + npm run build + environment: + NODE_ENV: production + - persist_to_workspace: + root: ~/qlik-smart-pivot + paths: + - build + - store_artifacts: + path: build + destination: build + deploy: + <<: *defaults + steps: + - checkout + - attach_workspace: + at: ~/qlik-smart-pivot + - run: + name: Install ghr + command: scripts/install-ghr.sh + - run: + name: Create GitHub Release + command: | + export VERSION=$(scripts/get-bumped-version.sh) + echo "Version: ${VERSION}" + scripts/create-release.sh $GITHUB_ORG $GITHUB_REPO $PACKAGE_NAME $VERSION + +workflows: + version: 2 + master_flow: + jobs: + - test + - bump-version: + requires: + - test + - build: + requires: + - bump-version + - deploy: + requires: + - build + filters: + branches: + only: + - master diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0f09989 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +# editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..8ffb3ec --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,63 @@ +module.exports = { + parserOptions: { + ecmaVersion: 6, + ecmaFeatures: { + jsx: true, + modules: true + }, + sourceType: "module" + }, + parser: "babel-eslint", + env: { + browser: true, + es6: true, + node: true + }, + globals: { + angular: false, + define: false, + describe: false, + document: false, + expect: false, + it: false, + require: false + }, + rules: { + "indent": ["error", 2, { "SwitchCase": 1 }], + "linebreak-style": ["error", "unix"], + "object-curly-spacing": ["error", "always"], + "max-lines": ["warn", 300], + "max-len": ["warn", { "code": 120, "ignoreComments": true, "ignoreTrailingComments": false }], + "no-console": ["warn"], + "no-mixed-operators": ["warn", { + "groups": [ + ["==", "!=", "===", "!==", ">", ">=", "<", "<="], + ["&&", "||"], + ["in", "instanceof"] + ], + "allowSamePrecedence": true + }], + "no-multi-spaces": ["error"], + "no-cond-assign": ["warn"], + "no-fallthrough": ["warn"], + "no-undef": ["error"], + "no-unused-vars": ["error"], + "no-use-before-define": ["warn", { "functions": false, "classes": false, "variables": false }], + "no-useless-escape": ["warn"], + "no-useless-return": ["warn"], + "no-underscore-dangle": ["warn", { "allow": ["_id"] }], + "no-redeclare": ["warn"], + "no-restricted-syntax": ["warn"], + "operator-linebreak": ["warn", "before"], + "prefer-promise-reject-errors": ["warn"], + "padded-blocks": ["warn", { "blocks": "never", "switches": "never", "classes": "never" }], + "semi": ["error", "always"], + "valid-typeof": ["warn"], + "no-eval": ["error"], + "no-implied-eval": ["error"], + "no-debugger": ["warn"], + }, + extends: [ + "eslint:recommended" + ] +} diff --git a/.gitattributes b/.gitattributes index bdb0cab..99b2250 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,3 +15,15 @@ *.PDF diff=astextplain *.rtf diff=astextplain *.RTF diff=astextplain + +* text=auto +.* text eol=lf +*.css text eol=lf +*.scss text eol=lf +*.html text eol=lf +*.js text eol=lf +*.json text eol=lf +*.md text eol=lf +*.sh text eol=lf +*.txt text eol=lf +*.svg text eol=lf diff --git a/.gitignore b/.gitignore index 4a280d0..93bc251 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,11 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk +# Temporary build files +node_modules/ +build/ +BUMPED_VERSION + # ========================= # Operating System Files # ========================= @@ -41,4 +46,3 @@ $RECYCLE.BIN/ Network Trash Folder Temporary Items .apdisk -dist/ diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..cffe8cd --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +save-exact=true diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bedfada --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License + +Copyright (c) 2018-present QlikTech International AB +Copyright (c) 2016-2018 Ivan Felipe Asensio + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/PLSmartPivot.qext b/PLSmartPivot.qext deleted file mode 100644 index d21dfd7..0000000 --- a/PLSmartPivot.qext +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name" : "P&L Smart Pivot", - "description" : "Formatted table for P&L reports", - "icon" : "table", - "type" : "visualization", - "version": "1.0", - "preview" : "table", - "author": "Ivan Felipe - QlikTech Iberia" -} \ No newline at end of file diff --git a/README.md b/README.md index ee12ac9..dca75c6 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,6 @@ -P&L Smart Pivot, a Qlik Sense Extension for Financial reporting - -============================= -================================== - -Available in https://github.com/iviasensio/PLSmartPivot - -Current version 2.1. Compatible with QS Sep 2017 -(from sep'17 color-picker is no more an integer but an object) - -Based on P&LSmart. - -Author Ivan Felipe Asensio QlikTech Iberia,s.l. - - - -This extension is useful to create reports where the look&feel is rellevantand and pivot a second dimension is needed. - +# P&L Smart Pivot, a Qlik Sense Extension for Financial reporting +This extension is useful to create reports where the look&feel is rellevantand and pivot a second dimension is needed. Based on P&L Smart. It's specifically focused on financial reports, trying to solve some common needs of this area: - smart export to excel @@ -25,28 +9,48 @@ It's specifically focused on financial reports, trying to solve some common need - selections inside the reports - custom external templates - analytical reports -- ... - -You'll find a manual 'P&LSmart Pivot Extension Manual.pdf' and one app example 'P&LSmartPivot_demo.qvf - -'. +# Manual +You'll find a manual [Qlik Sense P&LSmart Pivot Extension Manual.pdf](resources/Qlik Sense P&LSmart Pivot Extension Manual.pdf) and one app example [P&LSmartPivot_demo.qvf](resources/P&LSmartPivot_demo.qvf). - -*Install in Server: -- before import the extension from the server remember to remove all the non functional files. -- remove: -.gitattributes, -.gitignore, P&LSmartPivot_demo.qvf, 'Qlik Sense P&LSmart Pivot Extension Manual.pdf' +# If the import does not work at first time +- remove [Accounts.csv](resources/Accounts.csv), [Accounts2.csv](resources/Accounts2.csv) and [Excel.png](resources/Excel.png), zip it again and import. +- Then reintroduce [Accounts.csv](resources/Accounts.csv), [Accounts2.csv](resources/Accounts2.csv) and [Excel.png](resources/Excel.png), zip it again and import. -**If the import does not work at first time: -- remove Accounts.csv, Accounts2.csv and Excel.png, zip it again and import. -- Then reintroduce Accounts.csv, Accounts2.csv and Excel.png, zip it again and import. +# Installation + +1. Download the extension zip, `qlik-smart-pivot_.zip`, from the latest release(https://github.com/qlik-oss/PLSmartPivot/releases/latest) +2. Install the extension: + + a. **Qlik Sense Desktop**: unzip to a directory under [My Documents]/Qlik/Sense/Extensions. + + b. **Qlik Sense Server**: import the zip file in the QMC. -*Install in Desktop -- unzip and copy the folder in C:\Users\'username'\Documents\Qlik\Sense\Extensions -- copy the example P&LSmartPivot_demo.qvf in C:\Users\'username'\Documents\Qlik\Sense\Apps +# Developing the extension + +If you want to do code changes to the extension follow these simple steps to get going. + +1. Get Qlik Sense Desktop +1. Create a new app and add the extension to a sheet. +2. Clone the repository +3. Run `npm install` +4. Set the environment variable `BUILD_PATH` to your extensions directory. It will be something like `C:/Users//Documents/Qlik/Sense/Extensions/`. +5. You now have two options. Either run the watch task or the build task. They are explained below. Both of them default to development mode but can be run in production by setting `NODE_ENV=production` before running the npm task. + + a. **Watch**: `npm run watch`. This will start a watcher which will rebuild the extension and output all needed files to the `buildFolder` for each code change you make. See your changes directly in your Qlik Sense app. + + b. **Build**: `npm run build`. If you want to build the extension package. The output zip-file can be found in the `buildFolder`. + + +# Original authors + +[github.com/iviasensio](https://github.com/iviasensio) + + +# License + +Released under the [MIT License](LICENSE). \ No newline at end of file diff --git a/assets/qlik-smart-pivot.qext b/assets/qlik-smart-pivot.qext new file mode 100644 index 0000000..c980707 --- /dev/null +++ b/assets/qlik-smart-pivot.qext @@ -0,0 +1,16 @@ +{ + "name": "Smart pivot", + "description": "Formatted table for P&L reports.", + "type": "visualization", + "version": "X.Y.Z", + "icon": "table", + "preview": "", + "author": "Ivan Felipe Asensio ", + "homepage": "", + "keywords": "qlik-sense, visualization", + "license": "MIT", + "repository": "https://github.com/qlik-oss/PLSmartPivot", + "dependencies": { + "qlik-sense": ">=5.5.x" + } +} diff --git a/assets/wbfolder.wbl b/assets/wbfolder.wbl new file mode 100644 index 0000000..534e695 --- /dev/null +++ b/assets/wbfolder.wbl @@ -0,0 +1,3 @@ +qlik-smart-pivot.js; +qlik-smart-pivot.css; +qlik-smart-pivot.qext \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..eebe98b --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,75 @@ +var gulp = require('gulp'); +var zip = require('gulp-zip'); +var del = require('del'); +var path = require('path'); +var settings = require('./settings'); +var webpackConfig = require('./webpack.config'); +var webpack = require('webpack'); +var WebpackDevServer = require('webpack-dev-server'); +var jeditor = require("gulp-json-editor"); + +var srcFiles = path.resolve('./src/**/*.*'); + +gulp.task('remove-build-folder', function(){ + return del([settings.buildDestination], { force: true }); +}); + +gulp.task('zip-build', function(){ + return gulp.src(settings.buildDestination + '/**/*') + .pipe(zip(`${settings.name}_${settings.version}.zip`)) + .pipe(gulp.dest(settings.buildDestination)); +}); + +gulp.task('webpack-build', done => { + webpack(webpackConfig, (error, statistics) => { + const compilationErrors = statistics && statistics.compilation.errors; + const hasCompilationErrors = !statistics || (compilationErrors && compilationErrors.length > 0); + + console.log(statistics && statistics.toString({ chunks: false, colors: true })); // eslint-disable-line no-console + + if (error || hasCompilationErrors) { + console.log('Build has errors or eslint errors, fail it'); // eslint-disable-line no-console + process.exit(1); + } + + done(); + }); +}); + +gulp.task('update-qext-version', function () { + return gulp.src(`${settings.buildDestination}/${settings.name}.qext`) + .pipe(jeditor({ + 'version': settings.version + })) + .pipe(gulp.dest(settings.buildDestination)); +}); + +gulp.task('build', + gulp.series('remove-build-folder', 'webpack-build', 'update-qext-version', 'zip-build') +); + +gulp.task('default', + gulp.series('build') +); + +gulp.task('watch', () => new Promise((resolve, reject) => { + webpackConfig.entry.unshift('webpack-dev-server/client?http://localhost:' + settings.port); + const compiler = webpack(webpackConfig); + const originalOutputFileSystem = compiler.outputFileSystem; + const devServer = new WebpackDevServer(compiler, { + headers: { + "Access-Control-Allow-Origin": "*" + }, + }).listen(settings.port, 'localhost', error => { + compiler.outputFileSystem = originalOutputFileSystem; + if (error) { + console.error(error); // eslint-disable-line no-console + return reject(error); + } + + // eslint-disable-next-line no-console + console.log('Listening at localhost:' + settings.port); + + resolve(null, devServer); + }); +})); diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000..13a8708 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,43 @@ +const settings = require('./settings'); + +module.exports = (config) => { + config.set({ + browsers: ['SlimChromeHeadless'], + customLaunchers: { + SlimChromeHeadless: { + base: 'ChromeHeadless', + flags: ['--headless', '--disable-gpu', '--disable-translate', '--disable-extensions'] + } + }, + files: [ + { pattern: 'src/*.spec.js', watched: false } + ], + frameworks: ['jasmine'], + preprocessors: { + 'src/*.spec.js': ['webpack', 'sourcemap'] + }, + webpack: { + devtool: 'source-map', + mode: settings.mode, + externals: { + jquery: { + amd: 'jquery', + commonjs: 'jquery', + commonjs2: 'jquery', + root: '_' + }, + }, + module: { + rules: [ + { + test: /\.js$/, + exclude: [/node_modules/], + loaders: ['babel-loader'] + }, + { test: /\.less$/, loader: 'ignore-loader' }, + { test: /\.json$/, loader: 'ignore-loader' } + ] + } + } + }); +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..4f063de --- /dev/null +++ b/package.json @@ -0,0 +1,47 @@ +{ + "name": "qlik-smart-pivot", + "version": "0.0.1", + "description": "Formatted table for P&L reports.", + "keywords": "smart pivot qliksense extension", + "repository": "https://github.com/iviasensio/PLSmartPivot", + "author": "Ivan Felipe Asensio ", + "license": "MIT", + "scripts": { + "build": "gulp build", + "eslint": "eslint src", + "eslint:fix": "eslint --fix src", + "test": "karma start karma.conf.js", + "test-once": "karma start karma.conf.js --single-run", + "watch": "gulp watch" + }, + "devDependencies": { + "@babel/core": "7.1.2", + "@babel/polyfill": "7.0.0", + "@babel/preset-env": "7.1.0", + "babel-eslint": "10.0.1", + "babel-loader": "8.0.4", + "copy-webpack-plugin": "4.5.3", + "css-loader": "1.0.0", + "del": "2.0.2", + "eslint": "5.7.0", + "eslint-loader": "2.1.1", + "gulp": "4.0.0", + "gulp-json-editor": "2.4.3", + "gulp-zip": "3.0.2", + "jasmine-core": "3.2.1", + "jquery": "3.3.1", + "karma": "3.0.0", + "karma-chrome-launcher": "2.2.0", + "karma-jasmine": "1.1.2", + "karma-sourcemap-loader": "0.3.7", + "karma-webpack": "3.0.5", + "less": "3.8.1", + "less-loader": "4.1.0", + "style-loader": "0.23.1", + "stylelint": "8.4.0", + "stylelint-webpack-plugin": "0.10.5", + "webpack": "4.20.2", + "webpack-cli": "3.1.2", + "webpack-dev-server": "3.1.10" + } +} diff --git a/Accounts.csv b/resources/Accounts.csv similarity index 100% rename from Accounts.csv rename to resources/Accounts.csv diff --git a/Accounts2.csv b/resources/Accounts2.csv similarity index 100% rename from Accounts2.csv rename to resources/Accounts2.csv diff --git a/Excel.png b/resources/Excel.png similarity index 100% rename from Excel.png rename to resources/Excel.png diff --git a/P&LSmartPivot_demo.qvf b/resources/P&LSmartPivot_demo.qvf similarity index 100% rename from P&LSmartPivot_demo.qvf rename to resources/P&LSmartPivot_demo.qvf diff --git a/Qlik Sense P&LSmart Pivot Extension Manual.pdf b/resources/Qlik Sense P&LSmart Pivot Extension Manual.pdf similarity index 100% rename from Qlik Sense P&LSmart Pivot Extension Manual.pdf rename to resources/Qlik Sense P&LSmart Pivot Extension Manual.pdf diff --git a/QlikLook.csv b/resources/QlikLook.csv similarity index 100% rename from QlikLook.csv rename to resources/QlikLook.csv diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh new file mode 100755 index 0000000..b402988 --- /dev/null +++ b/scripts/bump-version.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -o errexit + +join_by () { + local IFS="$1"; shift; echo "$*"; +} + +if [ "${CIRCLE_BRANCH}" == "master" ]; then + # get version from repo + OLD_VERSION="$(scripts/get-latest-version.sh $1 $2)" + echo "Latest GitHub release version: ${OLD_VERSION}" + + # split into array + IFS='.' read -ra ARRAY_VERSION <<< "$OLD_VERSION" + + # bump minor + ARRAY_VERSION[1]=$((ARRAY_VERSION[1]+1)) + + # join into string + NEW_VERSION=$(join_by . ${ARRAY_VERSION[@]}) +elif [[ ! -z "${CIRCLE_BRANCH}" && ! -z "${CIRCLE_BUILD_NUM}" ]]; then + NEW_VERSION="$(echo ${CIRCLE_BRANCH} | sed -e 's/\//-/g')_${CIRCLE_BUILD_NUM}" +else + NEW_VERSION="dev" +fi + +echo "Bumped version: ${NEW_VERSION}" +echo "${NEW_VERSION}" > BUMPED_VERSION + + +# Usage +# $ bump-version.sh qlik-oss qsSimpleKPI diff --git a/scripts/create-release.sh b/scripts/create-release.sh new file mode 100755 index 0000000..c034212 --- /dev/null +++ b/scripts/create-release.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -o errexit + +echo "Creating release for version: $VERSION" +echo "Artifact name: ./build/${3}_${VERSION}.zip" +$HOME/bin/ghr -t ${ghoauth} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${VERSION} "./build/${3}_${4}.zip" + + +# Usage +# $ create-release.sh qlik-oss qsSimpleKPI qlik-multi-kpi 0.3.1 diff --git a/scripts/get-bumped-version.sh b/scripts/get-bumped-version.sh new file mode 100755 index 0000000..f8209f4 --- /dev/null +++ b/scripts/get-bumped-version.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -o errexit + +echo "$(head -n 1 BUMPED_VERSION)" + +# Usage +# $ get-bumped-version.sh diff --git a/scripts/get-latest-version.sh b/scripts/get-latest-version.sh new file mode 100755 index 0000000..ace3e43 --- /dev/null +++ b/scripts/get-latest-version.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -o errexit + +VERSION=$(curl --silent "https://api.github.com/repos/$1/$2/releases/latest" | # Get latest release from GitHub api + grep '"tag_name":' | # Get tag line + sed -E 's/.*"([^"]+)".*/\1/') # Pluck JSON value + +if [ -z "${VERSION}" ]; then + VERSION="0.1.0" +fi + +echo "${VERSION}" + +### Inspired by https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c +# Usage +# $ get-latest-version.sh qlik-oss qsSimpleKPI +# 0.12.0 diff --git a/scripts/install-ghr.sh b/scripts/install-ghr.sh new file mode 100755 index 0000000..68d9648 --- /dev/null +++ b/scripts/install-ghr.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -o errexit -o verbose + +URL="https://github.com/tcnksm/ghr/releases/download/v0.5.4/ghr_v0.5.4_linux_386.zip" +echo "Version to install: $URL" + +echo "Installing ghr" +curl -L ${URL} > ghr.zip +mkdir -p "$HOME/bin" +export PATH="$HOME/bin:$PATH" +unzip ghr.zip -d "$HOME/bin" +rm ghr.zip diff --git a/settings.js b/settings.js new file mode 100644 index 0000000..842ebc1 --- /dev/null +++ b/settings.js @@ -0,0 +1,13 @@ +const path = require('path'); +const packageJSON = require('./package.json'); + +const defaultBuildDestination = path.resolve("./build"); + +module.exports = { + buildDestination: process.env.BUILD_PATH || defaultBuildDestination, + mode: process.env.NODE_ENV || 'development', + name: packageJSON.name, + version: process.env.VERSION || 'local-dev', + url: process.env.BUILD_URL || defaultBuildDestination, + port: process.env.PORT || 8085 +}; diff --git a/PLSmartPivot.css b/src/PLSmartPivot.css similarity index 100% rename from PLSmartPivot.css rename to src/PLSmartPivot.css diff --git a/PLSmartPivot.js b/src/PLSmartPivot.js similarity index 100% rename from PLSmartPivot.js rename to src/PLSmartPivot.js diff --git a/PLSmartPivot.less b/src/PLSmartPivot.less similarity index 100% rename from PLSmartPivot.less rename to src/PLSmartPivot.less diff --git a/stylelint.config.js b/stylelint.config.js new file mode 100644 index 0000000..2cdb4a0 --- /dev/null +++ b/stylelint.config.js @@ -0,0 +1,35 @@ +"use strict"; + +module.exports = { + rules: { + "at-rule-no-unknown": true, + "block-no-empty": true, + "color-no-invalid-hex": true, + "comment-no-empty": true, + "declaration-block-no-duplicate-properties": [ + true, + { + ignore: ["consecutive-duplicates-with-different-values"] + } + ], + "declaration-block-no-shorthand-property-overrides": true, + "font-family-no-duplicate-names": true, + "font-family-no-missing-generic-family-keyword": true, + "function-calc-no-unspaced-operator": true, + "function-linear-gradient-no-nonstandard-direction": true, + "keyframe-declaration-no-important": true, + "media-feature-name-no-unknown": true, + "no-descending-specificity": true, + "no-duplicate-at-import-rules": true, + "no-duplicate-selectors": true, + "no-empty-source": true, + "no-extra-semicolons": true, + "no-invalid-double-slash-comments": true, + "property-no-unknown": true, + "selector-pseudo-class-no-unknown": true, + "selector-pseudo-element-no-unknown": true, + "selector-type-no-unknown": true, + "string-no-newline": true, + "unit-no-unknown": true + } +}; diff --git a/wbfolder.wbl b/wbfolder.wbl deleted file mode 100644 index 52b8ffb..0000000 --- a/wbfolder.wbl +++ /dev/null @@ -1,3 +0,0 @@ -PLSmartPivot.js; -PLSmartPivot.css; -PLSmartPivot.qext \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..2ebf8f4 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,63 @@ +const CopyWebpackPlugin = require('copy-webpack-plugin'); +const StyleLintPlugin = require('stylelint-webpack-plugin'); +const settings = require('./settings'); + +console.log('Webpack mode:', settings.mode); // eslint-disable-line no-console + +const config = { + devtool: 'source-map', + entry: [ + './src/index.js' + ], + mode: settings.mode, + output: { + path: settings.buildDestination, + filename: settings.name + '.js', + libraryTarget: 'amd' + }, + externals: { + jquery: { + amd: 'jquery', + commonjs: 'jquery', + commonjs2: 'jquery', + root: '_' + }, + }, + module: { + rules: [ + { + enforce: "pre", + test: /\.js$/, + exclude: /(node_modules|Library)/, + loader: "eslint-loader", + options: { + failOnError: true + } + }, + { + test: /.js$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader', + options: { + presets: ['@babel/preset-env'] + } + } + }, + { + test: /.less$/, + use: ['style-loader', 'css-loader', 'less-loader'] + } + ] + }, + plugins: [ + new CopyWebpackPlugin([ + 'assets/' + settings.name + '.qext', + 'assets/' + settings.name + '.png', + 'assets/wbfolder.wbl' + ], {}), + new StyleLintPlugin() + ] +}; + +module.exports = config; From d74d3eb028d71e7b3eb807cf4abd0a352954461e Mon Sep 17 00:00:00 2001 From: Alexander Szmidt Date: Fri, 7 Dec 2018 13:39:05 +0100 Subject: [PATCH 2/9] Run eslint autofix, tidy up spacing and adjust eslint rules --- .eslintrc.js | 6 +- src/PLSmartPivot.js | 4361 +++++++++++++++++++++---------------------- 2 files changed, 2157 insertions(+), 2210 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 8ffb3ec..73028cb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -41,7 +41,7 @@ module.exports = { "no-cond-assign": ["warn"], "no-fallthrough": ["warn"], "no-undef": ["error"], - "no-unused-vars": ["error"], + "no-unused-vars": ["warn"], "no-use-before-define": ["warn", { "functions": false, "classes": false, "variables": false }], "no-useless-escape": ["warn"], "no-useless-return": ["warn"], @@ -53,9 +53,11 @@ module.exports = { "padded-blocks": ["warn", { "blocks": "never", "switches": "never", "classes": "never" }], "semi": ["error", "always"], "valid-typeof": ["warn"], - "no-eval": ["error"], + "no-eval": ["warn"], "no-implied-eval": ["error"], "no-debugger": ["warn"], + "no-unreachable": ["warn"], + "quotes": ["warn", "single", { "avoidEscape": true }] }, extends: [ "eslint:recommended" diff --git a/src/PLSmartPivot.js b/src/PLSmartPivot.js index bf4e39d..d292099 100644 --- a/src/PLSmartPivot.js +++ b/src/PLSmartPivot.js @@ -1,2221 +1,2166 @@ -define(["jquery","text!./PLSmartPivot.css"], function(e,t) {'use strict'; - return e("