Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade dependencies and fix compilation errors #51

Merged
merged 1 commit into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
> 1%,
last 2 versions,
firefox >= 4,
safari 7,
safari 8,
IE 8,
IE 9,
IE 10,
IE 11
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"trailingComma": "none",
"useEditorConfig": false,
"singleQuote": true
}
18 changes: 9 additions & 9 deletions chore/chore.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
* which defines tasks
*/
'use strict';
var path = require('path');
const path = require('path');
module.exports = (function () {

var projectName = "Css Star Rating";
const projectName = "Css Star Rating";

var ENV_LOCAL = "local",
const ENV_LOCAL = "local",
ENV_STAGING = "staging",
ENV_PRODUCTION = "production",
ENV_TESTING = "testing";

var validEnvs = [ENV_LOCAL, ENV_STAGING, ENV_PRODUCTION, ENV_TESTING];
const validEnvs = [ENV_LOCAL, ENV_STAGING, ENV_PRODUCTION, ENV_TESTING];

//dir paths
var root = './',
const root = './',
src = 'src',
dist = 'dist',

Expand All @@ -25,8 +25,8 @@ module.exports = (function () {
app = 'app',
assets = 'assets';

var styleguideFolder = 'docs';
var styleguideCopies = [
const styleguideFolder = 'docs';
const styleguideCopies = [
{
src: [
path.join( 'src', 'assets', 'star-rating.icons.svg')
Expand All @@ -36,7 +36,7 @@ module.exports = (function () {
}
];

var config = {
const config = {
projectName:projectName,
root: root,
src: src,
Expand All @@ -56,4 +56,4 @@ module.exports = (function () {

return config;

})();
})();
248 changes: 127 additions & 121 deletions chore/gulp/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,145 +10,151 @@

'use strict';

module.exports = (function() {
var gulp = require('gulp');
var del = require('del');
var fs = require('fs');
var notify = require('gulp-notify');
var extendify = require('extendify');
var merge = require('merge-stream');
var $ = require('gulp-load-plugins')();
module.exports = (function () {
const gulp = require('gulp');
const del = require('del');
const fs = require('fs');
const notify = require('gulp-notify');
const extendify = require('extendify');
const merge = require('merge-stream');
const $ = require('gulp-load-plugins')();

//////////


var arrayMergeExtend = extendify({
inPlace: false,
isDeep: true
const arrayMergeExtend = extendify({
inPlace: false,
isDeep: true
}),
arrayReplaceExtend = extendify({
inPlace: false,
isDeep: true,
arrays : 'replace'
inPlace: false,
isDeep: true,
arrays: 'replace'
}),
arrayConcatExtend = extendify({
inPlace: false,
isDeep: true,
arrays : 'concat'
inPlace: false,
isDeep: true,
arrays: 'concat'
});

var helper = {
arrayMergeExtend: arrayMergeExtend,
arrayReplaceExtend: arrayReplaceExtend,
arrayConcatExtend: arrayConcatExtend,
getEnv: getEnv,
getEnvConfigJson: getEnvConfigJson,
log: log,
bulkCopy: bulkCopy,
clean: clean,
errorHandler: errorhandler,
bytediffFormatter: bytediffFormatter
};
const helper = {
arrayMergeExtend: arrayMergeExtend,
arrayReplaceExtend: arrayReplaceExtend,
arrayConcatExtend: arrayConcatExtend,
getEnv: getEnv,
getEnvConfigJson: getEnvConfigJson,
log: log,
bulkCopy: bulkCopy,
clean: clean,
errorHandler: errorhandler,
bytediffFormatter: bytediffFormatter
};

return helper;

///////////////////



function getEnv(){
return process.env.NODE_ENV || "local";
}


function getEnvConfigJson(filepath) {
return JSON.parse(fs.readFileSync(filepath));
}

/**
* Log a message or series of messages using chalk's green color.
* Can pass in a string, object or array.
*/
function log(msg, color) {
if (typeof(msg) === 'object') {
for (var item in msg) {
if (msg.hasOwnProperty(item)) {
if(color && color in $.util.colors) {
$.util.log($.util.colors[color](msg[item]));
}
$.util.log($.util.colors.lightgreen(msg[item]));
}
}
} else {
$.util.log($.util.colors.green(msg));
function getEnv() {
return process.env.NODE_ENV || 'local';
}

function getEnvConfigJson(filepath) {
return JSON.parse(fs.readFileSync(filepath));
}

/**
* Log a message or series of messages using chalk's green color.
* Can pass in a string, object or array.
*/
function log(msg, color) {
if (typeof msg === 'object') {
for (let item in msg) {
if (msg.hasOwnProperty(item)) {
if (color && color in $.util.colors) {
$.util.log($.util.colors[color](msg[item]));
}
$.util.log($.util.colors.lightgreen(msg[item]));
}
}
} else {
$.util?.log($.util.colors.green(msg));
}


/**/
function bulkCopy(copyArray, done) {
log('Performing bulk copy: ' + $.util.colors.green(copyArray.length) + ' tasks');
var merged = merge();

console.log('copyArray: ', copyArray);
if(copyArray.length == 0) {
log('Nothing to copy');
return merged;
}

for(var i = 0; i<=copyArray.length-1; i++) {
log('copy '+ (('name' in copyArray[i])?copyArray[i].name:'') +' files from '+ copyArray[i].src +' to '+ copyArray[i].dest);
var move = gulp.src(copyArray[i].src)
.pipe(gulp.dest(copyArray[i].dest));

merged.add(move);
}

return merged;
}

/**/
function bulkCopy(copyArray, done) {
log(
'Performing bulk copy: ' +
$.util.colors.green(copyArray.length) +
' tasks'
);
const merged = merge();

if (copyArray.length == 0) {
log('Nothing to copy');
return merged;
}


/**
* Delete all files in a given path
* @param {Array} path - array of paths to delete
* @param {Function} done - callback when complete
*/
function clean(path, done) {
log('Cleaning: ' + $.util.colors.green(path));
return del(path, done);
}


function errorhandler(title) {

return notify.onError({
title: title + ' error(s)',
message: '<%= error.message %>'
});
}


/**
* Formatter for bytediff to display the size changes after processing
* @param {Object} data - byte data
* @return {String} Difference in bytes, formatted
*/
function bytediffFormatter(data) {
var difference = (data.savings > 0) ? ' smaller.' : ' larger.';
return data.fileName + ' went from '
+ (data.startSize / 1000).toFixed(2) + ' kB to '
+ (data.endSize / 1000).toFixed(2) + ' kB and is '
+ formatPercent(1 - data.percent, 2) + '%' + difference;
}

/**
* Format a number as a percentage
* @param {Number} num Number to format as a percent
* @param {Number} precision Precision of the decimal
* @return {String} Formatted perentage
*/
function formatPercent(num, precision) {
return (num * 100).toFixed(precision);
for (const i = 0; i <= copyArray.length - 1; i++) {
log(
'copy ' +
('name' in copyArray[i] ? copyArray[i].name : '') +
' files from ' +
copyArray[i].src +
' to ' +
copyArray[i].dest
);
const move = gulp.src(copyArray[i].src).pipe(gulp.dest(copyArray[i].dest));

merged.add(move);
}

return merged;
}

/**
* Delete all files in a given path
* @param {Array} path - array of paths to delete
* @param {Function} done - callback when complete
*/
function clean(path, done) {
log('Cleaning: ' + $.util?.colors.green(path));
return del(path, done);
}

function errorhandler(title) {
return notify.onError({
title: title + ' error(s)',
message: '<%= error.message %>'
});
}

/**
* Formatter for bytediff to display the size changes after processing
* @param {Object} data - byte data
* @return {String} Difference in bytes, formatted
*/
function bytediffFormatter(data) {
const difference = data.savings > 0 ? ' smaller.' : ' larger.';
return (
data.fileName +
' went from ' +
(data.startSize / 1000).toFixed(2) +
' kB to ' +
(data.endSize / 1000).toFixed(2) +
' kB and is ' +
formatPercent(1 - data.percent, 2) +
'%' +
difference
);
}

/**
* Format a number as a percentage
* @param {Number} num Number to format as a percent
* @param {Number} precision Precision of the decimal
* @return {String} Formatted perentage
*/
function formatPercent(num, precision) {
return (num * 100).toFixed(precision);
}
})();
Loading