-
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(): updated gulp configurations
- Loading branch information
Showing
22 changed files
with
931 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,16 @@ | ||
// @ts-check | ||
|
||
const childProcess = require('child_process'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const ts = require('gulp-typescript'); | ||
const gulp = require('gulp'); | ||
const clean = require('gulp-clean'); | ||
|
||
const { join } = require('path'); | ||
const debug = require('gulp-debug'); | ||
const { promisify } = require('util'); | ||
|
||
const exec = promisify(childProcess.exec); | ||
|
||
/** | ||
* SETTINGS | ||
*/ | ||
const DIST = join(__dirname, 'dist'); | ||
const LIB = join(__dirname, 'lib'); | ||
const SAMPLE = join(__dirname, 'sample'); | ||
|
||
const terminus = ts.createProject(join(__dirname, 'tsconfig.json')); | ||
|
||
/** | ||
* UTIL | ||
*/ | ||
function getFolders(dir) { | ||
return fs | ||
.readdirSync(dir) | ||
.filter((file) => fs.statSync(path.join(dir, file)).isDirectory()); | ||
} | ||
|
||
const getDirs = (base) => getFolders(base).map((path) => `${base}/${path}`).filter(p => !p.includes('deprecated')); | ||
|
||
'use strict'; | ||
/** | ||
* TASK | ||
* Load the TypeScript compiler, then load the TypeScript gulpfile which simply loads all | ||
* the tasks. The tasks are really inside tools/gulp/tasks. | ||
*/ | ||
|
||
gulp.task('clean', () => { | ||
return gulp | ||
.src( | ||
[DIST, SAMPLE + '/*/node_modules/@nestjs/terminus', SAMPLE + '/*/dist'], | ||
{ | ||
allowEmpty: true, | ||
}, | ||
) | ||
.pipe(clean()); | ||
}); | ||
|
||
gulp.task('move:protos', () => { | ||
return gulp | ||
.src(join(LIB, './**/*.proto'), { base: LIB }) | ||
.pipe(debug({ title: 'move:protos' })) | ||
.pipe(gulp.dest(join(DIST))); | ||
}); | ||
|
||
gulp.task('build', () => { | ||
return terminus.src().pipe(terminus()).pipe(gulp.dest(DIST)); | ||
}); | ||
|
||
gulp.task('move', () => { | ||
const directories = getDirs(SAMPLE); | ||
|
||
let stream = gulp.src(['dist/**/*']); | ||
|
||
directories.forEach((dir) => { | ||
stream = stream.pipe(gulp.dest(dir + '/node_modules/@nestjs/terminus')); | ||
}); | ||
return stream; | ||
}); | ||
|
||
gulp.task('install:sample', async () => { | ||
const directories = getDirs(SAMPLE); | ||
|
||
const promises = directories.map((dir) => | ||
exec(`npm install --prefix ${dir}`), | ||
); | ||
|
||
return await Promise.all(promises); | ||
}); | ||
|
||
gulp.task('build:sample', async () => { | ||
const directories = getDirs(SAMPLE); | ||
const path = require('path'); | ||
|
||
const promises = directories.map((dir) => | ||
exec(`npm run build --prefix ${dir}`), | ||
); | ||
const projectDir = __dirname; | ||
const tsconfigPath = path.join(projectDir, 'tools/gulp/tsconfig.json'); | ||
|
||
return await Promise.all(promises); | ||
require('ts-node').register({ | ||
project: tsconfigPath | ||
}); | ||
|
||
/** | ||
* Aliases | ||
*/ | ||
gulp.task('default', gulp.series(['clean', 'build', 'move:protos'])); | ||
gulp.task('build:app', gulp.series(['default'])); | ||
gulp.task( | ||
'build:all', | ||
gulp.series([ | ||
'build:app', | ||
'install:sample', | ||
'move', | ||
'build:sample', | ||
]), | ||
); | ||
require('./tools/gulp/gulpfile'); |
Oops, something went wrong.