@khoaha/spek-cli 1.0.3

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.
@@ -0,0 +1,135 @@
1
+ # 🚀 Quick Publish Reference
2
+
3
+ ## Pre-Publish Checklist
4
+
5
+ ```bash
6
+ # 1. Verify token is configured
7
+ cat .env | grep NPM_ACCESS_TOKEN
8
+
9
+ # 2. Clean build
10
+ npm run build
11
+
12
+ # 3. Test locally
13
+ node dist/index.js --help
14
+ node dist/index.js --version
15
+
16
+ # 4. Dry run
17
+ npm publish --dry-run
18
+ ```
19
+
20
+ ## Publish Commands
21
+
22
+ ### Linux/macOS
23
+ ```bash
24
+ # Make executable (first time only)
25
+ chmod +x scripts/publish.sh
26
+
27
+ # Publish (choose one)
28
+ ./scripts/publish.sh # Patch: 1.0.0 → 1.0.1
29
+ ./scripts/publish.sh minor # Minor: 1.0.0 → 1.1.0
30
+ ./scripts/publish.sh major # Major: 1.0.0 → 2.0.0
31
+ ./scripts/publish.sh 2.5.3 # Specific version
32
+ ```
33
+
34
+ ### Windows (PowerShell)
35
+ ```powershell
36
+ # Publish (choose one)
37
+ .\scripts\publish.ps1 # Patch: 1.0.0 → 1.0.1
38
+ .\scripts\publish.ps1 minor # Minor: 1.0.0 → 1.1.0
39
+ .\scripts\publish.ps1 major # Major: 1.0.0 → 2.0.0
40
+ .\scripts\publish.ps1 2.5.3 # Specific version
41
+ ```
42
+
43
+ ### Or Use npm Scripts
44
+ ```bash
45
+ npm run publish:patch # 1.0.0 → 1.0.1
46
+ npm run publish:minor # 1.0.0 → 1.1.0
47
+ npm run publish:major # 1.0.0 → 2.0.0
48
+ ```
49
+
50
+ ## Post-Publish
51
+
52
+ ```bash
53
+ # 1. Verify on npm
54
+ https://www.npmjs.com/package/spek-cli
55
+
56
+ # 2. Test installation
57
+ npx spek-cli@latest --version
58
+
59
+ # 3. Push git tag
60
+ git push origin v1.0.0
61
+
62
+ # 4. Test full workflow
63
+ npx spek-cli -d <test-file-id>
64
+ ```
65
+
66
+ ## Quick Test
67
+
68
+ ```bash
69
+ # Test without publishing
70
+ npm link
71
+ spek-cli --help
72
+ spek-cli --version
73
+ npm unlink -g spek-cli
74
+ ```
75
+
76
+ ## Environment
77
+
78
+ Required in `.env`:
79
+ ```bash
80
+ NPM_ACCESS_TOKEN=npm_xxxxxxxxxxxxxxxxxxxxxx
81
+ ```
82
+
83
+ ## What the Script Does
84
+
85
+ 1. ✓ Checks git status
86
+ 2. ✓ Clean installs dependencies
87
+ 3. ✓ Builds TypeScript
88
+ 4. ✓ Verifies build output
89
+ 5. ✓ Bumps version
90
+ 6. ✓ Creates .npmrc with token
91
+ 7. ✓ Runs dry-run
92
+ 8. ✓ Asks for confirmation
93
+ 9. ✓ Publishes to npm
94
+ 10. ✓ Cleans up .npmrc
95
+ 11. ✓ Creates git tag
96
+ 12. ✓ Shows success message
97
+
98
+ ## Troubleshooting
99
+
100
+ ### "NPM_ACCESS_TOKEN not found"
101
+ ```bash
102
+ # Check .env file exists
103
+ ls -la .env
104
+
105
+ # Create if missing
106
+ echo "NPM_ACCESS_TOKEN=your-token-here" > .env
107
+ ```
108
+
109
+ ### "401 Unauthorized"
110
+ - Generate new token at https://www.npmjs.com/settings/~/tokens
111
+ - Update `.env` with new token
112
+
113
+ ### "403 Forbidden"
114
+ - Package name already exists
115
+ - Or insufficient token permissions
116
+
117
+ ### Build fails
118
+ ```bash
119
+ rm -rf dist node_modules
120
+ npm install
121
+ npm run build
122
+ ```
123
+
124
+ ## Quick Links
125
+
126
+ - **Publishing Guide**: `docs/PUBLISHING.md`
127
+ - **npm Registry**: https://www.npmjs.com/package/spek-cli
128
+ - **Token Settings**: https://www.npmjs.com/settings/~/tokens
129
+ - **Rename Summary**: `RENAME_COMPLETE.md`
130
+
131
+ ---
132
+
133
+ **Current Version**: 1.0.0 (unpublished)
134
+ **Ready**: ✅ Yes - All files updated and tested
135
+ **Next**: Run publish script
@@ -0,0 +1,186 @@
1
+ # SVG to Vector Drawable Conversion Feature
2
+
3
+ ## Overview
4
+ Added SVG to Android Vector Drawable XML conversion feature to the `spek-cli` CLI tool using `vd-tool` library.
5
+
6
+ ## Command Usage
7
+
8
+ ### Basic Conversion
9
+ ```bash
10
+ npx spek-cli svg-to-vd -i <input> -o <output>
11
+ ```
12
+
13
+ ### With Tint Color
14
+ ```bash
15
+ npx spek-cli svg-to-vd -i icon.svg -o icon.xml --tint "#FF5722"
16
+ ```
17
+
18
+ ### Examples
19
+ ```bash
20
+ # Convert SVG file
21
+ npx spek-cli svg-to-vd -i ./icons/heart.svg -o ./drawables/heart.xml
22
+
23
+ # With tint color
24
+ npx spek-cli svg-to-vd -i icon.svg -o icon.xml --tint "#FF5722"
25
+
26
+ # Using raw SVG content
27
+ npx spek-cli svg-to-vd -i "<svg>...</svg>" -o output.xml
28
+
29
+ # Output to nested directory (auto-creates directories)
30
+ npx spek-cli svg-to-vd -i icon.svg -o res/drawable/icon.xml
31
+ ```
32
+
33
+ ## Options
34
+
35
+ ### Required
36
+ - `-i, --input <input>` - SVG file path or raw SVG content (auto-detected)
37
+ - `-o, --output <output>` - Output Vector Drawable XML file path
38
+
39
+ ### Optional
40
+ - `--tint <color>` - Tint color to apply (e.g., "#FF5722")
41
+ - `-h, --help` - Show help message
42
+
43
+ ## Features
44
+
45
+ ### Auto-detection
46
+ The tool automatically detects whether the input is:
47
+ 1. **SVG content** - If starts with `<svg`
48
+ 2. **File path** - If file exists at the path
49
+ 3. **Fallback** - Treats as SVG content
50
+
51
+ ### Error Handling
52
+ Comprehensive error messages with suggestions:
53
+ - Missing required parameters
54
+ - Invalid SVG format
55
+ - File read errors
56
+ - Conversion failures
57
+ - Write permission issues
58
+
59
+ ### Smart Output
60
+ - **Directory creation** - Automatically creates output directories if they don't exist
61
+ - **Overwrite** - Silently overwrites existing files
62
+ - **Validation** - Validates SVG content before conversion
63
+ - **Progress feedback** - Shows step-by-step progress with emojis
64
+
65
+ ## Architecture
66
+
67
+ ### File Structure
68
+ ```
69
+ cli-tool/src/
70
+ ├── commands/
71
+ │ └── svg-to-vd/
72
+ │ └── handler.ts # Command handler with error handling
73
+ ├── utils/
74
+ │ ├── svg-converter.ts # Core conversion logic using vd-tool
75
+ │ └── file-utils.ts # File I/O utilities
76
+ ├── types/
77
+ │ └── index.ts # TypeScript interfaces
78
+ └── index.ts # Main CLI entry point
79
+ ```
80
+
81
+ ### Key Components
82
+
83
+ #### 1. SVG Converter (`utils/svg-converter.ts`)
84
+ - `convertSvgToVectorDrawable()` - Main conversion function
85
+ - `validateSvgContent()` - SVG format validation
86
+ - Uses temporary files for vd-tool processing
87
+ - Applies customizations (tint)
88
+ - Automatic cleanup
89
+
90
+ #### 2. File Utilities (`utils/file-utils.ts`)
91
+ - `detectInputType()` - Auto-detect file vs content
92
+ - `fileExists()` - Check file existence
93
+ - `readFileContent()` - Read SVG file
94
+ - `writeFileContent()` - Write XML with directory creation
95
+
96
+ #### 3. Command Handler (`commands/svg-to-vd/handler.ts`)
97
+ - Validates required options
98
+ - Orchestrates conversion flow
99
+ - Provides user-friendly error messages
100
+ - Shows progress feedback
101
+
102
+ #### 4. Type Definitions (`types/index.ts`)
103
+ - `SvgToVdOptions` - Command options
104
+ - `SvgConversionResult` - Conversion result
105
+ - Extended `CliOptions` for command routing
106
+
107
+ ## Implementation Details
108
+
109
+ ### Technology Stack
110
+ - **TypeScript 5.x** - Type-safe implementation
111
+ - **vd-tool 4.0.2** - SVG to Vector Drawable conversion
112
+ - **Node.js 18+** - ES Modules support
113
+ - **chalk 5.x** - Colored terminal output
114
+
115
+ ### Detection Priority
116
+ ```typescript
117
+ 1. Check if input starts with '<svg' → Treat as SVG content
118
+ 2. Check if file exists at path → Read file
119
+ 3. Fallback → Treat as SVG content
120
+ ```
121
+
122
+ ### Error Messages
123
+ All errors include:
124
+ - Clear description of the problem
125
+ - Helpful tip or suggestion
126
+ - Example usage when relevant
127
+
128
+ ### Conversion Process
129
+ ```
130
+ 1. Parse command arguments
131
+ 2. Auto-detect input type (file vs content)
132
+ 3. Read SVG content
133
+ 4. Validate SVG format
134
+ 5. Convert using vd-tool
135
+ 6. Apply customizations (tint if specified)
136
+ 7. Create output directory if needed
137
+ 8. Write Vector Drawable XML
138
+ 9. Show success message
139
+ ```
140
+
141
+ ## Testing Results
142
+
143
+ ### ✅ Tested Scenarios
144
+ 1. **File conversion** - Successfully converts SVG files
145
+ 2. **Tint application** - Correctly applies tint color
146
+ 3. **Nested directories** - Auto-creates output directories
147
+ 4. **Missing output** - Shows error with suggestion
148
+ 5. **Invalid input** - Validates and shows helpful error
149
+ 6. **Help text** - Both main and command-specific help work
150
+
151
+ ### Sample Output
152
+ ```xml
153
+ <vector xmlns:android="http://schemas.android.com/apk/res/android"
154
+ android:width="24dp"
155
+ android:height="24dp"
156
+ android:viewportWidth="24"
157
+ android:viewportHeight="24">
158
+ <path
159
+ android:pathData="M20.84,4.61a5.5,5.5..."
160
+ android:strokeLineJoin="round"
161
+ android:strokeWidth="2"
162
+ android:fillColor="#00000000"
163
+ android:strokeColor="currentColor"
164
+ android:strokeLineCap="round"/>
165
+ </vector>
166
+ ```
167
+
168
+ ## Dependencies Added
169
+ ```json
170
+ {
171
+ "vd-tool": "^4.0.2"
172
+ }
173
+ ```
174
+
175
+ ## Notes
176
+ - Complex SVG features may not be fully supported by vd-tool
177
+ - Output files are overwritten without confirmation
178
+ - Temporary files are automatically cleaned up after conversion
179
+ - Works on Windows, macOS, and Linux
180
+
181
+ ## Future Enhancements (Potential)
182
+ - Batch conversion support (multiple files)
183
+ - Custom naming patterns
184
+ - SVG optimization before conversion
185
+ - Preview mode (show output without writing)
186
+ - Configuration file support