feat(structure): create src/ layout, defer config.lua I/O #333

Merged
fuzzy merged 2 commits from feat/project-structure into main 2026-07-10 08:59:50 +00:00
Owner

What

Phase 6: Align project structure to conventions and remove load-time I/O side effects.

Changes

src/ layout (#292/#288-#291)

  • src/main.lua — thin executable entry point (alternative to bin/qpkg)
  • src/internal/<module>/init.lua — re-exports for all 10 modules
  • src/lib/utils/init.lua — shared utilities
  • src/errors/init.lua — centralized errors

All src/ files are thin wrappers that re-export from lib/ via package.path manipulation.

Compat path (#293)

Both lib/qpkg/ and src/ paths are searched. lib/qpkg/ remains the canonical module location. src/ provides the conventional layout.

Config I/O deferral (#296/#294/#295)

config.lua now has zero I/O at require time:

  • OS/arch detection is deferred to __index metamethod on first field access
  • Config file (qpkg.conf) loading deferred until first non-default field access
  • All existing callers unchanged — backward compatible

Testing

  • luacheck — 0 warnings, 0 errors
  • Old harness — 56/56 pass
  • busted — 76/76 pass
  • lua src/main.lua --version works
  • lua src/main.lua --help works

Closes #292

## What Phase 6: Align project structure to conventions and remove load-time I/O side effects. ## Changes ### src/ layout (#292/#288-#291) - `src/main.lua` — thin executable entry point (alternative to `bin/qpkg`) - `src/internal/<module>/init.lua` — re-exports for all 10 modules - `src/lib/utils/init.lua` — shared utilities - `src/errors/init.lua` — centralized errors All `src/` files are thin wrappers that re-export from `lib/` via package.path manipulation. ### Compat path (#293) Both `lib/qpkg/` and `src/` paths are searched. `lib/qpkg/` remains the canonical module location. `src/` provides the conventional layout. ### Config I/O deferral (#296/#294/#295) `config.lua` now has zero I/O at require time: - OS/arch detection is deferred to `__index` metamethod on first field access - Config file (`qpkg.conf`) loading deferred until first non-default field access - All existing callers unchanged — backward compatible ## Testing - [x] luacheck — 0 warnings, 0 errors - [x] Old harness — 56/56 pass - [x] busted — 76/76 pass - [x] `lua src/main.lua --version` works - [x] `lua src/main.lua --help` works Closes #292
Create src/ directory structure per project conventions:
- src/main.lua — thin entry point
- src/internal/<module>/init.lua — re-exports for all modules
- src/lib/utils/init.lua — shared utilities
- src/errors/init.lua — centralized errors

bin/qpkg now searches both lib/ and src/ paths for modules.

Refactor config.lua for zero I/O at require time:
- OS/arch detection deferred to lazy __index access
- Config file loading deferred until first field access
- Backward compatible — all existing callers unchanged

Closes #292, #288, #289, #290, #291, #293, #296, #294, #295
docs(roadmap): mark Phase 6 completed
All checks were successful
PR Checks / lint-and-test (pull_request) Successful in 16m26s
08a07e9ab6
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-07-10 08:50:16 +00:00
the.auditor left a comment

Review — Approved

Two independent changes, both correct:

Config I/O deferral — OS/arch detection and qpkg.conf loading deferred via __index metamethod. Zero I/O at require time. Results cached on config table after first access. Backward compatible.

src/ layout — 11 thin wrapper modules re-exporting from lib/ via package.path manipulation. src/main.lua entry point works (verified: lua src/main.lua --version). bin/qpkg updated with compat paths.

Verified

  • 76/76 tests pass
  • lua src/main.lua --versionqpkg version 0.1.0

Non-blocking

  1. Config defaults not cached on config table after first load (only os/arch are). Filed as #334.
## Review — Approved Two independent changes, both correct: **Config I/O deferral** — OS/arch detection and qpkg.conf loading deferred via `__index` metamethod. Zero I/O at `require` time. Results cached on `config` table after first access. Backward compatible. **src/ layout** — 11 thin wrapper modules re-exporting from `lib/` via `package.path` manipulation. `src/main.lua` entry point works (verified: `lua src/main.lua --version`). `bin/qpkg` updated with compat paths. ### Verified - 76/76 tests pass - `lua src/main.lua --version` → `qpkg version 0.1.0` ### Non-blocking 1. Config defaults not cached on `config` table after first load (only `os`/`arch` are). Filed as #334.
fuzzy merged commit 08a07e9ab6 into main 2026-07-10 08:59:50 +00:00
fuzzy deleted branch feat/project-structure 2026-07-10 08:59:50 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/qpkg!333
No description provided.