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.
Files changed (69) hide show
  1. package/README.md +26 -21
  2. package/lib/builder/amxxpc.d.ts +27 -27
  3. package/lib/builder/amxxpc.js +122 -122
  4. package/lib/builder/builder.d.ts +21 -22
  5. package/lib/builder/builder.js +379 -400
  6. package/lib/builder/constants.d.ts +3 -3
  7. package/lib/builder/constants.js +6 -6
  8. package/lib/builder/index.d.ts +1 -2
  9. package/lib/builder/index.js +9 -20
  10. package/lib/cli/controller.d.ts +20 -16
  11. package/lib/cli/controller.js +238 -181
  12. package/lib/cli/index.d.ts +3 -2
  13. package/lib/cli/index.js +13 -8
  14. package/lib/cli/program.d.ts +4 -4
  15. package/lib/cli/program.js +174 -118
  16. package/lib/cli/services/project-creator.d.ts +21 -0
  17. package/lib/cli/services/project-creator.js +274 -0
  18. package/lib/cli/services/template-builder.d.ts +11 -0
  19. package/lib/cli/services/template-builder.js +104 -0
  20. package/lib/cli/types.d.ts +12 -0
  21. package/lib/{compiler-downloader → cli}/types.js +2 -2
  22. package/lib/config/index.d.ts +8 -0
  23. package/lib/config/index.js +14 -0
  24. package/lib/downloaders/compiler/constants.d.ts +9 -0
  25. package/lib/{compiler-downloader → downloaders/compiler}/constants.js +14 -17
  26. package/lib/downloaders/compiler/downloader.d.ts +3 -0
  27. package/lib/{compiler-downloader → downloaders/compiler}/downloader.js +151 -174
  28. package/lib/{compiler-downloader → downloaders/compiler}/index.d.ts +1 -1
  29. package/lib/{compiler-downloader → downloaders/compiler}/index.js +9 -9
  30. package/lib/{compiler-downloader → downloaders/compiler}/resolvers.d.ts +6 -6
  31. package/lib/{compiler-downloader → downloaders/compiler}/resolvers.js +40 -39
  32. package/lib/{compiler-downloader → downloaders/compiler}/types.d.ts +16 -16
  33. package/lib/{builder → downloaders/compiler}/types.js +2 -2
  34. package/lib/downloaders/thirdparty/downloader.d.ts +3 -0
  35. package/lib/downloaders/thirdparty/downloader.js +69 -0
  36. package/lib/downloaders/thirdparty/index.d.ts +1 -0
  37. package/lib/downloaders/thirdparty/index.js +9 -0
  38. package/lib/downloaders/thirdparty/types.d.ts +5 -0
  39. package/lib/downloaders/thirdparty/types.js +2 -0
  40. package/lib/index.d.ts +2 -2
  41. package/lib/index.js +20 -20
  42. package/lib/logger/constants.d.ts +7 -0
  43. package/lib/logger/constants.js +12 -0
  44. package/lib/{services → logger}/logger.d.ts +16 -22
  45. package/lib/{services → logger}/logger.js +96 -104
  46. package/lib/logger/types.d.ts +3 -0
  47. package/lib/logger/types.js +2 -0
  48. package/lib/project-config/defaults.d.ts +3 -0
  49. package/lib/project-config/defaults.js +38 -0
  50. package/lib/project-config/index.d.ts +6 -0
  51. package/lib/project-config/index.js +8 -0
  52. package/lib/project-config/resolve.d.ts +3 -0
  53. package/lib/project-config/resolve.js +110 -0
  54. package/lib/types/index.d.ts +45 -0
  55. package/lib/types/index.js +2 -0
  56. package/lib/utils/accumulator.d.ts +2 -1
  57. package/lib/utils/accumulator.js +10 -10
  58. package/lib/utils/download.d.ts +6 -0
  59. package/lib/utils/download.js +63 -0
  60. package/package.json +7 -1
  61. package/resources/templates/include-directive.txt +1 -0
  62. package/resources/templates/include.txt +5 -0
  63. package/resources/templates/library-include.txt +6 -0
  64. package/resources/templates/library-script.txt +10 -0
  65. package/resources/templates/script.txt +5 -0
  66. package/lib/builder/types.d.ts +0 -20
  67. package/lib/compiler-downloader/constants.d.ts +0 -12
  68. package/lib/compiler-downloader/downloader.d.ts +0 -2
  69. package/resources/default-config.json +0 -22
