Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Commit

Permalink
Cleaned and aligned to other extensions in EB
Browse files Browse the repository at this point in the history
  • Loading branch information
Albert Backenhof authored and Albert Backenhof committed Feb 21, 2019
1 parent 3d1d0e6 commit 6fbae14
Show file tree
Hide file tree
Showing 22 changed files with 1,579 additions and 4,134 deletions.
83 changes: 28 additions & 55 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ version: 2
defaults: &defaults
working_directory: ~/qlik-share-button
docker:
- image: circleci/node:stretch
- image: circleci/node:stretch-browsers
environment:
GITHUB_ORG: "qlik-oss"
GITHUB_REPO: "Dashboard-Link-Generator"
PACKAGE_NAME: "qlik-share-button"

jobs:
test:
docker:
- image: circleci/node:stretch-browsers
build:
<<: *defaults
steps:
- checkout
- run:
Expand All @@ -27,76 +26,50 @@ jobs:
--blackduck.password=${svc_blackduck} \
--detect.project.name="Dashboard-Link-Generator"
- 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-share-button
paths:
- BUMPED_VERSION

build:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/qlik-share-button
- run:
name: Install dependencies
command: npm install
- run:
name: Build and package
name: Build
command: |
export VERSION=$(scripts/get-bumped-version.sh)
echo "Version: ${VERSION}"
npm run build
environment:
NODE_ENV: production
npm run build:zip
sudo chmod +x ./.circleci/verify-files.sh
./.circleci/verify-files.sh
- persist_to_workspace:
root: ~/qlik-share-button
paths:
- build
- store_artifacts:
path: build
destination: build
deploy:
- dist
release:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/qlik-share-button
- run:
name: Install ghr
command: scripts/install-ghr.sh
name: Install GHR
command: |
sudo chmod +x ./.circleci/install-ghr.sh
./.circleci/install-ghr.sh
- run:
name: Create GitHub Release
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
sudo chmod +x ./.circleci/get-package-version.sh
export PACKAGE_VERSION=$(./.circleci/get-package-version.sh)
echo "Version: ${PACKAGE_VERSION}"
sudo chmod +x ./.circleci/create-release.sh
./.circleci/create-release.sh $GITHUB_ORG $GITHUB_REPO $PACKAGE_NAME $PACKAGE_VERSION
workflows:
version: 2
master_flow:
build-release:
jobs:
- test
- bump-version:
requires:
- test
- build:
requires:
- bump-version
- deploy:
filters:
tags:
only:
- /v.*/
- release:
requires:
- build
filters:
branches:
ignore: /.*/
tags:
only:
- master
- /v.*/
26 changes: 26 additions & 0 deletions .circleci/create-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -o errexit

echo "Creating release for version: $PACKAGE_VERSION"
echo "Artifact name: ./dist/${3}_${PACKAGE_VERSION}.zip"

echo "1: ${1}"
echo "2: ${2}"
echo "3: ${3}"
echo "4: ${4}"

LATEST_VERSION=$(curl --silent "https://api.github.com/repos/$1/$2/releases/latest" |
grep '"tag_name":' |
sed -E 's/.*"([^"]+)".*/\1/')

echo "LATEST_VERSION: ${LATEST_VERSION}"

if [ "${LATEST_VERSION}" != "${PACKAGE_VERSION}" ]; then

$HOME/bin/ghr -t ${ghoauth} -u ${1} -r ${2} -c ${CIRCLE_SHA1} -delete ${PACKAGE_VERSION} "./dist/${3}_${4}.zip"

else

echo "VERSION: ${PACKAGE_VERSION} already released"

fi
11 changes: 11 additions & 0 deletions .circleci/get-package-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -o errexit

PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')

echo $PACKAGE_VERSION
2 changes: 1 addition & 1 deletion scripts/install-ghr.sh → .circleci/install-ghr.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ curl -L ${URL} > ghr.zip
mkdir -p "$HOME/bin"
export PATH="$HOME/bin:$PATH"
unzip ghr.zip -d "$HOME/bin"
rm ghr.zip
rm ghr.zip
28 changes: 28 additions & 0 deletions .circleci/verify-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# The build script has a known race-condition that sometimes causes it to not include all files
# in the built zip. This script verifies the that the zip contains the correct number of files.

