feat(tapnodetools): Add TestFileProvider for handling Docker Alpine image

This commit is contained in:
2024-11-06 21:07:05 +01:00
parent c54493ddbc
commit 36903d2d6c
8 changed files with 56 additions and 11 deletions

View File

@ -1,7 +1,9 @@
import { TestFileProvider } from './classes.testfileprovider.js';
import * as plugins from './plugins.js';
class TapNodeTools {
private smartshellInstance: plugins.smartshell.Smartshell;
public testFileProvider = new TestFileProvider();
constructor() {}

View File

@ -0,0 +1,17 @@
import * as plugins from './plugins.js';
import * as paths from './paths.js';
export const fileUrls = {
dockerAlpineImage: 'https://code.foss.global/testassets/docker/raw/branch/main/alpine.tar',
}
export class TestFileProvider {
public async getDockerAlpineImageAsLocalTarball(): Promise<string> {
const filePath = plugins.path.join(paths.testFilesDir, 'alpine.tar')
// fetch the docker alpine image
const response = await plugins.smartrequest.getBinary(fileUrls.dockerAlpineImage);
await plugins.smartfile.fs.ensureDir(paths.testFilesDir);
const AlpineBuffer = await plugins.smartfile.memory.toFs(response.body, filePath);
return filePath;
}
}

4
ts_node/paths.ts Normal file
View File

@ -0,0 +1,4 @@
import * as plugins from './plugins.js';
export const cwd = process.cwd();
export const testFilesDir = plugins.path.join(cwd, './.nogit/testfiles/');

View File

@ -1,12 +1,16 @@
// node native
import * as crypto from 'crypto';
import * as fs from 'fs';
import * as path from 'path';
export { crypto,fs };
export { crypto,fs, path, };
// @push.rocks scope
import * as qenv from '@push.rocks/qenv';
import * as smartcrypto from '@push.rocks/smartcrypto';
import * as smartfile from '@push.rocks/smartfile';
import * as smartpath from '@push.rocks/smartpath';
import * as smartrequest from '@push.rocks/smartrequest';
import * as smartshell from '@push.rocks/smartshell';
export { qenv, smartcrypto, smartshell };
export { qenv, smartcrypto, smartfile, smartpath, smartrequest, smartshell, };