9drive 1.0.1 → 1.0.3
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/README.md +432 -389
- package/backend/dist/modules/system/system.routes.js +57 -0
- package/backend/prisma/schema.sqlite.prisma +354 -354
- package/backend/public/assets/index-CriZZwHi.css +2 -0
- package/backend/public/assets/{index-EnIl3ceg.js → index-sAYu4Fpp.js} +2 -2
- package/backend/public/assets/{ort.bundle.min-B3pxUZZp.js → ort.bundle.min-DJ4PiNdC.js} +1 -1
- package/backend/public/assets/{ort.webgpu.bundle.min-oJmxMdTL.js → ort.webgpu.bundle.min-BmjguWk-.js} +1 -1
- package/backend/public/index.html +2 -2
- package/backend/public/sw.js +1 -1
- package/bin/9drive.js +423 -320
- package/package.json +60 -60
- package/backend/public/assets/index-xyDAj4M7.css +0 -2
|
@@ -13,6 +13,63 @@ const prisma_js_1 = require("../../config/prisma.js");
|
|
|
13
13
|
const crypto_js_1 = require("../../utils/crypto.js");
|
|
14
14
|
const busboy_1 = __importDefault(require("busboy"));
|
|
15
15
|
exports.systemRouter = (0, express_1.Router)();
|
|
16
|
+
function compareVersions(v1, v2) {
|
|
17
|
+
const p1 = v1.split('.').map(Number);
|
|
18
|
+
const p2 = v2.split('.').map(Number);
|
|
19
|
+
for (let i = 0; i < Math.max(p1.length, p2.length); i++) {
|
|
20
|
+
const n1 = p1[i] || 0;
|
|
21
|
+
const n2 = p2[i] || 0;
|
|
22
|
+
if (n1 > n2)
|
|
23
|
+
return 1;
|
|
24
|
+
if (n1 < n2)
|
|
25
|
+
return -1;
|
|
26
|
+
}
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
exports.systemRouter.get('/version', async (_req, res) => {
|
|
30
|
+
let currentVersion = '1.0.1';
|
|
31
|
+
try {
|
|
32
|
+
const pkgPaths = [
|
|
33
|
+
path_1.default.resolve(process.cwd(), 'package.json'),
|
|
34
|
+
path_1.default.resolve(process.cwd(), '../package.json'),
|
|
35
|
+
path_1.default.resolve(__dirname, '../../../package.json'),
|
|
36
|
+
];
|
|
37
|
+
for (const p of pkgPaths) {
|
|
38
|
+
if (fs_1.default.existsSync(p)) {
|
|
39
|
+
const pkg = JSON.parse(fs_1.default.readFileSync(p, 'utf8'));
|
|
40
|
+
if (pkg.name === '9drive' && pkg.version) {
|
|
41
|
+
currentVersion = pkg.version;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch { }
|
|
48
|
+
let latestVersion = currentVersion;
|
|
49
|
+
let hasUpdate = false;
|
|
50
|
+
try {
|
|
51
|
+
const controller = new AbortController();
|
|
52
|
+
const timeout = setTimeout(() => controller.abort(), 3000);
|
|
53
|
+
const npmRes = await fetch('https://registry.npmjs.org/9drive/latest', {
|
|
54
|
+
signal: controller.signal,
|
|
55
|
+
headers: { Accept: 'application/json' },
|
|
56
|
+
});
|
|
57
|
+
clearTimeout(timeout);
|
|
58
|
+
if (npmRes.ok) {
|
|
59
|
+
const data = (await npmRes.json());
|
|
60
|
+
if (data?.version) {
|
|
61
|
+
latestVersion = data.version;
|
|
62
|
+
hasUpdate = compareVersions(latestVersion, currentVersion) > 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch { }
|
|
67
|
+
res.json({
|
|
68
|
+
currentVersion,
|
|
69
|
+
latestVersion,
|
|
70
|
+
hasUpdate,
|
|
71
|
+
});
|
|
72
|
+
});
|
|
16
73
|
exports.systemRouter.post('/update', auth_middleware_js_1.requireAuth, (req, res, next) => {
|
|
17
74
|
const projectRoot = path_1.default.resolve(process.cwd(), '..');
|
|
18
75
|
const updateScript = path_1.default.join(projectRoot, 'update.sh');
|