@intecoag/inteco-cli 1.11.7 → 1.12.0-beta.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 +12 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +158 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/adbBridge.d.ts +2 -0
- package/dist/modules/adbBridge.d.ts.map +1 -0
- package/dist/modules/adbBridge.js +40 -0
- package/dist/modules/adbBridge.js.map +1 -0
- package/dist/modules/adbIntentSender.d.ts +2 -0
- package/dist/modules/adbIntentSender.d.ts.map +1 -0
- package/dist/modules/adbIntentSender.js +67 -0
- package/dist/modules/adbIntentSender.js.map +1 -0
- package/dist/modules/azureSync.d.ts +4 -0
- package/dist/modules/azureSync.d.ts.map +1 -0
- package/{src → dist}/modules/azureSync.js +50 -131
- package/dist/modules/azureSync.js.map +1 -0
- package/dist/modules/bundleProduct.d.ts +2 -0
- package/dist/modules/bundleProduct.d.ts.map +1 -0
- package/{src → dist}/modules/bundleProduct.js +41 -80
- package/dist/modules/bundleProduct.js.map +1 -0
- package/dist/modules/changelog.d.ts +3 -0
- package/dist/modules/changelog.d.ts.map +1 -0
- package/dist/modules/changelog.js +45 -0
- package/dist/modules/changelog.js.map +1 -0
- package/dist/modules/configMutation.d.ts +2 -0
- package/dist/modules/configMutation.d.ts.map +1 -0
- package/{src → dist}/modules/configMutation.js +54 -101
- package/dist/modules/configMutation.js.map +1 -0
- package/dist/modules/csvMerger.d.ts +2 -0
- package/dist/modules/csvMerger.d.ts.map +1 -0
- package/dist/modules/csvMerger.js +104 -0
- package/dist/modules/csvMerger.js.map +1 -0
- package/dist/modules/deleteDB.d.ts +2 -0
- package/dist/modules/deleteDB.d.ts.map +1 -0
- package/dist/modules/deleteDB.js +75 -0
- package/dist/modules/deleteDB.js.map +1 -0
- package/dist/modules/dumpDB.d.ts +3 -0
- package/dist/modules/dumpDB.d.ts.map +1 -0
- package/{src → dist}/modules/dumpDB.js +64 -89
- package/dist/modules/dumpDB.js.map +1 -0
- package/dist/modules/dumpTableToCSV.d.ts +2 -0
- package/dist/modules/dumpTableToCSV.d.ts.map +1 -0
- package/dist/modules/dumpTableToCSV.js +128 -0
- package/dist/modules/dumpTableToCSV.js.map +1 -0
- package/dist/modules/extdSearch.d.ts +2 -0
- package/dist/modules/extdSearch.d.ts.map +1 -0
- package/{src → dist}/modules/extdSearch.js +60 -60
- package/dist/modules/extdSearch.js.map +1 -0
- package/dist/modules/githubDeploymentKey.d.ts +3 -0
- package/dist/modules/githubDeploymentKey.d.ts.map +1 -0
- package/dist/modules/githubDeploymentKey.js +241 -0
- package/dist/modules/githubDeploymentKey.js.map +1 -0
- package/dist/modules/githubDeploymentKeysList.d.ts +6 -0
- package/dist/modules/githubDeploymentKeysList.d.ts.map +1 -0
- package/dist/modules/githubDeploymentKeysList.js +185 -0
- package/dist/modules/githubDeploymentKeysList.js.map +1 -0
- package/dist/modules/githubSecurityAdvisories.d.ts +3 -0
- package/dist/modules/githubSecurityAdvisories.d.ts.map +1 -0
- package/dist/modules/githubSecurityAdvisories.js +145 -0
- package/dist/modules/githubSecurityAdvisories.js.map +1 -0
- package/dist/modules/graphqlSchemaExport.d.ts +2 -0
- package/dist/modules/graphqlSchemaExport.d.ts.map +1 -0
- package/dist/modules/graphqlSchemaExport.js +59 -0
- package/dist/modules/graphqlSchemaExport.js.map +1 -0
- package/dist/modules/importDB.d.ts +2 -0
- package/dist/modules/importDB.d.ts.map +1 -0
- package/{src → dist}/modules/importDB.js +48 -66
- package/dist/modules/importDB.js.map +1 -0
- package/dist/modules/rewriteConfig.d.ts +3 -0
- package/dist/modules/rewriteConfig.d.ts.map +1 -0
- package/dist/modules/rewriteConfig.js +75 -0
- package/dist/modules/rewriteConfig.js.map +1 -0
- package/dist/modules/setCLIConfig.d.ts +2 -0
- package/dist/modules/setCLIConfig.d.ts.map +1 -0
- package/dist/modules/setCLIConfig.js +29 -0
- package/dist/modules/setCLIConfig.js.map +1 -0
- package/dist/modules/syncConfig.d.ts +2 -0
- package/dist/modules/syncConfig.d.ts.map +1 -0
- package/{src → dist}/modules/syncConfig.js +74 -127
- package/dist/modules/syncConfig.js.map +1 -0
- package/dist/modules/t003Rewrite.d.ts +2 -0
- package/dist/modules/t003Rewrite.d.ts.map +1 -0
- package/dist/modules/t003Rewrite.js +53 -0
- package/dist/modules/t003Rewrite.js.map +1 -0
- package/dist/modules/t009Search.d.ts +2 -0
- package/dist/modules/t009Search.d.ts.map +1 -0
- package/dist/modules/t009Search.js +30 -0
- package/dist/modules/t009Search.js.map +1 -0
- package/{src → dist}/ressources/cmds.json +3 -0
- package/dist/utils/azure/azure.d.ts +24 -0
- package/dist/utils/azure/azure.d.ts.map +1 -0
- package/{src → dist}/utils/azure/azure.js +14 -21
- package/dist/utils/azure/azure.js.map +1 -0
- package/dist/utils/config/config.d.ts +27 -0
- package/dist/utils/config/config.d.ts.map +1 -0
- package/dist/utils/config/config.js +74 -0
- package/dist/utils/config/config.js.map +1 -0
- package/dist/utils/db/DB.d.ts +14 -0
- package/dist/utils/db/DB.d.ts.map +1 -0
- package/dist/utils/db/DB.js +61 -0
- package/dist/utils/db/DB.js.map +1 -0
- package/dist/utils/fs/FS.d.ts +15 -0
- package/dist/utils/fs/FS.d.ts.map +1 -0
- package/{src → dist}/utils/fs/FS.js +31 -45
- package/dist/utils/fs/FS.js.map +1 -0
- package/dist/utils/github/github.d.ts +29 -0
- package/dist/utils/github/github.d.ts.map +1 -0
- package/dist/utils/github/github.js +96 -0
- package/dist/utils/github/github.js.map +1 -0
- package/dist/utils/shell/DatabaseShell.d.ts +77 -0
- package/dist/utils/shell/DatabaseShell.d.ts.map +1 -0
- package/{src → dist}/utils/shell/DatabaseShell.js +73 -87
- package/dist/utils/shell/DatabaseShell.js.map +1 -0
- package/dist/utils/shell/DatabaseShellBuilder.d.ts +67 -0
- package/dist/utils/shell/DatabaseShellBuilder.d.ts.map +1 -0
- package/{src → dist}/utils/shell/DatabaseShellBuilder.js +50 -59
- package/dist/utils/shell/DatabaseShellBuilder.js.map +1 -0
- package/dist/utils/shell/Shell.d.ts +30 -0
- package/dist/utils/shell/Shell.d.ts.map +1 -0
- package/{src → dist}/utils/shell/Shell.js +14 -19
- package/dist/utils/shell/Shell.js.map +1 -0
- package/dist/utils/shell/ShellBuilder.d.ts +60 -0
- package/dist/utils/shell/ShellBuilder.d.ts.map +1 -0
- package/{src → dist}/utils/shell/ShellBuilder.js +23 -44
- package/dist/utils/shell/ShellBuilder.js.map +1 -0
- package/package.json +31 -8
- package/.github/dependabot.yml +0 -28
- package/.github/workflows/publish.yml +0 -31
- package/.husky/commit-msg +0 -1
- package/.vscode/settings.json +0 -6
- package/commitlint.config.mjs +0 -4
- package/src/index.js +0 -130
- package/src/modules/adbBridge.js +0 -52
- package/src/modules/adbIntentSender.js +0 -82
- package/src/modules/changelog.js +0 -60
- package/src/modules/csvMerger.js +0 -118
- package/src/modules/deleteDB.js +0 -84
- package/src/modules/dumpTableToCSV.js +0 -154
- package/src/modules/githubDeploymentKey.js +0 -265
- package/src/modules/githubDeploymentKeysList.js +0 -199
- package/src/modules/githubSecurityAdvisories.js +0 -162
- package/src/modules/graphqlSchemaExport.js +0 -61
- package/src/modules/rewriteConfig.js +0 -93
- package/src/modules/setCLIConfig.js +0 -33
- package/src/modules/t003Rewrite.js +0 -64
- package/src/modules/t009Search.js +0 -34
- package/src/utils/config/config.js +0 -70
- package/src/utils/db/DB.js +0 -54
- package/src/utils/github/github.js +0 -102
- /package/{src → dist}/ressources/wegas_p.ico +0 -0
- /package/{src → dist}/utils/config/default.json +0 -0
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import prompts from 'prompts';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import Table from 'cli-table3';
|
|
4
|
-
import ora from 'ora';
|
|
5
|
-
import { getGithubToken, fetchPaginatedGithubAPI, fetchGithubAPI } from '../utils/github/github.js';
|
|
6
|
-
|
|
7
|
-
async function githubSecurityAdvisories() {
|
|
8
|
-
console.log();
|
|
9
|
-
|
|
10
|
-
// Get GitHub authentication token
|
|
11
|
-
let token;
|
|
12
|
-
let authMethod;
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
({ token, authMethod } = await getGithubToken());
|
|
16
|
-
} catch (error) {
|
|
17
|
-
console.log();
|
|
18
|
-
console.error(chalk.red(`✗ ${error.message}`));
|
|
19
|
-
console.log(chalk.yellow('\nAuthentication setup:'));
|
|
20
|
-
console.log(chalk.gray(' Option 1: Install GitHub CLI and run: gh auth login'));
|
|
21
|
-
console.log(chalk.gray(' Option 2: Set GITHUB_TOKEN environment variable'));
|
|
22
|
-
console.log();
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
console.log(chalk.green(`✓ Authenticated via: ${authMethod}`));
|
|
27
|
-
console.log();
|
|
28
|
-
|
|
29
|
-
const responses = await prompts([
|
|
30
|
-
{
|
|
31
|
-
type: 'text',
|
|
32
|
-
name: 'organization',
|
|
33
|
-
message: 'GitHub Organization Name?',
|
|
34
|
-
initial: 'intecoag',
|
|
35
|
-
validate: (value) => value.length > 0 || 'Organization name is required'
|
|
36
|
-
}
|
|
37
|
-
], {
|
|
38
|
-
onCancel: () => {
|
|
39
|
-
console.log();
|
|
40
|
-
console.log(chalk.red('Cancelled GitHub Security Advisories check!'));
|
|
41
|
-
console.log();
|
|
42
|
-
process.exit(0);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const { organization } = responses;
|
|
47
|
-
|
|
48
|
-
const spinner = ora('Fetching repositories...').start();
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
// Fetch all repositories for the organization
|
|
52
|
-
const baseUrl = `https://api.github.com/orgs/${organization}/repos`;
|
|
53
|
-
const repos = await fetchPaginatedGithubAPI(baseUrl, token);
|
|
54
|
-
|
|
55
|
-
if (repos.length === 0) {
|
|
56
|
-
spinner.warn(`No repositories found in organization "${organization}"`);
|
|
57
|
-
console.log();
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
spinner.text = `Found ${repos.length} repositories. Checking security advisories...`;
|
|
62
|
-
|
|
63
|
-
// Check security advisories for each repo
|
|
64
|
-
const results = [];
|
|
65
|
-
for (let i = 0; i < repos.length; i++) {
|
|
66
|
-
const repo = repos[i];
|
|
67
|
-
spinner.text = `Checking security advisories... [${i + 1}/${repos.length}] ${repo.name}`;
|
|
68
|
-
|
|
69
|
-
const advisories = await fetchSecurityAdvisories(organization, repo.name, token);
|
|
70
|
-
|
|
71
|
-
if (advisories.length > 0) {
|
|
72
|
-
results.push({
|
|
73
|
-
repository: repo.name,
|
|
74
|
-
advisoryCount: advisories.length,
|
|
75
|
-
url: repo.html_url
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
spinner.succeed('Security advisories check completed!');
|
|
81
|
-
console.log();
|
|
82
|
-
|
|
83
|
-
if (results.length === 0) {
|
|
84
|
-
console.log(chalk.green.bold('✓ No security advisories found in any repositories!'));
|
|
85
|
-
console.log();
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Sort by advisory count (descending)
|
|
90
|
-
results.sort((a, b) => b.advisoryCount - a.advisoryCount);
|
|
91
|
-
|
|
92
|
-
// Display results in a table
|
|
93
|
-
const table = new Table({
|
|
94
|
-
head: [
|
|
95
|
-
chalk.bold.cyan('Repository'),
|
|
96
|
-
chalk.bold.cyan('Advisories'),
|
|
97
|
-
chalk.bold.cyan('URL')
|
|
98
|
-
],
|
|
99
|
-
style: {
|
|
100
|
-
head: [],
|
|
101
|
-
border: ['cyan']
|
|
102
|
-
},
|
|
103
|
-
colWidths: [40, 15, 60],
|
|
104
|
-
wordWrap: true
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
for (const result of results) {
|
|
108
|
-
const advisoryColor = chalk.red;
|
|
109
|
-
table.push([
|
|
110
|
-
result.repository,
|
|
111
|
-
advisoryColor.bold(result.advisoryCount.toString()),
|
|
112
|
-
chalk.blue.underline(result.url)
|
|
113
|
-
]);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
console.log(table.toString());
|
|
117
|
-
console.log();
|
|
118
|
-
console.log(chalk.yellow.bold(`Summary: ${results.length} repository/repositories with open security advisories`));
|
|
119
|
-
console.log();
|
|
120
|
-
|
|
121
|
-
} catch (error) {
|
|
122
|
-
console.log();
|
|
123
|
-
spinner.fail('Error checking security advisories');
|
|
124
|
-
|
|
125
|
-
if (error.message.startsWith('401')) {
|
|
126
|
-
console.error(chalk.red(`✗ ${error.message}`));
|
|
127
|
-
console.log(chalk.yellow('\nAuthentication setup:'));
|
|
128
|
-
console.log(chalk.gray(' Option 1: Install GitHub CLI and run: gh auth login'));
|
|
129
|
-
console.log(chalk.gray(' Option 2: Set GITHUB_TOKEN environment variable'));
|
|
130
|
-
} else if (error.message.startsWith('404')) {
|
|
131
|
-
console.error(chalk.red(`✗ ${error.message} - Organization or repository not found`));
|
|
132
|
-
} else {
|
|
133
|
-
console.error(chalk.red(`Error: ${error.message}`));
|
|
134
|
-
}
|
|
135
|
-
console.log();
|
|
136
|
-
process.exit(1);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
async function fetchSecurityAdvisories(organization, repository, token) {
|
|
141
|
-
const url = `https://api.github.com/repos/${organization}/${repository}/dependabot/alerts`;
|
|
142
|
-
|
|
143
|
-
try {
|
|
144
|
-
const res = await fetchGithubAPI(url, token);
|
|
145
|
-
const alerts = await res.json();
|
|
146
|
-
|
|
147
|
-
// Filter for open and unresolved alerts
|
|
148
|
-
const openAlerts = Array.isArray(alerts) ? alerts.filter(alert => alert.state === 'open') : [];
|
|
149
|
-
|
|
150
|
-
return openAlerts;
|
|
151
|
-
} catch (error) {
|
|
152
|
-
// If the endpoint is not available or the repo is not accessible, return empty array
|
|
153
|
-
// 404: Resource not found (Dependabot disabled)
|
|
154
|
-
// 403: Access forbidden (Dependabot disabled or insufficient permissions)
|
|
155
|
-
if (error.message.startsWith('404') || error.message.startsWith('403')) {
|
|
156
|
-
return [];
|
|
157
|
-
}
|
|
158
|
-
throw error;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export default githubSecurityAdvisories;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import prompts from "prompts";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import { buildClientSchema, getIntrospectionQuery, printSchema } from "graphql"
|
|
4
|
-
import { writeFileSync, readFileSync, readdirSync, writeFile, unlinkSync, mkdirSync, renameSync, rmSync } from "fs";
|
|
5
|
-
|
|
6
|
-
export default async function qraphqlSchemaExport(){
|
|
7
|
-
console.log()
|
|
8
|
-
|
|
9
|
-
let success = true;
|
|
10
|
-
|
|
11
|
-
const responses = await prompts([{
|
|
12
|
-
type: 'text',
|
|
13
|
-
name: 'url',
|
|
14
|
-
message: 'URL?',
|
|
15
|
-
initial: "http://localhost:8080/graphql"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
type: 'text',
|
|
19
|
-
name: 'token',
|
|
20
|
-
message: 'AUTH-Token?'
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
type: 'text',
|
|
24
|
-
name: 'file',
|
|
25
|
-
message: 'File-Name?',
|
|
26
|
-
initial: 'schema.graphqls'
|
|
27
|
-
}], {
|
|
28
|
-
onCancel: () => {
|
|
29
|
-
console.log()
|
|
30
|
-
console.log(chalk.red("Cancelled GraphQL-Schema-Export!"))
|
|
31
|
-
console.log()
|
|
32
|
-
success = false
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
if(success){
|
|
37
|
-
console.log()
|
|
38
|
-
|
|
39
|
-
try{
|
|
40
|
-
const {data, errors} = await fetch(responses.url, {
|
|
41
|
-
method: "POST",
|
|
42
|
-
headers: {
|
|
43
|
-
"Content-Type": "application/json",
|
|
44
|
-
"Accept": "application/json",
|
|
45
|
-
"Authorization": "Bearer "+responses.token
|
|
46
|
-
},
|
|
47
|
-
body: JSON.stringify({query: getIntrospectionQuery()})
|
|
48
|
-
}).then(res => res.json())
|
|
49
|
-
|
|
50
|
-
const schema = buildClientSchema(data)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
writeFileSync(responses.file, printSchema(schema))
|
|
54
|
-
console.log(chalk.green("Schema loaded: "+responses.file))
|
|
55
|
-
console.log();
|
|
56
|
-
}catch(e){
|
|
57
|
-
console.log(chalk.red("Error loading schema: "+e))
|
|
58
|
-
console.log();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
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
|
-
type: 'autocomplete',
|
|
45
|
-
name: 'language',
|
|
46
|
-
message: 'Sprache?',
|
|
47
|
-
choices: [
|
|
48
|
-
{ title: '<Nicht Verändern>', value: '?' },
|
|
49
|
-
{ title: 'Deutsch', value: 'd' },
|
|
50
|
-
{ title: 'Französisch', value: 'f' },
|
|
51
|
-
{ title: 'Italienisch', value: 'i' }
|
|
52
|
-
]
|
|
53
|
-
}], {
|
|
54
|
-
onCancel: () => {
|
|
55
|
-
console.log()
|
|
56
|
-
console.log(chalk.red("Cancelled Rewrite!"))
|
|
57
|
-
console.log()
|
|
58
|
-
success = false
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
if (success) {
|
|
63
|
-
// Rewrite jwegas.properties
|
|
64
|
-
const editorJwegasProperties = createEditor(homedir + path.sep+"jwegas.properties")
|
|
65
|
-
editorJwegasProperties.set("user.mandant", responses.mnr.toString());
|
|
66
|
-
editorJwegasProperties.save();
|
|
67
|
-
|
|
68
|
-
// Rewrite wegas.properties
|
|
69
|
-
const editorWegasProperties = createEditor(config.configIndividualPath + path.sep+"wegas.properties")
|
|
70
|
-
editorWegasProperties.set("db.database", responses.dbName);
|
|
71
|
-
|
|
72
|
-
if(responses.language != '?') {
|
|
73
|
-
editorWegasProperties.set("language", responses.language)
|
|
74
|
-
}
|
|
75
|
-
editorWegasProperties.save();
|
|
76
|
-
|
|
77
|
-
// Rewrite path.yaml
|
|
78
|
-
const content = readFileSync(config.configIndividualPath +path.sep+"path.yaml", "utf-8");
|
|
79
|
-
|
|
80
|
-
const doc = YAML.parseDocument(content)
|
|
81
|
-
|
|
82
|
-
doc.set("pathIndividual", config.configIndividualPathWrite + "\\\\" + responses.configName + "\\\\")
|
|
83
|
-
|
|
84
|
-
writeFileSync(config.configIndividualPath +path.sep+"path.yaml", doc.toString());
|
|
85
|
-
|
|
86
|
-
console.log()
|
|
87
|
-
console.log(chalk.green("Config-Rewrite successful!"))
|
|
88
|
-
console.log()
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export default configRewrite;
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { DatabaseShellBuilder, TableConfig } from "../utils/shell/DatabaseShellBuilder.js";
|
|
2
|
-
|
|
3
|
-
export default async function t009Search() {
|
|
4
|
-
|
|
5
|
-
const overviewConfig = new TableConfig()
|
|
6
|
-
.withName("Overview")
|
|
7
|
-
.withShortcut(":ow")
|
|
8
|
-
.withSearchKeys(["mnr", "grp_pw", "lnr", "pgm", "flag", "bez", "bez_f", "bez_i"])
|
|
9
|
-
.withThreshold(0.7)
|
|
10
|
-
.withHeader(["MNR", "Mitarbeitergruppe", "Zeilennummer", "Programm-Name", "Typ (P=Programm, S=Shell)", "Bezeichnung", "Bezeichnung franz.", "Bezeichnung ital."])
|
|
11
|
-
.withFormatter(p => [p.mnr, p.grp_pw, p.lnr, p.pgm, p.flag, p.bez, p.bez_f, p.bez_i]);
|
|
12
|
-
|
|
13
|
-
const builder = new DatabaseShellBuilder();
|
|
14
|
-
builder
|
|
15
|
-
.withEditTools(
|
|
16
|
-
[
|
|
17
|
-
{ title: 'MNR', column: 'mnr', default: '1' },
|
|
18
|
-
{ title: 'Mitarbeitergruppe', column: 'grp_pw', default: '' },
|
|
19
|
-
{ title: 'Zeilennummer', column: 'lnr', default: null },
|
|
20
|
-
{ title: 'Programm-Name', column: 'pgm', default: null },
|
|
21
|
-
{ title: 'Typ', column: 'flag', default: 'P' },
|
|
22
|
-
{ title: 'Bezeichnung', column: 'bez', default: null },
|
|
23
|
-
{ title: 'Bezeichnung franz.', column: 'bez_f', default: null },
|
|
24
|
-
{ title: 'Bezeichnung ital.', column: 'bez_i', default: null },
|
|
25
|
-
],
|
|
26
|
-
["mnr", "pgm"],
|
|
27
|
-
["mnr", "lnr", "pgm", "bez"],
|
|
28
|
-
["grp_pw", "flag", "bez_f", "bez_i"])
|
|
29
|
-
.withConfig(overviewConfig)
|
|
30
|
-
.withTables("T009", ["t009"]);
|
|
31
|
-
|
|
32
|
-
const shell = builder.build();
|
|
33
|
-
await shell.run();
|
|
34
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
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
|
-
}
|
package/src/utils/db/DB.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { execSync } from 'child_process';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Get GitHub authentication token from environment or GitHub CLI
|
|
6
|
-
* @returns {Promise<{token: string, authMethod: string}>} Token and authentication method
|
|
7
|
-
* @throws {Error} If no authentication method is available
|
|
8
|
-
*/
|
|
9
|
-
export async function getGithubToken() {
|
|
10
|
-
let token = null;
|
|
11
|
-
let authMethod = null;
|
|
12
|
-
|
|
13
|
-
// 1. Try GITHUB_TOKEN environment variable
|
|
14
|
-
if (process.env.GITHUB_TOKEN) {
|
|
15
|
-
token = process.env.GITHUB_TOKEN;
|
|
16
|
-
authMethod = 'GITHUB_TOKEN (environment variable)';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// 2. Try GitHub CLI authentication if available
|
|
20
|
-
if (!token) {
|
|
21
|
-
try {
|
|
22
|
-
token = execSync('gh auth token', { encoding: 'utf-8' }).trim();
|
|
23
|
-
authMethod = 'GitHub CLI';
|
|
24
|
-
} catch (error) {
|
|
25
|
-
// GitHub CLI not available or not authenticated
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// 3. If no token found, prompt user to authenticate
|
|
30
|
-
if (!token) {
|
|
31
|
-
console.log(chalk.yellow('No GitHub authentication found. Please authenticate with GitHub CLI:'));
|
|
32
|
-
console.log(chalk.gray(' Run: gh auth login'));
|
|
33
|
-
console.log();
|
|
34
|
-
throw new Error('GitHub authentication required. Please run "gh auth login" or set GITHUB_TOKEN environment variable.');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return { token, authMethod };
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Make a GitHub API fetch request with proper headers and error handling
|
|
42
|
-
* @param {string} url - GitHub API endpoint URL
|
|
43
|
-
* @param {string} token - GitHub authentication token
|
|
44
|
-
* @returns {Promise<Response>} Fetch response
|
|
45
|
-
* @throws {Error} If fetch fails or returns error status
|
|
46
|
-
*/
|
|
47
|
-
export async function fetchGithubAPI(url, token) {
|
|
48
|
-
const res = await fetch(url, {
|
|
49
|
-
headers: {
|
|
50
|
-
'Authorization': `Bearer ${token}`,
|
|
51
|
-
'Accept': 'application/vnd.github+json',
|
|
52
|
-
'X-GitHub-Api-Version': '2022-11-28',
|
|
53
|
-
'User-Agent': 'inteco-cli'
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (!res.ok) {
|
|
58
|
-
if (res.status === 404) {
|
|
59
|
-
throw new Error(`404: Resource not found`);
|
|
60
|
-
}
|
|
61
|
-
if (res.status === 401) {
|
|
62
|
-
throw new Error('401: GitHub authentication failed');
|
|
63
|
-
}
|
|
64
|
-
if (res.status === 403) {
|
|
65
|
-
throw new Error('403: Access forbidden (Dependabot alerts may not be enabled)');
|
|
66
|
-
}
|
|
67
|
-
throw new Error(`${res.status}: GitHub API request failed: ${res.statusText}`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return res;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Fetch all items from a paginated GitHub API endpoint
|
|
75
|
-
* @param {string} baseUrl - Base GitHub API endpoint URL (without pagination params)
|
|
76
|
-
* @param {string} token - GitHub authentication token
|
|
77
|
-
* @param {number} page - Current page (default: 1)
|
|
78
|
-
* @param {Array} allItems - Accumulated items (default: [])
|
|
79
|
-
* @returns {Promise<Array>} All items from all pages
|
|
80
|
-
*/
|
|
81
|
-
export async function fetchPaginatedGithubAPI(baseUrl, token, page = 1, allItems = []) {
|
|
82
|
-
const url = `${baseUrl}${baseUrl.includes('?') ? '&' : '?'}page=${page}&per_page=100`;
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
const res = await fetchGithubAPI(url, token);
|
|
86
|
-
const items = await res.json();
|
|
87
|
-
|
|
88
|
-
if (items.length === 0) {
|
|
89
|
-
return allItems;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Recursively fetch all pages
|
|
93
|
-
return fetchPaginatedGithubAPI(baseUrl, token, page + 1, [...allItems, ...items]);
|
|
94
|
-
} catch (error) {
|
|
95
|
-
if (page === 1) {
|
|
96
|
-
// Only throw on first page - error getting initial data
|
|
97
|
-
throw error;
|
|
98
|
-
}
|
|
99
|
-
// On subsequent pages, return what we have so far
|
|
100
|
-
return allItems;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
File without changes
|
|
File without changes
|