redo pockethost package entry point

This commit is contained in:
Ben Allfree 2024-11-15 03:46:02 -08:00
parent 3facc2c3f3
commit c205de9bbd
40 changed files with 58 additions and 58 deletions

View File

@ -35,6 +35,7 @@
"mothership",
"multitenancy",
"multitenant",
"neverending",
"noaxis",
"nofile",
"nohup",

View File

@ -1,6 +1,6 @@
<script lang="ts">
import { userSubscriptionType } from '$util/stores'
import { PLAN_NAMES, SubscriptionType } from 'pockethost'
import { PLAN_NAMES, SubscriptionType } from 'pockethost/common'
import { userStore } from '$util/stores'
import { onMount } from 'svelte'
import FlounderCard from './FlounderCard.svelte'

View File

@ -1,5 +1,5 @@
<script lang="ts">
import { PLAN_NAMES, SubscriptionType } from 'pockethost'
import { PLAN_NAMES, SubscriptionType } from 'pockethost/common'
import { stats, userStore } from '$util/stores'
import PricingCard from '$src/routes/(static)/pricing/PricingCard.svelte'

View File

@ -3,7 +3,7 @@
import { globalInstancesStore, userSubscriptionType } from '$util/stores'
import { values } from '@s-libs/micro-dash'
import InstanceList from './InstanceList.svelte'
import { SubscriptionType } from 'pockethost'
import { SubscriptionType } from 'pockethost/common'
import { faPlus } from '@fortawesome/free-solid-svg-icons'
import Fa from 'svelte-fa'

View File

@ -5,7 +5,7 @@
import { globalInstancesStore } from '$util/stores'
import { faCircleInfo } from '@fortawesome/free-solid-svg-icons'
import { values } from '@s-libs/micro-dash'
import { type InstanceId } from 'pockethost'
import { type InstanceId } from 'pockethost/common'
import Fa from 'svelte-fa'
const { updateInstance } = client()
@ -26,7 +26,7 @@
{#each values($globalInstancesStore).sort( (a, b) => a.subdomain.localeCompare(b.subdomain), ) as instance, index}
<button
class={`card min-w-80 lg:max-w-80 flex-1 m-4 transition hover:bg-base-300 ${instance.maintenance ? 'bg-base-200' : 'bg-neutral'}`}
on:click={_=>goto(`/instances/${instance.id}`)}
on:click={(_) => goto(`/instances/${instance.id}`)}
>
<div class="card-body w-full">
<div class="card-title">
@ -38,7 +38,7 @@
? 'bg-red-500 hover:bg-red-500'
: 'toggle-success'}"
checked={!instance.maintenance}
on:click={e=>e.stopPropagation()}
on:click={(e) => e.stopPropagation()}
on:change={handleMaintenanceChange(instance.id)}
/>
</div>

View File

@ -4,7 +4,7 @@
import { client } from '$src/pocketbase-client'
import { instance } from '../store'
import { reduce } from '@s-libs/micro-dash'
import { logger, type UpdateInstancePayload } from 'pockethost'
import { logger, type UpdateInstancePayload } from 'pockethost/common'
import Fa from 'svelte-fa'
import { faTrash } from '@fortawesome/free-solid-svg-icons'

View File

@ -1,6 +1,6 @@
<script lang="ts">
import PricingCard from '$src/routes/(static)/pricing/PricingCard.svelte'
import { PLAN_NAMES, SubscriptionType } from 'pockethost'
import { PLAN_NAMES, SubscriptionType } from 'pockethost/common'
import PricingTable from './PricingTable.svelte'
import { userStore } from '$util/stores'
import FlounderCard from '$src/routes/(app)/account/FlounderCard.svelte'

View File

@ -1 +0,0 @@
export * from './src/common'

View File

@ -1,2 +0,0 @@
export * from './src/common'
export * from './src/core'

View File

