Skip to content

Conversation

@rs-amp
Copy link
Contributor

@rs-amp rs-amp commented Jun 17, 2021

(Previous feedback on my fork, at rs-amp#1 )

This command allows you to print a dependency tree for any folder of content items on your system. The input directory should contain content items in the same format that the export command generates. It does not require repo/folder layouts, just that all dependent content is contained within the parent directory.

dc-cli content-item tree <dir>

This uses the same dependency tree class as the import task, which uses it to import the deepest content items first so that references can be properly resolved. Here, the "levels" of content items are maintained, and the highest level (most layers of dependencies) is printed first, followed by the lower levels that have not been printed yet.

Each item shows the items that it references or links via a tree structure:

=== LEVEL 3 (1) ===
item1 
├─ item2 
│  └─ item4 
└─ item3 

=== LEVEL 2 (2) ===
item6 
└─ item5 

=== LEVEL 1 (4) ===
item7

When items have been printed before, their name is shown in brackets and their children are not printed. This saves a lot of space on the tree for content items that are reused a lot.

Circular dependencies are a possibility within DC. Like the import task, they are separated from the rest of the tree into a list of "circular dependencies", now ordered by depth to our best ability.

=== CIRCULAR (3) ===
item1 ═════════════════╗
├─ item2               ║
│  └─ item4            ║
│     └─ *** (item1) ══╝
└─ (item3) 

Overlapping circular dependencies with ordering:

=== CIRCULAR (6) ===
item5 ══════════════╗
└─ item6            ║
   └─ *** (item5) ══╝

item1 ══════════════════════╗
└─ item2 ═════════════════╗ ║
   └─ item3               ║ ║
      ├─ *** (item2) ═════╝ ║
      └─ item4              ║
         ├─ *** (item1) ════╝
         └─ (item5) 

This is useful for examining the dependency structure of content that has been created, and identifying potential problems you might encounter when importing content items to a hub. Since circular dependencies are undesirable and sometimes hard to track manually, it's a useful way of identifying them for removal.

This PR also changes the behaviour of importing content with circular dependencies. The circular dependencies are now imported in order of depth first, and should correctly nullify content references that are not yet available. This will not fix required circular dependencies, but it will fix imports for all circular dependencies that do not use required fields.

This PR is built on top of the feature/clone branch. It's in this repo for easier review.

@rs-amp rs-amp requested a review from easen-amp June 17, 2021 11:14
@rs-amp rs-amp merged commit 39bdddf into amplience:master Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants