@tui-sandbox/library 7.3.0 → 7.5.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 +14 -0
- package/dist/browser/assets/{index-DUKWG3jG.js → index-CWXBquay.js} +7 -7
- package/dist/browser/index.html +1 -1
- package/dist/src/client/terminal-client.js +3 -12
- package/dist/src/scripts/tui.js +8 -5
- package/dist/src/server/cypress-support/contents.js +14 -4
- package/dist/src/server/cypress-support/contents.test.js +14 -4
- package/dist/src/server/neovim/environment/createTempDir.d.ts +2 -2
- package/dist/src/server/neovim/index.d.ts +3 -3
- package/dist/src/server/neovim/index.js +3 -0
- package/dist/src/server/server.d.ts +6 -2
- package/dist/src/server/server.js +7 -3
- package/dist/src/server/types.d.ts +2 -2
- package/dist/src/server/updateTestdirectorySchemaFile.d.ts +6 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/src/client/terminal-client.ts +3 -12
- package/src/scripts/tui.ts +8 -5
- package/src/server/cypress-support/contents.test.ts +14 -4
- package/src/server/cypress-support/contents.ts +14 -4
- package/src/server/neovim/environment/createTempDir.ts +2 -2
- package/src/server/neovim/index.ts +6 -3
- package/src/server/server.ts +9 -5
- package/src/server/types.ts +2 -2
- package/src/server/updateTestdirectorySchemaFile.ts +7 -2
package/dist/browser/index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<title>tui-sandbox integration tests</title>
|
|
6
|
-
<script type="module" crossorigin src="/assets/index-
|
|
6
|
+
<script type="module" crossorigin src="/assets/index-CWXBquay.js"></script>
|
|
7
7
|
<link rel="stylesheet" crossorigin href="/assets/index-D6fBrqAi.css">
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
|
@@ -72,23 +72,14 @@ export class TerminalClient {
|
|
|
72
72
|
}
|
|
73
73
|
async runBlockingShellCommand(input) {
|
|
74
74
|
await this.ready;
|
|
75
|
-
return this.trpc.neovim.runBlockingShellCommand.mutate({
|
|
76
|
-
...input,
|
|
77
|
-
tabId: this.tabId,
|
|
78
|
-
});
|
|
75
|
+
return this.trpc.neovim.runBlockingShellCommand.mutate({ ...input, tabId: this.tabId });
|
|
79
76
|
}
|
|
80
77
|
async runLuaCode(input) {
|
|
81
78
|
await this.ready;
|
|
82
|
-
return this.trpc.neovim.runLuaCode.mutate({
|
|
83
|
-
luaCode: input.luaCode,
|
|
84
|
-
tabId: this.tabId,
|
|
85
|
-
});
|
|
79
|
+
return this.trpc.neovim.runLuaCode.mutate({ ...input, tabId: this.tabId });
|
|
86
80
|
}
|
|
87
81
|
async runExCommand(input) {
|
|
88
82
|
await this.ready;
|
|
89
|
-
return this.trpc.neovim.runExCommand.mutate({
|
|
90
|
-
command: input.command,
|
|
91
|
-
tabId: this.tabId,
|
|
92
|
-
});
|
|
83
|
+
return this.trpc.neovim.runExCommand.mutate({ ...input, tabId: this.tabId });
|
|
93
84
|
}
|
|
94
85
|
}
|
package/dist/src/scripts/tui.js
CHANGED
|
@@ -65,8 +65,11 @@ const outputFileName = "MyTestDirectory.ts";
|
|
|
65
65
|
* cwd of the script itself. */
|
|
66
66
|
const cwd = process.cwd();
|
|
67
67
|
const config = {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
directories: {
|
|
69
|
+
testEnvironmentPath: path.join(cwd, "test-environment/"),
|
|
70
|
+
outputFilePath: path.join(cwd, outputFileName),
|
|
71
|
+
},
|
|
72
|
+
port: process.env["PORT"] ? parseInt(process.env["PORT"]) : 3000,
|
|
70
73
|
};
|
|
71
74
|
// the arguments passed to this script start at index 2
|
|
72
75
|
const args = process.argv.slice(2);
|
|
@@ -80,11 +83,11 @@ if (args[0] === "neovim") {
|
|
|
80
83
|
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
81
84
|
try {
|
|
82
85
|
// automatically dispose of the neovim instance when done
|
|
83
|
-
const app = __addDisposableResource(env_1, new NeovimApplication(config.testEnvironmentPath), true);
|
|
86
|
+
const app = __addDisposableResource(env_1, new NeovimApplication(config.directories.testEnvironmentPath), true);
|
|
84
87
|
app.events.on("stdout", data => {
|
|
85
88
|
console.log(` neovim output: ${data}`);
|
|
86
89
|
});
|
|
87
|
-
const testDirectory = await prepareNewTestDirectory(config);
|
|
90
|
+
const testDirectory = await prepareNewTestDirectory(config.directories);
|
|
88
91
|
await app.startNextAndKillCurrent(testDirectory, { filename: "empty.txt", headlessCmd: command }, { cols: 80, rows: 24 });
|
|
89
92
|
await app.application.untilExit();
|
|
90
93
|
}
|
|
@@ -110,7 +113,7 @@ try {
|
|
|
110
113
|
cypressSupportDirectoryPath: path.join(cwd, "cypress", "support"),
|
|
111
114
|
supportFileName: "tui-sandbox.ts",
|
|
112
115
|
});
|
|
113
|
-
await updateTestdirectorySchemaFile(config);
|
|
116
|
+
await updateTestdirectorySchemaFile(config.directories);
|
|
114
117
|
await startTestServer(config);
|
|
115
118
|
}
|
|
116
119
|
catch (e) {
|
|
@@ -18,14 +18,13 @@ import type {
|
|
|
18
18
|
RunExCommandOutput,
|
|
19
19
|
RunLuaCodeOutput,
|
|
20
20
|
StartNeovimGenericArguments,
|
|
21
|
+
TestDirectory,
|
|
21
22
|
} from "@tui-sandbox/library/dist/src/server/types"
|
|
23
|
+
import assert from "assert"
|
|
22
24
|
import type { OverrideProperties } from "type-fest"
|
|
23
25
|
import type { MyTestDirectory, MyTestDirectoryFile } from "../../MyTestDirectory"
|
|
24
26
|
|
|
25
|
-
export type NeovimContext =
|
|
26
|
-
contents: MyTestDirectory
|
|
27
|
-
rootPathAbsolute: string
|
|
28
|
-
}
|
|
27
|
+
export type NeovimContext = TestDirectory<MyTestDirectory>
|
|
29
28
|
|
|
30
29
|
declare global {
|
|
31
30
|
interface Window {
|
|
@@ -47,6 +46,7 @@ type MyStartNeovimServerArguments = OverrideProperties<
|
|
|
47
46
|
|
|
48
47
|
Cypress.Commands.add("startNeovim", (startArguments?: MyStartNeovimServerArguments) => {
|
|
49
48
|
cy.window().then(async win => {
|
|
49
|
+
testWindow = win
|
|
50
50
|
return await win.startNeovim(startArguments)
|
|
51
51
|
})
|
|
52
52
|
})
|
|
@@ -75,6 +75,13 @@ Cypress.Commands.add("runExCommand", (input: ExCommandClientInput) => {
|
|
|
75
75
|
})
|
|
76
76
|
})
|
|
77
77
|
|
|
78
|
+
let testWindow: Window | undefined
|
|
79
|
+
|
|
80
|
+
Cypress.on("fail", async () => {
|
|
81
|
+
assert(testWindow, "testWindow is not defined")
|
|
82
|
+
await testWindow.runExCommand({ command: "messages", log: true })
|
|
83
|
+
})
|
|
84
|
+
|
|
78
85
|
before(function () {
|
|
79
86
|
// disable Cypress's default behavior of logging all XMLHttpRequests and
|
|
80
87
|
// fetches to the Command Log
|
|
@@ -97,6 +104,9 @@ declare global {
|
|
|
97
104
|
|
|
98
105
|
runLuaCode(input: LuaCodeClientInput): Chainable<RunLuaCodeOutput>
|
|
99
106
|
|
|
107
|
+
/** Run an ex command in neovim.
|
|
108
|
+
* @example "echo expand('%:.')" current file, relative to the cwd
|
|
109
|
+
*/
|
|
100
110
|
runExCommand(input: ExCommandClientInput): Chainable<RunExCommandOutput>
|
|
101
111
|
}
|
|
102
112
|
}
|
|
@@ -16,14 +16,13 @@ it("should return the expected contents", async () => {
|
|
|
16
16
|
RunExCommandOutput,
|
|
17
17
|
RunLuaCodeOutput,
|
|
18
18
|
StartNeovimGenericArguments,
|
|
19
|
+
TestDirectory,
|
|
19
20
|
} from "@tui-sandbox/library/dist/src/server/types"
|
|
21
|
+
import assert from "assert"
|
|
20
22
|
import type { OverrideProperties } from "type-fest"
|
|
21
23
|
import type { MyTestDirectory, MyTestDirectoryFile } from "../../MyTestDirectory"
|
|
22
24
|
|
|
23
|
-
export type NeovimContext =
|
|
24
|
-
contents: MyTestDirectory
|
|
25
|
-
rootPathAbsolute: string
|
|
26
|
-
}
|
|
25
|
+
export type NeovimContext = TestDirectory<MyTestDirectory>
|
|
27
26
|
|
|
28
27
|
declare global {
|
|
29
28
|
interface Window {
|
|
@@ -45,6 +44,7 @@ it("should return the expected contents", async () => {
|
|
|
45
44
|
|
|
46
45
|
Cypress.Commands.add("startNeovim", (startArguments?: MyStartNeovimServerArguments) => {
|
|
47
46
|
cy.window().then(async win => {
|
|
47
|
+
testWindow = win
|
|
48
48
|
return await win.startNeovim(startArguments)
|
|
49
49
|
})
|
|
50
50
|
})
|
|
@@ -73,6 +73,13 @@ it("should return the expected contents", async () => {
|
|
|
73
73
|
})
|
|
74
74
|
})
|
|
75
75
|
|
|
76
|
+
let testWindow: Window | undefined
|
|
77
|
+
|
|
78
|
+
Cypress.on("fail", async () => {
|
|
79
|
+
assert(testWindow, "testWindow is not defined")
|
|
80
|
+
await testWindow.runExCommand({ command: "messages", log: true })
|
|
81
|
+
})
|
|
82
|
+
|
|
76
83
|
before(function () {
|
|
77
84
|
// disable Cypress's default behavior of logging all XMLHttpRequests and
|
|
78
85
|
// fetches to the Command Log
|
|
@@ -95,6 +102,9 @@ it("should return the expected contents", async () => {
|
|
|
95
102
|
|
|
96
103
|
runLuaCode(input: LuaCodeClientInput): Chainable<RunLuaCodeOutput>
|
|
97
104
|
|
|
105
|
+
/** Run an ex command in neovim.
|
|
106
|
+
* @example "echo expand('%:.')" current file, relative to the cwd
|
|
107
|
+
*/
|
|
98
108
|
runExCommand(input: ExCommandClientInput): Chainable<RunExCommandOutput>
|
|
99
109
|
}
|
|
100
110
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TestDirectory } from "../../types.js";
|
|
2
|
-
import type {
|
|
3
|
-
export declare function createTempDir(config:
|
|
2
|
+
import type { DirectoriesConfig } from "../../updateTestdirectorySchemaFile.js";
|
|
3
|
+
export declare function createTempDir(config: DirectoriesConfig): Promise<TestDirectory>;
|
|
4
4
|
export type TestDirsPath = "testdirs";
|
|
5
5
|
export declare function removeTestDirectories(testEnvironmentPath: string): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "core-js/proposals/async-explicit-resource-management.js";
|
|
2
2
|
import type { BlockingCommandInput, ExCommandInput, LuaCodeInput } from "../server.js";
|
|
3
3
|
import type { BlockingShellCommandOutput, RunExCommandOutput, RunLuaCodeOutput, StartNeovimGenericArguments, TestDirectory } from "../types.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { DirectoriesConfig } from "../updateTestdirectorySchemaFile.js";
|
|
5
5
|
import { Lazy } from "../utilities/Lazy.js";
|
|
6
6
|
import type { TabId } from "../utilities/tabId.js";
|
|
7
7
|
import type { TerminalDimensions } from "./NeovimApplication.js";
|
|
@@ -9,8 +9,8 @@ export declare const resources: Lazy<AsyncDisposableStack>;
|
|
|
9
9
|
export declare function initializeStdout(options: {
|
|
10
10
|
client: TabId;
|
|
11
11
|
}, signal: AbortSignal | undefined, testEnvironmentPath: string): Promise<AsyncGenerator<string, void, unknown>>;
|
|
12
|
-
export declare function start(options: StartNeovimGenericArguments, terminalDimensions: TerminalDimensions, tabId: TabId, config:
|
|
13
|
-
export declare function prepareNewTestDirectory(config:
|
|
12
|
+
export declare function start(options: StartNeovimGenericArguments, terminalDimensions: TerminalDimensions, tabId: TabId, config: DirectoriesConfig): Promise<TestDirectory>;
|
|
13
|
+
export declare function prepareNewTestDirectory(config: DirectoriesConfig): Promise<TestDirectory>;
|
|
14
14
|
export declare function sendStdin(options: {
|
|
15
15
|
tabId: TabId;
|
|
16
16
|
data: string;
|
|
@@ -110,6 +110,9 @@ export async function runExCommand(options) {
|
|
|
110
110
|
console.log(`Neovim ${neovim.application.processId()} running Ex command: ${options.command}`);
|
|
111
111
|
try {
|
|
112
112
|
const output = await api.commandOutput(options.command);
|
|
113
|
+
if (options.log) {
|
|
114
|
+
console.log(`Ex command output: ${output}`);
|
|
115
|
+
}
|
|
113
116
|
return { value: output };
|
|
114
117
|
}
|
|
115
118
|
catch (e) {
|
|
@@ -3,7 +3,7 @@ import "core-js/proposals/async-explicit-resource-management.js";
|
|
|
3
3
|
import type { Except } from "type-fest";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { TestServer } from "./TestServer.js";
|
|
6
|
-
import type { TestServerConfig } from "./updateTestdirectorySchemaFile.js";
|
|
6
|
+
import type { DirectoriesConfig, TestServerConfig } from "./updateTestdirectorySchemaFile.js";
|
|
7
7
|
declare const blockingCommandInputSchema: z.ZodObject<{
|
|
8
8
|
command: z.ZodString;
|
|
9
9
|
shell: z.ZodOptional<z.ZodString>;
|
|
@@ -75,21 +75,24 @@ declare const exCommandInputSchema: z.ZodObject<{
|
|
|
75
75
|
tabId: string;
|
|
76
76
|
}>;
|
|
77
77
|
command: z.ZodString;
|
|
78
|
+
log: z.ZodOptional<z.ZodBoolean>;
|
|
78
79
|
}, "strip", z.ZodTypeAny, {
|
|
79
80
|
command: string;
|
|
80
81
|
tabId: {
|
|
81
82
|
tabId: string;
|
|
82
83
|
};
|
|
84
|
+
log?: boolean | undefined;
|
|
83
85
|
}, {
|
|
84
86
|
command: string;
|
|
85
87
|
tabId: {
|
|
86
88
|
tabId: string;
|
|
87
89
|
};
|
|
90
|
+
log?: boolean | undefined;
|
|
88
91
|
}>;
|
|
89
92
|
export type ExCommandClientInput = Except<ExCommandInput, "tabId">;
|
|
90
93
|
export type ExCommandInput = z.infer<typeof exCommandInputSchema>;
|
|
91
94
|
/** @private */
|
|
92
|
-
export declare function createAppRouter(config:
|
|
95
|
+
export declare function createAppRouter(config: DirectoriesConfig): Promise<import("@trpc/server/unstable-core-do-not-import").BuiltRouter<{
|
|
93
96
|
ctx: object;
|
|
94
97
|
meta: object;
|
|
95
98
|
errorShape: import("@trpc/server/unstable-core-do-not-import").DefaultErrorShape;
|
|
@@ -167,6 +170,7 @@ export declare function createAppRouter(config: TestServerConfig): Promise<impor
|
|
|
167
170
|
tabId: {
|
|
168
171
|
tabId: string;
|
|
169
172
|
};
|
|
173
|
+
log?: boolean | undefined;
|
|
170
174
|
};
|
|
171
175
|
output: import("./types.js").RunExCommandOutput;
|
|
172
176
|
}>;
|
|
@@ -17,7 +17,11 @@ const blockingCommandInputSchema = z.object({
|
|
|
17
17
|
envOverrides: z.record(z.string()).optional(),
|
|
18
18
|
});
|
|
19
19
|
const luaCodeInputSchema = z.object({ tabId: tabIdSchema, luaCode: z.string() });
|
|
20
|
-
const exCommandInputSchema = z.object({
|
|
20
|
+
const exCommandInputSchema = z.object({
|
|
21
|
+
tabId: tabIdSchema,
|
|
22
|
+
command: z.string(),
|
|
23
|
+
log: z.boolean().optional(),
|
|
24
|
+
});
|
|
21
25
|
/** @private */
|
|
22
26
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
23
27
|
export async function createAppRouter(config) {
|
|
@@ -68,9 +72,9 @@ export async function createAppRouter(config) {
|
|
|
68
72
|
}
|
|
69
73
|
export async function startTestServer(config) {
|
|
70
74
|
const testServer = new TestServer({
|
|
71
|
-
port:
|
|
75
|
+
port: config.port,
|
|
72
76
|
});
|
|
73
|
-
const appRouter = await createAppRouter(config);
|
|
77
|
+
const appRouter = await createAppRouter(config.directories);
|
|
74
78
|
await testServer.startAndRun(appRouter);
|
|
75
79
|
return testServer;
|
|
76
80
|
}
|
|
@@ -7,7 +7,7 @@ import type { VimValue } from "neovim/lib/types/VimValue.js";
|
|
|
7
7
|
* be written with confidence that the files and directories they expect are
|
|
8
8
|
* actually found. Otherwise the tests are brittle and can break easily.
|
|
9
9
|
*/
|
|
10
|
-
export type TestDirectory = {
|
|
10
|
+
export type TestDirectory<TContents extends object = object> = {
|
|
11
11
|
/** The path to the unique test directory (the root).
|
|
12
12
|
*
|
|
13
13
|
* @example /Users/mikavilpas/git/tui-sandbox/packages/integration-tests/test-environment/testdirs/dir-0199UZ
|
|
@@ -24,7 +24,7 @@ export type TestDirectory = {
|
|
|
24
24
|
* @example testdirs/dir-0199UZ/
|
|
25
25
|
*/
|
|
26
26
|
testEnvironmentPathRelative: string;
|
|
27
|
-
contents:
|
|
27
|
+
contents: TContents;
|
|
28
28
|
};
|
|
29
29
|
export type { StartNeovimGenericArguments } from "../server/neovim/NeovimApplication.js";
|
|
30
30
|
export type BlockingShellCommandOutput = {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type DirectoriesConfig = {
|
|
2
2
|
testEnvironmentPath: string;
|
|
3
3
|
outputFilePath: string;
|
|
4
4
|
};
|
|
5
|
+
export type TestServerConfig = {
|
|
6
|
+
directories: DirectoriesConfig;
|
|
7
|
+
port: number;
|
|
8
|
+
};
|
|
5
9
|
export type UpdateTestdirectorySchemaFileResult = "updated" | "did-nothing";
|
|
6
|
-
export declare function updateTestdirectorySchemaFile({ testEnvironmentPath, outputFilePath, }:
|
|
10
|
+
export declare function updateTestdirectorySchemaFile({ testEnvironmentPath, outputFilePath, }: DirectoriesConfig): Promise<UpdateTestdirectorySchemaFileResult>;
|