vaultfs 1.0.6 → 1.0.7

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.
@@ -1,137 +1,102 @@
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
- cwd: frontendDir,
103
- stdio: "inherit",
104
- shell: true
105
- });
106
- success("Dependencies installed");
107
-
108
- info("Building React app...");
109
- execSync(`${npmCmd} run build`, {
110
- cwd: frontendDir,
111
- stdio: "inherit",
112
- shell: true
113
- });
114
- success("React app built");
115
-
116
- // ─── Compile Java ──────────────────────────────────────────
117
- info("Compiling Java sources...");
118
- 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", {
119
- cwd: installDir,
120
- stdio: "inherit",
121
- shell: true
122
- });
123
- success("All sources compiled");
124
-
125
- // ─── Done ──────────────────────────────────────────────────
126
- console.log("");
127
- console.log(` ${GREEN}${BOLD}✅ VaultFS is ready!${RESET} Type ${CYAN}vaultfs${RESET} to launch.`);
128
- console.log("");
129
-
130
- } catch (err) {
131
- console.log("");
132
- error(`${RED}Post-install failed: ${err.message}${RESET}`);
133
- console.log("");
134
- console.log(` Run ${CYAN}vaultfs doctor${RESET} to diagnose the issue.`);
135
- console.log("");
136
- process.exit(1);
137
- }
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
+ const isWin = process.platform === 'win32';
8
+ const npmCmd = isWin ? 'npm.cmd' : 'npm';
9
+ const installDir = path.join(os.homedir(), '.vaultfs');
10
+ const frontendDir = path.join(installDir, 'frontend');
11
+
12
+ console.log('\n \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557');
13
+ console.log(' \u2551 VaultFS \u2014 Running post-install setup \u2551');
14
+ console.log(' \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n');
15
+
16
+ try {
17
+ // Step 1 Detect OS
18
+ const os_name = isWin ? 'Windows' : process.platform === 'darwin' ? 'macOS' : 'Linux';
19
+ console.log(` \u2713 OS detected: ${os_name}`);
20
+
21
+ // Step 2 — Check Java
22
+ try {
23
+ const javaVersion = execSync('java -version 2>&1', { shell: true }).toString();
24
+ console.log(` \u2713 Java found`);
25
+ } catch (e) {
26
+ console.error(' \u2717 Java 11+ is required. Download from: https://adoptium.net');
27
+ process.exit(1);
28
+ }
29
+
30
+ // Step 3 Copy files to ~/.vaultfs
31
+ console.log(` \u2192 Setting up ${installDir}...`);
32
+ if (!fs.existsSync(installDir)) {
33
+ fs.mkdirSync(installDir, { recursive: true });
34
+ }
35
+
36
+ const pkgDir = path.join(__dirname, '..');
37
+ const itemsToCopy = ['src', 'frontend', 'version.txt', '.env.example'];
38
+ for (const item of itemsToCopy) {
39
+ const src = path.join(pkgDir, item);
40
+ const dest = path.join(installDir, item);
41
+ if (fs.existsSync(src)) {
42
+ if (fs.existsSync(dest)) {
43
+ fs.rmSync(dest, { recursive: true, force: true });
44
+ }
45
+ fs.cpSync(src, dest, { recursive: true });
46
+ }
47
+ }
48
+ console.log(' \u2713 Source files copied');
49
+
50
+ // Step 4 — Create .env if missing
51
+ const envFile = path.join(installDir, '.env');
52
+ const envExample = path.join(installDir, '.env.example');
53
+ if (!fs.existsSync(envFile) && fs.existsSync(envExample)) {
54
+ fs.copyFileSync(envExample, envFile);
55
+ }
56
+
57
+ // Step 5 — Clean and install frontend dependencies
58
+ console.log(' \u2192 Installing frontend dependencies...');
59
+ const frontendModules = path.join(frontendDir, 'node_modules');
60
+ if (fs.existsSync(frontendModules)) {
61
+ fs.rmSync(frontendModules, { recursive: true, force: true });
62
+ console.log(' \u2713 Cleaned old modules');
63
+ }
64
+ execSync(`${npmCmd} install`, {
65
+ cwd: frontendDir,
66
+ stdio: 'inherit',
67
+ shell: true
68
+ });
69
+ console.log(' \u2713 Dependencies installed');
70
+
71
+ // Step 6 — Build frontend using local vite binary
72
+ console.log(' \u2192 Building React app...');
73
+ const viteBin = path.join(frontendDir, 'node_modules', '.bin', isWin ? 'vite.cmd' : 'vite');
74
+ if (!fs.existsSync(viteBin)) {
75
+ throw new Error(`Vite binary not found at: ${viteBin}`);
76
+ }
77
+ execSync(`"${viteBin}" build`, {
78
+ cwd: frontendDir,
79
+ stdio: 'inherit',
80
+ shell: true
81
+ });
82
+ console.log(' \u2713 React app built');
83
+
84
+ // Step 7 Compile Java
85
+ console.log(' \u2192 Compiling Java sources...');
86
+ const outDir = path.join(installDir, 'out');
87
+ if (!fs.existsSync(outDir)) {
88
+ fs.mkdirSync(outDir, { recursive: true });
89
+ }
90
+ execSync(
91
+ 'javac -d out src/models/*.java src/datastructures/*.java src/utils/*.java src/auth/*.java src/sync/*.java src/filesystem/*.java src/Main.java',
92
+ { cwd: installDir, stdio: 'inherit', shell: true }
93
+ );
94
+ console.log(' \u2713 Java compiled');
95
+
96
+ console.log('\n \u2705 VaultFS is ready! Type vaultfs to launch.\n');
97
+
98
+ } catch (err) {
99
+ console.error(`\n \u2717 Post-install failed: ${err.message}`);
100
+ console.error(' Run vaultfs doctor to diagnose the issue.\n');
101
+ process.exit(1);
102
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaultfs",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "A CLI-based secure file system simulator with OAuth 2.0 authentication and advanced data structures",
5
5
  "bin": {
6
6
  "vaultfs": "bin/vaultfs-npm.js"
@@ -24,7 +24,15 @@
24
24
  "files": [
25
25
  "bin/",
26
26
  "src/",
27
- "frontend/",
27
+ "frontend/src/",
28
+ "frontend/public/",
29
+ "frontend/package.json",
30
+ "frontend/index.html",
31
+ "frontend/vite.config.js",
32
+ "frontend/.env.example",
33
+ "frontend/eslint.config.js",
34
+ "frontend/README.md",
35
+ "frontend/success.html",
28
36
  "version.txt",
29
37
  ".env.example",
30
38
  "install.sh",
package/version.txt CHANGED
@@ -1 +1 @@
1
- 1.0.6
1
+ 1.0.7