Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build as proper NPM module #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules
dist
lib

data/symbols/kicad
data/symbols/custom/*.json
Expand All @@ -9,4 +11,4 @@ data/pcb/custom/*.json
data/module
data/module/custom/*.json

.DS_Store
.DS_Store
35 changes: 0 additions & 35 deletions cli/args.js

This file was deleted.

8 changes: 0 additions & 8 deletions cli/index.js

This file was deleted.

33 changes: 0 additions & 33 deletions index.js

This file was deleted.

21 changes: 0 additions & 21 deletions index.ts

This file was deleted.

117 changes: 65 additions & 52 deletions package.json
dominics marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,54 +1,67 @@
{
"name": "kicad-to-json",
"version": "1.3.0",
"main": "index.js",
"author": "Jason Thorpe",
"keywords": [
"kicad",
"json",
"yaml"
],
"repository": {
"type": "git",
"url": "git+https://github.com/jdthorpe/kicad-module-parser.git"
},
"license": "MIT",
"scripts": {
"build": "yarn build:module && yarn build:symbol && yarn build:package",
"build:module": "npx pegjs -o src/module-parser.js --allowed-start-rules module,board ./src/module.pegjs",
"build:symbol": "npx pegjs -o src/symbol-parser.js --allowed-start-rules kicad_symbol_lib ./src/symbol.pegjs",
"build:package": "tsc",
"build:tests": "tsc -p ./test",
"watch": "npx nodemon",
"test": "yarn build:tests && node test/",
"test:symbols": "yarn build:tests && node test/symbol-test.ts",
"test:modules": "yarn build:tests && node test/module-test.ts",
"test:boards": "yarn build:tests && node test/board-test.ts"
},
"devDependencies": {
"@types/argparse": "^2.0.10",
"@types/fs-extra": "^9.0.1",
"@types/js-yaml": "^4.0.2",
"@types/klaw": "^3.0.1",
"@types/through2": "^2.0.36",
"pegjs": "^0.10.0",
"prettier": "^3.2.5",
"prettier-plugin-pegjs": "^2.0.2",
"typescript": "^4.3.5"
},
"dependencies": {
"ajv": "^8.6.2",
"argparse": "^2.0.1",
"chalk": "^4.1.2",
"fs-extra": "^9.0.1",
"js-yaml": "^4.1.0",
"klaw": "^3.0.0",
"through2": "^4.0.2"
},
"bin": {
"k2j": "./bin/k2j"
},
"prettier": {
"plugins": ["prettier-plugin-pegjs"]
}
"name": "kicad-to-json",
"version": "1.3.0",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
dominics marked this conversation as resolved.
Show resolved Hide resolved
"author": "Jason Thorpe",
"keywords": [
"kicad",
"json",
"yaml"
],
"repository": {
"type": "git",
"url": "git+https://github.com/jdthorpe/kicad-module-parser.git"
},
"license": "MIT",
"scripts": {
"build": "run-s build:module build:symbol build:package",
"build:module": "npx pegjs -o src/module-parser.js --allowed-start-rules module,board ./src/module.pegjs",
"build:symbol": "npx pegjs -o src/symbol-parser.js --allowed-start-rules kicad_symbol_lib ./src/symbol.pegjs",
"build:package": "tsup",
dominics marked this conversation as resolved.
Show resolved Hide resolved
"check": "tsc -b -noEmit",
"clean": "rm -rf lib dist",
"watch": "run-p watch:package watch:test",
"watch:package": "tsup --watch",
"watch:test": "tsx watch --clear-screen=false ./test/index.ts",
"test": "tsx test/index.ts",
"test:symbols": "tsx test/symbol-test.ts",
"test:modules": "tsx test/module-test.ts",
"test:boards": "tsx test/board-test.ts"
},
"devDependencies": {
"@types/argparse": "^2.0.10",
"@types/fs-extra": "^9.0.1",
"@types/js-yaml": "^4.0.2",
"@types/klaw": "^3.0.1",
"@types/through2": "^2.0.36",
"npm-run-all": "4.1.5",
"pegjs": "^0.10.0",
"prettier": "^3.2.5",
"prettier-plugin-pegjs": "^2.0.2",
"tsup": "8.0.2",
"tsx": "4.19.1",
"typescript": "5.6.2"
},
"dependencies": {
"ajv": "^8.6.2",
"argparse": "^2.0.1",
"chalk": "^4.1.2",
"fs-extra": "^9.0.1",
"js-yaml": "^4.1.0",
"klaw": "^3.0.0",
"through2": "^4.0.2"
},
"bin": {
"k2j": "./bin/k2j"
},
"prettier": {
"plugins": [
"prettier-plugin-pegjs"
]
}
}
25 changes: 25 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// <reference path="types.d.ts"/>
export * from "./types";
import * as parsers from "./parse";

export const parse = {
module: (
x: string,
format: "compact" | "long" | "bare" = "compact",
options: any = {},
) => parsers.parseModule(x, format, { startRule: "module", ...options }),
board: (
x: string,
format: "compact" | "long" | "bare" = "compact",
options: any = {},
) => parsers.parseModule(x, format, { startRule: "board", ...options }),
symbol: (
x: string,
format: "compact" | "long" | "bare" = "compact",
options: any = {},
) =>
parsers.parseSymbolVerbose(x, format, {
startRule: "kicad_symbol_lib",
...options,
}),
};
2 changes: 1 addition & 1 deletion src/module-parser.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import { n_container } from "../types";
import { n_container } from "./types";
export function parse(x: string, options?: any): n_container;
54 changes: 0 additions & 54 deletions src/parse.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { parse as _parseModule } from "./module-parser";
import { parse as _parseSymbol } from "./symbol-parser";

import { post_process } from "./utils";
import { n_container } from "../types";
import { n_container } from "./types";
import chalk from "chalk";
interface options {
startRule: "module" | "board";
Expand Down
41 changes: 0 additions & 41 deletions src/process-file.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/symbol-parser.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import { n_container } from "../types";
import { n_container } from "./types";
export function parse(x: string, options?: any): n_container;
File renamed without changes.
Loading