drgame-cc 1.0.8 → 1.0.10
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 +1 -1
- package/scripts/postinstall.js +29 -28
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -4,48 +4,49 @@ const path = require('path');
|
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const fse = require('fs-extra');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const packageRoot = path.join(__dirname, '..');
|
|
29
|
-
const COCOS_ROOT = process.env.COCOS_CREATOR_ROOT || '..';
|
|
30
|
-
|
|
31
|
-
console.log('📦 正在拷贝资源到 Cocos Creator 项目...');
|
|
32
|
-
|
|
7
|
+
// ============================================================
|
|
8
|
+
// 1. 确定宿主项目根目录
|
|
9
|
+
// ============================================================
|
|
10
|
+
const projectRoot = path.resolve(__dirname, '..', '..');
|
|
11
|
+
|
|
12
|
+
// ============================================================
|
|
13
|
+
// 2. 加载宿主项目根目录下的 .env
|
|
14
|
+
// ============================================================
|
|
15
|
+
console.log('✅ 开始拷贝资源');
|
|
16
|
+
|
|
17
|
+
// ============================================================
|
|
18
|
+
// 3. 确定目标目录
|
|
19
|
+
// ============================================================
|
|
20
|
+
const COCOS_ROOT = process.env.COCOS_CREATOR_ROOT || projectRoot;
|
|
21
|
+
|
|
22
|
+
console.log(`📦 宿主项目: ${projectRoot}`);
|
|
23
|
+
console.log(`📦 目标目录: ${COCOS_ROOT}`);
|
|
24
|
+
|
|
25
|
+
// ============================================================
|
|
26
|
+
// 4. 拷贝资源
|
|
27
|
+
// ============================================================
|
|
33
28
|
try {
|
|
34
|
-
|
|
29
|
+
// build-templates
|
|
30
|
+
const buildTemplatesSrc = path.join(projectRoot, 'node_modules', 'drgame-cc', 'build-templates');
|
|
35
31
|
const buildTemplatesDest = path.join(COCOS_ROOT, 'build-templates');
|
|
36
32
|
|
|
37
33
|
if (fs.existsSync(buildTemplatesSrc)) {
|
|
38
34
|
fse.copySync(buildTemplatesSrc, buildTemplatesDest, { overwrite: true });
|
|
39
35
|
console.log('✅ build-templates 拷贝完成');
|
|
36
|
+
} else {
|
|
37
|
+
console.log(`⚠️ 源目录不存在: ${buildTemplatesSrc}`);
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
// tvui
|
|
41
|
+
const tvuiSrc = path.join(projectRoot, 'node_modules', 'drgame-cc', 'tvui');
|
|
43
42
|
const tvuiDest = path.join(COCOS_ROOT, 'assets', 'resources', 'tvui');
|
|
44
43
|
|
|
45
44
|
if (fs.existsSync(tvuiSrc)) {
|
|
46
45
|
fse.ensureDirSync(tvuiDest);
|
|
47
46
|
fse.copySync(tvuiSrc, tvuiDest, { overwrite: true });
|
|
48
47
|
console.log('✅ tvui 拷贝完成');
|
|
48
|
+
} else {
|
|
49
|
+
console.log(`⚠️ 源目录不存在: ${tvuiSrc}`);
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
console.log('🎉 资源拷贝完成!');
|