Skip to content

Commit

Permalink
Update agg layout process to handle task name change
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsciple committed Dec 1, 2016
1 parent d678aa2 commit 60cd209
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
26 changes: 18 additions & 8 deletions make-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,15 +694,15 @@ var linkNonAggregatedLayoutContent = function (sourceRoot, destRoot, metadataOnl
});
}

var linkAggregatedLayoutContent = function (sourceRoot, destRoot, release, commit) {
var linkAggregatedLayoutContent = function (sourceRoot, destRoot, release, commit, taskDestMap) {
assert(sourceRoot, 'sourceRoot');
assert(destRoot, 'destRoot');
assert(commit, 'commit');
console.log();
console.log(`> Linking ${path.basename(sourceRoot)}`);
mkdir('-p', destRoot);

// process each file/folder within the source root
// process each file/folder within the non-aggregated layout
fs.readdirSync(sourceRoot).forEach(function (itemName) {
// skip files
var taskSourcePath = path.join(sourceRoot, itemName);
Expand All @@ -720,7 +720,13 @@ var linkAggregatedLayoutContent = function (sourceRoot, destRoot, release, commi
}

// determine the dest folder based on the major version
var taskDestPath = path.join(destRoot, itemName + `__v${sourceTask.version.Major}`);
assert(sourceTask.id, 'sourceTask.id');
var taskDestKey = sourceTask.id + '@' + sourceTask.version.Major;
var taskDestPath = taskDestMap[taskDestKey];
if (!taskDestPath) {
taskDestPath = path.join(destRoot, itemName + `__v${sourceTask.version.Major}`);
taskDestMap[taskDestKey] = taskDestPath;
}

if (test('-e', taskDestPath)) {
// validate that a newer minor+patch does not exist in an older release
Expand Down Expand Up @@ -792,9 +798,9 @@ var getRefs = function () {
// get the ref info for HEAD
var info ={
head: {
branch: branch,
commit: commit,
release: release
branch: branch, // e.g. refs/heads/releases/m108
commit: commit, // leading 8 chars only
release: release // e.g. 108 or undefined if not a release branch
},
releases: { }
};
Expand Down Expand Up @@ -885,9 +891,13 @@ var createAggregatedZip = function (packagePath) {
mkdir('-p', aggregatedLayoutPath);
fs.writeFileSync(path.join(aggregatedLayoutPath, 'layout-version.txt'), '2');

// track task GUID + major version -> destination path
// task directory names can change between different release branches
var taskDestMap = { };

// link the tasks from the non-aggregated layout into the aggregated layout
var nonAggregatedLayoutPath = path.join(packagePath, 'non-aggregated-layout');
linkAggregatedLayoutContent(nonAggregatedLayoutPath, aggregatedLayoutPath, /*release:*/'', /*commit:*/refs.head.commit);
linkAggregatedLayoutContent(nonAggregatedLayoutPath, aggregatedLayoutPath, /*release:*/'', /*commit:*/refs.head.commit, taskDestMap);

// link the tasks from previous releases into the aggregated layout
Object.keys(refs.releases)
Expand All @@ -901,7 +911,7 @@ var createAggregatedZip = function (packagePath) {

var commit = refs.releases[release].commit;
var releaseLayout = getNonAggregatedLayout(packagePath, release, commit);
linkAggregatedLayoutContent(releaseLayout, aggregatedLayoutPath, /*release:*/release, /*commit:*/commit);
linkAggregatedLayoutContent(releaseLayout, aggregatedLayoutPath, /*release:*/release, /*commit:*/commit, taskDestMap);
});

// validate task uniqueness within the layout based on task GUID + major version
Expand Down
9 changes: 0 additions & 9 deletions make.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,6 @@ target.testLegacy = function() {
}

target.package = function() {
// validate powershell 5
ensureTool('powershell.exe',
'-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$PSVersionTable.PSVersion.Major"',
function (output) {
if (!Number.parseInt(output) >= 5) {
fail('expected version 5 or higher');
}
});

// clean
rm('-Rf', packagePath);

Expand Down

0 comments on commit 60cd209

Please sign in to comment.