Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-6901 Pm - retainfolderstructure rework #15357

Merged
merged 27 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
22ce4ab
initial tests
dnenov Jun 5, 2024
dba6392
upper case file extension
dnenov Jun 12, 2024
5fd407c
more caps extensions fixes
dnenov Jun 12, 2024
cce52b4
custom definition files delete
dnenov Jun 14, 2024
2a73f09
Merge remote-tracking branch 'upstream/master' into pm-retainfolderst…
dnenov Jun 14, 2024
949ddce
Merge remote-tracking branch 'upstream/master' into pm-retainfolderst…
dnenov Jun 24, 2024
ac2de63
content structure rework
dnenov Jun 24, 2024
5e0e775
major rework
dnenov Jun 26, 2024
1d3759b
revert pkg json removal changes
dnenov Jun 28, 2024
1a787d1
remove redundant TODO comment
dnenov Jun 28, 2024
ff4b76e
Merge branch 'pm-retainfolderstructure-updates' into pm-retainfolders…
dnenov Jun 28, 2024
1d5b229
Merge remote-tracking branch 'upstream/master' into pm-retainfolderst…
dnenov Jun 28, 2024
06eb57a
Merge remote-tracking branch 'upstream/master' into pm-retainfolderst…
dnenov Jun 28, 2024
9a2565c
fixing 'ghost' custom nodes preview
dnenov Jun 28, 2024
b1c1874
test fixes
dnenov Jun 28, 2024
85f89ab
added missing test files
dnenov Jul 3, 2024
3a84a5d
fix expected number of subfolders
dnenov Jul 3, 2024
7a7b56e
Merge branch 'pm-retainfolderstructure-updates' into pm-retainfolders…
dnenov Jul 3, 2024
3d989bd
edge case, test coverage
dnenov Jul 3, 2024
6c18cee
Merge remote-tracking branch 'upstream/master' into pm-retainfolderst…
dnenov Jul 3, 2024
8d65c1d
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into pm-r…
dnenov Jul 3, 2024
2c23ff8
fix breaking API changes
dnenov Jul 11, 2024
237e62f
removed commented out code
dnenov Jul 11, 2024
7ff9621
Merge remote-tracking branch 'upstream/master' into pm-retainfolderst…
dnenov Jul 11, 2024
f57d321
Merge remote-tracking branch 'upstream/master' into pm-retainfolderst…
dnenov Jul 15, 2024
e315e65
tests fix
dnenov Jul 15, 2024
d2c69ec
trying to verify failing test
dnenov Jul 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -895,8 +895,9 @@ public bool RetainFolderStructureOverride
/// <summary>
/// The root directory of the package
/// </summary>
private string CurrentPackageDirectory { get; set; }
private IEnumerable<string> CurrentPackageRootDirectories { get; set; }
private static MetadataLoadContext sharedMetaDataLoadContext = null;

/// <summary>
/// A shared MetaDataLoadContext that is used for assembly inspection during package publishing.
/// This member is shared so the behavior is similar to the ReflectionOnlyLoadContext this is replacing.
Expand Down Expand Up @@ -1073,34 +1074,30 @@ internal List<PackageItemRootViewModel> BindParentToChild(Dictionary<string, Pac
}

// Only add the folder items, they contain the files
var updatedItems = GetRootItems(items);
var updatedItems = OrganizePackageRootItems(items);
return updatedItems;
}

