@risleylima/escpos 0.1.1 → 0.2.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.1] - 2025-11-23
9
+
10
+ ### Added
11
+ - Versioning documentation (`docs/VERSIONING.md`) with explicit semantic versioning rules
12
+
13
+ ## [0.2.0] - 2025-11-23
14
+
15
+ ### Added
16
+ - `Serial.listSerial()` method to list all available serial ports
17
+ - Returns array of serial port objects with path, manufacturer, vendorId, productId, etc.
18
+ - Similar functionality to `USB.listUSB()` for consistency between adapters
19
+
8
20
  ## [0.1.0] - 2025-11-23
9
21
 
10
22
  ### Added
@@ -55,6 +67,8 @@ Initial stable release with USB and Serial adapter support.
55
67
 
56
68
  ## Version History
57
69
 
70
+ - **0.2.1** - Added versioning documentation
71
+ - **0.2.0** - Added `Serial.listSerial()` method for listing available serial ports
58
72
  - **0.1.0** - Major dependency updates, 100% test coverage, complete documentation
59
73
  - **0.0.14** - Initial stable release
60
74
 
package/README.md CHANGED
@@ -215,6 +215,14 @@ await USB.disconnect();
215
215
 
216
216
  #### Methods
217
217
 
218
+ ##### `Serial.listSerial()`
219
+ List all available serial ports.
220
+
221
+ ```javascript
222
+ const ports = await Serial.listSerial();
223
+ console.log(ports); // Array of serial port objects with path, manufacturer, vendorId, productId, etc.
224
+ ```
225
+
218
226
  ##### `Serial.connect(port, options)`
219
227
  Connect to a serial port printer.
220
228
 
package/docs/README.md CHANGED
@@ -28,6 +28,9 @@ Complete review of JSDoc documentation coverage across the library.
28
28
  ### [Public API Analysis](./PUBLIC_API_ANALYSIS.md)
29
29
  Detailed analysis of the public API and exported modules, including breaking changes impact assessment.
30
30
 
31
+ ### [Versioning Rules](./VERSIONING.md) ⚠️
32
+ Explicit semantic versioning rules for the project. **Read this before publishing any version update.**
33
+
31
34
  ## Main Documentation
32
35
 
33
36
  - **README.md** (root) - Main project documentation with installation, usage examples, and API reference
