sp-dev-fx-webparts/samples/react-kanban-board/gulpfile.js

56 lines
1.8 KiB
JavaScript
Raw Normal View History

'use strict';
2020-04-21 16:36:16 -04:00
const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
2020-04-21 16:36:16 -04:00
// This section is inspired by Stefan Bauer's article at https://n8d.at/how-to-version-new-sharepoint-framework-projects/
// Stefan rocks!
let syncVersionsSubtask = build.subTask('version-sync', function (gulp, buildOptions, done) {
this.log('Synching versions');
2020-04-21 16:36:16 -04:00
// import gulp utilits to write error messages
const gutil = require('gulp-util');
2020-04-21 16:36:16 -04:00
// import file system utilities form nodeJS
const fs = require('fs');
2020-04-21 16:36:16 -04:00
// read package.json
var pkgConfig = require('./package.json');
2020-04-21 16:36:16 -04:00
// read configuration of web part solution file
var pkgSolution = require('./config/package-solution.json');
2020-04-21 16:36:16 -04:00
// log old version
this.log('package-solution.json version:\t' + pkgSolution.solution.version);
2020-04-21 16:36:16 -04:00
// Generate new MS compliant version number
var newVersionNumber = pkgConfig.version.split('-')[0] + '.0';
2020-04-21 16:36:16 -04:00
if (pkgSolution.solution.version !== newVersionNumber) {
// assign newly generated version number to web part version
pkgSolution.solution.version = newVersionNumber;
// log new version
this.log('New package-solution.json version:\t' + pkgSolution.solution.version);
fs.writeFile('./config/package-solution.json', JSON.stringify(pkgSolution, null, 4), function (err, result) {
if (err) this.log('error', err);
});
2020-04-21 16:36:16 -04:00
}
else {
this.log('package-solution.json version is up-to-date');
2020-04-21 16:36:16 -04:00
}
2020-04-21 16:36:16 -04:00
done();
});
let syncVersionTask = build.task('version-sync', syncVersionsSubtask);
build.rig.addPreBuildTask(syncVersionTask);
2020-04-21 16:36:16 -04:00
build.initialize(gulp);