ics-builder 4.2.4 → 4.2.5

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.2.4",
3
+ "version": "4.2.5",
4
4
  "description": "",
5
5
  "main": "./src/app.js",
6
6
  "preferGlobal": true,
@@ -33,10 +33,10 @@ var DotnetApiBuilder = /** @class */ (function (_super) {
33
33
  }
34
34
  else {
35
35
  this.config.packages.forEach(function (pkg) {
36
- var packageInfo = _this.parsePackageInfoLegacy(path.join(_this.config.paths.source, pkg.name, "package.yml"));
37
- if (packageInfo && packageInfo.api && packageInfo.api.project) {
36
+ var pkgInfo = pkg.packageInfo;
37
+ if (pkgInfo.api && pkgInfo.api.project) {
38
38
  var apiSourceDir = path.join(_this.config.paths.source, pkg.name, "api");
39
- _this.buildApiModule(path.dirname(path.join(apiSourceDir, packageInfo.api.project)), pkg.name);
39
+ _this.buildApiModule(path.dirname(path.join(apiSourceDir, pkgInfo.api.project)), pkg.name);
40
40
  }
41
41
  else {
42
42
  _this.buildApiModules(pkg);
@@ -46,35 +46,41 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
46
46
  this._build();
47
47
  };
48
48
  Net5ApiBuilder.prototype._build = function () {
49
- var _this = this;
50
- var _a, _b;
49
+ var _a;
51
50
  if (this.modules.length == 0) {
52
51
  utils_1.Logger.warn("Api layer not found, skipping.");
53
52
  return;
54
53
  }
55
- var coreModule = (_a = this.modules.find(function (m) { return m.IsCoreModule; })) !== null && _a !== void 0 ? _a : this.modules[0];
54
+ var configuration = ((_a = this.config.api) === null || _a === void 0 ? void 0 : _a.configuration) || "Debug";
55
+ this._buildProjects(configuration);
56
+ this._buildSolutions(configuration);
57
+ };
58
+ Net5ApiBuilder.prototype._buildProjects = function (configuration) {
59
+ var _this = this;
60
+ var _a;
61
+ var coreModule = (_a = this.modules.find(function (m) { return m.isCoreModule; })) !== null && _a !== void 0 ? _a : this.modules[0];
56
62
  var slnName = "Mdt";
57
- var slnDir = path.dirname(coreModule.Project);
58
- var configuration = ((_b = this.config.api) === null || _b === void 0 ? void 0 : _b.configuration) || "Debug";
63
+ var slnDir = path.dirname(coreModule.buildFile.path);
59
64
  var tempSlnPath = path.join(slnDir, slnName + ".sln");
65
+ var projects = this.modules.map(function (m) { return m.buildFile; }).filter(function (f) { return f.type == ApiModuleBuildFileType.Project; });
60
66
  try {
61
67
  dotnetUtils_1.DotnetUtils.createTempSln(slnDir, slnName);
62
- for (var _i = 0, _c = this.modules; _i < _c.length; _i++) {
63
- var m = _c[_i];
64
- var csproj = new csprojFile_1.CsprojFile(m.Project);
65
- csproj.setPublishPath(m.OutputPath);
66
- csproj.save(m.Project);
68
+ for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) {
69
+ var p = projects_1[_i];
70
+ var csproj = new csprojFile_1.CsprojFile(p.path);
71
+ csproj.setPublishPath(p.outputPath);
72
+ csproj.save(p.path);
67
73
  }
68
- dotnetUtils_1.DotnetUtils.addProjectsToSln(tempSlnPath, this.modules.map(function (m) { return m.Project; }));
74
+ dotnetUtils_1.DotnetUtils.addProjectsToSln(tempSlnPath, projects.map(function (p) { return p.path; }));
69
75
  dotnetUtils_1.DotnetUtils.restoreNugetPackages(tempSlnPath);
70
76
  dotnetUtils_1.DotnetUtils.publish(tempSlnPath, configuration);
71
- var webConfigFilePath = path.join(coreModule.OutputPath, "web.config");
77
+ var webConfigFilePath = path.join(coreModule.buildFile.outputPath, "web.config");
72
78
  var webConfigFile = new webConfigFile_1.WebConfigFile(webConfigFilePath);
73
79
  webConfigFile.addDotnetProcessPath();
74
80
  webConfigFile.save();
75
- this.modules.filter(function (m) { return !m.IsCoreModule; }).forEach(function (m) {
76
- var projectDir = path.dirname(m.Project);
77
- _this.copyModuleConfig(projectDir, m.OutputPath, _this.configFile);
81
+ projects.filter(function (p) { return p.path != coreModule.buildFile.path; }).forEach(function (p) {
82
+ var projectDir = path.dirname(p.path);
83
+ _this.copyModuleConfig(projectDir, p.outputPath, _this.configFile);
78
84
  });
79
85
  this.emptyModulesWithConfig.forEach(function (val, key) {
80
86
  _this.copyModuleConfig(val, path.join(_this.buildApiFolder, "modules", key), _this.configFile);
@@ -84,6 +90,16 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
84
90
  utils_1.Utils.deleteFile(tempSlnPath);
85
91
  }
86
92
  };
93
+ Net5ApiBuilder.prototype._buildSolutions = function (configuration) {
94
+ var solutions = this.modules.map(function (m) { return m.buildFile; }).filter(function (f) { return f.type == ApiModuleBuildFileType.Solution; });
95
+ if (solutions.length == 0)
96
+ return;
97
+ utils_1.Logger.info("building additional solutions");
98
+ solutions.forEach(function (solution) {
99
+ dotnetUtils_1.DotnetUtils.restoreNugetPackages(solution.path);
100
+ dotnetUtils_1.DotnetUtils.publish(solution.path, configuration, solution.outputPath);
101
+ });
102
+ };
87
103
  Net5ApiBuilder.prototype.collectModuleInfo = function (pkg) {
88
104
  var _this = this;
89
105
  packageStructureManager_1.packageStructureManager.getModuleSourcePaths(pkg, "api", this.config).forEach(function (_a) {
@@ -138,14 +154,27 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
138
154
  }(baseBuilder_1.BaseBuilder));
139
155
  exports.Net5ApiBuilder = Net5ApiBuilder;
140
156
  var ApiModuleInfo = /** @class */ (function () {
141
- function ApiModuleInfo(pkg, module, project, buildApiFolder) {
142
- this.Package = pkg;
143
- this.Module = module;
144
- this.Project = project;
145
- this.IsCoreModule = module.name == "_core" && pkg == "mdt";
146
- this.OutputPath = this.IsCoreModule
157
+ function ApiModuleInfo(pkg, module, buildFilePath, buildApiFolder) {
158
+ this.package = pkg;
159
+ this.module = module;
160
+ this.isCoreModule = module.name == "_core" && pkg == "mdt";
161
+ var outputPath = this.isCoreModule
147
162
  ? buildApiFolder
148
- : path.join(buildApiFolder, "modules", utils_1.Utils.getFileName(project));
163
+ : path.join(buildApiFolder, "modules", utils_1.Utils.getFileName(buildFilePath));
164
+ this.buildFile = new ApiModuleBuildFile(buildFilePath, outputPath);
149
165
  }
150
166
  return ApiModuleInfo;
151
167
  }());
168
+ var ApiModuleBuildFile = /** @class */ (function () {
169
+ function ApiModuleBuildFile(path, outputPath) {
170
+ this.path = path;
171
+ this.outputPath = outputPath;
172
+ this.type = path.endsWith(".csproj") ? ApiModuleBuildFileType.Project : ApiModuleBuildFileType.Solution;
173
+ }
174
+ return ApiModuleBuildFile;
175
+ }());
176
+ var ApiModuleBuildFileType;
177
+ (function (ApiModuleBuildFileType) {
178
+ ApiModuleBuildFileType[ApiModuleBuildFileType["Project"] = 0] = "Project";
179
+ ApiModuleBuildFileType[ApiModuleBuildFileType["Solution"] = 1] = "Solution";
180
+ })(ApiModuleBuildFileType || (ApiModuleBuildFileType = {}));
@@ -10,7 +10,11 @@ var XmlFile = /** @class */ (function () {
10
10
  XmlFile.prototype._readFile = function () {
11
11
  var _this = this;
12
12
  var file = fs.readFileSync(this._path);
13
- xml2js.parseString(file, { explicitArray: false }, function (err, result) { return _this._xmlObj = result; });
13
+ xml2js.parseString(file, { explicitArray: false }, function (err, result) {
14
+ if (err)
15
+ throw new Error("Error while parsing xml file " + _this._path + ":\n" + err.message);
16
+ _this._xmlObj = result;
17
+ });
14
18
  };
15
19
  XmlFile.prototype.save = function (path) {
16
20
  if (path === void 0) { path = null; }
@@ -15,9 +15,6 @@ var BaseBuilder = /** @class */ (function () {
15
15
  BaseBuilder.prototype.parsePackageInfoLegacy = function (path) {
16
16
  return utils_1.Utils.ensurePath(path) ? yaml.load(path) : {};
17
17
  };
18
- BaseBuilder.prototype.parsePackageInfo = function (path) {
19
- return utils_1.Utils.ensurePath(path) ? yaml.load(path) : {};
20
- };
21
18
  BaseBuilder.prototype.writeBuildInfo = function (targetPath, object, mode) {
22
19
  fs.writeFileSync(targetPath.replace(new RegExp("." + mode.replace("yml", "ya?ml") + "$"), "").concat("." + mode), mode === "json" ? JSON.stringify(object, null, "\t") : yaml.stringify(object));
23
20
  };
@@ -25,11 +25,11 @@ var CustomUiBuilder = /** @class */ (function (_super) {
25
25
  CustomUiBuilder.prototype.run = function () {
26
26
  var _this = this;
27
27
  this.config.packages.forEach(function (pkg) {
28
- var _a, _b;
28
+ var _a, _b, _c, _d;
29
29
  var packageDir = path.join(_this.config.paths.source, pkg.name);
30
- var packageInfo = _this.parsePackageInfo(path.join(packageDir, "package.yml"));
31
- var buildDir = path.join(packageDir, (packageInfo.builder.ui.path || "").replace(pkg.name, ""));
32
- var cmd = ((_b = (_a = packageInfo === null || packageInfo === void 0 ? void 0 : packageInfo.builder) === null || _a === void 0 ? void 0 : _a.ui) === null || _b === void 0 ? void 0 : _b.cmd) || "";
30
+ var pkgInfo = pkg.packageInfo;
31
+ var buildDir = path.join(packageDir, (((_b = (_a = pkgInfo === null || pkgInfo === void 0 ? void 0 : pkgInfo.builder) === null || _a === void 0 ? void 0 : _a.ui) === null || _b === void 0 ? void 0 : _b.path) || "").replace(pkg.name, ""));
32
+ var cmd = ((_d = (_c = pkgInfo === null || pkgInfo === void 0 ? void 0 : pkgInfo.builder) === null || _c === void 0 ? void 0 : _c.ui) === null || _d === void 0 ? void 0 : _d.cmd) || "";
33
33
  var envArgs = _this.prepareEnvArgs();
34
34
  if (envArgs.length)
35
35
  cmd = _this.prepareCmd(cmd, envArgs);
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BuildManager = void 0;
4
- var path = require("path");
5
- var yaml = require("yamljs");
6
4
  var utils_1 = require("../utils");
7
5
  var dotnetApiBuilder_1 = require("../builder/api/dotnetApiBuilder");
8
6
  var dbBuilder_1 = require("../builder/db/dbBuilder");
@@ -75,18 +73,14 @@ var BuildManager = /** @class */ (function () {
75
73
  var layerBuilders = new Map();
76
74
  var packages = this.packageManager.getAllPackages();
77
75
  packages.forEach(function (pkg) {
78
- var packageInfoPath = path.join(_this.config.paths.source, pkg.name, "package.yml");
79
- if (utils_1.Utils.ensurePath(packageInfoPath)) {
80
- var packageInfo = yaml.load(packageInfoPath);
81
- packageInfo = packageInfo || {};
82
- var newVersionOfPackageYaml = !packageInfo.api;
83
- if (newVersionOfPackageYaml && packageInfo.builder && packageInfo.builder[layer]) {
84
- var layerInfo = packageInfo.builder[layer];
85
- layerInfo.path = layerInfo.path || layer;
86
- var builderType_1 = layerInfo.type || _this.getDefaultBuilder(layer);
87
- _this.updateLayerBuilder(layer, builderType_1, layerBuilders, pkg);
88
- return;
89
- }
76
+ var newVersionOfPackageYaml = !pkg.packageInfo.api;
77
+ var pkgInfo = pkg.packageInfo;
78
+ if (newVersionOfPackageYaml && pkgInfo.builder && pkgInfo.builder[layer]) {
79
+ var layerInfo = pkgInfo.builder[layer];
80
+ layerInfo.path = layerInfo.path || layer;
81
+ var builderType_1 = layerInfo.type || _this.getDefaultBuilder(layer);
82
+ _this.updateLayerBuilder(layer, builderType_1, layerBuilders, pkg);
83
+ return;
90
84
  }
91
85
  var builderType = _this.getDefaultBuilder(layer);
92
86
  _this.updateLayerBuilder(layer, builderType, layerBuilders, pkg);
@@ -36,7 +36,8 @@ var PackageManager = /** @class */ (function () {
36
36
  var mainPackage = this.config.package;
37
37
  if (!skipload)
38
38
  this.sourceManager.loadSource(mainPackage, skipload);
39
- var pkgDependencies = this.getPackageDependencies(mainPackage.name, skipload);
39
+ mainPackage.packageInfo = this.getPackageInfo(mainPackage.name);
40
+ var pkgDependencies = this.getPackageDependencies(mainPackage, skipload);
40
41
  packageStructureManager_1.packageStructureManager.writePackageStructureInfo(mainPackage, this.config);
41
42
  this.packages.set(mainPackage.name, this.preparePackageModules(mainPackage, pkgDependencies));
42
43
  }
@@ -56,22 +57,19 @@ var PackageManager = /** @class */ (function () {
56
57
  pkg.url = packageName;
57
58
  }
58
59
  _this.sourceManager.loadSource(pkg, skipload);
59
- var pkgDependencies = _this.getPackageDependencies(packageName, skipload);
60
+ pkg.packageInfo = _this.getPackageInfo(pkg.name);
61
+ var pkgDependencies = _this.getPackageDependencies(pkg, skipload);
60
62
  packageStructureManager_1.packageStructureManager.writePackageStructureInfo(pkg, _this.config);
61
63
  _this.packages.set(packageName, _this.preparePackageModules(pkg, pkgDependencies));
62
64
  });
63
65
  }
64
66
  };
65
- PackageManager.prototype.getPackageDependencies = function (packageName, skipload) {
66
- var pkgDependencies = null;
67
- var pkgInfoPath = this.getPackageInfoPath(packageName);
68
- if (utils_1.Utils.ensurePath(pkgInfoPath)) {
69
- var pkgInfo = yaml.load(pkgInfoPath);
70
- pkgDependencies = pkgInfo.modules;
71
- if (pkgInfo.using) {
72
- delete pkgInfo.using[packageName];
73
- this.loadPackages(pkgInfo.using, pkgInfoPath, skipload);
74
- }
67
+ PackageManager.prototype.getPackageDependencies = function (pkg, skipload) {
68
+ var pkgDependencies = pkg.packageInfo.modules;
69
+ var using = pkg.packageInfo.using;
70
+ if (using) {
71
+ delete using[pkg.name];
72
+ this.loadPackages(using, this.getPackageInfoPath(pkg.name), skipload);
75
73
  }
76
74
  return pkgDependencies;
77
75
  };
@@ -134,8 +132,17 @@ var PackageManager = /** @class */ (function () {
134
132
  var _this = this;
135
133
  return packages.sort(function (prev, curr) { return _this.config.packagesOrder.indexOf(prev.name) - _this.config.packagesOrder.indexOf(curr.name); });
136
134
  };
135
+ PackageManager.prototype.getPackageInfo = function (packageName) {
136
+ var pkgInfoPath = this.getPackageInfoPath(packageName);
137
+ return utils_1.Utils.ensurePath(pkgInfoPath) ? yaml.load(pkgInfoPath) : {};
138
+ };
137
139
  PackageManager.prototype.getPackageInfoPath = function (packageName) {
138
- return path.join(this.config.paths.source, packageName, "package.yml");
140
+ var packagePath = path.join(this.config.paths.source, packageName);
141
+ var packageInfoPath = path.join(packagePath, "package.yml");
142
+ if (utils_1.Utils.ensurePath(packageInfoPath))
143
+ return packageInfoPath;
144
+ packageInfoPath = path.join(packagePath, "package.yaml");
145
+ return packageInfoPath;
139
146
  };
140
147
  return PackageManager;
141
148
  }());