@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,121 @@
|
|
|
1
|
+
import prompts from "prompts"
|
|
2
|
+
import { writeFileSync, readFileSync, readdirSync, writeFile, unlinkSync, mkdirSync, renameSync, rmSync, copyFileSync } from "fs";
|
|
3
|
+
import Seven from 'node-7z'
|
|
4
|
+
import ora from "ora";
|
|
5
|
+
import { DB } from "../utils/db/DB.js";
|
|
6
|
+
import { exec, execFile, execFileSync, execSync } from "child_process";
|
|
7
|
+
import { Config } from "../utils/config/config.js";
|
|
8
|
+
import chalk from "chalk";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import sevenBin from '7zip-bin'
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export default async function importDB(cli) {
|
|
14
|
+
console.log()
|
|
15
|
+
|
|
16
|
+
const config = await Config.getConfig();
|
|
17
|
+
|
|
18
|
+
const files = readdirSync(process.cwd(), { withFileTypes: true }).filter(dirent => dirent.isFile()).map(dirent => { return { title: dirent.name } })
|
|
19
|
+
|
|
20
|
+
let success = true;
|
|
21
|
+
|
|
22
|
+
const results = await prompts([
|
|
23
|
+
{
|
|
24
|
+
// Ordnerauswahl von vorhandenen Ordner in configIndividual
|
|
25
|
+
type: 'autocomplete',
|
|
26
|
+
name: 'file',
|
|
27
|
+
message: 'Dump-Name?',
|
|
28
|
+
choices: files
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
// Ordnerauswahl von vorhandenen Ordner in configIndividual
|
|
32
|
+
type: 'text',
|
|
33
|
+
name: 'dbName',
|
|
34
|
+
message: 'DB-Name?'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'toggle',
|
|
38
|
+
name: 'dropDB',
|
|
39
|
+
message: 'Delete and Recreate DB before import?',
|
|
40
|
+
initial: true,
|
|
41
|
+
active: 'yes',
|
|
42
|
+
inactive: 'no'
|
|
43
|
+
}
|
|
44
|
+
], {
|
|
45
|
+
onCancel: () => {
|
|
46
|
+
console.log()
|
|
47
|
+
console.log(chalk.red("Cancelled Import!"))
|
|
48
|
+
console.log()
|
|
49
|
+
success = false
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
if (success) {
|
|
54
|
+
console.log()
|
|
55
|
+
rmSync("." + path.sep + "dump", { recursive: true, force: true })
|
|
56
|
+
mkdirSync("." + path.sep + "/dump", { recursive: true })
|
|
57
|
+
|
|
58
|
+
if (await isArchive(results.file)) {
|
|
59
|
+
|
|
60
|
+
const spinnerZIP = ora('Unpacking Archive').start();
|
|
61
|
+
|
|
62
|
+
const unpack = Seven.extract(results.file, "." + path.sep + "dump", {
|
|
63
|
+
$bin: sevenBin.path7za
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
unpack.on('end', async () => {
|
|
67
|
+
const filename = readdirSync("." + path.sep + "dump")[0]
|
|
68
|
+
renameSync("." + path.sep + "dump" + path.sep + "" + filename, "." + path.sep + "dump" + path.sep + "dump.sql")
|
|
69
|
+
spinnerZIP.succeed("Archive unpacked")
|
|
70
|
+
|
|
71
|
+
await importDBActual(config, results)
|
|
72
|
+
})
|
|
73
|
+
}else{
|
|
74
|
+
const spinnerCopy = ora('Copying Dump').start();
|
|
75
|
+
|
|
76
|
+
copyFileSync("."+path.sep+results.file, "." + path.sep + "dump" + path.sep + "dump.sql")
|
|
77
|
+
|
|
78
|
+
spinnerCopy.succeed("Dump copied")
|
|
79
|
+
|
|
80
|
+
await importDBActual(config, results)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function isArchive(file) {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
const test = Seven.list("."+path.sep+file, {
|
|
88
|
+
$bin: sevenBin.path7za
|
|
89
|
+
});
|
|
90
|
+
test.on('end', (stream) => {
|
|
91
|
+
resolve(true)
|
|
92
|
+
})
|
|
93
|
+
test.on('error', (stream) => {
|
|
94
|
+
resolve(false)
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function importDBActual(config, results) {
|
|
100
|
+
const spinnerImport = ora('Importing DB').start();
|
|
101
|
+
|
|
102
|
+
if (results.dropDB) {
|
|
103
|
+
await DB.executeQuery("DROP DATABASE IF EXISTS " + results.dbName);
|
|
104
|
+
await DB.executeQuery("CREATE DATABASE " + results.dbName);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
exec("mysql -u " + config.dbUser + " -p" + config.dbPassword + " " + results.dbName + " < dump" + path.sep + "dump.sql", (error, stdout, stderr) => {
|
|
108
|
+
if (error != null) {
|
|
109
|
+
spinnerImport.fail("Database-Import failed!")
|
|
110
|
+
console.log(error)
|
|
111
|
+
} else {
|
|
112
|
+
spinnerImport.succeed("Database imported")
|
|
113
|
+
|
|
114
|
+
const deleteSpinner = ora("Delete temporary dump").start()
|
|
115
|
+
rmSync("." + path.sep + "dump", { recursive: true, force: true })
|
|
116
|
+
deleteSpinner.succeed("Dump deleted")
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
console.log()
|
|
120
|
+
})
|
|
121
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import prompts from "prompts";
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import { createEditor } from "properties-parser";
|
|
4
|
+
import { writeFileSync, readFileSync, readdirSync } from "fs";
|
|
5
|
+
import YAML from 'yaml'
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import { Config } from "../utils/config/config.js";
|
|
8
|
+
import { DB } from "../utils/db/DB.js";
|
|
9
|
+
import path from "path";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
async function configRewrite(cli) {
|
|
14
|
+
console.log()
|
|
15
|
+
|
|
16
|
+
const homedir = os.homedir();
|
|
17
|
+
|
|
18
|
+
const config = await Config.getConfig();
|
|
19
|
+
|
|
20
|
+
const databaseNames = await DB.getDatabaseNames();
|
|
21
|
+
|
|
22
|
+
const configDirectories = readdirSync(config.configIndividualPath, { withFileTypes: true }).filter(dirent => dirent.isDirectory()).map(dirent => { return { title: dirent.name } })
|
|
23
|
+
|
|
24
|
+
let success = true;
|
|
25
|
+
|
|
26
|
+
const responses = await prompts([{
|
|
27
|
+
// DB-Auswahl von DB
|
|
28
|
+
type: 'autocomplete',
|
|
29
|
+
name: 'dbName',
|
|
30
|
+
message: 'DB-Name?',
|
|
31
|
+
choices: databaseNames.map(name => { return { title: name.name } })
|
|
32
|
+
}, {
|
|
33
|
+
// Ordnerauswahl von vorhandenen Ordner in configIndividual
|
|
34
|
+
type: 'autocomplete',
|
|
35
|
+
name: 'configName',
|
|
36
|
+
message: 'ConfigIndividual-Name?',
|
|
37
|
+
choices: configDirectories
|
|
38
|
+
}, {
|
|
39
|
+
type: 'number',
|
|
40
|
+
name: 'mnr',
|
|
41
|
+
message: 'Mandant?',
|
|
42
|
+
initial: '1'
|
|
43
|
+
}], {
|
|
44
|
+
onCancel: () => {
|
|
45
|
+
console.log()
|
|
46
|
+
console.log(chalk.red("Cancelled Rewrite!"))
|
|
47
|
+
console.log()
|
|
48
|
+
success = false
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (success) {
|
|
53
|
+
// Rewrite jwegas.properties
|
|
54
|
+
const editorJwegasProperties = createEditor(homedir + path.sep+"jwegas.properties")
|
|
55
|
+
editorJwegasProperties.set("user.mandant", responses.mnr.toString());
|
|
56
|
+
editorJwegasProperties.save();
|
|
57
|
+
|
|
58
|
+
// Rewrite wegas.properties
|
|
59
|
+
const editorWegasProperties = createEditor(config.configIndividualPath + path.sep+"wegas.properties")
|
|
60
|
+
editorWegasProperties.set("db.database", responses.dbName);
|
|
61
|
+
editorWegasProperties.save();
|
|
62
|
+
|
|
63
|
+
// Rewrite path.yaml
|
|
64
|
+
const content = readFileSync(config.configIndividualPath +path.sep+"path.yaml", "utf-8");
|
|
65
|
+
|
|
66
|
+
const doc = YAML.parseDocument(content)
|
|
67
|
+
|
|
68
|
+
doc.set("pathIndividual", config.configIndividualPathWrite + "\\\\" + responses.configName + "\\\\")
|
|
69
|
+
|
|
70
|
+
writeFileSync(config.configIndividualPath +path.sep+"path.yaml", doc.toString());
|
|
71
|
+
|
|
72
|
+
console.log()
|
|
73
|
+
console.log(chalk.green("Config-Rewrite successful!"))
|
|
74
|
+
console.log()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default configRewrite;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import prompts from "prompts";
|
|
2
|
+
import { Config } from "../utils/config/config.js";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
|
|
5
|
+
export default async function writeCLIConfig(){
|
|
6
|
+
console.log()
|
|
7
|
+
|
|
8
|
+
let data = await Config.getConfig();
|
|
9
|
+
|
|
10
|
+
let keys = Object.keys(data);
|
|
11
|
+
let success = true;
|
|
12
|
+
|
|
13
|
+
const responses = await prompts(keys.map(key => {
|
|
14
|
+
return {
|
|
15
|
+
// Ordnerauswahl von vorhandenen Ordner in configIndividual
|
|
16
|
+
type: 'text',
|
|
17
|
+
name: key,
|
|
18
|
+
message: key+":",
|
|
19
|
+
initial: data[key]
|
|
20
|
+
}
|
|
21
|
+
}), {
|
|
22
|
+
onCancel: () => {
|
|
23
|
+
console.log()
|
|
24
|
+
console.log(chalk.red("Cancelled Config!"))
|
|
25
|
+
console.log()
|
|
26
|
+
success = false
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
if(success){
|
|
31
|
+
Config.setConfig(responses)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import prompts from "prompts";
|
|
2
|
+
import { mkdirSync, existsSync, readdirSync, rmSync } from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { Config } from "../utils/config/config.js";
|
|
6
|
+
import { FS } from "../utils/fs/FS.js";
|
|
7
|
+
|
|
8
|
+
export default async function syncConfig() {
|
|
9
|
+
console.log()
|
|
10
|
+
|
|
11
|
+
const config = await Config.getConfig();
|
|
12
|
+
|
|
13
|
+
const configDirectoriesEclipse = readdirSync(config.configIndividualPathEclipse, { withFileTypes: true }).filter(dirent => dirent.isDirectory()).map(dirent => { return { title: dirent.name } })
|
|
14
|
+
|
|
15
|
+
const configDirectories = readdirSync(config.configIndividualPath, { withFileTypes: true }).filter(dirent => dirent.isDirectory()).map(dirent => { return { title: dirent.name } })
|
|
16
|
+
|
|
17
|
+
let success = true;
|
|
18
|
+
|
|
19
|
+
const responses = await prompts([
|
|
20
|
+
{
|
|
21
|
+
type: 'select',
|
|
22
|
+
name: 'direction',
|
|
23
|
+
message: 'Select Direction:',
|
|
24
|
+
choices: [
|
|
25
|
+
{ title: 'Import ConfigIndividual (Repository → Work)', value: 'import' },
|
|
26
|
+
{ title: 'Export ConfigIndividual (Work → Repository)', value: 'export' },
|
|
27
|
+
{ title: 'Import Config (Repository → Work)', value: 'import_config' },
|
|
28
|
+
{ title: 'Export Config (Work → Repository)', value: 'export_config' },
|
|
29
|
+
{ title: 'Import Everything (Repository → Work)', value: 'import_all' },
|
|
30
|
+
{ title: 'Export Everything (Work → Repository)', value: 'export_all' },
|
|
31
|
+
{ title: 'Import All ConfigIndividual (Repository → Work)', value: 'import_all_individuals' },
|
|
32
|
+
{ title: 'Export All ConfigIndividual (Work → Repository)', value: 'export_all_individuals' }
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: (prev) => (prev === 'import' || prev === 'export') ? 'autocomplete' : null,
|
|
37
|
+
name: 'configNameSource',
|
|
38
|
+
message: (prev, values) => values.direction === 'import'
|
|
39
|
+
? 'ConfigIndividual from Repository (Origin)?'
|
|
40
|
+
: 'ConfigIndividual from Work (Origin)?',
|
|
41
|
+
choices: (prev, values) => values.direction === 'import'
|
|
42
|
+
? configDirectoriesEclipse
|
|
43
|
+
: configDirectories
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: (prev, values) => (values.direction === 'import' || values.direction === 'export') ? 'autocomplete' : null,
|
|
47
|
+
name: 'configNameTarget',
|
|
48
|
+
message: (prev, values) => values.direction === 'import'
|
|
49
|
+
? 'ConfigIndividual in Work (Destination)?'
|
|
50
|
+
: 'ConfigIndividual in Repository (Destination)?',
|
|
51
|
+
choices: (prev, values) => values.direction === 'import'
|
|
52
|
+
? configDirectories
|
|
53
|
+
: configDirectoriesEclipse,
|
|
54
|
+
suggest: (input, choices) => {
|
|
55
|
+
const filtered = choices.filter(choice =>
|
|
56
|
+
choice.title.toLowerCase().includes(input.toLowerCase())
|
|
57
|
+
);
|
|
58
|
+
if (input && !choices.some(c => c.title === input)) {
|
|
59
|
+
return [...filtered, { title: `Use custom name: "${input}"`, value: input }];
|
|
60
|
+
}
|
|
61
|
+
return filtered;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: 'toggle',
|
|
66
|
+
name: 'dryRun',
|
|
67
|
+
message: 'Dry run? (show what would happen without making changes)',
|
|
68
|
+
initial: false,
|
|
69
|
+
active: 'yes',
|
|
70
|
+
inactive: 'no'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: 'select',
|
|
74
|
+
name: 'type',
|
|
75
|
+
message: 'Sync Type?',
|
|
76
|
+
choices: [
|
|
77
|
+
{ title: 'UPDATE', value: 'UPDATE' },
|
|
78
|
+
{ title: 'OVERWRITE', value: 'OVERWRITE' }
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
], {
|
|
82
|
+
onCancel: () => {
|
|
83
|
+
console.log();
|
|
84
|
+
console.log(chalk.red("Cancelled Operation!"));
|
|
85
|
+
console.log();
|
|
86
|
+
success = false;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
if (success) {
|
|
93
|
+
let sourcePaths, destPaths;
|
|
94
|
+
|
|
95
|
+
switch (responses.direction) {
|
|
96
|
+
case 'import':
|
|
97
|
+
sourcePaths = [path.join(config.configIndividualPathEclipse, responses.configNameSource)];
|
|
98
|
+
destPaths = [path.join(config.configIndividualPath, responses.configNameTarget)];
|
|
99
|
+
break;
|
|
100
|
+
|
|
101
|
+
case 'export':
|
|
102
|
+
sourcePaths = [path.join(config.configIndividualPath, responses.configNameSource)];
|
|
103
|
+
destPaths = [path.join(config.configIndividualPathEclipse, responses.configNameTarget)];
|
|
104
|
+
break;
|
|
105
|
+
|
|
106
|
+
case 'import_all':
|
|
107
|
+
sourcePaths = [path.resolve(config.configIndividualPathEclipse, '..', "config"), config.configIndividualPathEclipse];
|
|
108
|
+
destPaths = [path.resolve(config.configIndividualPath, '..', "config"), config.configIndividualPath];
|
|
109
|
+
break;
|
|
110
|
+
|
|
111
|
+
case 'export_all':
|
|
112
|
+
sourcePaths = [path.resolve(config.configIndividualPath, '..', "config"), config.configIndividualPath];
|
|
113
|
+
destPaths = [path.resolve(config.configIndividualPathEclipse, '..', "config"), config.configIndividualPathEclipse];
|
|
114
|
+
break;
|
|
115
|
+
|
|
116
|
+
case 'import_all_individuals':
|
|
117
|
+
sourcePaths = [path.resolve(config.configIndividualPathEclipse)];
|
|
118
|
+
destPaths = [path.resolve(config.configIndividualPath)];
|
|
119
|
+
break;
|
|
120
|
+
|
|
121
|
+
case 'export_all_individuals':
|
|
122
|
+
destPaths = [path.resolve(config.configIndividualPathEclipse)];
|
|
123
|
+
sourcePaths = [path.resolve(config.configIndividualPath)];
|
|
124
|
+
break;
|
|
125
|
+
|
|
126
|
+
case 'import_config': {
|
|
127
|
+
const sourceParent = path.resolve(config.configIndividualPathEclipse, '..');
|
|
128
|
+
const destParent = path.resolve(config.configIndividualPath, '..');
|
|
129
|
+
|
|
130
|
+
sourcePaths = [findConfigDirNamedConfigIn(sourceParent)];
|
|
131
|
+
destPaths = [findConfigDirNamedConfigIn(destParent)];
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
case 'export_config': {
|
|
136
|
+
const sourceParent = path.resolve(config.configIndividualPath, '..');
|
|
137
|
+
const destParent = path.resolve(config.configIndividualPathEclipse, '..');
|
|
138
|
+
|
|
139
|
+
sourcePaths = [findConfigDirNamedConfigIn(sourceParent)];
|
|
140
|
+
destPaths = [findConfigDirNamedConfigIn(destParent)];
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
processMultiple(responses, responses.dryRun, sourcePaths, destPaths);
|
|
146
|
+
|
|
147
|
+
if (responses.dryRun) {
|
|
148
|
+
console.log()
|
|
149
|
+
const confirmationResults = await prompts([
|
|
150
|
+
{
|
|
151
|
+
type: 'confirm',
|
|
152
|
+
name: 'confirmation',
|
|
153
|
+
message: 'Would you like to execute the dry-run?',
|
|
154
|
+
initial: true
|
|
155
|
+
}
|
|
156
|
+
], {
|
|
157
|
+
onCancel: () => {
|
|
158
|
+
console.log();
|
|
159
|
+
console.log(chalk.red("Cancelled Operation!"));
|
|
160
|
+
console.log();
|
|
161
|
+
success = false;
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
if(confirmationResults.confirmation){
|
|
166
|
+
processMultiple(responses, false, sourcePaths, destPaths);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
console.log();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
function processMultiple(responses, dryRun, sourcePaths, destPaths) {
|
|
175
|
+
console.log();
|
|
176
|
+
let summary = {};
|
|
177
|
+
|
|
178
|
+
switch (responses.type) {
|
|
179
|
+
case 'UPDATE':
|
|
180
|
+
console.log(chalk.yellow(`Updating files from ${sourcePaths.join(', ')} → ${destPaths.join(', ')}`));
|
|
181
|
+
summary = { added: 0, updated: 0 };
|
|
182
|
+
for(let i = 0; i < sourcePaths.length && i < destPaths.length; i++) {
|
|
183
|
+
FS.copyUpdatedFiles(sourcePaths[i], destPaths[i], dryRun, summary, ["wegas.properties", "path.yaml"]);
|
|
184
|
+
}
|
|
185
|
+
console.log();
|
|
186
|
+
console.log(chalk.green(`Summary: ${summary.updated} files added or updated.`));
|
|
187
|
+
break;
|
|
188
|
+
|
|
189
|
+
case 'OVERWRITE':
|
|
190
|
+
console.log(chalk.red(`Overwriting files from ${sourcePaths.join(', ')} → ${destPaths.join(', ')}`));
|
|
191
|
+
|
|
192
|
+
summary = { copied: 0 };
|
|
193
|
+
let deletedCount = 0;
|
|
194
|
+
for(let i = 0; i < sourcePaths.length && i < destPaths.length; i++) {
|
|
195
|
+
if (existsSync(destPaths[i])) {
|
|
196
|
+
deletedCount += countAndDeleteDir(destPaths[i], dryRun);
|
|
197
|
+
if (!dryRun) {
|
|
198
|
+
console.log(chalk.gray(`Deleted existing folder: ${destPaths[i]}`));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (!dryRun) {
|
|
203
|
+
mkdirSync(destPaths[i], { recursive: true });
|
|
204
|
+
} else {
|
|
205
|
+
console.log(chalk.gray(`[DryRun] Would create directory: ${destPaths[i]}`));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
FS.copyAllFiles(sourcePaths[i], destPaths[i], dryRun, summary, ["wegas.properties", "path.yaml"]);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
console.log();
|
|
212
|
+
console.log(chalk.green(`Summary: Deleted ${deletedCount} items, Copied ${summary.copied} files.`));
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
console.log();
|
|
217
|
+
if (dryRun) {
|
|
218
|
+
console.log(chalk.yellow("Dry run complete — no changes were made."));
|
|
219
|
+
} else {
|
|
220
|
+
console.log(chalk.green("Config sync completed successfully."));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function countAndDeleteDir(dirPath, dryRun = false) {
|
|
225
|
+
let deletedCount = 0;
|
|
226
|
+
|
|
227
|
+
if (existsSync(dirPath)) {
|
|
228
|
+
if (dryRun) {
|
|
229
|
+
console.log(chalk.red(`[DryRun] Would delete directory: ${dirPath}`));
|
|
230
|
+
// For dry run, recursively count files/directories without deleting
|
|
231
|
+
const entries = readdirSync(dirPath, { withFileTypes: true });
|
|
232
|
+
for (const entry of entries) {
|
|
233
|
+
const entryPath = path.join(dirPath, entry.name);
|
|
234
|
+
if (entry.isDirectory()) {
|
|
235
|
+
deletedCount += countAndDeleteDir(entryPath, dryRun);
|
|
236
|
+
} else {
|
|
237
|
+
deletedCount++;
|
|
238
|
+
console.log(chalk.red(`[DryRun] Would delete file: ${entryPath}`));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
deletedCount++; // counting the directory itself
|
|
242
|
+
} else {
|
|
243
|
+
rmSync(dirPath, { recursive: true, force: true });
|
|
244
|
+
// Can't count after delete, so you may skip or count before if desired
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return deletedCount;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function findConfigDirNamedConfigIn(parentPath) {
|
|
251
|
+
if (!parentPath || typeof parentPath !== 'string') {
|
|
252
|
+
throw new Error('Invalid or undefined parent path');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const candidate = path.join(parentPath, 'config');
|
|
256
|
+
if (existsSync(candidate)) {
|
|
257
|
+
return candidate;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
throw new Error(`No 'config/' directory found directly in ${parentPath}`);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import prompts from "prompts";
|
|
3
|
+
import { Config } from "../utils/config/config.js";
|
|
4
|
+
import { DB } from "../utils/db/DB.js";
|
|
5
|
+
|
|
6
|
+
export default async function t003Rewrite(cli) {
|
|
7
|
+
console.log()
|
|
8
|
+
|
|
9
|
+
const config = await Config.getConfig();
|
|
10
|
+
|
|
11
|
+
const databaseNames = await DB.getDatabaseNames();
|
|
12
|
+
|
|
13
|
+
let success = true;
|
|
14
|
+
|
|
15
|
+
const responseDB = await prompts([{
|
|
16
|
+
// DB-Auswahl von DB
|
|
17
|
+
type: 'autocomplete',
|
|
18
|
+
name: 'dbName',
|
|
19
|
+
message: 'DB-Name?',
|
|
20
|
+
choices: databaseNames.map(name => { return { title: name.name } })
|
|
21
|
+
}, {
|
|
22
|
+
type: 'number',
|
|
23
|
+
name: 'mnr',
|
|
24
|
+
message: 'Mandant?',
|
|
25
|
+
initial: '1'
|
|
26
|
+
}], {
|
|
27
|
+
onCancel: () => {
|
|
28
|
+
console.log()
|
|
29
|
+
console.log(chalk.red("Cancelled Rewrite!"))
|
|
30
|
+
console.log()
|
|
31
|
+
success = false
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (success) {
|
|
36
|
+
|
|
37
|
+
const users = await DB.executeQueryOnDB("SELECT t003_pw FROM t003 WHERE t003_mnr = " + responseDB.mnr, responseDB.dbName);
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const responses = await prompts([{
|
|
41
|
+
// Ordnerauswahl von vorhandenen Ordner in configIndividual
|
|
42
|
+
type: 'autocomplete',
|
|
43
|
+
name: 'username',
|
|
44
|
+
message: 'Username?',
|
|
45
|
+
choices: users.map(entry => { return ({ title: entry.t003_pw }) })
|
|
46
|
+
}], {
|
|
47
|
+
onCancel: () => {
|
|
48
|
+
console.log()
|
|
49
|
+
console.log(chalk.red("Cancelled Rewrite!"))
|
|
50
|
+
console.log()
|
|
51
|
+
success = false
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
if (success) {
|
|
56
|
+
console.log()
|
|
57
|
+
|
|
58
|
+
await DB.executeQueryOnDB("UPDATE t003 SET t003_pw = '"+config.wegasUsername+"' WHERE t003_mnr = "+responseDB.mnr+" AND t003_pw = '"+responses.username+"'", responseDB.dbName);
|
|
59
|
+
|
|
60
|
+
console.log(chalk.green("T003 rewritten!"))
|
|
61
|
+
console.log()
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dump_db": {
|
|
3
|
+
"desc": "Dumps a DB-Export from local MYSQL-Instance (optionally with table selection or data only)."
|
|
4
|
+
},
|
|
5
|
+
"import_db": {
|
|
6
|
+
"desc": "Imports a DB-Export (in Archive) to the local MYSQL-Instance"
|
|
7
|
+
},
|
|
8
|
+
"config_rewrite": {
|
|
9
|
+
"desc": "Rewrites WEGAS-Config"
|
|
10
|
+
},
|
|
11
|
+
"sync_config": {
|
|
12
|
+
"desc": "Synchronize Config/ConfigIndividual-Folders between Work and Repository (Eclipse-Repo)"
|
|
13
|
+
},
|
|
14
|
+
"t003_rewrite": {
|
|
15
|
+
"desc": "Rewrites t003 in DB"
|
|
16
|
+
},
|
|
17
|
+
"bundle_product":{
|
|
18
|
+
"desc": "Bundles the jWEGAS-Product after an Eclipse-Export"
|
|
19
|
+
},
|
|
20
|
+
"dump_db_mand": {
|
|
21
|
+
"desc": "Export a DB-Dump for a single Mandant"
|
|
22
|
+
},
|
|
23
|
+
"delete_db_mand": {
|
|
24
|
+
"desc": "Delete all Mandant-Data from a db"
|
|
25
|
+
},
|
|
26
|
+
"extd_search": {
|
|
27
|
+
"desc": "Search EXTD/EXTI interactively with full text search"
|
|
28
|
+
},
|
|
29
|
+
"set_cli_config": {
|
|
30
|
+
"desc": "Configure the Inteco CLI"
|
|
31
|
+
},
|
|
32
|
+
"dump_table_to_csv": {
|
|
33
|
+
"desc": "Dumps a specific table from multiple SQL-Exports to a CSV"
|
|
34
|
+
},
|
|
35
|
+
"csv_merge": {
|
|
36
|
+
"desc": "Merge multiple CSV-Files (with same headers) into single file (with optional filter)"
|
|
37
|
+
},
|
|
38
|
+
"adb_bridge": {
|
|
39
|
+
"desc": "Activates an ADB-Bridge-Connection to an Android-Device"
|
|
40
|
+
},
|
|
41
|
+
"adb_intent": {
|
|
42
|
+
"desc": "Sends a configurable Intent to an Android-Device"
|
|
43
|
+
},
|
|
44
|
+
"graphql_schema_export": {
|
|
45
|
+
"desc": "Dump the Graph-QL-Schema from an Endpoint"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import cfg from "application-config"
|
|
2
|
+
import defaultCFG from './default.json' with {type: 'json'};
|
|
3
|
+
|
|
4
|
+
export class Config{
|
|
5
|
+
static config = cfg("inteco_cli");
|
|
6
|
+
static configData;
|
|
7
|
+
|
|
8
|
+
static async initConfig(){
|
|
9
|
+
if(this.configData == null){
|
|
10
|
+
this.configData = await this.config.read();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if(Object.keys(this.configData).length === 0){
|
|
14
|
+
// Default Configuration
|
|
15
|
+
this.configData = defaultCFG
|
|
16
|
+
this.config.write(defaultCFG)
|
|
17
|
+
}else{
|
|
18
|
+
let data = this.configData;
|
|
19
|
+
let hasChange = false;
|
|
20
|
+
Object.keys(defaultCFG).forEach(key => {
|
|
21
|
+
// Write new config-entries if not present
|
|
22
|
+
if(!Object.keys(this.configData).includes(key)){
|
|
23
|
+
data[key] = defaultCFG[key];
|
|
24
|
+
hasChange = true;
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
Object.keys(this.configData).forEach(key => {
|
|
29
|
+
if(!Object.keys(defaultCFG).includes(key)){
|
|
30
|
+
delete data[key]
|
|
31
|
+
hasChange = true;
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
if(hasChange){
|
|
36
|
+
this.configData = data;
|
|
37
|
+
this.config.write(data);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static async getConfig(){
|
|
43
|
+
await this.initConfig()
|
|
44
|
+
|
|
45
|
+
return this.configData
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static async getConfigPath(){
|
|
49
|
+
await this.initConfig();
|
|
50
|
+
return this.config.filePath;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static async setConfigField(field, value){
|
|
54
|
+
await this.initConfig();
|
|
55
|
+
|
|
56
|
+
let data = this.configData;
|
|
57
|
+
|
|
58
|
+
data[field] = value;
|
|
59
|
+
|
|
60
|
+
this.configData = data;
|
|
61
|
+
this.config.write(data);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static async setConfig(data){
|
|
65
|
+
this.configData = data;
|
|
66
|
+
this.config.write(data);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"configIndividualPath": "C:/Daten/eclipse_mars64_1/eclipse/configIndividual",
|
|
3
|
+
"configIndividualPathWrite": "C:\\\\Daten\\\\eclipse_mars64_1\\\\eclipse\\\\configIndividual",
|
|
4
|
+
"configIndividualPathEclipse": "C:/Daten/wegas-ws-mars/ch.inteco.wegas.model/configIndividual",
|
|
5
|
+
"dbURL": "127.0.0.1",
|
|
6
|
+
"dbUser": "",
|
|
7
|
+
"dbPassword": "",
|
|
8
|
+
"wegasUsername": ""
|
|
9
|
+
}
|