ics-builder 4.1.95 → 4.1.99

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ics-builder",
3
- "version": "4.1.95",
3
+ "version": "4.1.99",
4
4
  "description": "",
5
5
  "main": "./src/app.js",
6
6
  "preferGlobal": true,
@@ -87,10 +87,8 @@ var DotnetApiBuilder = /** @class */ (function (_super) {
87
87
  var configuration = (this.config.api && this.config.api.configuration) || "debug";
88
88
  moduleDir = path.dirname(projectFile);
89
89
  var projectBinDir_1 = path.join(moduleDir, "bin");
90
- var projectObjDir = path.join(moduleDir, "obj");
91
90
  var webAppPath = path.join(moduleDir, "global.asax");
92
- utils_1.Utils.clearFolder(projectBinDir_1);
93
- utils_1.Utils.clearFolder(projectObjDir);
91
+ this.clearCache(moduleDir);
94
92
  if (utils_1.Utils.ensurePath(webAppPath)) {
95
93
  utils_1.Utils.copyFile(path.join(moduleDir, "web.config.template"), path.join(moduleDir, "web.config"));
96
94
  }
@@ -136,6 +134,10 @@ var DotnetApiBuilder = /** @class */ (function (_super) {
136
134
  skipLog: true
137
135
  });
138
136
  };
137
+ DotnetApiBuilder.prototype.clearCache = function (folderPath) {
138
+ utils_1.Utils.deleteAllFoldersRecursively(folderPath, "bin");
139
+ utils_1.Utils.deleteAllFoldersRecursively(folderPath, "obj");
140
+ };
139
141
  return DotnetApiBuilder;
140
142
  }(baseBuilder_1.BaseBuilder));
141
143
  exports.DotnetApiBuilder = DotnetApiBuilder;
@@ -28,6 +28,7 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
28
28
  var _this = _super.call(this, config) || this;
29
29
  _this.modules = new Array();
30
30
  _this.allProjects = [];
31
+ _this.emptyModulesWithConfig = new Map();
31
32
  _this.configFile = "appsettings.json";
32
33
  _this.buildApiFolder = path.join(_this.config.paths.build, "api");
33
34
  shell.config.silent = true;
@@ -56,7 +57,6 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
56
57
  dotnetUtils_1.DotnetUtils.createTempSln(slnDir, slnName);
57
58
  for (var _i = 0, _b = this.modules; _i < _b.length; _i++) {
58
59
  var m = _b[_i];
59
- utils_1.Utils.copyFile(m.Project, m.TempProject);
60
60
  var csproj = new csprojFile_1.CsprojFile(m.Project);
61
61
  csproj.setPublishPath(m.OutputPath);
62
62
  csproj.save(m.Project);
@@ -72,13 +72,12 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
72
72
  var projectDir = path.dirname(m.Project);
73
73
  _this.copyModuleConfig(projectDir, m.OutputPath, _this.configFile);
74
74
  });
75
+ this.emptyModulesWithConfig.forEach(function (val, key) {
76
+ _this.copyModuleConfig(val, path.join(_this.buildApiFolder, "modules", key), _this.configFile);
77
+ });
75
78
  }
76
79
  finally {
77
80
  utils_1.Utils.deleteFile(tempSlnPath);
78
- this.modules.forEach(function (m) {
79
- utils_1.Utils.copyFile(m.TempProject, m.Project);
80
- utils_1.Utils.deleteFile(m.TempProject);
81
- });
82
81
  }
83
82
  };
84
83
  Net5ApiBuilder.prototype.collectModuleInfo = function (pkg) {
@@ -88,10 +87,8 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
88
87
  _this.writeModulesProjects(pkg.name, pkg.modules.find(function (m) { return m.name == moduleName; }), sourcePath);
89
88
  });
90
89
  };
