foobar_templates 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.beader/.gitignore +6 -0
  3. data/.beader/issues/1-support-flexible-template-topologies.yaml +21 -0
  4. data/.beader/issues/2-add-monorepo-support-for-template-discovery-and-generation.yaml +33 -0
  5. data/.beader/issues/3-implement-monorepo-aware-recursive-template-inventory.yaml +29 -0
  6. data/.beader/issues/4-add-leaf-template-selection-with-ambiguity-and-not-found-handling.yaml +30 -0
  7. data/.beader/issues/5-integrate-leaf-template-resolution-into-generation-flow.yaml +30 -0
  8. data/.beader/issues/6-add-monorepo-discovery-and-generation-test-coverage.yaml +31 -0
  9. data/.beader/issues/7-document-monorepo-template-configuration-and-selection.yaml +30 -0
  10. data/.beader/meta.yaml +1 -0
  11. data/.gitignore +16 -0
  12. data/.rspec +2 -0
  13. data/Gemfile +3 -0
  14. data/LICENSE.txt +22 -0
  15. data/README.md +154 -0
  16. data/Rakefile +55 -0
  17. data/bin/foobar_templates +72 -0
  18. data/changelog +107 -0
  19. data/config/config +8 -0
  20. data/foobar_templates.gemspec +33 -0
  21. data/lib/foobar_templates/cli/cheat_sheet.rb +12 -0
  22. data/lib/foobar_templates/cli/cli.rb +3 -0
  23. data/lib/foobar_templates/cli/dir_to_template.rb +120 -0
  24. data/lib/foobar_templates/cli/setup_personal_templates_repo.rb +135 -0
  25. data/lib/foobar_templates/cli/template_generator.rb +462 -0
  26. data/lib/foobar_templates/configurator.rb +99 -0
  27. data/lib/foobar_templates/core/core.rb +9 -0
  28. data/lib/foobar_templates/core/dir_to_template.rb +114 -0
  29. data/lib/foobar_templates/strings.rb +23 -0
  30. data/lib/foobar_templates/template_manager.rb +119 -0
  31. data/lib/foobar_templates/templates/template-test/.vscode/launch.json +0 -0
  32. data/lib/foobar_templates/templates/template-test/foo-bar/keep +0 -0
  33. data/lib/foobar_templates/templates/template-test/foo-bar.rb +16 -0
  34. data/lib/foobar_templates/templates/template-test/foo_bar/keep +0 -0
  35. data/lib/foobar_templates/templates/template-test/foobar.yml +2 -0
  36. data/lib/foobar_templates/templates/template-test/simple_dir/keep +0 -0
  37. data/lib/foobar_templates/templates/template-test/test_confirmed +0 -0
  38. data/lib/foobar_templates/templates/test_template/foo-bar/keep +0 -0
  39. data/lib/foobar_templates/templates/test_template/foo-bar.rb +21 -0
  40. data/lib/foobar_templates/templates/test_template/foo_bar/keep +0 -0
  41. data/lib/foobar_templates/templates/test_template/foobar.yml +2 -0
  42. data/lib/foobar_templates/templates/test_template/simple_dir/keep +0 -0
  43. data/lib/foobar_templates/version.rb +3 -0
  44. data/lib/foobar_templates.rb +151 -0
  45. data/spec/data/variable_manifest_test.rb +21 -0
  46. data/spec/foobar_templates/cli/dir_to_template_spec.rb +153 -0
  47. data/spec/foobar_templates/core/dir_to_template_spec.rb +104 -0
  48. data/spec/foobar_templates_spec.rb +573 -0
  49. data/spec/spec_helper.rb +106 -0
  50. data/spec/template_manager_spec.rb +68 -0
  51. metadata +157 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8ce07f040ecc4ee93a6ee5b6d091af7fdecda0d95f36d17404f900cb48086fa9
4
+ data.tar.gz: dd0c320b9a1176f5873889fc18b9304923a2771383f426bc053a9158ed98e76a
5
+ SHA512:
6
+ metadata.gz: 9ed9a0c22a22e58eb73124062cd444bc547e1ce0d5ad48bf10942d68c571b3c3d15395aaeef732406ca77fe6e56ce561aa94ccefce39837ac170ebe513eb54eb
7
+ data.tar.gz: 1c09a14c319a55532052e0ece16582b7876a34f73377de7821c4ed0a40927483ffa675f56f843422cf8a31670d9cf3c26a4e97b29a0d99e54cc034e8dac7912b
@@ -0,0 +1,6 @@
1
+ *.lock
2
+ *.log
3
+ identities.yaml
4
+ integrations
5
+ hooks
6
+ issues
@@ -0,0 +1,21 @@
1
+ ---
2
+ id: 1
3
+ title: Support Flexible Template Topologies
4
+ type: epic
5
+ status: closed
6
+ priority: 1
7
+ assignees:
8
+ - kind-prism
9
+ created_at: 2026-04-01T03:29:28.803231289Z
10
+ updated_at: 2026-04-01T03:35:47.235779844Z
11
+ closed_at: 2026-04-01T03:35:47.235778978Z
12
+ ---
13
+
14
+ Broader effort to support evolving template repository structures (single-template repos and monorepo-style template collections) while preserving backward compatibility.
15
+
16
+ ---
17
+ COMMENT
18
+ 2026-04-01T03:35:47.232496261Z
19
+ author: kind-prism
20
+
21
+ Epic objective delivered for this cycle through root feature #2 and child issues #3-#7. Monorepo template discovery, selection, generation integration, tests, and documentation are complete.
@@ -0,0 +1,33 @@
1
+ ---
2
+ id: 2
3
+ title: Add monorepo support for template discovery and generation
4
+ type: feature
5
+ status: closed
6
+ priority: 1
7
+ parent: 1
8
+ assignees:
9
+ - kind-prism
10
+ created_at: 2026-04-01T03:29:28.848153656Z
11
+ updated_at: 2026-04-01T03:35:18.475324707Z
12
+ closed_at: 2026-04-01T03:35:18.475323732Z
13
+ ---
14
+
15
+ ## User Message
16
+ We need a syntax for bundlegem.yml file that allows us to specify that this is a monorepo with multiple templates within it. Maybe something like this...
17
+
18
+ monorepo: true
19
+
20
+ If that file is set, then we look for subdirectories that have their own bundlegem.yml file following the usual configurations.
21
+
22
+ ## Context
23
+ Implementation plan source: /memories/session/plan.md
24
+
25
+ ## Goal
26
+ Add opt-in monorepo support to template discovery and generation while preserving existing single-template behavior.
27
+
28
+ ---
29
+ COMMENT
30
+ 2026-04-01T03:35:18.472408807Z
31
+ author: kind-prism
32
+
33
+ Completed monorepo support for template discovery and generation. Implemented recursive monorepo-aware inventory from monorepo: true containers, leaf-template selection by subtemplate name, actionable ambiguity and not-found errors, and generation behavior validated to use leaf template config. Added unit/integration coverage and README documentation updates. Validation: bundle exec rspec passed (29 examples, 0 failures).
@@ -0,0 +1,29 @@
1
+ ---
2
+ id: 3
3
+ title: Implement monorepo-aware recursive template inventory
4
+ type: feature
5
+ status: closed
6
+ priority: 1
7
+ parent: 2
8
+ assignees:
9
+ - kind-prism
10
+ created_at: 2026-04-01T03:29:28.883340322Z
11
+ updated_at: 2026-04-01T03:32:36.142758994Z
12
+ closed_at: 2026-04-01T03:32:36.142758236Z
13
+ ---
14
+
15
+ Discovered from #2.
16
+
17
+ Implement recursive template inventory in configurator:
18
+ - Add safe bundlegem.yml config loading helper
19
+ - Classify directories as monorepo containers (monorepo: true) vs leaf templates
20
+ - Recurse only through monorepo-marked directories
21
+ - Emit only leaf templates for listing, preserving category behavior
22
+ - Ensure monorepo container root files are not treated as template sources
23
+
24
+ ---
25
+ COMMENT
26
+ 2026-04-01T03:32:36.139335553Z
27
+ author: kind-prism
28
+
29
+ Implemented recursive monorepo-aware template inventory in Configurator. Added safe bundlegem.yml loading, monorepo container detection via monorepo: true, recursive traversal only through monorepo containers, and leaf-only template emission for list output. Added specs for direct and nested monorepo listing behavior and helper fixture creation. Validation: bundle exec rspec passed (25 examples, 0 failures).
@@ -0,0 +1,30 @@
1
+ ---
2
+ id: 4
3
+ title: Add leaf-template selection with ambiguity and not-found handling
4
+ type: feature
5
+ status: closed
6
+ priority: 1
7
+ parent: 2
8
+ blocked_by:
9
+ - 3
10
+ assignees:
11
+ - kind-prism
12
+ created_at: 2026-04-01T03:29:28.915988414Z
13
+ updated_at: 2026-04-01T03:33:38.342992036Z
14
+ closed_at: 2026-04-01T03:33:38.342991170Z
15
+ ---
16
+
17
+ Discovered from #2.
18
+
19
+ Update template selection logic:
20
+ - Resolve template by subtemplate-only leaf name
21
+ - Fail with actionable not-found error when no match exists
22
+ - Fail with actionable ambiguity error when multiple leaf templates share a name
23
+ - Keep existing non-monorepo template selection behavior unchanged
24
+
25
+ ---
26
+ COMMENT
27
+ 2026-04-01T03:33:38.339552995Z
28
+ author: kind-prism
29
+
30
+ Implemented monorepo leaf-template selection in TemplateManager. Added recursive leaf discovery rooted at monorepo: true containers, unique subtemplate-only name matching, actionable not-found errors listing available leaves, and actionable ambiguity errors listing conflicting paths. Added focused unit tests covering unique match, duplicate-name ambiguity, and monorepo not-found behavior. Validation: bundle exec rspec passed (28 examples, 0 failures).
@@ -0,0 +1,30 @@
1
+ ---
2
+ id: 5
3
+ title: Integrate leaf template resolution into generation flow
4
+ type: task
5
+ status: closed
6
+ priority: 1
7
+ parent: 2
8
+ blocked_by:
9
+ - 4
10
+ assignees:
11
+ - kind-prism
12
+ created_at: 2026-04-01T03:29:28.945867072Z
13
+ updated_at: 2026-04-01T03:34:24.818985978Z
14
+ closed_at: 2026-04-01T03:34:24.818985111Z
15
+ ---
16
+
17
+ Discovered from #2.
18
+
19
+ Integrate generation with leaf template paths:
20
+ - Ensure resolved template source is a leaf template directory
21
+ - Keep CLI::Gem config loading based on the leaf bundlegem.yml
22
+ - Ensure bootstrap and prefix behavior come from leaf config only
23
+ - Preserve existing single-template generation flow
24
+
25
+ ---
26
+ COMMENT
27
+ 2026-04-01T03:34:24.815837053Z
28
+ author: kind-prism
29
+
30
+ Integrated monorepo leaf-template resolution into generation flow by relying on leaf path selection in TemplateManager and validating behavior end-to-end. Added integration coverage proving generation runs from a selected leaf template and uses leaf bootstrap configuration while ignoring container-level monorepo config. Validation: bundle exec rspec passed (29 examples, 0 failures).
@@ -0,0 +1,31 @@
1
+ ---
2
+ id: 6
3
+ title: Add monorepo discovery and generation test coverage
4
+ type: task
5
+ status: closed
6
+ priority: 1
7
+ parent: 2
8
+ blocked_by:
9
+ - 5
10
+ assignees:
11
+ - kind-prism
12
+ created_at: 2026-04-01T03:29:28.976366156Z
13
+ updated_at: 2026-04-01T03:34:38.442683072Z
14
+ closed_at: 2026-04-01T03:34:38.442681989Z
15
+ ---
16
+
17
+ Discovered from #2.
18
+
19
+ Add and update tests:
20
+ - Unit tests for recursive discovery and recursion boundaries
21
+ - Unit tests for ambiguous leaf-name selection failures
22
+ - Integration tests for list output with monorepo leaf templates
23
+ - Integration tests for end-to-end generation from discovered leaf templates
24
+ - Add helper fixtures/utilities for nested monorepo test trees
25
+
26
+ ---
27
+ COMMENT
28
+ 2026-04-01T03:34:38.439580189Z
29
+ author: kind-prism
30
+
31
+ Completed test coverage for monorepo behavior: added list integration tests for leaf-template discovery and nested recursion boundaries, added template-manager unit tests for ambiguous leaf-name failures and monorepo not-found behavior, added end-to-end generation integration test from discovered monorepo leaf templates, and added helper fixture utility create_monorepo_template for nested monorepo trees. Validation: bundle exec rspec passed (29 examples, 0 failures).
@@ -0,0 +1,30 @@
1
+ ---
2
+ id: 7
3
+ title: Document monorepo template configuration and selection
4
+ type: task
5
+ status: closed
6
+ priority: 2
7
+ parent: 2
8
+ blocked_by:
9
+ - 5
10
+ assignees:
11
+ - kind-prism
12
+ created_at: 2026-04-01T03:29:29.005536422Z
13
+ updated_at: 2026-04-01T03:35:05.533255090Z
14
+ closed_at: 2026-04-01T03:35:05.533254332Z
15
+ ---
16
+
17
+ Discovered from #2.
18
+
19
+ Document monorepo usage in README:
20
+ - Describe monorepo: true semantics
21
+ - Describe recursive traversal behavior through monorepo containers
22
+ - Describe subtemplate-only selection behavior
23
+ - Document ambiguity error behavior and expected resolution
24
+
25
+ ---
26
+ COMMENT
27
+ 2026-04-01T03:35:05.529805865Z
28
+ author: kind-prism
29
+
30
+ Updated README with a new monorepo template section documenting monorepo: true semantics, recursive traversal through monorepo containers, leaf-only template selection using subtemplate names, and ambiguity error behavior when duplicate leaf names exist. Validation: bundle exec rspec passed (29 examples, 0 failures).
data/.beader/meta.yaml ADDED
@@ -0,0 +1 @@
1
+ next_id: 8
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ *.swp
15
+ mkmf.log
16
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 TheNotary
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,154 @@
1
+ # Foobar Templates: A Pain-Free Project Templator
2
+ [![Gem Version](https://badge.fury.io/rb/foobar_templates.svg)](https://badge.fury.io/rb/foobar_templates)
3
+
4
+ Foobar Templates allow users to define project templates in the most native form to all technologist: Directory Structures, short commands, and helpful commands that make the tool's usage completely visible!
5
+
6
+ Programming often involves a lot of boilerplate and configuration "boot strapping" before you can get going actually writing any code. To automate this aspect of creating new projects and microservices, foobar_templates allows you to run a simple command `foobar_templates -t my-c-embedded-template project-name` and it will clone a template you've made with exact specifications, update the names of files and references within the files to match your project name, run any commands specified in your template. What once would have been a 5-10 minute distraction of remembering and implementing all those little patterns, testing dependencies, and pipeline definitions now happens immediately with a single command.
7
+
8
+ The most beneficial aspect of Foobar Templates is that it allows you to specify exactly how you want your 'default starting project' to look, rather than rely on what someone else thought would be generally helpful.
9
+
10
+ ### Installation
11
+
12
+ I highly recommend the `foobar` alias!
13
+
14
+ ```bash
15
+ gem install foobar_templates
16
+ foobar_templates --install-public-templates
17
+
18
+ echo "alias foobar='foobar_templates'" >> ~/.bashrc
19
+ source ~/.bashrc
20
+ ```
21
+
22
+ #### List Available Templates
23
+
24
+ ```bash
25
+ $ foobar_templates -l
26
+ PREDEFINED:
27
+ default - A basic ruby gem
28
+ service - A gem that allows installation as a service to run as a daemon
29
+
30
+ MISC:
31
+ my_service -
32
+
33
+ EMBEDDED:
34
+ arduino
35
+ ```
36
+
37
+ ### Usage
38
+
39
+ These commands will create a new gem named `project_name` in `/tmp/project_name`:
40
+
41
+ ```bash
42
+ $ cd /tmp
43
+ $ foobar_templates -t arduino project_name
44
+ ```
45
+
46
+ You'll find a project skeleton in ~/.foobar/templates/my_service that you can customize to your liking.
47
+
48
+ ### Configuration
49
+
50
+ Configuration is stored in `~/.foobar/config` (created automatically on first run). At minimum, you need your git user name and email configured:
51
+
52
+ ```bash
53
+ git config --global user.email your-public-gh@email.com
54
+ git config --global user.name YOUR_GH_NAME
55
+ ```
56
+
57
+ ## Create Your Own Template
58
+
59
+ > **WIP:** We're actively refactoring the template system. `constant_array` has been dropped and this may cause the ruby template to break. `unprefixed_name` and `unprefixed_pascal` have also been removed.
60
+
61
+ ###### Overview
62
+ - Define the project as a working codebase using `foo-bar` as the project name
63
+ - All name variants (`foo_bar`, `FooBar`, `FOO_BAR`, etc.) will be auto-replaced when generating a new project
64
+ - Use `FOO_` prefixed placeholders for non-name variables (e.g., `FOO_AUTHOR`, `FOO_EMAIL`)
65
+ - Add a `foobar.yml` file to the template to make it available for use
66
+ - Run `foobar_templates --copy-to-templates` to convert an existing project's name variants into foo-bar placeholders
67
+ - Use the template to kick off a new project, `foobar_templates -t my-template first-test`
68
+
69
+ To create your own template, just create a new project using the technologies you'd like. Place this project in `~/.foobar/templates/my-template`. Once it's done, it's a good idea to create a git commit. Then run something to the effect...
70
+
71
+ ```bash
72
+ $ echo "category: frontend" > foobar.yml
73
+ $ echo "purpose: frontend" >> foobar.yml
74
+ $ echo "language: javascript" >> foobar.yml
75
+
76
+ $ foobar_templates --copy-to-templates
77
+ ```
78
+
79
+ Change the foobar.yml contents to what makes sense for your template. The `--copy-to-templates` command will prompt you for the template's folder name (defaults to the current project's basename) and the `category` to record in `foobar.yml` (defaults to the existing value, or `misc`), then replace all occurrences of your project's name variants with `foo-bar` template placeholders.
80
+
81
+ #### Categorizing Your Template
82
+
83
+ You can specify the `category` of the gem by editing the `foobar.yml` file in each template's root. Categories are just used for organizing the output when you run `foobar_templates --list`. Here's an [example](https://github.com/TheNotary/template-html-css-js/blob/main/foobar.yml).
84
+
85
+ #### Monorepo Template Collections
86
+
87
+ You can organize templates in nested directories by marking a directory as a monorepo container:
88
+
89
+ ```yaml
90
+ monorepo: true
91
+ ```
92
+
93
+ When a directory is marked with `monorepo: true`, Foobar Templates treats it as a container and recursively scans child directories for templates. A child is treated as a template when it has its own `foobar.yml` and is not marked `monorepo: true`.
94
+
95
+ Container-level files are ignored for generation. Only discovered leaf templates are selectable and usable with `foobar_templates`.
96
+
97
+ Example layout:
98
+
99
+ ```text
100
+ ~/.foobar/templates/template-platform/
101
+ foobar.yml # monorepo: true
102
+ template-api/
103
+ foobar.yml # normal template config
104
+ foo-bar.rb
105
+ template-ui/
106
+ foobar.yml # normal template config
107
+ foo-bar.rb
108
+ ```
109
+
110
+ In this example, select templates by leaf name:
111
+
112
+ ```bash
113
+ foobar_templates -t api my-service
114
+ foobar_templates -t ui my-frontend
115
+ ```
116
+
117
+ If multiple monorepo leaves share the same name, Foobar Templates fails with an ambiguity error and shows the conflicting paths so one can be renamed.
118
+
119
+ #### Template Prefix Stripping
120
+
121
+ Some people sort their repos with prefixes... For instance, you might want to create a repo named `tool-go-my-tool` but have the project file take on the name `my-tool` and ignore those descriptive prefixes?
122
+
123
+ You can do that! Just setup your `foobar.yml` as below:
124
+ ```yaml
125
+ purpose: tool
126
+ language: go
127
+ ```
128
+
129
+ You can also set the prefix explicitly in `foobar.yml`:
130
+ ```yaml
131
+ prefix: "my-custom-prefix-"
132
+ ```
133
+
134
+ #### Customizing Your Own Templates
135
+
136
+ Place your own templates in `~/.foobar/templates`. You can populate it with examples by running `foobar_templates --install-public-templates` which will effectively clone down a few sample git repos into the templates folder for you such as [Go-cli](https://github.com/TheNotary/template-go-cli) for instance.
137
+
138
+ You'll get a good idea as to the possibilities by inspecting the various templates I've opensourced under my github org, e.g. [template-ruby-cli-gem](https://github.com/TheNotary/template-ruby-cli-gem).
139
+
140
+ To pull up a list of available variables, run this command
141
+
142
+ ```
143
+ $ foobar_templates --cheat-sheet
144
+ ```
145
+
146
+ If you would find additional variables handy, set me up with a PR and assuming it seems widely helpful, I'll merge it right as soon as I can. The implementation for the variables is largely found in [gem.rb](https://github.com/TheNotary/foobar_templates/blob/main/lib/foobar_templates/cli/template_generator.rb#L59).
147
+
148
+ #### Quick Tips Regarding Project Templates
149
+
150
+ - Templates are working code using `foo-bar` as the canonical project name
151
+ - Name variants (`foo_bar`, `FooBar`, `fooBar`, `FOO_BAR`, `Foo::Bar`, `Foo Bar`, `foo/bar`) are all auto-replaced
152
+ - Use `FOO_` prefixed placeholders for non-name variables: `FOO_AUTHOR`, `FOO_EMAIL`, `FOO_GIT_REPO_URL`, etc.
153
+ - Running `foobar_templates --cheat-sheet` will list off available template variables
154
+ - File **names** containing `foo-bar` or `foo_bar` will have those replaced by the project name
data/Rakefile ADDED
@@ -0,0 +1,55 @@
1
+ require 'rake'
2
+ require 'rspec/core/rake_task'
3
+
4
+ GEM_NAME = "foobar_templates"
5
+ GEM_SPEC = "#{GEM_NAME}.gemspec"
6
+
7
+ desc "Build #{GEM_NAME} gem"
8
+ task :build do
9
+ system "gem build #{GEM_SPEC}"
10
+ FileUtils.mkdir_p "pkg"
11
+ FileUtils.mv Dir.glob("#{GEM_NAME}-*.gem"), "pkg/"
12
+ end
13
+
14
+ desc "Install #{GEM_NAME} gem locally"
15
+ task install: :build do
16
+ system "gem install pkg/#{Dir.children('pkg').sort.last}"
17
+ end
18
+
19
+ desc "Build and push #{GEM_NAME} gem to RubyGems"
20
+ task release: :build do
21
+ gem_file = Dir.glob("pkg/#{GEM_NAME}-*.gem").sort.last
22
+ system "gem push #{gem_file}"
23
+ end
24
+
25
+ desc "Run unit specs"
26
+ RSpec::Core::RakeTask.new(:unit) do |t|
27
+ t.rspec_opts = %w(-fd -c)
28
+ t.pattern = "./spec/unit/**/*_spec.rb"
29
+ end
30
+
31
+ desc "Run integration specs that are very high level"
32
+ RSpec::Core::RakeTask.new(:integration) do |t|
33
+ t.rspec_opts = %w(-fd -c)
34
+ t.pattern = "./spec/integration/**/*_spec.rb"
35
+ end
36
+
37
+ desc "Run all specs"
38
+ RSpec::Core::RakeTask.new(:spec) do |t|
39
+ t.rspec_opts = %w(-fd -c)
40
+ end
41
+
42
+ # this is for running tests that you've marked current... eg: it 'should work', current: true do
43
+ RSpec::Core::RakeTask.new(:current) do |spec|
44
+ spec.pattern = 'spec/**/*_spec.rb'
45
+ spec.rspec_opts = ['--tag current']
46
+ end
47
+
48
+ # alias for current
49
+ RSpec::Core::RakeTask.new(:c) do |spec|
50
+ spec.pattern = 'spec/**/*_spec.rb'
51
+ spec.rspec_opts = ['--tag current']
52
+ end
53
+
54
+ task default: :spec
55
+ task test: :spec
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'foobar_templates'
5
+
6
+
7
+ Signal.trap("INT") { exit 1 }
8
+ options = {}
9
+
10
+ parser = OptionParser.new do |opts|
11
+ opts.banner = "Usage: #{File.basename($0)} [options] GEM_NAME"
12
+
13
+ opts.on("-t", "--template TEMPLATE", "Specify a template") do |template|
14
+ options[:template] = template
15
+ end
16
+
17
+ opts.on("-l", "--list", "List available templates") do
18
+ puts FoobarTemplates.list
19
+ exit
20
+ end
21
+
22
+ opts.on("-c", "--cheat-sheet", "Show list of variables available in templates") do
23
+ puts FoobarTemplates.cheat_sheet
24
+ exit
25
+ end
26
+
27
+ opts.on("-v", "--version", "Show version") do
28
+ puts FoobarTemplates.version
29
+ exit
30
+ end
31
+
32
+ opts.on("--install-public-templates", "Install public templates") do
33
+ FoobarTemplates.install_public_templates
34
+ exit
35
+ end
36
+
37
+ opts.on("--setup-personal-templates", "Create a personal mono-repo template collection") do
38
+ FoobarTemplates.setup_personal_templates
39
+ exit
40
+ end
41
+
42
+ opts.on("--copy-to-templates", "Exports the current project into your personal templates repo, converting it to a template") do
43
+ FoobarTemplates.dir_to_template
44
+ exit
45
+ end
46
+
47
+ opts.on(nil, "--help", "Show help") do
48
+ puts opts
49
+ puts FoobarTemplates::HELP_MSG
50
+ exit
51
+ end
52
+ end
53
+
54
+ # fyi parser.parse! splices options out of ARGV, so gem_name doesn't need to be specified first
55
+ parser.parse!
56
+
57
+ if ARGV.empty?
58
+ puts parser
59
+ puts FoobarTemplates::HELP_MSG
60
+ exit 1
61
+ end
62
+
63
+ if ARGV.length > 1
64
+ puts "Error: there were unrecognized parameters specified in command"
65
+ puts FoobarTemplates::HELP_MSG
66
+ exit 1
67
+ end
68
+
69
+
70
+ gem_name = ARGV.first
71
+ FoobarTemplates.generate_template(options, gem_name)
72
+
data/changelog ADDED
@@ -0,0 +1,107 @@
1
+ ** Unreleased **
2
+ - Rename: project renamed from `bundlegem` to `foobar_templates`. Module is now `FoobarTemplates`, executable is `foobar_templates`, per-template config file is `foobar.yml`, and user config/templates live under `~/.foobar/`. No backward-compatibility shims.
3
+
4
+ ** Planned 0.2.x **
5
+ - Feature: templates can declare a `name_validation:` block in bundlegem.yml with two optional keys: `reserved_names` (exact-match denylist) and `regex_validator` (a Ruby regex the project name must match). Validation runs after the built-in regex check and before any files are written. All checks happen in pure Ruby — no shell, no cross-platform concerns.
6
+ - Removed the hardcoded ruby-cli-gem constant-collision check from core; templates now declare their own naming rules via name_validation.
7
+
8
+ ** 0.2.0 **
9
+ - Feature: improves stdout feedback to enhance UX
10
+ - Feature: hides stack trace when user is simply missing a bundlegem.yml file
11
+ - Feature: allows interpolation of template variables within bootstrap_command
12
+ - Feature: adds a 'config[:title]' variable
13
+ - Bugfix: fixes issue where .git and it's subfolders were being created from the source template repo which wasted time
14
+ - Bugfix: fixes a performance issue where shelling out to git check-ignored was being performed many times within high frequency loops
15
+ - Bugfix: fixes bug where not specifying the category of a template apparently causes the list function to crash
16
+ - Bugfix: Cleans out dependencies that are no longer used
17
+ - Bugfix: Cleaned out tons of dead code and addressed tech debt I've been putting off since 1.8.5
18
+ - Bugfix: Changes working directory before running bootstrap_commands
19
+
20
+ ** 0.1.0 **
21
+ - Feature: Drops .bundlegem file in favor of bundlegem.yml in templates
22
+ - Feature: Introduces `--to-template` switch to add a `.tt` extension to all files in the current directory
23
+ - Feature: Enables execution of bootstrap_commands listing in bundlegem.yml
24
+ - Feature: Cleans out built-in templates in favor of externally managed templates
25
+ - Bugfix: Prevents creation of template files that are gitignored
26
+
27
+ ** 1.0.0 **
28
+ - Feature: Greatly expands the template interpolation values
29
+ - Bugfix: misc cleanup
30
+
31
+ ** 0.0.14 **
32
+ - Bugfix: The project didn't work with ruby 3 due to use of the method `exists?`???
33
+
34
+ ** 0.0.13 **
35
+ - Adds new built-in java template
36
+
37
+ ** 0.0.12 **
38
+ - Feature: File mode (permissions) is now cloned from source template file's permissions to dest
39
+ - Bugfix: project names may now contain hyphens
40
+ - Feature: java project template added to best templates
41
+ - Feature: python project template added to best templates
42
+
43
+ ** 0.0.11 **
44
+ - Bugfix: config[:bundler_version] was listing the version of bundlegem not bundler
45
+
46
+ ** 0.0.10 **
47
+ - Feature: tweaks built-in templates
48
+
49
+ ** 0.0.9 **
50
+ - Bugfix: there were misconfigurations with the Rakefiles for cli_gems and c_ect gems that were corrected
51
+ - Feature: `--version` option added
52
+
53
+ ** 0.0.8 **
54
+
55
+ - Bugfix: fixes bug where git clone was attempted even when the a clone
56
+ already took place in a prior run
57
+ - Bugfix: fixes bug where I thought I was using something cool like figaro
58
+ but was not
59
+ - Bugfix: fixes bug where configuration wasn't loaded before running
60
+ --install-public-templates
61
+ - Bugfix: fixes bug where require pry was left in
62
+
63
+ ** 0.0.7 **
64
+
65
+ - Feature: Ability to load templates from github via --install-public-templates
66
+ - Feature: Make each user defined gem have a subfolder that is the exact
67
+ project structure, so the readme for the gem can exist without fear of it
68
+ being copied into new projects
69
+ - Feature: Gem's display names are based on what's specified in their
70
+ respective root .bundlegem
71
+ - Feature: Allow better CLI parsing so -t t_name can be the first couple
72
+ arguments or at the end
73
+ - Bugfix: cli_gem and c_ext_gem now show up in the list
74
+ - Bugfix: cli_gem and c_ext_gem had typos fixed
75
+
76
+ ** 0.0.6 **
77
+ - Feature: List now indicates default template
78
+ - CORE: Created TemplateManager for working with templates
79
+ - BUG: Accidentally tracked in a test gem project and fixed tests to not
80
+ change directory into a test area for creating new gems.
81
+ - BUG: newgem template didn't have a dot in .gitignore.tt
82
+
83
+ ** 0.0.5 **
84
+ - Bug in 0.0.3 that broke building template gems fixed
85
+ * Template Directories part of code was being skipped for built in templates, but not all of it
86
+ - Bug where sub directories were not being explicitly created
87
+ - Added integration test just to make sure the built-in templates can be generated without problems
88
+ - Cleaned up internal API and how the binary works
89
+
90
+ ** 0.0.4 **
91
+ - Tell the user what files are being created
92
+ - Created config['git_repo_url'] variable to be used in templates
93
+
94
+ ** 0.0.3 **
95
+ - CMD: --list to list templates (with descriptions)
96
+ - Raise error when project name already exists, do not overwrite!
97
+ - Raises error if none of the files in the template directory end in .tt
98
+ - Create even empty folders
99
+
100
+ ** 0.0.2 **
101
+ - Added default gem template 'service'
102
+ - Better syntax of bundlegem gem_name -t template_name
103
+ - CMD: --help to display a help message
104
+
105
+ ** 0.0.1 **
106
+ - Very basic prototype that allows you to specify templates in
107
+ ~/.bundlegem/templates