@tui-sandbox/library 11.9.2 → 11.11.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/browser/assets/{index-D1p5KdqI.js → index-DCtcQK5s.js} +1 -1
  3. package/dist/browser/index.html +1 -1
  4. package/dist/src/client/neovim-terminal-client.js +1 -1
  5. package/dist/src/client/neovim-terminal-client.js.map +1 -1
  6. package/dist/src/scripts/resolveConfig.test.js +1 -0
  7. package/dist/src/scripts/resolveConfig.test.js.map +1 -1
  8. package/dist/src/server/applications/neovim/NeovimApplication.js +1 -5
  9. package/dist/src/server/applications/neovim/NeovimApplication.js.map +1 -1
  10. package/dist/src/server/applications/neovim/environment/createTempDir.js +20 -2
  11. package/dist/src/server/applications/neovim/environment/createTempDir.js.map +1 -1
  12. package/dist/src/server/applications/neovim/environment/createTempDir.test.js +1 -0
  13. package/dist/src/server/applications/neovim/environment/createTempDir.test.js.map +1 -1
  14. package/dist/src/server/applications/neovim/neovimRouter.d.ts +1 -9
  15. package/dist/src/server/applications/neovim/neovimRouter.js +0 -3
  16. package/dist/src/server/applications/neovim/neovimRouter.js.map +1 -1
  17. package/dist/src/server/applications/neovim/prepareNewTestDirectory.test.js +1 -0
  18. package/dist/src/server/applications/neovim/prepareNewTestDirectory.test.js.map +1 -1
  19. package/dist/src/server/applications/terminal/TerminalTestApplication.js +1 -0
  20. package/dist/src/server/applications/terminal/TerminalTestApplication.js.map +1 -1
  21. package/dist/src/server/applications/terminal/terminalRouter.d.ts +1 -0
  22. package/dist/src/server/config.js +1 -0
  23. package/dist/src/server/config.js.map +1 -1
  24. package/dist/src/server/server.d.ts +2 -9
  25. package/dist/src/server/types.d.ts +14 -0
  26. package/dist/src/server/types.js +1 -0
  27. package/dist/src/server/types.js.map +1 -1
  28. package/dist/src/server/updateTestdirectorySchemaFile.d.ts +1 -0
  29. package/dist/src/server/updateTestdirectorySchemaFile.js +1 -0
  30. package/dist/src/server/updateTestdirectorySchemaFile.js.map +1 -1
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +6 -6
  33. package/src/client/neovim-terminal-client.ts +1 -1
  34. package/src/scripts/resolveConfig.test.ts +1 -0
  35. package/src/server/applications/neovim/NeovimApplication.ts +1 -6
  36. package/src/server/applications/neovim/environment/createTempDir.test.ts +1 -0
  37. package/src/server/applications/neovim/environment/createTempDir.ts +26 -2
  38. package/src/server/applications/neovim/neovimRouter.ts +1 -4
  39. package/src/server/applications/neovim/prepareNewTestDirectory.test.ts +1 -0
  40. package/src/server/applications/terminal/TerminalTestApplication.ts +1 -0
  41. package/src/server/config.ts +1 -0
  42. package/src/server/types.ts +16 -5
  43. package/src/server/updateTestdirectorySchemaFile.ts +1 -0
  44. package/vite.config.js +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tui-sandbox/library",
3
- "version": "11.9.2",
3
+ "version": "11.11.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mikavilpas/tui-sandbox"
@@ -12,8 +12,8 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@catppuccin/palette": "1.7.1",
15
- "@trpc/client": "11.7.0",
16
- "@trpc/server": "11.7.0",
15
+ "@trpc/client": "11.7.1",
16
+ "@trpc/server": "11.7.1",
17
17
  "@xterm/addon-fit": "0.10.0",
18
18
  "@xterm/addon-unicode11": "0.8.0",
19
19
  "@xterm/xterm": "5.5.0",
@@ -31,13 +31,13 @@
31
31
  "devDependencies": {
32
32
  "@types/command-exists": "1.2.3",
33
33
  "@types/cors": "2.8.19",
34
- "@types/express": "5.0.4",
35
- "@types/node": "24.9.1",
34
+ "@types/express": "5.0.5",
35
+ "@types/node": "24.9.2",
36
36
  "cypress": "15.5.0",
37
37
  "nodemon": "3.1.10",
38
38
  "type-fest": "5.1.0",
39
39
  "vite": "7.1.12",
40
- "vitest": "4.0.3"
40
+ "vitest": "4.0.6"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "cypress": "^13 || ^14 || ^15",
@@ -62,7 +62,7 @@ export class NeovimTerminalClient {
62
62
  // time to complete
63
63
  this.ready = new Promise<void>(resolve => {
64
64
  console.log("Subscribing to stdout")
65
- trpc.neovim.initializeStdout.subscribe(
65
+ trpc.neovim.onStdout.subscribe(
66
66
  { client: tabId },
67
67
  {
68
68
  onStarted() {
@@ -22,6 +22,7 @@ it("loads a custom configuration file if it exists", async () => {
22
22
  directories: {
23
23
  testEnvironmentPath: "./test-environment2/",
24
24
  outputFilePath: "./output.ts",
25
+ latestSymlinkName: "latest",
25
26
  },
26
27
  integrations: { neovim: { NVIM_APPNAMEs: ["nvim", "nvim_2"] } },
27
28
  port: 12345,
@@ -204,14 +204,9 @@ export class NeovimApplication implements AsyncDisposable {
204
204
  ...process.env,
205
205
  ...({
206
206
  HOME: testDirectory.rootPathAbsolute,
207
-
208
- // this is needed so that neovim can load its configuration, emulating
209
- // a common setup real neovim users have
210
207
  XDG_CONFIG_HOME: join(testDirectory.rootPathAbsolute, ".config"),
211
- // the data directory is where lazy.nvim stores its plugins. To prevent
212
- // downloading a new set of plugins for each test, share the data
213
- // directory.
214
208
  XDG_DATA_HOME: join(testDirectory.testEnvironmentPath, ".repro", "data"),
209
+ TUI_SANDBOX_TEST_ENVIRONMENT_PATH: testDirectory.testEnvironmentPath,
215
210
  } satisfies TestEnvironmentCommonEnvironmentVariables),
216
211
  NVIM_APPNAME: NVIM_APPNAME ?? "nvim",
217
212
 
@@ -18,6 +18,7 @@ it("should create a temp dir with no contents", async () => {
18
18
  directories: {
19
19
  testEnvironmentPath: dir.path,
20
20
  outputFilePath: nodePath.join(dir.path, "MyTestDirectory.ts"),
21
+ latestSymlinkName: "latest",
21
22
  },
22
23
  } satisfies PartialDeep<TestServerConfig>)
23
24
 
@@ -1,7 +1,7 @@
1
1
  import assert from "assert"
2
2
  import { execSync } from "child_process"
3
3
  import { constants, readdirSync, statSync } from "fs"
4
- import { access, mkdir, mkdtemp } from "fs/promises"
4
+ import { access, mkdir, mkdtemp, symlink } from "fs/promises"
5
5
  import path from "path"
6
6
  import { debuglog } from "util"
7
7
  import { convertDree, getDirectoryTree } from "../../../dirtree/index.js"
@@ -28,12 +28,16 @@ export async function createTempDir(config: TestServerConfig): Promise<TestDirec
28
28
  const tree = convertDree(getDirectoryTree(dir).dree)
29
29
  assert(tree.type === "directory")
30
30
 
31
- await updateTestdirectorySchemaFile(config)
31
+ const [_, latestEnvironmentSymlink] = await Promise.all([
32
+ updateTestdirectorySchemaFile(config),
33
+ createLatestSymlink(config, dir),
34
+ ])
32
35
  return {
33
36
  rootPathAbsolute: dir,
34
37
  contents: tree.contents,
35
38
  testEnvironmentPath: config.directories.testEnvironmentPath,
36
39
  testEnvironmentPathRelative: path.relative(config.directories.testEnvironmentPath, dir),
40
+ latestEnvironmentSymlink,
37
41
  }
38
42
  } catch (err) {
39
43
  console.error(err)
@@ -56,6 +60,26 @@ async function createUniqueDirectory(testEnvironmentPath: string): Promise<strin
56
60
  return dir
57
61
  }
58
62
 
63
+ async function createLatestSymlink(config: TestServerConfig, uniqueTestDirectory: string): Promise<string> {
64
+ const latestSymlinkPath = path.join(
65
+ config.directories.testEnvironmentPath,
66
+ "testdirs" satisfies TestDirsPath,
67
+ config.directories.latestSymlinkName
68
+ )
69
+ try {
70
+ await access(latestSymlinkPath, constants.F_OK)
71
+ // If it already exists, remove it
72
+ execSync(`rm -f '${latestSymlinkPath}'`)
73
+ } catch {
74
+ // It doesn't exist, that's fine
75
+ }
76
+
77
+ // recreate it
78
+ await symlink(uniqueTestDirectory, latestSymlinkPath, "junction")
79
+
80
+ return latestSymlinkPath
81
+ }
82
+
59
83
  export async function removeTestDirectories(testEnvironmentPath: string): Promise<void> {
60
84
  try {
61
85
  const testdirs = path.join(testEnvironmentPath, "testdirs" satisfies TestDirsPath)
@@ -72,11 +72,8 @@ export function createNeovimRouter(config: TestServerConfig) {
72
72
  config
73
73
  )
74
74
  }),
75
- onStdout: trpc.procedure.input(z.object({ client: tabIdSchema })).subscription(options => {
76
- return neovim.initializeStdout(options.input, options.signal, config.directories.testEnvironmentPath)
77
- }),
78
75
 
79
- initializeStdout: trpc.procedure.input(z.object({ client: tabIdSchema })).subscription(options => {
76
+ onStdout: trpc.procedure.input(z.object({ client: tabIdSchema })).subscription(options => {
80
77
  return neovim.initializeStdout(options.input, options.signal, config.directories.testEnvironmentPath)
81
78
  }),
82
79
  sendStdin: trpc.procedure.input(z.object({ tabId: tabIdSchema, data: z.string() })).mutation(options => {
@@ -16,6 +16,7 @@ describe("prepareNewTestDirectory when the testEnvironmentPath does not exist",
16
16
  directories: {
17
17
  outputFilePath: path.join(testEnvironmentPath, "foo.ts"),
18
18
  testEnvironmentPath,
19
+ latestSymlinkName: "latest",
19
20
  },
20
21
  } satisfies PartialDeep<TestServerConfig>)
21
22
 
@@ -82,6 +82,7 @@ export default class TerminalTestApplication implements AsyncDisposable {
82
82
  HOME: testDirectory.rootPathAbsolute,
83
83
  XDG_CONFIG_HOME: join(testDirectory.rootPathAbsolute, ".config"),
84
84
  XDG_DATA_HOME: join(testDirectory.testEnvironmentPath, ".repro", "data"),
85
+ TUI_SANDBOX_TEST_ENVIRONMENT_PATH: testDirectory.testEnvironmentPath,
85
86
  ...additionalEnvironmentVariables,
86
87
  } satisfies TestEnvironmentCommonEnvironmentVariables
87
88
  }
@@ -6,6 +6,7 @@ export const createDefaultConfig = (cwd: string, environment: NodeJS.ProcessEnv)
6
6
  directories: {
7
7
  testEnvironmentPath: path.join(cwd, "test-environment/"),
8
8
  outputFilePath: path.join(cwd, "MyTestDirectory.ts"),
9
+ latestSymlinkName: "latest",
9
10
  },
10
11
  port: environment["PORT"] ? parseInt(environment["PORT"]) : 3000,
11
12
  integrations: {
@@ -29,6 +29,8 @@ export type TestDirectory<TContents extends Record<string, unknown> = Record<str
29
29
  */
30
30
  testEnvironmentPathRelative: string
31
31
 
32
+ latestEnvironmentSymlink: string
33
+
32
34
  contents: TContents
33
35
  }
34
36
 
@@ -36,6 +38,7 @@ export const serverTestDirectorySchema = z.object({
36
38
  rootPathAbsolute: z.string(),
37
39
  testEnvironmentPath: z.string(),
38
40
  testEnvironmentPathRelative: z.string(),
41
+ latestEnvironmentSymlink: z.string(),
39
42
  contents: z.record(z.string(), z.unknown()),
40
43
  })
41
44
  export type ServerTestDirectory = z.infer<typeof serverTestDirectorySchema>
@@ -43,14 +46,22 @@ export type ServerTestDirectory = z.infer<typeof serverTestDirectorySchema>
43
46
  export type TestEnvironmentCommonEnvironmentVariables = {
44
47
  HOME: string
45
48
 
46
- // this is needed so that the application being tested can load its
47
- // configuration, emulating a common setup real users have
49
+ /** This is needed so that the application being tested can load its
50
+ * configuration, emulating a common setup real users have
51
+ */
48
52
  XDG_CONFIG_HOME: string
49
53
 
50
- // the data directory is where the application stores its data. To prevent
51
- // downloading a new set of plugins/whatever for each test, share the data
52
- // directory.
54
+ /** The data directory is where the application stores its data. To prevent
55
+ * downloading a new set of plugins/whatever for each test, share the data
56
+ * directory.
57
+ */
53
58
  XDG_DATA_HOME: string
59
+
60
+ /** The path to the test environment directory, which is the blueprint for
61
+ * the test directory.
62
+ * @example /Users/mikavilpas/git/tui-sandbox/packages/integration-tests/test-environment
63
+ * */
64
+ TUI_SANDBOX_TEST_ENVIRONMENT_PATH: string
54
65
  }
55
66
 
56
67
  export type { StartNeovimGenericArguments } from "./applications/neovim/NeovimApplication.js"
@@ -37,6 +37,7 @@ export const testServerConfigSchema = z.strictObject({
37
37
  directories: z.object({
38
38
  testEnvironmentPath: z.string(),
39
39
  outputFilePath: z.string(),
40
+ latestSymlinkName: z.string().optional().default("latest"),
40
41
  }),
41
42
  port: z.number().int().min(1).max(65535),
42
43
  integrations: z.strictObject({
package/vite.config.js CHANGED
@@ -19,6 +19,7 @@ export default defineConfig({
19
19
  outDir: "./dist/browser/",
20
20
  },
21
21
  test: {
22
+ exclude: ["node_modules", "dist"],
22
23
  globals: true, // This will make describe, it, etc. available globally
23
24
  environment: "node",
24
25
  mockReset: true,