Skip to content

Commit cd6b0bf

Browse files
authored
Issue5 single install (#6)
* 🚑 Fixes (#5) * 📝 Updated CI/CD * 📝 Updated README * 🚑 Updated CICD to run internal build first
1 parent 92f4c71 commit cd6b0bf

File tree

10 files changed

+73
-52
lines changed

10 files changed

+73
-52
lines changed

.github/workflows/node.yml

+4-18
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
# need to build library first
3434
- name: Build Lib project
35-
run: npm run build:lib
35+
run: npm run build:libInternal && npm run build:lib
3636

3737
- name: Build CLI project
3838
run: npm run build:cli
@@ -45,34 +45,20 @@ jobs:
4545
with:
4646
name: release-artifact
4747
path: |
48-
packages/cli/dist
4948
packages/lib/dist
49+
dist
5050
package.lock.json
5151
package.json
5252
5353
- name: Publish Library to NPM (dry run)
5454
# Only run if the commit is tagged with release/v<version>
5555
env:
5656
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
57-
run: npm set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN && cd packages/lib && npm publish --dry-run
57+
run: npm set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN && npm publish --dry-run
5858

59-
- name: Publish CLI to NPM (dry run)
60-
# Only run if the commit is tagged with release/v<version>
61-
env:
62-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
63-
run: npm set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN && cd packages/cli && npm publish --dry-run
64-
6559
- name: Publish Library to NPM
6660
# Only run if the commit is tagged with release/v<version>
6761
if: startsWith(github.ref, 'refs/tags/release/v')
6862
env:
6963
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
70-
run: npm set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN && cd packages/lib && npm publish
71-
72-
- name: Publish CLI to NPM
73-
# Only run if the commit is tagged with release/v<version>
74-
if: startsWith(github.ref, 'refs/tags/release/v')
75-
env:
76-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
77-
run: npm set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN && cd packages/cli && npm publish
78-
64+
run: npm set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN && npm publish

README.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,19 @@
22
> mdtable2json is a TypeScript library and CLI tool that allows you to transpile tables in your markdown file to minified JSON. With mdtable2json, you can easily convert your markdown table data into a structured JSON format.
33
44
## Features
5+
- ESModule support
56
- Convert markdown tables to JSON
67
- Command-line interface (CLI) tool for easy conversion
78
- Multiple knobs available for customizing the conversion process. Don't need to minify? No problem! Prefer Array of Structures (AoS) over Structure of Arrays (SoA)? We got you covered!
89

9-
## Installation (CLI)
10+
## Installation (CLI and Library)
1011
```bash
11-
npm install -g mdt2json-cli
12-
```
13-
14-
## Installation (Library)
15-
```bash
16-
npm install mdt2json-ts
12+
npm install -g mdt2json
1713
```
1814

1915
## CLI Usage
2016
```bash
21-
Usage: mdt2json-cli-cli [options]
17+
Usage: mdt2json [options]
2218

2319
Options:
2420
-f, --file <file> file to transpile
@@ -32,7 +28,7 @@ Options:
3228

3329
## Library Usage
3430
```typescript
35-
import { MarkdownTable2Json, JsonLayout } from 'mdt2json-ts';
31+
import { MarkdownTable2Json, JsonLayout } from 'mdt2json';
3632

3733
const markdownString = `your_markdown_string_here`;
3834
const transpiler = new MarkdownTable2Json({markdownString, layout: JsonLayout.AoS , minify: true });

package-lock.json

+15-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+32-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,43 @@
11
{
22
"name": "mdt2json",
3-
"version": "0.1.0",
4-
"description": "Markdown Table to Minified JSON Transpiler",
5-
"main": "index.js",
3+
"version": "0.2.0",
4+
"description": "Configurable Markdown Table to Minified JSON Transpiler",
5+
"main": "./dist/lib/lib.js",
6+
"types": "./dist/lib/lib.d.ts",
7+
"type": "module",
8+
"exports": {
9+
".": {
10+
"types": "./dist/lib/lib.d.ts",
11+
"default": "./dist/lib/lib.js"
12+
},
13+
"./package.json": "./package.json"
14+
},
15+
"bin": {
16+
"mdt2json": "./dist/cli/main.js",
17+
"shebangify": "./shebangify.js"
18+
},
19+
"files": [
20+
"dist"
21+
],
22+
"readme": "README.md",
23+
"keywords": [
24+
"markdown",
25+
"table",
26+
"json",
27+
"transpiler"
28+
],
29+
"repository": {
30+
"type": "git",
31+
"url": "https://github.com/zeon256/mdtable2json"
32+
},
633
"workspaces": [
734
"packages/cli",
835
"packages/lib"
936
],
1037
"scripts": {
11-
"build:cli": "npm run cleanBuild -w packages/cli",
38+
"build:cli": "npm run cleanBuild -w packages/cli && node ./shebangify.cjs ./dist/cli/main.js",
1239
"build:lib": "npm run cleanBuild -w packages/lib",
40+
"build:libInternal": "npm run cleanBuild:internal -w packages/lib",
1341
"test:lib": "npm run test -w packages/lib"
1442
},
1543
"author": "Budi Syahiddin",

packages/cli/package.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
{
22
"name": "mdt2json-cli",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Markdown Table to Minified JSON Transpiler CLI tool",
55
"type": "module",
6-
"main": "./dist/main.js",
7-
"bin": "./dist/main.js",
86
"scripts": {
9-
"cleanBuild": "rm -rf ./dist && tsc && chmod +x ./dist/main.js && ../../shebangify ./dist/main.js"
7+
"cleanBuild": "rm -rf ../../dist/cli && tsc && chmod +x ../../dist/cli/main.js"
108
},
119
"dependencies": {
1210
"commander": "^11.0.0",
13-
"mdt2json-ts": "*"
11+
"mdt2json": "*"
1412
},
1513
"author": "Budi Syahiddin",
1614
"license": "MIT"

packages/cli/src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Command } from "commander";
2-
import { JsonLayout, MarkdownTable2Json } from "mdt2json-ts/dist/lib.js";
2+
import { JsonLayout, MarkdownTable2Json } from "mdt2json-ts";
33
import fs from "fs";
44

55
(() => {

packages/cli/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"rootDir": "src",
77
"moduleResolution": "Node",
88
"declaration": true,
9-
"outDir": "./dist",
9+
"outDir": "../../dist/cli",
1010
"isolatedModules": true,
1111
"esModuleInterop": true,
1212
"forceConsistentCasingInFileNames": true,

packages/lib/package.json

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
{
22
"name": "mdt2json-ts",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Markdown Table to Minified JSON Transpiler",
55
"main": "./dist/lib.js",
6-
"files": ["dist", "src", "tests"],
6+
"private": true,
7+
"files": [
8+
"dist",
9+
"src",
10+
"tests"
11+
],
712
"dist": {
813
"type": "module",
914
"main": "./dist/lib.js",
1015
"module": "./dist/lib.js",
1116
"types": "./dist/lib.d.ts"
1217
},
18+
"types": "./dist/lib.d.ts",
1319
"type": "module",
1420
"scripts": {
15-
"cleanBuild": "rm -rf ./dist && tsc",
21+
"cleanBuild": "rm -rf ../../dist/lib && tsc",
22+
"cleanBuild:internal": "rm -rf ./dist && tsc --outDir ./dist",
1623
"test": "NODE_OPTIONS=--experimental-vm-modules jest --verbose --config jest-unit.config.json"
1724
},
1825
"author": "Budi Syahiddin",
@@ -27,6 +34,7 @@
2734
},
2835
"dependencies": {
2936
"commander": "^11.0.0",
37+
"mdt2json": "^0.2.0",
3038
"remark": "^14.0.3",
3139
"remark-gfm": "^3.0.1",
3240
"remark-parse": "^10.0.2",

packages/lib/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"rootDir": "src",
77
"moduleResolution": "Node",
88
"declaration": true,
9-
"outDir": "./dist",
9+
"outDir": "../../dist/lib",
1010
"isolatedModules": true,
1111
"esModuleInterop": true,
1212
"forceConsistentCasingInFileNames": true,

shebangify shebangify.cjs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env node
21
const fs = require('fs');
32
const path = process.argv[2];
43
let data = "#!/usr/bin/env node\n\n";

0 commit comments

Comments
 (0)