@metricinsights/pp-dev 1.5.0-beta.25 → 1.5.0-beta.27
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 +152 -151
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/package.json +2 -132
- package/dist/cjs/plugin.js +1 -1
- package/dist/cjs/plugin.js.map +1 -1
- package/dist/cjs/request-capture.middleware-B_sm9kKb.js +2 -0
- package/dist/cjs/request-capture.middleware-B_sm9kKb.js.map +1 -0
- package/dist/esm/cli.js +1 -1
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/package.json +2 -132
- package/dist/esm/plugin.js +1 -1
- package/dist/esm/plugin.js.map +1 -1
- package/dist/esm/request-capture.middleware-CtR74u3A.js +2 -0
- package/dist/esm/request-capture.middleware-CtR74u3A.js.map +1 -0
- package/dist/types/helpers.d.ts +29 -0
- package/dist/types/index.d.ts +7 -190
- package/dist/types/plugin.d.ts +8 -0
- package/dist/types/pp-dev-config-D889A-PO.d.ts +189 -0
- package/package.json +5 -8
- package/dist/CHANGELOG.md +0 -442
- package/dist/README.md +0 -765
- package/dist/cjs/request-capture.middleware-0msmv4A0.js +0 -2
- package/dist/cjs/request-capture.middleware-0msmv4A0.js.map +0 -1
- package/dist/esm/request-capture.middleware-Dt_17Nnw.js +0 -2
- package/dist/esm/request-capture.middleware-Dt_17Nnw.js.map +0 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { ViteImageOptimizer } from 'vite-plugin-image-optimizer';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* pp-dev's config: its public types, validation and normalization.
|
|
5
|
+
*
|
|
6
|
+
* Kept free of the dev server's dependencies (express, axios, the proxy, jsdom, …): `withPPDev()`
|
|
7
|
+
* runs while Next.js evaluates next.config, and the CLI reads the config before it knows whether
|
|
8
|
+
* it will serve, so loading the config must not load the server.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
type MiMode = 'standalone' | 'embedding';
|
|
12
|
+
type MiInclude = 'shared-components' | 'top-bar';
|
|
13
|
+
type AppType = 'page' | 'template';
|
|
14
|
+
interface MiConfig {
|
|
15
|
+
/** MI instance base URL. Falls back to process.env.MI_BACKEND_URL. */
|
|
16
|
+
url?: string;
|
|
17
|
+
/** Personal Access Token. Falls back to process.env.MI_ACCESS_TOKEN. */
|
|
18
|
+
token?: string;
|
|
19
|
+
/** How the page integrates into MI. @default 'standalone' */
|
|
20
|
+
mode?: MiMode;
|
|
21
|
+
/** Optional MI shared resources. Only valid when mode === 'standalone'. */
|
|
22
|
+
include?: MiInclude;
|
|
23
|
+
/** MI API/routing version. @default 7 */
|
|
24
|
+
apiVersion?: 6 | 7;
|
|
25
|
+
}
|
|
26
|
+
interface AppConfig {
|
|
27
|
+
/** Portal page / app ID on MI. Required for type=template and type=page+standalone. */
|
|
28
|
+
id?: number;
|
|
29
|
+
/** Internal asset name. @default package.json#name */
|
|
30
|
+
name?: string;
|
|
31
|
+
/** App type affecting routing and data loading. @default 'template' */
|
|
32
|
+
type?: AppType;
|
|
33
|
+
}
|
|
34
|
+
interface ProxyConfig {
|
|
35
|
+
/** Enable request caching to the backend. @default true */
|
|
36
|
+
cache?: boolean;
|
|
37
|
+
/** Cache TTL in milliseconds. @default 600000 */
|
|
38
|
+
cacheTtl?: number;
|
|
39
|
+
tls?: {
|
|
40
|
+
/** Allow self-signed TLS certificates. @default false */
|
|
41
|
+
allowSelfSigned?: boolean;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
interface DistZipBuildConfig {
|
|
45
|
+
/** Output ZIP file name. @default '<app.name>.zip' */
|
|
46
|
+
fileName?: string;
|
|
47
|
+
/** Output directory for the ZIP archive. @default 'dist-zip' */
|
|
48
|
+
outDir?: string;
|
|
49
|
+
/** Input directory to zip. @default value of build.outDir */
|
|
50
|
+
inDir?: string;
|
|
51
|
+
}
|
|
52
|
+
interface VersionFileBuildConfig {
|
|
53
|
+
/** @default true */
|
|
54
|
+
enabled?: boolean;
|
|
55
|
+
/** @default 'VERSION-v{packageversion}-{currentDate}.json' */
|
|
56
|
+
fileNameTemplate?: string;
|
|
57
|
+
}
|
|
58
|
+
interface BuildConfig {
|
|
59
|
+
/** Build output directory. @default 'dist' */
|
|
60
|
+
outDir?: string;
|
|
61
|
+
/** Pack build output into a ZIP archive. @default true */
|
|
62
|
+
zip?: boolean | DistZipBuildConfig;
|
|
63
|
+
/** Create a VERSION JSON file with SHA256 hashes. @default true */
|
|
64
|
+
versionFile?: boolean | VersionFileBuildConfig;
|
|
65
|
+
/** Image optimisation options. @default true */
|
|
66
|
+
imageOptimisations?: boolean | Record<string, unknown>;
|
|
67
|
+
}
|
|
68
|
+
interface SyncConfig {
|
|
69
|
+
/** Directory for sync backups. @default 'backups' */
|
|
70
|
+
backupsDir?: string;
|
|
71
|
+
/**
|
|
72
|
+
* How many backups of this page to keep; each new backup deletes the oldest beyond that.
|
|
73
|
+
* `false` or `0` keeps them all. @default 20
|
|
74
|
+
*/
|
|
75
|
+
maxBackups?: number | false;
|
|
76
|
+
/**
|
|
77
|
+
* How long the build a sync starts (`pp-dev build`, `next build`) may run, in milliseconds,
|
|
78
|
+
* before it is stopped and the sync fails. @default 600000 (10 minutes)
|
|
79
|
+
*/
|
|
80
|
+
buildTimeoutMs?: number;
|
|
81
|
+
}
|
|
82
|
+
interface InspectorConfig {
|
|
83
|
+
/** Enable the request inspector web UI at /@pp-dev/inspector. @default true */
|
|
84
|
+
enabled?: boolean;
|
|
85
|
+
/** Maximum RAM for stored request/response payloads in bytes. @default 1073741824 (1 GB) */
|
|
86
|
+
maxMemory?: number;
|
|
87
|
+
/** Maximum bytes captured per individual request/response body. @default 10485760 (10 MB) */
|
|
88
|
+
captureLimit?: number;
|
|
89
|
+
}
|
|
90
|
+
type DevPanelPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
91
|
+
interface DevPanelConfig {
|
|
92
|
+
/** Screen corner the dev panel is anchored to. @default 'bottom-right' */
|
|
93
|
+
position?: DevPanelPosition;
|
|
94
|
+
/** Fully hide the panel. Restore in the browser with ?pp-dev-panel=show. @default false */
|
|
95
|
+
hidden?: boolean;
|
|
96
|
+
/** Auto-hide: the panel slides behind the screen edge leaving a thin strip; hover reveals it. @default false */
|
|
97
|
+
autoHide?: boolean;
|
|
98
|
+
}
|
|
99
|
+
interface UsersConfig {
|
|
100
|
+
/**
|
|
101
|
+
* Keep the users added with an API token between dev server runs, in a file in your home
|
|
102
|
+
* directory (`~/.pp-dev/users/`) that only you can read. Passwords and MI sessions are never kept.
|
|
103
|
+
* @default false
|
|
104
|
+
*/
|
|
105
|
+
persist?: boolean;
|
|
106
|
+
}
|
|
107
|
+
interface ServerConfig {
|
|
108
|
+
/**
|
|
109
|
+
* Host names the dev server answers besides `localhost`, `*.localhost` and IP addresses, as
|
|
110
|
+
* Vite's `server.allowedHosts`: `'my-app.ngrok.app'`, or `'.ngrok.app'` for that domain and its
|
|
111
|
+
* subdomains. Any other `Host` is refused (DNS rebinding). The value of `--host` is allowed too.
|
|
112
|
+
* Pages on the names listed without a leading dot may also use the dev server's API, its
|
|
113
|
+
* WebSocket and, under `pp-dev next`, Next's HMR (`withPPDev()` adds them to Next's
|
|
114
|
+
* `allowedDevOrigins` in development): a page through a tunnel. `true` answers any host; avoid it.
|
|
115
|
+
* @default []
|
|
116
|
+
*/
|
|
117
|
+
allowedHosts?: string[] | true;
|
|
118
|
+
}
|
|
119
|
+
interface PPDevConfig {
|
|
120
|
+
mi?: MiConfig;
|
|
121
|
+
app?: AppConfig;
|
|
122
|
+
proxy?: ProxyConfig;
|
|
123
|
+
build?: BuildConfig;
|
|
124
|
+
sync?: SyncConfig;
|
|
125
|
+
inspector?: InspectorConfig;
|
|
126
|
+
devPanel?: DevPanelConfig;
|
|
127
|
+
/** Working as other MI users (the dev panel's Users section). */
|
|
128
|
+
users?: UsersConfig;
|
|
129
|
+
/** The dev server itself (`pp-dev` and `pp-dev next`). */
|
|
130
|
+
server?: ServerConfig;
|
|
131
|
+
}
|
|
132
|
+
interface VersionPluginOptions {
|
|
133
|
+
/**
|
|
134
|
+
* Version file filename template.
|
|
135
|
+
* Placeholders: {packageversion}, {currentDate}
|
|
136
|
+
* @default "VERSION-v{packageversion}-{currentDate}.json"
|
|
137
|
+
*/
|
|
138
|
+
versionFileTemplate?: string;
|
|
139
|
+
/** @default true */
|
|
140
|
+
enabled?: boolean;
|
|
141
|
+
}
|
|
142
|
+
/** @internal — used by the Vite plugin and CLI; not part of the public API. */
|
|
143
|
+
interface NormalizedVitePPDevOptions {
|
|
144
|
+
templateName: string;
|
|
145
|
+
backendBaseURL?: string;
|
|
146
|
+
appId?: number;
|
|
147
|
+
templateLess: boolean;
|
|
148
|
+
miHudLess: boolean;
|
|
149
|
+
integrateMiTopBar: boolean | {
|
|
150
|
+
addRootElement?: boolean;
|
|
151
|
+
addSharedComponentsScripts?: boolean;
|
|
152
|
+
};
|
|
153
|
+
enableProxyCache: boolean;
|
|
154
|
+
proxyCacheTTL: number;
|
|
155
|
+
disableSSLValidation: boolean;
|
|
156
|
+
imageOptimizer: boolean | Parameters<typeof ViteImageOptimizer>[0];
|
|
157
|
+
outDir: string;
|
|
158
|
+
distZip: false | {
|
|
159
|
+
outFileName: string;
|
|
160
|
+
outDir: string;
|
|
161
|
+
inDir?: string;
|
|
162
|
+
};
|
|
163
|
+
versionPlugin: false | VersionPluginOptions;
|
|
164
|
+
syncBackupsDir: string;
|
|
165
|
+
/** `undefined` leaves DistService's default. */
|
|
166
|
+
syncMaxBackups?: number | false;
|
|
167
|
+
/** `undefined` leaves DistService's default. */
|
|
168
|
+
syncBuildTimeoutMs?: number;
|
|
169
|
+
v7Features: boolean;
|
|
170
|
+
personalAccessToken?: string;
|
|
171
|
+
inspectorEnabled: boolean;
|
|
172
|
+
inspectorMaxMemory: number;
|
|
173
|
+
inspectorCaptureLimit: number;
|
|
174
|
+
devPanelPosition: DevPanelPosition;
|
|
175
|
+
devPanelHidden: boolean;
|
|
176
|
+
devPanelAutoHide: boolean;
|
|
177
|
+
persistUsers: boolean;
|
|
178
|
+
/** `server.allowedHosts`, lowercased. */
|
|
179
|
+
allowedHosts: string[] | true;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* @param templateName - package.json's `name`; `app.name` takes precedence over it, here and in
|
|
183
|
+
* {@link normalizePPDevConfig} (whose `templateName` is the one name to use from then on).
|
|
184
|
+
*/
|
|
185
|
+
declare function validatePPDevConfig(config: PPDevConfig, templateName: string | undefined): void;
|
|
186
|
+
declare function normalizePPDevConfig(config: PPDevConfig, templateName: string | undefined): NormalizedVitePPDevOptions;
|
|
187
|
+
|
|
188
|
+
export { normalizePPDevConfig as n, validatePPDevConfig as v };
|
|
189
|
+
export type { AppConfig as A, BuildConfig as B, DevPanelConfig as D, InspectorConfig as I, MiConfig as M, NormalizedVitePPDevOptions as N, PPDevConfig as P, SyncConfig as S, UsersConfig as U, VersionPluginOptions as V, AppType as a, DevPanelPosition as b, MiInclude as c, MiMode as d, ProxyConfig as e, ServerConfig as f };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metricinsights/pp-dev",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.5.0-beta.
|
|
4
|
+
"version": "1.5.0-beta.27",
|
|
5
5
|
"description": "Portal Page dev build tool",
|
|
6
6
|
"bin": {
|
|
7
7
|
"pp-dev": "bin/pp-dev.js"
|
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
"test:integration:watch": "vitest --config vitest.integration.config.ts",
|
|
30
30
|
"test:e2e:ui": "npx playwright test --ui",
|
|
31
31
|
"test:all": "npm run test:unit && npm run test:integration",
|
|
32
|
-
"lint": "eslint src tests",
|
|
33
|
-
"lint:fix": "eslint src tests --fix",
|
|
32
|
+
"lint": "eslint src tests e2e",
|
|
33
|
+
"lint:fix": "eslint src tests e2e --fix",
|
|
34
|
+
"typecheck": "tsc --noEmit -p tsconfig.json && tsc -p tests/tsconfig.json && tsc -p e2e/tsconfig.json",
|
|
34
35
|
"audit:all": "node scripts/audit-all.mjs",
|
|
35
36
|
"prereinstall:all": "npm run build",
|
|
36
37
|
"reinstall:all": "node scripts/reinstall-all.mjs"
|
|
@@ -155,17 +156,13 @@
|
|
|
155
156
|
"dist",
|
|
156
157
|
"package.json",
|
|
157
158
|
"README.md",
|
|
158
|
-
"LICENSE
|
|
159
|
+
"LICENSE",
|
|
159
160
|
"pp-dev.d.ts",
|
|
160
|
-
"assets",
|
|
161
161
|
"CHANGELOG.md",
|
|
162
162
|
"TEMPLATE_VARIABLES.md",
|
|
163
163
|
"docs/features.md",
|
|
164
164
|
"docs/screenshots"
|
|
165
165
|
],
|
|
166
|
-
"directories": {
|
|
167
|
-
"test": "test"
|
|
168
|
-
},
|
|
169
166
|
"repository": {
|
|
170
167
|
"type": "git",
|
|
171
168
|
"url": "git+https://github.com/mi-examples/pp-dev.git"
|