set -o errexit

echo "Verifying built file count"

while read line; do
if [[ $line =~ ^\"name\": ]]; then
name=${line#*: \"}
name=${name%\"*}
elif [[ $line =~ ^\"version\": ]]; then
version=${line#*: \"}
version=${version%\"*}
fi
done < package.json

expected_file_count=$(($(find dist -type f | wc -l)-1))
zip_file_count=$(zipinfo dist/${name}_${version}.zip | grep ^- | wc -l)

if [ "${expected_file_count}" -ne "${zip_file_count}" ]; then
# File count is incorrect
echo "Expected file count ${expected_file_count}, but was ${zip_file_count}"
exit 1
fi
echo "File count OK"
exit 0
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $RECYCLE.BIN/

# Temporary build files
node_modules/
build/
dist/
BUMPED_VERSION

# =========================
Expand Down
98 changes: 54 additions & 44 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,66 @@
var gulp = require('gulp');
var gutil = require('gulp-util');
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 pkg = require('./package.json');

var srcFiles = path.resolve('./src/**/*.*');
var DIST = './dist'

gulp.task('remove-build-folder', function(){
return del([settings.buildDestination], { force: true });
gulp.task('qext', function () {
var qext = {
name: 'Share button',
type: 'visualization',
description: pkg.description,
version: pkg.version,
icon: 'share',
preview: 'sharebutton.png',
keywords: 'qlik-sense, visualization',
author: pkg.author,
homepage: pkg.homepage,
license: pkg.license,
repository: pkg.repository,
installer: 'QlikExtensionBundler',
bundle: {
id: 'qlik-dashboard-bundle',
name: 'Qlik Dashboard bundle',
description: "This is a set of supported extensions that will facilitate dashboard creation in Qlik Sense: A navigation button, a date picker, a slider, and two different container objects. These can be used in addition to the native objects found under 'Charts'.\n\nFor limitations and support conditions, see the documentation."
},
dependencies: {
'qlik-sense': '>=5.5.x'
}
};
if (pkg.contributors) {
qext.contributors = pkg.contributors;
}
var src = require('stream').Readable({
objectMode: true
});
src._read = function () {
this.push(new gutil.File({
cwd: '',
base: '',
path: pkg.name + '.qext',
contents: Buffer.from(JSON.stringify(qext, null, 4))
}));
this.push(null);
};
return src.pipe(gulp.dest(DIST));
});

gulp.task('zip-build', function(){
return gulp.src(settings.buildDestination + '/**/*')
.pipe(zip(`${settings.name}_${settings.version}.zip`))
.pipe(gulp.dest(settings.buildDestination));
gulp.task('clean', function(){
return del([DIST], { force: true });
});

gulp.task('add-src', function(){
return gulp.src(srcFiles).pipe(gulp.dest(settings.buildDestination));
gulp.task('zip-build', function(){
return gulp.src(DIST + '/**/*')
.pipe(zip(`${pkg.name}_${pkg.version}.zip`))
.pipe(gulp.dest(DIST));
});

gulp.task('add-assets', function(){
return gulp.src("./assets/**/*").pipe(gulp.dest(settings.buildDestination));
return gulp.src('./assets/**/*').pipe(gulp.dest(DIST));
});

gulp.task('webpack-build', done => {
Expand All @@ -44,39 +79,14 @@ gulp.task('webpack-build', 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', 'add-assets', 'zip-build')
gulp.series('clean', 'webpack-build', 'qext', 'add-assets')
);

gulp.task('zip',
gulp.series('build', '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

resolve(null, devServer);
});
}));
49 changes: 0 additions & 49 deletions karma.conf.js

This file was deleted.

Loading

0 comments on commit 6fbae14

Please sign in to comment.