qlcodes 1.1.3 → 1.1.4

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/README.md CHANGED
@@ -10,8 +10,7 @@ The project aims to cover sql states for most of RDBMS [drivers supported by **T
10
10
  Find bellow the actual coverage:
11
11
 
12
12
  🕓 MySQL | 🕓 MariaDB | ✅ PostgreSQL | 🕓 CockroachDB (Postgres-compatible)
13
- 🕓 Microsoft SQL Server | ✅ Oracle | 🕓 SQLite | 🕓 SAP HANA | 🕓 Google Spanner
14
- ✅ IBM*
13
+ 🕓 Microsoft SQL Server | ✅ Oracle | 🕓 SQLite | 🕓 SAP HANA | 🕓 Google Spanner | ✅ IBM*
15
14
  >( \* ) IBM defines and publishes SQLSTATE codes as part of the SQL standard, so their The codes should covere IBM products such as DB2, IBM Informix, IBM Netezza, IBM i (AS/400) .
16
15
 
17
16
  ## Installation
package/build.sh CHANGED
@@ -99,7 +99,7 @@ node generate.cjs --flag "oracle"> "$DIR/output3.txt"
99
99
  echo -e "$CHECK done"
100
100
 
101
101
  echo -e "${BLUE}Composition of the JSON file at $DIR/qlCodes.json${NC}"
102
- echo {} | node compose.mjs --file "$DIR/output1.txt"|\
102
+ node compose.mjs --file "$DIR/output1.txt"|\
103
103
  node compose.mjs --file "$DIR/output2.txt" |\
104
104
  node compose.mjs --file "$DIR/output3.txt" |\
105
105
  node pretty.mjs --file "$DIR/qlCodes.json"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qlcodes",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "main": "src/index.mjs",
5
5
  "scripts": {
6
6
  "build": "chmod +x ./build.sh; ./build.sh"
@@ -23,5 +23,10 @@
23
23
  ],
24
24
  "repository": {
25
25
  "url": "git+https://github.com/ManuUseGitHub/QLCodes.git"
26
+ },
27
+ "dependencies": {
28
+ "onstdin": "^1.0.0",
29
+ "reargv": "^1.0.2",
30
+ "to-snake-case": "^1.0.0"
26
31
  }
27
32
  }
package/src/compose.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from "fs";
2
- import { onStdIn } from "./utils/io.mjs";
2
+ import { onstdin } from "onstdin";
3
3
  import { CODE_RE, CLASS_RE, COMMENT_RE } from "./regex.mjs";
4
- import { reargv } from "./utils/args.mjs";
4
+ import { reargv } from "reargv";
5
5
  const argv = reargv();
