@tui-sandbox/library 11.6.1 → 11.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/src/scripts/commands/commandRun.d.ts +2 -1
- package/dist/src/scripts/commands/commandRun.js +25 -1
- package/dist/src/scripts/commands/commandRun.js.map +1 -1
- package/dist/src/scripts/tui.js +5 -2
- package/dist/src/scripts/tui.js.map +1 -1
- package/dist/src/server/applications/neovim/api.js +1 -3
- package/dist/src/server/applications/neovim/api.js.map +1 -1
- package/dist/src/server/applications/terminal/api.js +4 -6
- package/dist/src/server/applications/terminal/api.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/scripts/commands/commandRun.ts +35 -2
- package/src/scripts/tui.ts +6 -2
- package/src/server/applications/neovim/api.ts +1 -3
- package/src/server/applications/terminal/api.ts +5 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tui-sandbox/library",
|
|
3
|
-
"version": "11.6.
|
|
3
|
+
"version": "11.6.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/mikavilpas/tui-sandbox"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@xterm/xterm": "5.5.0",
|
|
20
20
|
"concurrently": "9.2.0",
|
|
21
21
|
"cors": "2.8.5",
|
|
22
|
-
"cypress": "14.5.
|
|
22
|
+
"cypress": "14.5.4",
|
|
23
23
|
"dree": "5.1.5",
|
|
24
24
|
"express": "5.1.0",
|
|
25
25
|
"neovim": "5.3.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@types/node": "24.2.0",
|
|
37
37
|
"nodemon": "3.1.10",
|
|
38
38
|
"tsx": "4.20.3",
|
|
39
|
-
"vite": "7.0
|
|
39
|
+
"vite": "7.1.0",
|
|
40
40
|
"vitest": "3.2.4"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import assert from "assert"
|
|
2
|
+
import type { CloseEvent } from "concurrently"
|
|
1
3
|
import concurrently from "concurrently"
|
|
4
|
+
import type { PartialDeep } from "type-fest"
|
|
2
5
|
import { debuglog } from "util"
|
|
6
|
+
import * as z from "zod"
|
|
7
|
+
import type { AllKeys } from "../../server/types.js"
|
|
3
8
|
|
|
4
9
|
const log = debuglog("tui-sandbox.commandRun")
|
|
5
10
|
|
|
6
|
-
export
|
|
11
|
+
export type TestResultExitCode = string | number
|
|
12
|
+
|
|
13
|
+
const cypressName = "cypress"
|
|
14
|
+
export async function commandRun(): Promise<TestResultExitCode> {
|
|
7
15
|
const job = concurrently(
|
|
8
16
|
[
|
|
9
17
|
{
|
|
@@ -12,7 +20,7 @@ export async function commandRun(): Promise<void> {
|
|
|
12
20
|
prefixColor: "blue",
|
|
13
21
|
},
|
|
14
22
|
{
|
|
15
|
-
name:
|
|
23
|
+
name: cypressName,
|
|
16
24
|
command: `'wait-on --timeout 60000 http-get://127.0.0.1:3000/ping && pnpm exec cypress run --config baseUrl=http://127.0.0.1:3000 --quiet'`,
|
|
17
25
|
prefixColor: "yellow",
|
|
18
26
|
},
|
|
@@ -32,4 +40,29 @@ export async function commandRun(): Promise<void> {
|
|
|
32
40
|
log("One or more commands failed. Debug info follows.", err)
|
|
33
41
|
}
|
|
34
42
|
)
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const result = await job.result
|
|
46
|
+
const cypressCommand = result.find(cmd => cmd.command.name === "cypress")
|
|
47
|
+
assert(cypressCommand, "Cypress command not found in the result")
|
|
48
|
+
return cypressCommand.exitCode
|
|
49
|
+
} catch (e) {
|
|
50
|
+
// an array of [`CloseEvent`](#CloseEvent), in the order that the commands terminated.
|
|
51
|
+
// https://github.com/open-cli-tools/concurrently/blob/37212b7d925d8ece22d3afa68a77eef36bb833cc/README.md?plain=1#L125
|
|
52
|
+
const infos = z
|
|
53
|
+
.array(
|
|
54
|
+
z.object({
|
|
55
|
+
command: z.object({
|
|
56
|
+
name: z.string(),
|
|
57
|
+
} satisfies PartialDeep<AllKeys<CloseEvent["command"]>>),
|
|
58
|
+
exitCode: z.number().or(z.string()),
|
|
59
|
+
} satisfies PartialDeep<AllKeys<CloseEvent>>)
|
|
60
|
+
)
|
|
61
|
+
.parse(e)
|
|
62
|
+
|
|
63
|
+
const cypressCommand = infos.find(cmd => cmd.command.name === cypressName)
|
|
64
|
+
assert(cypressCommand, "Cypress command not found in the result")
|
|
65
|
+
|
|
66
|
+
return cypressCommand.exitCode
|
|
67
|
+
}
|
|
35
68
|
}
|
package/src/scripts/tui.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert"
|
|
2
2
|
import path from "node:path"
|
|
3
3
|
import type { TestServerConfig } from "../server/index.js"
|
|
4
|
+
import type { TestResultExitCode } from "./commands/commandRun.js"
|
|
4
5
|
import { commandRun } from "./commands/commandRun.js"
|
|
5
6
|
import { commandTuiNeovimExec } from "./commands/commandTuiNeovimExec.js"
|
|
6
7
|
import { commandTuiNeovimPrepare } from "./commands/commandTuiNeovimPrepare.js"
|
|
@@ -52,8 +53,11 @@ switch (command?.action) {
|
|
|
52
53
|
break
|
|
53
54
|
}
|
|
54
55
|
case "run": {
|
|
55
|
-
await commandRun()
|
|
56
|
-
|
|
56
|
+
const result: TestResultExitCode = await commandRun()
|
|
57
|
+
// important:
|
|
58
|
+
//
|
|
59
|
+
// This is what determines if the test run was successful or not.
|
|
60
|
+
process.exit(result)
|
|
57
61
|
}
|
|
58
62
|
default: {
|
|
59
63
|
command satisfies undefined
|
|
@@ -83,9 +83,7 @@ export async function initializeStdout(
|
|
|
83
83
|
const neovim = neovims.get(tabId) ?? new NeovimApplication(testEnvironmentPath)
|
|
84
84
|
if (neovims.get(tabId) === undefined) {
|
|
85
85
|
neovims.set(tabId, neovim)
|
|
86
|
-
resources.get().
|
|
87
|
-
await n[Symbol.asyncDispose]()
|
|
88
|
-
})
|
|
86
|
+
resources.get().use(neovim)
|
|
89
87
|
}
|
|
90
88
|
|
|
91
89
|
const stdout = convertEventEmitterToAsyncGenerator(neovim.events, "stdout")
|
|
@@ -41,9 +41,7 @@ export async function initializeStdout(
|
|
|
41
41
|
const app = terminals.get(tabId) ?? new TerminalTestApplication(testEnvironmentPath)
|
|
42
42
|
if (terminals.get(tabId) === undefined) {
|
|
43
43
|
terminals.set(tabId, app)
|
|
44
|
-
resources.get().
|
|
45
|
-
await a[Symbol.asyncDispose]()
|
|
46
|
-
})
|
|
44
|
+
resources.get().use(app)
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
const stdout = convertEventEmitterToAsyncGenerator(app.events, "stdout")
|
|
@@ -59,7 +57,7 @@ export async function initializeStdout(
|
|
|
59
57
|
export async function sendStdin(options: { tabId: TabId; data: string }): Promise<void> {
|
|
60
58
|
const tabId = options.tabId.tabId
|
|
61
59
|
const app = terminals.get(tabId)
|
|
62
|
-
assert(app !== undefined, `Terminal instance for
|
|
60
|
+
assert(app !== undefined, `Terminal instance for tabId not found - cannot send stdin. Maybe it's not started yet?`)
|
|
63
61
|
assert(
|
|
64
62
|
app.application,
|
|
65
63
|
`Terminal application not found for client id ${options.tabId.tabId}. Maybe it's not started yet?`
|
|
@@ -75,11 +73,11 @@ export async function runBlockingShellCommand(
|
|
|
75
73
|
): Promise<BlockingShellCommandOutput> {
|
|
76
74
|
const tabId = input.tabId.tabId
|
|
77
75
|
const app = terminals.get(tabId)
|
|
78
|
-
assert(app !== undefined, `Terminal instance for clientId not found - cannot send stdin. Maybe it's not started yet?`)
|
|
79
76
|
assert(
|
|
80
|
-
app
|
|
81
|
-
`Terminal
|
|
77
|
+
app !== undefined,
|
|
78
|
+
`Terminal instance for tabId ${input.tabId.tabId} not found - cannot send stdin. Maybe it's not started yet?`
|
|
82
79
|
)
|
|
80
|
+
assert(app.application, `Terminal application not found for tabId ${input.tabId.tabId}. Maybe it's not started yet?`)
|
|
83
81
|
|
|
84
82
|
const testDirectory = app.state?.testDirectory
|
|
85
83
|
assert(testDirectory, `Test directory not found for client id ${input.tabId.tabId}. Maybe neovim's not started yet?`)
|