@capillarytech/cap-ui-dev-tools 1.0.0 → 1.2.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,13 +1,32 @@
1
- # Webpack Library Watcher Plugin
1
+ # @capillarytech/cap-ui-dev-tools
2
2
 
3
- [![NPM version](https://img.shields.io/npm/v/cap-ui-dev-tools.svg)](https://www.npmjs.com/package/cap-ui-dev-tools)
4
- [![Build Status](https://img.shields.io/travis/your-username/cap-ui-dev-tools.svg)](https://travis-ci.org/your-username/cap-ui-dev-tools)
3
+ [![NPM version](https://img.shields.io/npm/v/@capillarytech/cap-ui-dev-tools.svg)](https://www.npmjs.com/package/@capillarytech/cap-ui-dev-tools)
5
4
 
6
- A "zero-config" webpack plugin that **automatically aliases and hot-reloads** local libraries. Drastically reduces development iteration time when working with shared component libraries or utilities.
5
+ **Development tools for Capillary UI projects** - Webpack hot-reload plugin + CapVision session recording
7
6
 
8
- This plugin solves the common "it takes forever to see my changes" problem in a micro-frontend or shared library architecture. It provides a single place to manage local library development, keeping your main webpack configuration clean.
7
+ ## 📦 What's Included
9
8
 
10
- ## The Problem
9
+ ### 1. 🔥 Library Watcher Plugin (Webpack)
10
+ A "zero-config" webpack plugin that **automatically aliases and hot-reloads** local libraries.
11
+
12
+ ### 2. 🎥 CapVision Session Recording (NEW in v1.1.0)
13
+ Automatic session recording for WebdriverIO tests with HTML report integration.
14
+
15
+ ---
16
+
17
+ ## 🚀 Quick Start
18
+
19
+ ### Installation
20
+
21
+ ```bash
22
+ npm install --save-dev @capillarytech/cap-ui-dev-tools
23
+ ```
24
+
25
+ ---
26
+
27
+ ## Feature 1: Webpack Library Watcher Plugin
28
+
29
+ ### The Problem
11
30
 
12
31
  When developing an application that consumes a local library, you typically have to manage two separate configurations:
13
32
  1. **Webpack Alias:** You need to add a `resolve.alias` entry in your webpack config to point the library's package name to your local source code.
@@ -15,52 +34,37 @@ When developing an application that consumes a local library, you typically have
15
34
 
16
35
  Managing this in the main webpack config can be messy and error-prone.
17
36
 
18
- ## The Solution: "Explicit Alias" Mode
37
+ ### The Solution
19
38
 
20
- This plugin provides a single, clean interface to handle both aliasing and watching. You explicitly tell the plugin which libraries to manage, and it handles the complex webpack configuration for you.
39
+ This plugin provides a single, clean interface to handle both aliasing and watching.
21
40
 
22
41
  **Based on initial testing, this can reduce development iteration time by over 90% (e.g., from 3 minutes to under 10 seconds).**
23
42
 
24
43
  ![Architecture](architecture.png)
25
44
 
26
- ## Installation
27
-
28
- ```bash
29
- npm install --save-dev cap-ui-dev-tools
30
- ```
31
-
32
- ## Usage
33
-
34
- Add the plugin to your `webpack.config.js` file. It should only be active in `development` mode.
35
-
36
- ### Configuration
45
+ ### Usage
37
46
 
38
47
  ```javascript
39
48
  // webpack.config.js
40
- const LibraryWatcherPlugin = require('cap-ui-dev-tools');
49
+ const LibraryWatcherPlugin = require('@capillarytech/cap-ui-dev-tools');
50
+ // or
51
+ const LibraryWatcherPlugin = require('@capillarytech/cap-ui-dev-tools/webpack');
52
+
41
53
  const path = require('path');
42
54
 
43
55
  module.exports = {
44
56
  mode: 'development',
45
- // ... your other webpack config
46
-
47
- // NO need for a separate resolve.alias block for local development!
48
- // The plugin handles it for you.
49
- resolve: {
50
- // ... any other aliases can stay here
51
- },
52
-
57
+
53
58
  plugins: [
54
- // Ensure you have HotModuleReplacementPlugin enabled
55
59
  new webpack.HotModuleReplacementPlugin(),
56
-
60
+
57
61
  new LibraryWatcherPlugin({
58
62
  // An array of libraries to alias and watch.
59
63
  libs: [
60
64
  {
61
65
  // The package name of the library (from its package.json).
62
66
  name: 'cap-creatives-ui',
63
-
67
+
64
68
  // The absolute path to the library's source code.
65
69
  path: path.resolve(__dirname, '../cap-creatives-ui/src')
66
70
  },
@@ -69,12 +73,11 @@ module.exports = {
69
73
  path: path.resolve(__dirname, '../another-local-lib/src')
70
74
  }
71
75
  ],
72
-
76
+
73
77
  // Enable verbose logging to the console.
74
78
  verbose: true,
75
-
79
+
76
80
  // Optional: Options passed directly to chokidar.
77
- // See https://github.com/paulmillr/chokidar#api for details.
78
81
  watchOptions: {
79
82
  // ..
80
83
  }
@@ -83,43 +86,191 @@ module.exports = {
83
86
  };
84
87
  ```
85
88
 
86
- ## How It Works
89
+ ### How It Works
87
90
 
88
91
  1. During initialization, the plugin reads your `libs` array.
89
- 2. It **programmatically modifies webpack's configuration**, adding a `resolve.alias` entry for each library. This means you don't have to.
92
+ 2. It **programmatically modifies webpack's configuration**, adding a `resolve.alias` entry for each library.
90
93
  3. It then uses `chokidar` to watch the provided `path` for each library.
91
94
  4. It adds the watched paths to webpack's `contextDependencies` to make webpack aware of them.
92
95
  5. When a file change is detected, the plugin tells webpack's own watcher that the file has been invalidated, triggering a standard recompilation and HMR update.
93
96
 
94
- ## Troubleshooting
97
+ ---
98
+
99
+ ## Feature 2: CapVision Session Recording (NEW ✨)
100
+
101
+ ### Quick Start
102
+
103
+ ```javascript
104
+ // wdio.conf.js
105
+ const { createWDIOCapVisionHooks } = require('@capillarytech/cap-ui-dev-tools/capvision');
106
+
107
+ const capVisionHooks = createWDIOCapVisionHooks({
108
+ recordingsOutputDir: './reports/recordings',
109
+ enabledClusters: ['staging', 'production']
110
+ });
111
+
112
+ exports.config = {
113
+ onPrepare: capVisionHooks.onPrepare,
114
+ beforeTest: (test, context) => capVisionHooks.beforeTest(test, context, browser),
115
+ afterTest: capVisionHooks.afterTest,
116
+ onComplete: capVisionHooks.onComplete
117
+ };
118
+ ```
119
+
120
+ ### Features
121
+
122
+ - ✅ **Automatic Recording** - Zero manual intervention
123
+ - ✅ **Page Refresh Support** - Maintains recording across navigations
124
+ - ✅ **HTML Report Integration** - Auto-embeds playback in reports
125
+ - ✅ **Smart Filtering** - Configure by cluster, module, test type
126
+ - ✅ **Console Recording** - Captures console logs with UI interactions
127
+ - ✅ **Privacy First** - Auto-masks sensitive inputs
128
+ - ✅ **Framework Agnostic Core** - Works with WebdriverIO, Playwright, Puppeteer
129
+
130
+ ### Full Documentation
131
+
132
+ See [CAPVISION_USAGE.md](./CAPVISION_USAGE.md) for complete CapVision documentation including:
133
+ - Configuration options
134
+ - Usage patterns
135
+ - API reference
136
+ - Troubleshooting
137
+ - Examples
138
+
139
+ ---
95
140
 
96
- ### Changes are not detected.
141
+ ## 📦 Package Exports
142
+
143
+ ```javascript
144
+ // Webpack Plugin (default export)
145
+ const LibraryWatcherPlugin = require('@capillarytech/cap-ui-dev-tools');
146
+ // or explicitly
147
+ const LibraryWatcherPlugin = require('@capillarytech/cap-ui-dev-tools/webpack');
148
+
149
+ // CapVision Recorder
150
+ const { createWDIOCapVisionHooks } = require('@capillarytech/cap-ui-dev-tools/capvision');
151
+ // or from main export
152
+ const { createWDIOCapVisionHooks } = require('@capillarytech/cap-ui-dev-tools');
153
+
154
+ // Full CapVision module
155
+ const capVision = require('@capillarytech/cap-ui-dev-tools').capVisionRecorder;
156
+ ```
157
+
158
+ ---
159
+
160
+ ## 🎯 Use Cases
161
+
162
+ ### For UI Library Developers
163
+ Use **LibraryWatcherPlugin** to:
164
+ - Develop and test shared components in real-time
165
+ - Eliminate slow "npm link" workflows
166
+ - See changes instantly in consuming applications
167
+
168
+ ### For QA/Test Engineers
169
+ Use **CapVision Recorder** to:
170
+ - Automatically record test sessions
171
+ - Debug test failures visually
172
+ - Share test recordings with developers
173
+ - Enhance HTML reports with playback
174
+
175
+ ### For Full-Stack Teams
176
+ Use **both** for:
177
+ - Fast UI development iteration
178
+ - Automated test documentation
179
+ - Better collaboration between dev and QA
180
+
181
+ ---
182
+
183
+ ## 📚 Documentation
184
+
185
+ - **Webpack Plugin**: See sections above
186
+ - **CapVision Recorder**: See [CAPVISION_USAGE.md](./CAPVISION_USAGE.md)
187
+ - **Integration Guide**: See [INTEGRATION_GUIDE.md](./INTEGRATION_GUIDE.md)
188
+ - **Testing Guide**: See [TESTING_GUIDE.md](./TESTING_GUIDE.md)
189
+
190
+ ---
191
+
192
+ ## 🔧 Troubleshooting
193
+
194
+ ### Webpack Plugin
195
+
196
+ #### Changes are not detected
97
197
  - **Check Paths**: Make sure the `path` in the `libs` configuration is an **absolute path** pointing to the **source code** of your library. Use `path.resolve(__dirname, '..', 'your-lib')`.
98
- - **Check Name**: Ensure the `name` property matches the package name your host application is trying to import (e.g., `'cap-creatives-ui'`).
99
- - **Enable `verbose` mode**: Set `verbose: true` to see detailed logs. It will confirm which aliases are being created and which paths are being watched.
198
+ - **Check Name**: Ensure the `name` property matches the package name your host application is trying to import.
199
+ - **Enable `verbose` mode**: Set `verbose: true` to see detailed logs.
200
+
201
+ ### CapVision Recorder
202
+
203
+ See [CAPVISION_USAGE.md](./CAPVISION_USAGE.md#troubleshooting) for common issues and solutions.
100
204
 
101
- ## For Maintainers: Publishing to NPM
205
+ ---
102
206
 
103
- To publish a new version of this package to the NPM registry, follow these steps.
207
+ ## 📝 Changelog
104
208
 
105
- 1. **Update Version Number**:
106
- - Update the `version` field in `package.json` according to [Semantic Versioning (SemVer)](https://semver.org/).
209
+ ### v1.1.0 (2025-11-12)
210
+ - **NEW**: Added CapVision session recording module
211
+ - ✅ Support for automatic test recording
212
+ - ✅ HTML report enhancement with playback
213
+ - ✅ WebdriverIO integration via hooks
214
+ - ✅ Framework-agnostic core
215
+ - 📚 Comprehensive documentation added
216
+
217
+ ### v1.0.0 (Initial Release)
218
+ - ✅ Webpack Library Watcher Plugin
219
+ - ✅ Hot-reload for local libraries
220
+ - ✅ Zero-config webpack integration
221
+
222
+ ---
223
+
224
+ ## 🚀 Publishing to NPM
225
+
226
+ For maintainers:
227
+
228
+ 1. **Update Version Number**: Update the `version` field in `package.json` according to [SemVer](https://semver.org/).
107
229
 
108
230
  2. **Log in to NPM**:
109
- - If you are not already logged in, run the following command and enter your credentials.
110
231
  ```bash
111
232
  npm login
112
233
  ```
113
234
 
114
235
  3. **Perform a Dry Run**:
115
- - It is highly recommended to check what will be published without actually publishing it.
116
236
  ```bash
117
237
  npm publish --dry-run
118
238
  ```
119
- - This will list all files being included in the package. Verify that only necessary files (`src/LibraryWatcherPlugin.js`, `package.json`, `README.md`) are present.
120
239
 
121
240
  4. **Publish**:
122
- - Once you have verified the package contents, run the publish command:
123
241
  ```bash
124
242
  npm publish
125
243
  ```
244
+
245
+ ---
246
+
247
+ ## 🤝 Contributing
248
+
249
+ Contributions welcome! Please:
250
+ 1. Fork the repository
251
+ 2. Create a feature branch
252
+ 3. Make your changes
253
+ 4. Add tests if applicable
254
+ 5. Submit a pull request
255
+
256
+ ---
257
+
258
+ ## 📄 License
259
+
260
+ ISC License
261
+
262
+ ---
263
+
264
+ ## 🙏 Acknowledgments
265
+
266
+ - **CapVision**: Session recording solution (powered by rrweb)
267
+ - **Chokidar**: File watching library
268
+ - **Webpack**: Module bundler
269
+ - **WebdriverIO**: Test automation framework
270
+
271
+ ---
272
+
273
+ **Made with ❤️ by Capillary Technologies**
274
+
275
+ **Version**: 1.1.0
276
+ **Includes**: Webpack Hot-Reload Plugin + CapVision Session Recording
package/package.json CHANGED
@@ -1,10 +1,18 @@
1
1
  {
2
2
  "name": "@capillarytech/cap-ui-dev-tools",
3
- "version": "1.0.0",
4
- "main": "src/LibraryWatcherPlugin.js",
3
+ "version": "1.2.0",
4
+ "description": "Development tools for Capillary UI projects including webpack hot-reload plugin and CapVision session recording",
5
+ "main": "src/index.js",
6
+ "exports": {
7
+ ".": "./src/index.js",
8
+ "./webpack": "./src/LibraryWatcherPlugin.js",
9
+ "./capvision": "./src/capvision-recorder/index.js",
10
+ "./package.json": "./package.json"
11
+ },
5
12
  "files": [
6
- "src/LibraryWatcherPlugin.js",
7
- "README.md"
13
+ "src/",
14
+ "README.md",
15
+ "CAPVISION_USAGE.md"
8
16
  ],
9
17
  "publishConfig": {
10
18
  "access": "public"
@@ -19,12 +27,24 @@
19
27
  "homepage": "https://github.com/cap-ui-dev-tools/cap-ui-dev-tools#readme",
20
28
  "scripts": {
21
29
  "start": "webpack serve",
22
- "test": "jest"
30
+ "test": "jest",
31
+ "test:integration": "node test-integration.js",
32
+ "lint": "eslint src/**/*.js"
23
33
  },
24
- "keywords": [],
25
- "author": "",
34
+ "keywords": [
35
+ "webpack",
36
+ "plugin",
37
+ "hot-reload",
38
+ "library",
39
+ "development",
40
+ "capvision",
41
+ "session-recording",
42
+ "webdriverio",
43
+ "test-automation",
44
+ "capillary"
45
+ ],
46
+ "author": "Capillary Technologies",
26
47
  "license": "ISC",
27
- "description": "",
28
48
  "dependencies": {
29
49
  "chokidar": "^3.6.0"
30
50
  },
@@ -37,6 +57,15 @@
37
57
  "webpack-hot-middleware": "^2.26.1"
38
58
  },
39
59
  "peerDependencies": {
40
- "webpack": "^5.0.0"
60
+ "webpack": "^5.0.0",
61
+ "webdriverio": ">=7.0.0 || >=8.0.0"
62
+ },
63
+ "peerDependenciesMeta": {
64
+ "webpack": {
65
+ "optional": false
66
+ },
67
+ "webdriverio": {
68
+ "optional": true
69
+ }
41
70
  }
42
- }
71
+ }
@@ -2,8 +2,34 @@ const chokidar = require('chokidar');
2
2
  const path = require('path');
3
3
  const fs = require('fs');
4
4
 
5
+ /**
6
+ * @typedef {object} LibraryOption
7
+ * @property {string} name The package name of the library (e.g., 'my-shared-lib').
8
+ * @property {string} path The absolute path to the library's source code directory.
9
+ */
10
+
11
+ /**
12
+ * @typedef {object} PluginOptions
13
+ * @property {LibraryOption[]} libs An array of library objects to alias and watch.
14
+ * @property {boolean} [verbose=false] If true, prints detailed logs to the console.
15
+ * @property {import('chokidar').WatchOptions} [watchOptions] Options object passed directly to Chokidar.
16
+ */
17
+
18
+ /**
19
+ * A webpack plugin that automatically aliases local libraries and triggers hot-reloading on change.
20
+ * This eliminates the need for manual rebuilds or complex webpack configuration when developing
21
+ * applications that consume local, unpublished libraries.
22
+ */
5
23
  class LibraryWatcherPlugin {
24
+ /**
25
+ * Creates an instance of LibraryWatcherPlugin.
26
+ * @param {PluginOptions} options The plugin options.
27
+ */
6
28
  constructor(options = {}) {
29
+ /**
30
+ * @private
31
+ * @type {PluginOptions}
32
+ */
7
33
  this.options = {
8
34
  libs: [],
9
35
  watchOptions: {
@@ -18,11 +44,30 @@ class LibraryWatcherPlugin {
18
44
  verbose: false,
19
45
  ...options
20
46
  };
47
+
48
+ /**
49
+ * @private
50
+ * @type {import('chokidar').FSWatcher | null}
51
+ */
21
52
  this.watcher = null;
53
+
54
+ /**
55
+ * @private
56
+ * @type {string | null}
57
+ */
22
58
  this.entryFile = null; // To hold the path to the host app's entry file
59
+
60
+ /**
61
+ * @private
62
+ * @type {string[]}
63
+ */
23
64
  this.watchPaths = this.options.libs.map(lib => lib.path);
24
65
  }
25
66
 
67
+ /**
68
+ * The main entry point for the webpack plugin.
69
+ * @param {import('webpack').Compiler} compiler The webpack compiler instance.
70
+ */
26
71
  apply(compiler) {
27
72
  if (compiler.options.mode !== 'development' || !this.options.libs.length) {
28
73
  return;
@@ -80,6 +125,10 @@ class LibraryWatcherPlugin {
80
125
  });
81
126
  }
82
127
 
128
+ /**
129
+ * Initializes the Chokidar file watcher if it hasn't been started already.
130
+ * @private
131
+ */
83
132
  startWatcher() {
84
133
  if (this.watcher || !this.watchPaths.length) return;
85
134
 
@@ -115,6 +164,10 @@ class LibraryWatcherPlugin {
115
164
  }
116
165
  }
117
166
 
167
+ /**
168
+ * Gracefully stops the file watcher.
169
+ * @private
170
+ */
118
171
  stopWatcher() {
119
172
  if (this.watcher) {
120
173
  this.watcher.close();