watermarkchurch/contentful-schema-diff

Bug: Content type argument doesn't work

Sammii opened this issue · 9 comments

When including --content-type MYCONTENTTYPE in the command, the generated file still includes every file type from the export.

Example:
contentful-schema-diff --from MY-EXPORT-1.json --to MY-EXPORT-2.json -c image --one-file --out diff-output/

I expect that the above command would generate a diff file that only contains changes to image content type, but instead, it includes changes from all content types in the export files.

Hi Sammii,

Thanks for the bug report! It would be helpful if you can attach a minimal my-export-1.json and my-export-2.json which illustrates the problem. Please also tell me which version you are using with contentful-schema-diff --version

Hi @gburgett ! Do you have a recommendation for how to provide the export information without providing the actual details from my Space?

I am using version 0.9.4.

I suppose you can open the json file, rename your space ID, and delete any non-relevant content types. To reproduce this bug, I would expect there to be two content types in each json file, one with the ID image and one with a different ID.

Hi @Sammii , is this still an issue for you?

@gburgett Yes, this issue is still happening. The reason I never replied to your last question was that, since this command is exporting many content types from my entire Space, I wasn't comfortable divulging that data about my site.

The issue becomes more apparent when omitting the --one-file argument, as it more clearly reveals the number of content type changes that are being exported.

I did a bit more investigation and found the following:

If I run the command using "Method 1: download content types from the space directly" then it works as expected.
contentful-schema-diff --from <space-id> --to <environment> -c <content-type> --token <token>

But it is when I run the command using "Method 2: Export the files first" that the --content-type fails to work.
contentful-schema-diff --from <export1.json> --to <export2.json> -c <content-type> --token <token>

The command above generated 19 files for 19 content types. I expected just 1 file for the specified content type (which is included in the list of 19).

Ah thanks for that info! Yes those two methods go through two different code paths, and I don't think I ever implemented the --content-type flag for Method 2! I'll do that soon as I get some time. Or if you'd like to submit a pull request to filter out the content types based on that argument, I'd accept it!

Hi @gburgett, I've created a local branch to fix the issue but don't have permission to push to the remote. Mind if I get access so I can open that PR you mentioned? :)

Thanks Samii! The best way to create a PR is to fork the repository to your personal github account, and then push the branch to your fork. Then you can submit a PR from that fork.

Thanks for the nudge in the right direction @gburgett; think I got it now: #137