quantum-framework 0.18.0__py3-none-any.whl
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.
- quantum/__init__.py +1 -0
- quantum/cli/__init__.py +2 -0
- quantum/cli/admin.py +131 -0
- quantum/cli/check.py +223 -0
- quantum/cli/commands/__init__.py +15 -0
- quantum/cli/commands/build.py +414 -0
- quantum/cli/commands/dev.py +185 -0
- quantum/cli/commands/docs.py +329 -0
- quantum/cli/commands/lint.py +523 -0
- quantum/cli/commands/migrate.py +548 -0
- quantum/cli/commands/new.py +622 -0
- quantum/cli/commands/serve.py +190 -0
- quantum/cli/commands/test.py +193 -0
- quantum/cli/deploy.py +810 -0
- quantum/cli/hot_reload.py +951 -0
- quantum/cli/jobs.py +356 -0
- quantum/cli/mq.py +582 -0
- quantum/cli/pkg.py +390 -0
- quantum/cli/runner.py +565 -0
- quantum/cli/server_process.py +159 -0
- quantum/cli/utils.py +334 -0
- quantum/compiler/__init__.py +30 -0
- quantum/compiler/base_generator.py +367 -0
- quantum/compiler/cli.py +295 -0
- quantum/compiler/expression_transformer.py +444 -0
- quantum/compiler/javascript/__init__.py +10 -0
- quantum/compiler/javascript/generator.py +659 -0
- quantum/compiler/optimizer.py +270 -0
- quantum/compiler/python/__init__.py +10 -0
- quantum/compiler/python/generator.py +883 -0
- quantum/compiler/python/runtime.py +863 -0
- quantum/compiler/transpiler.py +330 -0
- quantum/core/__init__.py +3 -0
- quantum/core/ast_nodes.py +2619 -0
- quantum/core/config_env.py +54 -0
- quantum/core/docs_links.py +8 -0
- quantum/core/expression_diagnostics.py +87 -0
- quantum/core/expression_stdlib.py +208 -0
- quantum/core/expressions.py +677 -0
- quantum/core/features/agents/src/__init__.py +30 -0
- quantum/core/features/agents/src/ast_node.py +540 -0
- quantum/core/features/conditionals/src/__init__.py +8 -0
- quantum/core/features/conditionals/src/ast_node.py +68 -0
- quantum/core/features/data_import/src/__init__.py +0 -0
- quantum/core/features/data_import/src/ast_node.py +292 -0
- quantum/core/features/data_import/src/runtime.py +533 -0
- quantum/core/features/dump/src/__init__.py +12 -0
- quantum/core/features/dump/src/ast_node.py +106 -0
- quantum/core/features/dump/src/parser.py +61 -0
- quantum/core/features/dump/src/runtime.py +246 -0
- quantum/core/features/functions/src/__init__.py +8 -0
- quantum/core/features/functions/src/ast_node.py +149 -0
- quantum/core/features/game_engine_2d/src/__init__.py +19 -0
- quantum/core/features/game_engine_2d/src/ast_nodes.py +1719 -0
- quantum/core/features/game_engine_2d/src/parser.py +983 -0
- quantum/core/features/invocation/src/__init__.py +0 -0
- quantum/core/features/invocation/src/ast_node.py +147 -0
- quantum/core/features/invocation/src/runtime.py +332 -0
- quantum/core/features/knowledge_base/src/__init__.py +6 -0
- quantum/core/features/knowledge_base/src/ast_node.py +113 -0
- quantum/core/features/knowledge_base/src/parser.py +82 -0
- quantum/core/features/logging/src/__init__.py +12 -0
- quantum/core/features/logging/src/ast_node.py +111 -0
- quantum/core/features/logging/src/parser.py +50 -0
- quantum/core/features/logging/src/runtime.py +190 -0
- quantum/core/features/loops/src/__init__.py +8 -0
- quantum/core/features/loops/src/ast_node.py +60 -0
- quantum/core/features/query/src/__init__.py +0 -0
- quantum/core/features/query/src/query_validators.py +20 -0
- quantum/core/features/state_management/src/__init__.py +11 -0
- quantum/core/features/state_management/src/ast_node.py +121 -0
- quantum/core/features/terminal_engine/src/__init__.py +21 -0
- quantum/core/features/terminal_engine/src/ast_nodes.py +560 -0
- quantum/core/features/terminal_engine/src/parser.py +361 -0
- quantum/core/features/testing_engine/src/__init__.py +41 -0
- quantum/core/features/testing_engine/src/ast_nodes.py +1212 -0
- quantum/core/features/testing_engine/src/parser.py +604 -0
- quantum/core/features/theming/src/__init__.py +48 -0
- quantum/core/features/theming/src/ast_node.py +137 -0
- quantum/core/features/theming/src/presets.py +405 -0
- quantum/core/features/ui_engine/src/__init__.py +20 -0
- quantum/core/features/ui_engine/src/ast_nodes.py +1913 -0
- quantum/core/features/ui_engine/src/parser.py +1192 -0
- quantum/core/features/websocket/src/__init__.py +24 -0
- quantum/core/features/websocket/src/ast_node.py +247 -0
- quantum/core/guards.py +53 -0
- quantum/core/html_compat.py +299 -0
- quantum/core/parser.py +1551 -0
- quantum/core/parser_registry.py +213 -0
- quantum/core/parsers/__init__.py +76 -0
- quantum/core/parsers/ai/__init__.py +12 -0
- quantum/core/parsers/ai/agent_parser.py +106 -0
- quantum/core/parsers/ai/knowledge_parser.py +86 -0
- quantum/core/parsers/ai/llm_parser.py +78 -0
- quantum/core/parsers/ai/team_parser.py +88 -0
- quantum/core/parsers/base.py +322 -0
- quantum/core/parsers/composition/__init__.py +10 -0
- quantum/core/parsers/composition/import_parser.py +50 -0
- quantum/core/parsers/composition/slot_parser.py +48 -0
- quantum/core/parsers/control_flow/__init__.py +11 -0
- quantum/core/parsers/control_flow/if_parser.py +71 -0
- quantum/core/parsers/control_flow/loop_parser.py +105 -0
- quantum/core/parsers/control_flow/set_parser.py +93 -0
- quantum/core/parsers/data/__init__.py +12 -0
- quantum/core/parsers/data/data_parser.py +229 -0
- quantum/core/parsers/data/invoke_parser.py +133 -0
- quantum/core/parsers/data/query_parser.py +213 -0
- quantum/core/parsers/data/transaction_parser.py +86 -0
- quantum/core/parsers/events/__init__.py +9 -0
- quantum/core/parsers/events/dispatch_event_parser.py +44 -0
- quantum/core/parsers/forms/__init__.py +11 -0
- quantum/core/parsers/forms/action_parser.py +79 -0
- quantum/core/parsers/forms/flash_parser.py +34 -0
- quantum/core/parsers/forms/redirect_parser.py +33 -0
- quantum/core/parsers/functions/__init__.py +11 -0
- quantum/core/parsers/functions/function_parser.py +98 -0
- quantum/core/parsers/functions/param_parser.py +73 -0
- quantum/core/parsers/functions/return_parser.py +31 -0
- quantum/core/parsers/html/__init__.py +10 -0
- quantum/core/parsers/html/component_call_parser.py +130 -0
- quantum/core/parsers/html/html_parser.py +115 -0
- quantum/core/parsers/jobs/__init__.py +11 -0
- quantum/core/parsers/jobs/job_parser.py +71 -0
- quantum/core/parsers/jobs/schedule_parser.py +62 -0
- quantum/core/parsers/jobs/thread_parser.py +57 -0
- quantum/core/parsers/messaging/__init__.py +17 -0
- quantum/core/parsers/messaging/message_ack_parser.py +30 -0
- quantum/core/parsers/messaging/message_nack_parser.py +30 -0
- quantum/core/parsers/messaging/message_parser.py +114 -0
- quantum/core/parsers/messaging/queue_parser.py +61 -0
- quantum/core/parsers/messaging/websocket_parser.py +121 -0
- quantum/core/parsers/routing/__init__.py +9 -0
- quantum/core/parsers/routing/route_parser.py +41 -0
- quantum/core/parsers/scripting/__init__.py +12 -0
- quantum/core/parsers/scripting/pyclass_parser.py +62 -0
- quantum/core/parsers/scripting/pydecorator_parser.py +68 -0
- quantum/core/parsers/scripting/pyimport_parser.py +52 -0
- quantum/core/parsers/scripting/python_parser.py +49 -0
- quantum/core/parsers/services/__init__.py +12 -0
- quantum/core/parsers/services/dump_parser.py +52 -0
- quantum/core/parsers/services/file_parser.py +48 -0
- quantum/core/parsers/services/log_parser.py +46 -0
- quantum/core/parsers/services/mail_parser.py +65 -0
- quantum/core/tiers.py +164 -0
- quantum/core/xml_lines.py +81 -0
- quantum/packages/__init__.py +28 -0
- quantum/packages/manager.py +413 -0
- quantum/packages/manifest.py +351 -0
- quantum/packages/registry.py +399 -0
- quantum/packages/resolver.py +336 -0
- quantum/plugins/__init__.py +33 -0
- quantum/plugins/hooks.py +329 -0
- quantum/plugins/loader.py +479 -0
- quantum/plugins/manifest.py +336 -0
- quantum/plugins/registry.py +371 -0
- quantum/runtime/__init__.py +25 -0
- quantum/runtime/action_handler.py +532 -0
- quantum/runtime/adapters/__init__.py +88 -0
- quantum/runtime/adapters/memory_adapter.py +690 -0
- quantum/runtime/adapters/rabbitmq_adapter.py +715 -0
- quantum/runtime/adapters/redis_adapter.py +582 -0
- quantum/runtime/adapters/sqlite_adapter.py +414 -0
- quantum/runtime/agent_service.py +1133 -0
- quantum/runtime/ast_cache.py +506 -0
- quantum/runtime/auth_service.py +267 -0
- quantum/runtime/component.py +1048 -0
- quantum/runtime/component_composer.py +133 -0
- quantum/runtime/component_resolver.py +174 -0
- quantum/runtime/conditions.py +54 -0
- quantum/runtime/database_service.py +595 -0
- quantum/runtime/db_schema.py +100 -0
- quantum/runtime/dev_panel.py +178 -0
- quantum/runtime/email_service.py +162 -0
- quantum/runtime/error_handler.py +295 -0
- quantum/runtime/execution_context.py +283 -0
- quantum/runtime/executor_registry.py +178 -0
- quantum/runtime/executors/__init__.py +71 -0
- quantum/runtime/executors/ai/__init__.py +12 -0
- quantum/runtime/executors/ai/agent_executor.py +217 -0
- quantum/runtime/executors/ai/knowledge_executor.py +114 -0
- quantum/runtime/executors/ai/llm_executor.py +153 -0
- quantum/runtime/executors/ai/team_executor.py +171 -0
- quantum/runtime/executors/base.py +264 -0
- quantum/runtime/executors/control_flow/__init__.py +12 -0
- quantum/runtime/executors/control_flow/if_executor.py +98 -0
- quantum/runtime/executors/control_flow/loop_executor.py +308 -0
- quantum/runtime/executors/control_flow/redirect_executor.py +43 -0
- quantum/runtime/executors/control_flow/set_executor.py +464 -0
- quantum/runtime/executors/data/__init__.py +12 -0
- quantum/runtime/executors/data/data_executor.py +156 -0
- quantum/runtime/executors/data/invoke_executor.py +228 -0
- quantum/runtime/executors/data/query_executor.py +290 -0
- quantum/runtime/executors/data/transaction_executor.py +91 -0
- quantum/runtime/executors/jobs/__init__.py +11 -0
- quantum/runtime/executors/jobs/job_executor.py +190 -0
- quantum/runtime/executors/jobs/schedule_executor.py +132 -0
- quantum/runtime/executors/jobs/thread_executor.py +127 -0
- quantum/runtime/executors/messaging/__init__.py +17 -0
- quantum/runtime/executors/messaging/message_ack_executor.py +51 -0
- quantum/runtime/executors/messaging/message_executor.py +174 -0
- quantum/runtime/executors/messaging/queue_executor.py +103 -0
- quantum/runtime/executors/messaging/websocket_executor.py +197 -0
- quantum/runtime/executors/scripting/__init__.py +11 -0
- quantum/runtime/executors/scripting/pyclass_executor.py +90 -0
- quantum/runtime/executors/scripting/pyimport_executor.py +81 -0
- quantum/runtime/executors/scripting/python_executor.py +249 -0
- quantum/runtime/executors/services/__init__.py +12 -0
- quantum/runtime/executors/services/dump_executor.py +72 -0
- quantum/runtime/executors/services/file_executor.py +89 -0
- quantum/runtime/executors/services/log_executor.py +77 -0
- quantum/runtime/executors/services/mail_executor.py +81 -0
- quantum/runtime/expression_cache.py +498 -0
- quantum/runtime/file_upload_service.py +326 -0
- quantum/runtime/function_registry.py +118 -0
- quantum/runtime/game_builder.py +166 -0
- quantum/runtime/game_code_generator.py +2371 -0
- quantum/runtime/game_templates.py +2006 -0
- quantum/runtime/godot_code_generator.py +4681 -0
- quantum/runtime/godot_templates.py +1449 -0
- quantum/runtime/job_executor.py +1599 -0
- quantum/runtime/knowledge_service.py +546 -0
- quantum/runtime/llm_cache.py +100 -0
- quantum/runtime/llm_providers.py +704 -0
- quantum/runtime/llm_service.py +287 -0
- quantum/runtime/local_server.py +28 -0
- quantum/runtime/logging_setup.py +141 -0
- quantum/runtime/message_broker.py +364 -0
- quantum/runtime/message_queue_service.py +571 -0
- quantum/runtime/param_validation.py +218 -0
- quantum/runtime/pypy_compat.py +317 -0
- quantum/runtime/python_bridge.py +698 -0
- quantum/runtime/query_validators.py +304 -0
- quantum/runtime/renderer.py +734 -0
- quantum/runtime/service_container.py +470 -0
- quantum/runtime/table_params.py +163 -0
- quantum/runtime/terminal_builder.py +76 -0
- quantum/runtime/terminal_code_generator.py +607 -0
- quantum/runtime/terminal_templates.py +243 -0
- quantum/runtime/testing_builder.py +77 -0
- quantum/runtime/testing_code_generator.py +833 -0
- quantum/runtime/testing_templates.py +85 -0
- quantum/runtime/ui_builder.py +222 -0
- quantum/runtime/ui_console.py +405 -0
- quantum/runtime/ui_desktop.py +56 -0
- quantum/runtime/ui_form_rules.py +193 -0
- quantum/runtime/ui_html_adapter.py +2567 -0
- quantum/runtime/ui_html_templates.py +2106 -0
- quantum/runtime/ui_mobile_adapter.py +1832 -0
- quantum/runtime/ui_mobile_templates.py +1003 -0
- quantum/runtime/ui_page_renderer.py +392 -0
- quantum/runtime/ui_pager.py +73 -0
- quantum/runtime/ui_table_edit.py +139 -0
- quantum/runtime/ui_textual_adapter.py +1866 -0
- quantum/runtime/ui_textual_templates.py +45 -0
- quantum/runtime/ui_tokens.py +465 -0
- quantum/runtime/ui_validator.py +365 -0
- quantum/runtime/ui_view.py +221 -0
- quantum/runtime/validators.py +256 -0
- quantum/runtime/web_server.py +2131 -0
- quantum/runtime/websocket_adapter.py +501 -0
- quantum/runtime/websocket_service.py +585 -0
- quantum/runtime/websocket_transport.py +289 -0
- quantum/runtime/wsgi.py +101 -0
- quantum/services.py +109 -0
- quantum/utils/__init__.py +1 -0
- quantum_admin/__init__.py +4 -0
- quantum_admin/assets/quantum-admin-connectors.js +123 -0
- quantum_admin/assets/quantum-admin.css +2058 -0
- quantum_admin/assets/quantum-source-highlight.js +106 -0
- quantum_admin/backend/__init__.py +4 -0
- quantum_admin/backend/audit_service.py +346 -0
- quantum_admin/backend/auth_service.py +394 -0
- quantum_admin/backend/component_discovery.py +766 -0
- quantum_admin/backend/config_generator.py +586 -0
- quantum_admin/backend/connector_service.py +1016 -0
- quantum_admin/backend/crud.py +557 -0
- quantum_admin/backend/database.py +226 -0
- quantum_admin/backend/db_setup_service.py +193 -0
- quantum_admin/backend/deploy_service.py +698 -0
- quantum_admin/backend/docker_service.py +422 -0
- quantum_admin/backend/environment_service.py +418 -0
- quantum_admin/backend/git_service.py +370 -0
- quantum_admin/backend/health_service.py +390 -0
- quantum_admin/backend/job_service.py +347 -0
- quantum_admin/backend/log_service.py +331 -0
- quantum_admin/backend/main.py +14426 -0
- quantum_admin/backend/models.py +986 -0
- quantum_admin/backend/pipeline_service.py +812 -0
- quantum_admin/backend/resource_manager.py +1118 -0
- quantum_admin/backend/schemas.py +419 -0
- quantum_admin/backend/secret_manager.py +277 -0
- quantum_admin/backend/settings_service.py +488 -0
- quantum_admin/backend/template_service.py +710 -0
- quantum_admin/backend/test_execution_service.py +364 -0
- quantum_admin/backend/test_generator.py +782 -0
- quantum_admin/backend/webhook_service.py +454 -0
- quantum_admin/backend/websocket_manager.py +360 -0
- quantum_admin/components/admin/_layout/AdminShell.q +121 -0
- quantum_admin/components/admin/agents.q +107 -0
- quantum_admin/components/admin/app/[name].q +558 -0
- quantum_admin/components/admin/applications.q +160 -0
- quantum_admin/components/admin/component/[...path].q +205 -0
- quantum_admin/components/admin/components.q +59 -0
- quantum_admin/components/admin/connectors.q +283 -0
- quantum_admin/components/admin/dashboard.q +86 -0
- quantum_admin/components/admin/database.q +95 -0
- quantum_admin/components/admin/features.q +69 -0
- quantum_admin/components/admin/index.q +12 -0
- quantum_admin/components/admin/jobs.q +75 -0
- quantum_admin/components/admin/login.q +65 -0
- quantum_admin/components/admin/logout.q +11 -0
- quantum_admin/components/admin/settings.q +174 -0
- quantum_admin/components/admin/source.q +45 -0
- quantum_admin/components/admin/tests.q +73 -0
- quantum_admin/run.py +13 -0
- quantum_admin/services/__init__.py +16 -0
- quantum_admin/services/_base.py +84 -0
- quantum_admin/services/_component_test_generator.py +205 -0
- quantum_admin/services/_yaml_editor.py +82 -0
- quantum_admin/services/apps.py +330 -0
- quantum_admin/services/auth.py +61 -0
- quantum_admin/services/components.py +210 -0
- quantum_admin/services/connectors.py +164 -0
- quantum_admin/services/projects.py +189 -0
- quantum_admin/services/repository.py +223 -0
- quantum_admin/services/settings.py +150 -0
- quantum_admin/services/yaml_import.py +118 -0
- quantum_framework-0.18.0.dist-info/METADATA +281 -0
- quantum_framework-0.18.0.dist-info/RECORD +333 -0
- quantum_framework-0.18.0.dist-info/WHEEL +5 -0
- quantum_framework-0.18.0.dist-info/entry_points.txt +2 -0
- quantum_framework-0.18.0.dist-info/licenses/LICENSE +21 -0
- quantum_framework-0.18.0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Quantum CLI - New Command
|
|
3
|
+
|
|
4
|
+
Create new Quantum projects with templates.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import shutil
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Optional
|
|
11
|
+
|
|
12
|
+
import click
|
|
13
|
+
|
|
14
|
+
from quantum.cli.utils import get_console, validate_project_name
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# Project templates
|
|
18
|
+
TEMPLATES = {
|
|
19
|
+
'default': 'Basic Quantum web application',
|
|
20
|
+
'api': 'REST API with microservices',
|
|
21
|
+
'game': '2D game with canvas',
|
|
22
|
+
'terminal': 'Terminal TUI application',
|
|
23
|
+
'component-lib': 'Reusable component library',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@click.command('new')
|
|
28
|
+
@click.argument('project_name')
|
|
29
|
+
@click.option('--template', '-t', type=click.Choice(list(TEMPLATES.keys())), default='default',
|
|
30
|
+
help='Project template to use')
|
|
31
|
+
@click.option('--directory', '-d', type=click.Path(), default=None,
|
|
32
|
+
help='Directory to create project in (default: project name)')
|
|
33
|
+
@click.option('--no-git', is_flag=True, help='Skip git initialization')
|
|
34
|
+
@click.option('--quiet', '-q', is_flag=True, help='Quiet mode - minimal output')
|
|
35
|
+
def new(project_name: str, template: str, directory: Optional[str], no_git: bool, quiet: bool):
|
|
36
|
+
"""Create a new Quantum project.
|
|
37
|
+
|
|
38
|
+
PROJECT_NAME is the name of your new project.
|
|
39
|
+
|
|
40
|
+
Examples:
|
|
41
|
+
|
|
42
|
+
quantum new my-app
|
|
43
|
+
|
|
44
|
+
quantum new my-api --template api
|
|
45
|
+
|
|
46
|
+
quantum new my-game -t game -d ./projects
|
|
47
|
+
"""
|
|
48
|
+
console = get_console(quiet=quiet)
|
|
49
|
+
|
|
50
|
+
# Validate project name
|
|
51
|
+
is_valid, error = validate_project_name(project_name)
|
|
52
|
+
if not is_valid:
|
|
53
|
+
console.error(error)
|
|
54
|
+
raise click.Abort()
|
|
55
|
+
|
|
56
|
+
# Determine project directory
|
|
57
|
+
if directory:
|
|
58
|
+
project_dir = Path(directory) / project_name
|
|
59
|
+
else:
|
|
60
|
+
project_dir = Path.cwd() / project_name
|
|
61
|
+
|
|
62
|
+
# Check if directory exists
|
|
63
|
+
if project_dir.exists():
|
|
64
|
+
console.error(f"Directory already exists: {project_dir}")
|
|
65
|
+
raise click.Abort()
|
|
66
|
+
|
|
67
|
+
console.header(
|
|
68
|
+
"Creating Quantum Project",
|
|
69
|
+
f"Template: {template} | Location: {project_dir}"
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
try:
|
|
73
|
+
with console.spinner("Creating project structure..."):
|
|
74
|
+
_create_project_structure(project_dir, project_name, template)
|
|
75
|
+
|
|
76
|
+
if not no_git:
|
|
77
|
+
with console.spinner("Initializing git repository..."):
|
|
78
|
+
_init_git(project_dir)
|
|
79
|
+
|
|
80
|
+
console.success(f"Project '{project_name}' created successfully!")
|
|
81
|
+
console.print()
|
|
82
|
+
console.panel(
|
|
83
|
+
f"[bold]Next steps:[/bold]\n\n"
|
|
84
|
+
f" cd {project_name}\n"
|
|
85
|
+
f" quantum dev\n\n"
|
|
86
|
+
f"[dim]Open http://localhost:8080 in your browser[/dim]",
|
|
87
|
+
title="Get Started"
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
except Exception as e:
|
|
91
|
+
console.error(f"Failed to create project: {e}")
|
|
92
|
+
# Cleanup on failure
|
|
93
|
+
if project_dir.exists():
|
|
94
|
+
shutil.rmtree(project_dir)
|
|
95
|
+
raise click.Abort()
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _create_project_structure(project_dir: Path, project_name: str, template: str) -> None:
|
|
99
|
+
"""Create the project directory structure."""
|
|
100
|
+
# Create directories
|
|
101
|
+
dirs = [
|
|
102
|
+
'components',
|
|
103
|
+
'pages',
|
|
104
|
+
'layouts',
|
|
105
|
+
'assets/css',
|
|
106
|
+
'assets/js',
|
|
107
|
+
'assets/images',
|
|
108
|
+
'data',
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
for d in dirs:
|
|
112
|
+
(project_dir / d).mkdir(parents=True, exist_ok=True)
|
|
113
|
+
|
|
114
|
+
# Create quantum.config.yaml
|
|
115
|
+
config_content = f"""# Quantum Configuration
|
|
116
|
+
# Generated for: {project_name}
|
|
117
|
+
|
|
118
|
+
app:
|
|
119
|
+
name: {project_name}
|
|
120
|
+
version: 1.0.0
|
|
121
|
+
type: {_get_app_type(template)}
|
|
122
|
+
|
|
123
|
+
server:
|
|
124
|
+
port: 8080
|
|
125
|
+
host: 0.0.0.0
|
|
126
|
+
debug: true
|
|
127
|
+
reload: true
|
|
128
|
+
|
|
129
|
+
database:
|
|
130
|
+
default:
|
|
131
|
+
driver: sqlite
|
|
132
|
+
path: ./data/{project_name}.db
|
|
133
|
+
|
|
134
|
+
templates:
|
|
135
|
+
components_dir: ./components
|
|
136
|
+
layouts_dir: ./layouts
|
|
137
|
+
pages_dir: ./pages
|
|
138
|
+
|
|
139
|
+
build:
|
|
140
|
+
output_dir: ./dist
|
|
141
|
+
minify: true
|
|
142
|
+
sourcemaps: true
|
|
143
|
+
|
|
144
|
+
# Environment-specific overrides
|
|
145
|
+
environments:
|
|
146
|
+
development:
|
|
147
|
+
server:
|
|
148
|
+
debug: true
|
|
149
|
+
reload: true
|
|
150
|
+
production:
|
|
151
|
+
server:
|
|
152
|
+
debug: false
|
|
153
|
+
reload: false
|
|
154
|
+
"""
|
|
155
|
+
(project_dir / 'quantum.config.yaml').write_text(config_content)
|
|
156
|
+
|
|
157
|
+
# Create template-specific files
|
|
158
|
+
if template == 'default':
|
|
159
|
+
_create_default_template(project_dir, project_name)
|
|
160
|
+
elif template == 'api':
|
|
161
|
+
_create_api_template(project_dir, project_name)
|
|
162
|
+
elif template == 'game':
|
|
163
|
+
_create_game_template(project_dir, project_name)
|
|
164
|
+
elif template == 'terminal':
|
|
165
|
+
_create_terminal_template(project_dir, project_name)
|
|
166
|
+
elif template == 'component-lib':
|
|
167
|
+
_create_component_lib_template(project_dir, project_name)
|
|
168
|
+
|
|
169
|
+
# Create .gitignore
|
|
170
|
+
gitignore = """# Quantum
|
|
171
|
+
dist/
|
|
172
|
+
.quantum/
|
|
173
|
+
*.pyc
|
|
174
|
+
__pycache__/
|
|
175
|
+
|
|
176
|
+
# Environment
|
|
177
|
+
.env
|
|
178
|
+
.env.local
|
|
179
|
+
.env.*.local
|
|
180
|
+
|
|
181
|
+
# Databases
|
|
182
|
+
*.db
|
|
183
|
+
*.sqlite
|
|
184
|
+
|
|
185
|
+
# Logs
|
|
186
|
+
*.log
|
|
187
|
+
logs/
|
|
188
|
+
|
|
189
|
+
# OS
|
|
190
|
+
.DS_Store
|
|
191
|
+
Thumbs.db
|
|
192
|
+
|
|
193
|
+
# IDE
|
|
194
|
+
.idea/
|
|
195
|
+
.vscode/
|
|
196
|
+
*.swp
|
|
197
|
+
*.swo
|
|
198
|
+
|
|
199
|
+
# Dependencies
|
|
200
|
+
node_modules/
|
|
201
|
+
.venv/
|
|
202
|
+
venv/
|
|
203
|
+
"""
|
|
204
|
+
(project_dir / '.gitignore').write_text(gitignore)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def _get_app_type(template: str) -> str:
|
|
208
|
+
"""Get app type from template."""
|
|
209
|
+
type_map = {
|
|
210
|
+
'default': 'html',
|
|
211
|
+
'api': 'api',
|
|
212
|
+
'game': 'game',
|
|
213
|
+
'terminal': 'terminal',
|
|
214
|
+
'component-lib': 'library',
|
|
215
|
+
}
|
|
216
|
+
return type_map.get(template, 'html')
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def _create_default_template(project_dir: Path, project_name: str) -> None:
|
|
220
|
+
"""Create default web application template."""
|
|
221
|
+
# Main layout
|
|
222
|
+
layout = f"""<!-- Main Layout -->
|
|
223
|
+
<q:component name="MainLayout" xmlns:q="https://quantum.lang/ns">
|
|
224
|
+
<q:param name="title" type="string" default="{project_name}" />
|
|
225
|
+
|
|
226
|
+
<html lang="en">
|
|
227
|
+
<head>
|
|
228
|
+
<meta charset="UTF-8" />
|
|
229
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
230
|
+
<title>{{title}}</title>
|
|
231
|
+
<link rel="stylesheet" href="/assets/css/style.css" />
|
|
232
|
+
</head>
|
|
233
|
+
<body>
|
|
234
|
+
<header>
|
|
235
|
+
<nav>
|
|
236
|
+
<a href="/" class="logo">{project_name}</a>
|
|
237
|
+
<ul>
|
|
238
|
+
<li><a href="/">Home</a></li>
|
|
239
|
+
<li><a href="/about">About</a></li>
|
|
240
|
+
</ul>
|
|
241
|
+
</nav>
|
|
242
|
+
</header>
|
|
243
|
+
|
|
244
|
+
<main>
|
|
245
|
+
<q:children />
|
|
246
|
+
</main>
|
|
247
|
+
|
|
248
|
+
<footer>
|
|
249
|
+
<p>Built with Quantum Framework</p>
|
|
250
|
+
</footer>
|
|
251
|
+
</body>
|
|
252
|
+
</html>
|
|
253
|
+
</q:component>
|
|
254
|
+
"""
|
|
255
|
+
(project_dir / 'layouts' / 'main.q').write_text(layout)
|
|
256
|
+
|
|
257
|
+
# Home page
|
|
258
|
+
home = f"""<!-- Home Page -->
|
|
259
|
+
<q:component name="HomePage" xmlns:q="https://quantum.lang/ns">
|
|
260
|
+
<q:layout name="MainLayout" title="Welcome to {project_name}" />
|
|
261
|
+
|
|
262
|
+
<section class="hero">
|
|
263
|
+
<h1>Welcome to {project_name}</h1>
|
|
264
|
+
<p>Your Quantum application is ready!</p>
|
|
265
|
+
|
|
266
|
+
<q:set name="counter" value="0" />
|
|
267
|
+
|
|
268
|
+
<div class="counter">
|
|
269
|
+
<p>Counter: {{counter}}</p>
|
|
270
|
+
<q:action on="click" set="counter" value="{{counter + 1}}">
|
|
271
|
+
<button>Increment</button>
|
|
272
|
+
</q:action>
|
|
273
|
+
</div>
|
|
274
|
+
</section>
|
|
275
|
+
</q:component>
|
|
276
|
+
"""
|
|
277
|
+
(project_dir / 'pages' / 'home.q').write_text(home)
|
|
278
|
+
|
|
279
|
+
# CSS
|
|
280
|
+
css = """/* Quantum Default Styles */
|
|
281
|
+
* {
|
|
282
|
+
margin: 0;
|
|
283
|
+
padding: 0;
|
|
284
|
+
box-sizing: border-box;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
:root {
|
|
288
|
+
--primary: #6366f1;
|
|
289
|
+
--primary-hover: #4f46e5;
|
|
290
|
+
--bg: #f8fafc;
|
|
291
|
+
--text: #1e293b;
|
|
292
|
+
--text-muted: #64748b;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
body {
|
|
296
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
297
|
+
background: var(--bg);
|
|
298
|
+
color: var(--text);
|
|
299
|
+
line-height: 1.6;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
header {
|
|
303
|
+
background: white;
|
|
304
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
305
|
+
padding: 1rem 2rem;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
nav {
|
|
309
|
+
display: flex;
|
|
310
|
+
justify-content: space-between;
|
|
311
|
+
align-items: center;
|
|
312
|
+
max-width: 1200px;
|
|
313
|
+
margin: 0 auto;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.logo {
|
|
317
|
+
font-size: 1.5rem;
|
|
318
|
+
font-weight: bold;
|
|
319
|
+
color: var(--primary);
|
|
320
|
+
text-decoration: none;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
nav ul {
|
|
324
|
+
display: flex;
|
|
325
|
+
list-style: none;
|
|
326
|
+
gap: 2rem;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
nav a {
|
|
330
|
+
color: var(--text);
|
|
331
|
+
text-decoration: none;
|
|
332
|
+
transition: color 0.2s;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
nav a:hover {
|
|
336
|
+
color: var(--primary);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
main {
|
|
340
|
+
max-width: 1200px;
|
|
341
|
+
margin: 0 auto;
|
|
342
|
+
padding: 2rem;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.hero {
|
|
346
|
+
text-align: center;
|
|
347
|
+
padding: 4rem 0;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.hero h1 {
|
|
351
|
+
font-size: 3rem;
|
|
352
|
+
margin-bottom: 1rem;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.hero p {
|
|
356
|
+
color: var(--text-muted);
|
|
357
|
+
font-size: 1.25rem;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.counter {
|
|
361
|
+
margin-top: 2rem;
|
|
362
|
+
padding: 2rem;
|
|
363
|
+
background: white;
|
|
364
|
+
border-radius: 8px;
|
|
365
|
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
|
366
|
+
display: inline-block;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
button {
|
|
370
|
+
background: var(--primary);
|
|
371
|
+
color: white;
|
|
372
|
+
border: none;
|
|
373
|
+
padding: 0.75rem 1.5rem;
|
|
374
|
+
border-radius: 6px;
|
|
375
|
+
font-size: 1rem;
|
|
376
|
+
cursor: pointer;
|
|
377
|
+
transition: background 0.2s;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
button:hover {
|
|
381
|
+
background: var(--primary-hover);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
footer {
|
|
385
|
+
text-align: center;
|
|
386
|
+
padding: 2rem;
|
|
387
|
+
color: var(--text-muted);
|
|
388
|
+
margin-top: 4rem;
|
|
389
|
+
}
|
|
390
|
+
"""
|
|
391
|
+
(project_dir / 'assets' / 'css' / 'style.css').write_text(css)
|
|
392
|
+
|
|
393
|
+
# Application entry point
|
|
394
|
+
app = f"""<!-- Application Entry Point -->
|
|
395
|
+
<q:application id="{project_name}" type="html" xmlns:q="https://quantum.lang/ns">
|
|
396
|
+
<q:route path="/" page="pages/home.q" />
|
|
397
|
+
<q:route path="/about" page="pages/about.q" />
|
|
398
|
+
</q:application>
|
|
399
|
+
"""
|
|
400
|
+
(project_dir / 'app.q').write_text(app)
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def _create_api_template(project_dir: Path, project_name: str) -> None:
|
|
404
|
+
"""Create API template."""
|
|
405
|
+
api = f"""<!-- API Application -->
|
|
406
|
+
<q:application id="{project_name}-api" type="api" xmlns:q="https://quantum.lang/ns">
|
|
407
|
+
|
|
408
|
+
<!-- Health check endpoint -->
|
|
409
|
+
<q:function name="healthCheck" rest="GET /api/health">
|
|
410
|
+
<q:return value='{{"status": "ok", "service": "{project_name}"}}' />
|
|
411
|
+
</q:function>
|
|
412
|
+
|
|
413
|
+
<!-- Users CRUD -->
|
|
414
|
+
<q:component name="UsersAPI">
|
|
415
|
+
<q:function name="listUsers" rest="GET /api/users">
|
|
416
|
+
<q:query name="users" datasource="default">
|
|
417
|
+
SELECT id, name, email, created_at FROM users ORDER BY id
|
|
418
|
+
</q:query>
|
|
419
|
+
<q:return value="{{users}}" />
|
|
420
|
+
</q:function>
|
|
421
|
+
|
|
422
|
+
<q:function name="getUser" rest="GET /api/users/:id">
|
|
423
|
+
<q:param name="id" type="number" required="true" />
|
|
424
|
+
<q:query name="user" datasource="default">
|
|
425
|
+
SELECT * FROM users WHERE id = :id
|
|
426
|
+
</q:query>
|
|
427
|
+
<q:return value="{{user}}" />
|
|
428
|
+
</q:function>
|
|
429
|
+
|
|
430
|
+
<q:function name="createUser" rest="POST /api/users">
|
|
431
|
+
<q:param name="name" type="string" required="true" />
|
|
432
|
+
<q:param name="email" type="string" required="true" />
|
|
433
|
+
<q:query datasource="default">
|
|
434
|
+
INSERT INTO users (name, email) VALUES (:name, :email)
|
|
435
|
+
</q:query>
|
|
436
|
+
<q:return value='{{"success": true}}' />
|
|
437
|
+
</q:function>
|
|
438
|
+
</q:component>
|
|
439
|
+
|
|
440
|
+
</q:application>
|
|
441
|
+
"""
|
|
442
|
+
(project_dir / 'api.q').write_text(api)
|
|
443
|
+
|
|
444
|
+
# Update config for API
|
|
445
|
+
config_path = project_dir / 'quantum.config.yaml'
|
|
446
|
+
config = config_path.read_text(encoding="utf-8")
|
|
447
|
+
config = config.replace('type: api', 'type: microservices')
|
|
448
|
+
config_path.write_text(config)
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
def _create_game_template(project_dir: Path, project_name: str) -> None:
|
|
452
|
+
"""Create game template."""
|
|
453
|
+
game = f"""<!-- Game Application -->
|
|
454
|
+
<q:application id="{project_name}" type="game" xmlns:q="https://quantum.lang/ns">
|
|
455
|
+
|
|
456
|
+
<!-- Game Configuration -->
|
|
457
|
+
<q:config width="800" height="600" background="#1a1a2e" />
|
|
458
|
+
|
|
459
|
+
<!-- Assets -->
|
|
460
|
+
<q:assets>
|
|
461
|
+
<q:sprite id="player" src="/assets/images/player.png" />
|
|
462
|
+
</q:assets>
|
|
463
|
+
|
|
464
|
+
<!-- Main Scene -->
|
|
465
|
+
<q:scene id="main" default="true">
|
|
466
|
+
<!-- Player Entity -->
|
|
467
|
+
<q:entity id="player" x="400" y="300">
|
|
468
|
+
<q:sprite ref="player" width="32" height="32" />
|
|
469
|
+
<q:behavior type="keyboard-move" speed="200" />
|
|
470
|
+
</q:entity>
|
|
471
|
+
|
|
472
|
+
<!-- Score Display -->
|
|
473
|
+
<q:entity id="score-display" x="10" y="10">
|
|
474
|
+
<q:text content="Score: 0" font="24px Arial" color="white" />
|
|
475
|
+
</q:entity>
|
|
476
|
+
</q:scene>
|
|
477
|
+
|
|
478
|
+
<!-- Game Over Scene -->
|
|
479
|
+
<q:scene id="gameover">
|
|
480
|
+
<q:entity id="gameover-text" x="400" y="300" anchor="center">
|
|
481
|
+
<q:text content="Game Over!" font="48px Arial" color="red" />
|
|
482
|
+
</q:entity>
|
|
483
|
+
</q:scene>
|
|
484
|
+
|
|
485
|
+
</q:application>
|
|
486
|
+
"""
|
|
487
|
+
(project_dir / 'game.q').write_text(game)
|
|
488
|
+
|
|
489
|
+
# Create placeholder sprite
|
|
490
|
+
(project_dir / 'assets' / 'images' / '.gitkeep').write_text('')
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
def _create_terminal_template(project_dir: Path, project_name: str) -> None:
|
|
494
|
+
"""Create terminal TUI template."""
|
|
495
|
+
terminal = f"""<!-- Terminal TUI Application -->
|
|
496
|
+
<q:application id="{project_name}" type="terminal" xmlns:q="https://quantum.lang/ns">
|
|
497
|
+
|
|
498
|
+
<!-- Main Screen -->
|
|
499
|
+
<q:screen id="main" default="true">
|
|
500
|
+
<q:header title="{project_name}" />
|
|
501
|
+
|
|
502
|
+
<q:container layout="vertical">
|
|
503
|
+
<q:text>Welcome to {project_name}!</q:text>
|
|
504
|
+
<q:text>Press 'q' to quit, 'h' for help.</q:text>
|
|
505
|
+
|
|
506
|
+
<q:set name="items" value="['Item 1', 'Item 2', 'Item 3']" />
|
|
507
|
+
|
|
508
|
+
<q:list bind="items" selectable="true" on-select="handleSelect">
|
|
509
|
+
<q:template>
|
|
510
|
+
<q:text>{{item}}</q:text>
|
|
511
|
+
</q:template>
|
|
512
|
+
</q:list>
|
|
513
|
+
</q:container>
|
|
514
|
+
|
|
515
|
+
<q:footer>
|
|
516
|
+
<q:text>[q]uit [h]elp [Enter]select</q:text>
|
|
517
|
+
</q:footer>
|
|
518
|
+
</q:screen>
|
|
519
|
+
|
|
520
|
+
<!-- Keybindings -->
|
|
521
|
+
<q:keybind key="q" action="quit" />
|
|
522
|
+
<q:keybind key="h" action="show-help" />
|
|
523
|
+
|
|
524
|
+
</q:application>
|
|
525
|
+
"""
|
|
526
|
+
(project_dir / 'app.q').write_text(terminal)
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
def _create_component_lib_template(project_dir: Path, project_name: str) -> None:
|
|
530
|
+
"""Create component library template."""
|
|
531
|
+
# Button component
|
|
532
|
+
button = """<!-- Button Component -->
|
|
533
|
+
<q:component name="Button" xmlns:q="https://quantum.lang/ns">
|
|
534
|
+
<q:param name="variant" type="string" default="primary" />
|
|
535
|
+
<q:param name="size" type="string" default="medium" />
|
|
536
|
+
<q:param name="disabled" type="boolean" default="false" />
|
|
537
|
+
|
|
538
|
+
<button class="btn btn-{variant} btn-{size}" disabled="{disabled}">
|
|
539
|
+
<q:children />
|
|
540
|
+
</button>
|
|
541
|
+
</q:component>
|
|
542
|
+
"""
|
|
543
|
+
(project_dir / 'components' / 'Button.q').write_text(button)
|
|
544
|
+
|
|
545
|
+
# Card component
|
|
546
|
+
card = """<!-- Card Component -->
|
|
547
|
+
<q:component name="Card" xmlns:q="https://quantum.lang/ns">
|
|
548
|
+
<q:param name="title" type="string" />
|
|
549
|
+
<q:param name="elevation" type="number" default="1" />
|
|
550
|
+
|
|
551
|
+
<div class="card elevation-{elevation}">
|
|
552
|
+
<q:if condition="{title}">
|
|
553
|
+
<div class="card-header">
|
|
554
|
+
<h3>{title}</h3>
|
|
555
|
+
</div>
|
|
556
|
+
</q:if>
|
|
557
|
+
<div class="card-body">
|
|
558
|
+
<q:children />
|
|
559
|
+
</div>
|
|
560
|
+
</div>
|
|
561
|
+
</q:component>
|
|
562
|
+
"""
|
|
563
|
+
(project_dir / 'components' / 'Card.q').write_text(card)
|
|
564
|
+
|
|
565
|
+
# Input component
|
|
566
|
+
input_comp = """<!-- Input Component -->
|
|
567
|
+
<q:component name="Input" xmlns:q="https://quantum.lang/ns">
|
|
568
|
+
<q:param name="name" type="string" required="true" />
|
|
569
|
+
<q:param name="type" type="string" default="text" />
|
|
570
|
+
<q:param name="label" type="string" />
|
|
571
|
+
<q:param name="placeholder" type="string" />
|
|
572
|
+
<q:param name="required" type="boolean" default="false" />
|
|
573
|
+
<q:param name="error" type="string" />
|
|
574
|
+
|
|
575
|
+
<div class="form-group">
|
|
576
|
+
<q:if condition="{label}">
|
|
577
|
+
<label for="{name}">{label}</label>
|
|
578
|
+
</q:if>
|
|
579
|
+
<input
|
|
580
|
+
type="{type}"
|
|
581
|
+
id="{name}"
|
|
582
|
+
name="{name}"
|
|
583
|
+
placeholder="{placeholder}"
|
|
584
|
+
required="{required}"
|
|
585
|
+
class="{error ? 'has-error' : ''}"
|
|
586
|
+
/>
|
|
587
|
+
<q:if condition="{error}">
|
|
588
|
+
<span class="error-message">{error}</span>
|
|
589
|
+
</q:if>
|
|
590
|
+
</div>
|
|
591
|
+
</q:component>
|
|
592
|
+
"""
|
|
593
|
+
(project_dir / 'components' / 'Input.q').write_text(input_comp)
|
|
594
|
+
|
|
595
|
+
# Index file
|
|
596
|
+
index = f"""<!-- {project_name} Component Library -->
|
|
597
|
+
<q:component name="{project_name}Index" xmlns:q="https://quantum.lang/ns">
|
|
598
|
+
<!-- Export all components -->
|
|
599
|
+
<q:import component="Button" />
|
|
600
|
+
<q:import component="Card" />
|
|
601
|
+
<q:import component="Input" />
|
|
602
|
+
</q:component>
|
|
603
|
+
"""
|
|
604
|
+
(project_dir / 'index.q').write_text(index)
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
def _init_git(project_dir: Path) -> None:
|
|
608
|
+
"""Initialize git repository."""
|
|
609
|
+
import subprocess
|
|
610
|
+
|
|
611
|
+
try:
|
|
612
|
+
subprocess.run(['git', 'init'], cwd=project_dir, capture_output=True, check=True)
|
|
613
|
+
subprocess.run(['git', 'add', '.'], cwd=project_dir, capture_output=True, check=True)
|
|
614
|
+
subprocess.run(
|
|
615
|
+
['git', 'commit', '-m', 'Initial commit - Quantum project'],
|
|
616
|
+
cwd=project_dir,
|
|
617
|
+
capture_output=True,
|
|
618
|
+
check=True
|
|
619
|
+
)
|
|
620
|
+
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
621
|
+
# Git not available or failed - not critical
|
|
622
|
+
pass
|