/// <summary>
/// Gets the list PackageItemRootViewModel items which will be at the root directory of the package with all the child items.
/// Organizes package items into root items based on common paths and hierarchical structure.
/// This includes determining root items, establishing parent-child relationships, and collecting all child items.
/// </summary>
/// <param name="items"></param>
/// <returns></returns>
private List<PackageItemRootViewModel> GetRootItems(Dictionary<string, PackageItemRootViewModel> items)
/// <param name="items">A dictionary of package item keys and their corresponding PackageItemRootViewModel objects.</param>
/// <returns>A list of PackageItemRootViewModel items representing the organized root items and their child items.</returns>
private List<PackageItemRootViewModel> OrganizePackageRootItems(Dictionary<string, PackageItemRootViewModel> items)
{
var rootItems = items.Values.Where(x => !x.isChild).ToList();
if (!rootItems.Any()) return rootItems;

var roots = new List<PackageItemRootViewModel>();

var commonPaths = GetCommonPaths(items.Keys.ToArray());
if (commonPaths == null) return null;

if (CurrentPackageDirectory != null)
{
roots.Add(new PackageItemRootViewModel(CurrentPackageDirectory));
}
else
{
var commonPaths = GetCommonPaths(items.Keys.ToArray());
if (commonPaths == null) return null;
CurrentPackageRootDirectories = commonPaths;

// Add a new root item for each common path found
commonPaths.ForEach(p => roots.Add(new PackageItemRootViewModel(p)));
}
// Add a new root item for each common path found
commonPaths.ForEach(p => roots.Add(new PackageItemRootViewModel(p)));

// Check each root item and create any missing connections
foreach (var item in rootItems)
Expand Down Expand Up @@ -1532,7 +1529,7 @@ internal static PublishPackageViewModel FromLocalPackage(DynamoViewModel dynamoV
CopyrightHolder = pkg.CopyrightHolder,
CopyrightYear = pkg.CopyrightYear,
IsPublishFromLocalPackage = true,
CurrentPackageDirectory = pkg.RootDirectory,
CurrentPackageRootDirectories = new List<string> { pkg.RootDirectory },
//default retain folder structure to true when publishing a new version from local.
RetainFolderStructureOverride = retainFolderStructure
};
Expand Down Expand Up @@ -2270,7 +2267,7 @@ private void Submit()
{
// begin submission
var pmExtension = dynamoViewModel.Model.GetPackageManagerExtension();
var handle = pmExtension.PackageManagerClient.PublishAsync(Package, RetainFolderStructureOverride ? updatedFiles : contentFiles, MarkdownFiles, IsNewVersion, RetainFolderStructureOverride);
var handle = pmExtension.PackageManagerClient.PublishAsync(Package, RetainFolderStructureOverride ? updatedFiles : contentFiles, MarkdownFiles, IsNewVersion, CurrentPackageRootDirectories, RetainFolderStructureOverride);

// start upload
Uploading = true;
Expand Down Expand Up @@ -2365,11 +2362,7 @@ private void PublishLocally()
var remapper = new CustomNodePathRemapper(DynamoViewModel.Model.CustomNodeManager,
DynamoModel.IsTestMode);
var builder = new PackageDirectoryBuilder(new MutatingFileSystem(), remapper);
if (string.IsNullOrEmpty(Package.RootDirectory))
{
Package.RootDirectory = CurrentPackageDirectory;
}
builder.BuildRetainDirectory(Package, publishPath, updatedFiles, MarkdownFiles);
builder.BuildRetainDirectory(Package, publishPath, CurrentPackageRootDirectories, updatedFiles, MarkdownFiles);
UploadState = PackageUploadHandle.State.Uploaded;
}
else
Expand Down Expand Up @@ -2770,11 +2763,11 @@ internal PackageItemRootViewModel GetExistingRootItemViewModel(string publishPat
{
if (!PackageContents.Any()) return null;
if (PackageContents.Count(x => x.DependencyType.Equals(DependencyType.Folder)) == 1) {
// If there is only one root item, nest it under the new root package folder
// If there is only one root item, this root item becomes the new folder
var item = PackageContents.First(x => x.DependencyType.Equals(DependencyType.Folder));

item = new PackageItemRootViewModel(Path.Combine(publishPath, packageName));
item.AddChildren(new List<PackageItemRootViewModel> { PackageContents.First() } );
item.AddChildren( PackageContents.First().ChildItems.ToList() );

return item;
}
Expand All @@ -2783,6 +2776,9 @@ internal PackageItemRootViewModel GetExistingRootItemViewModel(string publishPat
var rootItem = new PackageItemRootViewModel(Path.Combine(publishPath, packageName));
foreach(var item in PackageContents)
{
// Skip 'bare' custom nodes, they will be represented by their CustomNodePreview counterparts
if(item.DependencyType.Equals(DependencyType.CustomNode)) { continue; }

item.isChild = true;
rootItem.AddChildren(item);
}
Expand Down
Loading
Loading