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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a72198a
Implement generator of resolved data
kawoou Feb 7, 2019
0397cf1
Implement load the resolved data
kawoou Feb 10, 2019
7fa8294
Remove dependency command-line property
kawoou Feb 11, 2019
d164096
Update dependency property
kawoou Feb 11, 2019
f15f4a7
Add resolve configuration
kawoou Feb 12, 2019
e53023e
Add method that inject dependency from string class
kawoou Feb 12, 2019
e62139f
Add to get property with type method
kawoou Feb 12, 2019
fb60ffd
Add resolve generate configuration
kawoou Feb 12, 2019
e67a542
Update deli.yml
kawoou Feb 12, 2019
a1bc1f1
Add test code.
kawoou Feb 13, 2019
80bcb8e
Support ConfigProperty type property.
kawoou Feb 14, 2019
814ac5b
Reduce codable code.
kawoou Feb 14, 2019
d0fb5ae
Fix typo.
kawoou Feb 14, 2019
767045a
Support common property.
kawoou Feb 14, 2019
3f54d58
Add some warning.
kawoou Feb 14, 2019
7ea9592
Update libraries version.
kawoou Feb 15, 2019
02977de
Add debug log flag.
kawoou Feb 15, 2019
c627937
Add design file.
kawoou Mar 20, 2019
aaede0b
Only support swift 5.1 and fix local path issues
kawoou Jan 12, 2020
c36b38a
Fix to search source path bug
kawoou Jan 12, 2020
b695905
Support nested type
kawoou Jan 12, 2020
0786f22
Update xcode version on travis ci
kawoou Jan 14, 2020
5b93c5e
Support swift 5.1
kawoou Jan 14, 2020
0e5aa40
Fix travis ci build failure
kawoou Jan 14, 2020
517814f
Fix travis ci build failure
kawoou Jan 14, 2020
25601da
Remove warning
kawoou Jan 14, 2020
fe760a9
Embed static swift stdlib
kawoou Jan 14, 2020
23fd73d
Update binary dependencies
kawoou Jan 14, 2020
fcf50b8
Fix output path issues
kawoou Jan 14, 2020
dbc9d34
Support parsing typealias keyword
kawoou Jan 15, 2020
57afd0e
Implement property wrapper feature
kawoou Mar 15, 2020
be2bf94
Update readme
kawoou Mar 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2
5.1
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
osx_image: xcode10
osx_image: xcode11.3
language: objective-c
sudo: required
branches:
Expand All @@ -15,10 +15,10 @@ env:
- SCHEME="Deli"
- FRAMEWORK="Deli"
matrix:
- TEST=1 DESTINATION="platform=iOS Simulator,name=iPhone 8,OS=12.0"
- TEST=1 DESTINATION="platform=iOS Simulator,name=iPhone 8,OS=13.3"
- TEST=1 DESTINATION="arch=x86_64"
- TEST=1 DESTINATION="OS=12.0,name=Apple TV"
- TEST=0 DESTINATION="OS=5.0,name=Apple Watch Series 4 - 40mm"
- TEST=1 DESTINATION="OS=13.3,name=Apple TV"
- TEST=0 DESTINATION="OS=6.0,name=Apple Watch Series 4 - 40mm"

install:
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)"
Expand Down
82 changes: 50 additions & 32 deletions Binary/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,101 +3,119 @@
"pins": [
{
"package": "AEXML",
"repositoryURL": "https://github.com/tadija/AEXML.git",
"repositoryURL": "https://github.com/tadija/AEXML",
"state": {
"branch": null,
"revision": "6eea665515d079c338690147082a8084a36484b0",
"version": "4.3.0"
"revision": "e4d517844dd03dac557e35d77a8e9ab438de91a6",
"version": "4.4.0"
}
},
{
"package": "Commandant",
"repositoryURL": "https://github.com/Carthage/Commandant.git",
"state": {
"branch": null,
"revision": "07cad52573bad19d95844035bf0b25acddf6b0f6",
"version": "0.15.0"
"revision": "ab68611013dec67413628ac87c1f29e8427bc8e4",
"version": "0.17.0"
}
},
{
"package": "CwlCatchException",
"repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git",
"state": {
"branch": null,
"revision": "7cd2f8cacc4d22f21bc0b2309c3b18acf7957b66",
"version": "1.2.0"
}
},
{
"package": "CwlPreconditionTesting",
"repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state": {
"branch": null,
"revision": "c228db5d2ad1b01ebc84435e823e6cca4e3db98b",
"version": "1.2.0"
}
},
{
"package": "Nimble",
"repositoryURL": "https://github.com/Quick/Nimble.git",
"state": {
"branch": null,
"revision": "cd6dfb86f496fcd96ce0bc6da962cd936bf41903",
"version": "7.3.1"
"revision": "b02b00b30b6353632aa4a5fb6124f8147f7140c0",
"version": "8.0.5"
}
},
{
"package": "Quick",
"repositoryURL": "https://github.com/Quick/Quick.git",
"package": "PathKit",
"repositoryURL": "https://github.com/kylef/PathKit",
"state": {
"branch": null,
"revision": "5fbf13871d185526993130c3a1fad0b70bfe37ce",
"version": "1.3.2"
"revision": "73f8e9dca9b7a3078cb79128217dc8f2e585a511",
"version": "1.0.0"
}
},
{
"package": "Regex",
"repositoryURL": "https://github.com/crossroadlabs/Regex.git",
"package": "Quick",
"repositoryURL": "https://github.com/Quick/Quick.git",
"state": {
"branch": null,
"revision": "f144250678e4c13f1d820ffa265a8326b25bcd86",
"version": "1.1.0"
"revision": "33682c2f6230c60614861dfc61df267e11a1602f",
"version": "2.2.0"
}
},
{
"package": "Result",
"repositoryURL": "https://github.com/antitypical/Result.git",
"package": "Regex",
"repositoryURL": "https://github.com/crossroadlabs/Regex.git",
"state": {
"branch": null,
"revision": "8fc088dcf72802801efeecba76ea8fb041fb773d",
"version": "4.0.0"
"revision": "166728756082a9cac6e4aed3ebbce8e41cb3a945",
"version": "1.2.0"
}
},
{
"package": "SourceKitten",
"repositoryURL": "https://github.com/jpsim/SourceKitten.git",
"state": {
"branch": null,
"revision": "4be914be6fa49cd30b1e7ef5d32d06c037d8f469",
"version": "0.21.2"
"revision": "97b5848e5692150d75b5cf0b81d7ebef5f4d5071",
"version": "0.28.0"
}
},
{
"package": "SwiftPM",
"repositoryURL": "https://github.com/apple/swift-package-manager",
"package": "Spectre",
"repositoryURL": "https://github.com/kylef/Spectre.git",
"state": {
"branch": null,
"revision": "6983434787dec4e543e9d398a0a9acf63ccd4da1",
"version": "0.2.1"
"revision": "f14ff47f45642aa5703900980b014c2e9394b6e5",
"version": "0.9.0"
}
},
{
"package": "SWXMLHash",
"repositoryURL": "https://github.com/drmohundro/SWXMLHash.git",
"state": {
"branch": null,
"revision": "0ce63a93a455adb3cd5e4c55f78f1232a590a5a5",
"version": "4.7.2"
"revision": "a4931e5c3bafbedeb1601d3bb76bbe835c6d475a",
"version": "5.0.1"
}
},
{
"package": "xcodeproj",
"package": "XcodeProj",
"repositoryURL": "https://github.com/tuist/xcodeproj.git",
"state": {
"branch": null,
"revision": "b645d432f79303a805c65cf712b9d185dff6f25c",
"version": "6.0.0"
"revision": "23f7e12a7e0db29b4f16052692d99f9fbe41fa15",
"version": "7.5.0"
}
},
{
"package": "Yams",
"repositoryURL": "https://github.com/jpsim/Yams.git",
"state": {
"branch": null,
"revision": "26ab35f50ea891e8edefcc9d975db2f6b67e1d68",
"version": "1.0.1"
"revision": "c947a306d2e80ecb2c0859047b35c73b8e1ca27f",
"version": "2.0.0"
}
}
]
Expand Down
14 changes: 7 additions & 7 deletions Binary/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:4.0
// swift-tools-version:5.0
import PackageDescription

let package = Package(
Expand All @@ -7,11 +7,11 @@ let package = Package(
.executable(name: "deli", targets: ["deli"])
],
dependencies: [
.package(url: "https://github.com/jpsim/SourceKitten.git", from: "0.21.1"),
.package(url: "https://github.com/jpsim/Yams.git", from: "1.0.0"),
.package(url: "https://github.com/crossroadlabs/Regex.git", from: "1.1.0"),
.package(url: "https://github.com/tuist/xcodeproj.git", from: "6.0.0"),
.package(url: "https://github.com/Carthage/Commandant.git", from: "0.15.0")
.package(url: "https://github.com/jpsim/SourceKitten.git", from: "0.28.0"),
.package(url: "https://github.com/jpsim/Yams.git", from: "2.0.0"),
.package(url: "https://github.com/crossroadlabs/Regex.git", from: "1.2.0"),
.package(url: "https://github.com/tuist/xcodeproj.git", from: "7.5.0"),
.package(url: "https://github.com/Carthage/Commandant.git", from: "0.17.0")
],
targets: [
.target(
Expand All @@ -20,7 +20,7 @@ let package = Package(
"SourceKittenFramework",
"Yams",
"Regex",
"xcodeproj",
"XcodeProj",
"Commandant"
],
path: "Sources/Deli"
Expand Down
29 changes: 0 additions & 29 deletions Binary/[email protected]

This file was deleted.

81 changes: 64 additions & 17 deletions Binary/Sources/Deli/Command/BuildCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,38 @@

import Foundation
import Commandant
import Result

struct BuildCommand: CommandProtocol {
let verb = "build"
let function = "Build the Dependency Graph."

func saveOutput(generator: Generator, outputFile: String) throws {
let outputData = try generator.generate()

var isDirectory: ObjCBool = false
if FileManager.default.fileExists(atPath: outputFile, isDirectory: &isDirectory), isDirectory.boolValue {
Logger.log(.error("Cannot overwrite a directory with an output file: \(outputFile)", nil))
throw CommandError.cannotOverwriteDirectory
}
try? FileManager.default.removeItem(atPath: outputFile)
try outputData.write(toFile: outputFile, atomically: false, encoding: .utf8)
}

func run(_ options: BuildOptions) -> Result<(), CommandError> {
Logger.isVerbose = options.isVerbose
Logger.isVerbose = options.isDebug || options.isVerbose
Logger.isDebug = options.isDebug

let configuration = Configuration()
let configure: Config
let properties = CommandLine.get(forKey: "property")
if let project = options.project {
guard let config = configuration.getConfig(project: project, scheme: options.scheme, target: options.target, output: options.output, properties: properties) else {
guard let config = configuration.getConfig(
project: project,
scheme: options.scheme,
target: options.target,
output: options.output,
properties: properties
) else {
return .failure(.failedToLoadConfigFile)
}
configure = config
Expand All @@ -45,6 +63,7 @@ struct BuildCommand: CommandProtocol {
Logger.log(.info("Set Target `\(target)`"))
let outputFile: String
let className: String
let resolvedOutputFile = configuration.getResolvedOutputPath(info: info)
if info.className != nil {
className = configuration.getClassName(info: info)
outputFile = configuration.getOutputPath(info: info, fileName: "\(className).swift")
Expand All @@ -63,6 +82,7 @@ struct BuildCommand: CommandProtocol {
}

let propertyParser = PropertyParser()
let resolveParser = ResolveParser()
let parser = Parser([
ComponentParser(),
ConfigurationParser(),
Expand All @@ -72,6 +92,8 @@ struct BuildCommand: CommandProtocol {
LazyAutowiredFactoryParser(),
InjectParser(),
InjectPropertyParser(),
DependencyParser(),
PropertyValueParser(),
ConfigPropertyParser()
])
let corrector = Corrector([
Expand All @@ -91,21 +113,32 @@ struct BuildCommand: CommandProtocol {
propertyParser.load(propertyFiles)

do {
try resolveParser.load(info.dependencies)

let results = try validator.run(
try corrector.run(
try parser.run(sourceFiles)
try resolveParser.run(
try parser.run(sourceFiles)
)
)
)
let outputData = try SourceGenerator(className: className, results: results, properties: propertyParser.properties).generate()
let url = URL(fileURLWithPath: outputFile)

var isDirectory: ObjCBool = false
if FileManager.default.fileExists(atPath: outputFile, isDirectory: &isDirectory), isDirectory.boolValue {
Logger.log(.error("Cannot overwrite a directory with an output file: \(outputFile)", nil))
throw CommandError.cannotOverwriteDirectory
let generator = SourceGenerator(
className: className,
accessControl: info.accessControl,
results: results,
properties: propertyParser.properties
)
try saveOutput(generator: generator, outputFile: outputFile)

if options.isResolveFile, (info.resolve?.isGenerate ?? true) {
let resolveGenerator = ResolveGenerator(
projectName: target,
fileName: info.output ?? "\(className).swift",
results: results,
properties: propertyParser.properties
)
try saveOutput(generator: resolveGenerator, outputFile: resolvedOutputFile)
}
try? FileManager.default.removeItem(at: url)
try outputData.write(to: url, atomically: false, encoding: .utf8)

Logger.log(.info("Generate file: \(outputFile)"))
} catch let error {
Expand All @@ -125,20 +158,24 @@ struct BuildOptions: OptionsProtocol {
let target: String?
let output: String?
let properties: String?
let isResolveFile: Bool
let isVerbose: Bool
let isDebug: Bool

static func create(configFile: String?) -> (_ project: String?) -> (_ scheme: String?) -> (_ target: String?) -> (_ output: String?) -> (_ properties: String?) -> (_ isVerbose: Bool) -> BuildOptions {
return { project in { scheme in { target in { output in { properties in { isVerbose in
static func create(configFile: String?) -> (_ project: String?) -> (_ scheme: String?) -> (_ target: String?) -> (_ output: String?) -> (_ properties: String?) -> (_ isResolveFile: Bool) -> (_ isVerbose: Bool) -> (_ isDebug: Bool) -> BuildOptions {
return { project in { scheme in { target in { output in { properties in { isResolveFile in { isVerbose in { isDebug in
self.init(
configFile: configFile,
project: project,
scheme: scheme,
target: target,
output: output,
properties: properties,
isVerbose: isVerbose
isResolveFile: isResolveFile,
isVerbose: isVerbose,
isDebug: isDebug
)
}}}}}}
}}}}}}}}
}

static func evaluate(_ mode: CommandMode) -> Result<BuildOptions, CommandantError<CommandError>> {
Expand Down Expand Up @@ -173,10 +210,20 @@ struct BuildOptions: OptionsProtocol {
defaultValue: nil,
usage: "the path of property file"
)
<*> mode <| Option(
key: "resolve-file",
defaultValue: true,
usage: "turn on generate resolved file"
)
<*> mode <| Option(
key: "verbose",
defaultValue: false,
usage: "turn on verbose logging"
)
<*> mode <| Option(
key: "debug",
defaultValue: false,
usage: "turn on debug logging"
)
}
}
Loading