91
- Net5ApiBuilder.prototype.writeModulesProjects = function (pkg, md, modulePath) {
92
- var _this = this;
90
+ Net5ApiBuilder.prototype.writeModulesProjects = function (packageName, module, modulePath) {
93
91
  var _a;
94
- var projectFile = new Array();
95
92
  var moduleConfig = this.parsePackageInfoLegacy(path.join(modulePath, "module.yml"));
96
93
  if ((_a = moduleConfig === null || moduleConfig === void 0 ? void 0 : moduleConfig.api) === null || _a === void 0 ? void 0 : _a.project) {
97
94
  var csprojPath = path.join(modulePath, moduleConfig.api.project);
@@ -99,32 +96,39 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
99
96
  utils_1.Logger.error(csprojPath + " does not exist");
100
97
  return;
101
98
  }
102
- this.modules.push(new ApiModuleInfo(pkg, md, csprojPath, this.buildApiFolder));
103
- projectFile.push(csprojPath);
99
+ this.modules.push(new ApiModuleInfo(packageName, module, csprojPath, this.buildApiFolder));
104
100
  }
105
101
  else {
106
- var files_1 = shell.ls(path.join(modulePath, "*.sln"));
107
- if (files_1.length) {
108
- this.modules.push(new ApiModuleInfo(pkg, md, files_1[0], this.buildApiFolder));
109
- return;
110
- }
111
- files_1 = shell.ls(path.join(modulePath, "*.csproj"));
112
- if (files_1.length) {
113
- this.modules.push(new ApiModuleInfo(pkg, md, files_1[0], this.buildApiFolder));
102
+ var files = shell.ls(path.join(modulePath, "*.sln"));
103
+ if (files.length) {
104
+ this.modules.push(new ApiModuleInfo(packageName, module, files[0], this.buildApiFolder));
114
105
  }
115
106
  else {
116
- utils_1.Logger.warn("Module " + md.name + " does not have .csproj file and will be skipped");
117
- return;
107
+ files = shell.ls(path.join(modulePath, "*.csproj"));
108
+ if (files.length) {
109
+ this.modules.push(new ApiModuleInfo(packageName, module, files[0], this.buildApiFolder));
110
+ }
111
+ else {
112
+ utils_1.Logger.warn("Module " + module.name + " does not have .csproj file and will be skipped");
113
+ var configFile = path.join(modulePath, this.configFile);
114
+ if (utils_1.Utils.ensurePath(configFile))
115
+ this.emptyModulesWithConfig.set(packageName + "." + module.name, modulePath);
116
+ return;
117
+ }
118
118
  }
119
119
  }
120
+ this.addProjectFiles(modulePath);
121
+ };
122
+ Net5ApiBuilder.prototype.addProjectFiles = function (modulePath) {
123
+ var _this = this;
120
124
  var files = shell.ls(path.join(modulePath, "*.csproj"), path.join(modulePath, "*", "*.csproj"));
121
125
  files.forEach(function (f) {
122
126
  _this.allProjects.push(f);
123
127
  });
124
128
  };
125
129
  Net5ApiBuilder.prototype.clearCache = function (folderPath) {
126
- utils_1.Utils.clearFolder(path.join(folderPath, "bin"));
127
- utils_1.Utils.clearFolder(path.join(folderPath, "obj"));
130
+ utils_1.Utils.deleteAllFoldersRecursively(folderPath, "bin");
131
+ utils_1.Utils.deleteAllFoldersRecursively(folderPath, "obj");
128
132
  };
129
133
  return Net5ApiBuilder;
130
134
  }(baseBuilder_1.BaseBuilder));
