@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,8 @@
1
+ <svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="{{title}}">
2
+ <rect width="128" height="128" rx="28" fill="#15181D"/>
3
+ <!-- the amxts braces -->
4
+ <path d="M48 40C40 40 40 46 40 52C40 60 34 62 30 64C34 66 40 68 40 76C40 82 40 88 48 88" stroke="#F2C94C" stroke-width="8" stroke-linecap="round" stroke-linejoin="round"/>
5
+ <path d="M80 40C88 40 88 46 88 52C88 60 94 62 98 64C94 66 88 68 88 76C88 82 88 88 80 88" stroke="#F2C94C" stroke-width="8" stroke-linecap="round" stroke-linejoin="round"/>
6
+ <!-- the module's own sign: replace this square with yours -->
7
+ <rect x="53" y="53" width="22" height="22" rx="6" fill="#9AA3AE"/>
8
+ </svg>
@@ -0,0 +1,4 @@
1
+ export default defineConfig({
2
+ modules: ["{{package}}"],
3
+ {{configKey}}: { greeting: "Hi" },
4
+ });
@@ -0,0 +1,3 @@
1
+ plugin({ name: "Welcome", version: "0.1.0", author: "{{author}}", description: "Tries {{title}} out" });
2
+
3
+ server.addCommand("/hello", {{camel}}.greet);
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "./.amxts/tsconfig.json"
3
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * {{title}}: an amxts module. Its exports are its API - the plugins of a
3
+ * project that lists it use it as `{{camel}}`, without an import - and one
4
+ * instance of it runs on the server for all of them.
5
+ */
6
+ import { Player, print } from "@amxts/core";
7
+ import { {{Options}} } from "./types";
8
+
9
+ export * from "./types";
10
+
11
+ export default defineModule<{{Options}}>({
12
+ meta: { name: "{{name}}", configKey: "{{configKey}}" },
13
+ defaults: { greeting: "Hello" },
14
+ imports: [{ from: "{{package}}", as: "{{camel}}" }],
15
+ setup(options) {
16
+ greeting = options.greeting;
17
+ },
18
+ });
19
+
20
+ let greeting = "";
21
+
22
+ /** Greets the player in chat. */
23
+ export function greet(player: Player) {
24
+ print(player, `${greeting}, ${player.name}!`);
25
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * {{title}} for Pawn plugins: each `export function` here is a native, and
3
+ * `npx amxts build` writes include/{{include}}.inc from them.
4
+ */
5
+ import { Player, plugin } from "@amxts/core";
6
+ import * as {{camel}} from "./index";
7
+
8
+ plugin({ name: "{{title}}", version: "0.1.0", author: "{{author}}", description: "{{title}} for amxts" });
9
+
10
+ /** Greets the player in chat. */
11
+ export function {{include}}_greet(player: Player) {
12
+ {{camel}}.greet(player);
13
+ }
@@ -0,0 +1,11 @@
1
+ /** {{title}}'s options: `{{configKey}}` in a project's amxts.config.ts. */
2
+ export interface {{Options}} {
3
+ /** What a player is greeted with. */
4
+ greeting: string;
5
+ }
6
+
7
+ declare module "@amxts/core" {
8
+ interface ModuleOptions {
9
+ {{configKey}}?: Partial<{{Options}}>;
10
+ }
11
+ }
@@ -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,25 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { setup } from "@amxts/core/test-utils";
3
+
4
+ // The first test compiles the plugins; the next runs take them from the cache.
5
+ const TIMEOUT = 120_000;
6
+
7
+ describe("{{name}}", () => {
8
+ test("the playground's plugin greets whoever asks, with the playground's greeting", async () => {
9
+ const server = await setup({ rootDir: "playground" });
10
+ const alice = server.join("Alice");
11
+
12
+ alice.say("/hello");
13
+ expect(alice.chat).toContain("Hi, Alice!");
14
+ }, TIMEOUT);
15
+ // #if natives
16
+
17
+ test("a Pawn plugin greets through the native", async () => {
18
+ const server = await setup();
19
+ const bob = server.join("Bob");
20
+
21
+ server.native("{{include}}_greet", bob.id);
22
+ expect(bob.chat).toContain("Hello, Bob!");
23
+ }, TIMEOUT);
24
+ // #endif
25
+ });
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@amxts/core/as/tsconfig.json",
3
+ "compilerOptions": {
4
+ "paths": {
5
+ "~/*": ["./node_modules/@amxts/core/as/*"]
6
+ },
7
+ "noEmit": true
8
+ },
9
+ "include": ["src/**/*.ts"]
10
+ }
@@ -0,0 +1,28 @@
1
+ # {{name}}
2
+
3
+ Counter-Strike 1.6 plugins in TypeScript, built with [amxts](https://amxts.github.io/).
4
+
5
+ ## Commands
6
+
7
+ - `{{install}}` - installs the core, the modules and the tools
8
+ - `{{run.dev}}` - builds, deploys to the server in `AMXTS_SERVER` and again on every save
9
+ - `{{run.build}}` - builds the plugins into `dist/`, with `plugins.ini`
10
+ - `{{run.typecheck}}` - checks the plugins as the editor does
11
+ - `{{run.test}}` - runs the tests in `test/` on a fake server
12
+ <!-- #if lint -->
13
+ - `{{run.lint}}` - oxlint and oxfmt check the code; `lint:fix` fixes what they can
14
+ <!-- #endif -->
15
+ - `{{amxts}} module add <name>` - installs a module and lists it in `amxts.config.ts`
16
+
17
+ `AMXTS_SERVER` in `.env` is the `addons/amxts` folder of the server `dev`
18
+ deploys to:
19
+
20
+ ```sh
21
+ AMXTS_SERVER=D:/hlds/cstrike/addons/amxts
22
+ ```
23
+
24
+ ## Layout
25
+
26
+ - `plugins/` - the plugins: each `.ts` file here is one plugin on the server
27
+ - `amxts.config.ts` - the modules the project uses and their options
28
+ - `test/` - tests: the plugins on a fake server, driven as players would
@@ -0,0 +1,7 @@
1
+ # #if lint
2
+ # oxfmt writes LF: the files it formats keep LF when checked out on Windows too.
3
+ *.json text eol=lf
4
+ *.jsonc text eol=lf
5
+ *.yaml text eol=lf
6
+ *.yml text eol=lf
7
+ # #endif
@@ -0,0 +1,7 @@
1
+ node_modules/
2
+ # amxts prepare: the editor config tsconfig.json extends, the includes it fetches
3
+ .amxts/
4
+ # amxts build
5
+ dist/
6
+ # this machine's settings: AMXTS_SERVER
7
+ .env
@@ -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
+ }