Skip to content

Commit 63cae91

Browse files
Properly handle globbing
1 parent 10a8f7c commit 63cae91

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/Nitro/CommandLine/src/CommandLine.Cloud/Commands/OpenApi/UploadOpenApiCollectionCommand.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
using System.Collections.Immutable;
12
using System.Text;
23
using System.Text.Json;
34
using ChilliCream.Nitro.CommandLine.Cloud.Client;
4-
using ChilliCream.Nitro.CommandLine.Cloud.Helpers;
55
using ChilliCream.Nitro.CommandLine.Cloud.Option;
66
using ChilliCream.Nitro.CommandLine.Cloud.Option.Binders;
77
using HotChocolate.Adapters.OpenApi;
@@ -66,15 +66,9 @@ await console
6666

6767
async Task UploadOpenApiCollection(StatusContext? ctx)
6868
{
69-
Matcher matcher = new();
70-
matcher.AddIncludePatterns(patterns);
69+
var files = GlobMatcher.Match(patterns).ToArray();
7170

72-
// TODO: Does this work with absolute paths?
73-
var globResult = matcher.Execute(
74-
new DirectoryInfoWrapper(
75-
new DirectoryInfo(Directory.GetCurrentDirectory())));
76-
77-
if (!globResult.HasMatches)
71+
if (files.Length < 1)
7872
{
7973
// TODO: Improve this error
8074
console.ErrorLine("Did not find any matches...");
@@ -84,13 +78,18 @@ async Task UploadOpenApiCollection(StatusContext? ctx)
8478
var archiveStream = new MemoryStream();
8579
var collectionArchive = OpenApiCollectionArchive.Create(archiveStream, leaveOpen: true);
8680

81+
await collectionArchive.SetArchiveMetadataAsync(
82+
new ArchiveMetadata(),
83+
cancellationToken);
84+
8785
var parser = new OpenApiDocumentParser();
8886

89-
foreach (var file in globResult.Files)
87+
foreach (var file in files)
9088
{
91-
var document = Utf8GraphQLParser.Parse("");
89+
var fileContent = await File.ReadAllBytesAsync(file, cancellationToken);
90+
var document = Utf8GraphQLParser.Parse(fileContent);
9291
// TODO: The id doesn't mean anything, we should probably get rid of it...
93-
var openApiDocumentDefinition = new OpenApiDocumentDefinition(file.Path, document);
92+
var openApiDocumentDefinition = new OpenApiDocumentDefinition(file, document);
9493

9594
var parseResult = parser.Parse(openApiDocumentDefinition);
9695

0 commit comments

Comments
 (0)