amxxpack 0.1.3 → 0.1.4
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 +1 -1
- package/lib/builder/amxxpc.d.ts +27 -27
- package/lib/builder/amxxpc.js +122 -122
- package/lib/builder/builder.d.ts +22 -22
- package/lib/builder/builder.js +400 -400
- package/lib/builder/constants.d.ts +3 -3
- package/lib/builder/constants.js +6 -6
- package/lib/builder/index.d.ts +2 -2
- package/lib/builder/index.js +20 -20
- package/lib/builder/types.d.ts +20 -20
- package/lib/builder/types.js +2 -2
- package/lib/cli/controller.d.ts +16 -16
- package/lib/cli/controller.js +181 -181
- package/lib/cli/index.d.ts +2 -2
- package/lib/cli/index.js +8 -8
- package/lib/cli/program.d.ts +4 -4
- package/lib/cli/program.js +118 -118
- package/lib/compiler-downloader/constants.d.ts +12 -12
- package/lib/compiler-downloader/constants.js +17 -17
- package/lib/compiler-downloader/downloader.d.ts +2 -2
- package/lib/compiler-downloader/downloader.js +174 -174
- package/lib/compiler-downloader/index.d.ts +1 -1
- package/lib/compiler-downloader/index.js +9 -9
- package/lib/compiler-downloader/resolvers.d.ts +6 -6
- package/lib/compiler-downloader/resolvers.js +39 -39
- package/lib/compiler-downloader/types.d.ts +16 -16
- package/lib/compiler-downloader/types.js +2 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.js +20 -20
- package/lib/services/logger.d.ts +22 -22
- package/lib/services/logger.js +104 -104
- package/lib/utils/accumulator.d.ts +1 -1
- package/lib/utils/accumulator.js +10 -10
- package/package.json +1 -1
- package/resources/default-config.json +1 -1
package/README.md
CHANGED
package/lib/builder/amxxpc.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
export declare enum AMXPCMessageType {
|
|
2
|
-
Echo = "echo",
|
|
3
|
-
Error = "error",
|
|
4
|
-
Warning = "warning",
|
|
5
|
-
FatalError = "fatal error"
|
|
6
|
-
}
|
|
7
|
-
interface IMessage {
|
|
8
|
-
filename?: string;
|
|
9
|
-
startLine?: number;
|
|
10
|
-
endLine?: number;
|
|
11
|
-
code?: number;
|
|
12
|
-
type: AMXPCMessageType;
|
|
13
|
-
text: string;
|
|
14
|
-
}
|
|
15
|
-
interface IParseOutputResult {
|
|
16
|
-
messages: IMessage[];
|
|
17
|
-
aborted: boolean;
|
|
18
|
-
error: boolean;
|
|
19
|
-
}
|
|
20
|
-
interface ICompileResult {
|
|
21
|
-
output: IParseOutputResult;
|
|
22
|
-
plugin: string;
|
|
23
|
-
error?: string;
|
|
24
|
-
success: boolean;
|
|
25
|
-
}
|
|
26
|
-
declare function compile(params: any): Promise<ICompileResult>;
|
|
27
|
-
export default compile;
|
|
1
|
+
export declare enum AMXPCMessageType {
|
|
2
|
+
Echo = "echo",
|
|
3
|
+
Error = "error",
|
|
4
|
+
Warning = "warning",
|
|
5
|
+
FatalError = "fatal error"
|
|
6
|
+
}
|
|
7
|
+
interface IMessage {
|
|
8
|
+
filename?: string;
|
|
9
|
+
startLine?: number;
|
|
10
|
+
endLine?: number;
|
|
11
|
+
code?: number;
|
|
12
|
+
type: AMXPCMessageType;
|
|
13
|
+
text: string;
|
|
14
|
+
}
|
|
15
|
+
interface IParseOutputResult {
|
|
16
|
+
messages: IMessage[];
|
|
17
|
+
aborted: boolean;
|
|
18
|
+
error: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface ICompileResult {
|
|
21
|
+
output: IParseOutputResult;
|
|
22
|
+
plugin: string;
|
|
23
|
+
error?: string;
|
|
24
|
+
success: boolean;
|
|
25
|
+
}
|
|
26
|
+
declare function compile(params: any): Promise<ICompileResult>;
|
|
27
|
+
export default compile;
|
package/lib/builder/amxxpc.js
CHANGED
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.AMXPCMessageType = void 0;
|
|
16
|
-
var path_1 = __importDefault(require("path"));
|
|
17
|
-
var child_process_1 = __importDefault(require("child_process"));
|
|
18
|
-
var mkdirp_1 = __importDefault(require("mkdirp"));
|
|
19
|
-
var accumulator_1 = __importDefault(require("../utils/accumulator"));
|
|
20
|
-
var PLUGIN_EXT = 'amxx';
|
|
21
|
-
var AMXPCMessageType;
|
|
22
|
-
(function (AMXPCMessageType) {
|
|
23
|
-
AMXPCMessageType["Echo"] = "echo";
|
|
24
|
-
AMXPCMessageType["Error"] = "error";
|
|
25
|
-
AMXPCMessageType["Warning"] = "warning";
|
|
26
|
-
AMXPCMessageType["FatalError"] = "fatal error";
|
|
27
|
-
})(AMXPCMessageType = exports.AMXPCMessageType || (exports.AMXPCMessageType = {}));
|
|
28
|
-
var MessageRegExp = {
|
|
29
|
-
filename: /([a-zA-Z0-9.\-_/:\\\s]+)/,
|
|
30
|
-
line: /\(([0-9]+)(?:\s--\s([0-9]+))?\)/,
|
|
31
|
-
type: /((?:fatal\s)?error|warning)/,
|
|
32
|
-
code: /([0-9]+)/,
|
|
33
|
-
text: /(.*)/
|
|
34
|
-
};
|
|
35
|
-
function buildMessageRegExp() {
|
|
36
|
-
var filename = MessageRegExp.filename, line = MessageRegExp.line, type = MessageRegExp.type, code = MessageRegExp.code, text = MessageRegExp.text;
|
|
37
|
-
var pattern = [
|
|
38
|
-
filename,
|
|
39
|
-
line,
|
|
40
|
-
/\s:\s/,
|
|
41
|
-
type,
|
|
42
|
-
/\s/,
|
|
43
|
-
code,
|
|
44
|
-
/:\s/,
|
|
45
|
-
text
|
|
46
|
-
].map(function (r) { return r.toString().slice(1, -1); }).join('');
|
|
47
|
-
return new RegExp(pattern);
|
|
48
|
-
}
|
|
49
|
-
var messageRegExp = buildMessageRegExp();
|
|
50
|
-
function parseLine(line) {
|
|
51
|
-
var match = line.match(messageRegExp);
|
|
52
|
-
if (!match) {
|
|
53
|
-
return { type: AMXPCMessageType.Echo, text: line };
|
|
54
|
-
}
|
|
55
|
-
var filename = match[1], startLine = match[2], endLine = match[3], type = match[4], code = match[5], text = match[6];
|
|
56
|
-
return {
|
|
57
|
-
filename: filename,
|
|
58
|
-
startLine: +startLine,
|
|
59
|
-
endLine: endLine ? +endLine : -1,
|
|
60
|
-
type: type,
|
|
61
|
-
code: +code,
|
|
62
|
-
text: text
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function isAbortedEcho(line) {
|
|
66
|
-
return line.startsWith('Compilation aborted.')
|
|
67
|
-
|| line.startsWith('Could not locate output file');
|
|
68
|
-
}
|
|
69
|
-
function parseOutput(output) {
|
|
70
|
-
var result = { messages: [], aborted: false, error: false };
|
|
71
|
-
output.split('\n').forEach(function (line) {
|
|
72
|
-
var message = parseLine(line);
|
|
73
|
-
var type = message.type;
|
|
74
|
-
if (type === AMXPCMessageType.Error || type === AMXPCMessageType.FatalError) {
|
|
75
|
-
result.error = true;
|
|
76
|
-
}
|
|
77
|
-
else if (type === AMXPCMessageType.Echo && isAbortedEcho(line)) {
|
|
78
|
-
result.error = true;
|
|
79
|
-
result.aborted = true;
|
|
80
|
-
}
|
|
81
|
-
result.messages.push(message);
|
|
82
|
-
});
|
|
83
|
-
return result;
|
|
84
|
-
}
|
|
85
|
-
function formatArgs(params, outPath) {
|
|
86
|
-
var includeArgs = params.includeDir instanceof Array
|
|
87
|
-
? params.includeDir.map(function (dir) { return "-i".concat(dir); })
|
|
88
|
-
: ["-i".concat(params.includeDir)];
|
|
89
|
-
return __spreadArray([params.path, "-o".concat(outPath)], includeArgs, true);
|
|
90
|
-
}
|
|
91
|
-
function compile(params) {
|
|
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);
|
|
96
|
-
return new Promise(function (resolve) {
|
|
97
|
-
var output = (0, accumulator_1.default)();
|
|
98
|
-
var done = function (error) {
|
|
99
|
-
var outputData = output();
|
|
100
|
-
var parsedOutput = parseOutput(outputData);
|
|
101
|
-
var errorMessage = error && error.message;
|
|
102
|
-
if (!errorMessage && parsedOutput.error) {
|
|
103
|
-
errorMessage = 'Compilation error';
|
|
104
|
-
}
|
|
105
|
-
resolve({
|
|
106
|
-
error: errorMessage,
|
|
107
|
-
plugin: fileName,
|
|
108
|
-
success: !errorMessage,
|
|
109
|
-
output: parsedOutput
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
var compilerProcess = child_process_1.default.spawn(params.compiler, formatArgs(params, dest), {
|
|
113
|
-
env: process.env,
|
|
114
|
-
cwd: path_1.default.parse(params.compiler).dir
|
|
115
|
-
});
|
|
116
|
-
compilerProcess.on('error', done);
|
|
117
|
-
compilerProcess.on('close', done);
|
|
118
|
-
compilerProcess.stdout.on('data', output);
|
|
119
|
-
compilerProcess.stderr.on('data', function (data) { return console.error(data); });
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
exports.default = compile;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AMXPCMessageType = void 0;
|
|
16
|
+
var path_1 = __importDefault(require("path"));
|
|
17
|
+
var child_process_1 = __importDefault(require("child_process"));
|
|
18
|
+
var mkdirp_1 = __importDefault(require("mkdirp"));
|
|
19
|
+
var accumulator_1 = __importDefault(require("../utils/accumulator"));
|
|
20
|
+
var PLUGIN_EXT = 'amxx';
|
|
21
|
+
var AMXPCMessageType;
|
|
22
|
+
(function (AMXPCMessageType) {
|
|
23
|
+
AMXPCMessageType["Echo"] = "echo";
|
|
24
|
+
AMXPCMessageType["Error"] = "error";
|
|
25
|
+
AMXPCMessageType["Warning"] = "warning";
|
|
26
|
+
AMXPCMessageType["FatalError"] = "fatal error";
|
|
27
|
+
})(AMXPCMessageType = exports.AMXPCMessageType || (exports.AMXPCMessageType = {}));
|
|
28
|
+
var MessageRegExp = {
|
|
29
|
+
filename: /([a-zA-Z0-9.\-_/:\\\s]+)/,
|
|
30
|
+
line: /\(([0-9]+)(?:\s--\s([0-9]+))?\)/,
|
|
31
|
+
type: /((?:fatal\s)?error|warning)/,
|
|
32
|
+
code: /([0-9]+)/,
|
|
33
|
+
text: /(.*)/
|
|
34
|
+
};
|
|
35
|
+
function buildMessageRegExp() {
|
|
36
|
+
var filename = MessageRegExp.filename, line = MessageRegExp.line, type = MessageRegExp.type, code = MessageRegExp.code, text = MessageRegExp.text;
|
|
37
|
+
var pattern = [
|
|
38
|
+
filename,
|
|
39
|
+
line,
|
|
40
|
+
/\s:\s/,
|
|
41
|
+
type,
|
|
42
|
+
/\s/,
|
|
43
|
+
code,
|
|
44
|
+
/:\s/,
|
|
45
|
+
text
|
|
46
|
+
].map(function (r) { return r.toString().slice(1, -1); }).join('');
|
|
47
|
+
return new RegExp(pattern);
|
|
48
|
+
}
|
|
49
|
+
var messageRegExp = buildMessageRegExp();
|
|
50
|
+
function parseLine(line) {
|
|
51
|
+
var match = line.match(messageRegExp);
|
|
52
|
+
if (!match) {
|
|
53
|
+
return { type: AMXPCMessageType.Echo, text: line };
|
|
54
|
+
}
|
|
55
|
+
var filename = match[1], startLine = match[2], endLine = match[3], type = match[4], code = match[5], text = match[6];
|
|
56
|
+
return {
|
|
57
|
+
filename: filename,
|
|
58
|
+
startLine: +startLine,
|
|
59
|
+
endLine: endLine ? +endLine : -1,
|
|
60
|
+
type: type,
|
|
61
|
+
code: +code,
|
|
62
|
+
text: text
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function isAbortedEcho(line) {
|
|
66
|
+
return line.startsWith('Compilation aborted.')
|
|
67
|
+
|| line.startsWith('Could not locate output file');
|
|
68
|
+
}
|
|
69
|
+
function parseOutput(output) {
|
|
70
|
+
var result = { messages: [], aborted: false, error: false };
|
|
71
|
+
output.split('\n').forEach(function (line) {
|
|
72
|
+
var message = parseLine(line);
|
|
73
|
+
var type = message.type;
|
|
74
|
+
if (type === AMXPCMessageType.Error || type === AMXPCMessageType.FatalError) {
|
|
75
|
+
result.error = true;
|
|
76
|
+
}
|
|
77
|
+
else if (type === AMXPCMessageType.Echo && isAbortedEcho(line)) {
|
|
78
|
+
result.error = true;
|
|
79
|
+
result.aborted = true;
|
|
80
|
+
}
|
|
81
|
+
result.messages.push(message);
|
|
82
|
+
});
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
function formatArgs(params, outPath) {
|
|
86
|
+
var includeArgs = params.includeDir instanceof Array
|
|
87
|
+
? params.includeDir.map(function (dir) { return "-i".concat(dir); })
|
|
88
|
+
: ["-i".concat(params.includeDir)];
|
|
89
|
+
return __spreadArray([params.path, "-o".concat(outPath)], includeArgs, true);
|
|
90
|
+
}
|
|
91
|
+
function compile(params) {
|
|
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);
|
|
96
|
+
return new Promise(function (resolve) {
|
|
97
|
+
var output = (0, accumulator_1.default)();
|
|
98
|
+
var done = function (error) {
|
|
99
|
+
var outputData = output();
|
|
100
|
+
var parsedOutput = parseOutput(outputData);
|
|
101
|
+
var errorMessage = error && error.message;
|
|
102
|
+
if (!errorMessage && parsedOutput.error) {
|
|
103
|
+
errorMessage = 'Compilation error';
|
|
104
|
+
}
|
|
105
|
+
resolve({
|
|
106
|
+
error: errorMessage,
|
|
107
|
+
plugin: fileName,
|
|
108
|
+
success: !errorMessage,
|
|
109
|
+
output: parsedOutput
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
var compilerProcess = child_process_1.default.spawn(params.compiler, formatArgs(params, dest), {
|
|
113
|
+
env: process.env,
|
|
114
|
+
cwd: path_1.default.parse(params.compiler).dir
|
|
115
|
+
});
|
|
116
|
+
compilerProcess.on('error', done);
|
|
117
|
+
compilerProcess.on('close', done);
|
|
118
|
+
compilerProcess.stdout.on('data', output);
|
|
119
|
+
compilerProcess.stderr.on('data', function (data) { return console.error(data); });
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
exports.default = compile;
|
package/lib/builder/builder.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { IAmxxBuilderConfig } from './types';
|
|
2
|
-
export default class AmxxBuilder {
|
|
3
|
-
private logger;
|
|
4
|
-
private config;
|
|
5
|
-
constructor(config: IAmxxBuilderConfig);
|
|
6
|
-
build(): Promise<void>;
|
|
7
|
-
watch(): Promise<void>;
|
|
8
|
-
buildSrc(): Promise<void>;
|
|
9
|
-
buildInclude(): Promise<void>;
|
|
10
|
-
buildAssets(): Promise<void>;
|
|
11
|
-
watchSrc(): Promise<void>;
|
|
12
|
-
watchInclude(): Promise<void>;
|
|
13
|
-
watchAssets(): Promise<void>;
|
|
14
|
-
updatePlugin(filePath: string): Promise<void>;
|
|
15
|
-
updateScript(filePath: string): Promise<void>;
|
|
16
|
-
updateAsset(filePath: string): Promise<void>;
|
|
17
|
-
updateInclude(filePath: string): Promise<void>;
|
|
18
|
-
findPlugins(pattern: string): Promise<string[]>;
|
|
19
|
-
compilePlugin(filePath: string): Promise<void>;
|
|
20
|
-
private buildDir;
|
|
21
|
-
private watchDir;
|
|
22
|
-
}
|
|
1
|
+
import { IAmxxBuilderConfig } from './types';
|
|
2
|
+
export default class AmxxBuilder {
|
|
3
|
+
private logger;
|
|
4
|
+
private config;
|
|
5
|
+
constructor(config: IAmxxBuilderConfig);
|
|
6
|
+
build(): Promise<void>;
|
|
7
|
+
watch(): Promise<void>;
|
|
8
|
+
buildSrc(): Promise<void>;
|
|
9
|
+
buildInclude(): Promise<void>;
|
|
10
|
+
buildAssets(): Promise<void>;
|
|
11
|
+
watchSrc(): Promise<void>;
|
|
12
|
+
watchInclude(): Promise<void>;
|
|
13
|
+
watchAssets(): Promise<void>;
|
|
14
|
+
updatePlugin(filePath: string): Promise<void>;
|
|
15
|
+
updateScript(filePath: string): Promise<void>;
|
|
16
|
+
updateAsset(filePath: string): Promise<void>;
|
|
17
|
+
updateInclude(filePath: string): Promise<void>;
|
|
18
|
+
findPlugins(pattern: string): Promise<string[]>;
|
|
19
|
+
compilePlugin(filePath: string): Promise<void>;
|
|
20
|
+
private buildDir;
|
|
21
|
+
private watchDir;
|
|
22
|
+
}
|