ics-builder 4.1.86 → 4.1.90

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.86",
3
+ "version": "4.1.90",
4
4
  "description": "",
5
5
  "main": "./src/app.js",
6
6
  "preferGlobal": true,
@@ -58,7 +58,7 @@
58
58
  "ts-loader": "^6.2.1",
59
59
  "tsconfig-paths-webpack-plugin": "^3.2.0",
60
60
  "typescript": "^3.8.3",
61
- "typescript-json-schema": "^0.43.0",
61
+ "typescript-json-schema": "^0.51.0",
62
62
  "virtual-module-webpack-plugin": "^0.4.1",
63
63
  "webpack": "^4.42.1",
64
64
  "webpack-cli": "^3.3.2",
package/src/app.js CHANGED
File without changes
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CsprojFile = void 0;
4
+ var xml2js = require("xml2js");
5
+ var fs = require("fs");
6
+ var CsprojFile = /** @class */ (function () {
7
+ function CsprojFile(_path) {
8
+ this._path = _path;
9
+ }
10
+ CsprojFile.prototype._readFile = function () {
11
+ var _this = this;
12
+ var file = fs.readFileSync(this._path);
13
+ xml2js.parseString(file, function (err, result) { return _this._xmlObj = result; });
14
+ };
15
+ CsprojFile.prototype.addPostBuildCopy = function (copyToPath) {
16
+ if (!this._xmlObj)
17
+ this._readFile();
18
+ if (!this._xmlObj.Project)
19
+ this._xmlObj.Project = {};
20
+ this._xmlObj.Project.Target = {
21
+ $: {
22
+ Name: "CopyTarget",
23
+ AfterTargets: "PostBuildEvent"
24
+ },
25
+ ItemGroup: {
26
+ OutputFiles: {
27
+ $: {
28
+ Include: "$(TargetDir)\\*.*"
29
+ }
30
+ }
31
+ },
32
+ Copy: {
33
+ $: {
34
+ SourceFiles: "@(OutputFiles)",
35
+ DestinationFolder: copyToPath,
36
+ }
37
+ }
38
+ };
39
+ };
40
+ CsprojFile.prototype.save = function (path) {
41
+ var builder = new xml2js.Builder();
42
+ var xml = builder.buildObject(this._xmlObj);
43
+ fs.writeFileSync(path, xml);
44
+ };
45
+ return CsprojFile;
46
+ }());
47
+ exports.CsprojFile = CsprojFile;
@@ -20,6 +20,7 @@ var baseBuilder_1 = require("../baseBuilder");
20
20
  var utils_1 = require("../../utils");
21
21
  var dotnetUtils_1 = require("../../dotnetUtils");
22
22
  var packageStructureManager_1 = require("../../services/packageStructure/packageStructureManager");
