Skip to content

Commit ea08857

Browse files
rewrite redot on top of ts-graphviz
* replace custom grammar with ts-graphviz * use jsdoc based typescript * align with unified toolchain * upgrade unified version * add tests * upgrade CI
1 parent c09e4b2 commit ea08857

36 files changed

+377
-710
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,16 @@ on:
66
branches: [main]
77
jobs:
88
build-and-test:
9-
name: '${{ matrix.platform }}: node.js ${{ matrix.nodejs-version }}'
9+
name: "${{ matrix.platform }}: node.js ${{ matrix.nodejs-version }}"
1010
strategy:
1111
matrix:
1212
platform: [ubuntu-latest, windows-latest, macos-latest]
13-
nodejs-version: [8, 10, 12]
13+
nodejs-version: [16, 18, 20]
1414
runs-on: ${{ matrix.platform }}
1515
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v2
18-
- name: Set up Node.js
19-
uses: actions/setup-node@v2
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
2018
with:
2119
version: ${{ matrix.nodejs-version }}
22-
- name: Build and test
23-
run: |
24-
npm install
25-
npm test
20+
- run: npm install
21+
- run: npm test

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# Visual Studio Code - https://code.visualstudio.com/
55
.settings/
66
.vscode/
7-
tsconfig.json
87
jsconfig.json
98

109
### Linux ###

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package-lock=false
2+
ignore-scripts=true

CODE_OF_CONDUCT.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ religion, or sexual identity and orientation.
1414
Examples of behavior that contributes to creating a positive environment
1515
include:
1616

17-
* Using welcoming and inclusive language
18-
* Being respectful of differing viewpoints and experiences
19-
* Gracefully accepting constructive criticism
20-
* Focusing on what is best for the community
21-
* Showing empathy towards other community members
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
2222

2323
Examples of unacceptable behavior by participants include:
2424

25-
* The use of sexualized language or imagery and unwelcome sexual attention or
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
2626
advances
27-
* Trolling, insulting/derogatory comments, and personal or political attacks
28-
* Public or private harassment
29-
* Publishing others' private information, such as a physical or electronic
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
3030
address, without explicit permission
31-
* Other conduct which could reasonably be considered inappropriate in a
31+
- Other conduct which could reasonably be considered inappropriate in a
3232
professional setting
3333

3434
## Our Responsibilities

CONTRIBUTING.md renamed to contributing.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@ next to their day job: you are not entitled to free customer service.
1212

1313
## Table of Contents
1414

