Skip to content

Commit

Permalink
rewrite redot on top of ts-graphviz
Browse files Browse the repository at this point in the history
* replace custom grammar with ts-graphviz
* use jsdoc based typescript
* align with unified toolchain
* upgrade unified version
* add tests
* upgrade CI
  • Loading branch information
ChristianMurphy committed Jul 29, 2023
1 parent c09e4b2 commit 4a160ab
Show file tree
Hide file tree
Showing 39 changed files with 390 additions and 844 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
nodejs-version: [8, 10, 12]
nodejs-version: [16, 18, 20]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
version: ${{ matrix.nodejs-version }}
- name: Build and test
run: |
npm install
npm test
- run: npm install
- run: npm test
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Visual Studio Code - https://code.visualstudio.com/
.settings/
.vscode/
tsconfig.json
jsconfig.json

### Linux ###
Expand Down Expand Up @@ -136,4 +135,4 @@ $RECYCLE.BIN/

package-lock.json
yarn.lock
dot.js
*.d.ts
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore-scripts=true
package-lock=false
73 changes: 0 additions & 73 deletions CODE_OF_CONDUCT.md

This file was deleted.

94 changes: 0 additions & 94 deletions CONTRIBUTING.md

This file was deleted.

7 changes: 0 additions & 7 deletions lerna.json

This file was deleted.

File renamed without changes.
69 changes: 38 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,55 @@
{
"type": "module",
"devDependencies": {
"eslint": "^6.0.0",
"eslint-plugin-node": "^10.0.0",
"husky": "^3.0.0",
"lerna": "^3.0.0",
"lint-staged": "^9.0.0",
"npm-run-all": "^4.1.3",
"prettier-eslint-cli": "^5.0.0",
"remark-cli": "^7.0.0",
"remark-preset-lint-consistent": "^2.0.1",
"remark-preset-lint-recommended": "^3.0.1"
"@types/node": "^20.0.0",
"c8": "^8.0.0",
"prettier": "^3.0.0",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"type-coverage": "^2.0.0",
"typescript": "^5.0.0",
"xo": "^0.55.0"
},
"scripts": {
"precommit": "lint-staged",
"postinstall": "lerna bootstrap --no-ci",
"test": "npm-run-all lint-js lint-md",
"lint-js": "eslint . --ignore-path=.gitignore",
"lint-md": "remark *.md packages/*/*.md --ignore-path .gitignore"
"prepack": "npm run build && npm run format",
"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "npm run test --workspaces",
"test-coverage": "c8 --100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"
},
"lint-staged": {
"*.{js,md}": [
"prettier-eslint --write",
"git add"
]
"workspaces": [
"packages/redot-parse",
"packages/redot-stringify",
"packages/redot",
"packages/redot-cli"
],
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"eslintConfig": {
"plugins": [
"node"
],
"extends": [
"eslint:recommended",
"plugin:node/recommended"
]
"xo": {
"prettier": true
},
"remarkConfig": {
"plugins": [
"preset-lint-recommended",
"preset-lint-consistent",
"remark-preset-wooorm",
[
"remark-lint-list-item-indent",
"remark-lint-no-html",
false
]
]
},
"typeCoverage": {
"atLeast": 100,
"detail": true,
"strict": true,
"ignoreCatch": true
},
"renovate": {
"extends": [
"schedule:weekly",
Expand Down
27 changes: 27 additions & 0 deletions packages/redot-cli/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env node
import {createRequire} from 'node:module'
import {args} from 'unified-args'
// eslint-disable-next-line import/order
import {redot} from 'redot'

const require = createRequire(import.meta.url)

const proc = require('redot/package.json')
const cli = require('./package.json')

const extensions = ['dot', 'gv']

args({
processor: redot,
name: proc.name,
description: cli.description,
version: [
proc.name + ': ' + proc.version,
cli.name + ': ' + cli.version
].join(', '),
pluginPrefix: proc.name,
packageField: proc.name + 'Config',
rcName: '.' + proc.name + 'rc',
ignoreName: '.' + proc.name + 'ignore',
extensions
})
4 changes: 2 additions & 2 deletions packages/redot-parse/NOTICE → packages/redot-cli/license
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)
MIT License

Copyright (c) 2014 Andrei Kashcha
Copyright (c) 2018 Christian Murphy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
21 changes: 11 additions & 10 deletions packages/redot-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
{
"name": "redot-cli",
"version": "0.6.0",
"description": "CLI to process Graphviz dot files with redot using plugins",
"main": "redot-cli.js",
"description": "Command line interface to inspect and change Graphviz dot files with redot",
"type": "module",
"main": "cli.js",
"bin": {
"redot": "redot-cli.js"
"redot": "cli.js"
},
"files": [
"redot-cli.js"
"cli.js"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/redotjs/redot.git"
"test": "node test.js"
},
"repository": "redotjs/redot",
"keywords": [
"graphviz",
"dot",
Expand All @@ -34,6 +32,9 @@
"homepage": "https://github.com/redotjs/redot#readme",
"dependencies": {
"redot": "^0.6.0",
"unified-args": "^7.0.0"
"unified-args": "^10.0.0"
},
"devDependencies": {
"execa": "^7.0.0"
}
}
8 changes: 4 additions & 4 deletions packages/redot-cli/README.md → packages/redot-cli/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ npm install redot-cli

Command-line interface for [**redot**](https://github.com/redotjs/redot).

* Loads `redot-` plugins
* Ignores paths found in [`.redotignore` files](https://github.com/unifiedjs/unified-engine/blob/main/doc/ignore.md)
* Loads configuration from [`.redot`, `.redot.js` files](https://github.com/unifiedjs/unified-engine/blob/main/doc/configure.md)
* Uses configuration from [`redotConfig` fields in `package.json`
- Loads `redot-` plugins
- Ignores paths found in [`.redotignore` files](https://github.com/unifiedjs/unified-engine/blob/main/doc/ignore.md)
- Loads configuration from [`.redot`, `.redot.js` files](https://github.com/unifiedjs/unified-engine/blob/main/doc/configure.md)
- Uses configuration from [`redotConfig` fields in `package.json`
files](https://github.com/unifiedjs/unified-engine/blob/main/doc/configure.md)

## Usage
Expand Down
Loading

0 comments on commit 4a160ab

Please sign in to comment.