@@ -0,0 +1,110 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
58
+ return (mod && mod.__esModule) ? mod : { "default": mod };
59
+ };
60
+ Object.defineProperty(exports, "__esModule", { value: true });
61
+ var lodash_1 = require("lodash");
62
+ var path_1 = __importDefault(require("path"));
63
+ var fs_1 = __importDefault(require("fs"));
64
+ var logger_1 = __importDefault(require("../logger/logger"));
65
+ var defaults_1 = __importDefault(require("./defaults"));
66
+ function resolve(_configPath) {
67
+ return __awaiter(this, void 0, void 0, function () {
68
+ var configPath, userConfig, config;
69
+ return __generator(this, function (_a) {
70
+ switch (_a.label) {
71
+ case 0:
72
+ configPath = path_1.default.resolve(_configPath);
73
+ userConfig = null;
74
+ if (!fs_1.default.existsSync(configPath)) return [3 /*break*/, 2];
75
+ return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require(configPath)); })];
76
+ case 1:
77
+ userConfig = _a.sent();
78
+ return [3 /*break*/, 3];
79
+ case 2:
80
+ logger_1.default.error('Cannot read config file!');
81
+ _a.label = 3;
82
+ case 3:
83
+ config = (0, lodash_1.merge)({}, defaults_1.default, userConfig);
84
+ // resolve paths
85
+ (0, lodash_1.merge)(config, {
86
+ input: {
87
+ scripts: path_1.default.resolve(config.input.scripts),
88
+ include: path_1.default.resolve(config.input.include),
89
+ assets: path_1.default.resolve(config.input.assets),
90
+ },
91
+ output: {
92
+ scripts: path_1.default.resolve(config.output.scripts),
93
+ plugins: path_1.default.resolve(config.output.plugins),
94
+ include: path_1.default.resolve(config.output.include),
95
+ assets: path_1.default.resolve(config.output.assets)
96
+ },
97
+ include: (0, lodash_1.map)(config.include, function (include) { return path_1.default.resolve(include); }),
98
+ compiler: {
99
+ dir: path_1.default.resolve(config.compiler.dir),
100
+ },
101
+ thirdparty: {
102
+ dir: path_1.default.resolve(config.thirdparty.dir)
103
+ }
104
+ });
105
+ return [2 /*return*/, config];
106
+ }
107
+ });
108
+ });
109
+ }
110
+ exports.default = resolve;
@@ -0,0 +1,45 @@
1
+ export interface IProjectConfig {
2
+ input: {
3
+ scripts: string;
4
+ include: string;
5
+ assets: string;
6
+ };
7
+ output: {
8
+ scripts: string;
9
+ plugins: string;
10
+ include: string;
11
+ assets: string;
12
+ };
13
+ compiler: {
14
+ dir: string;
15
+ version: string;
16
+ addons: [];
17
+ dev: boolean;
18
+ executable: string;
19
+ };
20
+ thirdparty: {
21
+ dir: string;
22
+ dependencies: {
23
+ name: string;
24
+ url: string;
25
+ }[];
26
+ };
27
+ include: string[];
28
+ rules: {
29
+ flatCompilation: boolean;
30
+ };
31
+ cli: {
32
+ templates: {
33
+ context: {
34
+ [key: string]: string;
35
+ };
36
+ files?: {
37
+ includeDirective?: string;
38
+ include?: string;
39
+ libraryInclude?: string;
40
+ libraryScript?: string;
41
+ script?: string;
42
+ };
43
+ };
44
+ };
45
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export default function accumulator(): (data?: string | undefined) => string;
1
+ declare function accumulator(): (data?: string) => string;
2
+ export default accumulator;
@@ -1,10 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function accumulator() {
4
- var value = '';
5
- return function (data) {
6
- value += (data || '');
7
- return value;
8
- };
9
- }
10
- exports.default = accumulator;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function accumulator() {
4
+ var value = '';
5
+ return function (data) {
6
+ value += (data || '');
7
+ return value;
8
+ };
9
+ }
10
+ exports.default = accumulator;
@@ -0,0 +1,6 @@
1
+ interface IDownloadResult {
2
+ url: string;
3
+ path: string;
4
+ }
5
+ declare function download(url: string, filePath: string): Promise<IDownloadResult>;
6
+ export default download;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var path_1 = __importDefault(require("path"));
43
+ var download_1 = __importDefault(require("download"));
44
+ var mkdirp_1 = __importDefault(require("mkdirp"));
45
+ function download(url, filePath) {
46
+ return __awaiter(this, void 0, void 0, function () {
47
+ var _a, dir, filename;
48
+ return __generator(this, function (_b) {
49
+ switch (_b.label) {
50
+ case 0:
51
+ _a = path_1.default.parse(filePath), dir = _a.dir, filename = _a.base;
52
+ return [4 /*yield*/, (0, mkdirp_1.default)(dir)];
53
+ case 1:
54
+ _b.sent();
55
+ return [4 /*yield*/, (0, download_1.default)(url, dir, { filename: filename })];
56
+ case 2:
57
+ _b.sent();
58
+ return [2 /*return*/, { url: url, path: filePath }];
59
+ }
60
+ });
61
+ });
62
+ }
63
+ exports.default = download;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "amxxpack",
3
3
  "description": "AMXXPack",
4
4
  "author": "Hedgehog Fog",
5
- "version": "0.1.2",
5
+ "version": "1.0.0",
6
6
  "license": "MIT",
7
7
  "main": "lib/builder/index.js",
8
8
  "types": "lib/builder/index.d.ts",
@@ -11,6 +11,7 @@
11
11
  "resources/**/*"
12
12
  ],
