Merge branch 'release' into mdonev-merge-release-resourceid-fix

This commit is contained in:
Manol Donev
2019-02-22 15:37:32 +02:00
2 changed files with 42 additions and 38 deletions

View File

@ -3,13 +3,13 @@ var shelljs = require("shelljs");
var path = require("path"); var path = require("path");
var fs = require("fs"); var fs = require("fs");
module.exports = function(grunt) { module.exports = function (grunt) {
if (grunt.option('profile')) { if (grunt.option('profile')) {
grunt.log.writeln('Profiling all grunt tasks...'); grunt.log.writeln('Profiling all grunt tasks...');
require('time-grunt')(grunt); require('time-grunt')(grunt);
} }
if (grunt.cli.tasks.indexOf("testsapp") >= 0 || grunt.cli.tasks.indexOf("buildOnlyTestsApp")>= 0 || grunt.cli.tasks.indexOf("runOnlyTestsApp")>= 0) { if (grunt.cli.tasks.indexOf("testsapp") >= 0 || grunt.cli.tasks.indexOf("buildOnlyTestsApp") >= 0 || grunt.cli.tasks.indexOf("runOnlyTestsApp") >= 0) {
var tsTester = require("./build/run-testsapp.grunt.js"); var tsTester = require("./build/run-testsapp.grunt.js");
tsTester.run(grunt); tsTester.run(grunt);
return; return;
@ -22,7 +22,7 @@ module.exports = function(grunt) {
} }
// Custom Functions // Custom Functions
var filterTypeScriptFiles = function(content, srcPath) { var filterTypeScriptFiles = function (content, srcPath) {
var leadingPrivate = /^.*@private/ig; var leadingPrivate = /^.*@private/ig;
if (leadingPrivate.test(content)) { if (leadingPrivate.test(content)) {
return false; return false;
@ -38,16 +38,15 @@ module.exports = function(grunt) {
return processed; return processed;
}; };
var updatePackageDef = function(content, update) var updatePackageDef = function (content, update) {
{
var contentAsObject = JSON.parse(content); var contentAsObject = JSON.parse(content);
update(contentAsObject); update(contentAsObject);
return JSON.stringify(contentAsObject, null, "\t"); return JSON.stringify(contentAsObject, null, "\t");
}; };
var updateModulesPackageDef = function(content, srcPath) { var updateModulesPackageDef = function (content, srcPath) {
console.log("Patch: " + srcPath); console.log("Patch: " + srcPath);
return updatePackageDef(content, function(contentAsObject) { return updatePackageDef(content, function (contentAsObject) {
contentAsObject.version = localCfg.packageVersion; contentAsObject.version = localCfg.packageVersion;
if (localCfg.commitSHA) { if (localCfg.commitSHA) {
contentAsObject.repository.url += "/commit/" + localCfg.commitSHA; contentAsObject.repository.url += "/commit/" + localCfg.commitSHA;
@ -55,27 +54,27 @@ module.exports = function(grunt) {
}); });
}; };
var updateAppPackageDef = function(content, srcPath) { var updateAppPackageDef = function (content, srcPath) {
return updatePackageDef(content, function(contentAsObject) { return updatePackageDef(content, function (contentAsObject) {
contentAsObject.version = localCfg.packageVersion; contentAsObject.version = localCfg.packageVersion;
}); });
}; };
var getCommitSha = function() { var getCommitSha = function () {
if (process.env.GIT_COMMIT) { if (process.env.GIT_COMMIT) {
return process.env.GIT_COMMIT; return process.env.GIT_COMMIT;
} }
return ""; return "";
}; };
var assignGitSHA = function(err, stdout, stderr, cb) { var assignGitSHA = function (err, stdout, stderr, cb) {
if (!localCfg.commitSHA) { if (!localCfg.commitSHA) {
localCfg.commitSHA = stdout.replace("\n", ""); localCfg.commitSHA = stdout.replace("\n", "");
} }
cb(); cb();
}; };
var getPackageVersion = function() { var getPackageVersion = function () {
var buildVersion = process.env.PACKAGE_VERSION; var buildVersion = process.env.PACKAGE_VERSION;
if (!buildVersion) { if (!buildVersion) {
return localCfg.mainPackageContent.version; return localCfg.mainPackageContent.version;
@ -124,7 +123,7 @@ module.exports = function(grunt) {
"!.*/**/*.*", "!.*/**/*.*",
"!obj/**/*.*" "!obj/**/*.*"
]; ];
localCfg.defaultExcludes = localCfg.typeScriptSrc.filter(function(item) { return /^!/.test(item); }); localCfg.defaultExcludes = localCfg.typeScriptSrc.filter(function (item) { return /^!/.test(item); });
localCfg.srcTsdFiles = [ localCfg.srcTsdFiles = [
"tns-core-modules/**/*.d.ts", "tns-core-modules/**/*.d.ts",
"!tns-core-modules/ios/**", "!tns-core-modules/ios/**",
@ -137,7 +136,7 @@ module.exports = function(grunt) {
// Config // Config
grunt.initConfig({ grunt.initConfig({
localCfg : localCfg, localCfg: localCfg,
pkg: grunt.file.readJSON('package.json'), pkg: grunt.file.readJSON('package.json'),
clean: { clean: {
build: { build: {
@ -166,10 +165,10 @@ module.exports = function(grunt) {
}, },
}, },
articles: { articles: {
src: [ localCfg.outArticlesDir ] src: [localCfg.outArticlesDir]
}, },
"apiref": { "apiref": {
src: [ localCfg.outApiRefDir ] src: [localCfg.outApiRefDir]
} }
}, },
copy: { copy: {
@ -186,7 +185,7 @@ module.exports = function(grunt) {
}, },
articleMDs: { articleMDs: {
expand: true, expand: true,
src: [ "**/*.md" ], src: ["**/*.md"],
dest: localCfg.outArticlesDir, dest: localCfg.outArticlesDir,
cwd: localCfg.srcTestsDir cwd: localCfg.srcTestsDir
}, },
@ -258,7 +257,6 @@ module.exports = function(grunt) {
expand: true, expand: true,
src: [ src: [
'**/*', '**/*',
'!*.md',
'!node_modules/**/*', '!node_modules/**/*',
'!unit-tests/**/*', '!unit-tests/**/*',
], ],
@ -267,6 +265,10 @@ module.exports = function(grunt) {
} }
}, },
exec: { exec: {
copyReadme: {
cmd: `cp "README.md" ${localCfg.outTnsCoreModules}`,
cwd: process.cwd()
},
packModules: { packModules: {
cmd: "npm pack", cmd: "npm pack",
cwd: localCfg.outTnsCoreModules + "/" cwd: localCfg.outTnsCoreModules + "/"
@ -342,31 +344,31 @@ module.exports = function(grunt) {
'tns-core-modules/**/package.json', 'tns-core-modules/**/package.json',
'!tns-core-modules/node_modules/**/*' '!tns-core-modules/node_modules/**/*'
]); ]);
var errors = packageDescriptors.map(function(packagePath) { var errors = packageDescriptors.map(function (packagePath) {
if (fileValidator(packagePath)) { if (fileValidator(packagePath)) {
return errorFormatter(packagePath); return errorFormatter(packagePath);
} else { } else {
return null; return null;
} }
}).filter(function(errorMessage) { return !!errorMessage; }); }).filter(function (errorMessage) { return !!errorMessage; });
if (errors.length > 0) if (errors.length > 0)
grunt.fail.fatal("\n" + errors.join("\n")); grunt.fail.fatal("\n" + errors.join("\n"));
} }
grunt.registerTask("check-packagejson-boms", function() { grunt.registerTask("check-packagejson-boms", function () {
validatePackageJsons(function (filepath) { validatePackageJsons(function (filepath) {
var buf = grunt.file.read(filepath, { encoding: null }); var buf = grunt.file.read(filepath, { encoding: null });
return (buf[0] === 0xEF && buf[1] === 0xBB && buf[2] === 0xBF); return (buf[0] === 0xEF && buf[1] === 0xBB && buf[2] === 0xBF);
}, function(filepath) { }, function (filepath) {
return "File " + filepath + " contains a UTF-8 BOM."; return "File " + filepath + " contains a UTF-8 BOM.";
}); });
}); });
grunt.registerTask("check-packagejson-mains", function() { grunt.registerTask("check-packagejson-mains", function () {
validatePackageJsons(function (filepath) { validatePackageJsons(function (filepath) {
var packageData = grunt.file.readJSON(filepath); var packageData = grunt.file.readJSON(filepath);
return /\.js/i.test(packageData.main || ""); return /\.js/i.test(packageData.main || "");
}, function(filepath) { }, function (filepath) {
return "File " + filepath + " contains a broken main setting."; return "File " + filepath + " contains a broken main setting.";
}); });
}); });
@ -376,6 +378,7 @@ module.exports = function(grunt) {
"compile-modules", "compile-modules",
"run-unit-test", "run-unit-test",
"copy:modulesPackageDef", "copy:modulesPackageDef",
"exec:copyReadme",
"exec:packModules" "exec:packModules"
]); ]);
@ -400,10 +403,10 @@ module.exports = function(grunt) {
"typedoc:build" "typedoc:build"
]); ]);
grunt.registerTask("herdArticles", function() { grunt.registerTask("herdArticles", function () {
var moveSinglesUp = function(dir) { var moveSinglesUp = function (dir) {
var objs = fs.readdirSync(dir); var objs = fs.readdirSync(dir);
for (var i=0; i<objs.length; i++) { for (var i = 0; i < objs.length; i++) {
var obj = objs[i]; var obj = objs[i];
var fullPath = path.join(dir, obj); var fullPath = path.join(dir, obj);
if (objs.length == 1) { if (objs.length == 1) {
@ -442,14 +445,14 @@ module.exports = function(grunt) {
"copy:apps", "copy:apps",
]); ]);
grunt.registerTask("pack-apps", function(){ grunt.registerTask("pack-apps", function () {
localCfg.srcAppDirs.forEach(function(srcAppDir){ localCfg.srcAppDirs.forEach(function (srcAppDir) {
var outAppDir = path.join(localCfg.outDir, srcAppDir); var outAppDir = path.join(localCfg.outDir, srcAppDir);
var packageJsonPath = path.join(outAppDir, "package.json"); var packageJsonPath = path.join(outAppDir, "package.json");
var content = fs.readFileSync(packageJsonPath, "utf8"); var content = fs.readFileSync(packageJsonPath, "utf8");
var newContent = updateAppPackageDef(content); var newContent = updateAppPackageDef(content);
fs.writeFileSync(packageJsonPath, newContent); fs.writeFileSync(packageJsonPath, newContent);
shelljs.exec("npm pack", {cwd: outAppDir}); shelljs.exec("npm pack", { cwd: outAppDir });
}); });
}); });

View File

@ -87,19 +87,19 @@ export function _setAndroidFragmentTransitions(
} }
let useLollipopTransition = !!(name && (name.indexOf("slide") === 0 || name === "fade" || name === "explode") && sdkVersion() >= 21); let useLollipopTransition = !!(name && (name.indexOf("slide") === 0 || name === "fade" || name === "explode") && sdkVersion() >= 21);
// [nested frames / fragments] force disable lollipop transitions in case nested fragments // [nested frames / fragments] force disable lollipop transitions in case nested fragments
// are detected as applying dummy animator to the nested fragment with the same duration as // are detected as applying dummy animator to the nested fragment with the same duration as
// the exit animator of the removing parent fragment as a workaround for // the exit animator of the removing parent fragment as a workaround for
// https://code.google.com/p/android/issues/detail?id=55228 works only if custom animations are // https://code.google.com/p/android/issues/detail?id=55228 works only if custom animations are
// used // used
// NOTE: this effectively means you cannot use Explode transition in nested frames scenarios as // NOTE: this effectively means you cannot use Explode transition in nested frames scenarios as
// we have implementations only for slide, fade, and flip // we have implementations only for slide, fade, and flip
if (currentFragment && if (currentFragment &&
currentFragment.getChildFragmentManager() && currentFragment.getChildFragmentManager() &&
currentFragment.getChildFragmentManager().getFragments().toArray().length > 0) { currentFragment.getChildFragmentManager().getFragments().toArray().length > 0) {
useLollipopTransition = false; useLollipopTransition = false;
} }
if (!animated) { if (!animated) {
name = "none"; name = "none";
} else if (transition) { } else if (transition) {
@ -114,8 +114,9 @@ export function _setAndroidFragmentTransitions(
let currentFragmentNeedsDifferentAnimation = false; let currentFragmentNeedsDifferentAnimation = false;
if (currentEntry) { if (currentEntry) {
_updateTransitions(currentEntry); _updateTransitions(currentEntry);
if (currentEntry.transitionName !== name if (currentEntry.transitionName !== name ||
|| currentEntry.transition !== transition) { currentEntry.transition !== transition ||
!useLollipopTransition) {
clearExitAndReenterTransitions(currentEntry, true); clearExitAndReenterTransitions(currentEntry, true);
currentFragmentNeedsDifferentAnimation = true; currentFragmentNeedsDifferentAnimation = true;
} }