-
Notifications
You must be signed in to change notification settings - Fork 472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker SDK Usage #432
Docker SDK Usage #432
Conversation
|
"e2b": "^0.16.2", | ||
"inquirer": "^9.2.12", | ||
"open": "^9.1.0", | ||
"ssh2": "^1.15.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added as a peer of dockerode
, resolves issue in testing:
Can't resolve './crypto/build/Release/sshcrypto.node'
Related:
@@ -0,0 +1,118 @@ | |||
import * as e2b from 'e2b' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file was moved from /template/build.js
for readability and mocking in the added tests.
@@ -13,7 +13,7 @@ export default defineConfig({ | |||
sourcemap: true, | |||
clean: true, | |||
noExternal: Object.keys(packageJSON.dependencies).filter( | |||
f => !excludedPackages.includes(f) | |||
(f) => !excludedPackages.includes(f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that if I use either:
- vscode prettier
npx prettier --fix
npx eslint --fix
They all are formatting the code in different ways, is this known, or a problem with my local environment?
@@ -0,0 +1,158 @@ | |||
import { test, expect, describe, vi, afterEach } from 'vitest' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests can be executed in the packages/cli
directory using pnpm test:unit
command, they use vitest to mock the commander template build command. The final test "should perform a build" will mock all points of the build, from requesting and saving a template to pushing and building with docker.
What?
child_process
Why
Using
child_process
can be brittle and there are already tested tools that allow us to interact with Docker programmatically, we should use those for better readability and maintainability.The CLI had few tests, so to make assertive changes here, I first added coverage for the CLI and then returned to make the dockerode / SDK changes.
How
Usage of npm package https://github.com/apocas/dockerode replaces
child_process
calls.Vitest is added under
pnpm test:unit
in the CLI package, mocks are used to interact with and assert the CLI.Refactors have been made for readability and to enable the mocking of modules in tests.