Skip to content

Commit

Permalink
feat: add swift to cli type generation
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgriffing committed Mar 10, 2024
1 parent 0a5b473 commit cc0adf6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
24 changes: 24 additions & 0 deletions packages/cli/src/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,5 +295,29 @@ data object {{{name}}}Group {
}
}
{{/groups}}`,
swift: `/*
{{{disclaimerText}}}
*/
{{#groups}}
enum {{{name}}}Group {
static let name: String = "{{{rawName}}}"
static let id: String = "{{{id}}}"
enum Features {
{{#features}}
static let {{{name}}} = "{{{id}}}"
{{/features}}
}
enum Environments {
{{#environments}}
static let {{{name}}} = "{{{id}}}"
{{/environments}}
}
}
{{/groups}}`,
};
13 changes: 12 additions & 1 deletion packages/cli/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ const languageTransformers: Record<
groups: groupsOutput,
});
},
swift: function (groups: PublishedGroup[], typePrefix = "", typeSuffix = "") {
const groupsOutput = groups.map(
parseGroup(typePrefix, typeSuffix, Case.camel, Case.pascal)
);

return mustache.render(templates.swift, {
disclaimerText,
groups: groupsOutput,
});
},

// csharp: function (groups: PublishedGroup[], typePrefix = "") {
// const tagsString = tags
Expand Down Expand Up @@ -263,14 +273,15 @@ const languageAliases: Record<string, Language> = {
golang: "go",
go: "go",
php: "php",
// py: "python",
py: "python",
python: "python",
ex: "elixir",
elixir: "elixir",
// rb: "ruby",
// ruby: "ruby",
rs: "rust",
rust: "rust",
swift: "swift",
// lua: "lua",
// flutter: "dart",
// dart: "dart",
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export type Language =
| "elixir"
| "php"
| "python"
| "kotlin";
| "kotlin"
| "swift";

0 comments on commit cc0adf6

Please sign in to comment.