@oamm/textor 1.0.2 → 1.0.4

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.
package/README.md CHANGED
@@ -89,6 +89,42 @@ Configure this in .textor/config.json:
89
89
  }
90
90
  ```
91
91
 
92
+ ## File Naming Patterns
93
+
94
+ You can override generated file names for feature and component sub-files (api, services, hooks, tests, etc.) using simple patterns. Patterns support `{{componentName}}`, `{{hookName}}`, `{{hookExtension}}`, `{{testExtension}}`, `{{componentExtension}}`, and `{{featureExtension}}`.
95
+
96
+ Example:
97
+ ```json
98
+ {
99
+ "filePatterns": {
100
+ "features": {
101
+ "api": "{{componentName}}.route.ts"
102
+ },
103
+ "components": {
104
+ "api": "{{componentName}}.route.ts"
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ More examples:
111
+ ```json
112
+ {
113
+ "filePatterns": {
114
+ "features": {
115
+ "hook": "use{{componentName}}.ts",
116
+ "test": "{{componentName}}.spec{{testExtension}}",
117
+ "readme": "{{componentName}}.md"
118
+ },
119
+ "components": {
120
+ "api": "{{componentName}}.route{{testExtension}}",
121
+ "services": "{{componentName}}.service{{hookExtension}}",
122
+ "stories": "{{componentName}}.stories.tsx"
123
+ }
124
+ }
125
+ }
126
+ ```
127
+
92
128
  ## 🛡️ Safety & File Tracking
93
129
 
94
130
  Textor uses a multi-layered safety approach to protect your codebase.
@@ -223,6 +259,26 @@ pnpm textor adopt /users
223
259
  pnpm textor adopt --all
224
260
  ```
225
261
 
262
+ ### upgrade-config
263
+ Upgrade `.textor/config.json` to the latest schema version without recreating it.
264
+
265
+ ```bash
266
+ pnpm textor upgrade-config
267
+ ```
268
+
269
+ **Options:**
270
+ - `--dry-run`: Print the upgraded config without writing it.
271
+
272
+ ### normalize-state
273
+ Normalize `.textor/state.json` to use project-relative paths (helpful when moving between machines).
274
+
275
+ ```bash
276
+ pnpm textor normalize-state
277
+ ```
278
+
279
+ **Options:**
280
+ - `--dry-run`: Print the normalized state without writing it.
281
+
226
282
  ## 🏗️ Technical Architecture
227
283
 
228
284
  Textor is designed with enterprise-grade robustness, moving beyond simple scaffolding to provide a reliable refactoring engine.
@@ -269,9 +325,11 @@ When moving or renaming sections, Textor performs scoped AST-like updates:
269
325
  ## ⚙️ Configuration
270
326
 
271
327
  The .textor/config.json file allows full control over the tool's behavior.
328
+ `configVersion` tracks schema changes and is updated by `textor upgrade-config`.
272
329
 
273
330
  ```json
274
331
  {
332
+ "configVersion": 2,
275
333
  "paths": {
276
334
  "pages": "src/pages",
277
335
  "features": "src/features",
@@ -402,16 +460,79 @@ The .textor/config.json file allows full control over the tool's behavior.
402
460
 
403
461
  ## 📝 Template Overrides
404
462
 
405
- Customize generated code by placing templates in .textor/templates/. Supported templates:
406
- - route.astro
407
- - feature.astro
408
- - component.astro
409
- - hook.ts
410
- - context.tsx
411
- - test.tsx
412
- - index.ts
463
+ You can customize the code generated by Textor by providing your own templates. Textor looks for override files in the `.textor/templates/` directory at your project root.
464
+
465
+ ### How to use Template Overrides
466
+
467
+ 1. Create the `.textor/templates/` directory if it doesn't exist.
468
+ 2. Create a file named according to the table below (e.g., `feature.astro` or `component.tsx`).
469
+ 3. Use `{{variable}}` placeholders in your template. Textor will automatically replace them when generating files.
470
+
471
+ ### Supported Templates
472
+
473
+ | Template Name | File to create in `.textor/templates/` | Available Variables |
474
+ | :--- | :--- | :--- |
475
+ | **Route** | `route.astro` | `{{layoutName}}`, `{{layoutImportPath}}`, `{{featureImportPath}}`, `{{featureComponentName}}` |
476
+ | **Feature** | `feature.astro` or `feature.tsx` | `{{componentName}}`, `{{scriptImportPath}}` |
477
+ | **Component** | `component.astro` or `component.tsx` | `{{componentName}}` |
478
+ | **Hook** | `hook.ts` | `{{componentName}}`, `{{hookName}}` |
479
+ | **Context** | `context.tsx` | `{{componentName}}` |
480
+ | **Test** | `test.tsx` | `{{componentName}}`, `{{componentPath}}` |
481
+ | **Index** | `index.ts` | `{{componentName}}`, `{{componentExtension}}` |
482
+ | **Types** | `types.ts` | `{{componentName}}` |
483
+ | **API** | `api.ts` | `{{componentName}}` |
484
+ | **Endpoint** | `endpoint.ts` | `{{componentName}}` |
485
+ | **Service** | `service.ts` | `{{componentName}}` |
486
+ | **Schema** | `schema.ts` | `{{componentName}}` |
487
+ | **Readme** | `readme.md` | `{{componentName}}` |
488
+ | **Stories** | `stories.tsx` | `{{componentName}}`, `{{componentPath}}` |
489
+ | **Config** | `config.ts` | `{{componentName}}` |
490
+ | **Constants** | `constants.ts` | `{{componentName}}` |
491
+ | **Scripts Index**| `scripts-index.ts` | (none) |
492
+
493
+ > **Note:** For `feature` and `component` templates, use the extension that matches your configured framework (`.astro` for Astro, `.tsx` for React). Other templates have fixed extensions for the override file, regardless of your project's configuration.
494
+
495
+ ### Variables Description
496
+
497
+ - `{{componentName}}`: The PascalCase name of the feature or component (e.g., `UserCatalog`).
498
+ - `{{hookName}}`: The camelCase name of the generated hook (e.g., `useUserCatalog`).
499
+ - `{{componentPath}}`: Relative path to the component file (useful for imports in tests or stories).
500
+ - `{{featureComponentName}}`: The name of the feature component as imported in a route.
501
+ - `{{featureImportPath}}`: The import path for the feature component.
502
+ - `{{layoutName}}`: The name of the layout component being used.
503
+ - `{{layoutImportPath}}`: The import path for the layout component.
504
+ - `{{scriptImportPath}}`: Relative path to the client-side script entry point.
505
+ - `{{componentExtension}}`: The file extension of the component (e.g., `.astro` or `.tsx`).
506
+
507
+ ### Example: Custom Feature Template (`.textor/templates/feature.astro`)
508
+
509
+ ```astro
510
+ ---
511
+ /**
512
+ * @generated by Textor
513
+ * Feature: {{componentName}}
514
+ */
515
+
516
+ interface Props {
517
+ title?: string;
518
+ }
519
+
520
+ const { title = "{{componentName}}" } = Astro.props;
521
+ ---
413
522
 
414
- Templates use {{variable}} syntax for placeholder replacement.
523
+ <section class="feature-{{componentName}}">
524
+ <h2>{title}</h2>
525
+ <slot />
526
+ </section>
527
+
528
+ <script src="{{scriptImportPath}}"></script>
529
+
530
+ <style>
531
+ .feature-{{componentName}} {
532
+ padding: 2rem;
533
+ }
534
+ </style>
535
+ ```
415
536
 
416
537
  ---
417
538