chore: $constants refactor

This commit is contained in:
Ben Allfree 2022-12-31 09:19:00 -08:00
parent c6ba24af87
commit a3fc37b149
14 changed files with 30 additions and 29 deletions

View File

@ -1,3 +1,4 @@
import { DEFAULT_PB_DEV_URL } from '$constants'
import { Parcel } from '@parcel/core'
import { debounce } from '@s-libs/micro-dash'
import chokidar from 'chokidar'
@ -5,7 +6,6 @@ import { Command } from 'commander'
import { join } from 'path'
import { cwd } from 'process'
import tmp from 'tmp'
import { DEFAULT_PB_DEV_URL } from '../constants'
import { SessionState } from '../providers/CustomAuthStore'
import { ensureAdminClient } from '../util/ensureAdminClient'
import { getProjectRoot, readSettings } from '../util/project'

View File

@ -1,8 +1,8 @@
import { DEFAULT_PB_DEV_URL } from '$constants'
import { Command } from 'commander'
import { existsSync, readFileSync } from 'fs'
import { join } from 'path'
import pocketbaseEs from 'pocketbase'
import { DEFAULT_PB_DEV_URL } from '../constants'
import { SessionState } from '../providers/CustomAuthStore'
import { die } from '../util/die'
import { ensureAdminClient } from '../util/ensureAdminClient'

View File

