fix(build): Update appengine deployment to include built files

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.
This commit is contained in:
Christopher Allen
2022-10-04 16:26:47 +01:00
parent 8d06fe74c2
commit 6a7d01ab59

View File

@@ -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.