@hardkas/node-runner 0.2.2-alpha → 0.2.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6 -1
- package/dist/index.js +24 -6
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -33,9 +33,14 @@ declare class DockerKaspadRunner {
|
|
|
33
33
|
start(): Promise<KaspadNodeStatus>;
|
|
34
34
|
stop(): Promise<KaspadNodeStatus>;
|
|
35
35
|
status(): Promise<KaspadNodeStatus>;
|
|
36
|
+
restart(): Promise<KaspadNodeStatus>;
|
|
37
|
+
reset(options?: {
|
|
38
|
+
removeData?: boolean;
|
|
39
|
+
}): Promise<KaspadNodeStatus>;
|
|
36
40
|
logs(options?: {
|
|
37
41
|
tail?: number;
|
|
38
|
-
|
|
42
|
+
follow?: boolean;
|
|
43
|
+
}): Promise<string | void>;
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
export { DEFAULT_CONTAINER_NAME, DEFAULT_IMAGE, DEFAULT_NETWORK, DEFAULT_PORTS, type DockerKaspadOptions, DockerKaspadRunner, type KaspadNetwork, type KaspadNodeStatus, type KaspadPorts };
|
package/dist/index.js
CHANGED
|
@@ -111,15 +111,33 @@ var DockerKaspadRunner = class {
|
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
+
async restart() {
|
|
115
|
+
await this.stop();
|
|
116
|
+
return this.start();
|
|
117
|
+
}
|
|
118
|
+
async reset(options = { removeData: true }) {
|
|
119
|
+
await this.stop();
|
|
120
|
+
if (options.removeData) {
|
|
121
|
+
const absoluteDataDir = path.isAbsolute(this.options.dataDir) ? this.options.dataDir : path.resolve(this.options.cwd, this.options.dataDir);
|
|
122
|
+
if (existsSync(absoluteDataDir)) {
|
|
123
|
+
await fs.rm(absoluteDataDir, { recursive: true, force: true });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return this.status();
|
|
127
|
+
}
|
|
114
128
|
async logs(options) {
|
|
115
129
|
try {
|
|
116
130
|
const tail = options?.tail || 100;
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
131
|
+
const args = ["logs", "--tail", tail.toString()];
|
|
132
|
+
if (options?.follow) {
|
|
133
|
+
args.push("-f");
|
|
134
|
+
await execa("docker", [...args, this.options.containerName], {
|
|
135
|
+
stdout: "inherit",
|
|
136
|
+
stderr: "inherit"
|
|
137
|
+
});
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const { stdout } = await execa("docker", [...args, this.options.containerName]);
|
|
123
141
|
return stdout;
|
|
124
142
|
} catch (e) {
|
|
125
143
|
throw new Error(`Could not get logs for container ${this.options.containerName}. Is it running?`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardkas/node-runner",
|
|
3
|
-
"version": "0.2.2-alpha",
|
|
3
|
+
"version": "0.2.2-alpha.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"tsup": "^8.3.5",
|
|
12
12
|
"typescript": "^5.7.2",
|
|
13
13
|
"vitest": "^2.1.8",
|
|
14
|
-
"@hardkas/config": "0.2.2-alpha"
|
|
14
|
+
"@hardkas/config": "0.2.2-alpha.1"
|
|
15
15
|
},
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"author": "Javier Rodriguez",
|