@coze-arch/cli 0.0.36-alpha.2c0689 → 0.0.36-alpha.4e6503

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.
Files changed (151) hide show
  1. package/README.md +104 -66
  2. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +18 -74
  3. package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +1 -1
  4. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +1 -1
  5. package/lib/__templates__/expo/client/metro.config.js +1 -3
  6. package/lib/__templates__/expo/pnpm-lock.yaml +5 -5
  7. package/lib/__templates__/expo/server/package.json +2 -2
  8. package/lib/__templates__/expo/server/src/index.ts +1 -1
  9. package/lib/__templates__/expo/template.config.js +2 -11
  10. package/lib/__templates__/native-static/.coze +0 -2
  11. package/lib/__templates__/nextjs/.coze +0 -5
  12. package/lib/__templates__/nextjs/package.json +1 -1
  13. package/lib/__templates__/nextjs/pnpm-lock.yaml +5 -5
  14. package/lib/__templates__/nextjs/scripts/dev.sh +2 -83
  15. package/lib/__templates__/nextjs/template.config.js +2 -4
  16. package/lib/__templates__/nuxt-vue/.coze +0 -5
  17. package/lib/__templates__/nuxt-vue/package.json +1 -1
  18. package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +5 -5
  19. package/lib/__templates__/nuxt-vue/scripts/dev.sh +1 -82
  20. package/lib/__templates__/pi-agent/package.json +1 -1
  21. package/lib/__templates__/pi-agent/pnpm-lock.yaml +5 -5
  22. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +1 -1
  23. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +68 -150
  24. package/lib/__templates__/taro/AGENTS.md +7 -11
  25. package/lib/__templates__/taro/README.md +4 -4
  26. package/lib/__templates__/taro/config/index.ts +2 -10
  27. package/lib/__templates__/taro/pnpm-lock.yaml +5 -5
  28. package/lib/__templates__/taro/server/package.json +1 -1
  29. package/lib/__templates__/taro/server/src/main.ts +2 -8
  30. package/lib/__templates__/templates.json +1 -51
  31. package/lib/__templates__/vite/package.json +1 -1
  32. package/lib/__templates__/vite/pnpm-lock.yaml +5 -5
  33. package/lib/__templates__/vite/scripts/build.ps1 +1 -1
  34. package/lib/__templates__/vite/scripts/dev.ps1 +65 -9
  35. package/lib/__templates__/vite/scripts/dev.sh +1 -82
  36. package/lib/__templates__/vite/scripts/start.ps1 +8 -2
  37. package/lib/__templates__/vite/template.config.js +2 -4
  38. package/lib/cli.js +205 -3426
  39. package/package.json +3 -5
  40. package/docs/deploy.md +0 -172
  41. package/lib/__templates__/native-static/scripts/serve.ps1 +0 -7
  42. package/lib/__templates__/nextjs/scripts/build.ps1 +0 -16
  43. package/lib/__templates__/nextjs/scripts/dev.ps1 +0 -63
  44. package/lib/__templates__/nextjs/scripts/prepare.ps1 +0 -18
  45. package/lib/__templates__/nextjs/scripts/start.ps1 +0 -11
  46. package/lib/__templates__/nextjs/scripts/validate.ps1 +0 -8
  47. package/lib/__templates__/nuxt-vue/scripts/build.ps1 +0 -12
  48. package/lib/__templates__/nuxt-vue/scripts/dev.ps1 +0 -63
  49. package/lib/__templates__/nuxt-vue/scripts/prepare.ps1 +0 -12
  50. package/lib/__templates__/nuxt-vue/scripts/start.ps1 +0 -11
  51. package/lib/__templates__/nuxt-vue/scripts/validate.ps1 +0 -8
  52. package/lib/__templates__/phaser/.coze +0 -18
  53. package/lib/__templates__/phaser/README.md +0 -45
  54. package/lib/__templates__/phaser/_gitignore +0 -23
  55. package/lib/__templates__/phaser/_npmrc +0 -14
  56. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0001.png +0 -0
  57. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0002.png +0 -0
  58. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0003.png +0 -0
  59. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0004.png +0 -0
  60. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0005.png +0 -0
  61. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0006.png +0 -0
  62. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0007.png +0 -0
  63. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0008.png +0 -0
  64. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0009.png +0 -0
  65. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0010.png +0 -0
  66. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0011.png +0 -0
  67. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0012.png +0 -0
  68. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0013.png +0 -0
  69. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0014.png +0 -0
  70. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0015.png +0 -0
  71. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0016.png +0 -0
  72. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0017.png +0 -0
  73. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0018.png +0 -0
  74. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0019.png +0 -0
  75. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0020.png +0 -0
  76. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0021.png +0 -0
  77. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0022.png +0 -0
  78. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0023.png +0 -0
  79. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0024.png +0 -0
  80. package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/manifest.json +0 -11
  81. package/lib/__templates__/phaser/debug-runtime/flow-graph.json +0 -20
  82. package/lib/__templates__/phaser/index.html +0 -12
  83. package/lib/__templates__/phaser/package.json +0 -31
  84. package/lib/__templates__/phaser/pnpm-lock.yaml +0 -661
  85. package/lib/__templates__/phaser/scripts/build.ps1 +0 -12
  86. package/lib/__templates__/phaser/scripts/build.sh +0 -8
  87. package/lib/__templates__/phaser/scripts/dev.ps1 +0 -49
  88. package/lib/__templates__/phaser/scripts/dev.sh +0 -82
  89. package/lib/__templates__/phaser/scripts/prepare.ps1 +0 -8
  90. package/lib/__templates__/phaser/scripts/prepare.sh +0 -7
  91. package/lib/__templates__/phaser/scripts/spawn-detached.cjs +0 -29
  92. package/lib/__templates__/phaser/scripts/start.ps1 +0 -49
  93. package/lib/__templates__/phaser/scripts/start.sh +0 -82
  94. package/lib/__templates__/phaser/scripts/validate.ps1 +0 -7
  95. package/lib/__templates__/phaser/scripts/validate.sh +0 -7
  96. package/lib/__templates__/phaser/src/assets.ts +0 -15
  97. package/lib/__templates__/phaser/src/global.d.ts +0 -39
  98. package/lib/__templates__/phaser/src/main.ts +0 -28
  99. package/lib/__templates__/phaser/src/scene/BootScene.ts +0 -213
  100. package/lib/__templates__/phaser/src/scene/DevLoadingScene.ts +0 -69
  101. package/lib/__templates__/phaser/src/style.css +0 -28
  102. package/lib/__templates__/phaser/src/types.ts +0 -32
  103. package/lib/__templates__/phaser/src/utils/asset-loader.ts +0 -319
  104. package/lib/__templates__/phaser/src/utils/index.ts +0 -2
  105. package/lib/__templates__/phaser/src/utils/mark-editable.ts +0 -13
  106. package/lib/__templates__/phaser/template.config.js +0 -43
  107. package/lib/__templates__/phaser/tsconfig.json +0 -23
  108. package/lib/__templates__/phaser/vite.config.ts +0 -96
  109. package/lib/__templates__/phaser-static/.coze +0 -15
  110. package/lib/__templates__/phaser-static/README.md +0 -40
  111. package/lib/__templates__/phaser-static/_gitignore +0 -6
  112. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0001.png +0 -0
  113. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0002.png +0 -0
  114. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0003.png +0 -0
  115. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0004.png +0 -0
  116. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0005.png +0 -0
  117. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0006.png +0 -0
  118. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0007.png +0 -0
  119. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0008.png +0 -0
  120. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0009.png +0 -0
  121. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0010.png +0 -0
  122. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0011.png +0 -0
  123. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0012.png +0 -0
  124. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0013.png +0 -0
  125. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0014.png +0 -0
  126. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0015.png +0 -0
  127. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0016.png +0 -0
  128. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0017.png +0 -0
  129. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0018.png +0 -0
  130. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0019.png +0 -0
  131. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0020.png +0 -0
  132. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0021.png +0 -0
  133. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0022.png +0 -0
  134. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0023.png +0 -0
  135. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0024.png +0 -0
  136. package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/manifest.json +0 -11
  137. package/lib/__templates__/phaser-static/debug-runtime/flow-graph.json +0 -20
  138. package/lib/__templates__/phaser-static/index.html +0 -17
  139. package/lib/__templates__/phaser-static/scripts/serve.ps1 +0 -7
  140. package/lib/__templates__/phaser-static/src/assets.js +0 -15
  141. package/lib/__templates__/phaser-static/src/main.js +0 -26
  142. package/lib/__templates__/phaser-static/src/phaser.js +0 -7
  143. package/lib/__templates__/phaser-static/src/scene/BootScene.js +0 -205
  144. package/lib/__templates__/phaser-static/src/scene/DevLoadingScene.js +0 -67
  145. package/lib/__templates__/phaser-static/src/style.css +0 -28
  146. package/lib/__templates__/phaser-static/src/utils/asset-loader.js +0 -267
  147. package/lib/__templates__/phaser-static/src/utils/index.js +0 -2
  148. package/lib/__templates__/phaser-static/src/utils/mark-editable.js +0 -3
  149. package/lib/__templates__/phaser-static/template.config.js +0 -35
  150. package/lib/deploy/package-project.js +0 -244
  151. package/lib/deploy/package-project.py +0 -183
