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", "mothership",
"multitenancy", "multitenancy",
"multitenant", "multitenant",
"neverending",
"noaxis", "noaxis",
"nofile", "nofile",
"nohup", "nohup",

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@
import { client } from '$src/pocketbase-client' import { client } from '$src/pocketbase-client'
import { instance } from '../store' import { instance } from '../store'
import { reduce } from '@s-libs/micro-dash' 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 Fa from 'svelte-fa'
import { faTrash } from '@fortawesome/free-solid-svg-icons' import { faTrash } from '@fortawesome/free-solid-svg-icons'

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import PricingCard from '$src/routes/(static)/pricing/PricingCard.svelte' 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 PricingTable from './PricingTable.svelte'
import { userStore } from '$util/stores' import { userStore } from '$util/stores'
import FlounderCard from '$src/routes/(app)/account/FlounderCard.svelte' 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" "url": "https://github.com/benallfree"
}, },
"license": "MIT", "license": "MIT",
"main": "./common.ts", "exports": {
"module": "./common.ts", ".": {
"import": "./src/index.ts"
},
"./common": {
"import": "./src/common/index.ts"
}
},
"type": "module", "type": "module",
"bin": { "bin": {
"pockethost": "src/cli/index.ts" "pockethost": "src/cli/index.ts"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@ import {
MOTHERSHIP_HOOKS_DIR, MOTHERSHIP_HOOKS_DIR,
PH_ALLOWED_POCKETBASE_SEMVER, PH_ALLOWED_POCKETBASE_SEMVER,
stringify, stringify,
} from '../../../../../core' } from '../../../..'
import { GobotService } from '../../../../services/GobotService' import { GobotService } from '../../../../services/GobotService'
function compareSemVer(a: string, b: string): number { 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 Database from 'better-sqlite3'
import Bottleneck from 'bottleneck' import Bottleneck from 'bottleneck'
import { Command, InvalidArgumentError } from 'commander' import { Command, InvalidArgumentError } from 'commander'
import { PocketBase, UserFields, logger } from '../../../common'
import { import {
MOTHERSHIP_ADMIN_PASSWORD, MOTHERSHIP_ADMIN_PASSWORD,
MOTHERSHIP_ADMIN_USERNAME, MOTHERSHIP_ADMIN_USERNAME,
MOTHERSHIP_DATA_DB, MOTHERSHIP_DATA_DB,
MOTHERSHIP_URL, MOTHERSHIP_URL,
TEST_EMAIL, TEST_EMAIL,
} from '../../../core' } from '../../..'
import { PocketBase, UserFields, logger } from '../../../common'
const TBL_SENT_MESSAGES = `sent_messages` const TBL_SENT_MESSAGES = `sent_messages`

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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