@tui-sandbox/library 11.4.0 → 11.4.1
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/browser/neovim-client.js +1 -1
- package/dist/src/browser/neovim-client.js.map +1 -1
- package/dist/src/client/index.d.ts +0 -2
- package/dist/src/client/index.js +0 -2
- package/dist/src/client/index.js.map +1 -1
- package/dist/src/client/terminal-terminal-client.d.ts +0 -1
- package/dist/src/client/terminal-terminal-client.js +0 -1
- package/dist/src/client/terminal-terminal-client.js.map +1 -1
- package/dist/src/scripts/commands/commandTuiNeovimExec.d.ts +2 -0
- package/dist/src/scripts/commands/commandTuiNeovimExec.js +82 -0
- package/dist/src/scripts/commands/commandTuiNeovimExec.js.map +1 -0
- package/dist/src/scripts/commands/commandTuiNeovimPrepare.d.ts +1 -0
- package/dist/src/scripts/commands/commandTuiNeovimPrepare.js +12 -0
- package/dist/src/scripts/commands/commandTuiNeovimPrepare.js.map +1 -0
- package/dist/src/scripts/commands/commandTuiStart.d.ts +1 -0
- package/dist/src/scripts/commands/commandTuiStart.js +30 -0
- package/dist/src/scripts/commands/commandTuiStart.js.map +1 -0
- package/dist/src/scripts/parseArguments.d.ts +7 -4
- package/dist/src/scripts/parseArguments.js +1 -1
- package/dist/src/scripts/parseArguments.js.map +1 -1
- package/dist/src/scripts/tui.d.ts +10 -1
- package/dist/src/scripts/tui.js +10 -113
- package/dist/src/scripts/tui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/browser/neovim-client.ts +1 -1
- package/src/client/index.ts +0 -2
- package/src/client/terminal-terminal-client.ts +0 -1
- package/src/scripts/commands/commandTuiNeovimExec.ts +23 -0
- package/src/scripts/commands/commandTuiNeovimPrepare.ts +16 -0
- package/src/scripts/commands/commandTuiStart.ts +29 -0
- package/src/scripts/parseArguments.ts +15 -8
- package/src/scripts/tui.ts +9 -56
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Terminal } from "@xterm/xterm"
|
|
2
|
-
import {
|
|
2
|
+
import { NeovimTerminalClient } from "../client/neovim-terminal-client.js"
|
|
3
3
|
import type { TuiTerminalApi } from "../client/startTerminal.js"
|
|
4
4
|
import { TerminalTerminalClient } from "../client/terminal-terminal-client.js"
|
|
5
5
|
import type {
|
package/src/client/index.ts
CHANGED
|
@@ -2,5 +2,3 @@
|
|
|
2
2
|
|
|
3
3
|
export { rgbify } from "./color-utilities.js"
|
|
4
4
|
export { textIsVisibleWithBackgroundColor, textIsVisibleWithColor } from "./cypress-assertions.js"
|
|
5
|
-
export { NeovimTerminalClient as TerminalClient } from "./neovim-terminal-client.js"
|
|
6
|
-
export { TerminalTerminalClient } from "./terminal-terminal-client.js"
|
|
@@ -7,7 +7,6 @@ import type { AppRouter } from "../server/server.js"
|
|
|
7
7
|
import type { BlockingShellCommandOutput, TestDirectory } from "../server/types.js"
|
|
8
8
|
import type { TuiTerminalApi } from "./startTerminal.js"
|
|
9
9
|
import { getTabId, startTerminal } from "./startTerminal.js"
|
|
10
|
-
import "./style.css"
|
|
11
10
|
import { supportDA1 } from "./terminal-config.js"
|
|
12
11
|
|
|
13
12
|
/** Manages the terminal state in the browser as well as the (browser's)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NeovimApplication, type StdoutOrStderrMessage } from "../../server/applications/neovim/NeovimApplication.js"
|
|
2
|
+
import { prepareNewTestDirectory } from "../../server/applications/neovim/prepareNewTestDirectory.js"
|
|
3
|
+
import type { NeovimExec } from "../parseArguments.js"
|
|
4
|
+
import { config } from "../tui.js"
|
|
5
|
+
|
|
6
|
+
export async function commandTuiNeovimExec(command: NeovimExec): Promise<void> {
|
|
7
|
+
// automatically dispose of the neovim instance when done
|
|
8
|
+
await using app = new NeovimApplication(config.directories.testEnvironmentPath)
|
|
9
|
+
app.events.on("stdout" satisfies StdoutOrStderrMessage, data => {
|
|
10
|
+
console.log(` neovim output: ${data}`)
|
|
11
|
+
})
|
|
12
|
+
const testDirectory = await prepareNewTestDirectory(config.directories)
|
|
13
|
+
await app.startNextAndKillCurrent(
|
|
14
|
+
testDirectory,
|
|
15
|
+
{
|
|
16
|
+
filename: "empty.txt",
|
|
17
|
+
headlessCmd: command.command,
|
|
18
|
+
NVIM_APPNAME: process.env["NVIM_APPNAME"],
|
|
19
|
+
},
|
|
20
|
+
{ cols: 80, rows: 24 }
|
|
21
|
+
)
|
|
22
|
+
await app.application.untilExit()
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { installDependencies } from "../../server/applications/neovim/api.js"
|
|
2
|
+
import { config } from "../tui.js"
|
|
3
|
+
|
|
4
|
+
export async function commandTuiNeovimPrepare(): Promise<void> {
|
|
5
|
+
const NVIM_APPNAME = process.env["NVIM_APPNAME"]
|
|
6
|
+
console.log(`🚀 Installing neovim dependencies${NVIM_APPNAME ? ` for NVIM_APPNAME=${NVIM_APPNAME}` : ""}...`)
|
|
7
|
+
await installDependencies(
|
|
8
|
+
config.directories.testEnvironmentPath,
|
|
9
|
+
process.env["NVIM_APPNAME"],
|
|
10
|
+
config.directories
|
|
11
|
+
).catch((err: unknown) => {
|
|
12
|
+
console.error("Error installing neovim dependencies", err)
|
|
13
|
+
process.exit(1)
|
|
14
|
+
})
|
|
15
|
+
process.exit(0)
|
|
16
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import path from "path"
|
|
2
|
+
import { createCypressSupportFile } from "../../server/cypress-support/createCypressSupportFile.js"
|
|
3
|
+
import { startTestServer } from "../../server/server.js"
|
|
4
|
+
import { updateTestdirectorySchemaFile } from "../../server/updateTestdirectorySchemaFile.js"
|
|
5
|
+
import { config, cwd } from "../tui.js"
|
|
6
|
+
|
|
7
|
+
export async function commandTuiStart(): Promise<void> {
|
|
8
|
+
try {
|
|
9
|
+
await createCypressSupportFile({
|
|
10
|
+
cypressSupportDirectoryPath: path.join(cwd, "cypress", "support"),
|
|
11
|
+
supportFileName: "tui-sandbox.ts",
|
|
12
|
+
})
|
|
13
|
+
} catch (e) {
|
|
14
|
+
console.error("Failed to createCypressSupportFile", e)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
await updateTestdirectorySchemaFile(config.directories)
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error("Failed to updateTestdirectorySchemaFile", e)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
console.log(`🚀 Starting test server in ${cwd} - this should be the root of your integration-tests directory 🤞🏻`)
|
|
25
|
+
await startTestServer(config)
|
|
26
|
+
} catch (e) {
|
|
27
|
+
console.error("Failed to startTestServer", e)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -14,7 +14,7 @@ export const parseArguments = async (args: string[]): Promise<ParseArgumentsResu
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
{
|
|
17
|
-
// tui neovim exec <command>
|
|
17
|
+
// tui neovim exec <command> <args>
|
|
18
18
|
const schema = z.tuple([z.literal("neovim"), z.literal("exec"), z.string()])
|
|
19
19
|
const execArguments = schema.safeParse(args)
|
|
20
20
|
if (execArguments.success) {
|
|
@@ -39,10 +39,17 @@ export const parseArguments = async (args: string[]): Promise<ParseArgumentsResu
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export type ParseArgumentsResult =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
export type ParseArgumentsResult = NeovimPrepare | NeovimExec | TuiStart
|
|
43
|
+
|
|
44
|
+
export type NeovimExec = {
|
|
45
|
+
action: "neovim exec"
|
|
46
|
+
command: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type NeovimPrepare = {
|
|
50
|
+
action: "neovim prepare"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type TuiStart = {
|
|
54
|
+
action: "start"
|
|
55
|
+
}
|
package/src/scripts/tui.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import path from "node:path"
|
|
2
|
-
import { installDependencies } from "../server/applications/neovim/api.js"
|
|
3
|
-
import type { StdoutOrStderrMessage } from "../server/applications/neovim/NeovimApplication.js"
|
|
4
|
-
import { NeovimApplication } from "../server/applications/neovim/NeovimApplication.js"
|
|
5
|
-
import { prepareNewTestDirectory } from "../server/applications/neovim/prepareNewTestDirectory.js"
|
|
6
|
-
import { createCypressSupportFile } from "../server/cypress-support/createCypressSupportFile.js"
|
|
7
2
|
import type { TestServerConfig } from "../server/index.js"
|
|
8
|
-
import {
|
|
3
|
+
import { commandTuiNeovimExec } from "./commands/commandTuiNeovimExec.js"
|
|
4
|
+
import { commandTuiNeovimPrepare } from "./commands/commandTuiNeovimPrepare.js"
|
|
5
|
+
import { commandTuiStart } from "./commands/commandTuiStart.js"
|
|
9
6
|
import { parseArguments } from "./parseArguments.js"
|
|
10
7
|
|
|
11
8
|
//
|
|
@@ -16,8 +13,8 @@ const outputFileName = "MyTestDirectory.ts"
|
|
|
16
13
|
|
|
17
14
|
/** The cwd in the user's directory when they are running this script. Not the
|
|
18
15
|
* cwd of the script itself. */
|
|
19
|
-
const cwd = process.cwd()
|
|
20
|
-
const config = {
|
|
16
|
+
export const cwd = process.cwd()
|
|
17
|
+
export const config = {
|
|
21
18
|
directories: {
|
|
22
19
|
testEnvironmentPath: path.join(cwd, "test-environment/"),
|
|
23
20
|
outputFilePath: path.join(cwd, outputFileName),
|
|
@@ -32,59 +29,15 @@ const command = await parseArguments(args)
|
|
|
32
29
|
|
|
33
30
|
switch (command?.action) {
|
|
34
31
|
case "neovim prepare": {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
await installDependencies(
|
|
38
|
-
config.directories.testEnvironmentPath,
|
|
39
|
-
process.env["NVIM_APPNAME"],
|
|
40
|
-
config.directories
|
|
41
|
-
).catch((err: unknown) => {
|
|
42
|
-
console.error("Error installing neovim dependencies", err)
|
|
43
|
-
process.exit(1)
|
|
44
|
-
})
|
|
45
|
-
process.exit(0)
|
|
32
|
+
await commandTuiNeovimPrepare()
|
|
33
|
+
break
|
|
46
34
|
}
|
|
47
35
|
case "neovim exec": {
|
|
48
|
-
|
|
49
|
-
await using app = new NeovimApplication(config.directories.testEnvironmentPath)
|
|
50
|
-
app.events.on("stdout" satisfies StdoutOrStderrMessage, data => {
|
|
51
|
-
console.log(` neovim output: ${data}`)
|
|
52
|
-
})
|
|
53
|
-
const testDirectory = await prepareNewTestDirectory(config.directories)
|
|
54
|
-
await app.startNextAndKillCurrent(
|
|
55
|
-
testDirectory,
|
|
56
|
-
{
|
|
57
|
-
filename: "empty.txt",
|
|
58
|
-
headlessCmd: command.command,
|
|
59
|
-
NVIM_APPNAME: process.env["NVIM_APPNAME"],
|
|
60
|
-
},
|
|
61
|
-
{ cols: 80, rows: 24 }
|
|
62
|
-
)
|
|
63
|
-
await app.application.untilExit()
|
|
36
|
+
await commandTuiNeovimExec(command)
|
|
64
37
|
break
|
|
65
38
|
}
|
|
66
39
|
case "start": {
|
|
67
|
-
|
|
68
|
-
await createCypressSupportFile({
|
|
69
|
-
cypressSupportDirectoryPath: path.join(cwd, "cypress", "support"),
|
|
70
|
-
supportFileName: "tui-sandbox.ts",
|
|
71
|
-
})
|
|
72
|
-
} catch (e) {
|
|
73
|
-
console.error("Failed to createCypressSupportFile", e)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
await updateTestdirectorySchemaFile(config.directories)
|
|
78
|
-
} catch (e) {
|
|
79
|
-
console.error("Failed to updateTestdirectorySchemaFile", e)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
try {
|
|
83
|
-
console.log(`🚀 Starting test server in ${cwd} - this should be the root of your integration-tests directory 🤞🏻`)
|
|
84
|
-
await startTestServer(config)
|
|
85
|
-
} catch (e) {
|
|
86
|
-
console.error("Failed to startTestServer", e)
|
|
87
|
-
}
|
|
40
|
+
await commandTuiStart()
|
|
88
41
|
break
|
|
89
42
|
}
|
|
90
43
|
default: {
|