Skip to content

Commit

Permalink
Create definition of WebsiteInstances from template
Browse files Browse the repository at this point in the history
Move definition of web sites to a JSON file and let gulp create
WebsiteInstances.php as well as a new website-instances.ts file
from templates.
  • Loading branch information
ermshiperete committed May 14, 2018
1 parent b537093 commit 7c5e78e
Show file tree
Hide file tree
Showing 8 changed files with 759 additions and 202 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ test/app/**/*.e2e-spec.js.map
test/app/**/*.e2e-spec.js
test/app/**/shared/*.js.map
test/app/**/shared/*.js

# Generated files
src/Api/Library/Shared/WebsiteInstances.php
src/angular-app/bellows/core/website-instances.generated-data.ts
48 changes: 44 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ var dotnetPublish = require('gulp-dotnet-cli').publish;
var dotnetTest = require('gulp-dotnet-cli').test;
var fs = require('fs');
var del = require('del');
var data = require('gulp-data');
var ejs = require('gulp-ejs');
var dest = require('gulp-dest');

// If using a JSON file for the Google API secrets, uncomment the following line and search for
// "Google API" to find other lines to uncomment further below.
Expand Down Expand Up @@ -135,10 +138,10 @@ gulp.task('sass:watch', function () {

function webpack(applicationName, callback, isProduction, isWatch) {
var watch = isWatch ? ' --watch' : '';
var env = applicationName ? ' --env.applicationName=' + applicationName : '';
var envApplication = applicationName ? ' --env.applicationName=' + applicationName : '';
var prod = isProduction ? ' -p' : '';
execute('$(npm bin)/webpack' + watch + env + prod + ' --colors',
{ cwd: '.' },
execute('$(npm bin)/webpack' + watch + envApplication + prod + ' --colors',
{ cwd: '.', env: process.env },
function (err) {
if (err) throw new gutil.PluginError('webpack', err);
callback();
Expand Down Expand Up @@ -1258,6 +1261,41 @@ gulp.task('build-upload', function (cb) {
);
});

// ------------------------------------------
// Create WebsiteInstances.php from template
// ------------------------------------------
gulp.task('build-createWebsiteDefsPhp', function () {
return gulp.src('src/Api/Library/Shared/WebsiteInstances.ejs')
.pipe(data(function () {
return JSON.parse(fs.readFileSync('src/Api/Library/Shared/WebsiteInstances.json'));
}))
.pipe(ejs())
.pipe(dest('src/Api/Library/Shared/:name.php'))
.pipe(gulp.dest('src/Api/Library/Shared/'));
});

// ------------------------------------------
// Create website-instances.ts from template
// ------------------------------------------
gulp.task('build-createWebsiteDefsTs', function () {
return gulp.src('src/angular-app/bellows/core/website-instances.ejs')
.pipe(data(function () {
return JSON.parse(fs.readFileSync('src/Api/Library/Shared/WebsiteInstances.json'));
}))
.pipe(ejs())
.pipe(dest('src/angular-app/bellows/core/:name.generated-data.ts'))
.pipe(gulp.dest('src/angular-app/bellows/core/'));
});

// ------------------------------------------
// Create files from templates
// ------------------------------------------
gulp.task('build-createWebsiteDefs',
gulp.parallel(
'build-createWebsiteDefsPhp',
'build-createWebsiteDefsTs')
);

// -------------------------------------
// Task: Build (General)
// -------------------------------------
Expand All @@ -1271,7 +1309,8 @@ gulp.task('build',
'build-productionConfig',
'build-clearLocalCache',
'build-remove-test-fixtures',
'build-dotnet'),
'build-dotnet',
'build-createWebsiteDefs'),
'sass',
'build-webpack',
'build-minify',
Expand Down Expand Up @@ -1307,6 +1346,7 @@ gulp.task('dev-build',
gulp.task('dev-dependencies-and-build',
gulp.series(
'get-dependencies',
'build-createWebsiteDefs',
'dev-build'
)
);
Expand Down
Loading

0 comments on commit 7c5e78e

Please sign in to comment.