@masumdev/markforge 0.3.0 → 0.4.1

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.
@@ -32,10 +32,9 @@ try {
32
32
  }
33
33
  } catch {
34
34
  }
35
- var FALLBACK_VERSION = "0.3.0";
36
35
  function readVersionFromPackageJson(fromDir) {
37
36
  let currentDir = fromDir;
38
- for (let i = 0; i < 6; i++) {
37
+ for (let i = 0; i < 10; i++) {
39
38
  try {
40
39
  const pkgJsonPath = path.join(currentDir, "package.json");
41
40
  if (fs.existsSync(pkgJsonPath)) {
@@ -50,7 +49,9 @@ function readVersionFromPackageJson(fromDir) {
50
49
  if (parentDir === currentDir) break;
51
50
  currentDir = parentDir;
52
51
  }
53
- return FALLBACK_VERSION;
52
+ throw new Error(
53
+ "Failed to resolve '@masumdev/markforge' package version: package.json was not found or is missing a valid 'version' field."
54
+ );
54
55
  }
55
56
  function getPackageDir() {
56
57
  if (typeof __dirname !== "undefined") {
package/dist/cli.mjs CHANGED
@@ -9,7 +9,7 @@ try {
9
9
  } catch {}
10
10
  import {
11
11
  MARKFORGE_VERSION
12
- } from "./chunk-HKB4CSPZ.mjs";
12
+ } from "./chunk-UNWAEVDU.mjs";
13
13
  import "./chunk-YZHGBG4N.mjs";
14
14
 
15
15
  // src/cli.tsx
@@ -45,7 +45,7 @@ process.on("warning", (w) => {
45
45
  });
46
46
  async function main() {
47
47
  const program = new Command();
48
- program.name("markforge").description("Modern Markdown & MDX multi-format publishing engine & CLI (DOCX, PDF, HTML, Images)").version(MARKFORGE_VERSION, "-V, --version", "Output current markforge version").argument("[input-file]", "Markdown or MDX source file to compile", "README.md").option("-t, --to <formats>", "Target formats to compile to (comma-separated: docx,pdf,html)").option("-o, --output <dir>", "Output directory for generated documents").option("--theme <theme>", "Built-in theme name (default, academic, github, corporate, minimal)").option("--css <path...>", "Custom CSS stylesheet(s) to inject").option("-c, --config <path>", "Path to custom markforge configuration file").option("--toc", "Force Table of Contents generation").option("-w, --watch", "Watch input file for changes and recompile", false).option("-s, --serve [port]", "Start local HTTP preview server", false).option("-O, --open", "Open compiled document in default browser", false);
48
+ program.name("markforge").description("Modern Markdown & MDX multi-format publishing engine & CLI (DOCX, PDF, HTML, Images)").version(MARKFORGE_VERSION, "-V, --version", "Output current markforge version").argument("[input-file]", "Markdown or MDX source file to compile", "README.md").option("-t, --to <formats>", "Target formats to compile to (comma-separated: docx,pdf,html)").option("-o, --output <dir>", "Output directory for generated documents").option("--theme <theme>", "Built-in theme name (default, academic, github, corporate, minimal)").option("--css <path...>", "Custom CSS stylesheet(s) to inject").option("-c, --config <path>", "Path to custom markforge configuration file").option("--toc", "Force Table of Contents generation").option("-w, --watch", "Watch input file for changes and recompile", false).option("-s, --serve [port]", "Start interactive live-reload preview server").option("-O, --open", "Open preview or compiled document in default browser", false);
49
49
  program.parse(process.argv);
50
50
  const options = program.opts();
51
51
  const inputArg = program.args[0] || "README.md";
@@ -55,12 +55,8 @@ async function main() {
55
55
  process.exit(1);
56
56
  }
57
57
  const cliFormats = options.to ? options.to.split(",").map((f) => f.trim().toLowerCase()).filter(Boolean) : void 0;
58
- const [{ render }, { App }, { loadConfig }] = await Promise.all([
59
- import("ink"),
60
- import("./App-AM2CWXHJ.mjs"),
61
- import("./loadConfig-PD6ENMAM.mjs")
62
- ]);
63
- const { config: fileConfig } = await loadConfig(
58
+ const { loadConfig } = await import("./loadConfig-PGJKPE6G.mjs");
59
+ const { config: fileConfig, configPath } = await loadConfig(
64
60
  options.config,
65
61
  path.dirname(resolvedInputPath)
66
62
  );
@@ -72,12 +68,46 @@ async function main() {
72
68
  ...options.css ? { css: options.css } : {},
73
69
  ...options.toc ? { toc: true } : {}
74
70
  };
71
+ if (options.serve !== false && options.serve !== void 0) {
72
+ const rawPort = options.serve === true ? 3e3 : parseInt(String(options.serve), 10);
73
+ const port = isNaN(rawPort) ? 3e3 : rawPort;
74
+ const { startPreviewServer } = await import("./previewServer-4EELOUAV.mjs");
75
+ const instance = await startPreviewServer({
76
+ filePath: resolvedInputPath,
77
+ port,
78
+ open: Boolean(options.open),
79
+ config: mergedConfig
80
+ });
81
+ const themeLabel = typeof mergedConfig.theme === "object" ? "Custom (ThemeProps)" : String(mergedConfig.theme || "corporate");
82
+ console.log(`
83
+ ======================================================`);
84
+ console.log(` MarkForge Live Reload Preview Server v${MARKFORGE_VERSION}`);
85
+ console.log(`======================================================`);
86
+ console.log(` Target File : ${resolvedInputPath}`);
87
+ console.log(` Config File : ${configPath || "(default auto-discovery)"}`);
88
+ console.log(` Theme : ${themeLabel} | Syntax: ${mergedConfig.syntaxTheme || "github-dark"}`);
89
+ console.log(` Layout : ${mergedConfig.paperSize || "A4"} (${mergedConfig.orientation || "portrait"})`);
90
+ console.log(` Server URL : ${instance.url}`);
91
+ console.log(` Auto-Open : ${Boolean(options.open) ? "Enabled" : "Disabled"}`);
92
+ console.log(` Author : Ma'sum (@masumrpg)`);
93
+ console.log(` GitHub : https://github.com/masumrpg`);
94
+ console.log(`======================================================
95
+ `);
96
+ console.log(`[READY] Watching for markdown and style changes. Press Ctrl+C to exit.
97
+ `);
98
+ return;
99
+ }
100
+ const [{ render }, { App }] = await Promise.all([
101
+ import("ink"),
102
+ import("./App-TPDCT2VL.mjs")
103
+ ]);
75
104
  render(
76
105
  /* @__PURE__ */ jsx(
77
106
  App,
78
107
  {
79
108
  inputFile: resolvedInputPath,
80
109
  config: mergedConfig,
110
+ configPath,
81
111
  onComplete: (res) => {
82
112
  if (res.errors && res.errors.length > 0) {
83
113
  process.exitCode = 1;