@entrinsik/vite-plugin-informer 1.0.3 → 1.0.4
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/bin/deploy.js +4 -1
- package/package.json +1 -1
- package/src/deploy.js +9 -3
- package/src/index.js +1 -0
- package/templates/skill/SKILL.md +49 -1
package/bin/deploy.js
CHANGED
|
@@ -29,14 +29,16 @@ let pkg;
|
|
|
29
29
|
let displayName;
|
|
30
30
|
let description;
|
|
31
31
|
let savedId;
|
|
32
|
+
let icon;
|
|
32
33
|
|
|
33
34
|
try {
|
|
34
35
|
pkg = JSON.parse(await readFile(pkgPath, 'utf8'));
|
|
35
36
|
|
|
36
|
-
// Read display name, description, and saved ID from informer config section
|
|
37
|
+
// Read display name, description, icon, and saved ID from informer config section
|
|
37
38
|
displayName = pkg.informer?.name;
|
|
38
39
|
description = pkg.informer?.description;
|
|
39
40
|
savedId = pkg.informer?.id;
|
|
41
|
+
icon = pkg.informer?.icon;
|
|
40
42
|
} catch {
|
|
41
43
|
console.error('Could not read package.json in current directory.');
|
|
42
44
|
process.exit(1);
|
|
@@ -66,6 +68,7 @@ try {
|
|
|
66
68
|
distDir,
|
|
67
69
|
name: displayName,
|
|
68
70
|
description,
|
|
71
|
+
icon,
|
|
69
72
|
id: savedId
|
|
70
73
|
});
|
|
71
74
|
|
package/package.json
CHANGED
package/src/deploy.js
CHANGED
|
@@ -16,10 +16,10 @@ const ROOT_CONFIG_FILES = ['data-access.yaml'];
|
|
|
16
16
|
/**
|
|
17
17
|
* Deploy a built Vite project to Informer as a Magic Report.
|
|
18
18
|
*
|
|
19
|
-
* @param {{ baseUrl: string, apiKey?: string, user?: string, pass?: string, distDir: string, name: string, description?: string, id?: string }} opts
|
|
19
|
+
* @param {{ baseUrl: string, apiKey?: string, user?: string, pass?: string, distDir: string, name: string, description?: string, icon?: string, id?: string }} opts
|
|
20
20
|
* @returns {Promise<{ id: string, url: string }>} The report's natural ID and URL
|
|
21
21
|
*/
|
|
22
|
-
export async function deploy({ baseUrl, apiKey, user, pass, distDir, name, description, id }) {
|
|
22
|
+
export async function deploy({ baseUrl, apiKey, user, pass, distDir, name, description, icon, id }) {
|
|
23
23
|
const api = createClient({ baseUrl, apiKey, user, pass });
|
|
24
24
|
|
|
25
25
|
let report = null;
|
|
@@ -57,10 +57,16 @@ export async function deploy({ baseUrl, apiKey, user, pass, distDir, name, descr
|
|
|
57
57
|
console.log(`Created report: ${naturalId}`);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
// 3. Update name/description if provided (for existing reports)
|
|
60
|
+
// 3. Update name/description/icon if provided (for existing reports)
|
|
61
61
|
const updates = {};
|
|
62
62
|
if (name && report.name !== name) updates.name = name;
|
|
63
63
|
if (description !== undefined && report.description !== description) updates.description = description;
|
|
64
|
+
if (icon) {
|
|
65
|
+
const currentDefn = report.defn || {};
|
|
66
|
+
if (currentDefn.icon !== icon) {
|
|
67
|
+
updates.defn = { ...currentDefn, icon };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
64
70
|
if (Object.keys(updates).length > 0) {
|
|
65
71
|
await api.put(`reports/${naturalId}`, updates);
|
|
66
72
|
}
|
package/src/index.js
CHANGED
package/templates/skill/SKILL.md
CHANGED
|
@@ -47,6 +47,28 @@ Builds your project and uploads to an Informer library:
|
|
|
47
47
|
5. Uploads `data-access.yaml` from project root (if it exists)
|
|
48
48
|
6. Report is viewable at `/reports/r/{owner}:{slug}`
|
|
49
49
|
|
|
50
|
+
### Package.json Configuration
|
|
51
|
+
|
|
52
|
+
The `informer` section in `package.json` controls deploy metadata:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"informer": {
|
|
57
|
+
"name": "Sales Dashboard",
|
|
58
|
+
"description": "Regional sales performance overview",
|
|
59
|
+
"icon": "BarChart",
|
|
60
|
+
"id": "a1b2c3d4-..."
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
| Field | Description |
|
|
66
|
+
|-------|-------------|
|
|
67
|
+
| `name` | Display name in Informer (falls back to package `name`) |
|
|
68
|
+
| `description` | Report description |
|
|
69
|
+
| `icon` | Material Icons name in PascalCase (e.g. `"TrendingUp"`, `"PieChart"`, `"Assessment"`) |
|
|
70
|
+
| `id` | Report UUID (auto-saved after first deploy) |
|
|
71
|
+
|
|
50
72
|
## Discovering Resources
|
|
51
73
|
|
|
52
74
|
Once `.env` is configured, Claude can query the Informer API directly to help you find available resources. Ask Claude to look up:
|
|
@@ -302,9 +324,35 @@ When running inside Informer (not dev mode), the report receives context:
|
|
|
302
324
|
```javascript
|
|
303
325
|
const reportId = window.__INFORMER__?.report?.id;
|
|
304
326
|
const reportName = window.__INFORMER__?.report?.name;
|
|
327
|
+
const theme = window.__INFORMER__?.theme; // 'light' or 'dark'
|
|
305
328
|
```
|
|
306
329
|
|
|
307
|
-
In dev mode, the Vite plugin mocks this with placeholder values.
|
|
330
|
+
In dev mode, the Vite plugin mocks this with placeholder values (theme defaults to `'light'`).
|
|
331
|
+
|
|
332
|
+
### Responding to Theme
|
|
333
|
+
|
|
334
|
+
Use the theme value to adapt your report's appearance:
|
|
335
|
+
|
|
336
|
+
```javascript
|
|
337
|
+
const theme = window.__INFORMER__?.theme || 'light';
|
|
338
|
+
document.documentElement.setAttribute('data-theme', theme);
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
```css
|
|
342
|
+
:root { --bg: #ffffff; --text: #1a1a1a; }
|
|
343
|
+
[data-theme="dark"] { --bg: #1e1e1e; --text: #e0e0e0; }
|
|
344
|
+
body { background: var(--bg); color: var(--text); }
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
To override the theme in dev mode, pass `mock.theme` in `vite.config.js`:
|
|
348
|
+
|
|
349
|
+
```javascript
|
|
350
|
+
import informer from 'vite-plugin-informer';
|
|
351
|
+
|
|
352
|
+
export default {
|
|
353
|
+
plugins: [informer({ mock: { theme: 'dark' } })]
|
|
354
|
+
};
|
|
355
|
+
```
|
|
308
356
|
|
|
309
357
|
## PDF Export
|
|
310
358
|
|