emessages 2.2.5 → 2.2.6
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 -6
- package/dist/cli.cjs +0 -101
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.d.cts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.mjs +0 -78
- package/dist/cli.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emessages",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "A flexible error handling library for JS/TS. Define custom errors with console, toast, and callbacks, supporting global/local scopes and all environments.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -27,11 +27,7 @@
|
|
|
27
27
|
"sideEffects": true,
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"scripts": {
|
|
30
|
-
"build": "tsup"
|
|
31
|
-
"postinstall": "node dist/cli.cjs"
|
|
32
|
-
},
|
|
33
|
-
"bin": {
|
|
34
|
-
"emessages": "./dist/cli.cjs"
|
|
30
|
+
"build": "tsup"
|
|
35
31
|
},
|
|
36
32
|
"devDependencies": {
|
|
37
33
|
"@types/node": "^20.11.24",
|
package/dist/cli.cjs
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
-
mod
|
|
24
|
-
));
|
|
25
|
-
|
|
26
|
-
// src/cli.ts
|
|
27
|
-
var fs = __toESM(require("fs"), 1);
|
|
28
|
-
var path = __toESM(require("path"), 1);
|
|
29
|
-
var readline = __toESM(require("readline"), 1);
|
|
30
|
-
var fileName = "EmessageGlobal";
|
|
31
|
-
var jsContent = `export const Emessage_global = [
|
|
32
|
-
{
|
|
33
|
-
GLOBAL_ERROR_MESSAGE: "Global error message.",
|
|
34
|
-
type:"war",
|
|
35
|
-
break:false,
|
|
36
|
-
toast: true
|
|
37
|
-
},
|
|
38
|
-
// {
|
|
39
|
-
// Add your custom global messages here.
|
|
40
|
-
// }
|
|
41
|
-
];
|
|
42
|
-
`;
|
|
43
|
-
var tsContent = `export const Emessage_global = [
|
|
44
|
-
{
|
|
45
|
-
GLOBAL_ERROR_MESSAGE: "Global error message.",
|
|
46
|
-
type:"war",
|
|
47
|
-
break:false,
|
|
48
|
-
toast: true
|
|
49
|
-
},
|
|
50
|
-
// {
|
|
51
|
-
// Add your custom global messages here.
|
|
52
|
-
// }
|
|
53
|
-
];
|
|
54
|
-
`;
|
|
55
|
-
function findProjectRoot(startDir) {
|
|
56
|
-
let currentDir = startDir;
|
|
57
|
-
while (currentDir !== path.parse(currentDir).root) {
|
|
58
|
-
if (fs.existsSync(path.join(currentDir, "package.json"))) {
|
|
59
|
-
return currentDir;
|
|
60
|
-
}
|
|
61
|
-
currentDir = path.dirname(currentDir);
|
|
62
|
-
}
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
function generateGlobalEmessageFile() {
|
|
66
|
-
const rl = readline.createInterface({
|
|
67
|
-
input: process.stdin,
|
|
68
|
-
output: process.stdout
|
|
69
|
-
});
|
|
70
|
-
rl.question("You want to create EmessageGlobal file: (y) ", (answer) => {
|
|
71
|
-
if (answer.toLowerCase() === "y" || answer.toLowerCase() === "yes" || answer === "") {
|
|
72
|
-
const cwd = process.cwd();
|
|
73
|
-
const projectRoot = findProjectRoot(cwd);
|
|
74
|
-
if (!projectRoot) {
|
|
75
|
-
console.error("Error: Could not find project root (package.json not found).");
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
78
|
-
const tsconfigPath = path.join(projectRoot, "tsconfig.json");
|
|
79
|
-
const isTypeScriptProject = fs.existsSync(tsconfigPath);
|
|
80
|
-
const fileExtension = isTypeScriptProject ? "ts" : "js";
|
|
81
|
-
const content = isTypeScriptProject ? tsContent : jsContent;
|
|
82
|
-
const outputFileName = `${fileName}.${fileExtension}`;
|
|
83
|
-
const outputPath = path.join(projectRoot, outputFileName);
|
|
84
|
-
if (fs.existsSync(outputPath)) {
|
|
85
|
-
console.warn(`Warning: ${outputFileName} already exists. Skipping file creation.`);
|
|
86
|
-
process.exit(0);
|
|
87
|
-
}
|
|
88
|
-
try {
|
|
89
|
-
fs.writeFileSync(outputPath, content, "utf8");
|
|
90
|
-
console.log(`Successfully created ${outputFileName} in your project root.`);
|
|
91
|
-
console.log("You can now configure global messages by editing this file.");
|
|
92
|
-
} catch (error) {
|
|
93
|
-
console.error(`Error creating ${outputFileName}:`, error.message);
|
|
94
|
-
process.exit(1);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
rl.close();
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
generateGlobalEmessageFile();
|
|
101
|
-
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as readline from 'readline';\n\nconst fileName = 'EmessageGlobal';\nconst jsContent = `export const Emessage_global = [\n {\n GLOBAL_ERROR_MESSAGE: \"Global error message.\",\n type:\"war\",\n break:false,\n toast: true\n },\n // {\n // Add your custom global messages here.\n // }\n];\n`;\n\nconst tsContent = `export const Emessage_global = [\n {\n GLOBAL_ERROR_MESSAGE: \"Global error message.\",\n type:\"war\",\n break:false,\n toast: true\n },\n // {\n // Add your custom global messages here.\n // }\n];\n`;\n\nfunction findProjectRoot(startDir: string): string | null {\n let currentDir = startDir;\n while (currentDir !== path.parse(currentDir).root) {\n if (fs.existsSync(path.join(currentDir, 'package.json'))) {\n return currentDir;\n }\n currentDir = path.dirname(currentDir);\n }\n return null;\n}\n\nfunction generateGlobalEmessageFile() {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n\n rl.question('You want to create EmessageGlobal file: (y) ', (answer) => {\n if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes' || answer === '') {\n const cwd = process.cwd();\n const projectRoot = findProjectRoot(cwd);\n\n if (!projectRoot) {\n console.error('Error: Could not find project root (package.json not found).');\n process.exit(1);\n }\n\n const tsconfigPath = path.join(projectRoot, 'tsconfig.json');\n const isTypeScriptProject = fs.existsSync(tsconfigPath);\n\n const fileExtension = isTypeScriptProject ? 'ts' : 'js';\n const content = isTypeScriptProject ? tsContent : jsContent;\n const outputFileName = `${fileName}.${fileExtension}`;\n const outputPath = path.join(projectRoot, outputFileName);\n\n if (fs.existsSync(outputPath)) {\n console.warn(`Warning: ${outputFileName} already exists. Skipping file creation.`);\n process.exit(0);\n }\n\n try {\n fs.writeFileSync(outputPath, content, 'utf8');\n console.log(`Successfully created ${outputFileName} in your project root.`);\n console.log('You can now configure global messages by editing this file.');\n } catch (error: any) {\n console.error(`Error creating ${outputFileName}:`, error.message);\n process.exit(1);\n }\n }\n rl.close();\n });\n}\n\ngenerateGlobalEmessageFile();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAoB;AACpB,WAAsB;AACtB,eAA0B;AAE1B,IAAM,WAAW;AACjB,IAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAalB,IAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAalB,SAAS,gBAAgB,UAAiC;AACtD,MAAI,aAAa;AACjB,SAAO,eAAoB,WAAM,UAAU,EAAE,MAAM;AAC/C,QAAO,cAAgB,UAAK,YAAY,cAAc,CAAC,GAAG;AACtD,aAAO;AAAA,IACX;AACA,iBAAkB,aAAQ,UAAU;AAAA,EACxC;AACA,SAAO;AACX;AAEA,SAAS,6BAA6B;AAClC,QAAM,KAAc,yBAAgB;AAAA,IAChC,OAAO,QAAQ;AAAA,IACf,QAAQ,QAAQ;AAAA,EACpB,CAAC;AAED,KAAG,SAAS,gDAAgD,CAAC,WAAW;AACpE,QAAI,OAAO,YAAY,MAAM,OAAO,OAAO,YAAY,MAAM,SAAS,WAAW,IAAI;AACjF,YAAM,MAAM,QAAQ,IAAI;AACxB,YAAM,cAAc,gBAAgB,GAAG;AAEvC,UAAI,CAAC,aAAa;AACd,gBAAQ,MAAM,8DAA8D;AAC5E,gBAAQ,KAAK,CAAC;AAAA,MAClB;AAEA,YAAM,eAAoB,UAAK,aAAa,eAAe;AAC3D,YAAM,sBAAyB,cAAW,YAAY;AAEtD,YAAM,gBAAgB,sBAAsB,OAAO;AACnD,YAAM,UAAU,sBAAsB,YAAY;AAClD,YAAM,iBAAiB,GAAG,QAAQ,IAAI,aAAa;AACnD,YAAM,aAAkB,UAAK,aAAa,cAAc;AAExD,UAAO,cAAW,UAAU,GAAG;AAC3B,gBAAQ,KAAK,YAAY,cAAc,0CAA0C;AACjF,gBAAQ,KAAK,CAAC;AAAA,MAClB;AAEA,UAAI;AACA,QAAG,iBAAc,YAAY,SAAS,MAAM;AAC5C,gBAAQ,IAAI,wBAAwB,cAAc,wBAAwB;AAC1E,gBAAQ,IAAI,6DAA6D;AAAA,MAC7E,SAAS,OAAY;AACjB,gBAAQ,MAAM,kBAAkB,cAAc,KAAK,MAAM,OAAO;AAChE,gBAAQ,KAAK,CAAC;AAAA,MAClB;AAAA,IACJ;AACA,OAAG,MAAM;AAAA,EACb,CAAC;AACL;AAEA,2BAA2B;","names":[]}
|
package/dist/cli.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
package/dist/cli.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
package/dist/cli.mjs
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/cli.ts
|
|
4
|
-
import * as fs from "fs";
|
|
5
|
-
import * as path from "path";
|
|
6
|
-
import * as readline from "readline";
|
|
7
|
-
var fileName = "EmessageGlobal";
|
|
8
|
-
var jsContent = `export const Emessage_global = [
|
|
9
|
-
{
|
|
10
|
-
GLOBAL_ERROR_MESSAGE: "Global error message.",
|
|
11
|
-
type:"war",
|
|
12
|
-
break:false,
|
|
13
|
-
toast: true
|
|
14
|
-
},
|
|
15
|
-
// {
|
|
16
|
-
// Add your custom global messages here.
|
|
17
|
-
// }
|
|
18
|
-
];
|
|
19
|
-
`;
|
|
20
|
-
var tsContent = `export const Emessage_global = [
|
|
21
|
-
{
|
|
22
|
-
GLOBAL_ERROR_MESSAGE: "Global error message.",
|
|
23
|
-
type:"war",
|
|
24
|
-
break:false,
|
|
25
|
-
toast: true
|
|
26
|
-
},
|
|
27
|
-
// {
|
|
28
|
-
// Add your custom global messages here.
|
|
29
|
-
// }
|
|
30
|
-
];
|
|
31
|
-
`;
|
|
32
|
-
function findProjectRoot(startDir) {
|
|
33
|
-
let currentDir = startDir;
|
|
34
|
-
while (currentDir !== path.parse(currentDir).root) {
|
|
35
|
-
if (fs.existsSync(path.join(currentDir, "package.json"))) {
|
|
36
|
-
return currentDir;
|
|
37
|
-
}
|
|
38
|
-
currentDir = path.dirname(currentDir);
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
function generateGlobalEmessageFile() {
|
|
43
|
-
const rl = readline.createInterface({
|
|
44
|
-
input: process.stdin,
|
|
45
|
-
output: process.stdout
|
|
46
|
-
});
|
|
47
|
-
rl.question("You want to create EmessageGlobal file: (y) ", (answer) => {
|
|
48
|
-
if (answer.toLowerCase() === "y" || answer.toLowerCase() === "yes" || answer === "") {
|
|
49
|
-
const cwd = process.cwd();
|
|
50
|
-
const projectRoot = findProjectRoot(cwd);
|
|
51
|
-
if (!projectRoot) {
|
|
52
|
-
console.error("Error: Could not find project root (package.json not found).");
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
const tsconfigPath = path.join(projectRoot, "tsconfig.json");
|
|
56
|
-
const isTypeScriptProject = fs.existsSync(tsconfigPath);
|
|
57
|
-
const fileExtension = isTypeScriptProject ? "ts" : "js";
|
|
58
|
-
const content = isTypeScriptProject ? tsContent : jsContent;
|
|
59
|
-
const outputFileName = `${fileName}.${fileExtension}`;
|
|
60
|
-
const outputPath = path.join(projectRoot, outputFileName);
|
|
61
|
-
if (fs.existsSync(outputPath)) {
|
|
62
|
-
console.warn(`Warning: ${outputFileName} already exists. Skipping file creation.`);
|
|
63
|
-
process.exit(0);
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
fs.writeFileSync(outputPath, content, "utf8");
|
|
67
|
-
console.log(`Successfully created ${outputFileName} in your project root.`);
|
|
68
|
-
console.log("You can now configure global messages by editing this file.");
|
|
69
|
-
} catch (error) {
|
|
70
|
-
console.error(`Error creating ${outputFileName}:`, error.message);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
rl.close();
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
generateGlobalEmessageFile();
|
|
78
|
-
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as readline from 'readline';\n\nconst fileName = 'EmessageGlobal';\nconst jsContent = `export const Emessage_global = [\n {\n GLOBAL_ERROR_MESSAGE: \"Global error message.\",\n type:\"war\",\n break:false,\n toast: true\n },\n // {\n // Add your custom global messages here.\n // }\n];\n`;\n\nconst tsContent = `export const Emessage_global = [\n {\n GLOBAL_ERROR_MESSAGE: \"Global error message.\",\n type:\"war\",\n break:false,\n toast: true\n },\n // {\n // Add your custom global messages here.\n // }\n];\n`;\n\nfunction findProjectRoot(startDir: string): string | null {\n let currentDir = startDir;\n while (currentDir !== path.parse(currentDir).root) {\n if (fs.existsSync(path.join(currentDir, 'package.json'))) {\n return currentDir;\n }\n currentDir = path.dirname(currentDir);\n }\n return null;\n}\n\nfunction generateGlobalEmessageFile() {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n\n rl.question('You want to create EmessageGlobal file: (y) ', (answer) => {\n if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes' || answer === '') {\n const cwd = process.cwd();\n const projectRoot = findProjectRoot(cwd);\n\n if (!projectRoot) {\n console.error('Error: Could not find project root (package.json not found).');\n process.exit(1);\n }\n\n const tsconfigPath = path.join(projectRoot, 'tsconfig.json');\n const isTypeScriptProject = fs.existsSync(tsconfigPath);\n\n const fileExtension = isTypeScriptProject ? 'ts' : 'js';\n const content = isTypeScriptProject ? tsContent : jsContent;\n const outputFileName = `${fileName}.${fileExtension}`;\n const outputPath = path.join(projectRoot, outputFileName);\n\n if (fs.existsSync(outputPath)) {\n console.warn(`Warning: ${outputFileName} already exists. Skipping file creation.`);\n process.exit(0);\n }\n\n try {\n fs.writeFileSync(outputPath, content, 'utf8');\n console.log(`Successfully created ${outputFileName} in your project root.`);\n console.log('You can now configure global messages by editing this file.');\n } catch (error: any) {\n console.error(`Error creating ${outputFileName}:`, error.message);\n process.exit(1);\n }\n }\n rl.close();\n });\n}\n\ngenerateGlobalEmessageFile();\n"],"mappings":";;;AAEA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,cAAc;AAE1B,IAAM,WAAW;AACjB,IAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAalB,IAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAalB,SAAS,gBAAgB,UAAiC;AACtD,MAAI,aAAa;AACjB,SAAO,eAAoB,WAAM,UAAU,EAAE,MAAM;AAC/C,QAAO,cAAgB,UAAK,YAAY,cAAc,CAAC,GAAG;AACtD,aAAO;AAAA,IACX;AACA,iBAAkB,aAAQ,UAAU;AAAA,EACxC;AACA,SAAO;AACX;AAEA,SAAS,6BAA6B;AAClC,QAAM,KAAc,yBAAgB;AAAA,IAChC,OAAO,QAAQ;AAAA,IACf,QAAQ,QAAQ;AAAA,EACpB,CAAC;AAED,KAAG,SAAS,gDAAgD,CAAC,WAAW;AACpE,QAAI,OAAO,YAAY,MAAM,OAAO,OAAO,YAAY,MAAM,SAAS,WAAW,IAAI;AACjF,YAAM,MAAM,QAAQ,IAAI;AACxB,YAAM,cAAc,gBAAgB,GAAG;AAEvC,UAAI,CAAC,aAAa;AACd,gBAAQ,MAAM,8DAA8D;AAC5E,gBAAQ,KAAK,CAAC;AAAA,MAClB;AAEA,YAAM,eAAoB,UAAK,aAAa,eAAe;AAC3D,YAAM,sBAAyB,cAAW,YAAY;AAEtD,YAAM,gBAAgB,sBAAsB,OAAO;AACnD,YAAM,UAAU,sBAAsB,YAAY;AAClD,YAAM,iBAAiB,GAAG,QAAQ,IAAI,aAAa;AACnD,YAAM,aAAkB,UAAK,aAAa,cAAc;AAExD,UAAO,cAAW,UAAU,GAAG;AAC3B,gBAAQ,KAAK,YAAY,cAAc,0CAA0C;AACjF,gBAAQ,KAAK,CAAC;AAAA,MAClB;AAEA,UAAI;AACA,QAAG,iBAAc,YAAY,SAAS,MAAM;AAC5C,gBAAQ,IAAI,wBAAwB,cAAc,wBAAwB;AAC1E,gBAAQ,IAAI,6DAA6D;AAAA,MAC7E,SAAS,OAAY;AACjB,gBAAQ,MAAM,kBAAkB,cAAc,KAAK,MAAM,OAAO;AAChE,gBAAQ,KAAK,CAAC;AAAA,MAClB;AAAA,IACJ;AACA,OAAG,MAAM;AAAA,EACb,CAAC;AACL;AAEA,2BAA2B;","names":[]}
|