@rokelamen/md2html 0.1.1 → 0.1.2

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/dist/index.js CHANGED
@@ -1,50 +1,7 @@
1
- #!/usr/bin/env node
2
- import { program } from 'commander';
3
- import * as fs from 'fs';
4
1
  /* The main parse logic */
5
2
  function parse(content) {
6
- const transform = content.trim();
7
- return `<p>${transform}</p>`;
3
+ const source = content.trim();
4
+ return `<p>${source}</p>`;
8
5
  }
9
- // Import these from package.json in the future
10
- const name = 'md2html';
11
- const version = '0.1.1';
12
- const description = 'A simple tool to convert markdown content to html';
13
- /* Command-line tool logic */
14
- function command() {
15
- /* Set basic info */
16
- program
17
- .name(name)
18
- .version(version)
19
- .description(description);
20
- /* Config arguments info */
21
- program
22
- .option('-f, --file <path>', 'source file path')
23
- .argument('[input]', 'input content');
24
- /* Parse the cli options */
25
- program.parse(process.argv);
26
- /* Validation check */
27
- const options = program.opts();
28
- const input = program.args[0];
29
- const hasFile = typeof options.file === 'string';
30
- const hasInput = typeof input === 'string';
31
- // XOR validation
32
- if (hasFile === hasInput) {
33
- console.error('error: exactly one content source must be provided (either <input> or -f, --file).');
34
- process.exit(1);
35
- }
36
- /* Define one-source content */
37
- const content = hasFile
38
- ? (() => {
39
- try {
40
- return fs.readFileSync(options.file, 'utf-8');
41
- }
42
- catch {
43
- console.error(`error: failed to read file "${options.file}"`);
44
- process.exit(1);
45
- }
46
- })()
47
- : input;
48
- console.log(parse(content));
49
- }
50
- command();
6
+
7
+ export { parse };
package/package.json CHANGED
@@ -1,20 +1,28 @@
1
1
  {
2
2
  "name": "@rokelamen/md2html",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "description": "A simple tool to convert markdown content to html",
6
6
  "author": "rokelamen <rogerskelamen@gmail.com>",
7
7
  "license": "MIT",
8
- "main": "dist/index.js",
8
+ "main": "./dist/index.js",
9
9
  "bin": {
10
- "md2html": "./dist/index.js"
10
+ "md2html": "./bin/cli.cjs"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ }
11
17
  },
12
18
  "scripts": {
13
- "clean": "rimraf dist",
14
- "build": "npm run clean && tsc",
19
+ "clean": "rimraf bin dist",
20
+ "build": "npm run clean && rollup -c rollup.config.ts --configPlugin typescript",
21
+ "test": "node bin/cli.cjs",
15
22
  "prepublishOnly": "npm run build"
16
23
  },
17
24
  "files": [
25
+ "bin",
18
26
  "dist"
19
27
  ],
20
28
  "keywords": [
@@ -23,12 +31,15 @@
23
31
  "md2html"
24
32
  ],
25
33
  "devDependencies": {
34
+ "@rollup/plugin-commonjs": "^29.0.0",
35
+ "@rollup/plugin-node-resolve": "^16.0.3",
36
+ "@rollup/plugin-typescript": "^12.3.0",
26
37
  "@types/commander": "^2.12.0",
27
38
  "@types/node": "^25.0.3",
39
+ "commander": "^14.0.2",
28
40
  "rimraf": "^6.1.2",
41
+ "rollup": "^4.54.0",
42
+ "tslib": "^2.8.1",
29
43
  "typescript": "^5.9.3"
30
- },
31
- "dependencies": {
32
- "commander": "^14.0.2"
33
44
  }
34
45
  }