Commit Graph

21 Commits

Author SHA1 Message Date
Sahid Velji bcd11ea9c8
chore: fix the directory structure (#121)
* chore: fix the directory structure

Signed-off-by: Sahid Velji <sahidvelji@gmail.com>

* chore: upgrade dependencies (#123)

Signed-off-by: Sahid Velji <sahidvelji@gmail.com>

---------

Signed-off-by: Sahid Velji <sahidvelji@gmail.com>
2025-05-31 18:13:14 +00:00
Sahid Velji 79d3dceb3a
chore: upgrade dependencies (#123)
Signed-off-by: Sahid Velji <sahid.velji@capitalone.com>
Co-authored-by: Sahid Velji <sahid.velji@capitalone.com>
2025-05-31 12:09:41 +00:00
Simon Schrottner 49e65c8283
fix: Naming of generated java class (#111)
Java expects to have a class with the same name as the file within the file. This constraint was violated, and renaming the class ort the file was needed
2025-05-20 15:19:37 -04:00
Kris Coleman 063cfca2d7
feat: adds compare command (#93)
* feat: add compare command to cli

A new 'compare' command has been added to the CLI. This command allows users to compare two manifest files and list the changes between them. The comparison is done by loading each manifest file, then using a new function from the 'manifest' package to identify differences. Error handling has also been implemented for scenarios where loading or comparing manifests fails. Tests were also included to test the compare function.

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>

* feat: adds tree behavior to compare cmd

Compare now supports flat, tree, and color output modes.

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>

* chore: refactors compare command flag handling

Refactors the compare command to use the global manifest
flag and introduces an 'against' flag for specifying the
target manifest for comparison.

This change simplifies command usage and aligns it with
other commands that utilize the global manifest configuration.

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>

* feat: Adds output formats to compare

Adds the ability to render the differences between manifests in JSON format,
providing a structured output suitable for consumption by other tools or
systems. Also, introduces validation for the output format flag.

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>

* feat: adds yaml output format

Adds the ability to output manifest comparison results in YAML format.

This provides users with another option for viewing and processing
the differences between manifests, which can be useful for
configuration management and automation tasks.

The changes include:
- Implementation of a new render function for YAML output.
- Modification of the output format selection logic to include YAML.
- Addition of YAML as a valid output format option in the command
  line interface and documentation.

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>

---------

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
2025-05-14 19:27:46 +00:00
Advitiya Jain 9a9f11fc6c
feat: add java generator (#107)
* Add Java generator

Signed-off-by: advitiya0201 <f20210979@pilani.bits-pilani.ac.in>

* Add Readme file for java

Signed-off-by: advitiya0201 <f20210979@pilani.bits-pilani.ac.in>

* Fix command description to show same value as openfeature_generate_java.md

Signed-off-by: advitiya0201 <f20210979@pilani.bits-pilani.ac.in>

* Change package name to com.example.openfeature

Signed-off-by: advitiya0201 <f20210979@pilani.bits-pilani.ac.in>

* Fix variable type and imports according to Openfeature java-SDK

Signed-off-by: advitiya0201 <f20210979@pilani.bits-pilani.ac.in>

* Refactor: expose only interface via factory method and hide client implementation

Signed-off-by: advitiya0201 <f20210979@pilani.bits-pilani.ac.in>

* Update generated docs after java generator extension

Signed-off-by: advitiya0201 <f20210979@pilani.bits-pilani.ac.in>

---------

Signed-off-by: advitiya0201 <f20210979@pilani.bits-pilani.ac.in>
2025-05-12 20:29:06 +00:00
Lukas Reining 5210429e39
feat: add codegen for NestJS (#99)
Signed-off-by: Lukas Reining <lukas.reining@codecentric.de>
Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
2025-04-18 14:28:35 +00:00
Kris Coleman ae645813c4
feat(csharp): added generator and integration tests (#97)
* feat: adds c# generator

Adds a new generator for C# to create typesafe clients.
This allows users to generate C# code based on feature flag
definitions, streamlining integration with .NET applications.
Includes necessary command-line flags, templates, and tests.

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>

* feat(csharp): adds C# generator integration test

Adds a C# code generator integration test to ensure the generated C# code compiles correctly.

This includes:
- A new C# generator based on templates
- Updates to the build process and documentation to support C# generation and testing
- An integration test using Docker to compile the generated C# code
- Fixes and adjustments to data type mappings for C# compatibility

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>

* chore: go fmt fixes

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>

* Update .github/workflows/csharp-integration.yml

Co-authored-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: Kris Coleman <kris.blacksuitmedia@gmail.com>
Signed-off-by: Kris Coleman <kriscodeman@gmail.com>

* Update CONTRIBUTING.md

Co-authored-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: Kris Coleman <kris.blacksuitmedia@gmail.com>
Signed-off-by: Kris Coleman <kriscodeman@gmail.com>

* Update internal/generators/csharp/csharp.go

Co-authored-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: Kris Coleman <kris.blacksuitmedia@gmail.com>
Signed-off-by: Kris Coleman <kriscodeman@gmail.com>

* chore(ci): moved the csharp integration into pr-test workflow as a separate job

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>

* chore: cleaned up generate code to private funcs are private

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>

* feat(csharp): implemented di for generated code

- updated openfeature to 2.3.2
- introduced IServiceCollection and DI patterns
- updated tests and expectations

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>

* Update .github/workflows/pr-test.yml

Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Signed-off-by: Kris Coleman <kris.blacksuitmedia@gmail.com>

* Update .github/workflows/pr-test.yml

Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Signed-off-by: Kris Coleman <kris.blacksuitmedia@gmail.com>

---------

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
Signed-off-by: Kris Coleman <kris.blacksuitmedia@gmail.com>
Co-authored-by: André Silva <2493377+askpt@users.noreply.github.com>
Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
2025-04-14 17:40:52 +00:00
Kim Gustyr 1f8f43ae04
feat: Python generator (#95)
* feat: Python generator

Signed-off-by: Kim Gustyr <kim.gustyr@flagsmith.com>

* fix booleans

Signed-off-by: Kim Gustyr <kim.gustyr@flagsmith.com>

* fix typo

Signed-off-by: Kim Gustyr <kim.gustyr@flagsmith.com>

* add docs

Signed-off-by: Kim Gustyr <kim.gustyr@flagsmith.com>

---------

Signed-off-by: Kim Gustyr <kim.gustyr@flagsmith.com>
2025-04-10 12:37:44 +00:00
Roman Dmytrenko 412a1174b5
fix: use the correct json schema url in init command (#96)
Signed-off-by: Roman Dmytrenko <rdmytrenko@gmail.com>
2025-04-07 12:56:39 +00:00
Michael Beemer 3fbd94726d
feat: consolidate logging and support debug flag (#92)
* feat: add nodejs generator

Signed-off-by: Michael Beemer <michael.beemer@dynatrace.com>

* feat: add a nodejs generator

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>

* improve doc diff output

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>

* check out expected sha

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>

* fix variable name

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>

* feat: consolidate logging and support debug flag

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>

* regenerate docs

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>

---------

Signed-off-by: Michael Beemer <michael.beemer@dynatrace.com>
Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
2025-04-02 14:21:20 +00:00
Michael Beemer a40b6a4d31
feat: add nodejs generator (#91)
Signed-off-by: Michael Beemer <michael.beemer@dynatrace.com>
2025-04-02 14:52:57 +01:00
Kris Coleman 9102d1390a
feat(cli): add stability annotations to generated Markdown documentation (#88)
closes #87

## This PR

This update introduces the addition of stability information to the
generated markdown content for commands in our CLI. The changes include
a new function, `addStabilityToMarkdown`, which checks if a command has
a 'stability' annotation and adds it to the markdown content
accordingly. This function is then used in both `generate.go` and
`init.go`. Additionally, formatting adjustments were made in `root.go`
for better readability.

### Notes
- Some of the logic felt a bit astonishing, so I left a lot of comments.
If this isn't helpful, I'd be happy to remove them.
- I tried to approach this in a way where the addedStabilityInfo was
inherent and not imperative.
- There is still one imperative func that needs to be used in each
command, I would be open to suggestions to eliminate it.
- The logic for customizing the markdown should work for any command we
implement in the future.
- I was going to try and use go templating to achieve this, but ended up
going with a 'mutate after the fact' approach.
- This approach could be utilized in the future to customize the docs
further, but the logic to do so is very procedural. In the future, I
would like to think up a more declarative approach, I think this could
improve it so it's more easily extensible and less to maintain.

### Follow-up Tasks
- Possibly introduce a more declarative approach so we can extend
markdown customization more easily in the future, without having to
write additional logic to figure out where to place the custom content.

### How to test
- [ ] run `make generate-docs` and you should see the stability info
output in the docs. Change or add a new stability info to a command, try
it, and you should see the changes updated.

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
2025-03-27 19:20:36 +00:00
Michael Beemer 106bf9ddfe
refactor!: add init command, update cli flags, support a config file (#71)
Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
2025-03-14 16:12:26 -04:00
Michael Beemer 68a72ee929
feat: add doc gen, move schema path, add tests, fix react gen (#68)
## This PR

- moves JSON schema to a dedicated directory
- added schema validation tests
- fixed React code gen (and tests)
- automate CLI doc generation
- Loosen JSON schema
- ~~Rename default value~~

### Related Issues

Fixes #66

### Notes

It's a big PR that I could break into smaller changes if necessary.

---------

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Signed-off-by: Michael Beemer <michael.beemer@dynatrace.com>
2025-01-27 15:20:19 +00:00
Florin-Mihai Anghel 0e7db0209e
feat: update golang output (#63)
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
<!-- add the description of the PR here -->

- updates the golang output for the flag accessors

---------

Signed-off-by: Florin-Mihai Anghel <fanghel@google.com>
Signed-off-by: Florin-Mihai Anghel <44744433+anghelflorinm@users.noreply.github.com>
Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
2024-12-09 18:25:21 +00:00
Florin-Mihai Anghel 515b5340b5
chore: update back to previous mkdir permissions (#61)
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
updates back to previous mkdir permissions.
context:
https://unix.stackexchange.com/questions/21251/execute-vs-read-bit-how-do-directory-permissions-in-linux-work

---------

Signed-off-by: Florin-Mihai Anghel <fanghel@google.com>
Signed-off-by: Florin-Mihai Anghel <44744433+anghelflorinm@users.noreply.github.com>
Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
2024-11-27 12:42:02 +00:00
Florin-Mihai Anghel e3058db6d7
refactor: change name of go module (#46)
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
Changes the name of the go module

### Related Issues
<!-- add here the GitHub issue that this PR resolves if applicable -->

Fixes #45

---------

Signed-off-by: Florin-Mihai Anghel <fanghel@google.com>
Signed-off-by: Florin-Mihai Anghel <44744433+anghelflorinm@users.noreply.github.com>
Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
2024-10-31 19:15:05 +00:00
Florin-Mihai Anghel ce14e1c99c
test: Add tests for golang and react with in memory files (#43)
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
<!-- add the description of the PR here -->

- adds tests for React and Golang

### Related Issues
https://github.com/open-feature/codegen/issues/42

Fixes #42 

### How to test
`go test ./...` from root folder

---------

Signed-off-by: Florin-Mihai Anghel <fanghel@google.com>
Signed-off-by: Florin-Mihai Anghel <44744433+anghelflorinm@users.noreply.github.com>
Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
2024-10-31 15:27:04 +00:00
Michael Beemer c13a4486b9
feat: add version command (#38)
Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
2024-10-22 14:59:59 -04:00
Michael Beemer 757ab66b7f
feat: add basic react support (#31)
## This PR

- proof-of-concept React code gen implementation

### How to test

#### Run:
`go run main.go generate react --flag_manifest_path
./sample/sample_manifest.json --output_path ./output.ts`

#### Output

```ts
'use client';

import {
	useBooleanFlagDetails,
	useNumberFlagDetails,
	useStringFlagDetails,
} from "@openfeature/react-sdk";

/**
* Discount percentage applied to purchases.
* 
* **Details:**
* - flag key: `discountPercentage`
* - default value: `0.15`
* - type: `number`
*/
export const useDiscountPercentage = (options: Parameters<typeof useNumberFlagDetails>[2]) => {
  return useNumberFlagDetails("discountPercentage", 0.15, options);
};

/**
* Controls whether Feature A is enabled.
* 
* **Details:**
* - flag key: `enableFeatureA`
* - default value: `false`
* - type: `boolean`
*/
export const useEnableFeatureA = (options: Parameters<typeof useBooleanFlagDetails>[2]) => {
  return useBooleanFlagDetails("enableFeatureA", false, options);
};

/**
* Maximum allowed length for usernames.
* 
* **Details:**
* - flag key: `usernameMaxLength`
* - default value: `50`
* - type: `number`
*/
export const useUsernameMaxLength = (options: Parameters<typeof useNumberFlagDetails>[2]) => {
  return useNumberFlagDetails("usernameMaxLength", 50, options);
};

/**
* The message to use for greeting users.
* 
* **Details:**
* - flag key: `greetingMessage`
* - default value: `Hello there!`
* - type: `string`
*/
export const useGreetingMessage = (options: Parameters<typeof useStringFlagDetails>[2]) => {
  return useStringFlagDetails("greetingMessage", "Hello there!", options);
};

```

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
2024-10-15 14:06:43 +00:00
Florin-Mihai Anghel 850c694c84
refactor: change folder, package structure; integrate with cobra (#27)
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
<!-- add the description of the PR here -->

refactor: changes folder, package structure; integrates CLI with cobra

### Related Issues
<!-- add here the GitHub issue that this PR resolves if applicable -->

Fixes https://github.com/open-feature/codegen/issues/20#issue-2559398075

---------

Signed-off-by: Florin-Mihai Anghel <fanghel@google.com>
Signed-off-by: Florin-Mihai Anghel <44744433+anghelflorinm@users.noreply.github.com>
Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
2024-10-10 07:55:36 +00:00