drgame-cc 1.0.14 → 1.0.15
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 +176 -351
- package/build-templates/web-mobile/splash_en - /345/211/257/346/234/254.png +0 -0
- package/{tvui → drres}/config/default.json +30 -11
- package/package.json +2 -2
- package/scripts/postinstall.js +99 -67
- package/bin/drgame.d.ts +0 -632
- package/bin/drgame.js +0 -3010
- /package/{tvui → drres}/config/default.json.meta +0 -0
- /package/{tvui → drres}/config.meta +0 -0
- /package/{tvui → drres}/icons/pointer-blue-60.png +0 -0
- /package/{tvui → drres}/icons/pointer-blue-60.png.meta +0 -0
- /package/{tvui → drres}/icons/pointer-pink-60.png +0 -0
- /package/{tvui → drres}/icons/pointer-pink-60.png.meta +0 -0
- /package/{tvui → drres}/icons/pointer-yellow-60.png +0 -0
- /package/{tvui → drres}/icons/pointer-yellow-60.png.meta +0 -0
- /package/{tvui → drres}/icons.meta +0 -0
- /package/{tvui → drres}/prefab/ExitWin.prefab +0 -0
- /package/{tvui → drres}/prefab/ExitWin.prefab.meta +0 -0
- /package/{tvui → drres}/prefab/Toast.prefab +0 -0
- /package/{tvui → drres}/prefab/Toast.prefab.meta +0 -0
- /package/{tvui → drres}/prefab.meta +0 -0
- /package/{tvui → drres}/tv_exit/Toast.png +0 -0
- /package/{tvui → drres}/tv_exit/Toast.png.meta +0 -0
- /package/{tvui → drres}/tv_exit/close.png +0 -0
- /package/{tvui → drres}/tv_exit/close.png.meta +0 -0
- /package/{tvui → drres}/tv_exit//345/217/226/346/266/210/346/214/211/351/222/256_/346/231/256/351/200/232.png" +0 -0
- /package/{tvui → drres}/tv_exit//345/217/226/346/266/210/346/214/211/351/222/256_/346/231/256/351/200/232.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//345/217/226/346/266/210/346/214/211/351/222/256_/351/200/211/344/270/255.png" +0 -0
- /package/{tvui → drres}/tv_exit//345/217/226/346/266/210/346/214/211/351/222/256_/351/200/211/344/270/255.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//346/241/206.png" +0 -0
- /package/{tvui → drres}/tv_exit//346/241/206.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//347/241/256/350/256/244/346/214/211/351/222/256_/346/231/256/351/200/232.png" +0 -0
- /package/{tvui → drres}/tv_exit//347/241/256/350/256/244/346/214/211/351/222/256_/346/231/256/351/200/232.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//347/241/256/350/256/244/346/214/211/351/222/256_/351/200/211/344/270/255.png" +0 -0
- /package/{tvui → drres}/tv_exit//347/241/256/350/256/244/346/214/211/351/222/256_/351/200/211/344/270/255.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//351/200/200/345/207/272/346/270/270/346/210/217.png" +0 -0
- /package/{tvui → drres}/tv_exit//351/200/200/345/207/272/346/270/270/346/210/217.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit.meta +0 -0
package/scripts/postinstall.js
CHANGED
|
@@ -1,67 +1,99 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const fse = require('fs-extra');
|
|
6
|
-
|
|
7
|
-
// ============================================================
|
|
8
|
-
// 1.
|
|
9
|
-
// ============================================================
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const fse = require('fs-extra');
|
|
6
|
+
|
|
7
|
+
// ============================================================
|
|
8
|
+
// 1. 包自身根目录(始终指向 drgame-cc 包目录)
|
|
9
|
+
// ============================================================
|
|
10
|
+
const pkgRoot = path.resolve(__dirname, '..');
|
|
11
|
+
|
|
12
|
+
// 宿主项目根目录(npm install 时 = node_modules 的父目录)
|
|
13
|
+
const projectRoot = path.resolve(__dirname, '..', '..', '..');
|
|
14
|
+
|
|
15
|
+
// ============================================================
|
|
16
|
+
// 2. 解析命令行参数,支持以下形式指定 Cocos 项目根目录:
|
|
17
|
+
// node scripts/postinstall.js <path>
|
|
18
|
+
// node scripts/postinstall.js --cocos-path <path>
|
|
19
|
+
// node scripts/postinstall.js --cocos-path=<path>
|
|
20
|
+
// node scripts/postinstall.js -p <path>
|
|
21
|
+
// 优先级:命令行参数 > 默认(node_modules 父目录)
|
|
22
|
+
// ============================================================
|
|
23
|
+
function resolveCocosPath(argv) {
|
|
24
|
+
const args = argv.slice(2);
|
|
25
|
+
for (let i = 0; i < args.length; i++) {
|
|
26
|
+
const a = args[i];
|
|
27
|
+
if (a.startsWith('--cocos-path=')) {
|
|
28
|
+
return a.slice('--cocos-path='.length);
|
|
29
|
+
}
|
|
30
|
+
if (a === '--cocos-path' || a === '-p') {
|
|
31
|
+
const next = args[i + 1];
|
|
32
|
+
if (next && !next.startsWith('-')) {
|
|
33
|
+
return next;
|
|
34
|
+
}
|
|
35
|
+
} else if (!a.startsWith('-') && a.length > 0) {
|
|
36
|
+
// 第一个非选项位置参数
|
|
37
|
+
return a;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const argPath = resolveCocosPath(process.argv);
|
|
44
|
+
let COCOS_ROOT = argPath || projectRoot;
|
|
45
|
+
// 相对路径相对于当前工作目录解析
|
|
46
|
+
if (!path.isAbsolute(COCOS_ROOT)) {
|
|
47
|
+
COCOS_ROOT = path.resolve(process.cwd(), COCOS_ROOT);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
console.log('✅ 开始拷贝资源');
|
|
51
|
+
console.log(`📦 宿主项目: ${projectRoot}`);
|
|
52
|
+
console.log(`📦 目标目录: ${COCOS_ROOT}`);
|
|
53
|
+
console.log(`🎯 Cocos 路径来源: ${argPath ? '命令行参数' : '默认(node_modules 父目录)'}`);
|
|
54
|
+
|
|
55
|
+
// ============================================================
|
|
56
|
+
// 3. 拷贝资源
|
|
57
|
+
// ============================================================
|
|
58
|
+
try {
|
|
59
|
+
// build-templates
|
|
60
|
+
const buildTemplatesSrc = path.join(pkgRoot, 'build-templates');
|
|
61
|
+
const buildTemplatesDest = path.join(COCOS_ROOT, 'build-templates');
|
|
62
|
+
|
|
63
|
+
if (fs.existsSync(buildTemplatesSrc)) {
|
|
64
|
+
fse.copySync(buildTemplatesSrc, buildTemplatesDest, { overwrite: true });
|
|
65
|
+
console.log('✅ build-templates 拷贝完成');
|
|
66
|
+
} else {
|
|
67
|
+
console.log(`⚠️ 源目录不存在: ${buildTemplatesSrc}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// drres
|
|
71
|
+
const drresSrc = path.join(pkgRoot, 'drres');
|
|
72
|
+
const drresDest = path.join(COCOS_ROOT, 'assets', 'resources', 'drres');
|
|
73
|
+
|
|
74
|
+
if (fs.existsSync(drresSrc)) {
|
|
75
|
+
fse.ensureDirSync(drresDest);
|
|
76
|
+
fse.copySync(drresSrc, drresDest, { overwrite: true });
|
|
77
|
+
console.log('✅ drres 拷贝完成');
|
|
78
|
+
} else {
|
|
79
|
+
console.log(`⚠️ 源目录不存在: ${drresSrc}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// drscript
|
|
83
|
+
const drscriptSrc = path.join(pkgRoot, 'drscript');
|
|
84
|
+
const drscriptDest = path.join(COCOS_ROOT, 'assets', 'drscript');
|
|
85
|
+
|
|
86
|
+
if (fs.existsSync(drscriptSrc)) {
|
|
87
|
+
fse.ensureDirSync(drscriptDest);
|
|
88
|
+
fse.copySync(drscriptSrc, drscriptDest, { overwrite: true });
|
|
89
|
+
console.log('✅ drscript 拷贝完成');
|
|
90
|
+
} else {
|
|
91
|
+
console.log(`⚠️ 源目录不存在: ${drscriptSrc}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
console.log('🎉 资源拷贝完成!');
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error('❌ 资源拷贝失败:', error.message);
|
|
97
|
+
console.error(error.stack);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|