Skip to content
Permalink
Browse files

Add support for build tasks to update localized task.json versions (#110

)

* Allow scripts to update localized task.json versions
* Update task.loc.json in common task code
* Use more conservative loc manifests algorithm
  • Loading branch information...
erdennis13 authored and jessehouwing committed Mar 5, 2019
1 parent a6e87d2 commit f7ea5e929eb7852942bc98ce1857b3f22a78e361
Showing with 31 additions and 11 deletions.
  1. +16 −2 BuildTasks/Common/Common.ts
  2. +15 −9 scripts/setTaskVersion.js
@@ -486,13 +486,27 @@ function getTaskManifestPaths(manifestPath: string, manifest: object): string[]
tl.debug(`Found task: ${task}`);
const taskRoot: string = path.join(rootFolder, task);
const rootManifest: string = path.join(taskRoot, "task.json");

let localizationRoot = tl.getInput("localizationRoot", false);
if (localizationRoot) {
localizationRoot = path.resolve(localizationRoot);
}

if (tl.exist(rootManifest)) {
tl.debug(`Found single-task manifest: ${rootManifest}`);
return (result).concat([rootManifest]);
let rootManifests: string[] = [rootManifest];
const rootLocManifest: string = path.join(localizationRoot || taskRoot, "task.loc.json");
if (tl.exist(rootLocManifest)) {
tl.debug(`Found localized single-task manifest: ${rootLocManifest}`);
rootManifests.push(rootLocManifest);
}
return (result).concat(rootManifests);
} else {
const versionManifests = tl.findMatch(taskRoot, "*/task.json");
const locVersionManifests = tl.findMatch(localizationRoot || taskRoot, "*/task.loc.json");
tl.debug(`Found multi-task manifests: ${versionManifests.join(", ")}`);
return (result).concat(versionManifests);
tl.debug(`Found multi-task localized manifests: ${locVersionManifests.join(", ")}`);
return (result).concat(versionManifests).concat(locVersionManifests);
}
}, []);
}
@@ -24,14 +24,20 @@ console.log("Setting all task versions to: " + JSON.stringify(newVersion));
var buildTasksDir = path.join(__dirname, "../BuildTasks");
var buildTaskNames = getBuildTasks();
buildTaskNames.forEach(function(name) {
var taskJsonFile = path.join(buildTasksDir, name, "task.json");
console.log("Updating: " + taskJsonFile);
if (fs.existsSync(taskJsonFile)) {
var task = jsonfile.readFileSync(taskJsonFile);

task["version"] = newVersion;

jsonfile.writeFileSync(taskJsonFile, task, {spaces: 2, EOL: '\r\n'});
}
var taskJsonFiles = [
path.join(buildTasksDir, name, "task.json"),
path.join(buildTasksDir, name, "task.loc.json")
];

taskJsonFiles.forEach(function(taskJsonFile) {
console.log("Updating: " + taskJsonFile);
if (fs.existsSync(taskJsonFile)) {
var task = jsonfile.readFileSync(taskJsonFile);

task["version"] = newVersion;

jsonfile.writeFileSync(taskJsonFile, task, {spaces: 2, EOL: '\r\n'});
}
});
});

0 comments on commit f7ea5e9

Please sign in to comment.
You can’t perform that action at this time.