Commit Graph

10 Commits

Author SHA1 Message Date
Kris Coleman 05e094db68
feat: add contributing guide and generator readme (#80)
## This PR

Added a new CONTRIBUTING.md file with detailed instructions on how to
contribute new generators to the project. This includes steps from
forking the repository, implementing the generator logic, writing tests,
registering the generator in CLI, updating documentation, and creating a
pull request.

Also added a README.md in the internal/generators directory explaining
how each generator works. It details about `language.go` and
`language.tmpl` files that are essential parts of each generator along
with an example workflow of how these components interact to generate
code based on OpenFeature flag manifest.

### Related Issues
closes #69

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
2025-03-18 23:08:49 +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 9dc1d9fbc3
chore: remove empty testutils package (#55)
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
Removes empty testutils package

---------

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-04 13:52:43 +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 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