Skip to content

Commit

Permalink
fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp committed Oct 7, 2024
1 parent 0c85ff9 commit be3dbf1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ public void addSupportingFiles(List<SupportingFile> supportingFiles, String outp

File templates = new File("templates/" + language + "/guides/" + client);
for (File f : templates.listFiles()) {
String fileName = f.getName().replace(".mustache", "");

if (language.equals("swift")) {
fileName = Helpers.capitalize(fileName) + "/main";
}

supportingFiles.add(
new SupportingFile(
"guides/" + client + "/" + f.getName(),
"guides/" + language + outputFolder + f.getName().replace(".mustache", "") + extension
)
new SupportingFile("guides/" + client + "/" + f.getName(), "guides/" + language + outputFolder + fileName + extension)
);
}
}
Expand All @@ -54,6 +57,14 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
bundle.put("isSearchClient", true);
}
bundle.put("isSyncClient", true);
// nothing to do here, the mustache uses dynamicSnippets lambda

if (language.equals("swift")) {
File templates = new File("templates/" + language + "/guides/" + client);
bundle.put(
"guides",
Arrays.stream(templates.listFiles()).map(File::getName).map(name -> Helpers.capitalize(name.replace(".mustache", ""))).toArray()
);
}
// no data to add to the bundle, the mustache uses dynamicSnippets lambda
}
}
23 changes: 14 additions & 9 deletions templates/swift/guides/Package.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

import PackageDescription

let dependencies: [Target.Dependency] = [{{#packageList}}
.product(
name: "{{{.}}}",
package: "algoliasearch-client-swift"
),{{/packageList}}
]

let package = Package(
name: "AlgoliaSearchClientGuides",
platforms: [
Expand All @@ -15,14 +22,12 @@ let package = Package(
.package(path: "../../clients/algoliasearch-client-swift")
],
targets: [
.executableTarget(
name: "AlgoliaSearchClientGuides",
dependencies: [{{#packageList}}
.product(
name: "{{{.}}}",
package: "algoliasearch-client-swift"
),{{/packageList}}
]
)
{{#guides}}
.executableTarget(
name: "{{{.}}}",
dependencies: dependencies,
path: "Sources/{{{.}}}"
),
{{/guides}}
]
)
8 changes: 6 additions & 2 deletions templates/swift/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Foundation
import Core
{{> snippets/import}}

func saveObjectsMovies() async throws {
Task {
let url = URL(string: "https://dashboard.algolia.com/sample_datasets/movie.json")!
var data: Data? = nil
#if os(Linux) // For linux interop
Expand All @@ -22,7 +22,11 @@ func saveObjectsMovies() async throws {
do {
// Save records in Algolia index
{{#dynamicSnippet}}saveObjectsMovies{{/dynamicSnippet}}
exit(EXIT_SUCCESS)
} catch {
print(error.localizedDescription)
exit(EXIT_FAILURE)
}
}
}

RunLoop.current.run()

0 comments on commit be3dbf1

Please sign in to comment.