amxxpack 1.0.1 → 1.0.2

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 CHANGED
@@ -28,11 +28,11 @@ npm install -g amxxpack
28
28
 
29
29
  ## ▶ Quick start
30
30
  - Open a terminal inside the project directory (existing or create a new one)
31
- - Execute `npm install amxxpack --save-dev` command to install `amxxpack` locally
32
- - Execute `npx amxxpack create .` command to create new config
33
- - Execute `npx amxxpack install` to download project dependencies (compiler, thirdparty etc.)
34
- - Use `npm run build` command to build the project
35
- - Use `npm run watch` command to build the project and watch changes
31
+ - Execute `npm install amxxpack -g` command to install `amxxpack` globally
32
+ - Execute `amxxpack create .` command to create new config
33
+ - Execute `amxxpack install` to download project dependencies (compiler, thirdparty etc.)
34
+ - Use `amxxpack build` command to build the project
35
+ - Use `amxxpack watch` command to build the project and watch changes
36
36
 
37
37
  ## 📋 Commands
38
38
  - `amxxpack create <name>` - create new project
@@ -283,7 +283,7 @@ var AmxxBuilder = /** @class */ (function () {
283
283
  return [4 /*yield*/, (0, glob_promise_1.default)(pathPattern)];
284
284
  case 1:
285
285
  matches = _a.sent();
286
- return [2 /*return*/, matches];
286
+ return [2 /*return*/, matches.filter(function (filePath) { return path_1.default.extname(filePath) === '.sma'; })];
287
287
  }
288
288
  });
289
289
  });
