drgame-cc 1.0.7 → 1.0.9
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 +6 -6
- package/scripts/postinstall.js +67 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drgame-cc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Cocos Creator 资源导出工具包 - 支持预制体、图片、音乐等资源导出",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
26
26
|
"@typescript-eslint/parser": "^7.0.0",
|
|
27
27
|
"eslint": "^8.57.0",
|
|
28
|
+
"gulp": "^5.0.1",
|
|
29
|
+
"gulp-inject-string": "^1.1.2",
|
|
30
|
+
"gulp-minify": "^3.1.0",
|
|
31
|
+
"gulp-typescript": "^6.0.0-alpha.1",
|
|
28
32
|
"rimraf": "^5.0.0",
|
|
29
33
|
"typescript": "5.9.3"
|
|
30
34
|
},
|
|
31
35
|
"dependencies": {
|
|
32
|
-
"fs-extra": "^11.2.0"
|
|
33
|
-
"gulp": "^5.0.1",
|
|
34
|
-
"gulp-inject-string": "^1.1.2",
|
|
35
|
-
"gulp-minify": "^3.1.0",
|
|
36
|
-
"gulp-typescript": "^6.0.0-alpha.1"
|
|
36
|
+
"fs-extra": "^11.2.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"typescript": "^5.0.0"
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,17 +1,77 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const { execSync } = require('child_process');
|
|
4
3
|
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const fse = require('fs-extra');
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
// ============================================================
|
|
8
|
+
// 1. 确定宿主项目根目录
|
|
9
|
+
// ============================================================
|
|
10
|
+
const projectRoot = path.resolve(__dirname, '..', '..');
|
|
7
11
|
|
|
12
|
+
// ============================================================
|
|
13
|
+
// 2. 加载宿主项目根目录下的 .env
|
|
14
|
+
// ============================================================
|
|
15
|
+
function loadEnvFile() {
|
|
16
|
+
const envPath = path.join(projectRoot, '.env');
|
|
17
|
+
if (fs.existsSync(envPath)) {
|
|
18
|
+
const envContent = fs.readFileSync(envPath, 'utf-8');
|
|
19
|
+
envContent.split('\n').forEach(line => {
|
|
20
|
+
const trimmedLine = line.trim();
|
|
21
|
+
if (trimmedLine && !trimmedLine.startsWith('#')) {
|
|
22
|
+
const [key, ...valueParts] = trimmedLine.split('=');
|
|
23
|
+
if (key && valueParts.length > 0) {
|
|
24
|
+
const value = valueParts.join('=').trim();
|
|
25
|
+
if (!process.env[key]) {
|
|
26
|
+
process.env[key] = value.replace(/^["']|["']$/g, '');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
console.log('✅ 已加载 .env');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
loadEnvFile();
|
|
36
|
+
|
|
37
|
+
// ============================================================
|
|
38
|
+
// 3. 确定目标目录
|
|
39
|
+
// ============================================================
|
|
40
|
+
const COCOS_ROOT = process.env.COCOS_CREATOR_ROOT || projectRoot;
|
|
41
|
+
|
|
42
|
+
console.log(`📦 宿主项目: ${projectRoot}`);
|
|
43
|
+
console.log(`📦 目标目录: ${COCOS_ROOT}`);
|
|
44
|
+
|
|
45
|
+
// ============================================================
|
|
46
|
+
// 4. 拷贝资源
|
|
47
|
+
// ============================================================
|
|
8
48
|
try {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
49
|
+
// build-templates
|
|
50
|
+
const buildTemplatesSrc = path.join(projectRoot, 'node_modules', 'drgame-cc', 'build-templates');
|
|
51
|
+
const buildTemplatesDest = path.join(COCOS_ROOT, 'build-templates');
|
|
52
|
+
|
|
53
|
+
if (fs.existsSync(buildTemplatesSrc)) {
|
|
54
|
+
fse.copySync(buildTemplatesSrc, buildTemplatesDest, { overwrite: true });
|
|
55
|
+
console.log('✅ build-templates 拷贝完成');
|
|
56
|
+
} else {
|
|
57
|
+
console.log(`⚠️ 源目录不存在: ${buildTemplatesSrc}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// tvui
|
|
61
|
+
const tvuiSrc = path.join(projectRoot, 'node_modules', 'drgame-cc', 'tvui');
|
|
62
|
+
const tvuiDest = path.join(COCOS_ROOT, 'assets', 'resources', 'tvui');
|
|
63
|
+
|
|
64
|
+
if (fs.existsSync(tvuiSrc)) {
|
|
65
|
+
fse.ensureDirSync(tvuiDest);
|
|
66
|
+
fse.copySync(tvuiSrc, tvuiDest, { overwrite: true });
|
|
67
|
+
console.log('✅ tvui 拷贝完成');
|
|
68
|
+
} else {
|
|
69
|
+
console.log(`⚠️ 源目录不存在: ${tvuiSrc}`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
console.log('🎉 资源拷贝完成!');
|
|
14
73
|
} catch (error) {
|
|
15
74
|
console.error('❌ 资源拷贝失败:', error.message);
|
|
75
|
+
console.error(error.stack);
|
|
16
76
|
process.exit(1);
|
|
17
77
|
}
|