zexus 1.6.2
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/LICENSE +0 -0
- package/README.md +2513 -0
- package/bin/zexus +2 -0
- package/bin/zpics +2 -0
- package/bin/zpm +2 -0
- package/bin/zx +2 -0
- package/bin/zx-deploy +2 -0
- package/bin/zx-dev +2 -0
- package/bin/zx-run +2 -0
- package/package.json +66 -0
- package/scripts/README.md +24 -0
- package/scripts/postinstall.js +44 -0
- package/shared_config.json +24 -0
- package/src/README.md +1525 -0
- package/src/tests/run_zexus_tests.py +117 -0
- package/src/tests/test_all_phases.zx +346 -0
- package/src/tests/test_blockchain_features.zx +306 -0
- package/src/tests/test_complexity_features.zx +321 -0
- package/src/tests/test_core_integration.py +185 -0
- package/src/tests/test_phase10_ecosystem.zx +177 -0
- package/src/tests/test_phase1_modifiers.zx +87 -0
- package/src/tests/test_phase2_plugins.zx +80 -0
- package/src/tests/test_phase3_security.zx +97 -0
- package/src/tests/test_phase4_vfs.zx +116 -0
- package/src/tests/test_phase5_types.zx +117 -0
- package/src/tests/test_phase6_metaprogramming.zx +125 -0
- package/src/tests/test_phase7_optimization.zx +132 -0
- package/src/tests/test_phase9_advanced_types.zx +157 -0
- package/src/tests/test_security_features.py +419 -0
- package/src/tests/test_security_features.zx +276 -0
- package/src/tests/test_simple_zx.zx +1 -0
- package/src/tests/test_verification_simple.zx +69 -0
- package/src/zexus/__init__.py +28 -0
- package/src/zexus/__main__.py +5 -0
- package/src/zexus/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/advanced_types.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/builtin_modules.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/capability_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/complexity_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/concurrency_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/config.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/dependency_injection.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/ecosystem.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/environment.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/error_reporter.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/hybrid_orchestrator.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/lexer.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/metaprogramming.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/module_cache.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/object.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/optimization.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/plugin_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/policy_engine.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/security.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/stdlib_integration.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/strategy_recovery.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/syntax_validator.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/type_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/virtual_filesystem.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/zexus_ast.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/zexus_token.cpython-312.pyc +0 -0
- package/src/zexus/advanced_types.py +401 -0
- package/src/zexus/blockchain/__init__.py +40 -0
- package/src/zexus/blockchain/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/blockchain/__pycache__/crypto.cpython-312.pyc +0 -0
- package/src/zexus/blockchain/__pycache__/ledger.cpython-312.pyc +0 -0
- package/src/zexus/blockchain/__pycache__/transaction.cpython-312.pyc +0 -0
- package/src/zexus/blockchain/crypto.py +463 -0
- package/src/zexus/blockchain/ledger.py +255 -0
- package/src/zexus/blockchain/transaction.py +267 -0
- package/src/zexus/builtin_modules.py +284 -0
- package/src/zexus/builtin_plugins.py +317 -0
- package/src/zexus/capability_system.py +372 -0
- package/src/zexus/cli/__init__.py +2 -0
- package/src/zexus/cli/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/cli/__pycache__/main.cpython-312.pyc +0 -0
- package/src/zexus/cli/main.py +707 -0
- package/src/zexus/cli/zpm.py +203 -0
- package/src/zexus/compare_interpreter_compiler.py +146 -0
- package/src/zexus/compiler/__init__.py +169 -0
- package/src/zexus/compiler/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/lexer.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/parser.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/zexus_ast.cpython-312.pyc +0 -0
- package/src/zexus/compiler/bytecode.py +266 -0
- package/src/zexus/compiler/compat_runtime.py +277 -0
- package/src/zexus/compiler/lexer.py +257 -0
- package/src/zexus/compiler/parser.py +779 -0
- package/src/zexus/compiler/semantic.py +118 -0
- package/src/zexus/compiler/zexus_ast.py +454 -0
- package/src/zexus/complexity_system.py +575 -0
- package/src/zexus/concurrency_system.py +493 -0
- package/src/zexus/config.py +201 -0
- package/src/zexus/crypto_bridge.py +19 -0
- package/src/zexus/dependency_injection.py +423 -0
- package/src/zexus/ecosystem.py +434 -0
- package/src/zexus/environment.py +101 -0
- package/src/zexus/environment_manager.py +119 -0
- package/src/zexus/error_reporter.py +314 -0
- package/src/zexus/evaluator/__init__.py +12 -0
- package/src/zexus/evaluator/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/bytecode_compiler.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/core.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/expressions.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/functions.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/integration.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/statements.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/utils.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/bytecode_compiler.py +700 -0
- package/src/zexus/evaluator/core.py +891 -0
- package/src/zexus/evaluator/expressions.py +827 -0
- package/src/zexus/evaluator/functions.py +3989 -0
- package/src/zexus/evaluator/integration.py +396 -0
- package/src/zexus/evaluator/statements.py +4303 -0
- package/src/zexus/evaluator/utils.py +126 -0
- package/src/zexus/evaluator_original.py +2041 -0
- package/src/zexus/external_bridge.py +16 -0
- package/src/zexus/find_affected_imports.sh +155 -0
- package/src/zexus/hybrid_orchestrator.py +152 -0
- package/src/zexus/input_validation.py +259 -0
- package/src/zexus/lexer.py +571 -0
- package/src/zexus/logging.py +89 -0
- package/src/zexus/lsp/__init__.py +9 -0
- package/src/zexus/lsp/completion_provider.py +207 -0
- package/src/zexus/lsp/definition_provider.py +22 -0
- package/src/zexus/lsp/hover_provider.py +71 -0
- package/src/zexus/lsp/server.py +269 -0
- package/src/zexus/lsp/symbol_provider.py +31 -0
- package/src/zexus/metaprogramming.py +321 -0
- package/src/zexus/module_cache.py +89 -0
- package/src/zexus/module_manager.py +107 -0
- package/src/zexus/object.py +973 -0
- package/src/zexus/optimization.py +424 -0
- package/src/zexus/parser/__init__.py +31 -0
- package/src/zexus/parser/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/parser/__pycache__/parser.cpython-312.pyc +0 -0
- package/src/zexus/parser/__pycache__/strategy_context.cpython-312.pyc +0 -0
- package/src/zexus/parser/__pycache__/strategy_structural.cpython-312.pyc +0 -0
- package/src/zexus/parser/integration.py +86 -0
- package/src/zexus/parser/parser.py +3977 -0
- package/src/zexus/parser/strategy_context.py +7254 -0
- package/src/zexus/parser/strategy_structural.py +1033 -0
- package/src/zexus/persistence.py +391 -0
- package/src/zexus/plugin_system.py +290 -0
- package/src/zexus/policy_engine.py +365 -0
- package/src/zexus/profiler/__init__.py +5 -0
- package/src/zexus/profiler/profiler.py +233 -0
- package/src/zexus/purity_system.py +398 -0
- package/src/zexus/runtime/__init__.py +20 -0
- package/src/zexus/runtime/async_runtime.py +324 -0
- package/src/zexus/search_old_imports.sh +65 -0
- package/src/zexus/security.py +1407 -0
- package/src/zexus/stack_trace.py +233 -0
- package/src/zexus/stdlib/__init__.py +27 -0
- package/src/zexus/stdlib/blockchain.py +341 -0
- package/src/zexus/stdlib/compression.py +167 -0
- package/src/zexus/stdlib/crypto.py +124 -0
- package/src/zexus/stdlib/datetime.py +163 -0
- package/src/zexus/stdlib/db_mongo.py +199 -0
- package/src/zexus/stdlib/db_mysql.py +162 -0
- package/src/zexus/stdlib/db_postgres.py +163 -0
- package/src/zexus/stdlib/db_sqlite.py +133 -0
- package/src/zexus/stdlib/encoding.py +230 -0
- package/src/zexus/stdlib/fs.py +195 -0
- package/src/zexus/stdlib/http.py +219 -0
- package/src/zexus/stdlib/http_server.py +248 -0
- package/src/zexus/stdlib/json_module.py +61 -0
- package/src/zexus/stdlib/math.py +360 -0
- package/src/zexus/stdlib/os_module.py +265 -0
- package/src/zexus/stdlib/regex.py +148 -0
- package/src/zexus/stdlib/sockets.py +253 -0
- package/src/zexus/stdlib/test_framework.zx +208 -0
- package/src/zexus/stdlib/test_runner.zx +119 -0
- package/src/zexus/stdlib_integration.py +341 -0
- package/src/zexus/strategy_recovery.py +256 -0
- package/src/zexus/syntax_validator.py +356 -0
- package/src/zexus/testing/zpics.py +407 -0
- package/src/zexus/testing/zpics_runtime.py +369 -0
- package/src/zexus/type_system.py +374 -0
- package/src/zexus/validation_system.py +569 -0
- package/src/zexus/virtual_filesystem.py +355 -0
- package/src/zexus/vm/__init__.py +8 -0
- package/src/zexus/vm/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/async_optimizer.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/bytecode.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/cache.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/jit.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/memory_manager.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/memory_pool.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/optimizer.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/parallel_vm.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/peephole_optimizer.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/profiler.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/register_allocator.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/register_vm.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/ssa_converter.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/vm.cpython-312.pyc +0 -0
- package/src/zexus/vm/async_optimizer.py +420 -0
- package/src/zexus/vm/bytecode.py +428 -0
- package/src/zexus/vm/bytecode_converter.py +297 -0
- package/src/zexus/vm/cache.py +532 -0
- package/src/zexus/vm/jit.py +720 -0
- package/src/zexus/vm/memory_manager.py +520 -0
- package/src/zexus/vm/memory_pool.py +511 -0
- package/src/zexus/vm/optimizer.py +478 -0
- package/src/zexus/vm/parallel_vm.py +899 -0
- package/src/zexus/vm/peephole_optimizer.py +452 -0
- package/src/zexus/vm/profiler.py +527 -0
- package/src/zexus/vm/register_allocator.py +462 -0
- package/src/zexus/vm/register_vm.py +520 -0
- package/src/zexus/vm/ssa_converter.py +757 -0
- package/src/zexus/vm/vm.py +1392 -0
- package/src/zexus/zexus_ast.py +1782 -0
- package/src/zexus/zexus_token.py +253 -0
- package/src/zexus/zpm/__init__.py +15 -0
- package/src/zexus/zpm/installer.py +116 -0
- package/src/zexus/zpm/package_manager.py +208 -0
- package/src/zexus/zpm/publisher.py +98 -0
- package/src/zexus/zpm/registry.py +110 -0
- package/src/zexus.egg-info/PKG-INFO +2235 -0
- package/src/zexus.egg-info/SOURCES.txt +876 -0
- package/src/zexus.egg-info/dependency_links.txt +1 -0
- package/src/zexus.egg-info/entry_points.txt +3 -0
- package/src/zexus.egg-info/not-zip-safe +1 -0
- package/src/zexus.egg-info/requires.txt +14 -0
- package/src/zexus.egg-info/top_level.txt +2 -0
- package/zexus.json +14 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# zexus_token.py (ENHANCED WITH PHASE 1 TOKENS)
|
|
2
|
+
|
|
3
|
+
# Special Tokens
|
|
4
|
+
ILLEGAL = "ILLEGAL"
|
|
5
|
+
EOF = "EOF"
|
|
6
|
+
|
|
7
|
+
# Identifiers + Literals
|
|
8
|
+
IDENT = "IDENT"
|
|
9
|
+
INT = "INT"
|
|
10
|
+
STRING = "STRING"
|
|
11
|
+
FLOAT = "FLOAT"
|
|
12
|
+
|
|
13
|
+
# Operators
|
|
14
|
+
ASSIGN = "="
|
|
15
|
+
PLUS = "+"
|
|
16
|
+
MINUS = "-"
|
|
17
|
+
SLASH = "/"
|
|
18
|
+
STAR = "*"
|
|
19
|
+
BANG = "!"
|
|
20
|
+
LT = "<"
|
|
21
|
+
GT = ">"
|
|
22
|
+
EQ = "=="
|
|
23
|
+
NOT_EQ = "!="
|
|
24
|
+
MOD = "%"
|
|
25
|
+
DOT = "."
|
|
26
|
+
LTE = "<="
|
|
27
|
+
GTE = ">="
|
|
28
|
+
APPEND = ">>" # Append operator for LOG: log >> file
|
|
29
|
+
IMPORT_OP = "<<" # Import operator: << file or let x << file
|
|
30
|
+
AND = "&&"
|
|
31
|
+
OR = "||"
|
|
32
|
+
QUESTION = "?" # Ternary operator: condition ? true_val : false_val
|
|
33
|
+
NULLISH = "??" # Nullish coalescing: value ?? default
|
|
34
|
+
|
|
35
|
+
# Delimiters
|
|
36
|
+
COMMA = ","
|
|
37
|
+
SEMICOLON = ";"
|
|
38
|
+
COLON = ":"
|
|
39
|
+
LPAREN = "("
|
|
40
|
+
RPAREN = ")"
|
|
41
|
+
LBRACE = "{"
|
|
42
|
+
RBRACE = "}"
|
|
43
|
+
LBRACKET = "["
|
|
44
|
+
RBRACKET = "]"
|
|
45
|
+
AT = "@" # Decorator symbol: @logged, @cached, etc.
|
|
46
|
+
|
|
47
|
+
# Backwards-compatible alias: some parts of the codebase expect the name
|
|
48
|
+
# ASTERISK for the multiplication token. Provide a stable alias to avoid
|
|
49
|
+
# NameError when older modules reference ASTERISK.
|
|
50
|
+
ASTERISK = STAR
|
|
51
|
+
|
|
52
|
+
# Keywords
|
|
53
|
+
LET = "LET"
|
|
54
|
+
CONST = "CONST" # NEW: Const immutable variables
|
|
55
|
+
DATA = "DATA" # NEW: Dataclass definitions
|
|
56
|
+
PRINT = "PRINT"
|
|
57
|
+
IF = "IF"
|
|
58
|
+
THEN = "THEN" # NEW: Then for if-then-else expressions
|
|
59
|
+
ELIF = "ELIF" # NEW: Elif else-if conditionals
|
|
60
|
+
ELSE = "ELSE"
|
|
61
|
+
RETURN = "RETURN"
|
|
62
|
+
TRUE = "TRUE"
|
|
63
|
+
FALSE = "FALSE"
|
|
64
|
+
NULL = "NULL"
|
|
65
|
+
FOR = "FOR"
|
|
66
|
+
EACH = "EACH"
|
|
67
|
+
IN = "IN"
|
|
68
|
+
ACTION = "ACTION"
|
|
69
|
+
FUNCTION = "FUNCTION"
|
|
70
|
+
SCREEN = "SCREEN"
|
|
71
|
+
COMPONENT = "COMPONENT"
|
|
72
|
+
THEME = "THEME"
|
|
73
|
+
COLOR = "COLOR"
|
|
74
|
+
GRAPHICS = "GRAPHICS"
|
|
75
|
+
CANVAS = "CANVAS"
|
|
76
|
+
ANIMATION = "ANIMATION"
|
|
77
|
+
CLOCK = "CLOCK"
|
|
78
|
+
MAP = "MAP"
|
|
79
|
+
WHILE = "WHILE"
|
|
80
|
+
USE = "USE"
|
|
81
|
+
EXACTLY = "EXACTLY"
|
|
82
|
+
EMBEDDED = "EMBEDDED"
|
|
83
|
+
EXPORT = "EXPORT"
|
|
84
|
+
LAMBDA = "LAMBDA"
|
|
85
|
+
DEBUG = "DEBUG" # NEW: Debug token
|
|
86
|
+
TRY = "TRY" # NEW: Try token
|
|
87
|
+
CATCH = "CATCH" # NEW: Catch token
|
|
88
|
+
CONTINUE = "CONTINUE" # NEW: Continue on error token
|
|
89
|
+
BREAK = "BREAK" # NEW: Break loop statement
|
|
90
|
+
THROW = "THROW" # NEW: Throw error statement
|
|
91
|
+
EXTERNAL = "EXTERNAL" # NEW: From token
|
|
92
|
+
FROM = "FROM" # NEW: From token
|
|
93
|
+
|
|
94
|
+
# ASYNC / AWAIT / MODULE / EVENT / ENUM / PROTOCOL tokens
|
|
95
|
+
ASYNC = "ASYNC"
|
|
96
|
+
AWAIT = "AWAIT"
|
|
97
|
+
EVENT = "EVENT"
|
|
98
|
+
EMIT = "EMIT"
|
|
99
|
+
ENUM = "ENUM"
|
|
100
|
+
PROTOCOL = "PROTOCOL"
|
|
101
|
+
IMPORT = "IMPORT"
|
|
102
|
+
|
|
103
|
+
# SECURITY & ADVANCED FEATURES
|
|
104
|
+
ENTITY = "ENTITY" # Entity declaration: entity User { ... }
|
|
105
|
+
VERIFY = "VERIFY" # Verify checks: verify(action_name, ...conditions)
|
|
106
|
+
CONTRACT = "CONTRACT" # Smart contracts: contract Token { ... }
|
|
107
|
+
PROTECT = "PROTECT" # Protection guardrails: protect(action, rules)
|
|
108
|
+
SEAL = "SEAL" # Seal objects: seal identifier
|
|
109
|
+
AUDIT = "AUDIT" # Audit log: audit data_name, action_type, timestamp
|
|
110
|
+
RESTRICT = "RESTRICT" # Field-level access control: restrict obj.field = "rule"
|
|
111
|
+
SANDBOX = "SANDBOX" # Isolated execution environment: sandbox { code }
|
|
112
|
+
TRAIL = "TRAIL" # Real-time audit/debug/print trail: trail audit_or_print_or_debug
|
|
113
|
+
|
|
114
|
+
# CAPABILITY-BASED SECURITY (NEW)
|
|
115
|
+
CAPABILITY = "CAPABILITY" # Define capabilities: capability(name, description, scope)
|
|
116
|
+
GRANT = "GRANT" # Grant capabilities: grant entity_name capability(name)
|
|
117
|
+
REVOKE = "REVOKE" # Revoke capabilities: revoke entity_name capability(name)
|
|
118
|
+
IMMUTABLE = "IMMUTABLE" # Enforce immutability: immutable identifier
|
|
119
|
+
|
|
120
|
+
# DATA VALIDATION & SANITIZATION (NEW)
|
|
121
|
+
VALIDATE = "VALIDATE" # Validate data: validate(value, schema, options)
|
|
122
|
+
SANITIZE = "SANITIZE" # Sanitize input: sanitize(value, rules, encoding)
|
|
123
|
+
|
|
124
|
+
# COMPLEXITY & LARGE PROJECT MANAGEMENT (NEW)
|
|
125
|
+
INTERFACE = "INTERFACE" # Define formal interface: interface Drawable { ... }
|
|
126
|
+
TYPE_ALIAS = "TYPE_ALIAS" # Type alias: type_alias UserID = integer;
|
|
127
|
+
MODULE = "MODULE" # Module definition: module database { ... }
|
|
128
|
+
USING = "USING" # Resource management: using(file) { ... }
|
|
129
|
+
PACKAGE = "PACKAGE" # Package/namespace: package myapp.utils { ... }
|
|
130
|
+
|
|
131
|
+
# CONCURRENCY & PERFORMANCE (NEW)
|
|
132
|
+
CHANNEL = "CHANNEL" # Channel definition: channel<integer> data;
|
|
133
|
+
SEND = "SEND" # Send to channel: send(channel, value);
|
|
134
|
+
RECEIVE = "RECEIVE" # Receive from channel: receive(channel);
|
|
135
|
+
ATOMIC = "ATOMIC" # Atomic operations: atomic(counter++);
|
|
136
|
+
|
|
137
|
+
# RENDERER OPERATIONS (ADD THESE)
|
|
138
|
+
MIX = "MIX" # Color mixing: mix("blue", "red", 0.5)
|
|
139
|
+
RENDER = "RENDER" # Render screen: render_screen("login")
|
|
140
|
+
ADD_TO = "ADD_TO" # Add component: add_to_screen("login", "button")
|
|
141
|
+
SET_THEME = "SET_THEME" # Set theme: set_theme("dark")
|
|
142
|
+
CREATE_CANVAS = "CREATE_CANVAS" # Create canvas: create_canvas(80, 25)
|
|
143
|
+
DRAW = "DRAW" # Draw operation: draw_line(x1, y1, x2, y2)
|
|
144
|
+
|
|
145
|
+
# PROPERTY TOKENS (ADD THESE)
|
|
146
|
+
WIDTH = "WIDTH"
|
|
147
|
+
HEIGHT = "HEIGHT"
|
|
148
|
+
X = "X"
|
|
149
|
+
Y = "Y"
|
|
150
|
+
TEXT = "TEXT"
|
|
151
|
+
BACKGROUND = "BACKGROUND"
|
|
152
|
+
BORDER = "BORDER"
|
|
153
|
+
STYLE = "STYLE"
|
|
154
|
+
RADIUS = "RADIUS"
|
|
155
|
+
FILL = "FILL"
|
|
156
|
+
|
|
157
|
+
# ADVANCED FEATURE TOKENS
|
|
158
|
+
MIDDLEWARE = "MIDDLEWARE"
|
|
159
|
+
AUTH = "AUTH"
|
|
160
|
+
THROTTLE = "THROTTLE"
|
|
161
|
+
CACHE = "CACHE"
|
|
162
|
+
INJECT = "INJECT" # Dependency injection: inject DatabaseAPI
|
|
163
|
+
|
|
164
|
+
# BLOCKCHAIN & SMART CONTRACT TOKENS
|
|
165
|
+
LEDGER = "LEDGER" # Immutable state ledger: ledger balances;
|
|
166
|
+
STATE = "STATE" # State management: state counter = 0;
|
|
167
|
+
TX = "TX" # Transaction context: TX.caller, TX.timestamp
|
|
168
|
+
REVERT = "REVERT" # Revert transaction: revert("reason");
|
|
169
|
+
REQUIRE = "REQUIRE" # Require condition: require(condition, "error");
|
|
170
|
+
HASH = "HASH" # Hash function: hash(data, "SHA256");
|
|
171
|
+
SIGNATURE = "SIGNATURE" # Create signature: signature(data, private_key);
|
|
172
|
+
VERIFY_SIG = "VERIFY_SIG" # Verify signature: verify_sig(data, sig, public_key);
|
|
173
|
+
LIMIT = "LIMIT" # Gas/resource limit: action transfer() limit 1000 { ... };
|
|
174
|
+
GAS = "GAS" # Gas tracking: gas_used(), gas_remaining()
|
|
175
|
+
PERSISTENT = "PERSISTENT"
|
|
176
|
+
STORAGE = "STORAGE"
|
|
177
|
+
REQUIRE = "REQUIRE"
|
|
178
|
+
|
|
179
|
+
# PERFORMANCE OPTIMIZATION TOKENS
|
|
180
|
+
NATIVE = "NATIVE" # Call C/C++ code: native { "func_name", arg1, arg2 }
|
|
181
|
+
GC = "GC" # Control garbage collection: gc "collect" or gc "pause"
|
|
182
|
+
INLINE = "INLINE" # Function inlining: inline func_name
|
|
183
|
+
BUFFER = "BUFFER" # Direct memory access: buffer(ptr, size)
|
|
184
|
+
SIMD = "SIMD" # Vector operations: simd(operation, vector1, vector2)
|
|
185
|
+
|
|
186
|
+
# CONVENIENCE FEATURES TOKENS
|
|
187
|
+
DEFER = "DEFER" # Cleanup code execution: defer cleanup_code;
|
|
188
|
+
PATTERN = "PATTERN" # Pattern matching: pattern value { case x => ...; }
|
|
189
|
+
MATCH = "MATCH" # Match expression: match value { Point(x, y) => ... }
|
|
190
|
+
|
|
191
|
+
# ADVANCED FEATURES TOKENS
|
|
192
|
+
ENUM = "ENUM" # Type-safe enumerations: enum Color { Red, Green, Blue }
|
|
193
|
+
STREAM = "STREAM" # Event streaming: stream name as event => handler;
|
|
194
|
+
WATCH = "WATCH" # Reactive state management: watch variable => reaction;
|
|
195
|
+
LOG = "LOG" # Output logging: log > filename.txt
|
|
196
|
+
|
|
197
|
+
# Modifiers (single keyword to extend declarations)
|
|
198
|
+
PUBLIC = "PUBLIC"
|
|
199
|
+
PRIVATE = "PRIVATE"
|
|
200
|
+
SEALED = "SEALED"
|
|
201
|
+
ASYNC = "ASYNC"
|
|
202
|
+
NATIVE = "NATIVE"
|
|
203
|
+
INLINE = "INLINE"
|
|
204
|
+
SECURE = "SECURE"
|
|
205
|
+
PURE = "PURE"
|
|
206
|
+
VIEW = "VIEW" # View function (alias for pure, read-only)
|
|
207
|
+
PAYABLE = "PAYABLE" # Payable function (can receive tokens)
|
|
208
|
+
MODIFIER = "MODIFIER" # Function modifier (like onlyOwner)
|
|
209
|
+
|
|
210
|
+
# Contract & Protocol
|
|
211
|
+
IMPLEMENTS = "IMPLEMENTS" # Protocol implementation: contract X implements Y
|
|
212
|
+
THIS = "THIS" # Reference to current contract instance
|
|
213
|
+
|
|
214
|
+
class Token:
|
|
215
|
+
def __init__(self, token_type, literal, line=None, column=None):
|
|
216
|
+
self.type = token_type
|
|
217
|
+
self.literal = literal
|
|
218
|
+
self.line = line # ✅ ADD line tracking
|
|
219
|
+
self.column = column # ✅ ADD column tracking
|
|
220
|
+
|
|
221
|
+
# For backward compatibility with code expecting dict-like tokens
|
|
222
|
+
self.value = literal # Alias for literal
|
|
223
|
+
|
|
224
|
+
def __repr__(self):
|
|
225
|
+
if self.line and self.column:
|
|
226
|
+
return f"Token({self.type}, '{self.literal}', line={self.line}, col={self.column})"
|
|
227
|
+
return f"Token({self.type}, '{self.literal}')"
|
|
228
|
+
|
|
229
|
+
def get(self, key, default=None):
|
|
230
|
+
"""Dict-like get method for backward compatibility"""
|
|
231
|
+
if hasattr(self, key):
|
|
232
|
+
return getattr(self, key)
|
|
233
|
+
return default
|
|
234
|
+
|
|
235
|
+
def __getitem__(self, key):
|
|
236
|
+
"""Allow dict-like access for compatibility"""
|
|
237
|
+
if hasattr(self, key):
|
|
238
|
+
return getattr(self, key)
|
|
239
|
+
raise KeyError(f"Token has no attribute '{key}'")
|
|
240
|
+
|
|
241
|
+
def __contains__(self, key):
|
|
242
|
+
"""Check if token has attribute"""
|
|
243
|
+
return hasattr(self, key)
|
|
244
|
+
|
|
245
|
+
def to_dict(self):
|
|
246
|
+
"""Convert token to dictionary for compatibility"""
|
|
247
|
+
return {
|
|
248
|
+
'type': self.type,
|
|
249
|
+
'literal': self.literal,
|
|
250
|
+
'value': self.literal,
|
|
251
|
+
'line': self.line,
|
|
252
|
+
'column': self.column
|
|
253
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ZPM - Zexus Package Manager
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .package_manager import PackageManager
|
|
6
|
+
from .registry import PackageRegistry
|
|
7
|
+
from .installer import PackageInstaller
|
|
8
|
+
from .publisher import PackagePublisher
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
'PackageManager',
|
|
12
|
+
'PackageRegistry',
|
|
13
|
+
'PackageInstaller',
|
|
14
|
+
'PackagePublisher'
|
|
15
|
+
]
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Package Installer - Handles package installation and dependencies
|
|
3
|
+
"""
|
|
4
|
+
import os
|
|
5
|
+
import json
|
|
6
|
+
import shutil
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Dict, Optional
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PackageInstaller:
|
|
12
|
+
"""Handles package installation"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, install_dir: Path):
|
|
15
|
+
self.install_dir = Path(install_dir)
|
|
16
|
+
self.install_dir.mkdir(parents=True, exist_ok=True)
|
|
17
|
+
|
|
18
|
+
def install(self, package_info: Dict) -> bool:
|
|
19
|
+
"""Install a package"""
|
|
20
|
+
name = package_info["name"]
|
|
21
|
+
version = package_info["version"]
|
|
22
|
+
pkg_type = package_info.get("type", "normal")
|
|
23
|
+
|
|
24
|
+
target_dir = self.install_dir / name
|
|
25
|
+
|
|
26
|
+
# Check if already installed
|
|
27
|
+
if target_dir.exists():
|
|
28
|
+
existing_pkg = target_dir / "zexus.json"
|
|
29
|
+
if existing_pkg.exists():
|
|
30
|
+
with open(existing_pkg) as f:
|
|
31
|
+
existing_info = json.load(f)
|
|
32
|
+
if existing_info.get("version") == version:
|
|
33
|
+
print(f"ℹ️ {name}@{version} already installed")
|
|
34
|
+
return True
|
|
35
|
+
|
|
36
|
+
# Create package directory
|
|
37
|
+
target_dir.mkdir(parents=True, exist_ok=True)
|
|
38
|
+
|
|
39
|
+
# For built-in packages, create stub
|
|
40
|
+
if pkg_type == "builtin":
|
|
41
|
+
self._install_builtin(name, version, target_dir)
|
|
42
|
+
else:
|
|
43
|
+
# TODO: Download and extract package
|
|
44
|
+
self._install_from_source(package_info, target_dir)
|
|
45
|
+
|
|
46
|
+
return True
|
|
47
|
+
|
|
48
|
+
def _install_builtin(self, name: str, version: str, target_dir: Path):
|
|
49
|
+
"""Install a built-in package"""
|
|
50
|
+
# Create package.json
|
|
51
|
+
pkg_json = {
|
|
52
|
+
"name": name,
|
|
53
|
+
"version": version,
|
|
54
|
+
"type": "builtin",
|
|
55
|
+
"main": "index.zx"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
with open(target_dir / "zexus.json", "w") as f:
|
|
59
|
+
json.dump(pkg_json, f, indent=2)
|
|
60
|
+
|
|
61
|
+
# Create stub main file
|
|
62
|
+
main_file = target_dir / "index.zx"
|
|
63
|
+
main_file.write_text(f"""// {name} - Built-in Zexus package
|
|
64
|
+
// Version: {version}
|
|
65
|
+
|
|
66
|
+
// This is a built-in package provided by Zexus
|
|
67
|
+
// Functions are available globally when imported
|
|
68
|
+
|
|
69
|
+
export {{
|
|
70
|
+
// Package exports will be defined here
|
|
71
|
+
}}
|
|
72
|
+
""")
|
|
73
|
+
|
|
74
|
+
def _install_from_source(self, package_info: Dict, target_dir: Path):
|
|
75
|
+
"""Install package from source/tarball"""
|
|
76
|
+
# TODO: Implement actual download and extraction
|
|
77
|
+
|
|
78
|
+
# For now, create placeholder
|
|
79
|
+
pkg_json = {
|
|
80
|
+
"name": package_info["name"],
|
|
81
|
+
"version": package_info["version"],
|
|
82
|
+
"description": package_info.get("description", ""),
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
with open(target_dir / "zexus.json", "w") as f:
|
|
86
|
+
json.dump(pkg_json, f, indent=2)
|
|
87
|
+
|
|
88
|
+
main_file = target_dir / "index.zx"
|
|
89
|
+
main_file.write_text(f"""// {package_info['name']}
|
|
90
|
+
// Placeholder - package installation from remote sources not yet implemented
|
|
91
|
+
""")
|
|
92
|
+
|
|
93
|
+
def uninstall(self, package: str) -> bool:
|
|
94
|
+
"""Uninstall a package"""
|
|
95
|
+
target_dir = self.install_dir / package
|
|
96
|
+
|
|
97
|
+
if not target_dir.exists():
|
|
98
|
+
print(f"⚠️ Package {package} not installed")
|
|
99
|
+
return False
|
|
100
|
+
|
|
101
|
+
shutil.rmtree(target_dir)
|
|
102
|
+
return True
|
|
103
|
+
|
|
104
|
+
def is_installed(self, package: str) -> bool:
|
|
105
|
+
"""Check if a package is installed"""
|
|
106
|
+
return (self.install_dir / package).exists()
|
|
107
|
+
|
|
108
|
+
def get_installed_version(self, package: str) -> Optional[str]:
|
|
109
|
+
"""Get installed version of a package"""
|
|
110
|
+
pkg_json = self.install_dir / package / "zexus.json"
|
|
111
|
+
if not pkg_json.exists():
|
|
112
|
+
return None
|
|
113
|
+
|
|
114
|
+
with open(pkg_json) as f:
|
|
115
|
+
info = json.load(f)
|
|
116
|
+
return info.get("version")
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Package Manager Core - Main ZPM interface
|
|
3
|
+
"""
|
|
4
|
+
import os
|
|
5
|
+
import json
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Dict, List, Optional
|
|
8
|
+
from .registry import PackageRegistry
|
|
9
|
+
from .installer import PackageInstaller
|
|
10
|
+
from .publisher import PackagePublisher
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class PackageManager:
|
|
14
|
+
"""Main package manager interface"""
|
|
15
|
+
|
|
16
|
+
def __init__(self, project_root: str = "."):
|
|
17
|
+
self.project_root = Path(project_root).resolve()
|
|
18
|
+
self.zpm_dir = self.project_root / "zpm_modules"
|
|
19
|
+
self.config_file = self.project_root / "zexus.json"
|
|
20
|
+
self.lock_file = self.project_root / "zexus-lock.json"
|
|
21
|
+
|
|
22
|
+
self.registry = PackageRegistry()
|
|
23
|
+
self.installer = PackageInstaller(self.zpm_dir)
|
|
24
|
+
self.publisher = PackagePublisher(self.registry)
|
|
25
|
+
|
|
26
|
+
def init(self, name: str = None, version: str = "1.6.2") -> Dict:
|
|
27
|
+
"""Initialize a new Zexus project with package.json"""
|
|
28
|
+
if self.config_file.exists():
|
|
29
|
+
print(f"⚠️ {self.config_file} already exists")
|
|
30
|
+
return self.load_config()
|
|
31
|
+
|
|
32
|
+
if not name:
|
|
33
|
+
name = self.project_root.name
|
|
34
|
+
|
|
35
|
+
config = {
|
|
36
|
+
"name": name,
|
|
37
|
+
"version": version,
|
|
38
|
+
"description": "",
|
|
39
|
+
"main": "main.zx",
|
|
40
|
+
"dependencies": {},
|
|
41
|
+
"devDependencies": {},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"test": "zx run tests/test_*.zx",
|
|
44
|
+
"build": "zx compile main.zx"
|
|
45
|
+
},
|
|
46
|
+
"author": "",
|
|
47
|
+
"license": "MIT"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
self.save_config(config)
|
|
51
|
+
print(f"✅ Created {self.config_file}")
|
|
52
|
+
print(f"📝 Edit {self.config_file} to customize your project")
|
|
53
|
+
|
|
54
|
+
return config
|
|
55
|
+
|
|
56
|
+
def install(self, package: str = None, dev: bool = False) -> bool:
|
|
57
|
+
"""Install a package or all packages from zexus.json"""
|
|
58
|
+
if not package:
|
|
59
|
+
# Install all dependencies
|
|
60
|
+
return self.install_all()
|
|
61
|
+
|
|
62
|
+
# Install specific package
|
|
63
|
+
print(f"📦 Installing {package}...")
|
|
64
|
+
|
|
65
|
+
# Parse package@version
|
|
66
|
+
if "@" in package:
|
|
67
|
+
name, version = package.split("@", 1)
|
|
68
|
+
else:
|
|
69
|
+
name, version = package, "latest"
|
|
70
|
+
|
|
71
|
+
# Get package info from registry
|
|
72
|
+
pkg_info = self.registry.get_package(name, version)
|
|
73
|
+
if not pkg_info:
|
|
74
|
+
print(f"❌ Package {name}@{version} not found")
|
|
75
|
+
return False
|
|
76
|
+
|
|
77
|
+
# Install package
|
|
78
|
+
success = self.installer.install(pkg_info)
|
|
79
|
+
if not success:
|
|
80
|
+
return False
|
|
81
|
+
|
|
82
|
+
# Update config
|
|
83
|
+
config = self.load_config()
|
|
84
|
+
dep_key = "devDependencies" if dev else "dependencies"
|
|
85
|
+
if dep_key not in config:
|
|
86
|
+
config[dep_key] = {}
|
|
87
|
+
|
|
88
|
+
config[dep_key][name] = version
|
|
89
|
+
self.save_config(config)
|
|
90
|
+
|
|
91
|
+
# Update lock file
|
|
92
|
+
self.update_lock_file()
|
|
93
|
+
|
|
94
|
+
print(f"✅ Installed {name}@{version}")
|
|
95
|
+
return True
|
|
96
|
+
|
|
97
|
+
def install_all(self) -> bool:
|
|
98
|
+
"""Install all dependencies from zexus.json"""
|
|
99
|
+
config = self.load_config()
|
|
100
|
+
if not config:
|
|
101
|
+
print("❌ No zexus.json found. Run 'zpm init' first.")
|
|
102
|
+
return False
|
|
103
|
+
|
|
104
|
+
dependencies = config.get("dependencies", {})
|
|
105
|
+
dev_dependencies = config.get("devDependencies", {})
|
|
106
|
+
all_deps = {**dependencies, **dev_dependencies}
|
|
107
|
+
|
|
108
|
+
if not all_deps:
|
|
109
|
+
print("✅ No dependencies to install")
|
|
110
|
+
return True
|
|
111
|
+
|
|
112
|
+
print(f"📦 Installing {len(all_deps)} package(s)...")
|
|
113
|
+
|
|
114
|
+
success_count = 0
|
|
115
|
+
for name, version in all_deps.items():
|
|
116
|
+
pkg_info = self.registry.get_package(name, version)
|
|
117
|
+
if pkg_info and self.installer.install(pkg_info):
|
|
118
|
+
success_count += 1
|
|
119
|
+
else:
|
|
120
|
+
print(f"⚠️ Failed to install {name}@{version}")
|
|
121
|
+
|
|
122
|
+
self.update_lock_file()
|
|
123
|
+
print(f"✅ Installed {success_count}/{len(all_deps)} package(s)")
|
|
124
|
+
return success_count == len(all_deps)
|
|
125
|
+
|
|
126
|
+
def uninstall(self, package: str) -> bool:
|
|
127
|
+
"""Uninstall a package"""
|
|
128
|
+
print(f"🗑️ Uninstalling {package}...")
|
|
129
|
+
|
|
130
|
+
success = self.installer.uninstall(package)
|
|
131
|
+
if not success:
|
|
132
|
+
return False
|
|
133
|
+
|
|
134
|
+
# Update config
|
|
135
|
+
config = self.load_config()
|
|
136
|
+
if package in config.get("dependencies", {}):
|
|
137
|
+
del config["dependencies"][package]
|
|
138
|
+
if package in config.get("devDependencies", {}):
|
|
139
|
+
del config["devDependencies"][package]
|
|
140
|
+
|
|
141
|
+
self.save_config(config)
|
|
142
|
+
self.update_lock_file()
|
|
143
|
+
|
|
144
|
+
print(f"✅ Uninstalled {package}")
|
|
145
|
+
return True
|
|
146
|
+
|
|
147
|
+
def list(self) -> List[Dict]:
|
|
148
|
+
"""List installed packages"""
|
|
149
|
+
if not self.zpm_dir.exists():
|
|
150
|
+
return []
|
|
151
|
+
|
|
152
|
+
packages = []
|
|
153
|
+
for item in self.zpm_dir.iterdir():
|
|
154
|
+
if item.is_dir():
|
|
155
|
+
pkg_json = item / "zexus.json"
|
|
156
|
+
if pkg_json.exists():
|
|
157
|
+
with open(pkg_json) as f:
|
|
158
|
+
pkg_info = json.load(f)
|
|
159
|
+
packages.append({
|
|
160
|
+
"name": pkg_info.get("name", item.name),
|
|
161
|
+
"version": pkg_info.get("version", "unknown"),
|
|
162
|
+
"path": str(item)
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
return packages
|
|
166
|
+
|
|
167
|
+
def search(self, query: str) -> List[Dict]:
|
|
168
|
+
"""Search for packages in registry"""
|
|
169
|
+
return self.registry.search(query)
|
|
170
|
+
|
|
171
|
+
def publish(self) -> bool:
|
|
172
|
+
"""Publish current package to registry"""
|
|
173
|
+
config = self.load_config()
|
|
174
|
+
if not config:
|
|
175
|
+
print("❌ No zexus.json found")
|
|
176
|
+
return False
|
|
177
|
+
|
|
178
|
+
return self.publisher.publish(self.project_root, config)
|
|
179
|
+
|
|
180
|
+
def load_config(self) -> Optional[Dict]:
|
|
181
|
+
"""Load zexus.json"""
|
|
182
|
+
if not self.config_file.exists():
|
|
183
|
+
return None
|
|
184
|
+
|
|
185
|
+
with open(self.config_file) as f:
|
|
186
|
+
return json.load(f)
|
|
187
|
+
|
|
188
|
+
def save_config(self, config: Dict):
|
|
189
|
+
"""Save zexus.json"""
|
|
190
|
+
with open(self.config_file, "w") as f:
|
|
191
|
+
json.dump(config, f, indent=2)
|
|
192
|
+
|
|
193
|
+
def update_lock_file(self):
|
|
194
|
+
"""Update zexus-lock.json with installed packages"""
|
|
195
|
+
packages = self.list()
|
|
196
|
+
lock_data = {
|
|
197
|
+
"lockfileVersion": 1,
|
|
198
|
+
"packages": {
|
|
199
|
+
pkg["name"]: {
|
|
200
|
+
"version": pkg["version"],
|
|
201
|
+
"path": pkg["path"]
|
|
202
|
+
}
|
|
203
|
+
for pkg in packages
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
with open(self.lock_file, "w") as f:
|
|
208
|
+
json.dump(lock_data, f, indent=2)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Package Publisher - Handles package publishing to registry
|
|
3
|
+
"""
|
|
4
|
+
import os
|
|
5
|
+
import json
|
|
6
|
+
import tarfile
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Dict
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PackagePublisher:
|
|
12
|
+
"""Handles package publishing"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, registry):
|
|
15
|
+
self.registry = registry
|
|
16
|
+
|
|
17
|
+
def publish(self, project_root: Path, config: Dict) -> bool:
|
|
18
|
+
"""Publish a package"""
|
|
19
|
+
name = config.get("name")
|
|
20
|
+
version = config.get("version")
|
|
21
|
+
|
|
22
|
+
if not name or not version:
|
|
23
|
+
print("❌ Package name and version required")
|
|
24
|
+
return False
|
|
25
|
+
|
|
26
|
+
print(f"📤 Publishing {name}@{version}...")
|
|
27
|
+
|
|
28
|
+
# Collect files
|
|
29
|
+
files = self._collect_files(project_root, config)
|
|
30
|
+
|
|
31
|
+
if not files:
|
|
32
|
+
print("❌ No files to publish")
|
|
33
|
+
return False
|
|
34
|
+
|
|
35
|
+
# Create tarball
|
|
36
|
+
tarball_path = self._create_tarball(project_root, name, version, files)
|
|
37
|
+
|
|
38
|
+
# Publish to registry
|
|
39
|
+
package_data = {
|
|
40
|
+
**config,
|
|
41
|
+
"tarball": str(tarball_path),
|
|
42
|
+
"files": files
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
success = self.registry.publish_package(package_data, files)
|
|
46
|
+
|
|
47
|
+
if success:
|
|
48
|
+
print(f"✅ Published {name}@{version}")
|
|
49
|
+
print(f"📦 Tarball: {tarball_path}")
|
|
50
|
+
else:
|
|
51
|
+
print(f"❌ Failed to publish {name}@{version}")
|
|
52
|
+
|
|
53
|
+
return success
|
|
54
|
+
|
|
55
|
+
def _collect_files(self, project_root: Path, config: Dict) -> list:
|
|
56
|
+
"""Collect files to include in package"""
|
|
57
|
+
files = []
|
|
58
|
+
|
|
59
|
+
# Include main file
|
|
60
|
+
main_file = config.get("main", "main.zx")
|
|
61
|
+
if (project_root / main_file).exists():
|
|
62
|
+
files.append(main_file)
|
|
63
|
+
|
|
64
|
+
# Include all .zx files (excluding node_modules equivalent)
|
|
65
|
+
for zx_file in project_root.rglob("*.zx"):
|
|
66
|
+
relative = zx_file.relative_to(project_root)
|
|
67
|
+
# Exclude zpm_modules, tests, etc.
|
|
68
|
+
if not any(part.startswith(".") or part in ["zpm_modules", "node_modules"]
|
|
69
|
+
for part in relative.parts):
|
|
70
|
+
files.append(str(relative))
|
|
71
|
+
|
|
72
|
+
# Include package.json
|
|
73
|
+
files.append("zexus.json")
|
|
74
|
+
|
|
75
|
+
# Include README if exists
|
|
76
|
+
for readme in ["README.md", "README.txt", "README"]:
|
|
77
|
+
if (project_root / readme).exists():
|
|
78
|
+
files.append(readme)
|
|
79
|
+
break
|
|
80
|
+
|
|
81
|
+
# Include LICENSE if exists
|
|
82
|
+
if (project_root / "LICENSE").exists():
|
|
83
|
+
files.append("LICENSE")
|
|
84
|
+
|
|
85
|
+
return files
|
|
86
|
+
|
|
87
|
+
def _create_tarball(self, project_root: Path, name: str, version: str, files: list) -> Path:
|
|
88
|
+
"""Create a tarball of the package"""
|
|
89
|
+
tarball_name = f"{name}-{version}.tar.gz"
|
|
90
|
+
tarball_path = project_root / tarball_name
|
|
91
|
+
|
|
92
|
+
with tarfile.open(tarball_path, "w:gz") as tar:
|
|
93
|
+
for file in files:
|
|
94
|
+
file_path = project_root / file
|
|
95
|
+
if file_path.exists():
|
|
96
|
+
tar.add(file_path, arcname=f"{name}/{file}")
|
|
97
|
+
|
|
98
|
+
return tarball_path
|