Skip to content

Commit eea5270

Browse files
committed
fix(cli-forge): ensure tui exits properly when user types exit
1 parent df9e9f8 commit eea5270

File tree

6 files changed

+89
-97
lines changed

6 files changed

+89
-97
lines changed

e2e/project.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
"implicitDependencies": ["examples", "parser", "cli-forge"],
44
"targets": {
55
"e2e": {
6-
"dependsOn": ["e2e:*"]
6+
"dependsOn": [
7+
{
8+
"target": "e2e:*",
9+
"projects": "self"
10+
}
11+
]
712
},
813
"e2e:jest": {
914
"command": "jest --config {projectRoot}/jest.config.ts"

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"verdaccio": "catalog:",
3838
"vite": "catalog:",
3939
"vitest": "catalog:",
40+
"why-is-node-running": "catalog:",
4041
"yaml": "catalog:",
4142
"zod": "catalog:"
4243
},
@@ -46,5 +47,5 @@
4647
"dependencies": {
4748
"react-hot-toast": "catalog:"
4849
},
49-
"packageManager": "pnpm@9.15.9+sha512.68046141893c66fad01c079231128e9afb89ef87e2691d69e4d40eee228988295fd4682181bae55b58418c3a253bde65a505ec7c5f9403ece5cc3cd37dcf2531"
50+
"packageManager": "pnpm@10.24.0+sha512.01ff8ae71b4419903b65c60fb2dc9d34cf8bb6e06d03bde112ef38f7a34d6904c424ba66bea5cdcf12890230bf39f9580473140ed9c946fef328b6e5238a345a"
5051
}

packages/cli-forge/cli.js

100644100755
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
require('./dist/bin/cli');
1+
#!/usr/bin/env node
2+
3+
const { default: cli } = require('./dist/bin/cli');
4+
5+
if (require.main === module) {
6+
(async () => {
7+
await cli.forge();
8+
})();
9+
}

packages/cli-forge/src/lib/interactive-shell.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class InteractiveShell {
5454
output: process.stdout,
5555
prompt: prompt,
5656
})
57-
.on('SIGINT', () => {
57+
.once('SIGINT', () => {
5858
process.emit('SIGINT');
5959
});
6060

@@ -81,21 +81,23 @@ export class InteractiveShell {
8181
currentCommand.clone().printHelp();
8282
} else if (nextArgs[0] === 'exit') {
8383
this.close();
84+
return true;
8485
} else if (line.trim()) {
8586
try {
8687
execSync(line, { stdio: 'inherit' });
8788
} catch {
8889
// ignore
8990
}
9091
}
92+
return false;
9193
});
9294
}
9395

