Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6de8681

Browse files
authoredAug 24, 2024··
refactor: replaces commander with native parseArgs (#215)
## 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).
1 parent 64589f2 commit 6de8681

23 files changed

+509
-372
lines changed
 

‎.c8rc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
".mocharc.js",
1212
"**/*.d.ts",
1313
"**/*.d.mts",
14-
"bin/*",
1514
"coverage/**/*",
1615
"dist/**/*",
1716
"doc/**/*",
1817
"docs/**/*",
1918
"public/**/*",
2019
"src/**/*-parser.mjs",
21-
"src/**/*.template.js"
20+
"src/**/*.template.js",
21+
"src/cli/main.mts"
2222
],
2323
"reporter": ["text-summary", "lcov", "html", "json-summary"]
2424
}

‎.github/codeql/codeql-config.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
ame: 'CodeQL config'
1+
ame: "CodeQL config"
22

33
# 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
44

55
paths:
66
- src/
7-
- bin/
87
- tools/
98
- docs/sitesrc/
109
- docs/smcat-online-interpreter.js
1110
- docs/state-machine-cat-inpage.js
1211
- docs/index.html
1312
- docs/inpage.html
1413
paths-ignore:
15-
- '**/*.template.js'
16-
- '**/*-parser.mjs'
14+
- "**/*.template.js"
15+
- "**/*-parser.mjs"
1716
queries:
1817
- uses: security-and-quality
1918
query-filters:
2019
- exclude:
21-
id: js/useless-assignment-to-local
20+
id: js/useless-assignment-to-local

‎.github/workflows/codeql-analysis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88
- main
99
paths:
1010
- src/
11-
- bin/
1211
- tools/
1312
- docs/sitesrc/
1413
- docs/smcat-online-interpreter.js
@@ -20,7 +19,6 @@ on:
2019
- main
2120
paths:
2221
- src/
23-
- bin/
2422
- tools/
2523
- docs/sitesrc/
2624
- docs/smcat-online-interpreter.js

‎bin/smcat.mjs

-5
This file was deleted.

‎config/dependency-cruiser/graph.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ export default {
66
options: {
77
...baseConfig.options,
88
cache: "node_modules/.cache/dependency-cruiser/graph",
9-
includeOnly: "^(bin|src)/",
9+
includeOnly: "^src/",
1010
reporterOptions: {
1111
archi: {
12-
collapsePattern: "^(bin|src/(cli|transform|[^/]+/[^/]+))",
12+
collapsePattern: "^(src/(cli|transform|[^/]+/[^/]+))",
1313
},
1414
dot: {
1515
theme: {

‎config/dependency-cruiser/lint-staged.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
// This configuration ensures dependency-cruiser will skip these
88
// rules
99
{ name: "no-orphans", severity: "ignore" },
10-
{ name: "no-unreachable-from-bin", severity: "ignore" },
10+
{ name: "no-unreachable-from-cli", severity: "ignore" },
1111
{ name: "no-unreachable-from-api", severity: "ignore" },
1212
{ name: "no-uncovered-by-tests", severity: "ignore" },
1313
],

‎config/dependency-cruiser/rules.mjs

+8-10
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export default {
5858
from: {},
5959
to: {
6060
dependencyTypes: ["deprecated"],
61-
pathNot: "node_modules/viz\\.js/viz\\.js$",
6261
},
6362
},
6463
{
@@ -67,7 +66,6 @@ export default {
6766
to: {
6867
moreThanOneDependencyType: true,
6968
dependencyTypesNot: ["type-only"],
70-
pathNot: "node_modules/viz\\.js/viz\\.js$",
7169
},
7270
},
7371
{
@@ -106,7 +104,7 @@ export default {
106104
"or when you want to run on the web - which state-machine-cat actually does).",
107105
severity: "error",
108106
from: {
109-
pathNot: "^(bin|src/cli|test|tools)",
107+
pathNot: "^(src/cli|test|tools)",
110108
},
111109
to: {
112110
dependencyTypes: ["core"],
@@ -158,25 +156,25 @@ export default {
158156
{
159157
name: "no-deps-on-cli",
160158
comment:
161-
"This module, that's neither in bin/ nor in cli/ nor is a test for either, depends on " +
162-
"cli/ and/ or bin/ code. As bin and cli are there to call other modules and not the other " +
159+
"This module, that's not in cli/ nor is a test for it, depends on " +
160+
"cli/ code. As cli is there to call other modules and not the other " +
163161
"way 'round, you're likely putting this module in the wrong spot.",
164162
severity: "error",
165163
from: {
166-
pathNot: "^src/cli|^bin|^test/cli",
164+
pathNot: "^src/cli|^test/cli",
167165
},
168166
to: {
169-
path: "^src/cli|^bin",
167+
path: "^src/cli",
170168
},
171169
},
172170
{
173-
name: "no-unreachable-from-bin",
171+
name: "no-unreachable-from-cli",
174172
comment:
175173
"This module is not reachable from the the command line interface. This means it's likely " +
176174
"'dead wood'. Either remove it, or start using it.",
177175
severity: "error",
178176
from: {
179-
path: "^bin/smcat$",
177+
path: "^src/cli/main.mts$",
180178
},
181179
to: {
182180
path: "^src/",
@@ -221,7 +219,7 @@ export default {
221219
to: {
222220
path: "^src/",
223221
reachable: false,
224-
pathNot: ["\\.d\\.(c|m)?ts$"],
222+
pathNot: ["\\.d\\.(c|m)?ts$", "^src/cli/main.mts$"],
225223
},
226224
},
227225
{

‎dist/cli/cli.mjs

+170
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Please sign in to comment.