From 07780e020e738c576cde27c89544838a1b3516bb Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Wed, 29 May 2019 02:24:46 -0600 Subject: [PATCH] reorganize build - move gulpfile.js folder to gulp.d - move gulpfile.js/index.js back to gulpfile.js - rename task to createTask - import tasks under task namespace --- .../lib/task.js => gulp.d/lib/create-task.js | 0 {gulpfile.js => gulp.d}/lib/export-tasks.js | 0 .../lib/gulp-prettier-eslint.js | 0 .../tasks/build-preview-pages.js | 0 {gulpfile.js => gulp.d}/tasks/build.js | 0 {gulpfile.js => gulp.d}/tasks/format.js | 0 {gulpfile.js => gulp.d}/tasks/index.js | 0 {gulpfile.js => gulp.d}/tasks/lint-css.js | 0 {gulpfile.js => gulp.d}/tasks/lint-js.js | 0 {gulpfile.js => gulp.d}/tasks/pack.js | 0 {gulpfile.js => gulp.d}/tasks/remove.js | 0 {gulpfile.js => gulp.d}/tasks/serve.js | 0 gulpfile.js/index.js => gulpfile.js | 55 +++++++++++----------- 13 files changed, 28 insertions(+), 27 deletions(-) rename gulpfile.js/lib/task.js => gulp.d/lib/create-task.js (100%) rename {gulpfile.js => gulp.d}/lib/export-tasks.js (100%) rename {gulpfile.js => gulp.d}/lib/gulp-prettier-eslint.js (100%) rename gulpfile.js/tasks/preview-pages.js => gulp.d/tasks/build-preview-pages.js (100%) rename {gulpfile.js => gulp.d}/tasks/build.js (100%) rename {gulpfile.js => gulp.d}/tasks/format.js (100%) rename {gulpfile.js => gulp.d}/tasks/index.js (100%) rename {gulpfile.js => gulp.d}/tasks/lint-css.js (100%) rename {gulpfile.js => gulp.d}/tasks/lint-js.js (100%) rename {gulpfile.js => gulp.d}/tasks/pack.js (100%) rename {gulpfile.js => gulp.d}/tasks/remove.js (100%) rename {gulpfile.js => gulp.d}/tasks/serve.js (100%) rename gulpfile.js/index.js => gulpfile.js (58%) diff --git a/gulpfile.js/lib/task.js b/gulp.d/lib/create-task.js similarity index 100% rename from gulpfile.js/lib/task.js rename to gulp.d/lib/create-task.js diff --git a/gulpfile.js/lib/export-tasks.js b/gulp.d/lib/export-tasks.js similarity index 100% rename from gulpfile.js/lib/export-tasks.js rename to gulp.d/lib/export-tasks.js diff --git a/gulpfile.js/lib/gulp-prettier-eslint.js b/gulp.d/lib/gulp-prettier-eslint.js similarity index 100% rename from gulpfile.js/lib/gulp-prettier-eslint.js rename to gulp.d/lib/gulp-prettier-eslint.js diff --git a/gulpfile.js/tasks/preview-pages.js b/gulp.d/tasks/build-preview-pages.js similarity index 100% rename from gulpfile.js/tasks/preview-pages.js rename to gulp.d/tasks/build-preview-pages.js diff --git a/gulpfile.js/tasks/build.js b/gulp.d/tasks/build.js similarity index 100% rename from gulpfile.js/tasks/build.js rename to gulp.d/tasks/build.js diff --git a/gulpfile.js/tasks/format.js b/gulp.d/tasks/format.js similarity index 100% rename from gulpfile.js/tasks/format.js rename to gulp.d/tasks/format.js diff --git a/gulpfile.js/tasks/index.js b/gulp.d/tasks/index.js similarity index 100% rename from gulpfile.js/tasks/index.js rename to gulp.d/tasks/index.js diff --git a/gulpfile.js/tasks/lint-css.js b/gulp.d/tasks/lint-css.js similarity index 100% rename from gulpfile.js/tasks/lint-css.js rename to gulp.d/tasks/lint-css.js diff --git a/gulpfile.js/tasks/lint-js.js b/gulp.d/tasks/lint-js.js similarity index 100% rename from gulpfile.js/tasks/lint-js.js rename to gulp.d/tasks/lint-js.js diff --git a/gulpfile.js/tasks/pack.js b/gulp.d/tasks/pack.js similarity index 100% rename from gulpfile.js/tasks/pack.js rename to gulp.d/tasks/pack.js diff --git a/gulpfile.js/tasks/remove.js b/gulp.d/tasks/remove.js similarity index 100% rename from gulpfile.js/tasks/remove.js rename to gulp.d/tasks/remove.js diff --git a/gulpfile.js/tasks/serve.js b/gulp.d/tasks/serve.js similarity index 100% rename from gulpfile.js/tasks/serve.js rename to gulp.d/tasks/serve.js diff --git a/gulpfile.js/index.js b/gulpfile.js similarity index 58% rename from gulpfile.js/index.js rename to gulpfile.js index 55a29a8..561a796 100644 --- a/gulpfile.js/index.js +++ b/gulpfile.js @@ -1,7 +1,8 @@ 'use strict' const { parallel, series, tree, watch } = require('gulp') -const task = require('./lib/task') +const createTask = require('./gulp.d/lib/create-task') +const exportTasks = require('./gulp.d/lib/export-tasks') const bundleName = 'ui' const buildDir = 'build' @@ -11,89 +12,89 @@ const srcDir = 'src' const destDir = `${previewDestDir}/_` const { reload: livereload } = process.env.LIVERELOAD === 'true' ? require('gulp-connect') : {} -const { remove, lintCss, lintJs, format, build, pack, previewPages, serve } = require('./tasks') +const task = require('./gulp.d/tasks') const glob = { all: [srcDir, previewSrcDir], css: `${srcDir}/css/**/*.css`, - js: ['gulpfile.js/**/*.js', `${srcDir}/{helpers,js}/**/*.js`], + js: ['gulpfile.js', 'gulp.d/**/*.js', `${srcDir}/{helpers,js}/**/*.js`], } -const cleanTask = task({ +const cleanTask = createTask({ name: 'clean', desc: 'Clean files and folders generated by build', - call: remove(['build', 'public']), + call: task.remove(['build', 'public']), }) -const lintCssTask = task({ +const lintCssTask = createTask({ name: 'lint:css', desc: 'Lint the CSS source files using stylelint (standard config)', - call: lintCss(glob.css), + call: task.lintCss(glob.css), }) -const lintJsTask = task({ +const lintJsTask = createTask({ name: 'lint:js', desc: 'Lint the JavaScript source files using eslint (JavaScript Standard Style)', - call: lintJs(glob.js), + call: task.lintJs(glob.js), }) -const lintTask = task({ +const lintTask = createTask({ name: 'lint', desc: 'Lint the CSS and JavaScript source files', call: parallel(lintCssTask, lintJsTask), }) -const formatTask = task({ +const formatTask = createTask({ name: 'format', desc: 'Format the JavaScript source files using prettify (JavaScript Standard Style)', - call: format(glob.js), + call: task.format(glob.js), }) -const buildTask = task({ +const buildTask = createTask({ name: 'build', desc: 'Build and stage the UI assets for bundling', - call: build(srcDir, destDir, tree().nodes.some((name) => ~name.indexOf('preview'))), + call: task.build(srcDir, destDir, tree().nodes.some((name) => ~name.indexOf('preview'))), }) -const bundleBuildTask = task({ +const bundleBuildTask = createTask({ name: 'bundle:build', call: series(cleanTask, lintTask, buildTask), }) -const bundlePackTask = task({ +const bundlePackTask = createTask({ name: 'bundle:pack', desc: 'Create a bundle of the staged UI assets for publishing', - call: pack(destDir, buildDir, bundleName), + call: task.pack(destDir, buildDir, bundleName), }) -const bundleTask = task({ +const bundleTask = createTask({ name: 'bundle', desc: 'Clean, lint, build, and bundle the UI for publishing', call: series(bundleBuildTask, bundlePackTask), }) -const previewPagesTask = task({ - name: 'preview:pages', - call: previewPages(srcDir, previewSrcDir, previewDestDir, livereload), +const buildPreviewPagesTask = createTask({ + name: 'preview:build-pages', + call: task.buildPreviewPages(srcDir, previewSrcDir, previewDestDir, livereload), }) -const previewBuildTask = task({ +const previewBuildTask = createTask({ name: 'preview:build', desc: 'Process and stage the UI assets and generate pages for the preview', - call: parallel(buildTask, previewPagesTask), + call: parallel(buildTask, buildPreviewPagesTask), }) -const previewServeTask = task({ +const previewServeTask = createTask({ name: 'preview:serve', - call: serve(previewDestDir, { port: 5252, livereload }, () => watch(glob.all, previewBuildTask)), + call: task.serve(previewDestDir, { port: 5252, livereload }, () => watch(glob.all, previewBuildTask)), }) -const previewTask = task({ +const previewTask = createTask({ name: 'preview', desc: 'Generate a preview site and launch a server to view it', call: series(previewBuildTask, previewServeTask), }) -module.exports = require('./lib/export-tasks')( +module.exports = exportTasks( bundleTask, cleanTask, lintTask, -- 2.11.0