Skip to content

Commit

Permalink
0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeycherepanov committed Jan 2, 2024
1 parent 8eb51ab commit 407bb7b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 6 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,14 @@
"testEnvironment": "node"
},
"bin": {
"devserver": "./dist/src/devserver.js"
"devserver.sh": "./src/devserver.js"
},
"pkg": {
"scripts": "dist/**/*.js",
"targets": [ "node18-macos-arm64" ],
"outputPath": "pkg"
},
"exports": {
"./package.json": "./package.json"
}
}
6 changes: 3 additions & 3 deletions src/module/vm/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export class VmCreateCommand extends CommandRunner {
password_hash: createHash('sha512').update(answers.password).digest('hex'),
// eslint-disable-next-line newline-per-chained-call
code_server_password_hash: createHash('sha256').update(answers.password).digest('hex'),
public_port: [],
public_port_username: 'web',
public_port_password_hash: apacheMd5('web'),
public_port: answers.public_port.split(","),
public_port_username: answers.public_port_username,
public_port_password_hash: apacheMd5(answers.public_port_password),
});
});
console.log(`Virtual machine created, ID: ${vm.$id}`);
Expand Down
64 changes: 62 additions & 2 deletions src/module/vm/questions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ID } from 'node-appwrite';
import { uniqueNamesGenerator, adjectives, animals } from 'unique-names-generator';

export const questionsVmCreate = [
Expand Down Expand Up @@ -27,7 +28,7 @@ export const questionsVmCreate = [
{
type: 'input',
name: 'username',
message: 'Username (1 - 32 symbols)',
message: 'System Username (1 - 32 symbols)',
default: 'developer',
validate(value: string | any[]) {
if (value.length < 3) {
Expand All @@ -43,12 +44,71 @@ export const questionsVmCreate = [
{
type: 'password',
name: 'password',
message: 'Password (only the hash will be used)',
message: 'System Password (will be hashed)',
mask: '*',
validate(value: string) {
if (!value) {
return "Password can't be empty";
}
if (value.length < 8) {
return 'Minimum length: 8';
}
return true;
},
},
{
type: 'input',
name: 'public_port',
message: 'Public Port(s) (3rd party access)',
default: 'none',
validate(value: string) {
if (value) {
const ports = value.split(",");
for (var i = 0; i < ports.length; i++) {
if (parseInt(ports[i]) < 1025) {
return 'Minimum port is: 1025';
}
if (parseInt(ports[i]) > 65535) {
return 'Maximum port is: 65535';
}
}
}

return true;
},
},
{
type: 'input',
name: 'public_port_username',
message: 'Public Username (1 - 32 symbols)',
default: 'web',
when: (current: { public_port: any; }) => {
return !!current.public_port && current.public_port != 'none';
},
validate(value: string | any[]) {
if (value.length < 3) {
return 'Minimum length: 3';
}
if (value.length > 32) {
return 'Maximum length: 32';
}

return true;
},
},
{
type: 'public_port_password',
name: 'public_port_password',
message: 'Public Password (will be hashed)',
mask: '*',
when: (current: { public_port: any; }) => {
return !!current.public_port && current.public_port != 'none';
},
validate(value: string) {
if (!value) {
return "Password can't be empty";
}

return true;
},
},
Expand Down

0 comments on commit 407bb7b

Please sign in to comment.