@@ -16,13 +16,11 @@ let package = Package(
1616 " LaunchAgentManager " ,
1717 " UpdateChecker " ,
1818 " UserDefaultsObserver " ,
19- " XcodeInspector " ,
2019 ]
2120 ) ,
2221 . library(
2322 name: " Client " ,
2423 targets: [
25- " SuggestionModel " ,
2624 " Client " ,
2725 " XPCShared " ,
2826 ]
@@ -31,7 +29,6 @@ let package = Package(
3129 name: " HostApp " ,
3230 targets: [
3331 " HostApp " ,
34- " SuggestionModel " ,
3532 " GitHubCopilotService " ,
3633 " Client " ,
3734 " XPCShared " ,
@@ -56,45 +53,46 @@ let package = Package(
5653 url: " https://github.com/pointfreeco/swift-composable-architecture " ,
5754 from: " 0.55.0 "
5855 ) ,
59- ] ,
56+ ] . pro ,
6057 targets: [
6158 // MARK: - Main
6259
6360 . target(
6461 name: " Client " ,
6562 dependencies: [
66- " SuggestionModel " ,
6763 " XPCShared " ,
6864 " GitHubCopilotService " ,
65+ . product( name: " SuggestionModel " , package : " Tool " ) ,
6966 . product( name: " Logger " , package : " Tool " ) ,
7067 . product( name: " Preferences " , package : " Tool " ) ,
7168 ]
7269 ) ,
7370 . target(
7471 name: " Service " ,
7572 dependencies: [
76- " SuggestionModel " ,
7773 " SuggestionService " ,
7874 " GitHubCopilotService " ,
7975 " XPCShared " ,
8076 " CGEventObserver " ,
8177 " DisplayLink " ,
82- " ActiveApplicationMonitor " ,
83- " AXNotificationStream " ,
84- " Environment " ,
8578 " SuggestionWidget " ,
86- " AXExtension " ,
8779 " ChatService " ,
8880 " PromptToCodeService " ,
8981 " ServiceUpdateMigration " ,
9082 " UserDefaultsObserver " ,
91- " ChatTab " ,
83+ " ChatGPTChatTab " ,
84+ . product( name: " AppMonitoring " , package : " Tool " ) ,
85+ . product( name: " Environment " , package : " Tool " ) ,
86+ . product( name: " SuggestionModel " , package : " Tool " ) ,
87+ . product( name: " ChatTab " , package : " Tool " ) ,
9288 . product( name: " Logger " , package : " Tool " ) ,
9389 . product( name: " OpenAIService " , package : " Tool " ) ,
9490 . product( name: " Preferences " , package : " Tool " ) ,
9591 . product( name: " AsyncAlgorithms " , package : " swift-async-algorithms " ) ,
9692 . product( name: " ComposableArchitecture " , package : " swift-composable-architecture " ) ,
97- ]
93+ ] . pro ( [
94+ " ProChatTabs " ,
95+ ] )
9896 ) ,
9997 . testTarget(
10098 name: " ServiceTests " ,
@@ -104,16 +102,8 @@ let package = Package(
104102 " GitHubCopilotService " ,
105103 " SuggestionInjector " ,
106104 " XPCShared " ,
107- " Environment " ,
108- " SuggestionModel " ,
109- . product( name: " Preferences " , package : " Tool " ) ,
110- ]
111- ) ,
112- . target(
113- name: " Environment " ,
114- dependencies: [
115- " ActiveApplicationMonitor " ,
116- " AXExtension " ,
105+ . product( name: " SuggestionModel " , package : " Tool " ) ,
106+ . product( name: " Environment " , package : " Tool " ) ,
117107 . product( name: " Preferences " , package : " Tool " ) ,
118108 ]
119109 ) ,
@@ -126,8 +116,8 @@ let package = Package(
126116 " Client " ,
127117 " GitHubCopilotService " ,
128118 " CodeiumService " ,
129- " SuggestionModel " ,
130119 " LaunchAgentManager " ,
120+ . product( name: " SuggestionModel " , package : " Tool " ) ,
131121 . product( name: " MarkdownUI " , package : " swift-markdown-ui " ) ,
132122 . product( name: " OpenAIService " , package : " Tool " ) ,
133123 . product( name: " Preferences " , package : " Tool " ) ,
@@ -139,22 +129,14 @@ let package = Package(
139129
140130 . target(
141131 name: " XPCShared " ,
142- dependencies: [ " SuggestionModel " ]
132+ dependencies: [ . product ( name : " SuggestionModel " , package : " Tool " ) , ]
143133 ) ,
144134
145135 // MARK: - Suggestion Service
146136
147- . target(
148- name: " SuggestionModel " ,
149- dependencies: [ " LanguageClient " ]
150- ) ,
151- . testTarget(
152- name: " SuggestionModelTests " ,
153- dependencies: [ " SuggestionModel " ]
154- ) ,
155137 . target(
156138 name: " SuggestionInjector " ,
157- dependencies: [ " SuggestionModel " ]
139+ dependencies: [ . product ( name : " SuggestionModel " , package : " Tool " ) , ]
158140 ) ,
159141 . testTarget(
160142 name: " SuggestionInjectorTests " ,
@@ -171,9 +153,9 @@ let package = Package(
171153 . target(
172154 name: " PromptToCodeService " ,
173155 dependencies: [
174- " Environment " ,
175156 " GitHubCopilotService " ,
176- " SuggestionModel " ,
157+ . product( name: " SuggestionModel " , package : " Tool " ) ,
158+ . product( name: " Environment " , package : " Tool " ) ,
177159 . product( name: " OpenAIService " , package : " Tool " ) ,
178160 ]
179161 ) ,
@@ -186,8 +168,6 @@ let package = Package(
186168 dependencies: [
187169 " ChatPlugin " ,
188170 " ChatContextCollector " ,
189- " Environment " ,
190- " XcodeInspector " ,
191171
192172 // plugins
193173 " MathChatPlugin " ,
@@ -197,6 +177,8 @@ let package = Package(
197177 // context collectors
198178 " WebChatContextCollector " ,
199179
180+ . product( name: " AppMonitoring " , package : " Tool " ) ,
181+ . product( name: " Environment " , package : " Tool " ) ,
200182 . product( name: " Parsing " , package : " swift-parsing " ) ,
201183 . product( name: " OpenAIService " , package : " Tool " ) ,
202184 . product( name: " Preferences " , package : " Tool " ) ,
@@ -206,29 +188,30 @@ let package = Package(
206188 . target(
207189 name: " ChatPlugin " ,
208190 dependencies: [
209- " Environment " ,
191+ . product ( name : " Environment " , package : " Tool " ) ,
210192 . product( name: " OpenAIService " , package : " Tool " ) ,
211193 . product( name: " Terminal " , package : " Tool " ) ,
212194 ]
213195 ) ,
214196 . target(
215197 name: " ChatContextCollector " ,
216198 dependencies: [
217- " Environment " ,
218- " SuggestionModel " ,
219- " XcodeInspector " ,
199+ . product ( name : " SuggestionModel " , package : " Tool " ) ,
200+ . product ( name : " AppMonitoring " , package : " Tool " ) ,
201+ . product ( name : " Environment " , package : " Tool " ) ,
220202 . product( name: " OpenAIService " , package : " Tool " ) ,
221203 . product( name: " Preferences " , package : " Tool " ) ,
222204 ]
223205 ) ,
224206
225207 . target(
226- name: " ChatTab " ,
208+ name: " ChatGPTChatTab " ,
227209 dependencies: [
228210 " SharedUIComponents " ,
229211 " ChatService " ,
230212 . product( name: " OpenAIService " , package : " Tool " ) ,
231213 . product( name: " Logger " , package : " Tool " ) ,
214+ . product( name: " ChatTab " , package : " Tool " ) ,
232215 . product( name: " MarkdownUI " , package : " swift-markdown-ui " ) ,
233216 ]
234217 ) ,
@@ -248,13 +231,12 @@ let package = Package(
248231 . target(
249232 name: " SuggestionWidget " ,
250233 dependencies: [
251- " ChatTab " ,
252- " ActiveApplicationMonitor " ,
253- " AXNotificationStream " ,
254- " Environment " ,
234+ " ChatGPTChatTab " ,
255235 " UserDefaultsObserver " ,
256- " XcodeInspector " ,
257236 " SharedUIComponents " ,
237+ . product( name: " AppMonitoring " , package : " Tool " ) ,
238+ . product( name: " Environment " , package : " Tool " ) ,
239+ . product( name: " ChatTab " , package : " Tool " ) ,
258240 . product( name: " Logger " , package : " Tool " ) ,
259241 . product( name: " AsyncAlgorithms " , package : " swift-async-algorithms " ) ,
260242 . product( name: " MarkdownUI " , package : " swift-markdown-ui " ) ,
@@ -274,21 +256,13 @@ let package = Package(
274256 . target( name: " FileChangeChecker " ) ,
275257 . target( name: " LaunchAgentManager " ) ,
276258 . target( name: " DisplayLink " ) ,
277- . target( name: " ActiveApplicationMonitor " ) ,
278- . target(
279- name: " AXNotificationStream " ,
280- dependencies: [
281- . product( name: " Logger " , package : " Tool " ) ,
282- ]
283- ) ,
284259 . target(
285260 name: " UpdateChecker " ,
286261 dependencies: [
287262 " Sparkle " ,
288263 . product( name: " Logger " , package : " Tool " ) ,
289264 ]
290265 ) ,
291- . target( name: " AXExtension " ) ,
292266 . target(
293267 name: " ServiceUpdateMigration " ,
294268 dependencies: [
@@ -297,26 +271,15 @@ let package = Package(
297271 ]
298272 ) ,
299273 . target( name: " UserDefaultsObserver " ) ,
300- . target(
301- name: " XcodeInspector " ,
302- dependencies: [
303- " AXExtension " ,
304- " SuggestionModel " ,
305- " Environment " ,
306- " AXNotificationStream " ,
307- . product( name: " Logger " , package : " Tool " ) ,
308- . product( name: " AsyncAlgorithms " , package : " swift-async-algorithms " ) ,
309- ]
310- ) ,
311274
312275 // MARK: - GitHub Copilot
313276
314277 . target(
315278 name: " GitHubCopilotService " ,
316279 dependencies: [
317280 " LanguageClient " ,
318- " SuggestionModel " ,
319281 " XPCShared " ,
282+ . product( name: " SuggestionModel " , package : " Tool " ) ,
320283 . product( name: " Logger " , package : " Tool " ) ,
321284 . product( name: " Preferences " , package : " Tool " ) ,
322285 . product( name: " Terminal " , package : " Tool " ) ,
@@ -334,9 +297,9 @@ let package = Package(
334297 name: " CodeiumService " ,
335298 dependencies: [
336299 " LanguageClient " ,
337- " SuggestionModel " ,
338300 " KeychainAccess " ,
339- " XcodeInspector " ,
301+ . product( name: " SuggestionModel " , package : " Tool " ) ,
302+ . product( name: " AppMonitoring " , package : " Tool " ) ,
340303 . product( name: " Preferences " , package : " Tool " ) ,
341304 . product( name: " Terminal " , package : " Tool " ) ,
342305 ]
@@ -391,3 +354,34 @@ let package = Package(
391354 ]
392355)
393356
357+ // MARK: - Pro
358+
359+ extension [ Target . Dependency ] {
360+ func pro( _ targetNames: [ String ] ) -> [ Target . Dependency ] {
361+ if isProIncluded ( ) {
362+ return self + targetNames. map { Target . Dependency. product ( name: $0, package : " Pro " ) }
363+ }
364+ return self
365+ }
366+ }
367+
368+ extension [ Package . Dependency ] {
369+ var pro : [ Package . Dependency ] {
370+ if isProIncluded ( ) {
371+ return self + [ . package ( path: " ../Pro " ) ]
372+ }
373+ return self
374+ }
375+ }
376+
377+ import Foundation
378+
379+ func isProIncluded( file: StaticString = #file) -> Bool {
380+ let filePath = " \( file) "
381+ let url = URL ( fileURLWithPath: filePath)
382+ . deletingLastPathComponent ( )
383+ . deletingLastPathComponent ( )
384+ . appendingPathComponent ( " Pro/Package.swift " )
385+ return FileManager . default. fileExists ( atPath: url. path)
386+ }
387+
0 commit comments