amxxpack 1.1.1 β†’ 1.3.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Hedgehog Fog
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # πŸ“¦ AMXXPack [![npm](https://img.shields.io/npm/v/amxxpack.svg)](https://www.npmjs.com/package/amxxpack)
1
+ # πŸ“¦ AMXXPack πŸ‡ΊπŸ‡¦ [![npm](https://img.shields.io/npm/v/amxxpack.svg)](https://www.npmjs.com/package/amxxpack)
2
2
  Simple build system and **CLI** for **AMX Mod X** projects.
3
3
 
4
- # πŸ“„ About
4
+ ## πŸ“„ About
5
5
 
6
6
  This system will be useful for projects with multiple plugins and assets. Using the command-line interface you can build entire project with a single command. It also supports hot rebuild to keep your plugins and assets up to date during the work.
7
7
 
@@ -47,8 +47,11 @@ npm install -g amxxpack
47
47
  - `amxxpack build` - command to build the project
48
48
  - `--watch` - flag to watch changes
49
49
  - `--config` - config file
50
+ - `--ignore` - ignore build errors
51
+ - `--no-cache` - disable caching
50
52
  - `amxxpack compile <path|glob>` - compile specific plugin in the project
51
53
  - `--config` - config file
54
+ - `--no-cache` - disable caching
52
55
  - `amxxpack new <script|lib|include> [name]` - create new file in the project workspace
53
56
  - `--config` - config file
54
57
  - `--name` - plugin name
@@ -61,3 +64,79 @@ npm install -g amxxpack
61
64
  - `amxpack n` - alias to `new` command
62
65
  - `amxpack b` - alias to `build` command
63
66
  - `amxpack c` - alias to `compile` command
67
+
68
+ ## 🦸 Advanced configuration
69
+
70
+ ### Thir-party dependencies
71
+ In case your project requires third-party modules you can specify a link to third-party archives and these archives will be downloaded and extracted to the third-party directory.
72
+ ```json
73
+ {
74
+ "thirdparty": {
75
+ "dir": "./.thirdparty",
76
+ "dependencies": [
77
+ {
78
+ "name": "somemodule",
79
+ "url": "https://website/somemodule-v100.zip"
80
+ }
81
+ ]
82
+ }
83
+ }
84
+ ```
85
+
86
+ configuration above will download `somemodule-v100.zip` archive and extract it to the `./.thirdparty/somemodule` directory then you can use thirparty files in your project. For example add thirparty directory to include list:
87
+ ```json
88
+ {
89
+ "include": [
90
+ "./.thirdparty/somemodule/include"
91
+ ]
92
+ }
93
+ ```
94
+
95
+ ### Multiple directories as an input
96
+ You can use multiple directories as builder inputs, just specify an array of directories in the project configuration. Example:
97
+
98
+ ```json
99
+ {
100
+ "input": {
101
+ "scripts": ["./src/scripts", "./src/extra-scripts"],
102
+ "include": ["./src/include", "./src/extra-include"],
103
+ "assets": ["./assets", "./extra-assets"]
104
+ }
105
+ }
106
+ ```
107
+
108
+ ### Assets filtering and subdirectories
109
+ Using glob filters you can specify which assets should be copied.
110
+
111
+ For example, you can exclude all assets except `*.mdl`:
112
+ ```json
113
+ {
114
+ "input": {
115
+ "assets": [
116
+ { "dir": "./assets", "filter": "*.mdl" }
117
+ ]
118
+ }
119
+ }
120
+ ```
121
+
122
+ or exclude `*.tga` and `*.wav` files:
123
+ ```json
124
+ {
125
+ "input": {
126
+ "assets": [
127
+ { "dir": "./assets", "filter": "*.!(tga|wav)" }
128
+ ]
129
+ }
130
+ }
131
+ ```
132
+
133
+ You can also specify subdirectories for copying. With this configuration the builder will copy all files from `./assets/models` to `./models/myproject` of the project build directory.
134
+ ```json
135
+ {
136
+ "input": {
137
+ "assets": [
138
+ { "dir": "./assets/models", "dest": "./models/myproject" }
139
+ ]
140
+ }
141
+ }
142
+ ```
@@ -90,9 +90,12 @@ function formatArgs(params, outPath) {
90
90
  }
91
91
  function compile(params) {
92
92
  var parsedPath = path_1.default.parse(params.path);
93
- var fileName = "".concat(parsedPath.name, ".").concat(PLUGIN_EXT);
94
- var dest = path_1.default.join(params.dest, fileName);
95
- mkdirp_1.default.sync(params.dest);
93
+ var dest = params.dest.endsWith(".".concat(PLUGIN_EXT))
94
+ ? params.dest
95
+ : path_1.default.join(params.dest, "".concat(parsedPath.name, ".").concat(PLUGIN_EXT));
96
+ var parsedDest = path_1.default.parse(dest);
97
+ var fileName = path_1.default.parse(dest).base;
98
+ mkdirp_1.default.sync(parsedDest.dir);
96
99
  return new Promise(function (resolve) {
97
100
  var output = (0, accumulator_1.default)();
98
101
  var done = function (error) {
@@ -1,21 +1,28 @@
1
- import { IProjectConfig } from '../types';
1
+ import { IAssetInput, IResolvedProjectConfig } from '../types';
2
+ export interface CompileOptions {
3
+ ignoreErrors?: boolean;
4
+ noCache?: boolean;
5
+ }
2
6
  export default class AmxxBuilder {
3
- private config;
4
- constructor(config: IProjectConfig);
5
- build(): Promise<void>;
6
- watch(): Promise<void>;
7
- buildSrc(): Promise<void>;
7
+ private projectConfig;
8
+ private pluginCache;
9
+ constructor(projectConfig: IResolvedProjectConfig);
10
+ build(compileOptions: CompileOptions): Promise<void>;
11
+ watch(compileOptions: CompileOptions): Promise<void>;
12
+ buildScripts(compileOptions: CompileOptions): Promise<boolean>;
8
13
  buildInclude(): Promise<void>;
9
14
  buildAssets(): Promise<void>;
10
- watchSrc(): Promise<void>;
15
+ watchScripts(compileOptions: CompileOptions): Promise<void>;
11
16
  watchInclude(): Promise<void>;
12
17
  watchAssets(): Promise<void>;
13
- updatePlugin(filePath: string): Promise<void>;
14
- updateScript(filePath: string): Promise<void>;
15
- updateAsset(filePath: string): Promise<void>;
18
+ updatePlugin(srcDir: string, srcFile: string, compileOptions: CompileOptions): Promise<boolean>;
19
+ updateScript(srcDir: string, srcFile: string): Promise<void>;
20
+ updateAsset(filePath: string, assetInput: IAssetInput): Promise<void>;
16
21
  updateInclude(filePath: string): Promise<void>;
17
22
  findPlugins(pattern: string): Promise<string[]>;
18
- compilePlugin(filePath: string): Promise<void>;
23
+ compilePlugin(srcDir: string, srcFile: string, compileOptions?: CompileOptions): Promise<void>;
19
24
  private buildDir;
20
25
  private watchDir;
26
+ private initPluginCache;
27
+ private execPathFilter;
21
28
  }