@qr-render/qrcode-cli 0.0.3 → 0.1.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.
package/README.md CHANGED
@@ -1 +1,248 @@
1
1
  # QRCodeCLI
2
+
3
+ A professional, high-performance QR Code generation tool for the terminal. Generate QR codes directly in your CLI with full customization support for colors, size, and error correction levels.
4
+
5
+ ## Features
6
+
7
+ ✨ **Fast QR Code Generation** - Efficiently generates QR codes with automatic version detection
8
+ 🎨 **Terminal Rendering** - Beautiful ANSI-colored output directly in your terminal
9
+ ⚙️ **Customizable** - Full control over size, colors, quiet zones, and error correction levels
10
+ 🛡️ **Error Correction** - Multiple error correction levels (L, M, Q, H) for reliable scanning
11
+ 📦 **TypeScript** - Built with TypeScript for type safety
12
+ 🧪 **Well Tested** - Comprehensive test coverage with Vitest
13
+
14
+ ## Installation
15
+
16
+ ### Using npm
17
+ ```bash
18
+ npm install -g @qr-render/qrcode-cli
19
+ ```
20
+
21
+ ### Using pnpm
22
+ ```bash
23
+ pnpm add -g @qr-render/qrcode-cli
24
+ ```
25
+
26
+ ### Using yarn
27
+ ```bash
28
+ yarn global add @qr-render/qrcode-cli
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ Generate a simple QR code:
34
+ ```bash
35
+ @qr-render/qrcode-cli "https://example.com"
36
+ ```
37
+
38
+ This will display a QR code in your terminal that you can scan with any QR code reader.
39
+
40
+ ## Usage
41
+
42
+ ### Basic Command Structure
43
+ ```bash
44
+ @qr-render/qrcode-cli <text> [options]
45
+ ```
46
+
47
+ ### Arguments
48
+
49
+ | Argument | Description | Required |
50
+ |----------|-------------|----------|
51
+ | `<text>` | The text or URL to encode in the QR code | Yes |
52
+
53
+ ### Options
54
+
55
+ #### `--size <number>` | `-s <number>`
56
+ Scale factor for the QR code modules (pixels). Default: `1`
57
+
58
+ ```bash
59
+ @qr-render/qrcode-cli "Hello" --size 2
60
+ ```
61
+
62
+ #### `--quiet-zone <number>` | `-q <number>`
63
+ The quiet zone (padding) around the QR code in modules. Default: `4`
64
+
65
+ The quiet zone is the white space around the QR code that helps scanners read it properly.
66
+
67
+ ```bash
68
+ @qr-render/qrcode-cli "Hello" --quiet-zone 6
69
+ ```
70
+
71
+ #### `--level <type>` | `-l <type>`
72
+ Error correction level. Default: `M`
73
+
74
+ Controls how much of the QR code can be damaged before it becomes unreadable:
75
+
76
+ | Level | Recovery Capacity | Use Case |
77
+ |-------|-------------------|----------|
78
+ | `L` | ~7% | Basic applications, clean environments |
79
+ | `M` | ~15% | Standard use, recommended |
80
+ | `Q` | ~25% | Moderate damage risk |
81
+ | `H` | ~30% | Outdoor use, high damage risk |
82
+
83
+ ```bash
84
+ @qr-render/qrcode-cli "Important Data" --level H
85
+ ```
86
+
87
+ #### `--dark <color>`
88
+ ANSI color code for dark modules (the black squares). Default: `\x1b[40m \x1b[0m` (black background)
89
+
90
+ Input an ANSI escape code to customize the dark color.
91
+
92
+ ```bash
93
+ @qr-render/qrcode-cli "Hello" --dark "\x1b[44m \x1b[0m" # Blue background
94
+ ```
95
+
96
+ #### `--light <color>`
97
+ ANSI color code for light modules (the white squares). Default: `\x1b[47m \x1b[0m` (white background)
98
+
99
+ Input an ANSI escape code to customize the light color.
100
+
101
+ ```bash
102
+ @qr-render/qrcode-cli "Hello" --light "\x1b[46m \x1b[0m" # Cyan background
103
+ ```
104
+
105
+ ## Examples
106
+
107
+ ### Simple URL Encoding
108
+ ```bash
109
+ @qr-render/qrcode-cli "https://github.com/OctaEDLP00/QrCodeCLI"
110
+ ```
111
+
112
+ ### Large QR Code with High Error Correction
113
+ ```bash
114
+ @qr-render/qrcode-cli "Payment Code: ABC123XYZ" --size 3 --level H --quiet-zone 5
115
+ ```
116
+
117
+ ### Minimal QR Code
118
+ ```bash
119
+ @qr-render/qrcode-cli "QR" --size 1 --quiet-zone 2 --level L
120
+ ```
121
+
122
+ ### Custom Colors (Blue and Green)
123
+ ```bash
124
+ @qr-render/qrcode-cli "Colored QR" --dark "\x1b[44m \x1b[0m" --light "\x1b[42m \x1b[0m"
125
+ ```
126
+
127
+ ### Generate QR Code for WiFi Connection
128
+ ```bash
129
+ @qr-render/qrcode-cli "WiFi-Network-Name" --level H --size 2
130
+ ```
131
+
132
+ ### Email Address Encoding
133
+ ```bash
134
+ @qr-render/qrcode-cli "mailto:user@example.com?subject=Hello" --level M
135
+ ```
136
+
137
+ ## Error Correction Levels Explained
138
+
139
+ QR codes use error correction to remain scannable even if partially damaged. Higher levels add more redundancy:
140
+
141
+ - **Level L (Low)**: Recommended for clean, protected environments. Smallest QR code size.
142
+ - **Level M (Medium)**: Default and recommended for most use cases. Good balance between size and reliability.
143
+ - **Level Q (Quartile)**: Use when moderate damage is expected (printing, outdoor use).
144
+ - **Level H (High)**: Use for outdoor environments or when maximum durability is needed. Larger QR code size.
145
+
146
+ ## How It Works
147
+
148
+ 1. **Input Parsing** - The CLI parses your input text and options
149
+ 2. **Optimal Version Selection** - Automatically determines the minimum QR code version (1-40) needed to encode your data without overflow
150
+ 3. **QR Code Generation** - Creates a QR code model with the selected version and error correction level
151
+ 4. **Terminal Rendering** - Renders the QR code using ANSI colors and Unicode blocks for beautiful terminal output
152
+
153
+ ## Technical Details
154
+
155
+ ### Data Encoding
156
+ - Supports alphanumeric and binary data
157
+ - Automatically selects the optimal QR code version based on data length and error correction level
158
+ - Versions range from 1 (21×21 modules) to 40 (177×177 modules)
159
+
160
+ ### Terminal Rendering
161
+ The QR code is rendered using:
162
+ - ANSI escape codes for colors
163
+ - Unicode blocks for representing QR modules
164
+ - Standard terminal output (stdout/stderr)
165
+
166
+ ### Performance
167
+ - Built in TypeScript with zero runtime dependencies (except commander for CLI parsing)
168
+ - Efficient module generation and rendering
169
+ - Immediate output without compilation delays
170
+
171
+ ## Project Structure
172
+
173
+ ```
174
+ src/
175
+ ├── cli.ts # Main CLI entry point
176
+ ├── core/
177
+ │ ├── QRCodeModel.ts # Core QR code generation
178
+ │ ├── QRBitBuffer.ts # Bit buffer management
179
+ │ └── QRRSBlock.ts # Reed-Solomon error correction
180
+ ├── libs/
181
+ │ ├── QRMath.ts # Mathematical utilities
182
+ │ └── QRPolynomial.ts # Polynomial arithmetic
183
+ ├── renderer/
184
+ │ └── ConsoleDrawing.ts # Terminal rendering
185
+ └── types/
186
+ └── index.d.ts # TypeScript definitions
187
+ ```
188
+
189
+ ## Scripts
190
+
191
+ ### Development
192
+ ```bash
193
+ npm run build # Build the CLI
194
+ npm run test # Run tests in watch mode
195
+ npm run test:run # Run tests once
196
+ npm run lint # Check code with oxlint
197
+ npm run lint:fix # Fix linting issues
198
+ npm run fmt # Format code
199
+ npm run type-check # Check TypeScript types
200
+ ```
201
+
202
+ ### Testing
203
+ ```bash
204
+ npm run test:coverage # Generate coverage report
205
+ npm run test:ui # Run tests with UI dashboard
206
+ ```
207
+
208
+ ## Error Messages
209
+
210
+ If you encounter errors, here are common issues and solutions:
211
+
212
+ | Error | Cause | Solution |
213
+ |-------|-------|----------|
214
+ | `Invalid error level` | Invalid level argument | Use L, M, Q, or H only |
215
+ | `Data too long for a standard QR Code` | Text is too long for any QR version | Use a shorter text or higher data compression |
216
+ | `Invalid color code` | ANSI code format is wrong | Ensure proper ANSI escape sequence format |
217
+
218
+ ## Troubleshooting
219
+
220
+ ### QR Code Won't Scan
221
+ - Increase the `--quiet-zone` value (default is 4)
222
+ - Use a higher error correction level with `--level H`
223
+ - Ensure your terminal supports ANSI colors
224
+ - Check that the QR code is fully rendered without line wrapping
225
+
226
+ ### Terminal Display Issues
227
+ - Ensure your terminal supports Unicode and ANSI colors
228
+ - Try using a modern terminal (iTerm2, Windows Terminal, GNOME Terminal, etc.)
229
+ - Check terminal font supports block characters
230
+
231
+ ### Color Not Showing
232
+ - Verify your terminal supports 256 colors or true color
233
+ - Check ANSI escape code syntax
234
+ - Try using common ANSI codes like `\x1b[31m` for red
235
+
236
+ ## License
237
+
238
+ MIT © [OctaEDLP00](https://github.com/OctaEDLP00)
239
+
240
+ ## Contributing
241
+
242
+ Contributions are welcome! Please feel free to submit a Pull Request.
243
+
244
+ ## See Also
245
+
246
+ - [QR Code Wikipedia](https://en.wikipedia.org/wiki/QR_code)
247
+ - [ANSI Escape Codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
248
+ - [Commander.js Documentation](https://github.com/tj/commander.js)
package/dist/cli.js CHANGED
@@ -786,6 +786,9 @@ var QrErrorCorrectLevel = {
786
786
 
787
787
  // src/cli.ts
788
788
  import { Command } from "commander";
789
+ import { createRequire } from "module";
790
+ var require2 = createRequire(import.meta.url);
791
+ var packageJson = require2("../package.json");
789
792
  var getOptimalVersion = (data, level) => {
790
793
  for (let v = 1; v <= 40; v++) {
791
794
  try {
@@ -801,7 +804,7 @@ var getOptimalVersion = (data, level) => {
801
804
  return 4;
802
805
  };
803
806
  var program = new Command();
804
- program.name("qrx").description("Professional QR Code generation in your terminal").version("1.0.0");
807
+ program.description("Professional QR Code generation in your terminal").version(packageJson.version);
805
808
  program.argument("<text>", "Text or URL to encode").option("-s, --size <number>", "Scale factor (1, 2, 3...)", (v) => parseInt(v, 10), 1).option("-q, --quiet-zone <number>", "Quiet zone (padding)", (v) => parseInt(v, 10), 4).option("-l, --level <type>", "Error correction level (L, M, Q, H)", "M").option("--dark <color>", "ANSI for dark modules", "\x1B[40m \x1B[0m").option("--light <color>", "ANSI for light modules", "\x1B[47m \x1B[0m").action((text, options) => {
806
809
  try {
807
810
  const levelMap = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qr-render/qrcode-cli",
3
- "version": "0.0.3",
3
+ "version": "0.1.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "builder",
@@ -36,6 +36,7 @@
36
36
  "@types/node": "25.0.10",
37
37
  "@vitest/coverage-v8": "4.0.18",
38
38
  "@vitest/ui": "4.0.18",
39
+ "happy-dom": "^20.5.0",
39
40
  "oxfmt": "^0.27.0",
40
41
  "oxlint": "1.42.0",
41
42
  "tsup": "8.5.1",
package/dist/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 OctaEDLP00
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/dist/README.md DELETED
@@ -1 +0,0 @@
1
- # QRCodeCLI
package/dist/package.json DELETED
@@ -1,64 +0,0 @@
1
- {
2
- "name": "@qr-render/qrcode-cli",
3
- "version": "0.0.3",
4
- "description": "",
5
- "keywords": [
6
- "builder",
7
- "cli",
8
- "installer",
9
- "readline",
10
- "typescript"
11
- ],
12
- "homepage": "https://github.com/OctaEDLP00/QrCodeCLI#readme",
13
- "bugs": {
14
- "url": "https://github.com/OctaEDLP00/QrCodeCLI/issues"
15
- },
16
- "license": "MIT",
17
- "author": "OctaEDLP00",
18
- "repository": {
19
- "type": "git",
20
- "url": "https://github.com/OctaEDLP00/QrCodeCLI.git"
21
- },
22
- "bin": "dist/cli.js",
23
- "files": [
24
- "dist/cli.js",
25
- "dist/README.md",
26
- "dist/LICENSE",
27
- "dist/package.json",
28
- "dist/tsconfig.json"
29
- ],
30
- "type": "module",
31
- "types": "./index.d.ts",
32
- "scripts": {
33
- "build": "tsup",
34
- "lint": "oxlint src/**/*.ts",
35
- "lint:fix": "oxlint src/**/*.ts --fix",
36
- "fmt": "oxfmt",
37
- "fmt:check": "oxfmt --check",
38
- "prepublishOnly": "pnpm run build && pnpm run test:run && pnpm run lint",
39
- "test": "vitest",
40
- "test:coverage": "vitest run --coverage",
41
- "test:run": "vitest run",
42
- "test:ui": "vitest --ui",
43
- "type-check": "tsc --noEmit"
44
- },
45
- "dependencies": {
46
- "commander": "14.0.2"
47
- },
48
- "devDependencies": {
49
- "@types/node": "25.0.10",
50
- "@vitest/coverage-v8": "4.0.18",
51
- "@vitest/ui": "4.0.18",
52
- "oxfmt": "^0.27.0",
53
- "oxlint": "1.42.0",
54
- "tsup": "8.5.1",
55
- "tsx": "4.21.0",
56
- "typescript": "5.9.3",
57
- "vitest": "4.0.18"
58
- },
59
- "pnpm": {
60
- "onlyBuiltDependencies": [
61
- "esbuild"
62
- ]
63
- }
64
- }