@1sat/cli 0.0.53 → 0.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1sat/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.54",
|
|
4
4
|
"description": "CLI for 1Sat Ordinals SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/cli.ts",
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@1sat/actions": "0.0.117",
|
|
29
29
|
"@1sat/client": "0.0.27",
|
|
30
|
-
"@1sat/knex-bun-sqlite": "0.0.1",
|
|
31
30
|
"@1sat/types": "0.0.19",
|
|
32
31
|
"@1sat/wallet-node": "0.0.43",
|
|
33
32
|
"@1sat/wallet-server": "0.0.13",
|
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
* `1sat serve messagebox` — launch the BSV message-box server using the
|
|
3
3
|
* CLI's wallet identity.
|
|
4
4
|
*
|
|
5
|
-
* Storage mirrors the wallet's choice: SQLite via `@1sat/knex-bun-sqlite`
|
|
6
|
-
* when wallet storage is `bun-sqlite`, Postgres when wallet storage is `pg`.
|
|
7
|
-
*
|
|
8
5
|
* messagebox-server boots itself as a side effect of `import` once env vars
|
|
9
6
|
* are populated, so this handler:
|
|
10
7
|
* 1. Reads CLI config + private key
|
|
11
8
|
* 2. Composes env (SERVER_PRIVATE_KEY, PORT, KNEX_DB_*, WALLET_STORAGE_URL, …)
|
|
12
|
-
* 3.
|
|
13
|
-
*
|
|
9
|
+
* 3. Switches cwd to the messagebox-server install dir so its knexfile's
|
|
10
|
+
* relative `./out/src/migrations` path resolves correctly
|
|
11
|
+
* 4. Dynamically imports `@bopen-io/messagebox-server`
|
|
12
|
+
* 5. Awaits SIGINT/SIGTERM, then closes the HTTP and WebSocket servers
|
|
14
13
|
*/
|
|
15
14
|
|
|
16
|
-
import { join } from 'node:path'
|
|
15
|
+
import { dirname, join } from 'node:path'
|
|
17
16
|
import { fileURLToPath } from 'node:url'
|
|
18
17
|
import type { PrivateKey } from '@bsv/sdk'
|
|
19
18
|
import type { GlobalFlags } from '../args'
|
|
@@ -65,33 +64,14 @@ export async function startMessagebox(
|
|
|
65
64
|
`[messagebox] websockets: ${resolved.websockets ? 'enabled' : 'disabled'}`,
|
|
66
65
|
)
|
|
67
66
|
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
)
|
|
77
|
-
const migrationsDir = fileURLToPath(new URL('src/migrations/', knexfileUrl))
|
|
78
|
-
const [knexfile, dialect] = await Promise.all([
|
|
79
|
-
import('@bopen-io/messagebox-server/out/knexfile.js') as Promise<{
|
|
80
|
-
default: Record<
|
|
81
|
-
string,
|
|
82
|
-
{ client: unknown; migrations?: { directory: string } }
|
|
83
|
-
>
|
|
84
|
-
}>,
|
|
85
|
-
import('@1sat/knex-bun-sqlite'),
|
|
86
|
-
])
|
|
87
|
-
const Client = dialect.default
|
|
88
|
-
for (const env of ['development', 'staging', 'production']) {
|
|
89
|
-
const cfg = knexfile.default[env]
|
|
90
|
-
if (!cfg) continue
|
|
91
|
-
cfg.client = Client
|
|
92
|
-
if (cfg.migrations) cfg.migrations.directory = migrationsDir
|
|
93
|
-
}
|
|
94
|
-
}
|
|
67
|
+
// messagebox-server's knexfile uses `./out/src/migrations` relative to
|
|
68
|
+
// cwd. Switch cwd to its install dir so that path resolves correctly
|
|
69
|
+
// regardless of where the CLI was invoked from.
|
|
70
|
+
const packageJsonUrl = import.meta.resolve(
|
|
71
|
+
'@bopen-io/messagebox-server/package.json',
|
|
72
|
+
)
|
|
73
|
+
const messageboxDir = dirname(fileURLToPath(packageJsonUrl))
|
|
74
|
+
process.chdir(messageboxDir)
|
|
95
75
|
|
|
96
76
|
// messagebox-server boots itself when its index module is loaded.
|
|
97
77
|
const mbox = (await import(
|
|
@@ -8,8 +8,3 @@ declare module '@bopen-io/messagebox-server' {
|
|
|
8
8
|
export const ROUTING_PREFIX: string
|
|
9
9
|
export function start(): Promise<void>
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
declare module '@bopen-io/messagebox-server/out/knexfile.js' {
|
|
13
|
-
const knexfile: Record<string, { client: unknown; [k: string]: unknown }>
|
|
14
|
-
export default knexfile
|
|
15
|
-
}
|