@brew-lang/sdk 0.0.0-stage → 0.3.0-alpha.1

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.
package/README.md CHANGED
@@ -1,3 +1,349 @@
1
- # Temporary Holding Version
1
+ # brewc — the Brew compiler: TypeScript to Skript
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Parses TypeScript with the **official TypeScript parser** (`ts.createSourceFile` from the
4
+ `typescript` npm package), walks the AST, and emits equivalent **Skript** code.
5
+
6
+ `object` is implemented as **Skript list variables**: object literals emit parallel
7
+ key/value lists which are then zipped into the target by a loop
8
+ (`set {_x::%loop-value%} to {_v::%loop-index%}`), and property access becomes
9
+ `{_x::propertyName}`.
10
+
11
+ Because Skript does not preserve list indices across function returns or
12
+ arguments (SkriptLang#811/#3127), `object`-typed **parameters and return
13
+ values cross function boundaries as an NBT compound**: the callee packs the
14
+ keyed list into a compound (its keys ride in a `brew:keys` string list tag)
15
+ and returns/passes the single compound value; the caller re-zips the compound
16
+ into the target keyed list. Compounds are single values, so no indices are
17
+ lost — and because everything stays in local variables, objects work inside
18
+ async sections too. This is invisible in the TS source.
19
+
20
+ Types are dispatched on their inheritance:
21
+
22
+ | Type derives from | Skript representation |
23
+ | --- | --- |
24
+ | `NBTCompound` | SkBee `nbt compound` — reads are `tag "name" of {_x}`, writes `set string tag "name" of {_x} to ...`; `new Compound({a: 1})` becomes `nbt compound from "a: 1"` |
25
+ | `JavaObject` (or an interface with methods) | skript-Reflect syntax — `player.getLocation()` becomes `{_player}.getLocation()` |
26
+ | `object` (everything else) | Skript list variables, indexed `{_x}::key` |
27
+
28
+ Static members of a mirrored class are called on the class itself, which the
29
+ transpiler lowers to skript-Reflect's class-object syntax (the class joins the
30
+ `import:` section via its `@classloc`):
31
+
32
+ ```ts
33
+ import type { BukkitAdapter } from "@brew-types/squaremap/xyz/jpenilla/squaremap/api/BukkitAdapter";
34
+ const id = BukkitAdapter.worldIdentifier(world);
35
+ // -> set {_id} to class "xyz.jpenilla.squaremap.api.BukkitAdapter".worldIdentifier({_world})
36
+ ```
37
+
38
+ `any[]` is implemented with the Skript type `objects` (or `object[]`). Array literals
39
+ (`[1, 2, 3]`) become `(1, 2, and 3).`
40
+
41
+ ### Automatic conversion
42
+
43
+ When a value of one representation is used where another is expected (declarations
44
+ with type annotations, assignments, call arguments, and `return` values), brewc
45
+ inserts the conversion for you:
46
+
47
+ - **list -> nbt**: loops the list and writes `set tag "%loop-index%" of {_out} to loop-value`
48
+ - **nbt -> list**: re-zips from the `brew:keys` string list tag (for NBTCompound values)
49
+ - **java**: cannot be converted automatically (Java objects cross over through
50
+ their own methods), so those values pass through unchanged
51
+
52
+ ```ts
53
+ const data = getNBT("starobj"); // NBTCompound
54
+ const asList: object = data; // -> loop string list tag "brew:keys" of {_data}: ...
55
+ const back: Compound = asList; // -> loop {_asList::*}: set tag ...
56
+ ```
57
+
58
+ ## Installation
59
+
60
+ ### From npm (recommended)
61
+
62
+ ```sh
63
+ npm i -g @brew-lang/brewc
64
+ ```
65
+
66
+ Then use the `brewc` command from anywhere:
67
+
68
+ ```sh
69
+ brewc <input.ts> [-o <output.sk>] # transpile a file
70
+ brewc -v # show the version
71
+ brewc --help # show CLI usage and options
72
+ ```
73
+
74
+ ### From source (development)
75
+
76
+ ```sh
77
+ npm install
78
+ npm run build # compile to build/ (tsc)
79
+ npm test # jest suite
80
+ npx jest -u # update snapshots after intentional changes
81
+ npx tsx src/cli.ts <input.ts> # run straight from TypeScript
82
+ ```
83
+
84
+ The published CLI is the compiled `build/cli.js`, wired up as the `brewc` bin
85
+ in `package.json`; the transpiler is also importable programmatically
86
+ (`import { transpile } from "@brew-lang/brewc"`).
87
+
88
+ ### Examples
89
+
90
+ ```bash
91
+ npm i -g @brew-lang/brewc
92
+ brewc samples/sample.ts -o samples/sample.sk # transpile a file
93
+ brewc samples/sample.ts # ...or print to stdout
94
+ ```
95
+
96
+ ## Building a TypeScript API over native Skript
97
+
98
+ Brew's JSDoc annotations:
99
+
100
+ - **`@ffi <pattern>`** — foreign function interface: maps a `declare`
101
+ function, a `declare const`, or an interface property onto native
102
+ Skript syntax (the original `@skript` name still works)
103
+ - **`@macro`** — a TypeScript macro, C/C++ `#define`-style: the function
104
+ is never emitted; every call site expands its body inline
105
+ - **`@inline`** — generates a macro from a function while keeping the
106
+ function itself: expression calls expand inline, and statement-bodied
107
+ inlines fall back to a real function call when used as a value
108
+ - **`@on <event>`** — compiles a function into an event trigger
109
+
110
+ `@macro` functions expand inline: arguments are evaluated into locals
111
+ once, the parameters bind to them, and the body's statements plus its
112
+ trailing `return` expression emit at the call site. A bare-`return` body
113
+ works in expression position; a macro with statements before its return
114
+ is statement-only:
115
+
116
+ ```ts
117
+ /** @macro */
118
+ function SQUARE(x: number): number {
119
+ return x * x;
120
+ }
121
+ const v = SQUARE(3 + 1); // -> set {_ts_m1} to 3 + 1, set {_v} to {_ts_m1} * {_ts_m1}
122
+ ```
123
+
124
+ `/** @ffi <pattern> */` above a `declare function` stub maps its calls onto
125
+ arbitrary native Skript syntax instead of a function call. `%1%`, `%2%`, … in
126
+ the pattern are the call arguments (text-typed parameters are quoted so
127
+ variables resolve at runtime):
128
+
129
+ ```ts
130
+ /** @ffi %1% parsed as player */
131
+ declare function getPlayer(name: string): Player;
132
+ /** @ffi all players */
133
+ declare function allPlayers(): Player[];
134
+ /** @ffi give %2% to %1% */
135
+ declare function give(p: Player, item: ItemType): void;
136
+ ```
137
+
138
+ ```sk
139
+ set {_p} to "%{_name}%" parsed as player
140
+ set {_byLiteral} to "starobj" parsed as player
141
+ loop all players:
142
+ give "diamond" to {_q}
143
+ ```
144
+
145
+ This is how a TypeScript API calls native Skript code under the hood — the
146
+ stubs give you full type checking in TS, and the patterns emit the Skript
147
+ syntax at runtime.
148
+
149
+ ### `@classloc` and the `import:` section
150
+
151
+ Interfaces can declare the full Java class location of what they represent:
152
+
153
+ ```ts
154
+ /**
155
+ * @classloc com.example.thirdparty.CustomThing
156
+ */
157
+ interface CustomThing extends JavaObject { ... }
158
+ ```
159
+
160
+ `brewc fetch` adds `@classloc` automatically (e.g. `@classloc org.bukkit.Location`).
161
+ Fetched interfaces extend `Object` — java.lang.Object, imported from the
162
+ `@brew-types/java__java.base` language pack — so every mirrored class carries
163
+ Object's methods (`toString`, `equals`, `hashCode`, ...) and dispatches as a
164
+ Java object.
165
+ To mirror a whole API instead of one class, `brewc fetch-javadoc <javadoc-base-url>`
166
+ walks a javadoc tree and `brewc fetch-git <git-url>` clones a Git repo of Java
167
+ sources; both emit the same package tree of interfaces (an `index.ts` per
168
+ directory, `import type` cross-references, `--package name` for a `.d.ts`
169
+ types package) into `-o <outDir>`.
170
+ Package names follow the `@brew-types/<languageFileExtension>__<groupId>__<artifactId>`
171
+ standard, double-underscore delimited — e.g. `@brew-types/java__java.base` for the
172
+ `java.base` module (`java.lang`) and `@brew-types/java__org.spigotmc__spigot-api` for
173
+ `org.spigotmc:spigot-api` (`org.bukkit`). A `--package` mirror also writes a
174
+ `brew.json` next to its `package.json` mapping each covered Java package to
175
+ the npm package, so `brewc fetch-git` links references the repo does not
176
+ declare itself into the package providing them:
177
+ `import type { World } from "@brew-types/java__org.spigotmc__spigot-api/org/bukkit/World"`.
178
+ When a script *uses* a type as a Java object, the transpiler emits the
179
+ skript-Reflect `import:` section at the top of the output with exactly the
180
+ classes it needs — unused classes are never imported. This also lets you
181
+ hand-declare APIs for third-party JAR libraries on your server.
182
+
183
+ ### Keeping the API in modules
184
+
185
+ The stubs can live in their own module and be imported — the transpiler
186
+ resolves relative imports and picks up the imported declarations, types, and
187
+ `@ffi` patterns (imported files are parsed, never type-checked):
188
+
189
+ ```ts
190
+ import { broadcast, give } from "../src/api/functions";
191
+ ```
192
+
193
+ The CLI resolves imports relative to the input file automatically. When using
194
+ `transpile()` programmatically, pass the input file's directory as
195
+ `importBase`.
196
+
197
+ ## Examples
198
+
199
+ The examples are complete packages that depend on `@brew-lang/brewc`
200
+ (via `file:../..` until the package is published) and compile
201
+ `src/main.ts` to `dist/main.sk` with the `brewc` CLI:
202
+
203
+ - [`examples/hello-world`](examples/hello-world) — a first script: player
204
+ lookups, broadcasts, NBT, with `Player` imported from the mirrored
205
+ Spigot-API tree
206
+ - [`examples/lambda`](examples/lambda) — async lambdas as skript-reflect
207
+ sections
208
+
209
+ Because `file:` dependencies copy the package at install time,
210
+ re-install (`npm install`) after rebuilding brewc so the examples pick
211
+ up the new compiler:
212
+
213
+ ```sh
214
+ npm run build # in the repo root: compile brewc itself
215
+ cd examples/lambda
216
+ npm install && npm run build # -> dist/main.sk
217
+ ```
218
+
219
+ ## Lambdas and async
220
+
221
+ Lambdas compile to [skript-reflect
222
+ sections](https://tpgamesnl.gitbook.io/skript-reflect/advanced/reflection/sections),
223
+ and `async` lambdas with `await` map onto their async runs. Locals from
224
+ before the lambda's creation stay readable inside it, which is how closures
225
+ capture:
226
+
227
+ ```ts
228
+ let i = 5;
229
+ let someLambda = async (a, b) => {
230
+ a *= i;
231
+ return a + b;
232
+ };
233
+ const foo = await someLambda(1, 2);
234
+ broadcast(`Result: ${foo}`); // shows 7
235
+ ```
236
+
237
+ ```sk
238
+ set {_i} to 5
239
+ create new section with {_a}, {_b} stored in {_someLambda}:
240
+ set {_a} to {_a} * {_i}
241
+ return {_a} + {_b}
242
+ run section {_someLambda} async with 1, 2 and store result in {_ts_l1} and wait
243
+ set {_foo} to {_ts_l1}
244
+ broadcast "Result: %{_foo}%" # shows 7
245
+ ```
246
+
247
+ An async section can only produce output when waited for, so using an
248
+ async lambda's result always waits; a bare `f(x)` statement runs
249
+ fire-and-forget, and `await f(x);` waits without keeping the result.
250
+ `await` on anything but a lambda (or `Function`-typed value) call is a
251
+ compile error.
252
+
253
+ A `Function`-typed parameter holds a section value, so higher-order
254
+ patterns work — pass a lambda and call the parameter with `await`.
255
+ Because Skript functions cannot contain delays, `await` is only legal in
256
+ trigger bodies and lambda bodies; a named function with an `await` inside
257
+ is a compile error.
258
+
259
+ Skript also forbids returning after a delay, so async sections deliver
260
+ their results through **globals**: `await` still synchronizes (the
261
+ caller waits for the section to finish), and the section stores its
262
+ result in a `globalThis` property instead of returning it:
263
+
264
+ ```ts
265
+ let doSomething = async (f: Function): Promise<number> => {
266
+ foo = await f(1, 2); // undeclared `foo` -> {globalThis::foo}
267
+ };
268
+ await doSomething(someLambda);
269
+ broadcast(`Result: ${foo}`); // reads {globalThis::foo}: 7
270
+ ```
271
+
272
+ ## What's supported
273
+
274
+ | TypeScript | Skript |
275
+ | --- | --- |
276
+ | `number` / `string` / `boolean` | `number` / `text` / `boolean` |
277
+ | `object` | list variables locally; an NBT compound across function boundaries |
278
+ | `object[]` / `any[]` | `objects` |
279
+ | `Player` / `World` / `ItemType` / `Location` / `Vector` / `Timespan` | `player` / `world` / `item type` / `location` / `vector` / `timespan` (PascalCase in TS; lowercase aliases still accepted) |
280
+ | `let x = e` / `x = e` | `set {_x} to e` |
281
+ | assignment to an undeclared name (`carl = 5`) | `set {globalThis::carl} to 5` — like JS, undeclared assignments are `globalThis` properties; every later read (from any trigger) is `{globalThis::carl}` |
282
+ | `x += e` / `x -= e` | `add e to {_x}` / `remove e from {_x}` |
283
+ | `x++` / `x--` (statement position) | `add 1 to {_x}` / `remove 1 from {_x}` |
284
+ | `cond ? a : b` | hoisted `if cond: set {_ts_tN} to a` / `else: set {_ts_tN} to b`; both branches are evaluated eagerly (unlike JS) |
285
+ | `Math.min/max/abs/floor/ceil/round/sqrt(...)` | Skript's `min(...)` / `max(...)` / … functions |
286
+ | `Math.pow(a, b)` | `a ^ b` |
287
+ | `Math.random(a?, b?)` | `random integer between a and b` (defaults 0..1) |
288
+ | `Object.keys(o)` | `indices of {_o::*}` — or the `brew:keys` tag when `o` is an nbt carrier |
289
+ | `Object.values(o)` | `{_o::*}` (not supported on nbt compounds — index with `Object.keys`) |
290
+ | `x *= e` / `x /= e` | `set {_x} to {_x} * e` / `set {_x} to {_x} / e` |
291
+ | `let f = (a, b) => { ... }` | skript-reflect section: `create new section with {_a}, {_b} stored in {_f}: ...` |
292
+ | `f(x, y)` on a lambda | `run section {_f} with x, y and store result in {_r}` |
293
+ | `async` lambda + `await f(x, y)` | `run section {_f} async with x, y and store result in {_r} and wait` |
294
+ | `if` / `else if` / `else` | `if cond:` / `else if cond:` / `else:` |
295
+ | `while` / `for..of` / `break` | `while` / `loop` (+ `loop-value`) / `exit loop` |
296
+ | `&&` / `\|\|` / `!` | `and` / `or` / `not` |
297
+ | `===` `!==` `<` `<=` `>` `>=` | `is` / `isn't` / `is less than` / … |
298
+ | `` `${x}` `` | `"…%{_x}%…"` (literal `%` escaped as `%%`) |
299
+ | `function f(a: number): string` | `function f(a: number) :: text:` (param `a` is `{_a}` in the body) |
300
+ | `/** @on player join */` above a function | `on player join:` trigger (params become `{_param}` locals) |
301
+ | `/** @command /kit give */` above a function | `command /kit give <name: text>:` block with a `trigger:` holding the function body; params become command arguments (TS types map to Skript arg types, `p?: number` → `[<p: number>]`), and Skript binds each arg to `{_p}` automatically. `@permission`, `@usage` and `@aliases` JSDoc tags (in the same block) become the command's options |
302
+ | top-level statements (`let BOOSTER = 10`, `broadcast(...)`, `if`…) | fold into the script's first `on load:` trigger, in source order; their `let`/`const` bind as `{globalThis::*}` globals so every later trigger reads them |
303
+ | `declare function f(...)` | not emitted — an ambient stub for a function provided by another script/addon |
304
+ | `/** @ffi <pattern> */` above a `declare function` | calls map onto native Skript syntax instead of a function call; `%1%`, `%2%`, … in the pattern are the call arguments (e.g. `@ffi broadcast %1%` emits `broadcast {_msg}`, `@ffi all players` emits `all players`) |
305
+ | `/** @ffi <pattern> */` above a `declare const X: T;` | a macro: the pattern substitutes for every use of `X` (e.g. `@ffi "starobj" parsed as a player` emits `"starobj" parsed as a player`), and the declared type `T` still drives dispatch |
306
+ | `/** @ffi <pattern> */` above an interface property | the property's native access syntax: `%this%` is the receiver, `%key%` the property name, `%value%` the assigned value (aliases `%1%`/`%2%`/`%3%`). A pattern without `%value%` is an expression (reads emit it, writes emit `set <pattern> to <value>`); a pattern with `%value%` is the full setter effect, and the property is set-only |
307
+ | object literal `{ a: 1 }` | keyed list: `set {_ts_k::*} to "a"` / `set {_ts_v::*} to 1` |
308
+ | `o.a` | `{_o::a}` |
309
+ | `return e` / bare `return` | `return e` / `stop` |
310
+
311
+ ## Testing
312
+
313
+ For unit testing, I've chosen to use `jest`, as its my favorite JavaScript unit
314
+ testing framework. You can run the tests with `npm test`. I've configured it
315
+ with `ts-jest` (see [`jest.config.ts`](jest.config.ts)). It covers:
316
+
317
+ - **Unit tests** per feature: type mapping, each statement type, operators,
318
+ template strings, nbt compounds, ambient `declare` stubs, event triggers.
319
+ - **A snapshot test** of `samples/sample.ts`: the full generated Skript is
320
+ compared against `test/__snapshots__/`. If a change alters output, jest
321
+ shows a diff — if the change is intentional, accept it with `npx jest -u`.
322
+
323
+ ## Roadmap ideas
324
+
325
+ - Method calls on real Skript types (`player.teleport(...)`)
326
+ - `switch` statements, `for(;;)` loops
327
+ - `await`-style scheduling (Skript's `wait N ticks`)
328
+ - A type dictionary so addon types (skrayfall, skbee elements) can be declared
329
+ - Local-variable scoping checks (Skript `{_x}` is function-scoped, not block-scoped)
330
+
331
+ ## Known limitations of this version
332
+
333
+ - `continue` has no direct Skript equivalent (emitted as a comment).
334
+ - Assignments inside expressions (e.g. `if (x = f())`) are rejected.
335
+ - Arrays are passed through as Skript lists (`player[]` -> `players`).
336
+ - Only function declarations and definitions are allowed at the top level.
337
+
338
+ ## Server requirements
339
+
340
+ As of this version, Skript output generated by `brewc` currently requires the
341
+ following to be installed on the server:
342
+
343
+ | Requirement | Minimum | Maximum |
344
+ |-----------------|---------|---------|
345
+ | Minecraft | 26.3 | 26.3 |
346
+ | Paper | 26.3 | 26.3 |
347
+ | Skript | ^2.7.0 | ^2.17.0 |
348
+ | SkBee | ^3.5.0 | ^3.26.0 |
349
+ | skript-reflect | ^2.6.0 | ^2.6.0 |
package/build/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/build/cli.js ADDED
@@ -0,0 +1,256 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ /**
38
+ * Brew Compiler (brewc) CLI
39
+ * Usage: npx tsx src/cli.ts input.ts [-o output.sk]
40
+ * (or compile with tsc and run: node dist/cli.js input.ts -o out.sk)
41
+ */
42
+ const fs = __importStar(require("fs"));
43
+ const path = __importStar(require("path"));
44
+ const transpiler_js_1 = require("./transpiler.js");
45
+ const fetch_js_1 = require("./fetch.js");
46
+ const fetchgit_js_1 = require("./fetchgit.js");
47
+ const HELP = `brewc — the Brew compiler: TypeScript to Skript
48
+
49
+ Usage:
50
+ brewc <input.ts> [options]
51
+ brewc fetch <javadoc-url> [-o output.ts]
52
+ brewc fetch-javadoc <javadoc-base-url> [-o outDir] [--limit N] [--package name]
53
+ brewc fetch-git <git-url> [-o outDir] [--branch ref] [--limit N] [--package name]
54
+
55
+ Options:
56
+ -o, --output <file> Write the transpiled Skript code to <file>
57
+ --obfuscate Shorten/obfuscate local variable names and rename
58
+ locally-defined functions with a per-file id
59
+ -h, --help Show this help message
60
+ -v, --version Show the version
61
+
62
+ Fetch subcommands mirror an API as a tree of .ts interfaces (an index.ts per
63
+ directory, @classloc docblocks, imports of the base Object type):
64
+ fetch one javadoc page -> one interface (default output: <Class>.ts)
65
+ fetch-javadoc a whole javadoc tree (formerly fetch-all)
66
+ fetch-git a Git repo's Java sources cloned and mirrored the same way
67
+
68
+ Examples:
69
+ brewc samples/sample.ts -o samples/sample.sk
70
+ brewc samples/sample.ts # prints to stdout
71
+ brewc fetch https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html
72
+ # -> Player.ts (interface from the javadoc)
73
+ brewc fetch-javadoc https://hub.spigotmc.org/javadocs/spigot/ -o packages/spigot-api \
74
+ --package @brew-types/java__org.spigotmc__spigot-api
75
+ brewc fetch-git https://github.com/PaperMC/Paper.git -o packages/paper-api
76
+ `;
77
+ const args = process.argv.slice(2);
78
+ let skipTranspile = false;
79
+ // brewc fetch <javadoc-url> [-o output.ts]
80
+ // Generates a TypeScript interface for a Spigot/Bukkit javadoc page. The
81
+ // output defaults to the class name with a .ts extension.
82
+ if (args[0] === "fetch" || args[0] === "--fetch") {
83
+ const url = args[1];
84
+ const outFlag2 = args.indexOf("-o") !== -1 ? args.indexOf("-o") : args.indexOf("--output");
85
+ const fetchOut = outFlag2 !== -1 ? args[outFlag2 + 1] : null;
86
+ if (!url) {
87
+ console.error("Usage: brewc fetch <javadoc-url> [-o output.ts]");
88
+ process.exit(1);
89
+ }
90
+ (0, fetch_js_1.fetchApiDocs)(url)
91
+ .then((result) => {
92
+ const file = (0, fetch_js_1.writeFetched)(result, fetchOut);
93
+ console.log(`Wrote ${file} (${result.name})`);
94
+ })
95
+ .catch((err) => {
96
+ console.error("Fetch error:", err.message);
97
+ process.exit(1);
98
+ });
99
+ // keep the process alive for the async fetch; the transpile path below
100
+ // must not run for this subcommand
101
+ skipTranspile = true;
102
+ }
103
+ // brewc fetch-javadoc <javadoc-base-url> [-o outDir] [--limit N] [--package name]
104
+ // (formerly fetch-all) Mirrors the whole javadoc API as a package tree of
105
+ // .ts interfaces with an index.ts per directory. --limit caps the number of
106
+ // classes (for trying it out quickly).
107
+ if (args[0] === "fetch-javadoc" || args[0] === "--fetch-javadoc" ||
108
+ args[0] === "javadoc-fetch" || args[0] === "--javadoc-fetch" ||
109
+ args[0] === "fetch-all" || args[0] === "--fetch-all") {
110
+ const url = args[1];
111
+ const outFlagA = args.indexOf("-o") !== -1 ? args.indexOf("-o") : args.indexOf("--output");
112
+ const outDir = outFlagA !== -1 ? args[outFlagA + 1]
113
+ : (url?.replace(/\/$/, "").split("/").pop() || "javadoc-api");
114
+ const limitFlag = args.indexOf("--limit");
115
+ const limit = limitFlag !== -1 ? Number(args[limitFlag + 1]) : undefined;
116
+ const pkgFlag = args.indexOf("--package");
117
+ const packageName = pkgFlag !== -1 ? args[pkgFlag + 1] : undefined;
118
+ if (!url) {
119
+ console.error("Usage: brewc fetch-javadoc <javadoc-base-url> [-o outDir] [--limit N] [--package name]");
120
+ process.exit(1);
121
+ }
122
+ (0, fetch_js_1.fetchAllApiDocs)(url, outDir, {
123
+ limit: Number.isFinite(limit) ? limit : undefined,
124
+ packageName,
125
+ log: (msg) => console.log(msg),
126
+ })
127
+ .then((result) => {
128
+ console.log(`Wrote ${result.classes} interfaces to ${outDir}/`);
129
+ if (result.errors.length) {
130
+ console.log(`${result.errors.length} pages failed:`);
131
+ for (const e of result.errors.slice(0, 10))
132
+ console.log(" " + e);
133
+ }
134
+ })
135
+ .catch((err) => {
136
+ console.error("Fetch error:", err.message);
137
+ process.exit(1);
138
+ });
139
+ skipTranspile = true;
140
+ }
141
+ // brewc fetch-git <git-url> [-o outDir] [--branch ref] [--limit N] [--package name]
142
+ // (--git-fetch also accepted) Clones the repo (shallow) and mirrors its
143
+ // .java sources as the same style of TypeScript package tree that
144
+ // fetch-javadoc produces from javadocs. The repo's `java/` source roots
145
+ // (each module's src/main/java) are discovered first — only sources
146
+ // beneath them are mirrored — and classes are placed by their `package`
147
+ // declaration, so Maven/Gradle layouts mirror correctly.
148
+ if (args[0] === "fetch-git" || args[0] === "--fetch-git" ||
149
+ args[0] === "git-fetch" || args[0] === "--git-fetch") {
150
+ const url = args[1];
151
+ const outFlagG = args.indexOf("-o") !== -1 ? args.indexOf("-o") : args.indexOf("--output");
152
+ const outDir = outFlagG !== -1 ? args[outFlagG + 1]
153
+ : (url?.replace(/\/$/, "").split("/").pop()?.replace(/\.git$/, "") || "git-api");
154
+ const limitFlag = args.indexOf("--limit");
155
+ const limit = limitFlag !== -1 ? Number(args[limitFlag + 1]) : undefined;
156
+ const pkgFlag = args.indexOf("--package");
157
+ const packageName = pkgFlag !== -1 ? args[pkgFlag + 1] : undefined;
158
+ const branchFlag = args.indexOf("--branch");
159
+ const branch = branchFlag !== -1 ? args[branchFlag + 1] : undefined;
160
+ if (!url) {
161
+ console.error("Usage: brewc fetch-git <git-url> [-o outDir] [--branch ref] [--limit N] [--package name]");
162
+ process.exit(1);
163
+ }
164
+ // brew.json maps of the installed @brew-types packages and of the sibling
165
+ // packages of outDir (e.g. packages/*): external refs (org.bukkit.World)
166
+ // are linked to the package providing them
167
+ const brewMap = (0, fetch_js_1.loadBrewMap)([
168
+ path.join(process.cwd(), "node_modules", "@brew-types"),
169
+ path.dirname(path.resolve(outDir)),
170
+ ]);
171
+ (0, fetchgit_js_1.fetchGitRepo)(url, outDir, {
172
+ branch,
173
+ limit: Number.isFinite(limit) ? limit : undefined,
174
+ packageName,
175
+ brewMap,
176
+ log: (msg) => console.log(msg),
177
+ })
178
+ .then((result) => {
179
+ console.log(`Wrote ${result.classes} interfaces to ${outDir}/`);
180
+ if (result.errors.length) {
181
+ console.log(`${result.errors.length} files failed:`);
182
+ for (const e of result.errors.slice(0, 10))
183
+ console.log(" " + e);
184
+ }
185
+ })
186
+ .catch((err) => {
187
+ console.error("Fetch error:", err.message);
188
+ process.exit(1);
189
+ });
190
+ skipTranspile = true;
191
+ }
192
+ if (args.includes("-h") || args.includes("--help")) {
193
+ console.log(HELP);
194
+ process.exit(0);
195
+ }
196
+ if (args.includes("-v") || args.includes("--version")) {
197
+ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8"));
198
+ console.log(pkg.version);
199
+ process.exit(0);
200
+ }
201
+ const inputFile = args.find((a) => !a.startsWith("-"));
202
+ const outFlag = args.indexOf("-o") !== -1 ? args.indexOf("-o") : args.indexOf("--output");
203
+ const outputFile = outFlag !== -1 ? args[outFlag + 1] : null;
204
+ if (!skipTranspile) {
205
+ // A typo'd subcommand flag (e.g. `--git-fetch` before it was an alias) used
206
+ // to fall through here and try to transpile its URL argument; reject unknown
207
+ // options and URL "input files" with a clear message instead.
208
+ const KNOWN_OPTIONS = new Set(["-o", "--output", "--obfuscate", "-h", "--help", "-v", "--version"]);
209
+ const unknownOptions = [];
210
+ for (let i = 0; i < args.length; i++) {
211
+ if (args[i] === "-o" || args[i] === "--output") {
212
+ i++;
213
+ continue;
214
+ } // skip the value
215
+ if (args[i].startsWith("-") && !KNOWN_OPTIONS.has(args[i]))
216
+ unknownOptions.push(args[i]);
217
+ }
218
+ if (unknownOptions.length) {
219
+ console.error(`brewc: unknown option${unknownOptions.length > 1 ? "s" : ""}: ${unknownOptions.join(", ")}`);
220
+ console.error(HELP);
221
+ process.exit(1);
222
+ }
223
+ if (!inputFile) {
224
+ console.error(HELP);
225
+ process.exit(1);
226
+ }
227
+ if (/^[a-z][\w+.-]*:\/\//i.test(inputFile)) {
228
+ console.error(`brewc: '${inputFile}' is a URL, not a local file.`);
229
+ console.error("To mirror an API instead, use one of:");
230
+ console.error(" brewc fetch <javadoc-url>");
231
+ console.error(" brewc fetch-javadoc <javadoc-base-url> [-o outDir]");
232
+ console.error(" brewc fetch-git <git-url> [-o outDir]");
233
+ process.exit(1);
234
+ }
235
+ try {
236
+ const source = fs.readFileSync(inputFile, "utf8");
237
+ const name = path.basename(inputFile, ".ts");
238
+ const skript = (0, transpiler_js_1.transpile)(source, name, {
239
+ importBase: path.dirname(inputFile),
240
+ obfuscate: args.includes("--obfuscate"),
241
+ });
242
+ if (outputFile) {
243
+ fs.mkdirSync(path.dirname(outputFile), { recursive: true });
244
+ fs.writeFileSync(outputFile, skript, "utf8");
245
+ console.log(`Wrote ${outputFile}`);
246
+ }
247
+ else {
248
+ process.stdout.write(skript);
249
+ }
250
+ }
251
+ catch (err) {
252
+ console.error("Transpile error:", err.message);
253
+ process.exit(1);
254
+ }
255
+ }
256
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;;;GAIG;AACH,uCAAyB;AACzB,2CAA6B;AAC7B,mDAA4C;AAC5C,yCAAsF;AACtF,+CAA6C;AAE7C,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BZ,CAAC;AAEF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,IAAI,aAAa,GAAG,KAAK,CAAC;AAE1B,2CAA2C;AAC3C,yEAAyE;AACzE,0DAA0D;AAC1D,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;IACjD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC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