@intecoag/inteco-cli 1.11.8 → 1.12.0-beta.2
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 +13 -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/adbBridge.test.d.ts +2 -0
- package/dist/modules/adbBridge.test.d.ts.map +1 -0
- package/dist/modules/adbBridge.test.js +39 -0
- package/dist/modules/adbBridge.test.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/adbIntentSender.test.d.ts +2 -0
- package/dist/modules/adbIntentSender.test.d.ts.map +1 -0
- package/dist/modules/adbIntentSender.test.js +48 -0
- package/dist/modules/adbIntentSender.test.js.map +1 -0
- package/dist/modules/azureSync.d.ts +16 -0
- package/dist/modules/azureSync.d.ts.map +1 -0
- package/{src → dist}/modules/azureSync.js +55 -136
- package/dist/modules/azureSync.js.map +1 -0
- package/dist/modules/azureSync.test.d.ts +2 -0
- package/dist/modules/azureSync.test.d.ts.map +1 -0
- package/dist/modules/azureSync.test.js +69 -0
- package/dist/modules/azureSync.test.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/bundleProduct.test.d.ts +2 -0
- package/dist/modules/bundleProduct.test.d.ts.map +1 -0
- package/dist/modules/bundleProduct.test.js +75 -0
- package/dist/modules/bundleProduct.test.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/changelog.test.d.ts +2 -0
- package/dist/modules/changelog.test.d.ts.map +1 -0
- package/dist/modules/changelog.test.js +33 -0
- package/dist/modules/changelog.test.js.map +1 -0
- package/dist/modules/configMutation.d.ts +5 -0
- package/dist/modules/configMutation.d.ts.map +1 -0
- package/{src → dist}/modules/configMutation.js +57 -104
- package/dist/modules/configMutation.js.map +1 -0
- package/dist/modules/configMutation.test.d.ts +2 -0
- package/dist/modules/configMutation.test.d.ts.map +1 -0
- package/dist/modules/configMutation.test.js +28 -0
- package/dist/modules/configMutation.test.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/csvMerger.test.d.ts +2 -0
- package/dist/modules/csvMerger.test.d.ts.map +1 -0
- package/dist/modules/csvMerger.test.js +76 -0
- package/dist/modules/csvMerger.test.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/deleteDB.test.d.ts +2 -0
- package/dist/modules/deleteDB.test.d.ts.map +1 -0
- package/dist/modules/deleteDB.test.js +78 -0
- package/dist/modules/deleteDB.test.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/dumpDB.test.d.ts +2 -0
- package/dist/modules/dumpDB.test.d.ts.map +1 -0
- package/dist/modules/dumpDB.test.js +104 -0
- package/dist/modules/dumpDB.test.js.map +1 -0
- package/dist/modules/dumpTableToCSV.d.ts +4 -0
- package/dist/modules/dumpTableToCSV.d.ts.map +1 -0
- package/dist/modules/dumpTableToCSV.js +135 -0
- package/dist/modules/dumpTableToCSV.js.map +1 -0
- package/dist/modules/dumpTableToCSV.test.d.ts +2 -0
- package/dist/modules/dumpTableToCSV.test.d.ts.map +1 -0
- package/dist/modules/dumpTableToCSV.test.js +15 -0
- package/dist/modules/dumpTableToCSV.test.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/extdSearch.test.d.ts +2 -0
- package/dist/modules/extdSearch.test.d.ts.map +1 -0
- package/dist/modules/extdSearch.test.js +114 -0
- package/dist/modules/extdSearch.test.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/githubDeploymentKey.test.d.ts +2 -0
- package/dist/modules/githubDeploymentKey.test.d.ts.map +1 -0
- package/dist/modules/githubDeploymentKey.test.js +50 -0
- package/dist/modules/githubDeploymentKey.test.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/githubDeploymentKeysList.test.d.ts +2 -0
- package/dist/modules/githubDeploymentKeysList.test.d.ts.map +1 -0
- package/dist/modules/githubDeploymentKeysList.test.js +70 -0
- package/dist/modules/githubDeploymentKeysList.test.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/githubSecurityAdvisories.test.d.ts +2 -0
- package/dist/modules/githubSecurityAdvisories.test.d.ts.map +1 -0
- package/dist/modules/githubSecurityAdvisories.test.js +67 -0
- package/dist/modules/githubSecurityAdvisories.test.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/graphqlSchemaExport.test.d.ts +2 -0
- package/dist/modules/graphqlSchemaExport.test.d.ts.map +1 -0
- package/dist/modules/graphqlSchemaExport.test.js +61 -0
- package/dist/modules/graphqlSchemaExport.test.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/importDB.test.d.ts +2 -0
- package/dist/modules/importDB.test.d.ts.map +1 -0
- package/dist/modules/importDB.test.js +65 -0
- package/dist/modules/importDB.test.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/rewriteConfig.test.d.ts +2 -0
- package/dist/modules/rewriteConfig.test.d.ts.map +1 -0
- package/dist/modules/rewriteConfig.test.js +62 -0
- package/dist/modules/rewriteConfig.test.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/setCLIConfig.test.d.ts +2 -0
- package/dist/modules/setCLIConfig.test.d.ts.map +1 -0
- package/dist/modules/setCLIConfig.test.js +40 -0
- package/dist/modules/setCLIConfig.test.js.map +1 -0
- package/dist/modules/syncConfig.d.ts +4 -0
- package/dist/modules/syncConfig.d.ts.map +1 -0
- package/{src → dist}/modules/syncConfig.js +76 -129
- package/dist/modules/syncConfig.js.map +1 -0
- package/dist/modules/syncConfig.test.d.ts +2 -0
- package/dist/modules/syncConfig.test.d.ts.map +1 -0
- package/dist/modules/syncConfig.test.js +71 -0
- package/dist/modules/syncConfig.test.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/t003Rewrite.test.d.ts +2 -0
- package/dist/modules/t003Rewrite.test.d.ts.map +1 -0
- package/dist/modules/t003Rewrite.test.js +43 -0
- package/dist/modules/t003Rewrite.test.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/dist/modules/t009Search.test.d.ts +2 -0
- package/dist/modules/t009Search.test.d.ts.map +1 -0
- package/dist/modules/t009Search.test.js +83 -0
- package/dist/modules/t009Search.test.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/azure/azure.test.d.ts +2 -0
- package/dist/utils/azure/azure.test.d.ts.map +1 -0
- package/dist/utils/azure/azure.test.js +98 -0
- package/dist/utils/azure/azure.test.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/config/config.test.d.ts +2 -0
- package/dist/utils/config/config.test.d.ts.map +1 -0
- package/dist/utils/config/config.test.js +64 -0
- package/dist/utils/config/config.test.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/db/DB.test.d.ts +2 -0
- package/dist/utils/db/DB.test.d.ts.map +1 -0
- package/dist/utils/db/DB.test.js +73 -0
- package/dist/utils/db/DB.test.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/fs/FS.test.d.ts +2 -0
- package/dist/utils/fs/FS.test.d.ts.map +1 -0
- package/dist/utils/fs/FS.test.js +124 -0
- package/dist/utils/fs/FS.test.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/github/github.test.d.ts +2 -0
- package/dist/utils/github/github.test.d.ts.map +1 -0
- package/dist/utils/github/github.test.js +83 -0
- package/dist/utils/github/github.test.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/DatabaseShell.test.d.ts +2 -0
- package/dist/utils/shell/DatabaseShell.test.d.ts.map +1 -0
- package/dist/utils/shell/DatabaseShell.test.js +78 -0
- package/dist/utils/shell/DatabaseShell.test.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/DatabaseShellBuilder.test.d.ts +2 -0
- package/dist/utils/shell/DatabaseShellBuilder.test.d.ts.map +1 -0
- package/dist/utils/shell/DatabaseShellBuilder.test.js +55 -0
- package/dist/utils/shell/DatabaseShellBuilder.test.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/Shell.test.d.ts +2 -0
- package/dist/utils/shell/Shell.test.d.ts.map +1 -0
- package/dist/utils/shell/Shell.test.js +65 -0
- package/dist/utils/shell/Shell.test.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/dist/utils/shell/ShellBuilder.test.d.ts +2 -0
- package/dist/utils/shell/ShellBuilder.test.d.ts.map +1 -0
- package/dist/utils/shell/ShellBuilder.test.js +39 -0
- package/dist/utils/shell/ShellBuilder.test.js.map +1 -0
- package/package.json +39 -11
- 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,265 +0,0 @@
|
|
|
1
|
-
import prompts from 'prompts';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import ora from 'ora';
|
|
4
|
-
import { execSync } from 'child_process';
|
|
5
|
-
import { getGithubToken, fetchPaginatedGithubAPI, fetchGithubAPI } from '../utils/github/github.js';
|
|
6
|
-
|
|
7
|
-
export async function addGithubDeploymentKey() {
|
|
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
|
-
// Step 1: Select Organization
|
|
30
|
-
const orgResponse = await prompts([
|
|
31
|
-
{
|
|
32
|
-
type: 'text',
|
|
33
|
-
name: 'organization',
|
|
34
|
-
message: 'GitHub Organization Name?',
|
|
35
|
-
initial: 'intecoag',
|
|
36
|
-
validate: (value) => value.length > 0 || 'Organization name is required'
|
|
37
|
-
}
|
|
38
|
-
], {
|
|
39
|
-
onCancel: () => {
|
|
40
|
-
console.log();
|
|
41
|
-
console.log(chalk.red('Cancelled GitHub Deployment Key setup!'));
|
|
42
|
-
console.log();
|
|
43
|
-
process.exit(0);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const { organization } = orgResponse;
|
|
48
|
-
|
|
49
|
-
const spinner = ora('Fetching repositories...').start();
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
// Fetch all repositories for the organization
|
|
53
|
-
const baseUrl = `https://api.github.com/orgs/${organization}/repos`;
|
|
54
|
-
const repos = await fetchPaginatedGithubAPI(baseUrl, token);
|
|
55
|
-
|
|
56
|
-
if (repos.length === 0) {
|
|
57
|
-
spinner.warn(`No repositories found in organization "${organization}"`);
|
|
58
|
-
console.log();
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
spinner.succeed(`Found ${repos.length} repositories`);
|
|
63
|
-
console.log();
|
|
64
|
-
|
|
65
|
-
// Step 2: Select Repository
|
|
66
|
-
const repoResponse = await prompts([
|
|
67
|
-
{
|
|
68
|
-
type: 'autocomplete',
|
|
69
|
-
name: 'repository',
|
|
70
|
-
message: 'Select repository:',
|
|
71
|
-
choices: repos.map(repo => ({
|
|
72
|
-
title: repo.name,
|
|
73
|
-
value: repo.name,
|
|
74
|
-
description: repo.description || 'No description'
|
|
75
|
-
})),
|
|
76
|
-
hint: 'Start typing to filter',
|
|
77
|
-
validate: (value) => {
|
|
78
|
-
const exists = repos.some(repo => repo.name === value);
|
|
79
|
-
return exists || 'Repository does not exist in this organization';
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
], {
|
|
83
|
-
onCancel: () => {
|
|
84
|
-
console.log();
|
|
85
|
-
console.log(chalk.red('Cancelled GitHub Deployment Key setup!'));
|
|
86
|
-
console.log();
|
|
87
|
-
process.exit(0);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
const { repository } = repoResponse;
|
|
92
|
-
|
|
93
|
-
// Step 3: Generate and display setup script
|
|
94
|
-
displayDeploymentKeyScript(organization, repository);
|
|
95
|
-
|
|
96
|
-
// Step 4: Prompt for public key and create deployment key
|
|
97
|
-
const publicKeyResponse = await prompts([
|
|
98
|
-
{
|
|
99
|
-
type: 'text',
|
|
100
|
-
name: 'publicKey',
|
|
101
|
-
message: 'Paste the public key content here:',
|
|
102
|
-
validate: (value) => {
|
|
103
|
-
if (!value.trim().length) return 'Public key is required';
|
|
104
|
-
if (!value.includes('ssh-ed25519') && !value.includes('ssh-rsa') && !value.includes('ecdsa-sha2')) {
|
|
105
|
-
return 'Invalid SSH public key format';
|
|
106
|
-
}
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
type: 'text',
|
|
112
|
-
name: 'keyName',
|
|
113
|
-
message: 'Deployment key name:',
|
|
114
|
-
validate: (value) => value.length > 0 || 'Key name is required'
|
|
115
|
-
}
|
|
116
|
-
], {
|
|
117
|
-
onCancel: () => {
|
|
118
|
-
console.log();
|
|
119
|
-
console.log(chalk.yellow('Skipped creating deployment key on GitHub. You can add it manually later.'));
|
|
120
|
-
console.log();
|
|
121
|
-
process.exit(0);
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const { publicKey, keyName } = publicKeyResponse;
|
|
126
|
-
|
|
127
|
-
// Create deployment key on GitHub
|
|
128
|
-
await createDeploymentKey(organization, repository, publicKey, keyName);
|
|
129
|
-
|
|
130
|
-
// Step 5: Show clone command
|
|
131
|
-
displayCloneCommand(organization, repository);
|
|
132
|
-
|
|
133
|
-
} catch (error) {
|
|
134
|
-
console.log();
|
|
135
|
-
spinner.fail('Error fetching repositories');
|
|
136
|
-
|
|
137
|
-
if (error.message.startsWith('401')) {
|
|
138
|
-
console.error(chalk.red(`✗ ${error.message}`));
|
|
139
|
-
console.log(chalk.yellow('\nAuthentication setup:'));
|
|
140
|
-
console.log(chalk.gray(' Option 1: Install GitHub CLI and run: gh auth login'));
|
|
141
|
-
console.log(chalk.gray(' Option 2: Set GITHUB_TOKEN environment variable'));
|
|
142
|
-
} else if (error.message.startsWith('404')) {
|
|
143
|
-
console.error(chalk.red(`✗ ${error.message} - Organization not found`));
|
|
144
|
-
} else {
|
|
145
|
-
console.error(chalk.red(`Error: ${error.message}`));
|
|
146
|
-
}
|
|
147
|
-
console.log();
|
|
148
|
-
process.exit(1);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function displayDeploymentKeyScript(organization, repository) {
|
|
153
|
-
// Use organization and repository in the key name to avoid collisions
|
|
154
|
-
const keyPath = `~/.ssh/id_ed25519_github_${organization}_${repository}`;
|
|
155
|
-
const deploymentKeyName = `${repository}-deployment-key`;
|
|
156
|
-
|
|
157
|
-
console.log();
|
|
158
|
-
console.log(chalk.bold.cyan('═══════════════════════════════════════════════════════════'));
|
|
159
|
-
console.log(chalk.bold.cyan(`Deployment Key Setup for: ${organization}/${repository}`));
|
|
160
|
-
console.log(chalk.bold.cyan('═══════════════════════════════════════════════════════════'));
|
|
161
|
-
console.log();
|
|
162
|
-
|
|
163
|
-
console.log(chalk.bold.yellow('STEP 1: Copy and paste the script below on your server'));
|
|
164
|
-
console.log(chalk.gray('─────────────────────────────────────────────────────────────'));
|
|
165
|
-
console.log();
|
|
166
|
-
|
|
167
|
-
const linuxScript = generateBashScript(keyPath, deploymentKeyName, organization, repository);
|
|
168
|
-
|
|
169
|
-
console.log(chalk.bold('Linux/macOS Setup Script:'));
|
|
170
|
-
console.log(chalk.blue('─────────────────────────────────────────────────────────────'));
|
|
171
|
-
console.log(linuxScript);
|
|
172
|
-
console.log();
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function generateBashScript(keyPath, keyName, organization, repository) {
|
|
177
|
-
// Convert ~ to $HOME for proper expansion in bash
|
|
178
|
-
const expandedKeyPath = keyPath.replace(/^~/, '$HOME');
|
|
179
|
-
|
|
180
|
-
return `
|
|
181
|
-
# Create SSH directory if it doesn't exist
|
|
182
|
-
mkdir -p ~/.ssh
|
|
183
|
-
chmod 700 ~/.ssh
|
|
184
|
-
|
|
185
|
-
# Generate ED25519 SSH key (secure and modern)
|
|
186
|
-
ssh-keygen -t ed25519 -C "${keyName}" -f "${expandedKeyPath}" -N ""
|
|
187
|
-
|
|
188
|
-
# Set proper permissions
|
|
189
|
-
chmod 600 "${expandedKeyPath}"
|
|
190
|
-
chmod 644 "${expandedKeyPath}.pub"
|
|
191
|
-
|
|
192
|
-
# Add to SSH config for easy usage
|
|
193
|
-
if ! grep -q "Host github-${organization}-${repository}" ~/.ssh/config 2>/dev/null; then
|
|
194
|
-
cat >> ~/.ssh/config << 'EOF'
|
|
195
|
-
|
|
196
|
-
Host github-${organization}-${repository}
|
|
197
|
-
HostName github.com
|
|
198
|
-
User git
|
|
199
|
-
IdentityFile ${keyPath}
|
|
200
|
-
IdentitiesOnly yes
|
|
201
|
-
EOF
|
|
202
|
-
fi
|
|
203
|
-
|
|
204
|
-
# Display public key for GitHub setup
|
|
205
|
-
echo ""
|
|
206
|
-
echo "========================================"
|
|
207
|
-
echo "Public Key (copy this to Inteco CLI):"
|
|
208
|
-
echo "========================================"
|
|
209
|
-
cat "${expandedKeyPath}.pub"
|
|
210
|
-
echo ""
|
|
211
|
-
echo "========================================"
|
|
212
|
-
echo "Private key saved to: ${expandedKeyPath}"
|
|
213
|
-
echo "SSH config updated for: github-${organization}-${repository}"
|
|
214
|
-
echo "========================================"
|
|
215
|
-
echo ""`;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
async function createDeploymentKey(organization, repository, publicKey, keyName) {
|
|
219
|
-
const spinner = ora('Creating deployment key on GitHub...').start();
|
|
220
|
-
|
|
221
|
-
try {
|
|
222
|
-
// Use GitHub CLI to add the deployment key
|
|
223
|
-
const result = execSync(
|
|
224
|
-
`gh repo deploy-key add --repo ${organization}/${repository} --title "${keyName}" -`,
|
|
225
|
-
{
|
|
226
|
-
input: publicKey,
|
|
227
|
-
encoding: 'utf-8'
|
|
228
|
-
}
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
spinner.succeed(`Deployment key "${keyName}" created successfully`);
|
|
232
|
-
console.log();
|
|
233
|
-
|
|
234
|
-
} catch (error) {
|
|
235
|
-
spinner.fail('Failed to create deployment key');
|
|
236
|
-
|
|
237
|
-
if (error.message.includes('not found')) {
|
|
238
|
-
console.error(chalk.red(`✗ Repository not found: ${organization}/${repository}`));
|
|
239
|
-
} else if (error.message.includes('already exists')) {
|
|
240
|
-
console.error(chalk.red(`✗ A key with this name already exists`));
|
|
241
|
-
} else if (error.message.includes('Permission denied')) {
|
|
242
|
-
console.error(chalk.red(`✗ Permission denied. You may not have write access to this repository`));
|
|
243
|
-
} else {
|
|
244
|
-
console.error(chalk.red(`✗ Error: ${error.message}`));
|
|
245
|
-
}
|
|
246
|
-
console.log();
|
|
247
|
-
process.exit(1);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function displayCloneCommand(organization, repository) {
|
|
252
|
-
console.log(chalk.bold.yellow('Clone Command'));
|
|
253
|
-
console.log(chalk.gray('─────────────────────────────────────────────────────────────'));
|
|
254
|
-
console.log('Use this command to clone the repository with the deployment key:');
|
|
255
|
-
console.log();
|
|
256
|
-
console.log(chalk.cyan(`git clone git@github-${organization}-${repository}:${organization}/${repository}.git`));
|
|
257
|
-
console.log();
|
|
258
|
-
console.log(chalk.bold.yellow('Deployment Setup Complete!'));
|
|
259
|
-
console.log(chalk.green(`✓ SSH key generated and stored locally`));
|
|
260
|
-
console.log(chalk.green(`✓ Deployment key added to ${organization}/${repository}`));
|
|
261
|
-
console.log(chalk.green(`✓ SSH config configured for easy access`));
|
|
262
|
-
console.log();
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export default addGithubDeploymentKey;
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import prompts from 'prompts';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import ora from 'ora';
|
|
4
|
-
import Table from 'cli-table3';
|
|
5
|
-
import { getGithubToken, fetchPaginatedGithubAPI, fetchGithubAPI } from '../utils/github/github.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Format a date string to a readable format, or show "Never" if null
|
|
9
|
-
* @param {string|null} dateString - ISO date string or null
|
|
10
|
-
* @returns {string} Formatted date or "Never"
|
|
11
|
-
*/
|
|
12
|
-
function formatDate(dateString) {
|
|
13
|
-
if (!dateString) return chalk.gray('Never');
|
|
14
|
-
|
|
15
|
-
const date = new Date(dateString);
|
|
16
|
-
const now = new Date();
|
|
17
|
-
const diffMs = now - date;
|
|
18
|
-
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
|
|
19
|
-
|
|
20
|
-
if (diffDays === 0) return chalk.green('Today');
|
|
21
|
-
if (diffDays === 1) return chalk.green('Yesterday');
|
|
22
|
-
if (diffDays < 7) return chalk.green(`${diffDays} days ago`);
|
|
23
|
-
if (diffDays < 30) return chalk.yellow(`${Math.floor(diffDays / 7)} weeks ago`);
|
|
24
|
-
if (diffDays < 365) return chalk.yellow(`${Math.floor(diffDays / 30)} months ago`);
|
|
25
|
-
|
|
26
|
-
return chalk.red(`${Math.floor(diffDays / 365)} years ago`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Fetch all deployment keys for a repository
|
|
31
|
-
* @param {string} baseUrl - Base API URL for the repository keys
|
|
32
|
-
* @param {string} token - GitHub authentication token
|
|
33
|
-
* @returns {Promise<Array>} Array of deployment keys
|
|
34
|
-
*/
|
|
35
|
-
async function fetchDeploymentKeys(baseUrl, token) {
|
|
36
|
-
try {
|
|
37
|
-
return await fetchPaginatedGithubAPI(baseUrl, token);
|
|
38
|
-
} catch (error) {
|
|
39
|
-
// Return empty array if there's an error fetching keys for this repo
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* List all deployment keys across all repositories in an organization
|
|
46
|
-
*/
|
|
47
|
-
export async function listGithubDeploymentKeys() {
|
|
48
|
-
console.log();
|
|
49
|
-
|
|
50
|
-
// Get GitHub authentication token
|
|
51
|
-
let token;
|
|
52
|
-
let authMethod;
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
({ token, authMethod } = await getGithubToken());
|
|
56
|
-
} catch (error) {
|
|
57
|
-
console.log();
|
|
58
|
-
console.error(chalk.red(`✗ ${error.message}`));
|
|
59
|
-
console.log(chalk.yellow('\nAuthentication setup:'));
|
|
60
|
-
console.log(chalk.gray(' Option 1: Install GitHub CLI and run: gh auth login'));
|
|
61
|
-
console.log(chalk.gray(' Option 2: Set GITHUB_TOKEN environment variable'));
|
|
62
|
-
console.log();
|
|
63
|
-
process.exit(1);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
console.log(chalk.green(`✓ Authenticated via: ${authMethod}`));
|
|
67
|
-
console.log();
|
|
68
|
-
|
|
69
|
-
// Get organization name
|
|
70
|
-
const orgResponse = await prompts([
|
|
71
|
-
{
|
|
72
|
-
type: 'text',
|
|
73
|
-
name: 'organization',
|
|
74
|
-
message: 'GitHub Organization Name?',
|
|
75
|
-
initial: 'intecoag',
|
|
76
|
-
validate: (value) => value.length > 0 || 'Organization name is required'
|
|
77
|
-
}
|
|
78
|
-
], {
|
|
79
|
-
onCancel: () => {
|
|
80
|
-
console.log();
|
|
81
|
-
console.log(chalk.red('Cancelled deployment keys listing!'));
|
|
82
|
-
console.log();
|
|
83
|
-
process.exit(0);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const { organization } = orgResponse;
|
|
88
|
-
|
|
89
|
-
let mainSpinner = ora('Fetching repositories...').start();
|
|
90
|
-
|
|
91
|
-
try {
|
|
92
|
-
// Fetch all repositories for the organization
|
|
93
|
-
const baseReposUrl = `https://api.github.com/orgs/${organization}/repos`;
|
|
94
|
-
const repos = await fetchPaginatedGithubAPI(baseReposUrl, token);
|
|
95
|
-
|
|
96
|
-
if (repos.length === 0) {
|
|
97
|
-
mainSpinner.warn(`No repositories found in organization "${organization}"`);
|
|
98
|
-
console.log();
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Fetch deployment keys for all repositories
|
|
103
|
-
const allKeys = [];
|
|
104
|
-
for (let i = 0; i < repos.length; i++) {
|
|
105
|
-
const repo = repos[i];
|
|
106
|
-
const progress = `[${i + 1}/${repos.length}]`;
|
|
107
|
-
mainSpinner.text = `${progress} Fetching deployment keys from: ${chalk.blue(repo.name)}...`;
|
|
108
|
-
|
|
109
|
-
const keysUrl = `https://api.github.com/repos/${organization}/${repo.name}/keys`;
|
|
110
|
-
const keys = await fetchDeploymentKeys(keysUrl, token);
|
|
111
|
-
|
|
112
|
-
keys.forEach(key => {
|
|
113
|
-
allKeys.push({
|
|
114
|
-
repository: repo.name,
|
|
115
|
-
keyId: key.id,
|
|
116
|
-
title: key.title,
|
|
117
|
-
createdAt: key.created_at,
|
|
118
|
-
lastUsedAt: key.last_used,
|
|
119
|
-
readOnly: key.read_only
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
mainSpinner.succeed(`Found ${allKeys.length} deployment keys across ${repos.length} repositories`);
|
|
125
|
-
console.log();
|
|
126
|
-
|
|
127
|
-
if (allKeys.length === 0) {
|
|
128
|
-
console.log(chalk.yellow('No deployment keys found in this organization.'));
|
|
129
|
-
console.log();
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Display keys in a table
|
|
134
|
-
const table = new Table({
|
|
135
|
-
head: [
|
|
136
|
-
chalk.cyan('Repository'),
|
|
137
|
-
chalk.cyan('Key Title'),
|
|
138
|
-
chalk.cyan('Created'),
|
|
139
|
-
chalk.cyan('Last Used'),
|
|
140
|
-
chalk.cyan('Read-Only')
|
|
141
|
-
].map(h => h),
|
|
142
|
-
style: { head: [], border: ['cyan'] },
|
|
143
|
-
colWidths: [25, 30, 20, 20, 12],
|
|
144
|
-
wordWrap: true
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
// Sort by repository name and then by last used date (newest first)
|
|
148
|
-
allKeys.sort((a, b) => {
|
|
149
|
-
if (a.repository !== b.repository) {
|
|
150
|
-
return a.repository.localeCompare(b.repository);
|
|
151
|
-
}
|
|
152
|
-
return new Date(b.lastUsedAt || 0) - new Date(a.lastUsedAt || 0);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
allKeys.forEach(key => {
|
|
156
|
-
table.push([
|
|
157
|
-
chalk.blue(key.repository),
|
|
158
|
-
key.title,
|
|
159
|
-
new Date(key.createdAt).toLocaleDateString(),
|
|
160
|
-
formatDate(key.lastUsedAt),
|
|
161
|
-
key.readOnly ? chalk.green('Yes') : chalk.yellow('No')
|
|
162
|
-
]);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
console.log(table.toString());
|
|
166
|
-
console.log();
|
|
167
|
-
|
|
168
|
-
// Show statistics
|
|
169
|
-
const keysNeverUsed = allKeys.filter(k => !k.lastUsedAt).length;
|
|
170
|
-
const readOnlyKeys = allKeys.filter(k => k.readOnly).length;
|
|
171
|
-
const readWriteKeys = allKeys.filter(k => !k.readOnly).length;
|
|
172
|
-
|
|
173
|
-
console.log(chalk.bold('Summary:'));
|
|
174
|
-
console.log(` Total deployment keys: ${chalk.cyan(allKeys.length)}`);
|
|
175
|
-
console.log(` Never used: ${chalk.yellow(keysNeverUsed)}`);
|
|
176
|
-
console.log(` Read-only keys: ${chalk.green(readOnlyKeys)}`);
|
|
177
|
-
console.log(` Read-write keys: ${chalk.yellow(readWriteKeys)}`);
|
|
178
|
-
console.log();
|
|
179
|
-
|
|
180
|
-
} catch (error) {
|
|
181
|
-
console.log();
|
|
182
|
-
mainSpinner.fail('Error fetching deployment keys');
|
|
183
|
-
|
|
184
|
-
if (error.message.startsWith('401')) {
|
|
185
|
-
console.error(chalk.red(`✗ ${error.message}`));
|
|
186
|
-
console.log(chalk.yellow('\nAuthentication setup:'));
|
|
187
|
-
console.log(chalk.gray(' Option 1: Install GitHub CLI and run: gh auth login'));
|
|
188
|
-
console.log(chalk.gray(' Option 2: Set GITHUB_TOKEN environment variable'));
|
|
189
|
-
} else if (error.message.startsWith('404')) {
|
|
190
|
-
console.error(chalk.red(`✗ ${error.message} - Organization not found`));
|
|
191
|
-
} else {
|
|
192
|
-
console.error(chalk.red(`Error: ${error.message}`));
|
|
193
|
-
}
|
|
194
|
-
console.log();
|
|
195
|
-
process.exit(1);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export default listGithubDeploymentKeys;
|
|
@@ -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
|
-
}
|