Skip to content

Commit 9eab58c

Browse files
refactorizando
1 parent d15d4f9 commit 9eab58c

23 files changed

+180
-118
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "PgUiRestore",
3-
"version": "2.2.0",
3+
"version": "2.2.1",
44
"description": "An Electron application with Vue and TypeScript",
55
"main": "./out/main/index.js",
66
"author": "RolandoHidalgo",

src/main/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ app.whenReady().then(() => {
109109
app.commandLine.appendSwitch('lang', 'es')
110110
// Set app user model id for windows
111111
electronApp.setAppUserModelId('com.electron.pgUI-restore')
112-
console.log(app.getVersion(), 'la versionnnn')
112+
113113
// Default open or close DevTools by F12 in development
114114
// and ignore CommandOrControl + R in production.
115115
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
@@ -131,13 +131,13 @@ app.whenReady().then(() => {
131131
})
132132

133133
ipcMain.on('create-db', (event, dbOptions, createDbOptions) => {
134-
console.log('create-db', dbOptions)
134+
135135
createDb(dbOptions, createDbOptions, event)
136136

137137
})
138138

139139
ipcMain.on('clone-db', (event, dbOptions, createDbOptions) => {
140-
console.log('clone-db', dbOptions)
140+
141141
cloneDb(dbOptions, createDbOptions, event)
142142

143143
})
@@ -175,7 +175,7 @@ app.whenReady().then(() => {
175175
const backupFile = process.argv.filter(e => {
176176
return e.toString().includes('.backup')
177177
})
178-
console.log(backupFile[0], 'file')
178+
179179
return backupFile.length > 0 ? backupFile[0] : null
180180

181181

@@ -188,7 +188,7 @@ app.whenReady().then(() => {
188188

189189
})
190190
ipcMain.handle('get-dbs', async (event, name: string) => {
191-
console.log('main con name', name)
191+
192192
return getDatabaseByDatasource(name)
193193

194194

@@ -221,7 +221,7 @@ app.whenReady().then(() => {
221221
// binary:'C:\\Program Files\\PostgreSQL\\13\\bin',
222222
// name:'local'
223223
// })
224-
// console.log('asdasdldldldldle3333',getDatasources())
224+
225225
app.on('activate', function() {
226226
// On macOS it's common to re-create a window in the app when the
227227
// dock icon is clicked and there are no other windows open.

src/main/utils/restore/binariesUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const getVersions = (basePath) => {
2323
}
2424

2525
const findBinarys = () => {
26-
console.log('el process desde el binary', process.argv)
26+
2727
return basePathsArch.map((e) => (fs.existsSync(e) ? getVersions(e) : [])).flat()
2828
}
2929
export type BackupInfo = {
@@ -56,7 +56,7 @@ const parseBackup = async (dsName: string, backupPath: string): Promise<BackupIn
5656
info.dbName = getValueAfterDoublePoints(line)
5757
}
5858
})
59-
console.log('infoLines', info)
59+
6060
return info
6161
}
6262
const getValueAfterDoublePoints = (line: string, splitPattern = ':') => {

src/main/utils/restore/drivesUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ const getUSBDrives = async ():Promise<{name:string,mount:string}> => {
1515
}
1616

1717
// Mostrar los puntos de montaje de las unidades extraíbles
18-
console.log('Puntos de montaje de unidades USB:');
18+
1919
const lines = stdout.trim().split('\n').slice(1); // Ignorar la cabecera
2020
res(lines.map((line) => {
2121
const [mount,name] = line.trim().split('2').map(usb=>usb.trim())
22-
console.log(name,mount,fs.existsSync(resolve(mount)));
22+
2323
return {name,mount:resolve(mount)}
2424
}))
2525
});

src/main/utils/restore/gitUtils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,24 @@ const performGitFlow = async (cwd: string): Promise<void> => {
4444

4545
const runCommand = async (cwd: string, exe: string, params: string): Promise<void> => {
4646
return new Promise((resolve, reject) => {
47-
console.log(params)
47+
4848
const paramsSplitted = params.toString().split(' ')
4949
const bat = spawn(exe, paramsSplitted, { cwd })
5050
bat.stdout.setEncoding('utf8')
5151
bat.stdout.on('data', (data: any) => {
52-
console.log('data', data.toString())
52+
5353
})
5454
bat.stderr.setEncoding('utf8')
5555
bat.stderr.on('data', (data: any) => {
56-
console.log('error', data.toString())
56+
5757
})
5858

5959
bat.on('exit', (code: any) => {
60-
console.log(`Child exited with code ${code}`)
60+
6161
resolve()
6262
})
6363
bat.on('error', (code: any) => {
64-
console.log(`error ${code}`)
64+
6565
reject(code)
6666
})
6767
})
@@ -71,7 +71,7 @@ const execCommand = async (cwd: string, exe: string, params: string): Promise<st
7171
return new Promise((resolve, reject) => {
7272
exec(`${exe} ${params}`, { cwd }, (error, stdout, stderr) => {
7373
if (error) {
74-
console.log(`error ${error}`)
74+
7575
reject(`Error al ejecutar el comando: ${error.message}`)
7676
return
7777
}

src/main/utils/restore/regeditUtils.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import fs from "node:fs";
55

66
import path from "node:path";
77

8-
console.log("sadasdasdasd");
8+
99

1010
const writeChekFile = () => {
11-
console.log("sadasdasdasd");
11+
1212
try {
1313
fs.writeFileSync(getCheckFilePaht(), "true");
1414
// file written successfully
@@ -22,7 +22,7 @@ const isFisrtRun = () => {
2222

2323

2424
try {
25-
console.log("is first??");
25+
2626
return !fs.existsSync(getCheckFilePaht());
2727
// file written successfully
2828
} catch (err) {
@@ -32,21 +32,21 @@ const isFisrtRun = () => {
3232
};
3333

3434
const getCheckFilePaht = () => {
35-
console.log("check");
35+
3636
const val = path.join(path.dirname(process.argv[0]), "apprun.info");
37-
console.log(val);
37+
3838
return val;
3939
};
4040

4141
const squirrelStartupEvent = () => {
42-
console.log("squirelllllllll");
42+
4343
if (process.platform !== "win32" || process.env.WEBPACK_DEV_SERVER_URL) {
44-
console.log("no instalar");
44+
4545
return false;
4646
}
4747

4848
if (isFisrtRun()) {
49-
console.log("a instalarrrrrrrr");
49+
5050
//... instantiate your ProgIds
5151
const progId = new ProgId({
5252
description: "Restaurar PostgreSQl .backup files",
@@ -64,11 +64,11 @@ const squirrelStartupEvent = () => {
6464
});
6565

6666
progId.install().then((e) => {
67-
console.log("el progId installed", e);
67+
6868
});
6969

7070
Regedit.installAll().then((e) => {
71-
console.log("all process installed", e);
71+
7272
});
7373
writeChekFile();
7474
}
@@ -77,7 +77,7 @@ const squirrelStartupEvent = () => {
7777
};
7878

7979
const handleSquirell = () => {
80-
console.log("handleeeeee");
80+
8181
const handle = squirrelStartupEvent();
8282
if (handle) {
8383
//app.quit();

src/main/utils/restore/restore-db.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,27 @@ const restoreDb = (dbOptions: DbOptions, event: IpcMainEvent) => {
4242
paramsSplitted.push(path.normalize(backupPath));
4343

4444

45-
console.log(binary, paramsSplitted.join(" "));
45+
4646
const exe = path.join(binary, 'pg_restore.exe');
4747
const bat = spawn(exe, paramsSplitted, {env: {...process.env, PGPASSWORD: password}});
4848
getBrowserWindow(event)?.setProgressBar(2);
4949
bat.stdout.setEncoding("utf8");
5050
bat.stdout.on("data", (data: any) => {
51-
console.log("data", data.toString());
51+
5252
event.sender.send("restore-logs", data.toString());
5353
});
5454
bat.stderr.setEncoding("utf8");
5555
bat.stderr.on("data", (data: any) => {
56-
console.log("error", data.toString());
56+
5757
event.sender.send("restore-logs", data.toString());
5858
});
5959

6060
bat.on("exit", (code: any) => {
61-
console.log(`Child exited with code ${code}`);
61+
6262
event.sender.send("restore-logs", `finish-OK`);
6363
});
6464
bat.on("error", (code: any) => {
65-
console.log(`error ${code}`);
65+
6666
event.sender.send("restore-logs", `error ${code}`);
6767
});
6868
};
@@ -84,7 +84,7 @@ function getFormattedDateTime() {
8484
function listDatabases(user: string, password: string, host: string, port: number, binary: string): Promise<string[]> {
8585
// Replace 'your_username' and 'your_password' with your credentials
8686

87-
console.log('listar con allamar con name', password);
87+
8888
return new Promise((resolve, reject) => {
8989
const command = `"${binary}\\psql.exe" -U ${user} --host ${host} --port ${port} -c "\\l"`;
9090

@@ -103,7 +103,7 @@ function listDatabases(user: string, password: string, host: string, port: numbe
103103
}
104104

105105
// Process and print the output
106-
console.log('Available Databases:');
106+
107107
const lines = stdout.split('\n')
108108
.filter(line => line.includes('|'))
109109
.map(line => line.split('|')[0].trim())
@@ -142,7 +142,7 @@ const obtenerEsquemas = (ds: DataSource, dbName: string): Promise<string[]> => {
142142
});
143143
};
144144
const getDatabaseByDatasource = async (dataSourceName: string): Promise<string[]> => {
145-
console.log('restore con con name', dataSourceName)
145+
146146
const ds: DataSource = getDatasource(dataSourceName);
147147
return listDatabases(ds.username, ds.password, ds.host, ds.port, ds.binary);
148148
}
@@ -169,15 +169,13 @@ const backupDb = (dbOptions: DbOptions, event: IpcMainEvent):Promise<string> =>
169169
//const params = `-F c --host ${host} --port ${port} --username ${user} --role postgres --dbname ${dbName}`;
170170
let params = `--file ${path.normalize(backupPath)} --host ${host} --port ${port} --username ${user} --format=c --verbose${schammaParams} ${dbName}`;
171171

172-
console.log(params);
173-
console.log(backupFullName);
174-
console.log(backupPath);
172+
175173
const paramsSplitted = params.toString().split(" ");
176174
//paramsSplitted.push(path.normalize(backupPath));
177175

178176

179177
const exe = path.join(binary, 'pg_dump.exe');
180-
console.log(exe, paramsSplitted);
178+
181179
const bat = spawn(exe, paramsSplitted, {env: {...process.env, PGPASSWORD: password}});
182180
getBrowserWindow(event)?.setProgressBar(2);
183181
bat.stdout.setEncoding("utf8");
@@ -233,14 +231,13 @@ const createDb = (dbOptions: DbOptions, createDbOptions: CreateDebOptions, event
233231
const paramsSplitted = params.toString().split(" ");
234232

235233
const exe = path.join(binary, 'createdb.exe');
236-
console.log(exe, paramsSplitted.join(" "));
237-
console.log(createDbOptions);
234+
238235

239236
const bat = spawn(exe, paramsSplitted, {env: {...process.env, PGPASSWORD: password}});
240237
getBrowserWindow(event)?.setProgressBar(2);
241238

242239
bat.stdout.setEncoding("utf8");
243-
console.log('va a ejecutar')
240+
244241
bat.stdout.on("data", (data: any) => {
245242
console.log("data", data.toString());
246243
event.sender.send("restore-logs", data.toString());
@@ -266,9 +263,9 @@ const createDb = (dbOptions: DbOptions, createDbOptions: CreateDebOptions, event
266263

267264
const cloneDb = async (dbOptions: DbOptions, createDbOptions: CreateDebOptions, event: IpcMainEvent)=>{
268265
dbOptions.backupPath = await backupDb(dbOptions,event)
269-
console.log("backup backup database", dbOptions);
266+
270267
dbOptions.dbName = dbOptions.targetCloneDbName
271-
console.log("backup backup database", dbOptions);
268+
272269
createDb(dbOptions,createDbOptions,event);
273270
}
274271

src/preload/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ const api = {
1515
dbOptions.host = ds?.host
1616
dbOptions.binary = ds?.binary
1717
dbOptions.port = ds?.port
18-
console.log(dbOptions, 'optionss')
18+
1919
return ipcRenderer.send('restore-db', dbOptions)
2020
},
2121
sincronizarUsb: (usbDrive: string) => ipcRenderer.send('sincronizar-usb', usbDrive),
2222
backupDb: (dbOptions: DbOptions) => {
23-
console.log(dbOptions, 'optionss1')
23+
2424
const ds: DataSource | undefined = getDatasources().filter(
2525
(e) => e.name === dbOptions.dsName
2626
)[0]
27-
console.log(ds, 'el ds')
27+
2828
dbOptions.user = ds?.username
2929
dbOptions.password = ds?.password
3030
dbOptions.host = ds?.host
3131
dbOptions.binary = ds?.binary
3232
dbOptions.port = ds?.port
33-
console.log(dbOptions, 'optionss')
33+
3434
ipcRenderer.send('backup-db', dbOptions)
3535
},
3636
addDatasource: async (ds: DataSource) => {
@@ -78,7 +78,7 @@ const api = {
7878
dbOptions.host = ds?.host
7979
dbOptions.binary = ds?.binary
8080
dbOptions.port = ds?.port
81-
console.log(dbOptions, 'optionss')
81+
8282
return ipcRenderer.send('create-db', dbOptions, createDbOptions)
8383
},
8484
cloneDb: (dbOptions: DbOptions, createDbOptions) => {
@@ -91,7 +91,7 @@ const api = {
9191
dbOptions.host = ds?.host
9292
dbOptions.binary = ds?.binary
9393
dbOptions.port = ds?.port
94-
console.log(dbOptions, 'optionss')
94+
9595
return ipcRenderer.send('clone-db', dbOptions, createDbOptions)
9696
},
9797
restoreFinish: () => ipcRenderer.send('restore-finish'),
@@ -104,7 +104,7 @@ const api = {
104104
getDrives: () => ipcRenderer.invoke('get-drives'),
105105
getDatasource: (): Promise<DataSource[]> => ipcRenderer.invoke('get-datasource'),
106106
getDbs: async (name: string) => {
107-
console.log('allamar con name', name)
107+
108108
return ipcRenderer.invoke('get-dbs', name)
109109
},
110110
getSchemmas: async (dsName: string, dbName: string) => {

src/renderer/src/components/AddDatasourceDialog.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const onSubmit = handleSubmit(async (values) => {
8585
})
8686
watchEffect(() => {
8787
if (!store.isDataSourceFormOpen) {
88-
console.log('limpiar')
88+
8989
store.currentDsForm = null
9090
resetForm()
9191
}
@@ -96,13 +96,13 @@ watchEffect(() => {
9696
// }
9797
})
9898
const handleReset = () => {
99-
console.log('limpiar')
99+
100100
resetForm({ values: { ...initVals } })
101101
}
102102
store.$onAction(({ name, after }) => {
103103
after(() => {
104104
if (name === 'openDataSourceForm') {
105-
console.log('seteando', store.currentDsForm)
105+
106106
setValues({ ...store.currentDsForm })
107107
//resetForm({ values: })
108108
store.currentDsForm = null

src/renderer/src/components/Backup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const {handleSubmit, values} = useForm({
6666
})
6767
6868
const onSubmit = handleSubmit((values) => {
69-
console.log(values, 'asdfsdfsf')
69+
7070
isOpenDialog.value = true
7171
const formValues = {...values, backupPath: ''}
7272
window.electron.backupDb(formValues)

0 commit comments

Comments
 (0)