@@ -1,183 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Create the source tar.gz consumed by CreateDeployHistoryV2.
3
-
4
- This is the standalone subset of coze-coding's devbox package.py. It keeps the
5
- same archive layout and deployment exclusions without importing the devbox
6
- service runtime (FastAPI, S3FS, project managers, and background tasks).
7
- """
8
-
9
- import argparse
10
- import os
11
- import subprocess
12
- import sys
13
- import tarfile
14
- from pathlib import Path
15
-
16
- try:
17
- import tomllib
18
- except ModuleNotFoundError as error: # pragma: no cover - depends on host Python
19
- raise RuntimeError("Python 3.11 or newer is required to read .coze") from error
20
-
21
-
22
- EXCLUDED_PARTS = {
23
- ".codegraph",
24
- ".next",
25
- ".venv",
26
- "__pycache__",
27
- "node_modules",
28
- "site-packages",
29
- }
30
- UPLOAD_SESSION_FILENAME = ".coze-deploy-upload.json"
31
- UPLOAD_SESSION_TEMP_PREFIX = ".coze-deploy-upload-"
32
- HOST_LINK_FILENAME = ".host.json"
33
- PROJECT_METADATA_FILE_MODE = 0o644
34
-
35
-
36
- def build_command_env():
37
- env = os.environ.copy()
38
- cli_bin_dir = Path(__file__).resolve().parent.parent / "node_modules" / ".bin"
39
- path = env.get("PATH", "")
40
- env["PATH"] = f"{cli_bin_dir}{os.pathsep}{path}" if path else str(cli_bin_dir)
41
- return env
42
-
43
-
44
- def read_coze_config(source_dir: Path):
45
- coze_path = source_dir / ".coze"
46
- if not coze_path.is_file():
47
- return {}
48
- with coze_path.open("rb") as file:
49
- return tomllib.load(file)
50
-
51
-
52
- def read_command(config, section: str, key: str):
53
- command = (config.get(section) or {}).get(key)
54
- if command is None:
55
- return None
56
- if not isinstance(command, list) or not all(
57
- isinstance(part, str) and part for part in command
58
- ):
59
- raise ValueError(f".coze {section}.{key} must be a string array")
60
- return command
61
-
62
-
63
- def read_platform_command(config, section: str, key: str, platform=sys.platform):
64
- default_command = read_command(config, section, key)
65
- windows_command = (
66
- read_command(config, section, f"{key}_win")
67
- if platform.startswith("win")
68
- else None
69
- )
70
- if windows_command:
71
- return f"{key}_win", windows_command
72
- return (key, default_command) if default_command else None
73
-
74
-
75
- def run_pack_command(source_dir: Path):
76
- configured_command = read_platform_command(
77
- read_coze_config(source_dir), "dev", "pack"
78
- )
79
- if configured_command:
80
- key, command = configured_command
81
- print(f"[package] Running dev.{key}: {' '.join(command)}", file=sys.stderr)
82
- subprocess.run(command, cwd=source_dir, env=build_command_env(), check=True)
83
-
84
-
85
- def has_index_html(directory: Path):
86
- return (directory / "index.html").is_file()
87
-
88
-
89
- def prepare_pages_output(source_dir: Path):
90
- if has_index_html(source_dir):
91
- print(f"[package] Pages static source: {source_dir}", file=sys.stderr)
92
- return source_dir
93
-
94
- coze_path = source_dir / ".coze"
95
- if not coze_path.is_file():
96
- raise ValueError(
97
- "Pages source contains neither index.html nor a .coze file. "
98
- "Add index.html or configure a Next.js build in .coze."
99
- )
100
-
101
- config = read_coze_config(source_dir)
102
- template = (config.get("project") or {}).get("template")
103
- if not isinstance(template, str) or template.strip().lower() != "nextjs":
104
- raise ValueError(
105
- 'Pages source contains no index.html; .coze project.template must be "nextjs"'
106
- )
107
- if not read_command(config, "deploy", "build"):
108
- raise ValueError(
109
- "Pages source contains no index.html; .coze deploy.build is required"
110
- )
111
- print(f"[package] Pages Next.js source: {source_dir}", file=sys.stderr)
112
- return source_dir
113
-
114
-
115
- def should_exclude(tar_info: tarfile.TarInfo, exclude_coze_file=False):
116
- parts = Path(tar_info.name).parts
117
-
118
- # Local deployment metadata is not application source. Including it can change
119
- # the package digest on the next CLI invocation and make the resumable PreDeploy
120
- # session look like a different artifact.
121
- if any(
122
- part in {UPLOAD_SESSION_FILENAME, HOST_LINK_FILENAME}
123
- or (part.startswith(UPLOAD_SESSION_TEMP_PREFIX) and part.endswith(".tmp"))
124
- for part in parts
125
- ):
126
- return None
127
- if ".env" in parts:
128
- return None
129
- if exclude_coze_file and ".coze" in parts:
130
- return None
131
- if any(part.startswith(".git") for part in parts):
132
- return None
133
- if any(part in EXCLUDED_PARTS for part in parts):
134
- return None
135
- if parts == (".coze",) and tar_info.isfile():
136
- tar_info.mode = PROJECT_METADATA_FILE_MODE
137
- return tar_info
138
-
139
-
140
- def create_tar_gz_without_root(source_dir: Path, output_path: Path, exclude_coze_file=False):
141
- if not source_dir.is_dir():
142
- raise ValueError(f"source directory does not exist: {source_dir}")
143
- output_path.parent.mkdir(parents=True, exist_ok=True)
144
- print(f"[package] Creating archive from: {source_dir}", file=sys.stderr)
145
- with tarfile.open(output_path, "w:gz") as archive:
146
- for entry in sorted(os.listdir(source_dir)):
147
- if entry == ".codegraph":
148
- continue
149
- if (source_dir / entry).resolve() == output_path.resolve():
150
- continue
151
- archive.add(
152
- source_dir / entry,
153
- arcname=entry,
154
- filter=lambda info: should_exclude(info, exclude_coze_file),
155
- )
156
- if not output_path.is_file() or output_path.stat().st_size <= 0:
157
- raise RuntimeError("source archive is empty")
158
- print(
159
- f"[package] Archive ready: {output_path.stat().st_size} bytes",
160
- file=sys.stderr,
161
- )
162
-
163
-
164
- def main():
165
- parser = argparse.ArgumentParser()
166
- parser.add_argument("source_dir")
167
- parser.add_argument("output_path")
168
- parser.add_argument("--pages", action="store_true")
169
- args = parser.parse_args()
170
-
171
- source_dir = Path(args.source_dir).resolve()
172
- output_path = Path(args.output_path).resolve()
173
- if args.pages:
174
- package_dir = prepare_pages_output(source_dir)
175
- else:
176
- run_pack_command(source_dir)
177
- package_dir = source_dir
178
- create_tar_gz_without_root(package_dir, output_path, args.pages)
179
- print(output_path.stat().st_size)
180
-
181
-
182
- if __name__ == "__main__":
183
- main()