Skip to content

Commit 3fbdb2e

Browse files
icebobkylecarbs
authored andcommitted
Implement #4 - fix password via CLI (#5)
1 parent 1d8da21 commit 3fbdb2e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

doc/self-hosted/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ OPTIONS
4848
-v, --version show CLI version
4949
--cert=cert
5050
--cert-key=cert-key
51+
--password=password
5152
--help show CLI help
5253
```
5354

packages/server/src/cli.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class Entry extends Command {
2626
version: flags.version({ char: "v" }),
2727
"no-auth": flags.boolean({ default: false }),
2828
"allow-http": flags.boolean({ default: false }),
29+
password: flags.string(),
2930

3031
// Dev flags
3132
"bootstrap-fork": flags.string({ hidden: true }),
@@ -132,13 +133,17 @@ export class Entry extends Command {
132133
}
133134
});
134135

135-
const passwordLength = 12;
136-
const possible = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
137-
const chars = [];
138-
for (let i = 0; i < passwordLength; i++) {
139-
chars.push(possible[Math.floor(Math.random() * possible.length)]);
136+
let password = flags["password"];
137+
if (!password) {
138+
// Generate a random password
139+
const passwordLength = 12;
140+
const possible = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
141+
const chars = [];
142+
for (let i = 0; i < passwordLength; i++) {
143+
chars.push(possible[Math.floor(Math.random() * possible.length)]);
144+
}
145+
password = chars.join("");
140146
}
141-
const password = chars.join("");
142147

143148
const hasCustomHttps = certData && certKeyData;
144149
const app = await createApp({

0 commit comments

Comments
 (0)