@necrolab/dashboard 0.4.46 β†’ 0.4.48

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,9 +1,9 @@
1
1
  {
2
2
  "name": "@necrolab/dashboard",
3
- "version": "0.4.46",
3
+ "version": "0.4.48",
4
4
  "type": "module",
5
5
  "scripts": {
6
- "build": "rm -rf dist && vite build && npx workbox-cli generateSW workbox-config.cjs",
6
+ "build": "rm -rf dist && npx workbox-cli generateSW workbox-config.cjs && vite build",
7
7
  "dev": "node dev-server.js",
8
8
  "bot": "node dev-server.js",
9
9
  "expose": "node dev-server.js",
package/postinstall.js CHANGED
@@ -5,33 +5,71 @@ import { fileURLToPath } from "node:url";
5
5
 
6
6
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
7
 
8
- console.log("πŸ”§ Running postinstall build...");
9
-
10
- // Use npx to run vite instead of hardcoded path
11
- try {
12
- execSync(`npx vite build`, {
13
- cwd: __dirname,
14
- stdio: "inherit"
15
- });
16
- console.log("βœ… Build completed successfully");
17
- } catch (error) {
18
- console.log("⚠️ Build failed, but continuing...");
19
- }
20
-
21
- // Only do file operations if we're in a nested structure
22
- const distPath = path.resolve(path.join(__dirname, "../../../dashboard/dist/"));
23
- const localDistPath = path.resolve("./dist/");
24
-
25
- if (fs.existsSync(localDistPath) && __dirname.includes("dashboard")) {
26
- try {
27
- if (fs.existsSync(distPath)) {
28
- fs.rmSync(distPath, { recursive: true });
29
- }
30
-
31
- // Copy entire dist folder (which already includes sw.js from build process)
32
- fs.cpSync(localDistPath, distPath, { recursive: true });
33
- console.log("πŸ“ Copied complete dist folder with service worker");
34
- } catch (error) {
35
- console.log("⚠️ Could not copy dist folder:", error.message);
36
- }
37
- }
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}`);
package/run CHANGED
@@ -1,10 +1,177 @@
1
+ #!/bin/bash
1
2
 
2
- if [[ $1 == 'build' ]]; then
3
- echo "Building files..."
4
- cd src/
5
- npm run build
6
- cd ..
7
- echo "Done!"
8
- fi
9
- echo "Starting server..."
10
- node .
3
+ # 🎯 Necro Dashboard Runner - Fire Edition πŸ”₯
4
+ # Enhanced runner script with style and robust functionality
5
+
6
+ # Colors for that fire output 🌈
7
+ RED='\033[0;31m'
8
+ GREEN='\033[0;32m'
9
+ YELLOW='\033[1;33m'
10
+ BLUE='\033[0;34m'
11
+ PURPLE='\033[0;35m'
12
+ CYAN='\033[0;36m'
13
+ WHITE='\033[1;37m'
14
+ BOLD='\033[1m'
15
+ NC='\033[0m' # No Color
16
+
17
+ # Fire emojis for maximum style
18
+ FIRE="πŸ”₯"
19
+ ROCKET="πŸš€"
20
+ GEAR="βš™οΈ"
21
+ CHECK="βœ…"
22
+ CROSS="❌"
23
+ LIGHTNING="⚑"
24
+
25
+ # Banner function
26
+ show_banner() {
27
+ echo -e "${PURPLE}${BOLD}"
28
+ echo " β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— "
29
+ echo " β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—"
30
+ echo " β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘"
31
+ echo " β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘"
32
+ echo " β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•"
33
+ echo " β•šβ•β• β•šβ•β•β•β•β•šβ•β•β•β•β•β•β• β•šβ•β•β•β•β•β•β•šβ•β• β•šβ•β• β•šβ•β•β•β•β•β• "
34
+ echo -e "${NC}"
35
+ echo -e "${CYAN}${BOLD}Dashboard Runner ${FIRE} v2.0${NC}"
36
+ echo -e "${WHITE}────────────────────────────────────────────${NC}"
37
+ }
38
+
39
+ # Spinner function for loading animations
40
+ spinner() {
41
+ local pid=$1
42
+ local delay=0.1
43
+ local spinstr='⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
44
+ while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
45
+ local temp=${spinstr#?}
46
+ printf " [%c] " "$spinstr"
47
+ local spinstr=$temp${spinstr%"$temp"}
48
+ sleep $delay
49
+ printf "\b\b\b\b\b\b"
50
+ done
51
+ printf " \b\b\b\b"
52
+ }
53
+
54
+ # Success message
55
+ success() {
56
+ echo -e "${GREEN}${BOLD}${CHECK} $1${NC}"
57
+ }
58
+
59
+ # Error message
60
+ error() {
61
+ echo -e "${RED}${BOLD}${CROSS} $1${NC}"
62
+ }
63
+
64
+ # Info message
65
+ info() {
66
+ echo -e "${CYAN}${BOLD}${LIGHTNING} $1${NC}"
67
+ }
68
+
69
+ # Warning message
70
+ warn() {
71
+ echo -e "${YELLOW}${BOLD}⚠️ $1${NC}"
72
+ }
73
+
74
+ # Check if npm is available
75
+ check_npm() {
76
+ if ! command -v npm &> /dev/null; then
77
+ error "npm is not installed or not in PATH"
78
+ exit 1
79
+ fi
80
+ }
81
+
82
+ # Check if node is available
83
+ check_node() {
84
+ if ! command -v node &> /dev/null; then
85
+ error "Node.js is not installed or not in PATH"
86
+ exit 1
87
+ fi
88
+ }
89
+
90
+ # Build function with proper error handling
91
+ build_project() {
92
+ info "Initiating build sequence ${GEAR}"
93
+
94
+ # Check dependencies
95
+ check_npm
96
+
97
+ echo -e "${YELLOW}${BOLD}Building production files...${NC}"
98
+
99
+ # Run build with error handling
100
+ if npm run build; then
101
+ success "Build completed successfully ${ROCKET}"
102
+ return 0
103
+ else
104
+ error "Build failed! Check the output above for details."
105
+ exit 1
106
+ fi
107
+ }
108
+
109
+ # Start server function
110
+ start_server() {
111
+ info "Starting Necro Dashboard server ${ROCKET}"
112
+
113
+ # Check if Node.js is available
114
+ check_node
115
+
116
+ # Check if index.js exists
117
+ if [[ ! -f "index.js" ]]; then
118
+ error "index.js not found in current directory"
119
+ exit 1
120
+ fi
121
+
122
+ echo -e "${GREEN}${BOLD}Server starting...${NC}"
123
+ echo -e "${CYAN}Press ${WHITE}Ctrl+C${CYAN} to stop the server${NC}"
124
+ echo -e "${WHITE}────────────────────────────────────────────${NC}"
125
+
126
+ # Start the server
127
+ node index.js
128
+ }
129
+
130
+ # Help function
131
+ show_help() {
132
+ echo -e "${WHITE}${BOLD}Usage:${NC}"
133
+ echo -e " ${CYAN}./run${NC} ${WHITE}Start the server${NC}"
134
+ echo -e " ${CYAN}./run build${NC} ${WHITE}Build project then start server${NC}"
135
+ echo -e " ${CYAN}./run help${NC} ${WHITE}Show this help message${NC}"
136
+ echo ""
137
+ echo -e "${WHITE}${BOLD}Examples:${NC}"
138
+ echo -e " ${YELLOW}./run${NC} ${GREEN}# Quick start for development${NC}"
139
+ echo -e " ${YELLOW}./run build${NC} ${GREEN}# Production build + start${NC}"
140
+ echo ""
141
+ echo -e "${PURPLE}Made with ${FIRE} for ticket automation${NC}"
142
+ }
143
+
144
+ # Main execution flow
145
+ main() {
146
+ # Clear screen for clean output
147
+ clear
148
+
149
+ # Show the fire banner
150
+ show_banner
151
+
152
+ case "${1:-}" in
153
+ "build")
154
+ build_project
155
+ echo ""
156
+ start_server
157
+ ;;
158
+ "help"|"-h"|"--help")
159
+ show_help
160
+ ;;
161
+ "")
162
+ start_server
163
+ ;;
164
+ *)
165
+ warn "Unknown command: $1"
166
+ echo ""
167
+ show_help
168
+ exit 1
169
+ ;;
170
+ esac
171
+ }
172
+
173
+ # Error handling for script interruption
174
+ trap 'echo -e "\n${YELLOW}${BOLD}${LIGHTNING} Server stopped${NC}"; exit 0' INT
175
+
176
+ # Run the main function
177
+ main "$@"
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
2
  globDirectory: "public/",
3
3
  globPatterns: ["**/*.{png,ico,svg,jpg,jpeg,webp}", "manifest.json"],
4
- swDest: "dist/sw.js",
4
+ swDest: "public/sw.js",
5
5
  sourcemap: false,
6
6
  skipWaiting: true,
7
7
  clientsClaim: true,