@@ -0,0 +1,102 @@
1
+ # Semantic Versioning Rules
2
+
3
+ This document defines the explicit versioning rules for this project.
4
+
5
+ ## Version Format
6
+
7
+ Following [Semantic Versioning](https://semver.org/spec/v2.0.0.html): `MAJOR.MINOR.PATCH`
8
+
9
+ ## Versioning Rules
10
+
11
+ ### Starting from `0.0.0`:
12
+
13
+ #### MINOR Update: `0.0.0` → `0.0.1`
14
+ - **When to use**: Adding new features, functions, or methods
15
+ - **Examples**:
16
+ - Adding a new function like `Serial.listSerial()`
17
+ - Adding a new method to an existing class
18
+ - Adding new functionality that doesn't break existing code
19
+ - **Rule**: New features = increment MINOR (third number)
20
+
21
+ #### MAJOR Update: `0.0.0` → `0.1.0`
22
+ - **When to use**: Significant changes, major updates, or substantial improvements
23
+ - **Examples**:
24
+ - Major dependency updates (e.g., `usb@^1.9.1` → `usb@^2.16.0`)
25
+ - Major refactoring
26
+ - Significant architectural changes
27
+ - Multiple new features bundled together
28
+ - **Rule**: Major changes = increment MAJOR (second number) when in `0.x.x` range
29
+
30
+ #### BREAKING CHANGES: `0.0.0` → `1.0.0`
31
+ - **When to use**: Breaking changes to the public API
32
+ - **Examples**:
33
+ - Removing or renaming public methods
34
+ - Changing method signatures in a way that breaks existing code
35
+ - Removing exported modules
36
+ - Changing behavior in a way that breaks backward compatibility
37
+ - **Rule**: Breaking changes = increment to `1.0.0` (first number)
38
+
39
+ ## Examples from This Project
40
+
41
+ ### `0.0.14` → `0.0.15` (MINOR)
42
+ - Adding a single new function: `Serial.listSerial()`
43
+ - This is a **MINOR** update (patch increment)
44
+
45
+ ### `0.0.14` → `0.1.0` (MAJOR)
46
+ - Major dependency updates (usb v1 → v2, serialport v12 → v13)
47
+ - Complete test suite addition
48
+ - Comprehensive documentation
49
+ - Multiple significant improvements bundled together
50
+ - This is a **MAJOR** update (minor increment in 0.x.x range)
51
+
52
+ ### Future: `0.x.x` → `1.0.0` (BREAKING)
53
+ - If we remove `USB.listUSB()` method
54
+ - If we change `Printer` constructor signature
55
+ - If we remove support for a feature
56
+ - This would be a **BREAKING** change (major increment to 1.0.0)
57
+
58
+ ## Decision Tree
59
+
60
+ ```
61
+ Is it a bug fix or small correction?
62
+ YES → PATCH (0.0.0 → 0.0.1)
63
+
64
+ Is it a single new feature/function?
65
+ YES → MINOR (0.0.0 → 0.0.1)
66
+
67
+ Is it multiple features or major updates?
68
+ YES → MAJOR (0.0.0 → 0.1.0)
69
+
70
+ Does it break existing code/API?
71
+ YES → BREAKING (0.0.0 → 1.0.0)
72
+ ```
73
+
74
+ ## Important Notes
75
+
76
+ 1. **In `0.x.x` range**:
77
+ - The second number (MINOR) acts as MAJOR
78
+ - The third number (PATCH) acts as MINOR
79
+ - This is standard Semantic Versioning behavior for pre-1.0.0 versions
80
+
81
+ 2. **After `1.0.0`**:
82
+ - Standard semver rules apply
83
+ - MAJOR.MINOR.PATCH
84
+ - Breaking changes = MAJOR increment
85
+ - New features = MINOR increment
86
+ - Bug fixes = PATCH increment
87
+
88
+ 3. **Always consider**:
89
+ - Impact on users
90
+ - Backward compatibility
91
+ - Number of changes
92
+ - Significance of changes
93
+
94
+ ## Summary Table
95
+
96
+ | Change Type | From `0.0.0` | Example |
97
+ |-------------|--------------|---------|
98
+ | Bug fix | `0.0.1` | Fix typo, fix error handling |
99
+ | New function/method | `0.0.1` | Add `Serial.listSerial()` |
100
+ | Major updates | `0.1.0` | Dependency updates, major refactoring |
101
+ | Breaking changes | `1.0.0` | Remove API, change signatures |
102
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@risleylima/escpos",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "Library to deal with ESCPOS using some adapters",
5
5
  "main": "index.js",
6
6
  "author": "Rlima Info",
@@ -26,6 +26,22 @@ const scope = {
26
26
  // Create Adapter instance first, so it's the same object used internally and exported
27
27
  const Serial = new Adapter();
28
28
 
29
+ /**
30
+ * List all available serial ports
31
+ * @async
32
+ * @returns {Promise<Array<Object>>} Array of serial port objects with properties like path, manufacturer, vendorId, productId, etc.
33
+ * @example
34
+ * const ports = await Serial.listSerial();
35
+ * console.log(ports);
36
+ * // [
37
+ * // { path: '/dev/ttyUSB0', manufacturer: 'FTDI', vendorId: '0403', productId: '6001' },
38
+ * // { path: '/dev/ttyUSB1', manufacturer: 'Prolific', vendorId: '067b', productId: '2303' }
39
+ * // ]
40
+ */
41
+ Serial.listSerial = async () => {
42
+ return await SerialPort.list();
43
+ };
44
+
29
45
  /**
30
46
  * Connect to a serial port printer
31
47
  * @async
@@ -49,6 +49,20 @@ describe('Serial Adapter', () => {
49
49
  jest.clearAllMocks();
50
50
  });
51
51
 
52
+ describe('listSerial', () => {
53
+ it('should list all available serial ports', async () => {
54
+ const ports = await Serial.listSerial();
55
+ expect(Array.isArray(ports)).toBe(true);
56
+ expect(SerialPort.list).toHaveBeenCalled();
57
+ });
58
+
59
+ it('should return port objects with path property', async () => {
60
+ const ports = await Serial.listSerial();
61
+ expect(ports.length).toBeGreaterThan(0);
62
+ expect(ports[0]).toHaveProperty('path');
63
+ });
64
+ });
65
+
52
66
  describe('connect', () => {
53
67
  it('should connect to serial port', async () => {
54
68
  const result = await Serial.connect('/dev/ttyUSB0');