@playcraft/cli 0.0.18 → 0.0.19
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/dist/build-config.js +2 -2
- package/dist/commands/build.js +26 -3
- package/dist/index.js +2 -2
- package/package.json +4 -4
package/dist/build-config.js
CHANGED
|
@@ -4,8 +4,8 @@ export async function loadBuildConfigFromFile(configPath) {
|
|
|
4
4
|
const content = await fs.readFile(configPath, 'utf-8');
|
|
5
5
|
const parsed = JSON.parse(content);
|
|
6
6
|
if (parsed && typeof parsed === 'object') {
|
|
7
|
-
// 优先从 build
|
|
8
|
-
const buildConfig = parsed.build
|
|
7
|
+
// 优先从 build 字段读取(创建副本避免修改原始对象,确保是普通对象)
|
|
8
|
+
const buildConfig = (parsed.build && typeof parsed.build === 'object' && !Array.isArray(parsed.build)) ? { ...parsed.build } : {};
|
|
9
9
|
// 如果 build 中没有 storeUrls,尝试从 agent 字段读取
|
|
10
10
|
if (!buildConfig.storeUrls && parsed.agent?.storeUrls) {
|
|
11
11
|
buildConfig.storeUrls = parsed.agent.storeUrls;
|
package/dist/commands/build.js
CHANGED
|
@@ -265,9 +265,32 @@ export async function buildCommand(projectPath, options) {
|
|
|
265
265
|
if (isPlayCanvas) {
|
|
266
266
|
if (options.scenes) {
|
|
267
267
|
// 命令行指定了场景参数
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
268
|
+
const scenesInput = options.scenes.trim().toLowerCase();
|
|
269
|
+
// 检查特殊关键字
|
|
270
|
+
if (scenesInput === 'all') {
|
|
271
|
+
// 打包所有场景
|
|
272
|
+
selectedScenes = undefined; // undefined 表示所有场景
|
|
273
|
+
console.log(`\n🎬 选中场景: 全部场景`);
|
|
274
|
+
}
|
|
275
|
+
else if (scenesInput === 'default') {
|
|
276
|
+
// 打包默认场景
|
|
277
|
+
const projectScenes = await detectProjectScenes(resolvedProjectPath);
|
|
278
|
+
const defaultScene = projectScenes.find(s => s.isMain === true) || projectScenes[0];
|
|
279
|
+
if (defaultScene) {
|
|
280
|
+
selectedScenes = [defaultScene.name || String(defaultScene.id)];
|
|
281
|
+
console.log(`\n🎬 选中场景: ${defaultScene.name || defaultScene.id}${defaultScene.isMain ? ' (默认场景)' : ' (第一个场景)'}`);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
console.log(`\n⚠️ 未找到默认场景,将打包所有场景`);
|
|
285
|
+
selectedScenes = undefined;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
// 普通场景名称列表
|
|
290
|
+
selectedScenes = options.scenes.split(',').map(s => s.trim()).filter(s => s);
|
|
291
|
+
if (selectedScenes.length > 0) {
|
|
292
|
+
console.log(`\n🎬 选中场景: ${selectedScenes.join(', ')}`);
|
|
293
|
+
}
|
|
271
294
|
}
|
|
272
295
|
}
|
|
273
296
|
else if (options.mode !== 'playable') {
|
package/dist/index.js
CHANGED
|
@@ -129,7 +129,7 @@ program
|
|
|
129
129
|
.option('-f, --format <format>', '输出格式 (html|zip)', 'html')
|
|
130
130
|
.option('-o, --output <path>', '输出目录', './dist')
|
|
131
131
|
.option('-c, --config <file>', '配置文件路径')
|
|
132
|
-
.option('-s, --scenes <scenes>', '
|
|
132
|
+
.option('-s, --scenes <scenes>', '选择场景: "all"=所有场景, "default"=默认场景, 或逗号分隔的场景名,如 "MainMenu,Gameplay"')
|
|
133
133
|
.option('-e, --engine <engine>', '指定引擎类型 (playcanvas|phaser|pixijs|threejs|cocos|babylonjs|layaair|egret|generic),默认自动检测')
|
|
134
134
|
.option('--clean', '构建前清理旧的输出目录(默认启用)', true)
|
|
135
135
|
.option('--no-clean', '跳过清理旧的输出目录')
|
|
@@ -165,7 +165,7 @@ program
|
|
|
165
165
|
.description('生成可运行的多文件构建产物(阶段1)')
|
|
166
166
|
.argument('<project-path>', '项目路径')
|
|
167
167
|
.option('-o, --output <path>', '输出目录', './build')
|
|
168
|
-
.option('-s, --scenes <scenes>', '
|
|
168
|
+
.option('-s, --scenes <scenes>', '选择场景: "all"=所有场景, "default"=默认场景, 或逗号分隔的场景名,如 "MainMenu,Gameplay"')
|
|
169
169
|
.option('-e, --engine <engine>', '指定引擎类型 (playcanvas|phaser|pixijs|threejs|cocos|babylonjs|layaair|egret|generic),默认自动检测')
|
|
170
170
|
.action(async (projectPath, options) => {
|
|
171
171
|
await buildCommand(projectPath, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcraft/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"build": "tsc",
|
|
18
18
|
"start": "node dist/index.js",
|
|
19
19
|
"test": "vitest run",
|
|
20
|
-
"link": "pnpm build && npm link",
|
|
20
|
+
"link": "node scripts/bump-local.js && pnpm build && npm link",
|
|
21
21
|
"unlink": "npm unlink -g @playcraft/cli",
|
|
22
22
|
"release": "node scripts/release.js"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@playcraft/common": "^0.0.
|
|
26
|
-
"@playcraft/build": "^0.0.
|
|
25
|
+
"@playcraft/common": "^0.0.9",
|
|
26
|
+
"@playcraft/build": "^0.0.17",
|
|
27
27
|
"chokidar": "^4.0.3",
|
|
28
28
|
"commander": "^13.1.0",
|
|
29
29
|
"cors": "^2.8.6",
|