You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 166706d
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: packages/lde-core/src/package/initialize.lua
+205Lines changed: 205 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3,13 +3,210 @@ local fs = require("fs")
3
3
localutil=require("util")
4
4
localansi=require("ansi")
5
5
localgit2=require("git2-sys")
6
+
localprocess=require("process")
6
7
7
8
localPackage=require("lde-core.package")
8
9
9
10
localfunctionhasGit()
10
11
returntrue
11
12
end
12
13
14
+
---@typestring
15
+
localAGENT_TEMPLATE=util.dedent([[
16
+
# Building Projects with lde
17
+
18
+
`lde` is a package manager and toolkit for Lua (LuaJIT). It manages project-local dependencies, runs Lua programs, runs tests, and compiles projects into single executables.
19
+
20
+
## Quick Reference
21
+
22
+
```sh
23
+
lde run # build + install deps + run entry point (src/init.lua)
24
+
lde test # run all **/*.test.lua files
25
+
lde compile # compile to a single native executable
26
+
lde bundle # bundle into a single .lua file
27
+
lde -e "<code>" # run a one-liner with project deps available
28
+
lde ./path/to/file.lua # run an arbitrary file with project deps available
29
+
30
+
lde add <alias> --path ../pkg # add a local path dependency
lde add <alias>@<version> # add a registry dependency
33
+
lde remove <alias> # remove a dependency
34
+
```
35
+
36
+
**Always use `lde add`/`lde remove`** — never edit `lde.json` by hand or the lockfile goes out of sync.
37
+
38
+
Dependency installation happens automatically on `lde run`, `lde test`, and `lde compile`. If an external runtime (e.g. LOVE2D) runs your code, use `lde sync` to populate `target/`.
Platform features (`windows`, `linux`, `macos`, `android`) are auto-detected. Optional deps listed under the current platform are installed automatically.
80
+
81
+
`lde-test` and `lde-build` are included with the lde runtime — adding them to `devDependencies` is only needed for LSP typings.
82
+
83
+
## How `require()` Resolution Works
84
+
85
+
`lde run` and `lde test` set `package.path` / `package.cpath` to point at `target/`:
86
+
87
+
```
88
+
target/?.lua
89
+
target/?/init.lua
90
+
target/?.so (or .dll / .dylib)
91
+
```
92
+
93
+
Dependencies are installed as symlinks at `target/<alias>`. **The require name is the key in `dependencies`, not the package's `name` field.** This means you can alias packages by choosing a different key.
94
+
95
+
During `lde test`, the project's `tests/` directory is exposed as `target/tests`, so test files can share helpers:
96
+
97
+
```lua
98
+
-- tests/foo.test.lua
99
+
local helper = require("tests.lib.helper") -- resolves to tests/lib/helper.lua
100
+
```
101
+
102
+
## Testing
103
+
104
+
```sh
105
+
lde test # run all **/*.test.lua in the package
106
+
lde test -- path/to/test # run a specific test file
107
+
```
108
+
109
+
Test files must match `**/*.test.lua`:
110
+
111
+
```lua
112
+
local test = require("lde-test")
113
+
114
+
test.it("describes the test", function()
115
+
test.equal(actual, expected)
116
+
test.notEqual(a, b)
117
+
test.truthy(x)
118
+
test.falsy(x)
119
+
test.deepEqual(t1, t2) -- recursive deep equality (including metatables)
120
+
test.match(actual, expected) -- subset match (like jest toMatchObject)
test.afterEach(function() ... end) -- runs after each test
132
+
test.afterAll(function() ... end) -- runs once after all tests
133
+
```
134
+
135
+
Assertions take no message argument — the test name serves as the description.
136
+
137
+
## Compiling
138
+
139
+
```sh
140
+
lde compile # compile to a single native executable
141
+
lde bundle # bundle into a single .lua file (no embedded runtime)
142
+
```
143
+
144
+
`lde compile` produces a self-contained binary that bundles your code, all dependencies, and the LuaJIT runtime.
145
+
146
+
## Build Scripts (`build.lua`)
147
+
148
+
If a package has a `build.lua` at its root, lde executes it instead of symlinking `src/`. **Always use the `lde-build` API** — it handles cross-platform behavior and provides fetch/extract without requiring any tools beyond lde on the user's machine.
149
+
150
+
```lua
151
+
local build = require("lde-build")
152
+
153
+
-- Network (no curl/wget needed)
154
+
local body = build:fetch(url) -- HTTP GET, returns body string
155
+
156
+
-- File I/O (all paths relative to output dir at target/<name>)
0 commit comments