MCPcopy Create free account
hub / github.com/TheCSir/TerminalStart / create_source_zip

Function create_source_zip

scripts/package_source.py:4–45  ·  view source on GitHub ↗
(output_filename)

Source from the content-addressed store, hash-verified

2import os
3
4def create_source_zip(output_filename):
5 # Root-level config files to include
6 include_files = [
7 "index.html", "package.json",
8 "package-lock.json", "tsconfig.json", "vite.config.js",
9 "tailwind.config.js", "postcss.config.js"
10 ]
11 # Directories to include
12 include_dirs = ["src", "extension", "scripts"]
13
14 # SECURITY: Use relative path to avoid exposing user info or hardcoded paths
15 base_dir = os.path.dirname(os.path.abspath(__file__))
16 project_root = os.path.dirname(base_dir)
17 output_path = os.path.join(project_root, output_filename)
18
19 with zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
20 # Add individual files
21 for f in include_files:
22 file_path = os.path.join(project_root, f)
23 if os.path.exists(file_path):
24 zipf.write(file_path, arcname=f)
25
26 # Add directories with forward slash enforcement
27 for d in include_dirs:
28 dir_path = os.path.join(project_root, d)
29 if os.path.exists(dir_path):
30 for root, dirs, files in os.walk(dir_path):
31 # Exclude hidden directories
32 dirs[:] = [d for d in dirs if d not in ['.git', '__pycache__', '.idea', '.vscode', 'node_modules']]
33
34 for file in files:
35 # Exclude build artifacts and system files
36 if file.endswith(('.zip', '.DS_Store')):
37 continue
38
39 full_path = os.path.join(root, file)
40 rel_path = os.path.relpath(full_path, project_root)
41 # CRITICAL: Force forward slashes for cross-platform compatibility
42 arcname = rel_path.replace(os.path.sep, '/')
43 zipf.write(full_path, arcname)
44
45 print(f"Successfully created source zip: {output_path}")
46
47if __name__ == "__main__":
48 create_source_zip("terminal-start-source-v1.0.0.zip")

Callers 1

package_source.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected