@necrolab/dashboard 0.4.60 â 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 +14 -2
- package/postinstall.js +94 -82
- package/vue.config.js +0 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@necrolab/dashboard",
|
|
3
|
-
"version": "0.4.
|
|
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,87 +5,99 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
|
|
6
6
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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) =>
|
|
25
|
-
console.log(`${colors.blue}đ ${colors.bright}${label}:${colors.reset} ${colors.magenta}${path}${colors.reset}`)
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// đ Banner for style
|
|
29
|
-
console.log(`${colors.cyan}${colors.bright}`);
|
|
30
|
-
console.log("âââââââââââââââââââââââââââââââââââââââ");
|
|
31
|
-
console.log("â đ§ NECRO POSTINSTALL SCRIPT â");
|
|
32
|
-
console.log("âââââââââââââââââââââââââââââââââââââââ");
|
|
33
|
-
console.log(`${colors.reset}`);
|
|
34
|
-
|
|
35
|
-
log.process("Running postinstall build...");
|
|
36
|
-
|
|
37
|
-
var vitePath = path.resolve(path.join(__dirname, "/../../vite/bin/vite.js"));
|
|
38
|
-
|
|
39
|
-
log.path("Vite path", vitePath);
|
|
40
|
-
log.path("Current directory", __dirname);
|
|
41
|
-
|
|
42
|
-
log.process("Generating service worker with Workbox...");
|
|
43
|
-
|
|
44
|
-
execSync(`npx workbox-cli generateSW workbox-config.cjs`, {
|
|
45
|
-
cwd: __dirname,
|
|
46
|
-
stdio: "inherit"
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
log.success("Service worker generated!");
|
|
50
|
-
|
|
51
|
-
log.process("Building with Vite...");
|
|
52
|
-
|
|
53
|
-
execSync(`node "${vitePath}" build`, {
|
|
54
|
-
cwd: __dirname,
|
|
55
|
-
stdio: "inherit"
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
log.success("Vite build completed!");
|
|
59
|
-
|
|
60
|
-
var oldPath = path.join(__dirname, "dist");
|
|
61
|
-
var projectRoot = path.resolve(__dirname, "../../..");
|
|
62
|
-
var distPath = path.join(projectRoot, "dashboard", "dist");
|
|
63
|
-
var dashboardDir = path.join(projectRoot, "dashboard");
|
|
64
|
-
|
|
65
|
-
log.process("Moving build artifacts...");
|
|
66
|
-
log.path("Source", oldPath);
|
|
67
|
-
log.path("Destination", distPath);
|
|
68
|
-
|
|
69
|
-
if (!fs.existsSync(dashboardDir)) {
|
|
70
|
-
fs.mkdirSync(dashboardDir, { recursive: true });
|
|
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}`);
|
|
71
16
|
}
|
|
72
17
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
+
}
|
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
|
-
};
|