@necrolab/dashboard 0.4.59 → 0.4.61

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@necrolab/dashboard",
3
- "version": "0.4.59",
3
+ "version": "0.4.61",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "rm -rf dist && npx workbox-cli generateSW workbox-config.cjs && vite build",
@@ -44,9 +44,21 @@
44
44
  },
45
45
  "main": "index.js",
46
46
  "devDependencies": {
47
- "@vue/cli-plugin-pwa": "^5.0.8",
48
47
  "eslint": "^9.17.0",
49
48
  "eslint-plugin-vue": "^9.32.0",
50
49
  "workbox-cli": "^7.3.0"
50
+ },
51
+ "overrides": {
52
+ "glob": "^11.0.0",
53
+ "braces": "^3.0.3",
54
+ "micromatch": "^4.0.8",
55
+ "postcss": "^8.4.49",
56
+ "cookie-parser": "^1.4.7",
57
+ "express": "^4.21.2",
58
+ "body-parser": "^1.20.3",
59
+ "whatwg-url": "^14.0.0",
60
+ "ws": "^8.17.1",
61
+ "path-to-regexp": "^0.1.12",
62
+ "tmp": "^0.2.3"
51
63
  }
52
64
  }
package/postinstall.js CHANGED
@@ -5,71 +5,99 @@ import { fileURLToPath } from "node:url";
5
5
 
6
6
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
7
 
8
- // 🎨 Cool colors for better output
9
- const colors = {
10
- reset: '\x1b[0m',
11
- bright: '\x1b[1m',
12
- cyan: '\x1b[36m',
13
- green: '\x1b[32m',
14
- yellow: '\x1b[33m',
15
- blue: '\x1b[34m',
16
- magenta: '\x1b[35m'
17
- };
18
-
19
- // đŸŽ¯ Cool logging functions
20
- const log = {
21
- info: (msg) => console.log(`${colors.cyan}${colors.bright}â„šī¸ ${msg}${colors.reset}`),
22
- success: (msg) => console.log(`${colors.green}${colors.bright}✅ ${msg}${colors.reset}`),
23
- process: (msg) => console.log(`${colors.yellow}${colors.bright}⚡ ${msg}${colors.reset}`),
24
- path: (label, path) => console.log(`${colors.blue}📁 ${colors.bright}${label}:${colors.reset} ${colors.magenta}${path}${colors.reset}`)
25
- };
26
-
27
- // 🚀 Banner for style
28
- console.log(`${colors.cyan}${colors.bright}`);
29
- console.log("┌─────────────────────────────────────┐");
30
- console.log("│ 🔧 NECRO POSTINSTALL SCRIPT │");
31
- console.log("└─────────────────────────────────────┘");
32
- console.log(`${colors.reset}`);
33
-
34
- log.process("Running postinstall build...");
35
-
36
- var vitePath = path.resolve(path.join(__dirname, "/../../vite/bin/vite.js"));
37
-
38
- log.path("Vite path", vitePath);
39
- log.path("Current directory", __dirname);
40
-
41
- log.process("Generating service worker with Workbox...");
42
-
43
- execSync(`npx workbox-cli generateSW workbox-config.cjs`, {
44
- cwd: __dirname,
45
- stdio: "inherit"
46
- });
47
-
48
- log.success("Service worker generated!");
49
-
50
- log.process("Building with Vite...");
51
-
52
- execSync(`node "${vitePath}" build`, {
53
- cwd: __dirname,
54
- stdio: "inherit"
55
- });
56
-
57
- log.success("Vite build completed!");
58
-
59
- var oldPath = path.resolve("./dist/");
60
- var distPath = path.resolve(path.join(__dirname, "../../../dashboard/dist/"));
61
-
62
- log.process("Moving build artifacts...");
63
- log.path("Source", oldPath);
64
- log.path("Destination", distPath);
65
-
66
- fs.rmSync(distPath, {
67
- recursive: true
68
- });
69
- fs.renameSync(oldPath, distPath);
70
-
71
- log.success("Build artifacts moved successfully!");
72
-
73
- console.log(`${colors.green}${colors.bright}`);
74
- console.log("🎉 Postinstall completed successfully!");
75
- console.log(`${colors.reset}`);
8
+ // Read package.json to get current version
9
+ const packageJsonPath = path.join(__dirname, "package.json");
10
+ let currentVersion = "0.0.0";
11
+ try {
12
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
13
+ currentVersion = packageJson.version;
14
+ } catch (e) {
15
+ console.error(`Failed to read package.json version: ${e.message}`);
16
+ }
17
+
18
+ try {
19
+ const projectRoot = path.resolve(__dirname, "../../..");
20
+ const dashboardDir = path.join(projectRoot, "dashboard");
21
+ const distPath = path.join(dashboardDir, "dist");
22
+ const versionFilePath = path.join(distPath, "version.txt");
23
+
24
+ // Check if we can skip logic
25
+ console.log(`Checking version at ${distPath}...`);
26
+ if (fs.existsSync(versionFilePath)) {
27
+ try {
28
+ const installedVersion = fs.readFileSync(versionFilePath, "utf-8").trim();
29
+ if (installedVersion === currentVersion) {
30
+ console.log(`Version ${currentVersion} is already installed at ${distPath}. Skipping build.`);
31
+ process.exit(0);
32
+ } else {
33
+ console.log(
34
+ `Version mismatch (Installed: ${installedVersion}, Target: ${currentVersion}). Proceeding with build.`
35
+ );
36
+ }
37
+ } catch (readErr) {
38
+ console.log("Could not read version file. Proceeding with build.");
39
+ }
40
+ } else {
41
+ console.log("No version file found. Proceeding with build.");
42
+ }
43
+
44
+ console.log("Running postinstall build...");
45
+
46
+ // Service Worker
47
+ console.log("Generating service worker...");
48
+ try {
49
+ execSync(`npx workbox-cli generateSW workbox-config.cjs`, {
50
+ cwd: __dirname,
51
+ stdio: "inherit"
52
+ });
53
+ } catch (error) {
54
+ console.error("Failed to generate service worker.");
55
+ throw error;
56
+ }
57
+
58
+ // Build
59
+ console.log("Building with Vite...");
60
+ try {
61
+ execSync(`npx vite build`, {
62
+ cwd: __dirname,
63
+ stdio: "inherit"
64
+ });
65
+ } catch (error) {
66
+ console.error("Failed to build with Vite.");
67
+ throw error;
68
+ }
69
+
70
+ const oldPath = path.join(__dirname, "dist");
71
+
72
+ if (!fs.existsSync(oldPath)) {
73
+ throw new Error(`Build failed: ${oldPath} does not exist.`);
74
+ }
75
+
76
+ console.log("Moving build artifacts...");
77
+
78
+ // Ensure target directory exists
79
+ if (!fs.existsSync(dashboardDir)) {
80
+ console.log(`Creating target directory: ${dashboardDir}`);
81
+ fs.mkdirSync(dashboardDir, { recursive: true });
82
+ }
83
+
84
+ // Clean destination
85
+ if (fs.existsSync(distPath)) {
86
+ fs.rmSync(distPath, { recursive: true, force: true });
87
+ }
88
+
89
+ // Copy
90
+ fs.cpSync(oldPath, distPath, { recursive: true });
91
+
92
+ // Write version file
93
+ fs.writeFileSync(versionFilePath, currentVersion);
94
+ console.log(`Written version ${currentVersion} to ${versionFilePath}`);
95
+
96
+ // Cleanup source dist
97
+ fs.rmSync(oldPath, { recursive: true, force: true });
98
+
99
+ console.log("Postinstall completed successfully.");
100
+ } catch (e) {
101
+ console.error(`An error occurred: ${e.message}`);
102
+ process.exit(1);
103
+ }
@@ -511,7 +511,7 @@ const openInBrowser = (debug) => {
511
511
  };
