@melfore/clibelt 6.0.2 → 6.0.3

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.
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var utils_1 = require("../utils");
43
+ var testFileResult_js_1 = __importDefault(require("./testFileResult.js"));
44
+ var node_path_1 = __importDefault(require("node:path"));
45
+ describe("Copy-Test", function () {
46
+ var file = node_path_1.default.join(process.cwd(), "src/cli/i18n-copy/_test_/testFile.js");
47
+ it("CheckSignleFile", function () { return __awaiter(void 0, void 0, void 0, function () {
48
+ var res;
49
+ return __generator(this, function (_a) {
50
+ switch (_a.label) {
51
+ case 0: return [4, (0, utils_1.checkSingleFile)(file, "it", "pl")];
52
+ case 1:
53
+ res = _a.sent();
54
+ expect(res).toEqual(testFileResult_js_1.default.messages);
55
+ return [2];
56
+ }
57
+ });
58
+ }); });
59
+ it("Wrong --from param", function () { return __awaiter(void 0, void 0, void 0, function () {
60
+ return __generator(this, function (_a) {
61
+ switch (_a.label) {
62
+ case 0: return [4, expect(function () { return (0, utils_1.checkSingleFile)(file, "FR", "pl"); }).rejects.toThrow("--from FR not exist")];
63
+ case 1:
64
+ _a.sent();
65
+ return [2];
66
+ }
67
+ });
68
+ }); });
69
+ });
@@ -0,0 +1,21 @@
1
+ export const messages: ({
2
+ code: string;
3
+ tr: {
4
+ l: string;
5
+ v: string;
6
+ }[];
7
+ overrides?: undefined;
8
+ } | {
9
+ code: string;
10
+ tr: {
11
+ l: string;
12
+ v: string;
13
+ }[];
14
+ overrides: {
15
+ customer: string;
16
+ tr: {
17
+ l: string;
18
+ v: string;
19
+ }[];
20
+ }[];
21
+ })[];
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ exports.messages = [
3
+ {
4
+ code: "error.code.login.failed",
5
+ tr: [
6
+ { l: "en", v: "Access denied. Please check your credentials and retry" },
7
+ { l: "it", v: "Accesso negato. Controllare le credenziali e riprovare" },
8
+ { l: "pl", v: "Accesso negato. Controllare le credenziali e riprovare" },
9
+ ],
10
+ },
11
+ {
12
+ code: "http.error.code.400",
13
+ tr: [
14
+ { l: "en", v: "Sorry, the request is wrong (400)" },
15
+ { l: "it", v: "Siamo spiacenti, la richiesta è errata (400)" },
16
+ { l: "pl", v: "Siamo spiacenti, la richiesta è errata (400)" },
17
+ ],
18
+ overrides: [
19
+ {
20
+ customer: "c1",
21
+ tr: [
22
+ { l: "en", v: "Access denied C1" },
23
+ { l: "it", v: "Accesso negato C1" },
24
+ { l: "pl", v: "Accesso negato C1" },
25
+ ],
26
+ },
27
+ {
28
+ customer: "c2",
29
+ tr: [
30
+ { l: "en", v: "Access denied C2" },
31
+ { l: "it", v: "Accesso negato C2" },
32
+ { l: "pl", v: "Accesso negato C2" },
33
+ ],
34
+ },
35
+ {
36
+ customer: "c1",
37
+ tr: [
38
+ { l: "en", v: "Access denied C1" },
39
+ { l: "it", v: "Accesso negato C1" },
40
+ { l: "pl", v: "Accesso negato C1" },
41
+ ],
42
+ },
43
+ ],
44
+ },
45
+ {
46
+ code: "http.error.code.generic",
47
+ tr: [
48
+ { l: "en", v: "Generic comunication error" },
49
+ { l: "it", v: "Errore di comunicazione generica" },
50
+ { l: "pl", v: "Errore di comunicazione generica" },
51
+ ],
52
+ },
53
+ ];
@@ -0,0 +1,21 @@
1
+ export const messages: ({
2
+ code: string;
3
+ tr: {
4
+ l: string;
5
+ v: string;
6
+ }[];
7
+ overrides?: undefined;
8
+ } | {
9
+ code: string;
10
+ tr: {
11
+ l: string;
12
+ v: string;
13
+ }[];
14
+ overrides: {
15
+ customer: string;
16
+ tr: {
17
+ l: string;
18
+ v: string;
19
+ }[];
20
+ }[];
21
+ })[];
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ exports.messages = [
3
+ {
4
+ code: "error.code.login.failed",
5
+ tr: [
6
+ {
7
+ l: "en",
8
+ v: "Access denied. Please check your credentials and retry",
9
+ },
10
+ {
11
+ l: "it",
12
+ v: "Accesso negato. Controllare le credenziali e riprovare",
13
+ },
14
+ {
15
+ l: "pl",
16
+ v: "Accesso negato. Controllare le credenziali e riprovare",
17
+ },
18
+ ],
19
+ },
20
+ {
21
+ code: "http.error.code.400",
22
+ tr: [
23
+ { l: "en", v: "Sorry, the request is wrong (400)" },
24
+ { l: "it", v: "Siamo spiacenti, la richiesta è errata (400)" },
25
+ { l: "pl", v: "Siamo spiacenti, la richiesta è errata (400)" },
26
+ ],
27
+ overrides: [
28
+ {
29
+ customer: "c1",
30
+ tr: [
31
+ {
32
+ l: "en",
33
+ v: "Access denied C1",
34
+ },
35
+ {
36
+ l: "it",
37
+ v: "Accesso negato C1",
38
+ },
39
+ {
40
+ l: "pl",
41
+ v: "Accesso negato C1",
42
+ },
43
+ ],
44
+ },
45
+ {
46
+ customer: "c2",
47
+ tr: [
48
+ {
49
+ l: "en",
50
+ v: "Access denied C2",
51
+ },
52
+ {
53
+ l: "it",
54
+ v: "Accesso negato C2",
55
+ },
56
+ {
57
+ l: "pl",
58
+ v: "Accesso negato C2",
59
+ },
60
+ ],
61
+ },
62
+ {
63
+ customer: "c1",
64
+ tr: [
65
+ {
66
+ l: "en",
67
+ v: "Access denied C1",
68
+ },
69
+ {
70
+ l: "it",
71
+ v: "Accesso negato C1",
72
+ },
73
+ {
74
+ l: "pl",
75
+ v: "Accesso negato C1",
76
+ },
77
+ ],
78
+ },
79
+ ],
80
+ },
81
+ {
82
+ code: "http.error.code.generic",
83
+ tr: [
84
+ { l: "en", v: "Generic comunication error" },
85
+ { l: "it", v: "Errore di comunicazione generica" },
86
+ { l: "pl", v: "Errore di comunicazione generica" },
87
+ ],
88
+ },
89
+ ];
@@ -1,2 +1,2 @@
1
- export declare const checkSingleFile: (inputPath: string, from: string, to: string) => Promise<void>;
1
+ export declare const checkSingleFile: (inputPath: string, from: string, to: string) => Promise<any>;
2
2
  export declare const checkMultipleFile: (inputPath: string, from: string, to: string) => Promise<void>;
