{"id":16767362,"url":"https://github.com/unmultimedio/samplr","last_synced_at":"2025-10-17T03:03:44.624Z","repository":{"id":64302368,"uuid":"258940579","full_name":"unmultimedio/samplr","owner":"unmultimedio","description":"Generate sample files (and keep them updated!) after you .gitignore your real ones.","archived":false,"fork":false,"pushed_at":"2020-07-11T03:53:46.000Z","size":73,"stargazers_count":8,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T19:43:20.430Z","etag":null,"topics":["git","gitignore","sample","secret-management"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unmultimedio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-26T04:40:15.000Z","updated_at":"2024-06-14T01:06:58.000Z","dependencies_parsed_at":"2023-01-15T09:45:43.769Z","dependency_job_id":null,"html_url":"https://github.com/unmultimedio/samplr","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/unmultimedio/samplr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unmultimedio%2Fsamplr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unmultimedio%2Fsamplr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unmultimedio%2Fsamplr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unmultimedio%2Fsamplr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unmultimedio","download_url":"https://codeload.github.com/unmultimedio/samplr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unmultimedio%2Fsamplr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279275218,"owners_count":26138562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-17T02:00:07.504Z","response_time":56,"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":["git","gitignore","sample","secret-management"],"created_at":"2024-10-13T06:08:58.719Z","updated_at":"2025-10-17T03:03:44.595Z","avatar_url":"https://github.com/unmultimedio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Samplr\n\n**Samplr** is a language-agnostic command that will generate updated commitable sample files, while you keep original ones git-ignored.\n\n\u003ca target=\"_blank\" href=\"https://youtu.be/g85wHOZSdxU\"\u003e\n  See it in action (1m video)\u003cbr/\u003e\n  \u003cimg src=\"https://img.youtube.com/vi/g85wHOZSdxU/maxresdefault.jpg\" alt=\"Samplr\" width=\"400\"/\u003e\n\u003c/a\u003e\n\n## Installation\n\nFollow instructions [here](./INSTALL.md).\n\n## Why?\n\nWe all `.gitignore` files in our repos. Many of those for security purposes, like configuration files with secrets or frequently-changing URLs that we don't want to commit and clutter in every PR everytime we change them.\n\n**So, what do we normally do?** We make a copy of the original file, and append a `.sample` to it. This serves the purpose for new repo clones to get a configuration file structure, and we just need to fill the secrets or URLs locally.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003e Actual file \u003c/th\u003e \u003cth\u003e File that we commit \u003c/th\u003e \u003cth\u003e So we can do \u003c/th\u003e\n\u003c/tr\u003e\n\n\u003ctr valign=\"top\"\u003e\n\u003ctd\u003e\n\n```yml\n# configuration.yml\nsome: variables\nurl: http://aws.url/changes.frequently\nfoo: bar\ntoken: MY.S3CUR3.T0K3N\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```yml\n# configuration.yml.sample\nsome: variables\nurl: REPLACE_ME_DEV_URL\nfoo: bar\ntoken: REPLACE_ME_TOKEN\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```gitignore\n# .gitignore\nconfiguration.yml\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n\n**And what's the issue with that?** It gets outdated really fast! When was the last time you found missing or renamed configs and secrets when onboarding someone?\n\n**Ok, so what's the idea?** I don't like making manual changes to the `.sample` file everytime I change something in the original. I know you don't either. Sometimes we just forget. What about if we could only edit the original one and the samples get updated automatically?\n\n\u003cimg src=\"https://i.kym-cdn.com/entries/icons/facebook/000/031/991/cover3.jpg\" alt=\"You son of a bitch, I'm in\" width=\"400\"/\u003e\n\n## Usage\n\n### 1. Samplr config\n\nSetup your `.samplr.yml` configuration file at the root of your project. It uses regex matches for file paths. Some example configs [here](./examples/.samplr.sample.yml)\n\n### 2. Setup your original files\n\nUse the special keywords in your original file, and samplr will take care of autogenerate the sample files.\n\n\u003e Important: you still need to manually `.gitignore` your original file.\n\n#### Keyword #samplr#\n\nRegular use case for team collaboration. It will replace the next line with the content right after. The samplr line itself will also be rendered.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003e Original file \u003c/th\u003e \u003cth\u003e Sample file \u003c/th\u003e\n\u003c/tr\u003e\n\n\u003ctr valign=\"top\"\u003e\n\u003ctd\u003e\n\n```yml\n# configuration.yml\nsome: variables\n#samplr#token: REPLACE_ME_TOKEN\ntoken: MY.S3CUR3.T0K3N\nfoo: bar\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```yml\n# configuration.sample.yml\nsome: variables\n#samplr#token: REPLACE_ME_TOKEN\ntoken: REPLACE_ME_TOKEN\nfoo: bar\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n#### Keyword #hsamplr#\n\nAs in \"hide this samplr comment\". It will replace the next line with the content right after. The samplr line itself will **not** be rendered.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003e Original file \u003c/th\u003e \u003cth\u003e Sample file \u003c/th\u003e\n\u003c/tr\u003e\n\n\u003ctr valign=\"top\"\u003e\n\u003ctd\u003e\n\n```yml\n# configuration.yml\nsome: variables\n#hsamplr#token: REPLACE_ME_TOKEN\ntoken: MY.S3CUR3.T0K3N\nfoo: bar\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```yml\n# configuration.sample.yml\nsome: variables\ntoken: REPLACE_ME_TOKEN\nfoo: bar\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n#### Keyword #ssamplr#\n\nAs in \"this is a secret samplr comment\". It will hide the samplr line itself. The next line will be rendered normally.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003e Original file \u003c/th\u003e \u003cth\u003e Sample file \u003c/th\u003e\n\u003c/tr\u003e\n\n\u003ctr valign=\"top\"\u003e\n\u003ctd\u003e\n\n```yml\n# configuration.yml\nsome: variables\n#ssamplr# secret token: MY.S3CUR3.T0K3N\nfoo: bar\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```yml\n# configuration.sample.yml\nsome: variables\nfoo: bar\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n#### Keywords combinations\n\nYou can use different keywords in the same file. If you use different keywords in the same line, it will use this priority:\n\n1. `#ssamplr#`\n1. `#hsamplr#`\n1. `#samplr#`\n\nAnd if many same keywords in the same line, it will use the first ocurrence.\n\n### 3. Samplr command\n\nRun `samplr` at the root of your project. When run, it will scan all of your directory files, and will generate samples if:\n\n- file path matches with the [configuration file](#1-samplr-config) settings.\n- it includes at least one [samplr keyword](#2-setup-your-original-files).\n\n### 4. Check the samples\n\nGenerated files does not include the `.sample` extension at the end of the file , but before the real extension (if exists), this helps editor linting and coloring.\n\n| Original filename | Generated sample filename |\n| ----------------- | ------------------------- |\n| configuration.yml | configuration.sample.yml  |\n| Dockerfile        | Dockerfile.sample         |\n\n### 5. Set up a githook (optional)\n\nGreat, now you have autogenerated sample files, but you need to remember to run `samplr` everytime? Let's set up a githook, so in every commit this happens automatically. Create a file `.git/hooks/pre-commit` (or append this to it).\n\n```sh\n#!/bin/sh\n\nset -e\n\n# Run samplr command to generate sample files\nsamplr\n# List all changed and not-ignored files, with a filename that matches with \".sample\", and add it to the commit\ngit ls-files -mo --exclude-standard | grep \"\\.sample\" | xargs git add\n```\n\n## Examples\n\nCheck examples for many type files [here](./examples).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funmultimedio%2Fsamplr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funmultimedio%2Fsamplr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funmultimedio%2Fsamplr/lists"}