From 36903d2d6c1dc5fd00b0ec38ea067c81e1ad687f Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Wed, 6 Nov 2024 21:07:05 +0100 Subject: [PATCH] feat(tapnodetools): Add TestFileProvider for handling Docker Alpine image --- changelog.md | 6 ++++++ package.json | 3 +++ pnpm-lock.yaml | 25 +++++++++++++++++-------- ts/00_commitinfo_data.ts | 2 +- ts_node/classes.tapnodetools.ts | 2 ++ ts_node/classes.testfileprovider.ts | 17 +++++++++++++++++ ts_node/paths.ts | 4 ++++ ts_node/plugins.ts | 8 ++++++-- 8 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 ts_node/classes.testfileprovider.ts create mode 100644 ts_node/paths.ts diff --git a/changelog.md b/changelog.md index 5a8aabc..00db4a3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2024-11-06 - 5.5.0 - feat(tapnodetools) +Add TestFileProvider for handling Docker Alpine image + +- Introduced TestFileProvider in TapNodeTools. +- Added method to retrieve Docker Alpine image as a local tarball. + ## 2024-11-06 - 5.4.4 - fix(dependencies) Update smarts3 dependency to version 2.2.5 diff --git a/package.json b/package.json index 9b3b8bc..35d170c 100644 --- a/package.json +++ b/package.json @@ -31,9 +31,12 @@ "@push.rocks/smartdelay": "^3.0.5", "@push.rocks/smartenv": "^5.0.12", "@push.rocks/smartexpect": "^1.2.1", + "@push.rocks/smartfile": "^11.0.21", "@push.rocks/smartjson": "^5.0.20", "@push.rocks/smartmongo": "^2.0.10", + "@push.rocks/smartpath": "^5.0.18", "@push.rocks/smartpromise": "^4.0.4", + "@push.rocks/smartrequest": "^2.0.23", "@push.rocks/smarts3": "^2.2.5", "@push.rocks/smartshell": "^3.0.6", "@push.rocks/smarttime": "^4.0.8" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ce1a633..ee67744 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,15 +26,24 @@ dependencies: '@push.rocks/smartexpect': specifier: ^1.2.1 version: 1.2.1 + '@push.rocks/smartfile': + specifier: ^11.0.21 + version: 11.0.21 '@push.rocks/smartjson': specifier: ^5.0.20 version: 5.0.20 '@push.rocks/smartmongo': specifier: ^2.0.10 version: 2.0.10(@aws-sdk/client-sso-oidc@3.682.0) + '@push.rocks/smartpath': + specifier: ^5.0.18 + version: 5.0.18 '@push.rocks/smartpromise': specifier: ^4.0.4 version: 4.0.4 + '@push.rocks/smartrequest': + specifier: ^2.0.23 + version: 2.0.23 '@push.rocks/smarts3': specifier: ^2.2.5 version: 2.2.5 @@ -108,7 +117,7 @@ packages: '@push.rocks/smartopen': 2.0.0 '@push.rocks/smartpath': 5.0.18 '@push.rocks/smartpromise': 4.0.4 - '@push.rocks/smartrequest': 2.0.22 + '@push.rocks/smartrequest': 2.0.23 '@push.rocks/smartrx': 3.0.7 '@push.rocks/smartsitemap': 2.0.3 '@push.rocks/smartstream': 3.2.4 @@ -1733,7 +1742,7 @@ packages: '@push.rocks/smartfile': 10.0.41 '@push.rocks/smartpath': 5.0.18 '@push.rocks/smartpromise': 4.0.4 - '@push.rocks/smartrequest': 2.0.22 + '@push.rocks/smartrequest': 2.0.23 '@push.rocks/smartrx': 3.0.7 '@push.rocks/smartstream': 2.0.8 '@push.rocks/smartunique': 3.0.9 @@ -1903,7 +1912,7 @@ packages: '@push.rocks/smartmime': 1.0.6 '@push.rocks/smartpath': 5.0.18 '@push.rocks/smartpromise': 4.0.4 - '@push.rocks/smartrequest': 2.0.22 + '@push.rocks/smartrequest': 2.0.23 '@push.rocks/smartstream': 2.0.8 '@types/fs-extra': 11.0.4 '@types/glob': 8.1.0 @@ -1924,7 +1933,7 @@ packages: '@push.rocks/smartmime': 2.0.2 '@push.rocks/smartpath': 5.0.18 '@push.rocks/smartpromise': 4.0.4 - '@push.rocks/smartrequest': 2.0.22 + '@push.rocks/smartrequest': 2.0.23 '@push.rocks/smartstream': 3.2.4 '@types/fs-extra': 11.0.4 '@types/glob': 8.1.0 @@ -1937,7 +1946,7 @@ packages: resolution: {integrity: sha512-J23q84f1O+TwFGmd4lrO9XLHUh2DaLXo9PN/9VmTWYzTkQDv5JehmifXVI0esophXcCIfbdIu6hbt7/aHlDF4A==} dependencies: '@push.rocks/smartpromise': 4.0.4 - '@push.rocks/smartrequest': 2.0.22 + '@push.rocks/smartrequest': 2.0.23 /@push.rocks/smarthash@3.0.4: resolution: {integrity: sha512-HJ/fSx41jm0CvSaqMLa6b2nuNK5rHAqAeAq3dAB7Sq9BCPm2M0J5ZVDTzEAH8pS91XYniUiwuE0jwPERNn9hmw==} @@ -2063,7 +2072,7 @@ packages: '@push.rocks/smartfile': 10.0.41 '@push.rocks/smartpath': 5.0.18 '@push.rocks/smartpromise': 4.0.4 - '@push.rocks/smartrequest': 2.0.22 + '@push.rocks/smartrequest': 2.0.23 '@push.rocks/smarttime': 4.0.8 '@push.rocks/smartversion': 3.0.5 package-json: 8.1.1 @@ -2137,8 +2146,8 @@ packages: - utf-8-validate dev: true - /@push.rocks/smartrequest@2.0.22: - resolution: {integrity: sha512-EfgmdEsLtDJ8aNOLOh59ca1NMsiiFz54aoHRigQFQ0cuoUs6phxejIY2FdMoPFn68ubTpkztdL2P4L1/cRYyHg==} + /@push.rocks/smartrequest@2.0.23: + resolution: {integrity: sha512-y+gtOwXFpmPL+mIQblYPdFuHufxHi5lMV0LKm5bPYgGdMq3/+QlnEqNEAumeMHjvXgxur7x30QiHSwpJGK5g9w==} dependencies: '@push.rocks/smartpromise': 4.0.4 '@push.rocks/smarturl': 3.1.0 diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index c598793..e5f6df6 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/tapbundle', - version: '5.4.4', + version: '5.5.0', description: 'A test automation library bundling utilities and tools for TAP (Test Anything Protocol) based testing, specifically tailored for tapbuffer.' } diff --git a/ts_node/classes.tapnodetools.ts b/ts_node/classes.tapnodetools.ts index f7e35ff..d6436f0 100644 --- a/ts_node/classes.tapnodetools.ts +++ b/ts_node/classes.tapnodetools.ts @@ -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() {} diff --git a/ts_node/classes.testfileprovider.ts b/ts_node/classes.testfileprovider.ts new file mode 100644 index 0000000..27e2478 --- /dev/null +++ b/ts_node/classes.testfileprovider.ts @@ -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 { + 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; + } +} \ No newline at end of file diff --git a/ts_node/paths.ts b/ts_node/paths.ts new file mode 100644 index 0000000..0b25d16 --- /dev/null +++ b/ts_node/paths.ts @@ -0,0 +1,4 @@ +import * as plugins from './plugins.js'; + +export const cwd = process.cwd(); +export const testFilesDir = plugins.path.join(cwd, './.nogit/testfiles/'); \ No newline at end of file diff --git a/ts_node/plugins.ts b/ts_node/plugins.ts index e51a2ab..3e5182e 100644 --- a/ts_node/plugins.ts +++ b/ts_node/plugins.ts @@ -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, };