@ -6,8 +6,14 @@
"url": "https://github.com/benallfree"
},
"license": "MIT",
"main": "./common.ts",
"module": "./common.ts",
"exports": {
".": {
"import": "./src/index.ts"
},
"./common": {
"import": "./src/common/index.ts"
}
},
"type": "module",
"bin": {
"pockethost": "src/cli/index.ts"

View File

@ -1,14 +1,14 @@
import Dockerode from 'dockerode'
import { ErrorRequestHandler } from 'express'
import { logger } from '../../../../../common'
import {
MOTHERSHIP_ADMIN_PASSWORD,
MOTHERSHIP_ADMIN_USERNAME,
MOTHERSHIP_URL,
discordAlert,
logger,
neverendingPromise,
tryFetch,
} from '../../../../../core'
} from '../../../../..'
import {
DOCKER_INSTANCE_IMAGE_NAME,
MothershipAdminClientService,

View File

@ -1,5 +1,5 @@
import { Command } from 'commander'
import { logger } from '../../../../../../common'
import { logger } from '../../../../../common'
import { daemon } from './daemon'
type Options = {

View File

@ -4,6 +4,7 @@ import { spawn } from 'child_process'
import { Mode, constants, createReadStream, createWriteStream } from 'fs'
import { FileStat, FileSystem, FtpConnection } from 'ftp-srv'
import { dirname, isAbsolute, join, normalize, resolve, sep } from 'path'
import { DATA_ROOT } from '../../../../..'
import {
InstanceFields,
Logger,
@ -11,7 +12,6 @@ import {
assert,
seqid,
} from '../../../../../common'
import { DATA_ROOT } from '../../../../../core'
import {
InstanceLogWriter,
InstanceLogWriterApi,

View File

@ -1,11 +1,5 @@
import { readFileSync } from 'fs'
import { FtpSrv } from 'ftp-srv'
import {
PocketBase,
logger,
mergeConfig,
mkSingleton,
} from '../../../../../common'
import {
MOTHERSHIP_URL,
PH_FTP_PASV_IP,
@ -15,7 +9,13 @@ import {
SSL_CERT,
SSL_KEY,
asyncExitHook,
} from '../../../../../core'
} from '../../../../..'
import {
PocketBase,
logger,
mergeConfig,
mkSingleton,
} from '../../../../../common'
import { PhFs } from './PhFs'
export type FtpConfig = { mothershipUrl: string }

View File

@ -1,9 +1,5 @@
import { MOTHERSHIP_URL, neverendingPromise, tryFetch } from '../../../../..'
import { logger } from '../../../../../common'
import {
MOTHERSHIP_URL,
neverendingPromise,
tryFetch,
} from '../../../../../core'
import { ftpService } from '../FtpService'
export async function ftp() {

View File

@ -1,5 +1,5 @@
import { Command } from 'commander'
import { logger } from '../../../../../../common'
import { logger } from '../../../../../common'
import { ftp } from './ftp'
type Options = {

View File

@ -7,7 +7,6 @@ import fs from 'fs'
import http from 'http'
import { createProxyMiddleware } from 'http-proxy-middleware'
import https from 'https'
import { logger } from '../../../../../common/Logger'
import {
APEX_DOMAIN,
DAEMON_PORT,
@ -18,7 +17,8 @@ import {
neverendingPromise,
SSL_CERT,
SSL_KEY,
} from '../../../../../core'
} from '../../../../..'
import { logger } from '../../../../../common/Logger'
import { createIpWhitelistMiddleware } from './cidr'
import { createVhostProxyMiddleware } from './createVhostProxyMiddleware'

View File

@ -1,5 +1,5 @@
import { Command } from 'commander'
import { logger } from '../../../../common'
import { logger } from '../../../common'
import { ServeCommand } from './ServeCommand'
type Options = {

View File

@ -9,7 +9,7 @@ import {
LoggerService,
MOTHERSHIP_PORT,
stringify,
} from '../../../../core'
} from '../../..'
export const checkHealth = async () => {
const { cpu, drive } = osu

View File

@ -1,7 +1,6 @@
import { execSync } from 'child_process'
import { globSync } from 'glob'
import { DATA_ROOT } from '../../../../core'
import { logger } from '../../../common/Logger'
import { DATA_ROOT, logger } from '../../..'
export const compact = async () => {
const { info, error } = logger()

View File

@ -1,5 +1,5 @@
import { Command } from 'commander'
import { logger } from '../../../../core'
import { logger } from '../../..'
type Options = {
debug: boolean

View File

@ -5,7 +5,7 @@ import {
MOTHERSHIP_DATA_ROOT,
MOTHERSHIP_MIGRATIONS_DIR,
MOTHERSHIP_SEMVER,
} from '../../../../../core'
} from '../../../..'
import { GobotService } from '../../../../services/GobotService'
export async function schema() {

View File

@ -15,7 +15,7 @@ import {
TEST_EMAIL,
_MOTHERSHIP_APP_ROOT,
mkContainerHomePath,
} from '../../../../../core'
} from '../../../..'
import { GobotService } from '../../../../services/GobotService'
export type MothershipConfig = {}

View File

@ -5,7 +5,7 @@ import {
MOTHERSHIP_HOOKS_DIR,
PH_ALLOWED_POCKETBASE_SEMVER,
stringify,
} from '../../../../../core'
} from '../../../..'
import { GobotService } from '../../../../services/GobotService'
function compareSemVer(a: string, b: string): number {

View File

@ -2,14 +2,14 @@ import { map } from '@s-libs/micro-dash'
import Database from 'better-sqlite3'
import Bottleneck from 'bottleneck'
import { Command, InvalidArgumentError } from 'commander'
import { PocketBase, UserFields, logger } from '../../../common'
import {
MOTHERSHIP_ADMIN_PASSWORD,
MOTHERSHIP_ADMIN_USERNAME,
MOTHERSHIP_DATA_DB,
MOTHERSHIP_URL,
TEST_EMAIL,
} from '../../../core'
} from '../../..'
import { PocketBase, UserFields, logger } from '../../../common'
const TBL_SENT_MESSAGES = `sent_messages`

View File

@ -1,6 +1,6 @@
import { Command } from 'commander'
import { neverendingPromise } from '../../..'
import { logger } from '../../../common'
import { neverendingPromise } from '../../../core'
import { daemon } from '../EdgeCommand/DaemonCommand/ServeCommand/daemon'
import { firewall } from '../FirewallCommand/ServeCommand/firewall/server'
import { mothership } from '../MothershipCommand/ServeCommand/mothership'

View File

@ -2,7 +2,7 @@
import { program } from 'commander'
import EventSource from 'eventsource'
import { LogLevelName, gracefulExit, logger } from '../../core'
import { LogLevelName, gracefulExit, logger } from '..'
import { version } from '../../package.json'
import { EdgeCommand } from './commands/EdgeCommand'
import { FirewallCommand } from './commands/FirewallCommand'

View File

@ -1,7 +1,7 @@
import { WinstonLoggerService } from '..'
import { version } from '../../package.json'
import { ioc } from '../common'
import { RegisterEnvSettingsService } from '../constants'
import { WinstonLoggerService } from '../core/winston'
import { GobotService } from '../services/GobotService'
export const initIoc = async () => {

View File

@ -12,15 +12,13 @@ import {
SettingsHandlerFactory,
SettingsService,
ioc,
} from '../core'
import {
mkBoolean,
mkCsvString,
mkNumber,
mkPath,
mkString,
} from './core/Settings'
import { settings } from './core/ioc'
settings,
} from '.'
const __dirname = dirname(fileURLToPath(import.meta.url))

View File

@ -5,7 +5,9 @@ export * from './discordAlert'
export * from './env'
export * from './exit'
export * from './internal'
export * from './ioc'
export * from './process'
export * from './Settings'
export * from './smartFetch'
export * from './tryFetch'
export * from './winston'

View File

@ -1 +1,2 @@
export * from './common'
export * from './core'

View File

@ -5,7 +5,7 @@ import {
LoggerService,
mkInstanceDataPath,
stringify,
} from '../../../core'
} from '../..'
type UnsubFunc = () => void

View File

@ -23,7 +23,7 @@ import {
now,
stringify,
tryFetch,
} from '../../../core'
} from '../..'
import {
InstanceLogWriter,
MothershipAdminClientService,

View File

@ -8,7 +8,7 @@ import {
PocketBase,
UserFields,
UserId,
} from '../../../core'
} from '../..'
export const mkInstanceCache = (client: PocketBase) => {
const { dbg } = LoggerService().create(`InstanceCache`)

View File

@ -6,7 +6,7 @@ import {
InstanceId,
InstanceStatus,
WithUser,
} from '../../../core'
} from '../..'
export type InstanceApi = ReturnType<typeof createInstanceMixin>

View File

@ -9,7 +9,7 @@ import {
RestMethods,
createRestHelper,
stringify,
} from '../../../core'
} from '../..'
import { createInstanceMixin } from './InstanceMIxin'
export type PocketbaseClientApi = ReturnType<typeof createAdminPbClient>

View File

@ -7,7 +7,7 @@ import {
PocketBase,
mergeConfig,
mkSingleton,
} from '../../../core'
} from '../..'
import { createAdminPbClient } from './createAdminPbClient'
export type ClientServiceConfig = {

View File

@ -15,7 +15,7 @@ import {
mkInstanceDataPath,
mkInternalUrl,
mkSingleton,
} from '../../../core'
} from '../..'
import { GobotService } from '../GobotService'
import { InstanceLogWriter } from '../InstanceLoggerService'

View File

@ -11,7 +11,7 @@ import {
asyncExitHook,
mkSingleton,
seqid,
} from '../../core'
} from '..'
export type ProxyServiceApi = AsyncReturnType<typeof proxyService>

View File

@ -7,7 +7,7 @@ import {
PocketBase,
SingletonBaseConfig,
stringify,
} from '../../core'
} from '..'
import { InstanceLogReader } from './InstanceLoggerService'
import { proxyService } from './ProxyService'