{"id":19788642,"url":"https://github.com/jaredramirez/elm-constants","last_synced_at":"2026-03-02T08:02:24.065Z","repository":{"id":53405353,"uuid":"208160184","full_name":"jaredramirez/elm-constants","owner":"jaredramirez","description":"Generate constant values in Elm from your environment","archived":false,"fork":false,"pushed_at":"2025-04-22T20:25:20.000Z","size":23,"stargazers_count":49,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-09T05:27:38.609Z","etag":null,"topics":["constants","elm"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaredramirez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-09-12T23:02:50.000Z","updated_at":"2025-04-22T20:25:24.000Z","dependencies_parsed_at":"2025-05-16T11:42:32.585Z","dependency_job_id":null,"html_url":"https://github.com/jaredramirez/elm-constants","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jaredramirez/elm-constants","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredramirez%2Felm-constants","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredramirez%2Felm-constants/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredramirez%2Felm-constants/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredramirez%2Felm-constants/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredramirez","download_url":"https://codeload.github.com/jaredramirez/elm-constants/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredramirez%2Felm-constants/sbom","scorecard":{"id":506444,"data":{"date":"2025-08-11","repo":{"name":"github.com/jaredramirez/elm-constants","commit":"627e9e43f50f24e29643b8c5a9ed1a932960c242"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":1,"reason":"Found 2/16 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":7,"reason":"3 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 9 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T23:20:17.218Z","repository_id":53405353,"created_at":"2025-08-19T23:20:17.218Z","updated_at":"2025-08-19T23:20:17.218Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29995910,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T01:47:34.672Z","status":"online","status_checked_at":"2026-03-02T02:00:07.342Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["constants","elm"],"created_at":"2024-11-12T06:28:11.360Z","updated_at":"2026-03-02T08:02:19.033Z","avatar_url":"https://github.com/jaredramirez.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# elm-constants\n\n\u003e Generate constant values in Elm from your environment\n\nBased on a config file, this tool will generate an Elm file of environment variables so you don't\nhave to pass them to Elm with flags and keep them around in your model.\n\n# Install\n\n`yarn add --dev elm-constants`\n\nor\n\n`npm install elm-constants --save-dev`\n\n# Usage\n\nAdd a config file to the root of your project called `elm-constants.json`.\n\nPopulate it like this:\n```json\n{\n  \"path\": \"./path/to/elm/dir\",\n  \"moduleName\": \"Constants\",\n  \"values\": [\n    [\"SERVER_URL\", \"backendUrl\"],\n    \"GOOGLE_API_KEY\"\n  ]\n}\n```\n\nFor the `values` field you can have either a regular string or an array with two values. If you specify\na regular string, this tool will automatically convert it to a valid Elm variable name. In the case of `GOOGLE_API_KEY`,\nit would generate `googleApiKey`. If you're not happy with the generated name or just want to rename it anyways,\nyou can specify an array where the first value is the environment variable and the second is the Elm name.\n\nThen, in your pre-build step, run `yarn elm-constants` (or `npx elm-constants`) to generate an Elm file!\n\nBased on the above config, you would get something like:\n```elm\nmodule Constants exposing (googleApiKey, serverUrl)\n\n\ngoogleApiKey : String\ngoogleApiKey =\n    \"def\"\n\n\nbackendUrl : String\nbackendUrl =\n    \"abc\"\n```\n\n\n# CLI Options\n```\nOptions:\n  --version, -v     Print the installed version                  [boolean]\n  --no-dotenv       Dont' use dotenv                             [boolean]\n  --env-path, -p    Path to env file                             [string]\n  --config, -c      Path to config file                          [string]\n  --help, -h        Show help                                    [boolean]\n```\n\n## Config Schema\n\nThe schema for the config file.\n\n```\n{ \"path\" : String\n, \"moduleName\" : String\n, \"values\" : [String, String] | String\n}\n```\n\n# Dotenv\n\nThis package automatically works with [`dotenv`](https://github.com/motdotla/dotenv).\nBy default this will look for an `.env` file at current working directory. Alternatively you \nmay provide a path flag (`--env-path`) for a custom file such as `--env-path=./env/.env.staging`.\nIf you run `elm-constants` in and `NODE_ENV` is **not** `production`, then this tool automatically loads that file.\n\nIf you want to turn this off, just pass `--no-dotenv` to `elm-constants`\n\n# Rationale\n\nHave you ever been writing an Elm app and started off like this:\n\n```elm\ntype alias Flags =\n  { serverUrl : String\n  , googleApiKey : String\n  , ...\n  }\n\n\ninit : Flags -\u003e ( Model, Cmd Msg )\ninit flags =\n  ( { severUrl = flags.severUrl, googleApiKey = flags.googleApiKey, ... }\n  , fetch flags.serverUrl\n  )\n```\n\nAnd if you're writing an SPA, you have to pass those flag down to every page:\n\n```elm\ntype Msg\n  = PageMsg Page.Msg\n  \n  \nupdate : Msg -\u003e Model -\u003e ( Model, Cmd Msg )\nupdate msg model = \n    case (msg, model.page) of\n       (PageMsg subMsg, PageModel subModel) -\u003e\n            let\n                (nextSubModel, nextSubMsg) =\n                    Page.update model.serverUrl -- Pass serverUrl down to each page\n                        subMsg\n                        subModel\n            in\n            ( { model | page = PageModel nextSubModel }\n            , nextSubMsg |\u003e Cmd.map PageMsg\n            )\n        ...\n      \nview : Model -\u003e Html Msg\nview model =\n    case model.page of\n       PageModel subModel -\u003e\n           Page.view model.googleApiKey subModel -- Pass googleApiKey to each page \n       ...\n```\n\nI got tired of havng to keep these seemingly static pieces of data in the model and having to pass them everywhere.\nSo I wrote a way to generate an Elm constants file based on your environment!\n\n# Thanks\n\nThanks to [`elm-graphql`](https://package.elm-lang.org/packages/dillonkearns/elm-graphql/latest) for making me think to use\nfile generation to solve a problem.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredramirez%2Felm-constants","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredramirez%2Felm-constants","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredramirez%2Felm-constants/lists"}