Skip to content

Commit

Permalink
refactor: replaces commander with native parseArgs (#215)
Browse files Browse the repository at this point in the history
## Description

- replaces commander with native parseArgs
- removes the cli main entry from the `bin` folder to `src` (and to
`dist` after running typestript)

## Motivation and Context

commander is a _great_ command line parser parser. It has been a good
fit for the state-machine-cat cli. `parseArgs`, which is part of
`node:utils`, is suitable for simple cli needs. And simple cli needas
are what state-machine-cat has. Using parseArgs also reduces
state-machine-cat('s cli's) dependencies, which means less to maintain &
worry about.

## How Has This Been Tested?

- [x] automated non-regression tests
- [x] green ci

## Types of changes

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Documentation only change
- [x] Refactor (non-breaking change which fixes an issue without
changing functionality)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)

## Checklist

- [x] 📖

  - My change doesn't require a documentation update, or ...
  - it _does_ and I have updated it

- [x] ⚖️
- The contribution will be subject to [The MIT license](../LICENSE), and
I'm OK with that.
  - The contribution is my own original work.
  - I am ok with the stuff in [**CONTRIBUTING.md**](./CONTRIBUTING.md).
  • Loading branch information
sverweij authored Aug 24, 2024
1 parent 64589f2 commit 6de8681
Show file tree
Hide file tree
Showing 23 changed files with 509 additions and 372 deletions.
4 changes: 2 additions & 2 deletions .c8rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
".mocharc.js",
"**/*.d.ts",
"**/*.d.mts",
"bin/*",
"coverage/**/*",
"dist/**/*",
"doc/**/*",
"docs/**/*",
"public/**/*",
"src/**/*-parser.mjs",
"src/**/*.template.js"
"src/**/*.template.js",
"src/cli/main.mts"
],
"reporter": ["text-summary", "lcov", "html", "json-summary"]
}
9 changes: 4 additions & 5 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
ame: 'CodeQL config'
ame: "CodeQL config"

# See https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs

paths:
- src/
- bin/
- tools/
- docs/sitesrc/
- docs/smcat-online-interpreter.js
- docs/state-machine-cat-inpage.js
- docs/index.html
- docs/inpage.html
paths-ignore:
- '**/*.template.js'
- '**/*-parser.mjs'
- "**/*.template.js"
- "**/*-parser.mjs"
queries:
- uses: security-and-quality
query-filters:
- exclude:
id: js/useless-assignment-to-local
id: js/useless-assignment-to-local
2 changes: 0 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
- main
paths:
- src/
- bin/
- tools/
- docs/sitesrc/
- docs/smcat-online-interpreter.js
Expand All @@ -20,7 +19,6 @@ on:
- main
paths:
- src/
- bin/
- tools/
- docs/sitesrc/
- docs/smcat-online-interpreter.js
Expand Down
5 changes: 0 additions & 5 deletions bin/smcat.mjs

This file was deleted.

4 changes: 2 additions & 2 deletions config/dependency-cruiser/graph.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export default {
options: {
...baseConfig.options,
cache: "node_modules/.cache/dependency-cruiser/graph",
includeOnly: "^(bin|src)/",
includeOnly: "^src/",
reporterOptions: {
archi: {
collapsePattern: "^(bin|src/(cli|transform|[^/]+/[^/]+))",
collapsePattern: "^(src/(cli|transform|[^/]+/[^/]+))",
},
dot: {
theme: {
Expand Down
2 changes: 1 addition & 1 deletion config/dependency-cruiser/lint-staged.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
// This configuration ensures dependency-cruiser will skip these
// rules
{ name: "no-orphans", severity: "ignore" },
{ name: "no-unreachable-from-bin", severity: "ignore" },
{ name: "no-unreachable-from-cli", severity: "ignore" },
{ name: "no-unreachable-from-api", severity: "ignore" },
{ name: "no-uncovered-by-tests", severity: "ignore" },
],
Expand Down
18 changes: 8 additions & 10 deletions config/dependency-cruiser/rules.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export default {
from: {},
to: {
dependencyTypes: ["deprecated"],
pathNot: "node_modules/viz\\.js/viz\\.js$",
},
},
{
Expand All @@ -67,7 +66,6 @@ export default {
to: {
moreThanOneDependencyType: true,
dependencyTypesNot: ["type-only"],
pathNot: "node_modules/viz\\.js/viz\\.js$",
},
},
{
Expand Down Expand Up @@ -106,7 +104,7 @@ export default {
"or when you want to run on the web - which state-machine-cat actually does).",
severity: "error",
from: {
pathNot: "^(bin|src/cli|test|tools)",
pathNot: "^(src/cli|test|tools)",
},
to: {
dependencyTypes: ["core"],
Expand Down Expand Up @@ -158,25 +156,25 @@ export default {
{
name: "no-deps-on-cli",
comment:
"This module, that's neither in bin/ nor in cli/ nor is a test for either, depends on " +
"cli/ and/ or bin/ code. As bin and cli are there to call other modules and not the other " +
"This module, that's not in cli/ nor is a test for it, depends on " +
"cli/ code. As cli is there to call other modules and not the other " +
"way 'round, you're likely putting this module in the wrong spot.",
severity: "error",
from: {
pathNot: "^src/cli|^bin|^test/cli",
pathNot: "^src/cli|^test/cli",
},
to: {
path: "^src/cli|^bin",
path: "^src/cli",
},
},
{
name: "no-unreachable-from-bin",
name: "no-unreachable-from-cli",
comment:
"This module is not reachable from the the command line interface. This means it's likely " +
"'dead wood'. Either remove it, or start using it.",
severity: "error",
from: {
path: "^bin/smcat$",
path: "^src/cli/main.mts$",
},
to: {
path: "^src/",
Expand Down Expand Up @@ -221,7 +219,7 @@ export default {
to: {
path: "^src/",
reachable: false,
pathNot: ["\\.d\\.(c|m)?ts$"],
pathNot: ["\\.d\\.(c|m)?ts$", "^src/cli/main.mts$"],
},
},
{
Expand Down
170 changes: 170 additions & 0 deletions dist/cli/cli.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6de8681

Please sign in to comment.