@tui-sandbox/library 11.8.6 → 11.9.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/src/scripts/commands/commandTuiNeovimExec.d.ts +2 -2
  3. package/dist/src/scripts/commands/commandTuiNeovimExec.js +10 -3
  4. package/dist/src/scripts/commands/commandTuiNeovimExec.js.map +1 -1
  5. package/dist/src/scripts/commands/commandTuiNeovimPrepare.d.ts +2 -2
  6. package/dist/src/scripts/commands/commandTuiNeovimPrepare.js +1 -1
  7. package/dist/src/scripts/commands/commandTuiNeovimPrepare.js.map +1 -1
  8. package/dist/src/scripts/commands/commandTuiStart.d.ts +2 -2
  9. package/dist/src/scripts/commands/commandTuiStart.js +2 -2
  10. package/dist/src/scripts/commands/commandTuiStart.js.map +1 -1
  11. package/dist/src/scripts/parseArguments.js +0 -4
  12. package/dist/src/scripts/parseArguments.js.map +1 -1
  13. package/dist/src/scripts/resolveConfig.test.js +6 -3
  14. package/dist/src/scripts/resolveConfig.test.js.map +1 -1
  15. package/dist/src/scripts/resolveTuiConfig.d.ts +2 -2
  16. package/dist/src/scripts/resolveTuiConfig.js +8 -2
  17. package/dist/src/scripts/resolveTuiConfig.js.map +1 -1
  18. package/dist/src/scripts/tui.js.map +1 -1
  19. package/dist/src/server/applications/neovim/NeovimApplication.js +1 -1
  20. package/dist/src/server/applications/neovim/NeovimApplication.js.map +1 -1
  21. package/dist/src/server/applications/neovim/NeovimJavascriptApiClient.js +10 -1
  22. package/dist/src/server/applications/neovim/NeovimJavascriptApiClient.js.map +1 -1
  23. package/dist/src/server/applications/terminal/TerminalTestApplication.js +1 -1
  24. package/dist/src/server/applications/terminal/TerminalTestApplication.js.map +1 -1
  25. package/dist/src/server/applications/terminal/runBlockingShellCommand.js +1 -1
  26. package/dist/src/server/applications/terminal/runBlockingShellCommand.js.map +1 -1
  27. package/dist/src/server/updateTestdirectorySchemaFile.d.ts +4 -0
  28. package/dist/src/server/updateTestdirectorySchemaFile.js.map +1 -1
  29. package/dist/tsconfig.tsbuildinfo +1 -1
  30. package/package.json +3 -3
  31. package/src/scripts/commands/commandTuiNeovimExec.ts +18 -5
  32. package/src/scripts/commands/commandTuiNeovimPrepare.ts +3 -3
  33. package/src/scripts/commands/commandTuiStart.ts +4 -4
  34. package/src/scripts/parseArguments.ts +0 -4
  35. package/src/scripts/resolveConfig.test.ts +6 -3
  36. package/src/scripts/resolveTuiConfig.ts +10 -4
  37. package/src/scripts/tui.ts +2 -2
  38. package/src/server/applications/neovim/NeovimApplication.ts +1 -1
  39. package/src/server/applications/neovim/NeovimJavascriptApiClient.ts +16 -1
  40. package/src/server/applications/terminal/TerminalTestApplication.ts +1 -1
  41. package/src/server/applications/terminal/runBlockingShellCommand.ts +1 -1
  42. 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.8.6",
3
+ "version": "11.9.1",
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.0",
36
- "cypress": "15.3.0",
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 { TestServerConfig } from "../../server/updateTestdirectorySchemaFile.js"
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: TestServerConfig): Promise<void> {
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: process.env["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 { TestServerConfig } from "../../server/updateTestdirectorySchemaFile.js"
2
+ import type { TestServerConfigMetadata } from "../../server/updateTestdirectorySchemaFile.js"
3
3
 
4
- export async function commandTuiNeovimPrepare(config: TestServerConfig): Promise<void> {
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: TestServerConfig): Promise<void> {
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: customConfig,
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 TestServerConfig, testServerConfigSchema } from "../server/updateTestdirectorySchemaFile.js"
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: TestServerConfig
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: defaultConfig,
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: customConfig.data.config,
53
+ result: {
54
+ config: customConfig.data.config,
55
+ configFilePath: url.pathname,
56
+ },
51
57
  }
52
58
  } else {
53
59
  return {
@@ -1,5 +1,5 @@
1
1
  import assert from "node:assert"
2
- import type { TestServerConfig } from "../server/updateTestdirectorySchemaFile.js"
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: TestServerConfig = configResult.result
35
+ const config: TestServerConfigMetadata = configResult.result
36
36
  const command = await parseArguments(args)
37
37
 
38
38
  switch (command?.action) {
@@ -172,7 +172,7 @@ export class NeovimApplication implements AsyncDisposable {
172
172
  args: neovimArguments,
173
173
 
174
174
  cwd: this.testEnvironmentPath,
175
- env: env,
175
+ env,
176
176
  dimensions: terminalDimensions,
177
177
 
178
178
  onStdoutOrStderr(data) {
@@ -17,9 +17,24 @@ export function connectNeovimApi(socketPath: string): Lazy<Promise<NeovimJavascr
17
17
  // https://github.com/neovim/node-client/blob/e0568e32e0fc8837ad900146bfd5ca27b9416235/README.md#logging
18
18
  const logger = createLogger({
19
19
  level: "warn",
20
+
20
21
  transports: [
21
22
  new transports.Console({
22
- format: format.combine(format.colorize(), format.simple()),
23
+ format: format.combine(
24
+ format(info => {
25
+ if ((info.message as string).startsWith("failed request to")) {
26
+ // This is logged when neovim is started with --embed, which we don't use.
27
+ // It's not a problem, so hide it.
28
+ //
29
+ // Returning false removes this log entry
30
+ return false
31
+ }
32
+
33
+ return info
34
+ })(),
35
+ format.colorize(),
36
+ format.simple()
37
+ ),
23
38
  }),
24
39
  ],
25
40
  })
@@ -52,7 +52,7 @@ export default class TerminalTestApplication implements AsyncDisposable {
52
52
  args: terminalArguments,
53
53
 
54
54
  cwd: testDirectory.rootPathAbsolute,
55
- env: env,
55
+ env,
56
56
  dimensions: terminalDimensions,
57
57
 
58
58
  onStdoutOrStderr(data) {
@@ -24,7 +24,7 @@ export async function executeBlockingShellCommand(
24
24
 
25
25
  try {
26
26
  const result = await execPromise(input.command, {
27
- signal: signal,
27
+ signal,
28
28
  shell: input.shell,
29
29
  uid: input.uid,
30
30
  gid: input.gid,
@@ -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>