512
512
 
513
513
  const formatDate = (date) => {
514
- if (!date) return "-";
514
+ if (!date) return "TBA";
515
515
  const d = new Date(date);
516
516
  const iso = d.toISOString();
517
517
  const [year, month, day] = iso.substring(0, 10).split("-");
package/vue.config.js DELETED
@@ -1,32 +0,0 @@
1
- export default {
2
- chainWebpack: (config) => {
3
- config.plugin('preload').tap((options) => {
4
- options[0].as = (entry) => {
5
- if (/\.css$/.test(entry)) return 'style';
6
- if (/\.woff$/.test(entry)) return 'font';
7
- if (/\.png$/.test(entry)) return 'image';
8
- return 'script';
9
- };
10
- options[0].include = 'allAssets';
11
- // options[0].fileWhitelist: [/\.files/, /\.to/, /\.include/]
12
- // options[0].fileBlacklist: [/\.files/, /\.to/, /\.exclude/]
13
- return options;
14
- });
15
- },
16
- pwa: {
17
- name: 'Necro Lab',
18
- themeColor: '#4DBA87',
19
- msTileColor: '#000000',
20
- appleMobileWebAppCapable: 'yes',
21
- appleMobileWebAppStatusBarStyle: 'black',
22
-
23
- // configure the workbox plugin
24
- // workboxPluginMode: 'InjectManifest',
25
- workboxPluginMode: "GenerateSW",
26
- workboxOptions: {
27
- // swSrc is required in InjectManifest mode.
28
- swSrc: 'dev/sw.js',
29
- // ...other Workbox options...
30
- }
31
- }
32
- };