13
13
  "scripts": {
14
+ "test": "jest",
14
15
  "build": "tsc",
15
16
  "lint": "eslint",
16
17
  "prepare": "npm run build"
@@ -38,6 +39,7 @@
38
39
  "colors": "^1.4.0",
39
40
  "commander": "^9.0.0",
40
41
  "decompress": "^4.2.1",
42
+ "download": "^8.0.0",
41
43
  "glob": "^7.2.0",
42
44
  "glob-promise": "^4.2.2",
43
45
  "lodash": "^4.17.21",
@@ -49,6 +51,8 @@
49
51
  "@types/colors": "^1.2.1",
50
52
  "@types/commander": "^2.12.2",
51
53
  "@types/decompress": "^4.2.4",
54
+ "@types/download": "^8.0.1",
55
+ "@types/jest": "^27.4.1",
52
56
  "@types/lodash": "^4.14.178",
53
57
  "@types/mkdirp": "^1.0.2",
54
58
  "@types/normalize-path": "^3.0.0",
@@ -58,6 +62,8 @@
58
62
  "eslint-config-airbnb-base": "^15.0.0",
59
63
  "eslint-config-airbnb-typescript": "^16.1.0",
60
64
  "eslint-plugin-import": "^2.25.4",
65
+ "jest": "^27.5.1",
66
+ "ts-jest": "^27.1.3",
61
67
  "typescript": "^4.5.5"
62
68
  }
63
69
  }
@@ -0,0 +1 @@
1
+ #include <{{FILE}}>
@@ -0,0 +1,5 @@
1
+ #if defined _{{FILE_NAME}}_included
2
+ #endinput
3
+ #endif
4
+ #define _{{FILE_NAME}}_included
5
+
@@ -0,0 +1,6 @@
1
+ #if defined _{{LIBRARY_NAME}}_included
2
+ #endinput
3
+ #endif
4
+ #define _{{LIBRARY_NAME}}_included
5
+
6
+ #pragma reqlib {{LIBRARY_NAME}}
@@ -0,0 +1,10 @@
1
+ {{INCLUDES}}
2
+ #include <{{INCLUDE_NAME}}>
3
+
4
+ public plugin_init() {
5
+ register_plugin("{{PLUGIN_NAME}}", "{{PLUGIN_VERSION}}", "{{PLUGIN_AUTHOR}}");
6
+ }
7
+
8
+ public plugin_native() {
9
+ register_library("{{LIBRARY_NAME}}");
10
+ }
@@ -0,0 +1,5 @@
1
+ {{INCLUDES}}
2
+
3
+ public plugin_init() {
4
+ register_plugin("{{PLUGIN_NAME}}", "{{PLUGIN_VERSION}}", "{{PLUGIN_AUTHOR}}");
5
+ }
@@ -1,20 +0,0 @@
1
- export interface IAmxxBuilderConfig {
2
- compiler: {
3
- executable: string;
4
- include: string[];
5
- };
6
- input: {
7
- scripts: string;
8
- include: string;
9
- assets: string;
10
- };
11
- output: {
12
- scripts: string;
13
- plugins: string;
14
- include: string;
15
- assets: string;
16
- };
17
- rules?: {
18
- flatCompilation?: boolean;
19
- };
20
- }
@@ -1,12 +0,0 @@
1
- export declare const DOWNLOAD_HOST = "https://www.amxmodx.org";
2
- export declare const SCRIPTING_DIR = "addons/amxmodx/scripting/";
3
- export declare const EXTENSIONS_IGNORE_LIST: string[];
4
- export declare enum CompilerPlatform {
5
- Windows = "windows",
6
- Linux = "linux",
7
- Mac = "mac"
8
- }
9
- export declare enum DistSource {
10
- Dev = "amxxdrop",
11
- Release = "release"
12
- }
@@ -1,2 +0,0 @@
1
- import { IDownloadCompilerOptions } from './types';
2
- export default function downloadCompiler(options: IDownloadCompilerOptions): Promise<void>;
@@ -1,22 +0,0 @@
1
- {
2
- "compiler": {
3
- "executable": "./compiler/amxxpc.exe",
4
- "include": [
5
- "./compiler/include"
6
- ]
7
- },
8
- "input": {
9
- "scripts": "./src/scripts",
10
- "include": "./src/include",
11
- "assets": "./assets"
12
- },
13
- "output": {
14
- "scripts": "./dist/addons/amxmodx/scripting",
15
- "plugins": "./dist/addons/amxmodx/plugins",
16
- "include": "./dist/addons/amxmodx/scripting/include",
17
- "assets": "./dist"
18
- },
19
- "rules": {
20
- "flatCompilation": true
21
- }
22
- }