mbkbucket 1.0.1 → 1.0.2
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/index.js +9 -1
- package/lib/config/index.js +57 -0
- package/package.json +8 -2
package/index.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { checkVersion } from "./lib/config/index.js";
|
|
2
|
+
|
|
3
|
+
if (process.env.test === "dev") {
|
|
4
|
+
console.log("[mbkbucket] Dev mode is enabled. Starting server in dev mode.");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
if (process.env.test !== "dev") {
|
|
8
|
+
await checkVersion();
|
|
9
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createRequire } from "module";
|
|
2
|
+
|
|
3
|
+
// Load package.json from mbkbucket package (not parent project)
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
let packageJson;
|
|
6
|
+
try {
|
|
7
|
+
// Try to load from mbkbucket package directory
|
|
8
|
+
packageJson = require("mbkbucket/package.json");
|
|
9
|
+
} catch {
|
|
10
|
+
// Fallback to relative path (for development/testing)
|
|
11
|
+
packageJson = require("../../package.json");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Parent project version
|
|
15
|
+
let appVersion;
|
|
16
|
+
try {
|
|
17
|
+
appVersion = require("../../../../package.json")?.version || "unknown";
|
|
18
|
+
} catch {
|
|
19
|
+
// Fallback if path doesn't work
|
|
20
|
+
try {
|
|
21
|
+
appVersion = require(process.cwd() + "/package.json")?.version || "unknown";
|
|
22
|
+
} catch {
|
|
23
|
+
appVersion = "unknown";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Fetch latest version from GitHub
|
|
28
|
+
async function getLatestVersion() {
|
|
29
|
+
try {
|
|
30
|
+
const response = await fetch('https://raw.githubusercontent.com/MIbnEKhalid/mbkbucket/master/package.json');
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
console.error(`[mbkbucket] GitHub API responded with status ${response.status}`);
|
|
33
|
+
return "0.0.0";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const latestPackageJson = await response.json();
|
|
37
|
+
return latestPackageJson.version;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('[mbkbucket] Error fetching latest version from GitHub:', error);
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Version check with error handling
|
|
45
|
+
async function checkVersion() {
|
|
46
|
+
try {
|
|
47
|
+
const latestVersion = await getLatestVersion();
|
|
48
|
+
if (latestVersion && latestVersion !== packageJson.version) {
|
|
49
|
+
console.warn(`[mbkbucket] Current version (${packageJson.version}) is outdated. Latest version: ${latestVersion}. Consider updating mbkbucket.`);
|
|
50
|
+
} else if (latestVersion) {
|
|
51
|
+
console.info(`[mbkbucket] Running latest version (${packageJson.version}).`);
|
|
52
|
+
}
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.warn(`[mbkbucket] Failed to check for updates: ${error.message}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export { packageJson, appVersion, getLatestVersion, checkVersion };
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mbkbucket",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Bucket manager for mbkauthe apps",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"scripts": {
|
|
8
|
+
"dev": "nodemon index.js",
|
|
7
9
|
"test": "echo \\\"Error: no test specified\\\" && exit 1"
|
|
8
10
|
},
|
|
9
11
|
"repository": {
|
|
@@ -28,6 +30,10 @@
|
|
|
28
30
|
},
|
|
29
31
|
"homepage": "https://github.com/MIbnEKhalid/mbkbucket#readme",
|
|
30
32
|
"dependencies": {
|
|
31
|
-
"mbkauthe": "latest"
|
|
33
|
+
"mbkauthe": "latest",
|
|
34
|
+
"module": "^2.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"nodemon": "^3.1.11"
|
|
32
38
|
}
|
|
33
39
|
}
|