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 28, 2023
1 parent c09e4b2 commit af71d1d
Show file tree
Hide file tree
Showing 36 changed files with 376 additions and 710 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@ on:
branches: [main]
jobs:
build-and-test:
name: '${{ matrix.platform }}: node.js ${{ matrix.nodejs-version }}'
name: "${{ matrix.platform }}: node.js ${{ matrix.nodejs-version }}"
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
1 change: 0 additions & 1 deletion .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
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package-lock=false
ignore-scripts=true
20 changes: 10 additions & 10 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

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

Examples of unacceptable behavior by participants include:

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

## Our Responsibilities
Expand Down
60 changes: 30 additions & 30 deletions CONTRIBUTING.md → contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ next to their day job: you are not entitled to free customer service.

## Table of Contents

* [Questions](#questions)
* [Contributions](#contributions)
* [Improve documentation](#improve-documentation)
* [Improve issues](#improve-issues)
* [Give feedback on issues](#give-feedback-on-issues)
* [Write code](#write-code)
* [Submitting an issue](#submitting-an-issue)
* [Submitting a pull request](#submitting-a-pull-request)
* [Resources](#resources)
- [Questions](#questions)
- [Contributions](#contributions)
- [Improve documentation](#improve-documentation)
- [Improve issues](#improve-issues)
- [Give feedback on issues](#give-feedback-on-issues)
- [Write code](#write-code)
- [Submitting an issue](#submitting-an-issue)
- [Submitting a pull request](#submitting-a-pull-request)
- [Resources](#resources)

## Questions

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

* [**unified**](https://gitter.im/unifiedjs/Lobby)
- [**unified**](https://gitter.im/unifiedjs/Lobby)
— Topics relating to [**unified**](https://github.com/unifiedjs/unified) in general
* [**vfile**](https://gitter.im/vfile/Lobby)
- [**vfile**](https://gitter.im/vfile/Lobby)
— Topics relating to [**vfile**](https://github.com/vfile): virtual files
* [**syntax-tree**](https://gitter.im/syntax-tree/Lobby)
- [**syntax-tree**](https://gitter.im/syntax-tree/Lobby)
— Topics relating to [**syntax-tree**](https://github.com/syntax-tree) and [**unist**](https://github.com/syntax-tree/unist)
* [**redot**](https://gitter.im/redotjs/Lobby)
- [**redot**](https://gitter.im/redotjs/Lobby)
— Topics relating to the [**redot**](https://github.com/redotjs/redot) ecosystem, graphivz,
and [**dotast**](https://github.com/redotjs/dotast)

Expand Down Expand Up @@ -64,31 +64,31 @@ prevent you from doing unnecessary work.

## Submitting an issue

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

## Submitting a pull request

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

## Resources

* [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
* [Making your first contribution](https://medium.com/@vadimdemedes/making-your-first-contribution-de6576ddb190)
* [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
* [GitHub Help](https://help.github.com)
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
- [Making your first contribution](https://medium.com/@vadimdemedes/making-your-first-contribution-de6576ddb190)
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
- [GitHub Help](https://help.github.com)
7 changes: 0 additions & 7 deletions lerna.json

This file was deleted.

File renamed without changes.
68 changes: 37 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,54 @@
{
"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"
"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 && node --conditions development test/index.js",
"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
26 changes: 26 additions & 0 deletions packages/redot-cli/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node
import {createRequire} from 'node:module'
import {args} from 'unified-args'
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,
});
16 changes: 10 additions & 6 deletions packages/redot-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"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"
"test": "node test.js"
},
"repository": {
"type": "git",
Expand All @@ -34,6 +35,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.2.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
24 changes: 0 additions & 24 deletions packages/redot-cli/redot-cli.js

This file was deleted.

Loading

0 comments on commit af71d1d

Please sign in to comment.