@@ -58,9 +58,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
58
58
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
59
  }
60
60
  };
61
+ var __importDefault = (this && this.__importDefault) || function (mod) {
62
+ return (mod && mod.__esModule) ? mod : { "default": mod };
63
+ };
61
64
  Object.defineProperty(exports, "__esModule", { value: true });
62
65
  exports.checkMultipleFile = exports.checkSingleFile = void 0;
63
- var fs = require("fs");
66
+ var fs_1 = __importDefault(require("fs"));
64
67
  var prettier = __importStar(require("prettier"));
65
68
  var checkSingleFile = function (inputPath, from, to) { return __awaiter(void 0, void 0, void 0, function () {
66
69
  var fileContent, addValue, existLang, newContent, writeContent, prettierContent;
@@ -111,8 +114,8 @@ var checkSingleFile = function (inputPath, from, to) { return __awaiter(void 0,
111
114
  return [4, prettier.format(writeContent, { parser: "babel" })];
112
115
  case 1:
113
116
  prettierContent = _a.sent();
114
- fs.writeFileSync(inputPath, prettierContent, "utf-8");
115
- return [2];
117
+ fs_1.default.writeFileSync(inputPath, prettierContent, "utf-8");
118
+ return [2, newContent];
116
119
  }
117
120
  });
118
121
  }); };
@@ -166,7 +169,7 @@ var checkMultipleFile = function (inputPath, from, to) { return __awaiter(void 0
166
169
  return [4, prettier.format(writeContent, { parser: "babel" })];
167
170
  case 1:
168
171
  prettierContent = _a.sent();
169
- fs.writeFileSync(inputPath, prettierContent, "utf-8");
172
+ fs_1.default.writeFileSync(inputPath, prettierContent, "utf-8");
170
173
  return [2];
171
174
  }
172
175
  });
@@ -109,11 +109,12 @@ var writeNamespacesFile = function (namespaces) {
109
109
  var ns = _a[0];
110
110
  return result + "export * from './".concat(ns, "';").concat(os_1.EOL);
111
111
  }, AUTOGENERATED_HEADER);
112
- fs_1.default.writeFile(outTsFile, content, function (err) {
113
- if (err) {
114
- console.log("Error writing to", outTsFile);
115
- }
116
- });
112
+ try {
113
+ fs_1.default.writeFileSync(outTsFile, content);
114
+ }
115
+ catch (e) {
116
+ console.log("Error writing to", outTsFile);
117
+ }
117
118
  };
