mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
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:
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -178,6 +178,7 @@ const recompile = gulp.series(
|
||||
buildTasks.build,
|
||||
buildTasks.checkinBuilt,
|
||||
typings.typings,
|
||||
typings.checkinTypings,
|
||||
gitTasks.pushRebuildBranch
|
||||
);
|
||||
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user