amxxpack 1.4.4 → 1.4.6
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 +13 -0
- package/lib/builder/builder.js +33 -25
- package/lib/builder/constants.d.ts +1 -1
- package/lib/builder/constants.js +1 -1
- package/lib/builder/plugins-cache.js +1 -1
- package/lib/cli/controller.js +3 -1
- package/lib/utils/create-dir-hash.d.ts +1 -1
- package/lib/utils/create-dir-hash.js +12 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,6 +106,19 @@ You can use multiple directories as builder inputs, just specify an array of dir
|
|
|
106
106
|
}
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
+
### Disabling output
|
|
110
|
+
Use `null` value for outputs to disable copying of specific output.
|
|
111
|
+
|
|
112
|
+
For example, in this case, include files will not be copied to the output folder:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"output": {
|
|
117
|
+
"include": null
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
109
122
|
### Assets filtering and subdirectories
|
|
110
123
|
Using glob filters you can specify which assets should be copied.
|
|
111
124
|
|
package/lib/builder/builder.js
CHANGED
|
@@ -468,7 +468,7 @@ var AmxxBuilder = /** @class */ (function () {
|
|
|
468
468
|
switch (_a.label) {
|
|
469
469
|
case 0:
|
|
470
470
|
pathPattern = (0, lodash_1.map)(this.projectConfig.input.scripts, function (dir) { return path_1.default.join(dir, '**', pattern); });
|
|
471
|
-
return [4 /*yield*/, globule_1.default.find(pathPattern)];
|
|
471
|
+
return [4 /*yield*/, globule_1.default.find(pathPattern, { nodir: true })];
|
|
472
472
|
case 1:
|
|
473
473
|
matches = _a.sent();
|
|
474
474
|
return [2 /*return*/, matches.filter(function (filePath) { return path_1.default.extname(filePath) === '.sma'; })];
|
|
@@ -479,9 +479,10 @@ var AmxxBuilder = /** @class */ (function () {
|
|
|
479
479
|
AmxxBuilder.prototype.compilePlugin = function (srcDir, srcFile, compileOptions) {
|
|
480
480
|
if (compileOptions === void 0) { compileOptions = {}; }
|
|
481
481
|
return __awaiter(this, void 0, void 0, function () {
|
|
482
|
-
var srcPath, _a, scriptName, srcNestedDir, destDir, pluginDest, isUpdated, _b, relateiveSrcPath, executablePath, result, destPath, relativeFilePath;
|
|
483
|
-
|
|
484
|
-
|
|
482
|
+
var srcPath, _a, scriptName, srcNestedDir, destDir, pluginDest, isUpdated, _b, relateiveSrcPath, executablePath, result, _c, _d, _e, destPath, relativeFilePath;
|
|
483
|
+
var _f;
|
|
484
|
+
return __generator(this, function (_g) {
|
|
485
|
+
switch (_g.label) {
|
|
485
486
|
case 0:
|
|
486
487
|
if (!this.projectConfig.output.plugins) {
|
|
487
488
|
return [2 /*return*/];
|
|
@@ -495,8 +496,8 @@ var AmxxBuilder = /** @class */ (function () {
|
|
|
495
496
|
return [3 /*break*/, 3];
|
|
496
497
|
case 1: return [4 /*yield*/, this.pluginCache.isPluginUpdated(srcPath, pluginDest)];
|
|
497
498
|
case 2:
|
|
498
|
-
_b =
|
|
499
|
-
|
|
499
|
+
_b = _g.sent();
|
|
500
|
+
_g.label = 3;
|
|
500
501
|
case 3:
|
|
501
502
|
isUpdated = _b;
|
|
502
503
|
relateiveSrcPath = path_1.default.relative(process.cwd(), srcPath);
|
|
@@ -507,28 +508,35 @@ var AmxxBuilder = /** @class */ (function () {
|
|
|
507
508
|
executablePath = path_1.default.join(this.projectConfig.compiler.dir, this.projectConfig.compiler.executable);
|
|
508
509
|
return [4 /*yield*/, (0, mkdirp_1.default)(destDir)];
|
|
509
510
|
case 4:
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
511
|
+
_g.sent();
|
|
512
|
+
_c = amxxpc_1.default;
|
|
513
|
+
_f = {
|
|
514
|
+
path: srcPath,
|
|
515
|
+
dest: pluginDest,
|
|
516
|
+
compiler: executablePath
|
|
517
|
+
};
|
|
518
|
+
_d = [[
|
|
519
|
+
path_1.default.join(this.projectConfig.compiler.dir, 'include')
|
|
520
|
+
]];
|
|
521
|
+
return [4 /*yield*/, globule_1.default.find(this.projectConfig.include)];
|
|
519
522
|
case 5:
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
+
_e = [__spreadArray.apply(void 0, _d.concat([_g.sent(), true]))];
|
|
524
|
+
return [4 /*yield*/, globule_1.default.find(this.projectConfig.input.include)];
|
|
525
|
+
case 6: return [4 /*yield*/, _c.apply(void 0, [(_f.includeDir = __spreadArray.apply(void 0, _e.concat([_g.sent(), true])),
|
|
526
|
+
_f)])];
|
|
527
|
+
case 7:
|
|
528
|
+
result = _g.sent();
|
|
529
|
+
if (!!compileOptions.noCache) return [3 /*break*/, 11];
|
|
530
|
+
if (!!result.error) return [3 /*break*/, 9];
|
|
523
531
|
return [4 /*yield*/, this.pluginCache.updatePlugin(srcPath, pluginDest)];
|
|
524
|
-
case 6:
|
|
525
|
-
_c.sent();
|
|
526
|
-
return [3 /*break*/, 9];
|
|
527
|
-
case 7: return [4 /*yield*/, this.pluginCache.deletePlugin(srcPath)];
|
|
528
532
|
case 8:
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
case 9:
|
|
533
|
+
_g.sent();
|
|
534
|
+
return [3 /*break*/, 11];
|
|
535
|
+
case 9: return [4 /*yield*/, this.pluginCache.deletePlugin(srcPath)];
|
|
536
|
+
case 10:
|
|
537
|
+
_g.sent();
|
|
538
|
+
_g.label = 11;
|
|
539
|
+
case 11:
|
|
532
540
|
result.output.messages.forEach(function (message) {
|
|
533
541
|
var startLine = message.startLine, type = message.type, code = message.code, text = message.text, filename = message.filename;
|
|
534
542
|
var relativeFilePath = filename ? path_1.default.relative(process.cwd(), filename) : relateiveSrcPath;
|
package/lib/builder/constants.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ASSETS_PATH_PATTERN = exports.INCLUDE_PATH_PATTERN = exports.SCRIPTS_PATH_PATTERN = void 0;
|
|
4
4
|
exports.SCRIPTS_PATH_PATTERN = '**/*.sma';
|
|
5
|
-
exports.INCLUDE_PATH_PATTERN = '
|
|
5
|
+
exports.INCLUDE_PATH_PATTERN = '*.inc';
|
|
6
6
|
exports.ASSETS_PATH_PATTERN = '**/*.*';
|
|
@@ -157,7 +157,7 @@ var PluginsCache = /** @class */ (function () {
|
|
|
157
157
|
case 0: return [4 /*yield*/, (0, create_dir_hash_1.default)(includeDirs, function (p) { return !p.info.isFile() || path_1.default.parse(p.info.name).ext === '.inc'; })];
|
|
158
158
|
case 1:
|
|
159
159
|
includeHash = _a.sent();
|
|
160
|
-
return [2 /*return*/, includeHash];
|
|
160
|
+
return [2 /*return*/, includeHash.digest('hex')];
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
163
|
});
|
package/lib/cli/controller.js
CHANGED
|
@@ -247,7 +247,9 @@ var Controller = /** @class */ (function () {
|
|
|
247
247
|
Controller.prototype.cleanCache = function () {
|
|
248
248
|
return __awaiter(this, void 0, void 0, function () {
|
|
249
249
|
return __generator(this, function (_a) {
|
|
250
|
-
fs_1.default.
|
|
250
|
+
if (fs_1.default.existsSync(config_1.default.cacheFile)) {
|
|
251
|
+
fs_1.default.promises.rm(config_1.default.cacheFile);
|
|
252
|
+
}
|
|
251
253
|
fs_1.default.promises.rm(config_1.default.downloadDir, { recursive: true, force: true });
|
|
252
254
|
return [2 /*return*/];
|
|
253
255
|
});
|
|
@@ -5,5 +5,5 @@ import crypto from 'crypto';
|
|
|
5
5
|
declare function createDirHash(dirs: string[], filterFn?: (p: {
|
|
6
6
|
dir: string;
|
|
7
7
|
info: fs.Dirent;
|
|
8
|
-
}) => boolean, initialHash?: crypto.Hash): Promise<
|
|
8
|
+
}) => boolean, initialHash?: crypto.Hash): Promise<crypto.Hash>;
|
|
9
9
|
export default createDirHash;
|
|
@@ -54,10 +54,10 @@ function createDirHash(dirs, filterFn, initialHash) {
|
|
|
54
54
|
_i = 0, dirs_1 = dirs;
|
|
55
55
|
_b.label = 1;
|
|
56
56
|
case 1:
|
|
57
|
-
if (!(_i < dirs_1.length)) return [3 /*break*/,
|
|
57
|
+
if (!(_i < dirs_1.length)) return [3 /*break*/, 9];
|
|
58
58
|
dir = dirs_1[_i];
|
|
59
59
|
if (!fs_1.default.existsSync(dir)) {
|
|
60
|
-
return [3 /*break*/,
|
|
60
|
+
return [3 /*break*/, 8];
|
|
61
61
|
}
|
|
62
62
|
return [4 /*yield*/, fs_1.default.promises.readdir(dir, { withFileTypes: true })];
|
|
63
63
|
case 2:
|
|
@@ -65,11 +65,11 @@ function createDirHash(dirs, filterFn, initialHash) {
|
|
|
65
65
|
_a = 0, items_1 = items;
|
|
66
66
|
_b.label = 3;
|
|
67
67
|
case 3:
|
|
68
|
-
if (!(_a < items_1.length)) return [3 /*break*/,
|
|
68
|
+
if (!(_a < items_1.length)) return [3 /*break*/, 8];
|
|
69
69
|
item = items_1[_a];
|
|
70
70
|
fullPath = path_1.default.join(dir, item.name);
|
|
71
71
|
if (filterFn && !filterFn({ dir: dir, info: item })) {
|
|
72
|
-
return [3 /*break*/,
|
|
72
|
+
return [3 /*break*/, 7];
|
|
73
73
|
}
|
|
74
74
|
if (!item.isFile()) return [3 /*break*/, 5];
|
|
75
75
|
return [4 /*yield*/, fs_1.default.promises.stat(fullPath)];
|
|
@@ -77,19 +77,20 @@ function createDirHash(dirs, filterFn, initialHash) {
|
|
|
77
77
|
fileStat = _b.sent();
|
|
78
78
|
data = "".concat(fullPath, ":").concat(fileStat.size, ":").concat(fileStat.mtimeMs);
|
|
79
79
|
hashSum.update(data);
|
|
80
|
-
return [3 /*break*/,
|
|
80
|
+
return [3 /*break*/, 7];
|
|
81
81
|
case 5:
|
|
82
|
-
if (item.isDirectory())
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
_b.label = 6;
|
|
82
|
+
if (!item.isDirectory()) return [3 /*break*/, 7];
|
|
83
|
+
return [4 /*yield*/, createDirHash([fullPath], filterFn, hashSum)];
|
|
86
84
|
case 6:
|
|
85
|
+
_b.sent();
|
|
86
|
+
_b.label = 7;
|
|
87
|
+
case 7:
|
|
87
88
|
_a++;
|
|
88
89
|
return [3 /*break*/, 3];
|
|
89
|
-
case
|
|
90
|
+
case 8:
|
|
90
91
|
_i++;
|
|
91
92
|
return [3 /*break*/, 1];
|
|
92
|
-
case
|
|
93
|
+
case 9: return [2 /*return*/, hashSum];
|
|
93
94
|
}
|
|
94
95
|
});
|
|
95
96
|
});
|