@json-to-office/jto 0.8.2 → 0.8.3
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 +4 -4
- package/dist/cli.js +19 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.js +18 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -22,8 +22,8 @@ jto pptx dev
|
|
|
22
22
|
### `dev`: visual playground
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
jto docx dev
|
|
26
|
-
jto pptx dev
|
|
25
|
+
jto docx dev
|
|
26
|
+
jto pptx dev
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
Opens a browser-based IDE at `localhost:3000` with:
|
|
@@ -41,8 +41,8 @@ Opens a browser-based IDE at `localhost:3000` with:
|
|
|
41
41
|
### `generate`: render files
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
jto docx generate
|
|
45
|
-
jto pptx generate
|
|
44
|
+
jto docx generate ./template.json -o ./report.docx
|
|
45
|
+
jto pptx generate ./template.json -o ./deck.pptx
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
Reads a JSON document definition and writes a `.docx` or `.pptx` file. Works in CI/CD pipelines, cron jobs, and scripts.
|
package/dist/cli.js
CHANGED
|
@@ -3412,6 +3412,10 @@ import chalk9 from "chalk";
|
|
|
3412
3412
|
init_esm_shims();
|
|
3413
3413
|
import * as path2 from "path";
|
|
3414
3414
|
import * as fs from "fs";
|
|
3415
|
+
var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
3416
|
+
function safeThemeKey(name) {
|
|
3417
|
+
return name && !UNSAFE_KEYS.has(name) ? name : "custom";
|
|
3418
|
+
}
|
|
3415
3419
|
function buildServicesFromEnv() {
|
|
3416
3420
|
const serverUrl = process.env.HIGHCHARTS_SERVER_URL;
|
|
3417
3421
|
const apiKey = process.env.HIGHCHARTS_API_KEY;
|
|
@@ -3548,16 +3552,20 @@ ${errors.map((e) => ` - ${e.path}: ${e.message}`).join("\n")}`
|
|
|
3548
3552
|
Object.assign(customThemes, options.customThemes);
|
|
3549
3553
|
}
|
|
3550
3554
|
if (typeof options.theme === "object" && options.theme !== null) {
|
|
3551
|
-
customThemes.
|
|
3555
|
+
customThemes[safeThemeKey(options.theme.name)] = options.theme;
|
|
3552
3556
|
}
|
|
3553
3557
|
if (options.themePath) {
|
|
3554
3558
|
try {
|
|
3559
|
+
let theme;
|
|
3555
3560
|
if (options.themePath.endsWith(".json")) {
|
|
3556
|
-
|
|
3561
|
+
theme = await core.loadThemeFromFile(options.themePath);
|
|
3557
3562
|
} else {
|
|
3558
3563
|
const themePath = path2.resolve(process.cwd(), options.themePath);
|
|
3559
3564
|
const themeModule = await import(themePath);
|
|
3560
|
-
|
|
3565
|
+
theme = themeModule.default || themeModule.theme;
|
|
3566
|
+
}
|
|
3567
|
+
if (theme) {
|
|
3568
|
+
customThemes[safeThemeKey(theme.name)] = theme;
|
|
3561
3569
|
}
|
|
3562
3570
|
} catch (error) {
|
|
3563
3571
|
console.warn(
|
|
@@ -3767,20 +3775,24 @@ ${errors.map((e) => ` - ${e.path}: ${e.message}`).join("\n")}`
|
|
|
3767
3775
|
Object.assign(customThemes, options.customThemes);
|
|
3768
3776
|
}
|
|
3769
3777
|
if (typeof options.theme === "object" && options.theme !== null) {
|
|
3770
|
-
customThemes.
|
|
3778
|
+
customThemes[safeThemeKey(options.theme.name)] = options.theme;
|
|
3771
3779
|
}
|
|
3772
3780
|
if (options.themePath) {
|
|
3773
3781
|
try {
|
|
3782
|
+
let theme;
|
|
3774
3783
|
if (options.themePath.endsWith(".json")) {
|
|
3775
3784
|
const content = fs.readFileSync(
|
|
3776
3785
|
path2.resolve(process.cwd(), options.themePath),
|
|
3777
3786
|
"utf-8"
|
|
3778
3787
|
);
|
|
3779
|
-
|
|
3788
|
+
theme = JSON.parse(content);
|
|
3780
3789
|
} else {
|
|
3781
3790
|
const themePath = path2.resolve(process.cwd(), options.themePath);
|
|
3782
3791
|
const themeModule = await import(themePath);
|
|
3783
|
-
|
|
3792
|
+
theme = themeModule.default || themeModule.theme;
|
|
3793
|
+
}
|
|
3794
|
+
if (theme) {
|
|
3795
|
+
customThemes[safeThemeKey(theme.name)] = theme;
|
|
3784
3796
|
}
|
|
3785
3797
|
} catch (error) {
|
|
3786
3798
|
console.warn(
|
|
@@ -5885,7 +5897,7 @@ ${chalk8.cyan("Health:")} ${url}/health
|
|
|
5885
5897
|
}
|
|
5886
5898
|
|
|
5887
5899
|
// src/cli.ts
|
|
5888
|
-
var PACKAGE_VERSION = true ? "0.8.
|
|
5900
|
+
var PACKAGE_VERSION = true ? "0.8.3" : "dev-mode";
|
|
5889
5901
|
function registerFormatCommands(parent, adapter) {
|
|
5890
5902
|
parent.addCommand(createGenerateCommand(adapter));
|
|
5891
5903
|
parent.addCommand(createValidateCommand(adapter));
|