@intecoag/inteco-cli 0.5.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/README.md +3 -0
- package/package.json +35 -0
- package/src/index.js +85 -0
- package/src/modules/adbBridge.js +52 -0
- package/src/modules/adbIntentSender.js +82 -0
- package/src/modules/bundleProduct.js +161 -0
- package/src/modules/csvMerger.js +118 -0
- package/src/modules/deleteDB.js +84 -0
- package/src/modules/dumpDB.js +216 -0
- package/src/modules/dumpTableToCSV.js +154 -0
- package/src/modules/extdSearch.js +226 -0
- package/src/modules/graphqlSchemaExport.js +61 -0
- package/src/modules/importDB.js +121 -0
- package/src/modules/rewriteConfig.js +79 -0
- package/src/modules/setCLIConfig.js +33 -0
- package/src/modules/syncConfig.js +264 -0
- package/src/modules/t003Rewrite.js +64 -0
- package/src/ressources/cmds.json +47 -0
- package/src/ressources/wegas_p.ico +0 -0
- package/src/utils/config/config.js +70 -0
- package/src/utils/config/default.json +9 -0
- package/src/utils/db/DB.js +54 -0
- package/src/utils/fs/FS.js +88 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import mysql from "mysql-await"
|
|
2
|
+
import { Config } from "../config/config.js";
|
|
3
|
+
|
|
4
|
+
export class DB{
|
|
5
|
+
static connection;
|
|
6
|
+
|
|
7
|
+
static async connect(db){
|
|
8
|
+
const config = await Config.getConfig();
|
|
9
|
+
|
|
10
|
+
this.connection = mysql.createConnection({
|
|
11
|
+
host:config.dbURL,
|
|
12
|
+
user:config.dbUser,
|
|
13
|
+
password:config.dbPassword,
|
|
14
|
+
database: db!=null?db:""
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static async executeQuery(query){
|
|
19
|
+
await this.connect(null)
|
|
20
|
+
|
|
21
|
+
let results = await this.connection.awaitQuery(query)
|
|
22
|
+
|
|
23
|
+
this.connection.end();
|
|
24
|
+
|
|
25
|
+
return results
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static async executeQueryOnDB(query, db){
|
|
29
|
+
await this.connect(db)
|
|
30
|
+
|
|
31
|
+
let results = await this.connection.awaitQuery(query)
|
|
32
|
+
|
|
33
|
+
this.connection.end();
|
|
34
|
+
|
|
35
|
+
return results
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static async getDatabaseNames(){
|
|
39
|
+
await this.connect(null)
|
|
40
|
+
|
|
41
|
+
let results = await this.connection.awaitQuery("SHOW DATABASES")
|
|
42
|
+
|
|
43
|
+
this.connection.end();
|
|
44
|
+
|
|
45
|
+
results = results.filter((val) => {
|
|
46
|
+
if(val.Database == "sys" || val.Database == "information_schema" || val.Database == "mysql" || val.Database == "performance_schema"){
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return true
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
return results.map(result => {return {"name":result.Database}})
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { statSync, mkdirSync, existsSync, copyFileSync, readdirSync } from "fs";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class FS {
|
|
7
|
+
static copyUpdatedFiles(sourceDir, destDir, dryRun = false, stats = { added: 0, updated: 0 }, filenameBlacklist = []) {
|
|
8
|
+
if (!existsSync(destDir)) {
|
|
9
|
+
if (dryRun) {
|
|
10
|
+
console.log(chalk.gray(`[DryRun] Would create directory: ${destDir}`));
|
|
11
|
+
} else {
|
|
12
|
+
mkdirSync(destDir, { recursive: true });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const entries = readdirSync(sourceDir, { withFileTypes: true });
|
|
17
|
+
|
|
18
|
+
for (const entry of entries) {
|
|
19
|
+
if(filenameBlacklist.includes(entry.name)) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const sourcePath = path.join(sourceDir, entry.name);
|
|
24
|
+
const destPath = path.join(destDir, entry.name);
|
|
25
|
+
|
|
26
|
+
if (entry.isDirectory()) {
|
|
27
|
+
FS.copyUpdatedFiles(sourcePath, destPath, dryRun, stats, filenameBlacklist);
|
|
28
|
+
} else {
|
|
29
|
+
let shouldCopy = false;
|
|
30
|
+
|
|
31
|
+
if (!existsSync(destPath)) {
|
|
32
|
+
shouldCopy = true;
|
|
33
|
+
} else {
|
|
34
|
+
const sourceStat = statSync(sourcePath);
|
|
35
|
+
const destStat = statSync(destPath);
|
|
36
|
+
|
|
37
|
+
if (sourceStat.mtime > destStat.mtime) {
|
|
38
|
+
shouldCopy = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (shouldCopy) {
|
|
43
|
+
if (dryRun) {
|
|
44
|
+
console.log(chalk.blue(`[DryRun] Would update file: ${destPath}`));
|
|
45
|
+
} else {
|
|
46
|
+
copyFileSync(sourcePath, destPath);
|
|
47
|
+
}
|
|
48
|
+
stats.updated++;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
static copyAllFiles(sourceDir, destDir, dryRun = false, stats = { copied: 0 }, filenameBlacklist = []) {
|
|
56
|
+
if (!existsSync(destDir)) {
|
|
57
|
+
if (dryRun) {
|
|
58
|
+
console.log(chalk.gray(`[DryRun] Would create directory: ${destDir}`));
|
|
59
|
+
} else {
|
|
60
|
+
mkdirSync(destDir, { recursive: true });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const entries = readdirSync(sourceDir, { withFileTypes: true });
|
|
65
|
+
|
|
66
|
+
for (const entry of entries) {
|
|
67
|
+
if(filenameBlacklist.includes(entry.name)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const sourcePath = path.join(sourceDir, entry.name);
|
|
72
|
+
const destPath = path.join(destDir, entry.name);
|
|
73
|
+
|
|
74
|
+
if (entry.isDirectory()) {
|
|
75
|
+
FS.copyAllFiles(sourcePath, destPath, dryRun, stats, filenameBlacklist);
|
|
76
|
+
} else {
|
|
77
|
+
if (dryRun) {
|
|
78
|
+
console.log(chalk.magenta(`[DryRun] Would copy file: ${destPath}`));
|
|
79
|
+
} else {
|
|
80
|
+
copyFileSync(sourcePath, destPath);
|
|
81
|
+
}
|
|
82
|
+
stats.copied++;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
}
|