amxxpack 1.5.0-beta.2 β 1.5.0-beta.3
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 +237 -19
- package/lib/builder/builder.d.ts +9 -8
- package/lib/builder/builder.js +105 -81
- package/lib/builder/cache.d.ts +41 -0
- package/lib/builder/cache.js +243 -0
- package/lib/builder/compiler.js +2 -2
- package/lib/builder/plugins-cache.d.ts +1 -1
- package/lib/builder/plugins-cache.js +1 -1
- package/lib/cli/controller.js +3 -3
- package/lib/cli/program.js +1 -2
- package/lib/cli/services/project-creator.js +11 -11
- package/lib/config/index.d.ts +1 -0
- package/lib/config/index.js +2 -0
- package/lib/downloaders/compiler/index.js +3 -3
- package/lib/downloaders/thirdparty/index.js +3 -2
- package/lib/logger/logger.js +1 -1
- package/lib/project-config/index.js +47 -19
- package/lib/types/index.d.ts +31 -23
- package/lib/types/index.js +4 -0
- package/lib/utils/setup-watch.js +1 -1
- package/package.json +2 -1
- package/resources/project-types/amxmodx-legacy.json +21 -0
- package/resources/project-types/amxmodx.json +21 -0
- package/resources/project-types/sourcemod.json +21 -0
package/README.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
# π¦ AMXXPack πΊπ¦
|
|
2
|
-
|
|
1
|
+
# π¦ AMXXPack πΊπ¦
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/amxxpack/v/beta)
|
|
4
|
+
[](https://github.com/Hedgefog/node-amxxpack/blob/master/LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/amxxpack/v/beta)
|
|
6
|
+
[](https://github.com/Hedgefog/node-amxxpack/issues)
|
|
7
|
+
[](https://libraries.io/npm/amxxpack)
|
|
8
|
+
[](https://github.com/Hedgefog/node-amxxpack/pulls)
|
|
9
|
+
|
|
10
|
+
Build system and **CLI** for **AMX Mod X** and **SourceMod** projects.
|
|
3
11
|
|
|
4
12
|
---
|
|
5
13
|
|
|
@@ -9,9 +17,16 @@ Simple build system and **CLI** for **AMX Mod X** projects.
|
|
|
9
17
|
- [Requirements](#-requirements)
|
|
10
18
|
- [Installation](#-installation)
|
|
11
19
|
- [Quick start](#-quick-start)
|
|
20
|
+
- [Examples](#-examples)
|
|
21
|
+
- [Basic Project Structure](#basic-project-structure)
|
|
22
|
+
- [Configuration Examples](#configuration-examples)
|
|
23
|
+
- [Development Workflow](#development-workflow-examples)
|
|
24
|
+
- [Integration Examples](#integration-examples)
|
|
12
25
|
- [Commands](#-commands)
|
|
13
26
|
- [Advanced configuration](#-advanced-configuration)
|
|
14
27
|
- [Using with SourceMod](#using-with-sourcemod)
|
|
28
|
+
- [Troubleshooting](#-troubleshooting)
|
|
29
|
+
- [Contributing](#-contributing)
|
|
15
30
|
- [License](#-license)
|
|
16
31
|
|
|
17
32
|
---
|
|
@@ -20,43 +35,61 @@ Simple build system and **CLI** for **AMX Mod X** projects.
|
|
|
20
35
|
|
|
21
36
|
This system will be useful for projects with multiple plugins and assets. Using the command-line interface you can build an entire project with a single command. It also supports hot rebuild to keep your plugins and assets up to date during the work.
|
|
22
37
|
|
|
38
|
+
Check out projects [built with **AMXXPack**](https://github.com/search?q=path%3A.amxxpack*.json&type=code)
|
|
39
|
+
|
|
23
40
|
---
|
|
24
41
|
|
|
25
42
|
## π Features
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
43
|
+
|
|
44
|
+
### π Build System
|
|
45
|
+
- β Flexible JSON-based configuration
|
|
46
|
+
- ποΈ Multi-plugin project support
|
|
47
|
+
- π Incremental builds with caching
|
|
48
|
+
- π― Selective plugin compilation
|
|
49
|
+
- π Support for multiple input directories
|
|
50
|
+
- π§ Customizable output structure
|
|
51
|
+
- π₯ Hot reload for rapid development
|
|
52
|
+
|
|
53
|
+
### π§© Plugin Development
|
|
54
|
+
- π Third-party dependencies management
|
|
55
|
+
- π₯ Automatic compiler downloads
|
|
56
|
+
- π Generating new files using CLI commands
|
|
57
|
+
- βοΈ Support for both **AMX Mod X** and **SourceMod**
|
|
58
|
+
|
|
59
|
+
### π§Έ Asset Management
|
|
60
|
+
- π Glob pattern filtering
|
|
29
61
|
|
|
30
62
|
---
|
|
31
63
|
|
|
32
|
-
## πRequirements
|
|
33
|
-
- Node.js
|
|
64
|
+
## π Requirements
|
|
65
|
+
- Node.js 16.0.0 or higher
|
|
34
66
|
|
|
35
67
|
---
|
|
36
68
|
|
|
37
69
|
## π§ Installation
|
|
38
70
|
**AMXXPack** is available through the npm registry.
|
|
39
|
-
Installation can be done using the `npm i amxxpack@
|
|
71
|
+
Installation can be done using the `npm i amxxpack@beta` command:
|
|
40
72
|
```
|
|
41
|
-
npm install amxxpack
|
|
73
|
+
npm install amxxpack@beta
|
|
42
74
|
```
|
|
43
75
|
|
|
44
76
|
or install it globally to use as a system command
|
|
45
77
|
```
|
|
46
|
-
npm install -g amxxpack
|
|
78
|
+
npm install -g amxxpack@beta
|
|
47
79
|
```
|
|
48
80
|
|
|
49
81
|
---
|
|
50
82
|
|
|
51
|
-
|
|
52
83
|
## βΆ Quick start
|
|
53
84
|
- Open a terminal inside the project directory (existing or create a new one)
|
|
54
|
-
- Execute `npm install amxxpack@
|
|
85
|
+
- Execute `npm install amxxpack@beta -g` command to install `amxxpack` globally
|
|
55
86
|
- Execute `amxxpack create .` command to create a new config
|
|
56
87
|
- Execute `amxxpack install` to download project dependencies (compiler, thirdparty etc.)
|
|
57
88
|
- Use `amxxpack build` command to build the project
|
|
58
89
|
- Use `amxxpack watch` command to build the project and watch changes
|
|
59
90
|
|
|
91
|
+
---
|
|
92
|
+
|
|
60
93
|
## π Commands
|
|
61
94
|
- `amxxpack create <name>` - create new project
|
|
62
95
|
- `--git` - initialize git
|
|
@@ -93,6 +126,161 @@ npm install -g amxxpack
|
|
|
93
126
|
|
|
94
127
|
---
|
|
95
128
|
|
|
129
|
+
## π Examples
|
|
130
|
+
|
|
131
|
+
### Basic Project Structure
|
|
132
|
+
|
|
133
|
+
Here's a typical **AMXXPack** project structure:
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
myproject/
|
|
137
|
+
βββ .thirdparty/ # Third-party dependencies
|
|
138
|
+
β
|
|
139
|
+
βββ assets/ # Game assets
|
|
140
|
+
β βββ models/
|
|
141
|
+
β βββ sounds/
|
|
142
|
+
β
|
|
143
|
+
βββ src/
|
|
144
|
+
β βββ scripts/ # Plugin source files
|
|
145
|
+
β β βββ plugin1.sma
|
|
146
|
+
β β βββ plugin2.sma
|
|
147
|
+
β βββ include/ # Include files
|
|
148
|
+
β βββ constants.inc
|
|
149
|
+
β βββ stocks.inc
|
|
150
|
+
β
|
|
151
|
+
βββ .amxxpack.json # Project configuration
|
|
152
|
+
βββ package.json # NPM configuration
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Configuration Examples
|
|
156
|
+
|
|
157
|
+
#### Basic Configuration
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"type": "amxmodx",
|
|
161
|
+
"compiler": {
|
|
162
|
+
"version": "1.9",
|
|
163
|
+
"addons": ["cstrike"]
|
|
164
|
+
},
|
|
165
|
+
"input": {
|
|
166
|
+
"scripts": "./src/scripts",
|
|
167
|
+
"include": "./src/include",
|
|
168
|
+
"assets": "./assets"
|
|
169
|
+
},
|
|
170
|
+
"output": {
|
|
171
|
+
"base": "./dist",
|
|
172
|
+
"plugins": "./addons/amxmodx/plugins",
|
|
173
|
+
"scripts": "./addons/amxmodx/scripting",
|
|
174
|
+
"include": "./addons/amxmodx/scripting/include",
|
|
175
|
+
"assets": "."
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### Advanced Configuration with Third-party Dependencies
|
|
181
|
+
```json
|
|
182
|
+
{
|
|
183
|
+
"type": "amxmodx",
|
|
184
|
+
"compiler": {
|
|
185
|
+
"version": "1.9",
|
|
186
|
+
"addons": ["cstrike"]
|
|
187
|
+
},
|
|
188
|
+
"thirdparty": {
|
|
189
|
+
"dependencies": [
|
|
190
|
+
{ "name": "somemodule", "url": "https://website/somemodule-v100.zip" }
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
"include": [
|
|
194
|
+
"./.compiler/include",
|
|
195
|
+
"./.thirdparty/somemodule/include"
|
|
196
|
+
],
|
|
197
|
+
"input": {
|
|
198
|
+
"scripts": [
|
|
199
|
+
{ "dir": "./src/scripts", "output": { "prefix": "mymod_" } },
|
|
200
|
+
{ "dir": "./somemodule/scripts" }
|
|
201
|
+
],
|
|
202
|
+
"include": ["./src/include"],
|
|
203
|
+
"assets": [
|
|
204
|
+
{ "dir": "./assets" },
|
|
205
|
+
{ "dir": "./somemodule/models", "output": { "dest": "./models" } }
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
"output": {
|
|
209
|
+
"base": "./dist",
|
|
210
|
+
"plugins": "./addons/amxmodx/plugins",
|
|
211
|
+
"scripts": "./addons/amxmodx/scripting",
|
|
212
|
+
"include": "./addons/amxmodx/scripting/include",
|
|
213
|
+
"assets": "."
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Development Workflow Examples
|
|
219
|
+
|
|
220
|
+
1. **Starting a New Project**
|
|
221
|
+
```bash
|
|
222
|
+
# Create a new directory
|
|
223
|
+
mkdir myproject
|
|
224
|
+
cd myproject
|
|
225
|
+
|
|
226
|
+
# Initialize the project
|
|
227
|
+
amxxpack create . --git --type amxmodx
|
|
228
|
+
|
|
229
|
+
# Install dependencies
|
|
230
|
+
amxxpack install
|
|
231
|
+
|
|
232
|
+
# Generate a new plugin
|
|
233
|
+
amxxpack generate script mymod_core --author "Your Name" --version "1.0.0"
|
|
234
|
+
|
|
235
|
+
# Start development with hot reload
|
|
236
|
+
amxxpack build --watch
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
2. **Working with Multiple Plugins**
|
|
240
|
+
```bash
|
|
241
|
+
# Compile specific plugins
|
|
242
|
+
amxxpack compile "mymod_core.sma"
|
|
243
|
+
amxxpack compile "mymod_*.sma"
|
|
244
|
+
amxxpack compile "features/*.sma"
|
|
245
|
+
|
|
246
|
+
# Build entire project
|
|
247
|
+
amxxpack build
|
|
248
|
+
|
|
249
|
+
# Watch for changes
|
|
250
|
+
amxxpack build --watch
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
3. **Using with Version Control**
|
|
254
|
+
```bash
|
|
255
|
+
# Typical .gitignore entries
|
|
256
|
+
node_modules/
|
|
257
|
+
.compiler/
|
|
258
|
+
.thirdparty/
|
|
259
|
+
dist/
|
|
260
|
+
*.amxx
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Integration Examples
|
|
264
|
+
|
|
265
|
+
1. **CI/CD Pipeline (GitHub Actions)**
|
|
266
|
+
```yaml
|
|
267
|
+
name: Build
|
|
268
|
+
|
|
269
|
+
on: [push, pull_request]
|
|
270
|
+
|
|
271
|
+
jobs:
|
|
272
|
+
build:
|
|
273
|
+
runs-on: ubuntu-latest
|
|
274
|
+
steps:
|
|
275
|
+
- uses: actions/checkout@v5
|
|
276
|
+
- uses: actions/setup-node@v5
|
|
277
|
+
with:
|
|
278
|
+
node-version: '22'
|
|
279
|
+
- run: npm install -g amxxpack@beta
|
|
280
|
+
- run: amxxpack install
|
|
281
|
+
- run: amxxpack build
|
|
282
|
+
```
|
|
283
|
+
|
|
96
284
|
## π¦Έ Advanced configuration
|
|
97
285
|
|
|
98
286
|
### Third-party dependencies
|
|
@@ -174,16 +362,28 @@ You can use multiple directories as builder inputs, just specify an array of dir
|
|
|
174
362
|
}
|
|
175
363
|
```
|
|
176
364
|
|
|
177
|
-
###
|
|
178
|
-
You can specify additional options for the input directories.
|
|
365
|
+
### Configuring input and output
|
|
366
|
+
You can specify additional output options for the input directories.
|
|
367
|
+
Output options can be specified in the input configuration or in the output configuration. Specifying options in the input configuration will override output configuration for specific input.
|
|
179
368
|
|
|
180
369
|
#### Flat compilation
|
|
181
|
-
`flat` option is used to specify if the
|
|
370
|
+
`flat` option is used to specify if the input directory should be copied using a flat directory structure.
|
|
371
|
+
By default only `assets` are compiled without a flat directory structure.
|
|
182
372
|
|
|
183
373
|
```json
|
|
184
374
|
{
|
|
185
375
|
"input": {
|
|
186
|
-
"scripts": ["./src/scripts", { "dir": "./src/scripts", "flat": false }]
|
|
376
|
+
"scripts": ["./src/scripts", { "dir": "./src/scripts", "output": { "flat": false } }]
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
Same option can be specified for the output directories:
|
|
382
|
+
|
|
383
|
+
```json
|
|
384
|
+
{
|
|
385
|
+
"output": {
|
|
386
|
+
"scripts": { "dir": "./dist/scripts", "flat": false }
|
|
187
387
|
}
|
|
188
388
|
}
|
|
189
389
|
```
|
|
@@ -194,7 +394,16 @@ You can specify additional options for the input directories.
|
|
|
194
394
|
```json
|
|
195
395
|
{
|
|
196
396
|
"input": {
|
|
197
|
-
"scripts": ["./src/scripts", { "dir": "./src/scripts", "prefix": "test_" }]
|
|
397
|
+
"scripts": ["./src/scripts", { "dir": "./src/scripts", "output": { "prefix": "test_" } }]
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
For output directories:
|
|
403
|
+
```json
|
|
404
|
+
{
|
|
405
|
+
"output": {
|
|
406
|
+
"scripts": { "dir": "./dist/scripts", "prefix": "test_" }
|
|
198
407
|
}
|
|
199
408
|
}
|
|
200
409
|
```
|
|
@@ -206,7 +415,16 @@ You can specify additional options for the input directories.
|
|
|
206
415
|
```json
|
|
207
416
|
{
|
|
208
417
|
"input": {
|
|
209
|
-
"scripts": ["./src/scripts", { "dir": "./src/scripts", "dest": "sub" }]
|
|
418
|
+
"scripts": ["./src/scripts", { "dir": "./src/scripts", "output": { "dest": "sub" } }]
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
For output directories:
|
|
424
|
+
```json
|
|
425
|
+
{
|
|
426
|
+
"output": {
|
|
427
|
+
"scripts": { "dir": "./dist/scripts", "dest": "sub" }
|
|
210
428
|
}
|
|
211
429
|
}
|
|
212
430
|
```
|
|
@@ -292,7 +510,7 @@ If you use **SourceMod** with **AMXXPack** you should set `type` to `sourcemod`
|
|
|
292
510
|
{
|
|
293
511
|
"type": "sourcemod",
|
|
294
512
|
"compiler": {
|
|
295
|
-
"version": "1.12
|
|
513
|
+
"version": "1.12",
|
|
296
514
|
}
|
|
297
515
|
}
|
|
298
516
|
```
|
package/lib/builder/builder.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IResolvedInput, IResolvedProjectConfig } from '../types';
|
|
2
2
|
export interface IBuildOptions {
|
|
3
3
|
noCache?: boolean;
|
|
4
4
|
ignoreErrors?: boolean;
|
|
@@ -6,7 +6,7 @@ export interface IBuildOptions {
|
|
|
6
6
|
export default class AmxxBuilder {
|
|
7
7
|
private projectConfig;
|
|
8
8
|
private options;
|
|
9
|
-
private
|
|
9
|
+
private cache;
|
|
10
10
|
private scriptsPathPattern;
|
|
11
11
|
private includePathPattern;
|
|
12
12
|
private assetsPathPattern;
|
|
@@ -22,15 +22,16 @@ export default class AmxxBuilder {
|
|
|
22
22
|
watchScripts(): Promise<void>;
|
|
23
23
|
watchInclude(): Promise<void>;
|
|
24
24
|
watchAssets(): Promise<void>;
|
|
25
|
-
updateScript(srcPath: string): Promise<boolean>;
|
|
26
|
-
updateAsset(filePath: string,
|
|
27
|
-
updateInclude(filePath: string): Promise<boolean>;
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
updateScript(srcPath: string, options: IResolvedInput): Promise<boolean>;
|
|
26
|
+
updateAsset(filePath: string, options: IResolvedInput): Promise<boolean>;
|
|
27
|
+
updateInclude(filePath: string, input: IResolvedInput): Promise<boolean>;
|
|
28
|
+
updatePlugin(srcPath: string, options: IResolvedInput): Promise<boolean>;
|
|
29
|
+
compileScript(srcPath: string, options: IResolvedInput): Promise<boolean>;
|
|
30
30
|
private buildDir;
|
|
31
31
|
private watchDir;
|
|
32
|
-
private
|
|
32
|
+
private initCache;
|
|
33
33
|
private getNativeIncludes;
|
|
34
34
|
private execPathFilter;
|
|
35
35
|
private getScriptOptions;
|
|
36
|
+
private resolveDestPath;
|
|
36
37
|
}
|