amxxpack 0.1.2 → 1.0.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/README.md +26 -21
- package/lib/builder/amxxpc.d.ts +27 -27
- package/lib/builder/amxxpc.js +122 -122
- package/lib/builder/builder.d.ts +21 -22
- package/lib/builder/builder.js +379 -400
- package/lib/builder/constants.d.ts +3 -3
- package/lib/builder/constants.js +6 -6
- package/lib/builder/index.d.ts +1 -2
- package/lib/builder/index.js +9 -20
- package/lib/cli/controller.d.ts +20 -16
- package/lib/cli/controller.js +238 -181
- package/lib/cli/index.d.ts +3 -2
- package/lib/cli/index.js +13 -8
- package/lib/cli/program.d.ts +4 -4
- package/lib/cli/program.js +174 -118
- package/lib/cli/services/project-creator.d.ts +21 -0
- package/lib/cli/services/project-creator.js +274 -0
- package/lib/cli/services/template-builder.d.ts +11 -0
- package/lib/cli/services/template-builder.js +104 -0
- package/lib/cli/types.d.ts +12 -0
- package/lib/{compiler-downloader → cli}/types.js +2 -2
- package/lib/config/index.d.ts +8 -0
- package/lib/config/index.js +14 -0
- package/lib/downloaders/compiler/constants.d.ts +9 -0
- package/lib/{compiler-downloader → downloaders/compiler}/constants.js +14 -17
- package/lib/downloaders/compiler/downloader.d.ts +3 -0
- package/lib/{compiler-downloader → downloaders/compiler}/downloader.js +151 -174
- package/lib/{compiler-downloader → downloaders/compiler}/index.d.ts +1 -1
- package/lib/{compiler-downloader → downloaders/compiler}/index.js +9 -9
- package/lib/{compiler-downloader → downloaders/compiler}/resolvers.d.ts +6 -6
- package/lib/{compiler-downloader → downloaders/compiler}/resolvers.js +40 -39
- package/lib/{compiler-downloader → downloaders/compiler}/types.d.ts +16 -16
- package/lib/{builder → downloaders/compiler}/types.js +2 -2
- package/lib/downloaders/thirdparty/downloader.d.ts +3 -0
- package/lib/downloaders/thirdparty/downloader.js +69 -0
- package/lib/downloaders/thirdparty/index.d.ts +1 -0
- package/lib/downloaders/thirdparty/index.js +9 -0
- package/lib/downloaders/thirdparty/types.d.ts +5 -0
- package/lib/downloaders/thirdparty/types.js +2 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +20 -20
- package/lib/logger/constants.d.ts +7 -0
- package/lib/logger/constants.js +12 -0
- package/lib/{services → logger}/logger.d.ts +16 -22
- package/lib/{services → logger}/logger.js +96 -104
- package/lib/logger/types.d.ts +3 -0
- package/lib/logger/types.js +2 -0
- package/lib/project-config/defaults.d.ts +3 -0
- package/lib/project-config/defaults.js +38 -0
- package/lib/project-config/index.d.ts +6 -0
- package/lib/project-config/index.js +8 -0
- package/lib/project-config/resolve.d.ts +3 -0
- package/lib/project-config/resolve.js +110 -0
- package/lib/types/index.d.ts +45 -0
- package/lib/types/index.js +2 -0
- package/lib/utils/accumulator.d.ts +2 -1
- package/lib/utils/accumulator.js +10 -10
- package/lib/utils/download.d.ts +6 -0
- package/lib/utils/download.js +63 -0
- package/package.json +7 -1
- package/resources/templates/include-directive.txt +1 -0
- package/resources/templates/include.txt +5 -0
- package/resources/templates/library-include.txt +6 -0
- package/resources/templates/library-script.txt +10 -0
- package/resources/templates/script.txt +5 -0
- package/lib/builder/types.d.ts +0 -20
- package/lib/compiler-downloader/constants.d.ts +0 -12
- package/lib/compiler-downloader/downloader.d.ts +0 -2
- package/resources/default-config.json +0 -22
package/lib/builder/builder.js
CHANGED
|
@@ -1,400 +1,379 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
31
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
32
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
33
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
34
|
-
function step(op) {
|
|
35
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
36
|
-
while (_) try {
|
|
37
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
38
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
39
|
-
switch (op[0]) {
|
|
40
|
-
case 0: case 1: t = op; break;
|
|
41
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
42
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
43
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
44
|
-
default:
|
|
45
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
46
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
47
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
48
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
49
|
-
if (t[2]) _.ops.pop();
|
|
50
|
-
_.trys.pop(); continue;
|
|
51
|
-
}
|
|
52
|
-
op = body.call(thisArg, _);
|
|
53
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
54
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
58
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
59
|
-
if (ar || !(i in from)) {
|
|
60
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
61
|
-
ar[i] = from[i];
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
65
|
-
};
|
|
66
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
67
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
68
|
-
};
|
|
69
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
-
var path_1 = __importDefault(require("path"));
|
|
71
|
-
var fs_1 = __importDefault(require("fs"));
|
|
72
|
-
var mkdirp_1 = __importDefault(require("mkdirp"));
|
|
73
|
-
var glob_promise_1 = __importDefault(require("glob-promise"));
|
|
74
|
-
var chokidar_1 = __importDefault(require("chokidar"));
|
|
75
|
-
var normalize_path_1 = __importDefault(require("normalize-path"));
|
|
76
|
-
var
|
|
77
|
-
var
|
|
78
|
-
var logger_1 = __importDefault(require("../
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
this
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
case
|
|
110
|
-
|
|
111
|
-
return [4 /*yield*/, this.
|
|
112
|
-
case
|
|
113
|
-
_a.sent();
|
|
114
|
-
return [4 /*yield*/, this.
|
|
115
|
-
case
|
|
116
|
-
_a.sent();
|
|
117
|
-
return [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
case
|
|
228
|
-
_a.sent();
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return [
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
return [4 /*yield*/, (0,
|
|
306
|
-
case 1:
|
|
307
|
-
|
|
308
|
-
return [
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
});
|
|
383
|
-
};
|
|
384
|
-
AmxxBuilder.prototype.watchDir = function (baseDir, pattern, cb) {
|
|
385
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
386
|
-
var pathPattern, watcher, updateFn;
|
|
387
|
-
var _this = this;
|
|
388
|
-
return __generator(this, function (_a) {
|
|
389
|
-
pathPattern = path_1.default.join(baseDir, pattern);
|
|
390
|
-
watcher = chokidar_1.default.watch(pathPattern, { ignoreInitial: true });
|
|
391
|
-
updateFn = function (filePath) { return cb(filePath).catch(function (err) { return _this.logger.error(err.message); }); };
|
|
392
|
-
watcher.on('add', updateFn);
|
|
393
|
-
watcher.on('change', updateFn);
|
|
394
|
-
return [2 /*return*/];
|
|
395
|
-
});
|
|
396
|
-
});
|
|
397
|
-
};
|
|
398
|
-
return AmxxBuilder;
|
|
399
|
-
}());
|
|
400
|
-
exports.default = AmxxBuilder;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
31
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
32
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
33
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
34
|
+
function step(op) {
|
|
35
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
36
|
+
while (_) try {
|
|
37
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
38
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
39
|
+
switch (op[0]) {
|
|
40
|
+
case 0: case 1: t = op; break;
|
|
41
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
42
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
43
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
44
|
+
default:
|
|
45
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
46
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
47
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
48
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
49
|
+
if (t[2]) _.ops.pop();
|
|
50
|
+
_.trys.pop(); continue;
|
|
51
|
+
}
|
|
52
|
+
op = body.call(thisArg, _);
|
|
53
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
54
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
58
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
59
|
+
if (ar || !(i in from)) {
|
|
60
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
61
|
+
ar[i] = from[i];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
65
|
+
};
|
|
66
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
67
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
68
|
+
};
|
|
69
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
+
var path_1 = __importDefault(require("path"));
|
|
71
|
+
var fs_1 = __importDefault(require("fs"));
|
|
72
|
+
var mkdirp_1 = __importDefault(require("mkdirp"));
|
|
73
|
+
var glob_promise_1 = __importDefault(require("glob-promise"));
|
|
74
|
+
var chokidar_1 = __importDefault(require("chokidar"));
|
|
75
|
+
var normalize_path_1 = __importDefault(require("normalize-path"));
|
|
76
|
+
var amxxpc_1 = __importStar(require("./amxxpc"));
|
|
77
|
+
var constants_1 = require("./constants");
|
|
78
|
+
var logger_1 = __importDefault(require("../logger/logger"));
|
|
79
|
+
var AmxxBuilder = /** @class */ (function () {
|
|
80
|
+
function AmxxBuilder(config) {
|
|
81
|
+
this.config = config;
|
|
82
|
+
}
|
|
83
|
+
AmxxBuilder.prototype.build = function () {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
logger_1.default.info('Building...');
|
|
89
|
+
return [4 /*yield*/, this.buildAssets()];
|
|
90
|
+
case 1:
|
|
91
|
+
_a.sent();
|
|
92
|
+
return [4 /*yield*/, this.buildInclude()];
|
|
93
|
+
case 2:
|
|
94
|
+
_a.sent();
|
|
95
|
+
return [4 /*yield*/, this.buildSrc()];
|
|
96
|
+
case 3:
|
|
97
|
+
_a.sent();
|
|
98
|
+
logger_1.default.success('Build finished!');
|
|
99
|
+
return [2 /*return*/];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
AmxxBuilder.prototype.watch = function () {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
+
return __generator(this, function (_a) {
|
|
107
|
+
switch (_a.label) {
|
|
108
|
+
case 0: return [4 /*yield*/, this.watchAssets()];
|
|
109
|
+
case 1:
|
|
110
|
+
_a.sent();
|
|
111
|
+
return [4 /*yield*/, this.watchInclude()];
|
|
112
|
+
case 2:
|
|
113
|
+
_a.sent();
|
|
114
|
+
return [4 /*yield*/, this.watchSrc()];
|
|
115
|
+
case 3:
|
|
116
|
+
_a.sent();
|
|
117
|
+
return [2 /*return*/];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
AmxxBuilder.prototype.buildSrc = function () {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
124
|
+
var _this = this;
|
|
125
|
+
return __generator(this, function (_a) {
|
|
126
|
+
switch (_a.label) {
|
|
127
|
+
case 0: return [4 /*yield*/, this.buildDir(this.config.input.scripts, constants_1.SCRIPTS_PATH_PATTERN, function (filePath) { return _this.updatePlugin(filePath); })];
|
|
128
|
+
case 1:
|
|
129
|
+
_a.sent();
|
|
130
|
+
return [2 /*return*/];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
AmxxBuilder.prototype.buildInclude = function () {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
+
var _this = this;
|
|
138
|
+
return __generator(this, function (_a) {
|
|
139
|
+
switch (_a.label) {
|
|
140
|
+
case 0: return [4 /*yield*/, this.buildDir(this.config.input.include, constants_1.INCLUDE_PATH_PATTERN, function (filePath) { return _this.updateInclude(filePath); })];
|
|
141
|
+
case 1:
|
|
142
|
+
_a.sent();
|
|
143
|
+
return [2 /*return*/];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
AmxxBuilder.prototype.buildAssets = function () {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
150
|
+
var _this = this;
|
|
151
|
+
return __generator(this, function (_a) {
|
|
152
|
+
switch (_a.label) {
|
|
153
|
+
case 0: return [4 /*yield*/, this.buildDir(this.config.input.assets, constants_1.ASSETS_PATH_PATTERN, function (filePath) { return _this.updateAsset(filePath); })];
|
|
154
|
+
case 1:
|
|
155
|
+
_a.sent();
|
|
156
|
+
return [2 /*return*/];
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
AmxxBuilder.prototype.watchSrc = function () {
|
|
162
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
163
|
+
var _this = this;
|
|
164
|
+
return __generator(this, function (_a) {
|
|
165
|
+
switch (_a.label) {
|
|
166
|
+
case 0: return [4 /*yield*/, this.watchDir(this.config.input.scripts, constants_1.SCRIPTS_PATH_PATTERN, function (filePath) { return _this.updatePlugin(filePath); })];
|
|
167
|
+
case 1:
|
|
168
|
+
_a.sent();
|
|
169
|
+
return [2 /*return*/];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
AmxxBuilder.prototype.watchInclude = function () {
|
|
175
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176
|
+
var _this = this;
|
|
177
|
+
return __generator(this, function (_a) {
|
|
178
|
+
switch (_a.label) {
|
|
179
|
+
case 0: return [4 /*yield*/, this.watchDir(this.config.input.include, constants_1.INCLUDE_PATH_PATTERN, function (filePath) { return _this.updateInclude(filePath); })];
|
|
180
|
+
case 1:
|
|
181
|
+
_a.sent();
|
|
182
|
+
return [2 /*return*/];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
AmxxBuilder.prototype.watchAssets = function () {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
189
|
+
var _this = this;
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
switch (_a.label) {
|
|
192
|
+
case 0: return [4 /*yield*/, this.watchDir(this.config.input.assets, constants_1.ASSETS_PATH_PATTERN, function (filePath) { return _this.updateAsset(filePath); })];
|
|
193
|
+
case 1:
|
|
194
|
+
_a.sent();
|
|
195
|
+
return [2 /*return*/];
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
AmxxBuilder.prototype.updatePlugin = function (filePath) {
|
|
201
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
202
|
+
return __generator(this, function (_a) {
|
|
203
|
+
switch (_a.label) {
|
|
204
|
+
case 0: return [4 /*yield*/, this.updateScript(filePath)];
|
|
205
|
+
case 1:
|
|
206
|
+
_a.sent();
|
|
207
|
+
return [4 /*yield*/, this.compilePlugin(filePath)];
|
|
208
|
+
case 2:
|
|
209
|
+
_a.sent();
|
|
210
|
+
return [2 /*return*/];
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
AmxxBuilder.prototype.updateScript = function (filePath) {
|
|
216
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
217
|
+
var srcPath, destPath;
|
|
218
|
+
return __generator(this, function (_a) {
|
|
219
|
+
switch (_a.label) {
|
|
220
|
+
case 0:
|
|
221
|
+
srcPath = path_1.default.resolve(filePath);
|
|
222
|
+
destPath = path_1.default.join(this.config.output.scripts, path_1.default.parse(filePath).base);
|
|
223
|
+
return [4 /*yield*/, (0, mkdirp_1.default)(this.config.output.scripts)];
|
|
224
|
+
case 1:
|
|
225
|
+
_a.sent();
|
|
226
|
+
return [4 /*yield*/, fs_1.default.promises.copyFile(srcPath, destPath)];
|
|
227
|
+
case 2:
|
|
228
|
+
_a.sent();
|
|
229
|
+
logger_1.default.info('Script updated:', (0, normalize_path_1.default)(destPath));
|
|
230
|
+
return [2 /*return*/];
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
AmxxBuilder.prototype.updateAsset = function (filePath) {
|
|
236
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
237
|
+
var srcPath, relativePath, destPath;
|
|
238
|
+
return __generator(this, function (_a) {
|
|
239
|
+
switch (_a.label) {
|
|
240
|
+
case 0:
|
|
241
|
+
srcPath = path_1.default.resolve(filePath);
|
|
242
|
+
relativePath = path_1.default.relative(this.config.input.assets, filePath);
|
|
243
|
+
destPath = path_1.default.join(this.config.output.assets, relativePath);
|
|
244
|
+
return [4 /*yield*/, (0, mkdirp_1.default)(path_1.default.parse(destPath).dir)];
|
|
245
|
+
case 1:
|
|
246
|
+
_a.sent();
|
|
247
|
+
return [4 /*yield*/, fs_1.default.promises.copyFile(srcPath, destPath)];
|
|
248
|
+
case 2:
|
|
249
|
+
_a.sent();
|
|
250
|
+
logger_1.default.info('Asset updated', (0, normalize_path_1.default)(destPath));
|
|
251
|
+
return [2 /*return*/];
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
AmxxBuilder.prototype.updateInclude = function (filePath) {
|
|
257
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
258
|
+
var srcPath, destPath;
|
|
259
|
+
return __generator(this, function (_a) {
|
|
260
|
+
switch (_a.label) {
|
|
261
|
+
case 0:
|
|
262
|
+
srcPath = path_1.default.resolve(filePath);
|
|
263
|
+
destPath = path_1.default.join(this.config.output.include, path_1.default.parse(filePath).base);
|
|
264
|
+
return [4 /*yield*/, (0, mkdirp_1.default)(this.config.output.include)];
|
|
265
|
+
case 1:
|
|
266
|
+
_a.sent();
|
|
267
|
+
return [4 /*yield*/, fs_1.default.promises.copyFile(srcPath, destPath)];
|
|
268
|
+
case 2:
|
|
269
|
+
_a.sent();
|
|
270
|
+
logger_1.default.info('Include updated:', (0, normalize_path_1.default)(destPath));
|
|
271
|
+
return [2 /*return*/];
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
AmxxBuilder.prototype.findPlugins = function (pattern) {
|
|
277
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
278
|
+
var pathPattern, matches;
|
|
279
|
+
return __generator(this, function (_a) {
|
|
280
|
+
switch (_a.label) {
|
|
281
|
+
case 0:
|
|
282
|
+
pathPattern = path_1.default.join(this.config.input.scripts, '**', pattern);
|
|
283
|
+
return [4 /*yield*/, (0, glob_promise_1.default)(pathPattern)];
|
|
284
|
+
case 1:
|
|
285
|
+
matches = _a.sent();
|
|
286
|
+
return [2 /*return*/, matches];
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
AmxxBuilder.prototype.compilePlugin = function (filePath) {
|
|
292
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
293
|
+
var srcPath, destDir, srcDir, relateiveSrcPath, executable, result, destPath, relativeFilePath;
|
|
294
|
+
return __generator(this, function (_a) {
|
|
295
|
+
switch (_a.label) {
|
|
296
|
+
case 0:
|
|
297
|
+
srcPath = path_1.default.resolve(filePath);
|
|
298
|
+
destDir = path_1.default.resolve(this.config.output.plugins);
|
|
299
|
+
if (!this.config.rules.flatCompilation) {
|
|
300
|
+
srcDir = path_1.default.parse(srcPath).dir;
|
|
301
|
+
destDir = path_1.default.join(destDir, path_1.default.relative(this.config.input.scripts, srcDir));
|
|
302
|
+
}
|
|
303
|
+
relateiveSrcPath = path_1.default.relative(process.cwd(), srcPath);
|
|
304
|
+
executable = path_1.default.join(this.config.compiler.dir, this.config.compiler.executable);
|
|
305
|
+
return [4 /*yield*/, (0, mkdirp_1.default)(destDir)];
|
|
306
|
+
case 1:
|
|
307
|
+
_a.sent();
|
|
308
|
+
return [4 /*yield*/, (0, amxxpc_1.default)({
|
|
309
|
+
path: srcPath,
|
|
310
|
+
dest: destDir,
|
|
311
|
+
compiler: executable,
|
|
312
|
+
includeDir: __spreadArray(__spreadArray([
|
|
313
|
+
path_1.default.join(this.config.compiler.dir, 'include')
|
|
314
|
+
], this.config.include, true), [
|
|
315
|
+
this.config.input.include,
|
|
316
|
+
], false)
|
|
317
|
+
})];
|
|
318
|
+
case 2:
|
|
319
|
+
result = _a.sent();
|
|
320
|
+
result.output.messages.forEach(function (message) {
|
|
321
|
+
var startLine = message.startLine, type = message.type, code = message.code, text = message.text;
|
|
322
|
+
if (type === amxxpc_1.AMXPCMessageType.Error || type === amxxpc_1.AMXPCMessageType.FatalError) {
|
|
323
|
+
logger_1.default.error("".concat((0, normalize_path_1.default)(relateiveSrcPath), "(").concat(startLine, ")"), type, code, ':', text);
|
|
324
|
+
}
|
|
325
|
+
else if (type === amxxpc_1.AMXPCMessageType.Warning) {
|
|
326
|
+
logger_1.default.warn("".concat((0, normalize_path_1.default)(relateiveSrcPath), "(").concat(startLine, ")"), type, code, ':', text);
|
|
327
|
+
}
|
|
328
|
+
else if (type === amxxpc_1.AMXPCMessageType.Echo) {
|
|
329
|
+
logger_1.default.debug(text);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
if (result.success) {
|
|
333
|
+
destPath = path_1.default.join(destDir, result.plugin);
|
|
334
|
+
relativeFilePath = path_1.default.relative(process.cwd(), filePath);
|
|
335
|
+
logger_1.default.success('Compilation success:', (0, normalize_path_1.default)(relativeFilePath));
|
|
336
|
+
logger_1.default.info('Plugin updated:', (0, normalize_path_1.default)(destPath));
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
throw new Error("Failed to compile ".concat((0, normalize_path_1.default)(relateiveSrcPath), " : \"").concat(result.error, "\""));
|
|
340
|
+
}
|
|
341
|
+
return [2 /*return*/];
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
AmxxBuilder.prototype.buildDir = function (baseDir, pattern, cb) {
|
|
347
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
348
|
+
var pathPattern, matches;
|
|
349
|
+
return __generator(this, function (_a) {
|
|
350
|
+
switch (_a.label) {
|
|
351
|
+
case 0:
|
|
352
|
+
pathPattern = path_1.default.join(baseDir, pattern);
|
|
353
|
+
return [4 /*yield*/, (0, glob_promise_1.default)(pathPattern, { nodir: true })];
|
|
354
|
+
case 1:
|
|
355
|
+
matches = _a.sent();
|
|
356
|
+
return [4 /*yield*/, matches.reduce(function (acc, match) { return acc.then(function () { return cb(match); }); }, Promise.resolve())];
|
|
357
|
+
case 2:
|
|
358
|
+
_a.sent();
|
|
359
|
+
return [2 /*return*/];
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
AmxxBuilder.prototype.watchDir = function (baseDir, pattern, cb) {
|
|
365
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
366
|
+
var pathPattern, watcher, updateFn;
|
|
367
|
+
return __generator(this, function (_a) {
|
|
368
|
+
pathPattern = path_1.default.join(baseDir, pattern);
|
|
369
|
+
watcher = chokidar_1.default.watch(pathPattern, { ignoreInitial: true });
|
|
370
|
+
updateFn = function (filePath) { return cb(filePath).catch(function (err) { return logger_1.default.error(err.message); }); };
|
|
371
|
+
watcher.on('add', updateFn);
|
|
372
|
+
watcher.on('change', updateFn);
|
|
373
|
+
return [2 /*return*/];
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
return AmxxBuilder;
|
|
378
|
+
}());
|
|
379
|
+
exports.default = AmxxBuilder;
|