From 6f2a9127080b2f249bfddbdfb3ebce458ae72f3f Mon Sep 17 00:00:00 2001 From: jlukic Date: Thu, 6 Oct 2022 12:19:38 -0400 Subject: [PATCH] Work on admin scripts gulp4 --- tasks/admin/distributions/create.js | 31 +++++++++++----------- tasks/admin/distributions/init.js | 6 ++--- tasks/admin/publish.js | 24 +++++++++++------ tasks/admin/release.js | 41 ++++++++++++++++++++--------- tasks/collections/admin.js | 2 +- tasks/collections/build.js | 4 +-- 6 files changed, 67 insertions(+), 41 deletions(-) diff --git a/tasks/admin/distributions/create.js b/tasks/admin/distributions/create.js index 283bca3e5..2f35a04a7 100644 --- a/tasks/admin/distributions/create.js +++ b/tasks/admin/distributions/create.js @@ -9,7 +9,7 @@ * update package.json file */ -var +let gulp = require('gulp'), // node dependencies @@ -43,7 +43,7 @@ var module.exports = function(callback) { - var + let stream, index, tasks = [] @@ -51,14 +51,14 @@ module.exports = function(callback) { for(index in release.distributions) { - var + let distribution = release.distributions[index] ; // streams... designed to save time and make coding fun... (function(distribution) { - var + let distLowerCase = distribution.toLowerCase(), outputDirectory = path.join(release.outputRoot, distLowerCase), packageFile = path.join(outputDirectory, release.files.npm), @@ -81,8 +81,9 @@ module.exports = function(callback) { // get files for meteor gatherFiles = function(dir) { - var - dir = dir || path.resolve('.'), + dir = dir || path.resolve('.'); + + let list = fs.readdirSync(dir), omitted = [ '.git', @@ -97,7 +98,7 @@ module.exports = function(callback) { files = [] ; list.forEach(function(file) { - var + let isOmitted = (omitted.indexOf(file) > -1), filePath = path.join(dir, file), stat = fs.statSync(filePath) @@ -116,8 +117,8 @@ module.exports = function(callback) { // spaces out list correctly createList = function(files) { - var filenames = ''; - for(var file in files) { + let filenames = ''; + for(let file in files) { if(file == (files.length - 1) ) { filenames += "'" + files[file] + "'"; } @@ -130,7 +131,7 @@ module.exports = function(callback) { gulp.task(task.meteor, function() { - var + let files = gatherFiles(outputDirectory), filenames = createList(files) ; @@ -146,7 +147,7 @@ module.exports = function(callback) { if(distribution == 'CSS') { gulp.task(task.repo, function() { - var + let themes, components, releases @@ -165,7 +166,7 @@ module.exports = function(callback) { } else if(distribution == 'LESS') { gulp.task(task.repo, function() { - var + let definitions, themeImport, themeConfig, @@ -198,11 +199,11 @@ module.exports = function(callback) { gulp.task(task.package, function() { return gulp.src(packageFile) .pipe(plumber()) - .pipe(jsonEditor(function(package) { + .pipe(jsonEditor(function(json) { if(version) { - package.version = version; + json.version = version; } - return package; + return json; })) .pipe(gulp.dest(outputDirectory)) ; diff --git a/tasks/admin/distributions/init.js b/tasks/admin/distributions/init.js index 124e13167..26d5047ca 100644 --- a/tasks/admin/distributions/init.js +++ b/tasks/admin/distributions/init.js @@ -12,7 +12,7 @@ */ -var +let gulp = require('gulp'), // node dependencies @@ -63,7 +63,7 @@ module.exports = function(callback) { return; } - var + let component = release.distributions[index], lowerCaseComponent = component.toLowerCase(), outputDirectory = path.resolve(release.outputRoot + lowerCaseComponent), @@ -147,7 +147,7 @@ module.exports = function(callback) { // avoid rate throttling global.clearTimeout(timer); timer = global.setTimeout(function() { - stepRepo() + stepRepo(); }, 0); } diff --git a/tasks/admin/publish.js b/tasks/admin/publish.js index 9272076e9..ae2a9f003 100644 --- a/tasks/admin/publish.js +++ b/tasks/admin/publish.js @@ -8,15 +8,23 @@ * Commits changes from create components to GitHub and Tags */ +let + gulp = require('gulp'), + {series, parallel} = gulp, + updateComponents = require('../admin/components/update'), + updateDistributions = require('../admin/distributions/update'), -/* Release All */ -module.exports = function(callback) { + publish +; - gulp.series( - 'update distributions', // commit less/css versions to github - 'update components', // commit components to github - callback - ); +/* Release All */ +publish = series( + updateDistributions, // commit less/css versions to github + updateComponents // commit components to github +); -}; +/* Export with Metadata */ +publish.displayName = 'publish'; +publish.description = 'Publish new versions of SUI across all repos'; +module.exports = publish; diff --git a/tasks/admin/release.js b/tasks/admin/release.js index dc047d1a8..f2deaa24b 100644 --- a/tasks/admin/release.js +++ b/tasks/admin/release.js @@ -2,6 +2,23 @@ Release *******************************/ +let + gulp = require('gulp'), + {series, parallel} = gulp, + + build = require('../build'), + + // less/css distributions + initComponents = require('./components/init'), + createComponents = require('./components/create'), + + // single component releases + initDistributions = require('./distributions/init'), + createDistributions = require('./distributions/create'), + + release +; + /* This task update all SUI individual component repos with new versions of components @@ -11,15 +28,15 @@ */ /* Release All */ -module.exports = function(callback) { - - gulp.series( - //'build', // build Semantic - 'init distributions', // sync with current github version - 'create distributions', // update each repo with changes from master repo - 'init components', // sync with current github version - 'create components', // update each repo - callback - ); - -}; +release = series( + build, // build Semantic + initDistributions, // sync with current github version + createDistributions, // update each repo with changes from master repo + initComponents, // sync with current github version + createComponents // update each repo +); + +/* Export with Metadata */ +release.displayName = 'release'; +release.description = 'Release SUI across all repos'; +module.exports = release; diff --git a/tasks/collections/admin.js b/tasks/collections/admin.js index efd4df748..1f48d106e 100644 --- a/tasks/collections/admin.js +++ b/tasks/collections/admin.js @@ -15,7 +15,7 @@ module.exports = function(gulp) { - var + let // less/css distributions initComponents = require('../admin/components/init'), createComponents = require('../admin/components/create'), diff --git a/tasks/collections/build.js b/tasks/collections/build.js index ce79b06a1..3e865742b 100644 --- a/tasks/collections/build.js +++ b/tasks/collections/build.js @@ -4,14 +4,14 @@ module.exports = function(gulp) { - var + let // build sub-tasks buildJS = require('./../build/javascript'), buildCSS = require('./../build/css'), buildAssets = require('./../build/assets') ; - // in case these tasks are undefined during import, less make sure these are available in scope + // in case these tasks are undefined during import, lets make sure these are available in scope gulp.task('build-javascript', buildJS); gulp.task('build-css', buildCSS); gulp.task('build-assets', buildAssets);