ics-builder 4.4.0 → 4.4.2

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,12 +1,12 @@
1
1
  {
2
2
  "name": "ics-builder",
3
- "version": "4.4.0",
3
+ "version": "4.4.2",
4
4
  "description": "",
5
- "main": "./src/app.js",
5
+ "main": "./src/index.js",
6
6
  "preferGlobal": true,
7
7
  "scripts": {
8
8
  "test": "jest",
9
- "dev": "ts-node ./src/app.ts",
9
+ "dev": "ts-node ./src/index.ts",
10
10
  "copy-assets": "xcopy \"src/services/source/assets\" \"dist/src/services/source/assets\" /e /i",
11
11
  "patch": "npx tsc && npm run copy-assets && npm version patch && copy package.json dist && copy jest.config.js dist && cd dist && npm publish",
12
12
  "minor": "npx tsc && npm run copy-assets && npm version minor && copy package.json dist && copy jest.config.js dist && cd dist && npm publish",
@@ -14,7 +14,7 @@
14
14
  "pack": "npx tsc && npm run copy-assets && copy package.json dist && copy jest.config.js dist && cd dist && npm pack"
15
15
  },
16
16
  "bin": {
17
- "builder": "./src/app.js"
17
+ "builder": "./src/index.js"
18
18
  },
19
19
  "keywords": [
20
20
  "build tool"
package/src/app.js CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env node
2
1
  "use strict";
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  var path = require("path");
@@ -40,56 +40,80 @@ var DbBuilder = /** @class */ (function (_super) {
40
40
  utils_1.Utils.copyAllFilesByPattern(path.join(sourcePath, "data"), path.join(moduleDestinationDir, "data"), "**/*.xml");
41
41
  utils_1.Utils.copyAllFilesByPattern(path.join(sourcePath, "scripts"), path.join(moduleDestinationDir, "scripts"), "**/*.sql");
42
42
  utils_1.Utils.copyAllFilesByPattern(path.join(sourcePath, "updates"), path.join(moduleDestinationDir, "updates"), "**/*.sql");
43
+ var otherUpdatesDirs = fs.readdirSync(sourcePath, { withFileTypes: true })
44
+ .filter(function (d) { return d.isDirectory(); })
45
+ .map(function (d) { return d.name; })
46
+ .filter(function (d) { return d.startsWith("updates."); });
47
+ for (var _i = 0, otherUpdatesDirs_1 = otherUpdatesDirs; _i < otherUpdatesDirs_1.length; _i++) {
48
+ var updateDir = otherUpdatesDirs_1[_i];
49
+ utils_1.Utils.copyAllFilesByPattern(path.join(sourcePath, updateDir), path.join(moduleDestinationDir, updateDir), "**/*.sql");
50
+ }
51
+ var otherScriptsDirs = fs.readdirSync(sourcePath, { withFileTypes: true })
52
+ .filter(function (d) { return d.isDirectory(); })
53
+ .map(function (d) { return d.name; })
54
+ .filter(function (d) { return d.startsWith("scripts."); });
55
+ for (var _b = 0, otherScriptsDirs_1 = otherScriptsDirs; _b < otherScriptsDirs_1.length; _b++) {
56
+ var scriptDir = otherScriptsDirs_1[_b];
57
+ utils_1.Utils.copyAllFilesByPattern(path.join(sourcePath, scriptDir), path.join(moduleDestinationDir, scriptDir), "**/*.sql");
58
+ }
43
59
  if (utils_1.Utils.ensurePath(moduleDestinationDir)) {
44
- var order_1 = new Array();
45
- var files_1 = new Array();
46
- var dependencies_1 = {};
47
- var scriptsPath_1 = path.join(sourcePath, "scripts");
48
- var dirs = ["view*", "function*", "procedure*", "trigger*", "index*"];
49
- dirs.forEach(function (dir) {
50
- files_1 = files_1.concat(glob.sync(path.join(scriptsPath_1, dir, "**/*.sql")));
51
- });
52
- for (var i = 0; i < files_1.length; i++)
53
- files_1[i] = files_1[i].replace(/\//g, path.sep);
54
- var reorder_1 = function (file, parent) {
55
- if (file == parent)
56
- throw "Circular dependencies! " + parent;
57
- var deps = dependencies_1[file];
58
- deps &&
59
- deps.forEach(function (dep) {
60
- dep = path.resolve(scriptsPath_1, dep);
61
- if (files_1.indexOf(dep) != -1)
62
- reorder_1(dep, parent || file);
63
- });
64
- if (!parent || order_1.indexOf(parent) > order_1.indexOf(file))
65
- return;
66
- order_1.splice(order_1.indexOf(file), 1);
67
- order_1.splice(order_1.indexOf(parent), 0, file);
68
- };
69
- files_1.forEach(function (file) {
70
- var deps = (dependencies_1[file] = []);
71
- var data = fs.readFileSync(file).toString();
72
- data.split("\n").forEach(function (line) {
73
- var m = line.replace(/^\uFEFF/, "").match(/^--\s*\$dep\s+(.+?)\s*$/);
74
- if (m) {
75
- deps.push(m[1]);
76
- }
77
- });
78
- order_1.push(file);
79
- });
80
- // reorder
81
- files_1.forEach(function (file) {
82
- reorder_1(file);
83
- });
84
- if (order_1.length)
85
- fs.writeFileSync(moduleDestinationDir + "/scripts/order.txt", order_1
86
- .map(function (f) {
87
- return path.relative(scriptsPath_1, f);
88
- })
89
- .join("\n"));
60
+ var scriptsPath = path.join(sourcePath, "scripts");
61
+ _this.GenerateOrderFile(scriptsPath, moduleDestinationDir + "/scripts");
62
+ for (var _c = 0, otherScriptsDirs_2 = otherScriptsDirs; _c < otherScriptsDirs_2.length; _c++) {
63
+ var scriptDir = otherScriptsDirs_2[_c];
64
+ var otherScriptPath = path.join(sourcePath, scriptDir);
65
+ _this.GenerateOrderFile(otherScriptPath, moduleDestinationDir + "/" + scriptDir);
66
+ }
67
+ }
68
+ });
69
+ });
70
+ };
71
+ DbBuilder.prototype.GenerateOrderFile = function (scriptsPath, destinationScriptsPath) {
72
+ var order = new Array();
73
+ var files = new Array();
74
+ var dependencies = {};
75
+ var dirs = ["view*", "function*", "procedure*", "trigger*", "index*"];
76
+ dirs.forEach(function (dir) {
77
+ files = files.concat(glob.sync(path.join(scriptsPath, dir, "**/*.sql")));
78
+ });
79
+ for (var i = 0; i < files.length; i++)
80
+ files[i] = files[i].replace(/\//g, path.sep);
81
+ var reorder = function (file, parent) {
82
+ if (file == parent)
83
+ throw "Circular dependencies! " + parent;
84
+ var deps = dependencies[file];
85
+ deps &&
86
+ deps.forEach(function (dep) {
87
+ dep = path.resolve(scriptsPath, dep);
88
+ if (files.indexOf(dep) != -1)
89
+ reorder(dep, parent || file);
90
+ });
91
+ if (!parent || order.indexOf(parent) > order.indexOf(file))
92
+ return;
93
+ order.splice(order.indexOf(file), 1);
94
+ order.splice(order.indexOf(parent), 0, file);
95
+ };
96
+ files.forEach(function (file) {
97
+ var deps = (dependencies[file] = []);
98
+ var data = fs.readFileSync(file).toString();
99
+ data.split("\n").forEach(function (line) {
100
+ var m = line.replace(/^\uFEFF/, "").match(/^--\s*\$dep\s+(.+?)\s*$/);
101
+ if (m) {
102
+ deps.push(m[1]);
90
103
  }
91
104
  });
105
+ order.push(file);
106
+ });
107
+ // reorder
108
+ files.forEach(function (file) {
109
+ reorder(file);
92
110
  });
111
+ if (order.length)
112
+ fs.writeFileSync(destinationScriptsPath + "/order.txt", order
113
+ .map(function (f) {
114
+ return path.relative(scriptsPath, f);
115
+ })
116
+ .join("\n"));
93
117
  };
94
118
  DbBuilder.prototype.convertToXml = function (paths, module, destinationDir) {
95
119
  paths.forEach(function (p) {
@@ -45,9 +45,9 @@ var UIDependencyBuilder = /** @class */ (function (_super) {
45
45
  utils_1.Logger.warn("File package.json not found!");
46
46
  return;
47
47
  }
48
- var packageLockPath = Path.join(cwd, "package-lock.json");
49
- var hasPackageLockPath = utils_1.Utils.ensurePath(packageLockPath);
50
- utils_1.Utils.exec("npm " + (hasPackageLockPath ? "ci" : "install") + " --force", { silent: true, cwd: cwd });
48
+ // let packageLockPath = Path.join(cwd, "package-lock.json");
49
+ // let hasPackageLockPath = Utils.ensurePath(packageLockPath);
50
+ utils_1.Utils.exec("npm install --no-save --prefer-offline --force", { silent: true, cwd: cwd });
51
51
  };
52
52
  return UIDependencyBuilder;
53
53
  }(baseBuilder_1.BaseBuilder));
package/src/index.js ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __assign = (this && this.__assign) || function () {
4
+ __assign = Object.assign || function(t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
+ t[p] = s[p];
9
+ }
10
+ return t;
11
+ };
12
+ return __assign.apply(this, arguments);
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ var utils_1 = require("./utils");
16
+ var path = require("path");
17
+ function isLegacyProviderNeeded() {
18
+ var nodeJsMajorVersion = parseInt(process.versions.node.split(".")[0]);
19
+ return nodeJsMajorVersion > 16;
20
+ }
21
+ function getCliArgs() {
22
+ return process.argv.slice(2);
23
+ }
24
+ function envWithLagacyProvider() {
25
+ return __assign(__assign({}, process.env), { NODE_OPTIONS: "--openssl-legacy-provider" });
26
+ }
27
+ function run() {
28
+ var options = {
29
+ stdio: "inherit",
30
+ cwd: process.cwd()
31
+ };
32
+ if (isLegacyProviderNeeded())
33
+ options.env = envWithLagacyProvider();
34
+ var pathToApp = path.resolve(__dirname, "app");
35
+ utils_1.Utils.execModule(pathToApp, getCliArgs(), options);
36
+ }
37
+ run();
@@ -10,7 +10,7 @@ var ConfigManager = /** @class */ (function () {
10
10
  ConfigManager.getConfig = function (configPath, multipleSchemaFiles) {
11
11
  var config;
12
12
  if (!utils_1.Utils.ensurePath(configPath)) {
13
- utils_1.Logger.info("Build config " + configPath + " is not found. Using default config.");
13
+ utils_1.Logger.warn("Build config " + configPath + " is not found. Using default config.");
14
14
  config = { api: { configuration: "Debug", framework: ".net5" } };
15
15
  }
16
16
  else
@@ -30,7 +30,7 @@ var PackageManager = /** @class */ (function () {
30
30
  var _this = this;
31
31
  if (!using) {
32
32
  if (!this.config.package && skipload) {
33
- this.packages.set(null, { name: "", version: "", modules: [{ name: "_core" }], isSingleModule: true });
33
+ this.packages.set(null, { name: "", version: "", modules: [{ name: "_core" }], isSingleModule: true, packageInfo: {} });
34
34
  return;
35
35
  }
36
36
  var mainPackage = this.config.package;
@@ -47,6 +47,9 @@ var GitScmProvider = /** @class */ (function () {
47
47
  utils_1.Logger.error("Cannot find version " + config.package.version + " of module " + config.package.name);
48
48
  return version;
49
49
  };
50
+ GitScmProvider.prototype.cleanPackageLock = function (config) {
51
+ return this.exec("clean -fdx '*/package-lock.json'", config.paths.source);
52
+ };
50
53
  GitScmProvider.prototype._getGitUrl = function (config) {
51
54
  var _a;
52
55
  return (_a = config.package.url) !== null && _a !== void 0 ? _a : this.options.url + this.options.group + "/" + config.package.name;
@@ -44,6 +44,9 @@ var HgScmProvider = /** @class */ (function () {
44
44
  utils_1.Logger.error("Cannot find version " + config.package.version + " of module " + config.package.name);
45
45
  return version;
46
46
  };
47
+ HgScmProvider.prototype.cleanPackageLock = function (config) {
48
+ return null;
49
+ };
47
50
  return HgScmProvider;
48
51
  }());
49
52
  exports.HgScmProvider = HgScmProvider;
@@ -30,9 +30,13 @@ var SourceManager = /** @class */ (function () {
30
30
  var version;
31
31
  if (!skipLoad) {
32
32
  try {
33
- utils_1.Utils.ensurePath(path.join(sourceConfig.paths.source, "." + sourceType.toLowerCase()))
34
- ? scmProvider.pull(sourceConfig)
35
- : scmProvider.clone(sourceConfig);
33
+ if (utils_1.Utils.ensurePath(path.join(sourceConfig.paths.source, "." + sourceType.toLowerCase()))) {
34
+ scmProvider.cleanPackageLock(sourceConfig);
35
+ scmProvider.pull(sourceConfig);
36
+ }
37
+ else {
38
+ scmProvider.clone(sourceConfig);
39
+ }
36
40
  version = this.update(scmProvider, sourceConfig, true);
37
41
  }
38
42
  catch (e) {
package/src/utils.js CHANGED
@@ -29,6 +29,7 @@ var fs = require("fs");
29
29
  var path = require("path");
30
30
  var glob = require("glob");
31
31
  var stripBomBuffer = require("strip-bom-buf");
32
+ var child_process = require("child_process");
32
33
  var Utils = /** @class */ (function () {
33
34
  function Utils() {
34
35
  }
@@ -52,6 +53,21 @@ var Utils = /** @class */ (function () {
52
53
  throw e;
53
54
  }
54
55
  };
56
+ Utils.execModule = function (path, args, options) {
57
+ var proc = child_process.fork(path, args, options);
58
+ process.on("SIGTERM", function () { return proc.kill("SIGTERM"); });
59
+ process.on("SIGINT", function () { return proc.kill("SIGINT"); });
60
+ process.on("SIGBREAK", function () { return proc.kill("SIGBREAK"); });
61
+ process.on("SIGHUP", function () { return proc.kill("SIGHUP"); });
62
+ proc.on("exit", function (code, signal) {
63
+ var exitCode = code;
64
+ if (exitCode === null) {
65
+ exitCode = signal === "SIGINT" ? 0 : 1;
66
+ }
67
+ process.exit(exitCode);
68
+ });
69
+ return proc;
70
+ };
55
71
  Utils.ensurePath = function (path) {
56
72
  return fs.existsSync(path);
57
73
  };