94-
registerLineListener(callback: (line: string) => Promise<void>) {
96+
registerLineListener(callback: (line: string) => Promise<boolean | void>) {
9597
const wrapped = async (line: string) => {
9698
this.rl.pause();
97-
await callback(line);
98-
this.rl.prompt();
99+
const shouldHalt = await callback(line);
100+
if (!shouldHalt) this.rl.prompt();
99101
};
100102
this.listeners.push(wrapped);
101103
this.rl.on('line', wrapped);

pnpm-lock.yaml

Lines changed: 15 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 51 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,67 @@
11
packages:
2-
- "packages/*"
3-
- "docs-site"
4-
- "examples"
5-
- "e2e"
6-
- "tools/scripts"
2+
- packages/*
3+
- docs-site
4+
- examples
5+
- e2e
6+
- tools/scripts
77

88
catalog:
9-
# Build tooling
10-
tslib: ^2.3.0
11-
typescript: 5.9.3
12-
13-
# Nx and related
14-
nx: 22.1.3
15-
"@nx/eslint": 22.1.3
16-
"@nx/eslint-plugin": 22.1.3
17-
"@nx/js": 22.1.3
18-
"@nx/vite": 22.1.3
19-
"@nx/web": 22.1.3
20-
"@nx/workspace": 22.1.3
21-
"@nx/devkit": 22.1.3
22-
nx-github-pages: ^1.0.0
23-
24-
# SWC
25-
"@swc-node/register": ~1.11.1
26-
"@swc/core": ~1.15.3
27-
"@swc/helpers": ~0.5.17
28-
29-
# TypeScript/ESLint
30-
"@typescript-eslint/eslint-plugin": ^7.16.0
31-
"@typescript-eslint/parser": ^7.16.0
9+
'@docusaurus/core': 3.9.2
10+
'@docusaurus/module-type-aliases': 3.9.2
11+
'@docusaurus/preset-classic': 3.9.2
12+
'@docusaurus/remark-plugin-npm2yarn': ^3.9.2
13+
'@docusaurus/theme-common': 3.9.2
14+
'@docusaurus/tsconfig': 3.9.2
15+
'@docusaurus/types': 3.9.2
16+
'@mdx-js/react': ^3.1.1
17+
'@nx/devkit': 22.1.3
18+
'@nx/eslint': 22.1.3
19+
'@nx/eslint-plugin': 22.1.3
20+
'@nx/js': 22.1.3
21+
'@nx/vite': 22.1.3
22+
'@nx/web': 22.1.3
23+
'@nx/workspace': 22.1.3
24+
'@swc-node/register': ~1.11.1
25+
'@swc/core': ~1.15.3
26+
'@swc/helpers': ~0.5.17
27+
'@types/jest': ^29.5.12
28+
'@types/node': 18.16.9
29+
'@typescript-eslint/eslint-plugin': ^7.16.0
30+
'@typescript-eslint/parser': ^7.16.0
31+
'@typescript/sandbox': ^0.1.7
32+
'@vitest/coverage-v8': ^1.0.4
33+
'@vitest/ui': ^1.3.1
34+
clsx: ^2.0.0
35+
docusaurus-plugin-sass: ^0.2.5
36+
docusaurus-plugin-typedoc: ^1.0.3
3237
eslint: ~8.57.0
3338
eslint-config-prettier: 10.1.8
34-
35-
# Testing
36-
"@types/jest": ^29.5.12
39+
fast-glob: ^3.3.3
3740
jest: ^29.7.0
38-
ts-jest: ^29.2.5
39-
vitest: ^1.3.1
40-
"@vitest/coverage-v8": ^1.0.4
41-
"@vitest/ui": ^1.3.1
42-
43-
# Vite (5.x required for vitest 1.x compatibility)
44-
vite: ^5.4.0
45-
46-
# React
47-
react: ^19.0.0
48-
react-dom: ^19.0.0
49-
react-hot-toast: ^2.6.0
50-
"@mdx-js/react": ^3.1.1
51-
52-
# Docusaurus
53-
"@docusaurus/core": 3.9.2
54-
"@docusaurus/preset-classic": 3.9.2
55-
"@docusaurus/module-type-aliases": 3.9.2
56-
"@docusaurus/tsconfig": 3.9.2
57-
"@docusaurus/types": 3.9.2
58-
"@docusaurus/remark-plugin-npm2yarn": ^3.9.2
59-
"@docusaurus/theme-common": 3.9.2
60-
docusaurus-plugin-typedoc: ^1.0.3
61-
docusaurus-plugin-sass: ^0.2.5
62-
63-
# Types
64-
"@types/node": 18.16.9
65-
66-
# Utilities
6741
jiti: 2.4.2
6842
lz-string: ^1.5.0
6943
markdown-factory: ^0.2.0
70-
prettier: ^2.6.2
71-
tsx: ^4.19.0
72-
yaml: ^2.5.0
73-
zod: ^4.1.13
74-
clsx: ^2.0.0
75-
fast-glob: ^3.3.3
76-
77-
# TypeScript playground
78-
"@typescript/sandbox": ^0.1.7
79-
80-
# Monaco
8144
monaco-editor: ^0.52.0
8245
monaco-editor-webpack-plugin: ^7.1.0
83-
84-
# Sass
85-
sass: ^1.79.3
86-
87-
# Misc
46+
nx: 22.1.3
47+
nx-github-pages: ^1.0.0
48+
prettier: ^2.6.2
8849
prism-react-renderer: ^2.3.0
50+
react: ^19.0.0
51+
react-dom: ^19.0.0
52+
react-hot-toast: ^2.6.0
8953
remark-github: ^12.0.0
54+
sass: ^1.79.3
55+
style-loader: ^4.0.0
56+
ts-jest: ^29.2.5
57+
tslib: ^2.3.0
58+
tsx: ^4.19.0
9059
typedoc: ^0.28.15
9160
typedoc-plugin-markdown: ^4.9.0
92-
style-loader: ^4.0.0
61+
typescript: 5.9.3
9362
verdaccio: 6.2.3
63+
vite: ^5.4.0
64+
vitest: ^1.3.1
65+
why-is-node-running: ^3.2.2
66+
yaml: ^2.5.0
67+
zod: ^4.1.13

0 commit comments

Comments
 (0)