Skip to content

Commit

Permalink
Merge pull request #33 from ibm-wch/rel3.2.3
Browse files Browse the repository at this point in the history
release 3.2.3 code changes
  • Loading branch information
Kevin Tapperson authored Oct 30, 2018
2 parents 2407887 + bae90a9 commit d34a0cb
Show file tree
Hide file tree
Showing 73 changed files with 5,040 additions and 1,760 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*.gitattributes eol=crlf
*.zip binary
*.gz binary
*.md binary
*.jpg binary
*.gif binary
*.png binary
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# Changelog

### 3.2 changes since 3.1

- Add full support for push, pull, list, delete, and compare of multiple site definitions and the associated pages. The site-context option can be used to specify a site for an operation.
- Add prompts when deleting a page, if drafts of that page will be cancelled, or if children of that page will also be deleted.
- Add --set-tag <tagname> to the push command, to optionally set a tag on assets, contents and types, when pushed
- Add a warning after successful push, if --publish-now not specified and a publishing schedule is set, that may delay the publishing of the ready artifacts that were just pushed.
- Update manifest support to handle placeholder sites
- Update paging support to use the next links provided in service responses

### 3.1 changes since 3.0

- Add latent support for push, pull, list, and compare of multiple sites. The artifact file name for a non-default site is based on the contextRoot property of the site. The artifact file name for a draft site is further qualifed by appending the site's project id, or "draft" if the site is not part of a project.
- Add latent support for push, pull, list, and compare of multiple sites. The artifact file name for a non-default site is based on the contextRoot property of the site. The artifact file name for a draft site is further qualifed by appending "_wchdraft" and the site's project id, if the site is part of a project.
- Add support for push, pull, and list of pages by path. This is the same as the existing functionality for web assets, types, layouts, and layout mappings.
- Add support for push, pull, list, and compare of orphaned resources.
- Fix a bug with the creation of minimal asset metadata when run with the createOnly option.
Expand Down
87 changes: 67 additions & 20 deletions CLI/commands/compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ class CompareCommand extends BaseCommand {
*/
initSitesForCompare (context) {
const self = this;
const helper = ToolsApi.getSitesHelper();

// Create a combined list of sites for the source and target.
const siteList = [];
// Create ready and draft site lists to store the sites from both the source and target.
const readySites = [];
const draftSites = [];

// Obtain the list of sites for the source.
const remote = utils.isValidApiUrl(self.getSource());
Expand All @@ -136,12 +138,16 @@ class CompareCommand extends BaseCommand {
}
return self.initSites(context, remote, sourceOpts)
.then(function () {
// Add the source sites to the combined list.
// Add each source site to one of the combined site lists.
context.siteList.forEach(function (siteItem) {
siteList.push(siteItem);
if (helper.getStatus(context, siteItem, self.getApiOptions()) === "draft") {
draftSites.push(siteItem);
} else {
readySites.push(siteItem);
}
});

// Delete the context site list, so that the target list is not filtered using the source list.
// Delete the context site list, so that the target site list isn't filtered using the source site list.
delete context.siteList;

// Obtain the list of sites for the target.
Expand All @@ -155,21 +161,33 @@ class CompareCommand extends BaseCommand {
return self.initSites(context, remote, targetOpts);
})
.then(function () {
// Add the target sites to the combined list.
// Add each target site to one of the combined site lists.
context.siteList.forEach(function (siteItem) {
// Determine whether the tartget site already exists in the combined list.
const exists = siteList.some(function (site) {
return site.id === siteItem.id
});
if (helper.getStatus(context, siteItem, self.getApiOptions()) === "draft") {
// Determine whether the draft target site already exists in the combined draft sites list.
const exists = draftSites.some(function (site) {
return site.id === siteItem.id
});

// Add the draft target site to the combined draft site list if it isn't already there.
if (!exists) {
draftSites.push(siteItem);
}
} else {
// Determine whether the ready target site already exists in the combined ready sites list.
const exists = readySites.some(function (site) {
return site.id === siteItem.id
});

// Add the target site to the combined list if it isn't already in the list.
if (!exists) {
siteList.push(siteItem);
// Add the ready target site to the combined ready site list if it isn't already there.
if (!exists) {
readySites.push(siteItem);
}
}
});

// Set the context site list to the combined list of source and target sites.
context.siteList = siteList;
context.siteList = self.createSiteList(readySites, draftSites);
});
}

Expand Down Expand Up @@ -204,6 +222,10 @@ class CompareCommand extends BaseCommand {
// Make sure the "path" option can be handled successfully.
return self.handlePathOption();
})
.then(function () {
// Handle the site-context option.
return self.handleSiteContextOption();
})
.then(function () {
// Handle the ready and draft options.
return self.handleReadyDraftOptions();
Expand Down Expand Up @@ -555,8 +577,15 @@ class CompareCommand extends BaseCommand {

// The API emits an event when an item is different, so we display it for the user.
const artifactDiff = function (diff) {
const messageKey = "cli_compare_" + serviceToMessageKey[diff.artifactName] + "_diff";
const message = i18n.__(messageKey, {id: diff.item.path||diff.item.name||diff.item.id});
let messageKey;
let message;
if (diff.artifactName === "sites") {
messageKey = "cli_compare_site_diff";
message = i18n.__(messageKey, {contextName: ToolsApi.getSitesHelper().getSiteContextName(diff.item)});
} else {
messageKey = "cli_compare_" + serviceToMessageKey[diff.artifactName] + "_diff";
message = i18n.__(messageKey, {id: diff.item.path || diff.item.name || diff.item.id});
}
self.getLogger().info(message);
if (verbose) {
if (diff.diffs) {
Expand Down Expand Up @@ -591,16 +620,33 @@ class CompareCommand extends BaseCommand {

// The API emits an event when an item is added, so we display it for the user.
const artifactAdded = function (diff) {
const messageKey = "cli_compare_" + serviceToMessageKey[diff.artifactName] + "_added";
const message = i18n.__(messageKey, {id: diff.item.path||diff.item.name||diff.item.id});
let messageKey;
let message;
if (diff.artifactName === "sites") {
messageKey = "cli_compare_site_added";
message = i18n.__(messageKey, {contextName: ToolsApi.getSitesHelper().getSiteContextName(diff.item)});
} else {
messageKey = "cli_compare_" + serviceToMessageKey[diff.artifactName] + "_added";
message = i18n.__(messageKey, {id: diff.item.path || diff.item.name || diff.item.id});
}
self.getLogger().info(message);
};
emitter.on(EVENT_ITEM_ADDED, artifactAdded);

// The API emits an event when an item is removed, so we display it for the user.
const artifactRemoved = function (diff) {
const messageKey = "cli_compare_" + serviceToMessageKey[diff.artifactName] + "_removed";
const message = i18n.__(messageKey, {id: diff.item.path||diff.item.name||diff.item.id});
let messageKey;
let message;
if (diff.artifactName === "sites") {
messageKey = "cli_compare_site_removed";
message = i18n.__(messageKey, {contextName: ToolsApi.getSitesHelper().getSiteContextName(diff.item)});
} else {
messageKey = "cli_compare_" + serviceToMessageKey[diff.artifactName] + "_removed";
message = i18n.__(messageKey, {id: diff.item.path || diff.item.name || diff.item.id});
}



self.getLogger().info(message);
};
emitter.on(EVENT_ITEM_REMOVED, artifactRemoved);
Expand Down Expand Up @@ -868,6 +914,7 @@ function compareCommand (program) {
.option('-A --all-authoring', i18n.__('cli_compare_opt_all'))
.option('--ready', i18n.__('cli_compare_opt_ready'))
.option('--draft', i18n.__('cli_compare_opt_draft'))
.option('--site-context <contextRoot>', i18n.__('cli_compare_opt_siteContext'))
.option('--manifest <manifest>', i18n.__('cli_compare_opt_use_manifest'))
.option('--filter-deletions <manifest>', i18n.__('cli_compare_opt_filter_deletions'))
.option('--write-manifest <manifest>', i18n.__('cli_compare_opt_write_manifest'))
Expand Down
Loading

0 comments on commit d34a0cb

Please sign in to comment.