Browse Source

Same docs/admin task refactoring

pull/6983/head
Jack 4 years ago
parent
commit
eafcc70e93
6 changed files with 39 additions and 46 deletions
  1. 3
      tasks/admin/components/init.js
  2. 1
      tasks/admin/components/update.js
  3. 1
      tasks/admin/distributions/init.js
  4. 1
      tasks/admin/distributions/update.js
  5. 15
      tasks/config/admin/github.js
  6. 64
      tasks/docs/serve.js

3
tasks/admin/components/init.js

@ -21,7 +21,6 @@ var
fs = require('fs'),
path = require('path'),
git = require('gulp-git'),
githubAPI = require('@octokit/rest'),
mkdirp = require('mkdirp'),
// admin files
@ -149,7 +148,7 @@ module.exports = function(callback) {
// avoid rate throttling
global.clearTimeout(timer);
timer = global.setTimeout(function() {
stepRepo()
stepRepo();
}, 0);
}

1
tasks/admin/components/update.js

@ -20,7 +20,6 @@ var
fs = require('fs'),
path = require('path'),
git = require('gulp-git'),
githubAPI = require('@octokit/rest'),
requireDotFile = require('require-dot-file'),
// admin files

1
tasks/admin/distributions/init.js

@ -21,7 +21,6 @@ var
fs = require('fs'),
path = require('path'),
git = require('gulp-git'),
githubAPI = require('@octokit/rest'),
mkdirp = require('mkdirp'),
// admin files

1
tasks/admin/distributions/update.js

@ -20,7 +20,6 @@ var
fs = require('fs'),
path = require('path'),
git = require('gulp-git'),
githubAPI = require('@octokit/rest'),
requireDotFile = require('require-dot-file'),
// admin files

15
tasks/config/admin/github.js

@ -8,7 +8,7 @@
var
fs = require('fs'),
path = require('path'),
githubAPI = require('@octokit/rest'),
{ Octokit } = require('@octokit/rest'),
// stores oauth info for GitHub API
oAuthConfig = path.join(__dirname, 'oauth.js'),
@ -22,16 +22,11 @@ if(!oAuth) {
console.error('Must add oauth token for GitHub in tasks/config/admin/oauth.js');
}
github = new githubAPI({
version : '3.0.0',
debug : true,
protocol : 'https',
github = new Octokit({
version : '3.0.0',
auth : oAuth.token,
userAgent : 'Semantic-Org-Pusher-Bot',
timeout : 5000
});
github.authenticate({
type: 'oauth',
token: oAuth.token
});
module.exports = github;

64
tasks/docs/serve.js

@ -85,9 +85,9 @@ serveDocs = function () {
'src/**/*.*'
])
;
watchSRCCallback = function(file) {
watchSRCCallback = function(filePath) {
console.clear();
return gulp.src(file.path, {
return gulp.src(filePath, {
base: 'src/'
})
.pipe(gulp.dest(output.less))
@ -109,9 +109,9 @@ serveDocs = function () {
])
;
watchExamplesCallback = function(file) {
watchExamplesCallback = function(filePath) {
console.clear();
return gulp.src(file.path, {
return gulp.src(filePath, {
base: 'examples/'
})
.pipe(gulp.dest(output.examples))
@ -136,7 +136,7 @@ serveDocs = function () {
source.themes + '/**/*.{overrides,variables}'
])
;
watchCSSCallback = function(file) {
watchCSSCallback = function(filePath) {
let
lessPath,
@ -151,7 +151,7 @@ serveDocs = function () {
;
// log modified file
gulp.src(file.path)
gulp.src(filePath)
.pipe(print(log.modified))
;
@ -160,10 +160,10 @@ serveDocs = function () {
---------------*/
// recompile on *.override , *.variable change
isConfig = (file.path.indexOf('theme.config') !== -1 || file.path.indexOf('site.variables') !== -1);
isPackagedTheme = (file.path.indexOf(source.themes) !== -1);
isSiteTheme = (file.path.indexOf(source.site) !== -1);
isDefinition = (file.path.indexOf(source.definitions) !== -1);
isConfig = (filePath.indexOf('theme.config') !== -1 || filePath.indexOf('site.variables') !== -1);
isPackagedTheme = (filePath.indexOf(source.themes) !== -1);
isSiteTheme = (filePath.indexOf(source.site) !== -1);
isDefinition = (filePath.indexOf(source.definitions) !== -1);
if(isConfig) {
// console.info('Rebuilding all files');
@ -173,17 +173,17 @@ serveDocs = function () {
}
else if(isPackagedTheme) {
console.log('Change detected in packaged theme');
lessPath = replaceExt(file.path, '.less');
lessPath = replaceExt(filePath, '.less');
lessPath = lessPath.replace(tasks.regExp.theme, source.definitions);
}
else if(isSiteTheme) {
console.log('Change detected in site theme');
lessPath = replaceExt(file.path, '.less');
lessPath = replaceExt(filePath, '.less');
lessPath = lessPath.replace(source.site, source.definitions);
}
else {
console.log('Change detected in definition');
lessPath = file.path;
lessPath = filePath;
}
/*--------------
@ -249,24 +249,26 @@ serveDocs = function () {
watchJS = gulp
.watch([
source.definitions + '/**/*.js'
], function(file) {
gulp.src(file.path)
.pipe(plumber())
.pipe(gulpif(config.hasPermission, chmod(config.permission)))
.pipe(gulp.dest(output.uncompressed))
.pipe(print(log.created))
.pipe(uglify(settings.uglify))
.pipe(rename(settings.rename.minJS))
.pipe(gulp.dest(output.compressed))
.pipe(print(log.created))
.on('end', function() {
gulp.start('package compressed docs js');
gulp.start('package uncompressed docs js');
})
;
})
])
;
watchJSCallback = function(filePath) {
gulp.src(filePath)
.pipe(plumber())
.pipe(gulpif(config.hasPermission, chmod(config.permission)))
.pipe(gulp.dest(output.uncompressed))
.pipe(print(log.created))
.pipe(uglify(settings.uglify))
.pipe(rename(settings.rename.minJS))
.pipe(gulp.dest(output.compressed))
.pipe(print(log.created))
.on('end', function() {
gulp.start('package compressed docs js');
gulp.start('package uncompressed docs js');
})
;
};
watchJS
.on('add', watchJSCallback)
.on('change', watchJSCallback)
@ -283,8 +285,8 @@ serveDocs = function () {
])
;
// copy assets
watchAssetsCallback = function(file) {
gulp.src(file.path, { base: source.themes })
watchAssetsCallback = function(filePath) {
gulp.src(filePath, { base: source.themes })
.pipe(gulpif(config.hasPermission, chmod(config.permission)))
.pipe(gulp.dest(output.themes))
.pipe(print(log.created))

Loading…
Cancel
Save