ics-builder 4.1.85 → 4.1.89
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 +2 -2
- package/src/builder/api/csprojFile.js +47 -0
- package/src/builder/api/dotnetApiBuilder.js +2 -7
- package/src/builder/api/net5Builder.js +52 -12
- package/src/builder/baseBuilder.js +6 -0
- package/src/builder/schema/schemaBuilder.js +2 -1
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ics-builder",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.89",
|
|
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.
|
|
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",
|
|
@@ -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;
|
|
@@ -123,13 +123,8 @@ var DotnetApiBuilder = /** @class */ (function (_super) {
|
|
|
123
123
|
if (/(\.svc)$/.test(fileName))
|
|
124
124
|
utils_1.Utils.copyFile(path.join(moduleDir, fileName), path.join(targetDir, fileName));
|
|
125
125
|
});
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
var baseDir = path.basename(moduleDir);
|
|
129
|
-
if (baseDir.endsWith("api"))
|
|
130
|
-
baseDir = path.basename(path.dirname(moduleDir));
|
|
131
|
-
utils_1.Utils.copyFile(moduleConfigFile, path.join(targetDir, moduleName + ".app.config"));
|
|
132
|
-
}
|
|
126
|
+
var moduleConfigFileName = "app.config";
|
|
127
|
+
this.copyModuleConfig(moduleDir, targetDir, moduleConfigFileName, moduleName + "." + moduleConfigFileName);
|
|
133
128
|
utils_1.Utils.deleteFiles(targetDir, ["packages.config", "web.config.template"]);
|
|
134
129
|
utils_1.Logger.info(moduleName.replace("._core", "") + ": " + info.join(", "));
|
|
135
130
|
}
|
|
@@ -20,19 +20,20 @@ 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) {
|
|
26
27
|
var _this = _super.call(this, config) || this;
|
|
27
28
|
_this.modules = new Array();
|
|
28
29
|
_this.allProjects = [];
|
|
30
|
+
_this.configFile = "appsettings.json";
|
|
29
31
|
_this.buildApiFolder = path.join(_this.config.paths.build, "api");
|
|
30
32
|
shell.config.silent = true;
|
|
31
33
|
return _this;
|
|
32
34
|
}
|
|
33
35
|
Net5ApiBuilder.prototype.run = function () {
|
|
34
36
|
var _this = this;
|
|
35
|
-
var _a;
|
|
36
37
|
this.config.packages.forEach(function (pkg) {
|
|
37
38
|
_this.collectModuleInfo(pkg);
|
|
38
39
|
});
|
|
@@ -40,16 +41,43 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
|
|
|
40
41
|
this.allProjects.forEach(function (p) {
|
|
41
42
|
_this.clearCache(path.dirname(p));
|
|
42
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);
|
|
43
52
|
var configuration = ((_a = this.config.api) === null || _a === void 0 ? void 0 : _a.configuration) || "Debug";
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
var tempSlnPath = path.join(slnDir, slnName + ".sln");
|
|
54
|
+
var tempProjects = [];
|
|
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
|
+
var csproj = new csprojFile_1.CsprojFile(m.Project);
|
|
60
|
+
csproj.addPostBuildCopy(m.OutputPath);
|
|
61
|
+
var tempProjPath = this.getTempProjPath(m.Project);
|
|
62
|
+
tempProjects.push(tempProjPath);
|
|
63
|
+
csproj.save(tempProjPath);
|
|
64
|
+
}
|
|
65
|
+
dotnetUtils_1.DotnetUtils.addProjectsToSln(tempSlnPath, tempProjects);
|
|
66
|
+
dotnetUtils_1.DotnetUtils.restoreNugetPackages(tempSlnPath);
|
|
67
|
+
dotnetUtils_1.DotnetUtils.publish(tempSlnPath, configuration);
|
|
68
|
+
this.modules.filter(function (m) { return !m.IsCoreModule; }).forEach(function (m) {
|
|
69
|
+
var projectDir = path.dirname(m.Project);
|
|
70
|
+
_this.copyModuleConfig(projectDir, m.OutputPath, _this.configFile);
|
|
51
71
|
});
|
|
52
|
-
}
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
utils_1.Utils.deleteFile(tempSlnPath);
|
|
75
|
+
tempProjects.forEach(function (p) { return utils_1.Utils.deleteFile(p); });
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
Net5ApiBuilder.prototype.getTempProjPath = function (projPath) {
|
|
79
|
+
var dir = path.dirname(projPath);
|
|
80
|
+
return path.join(dir, utils_1.Utils.getFileName(projPath) + "_temp.csproj");
|
|
53
81
|
};
|
|
54
82
|
Net5ApiBuilder.prototype.collectModuleInfo = function (pkg) {
|
|
55
83
|
var _this = this;
|
|
@@ -69,18 +97,18 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
|
|
|
69
97
|
utils_1.Logger.error(csprojPath + " does not exist");
|
|
70
98
|
return;
|
|
71
99
|
}
|
|
72
|
-
this.modules.push(
|
|
100
|
+
this.modules.push(new ApiModuleInfo(pkg, md, csprojPath, this.buildApiFolder));
|
|
73
101
|
projectFile.push(csprojPath);
|
|
74
102
|
}
|
|
75
103
|
else {
|
|
76
104
|
var files_1 = shell.ls(path.join(modulePath, "*.sln"));
|
|
77
105
|
if (files_1.length) {
|
|
78
|
-
this.modules.push(
|
|
106
|
+
this.modules.push(new ApiModuleInfo(pkg, md, files_1[0], this.buildApiFolder));
|
|
79
107
|
return;
|
|
80
108
|
}
|
|
81
109
|
files_1 = shell.ls(path.join(modulePath, "*.csproj"));
|
|
82
110
|
if (files_1.length) {
|
|
83
|
-
this.modules.push(
|
|
111
|
+
this.modules.push(new ApiModuleInfo(pkg, md, files_1[0], this.buildApiFolder));
|
|
84
112
|
}
|
|
85
113
|
else {
|
|
86
114
|
utils_1.Logger.warn("Module " + md.name + " does not have .csproj file and will be skipped");
|
|
@@ -99,3 +127,15 @@ var Net5ApiBuilder = /** @class */ (function (_super) {
|
|
|
99
127
|
return Net5ApiBuilder;
|
|
100
128
|
}(baseBuilder_1.BaseBuilder));
|
|
101
129
|
exports.Net5ApiBuilder = Net5ApiBuilder;
|
|
130
|
+
var ApiModuleInfo = /** @class */ (function () {
|
|
131
|
+
function ApiModuleInfo(pkg, module, project, buildApiFolder) {
|
|
132
|
+
this.Package = pkg;
|
|
133
|
+
this.Module = module;
|
|
134
|
+
this.Project = project;
|
|
135
|
+
this.IsCoreModule = module.name == "_core" && pkg == "mdt";
|
|
136
|
+
this.OutputPath = this.IsCoreModule
|
|
137
|
+
? buildApiFolder
|
|
138
|
+
: path.join(buildApiFolder, "modules", utils_1.Utils.getFileName(project));
|
|
139
|
+
}
|
|
140
|
+
return ApiModuleInfo;
|
|
141
|
+
}());
|
|
@@ -38,6 +38,12 @@ var BaseBuilder = /** @class */ (function () {
|
|
|
38
38
|
utils_1.Logger.info("Tests successfully passed. Coverage report: \n" + stdout);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
+
BaseBuilder.prototype.copyModuleConfig = function (sourceDir, targetDir, configFileName, newConfigFileName) {
|
|
42
|
+
var moduleConfigFile = path.join(sourceDir, configFileName);
|
|
43
|
+
if (utils_1.Utils.ensurePath(moduleConfigFile)) {
|
|
44
|
+
utils_1.Utils.copyFile(moduleConfigFile, path.join(targetDir, newConfigFileName !== null && newConfigFileName !== void 0 ? newConfigFileName : configFileName));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
41
47
|
return BaseBuilder;
|
|
42
48
|
}());
|
|
43
49
|
exports.BaseBuilder = BaseBuilder;
|
|
@@ -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)) {
|
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);
|