@hile/cli 1.0.22 → 1.1.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
@@ -104,7 +104,7 @@ HILE_RUNTIME_DIR=./custom hile start
104
104
  import { defineService, loadService } from '@hile/core'
105
105
  import { configService } from './services/config'
106
106
 
107
- export default defineService(async (shutdown) => {
107
+ export default defineService('http', async (shutdown) => {
108
108
  const config = await loadService(configService)
109
109
  const pool = await createPool(config.dbUrl)
110
110
  shutdown(() => pool.end())
package/dist/index.js CHANGED
@@ -16,8 +16,13 @@ program.version(pkg.version, '-v, --version', '当前版本号');
16
16
  program
17
17
  .command('start')
18
18
  .option('-d, --dev', '开发模式', false)
19
+ .option('-s, --silent', '静默模式', false)
19
20
  .option('-e, --env-file <path>', '加载指定 env 文件(兼容 Node --env-file 语义;可多次指定,先加载的不被后加载覆盖)', (v, acc) => (acc.push(v), acc), [])
20
21
  .description('启动服务,加载所有后缀为 boot.ts 或 boot.js 的服务,并注册退出钩子,在进程退出时销毁所有服务')
21
- .action((options) => start({ dev: options.dev, envFile: options.envFile }));
22
+ .action((options) => start({
23
+ dev: options.dev,
24
+ envFile: options.envFile,
25
+ silent: options.silent
26
+ }));
22
27
  program.parseAsync(process.argv);
23
28
  export * from './start.js';
package/dist/start.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare function start(options: {
2
2
  dev: boolean;
3
3
  envFile?: string[];
4
+ silent?: boolean;
4
5
  }): Promise<void>;
package/dist/start.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { registerExitHook } from './exitHook.js';
2
2
  import { glob } from 'glob';
3
3
  import { resolve } from 'node:path';
4
- import { container, isService, loadService } from '@hile/core';
4
+ import { container, formatServiceKey, isService, loadService } from '@hile/core';
5
5
  import { createRequire } from 'node:module';
6
6
  import { pathToFileURL } from 'node:url';
7
7
  const require = createRequire(import.meta.url);
@@ -29,23 +29,23 @@ function logContainerEvent(event) {
29
29
  const dim = (s) => (colorize ? `${c.dim}${s}${c.reset}` : s);
30
30
  switch (event.type) {
31
31
  case 'service:init':
32
- console.info(`${tag} ${target(`service#${event.id}`)} ${dim('init')}`);
32
+ console.info(`${tag} ${target(`service(${formatServiceKey(event.key)})`)} ${dim('init')}`);
33
33
  break;
34
34
  case 'service:ready':
35
- console.info(`${tag} ${target(`service#${event.id}`)} ${ok('ready')} ${dim(`(${event.durationMs}ms)`)}`);
35
+ console.info(`${tag} ${target(`service(${formatServiceKey(event.key)})`)} ${ok('ready')} ${dim(`(${event.durationMs}ms)`)}`);
36
36
  break;
37
37
  case 'service:error':
38
- console.error(`${tag} ${target(`service#${event.id}`)} ${err('failed')} ${dim(`(${event.durationMs}ms)`)}`);
38
+ console.error(`${tag} ${target(`service(${formatServiceKey(event.key)})`)} ${err('failed')} ${dim(`(${event.durationMs}ms)`)}`);
39
39
  console.error(event.error);
40
40
  break;
41
41
  case 'service:shutdown:start':
42
- console.info(`${tag} ${target(`service#${event.id}`)} ${warn('stopping')}`);
42
+ console.info(`${tag} ${target(`service(${formatServiceKey(event.key)})`)} ${warn('stopping')}`);
43
43
  break;
44
44
  case 'service:shutdown:done':
45
- console.info(`${tag} ${target(`service#${event.id}`)} ${dim('stopped')} ${dim(`(${event.durationMs}ms)`)}`);
45
+ console.info(`${tag} ${target(`service(${formatServiceKey(event.key)})`)} ${dim('stopped')} ${dim(`(${event.durationMs}ms)`)}`);
46
46
  break;
47
47
  case 'service:shutdown:error':
48
- console.error(`${tag} ${target(`service#${event.id}`)} ${err('shutdown error')}`);
48
+ console.error(`${tag} ${target(`service(${formatServiceKey(event.key)})`)} ${err('shutdown error')}`);
49
49
  console.error(event.error);
50
50
  break;
51
51
  case 'container:shutdown:start':
@@ -74,7 +74,7 @@ export async function start(options) {
74
74
  else {
75
75
  process.env.NODE_ENV = 'production';
76
76
  }
77
- const offEvent = process.env.NODE_ENV === 'development'
77
+ const offEvent = !options.silent && process.env.NODE_ENV === 'development'
78
78
  ? container.on(logContainerEvent)
79
79
  : () => { };
80
80
  const cwd = process.cwd();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hile/cli",
3
- "version": "1.0.22",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -25,11 +25,11 @@
25
25
  "vitest": "^4.0.18"
26
26
  },
27
27
  "dependencies": {
28
- "@hile/core": "^1.0.22",
28
+ "@hile/core": "^1.1.0",
29
29
  "async-exit-hook": "^2.0.1",
30
30
  "commander": "^14.0.3",
31
31
  "glob": "^13.0.6",
32
32
  "tsx": "^4.21.0"
33
33
  },
34
- "gitHead": "4ad0c56518461cbcc48c1dfe2fcb667303c5c889"
34
+ "gitHead": "ec49eb8979b6c9c3ce99cb5311f1684bcde1bf2a"
35
35
  }