@ -1,6 +1,6 @@
import { PH_BIN_CACHE, PUBLIC_PB_SUBDOMAIN } from '$constants'
import { pocketbase } from '$services'
import { InstanceStatus, logger, safeCatch } from '@pockethost/common'
import { PH_BIN_CACHE, PUBLIC_PB_SUBDOMAIN } from '../constants'
import { schema } from './schema'
import { withInstance } from './withInstance'
;(async () => {

View File

@ -1,12 +1,12 @@
import { createPbClient, pocketbase, PocketbaseClientApi } from '$services'
import { logger, safeCatch } from '@pockethost/common'
import {
DAEMON_PB_PASSWORD,
DAEMON_PB_USERNAME,
PUBLIC_PB_DOMAIN,
PUBLIC_PB_PROTOCOL,
PUBLIC_PB_SUBDOMAIN,
} from '../constants'
} from '$constants'
import { createPbClient, pocketbase, PocketbaseClientApi } from '$services'
import { logger, safeCatch } from '@pockethost/common'
export const withInstance = safeCatch(
`withInstance`,

View File

@ -1,3 +1,4 @@
import { DEBUG, PH_BIN_CACHE, PUBLIC_PB_SUBDOMAIN } from '$constants'
import {
backupService,
clientService,
@ -8,7 +9,6 @@ import {
rpcService,
} from '$services'
import { logger } from '@pockethost/common'
import { DEBUG, PH_BIN_CACHE, PUBLIC_PB_SUBDOMAIN } from './constants'
logger({ debug: DEBUG })

View File

@ -1,7 +1,3 @@
import { clientService, createPbClient } from '$services'
import { logger, mkSingleton } from '@pockethost/common'
import { readFileSync } from 'fs'
import { FtpSrv } from 'ftp-srv'
import {
PH_FTP_PASV_IP,
PH_FTP_PASV_PORT_MAX,
@ -9,7 +5,11 @@ import {
PH_FTP_PORT,
SSL_CERT,
SSL_KEY,
} from '../../constants'
} from '$constants'
import { clientService, createPbClient } from '$services'
import { logger, mkSingleton } from '@pockethost/common'
import { readFileSync } from 'fs'
import { FtpSrv } from 'ftp-srv'
import { PhFs } from './PhFs'
export type FtpConfig = {}

View File

@ -1,9 +1,9 @@
import { DAEMON_PB_DATA_DIR } from '$constants'
import { Logger, logger } from '@pockethost/common'
import { existsSync, mkdirSync } from 'fs'
import { FileStat, FileSystem, FtpConnection } from 'ftp-srv'
import { join } from 'path'
import { Readable } from 'stream'
import { DAEMON_PB_DATA_DIR } from '../../constants'
import { PocketbaseClientApi } from '../clientService/PbClient'
import {
FOLDER_NAMES,

View File

@ -1,3 +1,9 @@
import {
DAEMON_PB_IDLE_TTL,
DAEMON_PB_PORT_BASE,
PUBLIC_APP_DOMAIN,
PUBLIC_APP_PROTOCOL,
} from '$constants'
import { clientService, rpcService } from '$services'
import { mkInternalUrl, now } from '$util'
import {
@ -17,12 +23,6 @@ import { forEachRight, map } from '@s-libs/micro-dash'
import Bottleneck from 'bottleneck'
import getPort from 'get-port'
import { AsyncReturnType } from 'type-fest'
import {
DAEMON_PB_IDLE_TTL,
DAEMON_PB_PORT_BASE,
PUBLIC_APP_DOMAIN,
PUBLIC_APP_PROTOCOL,
} from '../constants'
import { pocketbase, PocketbaseProcess } from './PocketBaseService'
type InstanceApi = {

View File

@ -1,3 +1,4 @@
import { DAEMON_PB_DATA_DIR } from '$constants'
import {
downloadAndExtract,
mkInternalAddress,
@ -15,7 +16,6 @@ import { type } from 'os'
import { join } from 'path'
import { maxSatisfying, rsort } from 'semver'
import { AsyncReturnType } from 'type-fest'
import { DAEMON_PB_DATA_DIR } from '../constants'
export type PocketbaseCommand = 'serve' | 'upgrade'
export type SpawnConfig = {

View File

@ -1,13 +1,13 @@
import {
PUBLIC_APP_DOMAIN,
PUBLIC_APP_PROTOCOL,
PUBLIC_PB_SUBDOMAIN,
} from '$constants'
import { instanceService } from '$services'
import { logger, mkSingleton } from '@pockethost/common'
import { createServer } from 'http'
import httpProxy from 'http-proxy'
import { AsyncReturnType } from 'type-fest'
import {
PUBLIC_APP_DOMAIN,
PUBLIC_APP_PROTOCOL,
PUBLIC_PB_SUBDOMAIN,
} from '../constants'
export type ProxyServiceApi = AsyncReturnType<typeof proxyService>

View File

@ -1,3 +1,4 @@
import { DAEMON_PB_DATA_DIR, PUBLIC_PB_SUBDOMAIN } from '$constants'
import { logger, safeCatch } from '@pockethost/common'
import { Knex } from 'knex'
import {
@ -5,7 +6,6 @@ import {
default as PocketBase,
default as pocketbaseEs,
} from 'pocketbase'
import { DAEMON_PB_DATA_DIR, PUBLIC_PB_SUBDOMAIN } from '../../constants'
import { Collection_Serialized } from '../../migrate/schema'
import { createBackupMixin } from './BackupMixin'
import { createInstanceMixin } from './InstanceMIxin'

View File

@ -1,11 +1,11 @@
import { logger, mkSingleton } from '@pockethost/common'
import {
DAEMON_PB_PASSWORD,
DAEMON_PB_USERNAME,
PUBLIC_PB_DOMAIN,
PUBLIC_PB_PROTOCOL,
PUBLIC_PB_SUBDOMAIN,
} from '../../constants'
} from '$constants'
import { logger, mkSingleton } from '@pockethost/common'
import { createPbClient } from './PbClient'
export const clientService = mkSingleton(async (url: string) => {

View File

@ -1,3 +1,4 @@
import { DAEMON_PB_DATA_DIR } from '$constants'
import {
BackupRecordId,
InstanceId,
@ -9,7 +10,6 @@ import { basename, resolve } from 'path'
import { chdir, cwd } from 'process'
import { Database } from 'sqlite3'
import tmp from 'tmp'
import { DAEMON_PB_DATA_DIR } from '../constants'
import { pexec } from '../migrate/pexec'
import { ensureDirExists } from './ensureDirExists'

View File

@ -18,6 +18,7 @@
"paths": {
"$util": ["src/util/index"],
"$services": ["src/services/index"],
"$constants": ["src/constants"],
"$src/*": ["src/*"]
}
},