Skip to content

Commit

Permalink
draft of suggested changes and switch off logs
Browse files Browse the repository at this point in the history
  • Loading branch information
patryk-sierzega committed Oct 20, 2023
1 parent 302c172 commit 578cf2a
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 13 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,8 @@
"engines": {
"node": "14.17.3",
"npm": "6.14.13"
},
"dependencies": {
"@vscode/sudo-prompt": "^9.3.1"
}
}
56 changes: 56 additions & 0 deletions packages/app/src/__deprecated__/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,69 @@ import { registerOsUpdateAlreadyDownloadedCheck } from "App/update/requests"
import { createSettingsService } from "App/settings/containers/settings.container"
import { ApplicationModule } from "App/core/application.module"
import registerExternalUsageDevice from "App/device/listeners/register-external-usage-device.listner"
import { exec } from "child_process"
import sudoPrompt from "@vscode/sudo-prompt"

// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
require("dotenv").config()

logger.info("Starting the app")

logger.info(`process.platform: ${process.platform}`)

if (process.platform === "linux") {
const processUid = process.getuid ? process.getuid() : undefined
const isAdmin = processUid === 0

// exec("groups", (error3, stdout3, stderr3) => {
// //now it should work :)
// logger.info(`runProcessElevated stderr3 ${stderr3}`)
// logger.info(`runProcessElevated error3 ${error3}`)
// logger.info(`runProcessElevated stdout3 ${stdout3}`)
// })

if (isAdmin) {
//notify user that not all features will work correctly
} else {
exec("groups", (error, stdout, stderr) => {
if (error) {
logger.info(`error: ${error.message}`)
}
if (stderr) {
logger.info(`stderr: ${stderr}`)
}
logger.info(`stdout: ${stdout}`)

const userInDialout = stdout.includes("dialout")
logger.info(`userInDialout: ${userInDialout}`)

Check warning on line 116 in packages/app/src/__deprecated__/main/main.ts

View workflow job for this annotation

GitHub Actions / validate (14.17.3)

Invalid type "boolean" of template literal expression

//ask user for confirmation... :)
if (!userInDialout) {
sudoPrompt.exec(
"usermod -aG dialout $USER",
{ name: "Electron Runas Admin" },
(error2, stdout2, stderr2) => {
if (stderr) {
logger.info(`runProcessElevated stderr2 ${stderr2}`)

Check warning on line 125 in packages/app/src/__deprecated__/main/main.ts

View workflow job for this annotation

GitHub Actions / validate (14.17.3)

Invalid type "string | Buffer | undefined" of template literal expression
}
if (error2) {
logger.info(`runProcessElevated error2 ${error2}`)

Check warning on line 128 in packages/app/src/__deprecated__/main/main.ts

View workflow job for this annotation

GitHub Actions / validate (14.17.3)

Invalid type "Error" of template literal expression
}
if (stdout2) {
logger.info(`runProcessElevated stdout2 ${stdout2}`)

Check warning on line 131 in packages/app/src/__deprecated__/main/main.ts

View workflow job for this annotation

GitHub Actions / validate (14.17.3)

Invalid type "string | Buffer" of template literal expression
}
logger.info(`runProcessElevated no error no stdout`)
logger.info(`runProcessElevated now you can restart/logout`)
}
)
} else {
//it's fine? User is in dialout group
}
})
}
}

let win: BrowserWindow | null
let helpWindow: BrowserWindow | null = null
let googleAuthWindow: BrowserWindow | null = null
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/__deprecated__/main/utils/pure-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export interface ScrubProps {
class PureLogger implements ConsoleLogger {
info(message: string): void {

Check failure on line 20 in packages/app/src/__deprecated__/main/utils/pure-logger.ts

View workflow job for this annotation

GitHub Actions / validate (14.17.3)

'message' is defined but never used. Allowed unused args must match /^_/u
if (flags.get(Feature.LogsScrubbingEnabled)) {
logger.info(this.scrub(message))
//logger.info(this.scrub(message))
} else {
logger.info(this.scrubFileSystemData(message))
//logger.info(this.scrubFileSystemData(message))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export class AnalyticDataTrackerFactory {
{ siteId, apiUrl }: AnalyticDataTrackerFactoryOption
): AnalyticDataTrackerClass {
if (siteId === undefined || isNaN(Number(siteId))) {
logger.info(`AnalyticDataTracker siteId is required`)
//logger.info(`AnalyticDataTracker siteId is required`)
return new MatomoTrackerPlaceholder()
}

if (typeof apiUrl !== "string" || apiUrl === "") {
logger.info(`AnalyticDataTracker apiUrl is required`)
//logger.info(`AnalyticDataTracker apiUrl is required`)
return new MatomoTrackerPlaceholder()
}

Expand Down
12 changes: 6 additions & 6 deletions packages/app/src/core/decorators/log.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ export function log(message: string, logConfig = LogConfig.ReturnValue) {
)

void Promise.resolve(valueOrPromise).then((value: unknown) => {
logger.info(message)
//logger.info(message)

if (logConfig === LogConfig.ReturnValue) {
if (
Object.prototype.hasOwnProperty.call(value, "data") &&
Object.prototype.hasOwnProperty.call(value, "ok")
) {
logger.info(
JSON.stringify([(value as ResultObject<unknown>).data], null, 2)
)
// logger.info(
// JSON.stringify([(value as ResultObject<unknown>).data], null, 2)
// )
} else {
logger.info(JSON.stringify([value], null, 2))
//logger.info(JSON.stringify([value], null, 2))
}
} else {
logger.info(JSON.stringify(args, null, 2))
//logger.info(JSON.stringify(args, null, 2))
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ export class DeviceFileSystemService {
const receivedFileCrc32 =
downloadFileResponse.data.fileCrc32.toLowerCase()
const countedFileCrc32 = countCRC32(fileBuffer)
logger.info(
`downloadFile crc: received ${receivedFileCrc32}, counted ${countedFileCrc32}`
)
// logger.info(
// `downloadFile crc: received ${receivedFileCrc32}, counted ${countedFileCrc32}`
// )

if (receivedFileCrc32 === countedFileCrc32) {
return Result.success(fileBuffer)
Expand Down

0 comments on commit 578cf2a

Please sign in to comment.