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

Using other modules dependency #36

Merged
merged 32 commits into from
Mar 15, 2020
Merged

Using other modules dependency #36

merged 32 commits into from
Mar 15, 2020

Conversation

kawoou
Copy link
Owner

@kawoou kawoou commented May 25, 2019

1. Generate resolved data

Deli binary:

deli build --resolve-file true

deli.yml:

target:
  - MyProject

config:
  MyProject:
    project: MyProject
    
    # ...

    # >>>
    resolve:
      output: Deli.resolved
      generate: true
    accessControl: public
    # <<<

DeliFactory.swift:

public final class DeliFactory: ModuleFactory {
    public override func load(context: AppContext) {
        // ...
    }
}

Deli.resolved:

Generated resolving data of dependency.

VERSION: 0.8.1
DEPENDENCY:
- TYPE: GitHubServiceImpl
  LAZILY: false
  FACTORY: false
  VALUE_TYPE: false
  DEPENDENCY:
  - TYPE: NetworkManager
    QUALIFIER: 
  LINK:
  - GitHubService
- TYPE: NetworkManagerImpl
  LAZILY: false
  FACTORY: false
  VALUE_TYPE: false
  DEPENDENCY: []
  LINK:
  - NetworkManager
- TYPE: ViewController
  LAZILY: false
  FACTORY: false
  VALUE_TYPE: false
  DEPENDENCY:
  - TYPE: ViewModel
    QUALIFIER: 
  LINK: []
- TYPE: ViewModel
  LAZILY: false
  FACTORY: false
  VALUE_TYPE: false
  DEPENDENCY:
  - TYPE: GitHubService
    QUALIFIER: 
  LINK: []
PROPERTY: {}
PROJECT: GitHubSearch
REFERENCE: GitHubSearch

2. Load resolved data

deli.yml:

target:
  - MyProject

config:
  MyProject:
    project: MyProject
    
    # ...

    # >>>
    dependencies:
      - path: Dependency files...
        imports: UIKit
    # <<<

3. Add method that inject dependency from string class

protocol BaseProtocol {}
class ImplementClass: BaseProtocol, Component {}

// ...

let appContext = AppContext.shared
let instance: BaseProtocol? = appContext.get(BaseProtocol.self, "ImplementClass")

4. Add to get property with type method

let port: Int? = AppContext.shared.getProperty("server.port", Int.self)

5. Support ConfigProperty type property

struct ServerConfig: ConfigProperty {
    let method: String?
    let url: String
    let port: Int

    // Remove under
    //
    // init(method: String, url: String, port: String) {
    //     self.method = method
    //     self.url = url
    //     self.port = Int(port) ?? 0
    // }
}

// ...

let type: ServerInfo? = AppContext.shared.getProperty("server", ServerInfo.self)

6. Fix typo

  • ResolveRule to ResolveRole

7. Fix property merging bug when multi-module environment.

8. Fix specific local path bug.

  • Directory/1. TestDirectory/Test1.swift
  • Directory/2. TestDirectory/Test2.swift

9. Fix to searches source-code path bug.

10. Support swift 5+

11. Support nested type.

import Deli

class A {
    struct B: Component {
        ...
    }
}

class C: Autowired {
    required init(_ ab: A.B) {
        ...
    }
}

12. Support typealias keyword

class A {
    struct B: Component {
        ...
    }
}

struct C {
    class D: Component {
        struct E {
            class F: Component {
                ...
            }
        }
    }
}
class NestedTestClass: Autowired {
    typealias NestedType = C.D.E.F

    let a: A.B
    let b: C.D
    let c: NestedType

    required init(_ a: A.B, _ b: C.D, _ c: NestedType) {
        ...
    }
}

13. Implement property wrapper feature

struct A {
    @Dependency
    var userService: UserService

    @PropertyValue("server.url")
    var serverURL: String

    func login() {
        userService.login()
    }

    init() {
        print(serverURL)
    }
}

14. Update libraries

  • SourceKitten: 0.21.2 -> 0.28.0
  • Yams: 1.0.0 -> 2.0.0
  • Regex: 1.1.0 -> 1.2.0
  • xcodeproj: 6.0.0 -> 7.5.0
  • Commandant: 0.15.0 -> 0.17.0
  • Nimble: 7.3.1 -> 8.0.2
  • Quick: 1.3.2 -> 2.2.0

15. TODO

  • Write section on README.md

@kawoou kawoou self-assigned this May 25, 2019
@kawoou kawoou added the enhancement New feature or request label May 25, 2019
@codecov-io
Copy link

codecov-io commented May 25, 2019

Codecov Report

Merging #36 into develop will increase coverage by 1.42%.
The diff coverage is 80.52%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #36      +/-   ##
===========================================
+ Coverage     75.8%   77.22%   +1.42%     
===========================================
  Files           16       19       +3     
  Lines          624      830     +206     
===========================================
+ Hits           473      641     +168     
- Misses         151      189      +38
Impacted Files Coverage Δ
Sources/Deli/Configuration.swift 7.36% <ø> (ø) ⬆️
Sources/Deli/Inject.swift 100% <ø> (ø) ⬆️
Sources/Deli/Core/Type/ResolveRole.swift 100% <ø> (ø)
Sources/Deli/AutowiredFactory.swift 9.09% <100%> (ø) ⬆️
Sources/Deli/Component.swift 100% <100%> (ø) ⬆️
Sources/Deli/PropertyValue.swift 100% <100%> (ø)
Sources/Deli/Dependency.swift 100% <100%> (ø)
Sources/Deli/DependencyArray.swift 100% <100%> (ø)
Sources/Deli/LazyAutowiredFactory.swift 18.18% <100%> (ø) ⬆️
Sources/Deli/Autowired.swift 10% <100%> (ø) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9dffba1...be2bf94. Read the comment docs.

@kawoou kawoou merged commit c786919 into develop Mar 15, 2020
@kawoou kawoou deleted the feature/resolved branch March 15, 2020 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants