@spcookie/erii-runtime-windows-x64 1.0.0

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 ADDED
@@ -0,0 +1,4 @@
1
+ # @spcookie/erii-runtime-erii-windows-x64
2
+
3
+ Erii JDK runtime for erii-windows x64.
4
+
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@spcookie/erii-runtime-windows-x64",
3
+ "version": "1.0.0",
4
+ "os": [
5
+ "win32"
6
+ ],
7
+ "cpu": [
8
+ "x64"
9
+ ],
10
+ "scripts": {
11
+ "postinstall": "node postinstall.js"
12
+ },
13
+ "keywords": [
14
+ "erii",
15
+ "qq",
16
+ "bot",
17
+ "chatbot",
18
+ "group-chat",
19
+ "机器人",
20
+ "群聊机器人",
21
+ "ai",
22
+ "napcat",
23
+ "mirai"
24
+ ],
25
+ "author": "spcookie",
26
+ "license": "MIT",
27
+ "description": "",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/spcookie/erii.git",
31
+ "directory": "erii-distribution/packages/erii-runtime/erii-windows/x64"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/spcookie/erii/issues"
35
+ },
36
+ "homepage": "https://github.com/spcookie/erii#readme",
37
+ "publishConfig": {
38
+ "access": "public"
39
+ }
40
+ }
package/postinstall.js ADDED
@@ -0,0 +1,79 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { execSync } = require('child_process');
4
+
5
+ const isWindows = process.platform === 'win32';
6
+
7
+ // Detect install layout (mirrors erii/postinstall.js logic)
8
+ const spcookieFlat = path.resolve(__dirname, '..');
9
+ const spcookieNested = path.join(__dirname, 'node_modules', '@spcookie');
10
+ const nestedExists = fs.existsSync(spcookieNested);
11
+ const linkRoot = nestedExists ? __dirname : path.resolve(spcookieFlat, '..', '..');
12
+
13
+ function readExistingLink(linkPath) {
14
+ try {
15
+ return fs.readlinkSync(linkPath);
16
+ } catch {
17
+ return null;
18
+ }
19
+ }
20
+
21
+ function createDirLink(target, linkPath) {
22
+ const existing = readExistingLink(linkPath);
23
+ if (existing !== null) {
24
+ const resolved = path.resolve(path.dirname(linkPath), existing);
25
+ if (resolved === path.resolve(target)) return 'skipped';
26
+ console.log(` [WARN] ${linkPath} exists but points elsewhere, skipping.`);
27
+ return 'skipped';
28
+ }
29
+ if (fs.existsSync(linkPath)) {
30
+ console.log(` [WARN] ${linkPath} already exists as a regular file/dir, skipping.`);
31
+ return 'skipped';
32
+ }
33
+
34
+ if (isWindows) {
35
+ fs.symlinkSync(target, linkPath, 'junction');
36
+ } else {
37
+ fs.symlinkSync(target, linkPath, 'dir');
38
+ }
39
+ return 'created';
40
+ }
41
+
42
+ function extractIfNeeded() {
43
+ const tarFiles = fs.readdirSync(__dirname).filter(f => f.endsWith('.tar.gz'));
44
+ if (tarFiles.length === 0) return;
45
+
46
+ const tarFile = path.join(__dirname, tarFiles[0]);
47
+ const jdkDirs = fs.readdirSync(__dirname).filter(f => f.startsWith('jdk-'));
48
+
49
+ if (jdkDirs.length > 0) {
50
+ console.log('JDK already extracted, skipping.');
51
+ return;
52
+ }
53
+
54
+ console.log(`Extracting ${tarFiles[0]}...`);
55
+ try {
56
+ execSync(`tar --force-local -xzf "${tarFile}"`, {cwd: __dirname, stdio: 'pipe'});
57
+ } catch {
58
+ execSync(`tar -xzf "${tarFile}"`, {cwd: __dirname});
59
+ }
60
+ fs.unlinkSync(tarFile);
61
+ console.log('Done.');
62
+ }
63
+
64
+ function linkRuntime() {
65
+ const entries = fs.readdirSync(__dirname, {withFileTypes: true});
66
+ const jdk = entries.find(e => e.isDirectory() && e.name.startsWith('jdk-'));
67
+ if (!jdk) {
68
+ console.log(' [WARN] no jdk-* directory found');
69
+ return;
70
+ }
71
+ const jdkPath = path.join(__dirname, jdk.name);
72
+ const linkPath = path.join(linkRoot, 'runtime');
73
+ const r = createDirLink(jdkPath, linkPath);
74
+ const icon = r === 'created' ? '✓' : '○';
75
+ console.log(` ${icon} runtime`);
76
+ }
77
+
78
+ extractIfNeeded();
79
+ linkRuntime();
Binary file