15-
* [Questions](#questions)
16-
* [Contributions](#contributions)
17-
* [Improve documentation](#improve-documentation)
18-
* [Improve issues](#improve-issues)
19-
* [Give feedback on issues](#give-feedback-on-issues)
20-
* [Write code](#write-code)
21-
* [Submitting an issue](#submitting-an-issue)
22-
* [Submitting a pull request](#submitting-a-pull-request)
23-
* [Resources](#resources)
15+
- [Questions](#questions)
16+
- [Contributions](#contributions)
17+
- [Improve documentation](#improve-documentation)
18+
- [Improve issues](#improve-issues)
19+
- [Give feedback on issues](#give-feedback-on-issues)
20+
- [Write code](#write-code)
21+
- [Submitting an issue](#submitting-an-issue)
22+
- [Submitting a pull request](#submitting-a-pull-request)
23+
- [Resources](#resources)
2424

2525
## Questions
2626

2727
Please chat and ask questions on Gitter! Jump in there and lurk, talk to us,
2828
and help others.
2929

30-
* [**unified**](https://gitter.im/unifiedjs/Lobby)
30+
- [**unified**](https://gitter.im/unifiedjs/Lobby)
3131
— Topics relating to [**unified**](https://github.com/unifiedjs/unified) in general
32-
* [**vfile**](https://gitter.im/vfile/Lobby)
32+
- [**vfile**](https://gitter.im/vfile/Lobby)
3333
— Topics relating to [**vfile**](https://github.com/vfile): virtual files
34-
* [**syntax-tree**](https://gitter.im/syntax-tree/Lobby)
34+
- [**syntax-tree**](https://gitter.im/syntax-tree/Lobby)
3535
— Topics relating to [**syntax-tree**](https://github.com/syntax-tree) and [**unist**](https://github.com/syntax-tree/unist)
36-
* [**redot**](https://gitter.im/redotjs/Lobby)
36+
- [**redot**](https://gitter.im/redotjs/Lobby)
3737
— Topics relating to the [**redot**](https://github.com/redotjs/redot) ecosystem, graphivz,
3838
and [**dotast**](https://github.com/redotjs/dotast)
3939

@@ -64,31 +64,31 @@ prevent you from doing unnecessary work.
6464

6565
## Submitting an issue
6666

67-
* The issue tracker is for issues. Use chat for support
68-
* Search the issue tracker (including closed issues) before opening a new
67+
- The issue tracker is for issues. Use chat for support
68+
- Search the issue tracker (including closed issues) before opening a new
6969
issue
70-
* Ensure you’re using the latest version of projects
71-
* Use a clear and descriptive title
72-
* Include as much information as possible: steps to reproduce the issue,
70+
- Ensure you’re using the latest version of projects
71+
- Use a clear and descriptive title
72+
- Include as much information as possible: steps to reproduce the issue,
7373
error message, version, operating system, etcetera
74-
* The more time you put into an issue, the more we will
75-
* The best issue report is a [failing test](https://twitter.com/sindresorhus/status/579306280495357953) proving it
74+
- The more time you put into an issue, the more we will
75+
- The best issue report is a [failing test](https://twitter.com/sindresorhus/status/579306280495357953) proving it
7676

7777
## Submitting a pull request
7878

79-
* Non-trivial changes are often best discussed in an issue first, to prevent
79+
- Non-trivial changes are often best discussed in an issue first, to prevent
8080
you from doing unnecessary work
81-
* For ambitious tasks, you should try to get your work in front of the
81+
- For ambitious tasks, you should try to get your work in front of the
8282
community for feedback as soon as possible
83-
* New features should be accompanied with tests and documentation
84-
* Don’t include unrelated changes
85-
* Lint and test before submitting code by running `$ npm test`
86-
* Write a convincing description of why we should land your pull request:
83+
- New features should be accompanied with tests and documentation
84+
- Don’t include unrelated changes
85+
- Lint and test before submitting code by running `$ npm test`
86+
- Write a convincing description of why we should land your pull request:
8787
it’s your job to convince us
8888

8989
## Resources
9090

91-
* [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
92-
* [Making your first contribution](https://medium.com/@vadimdemedes/making-your-first-contribution-de6576ddb190)
93-
* [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
94-
* [GitHub Help](https://help.github.com)
91+
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
92+
- [Making your first contribution](https://medium.com/@vadimdemedes/making-your-first-contribution-de6576ddb190)
93+
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
94+
- [GitHub Help](https://help.github.com)

lerna.json

Lines changed: 0 additions & 7 deletions
This file was deleted.
File renamed without changes.

package.json

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,55 @@
11
{
2+
"type": "module",
23
"devDependencies": {
3-
"eslint": "^6.0.0",
4-
"eslint-plugin-node": "^10.0.0",
5-
"husky": "^3.0.0",
6-
"lerna": "^3.0.0",
7-
"lint-staged": "^9.0.0",
8-
"npm-run-all": "^4.1.3",
9-
"prettier-eslint-cli": "^5.0.0",
10-
"remark-cli": "^7.0.0",
11-
"remark-preset-lint-consistent": "^2.0.1",
12-
"remark-preset-lint-recommended": "^3.0.1"
4+
"@types/node": "^20.0.0",
5+
"c8": "^8.0.0",
6+
"prettier": "^3.0.0",
7+
"remark-cli": "^11.0.0",
8+
"remark-preset-wooorm": "^9.0.0",
9+
"type-coverage": "^2.0.0",
10+
"typescript": "^5.0.0",
11+
"xo": "^0.55.0"
1312
},
1413
"scripts": {
15-
"precommit": "lint-staged",
16-
"postinstall": "lerna bootstrap --no-ci",
17-
"test": "npm-run-all lint-js lint-md",
18-
"lint-js": "eslint . --ignore-path=.gitignore",
19-
"lint-md": "remark *.md packages/*/*.md --ignore-path .gitignore"
14+
"prepack": "npm run build && npm run format",
15+
"build": "tsc --build --clean && tsc --build && type-coverage",
16+
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
17+
"test-api": "npm run test --workspaces && node --conditions development test/index.js",
18+
"test-coverage": "c8 --100 --reporter lcov npm run test-api",
19+
"test": "npm run build && npm run format && npm run test-coverage"
2020
},
21-
"lint-staged": {
22-
"*.{js,md}": [
23-
"prettier-eslint --write",
24-
"git add"
25-
]
21+
"workspaces": [
22+
"packages/redot-parse",
23+
"packages/redot-stringify",
24+
"packages/redot",
25+
"packages/redot-cli"
26+
],
27+
"prettier": {
28+
"tabWidth": 2,
29+
"useTabs": false,
30+
"singleQuote": true,
31+
"bracketSpacing": false,
32+
"semi": false,
33+
"trailingComma": "none"
2634
},
27-
"eslintConfig": {
28-
"plugins": [
29-
"node"
30-
],
31-
"extends": [
32-
"eslint:recommended",
33-
"plugin:node/recommended"
34-
]
35+
"xo": {
36+
"prettier": true
3537
},
3638
"remarkConfig": {
3739
"plugins": [
38-
"preset-lint-recommended",
39-
"preset-lint-consistent",
40+
"remark-preset-wooorm",
4041
[
41-
"remark-lint-list-item-indent",
42+
"remark-lint-no-html",
4243
false
4344
]
4445
]
4546
},
47+
"typeCoverage": {
48+
"atLeast": 100,
49+
"detail": true,
50+
"strict": true,
51+
"ignoreCatch": true
52+
},
4653
"renovate": {
4754
"extends": [
4855
"schedule:weekly",

packages/redot-cli/cli.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env node
2+
import {createRequire} from 'node:module'
3+
import {args} from 'unified-args'
4+
import {redot} from 'redot'
5+
6+
const require = createRequire(import.meta.url)
7+
8+
const proc = require('redot/package.json')
9+
const cli = require('./package.json')
10+
11+
const extensions = ['dot', 'gv'];
12+
13+
args({
14+
processor: redot,
15+
name: proc.name,
16+
description: cli.description,
17+
version: [
18+
proc.name + ': ' + proc.version,
19+
cli.name + ': ' + cli.version,
20+
].join(', '),
21+
pluginPrefix: proc.name,
22+
packageField: proc.name + 'Config',
23+
rcName: '.' + proc.name + 'rc',
24+
ignoreName: '.' + proc.name + 'ignore',
25+
extensions,
26+
});

packages/redot-cli/package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
22
"name": "redot-cli",
33
"version": "0.6.0",
4-
"description": "CLI to process Graphviz dot files with redot using plugins",
5-
"main": "redot-cli.js",
4+
"description": "Command line interface to inspect and change Graphviz dot files with redot",
5+
"type": "module",
6+
"main": "cli.js",
67
"bin": {
7-
"redot": "redot-cli.js"
8+
"redot": "cli.js"
89
},
910
"files": [
10-
"redot-cli.js"
11+
"cli.js"
1112
],
1213
"scripts": {
13-
"test": "echo \"Error: no test specified\" && exit 1"
14+
"test": "node test.js"
1415
},
1516
"repository": {
1617
"type": "git",
@@ -34,6 +35,9 @@
3435
"homepage": "https://github.com/redotjs/redot#readme",
3536
"dependencies": {
3637
"redot": "^0.6.0",
37-
"unified-args": "^7.0.0"
38+
"unified-args": "^10.0.0"
39+
},
40+
"devDependencies": {
41+
"execa": "^7.2.0"
3842
}
3943
}

0 commit comments

Comments
 (0)