emessages 2.2.0 → 2.2.1

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/dist/cli.cjs ADDED
@@ -0,0 +1,89 @@
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 fileName = "globalEMessage";
30
+ var jsContent = `import { Emessage } from "emessages";
31
+
32
+ /*
33
+ * Add your global error messages and available operation here.
34
+ */
35
+ Emessage.global(
36
+ {
37
+ "GLOBAL_ERROR_NAME": "GLOBAL ERROR MESSAGE",
38
+ }
39
+ );
40
+ `;
41
+ var tsContent = `import { Emessage } from "emessages";
42
+
43
+ /*
44
+ * Add your global error messages and available operation here.
45
+ */
46
+ Emessage.global(
47
+ {
48
+ "GLOBAL_ERROR_NAME": "GLOBAL ERROR MESSAGE",
49
+ }
50
+ );
51
+ `;
52
+ function findProjectRoot(startDir) {
53
+ let currentDir = startDir;
54
+ while (currentDir !== path.parse(currentDir).root) {
55
+ if (fs.existsSync(path.join(currentDir, "package.json"))) {
56
+ return currentDir;
57
+ }
58
+ currentDir = path.dirname(currentDir);
59
+ }
60
+ return null;
61
+ }
62
+ function generateGlobalEmessageFile() {
63
+ const cwd = process.cwd();
64
+ const projectRoot = findProjectRoot(cwd);
65
+ if (!projectRoot) {
66
+ console.error("Error: Could not find project root (package.json not found).");
67
+ process.exit(1);
68
+ }
69
+ const tsconfigPath = path.join(projectRoot, "tsconfig.json");
70
+ const isTypeScriptProject = fs.existsSync(tsconfigPath);
71
+ const fileExtension = isTypeScriptProject ? "ts" : "js";
72
+ const content = isTypeScriptProject ? tsContent : jsContent;
73
+ const outputFileName = `${fileName}.${fileExtension}`;
74
+ const outputPath = path.join(projectRoot, outputFileName);
75
+ if (fs.existsSync(outputPath)) {
76
+ console.warn(`Warning: ${outputFileName} already exists. Skipping file creation.`);
77
+ process.exit(0);
78
+ }
79
+ try {
80
+ fs.writeFileSync(outputPath, content, "utf8");
81
+ console.log(`Successfully created ${outputFileName} in your project root.`);
82
+ console.log("You can now configure global messages by editing this file.");
83
+ } catch (error) {
84
+ console.error(`Error creating ${outputFileName}:`, error.message);
85
+ process.exit(1);
86
+ }
87
+ }
88
+ generateGlobalEmessageFile();
89
+ //# sourceMappingURL=cli.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nconst fileName = 'globalEMessage';\nconst jsContent = `import { Emessage } from \"emessages\";\n\n/*\n * Add your global error messages and available operation here.\n */\nEmessage.global(\n {\n \"GLOBAL_ERROR_NAME\": \"GLOBAL ERROR MESSAGE\",\n }\n);\n`;\n\nconst tsContent = `import { Emessage } from \"emessages\";\n\n/*\n * Add your global error messages and available operation here.\n */\nEmessage.global(\n {\n \"GLOBAL_ERROR_NAME\": \"GLOBAL ERROR MESSAGE\",\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 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\ngenerateGlobalEmessageFile();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAoB;AACpB,WAAsB;AAEtB,IAAM,WAAW;AACjB,IAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYlB,IAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYlB,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,MAAM,QAAQ,IAAI;AACxB,QAAM,cAAc,gBAAgB,GAAG;AAEvC,MAAI,CAAC,aAAa;AACd,YAAQ,MAAM,8DAA8D;AAC5E,YAAQ,KAAK,CAAC;AAAA,EAClB;AAEA,QAAM,eAAoB,UAAK,aAAa,eAAe;AAC3D,QAAM,sBAAyB,cAAW,YAAY;AAEtD,QAAM,gBAAgB,sBAAsB,OAAO;AACnD,QAAM,UAAU,sBAAsB,YAAY;AAClD,QAAM,iBAAiB,GAAG,QAAQ,IAAI,aAAa;AACnD,QAAM,aAAkB,UAAK,aAAa,cAAc;AAExD,MAAO,cAAW,UAAU,GAAG;AAC3B,YAAQ,KAAK,YAAY,cAAc,0CAA0C;AACjF,YAAQ,KAAK,CAAC;AAAA,EAClB;AAEA,MAAI;AACA,IAAG,iBAAc,YAAY,SAAS,MAAM;AAC5C,YAAQ,IAAI,wBAAwB,cAAc,wBAAwB;AAC1E,YAAQ,IAAI,6DAA6D;AAAA,EAC7E,SAAS,OAAY;AACjB,YAAQ,MAAM,kBAAkB,cAAc,KAAK,MAAM,OAAO;AAChE,YAAQ,KAAK,CAAC;AAAA,EAClB;AACJ;AAEA,2BAA2B;","names":[]}
package/dist/cli.d.cts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.mjs ADDED
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli.ts
4
+ import * as fs from "fs";
5
+ import * as path from "path";
6
+ var fileName = "globalEMessage";
7
+ var jsContent = `import { Emessage } from "emessages";
8
+
9
+ /*
10
+ * Add your global error messages and available operation here.
11
+ */
12
+ Emessage.global(
13
+ {
14
+ "GLOBAL_ERROR_NAME": "GLOBAL ERROR MESSAGE",
15
+ }
16
+ );
17
+ `;
18
+ var tsContent = `import { Emessage } from "emessages";
19
+
20
+ /*
21
+ * Add your global error messages and available operation here.
22
+ */
23
+ Emessage.global(
24
+ {
25
+ "GLOBAL_ERROR_NAME": "GLOBAL ERROR MESSAGE",
26
+ }
27
+ );
28
+ `;
29
+ function findProjectRoot(startDir) {
30
+ let currentDir = startDir;
31
+ while (currentDir !== path.parse(currentDir).root) {
32
+ if (fs.existsSync(path.join(currentDir, "package.json"))) {
33
+ return currentDir;
34
+ }
35
+ currentDir = path.dirname(currentDir);
36
+ }
37
+ return null;
38
+ }
39
+ function generateGlobalEmessageFile() {
40
+ const cwd = process.cwd();
41
+ const projectRoot = findProjectRoot(cwd);
42
+ if (!projectRoot) {
43
+ console.error("Error: Could not find project root (package.json not found).");
44
+ process.exit(1);
45
+ }
46
+ const tsconfigPath = path.join(projectRoot, "tsconfig.json");
47
+ const isTypeScriptProject = fs.existsSync(tsconfigPath);
48
+ const fileExtension = isTypeScriptProject ? "ts" : "js";
49
+ const content = isTypeScriptProject ? tsContent : jsContent;
50
+ const outputFileName = `${fileName}.${fileExtension}`;
51
+ const outputPath = path.join(projectRoot, outputFileName);
52
+ if (fs.existsSync(outputPath)) {
53
+ console.warn(`Warning: ${outputFileName} already exists. Skipping file creation.`);
54
+ process.exit(0);
55
+ }
56
+ try {
57
+ fs.writeFileSync(outputPath, content, "utf8");
58
+ console.log(`Successfully created ${outputFileName} in your project root.`);
59
+ console.log("You can now configure global messages by editing this file.");
60
+ } catch (error) {
61
+ console.error(`Error creating ${outputFileName}:`, error.message);
62
+ process.exit(1);
63
+ }
64
+ }
65
+ generateGlobalEmessageFile();
66
+ //# sourceMappingURL=cli.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nconst fileName = 'globalEMessage';\nconst jsContent = `import { Emessage } from \"emessages\";\n\n/*\n * Add your global error messages and available operation here.\n */\nEmessage.global(\n {\n \"GLOBAL_ERROR_NAME\": \"GLOBAL ERROR MESSAGE\",\n }\n);\n`;\n\nconst tsContent = `import { Emessage } from \"emessages\";\n\n/*\n * Add your global error messages and available operation here.\n */\nEmessage.global(\n {\n \"GLOBAL_ERROR_NAME\": \"GLOBAL ERROR MESSAGE\",\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 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\ngenerateGlobalEmessageFile();\n"],"mappings":";;;AAEA,YAAY,QAAQ;AACpB,YAAY,UAAU;AAEtB,IAAM,WAAW;AACjB,IAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYlB,IAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYlB,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,MAAM,QAAQ,IAAI;AACxB,QAAM,cAAc,gBAAgB,GAAG;AAEvC,MAAI,CAAC,aAAa;AACd,YAAQ,MAAM,8DAA8D;AAC5E,YAAQ,KAAK,CAAC;AAAA,EAClB;AAEA,QAAM,eAAoB,UAAK,aAAa,eAAe;AAC3D,QAAM,sBAAyB,cAAW,YAAY;AAEtD,QAAM,gBAAgB,sBAAsB,OAAO;AACnD,QAAM,UAAU,sBAAsB,YAAY;AAClD,QAAM,iBAAiB,GAAG,QAAQ,IAAI,aAAa;AACnD,QAAM,aAAkB,UAAK,aAAa,cAAc;AAExD,MAAO,cAAW,UAAU,GAAG;AAC3B,YAAQ,KAAK,YAAY,cAAc,0CAA0C;AACjF,YAAQ,KAAK,CAAC;AAAA,EAClB;AAEA,MAAI;AACA,IAAG,iBAAc,YAAY,SAAS,MAAM;AAC5C,YAAQ,IAAI,wBAAwB,cAAc,wBAAwB;AAC1E,YAAQ,IAAI,6DAA6D;AAAA,EAC7E,SAAS,OAAY;AACjB,YAAQ,MAAM,kBAAkB,cAAc,KAAK,MAAM,OAAO;AAChE,YAAQ,KAAK,CAAC;AAAA,EAClB;AACJ;AAEA,2BAA2B;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emessages",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
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",
@@ -29,6 +29,9 @@
29
29
  "scripts": {
30
30
  "build": "tsup"
31
31
  },
32
+ "bin": {
33
+ "emessages": "./dist/cli.cjs"
34
+ },
32
35
  "devDependencies": {
33
36
  "@types/node": "^20.11.24",
34
37
  "tsup": "^8.0.2",