@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,81 @@
1
+ <div align="center">
2
+
3
+ <img src="assets/logo.svg" width="96" alt="{{title}}">
4
+
5
+ # {{title}}
6
+
7
+ *What {{title}} does, in one line*
8
+
9
+ [![amxts module](https://img.shields.io/badge/amxts-module-3178c6?style=flat-square)](https://amxts.github.io/)
10
+ [![License](https://img.shields.io/badge/License-MIT-blue?style=flat-square)](LICENSE)
11
+
12
+ [Features](#features) • [Installation](#installation) • [Usage](#usage) • [Development](#development)
13
+
14
+ **English** | [Русский](README.ru.md)
15
+
16
+ </div>
17
+
18
+ {{title}} greets players — say here what your module does, for whom and why.
19
+
20
+ ## Features
21
+
22
+ - **Greets players.** `greet(player)` says hello in chat — replace this with what your module does.
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ npx amxts module add {{package}}
28
+ ```
29
+
30
+ It installs the package and adds it to your project's `amxts.config.ts`:
31
+
32
+ ```ts
33
+ export default defineConfig({
34
+ modules: ["{{package}}"],
35
+ {{configKey}}: {
36
+ greeting: "Hi",
37
+ },
38
+ });
39
+ ```
40
+
41
+ | Option | Default | What it does |
42
+ | --- | --- | --- |
43
+ | `greeting` | `"Hello"` | What a player is greeted with. |
44
+
45
+ ## Usage
46
+
47
+ A plugin of a project that lists the module uses it as `{{camel}}`, without an import:
48
+
49
+ ```ts
50
+ server.addCommand("/hello", {{camel}}.greet);
51
+ ```
52
+
53
+ | Function | What it does |
54
+ | --- | --- |
55
+ | `greet(player)` | Greets the player in chat. |
56
+
57
+ The module is built only for a project whose plugins use it.
58
+ <!-- #if natives -->
59
+
60
+ ## Pawn plugins
61
+
62
+ Pawn plugins call the module through its natives: `#include <{{include}}>` — the package ships `include/{{include}}.inc`. A project whose Pawn plugins call them keeps the module in the build when no TypeScript plugin uses it: `pawn: ["{{package}}"]` in `amxts.config.ts`.
63
+
64
+ ```pawn
65
+ #include <{{include}}>
66
+
67
+ public client_putinserver(id) {
68
+ {{include}}_greet(id);
69
+ }
70
+ ```
71
+ <!-- #endif -->
72
+
73
+ ## Development
74
+
75
+ ```bash
76
+ npm install
77
+ npm test # the tests in test/, on the playground project
78
+ npm run check # the package is ready to publish
79
+ ```
80
+
81
+ `playground/` is a project with the module in it: its `amxts.config.ts` lists the module, and `plugins/` has a plugin that uses it. `npx amxts build` there builds it for a server.
@@ -0,0 +1,81 @@
1
+ <div align="center">
2
+
3
+ <img src="assets/logo.svg" width="96" alt="{{title}}">
4
+
5
+ # {{title}}
6
+
7
+ *Что делает {{title}}, одной строкой*
8
+
9
+ [![amxts module](https://img.shields.io/badge/amxts-module-3178c6?style=flat-square)](https://amxts.github.io/)
10
+ [![License](https://img.shields.io/badge/License-MIT-blue?style=flat-square)](LICENSE)
11
+
12
+ [Возможности](#возможности) • [Установка](#установка) • [Использование](#использование) • [Разработка](#разработка)
13
+
14
+ [English](README.md) | **Русский**
15
+
16
+ </div>
17
+
18
+ {{title}} приветствует игроков — напишите здесь, что делает ваш модуль, для кого и зачем.
19
+
20
+ ## Возможности
21
+
22
+ - **Приветствует игроков.** `greet(player)` здоровается в чате — замените это тем, что делает ваш модуль.
23
+
24
+ ## Установка
25
+
26
+ ```bash
27
+ npx amxts module add {{package}}
28
+ ```
29
+
30
+ Команда ставит пакет и добавляет его в `amxts.config.ts` проекта:
31
+
32
+ ```ts
33
+ export default defineConfig({
34
+ modules: ["{{package}}"],
35
+ {{configKey}}: {
36
+ greeting: "Привет",
37
+ },
38
+ });
39
+ ```
40
+
41
+ | Настройка | По умолчанию | Что делает |
42
+ | --- | --- | --- |
43
+ | `greeting` | `"Hello"` | Чем приветствовать игрока. |
44
+
45
+ ## Использование
46
+
47
+ Плагин проекта, в котором модуль указан, пользуется им как `{{camel}}`, без импорта:
48
+
49
+ ```ts
50
+ server.addCommand("/hello", {{camel}}.greet);
51
+ ```
52
+
53
+ | Функция | Что делает |
54
+ | --- | --- |
55
+ | `greet(player)` | Приветствует игрока в чате. |
56
+
57
+ Модуль собирается только для проекта, плагины которого им пользуются.
58
+ <!-- #if natives -->
59
+
60
+ ## Pawn-плагины
61
+
62
+ Pawn-плагины обращаются к модулю через его нативы: `#include <{{include}}>` — пакет поставляет `include/{{include}}.inc`. Проект, Pawn-плагины которого их вызывают, оставляет модуль в сборке, даже когда им не пользуется ни один плагин на TypeScript: `pawn: ["{{package}}"]` в `amxts.config.ts`.
63
+
64
+ ```pawn
65
+ #include <{{include}}>
66
+
67
+ public client_putinserver(id) {
68
+ {{include}}_greet(id);
69
+ }
70
+ ```
71
+ <!-- #endif -->
72
+
73
+ ## Разработка
74
+
75
+ ```bash
76
+ npm install
77
+ npm test # тесты из test/ на проекте playground
78
+ npm run check # пакет готов к публикации
79
+ ```
80
+
81
+ `playground/` — проект с модулем: его `amxts.config.ts` перечисляет модуль, а в `plugins/` лежит плагин, который им пользуется. `npx amxts build` там собирает его для сервера.
@@ -0,0 +1,5 @@
1
+ # oxfmt writes LF: the files it formats keep LF when checked out on Windows too.
2
+ *.json text eol=lf
3
+ *.jsonc text eol=lf
4
+ *.yaml text eol=lf
5
+ *.yml text eol=lf
@@ -0,0 +1,11 @@
1
+ node_modules/
2
+ *.tgz
3
+ # amxts prepare: the editor config the playground extends
4
+ .amxts/
5
+ # amxts build
6
+ dist/
7
+ # a library: the consumer resolves its own versions
8
+ bun.lock
9
+ package-lock.json
10
+ pnpm-lock.yaml
11
+ yarn.lock
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "./node_modules/oxfmt/configuration_schema.json",
3
+ "useTabs": true,
4
+ "singleQuote": false,
5
+ "sortPackageJson": false,
6
+ "ignorePatterns": [
7
+ "**/*.ts",
8
+ "**/*.mts",
9
+ "**/*.cts",
10
+ "**/*.tsx",
11
+ "**/*.js",
12
+ "**/*.mjs",
13
+ "**/*.cjs",
14
+ "**/*.jsx",
15
+ "**/*.md",
16
+ "**/*.inc"
17
+ ]
18
+ }