@@ -97,8 +97,7 @@ var Controller = /** @class */ (function () {
97
97
  };
98
98
  Controller.prototype.compile = function (scriptPath, configPath) {
99
99
  return __awaiter(this, void 0, void 0, function () {
100
- var builder, matches;
101
- var _this = this;
100
+ var builder, matches, _i, matches_1, filePath, srcPath;
102
101
  return __generator(this, function (_a) {
103
102
  switch (_a.label) {
104
103
  case 0: return [4 /*yield*/, this.createBuilder(configPath)];
@@ -107,20 +106,20 @@ var Controller = /** @class */ (function () {
107
106
  return [4 /*yield*/, builder.findPlugins(scriptPath)];
108
107
  case 2:
109
108
  matches = _a.sent();
110
- matches.map(function (filePath) { return __awaiter(_this, void 0, void 0, function () {
111
- var srcPath;
112
- return __generator(this, function (_a) {
113
- switch (_a.label) {
114
- case 0:
115
- srcPath = path_1.default.resolve(filePath);
116
- return [4 /*yield*/, builder.compilePlugin(srcPath)];
117
- case 1:
118
- _a.sent();
119
- return [2 /*return*/];
120
- }
121
- });
122
- }); });
123
- return [2 /*return*/];
109
+ _i = 0, matches_1 = matches;
110
+ _a.label = 3;
111
+ case 3:
112
+ if (!(_i < matches_1.length)) return [3 /*break*/, 6];
113
+ filePath = matches_1[_i];
114
+ srcPath = path_1.default.resolve(filePath);
115
+ return [4 /*yield*/, builder.compilePlugin(srcPath)];
116
+ case 4:
117
+ _a.sent();
118
+ _a.label = 5;
119
+ case 5:
120
+ _i++;
121
+ return [3 /*break*/, 3];
122
+ case 6: return [2 /*return*/];
124
123
  }
125
124
  });
126
125
  });
@@ -7,7 +7,7 @@ declare class ProjectCreator {
7
7
  isCurrentDir: boolean;
8
8
  constructor(options?: IProjectOptions);
9
9
  createProject(): Promise<void>;
10
- createPackage(): Promise<void>;
10
+ updatePackage(): Promise<void>;
11
11
  createConfig(): Promise<void>;
12
12
  createDirectories(): Promise<void>;
13
13
  installDependencies(): Promise<void>;
@@ -98,7 +98,7 @@ var ProjectCreator = /** @class */ (function () {
98
98
  case 2:
99
99
  _a.sent();
100
100
  if (!!this.options.nonpm) return [3 /*break*/, 4];
101
- return [4 /*yield*/, this.createPackage()];
101
+ return [4 /*yield*/, this.updatePackage()];
102
102
  case 3:
103
103
  _a.sent();
104
104
  _a.label = 4;
@@ -109,14 +109,14 @@ var ProjectCreator = /** @class */ (function () {
109
109
  _a.sent();
110
110
  _a.label = 6;
111
111
  case 6:
112
- if (!this.isNpmPackageInitialized()) return [3 /*break*/, 8];
113
- return [4 /*yield*/, this.installDependencies()];
112
+ if (!this.isGitInitialized()) return [3 /*break*/, 8];
113
+ return [4 /*yield*/, this.updateGitignore()];
114
114
  case 7:
115
115
  _a.sent();
116
116
  _a.label = 8;
117
117
  case 8:
118
- if (!this.isGitInitialized()) return [3 /*break*/, 10];
119
- return [4 /*yield*/, this.updateGitignore()];
118
+ if (!this.isNpmPackageInitialized()) return [3 /*break*/, 10];
119
+ return [4 /*yield*/, this.installDependencies()];
120
120
  case 9:
121
121
  _a.sent();
122
122
  _a.label = 10;
@@ -127,11 +127,11 @@ var ProjectCreator = /** @class */ (function () {
127
127
  });
128
128
  });
129
129
  };
130
- ProjectCreator.prototype.createPackage = function () {
130
+ ProjectCreator.prototype.updatePackage = function () {
131
131
  return __awaiter(this, void 0, void 0, function () {
132
- var packagePath, packageData;
133
- return __generator(this, function (_a) {
134
- switch (_a.label) {
132
+ var packagePath, packageData, _a, _b, _c, _d, _e;
133
+ return __generator(this, function (_f) {
134
+ switch (_f.label) {
135
135
  case 0:
136
136
  logger_1.default.info('📦 Initializing npm package...');
137
137
  packagePath = path_1.default.join(this.projectDir, 'package.json');
@@ -139,16 +139,34 @@ var ProjectCreator = /** @class */ (function () {
139
139
  name: this.options.name,
140
140
  version: (0, lodash_1.get)(this.options, 'version', '0.1.0'),
141
141
  author: (0, lodash_1.get)(this.options, 'author', 'AMXXPack'),
142
- description: (0, lodash_1.get)(this.options, 'description', 'This project was generated by AMXXPack CLI'),
142
+ description: (0, lodash_1.get)(this.options, 'description', 'This project was generated by AMXXPack CLI')
143
+ };
144
+ if (!fs_1.default.existsSync(packagePath)) return [3 /*break*/, 4];
145
+ _f.label = 1;
146
+ case 1:
147
+ _f.trys.push([1, 3, , 4]);
148
+ _a = lodash_1.merge;
149
+ _b = [packageData];
150
+ _d = (_c = JSON).parse;
151
+ return [4 /*yield*/, fs_1.default.promises.readFile(packagePath, 'utf8')];
152
+ case 2:
153
+ _a.apply(void 0, _b.concat([_d.apply(_c, [_f.sent()])]));
154
+ return [3 /*break*/, 4];
155
+ case 3:
156
+ _e = _f.sent();
157
+ logger_1.default.error('Cannot read package.json file');
158
+ return [3 /*break*/, 4];
159
+ case 4:
160
+ (0, lodash_1.merge)(packageData, {
143
161
  scripts: {
144
162
  build: 'amxxpack build',
145
163
  watch: 'amxxpack build --watch',
146
164
  postinstall: 'amxxpack install'
147
165
  }
148
- };
166
+ });
149
167
  return [4 /*yield*/, fs_1.default.promises.writeFile(packagePath, JSON.stringify(packageData, null, 2))];
150
- case 1:
151
- _a.sent();
168
+ case 5:
169
+ _f.sent();
152
170
  return [2 /*return*/];
153
171
  }
154
172
  });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "amxxpack",
3
3
  "description": "AMXXPack",
4
4
  "author": "Hedgehog Fog",
5
- "version": "1.0.1",
5
+ "version": "1.0.2",
6
6
  "license": "MIT",
7
7
  "main": "lib/builder/index.js",
8
8
  "types": "lib/builder/index.d.ts",