23
+ var csprojFile_1 = require("./csprojFile");
23
24
  var Net5ApiBuilder = /** @class */ (function (_super) {
24
25
  __extends(Net5ApiBuilder, _super);
25
26
  function Net5ApiBuilder(config) {
@@ -33,7 +34,6 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
33
34
  }
34
35
  Net5ApiBuilder.prototype.run = function () {
35
36
  var _this = this;
36
- var _a;
37
37
  this.config.packages.forEach(function (pkg) {
38
38
  _this.collectModuleInfo(pkg);
39
39
  });
@@ -41,20 +41,40 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
41
41
  this.allProjects.forEach(function (p) {
42
42
  _this.clearCache(path.dirname(p));
43
43
  });
44
+ this._build();
45
+ };
46
+ Net5ApiBuilder.prototype._build = function () {
47
+ var _this = this;
48
+ var _a;
49
+ var coreModule = this.modules.find(function (m) { return m.IsCoreModule; });
50
+ var slnName = "Mdt";
51
+ var slnDir = path.dirname(coreModule.Project);
44
52
  var configuration = ((_a = this.config.api) === null || _a === void 0 ? void 0 : _a.configuration) || "Debug";
45
- this.modules.forEach(function (m) {
46
- dotnetUtils_1.DotnetUtils.restoreNugetPackages(m.Project);
47
- var isCoreModule = m.Module.name == "_core" && m.Package == "mdt";
48
- var outputPath = isCoreModule ? _this.buildApiFolder : path.join(_this.buildApiFolder, "modules", utils_1.Utils.getFileName(m.Project));
49
- utils_1.Utils.exec("dotnet publish " + m.Project + " --no-restore -c " + configuration + " -o " + outputPath + " -nologo -v q", {
50
- silent: false,
51
- skipLog: true
52
- });
53
- if (!isCoreModule) {
54
- var projectDir = path.dirname(m.Project);
55
- _this.copyModuleConfig(projectDir, outputPath, _this.configFile);
53
+ var tempSlnPath = path.join(slnDir, slnName + ".sln");
54
+ try {
55
+ dotnetUtils_1.DotnetUtils.createTempSln(slnDir, slnName);
56
+ for (var _i = 0, _b = this.modules; _i < _b.length; _i++) {
57
+ var m = _b[_i];
58
+ utils_1.Utils.copyFile(m.Project, m.TempProject);
59
+ var csproj = new csprojFile_1.CsprojFile(m.Project);
60
+ csproj.addPostBuildCopy(m.OutputPath);
61
+ csproj.save(m.Project);
56
62
  }
57
- });
63
+ dotnetUtils_1.DotnetUtils.addProjectsToSln(tempSlnPath, this.modules.map(function (m) { return m.Project; }));
64
+ dotnetUtils_1.DotnetUtils.restoreNugetPackages(tempSlnPath);
65
+ dotnetUtils_1.DotnetUtils.publish(tempSlnPath, configuration);
66
+ this.modules.filter(function (m) { return !m.IsCoreModule; }).forEach(function (m) {
67
+ var projectDir = path.dirname(m.Project);
68
+ _this.copyModuleConfig(projectDir, m.OutputPath, _this.configFile);
69
+ });
70
+ }
71
+ finally {
72
+ utils_1.Utils.deleteFile(tempSlnPath);
73
+ this.modules.forEach(function (m) {
74
+ utils_1.Utils.copyFile(m.TempProject, m.Project);
75
+ utils_1.Utils.deleteFile(m.TempProject);
76
+ });
77
+ }
58
78
  };
59
79
  Net5ApiBuilder.prototype.collectModuleInfo = function (pkg) {
60
80
  var _this = this;
@@ -74,18 +94,18 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
74
94
  utils_1.Logger.error(csprojPath + " does not exist");
75
95
  return;
76
96
  }
77
- this.modules.push({ Module: md, Package: pkg, Project: csprojPath });
97
+ this.modules.push(new ApiModuleInfo(pkg, md, csprojPath, this.buildApiFolder));
78
98
  projectFile.push(csprojPath);
79
99
  }
80
100
  else {
81
101
  var files_1 = shell.ls(path.join(modulePath, "*.sln"));
82
102
  if (files_1.length) {
83
- this.modules.push({ Module: md, Package: pkg, Project: files_1[0] });
103
+ this.modules.push(new ApiModuleInfo(pkg, md, files_1[0], this.buildApiFolder));
84
104
  return;
85
105
  }
86
106
  files_1 = shell.ls(path.join(modulePath, "*.csproj"));
87
107
  if (files_1.length) {
88
- this.modules.push({ Module: md, Package: pkg, Project: files_1[0] });
108
+ this.modules.push(new ApiModuleInfo(pkg, md, files_1[0], this.buildApiFolder));
89
109
  }
90
110
  else {
91
111
  utils_1.Logger.warn("Module " + md.name + " does not have .csproj file and will be skipped");
@@ -104,3 +124,17 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
104
124
  return Net5ApiBuilder;
105
125
  }(baseBuilder_1.BaseBuilder));
106
126
  exports.Net5ApiBuilder = Net5ApiBuilder;
127
+ var ApiModuleInfo = /** @class */ (function () {
128
+ function ApiModuleInfo(pkg, module, project, buildApiFolder) {
129
+ this.Package = pkg;
130
+ this.Module = module;
131
+ this.Project = project;
132
+ var dir = path.dirname(project);
133
+ this.TempProject = path.join(dir, utils_1.Utils.getFileName(project) + "_temp.csproj");
134
+ this.IsCoreModule = module.name == "_core" && pkg == "mdt";
135
+ this.OutputPath = this.IsCoreModule
136
+ ? buildApiFolder
137
+ : path.join(buildApiFolder, "modules", utils_1.Utils.getFileName(project));
138
+ }
139
+ return ApiModuleInfo;
140
+ }());
@@ -109,7 +109,8 @@ var SchemaBuilder = /** @class */ (function (_super) {
109
109
  var settings = {
110
110
  ignoreErrors: true,
111
111
  validationKeywords: ["markdownDescription", "defaultSnippets", "title"],
112
- required: true
112
+ required: true,
113
+ excludePrivate: true
113
114
  };
114
115
  var tsConfigPath = Path.join(sourcePath, "tsconfig.json");
115
116
  if (!utils_1.Utils.ensurePath(tsConfigPath)) {
@@ -10,10 +10,18 @@ var DotnetUtils = /** @class */ (function () {
10
10
  utils_1.Utils.deleteFiles(slnFilePath, [slnFileName + ".sln"]);
11
11
  utils_1.Utils.exec("dotnet new sln -n " + slnFileName + " -o " + slnFilePath);
12
12
  };
13
- DotnetUtils.restoreNugetPackages = function (projectPath, dropSlnOnFail) {
14
- utils_1.Utils.exec(
15
- // `dotnet restore ${projectPath} -s "https://stage.ics-it.ru/nuget/nuget/" -s "https://api.nuget.org/v3/index.json" -nologo -v q`);
16
- "dotnet restore " + projectPath + " -nologo -v q");
13
+ DotnetUtils.restoreNugetPackages = function (projectPath) {
14
+ utils_1.Utils.exec("dotnet restore " + projectPath + " -nologo -v q");
15
+ };
16
+ DotnetUtils.publish = function (projectPath, configuration, outputPath) {
17
+ if (outputPath === void 0) { outputPath = null; }
18
+ var command = "dotnet publish " + projectPath + " --no-restore -c " + configuration + " -nologo -v q";
19
+ if (outputPath)
20
+ command += " -o " + outputPath;
21
+ utils_1.Utils.exec(command, {
22
+ silent: false,
23
+ skipLog: true
24
+ });
17
25
  };
18
26
  DotnetUtils.addProjectsToSln = function (slnFilePath, projects, dropSlnOnFail) {
19
27
  var _this = this;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var BuilderException = /** @class */ (function () {
4
+ function BuilderException(message) {
5
+ this.message = message;
6
+ }
7
+ return BuilderException;
8
+ }());
9
+ exports.default = BuilderException;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.structureUtils = void 0;
4
+ var BuilderException_1 = require("../../exceptions/BuilderException");
4
5
  exports.structureUtils = {
5
6
  getModules: function (pkg, pkgDependencies, config, getAllPackageModuleNames, getModuleDeps) {
6
7
  if (getModuleDeps === void 0) { getModuleDeps = null; }
@@ -11,16 +12,19 @@ exports.structureUtils = {
11
12
  });
12
13
  var modules;
13
14
  var core = "_core";
15
+ var allModuleNames = getAllPackageModuleNames(pkg, isIgnoredDirectory, config);
14
16
  if (config.modules && config.modules.length > 0)
15
17
  modules = config.modules
16
18
  .filter(function (m) { return pkg.name == m.split(".")[0]; })
17
19
  .map(function (val) {
18
20
  var split = val.split(".");
19
21
  var moduleName = split.length == 1 ? core : split.slice(1).join(".");
22
+ if (!isIgnoredModule(pkg.name, moduleName) && !allModuleNames.includes(moduleName))
23
+ throw new BuilderException_1.default("Module " + val + " not found!");
20
24
  return createModule(mappedPkgDependencies, moduleName, pkg, getModuleDeps, config);
21
25
  });
22
26
  else {
23
- modules = getAllPackageModuleNames(pkg, isIgnoredDirectory, config).map(function (moduleName) {
27
+ modules = allModuleNames.map(function (moduleName) {
24
28
  return createModule(mappedPkgDependencies, moduleName, pkg, getModuleDeps, config);
25
29
  });
26
30
  }
@@ -29,6 +33,15 @@ exports.structureUtils = {
29
33
  return modules;
30
34
  }
31
35
  };
36
+ function isIgnoredModule(packageName, moduleName) {
37
+ if (moduleName === "_core")
38
+ return true;
39
+ if (packageName === "mdt") {
40
+ if (moduleName === "storage" || moduleName === "template")
41
+ return true;
42
+ }
43
+ return false;
44
+ }
32
45
  function isIgnoredDirectory(name) {
33
46
  return name == "node_modules" || name == "_core" || name.startsWith(".");
34
47
  }
package/src/utils.js CHANGED
@@ -136,10 +136,13 @@ var Utils = /** @class */ (function () {
136
136
  Utils.deleteFiles = function (dir, files) {
137
137
  for (var i = 0; i < files.length; i++) {
138
138
  var file = path.join(dir, files[i]);
139
- if (fs.existsSync(file))
140
- fs.unlinkSync(file);
139
+ this.deleteFile(file);
141
140
  }
142
141
  };
142
+ Utils.deleteFile = function (path) {
143
+ if (fs.existsSync(path))
144
+ fs.unlinkSync(path);
145
+ };
143
146
  Utils.prepareDir = function (dir) {
144
147
  Utils.clearFolder(dir);
145
148
  Utils.ensureFolder(dir);