@@ -134,8 +138,6 @@ var ApiModuleInfo = /** @class */ (function () {
134
138
  this.Package = pkg;
135
139
  this.Module = module;
136
140
  this.Project = project;
137
- var dir = path.dirname(project);
138
- this.TempProject = path.join(dir, utils_1.Utils.getFileName(project) + "_temp.csproj");
139
141
  this.IsCoreModule = module.name == "_core" && pkg == "mdt";
140
142
  this.OutputPath = this.IsCoreModule
141
143
  ? buildApiFolder
@@ -61,7 +61,6 @@ var autoprefixer = require("autoprefixer");
61
61
  var webpack = require("webpack");
62
62
  var WebpackDevServer = require("webpack-dev-server");
63
63
  var path = require("path");
64
- var shell = require("shelljs");
65
64
  var glob = require("glob");
66
65
  var yaml = require("yamljs");
67
66
  var fs = require("fs");
@@ -72,7 +71,6 @@ var WebpackUiBuilder = /** @class */ (function (_super) {
72
71
  __extends(WebpackUiBuilder, _super);
73
72
  function WebpackUiBuilder(config) {
74
73
  var _this = _super.call(this, config) || this;
75
- _this.nodeModulesPaths = new Array();
76
74
  _this.isLegacy = false;
77
75
  return _this;
78
76
  }
@@ -126,6 +124,9 @@ var WebpackUiBuilder = /** @class */ (function (_super) {
126
124
  .getModuleSourcePaths(p, "ui", _this.config)
127
125
  .forEach(function (_a) {
128
126
  var moduleName = _a.moduleName, sourcePath = _a.sourcePath;
127
+ var packagePath = path.join(sourcePath, "package.json");
128
+ if (!utils_1.Utils.ensurePath(packagePath))
129
+ return;
129
130
  utils_1.Utils.exec("npm run build", { cwd: sourcePath });
130
131
  var moduleFile = path.join(sourcePath, "dist/module.js");
131
132
  var outputModuleFile = path.join(outputModulesPath, p.name, p.isSingleModule ? "index.js" : path.join(moduleName, "index.js"));
@@ -353,36 +354,6 @@ var WebpackUiBuilder = /** @class */ (function (_super) {
353
354
  }
354
355
  };
355
356
  };
356
- WebpackUiBuilder.prototype.checkNpm = function (dir) {
357
- var _this = this;
358
- var packageJsons = glob.sync(dir).filter(function (x) { return x; });
359
- if (packageJsons.length) {
360
- packageJsons.forEach(function (pkg) {
361
- utils_1.Logger.info("Found package.json at path " + path.dirname(pkg) + ", install dependecies...");
362
- var nodeModulesPath = path.join(path.dirname(pkg), "node_modules");
363
- _this.nodeModulesPaths.push(nodeModulesPath);
364
- });
365
- if (this.nodeModulesPaths.every(function (dir) {
366
- return utils_1.Utils.ensurePath(dir);
367
- }))
368
- return true;
369
- this.nodeModulesPaths
370
- .filter(function (dir) {
371
- return !utils_1.Utils.ensurePath(dir);
372
- })
373
- .forEach(function (dir) {
374
- utils_1.Utils.exec("npm install --no-save", { cwd: path.dirname(dir), silent: true });
375
- });
376
- return true;
377
- }
378
- return false;
379
- };
380
- WebpackUiBuilder.prototype.removeNodeModules = function (paths) {
381
- utils_1.Logger.info("Removing " + paths.join("\n"));
382
- paths.forEach(function (p) {
383
- shell.rm("-rf", p);
384
- });
385
- };
386
357
  WebpackUiBuilder.prototype.importThemes = function (modules, theme) {
387
358
  var themesDir = "_core/themes";
388
359
  return ("@import '" + path.join(themesDir, "_base/vars.less") + "';\n").concat("@import '" + path.join(themesDir, theme + "/vars.less") + "';\n", modules.map(function (module) { return "@import '" + module + "';"; }).join("\n") + "\n", "@import '" + path.join(themesDir, "_base/theme.less") + "';\n", "@import '" + path.join(themesDir, theme + "/theme.less") + "';\n");
package/src/utils.js CHANGED
@@ -188,6 +188,20 @@ var Utils = /** @class */ (function () {
188
188
  }
189
189
  return res;
190
190
  };
191
+ Utils.deleteAllFoldersRecursively = function (cwd, folderName) {
192
+ var _this = this;
193
+ var files = fs.readdirSync(cwd, { withFileTypes: true });
194
+ files.forEach(function (f) {
195
+ if (!f.isDirectory())
196
+ return;
197
+ var dirFullPath = path.join(cwd, f.name);
198
+ if (f.name == folderName) {
199
+ Utils.clearFolder(dirFullPath);
200
+ return;
201
+ }
202
+ _this.deleteAllFoldersRecursively(dirFullPath, folderName);
203
+ });
204
+ };
191
205
  Utils.getFileName = function (path) {
192
206
  var _a, _b;
193
207
  return (_b = (_a = path.match(/([^\\/]+?)(\.[^.\\/]+)?$/)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : "";