From 015276f84189dbb702805042e0a433011a459140 Mon Sep 17 00:00:00 2001
From: Massimo Melina
Date: Fri, 3 Jan 2025 14:52:47 +0100
Subject: [PATCH] fix: (regression 0.55.0) admin/logs/console: first lines were
not logged
---
src/argv.ts | 3 +++
src/commands.ts | 3 ++-
src/config.ts | 3 ++-
src/consoleLog.ts | 2 +-
src/const.ts | 2 +-
src/github.ts | 3 ++-
src/listen.ts | 3 ++-
src/update.ts | 3 ++-
8 files changed, 15 insertions(+), 7 deletions(-)
create mode 100644 src/argv.ts
diff --git a/src/argv.ts b/src/argv.ts
new file mode 100644
index 000000000..0a29f903c
--- /dev/null
+++ b/src/argv.ts
@@ -0,0 +1,3 @@
+import minimist from 'minimist'
+
+export const argv = minimist(process.argv.slice(2))
diff --git a/src/commands.ts b/src/commands.ts
index 96a9cb13b..f34f88e1c 100644
--- a/src/commands.ts
+++ b/src/commands.ts
@@ -6,13 +6,14 @@ import _ from 'lodash'
import { getUpdates, update } from './update'
import { openAdmin } from './listen'
import yaml from 'yaml'
-import { argv, BUILD_TIMESTAMP, VERSION } from './const'
+import { BUILD_TIMESTAMP, VERSION } from './const'
import { createInterface } from 'readline'
import { getAvailablePlugins, mapPlugins, startPlugin, stopPlugin } from './plugins'
import { purgeFileAttr } from './fileAttr'
import { downloadPlugin } from './github'
import { Dict, formatBytes, formatSpeed, formatTimestamp, makeMatcher } from './cross'
import apiMonitor from './api.monitor'
+import { argv } from './argv'
if (!argv.updating)
try {
diff --git a/src/config.ts b/src/config.ts
index fc1471d9e..a18e58c7c 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -1,6 +1,6 @@
// This file is part of HFS - Copyright 2021-2023, Massimo Melina - License https://www.gnu.org/licenses/gpl-3.0.txt
-import { argv, ORIGINAL_CWD, VERSION, CONFIG_FILE } from './const'
+import { ORIGINAL_CWD, VERSION, CONFIG_FILE } from './const'
import { watchLoad } from './watchLoad'
import yaml from 'yaml'
import _ from 'lodash'
@@ -10,6 +10,7 @@ import { join, resolve } from 'path'
import events from './events'
import { copyFile, stat } from 'fs/promises'
import produce, { setAutoFreeze } from 'immer'
+import { argv } from './argv'
setAutoFreeze(false) // we still want to mess with objects later (eg: account.belongs)
diff --git a/src/consoleLog.ts b/src/consoleLog.ts
index de0234a25..15fef76fb 100644
--- a/src/consoleLog.ts
+++ b/src/consoleLog.ts
@@ -1,7 +1,7 @@
import events from './events'
import { formatTime, formatTimestamp } from './cross'
import { createWriteStream } from 'fs'
-import { argv } from './const'
+import { argv } from './argv'
export const consoleLog: Array<{ ts: Date, k: string, msg: string }> = []
const f = argv.consoleFile ? createWriteStream(argv.consoleFile, 'utf-8') : null
diff --git a/src/const.ts b/src/const.ts
index 09438686a..acca60f11 100644
--- a/src/const.ts
+++ b/src/const.ts
@@ -6,12 +6,12 @@ import { homedir } from 'os'
import _ from 'lodash'
import { basename, dirname, join } from 'path'
import { formatTimestamp } from './cross'
+import { argv } from './argv'
export * from './cross-const'
export const API_VERSION = 10.3
export const COMPATIBLE_API_VERSION = 1 // while changes in the api are not breaking, this number stays the same, otherwise it is made equal to API_VERSION
-export const argv = minimist(process.argv.slice(2))
// you can add arguments with this file, currently used for the update process on mac/linux
export const ARGS_FILE = join(homedir(), 'hfs-args')
try {
diff --git a/src/github.ts b/src/github.ts
index f5eb5fb47..1ad012600 100644
--- a/src/github.ts
+++ b/src/github.ts
@@ -11,13 +11,14 @@ import {
import { ApiError } from './apiMiddleware'
import _ from 'lodash'
import {
- argv, HFS_REPO, HFS_REPO_BRANCH, HTTP_BAD_REQUEST, HTTP_CONFLICT, HTTP_FORBIDDEN, HTTP_NOT_ACCEPTABLE,
+ HFS_REPO, HFS_REPO_BRANCH, HTTP_BAD_REQUEST, HTTP_CONFLICT, HTTP_FORBIDDEN, HTTP_NOT_ACCEPTABLE,
HTTP_SERVER_ERROR, VERSION
} from './const'
import { rename, rm } from 'fs/promises'
import { join } from 'path'
import { readFileSync } from 'fs'
import { storedMap } from './persistence'
+import { argv } from './argv'
const DIST_ROOT = 'dist'
diff --git a/src/listen.ts b/src/listen.ts
index 2f5eb2635..7ec65ddeb 100644
--- a/src/listen.ts
+++ b/src/listen.ts
@@ -11,7 +11,7 @@ import open from 'open'
import {
CFG, debounceAsync, ipForUrl, makeNetMatcher, MINUTE, objSameKeys, onlyTruthy, prefix, runAt, wait, xlate
} from './misc'
-import { PORT_DISABLED, ADMIN_URI, argv, DEV, IS_WINDOWS } from './const'
+import { PORT_DISABLED, ADMIN_URI, DEV, IS_WINDOWS } from './const'
import findProcess from 'find-process'
import { anyAccountCanLoginAdmin } from './adminApis'
import _ from 'lodash'
@@ -20,6 +20,7 @@ import events from './events'
import { isIPv6 } from 'net'
import { defaultBaseUrl } from './nat'
import { storedMap } from './persistence'
+import { argv } from './argv'
interface ServerExtra { name: string, error?: string, busy?: Promise }
let httpSrv: undefined | http.Server & ServerExtra
diff --git a/src/update.ts b/src/update.ts
index 58f66b97a..9248d8a86 100644
--- a/src/update.ts
+++ b/src/update.ts
@@ -1,7 +1,7 @@
// This file is part of HFS - Copyright 2021-2023, Massimo Melina - License https://www.gnu.org/licenses/gpl-3.0.txt
import { getProjectInfo, getRepoInfo } from './github'
-import { ARGS_FILE, argv, HFS_REPO, IS_BINARY, IS_WINDOWS, RUNNING_BETA } from './const'
+import { ARGS_FILE, HFS_REPO, IS_BINARY, IS_WINDOWS, RUNNING_BETA } from './const'
import { dirname, join } from 'path'
import { spawn, spawnSync } from 'child_process'
import { DAY, exists, debounceAsync, httpStream, unzip, prefix, xlate, HOUR } from './misc'
@@ -15,6 +15,7 @@ import { cmdEscape, RUNNING_AS_SERVICE } from './util-os'
import { onProcessExit } from './first'
import { storedMap } from './persistence'
import _ from 'lodash'
+import { argv } from './argv'
const updateToBeta = defineConfig('update_to_beta', false)
const autoCheckUpdate = defineConfig('auto_check_update', true)