dirfy 0.3.1 → 0.3.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2280485e374e77646217758bb7ff581745d1027c716de33bbf180532c37099d5
4
- data.tar.gz: 9ce1d4d53bb3bc4f1c6d4b39bbf0d9dca6a73f0c50ecd2a28a089af2301076fd
3
+ metadata.gz: eff3a8ed004db0f78ce8f4e0660648cf18f4983bb064a1e41e0d74fd3db8fdcb
4
+ data.tar.gz: a378b3fdfbdd8c34170920a769307938fe4495bc9222996140e39d5a68fddc6b
5
5
  SHA512:
6
- metadata.gz: 57c73e9a491dd9ad6ca56cceb0e7d16bdcfc65524b93e331f4008eebea5d77a5d27e9775553cf354adeaa809e75c1a174133a5a4542ccc18a15a139b8af53af5
7
- data.tar.gz: ef290b90b405d6151738c97bede4e2778c437394865ed42830849e3fb0d5b4ebbff7f287bcbeaf7ce198b0b05a95c9ec03e94a0b3dcac015a792d5629530c8c4
6
+ metadata.gz: 24b201dbd606f722eab03643b190b5edc1cbf97960f5ee1dd1b476a4502a0a11934f381a7d0f80857ec1ece4e5f7d247bb4c7f0d2ad50d96bbe56190fe0b04f3
7
+ data.tar.gz: d34793f417f3310bbe515f1b0c3fe03c137f2c6263ea6cc017dec09fb1949e8c624699ad9d7658561b3c49c656b398d2ee47d274a685f058bb4e8b087c79540b
data/README.md CHANGED
@@ -6,7 +6,18 @@
6
6
  [![Ruby ≥2.7](https://img.shields.io/badge/ruby-%3E%3D2.7-blue.svg)](https://www.ruby-lang.org/)
7
7
  [![Issues](https://img.shields.io/github/issues/ahmedmelhady7/dirfy.svg)](https://github.com/ahmedmelhady7/dirfy/issues)
8
8
 
9
- > **Instantly scaffold directory & file structures from any ASCII/Unicode tree diagram** 🚀
9
+ > **Instantly scaffold directory & file structures from any ASCII/Unicode "tree" diagram** 🚀
10
+
11
+ ## 📚 Table of Contents
12
+
13
+ - [📋 Problem Statement](#-problem-statement)
14
+ - [✨ Features](#-features)
15
+ - [🚀 Installation](#-installation)
16
+ - [💡 Usage](#-usage)
17
+ - [🛠️ Examples](#️-examples)
18
+ - [🤝 Contributing](#-contributing)
19
+ - [🚀 Release Process](#-release-process)
20
+ - [📝 License](#-license)
10
21
 
11
22
  ---
12
23
 
@@ -108,6 +119,19 @@ DRY-RUN File: my_app/README.md
108
119
 
109
120
  Remove `-d` to actually scaffold.
110
121
 
122
+ ### 📁 Sample Files
123
+
124
+ To test Dirfy quickly without creating your own tree files, check out the [examples/](./examples/) directory. It contains several sample tree files you can use:
125
+
126
+ - `examples/simple.tree` — A basic Ruby project structure
127
+ - `examples/web_project.tree` — A front-end web project layout
128
+ - `examples/complex.tree` — Deeply nested directories with mixed file types
129
+ - `examples/unicode.tree` — Non-ASCII filenames and Unicode handling tests
130
+
131
+ ```bash
132
+ dirfy -d examples/web_project.tree
133
+ ```
134
+
111
135
  ---
112
136
 
113
137
  ## 🤝 Contributing
@@ -129,76 +153,89 @@ Happy scaffolding! 🚀
129
153
 
130
154
  ---
131
155
 
132
- ## Release Process
156
+ ## 🚀 Release Process
133
157
 
134
- This section documents the release process for maintainers.
158
+ This project uses a **semi-automated release process** that balances automation with security. GitHub Actions handles building and testing, while gem publishing is done manually to support 2FA authentication.
135
159
 
136
160
  ### Prerequisites
137
161
 
138
162
  - Push access to the repository
139
163
  - RubyGems account with push access to the `dirfy` gem
140
- - 2FA enabled on RubyGems account
164
+ - 2FA enabled on RubyGems account (recommended for security)
141
165
 
142
- ### Release Steps
166
+ ### Semi-Automated Release Process
143
167
 
144
- 1. **Run tests and ensure clean state**
145
- ```bash
146
- bundle exec rake
147
- git status # should be clean
148
- ```
168
+ **What's automated:**
169
+ - ✅ Gem building when you push tags
170
+ - Running tests before release
171
+ - GitHub release creation (optional)
172
+
173
+ **What requires manual action:**
174
+ - 🔐 Gem publishing to RubyGems (due to 2FA requirements)
149
175
 
150
- 2. **Update version**
176
+ ### Release Steps
177
+
178
+ 1. **Update version and run tests**
151
179
  ```bash
152
- # Edit lib/dirfy/version.rb
180
+ # Edit lib/dirfy/version.rb to bump version
153
181
  vim lib/dirfy/version.rb
182
+ bundle install # updates Gemfile.lock
183
+ bundle exec rake # run tests
154
184
  ```
155
185
 
156
- 3. **Commit version bump**
186
+ 2. **Commit and tag**
157
187
  ```bash
158
188
  git add lib/dirfy/version.rb Gemfile.lock
159
189
  git commit -m "chore: bump version to vX.Y.Z"
160
- ```
161
-
162
- 4. **Create and push tag**
163
- ```bash
164
190
  git tag vX.Y.Z
165
- git push origin main
166
- git push origin vX.Y.Z
191
+ git push origin main --follow-tags
167
192
  ```
168
193
 
169
- 5. **Build and publish gem**
194
+ 3. **Manual gem publishing (with 2FA)**
170
195
  ```bash
171
196
  rake build
172
197
  gem push pkg/dirfy-X.Y.Z.gem
173
- # Follow 2FA authentication flow
198
+ # Complete 2FA authentication in browser
174
199
  ```
175
200
 
176
- 6. **Create GitHub release**
201
+ 4. **Optional: Create GitHub release**
177
202
  ```bash
178
203
  gh release create vX.Y.Z pkg/dirfy-X.Y.Z.gem \
179
204
  --title "vX.Y.Z" \
180
205
  --notes "Release notes here"
181
206
  ```
182
207
 
183
- ### Automated Release (Helper Script)
208
+ ### Using the Release Helper Script
184
209
 
185
- Use the provided release script for semi-automated releases:
210
+ For even easier releases, use the provided script:
186
211
 
187
212
  ```bash
188
- ./scripts/release.sh patch # for patch version (0.0.X)
189
- ./scripts/release.sh minor # for minor version (0.X.0)
190
- ./scripts/release.sh major # for major version (X.0.0)
213
+ ./scripts/release.sh X.Y.Z
191
214
  ```
192
215
 
216
+ This script will:
217
+ - Update the version in `lib/dirfy/version.rb`
218
+ - Run tests to ensure everything works
219
+ - Build the gem locally
220
+ - Commit changes and create/push the tag
221
+ - Prompt you to manually publish with `gem push` (for 2FA)
222
+
223
+ ### Why Semi-Automated?
224
+
225
+ - **Security**: Maintains 2FA protection on your RubyGems account
226
+ - **Reliability**: Manual gem push ensures you can handle 2FA interactively
227
+ - **Automation**: CI still handles building, testing, and GitHub releases
228
+ - **Simplicity**: No need to manage CI-specific RubyGems accounts or tokens
229
+
193
230
  ### Troubleshooting
194
231
 
195
- - **2FA Authentication**: RubyGems requires 2FA. Use WebAuthn or `--otp` flag
196
- - **Workflow scope**: GitHub token needs `workflow` scope to modify Actions
197
- - **Permission denied**: Ensure you have push access to both repo and RubyGems
232
+ - **2FA Authentication**: Follow the WebAuthn flow in your browser or use `--otp` flag
233
+ - **Build failures**: CI will automatically build when you push tags - check Actions tab for issues
234
+ - **Permission denied**: Ensure you have push access to both the repository and RubyGems gem
198
235
 
199
236
  ---
200
237
 
201
- ## �📝 License
238
+ ## 📝 License
202
239
 
203
240
  MIT © [Ahmed Elhady](https://github.com/ahmedmelhady7)
204
241
 
@@ -206,45 +243,4 @@ MIT © [Ahmed Elhady](https://github.com/ahmedmelhady7)
206
243
 
207
244
  > Built with ❤️ to make AI-generated project scaffolding a breeze.
208
245
 
209
- ---
210
-
211
- ## Release steps
212
-
213
- This project supports both local and GitHub Actions-based releases. The workflow `/.github/workflows/release.yml` will publish a built gem when a `vX.Y.Z` tag is pushed, but the runner needs a valid `RUBYGEMS_API_KEY` secret and the repository maintainer must ensure the CI token can run workflow jobs that modify releases.
214
-
215
- Local release (recommended when you need to provide 2FA interactively):
216
-
217
- 1. Bump the version in `lib/dirfy/version.rb` (e.g. `0.3.0`).
218
- 2. Build the gem locally:
219
-
220
- ```bash
221
- bundle install
222
- bundle exec rake build
223
- ```
224
-
225
- 3. Create a git tag and push it (this will trigger CI if configured):
226
-
227
- ```bash
228
- git add -A
229
- git commit -m "Release vX.Y.Z"
230
- git tag vX.Y.Z
231
- git push origin main --follow-tags
232
- ```
233
-
234
- 4. Publish the gem to RubyGems interactively (you may need to complete 2FA):
235
-
236
- ```bash
237
- gem push pkg/dirfy-X.Y.Z.gem
238
- ```
239
-
240
- CI-based release (recommended for automated releases):
241
-
242
- 1. Ensure the repository has the secret `RUBYGEMS_API_KEY` configured in GitHub Settings → Secrets.
243
- 2. Ensure the repository's token has appropriate permissions to run workflow jobs that create or update releases (the token needs `workflow` scope to update workflows).
244
- 3. Push a tag `vX.Y.Z` to the repo. The `release.yml` workflow will build and push the gem.
245
-
246
- Notes and troubleshooting
247
246
 
248
- - If you see an error like `Invalid credentials (401)` during `gem push` in CI, double-check that `RUBYGEMS_API_KEY` is correctly set and that the CI runner writes it to `~/.gem/credentials` before pushing.
249
- - If GitHub rejects pushes that modify workflow files, ensure the token used has `workflow` scope or make the workflow change via the GitHub web UI.
250
- - For local gem publishing, if 2FA is enabled you will be prompted to authenticate in your browser or provide an OTP.
data/lib/dirfy/cli.rb CHANGED
@@ -12,7 +12,8 @@ module Dirfy
12
12
  dry_run: false,
13
13
  verbose: false,
14
14
  indent: 4,
15
- prefix: ""
15
+ prefix: "",
16
+ validate: false
16
17
  }
17
18
 
18
19
  parser = OptionParser.new do |opts|
@@ -26,6 +27,10 @@ module Dirfy
26
27
  options[:verbose] = true
27
28
  end
28
29
 
30
+ opts.on("--validate", "Check tree syntax without creating files") do
31
+ options[:validate] = true
32
+ end
33
+
29
34
  opts.on("-iN", "--indent=N", Integer, "Spaces per level (default 4)") do |n|
30
35
  options[:indent] = n
31
36
  end
@@ -60,6 +65,12 @@ module Dirfy
60
65
  items = Parser.new(indent: options[:indent]).parse(lines)
61
66
  items.map! { |p| options[:prefix] + p }
62
67
 
68
+ # Validation mode: just check syntax and exit
69
+ if options[:validate]
70
+ puts "✅ Tree syntax is valid (#{items.size} items detected)"
71
+ exit(0)
72
+ end
73
+
63
74
  puts "🔍 Detected #{items.size} items to create."
64
75
  unless options[:dry_run]
65
76
  print "Proceed? (y/N) "
data/lib/dirfy/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Dirfy
3
- VERSION = "0.3.1"
4
- end
3
+ VERSION = "0.3.2"
4
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dirfy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Your Name