dhti-cli 0.7.0 → 0.7.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/commands/docker.d.ts +2 -0
- package/dist/commands/docker.js +34 -1
- package/oclif.manifest.json +16 -1
- package/package.json +1 -1
|
@@ -10,7 +10,9 @@ export default class Docker extends Command {
|
|
|
10
10
|
down: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
11
|
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
12
|
file: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
gateway: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
14
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
restart: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
16
|
type: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
17
|
up: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
18
|
};
|
package/dist/commands/docker.js
CHANGED
|
@@ -27,7 +27,9 @@ export default class Docker extends Command {
|
|
|
27
27
|
default: `${os.homedir()}/dhti/docker-compose.yml`,
|
|
28
28
|
description: 'Full path to the docker compose file to edit or run.',
|
|
29
29
|
}),
|
|
30
|
+
gateway: Flags.boolean({ char: 'g', default: false, description: 'Restart the gateway container' }),
|
|
30
31
|
name: Flags.string({ char: 'n', description: 'Name of the container to build' }),
|
|
32
|
+
restart: Flags.string({ char: 'r', description: 'Restart a specific container by name' }),
|
|
31
33
|
type: Flags.string({ char: 't', default: 'elixir', description: 'Type of the service (elixir/conch)' }),
|
|
32
34
|
up: Flags.boolean({ char: 'u', default: false, description: 'Run docker-compose up after building' }),
|
|
33
35
|
};
|
|
@@ -67,7 +69,38 @@ export default class Docker extends Command {
|
|
|
67
69
|
});
|
|
68
70
|
return;
|
|
69
71
|
}
|
|
70
|
-
if (
|
|
72
|
+
if (flags.gateway || flags.restart) {
|
|
73
|
+
// Validate that only one restart option is provided
|
|
74
|
+
if (flags.gateway && flags.restart) {
|
|
75
|
+
console.error('Error: Cannot use both --gateway and --restart flags at the same time');
|
|
76
|
+
this.exit(1);
|
|
77
|
+
}
|
|
78
|
+
const containerName = flags.gateway ? 'dhti-gateway-1' : flags.restart;
|
|
79
|
+
// Validate container name to prevent command injection
|
|
80
|
+
if (containerName && !/^[\w-]+$/.test(containerName)) {
|
|
81
|
+
console.error('Error: Invalid container name. Container names can only contain letters, numbers, hyphens, and underscores.');
|
|
82
|
+
this.exit(1);
|
|
83
|
+
}
|
|
84
|
+
const restartCommand = `docker restart ${containerName}`;
|
|
85
|
+
if (flags['dry-run']) {
|
|
86
|
+
console.log(chalk.yellow('[DRY RUN] Would execute:'));
|
|
87
|
+
console.log(chalk.cyan(` ${restartCommand}`));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
exec(restartCommand, (error, stdout, stderr) => {
|
|
91
|
+
if (error) {
|
|
92
|
+
console.error(`exec error: ${error}`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
console.log(`Successfully restarted container: ${containerName}`);
|
|
96
|
+
if (stdout)
|
|
97
|
+
console.log(`stdout: ${stdout}`);
|
|
98
|
+
if (stderr)
|
|
99
|
+
console.error(`stderr: ${stderr}`);
|
|
100
|
+
});
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (args.path !== 'bootstrap' && !flags.name && !flags.up && !flags.down && !flags.gateway && !flags.restart) {
|
|
71
104
|
console.log('Please provide a name for the container to build');
|
|
72
105
|
this.exit(1);
|
|
73
106
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -203,6 +203,13 @@
|
|
|
203
203
|
"multiple": false,
|
|
204
204
|
"type": "option"
|
|
205
205
|
},
|
|
206
|
+
"gateway": {
|
|
207
|
+
"char": "g",
|
|
208
|
+
"description": "Restart the gateway container",
|
|
209
|
+
"name": "gateway",
|
|
210
|
+
"allowNo": false,
|
|
211
|
+
"type": "boolean"
|
|
212
|
+
},
|
|
206
213
|
"name": {
|
|
207
214
|
"char": "n",
|
|
208
215
|
"description": "Name of the container to build",
|
|
@@ -211,6 +218,14 @@
|
|
|
211
218
|
"multiple": false,
|
|
212
219
|
"type": "option"
|
|
213
220
|
},
|
|
221
|
+
"restart": {
|
|
222
|
+
"char": "r",
|
|
223
|
+
"description": "Restart a specific container by name",
|
|
224
|
+
"name": "restart",
|
|
225
|
+
"hasDynamicHelp": false,
|
|
226
|
+
"multiple": false,
|
|
227
|
+
"type": "option"
|
|
228
|
+
},
|
|
214
229
|
"type": {
|
|
215
230
|
"char": "t",
|
|
216
231
|
"description": "Type of the service (elixir/conch)",
|
|
@@ -741,5 +756,5 @@
|
|
|
741
756
|
]
|
|
742
757
|
}
|
|
743
758
|
},
|
|
744
|
-
"version": "0.7.
|
|
759
|
+
"version": "0.7.1"
|
|
745
760
|
}
|