Have npm run typings use built directory; fix typescript tests

* Modify scripts/gulpfiles/typings.js to write typings to BUILD_DIR.
* Modify tests/scripts/compile_typings.sh to check compilability of
  resulting output from BUILD_DIR.
* Rename checkin script to checkin:built, add a checkin:typings script
  to do the same for .d.ts files, and a new checkin script to do both.
* Have recompile run checkin:typings.
This commit is contained in:
Christopher Allen
2021-06-29 16:25:36 +01:00
parent 1aa35ef438
commit 37ecce8d80
5 changed files with 28 additions and 12 deletions

View File

@@ -178,6 +178,7 @@ const recompile = gulp.series(
buildTasks.build,
buildTasks.checkinBuilt,
typings.typings,
typings.checkinTypings,
gitTasks.pushRebuildBranch
);

View File

@@ -16,6 +16,7 @@ var path = require('path');
var fs = require('fs');
var rimraf = require('rimraf');
var execSync = require('child_process').execSync;
var {BUILD_DIR} = require('./config');
/**
* Recursively generates a list of file paths with the specified extension
@@ -94,7 +95,7 @@ function typings() {
];
return gulp.src(srcs)
.pipe(gulp.concat('blockly.d.ts'))
.pipe(gulp.dest('typings'))
.pipe(gulp.dest(BUILD_DIR))
.on('end', function () {
// Clean up tmp directory.
if (fs.existsSync(tmpDir)) {
@@ -110,12 +111,24 @@ function msgTypings(cb) {
msgFiles.forEach(msg => {
const localeName = msg.substring(0, msg.indexOf('.json'));
const msgTypings = template.slice().replace(/<%= locale %>/gi, localeName);
fs.writeFileSync(path.join('typings', 'msg', localeName + '.d.ts'), msgTypings, 'utf-8');
fs.writeFileSync(path.join(BUILD_DIR, 'msg', localeName + '.d.ts'), msgTypings, 'utf-8');
})
cb();
}
/**
* This task copies built files from BUILD_DIR back to the repository
* so they can be committed to git.
*/
function checkinTypings() {
return gulp.src([
`${BUILD_DIR}/**.d.ts`,
`${BUILD_DIR}/**/**.d.ts`,
]).pipe(gulp.dest('typings'));
};
module.exports = {
typings: typings,
msgTypings: msgTypings
msgTypings: msgTypings,
checkinTypings: checkinTypings,
};