6
6
  function flushBuffer(buffer, currentClass, currentCode) {
7
7
  if (!buffer.length) return buffer;
@@ -95,10 +95,11 @@ const debugInFile = (file, data = null) => {
95
95
  if (argv.options.file || argv.files.length) {
96
96
  const file = argv.options.file || argv.files[0];
97
97
 
98
- onStdIn((content) => {
98
+ onstdin((content) => {
99
99
  const isDebug = process.env.DEBUG;
100
100
  let states;
101
101
  try {
102
+ debugInFile(file, `content!${content}!`);
102
103
  states = JSON.parse(content ? content : "{}");
103
104
  } catch {
104
105
  states = {};
@@ -1,6 +1,6 @@
1
- import { onStdIn } from "../utils/io.mjs";
1
+ import { onstdin } from "onstdin";
2
2
 
3
- onStdIn((input) => {
3
+ onstdin((input) => {
4
4
  console.log(
5
5
  input
6
6
  .replaceAll("SQLSTATE Value;Meaning", "")
@@ -1,7 +1,7 @@
1
1
  import { insertHeadersAndFormat } from "../utils/codeName.mjs";
2
- import { onStdIn } from "../utils/io.mjs";
2
+ import { onstdin } from "onstdin";
3
3
 
4
- onStdIn((input) => {
4
+ onstdin((input) => {
5
5
  console.log(
6
6
  insertHeadersAndFormat(
7
7
  input
@@ -1,6 +1,6 @@
1
- import { onStdIn } from "../utils/io.mjs";
1
+ import { onstdin } from "onstdin";
2
2
 
3
- onStdIn((input) => {
3
+ onstdin((input) => {
4
4
  console.log(
5
5
  input
6
6
  .replaceAll(/ use_of_| the_| an_| a_|for_the_|_the|of_the_/gm, "")
package/src/generate.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  const fs = require("fs");
2
2
  const { ERROR_CODE_HEADER_RGX } = require("./regex.mjs");
3
3
  const { newCode } = require("./utils/codeName.mjs");
4
- const { reargv } = require("./utils/args.mjs");
5
- const { onStdIn } = require("./utils/io.mjs");
4
+ const { onstdin } = require("onstdin");
5
+ const { reargv } = require("reargv");
6
6
 
7
7
  const argv = reargv();
8
8
 
@@ -36,7 +36,7 @@ if (argv.options.file || argv.files.length) {
36
36
  const file = argv.options.file || argv.files[0];
37
37
  console.log(processCSVLines(fs.readFileSync(file, "utf8")));
38
38
  } else {
39
- onStdIn((csv) => {
39
+ onstdin((csv) => {
40
40
  console.log(processCSVLines(csv));
41
41
  });
42
42
  }
package/src/pretty.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import fs from "fs";
2
- import { reargv } from "./utils/args.mjs";
3
- import { onStdIn } from "./utils/io.mjs";
2
+ import { onstdin } from "onstdin";
3
+ import { reargv } from "reargv";
4
4
 
5
5
  const isDebug = process.env.DEBUG === "true";
6
6
  const argv = reargv();
@@ -8,7 +8,7 @@ const argv = reargv();
8
8
  if (argv.options.file || argv.files.length) {
9
9
  const file = argv.options.file || argv.files[0];
10
10
 
11
- onStdIn((content) => {
11
+ onstdin((content) => {
12
12
  fs.writeFile(
13
13
  file,
14
14
  JSON.stringify(JSON.parse(content), null, isDebug ? 2 : undefined),
package/src/readFile.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  import fs from "fs";
2
- import { reargv } from "./utils/args.mjs";
2
+ import { reargv } from "reargv";
3
3
 
4
4
  console.log(fs.readFileSync(reargv().files[0], "utf8"));
@@ -1,5 +1,5 @@
1
- import { reargv } from "./args.mjs";
2
- import { toSnakeCase } from "./str.mjs";
1
+ import { reargv } from "reargv";
2
+ import toSnakeCase from "to-snake-case";
3
3
 
4
4
  const argv = reargv();
5
5
 
@@ -1,32 +0,0 @@
1
- export const reargv = () => {
2
- const args = process.argv.slice(2);
3
- const argvs = { misc: [], options: {}, files: [] };
4
- const len = args.length;
5
- let jump = 0;
6
- for (const [i, arg] of args.entries()) {
7
- if (jump) {
8
- jump--;
9
- continue;
10
- }
11
- if (arg.startsWith("--")) {
12
- const option = arg.replace(/^-+/g, "");
13
- if (i + 1 < len) {
14
- const nextArg = args[i + 1];
15
- if (!nextArg.startsWith("--")) {
16
- argvs.options[option] = args[i + 1];
17
- jump++;
18
- } else {
19
- argvs.options[option] = true;
20
- jump++;
21
- }
22
- } else {
23
- argvs.options[option] = true;
24
- }
25
- } else if (/(\.(?:[a-zA-Z]+)+)$/.test(arg)) {
26
- argvs.files.push(arg);
27
- } else {
28
- argvs.misc.push(arg);
29
- }
30
- }
31
- return argvs;
32
- };
package/src/utils/io.mjs DELETED
@@ -1,11 +0,0 @@
1
- export const onStdIn = (cb) => {
2
- let input = "";
3
- process.stdin.setEncoding("utf8");
4
- process.stdin.on("data", (chunk) => {
5
- input += chunk;
6
- });
7
-
8
- process.stdin.on("end", () => {
9
- cb(input);
10
- });
11
- };
package/src/utils/str.mjs DELETED
@@ -1,5 +0,0 @@
1
- export const toSnakeCase = (text) =>
2
- text
3
- .toLowerCase()
4
- .replace(/[^a-z0-9]+/g, "_")
5
- .replace(/^_|_$/g, "");