diff --git a/gulpfile.js b/gulpfile.js index a7bcf73ce..b843f890a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,6 +2,7 @@ const babel = require('gulp-babel'); const concat = require('gulp-concat'); const cssmin = require('gulp-cssmin'); const del = require('del'); +const exec = require('child_process').exec; const gulp = require('gulp'); const gulpif = require('gulp-if'); const postcss = require('gulp-postcss'); @@ -74,6 +75,32 @@ function watch() { }, scripts)); } +/** + * Generate the language files to be consumed by front end. + * + * @returns {Promise} + */ +function i18n() { + return new Promise((resolve, reject) => { + exec('php artisan vue-i18n:generate', {}, (err, stdout, stderr) => { + return err ? reject(err) : resolve({ stdout, stderr }); + }) + }) +} + +/** + * Generate the routes file to be used in Vue files. + * + * @returns {Promise} + */ +function routes() { + return new Promise((resolve, reject) => { + exec('php artisan ziggy:generate resources/assets/scripts/helpers/ziggy.js', {}, (err, stdout, stderr) => { + return err ? reject(err) : resolve({ stdout, stderr }); + }); + }) +} + /** * Cleanup unused versions of hashed assets. */ @@ -82,9 +109,12 @@ function clean() { } exports.clean = clean; +exports.i18n = i18n; +exports.routes = routes; exports.styles = styles; exports.scripts = scripts; exports.watch = watch; +gulp.task('components', gulp.parallel(i18n, routes)); gulp.task('scripts', gulp.series(clean, scripts)); -gulp.task('default', gulp.series(clean, styles, scripts)); +gulp.task('default', gulp.series(clean, i18n, routes, styles, scripts)); diff --git a/package.json b/package.json index a790e437f..1eea87689 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "build:filemanager": "./node_modules/babel-cli/bin/babel.js public/themes/pterodactyl/js/frontend/files/src --source-maps --out-file public/themes/pterodactyl/js/frontend/files/filemanager.min.js", "watch": "./node_modules/gulp-cli/bin/gulp.js watch", "build": "./node_modules/gulp-cli/bin/gulp.js default", + "build:components": "./node_modules/gulp-cli/bin/gulp.js components", "build:styles": "./node_modules/gulp-cli/bin/gulp.js styles", "build:scripts": "./node_modules/gulp-cli/bin/gulp.js scripts" },