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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drgame-cc",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Cocos Creator 资源导出工具包 - 支持预制体、图片、音乐等资源导出",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -4,48 +4,49 @@ const path = require('path');
4
4
  const fs = require('fs');
5
5
  const fse = require('fs-extra');
6
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 || '..';
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
- const buildTemplatesSrc = path.join(packageRoot, 'build-templates');
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
- const tvuiSrc = path.join(packageRoot, 'tvui');
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('🎉 资源拷贝完成!');