118
119
  var allLanguagesReport = function (data, languages) {
119
120
  data.forEach(function (value) {
@@ -129,7 +130,7 @@ var allLanguagesReport = function (data, languages) {
129
130
  }
130
131
  });
131
132
  };
132
- var report = function (data, languages, uniqueCode) {
133
+ var report = function (data, languages, uniqueCode, uniqueOverrides) {
133
134
  var e = 0;
134
135
  data.forEach(function (value) {
135
136
  var _a;
@@ -144,11 +145,33 @@ var report = function (data, languages, uniqueCode) {
144
145
  e = 1;
145
146
  }
146
147
  value.tr.forEach(function (i) {
147
- valueLanguages.push(i.l);
148
+ var isUniqueLang = valueLanguages.includes(i.l);
149
+ if (!isUniqueLang) {
150
+ valueLanguages.push(i.l);
151
+ }
152
+ else {
153
+ console.log("\x1b[31m Duplicate language: \x1b[0m", i.l, "\x1b[31m in Code: \x1b[0m", value.code);
154
+ e = 1;
155
+ }
148
156
  });
149
157
  (_a = value.overrides) === null || _a === void 0 ? void 0 : _a.forEach(function (i) {
158
+ var isUniqueOverrides = uniqueOverrides.includes(i.customer);
159
+ if (!isUniqueOverrides) {
160
+ uniqueOverrides.push(i.customer);
161
+ }
162
+ else {
163
+ console.log("\x1b[31m Duplicate Customer: \x1b[0m", i.customer);
164
+ e = 1;
165
+ }
150
166
  i.tr.forEach(function (value) {
151
- valueLanguagesOverrites.push(value.l);
167
+ var isUniqueOverridesLang = valueLanguagesOverrites.includes(value.l);
168
+ if (!isUniqueOverridesLang) {
169
+ valueLanguagesOverrites.push(value.l);
170
+ }
171
+ else {
172
+ console.log("\x1b[31m Duplicate language: \x1b[0m", value.l, "\x1b[31m in Customer: \x1b[0m", i.customer);
173
+ e = 1;
174
+ }
152
175
  });
153
176
  var differentArrOverrides = languages.filter(function (x) { return !valueLanguagesOverrites.includes(x); });
154
177
  if (differentArrOverrides[0]) {
@@ -174,9 +197,10 @@ var multiFileReport = function (languages, namespaces) {
174
197
  var uniqueLang = getAllLanguagesUnique(languages);
175
198
  var numeError = 0;
176
199
  var uniqueCode = [];
200
+ var uniqueOverrides = [];
177
201
  for (var _i = 0, namespaces_1 = namespaces; _i < namespaces_1.length; _i++) {
178
202
  var _a = namespaces_1[_i], messages = _a[1];
179
- var e = report(messages, uniqueLang, uniqueCode);
203
+ var e = report(messages, uniqueLang, uniqueCode, uniqueOverrides);
180
204
  numeError = numeError + e;
181
205
  }
182
206
  console.log("All languages: ", uniqueLang);
@@ -184,10 +208,11 @@ var multiFileReport = function (languages, namespaces) {
184
208
  };
185
209
  var singleFileReport = function (message, languages) {
186
210
  var uniqueCode = [];
211
+ var uniqueOverrides = [];
187
212
  console.log();
188
213
  console.log("-----REPORT-------");
189
214
  var uniqueLang = getAllLanguagesUnique(languages);
190
- var e = report(message, uniqueLang, uniqueCode);
215
+ var e = report(message, uniqueLang, uniqueCode, uniqueOverrides);
191
216
  console.log("All languages: ", uniqueLang);
192
217
  return e !== 0 ? 1 : 0;
193
218
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var pwd2hash_1 = require("./pwd2hash");
3
+ var pwd2hash_1 = require("../pwd2hash");
4
4
  describe("verify password hash", function () {
5
5
  it("returns md5 hex value of password in case of password hash is running well", function () {
6
6
  var password = "NonDireGatto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melfore/clibelt",
3
- "version": "6.0.2",
3
+ "version": "6.0.3",
4
4
  "homepage": "https://github.com/melfore/clibelt#readme",
5
5
  "description": "CLI belt: the Melfore tool belt",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "copy:assets": "copyfiles --verbose ./src/**/*.{json,png,jpg,svg,xls,xlsx} ./dist/",
29
29
  "republish": "npm run build:clean && yalc push",
30
30
  "test:i18n": "rm -f test/out/*.json test/out/*.ts && nodemon --exec 'ts-node' src/cli/i18n-msg/index.ts",
31
- "test": "jest --config jest.config.js --runInBand",
31
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config jest.config.js --runInBand",
32
32
  "test:watch": "jest --config jest.config.js --watch --detectOpenHandles",
33
33
  "lintify": "eslint .",
34
34
  "prettify": "prettier --write .",