vaultfs 1.0.3 → 1.0.4
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/README.md +139 -232
- package/bin/postinstall.js +138 -129
- package/bin/vaultfs-npm.js +148 -147
- package/package.json +34 -34
- package/src/auth/AuthConfig.java +9 -9
- package/src/auth/AuthManager.java +267 -267
- package/version.txt +1 -1
package/bin/postinstall.js
CHANGED
|
@@ -1,129 +1,138 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const { execSync } = require("child_process");
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const os = require("os");
|
|
6
|
-
|
|
7
|
-
// ─── Colors ──────────────────────────────────────────────────
|
|
8
|
-
const RESET = "\x1b[0m";
|
|
9
|
-
const BOLD = "\x1b[1m";
|
|
10
|
-
const RED = "\x1b[31m";
|
|
11
|
-
const GREEN = "\x1b[32m";
|
|
12
|
-
const CYAN = "\x1b[36m";
|
|
13
|
-
const DIM = "\x1b[2m";
|
|
14
|
-
|
|
15
|
-
function success(msg) { console.log(` ${GREEN}✓${RESET} ${msg}`); }
|
|
16
|
-
function error(msg) { console.log(` ${RED}✗${RESET} ${msg}`); }
|
|
17
|
-
function info(msg) { console.log(` ${CYAN}→${RESET} ${msg}`); }
|
|
18
|
-
|
|
19
|
-
// ─── Banner ──────────────────────────────────────────────────
|
|
20
|
-
console.log("");
|
|
21
|
-
console.log(`${CYAN}${BOLD} ╔══════════════════════════════════════════════╗${RESET}`);
|
|
22
|
-
console.log(`${CYAN}${BOLD} ║ ║${RESET}`);
|
|
23
|
-
console.log(`${CYAN}${BOLD} ║ ${GREEN}▓▓ VaultFS — Running post-install setup${CYAN} ║${RESET}`);
|
|
24
|
-
console.log(`${CYAN}${BOLD} ║ ║${RESET}`);
|
|
25
|
-
console.log(`${CYAN}${BOLD} ╚══════════════════════════════════════════════╝${RESET}`);
|
|
26
|
-
console.log("");
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
// ─── Detect OS ─────────────────────────────────────────────
|
|
30
|
-
const platform = process.platform; // win32, darwin, linux
|
|
31
|
-
const platformName =
|
|
32
|
-
platform === "win32" ? "Windows" :
|
|
33
|
-
platform === "darwin" ? "macOS" : "Linux";
|
|
34
|
-
success(`OS detected: ${BOLD}${platformName}${RESET}`);
|
|
35
|
-
|
|
36
|
-
// ─── Check Java 11+ ───────────────────────────────────────
|
|
37
|
-
let javaVersion;
|
|
38
|
-
try {
|
|
39
|
-
const javaOut = execSync("java -version 2>&1", { encoding: "utf8" });
|
|
40
|
-
const match = javaOut.match(/"(\d+)/);
|
|
41
|
-
javaVersion = match ? parseInt(match[1], 10) : 0;
|
|
42
|
-
} catch {
|
|
43
|
-
javaVersion = 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (javaVersion < 11) {
|
|
47
|
-
error(`${RED}Java 11+ is required${javaVersion > 0 ? ` (found Java ${javaVersion})` : " (not found)"}.${RESET}`);
|
|
48
|
-
console.log("");
|
|
49
|
-
console.log(` Download Java from: ${CYAN}https://adoptium.net${RESET}`);
|
|
50
|
-
console.log("");
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
success(`Java ${BOLD}${javaVersion}${RESET} found`);
|
|
54
|
-
|
|
55
|
-
// ─── Install directory ─────────────────────────────────────
|
|
56
|
-
const installDir = path.join(os.homedir(), ".vaultfs");
|
|
57
|
-
|
|
58
|
-
if (fs.existsSync(installDir) && fs.existsSync(path.join(installDir, "out", "Main.class"))) {
|
|
59
|
-
info("Already installed, skipping build.");
|
|
60
|
-
console.log("");
|
|
61
|
-
console.log(` ${GREEN}${BOLD}✅ VaultFS is ready!${RESET} Type ${CYAN}vaultfs${RESET} to launch.`);
|
|
62
|
-
console.log("");
|
|
63
|
-
process.exit(0);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// ─── Copy package contents into install dir ────────────────
|
|
67
|
-
info(`Setting up ${DIM}${installDir}${RESET}...`);
|
|
68
|
-
|
|
69
|
-
if (!fs.existsSync(installDir)) {
|
|
70
|
-
fs.mkdirSync(installDir, { recursive: true });
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Resolve the package root (one level up from bin/)
|
|
74
|
-
const pkgRoot = path.resolve(__dirname, "..");
|
|
75
|
-
|
|
76
|
-
const toCopy = ["src", "frontend", "version.txt", ".env.example"];
|
|
77
|
-
for (const item of toCopy) {
|
|
78
|
-
const src = path.join(pkgRoot, item);
|
|
79
|
-
const dest = path.join(installDir, item);
|
|
80
|
-
if (!fs.existsSync(src)) continue;
|
|
81
|
-
|
|
82
|
-
const stat = fs.statSync(src);
|
|
83
|
-
if (stat.isDirectory()) {
|
|
84
|
-
fs.cpSync(src, dest, { recursive: true, force: true });
|
|
85
|
-
} else {
|
|
86
|
-
// Ensure parent dir exists
|
|
87
|
-
const parent = path.dirname(dest);
|
|
88
|
-
if (!fs.existsSync(parent)) fs.mkdirSync(parent, { recursive: true });
|
|
89
|
-
fs.copyFileSync(src, dest);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
success("Source files copied");
|
|
93
|
-
|
|
94
|
-
// ─── Platform-aware commands ───────────────────────────────
|
|
95
|
-
const npmCmd = platform === "win32" ? "npm.cmd" : "npm";
|
|
96
|
-
const npxCmd = platform === "win32" ? "npx.cmd" : "npx";
|
|
97
|
-
|
|
98
|
-
// ─── Build frontend ────────────────────────────────────────
|
|
99
|
-
info("Installing frontend dependencies...");
|
|
100
|
-
const frontendDir = path.join(installDir, "frontend");
|
|
101
|
-
execSync(`${npmCmd} install`, {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
success("
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
execSync("
|
|
111
|
-
cwd:
|
|
112
|
-
stdio: "inherit",
|
|
113
|
-
shell: true
|
|
114
|
-
});
|
|
115
|
-
success("
|
|
116
|
-
|
|
117
|
-
// ───
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
console.log("");
|
|
128
|
-
|
|
129
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execSync } = require("child_process");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
|
|
7
|
+
// ─── Colors ──────────────────────────────────────────────────
|
|
8
|
+
const RESET = "\x1b[0m";
|
|
9
|
+
const BOLD = "\x1b[1m";
|
|
10
|
+
const RED = "\x1b[31m";
|
|
11
|
+
const GREEN = "\x1b[32m";
|
|
12
|
+
const CYAN = "\x1b[36m";
|
|
13
|
+
const DIM = "\x1b[2m";
|
|
14
|
+
|
|
15
|
+
function success(msg) { console.log(` ${GREEN}✓${RESET} ${msg}`); }
|
|
16
|
+
function error(msg) { console.log(` ${RED}✗${RESET} ${msg}`); }
|
|
17
|
+
function info(msg) { console.log(` ${CYAN}→${RESET} ${msg}`); }
|
|
18
|
+
|
|
19
|
+
// ─── Banner ──────────────────────────────────────────────────
|
|
20
|
+
console.log("");
|
|
21
|
+
console.log(`${CYAN}${BOLD} ╔══════════════════════════════════════════════╗${RESET}`);
|
|
22
|
+
console.log(`${CYAN}${BOLD} ║ ║${RESET}`);
|
|
23
|
+
console.log(`${CYAN}${BOLD} ║ ${GREEN}▓▓ VaultFS — Running post-install setup${CYAN} ║${RESET}`);
|
|
24
|
+
console.log(`${CYAN}${BOLD} ║ ║${RESET}`);
|
|
25
|
+
console.log(`${CYAN}${BOLD} ╚══════════════════════════════════════════════╝${RESET}`);
|
|
26
|
+
console.log("");
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
// ─── Detect OS ─────────────────────────────────────────────
|
|
30
|
+
const platform = process.platform; // win32, darwin, linux
|
|
31
|
+
const platformName =
|
|
32
|
+
platform === "win32" ? "Windows" :
|
|
33
|
+
platform === "darwin" ? "macOS" : "Linux";
|
|
34
|
+
success(`OS detected: ${BOLD}${platformName}${RESET}`);
|
|
35
|
+
|
|
36
|
+
// ─── Check Java 11+ ───────────────────────────────────────
|
|
37
|
+
let javaVersion;
|
|
38
|
+
try {
|
|
39
|
+
const javaOut = execSync("java -version 2>&1", { encoding: "utf8" });
|
|
40
|
+
const match = javaOut.match(/"(\d+)/);
|
|
41
|
+
javaVersion = match ? parseInt(match[1], 10) : 0;
|
|
42
|
+
} catch {
|
|
43
|
+
javaVersion = 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (javaVersion < 11) {
|
|
47
|
+
error(`${RED}Java 11+ is required${javaVersion > 0 ? ` (found Java ${javaVersion})` : " (not found)"}.${RESET}`);
|
|
48
|
+
console.log("");
|
|
49
|
+
console.log(` Download Java from: ${CYAN}https://adoptium.net${RESET}`);
|
|
50
|
+
console.log("");
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
success(`Java ${BOLD}${javaVersion}${RESET} found`);
|
|
54
|
+
|
|
55
|
+
// ─── Install directory ─────────────────────────────────────
|
|
56
|
+
const installDir = path.join(os.homedir(), ".vaultfs");
|
|
57
|
+
|
|
58
|
+
if (fs.existsSync(installDir) && fs.existsSync(path.join(installDir, "out", "Main.class"))) {
|
|
59
|
+
info("Already installed, skipping build.");
|
|
60
|
+
console.log("");
|
|
61
|
+
console.log(` ${GREEN}${BOLD}✅ VaultFS is ready!${RESET} Type ${CYAN}vaultfs${RESET} to launch.`);
|
|
62
|
+
console.log("");
|
|
63
|
+
process.exit(0);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ─── Copy package contents into install dir ────────────────
|
|
67
|
+
info(`Setting up ${DIM}${installDir}${RESET}...`);
|
|
68
|
+
|
|
69
|
+
if (!fs.existsSync(installDir)) {
|
|
70
|
+
fs.mkdirSync(installDir, { recursive: true });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Resolve the package root (one level up from bin/)
|
|
74
|
+
const pkgRoot = path.resolve(__dirname, "..");
|
|
75
|
+
|
|
76
|
+
const toCopy = ["src", "frontend", "version.txt", ".env.example"];
|
|
77
|
+
for (const item of toCopy) {
|
|
78
|
+
const src = path.join(pkgRoot, item);
|
|
79
|
+
const dest = path.join(installDir, item);
|
|
80
|
+
if (!fs.existsSync(src)) continue;
|
|
81
|
+
|
|
82
|
+
const stat = fs.statSync(src);
|
|
83
|
+
if (stat.isDirectory()) {
|
|
84
|
+
fs.cpSync(src, dest, { recursive: true, force: true });
|
|
85
|
+
} else {
|
|
86
|
+
// Ensure parent dir exists
|
|
87
|
+
const parent = path.dirname(dest);
|
|
88
|
+
if (!fs.existsSync(parent)) fs.mkdirSync(parent, { recursive: true });
|
|
89
|
+
fs.copyFileSync(src, dest);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
success("Source files copied");
|
|
93
|
+
|
|
94
|
+
// ─── Platform-aware commands ───────────────────────────────
|
|
95
|
+
const npmCmd = platform === "win32" ? "npm.cmd" : "npm";
|
|
96
|
+
const npxCmd = platform === "win32" ? "npx.cmd" : "npx";
|
|
97
|
+
|
|
98
|
+
// ─── Build frontend ────────────────────────────────────────
|
|
99
|
+
info("Installing frontend dependencies...");
|
|
100
|
+
const frontendDir = path.join(installDir, "frontend");
|
|
101
|
+
execSync(`${npmCmd} install --prefer-offline`, {
|
|
102
|
+
cwd: frontendDir,
|
|
103
|
+
stdio: "inherit",
|
|
104
|
+
shell: true
|
|
105
|
+
});
|
|
106
|
+
success("Dependencies installed");
|
|
107
|
+
|
|
108
|
+
info("Building React app...");
|
|
109
|
+
const viteBin = path.join(frontendDir, "node_modules", ".bin", "vite");
|
|
110
|
+
execSync(`"${viteBin}" build`, {
|
|
111
|
+
cwd: frontendDir,
|
|
112
|
+
stdio: "inherit",
|
|
113
|
+
shell: true
|
|
114
|
+
});
|
|
115
|
+
success("React app built");
|
|
116
|
+
|
|
117
|
+
// ─── Compile Java ──────────────────────────────────────────
|
|
118
|
+
info("Compiling Java sources...");
|
|
119
|
+
execSync("javac -d out src/models/*.java src/datastructures/*.java src/utils/*.java src/auth/*.java src/sync/*.java src/filesystem/*.java src/Main.java", {
|
|
120
|
+
cwd: installDir,
|
|
121
|
+
stdio: "inherit",
|
|
122
|
+
shell: true
|
|
123
|
+
});
|
|
124
|
+
success("All sources compiled");
|
|
125
|
+
|
|
126
|
+
// ─── Done ──────────────────────────────────────────────────
|
|
127
|
+
console.log("");
|
|
128
|
+
console.log(` ${GREEN}${BOLD}✅ VaultFS is ready!${RESET} Type ${CYAN}vaultfs${RESET} to launch.`);
|
|
129
|
+
console.log("");
|
|
130
|
+
|
|
131
|
+
} catch (err) {
|
|
132
|
+
console.log("");
|
|
133
|
+
error(`${RED}Post-install failed: ${err.message}${RESET}`);
|
|
134
|
+
console.log("");
|
|
135
|
+
console.log(` Run ${CYAN}vaultfs doctor${RESET} to diagnose the issue.`);
|
|
136
|
+
console.log("");
|
|
137
|
+
process.exit(1);
|
|
138
|
+
}
|
package/bin/vaultfs-npm.js
CHANGED
|
@@ -1,147 +1,148 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const { execSync, spawn } = require("child_process");
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const os = require("os");
|
|
6
|
-
|
|
7
|
-
// ─── Colors ──────────────────────────────────────────────────
|
|
8
|
-
const RESET = "\x1b[0m";
|
|
9
|
-
const BOLD = "\x1b[1m";
|
|
10
|
-
const RED = "\x1b[31m";
|
|
11
|
-
const GREEN = "\x1b[32m";
|
|
12
|
-
const CYAN = "\x1b[36m";
|
|
13
|
-
|
|
14
|
-
const installDir = path.join(os.homedir(), ".vaultfs");
|
|
15
|
-
const npmCmd = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
16
|
-
const npxCmd = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
17
|
-
const versionFile = path.join(installDir, "version.txt");
|
|
18
|
-
const args = process.argv.slice(2);
|
|
19
|
-
const cmd = args[0];
|
|
20
|
-
|
|
21
|
-
// ─── --version / -v ──────────────────────────────────────────
|
|
22
|
-
if (cmd === "--version" || cmd === "-v") {
|
|
23
|
-
try {
|
|
24
|
-
const ver = fs.readFileSync(versionFile, "utf8").trim();
|
|
25
|
-
console.log(`VaultFS v${ver}`);
|
|
26
|
-
} catch {
|
|
27
|
-
console.log("VaultFS (version unknown)");
|
|
28
|
-
}
|
|
29
|
-
process.exit(0);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// ─── update ──────────────────────────────────────────────────
|
|
33
|
-
if (cmd === "update") {
|
|
34
|
-
console.log("Checking for updates...");
|
|
35
|
-
try {
|
|
36
|
-
execSync("git fetch origin main", { cwd: installDir, stdio: "inherit" });
|
|
37
|
-
const local = execSync("git rev-parse HEAD", { cwd: installDir, encoding: "utf8" }).trim();
|
|
38
|
-
const remote = execSync("git rev-parse origin/main", { cwd: installDir, encoding: "utf8" }).trim();
|
|
39
|
-
|
|
40
|
-
if (local === remote) {
|
|
41
|
-
console.log("✅ Already up to date.");
|
|
42
|
-
} else {
|
|
43
|
-
console.log("Update available! Pulling latest...");
|
|
44
|
-
execSync("git pull origin main", { cwd: installDir, stdio: "inherit" });
|
|
45
|
-
|
|
46
|
-
// Rebuild frontend
|
|
47
|
-
const frontendDir = path.join(installDir, "frontend");
|
|
48
|
-
execSync(`${npmCmd} install`, { cwd: frontendDir, stdio: "inherit" });
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
console.log("
|
|
72
|
-
console.log("
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execSync, spawn } = require("child_process");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
|
|
7
|
+
// ─── Colors ──────────────────────────────────────────────────
|
|
8
|
+
const RESET = "\x1b[0m";
|
|
9
|
+
const BOLD = "\x1b[1m";
|
|
10
|
+
const RED = "\x1b[31m";
|
|
11
|
+
const GREEN = "\x1b[32m";
|
|
12
|
+
const CYAN = "\x1b[36m";
|
|
13
|
+
|
|
14
|
+
const installDir = path.join(os.homedir(), ".vaultfs");
|
|
15
|
+
const npmCmd = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
16
|
+
const npxCmd = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
17
|
+
const versionFile = path.join(installDir, "version.txt");
|
|
18
|
+
const args = process.argv.slice(2);
|
|
19
|
+
const cmd = args[0];
|
|
20
|
+
|
|
21
|
+
// ─── --version / -v ──────────────────────────────────────────
|
|
22
|
+
if (cmd === "--version" || cmd === "-v") {
|
|
23
|
+
try {
|
|
24
|
+
const ver = fs.readFileSync(versionFile, "utf8").trim();
|
|
25
|
+
console.log(`VaultFS v${ver}`);
|
|
26
|
+
} catch {
|
|
27
|
+
console.log("VaultFS (version unknown)");
|
|
28
|
+
}
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ─── update ──────────────────────────────────────────────────
|
|
33
|
+
if (cmd === "update") {
|
|
34
|
+
console.log("Checking for updates...");
|
|
35
|
+
try {
|
|
36
|
+
execSync("git fetch origin main", { cwd: installDir, stdio: "inherit" });
|
|
37
|
+
const local = execSync("git rev-parse HEAD", { cwd: installDir, encoding: "utf8" }).trim();
|
|
38
|
+
const remote = execSync("git rev-parse origin/main", { cwd: installDir, encoding: "utf8" }).trim();
|
|
39
|
+
|
|
40
|
+
if (local === remote) {
|
|
41
|
+
console.log("✅ Already up to date.");
|
|
42
|
+
} else {
|
|
43
|
+
console.log("Update available! Pulling latest...");
|
|
44
|
+
execSync("git pull origin main", { cwd: installDir, stdio: "inherit" });
|
|
45
|
+
|
|
46
|
+
// Rebuild frontend
|
|
47
|
+
const frontendDir = path.join(installDir, "frontend");
|
|
48
|
+
execSync(`${npmCmd} install --prefer-offline`, { cwd: frontendDir, stdio: "inherit", shell: true });
|
|
49
|
+
const viteBin = path.join(frontendDir, "node_modules", ".bin", "vite");
|
|
50
|
+
execSync(`"${viteBin}" build`, { cwd: frontendDir, stdio: "inherit", shell: true });
|
|
51
|
+
|
|
52
|
+
// Recompile Java
|
|
53
|
+
execSync("javac -d out src/models/*.java src/datastructures/*.java src/utils/*.java src/auth/*.java src/sync/*.java src/filesystem/*.java src/Main.java", {
|
|
54
|
+
cwd: installDir,
|
|
55
|
+
stdio: "inherit",
|
|
56
|
+
shell: true
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const ver = fs.readFileSync(versionFile, "utf8").trim();
|
|
60
|
+
console.log(`✅ VaultFS updated to v${ver}!`);
|
|
61
|
+
}
|
|
62
|
+
} catch (err) {
|
|
63
|
+
console.error(`${RED}Update failed: ${err.message}${RESET}`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
process.exit(0);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ─── doctor ──────────────────────────────────────────────────
|
|
70
|
+
if (cmd === "doctor") {
|
|
71
|
+
console.log("");
|
|
72
|
+
console.log("🔍 VaultFS Doctor — Health Check");
|
|
73
|
+
console.log("=================================");
|
|
74
|
+
|
|
75
|
+
// Java
|
|
76
|
+
try {
|
|
77
|
+
const javaOut = execSync("java -version 2>&1", { encoding: "utf8" });
|
|
78
|
+
const firstLine = javaOut.split("\n")[0];
|
|
79
|
+
console.log(`✅ Java: ${firstLine}`);
|
|
80
|
+
} catch {
|
|
81
|
+
console.log("❌ Java: NOT FOUND");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Node
|
|
85
|
+
try {
|
|
86
|
+
const nodeVer = execSync("node --version", { encoding: "utf8" }).trim();
|
|
87
|
+
console.log(`✅ Node: ${nodeVer}`);
|
|
88
|
+
} catch {
|
|
89
|
+
console.log("❌ Node: NOT FOUND");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Git
|
|
93
|
+
try {
|
|
94
|
+
const gitVer = execSync("git --version", { encoding: "utf8" }).trim();
|
|
95
|
+
console.log(`✅ Git: ${gitVer}`);
|
|
96
|
+
} catch {
|
|
97
|
+
console.log("❌ Git: NOT FOUND");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Install dir
|
|
101
|
+
if (fs.existsSync(installDir)) {
|
|
102
|
+
console.log(`✅ Install dir: ${installDir} exists`);
|
|
103
|
+
} else {
|
|
104
|
+
console.log(`❌ Install dir: ${installDir} NOT FOUND`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Compiled classes
|
|
108
|
+
if (fs.existsSync(path.join(installDir, "out", "Main.class"))) {
|
|
109
|
+
console.log("✅ Java classes: compiled");
|
|
110
|
+
} else {
|
|
111
|
+
console.log("❌ Java classes: NOT compiled — run 'vaultfs update' to fix");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Frontend build
|
|
115
|
+
if (fs.existsSync(path.join(installDir, "frontend", "dist"))) {
|
|
116
|
+
console.log("✅ Frontend: built");
|
|
117
|
+
} else {
|
|
118
|
+
console.log("❌ Frontend: NOT built — run 'vaultfs update' to fix");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Version
|
|
122
|
+
if (fs.existsSync(versionFile)) {
|
|
123
|
+
const ver = fs.readFileSync(versionFile, "utf8").trim();
|
|
124
|
+
console.log(`✅ Version: v${ver}`);
|
|
125
|
+
} else {
|
|
126
|
+
console.log("⚠️ Version file missing");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
console.log("");
|
|
130
|
+
process.exit(0);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ─── Default: launch the app ─────────────────────────────────
|
|
134
|
+
const outDir = path.join(installDir, "out");
|
|
135
|
+
|
|
136
|
+
if (!fs.existsSync(path.join(outDir, "Main.class"))) {
|
|
137
|
+
console.error(`${RED}VaultFS is not compiled. Run 'vaultfs doctor' to check your installation.${RESET}`);
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const child = spawn("java", [`-Dvaultfs.home=${installDir}`, "-cp", outDir, "Main", ...args], {
|
|
142
|
+
stdio: "inherit",
|
|
143
|
+
cwd: installDir
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
child.on("exit", (code) => {
|
|
147
|
+
process.exit(code ?? 0);
|
|
148
|
+
});
|
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vaultfs",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "A CLI-based secure file system simulator with OAuth 2.0 authentication and advanced data structures",
|
|
5
|
-
"bin": {
|
|
6
|
-
"vaultfs": "bin/vaultfs-npm.js"
|
|
7
|
-
},
|
|
8
|
-
"scripts": {
|
|
9
|
-
"postinstall": "node ./bin/postinstall.js"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [
|
|
12
|
-
"cli",
|
|
13
|
-
"filesystem",
|
|
14
|
-
"oauth",
|
|
15
|
-
"java",
|
|
16
|
-
"security",
|
|
17
|
-
"data-structures"
|
|
18
|
-
],
|
|
19
|
-
"author": "ThreatGuardian",
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"engines": {
|
|
22
|
-
"node": ">=18.0.0"
|
|
23
|
-
},
|
|
24
|
-
"files": [
|
|
25
|
-
"bin/",
|
|
26
|
-
"src/",
|
|
27
|
-
"frontend/",
|
|
28
|
-
"version.txt",
|
|
29
|
-
".env.example",
|
|
30
|
-
"install.sh",
|
|
31
|
-
"install.bat",
|
|
32
|
-
"uninstall.sh"
|
|
33
|
-
]
|
|
34
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "vaultfs",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "A CLI-based secure file system simulator with OAuth 2.0 authentication and advanced data structures",
|
|
5
|
+
"bin": {
|
|
6
|
+
"vaultfs": "bin/vaultfs-npm.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node ./bin/postinstall.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"cli",
|
|
13
|
+
"filesystem",
|
|
14
|
+
"oauth",
|
|
15
|
+
"java",
|
|
16
|
+
"security",
|
|
17
|
+
"data-structures"
|
|
18
|
+
],
|
|
19
|
+
"author": "ThreatGuardian",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18.0.0"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"bin/",
|
|
26
|
+
"src/",
|
|
27
|
+
"frontend/",
|
|
28
|
+
"version.txt",
|
|
29
|
+
".env.example",
|
|
30
|
+
"install.sh",
|
|
31
|
+
"install.bat",
|
|
32
|
+
"uninstall.sh"
|
|
33
|
+
]
|
|
34
|
+
}
|