@amxts/cli 0.1.0

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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +20 -0
  3. package/bin/amxts.mjs +8 -0
  4. package/package.json +45 -0
  5. package/src/args.mjs +62 -0
  6. package/src/catalog.mjs +196 -0
  7. package/src/config.mjs +191 -0
  8. package/src/core.mjs +272 -0
  9. package/src/includes.mjs +181 -0
  10. package/src/info.mjs +85 -0
  11. package/src/init-module.mjs +117 -0
  12. package/src/init.mjs +316 -0
  13. package/src/lint.mjs +26 -0
  14. package/src/main.mjs +273 -0
  15. package/src/module.mjs +150 -0
  16. package/src/modules.json +47 -0
  17. package/src/pm.mjs +111 -0
  18. package/src/server.mjs +72 -0
  19. package/src/system.mjs +32 -0
  20. package/src/template.mjs +74 -0
  21. package/src/ui.mjs +101 -0
  22. package/templates/module/LICENSE +21 -0
  23. package/templates/module/README.md +81 -0
  24. package/templates/module/README.ru.md +81 -0
  25. package/templates/module/_gitattributes +5 -0
  26. package/templates/module/_gitignore +11 -0
  27. package/templates/module/_oxfmtrc.json +18 -0
  28. package/templates/module/_oxlintrc.json +784 -0
  29. package/templates/module/assets/logo.svg +8 -0
  30. package/templates/module/playground/amxts.config.ts +4 -0
  31. package/templates/module/playground/plugins/welcome.ts +3 -0
  32. package/templates/module/playground/tsconfig.json +3 -0
  33. package/templates/module/src/index.ts +25 -0
  34. package/templates/module/src/natives.ts +13 -0
  35. package/templates/module/src/types.ts +11 -0
  36. package/templates/module/test/tsconfig.json +13 -0
  37. package/templates/module/test/{{name}}.test.ts +25 -0
  38. package/templates/module/tsconfig.json +10 -0
  39. package/templates/project/README.md +28 -0
  40. package/templates/project/_gitattributes +7 -0
  41. package/templates/project/_gitignore +7 -0
  42. package/templates/project/_oxfmtrc.json +18 -0
  43. package/templates/project/_oxlintrc.json +784 -0
  44. package/templates/project/_vscode/extensions.json +3 -0
  45. package/templates/project/_vscode/settings.json +13 -0
  46. package/templates/project/amxts.config.ts +24 -0
  47. package/templates/project/knip.json +4 -0
  48. package/templates/project/plugins/hello.ts +39 -0
  49. package/templates/project/test/hello.test.ts +37 -0
  50. package/templates/project/test/tsconfig.json +13 -0
  51. package/templates/project/tsconfig.json +3 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ "recommendations": ["amxts.amxts-vscode", "oxc.oxc-vscode", "redhat.vscode-yaml"]
