Skip to content

Commit

Permalink
Add support for build tasks to update localized task.json versions (#110
Browse files Browse the repository at this point in the history
)

* 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
ethanis authored and jessehouwing committed Mar 5, 2019
1 parent a6e87d2 commit f7ea5e9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
18 changes: 16 additions & 2 deletions BuildTasks/Common/Common.ts
Expand Up @@ -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);
}
}, []);
}
Expand Down
24 changes: 15 additions & 9 deletions scripts/setTaskVersion.js
Expand Up @@ -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.