kubun 0.3.4 → 0.4.0

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/README.md CHANGED
@@ -20,7 +20,7 @@ $ npm install -g kubun
20
20
  $ kubun COMMAND
21
21
  running command...
22
22
  $ kubun (--version)
23
- kubun/0.3.4 darwin-arm64 node-v24.12.0
23
+ kubun/0.4.0 darwin-arm64 node-v24.12.0
24
24
  $ kubun --help [COMMAND]
25
25
  USAGE
26
26
  $ kubun COMMAND
@@ -509,11 +509,14 @@ Start a local Kubun server
509
509
 
510
510
  ```
511
511
  USAGE
512
- $ kubun serve [-a <value>] [--db <value>] [-p <value>] [-k <value> | --id <value>]
512
+ $ kubun serve [-a <value>] [--db <value>] [-l trace|debug|info|warning|error|fatal] [-p <value>] [-k
513
+ <value> | --id <value>]
513
514
 
514
515
  FLAGS
515
516
  -a, --allowedOrigin=<value> [default: *, env: KUBUN_ALLOWED_ORIGIN] allowed HTTP origin
516
517
  -k, --privateKey=<value> [env: KUBUN_PRIVATE_KEY] base64-encoded private key
518
+ -l, --logLevel=<option> [default: warning] log level
519
+ <options: trace|debug|info|warning|error|fatal>
517
520
  -p, --port=<value> port to listen on
518
521
  --db=<value> path to the local SQLite database
519
522
  --id=<value> server ID
@@ -7,7 +7,9 @@ import { serve as serveHTTP } from '@hono/node-server';
7
7
  import { KubunDB } from '@kubun/db';
8
8
  import { PostgresAdapter } from '@kubun/db-postgres';
9
9
  import { SQLiteAdapter } from '@kubun/db-sqlite';
10
+ import { getKubunLogger } from '@kubun/logger';
10
11
  import { createHandlers } from '@kubun/server';
12
+ import { configureSync, getConsoleSink, getLogLevels } from '@logtape/logtape';
11
13
  import { Command, Flags } from '@oclif/core';
12
14
  import getPort from 'get-port';
13
15
  import ora from 'ora';
@@ -16,9 +18,20 @@ import { resolvePath } from '../fs.js';
16
18
  export default class Serve extends Command {
17
19
  static description = 'Start a local Kubun server';
18
20
  static flags = {
19
- allowedOrigin: Flags.string({ char: 'a', description: 'allowed HTTP origin', env: 'KUBUN_ALLOWED_ORIGIN', default: '*' }),
21
+ allowedOrigin: Flags.string({
22
+ char: 'a',
23
+ description: 'allowed HTTP origin',
24
+ env: 'KUBUN_ALLOWED_ORIGIN',
25
+ default: '*',
26
+ }),
20
27
  db: Flags.file({ description: 'path to the local SQLite database' }),
21
28
  id: Flags.string({ description: 'server ID' }),
29
+ logLevel: Flags.string({
30
+ char: 'l',
31
+ description: 'log level',
32
+ options: getLogLevels(),
33
+ default: 'warning',
34
+ }),
22
35
  port: Flags.integer({ char: 'p', description: 'port to listen on' }),
23
36
  privateKey: Flags.string({
24
37
  char: 'k',
@@ -60,13 +73,24 @@ export default class Serve extends Command {
60
73
  db = new KubunDB({ adapter: new SQLiteAdapter({ database }) });
61
74
  spinner.info(`Using local SQLite database: ${database}`);
62
75
  }
76
+ configureSync({
77
+ sinks: { console: getConsoleSink() },
78
+ loggers: [
79
+ { category: ['logtape', 'meta'], lowestLevel: 'error', sinks: ['console'] },
80
+ { category: ['kubun'], lowestLevel: flags.logLevel, sinks: ['console'] },
81
+ ],
82
+ });
63
83
  const allowedOrigin = flags.allowedOrigin.split(',').map((origin) => origin.trim());
64
84
  const transport = new ServerTransport({ allowedOrigin });
65
- serve({ handlers: createHandlers({ db }), id, transport });
66
- spinner.start(`Starting the server with allowed origin: ${allowedOrigin.join(', ')}`);
85
+ serve({
86
+ handlers: createHandlers({ db, logger: getKubunLogger('server') }),
87
+ id,
88
+ transport,
89
+ });
90
+ spinner.start('Starting the server...');
67
91
  const port = flags.port ?? (await getPort({ port: 4321 }));
68
92
  const httpServer = serveHTTP({ fetch: transport.fetch, port }, (info) => {
69
- spinner.succeed(`HTTP server listening on port ${info.port}`);
93
+ spinner.succeed(`HTTP server listening on port ${info.port} with allowed origin: ${allowedOrigin.join(', ')}`);
70
94
  });
71
95
  const stopped = defer();
72
96
  async function stop() {
@@ -29,6 +29,23 @@
29
29
  "multiple": false,
30
30
  "type": "option"
31
31
  },
32
+ "logLevel": {
33
+ "char": "l",
34
+ "description": "log level",
35
+ "name": "logLevel",
36
+ "default": "warning",
37
+ "hasDynamicHelp": false,
38
+ "multiple": false,
39
+ "options": [
40
+ "trace",
41
+ "debug",
42
+ "info",
43
+ "warning",
44
+ "error",
45
+ "fatal"
46
+ ],
47
+ "type": "option"
48
+ },
32
49
  "port": {
33
50
  "char": "p",
34
51
  "description": "port to listen on",
@@ -295,6 +312,45 @@
295
312
  "query.js"
296
313
  ]
297
314
  },
315
+ "graphql:schema": {
316
+ "aliases": [],
317
+ "args": {},
318
+ "description": "Create a GraphQL schema from clusters of document models",
319
+ "flags": {
320
+ "cluster": {
321
+ "char": "c",
322
+ "description": "path of the JSON file of the cluster",
323
+ "name": "cluster",
324
+ "required": true,
325
+ "hasDynamicHelp": false,
326
+ "multiple": true,
327
+ "type": "option"
328
+ },
329
+ "output": {
330
+ "char": "o",
331
+ "description": "output file for the GraphQL schema",
332
+ "name": "output",
333
+ "hasDynamicHelp": false,
334
+ "multiple": false,
335
+ "type": "option"
336
+ }
337
+ },
338
+ "hasDynamicHelp": false,
339
+ "hiddenAliases": [],
340
+ "id": "graphql:schema",
341
+ "pluginAlias": "kubun",
342
+ "pluginName": "kubun",
343
+ "pluginType": "core",
344
+ "strict": true,
345
+ "enableJsonFlag": false,
346
+ "isESM": true,
347
+ "relativePath": [
348
+ "dist",
349
+ "commands",
350
+ "graphql",
351
+ "schema.js"
352
+ ]
353
+ },
298
354
  "model:cluster": {
299
355
  "aliases": [],
300
356
  "args": {},
@@ -403,46 +459,7 @@
403
459
  "model",
404
460
  "create.js"
405
461
  ]
406
- },
407
- "graphql:schema": {
408
- "aliases": [],
409
- "args": {},
410
- "description": "Create a GraphQL schema from clusters of document models",
411
- "flags": {
412
- "cluster": {
413
- "char": "c",
414
- "description": "path of the JSON file of the cluster",
415
- "name": "cluster",
416
- "required": true,
417
- "hasDynamicHelp": false,
418
- "multiple": true,
419
- "type": "option"
420
- },
421
- "output": {
422
- "char": "o",
423
- "description": "output file for the GraphQL schema",
424
- "name": "output",
425
- "hasDynamicHelp": false,
426
- "multiple": false,
427
- "type": "option"
428
- }
429
- },
430
- "hasDynamicHelp": false,
431
- "hiddenAliases": [],
432
- "id": "graphql:schema",
433
- "pluginAlias": "kubun",
434
- "pluginName": "kubun",
435
- "pluginType": "core",
436
- "strict": true,
437
- "enableJsonFlag": false,
438
- "isESM": true,
439
- "relativePath": [
440
- "dist",
441
- "commands",
442
- "graphql",
443
- "schema.js"
444
- ]
445
462
  }
446
463
  },
447
- "version": "0.3.4"
464
+ "version": "0.4.0"
448
465
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kubun",
3
- "version": "0.3.4",
3
+ "version": "0.4.0",
4
4
  "license": "see LICENSE.md",
5
5
  "description": "Kubun CLI",
6
6
  "keywords": [],
@@ -40,24 +40,26 @@
40
40
  "@enkaku/server": "^0.12.2",
41
41
  "@enkaku/token": "0.12.3",
42
42
  "@hono/node-server": "^1.19.8",
43
+ "@logtape/logtape": "^1.3.6",
43
44
  "@oclif/core": "^4.8.0",
44
45
  "@oclif/plugin-help": "^6.2.36",
45
46
  "@oclif/plugin-plugins": "^5.4.54",
46
47
  "get-port": "^7.1.0",
47
48
  "graphql": "^16.12.0",
48
49
  "ora": "^9.0.0",
49
- "@kubun/db": "^0.3.7",
50
- "@kubun/db-postgres": "^0.3.2",
51
- "@kubun/graphql": "^0.3.14",
52
- "@kubun/db-sqlite": "^0.3.4",
53
- "@kubun/http-client": "^0.3.1",
54
- "@kubun/server": "^0.3.13",
55
- "@kubun/client": "^0.3.8",
56
- "@kubun/protocol": "^0.3.11"
50
+ "@kubun/client": "^0.4.0",
51
+ "@kubun/db-postgres": "^0.4.0",
52
+ "@kubun/db-sqlite": "^0.4.0",
53
+ "@kubun/graphql": "^0.4.0",
54
+ "@kubun/db": "^0.4.0",
55
+ "@kubun/http-client": "^0.4.0",
56
+ "@kubun/logger": "^0.4.0",
57
+ "@kubun/protocol": "^0.4.0",
58
+ "@kubun/server": "^0.4.0"
57
59
  },
58
60
  "devDependencies": {
59
61
  "@oclif/test": "^4.1.15",
60
- "oclif": "^4.22.63",
62
+ "oclif": "^4.22.65",
61
63
  "shx": "^0.4.0",
62
64
  "ts-node": "^10",
63
65
  "typescript": "^5.9.3"