marp-dev-preview 0.1.0 → 0.1.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.
@@ -10,9 +10,9 @@ import { hideBin } from 'yargs/helpers';
10
10
  import markdownItFootnote from 'markdown-it-footnote';
11
11
  import markdownItMark from 'markdown-it-mark';
12
12
  import markdownItContainer from 'markdown-it-container';
13
- import morphdom from 'morphdom';
14
13
  import { fileURLToPath } from 'url';
15
14
 
15
+
16
16
  const __filename = fileURLToPath(import.meta.url);
17
17
  const __dirname = path.dirname(__filename);
18
18
 
@@ -33,6 +33,12 @@ const argv = yargs(hideBin(process.argv))
33
33
  type: 'number',
34
34
  default: 8080
35
35
  })
36
+ .option('verbose', {
37
+ alias: 'v',
38
+ describe: 'Enable verbose logging',
39
+ type: 'boolean',
40
+ default: false
41
+ })
36
42
  .config('config', 'Path to a JSON config file')
37
43
  .default('config', '.mp-config.json')
38
44
  .demandCommand(1, 'You must provide a markdown file.')
@@ -41,6 +47,41 @@ const argv = yargs(hideBin(process.argv))
41
47
  const markdownFile = argv._[0]
42
48
  const themeDir = argv.themeDir;
43
49
  const port = argv.port;
50
+ const verbose = argv.verbose;
51
+
52
+ async function findPackageJson(startDir) {
53
+ let dir = startDir;
54
+ while (dir !== path.parse(dir).root) {
55
+ const pkgPath = path.join(dir, 'package.json');
56
+ try {
57
+ await fs.access(pkgPath);
58
+ return pkgPath;
59
+ } catch {
60
+ dir = path.dirname(dir);
61
+ }
62
+ }
63
+ return null;
64
+ }
65
+
66
+ // Version reporting block (replace your current version block)
67
+ if (argv.version || argv.v) {
68
+ const __filename = fileURLToPath(import.meta.url);
69
+ const __dirname = dirname(__filename);
70
+ const pkgPath = await findPackageJson(__dirname);
71
+ if (pkgPath) {
72
+ const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf8'));
73
+ console.log(`marp-dev-preview version ${pkg.version}`);
74
+ } else {
75
+ console.error('Could not find package.json for version info.');
76
+ }
77
+ process.exit(0);
78
+ }
79
+
80
+ if (verbose) {
81
+ console.debug = console.log;
82
+ } else {
83
+ console.debug = () => { };
84
+ }
44
85
 
45
86
  if (!markdownFile) {
46
87
  console.error('Error: You must provide a path to a markdown file.');
@@ -183,7 +224,7 @@ const server = http.createServer(async (req, res) => {
183
224
  body += chunk.toString();
184
225
  });
185
226
  req.on('end', async () => {
186
- console.debug("Reload request received");
227
+ console.debug("Reload request received");
187
228
  const success = await reload(body);
188
229
  if (success) {
189
230
  res.writeHead(200, { 'Content-Type': 'application/json' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marp-dev-preview",
3
- "version": "0.1.0",
3
+ "version": "0.1.4",
4
4
  "description": "A CLI tool to preview Marp markdown files.",
5
5
  "main": "marp-dev-preview.mjs",
6
6
  "type": "module",