@tui-sandbox/library 11.8.6 → 11.9.0
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/commandTuiNeovimExec.d.ts +2 -2
- package/dist/src/scripts/commands/commandTuiNeovimExec.js +10 -3
- package/dist/src/scripts/commands/commandTuiNeovimExec.js.map +1 -1
- package/dist/src/scripts/commands/commandTuiNeovimPrepare.d.ts +2 -2
- package/dist/src/scripts/commands/commandTuiNeovimPrepare.js +1 -1
- package/dist/src/scripts/commands/commandTuiNeovimPrepare.js.map +1 -1
- package/dist/src/scripts/commands/commandTuiStart.d.ts +2 -2
- package/dist/src/scripts/commands/commandTuiStart.js +2 -2
- package/dist/src/scripts/commands/commandTuiStart.js.map +1 -1
- package/dist/src/scripts/parseArguments.js +0 -4
- package/dist/src/scripts/parseArguments.js.map +1 -1
- package/dist/src/scripts/resolveConfig.test.js +6 -3
- package/dist/src/scripts/resolveConfig.test.js.map +1 -1
- package/dist/src/scripts/resolveTuiConfig.d.ts +2 -2
- package/dist/src/scripts/resolveTuiConfig.js +8 -2
- package/dist/src/scripts/resolveTuiConfig.js.map +1 -1
- package/dist/src/scripts/tui.js.map +1 -1
- package/dist/src/server/applications/neovim/NeovimApplication.js +1 -1
- package/dist/src/server/applications/neovim/NeovimApplication.js.map +1 -1
- package/dist/src/server/applications/terminal/TerminalTestApplication.js +1 -1
- package/dist/src/server/applications/terminal/TerminalTestApplication.js.map +1 -1
- package/dist/src/server/applications/terminal/runBlockingShellCommand.js +1 -1
- package/dist/src/server/applications/terminal/runBlockingShellCommand.js.map +1 -1
- package/dist/src/server/updateTestdirectorySchemaFile.d.ts +4 -0
- package/dist/src/server/updateTestdirectorySchemaFile.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/scripts/commands/commandTuiNeovimExec.ts +18 -5
- package/src/scripts/commands/commandTuiNeovimPrepare.ts +3 -3
- package/src/scripts/commands/commandTuiStart.ts +4 -4
- package/src/scripts/parseArguments.ts +0 -4
- package/src/scripts/resolveConfig.test.ts +6 -3
- package/src/scripts/resolveTuiConfig.ts +10 -4
- package/src/scripts/tui.ts +2 -2
- package/src/server/applications/neovim/NeovimApplication.ts +1 -1
- package/src/server/applications/terminal/TerminalTestApplication.ts +1 -1
- package/src/server/applications/terminal/runBlockingShellCommand.ts +1 -1
- package/src/server/updateTestdirectorySchemaFile.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tui-sandbox/library",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.9.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/mikavilpas/tui-sandbox"
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"@types/command-exists": "1.2.3",
|
|
33
33
|
"@types/cors": "2.8.19",
|
|
34
34
|
"@types/express": "5.0.3",
|
|
35
|
-
"@types/node": "24.7.
|
|
36
|
-
"cypress": "15.
|
|
35
|
+
"@types/node": "24.7.1",
|
|
36
|
+
"cypress": "15.4.0",
|
|
37
37
|
"nodemon": "3.1.10",
|
|
38
38
|
"type-fest": "5.0.1",
|
|
39
39
|
"vite": "7.1.9",
|
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
import { NeovimApplication, type StdoutOrStderrMessage } from "../../server/applications/neovim/NeovimApplication.js"
|
|
2
2
|
import { prepareNewTestDirectory } from "../../server/applications/neovim/prepareNewTestDirectory.js"
|
|
3
|
-
import type {
|
|
3
|
+
import type { TestServerConfigMetadata } from "../../server/updateTestdirectorySchemaFile.js"
|
|
4
4
|
import type { NeovimExec } from "../parseArguments.js"
|
|
5
5
|
|
|
6
|
-
export async function commandTuiNeovimExec(command: NeovimExec, config:
|
|
6
|
+
export async function commandTuiNeovimExec(command: NeovimExec, config: TestServerConfigMetadata): Promise<void> {
|
|
7
7
|
// automatically dispose of the neovim instance when done
|
|
8
|
-
await using app = new NeovimApplication(config.directories.testEnvironmentPath)
|
|
8
|
+
await using app = new NeovimApplication(config.config.directories.testEnvironmentPath)
|
|
9
9
|
app.events.on("stdout" satisfies StdoutOrStderrMessage, data => {
|
|
10
10
|
console.log(` neovim output: ${data}`)
|
|
11
11
|
})
|
|
12
|
-
const testDirectory = await prepareNewTestDirectory(config)
|
|
12
|
+
const testDirectory = await prepareNewTestDirectory(config.config)
|
|
13
|
+
const NVIM_APPNAME = process.env["NVIM_APPNAME"]
|
|
14
|
+
|
|
15
|
+
if (NVIM_APPNAME && !config.config.integrations.neovim.NVIM_APPNAMEs.find(n => n === NVIM_APPNAME)) {
|
|
16
|
+
process.exitCode = 1
|
|
17
|
+
const message = `The NVIM_APPNAME environment variable is set to "${NVIM_APPNAME}", but only the following neovim configurations are known in the configuration file: ${JSON.stringify(
|
|
18
|
+
config.config.integrations.neovim.NVIM_APPNAMEs
|
|
19
|
+
)}. Please set NVIM_APPNAME to one of the configured names or unset it to use the default ("nvim"). Config file path: ${config.configFilePath}`
|
|
20
|
+
|
|
21
|
+
console.error(message)
|
|
22
|
+
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
|
|
13
26
|
await app.startNextAndKillCurrent(
|
|
14
27
|
testDirectory,
|
|
15
28
|
{
|
|
16
29
|
filename: "empty.txt",
|
|
17
30
|
headlessCmd: command.command,
|
|
18
|
-
NVIM_APPNAME
|
|
31
|
+
NVIM_APPNAME,
|
|
19
32
|
},
|
|
20
33
|
{ cols: 80, rows: 24 }
|
|
21
34
|
)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { installDependencies } from "../../server/applications/neovim/api.js"
|
|
2
|
-
import type {
|
|
2
|
+
import type { TestServerConfigMetadata } from "../../server/updateTestdirectorySchemaFile.js"
|
|
3
3
|
|
|
4
|
-
export async function commandTuiNeovimPrepare(config:
|
|
4
|
+
export async function commandTuiNeovimPrepare(config: TestServerConfigMetadata): Promise<void> {
|
|
5
5
|
const NVIM_APPNAME = process.env["NVIM_APPNAME"]
|
|
6
6
|
console.log(`🚀 Installing neovim dependencies${NVIM_APPNAME ? ` for NVIM_APPNAME=${NVIM_APPNAME}` : ""}...`)
|
|
7
|
-
await installDependencies(process.env["NVIM_APPNAME"], config).catch((err: unknown) => {
|
|
7
|
+
await installDependencies(process.env["NVIM_APPNAME"], config.config).catch((err: unknown) => {
|
|
8
8
|
console.error("Error installing neovim dependencies", err)
|
|
9
9
|
process.exit(1)
|
|
10
10
|
})
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import path from "path"
|
|
2
2
|
import { createCypressSupportFile } from "../../server/cypress-support/createCypressSupportFile.js"
|
|
3
3
|
import { startTestServer } from "../../server/server.js"
|
|
4
|
-
import type { TestServerConfig } from "../../server/updateTestdirectorySchemaFile.js"
|
|
4
|
+
import type { TestServerConfig, TestServerConfigMetadata } from "../../server/updateTestdirectorySchemaFile.js"
|
|
5
5
|
import { updateTestdirectorySchemaFile } from "../../server/updateTestdirectorySchemaFile.js"
|
|
6
6
|
import { cwd } from "../tui.js"
|
|
7
7
|
|
|
8
|
-
export async function commandTuiStart(config:
|
|
9
|
-
await Promise.allSettled([updateSchemaFile(config), createSupportFile()])
|
|
8
|
+
export async function commandTuiStart(config: TestServerConfigMetadata): Promise<void> {
|
|
9
|
+
await Promise.allSettled([updateSchemaFile(config.config), createSupportFile()])
|
|
10
10
|
|
|
11
11
|
try {
|
|
12
12
|
console.log(`🚀 Starting test server in ${cwd} - this should be the root of your integration-tests directory 🤞🏻`)
|
|
13
|
-
await startTestServer(config)
|
|
13
|
+
await startTestServer(config.config)
|
|
14
14
|
} catch (e) {
|
|
15
15
|
console.error("Failed to startTestServer", e)
|
|
16
16
|
}
|
|
@@ -3,7 +3,6 @@ import * as z from "zod"
|
|
|
3
3
|
|
|
4
4
|
export const parseArguments = async (args: string[]): Promise<ParseArgumentsResult | undefined> => {
|
|
5
5
|
{
|
|
6
|
-
// tui neovim prepare
|
|
7
6
|
const schema = z.tuple([z.literal("neovim"), z.literal("prepare")])
|
|
8
7
|
const prepareArguments = schema.safeParse(args)
|
|
9
8
|
if (prepareArguments.success) {
|
|
@@ -14,7 +13,6 @@ export const parseArguments = async (args: string[]): Promise<ParseArgumentsResu
|
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
{
|
|
17
|
-
// tui neovim exec <command>
|
|
18
16
|
const schema = z.tuple([z.literal("neovim"), z.literal("exec"), z.string()])
|
|
19
17
|
const execArguments = schema.safeParse(args)
|
|
20
18
|
if (execArguments.success) {
|
|
@@ -28,7 +26,6 @@ export const parseArguments = async (args: string[]): Promise<ParseArgumentsResu
|
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
{
|
|
31
|
-
// tui start
|
|
32
29
|
const schema = z.tuple([z.literal("start")])
|
|
33
30
|
const result = schema.safeParse(args)
|
|
34
31
|
if (result.success) {
|
|
@@ -39,7 +36,6 @@ export const parseArguments = async (args: string[]): Promise<ParseArgumentsResu
|
|
|
39
36
|
}
|
|
40
37
|
|
|
41
38
|
{
|
|
42
|
-
// tui start
|
|
43
39
|
const schema = z.tuple([z.literal("run")])
|
|
44
40
|
const result = schema.safeParse(args)
|
|
45
41
|
if (result.success) {
|
|
@@ -11,12 +11,13 @@ it("defaults to the default configuration if no config file is found", async ()
|
|
|
11
11
|
const config = await resolveTuiConfig(__dirname)
|
|
12
12
|
assert(!config.error)
|
|
13
13
|
expect(config.id).toBe("no-config-found" satisfies ResolveTuiConfigResultSuccess["id"])
|
|
14
|
-
expect(testServerConfigSchema.safeParse(config.result).success).toBe(true)
|
|
14
|
+
expect(testServerConfigSchema.safeParse(config.result.config).success).toBe(true)
|
|
15
15
|
})
|
|
16
16
|
|
|
17
17
|
it("loads a custom configuration file if it exists", async () => {
|
|
18
18
|
using dir = TempDirectory.create()
|
|
19
19
|
|
|
20
|
+
const filename = `${dir.path}/tui-sandbox.config.ts`
|
|
20
21
|
const customConfig: TestServerConfig = {
|
|
21
22
|
directories: {
|
|
22
23
|
testEnvironmentPath: "./test-environment2/",
|
|
@@ -26,7 +27,6 @@ it("loads a custom configuration file if it exists", async () => {
|
|
|
26
27
|
port: 12345,
|
|
27
28
|
}
|
|
28
29
|
{
|
|
29
|
-
const filename = `${dir.path}/tui-sandbox.config.ts`
|
|
30
30
|
const contents = `export const config = ${JSON.stringify(customConfig)}`
|
|
31
31
|
await writeFile(filename, contents)
|
|
32
32
|
}
|
|
@@ -34,7 +34,10 @@ it("loads a custom configuration file if it exists", async () => {
|
|
|
34
34
|
const config = await resolveTuiConfig(dir.path)
|
|
35
35
|
expect(config).toStrictEqual({
|
|
36
36
|
id: "custom-config",
|
|
37
|
-
result:
|
|
37
|
+
result: {
|
|
38
|
+
config: customConfig,
|
|
39
|
+
configFilePath: filename,
|
|
40
|
+
},
|
|
38
41
|
} satisfies ResolveTuiConfigResult)
|
|
39
42
|
})
|
|
40
43
|
|
|
@@ -4,13 +4,13 @@ import { pathToFileURL } from "url"
|
|
|
4
4
|
import { debuglog } from "util"
|
|
5
5
|
import * as z from "zod"
|
|
6
6
|
import { createDefaultConfig } from "../server/config.js"
|
|
7
|
-
import { type
|
|
7
|
+
import { testServerConfigSchema, type TestServerConfigMetadata } from "../server/updateTestdirectorySchemaFile.js"
|
|
8
8
|
|
|
9
9
|
const log = debuglog("tui-sandbox.resolveConfig")
|
|
10
10
|
|
|
11
11
|
export type ResolveTuiConfigResultSuccess = {
|
|
12
12
|
id: "default-config" | "custom-config" | "no-config-found"
|
|
13
|
-
result:
|
|
13
|
+
result: TestServerConfigMetadata
|
|
14
14
|
error?: never
|
|
15
15
|
}
|
|
16
16
|
export type ResolveTuiConfigResultError = {
|
|
@@ -37,7 +37,10 @@ export const resolveTuiConfig = async (cwd: string): Promise<ResolveTuiConfigRes
|
|
|
37
37
|
|
|
38
38
|
return {
|
|
39
39
|
id: "no-config-found",
|
|
40
|
-
result:
|
|
40
|
+
result: {
|
|
41
|
+
config: defaultConfig,
|
|
42
|
+
configFilePath: url.pathname,
|
|
43
|
+
},
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
|
|
@@ -47,7 +50,10 @@ export const resolveTuiConfig = async (cwd: string): Promise<ResolveTuiConfigRes
|
|
|
47
50
|
if (customConfig.success) {
|
|
48
51
|
return {
|
|
49
52
|
id: "custom-config",
|
|
50
|
-
result:
|
|
53
|
+
result: {
|
|
54
|
+
config: customConfig.data.config,
|
|
55
|
+
configFilePath: url.pathname,
|
|
56
|
+
},
|
|
51
57
|
}
|
|
52
58
|
} else {
|
|
53
59
|
return {
|
package/src/scripts/tui.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import assert from "node:assert"
|
|
2
|
-
import type {
|
|
2
|
+
import type { TestServerConfigMetadata } from "../server/updateTestdirectorySchemaFile.js"
|
|
3
3
|
import type { TestResultExitCode } from "./commands/commandRun.js"
|
|
4
4
|
import { commandRun } from "./commands/commandRun.js"
|
|
5
5
|
import { commandTuiNeovimExec } from "./commands/commandTuiNeovimExec.js"
|
|
@@ -32,7 +32,7 @@ if (configResult.error) {
|
|
|
32
32
|
|
|
33
33
|
// the arguments passed to this script start at index 2
|
|
34
34
|
const args = process.argv.slice(2)
|
|
35
|
-
const config:
|
|
35
|
+
const config: TestServerConfigMetadata = configResult.result
|
|
36
36
|
const command = await parseArguments(args)
|
|
37
37
|
|
|
38
38
|
switch (command?.action) {
|
|
@@ -9,6 +9,11 @@ export type DirectoriesConfig = TestServerConfig["directories"]
|
|
|
9
9
|
|
|
10
10
|
export type TestServerConfig = z.output<typeof testServerConfigSchema>
|
|
11
11
|
|
|
12
|
+
export type TestServerConfigMetadata = {
|
|
13
|
+
configFilePath: string
|
|
14
|
+
config: TestServerConfig
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
export type Dictionary = Record<string, string>
|
|
13
18
|
|
|
14
19
|
export type CustomizeEnv = (env: Dictionary) => Promise<Dictionary>
|