ics-builder 4.1.87 → 4.1.91
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 +1 -1
- package/src/app.js +0 -0
- package/src/builder/api/csprojFile.js +50 -0
- package/src/builder/api/net5Builder.js +55 -16
- package/src/builder/api/webConfigFile.js +33 -0
- package/src/builder/api/xmlFile.js +23 -0
- package/src/dotnetUtils.js +12 -4
- package/src/exceptions/BuilderException.js +9 -0
- package/src/services/packageStructure/structureUtils.js +14 -1
- package/src/utils.js +5 -2
package/package.json
CHANGED
package/src/app.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.CsprojFile = void 0;
|
|
17
|
+
var xmlFile_1 = require("./xmlFile");
|
|
18
|
+
var CsprojFile = /** @class */ (function (_super) {
|
|
19
|
+
__extends(CsprojFile, _super);
|
|
20
|
+
function CsprojFile() {
|
|
21
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
22
|
+
}
|
|
23
|
+
CsprojFile.prototype.addPostBuildCopy = function (copyToPath) {
|
|
24
|
+
if (!this._xmlObj)
|
|
25
|
+
this._readFile();
|
|
26
|
+
if (!this._xmlObj.Project)
|
|
27
|
+
this._xmlObj.Project = {};
|
|
28
|
+
this._xmlObj.Project.Target = {
|
|
29
|
+
$: {
|
|
30
|
+
Name: "CopyTarget",
|
|
31
|
+
AfterTargets: "PostBuildEvent"
|
|
32
|
+
},
|
|
33
|
+
ItemGroup: {
|
|
34
|
+
OutputFiles: {
|
|
35
|
+
$: {
|
|
36
|
+
Include: "$(TargetDir)\\*.*"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
Copy: {
|
|
41
|
+
$: {
|
|
42
|
+
SourceFiles: "@(OutputFiles)",
|
|
43
|
+
DestinationFolder: copyToPath,
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
return CsprojFile;
|
|
49
|
+
}(xmlFile_1.XmlFile));
|
|
50
|
+
exports.CsprojFile = CsprojFile;
|
|
@@ -20,6 +20,8 @@ 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");
|
|
24
|
+
var webConfigFile_1 = require("./webConfigFile");
|
|
23
25
|
var Net5ApiBuilder = /** @class */ (function (_super) {
|
|
24
26
|
__extends(Net5ApiBuilder, _super);
|
|
25
27
|
function Net5ApiBuilder(config) {
|
|
@@ -33,7 +35,6 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
|
|
|
33
35
|
}
|
|
34
36
|
Net5ApiBuilder.prototype.run = function () {
|
|
35
37
|
var _this = this;
|
|
36
|
-
var _a;
|
|
37
38
|
this.config.packages.forEach(function (pkg) {
|
|
38
39
|
_this.collectModuleInfo(pkg);
|
|
39
40
|
});
|
|
@@ -41,20 +42,44 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
|
|
|
41
42
|
this.allProjects.forEach(function (p) {
|
|
42
43
|
_this.clearCache(path.dirname(p));
|
|
43
44
|
});
|
|
45
|
+
this._build();
|
|
46
|
+
};
|
|
47
|
+
Net5ApiBuilder.prototype._build = function () {
|
|
48
|
+
var _this = this;
|
|
49
|
+
var _a;
|
|
50
|
+
var coreModule = this.modules.find(function (m) { return m.IsCoreModule; });
|
|
51
|
+
var slnName = "Mdt";
|
|
52
|
+
var slnDir = path.dirname(coreModule.Project);
|
|
44
53
|
var configuration = ((_a = this.config.api) === null || _a === void 0 ? void 0 : _a.configuration) || "Debug";
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var projectDir = path.dirname(m.Project);
|
|
55
|
-
_this.copyModuleConfig(projectDir, outputPath, _this.configFile);
|
|
54
|
+
var tempSlnPath = path.join(slnDir, slnName + ".sln");
|
|
55
|
+
try {
|
|
56
|
+
dotnetUtils_1.DotnetUtils.createTempSln(slnDir, slnName);
|
|
57
|
+
for (var _i = 0, _b = this.modules; _i < _b.length; _i++) {
|
|
58
|
+
var m = _b[_i];
|
|
59
|
+
utils_1.Utils.copyFile(m.Project, m.TempProject);
|
|
60
|
+
var csproj = new csprojFile_1.CsprojFile(m.Project);
|
|
61
|
+
csproj.addPostBuildCopy(m.OutputPath);
|
|
62
|
+
csproj.save(m.Project);
|
|
56
63
|
}
|
|
57
|
-
|
|
64
|
+
dotnetUtils_1.DotnetUtils.addProjectsToSln(tempSlnPath, this.modules.map(function (m) { return m.Project; }));
|
|
65
|
+
dotnetUtils_1.DotnetUtils.restoreNugetPackages(tempSlnPath);
|
|
66
|
+
dotnetUtils_1.DotnetUtils.publish(tempSlnPath, configuration);
|
|
67
|
+
var webConfigFilePath = path.join(coreModule.OutputPath, "web.config");
|
|
68
|
+
var webConfigFile = new webConfigFile_1.WebConfigFile(webConfigFilePath);
|
|
69
|
+
webConfigFile.addDotnetProcessPath();
|
|
70
|
+
webConfigFile.save();
|
|
71
|
+
this.modules.filter(function (m) { return !m.IsCoreModule; }).forEach(function (m) {
|
|
72
|
+
var projectDir = path.dirname(m.Project);
|
|
73
|
+
_this.copyModuleConfig(projectDir, m.OutputPath, _this.configFile);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
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
|
+
}
|
|
58
83
|
};
|
|
59
84
|
Net5ApiBuilder.prototype.collectModuleInfo = function (pkg) {
|
|
60
85
|
var _this = this;
|
|
@@ -74,18 +99,18 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
|
|
|
74
99
|
utils_1.Logger.error(csprojPath + " does not exist");
|
|
75
100
|
return;
|
|
76
101
|
}
|
|
77
|
-
this.modules.push(
|
|
102
|
+
this.modules.push(new ApiModuleInfo(pkg, md, csprojPath, this.buildApiFolder));
|
|
78
103
|
projectFile.push(csprojPath);
|
|
79
104
|
}
|
|
80
105
|
else {
|
|
81
106
|
var files_1 = shell.ls(path.join(modulePath, "*.sln"));
|
|
82
107
|
if (files_1.length) {
|
|
83
|
-
this.modules.push(
|
|
108
|
+
this.modules.push(new ApiModuleInfo(pkg, md, files_1[0], this.buildApiFolder));
|
|
84
109
|
return;
|
|
85
110
|
}
|
|
86
111
|
files_1 = shell.ls(path.join(modulePath, "*.csproj"));
|
|
87
112
|
if (files_1.length) {
|
|
88
|
-
this.modules.push(
|
|
113
|
+
this.modules.push(new ApiModuleInfo(pkg, md, files_1[0], this.buildApiFolder));
|
|
89
114
|
}
|
|
90
115
|
else {
|
|
91
116
|
utils_1.Logger.warn("Module " + md.name + " does not have .csproj file and will be skipped");
|
|
@@ -104,3 +129,17 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
|
|
|
104
129
|
return Net5ApiBuilder;
|
|
105
130
|
}(baseBuilder_1.BaseBuilder));
|
|
106
131
|
exports.Net5ApiBuilder = Net5ApiBuilder;
|
|
132
|
+
var ApiModuleInfo = /** @class */ (function () {
|
|
133
|
+
function ApiModuleInfo(pkg, module, project, buildApiFolder) {
|
|
134
|
+
this.Package = pkg;
|
|
135
|
+
this.Module = module;
|
|
136
|
+
this.Project = project;
|
|
137
|
+
var dir = path.dirname(project);
|
|
138
|
+
this.TempProject = path.join(dir, utils_1.Utils.getFileName(project) + "_temp.csproj");
|
|
139
|
+
this.IsCoreModule = module.name == "_core" && pkg == "mdt";
|
|
140
|
+
this.OutputPath = this.IsCoreModule
|
|
141
|
+
? buildApiFolder
|
|
142
|
+
: path.join(buildApiFolder, "modules", utils_1.Utils.getFileName(project));
|
|
143
|
+
}
|
|
144
|
+
return ApiModuleInfo;
|
|
145
|
+
}());
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.WebConfigFile = void 0;
|
|
17
|
+
var xmlFile_1 = require("./xmlFile");
|
|
18
|
+
var WebConfigFile = /** @class */ (function (_super) {
|
|
19
|
+
__extends(WebConfigFile, _super);
|
|
20
|
+
function WebConfigFile() {
|
|
21
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
22
|
+
}
|
|
23
|
+
WebConfigFile.prototype.addDotnetProcessPath = function () {
|
|
24
|
+
if (!this._xmlObj)
|
|
25
|
+
this._readFile();
|
|
26
|
+
var aspNetCoreSectionOptions = this._xmlObj.configuration.location[0]["system.webServer"][0].aspNetCore[0].$;
|
|
27
|
+
aspNetCoreSectionOptions.processPath = "dotnet";
|
|
28
|
+
aspNetCoreSectionOptions.arguments = ".\\Mdt.WebApi.dll";
|
|
29
|
+
aspNetCoreSectionOptions.stdoutLogEnabled = "false";
|
|
30
|
+
};
|
|
31
|
+
return WebConfigFile;
|
|
32
|
+
}(xmlFile_1.XmlFile));
|
|
33
|
+
exports.WebConfigFile = WebConfigFile;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XmlFile = void 0;
|
|
4
|
+
var xml2js = require("xml2js");
|
|
5
|
+
var fs = require("fs");
|
|
6
|
+
var XmlFile = /** @class */ (function () {
|
|
7
|
+
function XmlFile(_path) {
|
|
8
|
+
this._path = _path;
|
|
9
|
+
}
|
|
10
|
+
XmlFile.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
|
+
XmlFile.prototype.save = function (path) {
|
|
16
|
+
if (path === void 0) { path = null; }
|
|
17
|
+
var builder = new xml2js.Builder();
|
|
18
|
+
var xml = builder.buildObject(this._xmlObj);
|
|
19
|
+
fs.writeFileSync(path !== null && path !== void 0 ? path : this._path, xml);
|
|
20
|
+
};
|
|
21
|
+
return XmlFile;
|
|
22
|
+
}());
|
|
23
|
+
exports.XmlFile = XmlFile;
|
package/src/dotnetUtils.js
CHANGED
|
@@ -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
|
|
14
|
-
utils_1.Utils.exec(
|
|
15
|
-
|
|
16
|
-
|
|
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 =
|
|
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
|
-
|
|
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);
|