feat(tapbundle_serverside): add network port discovery utilities and migrate file I/O to smartfs; refactor runtimes to use Node fs and SmartFs, update server APIs and bump dependencies
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import * as plugins from './tstest.plugins.js';
|
||||
import * as paths from './tstest.paths.js';
|
||||
import { SmartFile } from '@push.rocks/smartfile';
|
||||
import { type SmartFile, SmartFileFactory } from '@push.rocks/smartfile';
|
||||
import { TestExecutionMode } from './index.js';
|
||||
|
||||
const smartFileFactory = SmartFileFactory.nodeFs();
|
||||
|
||||
// tap related stuff
|
||||
import { TapCombinator } from './tstest.classes.tap.combinator.js';
|
||||
import { TapParser } from './tstest.classes.tap.parser.js';
|
||||
@@ -45,28 +47,28 @@ export class TestDirectory {
|
||||
switch (this.executionMode) {
|
||||
case TestExecutionMode.FILE:
|
||||
// Single file mode
|
||||
const filePath = plugins.path.isAbsolute(this.testPath)
|
||||
? this.testPath
|
||||
const filePath = plugins.path.isAbsolute(this.testPath)
|
||||
? this.testPath
|
||||
: plugins.path.join(this.cwd, this.testPath);
|
||||
|
||||
if (await plugins.smartfile.fs.fileExists(filePath)) {
|
||||
this.testfileArray = [await plugins.smartfile.SmartFile.fromFilePath(filePath)];
|
||||
|
||||
if (await plugins.smartfsInstance.file(filePath).exists()) {
|
||||
this.testfileArray = [await smartFileFactory.fromFilePath(filePath)];
|
||||
} else {
|
||||
throw new Error(`Test file not found: ${filePath}`);
|
||||
}
|
||||
break;
|
||||
|
||||
case TestExecutionMode.GLOB:
|
||||
// Glob pattern mode - use listFileTree which supports glob patterns
|
||||
// Glob pattern mode - use Node.js fs.globSync for full glob support
|
||||
const globPattern = this.testPath;
|
||||
const matchedFiles = await plugins.smartfile.fs.listFileTree(this.cwd, globPattern);
|
||||
|
||||
const matchedFiles = plugins.fs.globSync(globPattern, { cwd: this.cwd });
|
||||
|
||||
this.testfileArray = await Promise.all(
|
||||
matchedFiles.map(async (filePath) => {
|
||||
const absolutePath = plugins.path.isAbsolute(filePath)
|
||||
? filePath
|
||||
matchedFiles.map(async (filePath: string) => {
|
||||
const absolutePath = plugins.path.isAbsolute(filePath)
|
||||
? filePath
|
||||
: plugins.path.join(this.cwd, filePath);
|
||||
return await plugins.smartfile.SmartFile.fromFilePath(absolutePath);
|
||||
return await smartFileFactory.fromFilePath(absolutePath);
|
||||
})
|
||||
);
|
||||
break;
|
||||
@@ -79,19 +81,16 @@ export class TestDirectory {
|
||||
const tsPattern = '**/test*.ts';
|
||||
const dockerPattern = '**/*.docker.sh';
|
||||
|
||||
const [tsFiles, dockerFiles] = await Promise.all([
|
||||
plugins.smartfile.fs.listFileTree(dirPath, tsPattern),
|
||||
plugins.smartfile.fs.listFileTree(dirPath, dockerPattern),
|
||||
]);
|
||||
|
||||
const allTestFiles = [...tsFiles, ...dockerFiles];
|
||||
const tsFiles = plugins.fs.globSync(tsPattern, { cwd: dirPath });
|
||||
const dockerFiles = plugins.fs.globSync(dockerPattern, { cwd: dirPath });
|
||||
const allTestFiles = [...tsFiles, ...dockerFiles] as string[];
|
||||
|
||||
this.testfileArray = await Promise.all(
|
||||
allTestFiles.map(async (filePath) => {
|
||||
const absolutePath = plugins.path.isAbsolute(filePath)
|
||||
? filePath
|
||||
: plugins.path.join(dirPath, filePath);
|
||||
return await plugins.smartfile.SmartFile.fromFilePath(absolutePath);
|
||||
return await smartFileFactory.fromFilePath(absolutePath);
|
||||
})
|
||||
);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user