diff --git a/gulpfile.js b/gulpfile.js index 65cecb977..9f707bfa0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -32,10 +32,9 @@ module.exports = { buildCompressed: buildTasks.compressed, buildGenerators: buildTasks.generators, buildAdvancedCompilationTest: buildTasks.advancedCompilationTest, + checkin: gulp.series(buildTasks.checkinBuilt, typings.checkinTypings), checkinBuilt: buildTasks.checkinBuilt, - clean: gulp.series( - buildTasks.cleanBuildDir, - packageTasks.cleanReleaseDir), + clean: gulp.series(buildTasks.cleanBuildDir, packageTasks.cleanReleaseDir), cleanBuildDir: buildTasks.cleanBuildDir, cleanReleaseDir: packageTasks.cleanReleaseDir, gitSyncDevelop: gitTasks.syncDevelop, @@ -43,6 +42,7 @@ module.exports = { gitCreateRC: gitTasks.createRC, gitUpdateGithubPages: gitTasks.updateGithubPages, typings: gulp.series(typings.typings, typings.msgTypings), + checkinTypings: typings.checkinTypings, package: packageTasks.package, checkLicenses: licenseTasks.checkLicenses, recompile: releaseTasks.recompile, diff --git a/package.json b/package.json index 7f345709d..41308cf5e 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,9 @@ "clean": "gulp clean", "clean:build": "gulp cleanBuildDir", "clean:release": "gulp cleanReleaseDir", - "checkin": "gulp checkinBuilt", + "checkin": "gulp checkin", + "checkin:built": "gulp checkinBuilt", + "checkin:typings": "gulp checkinTypings", "deployDemos": "gulp deployDemos", "format": "git-clang-format", "format:sortrequires": "gulp sortRequires", diff --git a/scripts/gulpfiles/release_tasks.js b/scripts/gulpfiles/release_tasks.js index b0faa759f..c4480f06c 100644 --- a/scripts/gulpfiles/release_tasks.js +++ b/scripts/gulpfiles/release_tasks.js @@ -178,6 +178,7 @@ const recompile = gulp.series( buildTasks.build, buildTasks.checkinBuilt, typings.typings, + typings.checkinTypings, gitTasks.pushRebuildBranch ); diff --git a/scripts/gulpfiles/typings.js b/scripts/gulpfiles/typings.js index 67b94f59c..4f4a82845 100644 --- a/scripts/gulpfiles/typings.js +++ b/scripts/gulpfiles/typings.js @@ -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, }; diff --git a/tests/scripts/compile_typings.sh b/tests/scripts/compile_typings.sh index ee16beb56..893407732 100755 --- a/tests/scripts/compile_typings.sh +++ b/tests/scripts/compile_typings.sh @@ -1,21 +1,21 @@ #!/bin/bash +# Location that npm run typings will write .d.ts files to. +readonly BUILD_DIR='built' + # ANSI colors BOLD_GREEN='\033[1;32m' BOLD_RED='\033[1;31m' ANSI_RESET='\033[0m' -# Download TypeScript to obtain the compiler. -echo "Downloading TypeScript" -npm install typescript - # Generate Blockly typings. echo "Generating Blockly typings" npm run typings # Use the TypeScript compiler to compile the generated typings. echo "Compiling typings" -cd typings + +cd "${BUILD_DIR}" ../node_modules/.bin/tsc blockly.d.ts