Skip to content

Remove support for deprecated project structures and configuration#820

Merged
cmoesel merged 21 commits intomasterfrom
remove-deprecated-config
Jun 4, 2021
Merged

Remove support for deprecated project structures and configuration#820
cmoesel merged 21 commits intomasterfrom
remove-deprecated-config

Conversation

@jafeltra
Copy link
Collaborator

This PR removes all the special case handling for legacy FSH tank structures and previously deprecated configuration options. All FSH tanks should have an input/fsh/ directory with FSH files in it. The legacy fsh/ structure and flat tank structures are no longer supported.

When SUSHI encounters an old tank structure, it now logs an error with (hopefully) helpful steps for updating the structure of the tank, and it then exits. The only files that are ever written by SUSHI are now the JSON files from FSH files, the IG definition JSON file, a menu.xml file if specified in configuration, and an index.md file if specified in configuration.

As a part of this, I was able to clean up a lot of code that was used for copying files over from ig-data, creating the SUSHI-GENERATED-FILES file, generating a sushi-config.yaml file, and using the now unsupported history and template configuration properties. I went through the test suites for the files I updated and updated all tests. I also did my best to keep track of the fixtures that were no longer used and deleted those and uninstall dependencies that are no longer used.

This does break a fair number of repositories in the regression script that have not updated to a 1.x version of SUSHI. I tested out using the old project configurations and followed the error message to update the directory structure and things seemed to work for me as I'd expect. However, reviewers should make sure they are sufficient. There's also always a chance I missed other features or parts of the process that we no longer need. If you notice any, please let me know (I'd gladly get to that 50 files changed and 4,000 deletions mark).

jafeltra added 15 commits May 20, 2021 08:04
- Remove handling for legacy tank configurations
- Update IG Exporter to only handle current tank configuration
- Note: tests are not yet updated and additional functions will be removed for output logs
- Remove output log functions
- Clean up dependencies that are no longer used
- Update function arguments and comments that no longer ouptut files
- Log an error if a deprecated config file is used (config.yaml or config.yml)
- Update ensureConfigurationFile tests
…kage-list test to only check for logged error
@ngfreiter ngfreiter self-assigned this May 28, 2021
Copy link
Contributor

@ngfreiter ngfreiter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, this must have been satisfying to do.

- Remove two space tragedy
- Rename igDataPath to inputPath
- Explicitly prefer index.md over index.xml file
- Remove unnecessary variables and patch checks for input path
- Update comments
Copy link
Contributor

@ngfreiter ngfreiter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more minor comments, but looking good.

logger.info(`Copied ${path.join(pagesExportPath, 'index.md')}`);
}
} else if (existsSync(inputIndexXMLPagesPath)) {
} else if (!existsSync(inputIndexMarkdownPagesPath) && existsSync(inputIndexXMLPagesPath)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this else if be combined with the one above so that it is the same as the one on line 308?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Updated in e02ff58

Comment on lines 308 to 312
if (
(!existsSync(inputIndexMarkdownPagesPath) && existsSync(inputIndexXMLPagesPath)) ||
(!existsSync(inputIndexMarkdownPageContentPath) &&
existsSync(inputIndexXMLPageContentPath))
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very nitpicky, but if you had pages/index.md, and pagecontent/index.xml, wouldn't this end up preferring pagecontent/index.xml? Which seems slightly wrong. I think we might want to prefer both md files first, and only then go to xml, so:

if (
!existsSync(inputIndexMarkdownPagesPath) &&
!existsSync(inputIndexMarkdownPageContentPath) &&
(existsSync(inputIndexXMLPagesPath) || existsSync(inputIndexXMLPageContentPath))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think this is a good idea. We can just always prefer either .md file over either .xml file. I think I was still caught up on the pattern that we had established previously, but I think this makes more sense. Updated in e02ff58

@cmoesel cmoesel self-assigned this Jun 3, 2021
Copy link
Member

@cmoesel cmoesel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love seeing all this deleted code. It is so wonderful.

It took a while to review this, so I can't remember everything I commented on (!), but I think it may have been mostly related to updating some comments in the code to make a couple of things more clear.

I also have not yet run regression on this, but plan to do that while I do some other things. Since that takes time and it is nearing end of day, I thought I'd go ahead and post this review now -- and I will come back to indicate how regression went.

pkg.logicals.push(...pkgLogicals);
pkg.resources.push(...pkgResources);
exporter = new IGExporter(pkg, defs, path.resolve(fixtures, 'ig-data'), false);
exporter = new IGExporter(pkg, defs, path.resolve(fixtures, 'ig-data'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this really be using an ig-data folder?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind. I see this was discussed below.

But for the record, I think I would like us to eventually clean this up. But we don't need to do it in this PR. Right now, I'd rather see this PR merged sooner than wait for this cosmetic change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If my searching was accurate, there are 70 files within various test fixture ig-data folders. I really want to update them, but it might also even just be easier to review changes if they're in a separate PR. Otherwise, I do think it would be doable here - it doesn't seem difficult.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to add my vote to doing it another time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Let's do it later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect 🙏

I'll plan to make a PR post-2.0.

@jafeltra
Copy link
Collaborator Author

jafeltra commented Jun 3, 2021

@cmoesel I updated the comments for the template and history properties in the type definitions. I am more than happy to remove them entirely from the types. We previously had error and warning messages when those properties were used, which should be logged in both 0.x and 1.x versions, and if we encourage people to update from 0.x to 1.x first, those warnings should update to errors, and then maybe it's safe to remove them entirely here.

@cmoesel
Copy link
Member

cmoesel commented Jun 3, 2021

@jafeltra -- I think it's fine to leave them in for now. That might help the initial transition go a little easier. And since we're not actually doing anything with them except generating error messages, I think we can remove them later without it being a breaking change (since they are basically non-functional).

@cmoesel
Copy link
Member

cmoesel commented Jun 3, 2021

Changes look good. Just waiting for the regression results now. I know there will be regressions -- I will just be testing that they are only happening where expected.

@cmoesel
Copy link
Member

cmoesel commented Jun 3, 2021

I've run regression and almost everything looks great! My one concern is with US Core. US Core currently uses an approach in which they use SUSHI only for configuration in most builds. As a result, they have neither a fsh folder nor an input/fsh folder (although they do have an input/_fsh folder, but again that is intentional). When SUSHI 1.x runs, it spits out a warning about folder structure and outputs its files to build. I think this is what they want, because they manually copy those and tweak them a bit.

When this PR detects US Core as a legacy project structure since it does not have an input/fsh folder, spits out the error and then exits. If US Core adds an input/fsh folder, then it succeeds, but it generates files to fsh-generated, which I think they are also trying to avoid. So... I'm not sure what the solution is.

I feel like we had some conversations with Eric about this and intentionally implemented some behavior to get what they wanted. Do you remember that? Do you think there is anything we can or should do? Or is there not really a good solution and perhaps they need to rework how they do it on their end?

@jafeltra
Copy link
Collaborator Author

jafeltra commented Jun 4, 2021

Hm this is an interesting case. We definitely support the case for using a current project structure without any FSH to run a sushi-config.yaml-only option (the cases we check are here). I looked into this a little, and it looks like US Core isn't satisfying this definition of "configuration only" because there is a single .fsh file within their _fsh/ directory, even though it only contains commented out FSH. Therefore, when we check if they are a currentTankWithNoFsh, we can successfully tell there is no input/fsh folder, so we also check that there are no .fsh files anywhere within the input directory (because if there were any, the current project structure requires them to be in input/fsh/ which doesn't exist). That single .fsh means that US Core isn't considered a tank with no FSH files and so it falls into a "legacy" tank configuration case.

Even if we did implement some additional logic to only check for FSH files that have actual content, that doesn't resolve the output to build vs fsh-generated issue. It is possible to use -o build, but it sounds like that isn't an option for them because the IG publisher won't run SUSHI with that flag. Any other workaround within SUSHI that I can think of doesn't really work because fsh-generated gets cleared out on each run now. So it really isn't a safe place to put any provided files, even if SUSHI wouldn't generate and overwrite them.

@cmoesel
Copy link
Member

cmoesel commented Jun 4, 2021

Thanks for the detailed analysis, @jafeltra! I don't think it makes sense to try to address this at this point. Based on how US Core is currently using SUSHI, I think they should just create a fsh.ini file and fix SUSHI to a 1.x version there. When they want to start using SUSHI for compiling real FSH, they (and we) can revisit to find what approach works for them (hopefully within the confines of SUSHI's normal operation).

Copy link
Member

@cmoesel cmoesel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have I mentioned that I love deleting code? (Well, at least when it is intentional).

@cmoesel
Copy link
Member

cmoesel commented Jun 4, 2021

@jafeltra -- I think you've addressed all of @ngfreiter's comments, and seeing as he is away and we want this merged ASAP, I'm comfortable merging it despite his lingering "change requested". Would you agree?

@jafeltra
Copy link
Collaborator Author

jafeltra commented Jun 4, 2021

@cmoesel - I agree. His last two comments I've addressed and they were fairly straightforward, so I feel comfortable with merging.

@cmoesel cmoesel merged commit f91a4f1 into master Jun 4, 2021
@cmoesel cmoesel deleted the remove-deprecated-config branch June 4, 2021 14:12
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