@coze-arch/cli 0.0.36-alpha.fde2b5 → 0.0.36

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