@tui-sandbox/library 9.1.4 → 9.1.5
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/tui.js +1 -1
- package/dist/src/scripts/tui.js.map +1 -1
- package/dist/src/server/neovim/environment/createTempDir.js +4 -2
- package/dist/src/server/neovim/environment/createTempDir.js.map +1 -1
- package/dist/src/server/neovim/index.d.ts +0 -1
- package/dist/src/server/neovim/index.js +1 -6
- package/dist/src/server/neovim/index.js.map +1 -1
- package/dist/src/server/neovim/prepareNewTestDirectory.d.ts +3 -0
- package/dist/src/server/neovim/prepareNewTestDirectory.js +16 -0
- package/dist/src/server/neovim/prepareNewTestDirectory.js.map +1 -0
- package/dist/src/server/neovim/prepareNewTestDirectory.test.d.ts +1 -0
- package/dist/src/server/neovim/prepareNewTestDirectory.test.js +24 -0
- package/dist/src/server/neovim/prepareNewTestDirectory.test.js.map +1 -0
- package/dist/src/server/terminal/index.js +1 -1
- package/dist/src/server/terminal/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/scripts/tui.ts +1 -1
- package/src/server/neovim/environment/createTempDir.ts +4 -2
- package/src/server/neovim/index.ts +1 -7
- package/src/server/neovim/prepareNewTestDirectory.test.ts +24 -0
- package/src/server/neovim/prepareNewTestDirectory.ts +18 -0
- package/src/server/terminal/index.ts +1 -1
package/package.json
CHANGED
package/src/scripts/tui.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { TestServerConfig } from "../server/index.js"
|
|
|
5
5
|
import { startTestServer, updateTestdirectorySchemaFile } from "../server/index.js"
|
|
6
6
|
import type { StdoutOrStderrMessage } from "../server/neovim/NeovimApplication.js"
|
|
7
7
|
import { NeovimApplication } from "../server/neovim/NeovimApplication.js"
|
|
8
|
-
import { prepareNewTestDirectory } from "../server/neovim/
|
|
8
|
+
import { prepareNewTestDirectory } from "../server/neovim/prepareNewTestDirectory.js"
|
|
9
9
|
|
|
10
10
|
//
|
|
11
11
|
// This is the main entrypoint to tui-sandbox
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "assert"
|
|
2
2
|
import { execSync } from "child_process"
|
|
3
3
|
import { Type } from "dree"
|
|
4
|
-
import { constants, readdirSync } from "fs"
|
|
4
|
+
import { constants, readdirSync, statSync } from "fs"
|
|
5
5
|
import { access, mkdir, mkdtemp } from "fs/promises"
|
|
6
6
|
import path from "path"
|
|
7
7
|
import { convertDree, getDirectoryTree } from "../../dirtree/index.js"
|
|
@@ -11,6 +11,8 @@ import { updateTestdirectorySchemaFile } from "../../updateTestdirectorySchemaFi
|
|
|
11
11
|
|
|
12
12
|
export async function createTempDir(config: DirectoriesConfig): Promise<TestDirectory> {
|
|
13
13
|
try {
|
|
14
|
+
// before calling this function, the testEnvironmentPath should already exist
|
|
15
|
+
statSync(config.testEnvironmentPath)
|
|
14
16
|
const dir = await createUniqueDirectory(config.testEnvironmentPath)
|
|
15
17
|
|
|
16
18
|
readdirSync(config.testEnvironmentPath).forEach(entry => {
|
|
@@ -58,6 +60,6 @@ export async function removeTestDirectories(testEnvironmentPath: string): Promis
|
|
|
58
60
|
await access(testdirs, constants.F_OK)
|
|
59
61
|
execSync(`rm -rf ${testdirs}/*`)
|
|
60
62
|
} catch (e) {
|
|
61
|
-
console.
|
|
63
|
+
console.debug("Could not remove test directories, maybe they don't exist yet", e)
|
|
62
64
|
}
|
|
63
65
|
}
|
|
@@ -16,9 +16,9 @@ import type { DirectoriesConfig } from "../updateTestdirectorySchemaFile.js"
|
|
|
16
16
|
import { convertEventEmitterToAsyncGenerator } from "../utilities/generator.js"
|
|
17
17
|
import { Lazy } from "../utilities/Lazy.js"
|
|
18
18
|
import type { TabId } from "../utilities/tabId.js"
|
|
19
|
-
import { createTempDir, removeTestDirectories } from "./environment/createTempDir.js"
|
|
20
19
|
import type { StdoutOrStderrMessage, TerminalDimensions } from "./NeovimApplication.js"
|
|
21
20
|
import { NeovimApplication } from "./NeovimApplication.js"
|
|
21
|
+
import { prepareNewTestDirectory } from "./prepareNewTestDirectory.js"
|
|
22
22
|
|
|
23
23
|
const neovims = new Map<TabId["tabId"], NeovimApplication>()
|
|
24
24
|
const resources: Lazy<AsyncDisposableStack> = new Lazy(() => {
|
|
@@ -97,12 +97,6 @@ export async function start(
|
|
|
97
97
|
return testDirectory
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
export async function prepareNewTestDirectory(config: DirectoriesConfig): Promise<TestDirectory> {
|
|
101
|
-
await removeTestDirectories(config.testEnvironmentPath)
|
|
102
|
-
const testDirectory = await createTempDir(config)
|
|
103
|
-
return testDirectory
|
|
104
|
-
}
|
|
105
|
-
|
|
106
100
|
export async function sendStdin(options: { tabId: TabId; data: string }): Promise<void> {
|
|
107
101
|
const neovim = neovims.get(options.tabId.tabId)
|
|
108
102
|
assert(
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { rm } from "fs/promises"
|
|
2
|
+
import path from "path"
|
|
3
|
+
import { prepareNewTestDirectory } from "./prepareNewTestDirectory.js"
|
|
4
|
+
|
|
5
|
+
describe("prepareNewTestDirectory when the testEnvironmentPath does not exist", () => {
|
|
6
|
+
it("should be able to create a new test directory", async () => {
|
|
7
|
+
// this happens when starting a new project, and the directory structure
|
|
8
|
+
// has not been created yet
|
|
9
|
+
const testEnvironmentPath = "/tmp/test"
|
|
10
|
+
const testDirectory = await prepareNewTestDirectory({
|
|
11
|
+
outputFilePath: path.join(testEnvironmentPath, "foo.ts"),
|
|
12
|
+
testEnvironmentPath,
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
expect(testDirectory.contents).toEqual({})
|
|
17
|
+
expect(testDirectory.testEnvironmentPath).toEqual("/tmp/test")
|
|
18
|
+
} finally {
|
|
19
|
+
// for safety, only remove inside /tmp
|
|
20
|
+
assert(testEnvironmentPath.startsWith("/tmp/"))
|
|
21
|
+
await rm(testEnvironmentPath, { recursive: true })
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { access, mkdir } from "fs/promises"
|
|
2
|
+
import type { TestDirectory } from "../types.js"
|
|
3
|
+
import type { DirectoriesConfig } from "../updateTestdirectorySchemaFile.js"
|
|
4
|
+
import { createTempDir, removeTestDirectories } from "./environment/createTempDir.js"
|
|
5
|
+
|
|
6
|
+
export async function prepareNewTestDirectory(config: DirectoriesConfig): Promise<TestDirectory> {
|
|
7
|
+
try {
|
|
8
|
+
// if the directory does not exist, create it
|
|
9
|
+
await access(config.testEnvironmentPath)
|
|
10
|
+
} catch {
|
|
11
|
+
console.log(`Creating testEnvironmentPath directory at ${config.testEnvironmentPath}`)
|
|
12
|
+
await mkdir(config.testEnvironmentPath, { recursive: true })
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
await removeTestDirectories(config.testEnvironmentPath)
|
|
16
|
+
const testDirectory = await createTempDir(config)
|
|
17
|
+
return testDirectory
|
|
18
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "assert"
|
|
2
2
|
import "core-js/proposals/async-explicit-resource-management.js"
|
|
3
|
-
import { prepareNewTestDirectory } from "../neovim/index.js"
|
|
4
3
|
import type { TerminalDimensions } from "../neovim/NeovimApplication.js"
|
|
4
|
+
import { prepareNewTestDirectory } from "../neovim/prepareNewTestDirectory.js"
|
|
5
5
|
import type { DirectoriesConfig } from "../updateTestdirectorySchemaFile.js"
|
|
6
6
|
import { convertEventEmitterToAsyncGenerator } from "../utilities/generator.js"
|
|
7
7
|
import { Lazy } from "../utilities/Lazy.js"
|