From 6a7d01ab59e8bfb18f264aaf96633f2ada3dfaab Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Tue, 4 Oct 2022 16:26:47 +0100 Subject: [PATCH] fix(build): Update appengine deployment to include built files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modify the prepareDemos task as follows: * Use the git index instead of HEAD, so that most local changes will be applied (without copying whatever .gitignored cruft might be in the local directory). 
* Run clean and build and then copy build/msg and dist/*_compressed.js* to the deploy directory. This fixes the problem created by the previous commit, wherein the demos relied on built files that were not being deployed to appengine. --- scripts/gulpfiles/appengine_tasks.js | 39 +++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/scripts/gulpfiles/appengine_tasks.js b/scripts/gulpfiles/appengine_tasks.js index cf2f53948..0bb6408e4 100644 --- a/scripts/gulpfiles/appengine_tasks.js +++ b/scripts/gulpfiles/appengine_tasks.js @@ -14,9 +14,11 @@ var fs = require('fs'); var rimraf = require('rimraf'); var path = require('path'); var execSync = require('child_process').execSync; +const buildTasks = require('./build_tasks.js'); +const packageTasks = require('./package_tasks.js'); var packageJson = require('../../package.json'); - +var packageJson = require('../../package.json'); const demoTmpDir = '../_deploy'; const demoStaticTmpDir = '../_deploy/static'; @@ -33,13 +35,25 @@ function prepareDeployDir(done) { } /** - * Copies all files into static deploy directory except for those under - * appengine. + * Copies all files from current git index into static deploy + * directory. We do this rather than just copying the working tree, + * because the working tree is probably full of leftover editor + * backup-save files, vesigial empty directories, etc. */ function copyStaticSrc(done) { - execSync(`git archive HEAD | tar -x -C ${demoStaticTmpDir}`, + execSync(`GIT_WORK_TREE='${demoStaticTmpDir}' git checkout-index --all`, { stdio: 'inherit' }); - done() + done(); +} + +/** + * Copies needed built files into the static deploy directory. + * + * Prerequisite: clean, build. + */ +function copyBuilt(done) { + return gulp.src(['build/msg/**/*', 'dist/*_compressed.js*'], {base: '.'}) + .pipe(gulp.dest(demoTmpDir)); } /** @@ -127,10 +141,21 @@ function deployBetaAndClean(done) { /** * Prepares demos. + * + * Prerequisites (invoked): clean, build */ const prepareDemos = gulp.series( - prepareDeployDir, copyStaticSrc, copyAppengineSrc, copyPlaygroundDeps); - + prepareDeployDir, + gulp.parallel( + gulp.series( + copyStaticSrc, + copyAppengineSrc), + gulp.series( + gulp.parallel(buildTasks.cleanBuildDir, + packageTasks.cleanReleaseDir), + buildTasks.build, + copyBuilt), + copyPlaygroundDeps)); /** * Deploys demos.