drgame-cc 1.0.6 → 1.0.8
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 +45 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drgame-cc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
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,56 @@
|
|
|
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');
|
|
6
|
+
|
|
7
|
+
function loadEnvFile() {
|
|
8
|
+
const envPath = path.join(__dirname, '..', '.env');
|
|
9
|
+
if (fs.existsSync(envPath)) {
|
|
10
|
+
const envContent = fs.readFileSync(envPath, 'utf-8');
|
|
11
|
+
envContent.split('\n').forEach(line => {
|
|
12
|
+
const trimmedLine = line.trim();
|
|
13
|
+
if (trimmedLine && !trimmedLine.startsWith('#')) {
|
|
14
|
+
const [key, ...valueParts] = trimmedLine.split('=');
|
|
15
|
+
if (key && valueParts.length > 0) {
|
|
16
|
+
const value = valueParts.join('=').trim();
|
|
17
|
+
if (!process.env[key]) {
|
|
18
|
+
process.env[key] = value.replace(/^["']|["']$/g, '');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
loadEnvFile();
|
|
27
|
+
|
|
28
|
+
const packageRoot = path.join(__dirname, '..');
|
|
29
|
+
const COCOS_ROOT = process.env.COCOS_CREATOR_ROOT || '..';
|
|
5
30
|
|
|
6
31
|
console.log('📦 正在拷贝资源到 Cocos Creator 项目...');
|
|
7
32
|
|
|
8
33
|
try {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
34
|
+
const buildTemplatesSrc = path.join(packageRoot, 'build-templates');
|
|
35
|
+
const buildTemplatesDest = path.join(COCOS_ROOT, 'build-templates');
|
|
36
|
+
|
|
37
|
+
if (fs.existsSync(buildTemplatesSrc)) {
|
|
38
|
+
fse.copySync(buildTemplatesSrc, buildTemplatesDest, { overwrite: true });
|
|
39
|
+
console.log('✅ build-templates 拷贝完成');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const tvuiSrc = path.join(packageRoot, 'tvui');
|
|
43
|
+
const tvuiDest = path.join(COCOS_ROOT, 'assets', 'resources', 'tvui');
|
|
44
|
+
|
|
45
|
+
if (fs.existsSync(tvuiSrc)) {
|
|
46
|
+
fse.ensureDirSync(tvuiDest);
|
|
47
|
+
fse.copySync(tvuiSrc, tvuiDest, { overwrite: true });
|
|
48
|
+
console.log('✅ tvui 拷贝完成');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
console.log('🎉 资源拷贝完成!');
|
|
14
52
|
} catch (error) {
|
|
15
53
|
console.error('❌ 资源拷贝失败:', error.message);
|
|
54
|
+
console.error(error.stack);
|
|
16
55
|
process.exit(1);
|
|
17
56
|
}
|