@metricinsights/pp-dev 0.18.0 → 0.18.2
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 +84 -64
- package/README.md +91 -66
- package/dist/CHANGELOG.md +84 -64
- package/dist/README.md +91 -66
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/helpers.js.map +1 -1
- package/dist/cjs/index-B1GblhLQ.js +2 -0
- package/dist/cjs/index-B1GblhLQ.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/package.json +10 -3
- package/dist/cjs/plugin-DY9gjLm8.js +2 -0
- package/dist/cjs/plugin-DY9gjLm8.js.map +1 -0
- package/dist/cjs/plugin.js +1 -1
- package/dist/cjs/version-plugin-DSLhm6Q1.js +2 -0
- package/dist/cjs/version-plugin-DSLhm6Q1.js.map +1 -0
- package/dist/client/client.css +1 -1
- package/dist/client/client.css.map +1 -1
- package/dist/client/client.js +91 -2
- package/dist/client/client.js.map +1 -1
- package/dist/client/index.html +12 -9
- package/dist/esm/cli.js +1 -1
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/helpers.js.map +1 -1
- package/dist/esm/index-basLGB1P.js +2 -0
- package/dist/esm/index-basLGB1P.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/package.json +10 -3
- package/dist/esm/plugin-B6DaUVqp.js +2 -0
- package/dist/esm/plugin-B6DaUVqp.js.map +1 -0
- package/dist/esm/plugin.js +1 -1
- package/dist/esm/version-plugin-DekxT1OJ.js +2 -0
- package/dist/esm/version-plugin-DekxT1OJ.js.map +1 -0
- package/dist/types/index.d.ts +1 -205
- package/package.json +13 -4
- package/pp-dev.d.ts +1 -0
- package/scripts/patch-npm-bundled-vulnerabilities.mjs +9 -11
- package/dist/cjs/index-DR5Vl6zz.js +0 -2
- package/dist/cjs/index-DR5Vl6zz.js.map +0 -1
- package/dist/cjs/plugin-DMyHXqs8.js +0 -2
- package/dist/cjs/plugin-DMyHXqs8.js.map +0 -1
- package/dist/cjs/version-plugin-Cj4Pv-pw.js +0 -2
- package/dist/cjs/version-plugin-Cj4Pv-pw.js.map +0 -1
- package/dist/esm/index-Co3ktLxA.js +0 -2
- package/dist/esm/index-Co3ktLxA.js.map +0 -1
- package/dist/esm/plugin-CcoYWcTD.js +0 -2
- package/dist/esm/plugin-CcoYWcTD.js.map +0 -1
- package/dist/esm/version-plugin-B1n39tE6.js +0 -2
- package/dist/esm/version-plugin-B1n39tE6.js.map +0 -1
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ import '@metricinsights/pp-dev/client/css/client.css';
|
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
**Available Exports**:
|
|
56
|
+
|
|
56
57
|
- **Main**: Complete pp-dev functionality with CLI and plugins
|
|
57
58
|
- **Plugin**: Vite plugin for integration with build tools
|
|
58
59
|
- **Helpers**: Utility functions for authentication and configuration
|
|
@@ -63,6 +64,7 @@ import '@metricinsights/pp-dev/client/css/client.css';
|
|
|
63
64
|
The pp-dev package includes optimized startup performance and build system with multiple strategies:
|
|
64
65
|
|
|
65
66
|
### Quick Start
|
|
67
|
+
|
|
66
68
|
```bash
|
|
67
69
|
# Standard build (parallel)
|
|
68
70
|
npm run build
|
|
@@ -84,6 +86,7 @@ npm run startup:optimize
|
|
|
84
86
|
```
|
|
85
87
|
|
|
86
88
|
### Performance Features
|
|
89
|
+
|
|
87
90
|
- **40-50% faster startup** with intelligent caching
|
|
88
91
|
- **60-70% faster subsequent starts** with connection pooling
|
|
89
92
|
- **Lazy loading** of heavy modules (jsdom, esbuild)
|
|
@@ -93,6 +96,7 @@ npm run startup:optimize
|
|
|
93
96
|
- **Intelligent dependency optimization** based on profiling data
|
|
94
97
|
|
|
95
98
|
### Build Features
|
|
99
|
+
|
|
96
100
|
- **Parallel builds** for 40-60% faster build times
|
|
97
101
|
- **Enhanced tree-shaking** for smaller bundles
|
|
98
102
|
- **Multiple output formats** (ESM, CJS, Types)
|
|
@@ -110,6 +114,7 @@ The new startup optimization system in v0.11.0 provides:
|
|
|
110
114
|
- **Optimization Suggestions**: Automated recommendations for performance improvements
|
|
111
115
|
|
|
112
116
|
Run the startup optimizer to analyze and improve your development environment:
|
|
117
|
+
|
|
113
118
|
```bash
|
|
114
119
|
npm run startup:optimize
|
|
115
120
|
```
|
|
@@ -122,6 +127,7 @@ npm run startup:optimize
|
|
|
122
127
|
### Configuration File
|
|
123
128
|
|
|
124
129
|
Create a configuration file named `pp-dev.config` with one of these extensions:
|
|
130
|
+
|
|
125
131
|
- `.js` or `.cjs` (for CommonJS)
|
|
126
132
|
- `.ts` (for TypeScript)
|
|
127
133
|
- `.json`
|
|
@@ -200,28 +206,28 @@ export default config;
|
|
|
200
206
|
|
|
201
207
|
### Required Options
|
|
202
208
|
|
|
203
|
-
| Option
|
|
204
|
-
|
|
205
|
-
| `backendBaseURL` | string | URL of the Metric Insights instance for API proxying
|
|
206
|
-
| `portalPageId`
|
|
207
|
-
| `appId`
|
|
209
|
+
| Option | Type | Description |
|
|
210
|
+
| ---------------- | ------ | --------------------------------------------------------------------------- |
|
|
211
|
+
| `backendBaseURL` | string | URL of the Metric Insights instance for API proxying |
|
|
212
|
+
| `portalPageId` | number | ID of the Portal Page for variable values (deprecated, use `appId` instead) |
|
|
213
|
+
| `appId` | number | ID of the Portal Page for variable values (synonym for `portalPageId`) |
|
|
208
214
|
|
|
209
215
|
### Optional Options
|
|
210
216
|
|
|
211
|
-
| Option
|
|
212
|
-
|
|
213
|
-
| `miHudLess`
|
|
214
|
-
| `integrateMiTopBar`
|
|
215
|
-
| `templateLess`
|
|
216
|
-
| `enableProxyCache`
|
|
217
|
-
| `proxyCacheTTL`
|
|
218
|
-
| `disableSSLValidation` | boolean
|
|
219
|
-
| `imageOptimizer`
|
|
220
|
-
| `outDir`
|
|
221
|
-
| `distZip`
|
|
222
|
-
| `syncBackupsDir`
|
|
223
|
-
| `v7Features`
|
|
224
|
-
| `personalAccessToken`
|
|
217
|
+
| Option | Type | Default | Description |
|
|
218
|
+
| ---------------------- | ----------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
219
|
+
| `miHudLess` | boolean | `false` | Disables Metric Insights navigation bar in development |
|
|
220
|
+
| `integrateMiTopBar` | boolean \| object | `false` | Integrates MI Top Bar and scripts into the App build (requires `miHudLess: true`). When `true`, enables both `addRootElement` and `addSharedComponentsScripts`. When an object, allows selective enabling: `{ addRootElement?: boolean, addSharedComponentsScripts?: boolean }` |
|
|
221
|
+
| `templateLess` | boolean | `false` | Disables template variable transformation |
|
|
222
|
+
| `enableProxyCache` | boolean | `true` | Enables caching of proxied requests |
|
|
223
|
+
| `proxyCacheTTL` | number | `600000` | Cache TTL in milliseconds (10 minutes) |
|
|
224
|
+
| `disableSSLValidation` | boolean | `false` | Disables SSL certificate validation for proxy requests |
|
|
225
|
+
| `imageOptimizer` | boolean \| object | `true` | Controls image optimization. See [vite-plugin-image-optimizer](https://www.npmjs.com/package/vite-plugin-image-optimizer#plugin-options) for object options |
|
|
226
|
+
| `outDir` | string | `dist` | Output directory for builds |
|
|
227
|
+
| `distZip` | boolean \| object | `true` | Controls build output zipping. Object options: `{ outDir?: string, outFileName?: string }` |
|
|
228
|
+
| `syncBackupsDir` | string | `backups` | Directory for asset backups from MI server |
|
|
229
|
+
| `v7Features` | boolean | `false` | Enables Metric Insights v7 features |
|
|
230
|
+
| `personalAccessToken` | string | `process.env.MI_ACCESS_TOKEN` | Personal Access Token for the MI instance |
|
|
225
231
|
|
|
226
232
|
### integrateMiTopBar Details
|
|
227
233
|
|
|
@@ -238,10 +244,12 @@ The `integrateMiTopBar` option allows you to integrate the Metric Insights Top B
|
|
|
238
244
|
`integrateMiTopBar` can be configured in two ways:
|
|
239
245
|
|
|
240
246
|
**1. Boolean (Simple)**
|
|
247
|
+
|
|
241
248
|
- `true`: Enables both `addRootElement` and `addSharedComponentsScripts`
|
|
242
249
|
- `false`: Disables integration (default)
|
|
243
250
|
|
|
244
251
|
**2. Object (Advanced)**
|
|
252
|
+
|
|
245
253
|
- `addRootElement`: Adds `<div id="mi-react-root">` element to the body for React mounting
|
|
246
254
|
- `addSharedComponentsScripts`: Adds MI shared component scripts and styles:
|
|
247
255
|
- `/auth/info.js` - Authentication info script
|
|
@@ -251,17 +259,19 @@ The `integrateMiTopBar` option allows you to integrate the Metric Insights Top B
|
|
|
251
259
|
#### Examples
|
|
252
260
|
|
|
253
261
|
**Simple boolean configuration:**
|
|
262
|
+
|
|
254
263
|
```javascript
|
|
255
264
|
// pp-dev.config.js
|
|
256
265
|
module.exports = {
|
|
257
266
|
backendBaseURL: 'https://mi.company.com',
|
|
258
267
|
appId: 1,
|
|
259
|
-
miHudLess: true,
|
|
260
|
-
integrateMiTopBar: true,
|
|
268
|
+
miHudLess: true, // Required: Disable dynamic MI scripts
|
|
269
|
+
integrateMiTopBar: true, // Enable: Integrate Top Bar into build
|
|
261
270
|
};
|
|
262
271
|
```
|
|
263
272
|
|
|
264
273
|
**Advanced object configuration (selective features):**
|
|
274
|
+
|
|
265
275
|
```javascript
|
|
266
276
|
// pp-dev.config.js
|
|
267
277
|
module.exports = {
|
|
@@ -269,13 +279,14 @@ module.exports = {
|
|
|
269
279
|
appId: 1,
|
|
270
280
|
miHudLess: true,
|
|
271
281
|
integrateMiTopBar: {
|
|
272
|
-
addRootElement: true,
|
|
273
|
-
addSharedComponentsScripts: true,
|
|
282
|
+
addRootElement: true, // Add root element for React
|
|
283
|
+
addSharedComponentsScripts: true, // Add MI scripts and styles
|
|
274
284
|
},
|
|
275
285
|
};
|
|
276
286
|
```
|
|
277
287
|
|
|
278
288
|
**Partial integration (scripts only, manual root element):**
|
|
289
|
+
|
|
279
290
|
```javascript
|
|
280
291
|
// pp-dev.config.js
|
|
281
292
|
module.exports = {
|
|
@@ -283,8 +294,8 @@ module.exports = {
|
|
|
283
294
|
appId: 1,
|
|
284
295
|
miHudLess: true,
|
|
285
296
|
integrateMiTopBar: {
|
|
286
|
-
addRootElement: false,
|
|
287
|
-
addSharedComponentsScripts: true,
|
|
297
|
+
addRootElement: false, // Don't add root element
|
|
298
|
+
addSharedComponentsScripts: true, // Add MI scripts and styles
|
|
288
299
|
},
|
|
289
300
|
};
|
|
290
301
|
```
|
|
@@ -292,6 +303,7 @@ module.exports = {
|
|
|
292
303
|
### v7Features Details
|
|
293
304
|
|
|
294
305
|
When enabled (`true`), this option:
|
|
306
|
+
|
|
295
307
|
1. Changes development path from `/pt/<portal-page-name>` to `/pl/<portal-page-name>`
|
|
296
308
|
2. Updates Code Sync feature to use v7.1.0+ URLs
|
|
297
309
|
|
|
@@ -300,6 +312,7 @@ When enabled (`true`), this option:
|
|
|
300
312
|
The `personalAccessToken` option allows you to authenticate with the Metric Insights instance. You can set it in your configuration or use the `MI_ACCESS_TOKEN` environment variable.
|
|
301
313
|
|
|
302
314
|
Example with authentication and Top Bar integration:
|
|
315
|
+
|
|
303
316
|
```javascript
|
|
304
317
|
// pp-dev.config.js
|
|
305
318
|
module.exports = {
|
|
@@ -312,10 +325,16 @@ module.exports = {
|
|
|
312
325
|
```
|
|
313
326
|
|
|
314
327
|
**Environment Variable**: Set `MI_ACCESS_TOKEN` in your `.env` file:
|
|
328
|
+
|
|
315
329
|
```bash
|
|
316
330
|
MI_ACCESS_TOKEN=your_token_here
|
|
317
331
|
```
|
|
318
332
|
|
|
333
|
+
**Local development and network exposure**: pp-dev is a **development** tool. It assumes a trusted machine. Personal access tokens and session helpers are still sensitive: they can authenticate to your Metric Insights backend as you.
|
|
334
|
+
|
|
335
|
+
- Prefer binding the dev server to **`localhost`** when you do not need access from other devices. If you use **`--host`** (or equivalent) so the app listens on **all interfaces** or your LAN, other machines on the same network can reach the dev server and its dev-only routes (for example the in-browser token login flow). Treat that like exposing credentials: use only on networks you trust, or restrict access with your OS firewall.
|
|
336
|
+
- Do not commit real tokens; keep them in `.env` (gitignored) or your secret store. Avoid sharing screen recordings or logs that contain `MI_ACCESS_TOKEN` or bearer tokens.
|
|
337
|
+
|
|
319
338
|
### Enhanced Authentication (v0.11.0+)
|
|
320
339
|
|
|
321
340
|
The new authentication system in v0.11.0 provides:
|
|
@@ -326,11 +345,13 @@ The new authentication system in v0.11.0 provides:
|
|
|
326
345
|
- **Connection Pooling**: Optimized HTTP connections for better performance
|
|
327
346
|
|
|
328
347
|
**Supported Environment Variables**:
|
|
348
|
+
|
|
329
349
|
- `MI_ACCESS_TOKEN`: Personal access token for authentication
|
|
330
350
|
- `MI_BACKEND_URL`: Alternative to `backendBaseURL` in config
|
|
331
351
|
- `MI_APP_ID`: Alternative to `appId` in config
|
|
332
352
|
|
|
333
353
|
**Automatic Loading**: pp-dev automatically detects and loads these variables from your project's `.env` file:
|
|
354
|
+
|
|
334
355
|
```bash
|
|
335
356
|
# .env
|
|
336
357
|
MI_ACCESS_TOKEN=your_personal_access_token
|
|
@@ -342,13 +363,13 @@ MI_APP_ID=123
|
|
|
342
363
|
|
|
343
364
|
### Global Options
|
|
344
365
|
|
|
345
|
-
| Option
|
|
346
|
-
|
|
347
|
-
| `-c, --config <file>`
|
|
348
|
-
| `--base <path>`
|
|
366
|
+
| Option | Description |
|
|
367
|
+
| ------------------------ | -------------------------------------------------------------------------------- |
|
|
368
|
+
| `-c, --config <file>` | Path to configuration file (default: `pp-dev.config.js`) |
|
|
369
|
+
| `--base <path>` | Public base path (default: `/`) |
|
|
349
370
|
| `-l, --logLevel <level>` | Log level: `trace`, `debug`, `info`, `warn`, `error`, `silent` (default: `info`) |
|
|
350
|
-
| `--clearScreen`
|
|
351
|
-
| `--mode <mode>`
|
|
371
|
+
| `--clearScreen` | Clear screen before logging |
|
|
372
|
+
| `--mode <mode>` | Environment mode: `development`, `production`, `test` (default: `development`) |
|
|
352
373
|
|
|
353
374
|
### Development Server
|
|
354
375
|
|
|
@@ -357,15 +378,16 @@ pp-dev [root] [options]
|
|
|
357
378
|
# Aliases: pp-dev dev, pp-dev serve
|
|
358
379
|
```
|
|
359
380
|
|
|
360
|
-
| Option
|
|
361
|
-
|
|
362
|
-
| `[root]`
|
|
363
|
-
| `--host <host>` | `localhost` | Server hostname
|
|
364
|
-
| `--port <port>` | `3000`
|
|
365
|
-
| `--open [path]` | -
|
|
366
|
-
| `--strictPort`
|
|
381
|
+
| Option | Default | Description |
|
|
382
|
+
| --------------- | ----------- | --------------------------------- |
|
|
383
|
+
| `[root]` | `.` | Root directory of the application |
|
|
384
|
+
| `--host <host>` | `localhost` | Server hostname |
|
|
385
|
+
| `--port <port>` | `3000` | Server port |
|
|
386
|
+
| `--open [path]` | - | Open browser on server start |
|
|
387
|
+
| `--strictPort` | - | Exit if port is already in use |
|
|
367
388
|
|
|
368
389
|
**Development Shortcuts**:
|
|
390
|
+
|
|
369
391
|
- `p` - Start/stop performance profiler (v0.11.0+)
|
|
370
392
|
- `l` - Proxy re-login (refresh authentication)
|
|
371
393
|
- `r` - Restart dev server
|
|
@@ -381,11 +403,11 @@ pp-dev next [options]
|
|
|
381
403
|
# Aliases: pp-dev next-server, pp-dev next-dev
|
|
382
404
|
```
|
|
383
405
|
|
|
384
|
-
| Option
|
|
385
|
-
|
|
386
|
-
| `[root]`
|
|
387
|
-
| `--port <port>` | `3000`
|
|
388
|
-
| `--host <host>` | `localhost` | Server hostname
|
|
406
|
+
| Option | Default | Description |
|
|
407
|
+
| --------------- | ----------- | --------------------------------- |
|
|
408
|
+
| `[root]` | `.` | Root directory of the application |
|
|
409
|
+
| `--port <port>` | `3000` | Server port |
|
|
410
|
+
| `--host <host>` | `localhost` | Server hostname |
|
|
389
411
|
|
|
390
412
|
### Build
|
|
391
413
|
|
|
@@ -393,13 +415,13 @@ pp-dev next [options]
|
|
|
393
415
|
pp-dev build [options]
|
|
394
416
|
```
|
|
395
417
|
|
|
396
|
-
| Option
|
|
397
|
-
|
|
398
|
-
| `[root]`
|
|
399
|
-
| `--target <target>`
|
|
400
|
-
| `--outDir <dir>`
|
|
401
|
-
| `--assetsDir <dir>`
|
|
402
|
-
| `--changelog [file]` | `true`
|
|
418
|
+
| Option | Default | Description |
|
|
419
|
+
| -------------------- | --------- | --------------------------------- |
|
|
420
|
+
| `[root]` | `.` | Root directory of the application |
|
|
421
|
+
| `--target <target>` | `modules` | Transpile target |
|
|
422
|
+
| `--outDir <dir>` | `dist` | Output directory |
|
|
423
|
+
| `--assetsDir <dir>` | `assets` | Assets directory under outDir |
|
|
424
|
+
| `--changelog [file]` | `true` | Create changelog file |
|
|
403
425
|
|
|
404
426
|
### Changelog Generation
|
|
405
427
|
|
|
@@ -407,14 +429,14 @@ pp-dev build [options]
|
|
|
407
429
|
pp-dev changelog [oldAssetPath] [newAssetPath] [options]
|
|
408
430
|
```
|
|
409
431
|
|
|
410
|
-
| Option
|
|
411
|
-
|
|
412
|
-
| `[oldAssetPath]`
|
|
413
|
-
| `[newAssetPath]`
|
|
414
|
-
| `--oldAssetsPath <path>` | -
|
|
415
|
-
| `--newAssetsPath <path>` | -
|
|
416
|
-
| `--destination <path>`
|
|
417
|
-
| `--filename <name>`
|
|
432
|
+
| Option | Default | Description |
|
|
433
|
+
| ------------------------ | ---------------- | -------------------------- |
|
|
434
|
+
| `[oldAssetPath]` | - | Path to previous assets |
|
|
435
|
+
| `[newAssetPath]` | - | Path to current assets |
|
|
436
|
+
| `--oldAssetsPath <path>` | - | Path to previous assets |
|
|
437
|
+
| `--newAssetsPath <path>` | - | Path to current assets |
|
|
438
|
+
| `--destination <path>` | `.` | Changelog output directory |
|
|
439
|
+
| `--filename <name>` | `CHANGELOG.html` | Changelog filename |
|
|
418
440
|
|
|
419
441
|
### Icon Font Generation
|
|
420
442
|
|
|
@@ -422,13 +444,13 @@ pp-dev changelog [oldAssetPath] [newAssetPath] [options]
|
|
|
422
444
|
pp-dev generate-icon-font [source] [destination] [options]
|
|
423
445
|
```
|
|
424
446
|
|
|
425
|
-
| Option
|
|
426
|
-
|
|
427
|
-
| `[source]`
|
|
428
|
-
| `[destination]`
|
|
429
|
-
| `--source <path>`
|
|
430
|
-
| `--destination <path>` | -
|
|
431
|
-
| `--fontName <name>`
|
|
447
|
+
| Option | Default | Description |
|
|
448
|
+
| ---------------------- | ----------- | ------------------------------- |
|
|
449
|
+
| `[source]` | - | Source directory with SVG icons |
|
|
450
|
+
| `[destination]` | - | Output directory |
|
|
451
|
+
| `--source <path>` | - | Source directory with SVG icons |
|
|
452
|
+
| `--destination <path>` | - | Output directory |
|
|
453
|
+
| `--fontName <name>` | `icon-font` | Font name |
|
|
432
454
|
|
|
433
455
|
## Next.js Integration
|
|
434
456
|
|
|
@@ -442,12 +464,13 @@ pp-dev generate-icon-font [source] [destination] [options]
|
|
|
442
464
|
}
|
|
443
465
|
```
|
|
444
466
|
3. Wrap your Next.js config:
|
|
467
|
+
|
|
445
468
|
```javascript
|
|
446
469
|
// next.config.js
|
|
447
470
|
const { withPPDev } = require('@metricinsights/pp-dev');
|
|
448
471
|
|
|
449
472
|
module.exports = withPPDev({
|
|
450
|
-
|
|
473
|
+
// your Next.js config
|
|
451
474
|
});
|
|
452
475
|
```
|
|
453
476
|
|
|
@@ -464,11 +487,13 @@ For custom build configuration, create a `vite.config` file. See [Vite Configura
|
|
|
464
487
|
If you encounter an error like "Next.js is required but not available":
|
|
465
488
|
|
|
466
489
|
1. **Install Next.js in your project:**
|
|
490
|
+
|
|
467
491
|
```bash
|
|
468
492
|
npm install next@^15
|
|
469
493
|
```
|
|
470
494
|
|
|
471
495
|
2. **Verify the installation:**
|
|
496
|
+
|
|
472
497
|
```bash
|
|
473
498
|
npm list next
|
|
474
499
|
```
|