From e2b448cc65f73f96e5b89cd131b1222a7b6f4282 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 12 Nov 2021 10:24:19 +0900 Subject: [PATCH] add install/build scripts --- gulpfile.js | 8 -------- package.json | 10 ++++------ scripts/build.js | 33 +++++++++++++++++++++++++++++++++ scripts/install-packages.js | 19 +++++++++++++++++++ 4 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 scripts/build.js create mode 100644 scripts/install-packages.js diff --git a/gulpfile.js b/gulpfile.js index 91d3a3ade..c27abefcb 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -50,14 +50,6 @@ gulp.task('build:backend:style', () => { .pipe(gulp.dest('./packages/backend/built/server/web/')); }); -gulp.task('clean', cb => - rimraf('./built', cb) -); - -gulp.task('cleanall', gulp.parallel('clean', cb => - rimraf('./node_modules', cb) -)); - gulp.task('build', gulp.parallel( 'copy:client:locales', 'copy:backend:views', 'build:backend:script', 'build:backend:style', 'copy:client:fonts' )); diff --git a/package.json b/package.json index 66d52e578..129e0f111 100644 --- a/package.json +++ b/package.json @@ -8,22 +8,19 @@ }, "private": true, "scripts": { + "postinstall": "node ./scripts/install-packages.js", + "build": "node ./scripts/build.js", "start": "cd packages/backend && node --experimental-json-modules ./built/index.js", "start:test": "cd packages/backend && cross-env NODE_ENV=test node --experimental-json-modules ./index.js", "init": "npm run migrate", "ormconfig": "node ./packages/backend/ormconfig.js", "migrate": "cd packages/backend && npx typeorm migration:run", "migrateandstart": "npm run migrate && npm run start", - "build": "npm run build-client && npm run build-backend && npm run build-gulp", - "build-client": "cd packages/client && npm run build", - "build-backend": "cd packages/backend && npm run build", - "build-gulp": "gulp build", + "gulp": "gulp build", "watch": "concurrently \"npm:watch-*\"", "watch-webpack": "webpack --watch", "watch-ts": "tsc -w -p packages/tsconfig.json && tsc-alias -w -p packages/tsconfig.json", "watch-gulp": "gulp watch", - "clean": "gulp clean", - "cleanall": "gulp cleanall", "lint": "tslint 'packages/**/*.ts'", "cy:open": "cypress open", "cy:run": "cypress run", @@ -35,6 +32,7 @@ "dependencies": { "@types/gulp": "4.0.9", "@types/gulp-rename": "2.0.1", + "execa": "5.1.1", "gulp": "4.0.2", "gulp-cssnano": "2.1.3", "gulp-rename": "2.0.0", diff --git a/scripts/build.js b/scripts/build.js new file mode 100644 index 000000000..6d4bb6c6e --- /dev/null +++ b/scripts/build.js @@ -0,0 +1,33 @@ +const execa = require('execa'); + +(async () => { + console.log('building packages/backend ...'); + + await execa('npm', ['run', 'build'], { + cwd: __dirname + '/../packages/backend', + stdout: process.stdout, + stderr: process.stderr, + }); + + console.log('building packages/client ...'); + + await execa('npm', ['run', 'build'], { + cwd: __dirname + '/../packages/client', + stdout: process.stdout, + stderr: process.stderr, + }); + + await execa('npm', ['run', 'build'], { + cwd: __dirname + '/../packages/client', + stdout: process.stdout, + stderr: process.stderr, + }); + + console.log('build finishing ...'); + + await execa('npm', ['run', 'gulp'], { + cwd: __dirname + '/../', + stdout: process.stdout, + stderr: process.stderr, + }); +})(); diff --git a/scripts/install-packages.js b/scripts/install-packages.js new file mode 100644 index 000000000..c25063b29 --- /dev/null +++ b/scripts/install-packages.js @@ -0,0 +1,19 @@ +const execa = require('execa'); + +(async () => { + console.log('installing dependencies of packages/backend ...'); + + await execa('yarn', ['install'], { + cwd: __dirname + '/../packages/backend', + stdout: process.stdout, + stderr: process.stderr, + }); + + console.log('installing dependencies of packages/client ...'); + + await execa('yarn', ['install'], { + cwd: __dirname + '/../packages/client', + stdout: process.stdout, + stderr: process.stderr, + }); +})();