fix(deps): upgrade core tooling dependencies and adapt Docker client internals for compatibility

This commit is contained in:
2026-03-28 05:39:48 +00:00
parent 1923837225
commit 645e1fd4a9
19 changed files with 5861 additions and 7164 deletions

View File

@@ -29,7 +29,7 @@ export class DockerHost {
public socketPath: string;
private registryToken: string = '';
private imageStore: DockerImageStore; // Now private - use storeImage/retrieveImage instead
public smartBucket: plugins.smartbucket.SmartBucket;
public smartBucket!: plugins.smartbucket.SmartBucket;
/**
* the constructor to instantiate a new docker sock instance
@@ -64,8 +64,8 @@ export class DockerHost {
console.log(`using docker sock at ${pathToUse}`);
this.socketPath = pathToUse;
this.imageStore = new DockerImageStore({
bucketDir: null,
localDirPath: this.options.imageStoreDir,
bucketDir: null!,
localDirPath: this.options.imageStoreDir!,
});
}
@@ -74,6 +74,9 @@ export class DockerHost {
}
public async stop() {
await this.imageStore.stop();
if (this.smartBucket) {
this.smartBucket.storageClient.destroy();
}
}
/**
@@ -131,7 +134,7 @@ export class DockerHost {
const dockerConfigPath = plugins.smartpath.get.home(
'~/.docker/config.json',
);
const configObject = plugins.smartfile.fs.toObjectSync(dockerConfigPath);
const configObject = JSON.parse(plugins.fs.readFileSync(dockerConfigPath, 'utf8'));
const gitlabAuthBase64 = configObject.auths[registryUrlArg].auth;
const gitlabAuth: string =
plugins.smartstring.base64.decode(gitlabAuthBase64);
@@ -379,8 +382,14 @@ export class DockerHost {
console.log(e);
}
});
nodeStream.on('error', (err) => {
// Connection resets are expected when the stream is destroyed
if ((err as any).code !== 'ECONNRESET') {
observer.error(err);
}
});
return () => {
nodeStream.emit('end');
nodeStream.destroy();
};
});
}
@@ -390,14 +399,19 @@ export class DockerHost {
*/
public async activateSwarm(addvertisementIpArg?: string) {
// determine advertisement address
let addvertisementIp: string;
let addvertisementIp: string = '';
if (addvertisementIpArg) {
addvertisementIp = addvertisementIpArg;
} else {
const smartnetworkInstance = new plugins.smartnetwork.SmartNetwork();
const defaultGateway = await smartnetworkInstance.getDefaultGateway();
if (defaultGateway) {
addvertisementIp = defaultGateway.ipv4.address;
try {
const smartnetworkInstance = new plugins.smartnetwork.SmartNetwork();
const defaultGateway = await smartnetworkInstance.getDefaultGateway();
if (defaultGateway) {
addvertisementIp = defaultGateway.ipv4.address;
}
} catch (err) {
// Failed to determine default gateway (e.g. in Deno without --allow-run)
// Docker will auto-detect the advertise address
}
}
@@ -502,7 +516,7 @@ export class DockerHost {
routeArg: string,
readStream?: plugins.smartstream.stream.Readable,
jsonData?: any,
) {
): Promise<plugins.smartstream.stream.Readable | { statusCode: number; body: string; headers: any }> {
const requestUrl = `${this.socketPath}${routeArg}`;
// Build the request using the fluent API
@@ -579,6 +593,10 @@ export class DockerHost {
// Convert web ReadableStream to Node.js stream for backward compatibility
const nodeStream = plugins.smartstream.nodewebhelpers.convertWebReadableToNodeReadable(webStream);
// Add a default error handler to prevent unhandled 'error' events from crashing the process.
// Callers that attach their own 'error' listener will still receive the event.
nodeStream.on('error', () => {});
// Add properties for compatibility
(nodeStream as any).statusCode = response.status;
(nodeStream as any).body = ''; // For compatibility