@danielarndt0/cnpj-db-loader 2.3.0 → 2.3.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.js +16 -7
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7,12 +7,12 @@ import { Command } from "commander";
|
|
|
7
7
|
import { stdin as input, stdout as output } from "process";
|
|
8
8
|
import { createInterface } from "readline";
|
|
9
9
|
async function confirm(question) {
|
|
10
|
-
return await new Promise((
|
|
10
|
+
return await new Promise((resolve2, reject) => {
|
|
11
11
|
const rl = createInterface({ input, output });
|
|
12
12
|
rl.question(`${question} [y/N] `, (answer) => {
|
|
13
13
|
const normalized = answer.trim().toLowerCase();
|
|
14
14
|
rl.close();
|
|
15
|
-
|
|
15
|
+
resolve2(normalized === "y" || normalized === "yes");
|
|
16
16
|
});
|
|
17
17
|
rl.on("error", (error) => {
|
|
18
18
|
rl.close();
|
|
@@ -3710,13 +3710,13 @@ async function copyRowsToTable(client, tableName, columns, rows) {
|
|
|
3710
3710
|
}
|
|
3711
3711
|
const statement = buildCopyStatement(tableName, columns);
|
|
3712
3712
|
const payload = serializeCopyRows(rows);
|
|
3713
|
-
await new Promise((
|
|
3713
|
+
await new Promise((resolve2, reject) => {
|
|
3714
3714
|
const query = new CopyFromTextQuery(statement, payload, (error) => {
|
|
3715
3715
|
if (error) {
|
|
3716
3716
|
reject(error);
|
|
3717
3717
|
return;
|
|
3718
3718
|
}
|
|
3719
|
-
|
|
3719
|
+
resolve2();
|
|
3720
3720
|
});
|
|
3721
3721
|
client.query(query);
|
|
3722
3722
|
});
|
|
@@ -7824,7 +7824,7 @@ async function sanitizeDatasetFile(plan, onChunk) {
|
|
|
7824
7824
|
} finally {
|
|
7825
7825
|
input2.close();
|
|
7826
7826
|
output2.end();
|
|
7827
|
-
await new Promise((
|
|
7827
|
+
await new Promise((resolve2) => output2.on("finish", () => resolve2()));
|
|
7828
7828
|
}
|
|
7829
7829
|
return {
|
|
7830
7830
|
plan,
|
|
@@ -10270,11 +10270,20 @@ function registerValidateCommands(program) {
|
|
|
10270
10270
|
}
|
|
10271
10271
|
|
|
10272
10272
|
// src/cli/shared/app-config.ts
|
|
10273
|
+
import { readFileSync } from "fs";
|
|
10274
|
+
import { dirname as dirname2, resolve } from "path";
|
|
10275
|
+
import { fileURLToPath } from "url";
|
|
10276
|
+
function getPackageVersion() {
|
|
10277
|
+
const currentDir = dirname2(fileURLToPath(import.meta.url));
|
|
10278
|
+
const packageJsonPath = resolve(currentDir, "../package.json");
|
|
10279
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
10280
|
+
return packageJson.version ?? "0.0.0";
|
|
10281
|
+
}
|
|
10273
10282
|
var APP_CONFIG = {
|
|
10274
10283
|
appName: "cnpj-db-loader",
|
|
10275
|
-
version:
|
|
10284
|
+
version: getPackageVersion(),
|
|
10276
10285
|
environment: process.env.APP_ENV ?? "development",
|
|
10277
|
-
description: "CLI for inspecting, extracting, validating, and
|
|
10286
|
+
description: "CLI for inspecting, extracting, validating, and importing Brazilian Federal Revenue CNPJ datasets."
|
|
10278
10287
|
};
|
|
10279
10288
|
|
|
10280
10289
|
// src/cli/shared/help.ts
|