Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion internal/module/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"hash/fnv"
"os"
"path/filepath"
"strconv"
"strings"

"github.com/ophidiarium/moltark/internal/filefmt"
Expand Down Expand Up @@ -66,8 +67,17 @@ func InitRepository(root string) (string, error) {
}
}

escapedName := strings.TrimSuffix(strings.TrimPrefix(strconv.Quote(name), "\""), "\"")
content := fmt.Sprintf(
"python = use(%q)\n\nroot = python.python_project(\n name = %q,\n path = \".\",\n version = %q,\n requires_python = %q,\n)\n",
"\"\"\"Moltark configuration for %s.\"\"\"\n\n"+
"python = use(%q)\n\n"+
"root = python.python_project(\n"+
" name = %q,\n"+
" path = \".\",\n"+
" version = %q,\n"+
" requires_python = %q,\n"+
")\n",
escapedName,
model.ModuleSourcePython,
name,
version,
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/bare_python_repo_with_uv_deps/molt.star
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""A bare Python project with uv dependency management."""

python = use("moltark/python")

python.python_project(
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/conflicting_owned_fields/molt.star
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""A Python project with conflicting owned field values."""

python = use("moltark/python")

python.python_project(
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/core_structured_file_primitives/molt.star
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""A workspace managing structured JSON, TOML, and YAML files."""

core = use("moltark/core")

repo = core.project(
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/core_tasks_with_triggers/molt.star
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""A uv workspace with tasks, triggers, and bootstrap requirements."""

python = use("moltark/python")
uv = use("astral/uv")
core = use("moltark/core")
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/drifted_owned_fields/molt.star
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""A Python project with drifted owned field values."""

python = use("moltark/python")

python.python_project(
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/go_lint_vscode_component/molt.star
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""A Go project with linting, VS Code integration, and fact-driven config."""

core = use("moltark/core")

app = core.project(
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/opaque_root_with_python_child/molt.star
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""A workspace with an opaque root and a nested Python child project."""

core = use("moltark/core")
python = use("moltark/python")

Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/upgraded_template_v1_to_v2/molt.star
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""A Python project upgraded from template v1 to v2."""

python = use("moltark/python")

python.python_project(
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/uv_workspace_with_nested_root/molt.star
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""A uv workspace with a nested root and multiple integration packages."""

python = use("moltark/python")
uv = use("astral/uv")

Expand Down
20 changes: 20 additions & 0 deletions tests/integration/__snapshots__/integration_test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ stderr:

/-/-/-/
== molt.star ==
"""Moltark configuration for demo."""

python = use("moltark/python")

root = python.python_project(
Expand Down Expand Up @@ -213,6 +215,8 @@ stderr:

/-/-/-/
== molt.star ==
"""A bare Python project with uv dependency management."""

python = use("moltark/python")

python.python_project(
Expand Down Expand Up @@ -340,6 +344,8 @@ stderr:

/-/-/-/
== molt.star ==
"""A Python project with drifted owned field values."""

python = use("moltark/python")

python.python_project(
Expand Down Expand Up @@ -460,6 +466,8 @@ stderr:

/-/-/-/
== molt.star ==
"""A Python project with conflicting owned field values."""

python = use("moltark/python")

python.python_project(
Expand Down Expand Up @@ -601,6 +609,8 @@ stderr:

/-/-/-/
== molt.star ==
"""A Python project upgraded from template v1 to v2."""

python = use("moltark/python")

python.python_project(
Expand Down Expand Up @@ -1992,6 +2002,8 @@ stderr:

/-/-/-/
== molt.star ==
"""A uv workspace with a nested root and multiple integration packages."""

python = use("moltark/python")
uv = use("astral/uv")

Expand Down Expand Up @@ -3532,6 +3544,8 @@ stderr:

/-/-/-/
== molt.star ==
"""A uv workspace with tasks, triggers, and bootstrap requirements."""

python = use("moltark/python")
uv = use("astral/uv")
core = use("moltark/core")
Expand Down Expand Up @@ -4553,6 +4567,8 @@ stderr:

/-/-/-/
== molt.star ==
"""A Go project with linting, VS Code integration, and fact-driven config."""

core = use("moltark/core")

app = core.project(
Expand Down Expand Up @@ -5263,6 +5279,8 @@ stderr:

/-/-/-/
== molt.star ==
"""A workspace with an opaque root and a nested Python child project."""

core = use("moltark/core")
python = use("moltark/python")

Expand Down Expand Up @@ -5948,6 +5966,8 @@ stderr:

/-/-/-/
== molt.star ==
"""A workspace managing structured JSON, TOML, and YAML files."""

core = use("moltark/core")

repo = core.project(
Expand Down