@@ -90,12 +90,12 @@ public List<PSResourceInfo> FindByResourceName(
90
90
return foundPackages ;
91
91
}
92
92
93
- _pkgsLeftToFind = name . ToList ( ) ;
93
+ _pkgsLeftToFind = new List < string > ( name ) ;
94
94
95
95
// Error out if repository array of names to be searched contains wildcards.
96
96
if ( repository != null )
97
97
{
98
- repository = Utils . ProcessNameWildcards ( repository , out string [ ] errorMsgs , out _repositoryNameContainsWildcard ) ;
98
+ repository = Utils . ProcessNameWildcards ( repository , removeWildcardEntries : false , out string [ ] errorMsgs , out _repositoryNameContainsWildcard ) ;
99
99
foreach ( string error in errorMsgs )
100
100
{
101
101
_cmdletPassedIn . WriteError ( new ErrorRecord (
@@ -154,6 +154,161 @@ public List<PSResourceInfo> FindByResourceName(
154
154
return foundPackages ;
155
155
}
156
156
157
+ public List < PSCommandResourceInfo > FindCommandOrDscResource (
158
+ ResourceType type ,
159
+ SwitchParameter prerelease ,
160
+ string [ ] tag ,
161
+ string [ ] repository ,
162
+ PSCredential credential )
163
+ {
164
+ _type = type ;
165
+ _prerelease = prerelease ;
166
+ _tag = tag ;
167
+ _credential = credential ;
168
+
169
+ List < PSCommandResourceInfo > foundPackages = new List < PSCommandResourceInfo > ( ) ;
170
+ List < string > cmdsLeftToFind = new List < string > ( tag ) ;
171
+
172
+ if ( tag . Length == 0 )
173
+ {
174
+ return foundPackages ;
175
+ }
176
+
177
+ // Error out if repository array of names to be searched contains wildcards.
178
+ if ( repository != null )
179
+ {
180
+ repository = Utils . ProcessNameWildcards ( repository , removeWildcardEntries : false , out string [ ] errorMsgs , out _repositoryNameContainsWildcard ) ;
181
+ foreach ( string error in errorMsgs )
182
+ {
183
+ _cmdletPassedIn . WriteError ( new ErrorRecord (
184
+ new PSInvalidOperationException ( error ) ,
185
+ "ErrorFilteringNamesForUnsupportedWildcards" ,
186
+ ErrorCategory . InvalidArgument ,
187
+ this ) ) ;
188
+ }
189
+ }
190
+
191
+ // Get repositories to search.
192
+ List < PSRepositoryInfo > repositoriesToSearch ;
193
+ try
194
+ {
195
+ repositoriesToSearch = RepositorySettings . Read ( repository , out string [ ] errorList ) ;
196
+ foreach ( string error in errorList )
197
+ {
198
+ _cmdletPassedIn . WriteError ( new ErrorRecord (
199
+ new PSInvalidOperationException ( error ) ,
200
+ "ErrorGettingSpecifiedRepo" ,
201
+ ErrorCategory . InvalidOperation ,
202
+ this ) ) ;
203
+ }
204
+ }
205
+ catch ( Exception e )
206
+ {
207
+ _cmdletPassedIn . ThrowTerminatingError ( new ErrorRecord (
208
+ new PSInvalidOperationException ( e . Message ) ,
209
+ "ErrorLoadingRepositoryStoreFile" ,
210
+ ErrorCategory . InvalidArgument ,
211
+ this ) ) ;
212
+
213
+ return foundPackages ;
214
+ }
215
+
216
+ for ( int i = 0 ; i < repositoriesToSearch . Count && cmdsLeftToFind . Any ( ) ; i ++ )
217
+ {
218
+ _cmdletPassedIn . WriteVerbose ( string . Format ( "Searching in repository {0}" , repositoriesToSearch [ i ] . Name ) ) ;
219
+ if ( repositoriesToSearch [ i ] . ApiVersion == PSRepositoryInfo . APIVersion . v2 )
220
+ {
221
+ foreach ( PSCommandResourceInfo cmdInfo in HttpFindCmdOrDsc ( repositoriesToSearch [ i ] , _type ) )
222
+ {
223
+ foundPackages . Add ( cmdInfo ) ;
224
+
225
+ foreach ( string cmd in cmdInfo . Names )
226
+ {
227
+ cmdsLeftToFind . Remove ( cmd ) ;
228
+ }
229
+ }
230
+ }
231
+ }
232
+
233
+ return foundPackages ;
234
+ }
235
+
236
+ public List < PSResourceInfo > FindTag (
237
+ ResourceType type ,
238
+ SwitchParameter prerelease ,
239
+ string [ ] tag ,
240
+ string [ ] repository ,
241
+ PSCredential credential )
242
+ {
243
+ _type = type ;
244
+ _prerelease = prerelease ;
245
+ _tag = tag ;
246
+ _credential = credential ;
247
+
248
+ List < PSResourceInfo > foundPackages = new List < PSResourceInfo > ( ) ;
249
+ List < string > tagsLeftToFind = new List < string > ( tag ) ;
250
+
251
+ if ( tag . Length == 0 )
252
+ {
253
+ return foundPackages ;
254
+ }
255
+
256
+ // Error out if repository array of names to be searched contains wildcards.
257
+ if ( repository != null )
258
+ {
259
+ repository = Utils . ProcessNameWildcards ( repository , removeWildcardEntries : false , out string [ ] errorMsgs , out _repositoryNameContainsWildcard ) ;
260
+ foreach ( string error in errorMsgs )
261
+ {
262
+ _cmdletPassedIn . WriteError ( new ErrorRecord (
263
+ new PSInvalidOperationException ( error ) ,
264
+ "ErrorFilteringNamesForUnsupportedWildcards" ,
265
+ ErrorCategory . InvalidArgument ,
266
+ this ) ) ;
267
+ }
268
+ }
269
+
270
+ // Get repositories to search.
271
+ List < PSRepositoryInfo > repositoriesToSearch ;
272
+ try
273
+ {
274
+ repositoriesToSearch = RepositorySettings . Read ( repository , out string [ ] errorList ) ;
275
+ foreach ( string error in errorList )
276
+ {
277
+ _cmdletPassedIn . WriteError ( new ErrorRecord (
278
+ new PSInvalidOperationException ( error ) ,
279
+ "ErrorGettingSpecifiedRepo" ,
280
+ ErrorCategory . InvalidOperation ,
281
+ this ) ) ;
282
+ }
283
+ }
284
+ catch ( Exception e )
285
+ {
286
+ _cmdletPassedIn . ThrowTerminatingError ( new ErrorRecord (
287
+ new PSInvalidOperationException ( e . Message ) ,
288
+ "ErrorLoadingRepositoryStoreFile" ,
289
+ ErrorCategory . InvalidArgument ,
290
+ this ) ) ;
291
+
292
+ return foundPackages ;
293
+ }
294
+
295
+ for ( int i = 0 ; i < repositoriesToSearch . Count && tagsLeftToFind . Any ( ) ; i ++ )
296
+ {
297
+ _cmdletPassedIn . WriteVerbose ( string . Format ( "Searching in repository {0}" , repositoriesToSearch [ i ] . Name ) ) ;
298
+ if ( repositoriesToSearch [ i ] . ApiVersion == PSRepositoryInfo . APIVersion . v2 )
299
+ {
300
+ // tag1, tag2, tag3
301
+
302
+ // TODO: didn't really finsh come back here
303
+ foreach ( PSResourceInfo cmdInfo in HttpSearchFromRepository ( repositoriesToSearch [ i ] ) )
304
+ {
305
+ foundPackages . Add ( cmdInfo ) ;
306
+ }
307
+ }
308
+ }
309
+
310
+ return foundPackages ;
311
+ }
157
312
#endregion
158
313
159
314
#region Private methods
@@ -701,6 +856,12 @@ private PSResourceInfo[] HttpFindTags(PSRepositoryInfo repository, ResourceType
701
856
// TODO: write out error
702
857
}
703
858
859
+ private PSCommandResourceInfo [ ] HttpFindCmdOrDsc ( PSRepositoryInfo repository , ResourceType type )
860
+ {
861
+ return _httpFindPSResource . FindCommandOrDscResource ( _tag , repository , _prerelease , type , out string errRecord ) ;
862
+ // TODO: write out error
863
+ }
864
+
704
865
private List < PSResourceInfo > FindDependencyPackages (
705
866
PSResourceInfo currentPkg ,
706
867
PackageMetadataResource packageMetadataResource ,
0 commit comments