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

rewrite redot on top of ts-graphviz #25

Open
wants to merge 1 commit into
base: main
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
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'
Comment on lines +3 to +5

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn’t this work?

Suggested change
import {args} from 'unified-args'
// eslint-disable-next-line import/order
import {redot} from 'redot'
import {redot} from 'redot'
import {args} from 'unified-args'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root of the issue is the newline between the import and require

With the original code or with your patch, the error is:

  ✖  4:1  There should be no empty line between import groups  import/order

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this ESLint rule just isn’t very good, so I don’t worry about it


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn’t we keep the original license instead? It’s ok to rename it though. Maybe the original license should be copied to all packages as well. I’m not sure who made what.

Copy link
Member Author

@ChristianMurphy ChristianMurphy Jul 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff is a bit misleading, the original file wasn't a license, it was a notice.
The redot-parse previously embedded a peg parser written by Andrei, but not published to npm.
To meet the terms of MIT, this notice file was added to the project.
Andrei did not create redot project nor actively contributed to the project.
With the peg file removed there is no reason to keep the notice for the peg file.


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