Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use manifest project #47

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,11 @@ async def compile_project(project_root: Path, manifest: PackageManifest):
# Create a contracts directory
contracts_dir = project_root / "contracts"
contracts_dir.mkdir()
project = Project.from_manifest(manifest)
Copy link
Member Author

@antazoey antazoey Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw when it comes time to add the dependencies, you can do it like this:

project = Project.from_manifest(manifest, config_override={"dependencies": [{"pypi": "snekmate"}]})

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can config_override accept a list of DependencyAPI objects? that's how I was thinking to parse the incoming dependency specifications


# add request contracts in temp directory
if manifest.sources:
for filename, source in manifest.sources.items():
path = contracts_dir / filename
# NOTE: In case there is a multi-level path
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(source.fetch_content())
try:
project = Project(project_root)
compiled_manifest = project.extract_manifest()
results[project_root.name] = compiled_manifest
tasks[project_root.name] = TaskStatus.SUCCESS
# NOTE: Updates itself because manifest projects are their own cache.
project.load_contracts()
except CompilerError as e:
results[project_root.name] = [
f"{e['sourceLocation'].get('file', 'Unknown file')}\n{e['type']}: {e.get('formattedMessage', e['message'])}"
Expand All @@ -200,3 +192,6 @@ async def compile_project(project_root: Path, manifest: PackageManifest):
except Exception as e:
results[project_root.name] = {e.__class__.__name__: str(e)}
tasks[project_root.name] = TaskStatus.FAILED
antazoey marked this conversation as resolved.
Show resolved Hide resolved
else:
results[project_root.name] = manifest
tasks[project_root.name] = TaskStatus.SUCCESS
Loading