mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
build(): Add build:samples script
This commit is contained in:
53
gulpfile.js
53
gulpfile.js
@@ -5,6 +5,15 @@ const ts = require('gulp-typescript');
|
||||
const sourcemaps = require('gulp-sourcemaps');
|
||||
const clean = require('gulp-clean');
|
||||
const deleteEmpty = require('delete-empty');
|
||||
const childProcess = require('child_process');
|
||||
const log = require('fancy-log');
|
||||
const clc = require('cli-color');
|
||||
|
||||
const { promisify } = require('util');
|
||||
|
||||
const exec = promisify(childProcess.exec);
|
||||
|
||||
const SAMPLE = path.join(__dirname, 'sample');
|
||||
|
||||
const packages = {
|
||||
common: ts.createProject('packages/common/tsconfig.json'),
|
||||
@@ -101,9 +110,49 @@ function getFolders(dir) {
|
||||
return fs.statSync(path.join(dir, file)).isDirectory();
|
||||
});
|
||||
}
|
||||
gulp.task('move', function() {
|
||||
const getDirs = base => getFolders(base).map(path => `${base}/${path}`);
|
||||
|
||||
const getDirs = base => getFolders(base).map(path => `${base}/${path}`);
|
||||
|
||||
gulp.task('install:samples', async () => {
|
||||
const directories = getDirs(SAMPLE);
|
||||
|
||||
const promises = directories.map(async dir => {
|
||||
log.info(
|
||||
`Installing dependencies of ${clc.magenta(dir.replace(__dirname, ''))}`,
|
||||
);
|
||||
try {
|
||||
await exec(`npm install --no-shrinkwrap --prefix ${dir}`);
|
||||
} catch (err) {
|
||||
log.error(`Failed installing dependencies of ${dir}`);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
await Promise.all(promises);
|
||||
});
|
||||
|
||||
gulp.task('build:samples', async () => {
|
||||
const directories = getDirs(SAMPLE);
|
||||
|
||||
const promises = directories.map(async dir => {
|
||||
log.info(
|
||||
`Building ${clc.magenta(dir.replace(__dirname, ''))}`,
|
||||
);
|
||||
try {
|
||||
await exec(`npm run build --prefix ${dir}`);
|
||||
} catch (err) {
|
||||
log.error(`Failed building ${clc.magenta(dir)}:`);
|
||||
if(err.stdout) {
|
||||
log.error(err.stdout);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
return await Promise.all(promises);
|
||||
});
|
||||
|
||||
gulp.task('move', function() {
|
||||
const examplesDirs = getDirs('sample');
|
||||
const integrationDirs = getDirs('integration');
|
||||
const directories = examplesDirs.concat(integrationDirs);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"build": "npm run clean && gulp build",
|
||||
"prebuild:dev": "rm -rf node_modules/@nestjs",
|
||||
"build:dev": "gulp build --dist node_modules/@nestjs && gulp move",
|
||||
"build:samples": "gulp install:samples && npm run build:dev && gulp build:samples",
|
||||
"postinstall": "opencollective",
|
||||
"prerelease": "gulp copy-misc && gulp build --dist node_modules/@nestjs",
|
||||
"publish": "npm run prerelease && npm run build && ./node_modules/.bin/lerna publish --force-publish --access public --exact -m \"chore(@nestjs) publish %s release\"",
|
||||
@@ -103,6 +104,7 @@
|
||||
"coveralls": "3.0.4",
|
||||
"csv-write-stream": "2.0.0",
|
||||
"delete-empty": "3.0.0",
|
||||
"fancy-log": "^1.3.3",
|
||||
"fastify-static": "2.5.0",
|
||||
"gulp": "4.0.1",
|
||||
"gulp-clang-format": "1.0.27",
|
||||
|
||||
Reference in New Issue
Block a user