cocos2d-cli 2.1.1 → 2.1.3

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.
@@ -3,12 +3,14 @@ import { takeScreenshot } from '../lib/screenshot-core.js';
3
3
  export async function run(args) {
4
4
  const jsonFilePath = args[0];
5
5
  if (!jsonFilePath) {
6
- console.log(JSON.stringify({ error: '用法: cocos2d-cli screenshot <json文件> [--width <宽度>] [--height <高度>] [--output <输出路径>]' }));
6
+ console.log(JSON.stringify({ error: '用法: cocos2d-cli screenshot <json文件> [--width <宽度>] [--height <高度>] [--output <输出目录>] [--debug-bounds] [--wait <毫秒>]' }));
7
7
  return;
8
8
  }
9
9
  let width = 750;
10
10
  let height = 1334;
11
- let outputPath = path.join(process.cwd(), `screenshot-${Date.now()}.png`);
11
+ let outputDir = process.cwd();
12
+ let debugBounds = false;
13
+ let waitTime = 3000;
12
14
  for (let i = 1; i < args.length; i++) {
13
15
  const arg = args[i];
14
16
  if (arg === '--width' && args[i + 1]) {
@@ -19,8 +21,15 @@ export async function run(args) {
19
21
  height = parseInt(args[i + 1]);
20
22
  i++;
21
23
  }
22
- else if (arg === '--output' && args[i + 1]) {
23
- outputPath = args[i + 1];
24
+ else if ((arg === '--output' || arg === '-o') && args[i + 1]) {
25
+ outputDir = args[i + 1];
26
+ i++;
27
+ }
28
+ else if (arg === '--debug-bounds') {
29
+ debugBounds = true;
30
+ }
31
+ else if (arg === '--wait' && args[i + 1]) {
32
+ waitTime = parseInt(args[i + 1]);
24
33
  i++;
25
34
  }
26
35
  }
@@ -28,12 +37,14 @@ export async function run(args) {
28
37
  const { screenshotPath, logs } = await takeScreenshot({
29
38
  jsonPath: jsonFilePath,
30
39
  viewport: { width, height },
31
- outputDir: path.dirname(outputPath),
40
+ outputDir,
32
41
  fullPage: true,
42
+ debugBounds,
33
43
  timeout: 30000,
34
- waitTime: 1000
44
+ waitTime
35
45
  });
36
- console.log(JSON.stringify({ success: true, outputPath: screenshotPath }));
46
+ const filename = path.basename(screenshotPath);
47
+ console.log(JSON.stringify({ success: true, filename }));
37
48
  }
38
49
  catch (err) {
39
50
  console.log(JSON.stringify({ error: err.message }));
@@ -10,7 +10,7 @@ const DEFAULT_CONFIG = {
10
10
  fullPage: true,
11
11
  debugBounds: false,
12
12
  timeout: 30000,
13
- waitTime: 1000
13
+ waitTime: 3000
14
14
  };
15
15
  function getAssetsDir() {
16
16
  return path.join(__dirname, '..', '..', '..', 'data', 'screenshot');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cocos2d-cli",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Command-line tools for AI to read and manipulate Cocos Creator 2.4.x project scenes",
5
5
  "type": "module",
6
6
  "main": "dist/bin/cocos2d-cli.js",