mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 22:36:01 +00:00
removed upload error to Gist feature
This commit is contained in:
5
.github/workflows/build-npm.yaml
vendored
5
.github/workflows/build-npm.yaml
vendored
@@ -37,11 +37,6 @@ jobs:
|
|||||||
- name: setCurrentVersion
|
- name: setCurrentVersion
|
||||||
run: |
|
run: |
|
||||||
yarn setCurrentVersion
|
yarn setCurrentVersion
|
||||||
- name: printSecrets
|
|
||||||
run: |
|
|
||||||
yarn printSecrets
|
|
||||||
env:
|
|
||||||
GIST_UPLOAD_SECRET: ${{secrets.GIST_UPLOAD_SECRET}}
|
|
||||||
- name: Publish types
|
- name: Publish types
|
||||||
working-directory: packages/types
|
working-directory: packages/types
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ module.exports = ({ editMenu, isMac }) => [
|
|||||||
{ divider: true },
|
{ divider: true },
|
||||||
{ command: 'folder.showLogs', hideDisabled: true },
|
{ command: 'folder.showLogs', hideDisabled: true },
|
||||||
{ command: 'folder.showData', hideDisabled: true },
|
{ command: 'folder.showData', hideDisabled: true },
|
||||||
{ command: 'new.gist', hideDisabled: true },
|
|
||||||
{ command: 'app.resetSettings', hideDisabled: true },
|
{ command: 'app.resetSettings', hideDisabled: true },
|
||||||
{ divider: true },
|
{ divider: true },
|
||||||
{ command: 'app.exportConnections', hideDisabled: true },
|
{ command: 'app.exportConnections', hideDisabled: true },
|
||||||
|
|||||||
@@ -1,19 +1,8 @@
|
|||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { uploadsdir, getLogsFilePath, filesdir } = require('../utility/directories');
|
const { uploadsdir } = require('../utility/directories');
|
||||||
const { getLogger, extractErrorLogData } = require('dbgate-tools');
|
const { getLogger } = require('dbgate-tools');
|
||||||
const logger = getLogger('uploads');
|
const logger = getLogger('uploads');
|
||||||
const axios = require('axios');
|
|
||||||
const os = require('os');
|
|
||||||
const fs = require('fs/promises');
|
|
||||||
const { read } = require('./queryHistory');
|
|
||||||
const platformInfo = require('../utility/platformInfo');
|
|
||||||
const _ = require('lodash');
|
|
||||||
const serverConnections = require('./serverConnections');
|
|
||||||
const config = require('./config');
|
|
||||||
const gistSecret = require('../gistSecret');
|
|
||||||
const currentVersion = require('../currentVersion');
|
|
||||||
const socket = require('../utility/socket');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
upload_meta: {
|
upload_meta: {
|
||||||
@@ -51,88 +40,70 @@ module.exports = {
|
|||||||
res.sendFile(path.join(uploadsdir(), req.query.file));
|
res.sendFile(path.join(uploadsdir(), req.query.file));
|
||||||
},
|
},
|
||||||
|
|
||||||
async getGistToken() {
|
// uploadErrorToGist_meta: true,
|
||||||
const settings = await config.getSettings();
|
// async uploadErrorToGist() {
|
||||||
|
// const logs = await fs.readFile(getLogsFilePath(), { encoding: 'utf-8' });
|
||||||
|
// const connections = await serverConnections.getOpenedConnectionReport();
|
||||||
|
// try {
|
||||||
|
// const response = await axios.default.post(
|
||||||
|
// 'https://api.github.com/gists',
|
||||||
|
// {
|
||||||
|
// description: `DbGate ${currentVersion.version} error report`,
|
||||||
|
// public: false,
|
||||||
|
// files: {
|
||||||
|
// 'logs.jsonl': {
|
||||||
|
// content: logs,
|
||||||
|
// },
|
||||||
|
// 'os.json': {
|
||||||
|
// content: JSON.stringify(
|
||||||
|
// {
|
||||||
|
// release: os.release(),
|
||||||
|
// arch: os.arch(),
|
||||||
|
// machine: os.machine(),
|
||||||
|
// platform: os.platform(),
|
||||||
|
// type: os.type(),
|
||||||
|
// },
|
||||||
|
// null,
|
||||||
|
// 2
|
||||||
|
// ),
|
||||||
|
// },
|
||||||
|
// 'platform.json': {
|
||||||
|
// content: JSON.stringify(
|
||||||
|
// _.omit(
|
||||||
|
// {
|
||||||
|
// ...platformInfo,
|
||||||
|
// },
|
||||||
|
// ['defaultKeyfile', 'sshAuthSock']
|
||||||
|
// ),
|
||||||
|
// null,
|
||||||
|
// 2
|
||||||
|
// ),
|
||||||
|
// },
|
||||||
|
// 'connections.json': {
|
||||||
|
// content: JSON.stringify(connections, null, 2),
|
||||||
|
// },
|
||||||
|
// 'version.json': {
|
||||||
|
// content: JSON.stringify(currentVersion, null, 2),
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// headers: {
|
||||||
|
// Authorization: `token ${await this.getGistToken()}`,
|
||||||
|
// 'Content-Type': 'application/json',
|
||||||
|
// Accept: 'application/vnd.github.v3+json',
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
return settings['other.gistCreateToken'] || gistSecret;
|
// return response.data;
|
||||||
},
|
// } catch (err) {
|
||||||
|
// logger.error(extractErrorLogData(err), 'DBGM-00148 Error uploading gist');
|
||||||
|
|
||||||
uploadErrorToGist_meta: true,
|
// return {
|
||||||
async uploadErrorToGist() {
|
// apiErrorMessage: err.message,
|
||||||
const logs = await fs.readFile(getLogsFilePath(), { encoding: 'utf-8' });
|
// };
|
||||||
const connections = await serverConnections.getOpenedConnectionReport();
|
// // console.error('Error creating gist:', error.response ? error.response.data : error.message);
|
||||||
try {
|
// }
|
||||||
const response = await axios.default.post(
|
// },
|
||||||
'https://api.github.com/gists',
|
// };
|
||||||
{
|
|
||||||
description: `DbGate ${currentVersion.version} error report`,
|
|
||||||
public: false,
|
|
||||||
files: {
|
|
||||||
'logs.jsonl': {
|
|
||||||
content: logs,
|
|
||||||
},
|
|
||||||
'os.json': {
|
|
||||||
content: JSON.stringify(
|
|
||||||
{
|
|
||||||
release: os.release(),
|
|
||||||
arch: os.arch(),
|
|
||||||
machine: os.machine(),
|
|
||||||
platform: os.platform(),
|
|
||||||
type: os.type(),
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
2
|
|
||||||
),
|
|
||||||
},
|
|
||||||
'platform.json': {
|
|
||||||
content: JSON.stringify(
|
|
||||||
_.omit(
|
|
||||||
{
|
|
||||||
...platformInfo,
|
|
||||||
},
|
|
||||||
['defaultKeyfile', 'sshAuthSock']
|
|
||||||
),
|
|
||||||
null,
|
|
||||||
2
|
|
||||||
),
|
|
||||||
},
|
|
||||||
'connections.json': {
|
|
||||||
content: JSON.stringify(connections, null, 2),
|
|
||||||
},
|
|
||||||
'version.json': {
|
|
||||||
content: JSON.stringify(currentVersion, null, 2),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
Authorization: `token ${await this.getGistToken()}`,
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
Accept: 'application/vnd.github.v3+json',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return response.data;
|
|
||||||
} catch (err) {
|
|
||||||
logger.error(extractErrorLogData(err), 'DBGM-00148 Error uploading gist');
|
|
||||||
|
|
||||||
return {
|
|
||||||
apiErrorMessage: err.message,
|
|
||||||
};
|
|
||||||
// console.error('Error creating gist:', error.response ? error.response.data : error.message);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
deleteGist_meta: true,
|
|
||||||
async deleteGist({ url }) {
|
|
||||||
const response = await axios.default.delete(url, {
|
|
||||||
headers: {
|
|
||||||
Authorization: `token ${await this.getGistToken()}`,
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
Accept: 'application/vnd.github.v3+json',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
module.exports = process.env.GIST_UPLOAD_SECRET;
|
|
||||||
@@ -1137,13 +1137,6 @@ registerCommand({
|
|||||||
onClick: () => getElectron().send('window-action', 'selectAll'),
|
onClick: () => getElectron().send('window-action', 'selectAll'),
|
||||||
});
|
});
|
||||||
|
|
||||||
registerCommand({
|
|
||||||
id: 'new.gist',
|
|
||||||
category: 'New',
|
|
||||||
name: 'Upload error to gist',
|
|
||||||
onClick: () => showModal(UploadErrorModal),
|
|
||||||
});
|
|
||||||
|
|
||||||
registerCommand({
|
registerCommand({
|
||||||
id: 'app.unsetCurrentDatabase',
|
id: 'app.unsetCurrentDatabase',
|
||||||
category: 'Application',
|
category: 'Application',
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { onMount } from 'svelte';
|
|
||||||
import FormStyledButton from '../buttons/FormStyledButton.svelte';
|
|
||||||
|
|
||||||
import FormProvider from '../forms/FormProvider.svelte';
|
|
||||||
import FormSubmit from '../forms/FormSubmit.svelte';
|
|
||||||
import FormTextField from '../forms/FormTextField.svelte';
|
|
||||||
import { apiCall } from '../utility/api';
|
|
||||||
import ModalBase from './ModalBase.svelte';
|
|
||||||
import { closeCurrentModal } from './modalTools';
|
|
||||||
import { copyTextToClipboard } from '../utility/clipboard';
|
|
||||||
import Link from '../elements/Link.svelte';
|
|
||||||
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
|
||||||
import { showSnackbarSuccess } from '../utility/snackbar';
|
|
||||||
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
|
||||||
|
|
||||||
export let error = null;
|
|
||||||
let htmlUrl;
|
|
||||||
let url;
|
|
||||||
let errorMessage;
|
|
||||||
|
|
||||||
async function upload() {
|
|
||||||
const resp = await apiCall('uploads/upload-error-to-gist');
|
|
||||||
url = resp.url;
|
|
||||||
htmlUrl = resp.html_url;
|
|
||||||
errorMessage = resp.errorMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
upload();
|
|
||||||
});
|
|
||||||
|
|
||||||
async function handleDelete() {
|
|
||||||
const resp = await apiCall('uploads/delete-gist', { url });
|
|
||||||
closeCurrentModal();
|
|
||||||
showSnackbarSuccess('Gist was deleted');
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleCopy() {
|
|
||||||
copyTextToClipboard(htmlUrl);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<ModalBase {...$$restProps}>
|
|
||||||
<svelte:fragment slot="header">Upload error</svelte:fragment>
|
|
||||||
|
|
||||||
{#if htmlUrl}
|
|
||||||
<div>
|
|
||||||
<p>
|
|
||||||
Upload error to gist was successful. Please copy gist URL abnd paste it to related github issue. You could check
|
|
||||||
uploaded data, if don't want to make them public, use Delete button to remove them from gist.
|
|
||||||
</p>
|
|
||||||
<p><Link href={htmlUrl}>Open uploaded data</Link></p>
|
|
||||||
</div>
|
|
||||||
{:else if errorMessage}
|
|
||||||
<ErrorInfo message={errorMessage} />
|
|
||||||
{:else}
|
|
||||||
<LoadingInfo message="Uploading error to gist..." />
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<svelte:fragment slot="footer">
|
|
||||||
<FormStyledButton value="Copy URL" disabled={!htmlUrl} on:click={handleCopy} />
|
|
||||||
<FormStyledButton type="button" value="Close" on:click={closeCurrentModal} />
|
|
||||||
<FormStyledButton value="Delete" disabled={!url} on:click={handleDelete} />
|
|
||||||
</svelte:fragment>
|
|
||||||
</ModalBase>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
const text = `
|
|
||||||
module.exports = '${process.env.GIST_UPLOAD_SECRET}';
|
|
||||||
`;
|
|
||||||
|
|
||||||
fs.writeFileSync('packages/api/src/gistSecret.js', text);
|
|
||||||
@@ -137,12 +137,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
<<cd_merged>>
|
<<cd_merged>>
|
||||||
yarn setCurrentVersion
|
yarn setCurrentVersion
|
||||||
- name: printSecrets
|
|
||||||
run: |
|
|
||||||
<<cd_merged>>
|
|
||||||
yarn printSecrets
|
|
||||||
env:
|
|
||||||
GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}}
|
|
||||||
- name: fillPackagedPlugins
|
- name: fillPackagedPlugins
|
||||||
run: |
|
run: |
|
||||||
<<cd_merged>>
|
<<cd_merged>>
|
||||||
|
|||||||
@@ -59,14 +59,6 @@ jobs:
|
|||||||
cd dbgate-merged
|
cd dbgate-merged
|
||||||
yarn setCurrentVersion
|
yarn setCurrentVersion
|
||||||
|
|
||||||
- name: printSecrets
|
|
||||||
run: |
|
|
||||||
cd ..
|
|
||||||
cd dbgate-merged
|
|
||||||
yarn printSecrets
|
|
||||||
env:
|
|
||||||
GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}}
|
|
||||||
|
|
||||||
- name: Prepare packer build
|
- name: Prepare packer build
|
||||||
run: |
|
run: |
|
||||||
cd ..
|
cd ..
|
||||||
|
|||||||
@@ -95,12 +95,6 @@ jobs:
|
|||||||
<<cd_merged>>
|
<<cd_merged>>
|
||||||
yarn setCurrentVersion
|
yarn setCurrentVersion
|
||||||
|
|
||||||
- name: printSecrets
|
|
||||||
run: |
|
|
||||||
<<cd_merged>>
|
|
||||||
yarn printSecrets
|
|
||||||
env:
|
|
||||||
GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}}
|
|
||||||
- name: Prepare docker image
|
- name: Prepare docker image
|
||||||
run: |
|
run: |
|
||||||
<<cd_merged>>
|
<<cd_merged>>
|
||||||
|
|||||||
@@ -69,13 +69,6 @@ jobs:
|
|||||||
cd dbgate-merged
|
cd dbgate-merged
|
||||||
yarn setCurrentVersion
|
yarn setCurrentVersion
|
||||||
|
|
||||||
- name: printSecrets
|
|
||||||
run: |
|
|
||||||
cd ..
|
|
||||||
cd dbgate-merged
|
|
||||||
yarn printSecrets
|
|
||||||
env:
|
|
||||||
GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}}
|
|
||||||
|
|
||||||
- name: Publish dbgate-api-premium
|
- name: Publish dbgate-api-premium
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -49,12 +49,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
yarn setCurrentVersion
|
yarn setCurrentVersion
|
||||||
|
|
||||||
- name: printSecrets
|
|
||||||
run: |
|
|
||||||
yarn printSecrets
|
|
||||||
env:
|
|
||||||
GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}}
|
|
||||||
|
|
||||||
- name: Publish types
|
- name: Publish types
|
||||||
working-directory: packages/types
|
working-directory: packages/types
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user