3
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "files.insertFinalNewline": true,
3
+
4
+ "editor.formatOnSave": false,
5
+ "editor.codeActionsOnSave": {
6
+ "source.fixAll.oxc": "explicit",
7
+ "source.organizeImports": "never"
8
+ },
9
+ "[json][jsonc][yaml]": {
10
+ "editor.defaultFormatter": "oxc.oxc-vscode",
11
+ "editor.formatOnSave": true
12
+ }
13
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The project's config: the modules it uses and their options.
3
+ * About this file: https://amxts.github.io/docs/getting-started/quick-start#a-project
4
+ */
5
+ export default defineConfig({
6
+ /**
7
+ * The modules the plugins use. A module no plugin uses is left out of the
8
+ * build; one whose natives only Pawn plugins call stays with
9
+ * `pawn: ["@amxts/menu-core"]`.
10
+ */
11
+ modules: {{modules}},
12
+
13
+ /**
14
+ * The server the plugins are for: "rehlds" (ReHLDS, ReGameDLL, ReAPI) or "hlds".
15
+ * With AMXTS_SERVER the build takes that server's includes; without, amxts
16
+ * fetches this one's into .amxts/include.
17
+ */
18
+ target: "{{target}}",
19
+ // #if menu-core
20
+
21
+ // Where menu-core reads its menus - configs/menu.ini, .yaml or .json:
22
+ // menus: { file: "menu" },
23
+ // #endif
24
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "entry": ["plugins/**/*.ts", "amxts.config.ts", "test/**/*.ts"],
3
+ "project": ["**/*.ts"]
4
+ }
@@ -0,0 +1,39 @@
1
+ plugin({ name: "Hello", version: "1.0.0", author: "{{author}}", description: "The first plugin of {{name}}" });
2
+
3
+ // #if config-core
4
+ // configs/hello.yaml (or hello.json) says what a player is greeted with -
5
+ // "greeting: Hi" - and "Welcome" is what it is when the file does not say.
6
+ const { greeting } = configs.load("hello", { greeting: "Welcome" });
7
+ // #endif
8
+ // #if !config-core
9
+ const greeting = "Welcome";
10
+ // #endif
11
+
12
+ server.addCommand("/hp", sayHp);
13
+ server.addEventListener("putinserver", event => print(0, `${greeting}, ${event.player.name}!`));
14
+ // #if menu-core
15
+
16
+ // A menu made in code: its title and items can be functions of the player.
17
+ const hello = menus.create("HELLO", { title: player => `Hello, ${player.name}` });
18
+ hello.addItem("Wave", { onSelect: wave });
19
+ hello.addItem(player => `Heal (${player.health} HP)`, {
20
+ visible: player => player.health < 100,
21
+ onSelect: heal,
22
+ });
23
+
24
+ server.addCommand("/menu", player => hello.show(player));
25
+ // #endif
26
+
27
+ function sayHp(player: Player) {
28
+ print(player, `${player.name}, your HP: ${player.health}`);
29
+ }
30
+ // #if menu-core
31
+
32
+ function wave(player: Player) {
33
+ print(0, `${player.name} waves`);
34
+ }
35
+
36
+ function heal(player: Player) {
37
+ player.health = 100;
38
+ }
39
+ // #endif
@@ -0,0 +1,37 @@
1
+ import { expect, setDefaultTimeout, test } from "bun:test";
2
+ import { setup } from "@amxts/core/test-utils";
3
+ // #if menu-core
4
+ import { menusOf } from "@amxts/menu-core/testing";
5
+ // #endif
6
+
7
+ // The first run compiles the plugins; the next ones take them from the cache.
8
+ setDefaultTimeout(120_000);
9
+
10
+ test("a player who joins is greeted", async () => {
11
+ const server = await setup();
12
+ const alice = server.join("Alice");
13
+
14
+ expect(alice.chat).toContain("Welcome, Alice!");
15
+ });
16
+
17
+ test("/hp tells a player their health", async () => {
18
+ const server = await setup();
19
+ const alice = server.join("Alice", { health: 40 });
20
+
21
+ alice.say("/hp");
22
+ expect(alice.chat).toContain("Alice, your HP: 40");
23
+ });
24
+ // #if menu-core
25
+
26
+ test("/menu heals a hurt player", async () => {
27
+ const server = await setup();
28
+ const menus = menusOf(server);
29
+ const alice = server.join("Alice", { health: 40 });
30
+
31
+ alice.say("/menu");
32
+ expect(menus.screen(alice)!.text).toContain("Heal (40 HP)");
33
+
34
+ menus.press(alice, 2);
35
+ expect(alice.health).toBe(100);
36
+ });
37
+ // #endif
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2022"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "types": ["bun"],
8
+ "strict": true,
9
+ "noEmit": true,
10
+ "skipLibCheck": true
11
+ },
12
+ "include": ["./**/*.ts"]
13
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "./.amxts/tsconfig.json"
3
+ }