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

Add --include flag to SafeDITool #80

Merged
merged 14 commits into from
May 19, 2024
Merged

Add --include flag to SafeDITool #80

merged 14 commits into from
May 19, 2024

Conversation

dfed
Copy link
Owner

@dfed dfed commented May 18, 2024

Makes it much easier to integrate SafeDI into a project by adding an --include flag to SafeDITool, removing the need to utilize a .csv file.

This new flag made it easier to showcase what it would look like to run SafeDI in a multi-module Xcode project, so I added those directions and also created ExampleMultiProjectIntegration. The ExampleMultiProjectIntegration project has the same code as ExampleProjectIntegration, but split into one app target and one library.

Best reviewed with the Examples/ExampleMultiProjectIntegration/ path folded. This new project constitutes the majority of the diff, and it does not need to be carefully reviewed.

@dfed dfed self-assigned this May 18, 2024
@dfed dfed force-pushed the dfed--include branch 3 times, most recently from 208af58 to 886efc3 Compare May 18, 2024 21:52
Copy link

codecov bot commented May 18, 2024

Codecov Report

Attention: Patch coverage is 95.65217% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 99.52%. Comparing base (e2690ec) to head (09c8688).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #80      +/-   ##
==========================================
- Coverage   99.59%   99.52%   -0.08%     
==========================================
  Files          44       44              
  Lines        9295     9383      +88     
==========================================
+ Hits         9257     9338      +81     
- Misses         38       45       +7     
Files Coverage Δ
Tests/SafeDIToolTests/SafeDIToolTests.swift 99.97% <100.00%> (-0.03%) ⬇️
Sources/SafeDITool/SafeDITool.swift 96.49% <91.66%> (-3.51%) ⬇️

@@ -1,3 +1,7 @@
# file options

--exclude Examples/ExampleMultiProjectIntegration/ExampleMultiProjectIntegration/SafeDI.swift
Copy link
Owner Author

Choose a reason for hiding this comment

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

The linter does not approve of the code-gen. Go figure.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What specifically doesn't it like? Worth it to fix?

Copy link
Owner Author

Choose a reason for hiding this comment

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

It's my own swift format config that I'm fighting. Not worth fixing (at least not in the short term) – this generated code isn't meant to be pretty as much as it's meant to be easy to write + maintain.

Biggest delta is that my format config wants @MainActor on its own line rather than on the same line as func.

README.md Outdated Show resolved Hide resolved

extension FileManager: FileFinder {}

var fileFinder: FileFinder = FileManager.default
Copy link
Owner Author

Choose a reason for hiding this comment

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

A little nuts to have a global like this, but since SafeDITool must be Decodable (which FileFinder most assuredly isn't) we can't add it as an ivar.

Open to better ideas here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmmm yeah this is a tricky one. I was thinking maybe you could wrap this in another type like GlobalDependencies or something but you still have the same setup. Not sure if there's anything that's obviously better.

@Argument(help: "A path to a CSV file containing paths of Swift files to parse.") var swiftSourcesFilePath: String
@Argument(help: "A path to a CSV file containing paths of Swift files to parse.") var swiftSourcesFilePath: String?

@Option(parsing: .upToNextOption, help: "Directories containing Swift files to include, relative to the executing directory.") var include: [String] = []
Copy link
Owner Author

Choose a reason for hiding this comment

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

One of these days we may want to add an exclude, but for now this gets the job done.

@dfed dfed requested a review from MrAdamBoyd May 18, 2024 22:47
@dfed dfed marked this pull request as ready for review May 18, 2024 22:47
@dfed dfed force-pushed the dfed--include branch 3 times, most recently from a92bb66 to 6960ed6 Compare May 19, 2024 02:08
run: xcrun swift build -c release --package-path Examples/ExamplePackageIntegration
run: xcrun swift build --package-path Examples/ExamplePackageIntegration
Copy link
Owner Author

Choose a reason for hiding this comment

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

an unrelated change, but we're already building for release elsewhere – no reason to do it here as well.

Comment on lines +48 to +59
public init(
userService: any UserService,
stringStorage: StringStorage,
nameEntryViewBuilder: Instantiator<NameEntryView>,
noteViewBuilder: Instantiator<NoteView>
) {
self.userService = userService
self.stringStorage = stringStorage
self.nameEntryViewBuilder = nameEntryViewBuilder
self.noteViewBuilder = noteViewBuilder
observedUserService = AnyObservableObject(userService)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you think it's worth mentioning above that, in addition to the reasons you outlined, there's also a property here not marked with @Instantiated/@Forwarded/@received so you must write your own init?

Copy link
Owner Author

Choose a reason for hiding this comment

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

That’s useful info but I fear it’s a bit tangential to what I’m trying to get across with this comment. There’s so much information to convey when teaching this lib. It’s probably best to not try to do it all at once.

README.md Outdated Show resolved Hide resolved
@dfed dfed enabled auto-merge (squash) May 19, 2024 15:45
@dfed dfed merged commit c3d3d5c into main May 19, 2024
13 checks passed
@dfed dfed deleted the dfed--include branch May 19, 2024 15:48
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.

2 participants