poon-choi 0.0.5 → 1.0.1

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "date": "2026-11-16T07:10:58.154Z",
2
+ "date": "2026-11-16T10:04:07.917Z",
3
3
  "preset": "node-server",
4
4
  "framework": {
5
5
  "name": "nitro",
@@ -13,35 +13,35 @@ var public_assets_data_default = {
13
13
  "/assets/about-D4e6L2RX.js": {
14
14
  "type": "text/javascript; charset=utf-8",
15
15
  "etag": "\"2d3-K/Mk8Xwun59XEuZOXW4FszGlmCo\"",
16
- "mtime": "2026-11-16T07:10:57.598Z",
16
+ "mtime": "2026-11-16T10:04:07.361Z",
17
17
  "size": 723,
18
18
  "path": "../public/assets/about-D4e6L2RX.js"
19
19
  },
20
20
  "/assets/index-B6P0kA2f.css": {
21
21
  "type": "text/css; charset=utf-8",
22
22
  "etag": "\"ebc-+E2ER+la0niWYHOeTJb/km1hZ3g\"",
23
- "mtime": "2026-11-16T07:10:57.599Z",
23
+ "mtime": "2026-11-16T10:04:07.362Z",
24
24
  "size": 3772,
25
25
  "path": "../public/assets/index-B6P0kA2f.css"
26
26
  },
27
- "/assets/styles-DqQrEVt_.css": {
28
- "type": "text/css; charset=utf-8",
29
- "etag": "\"65ac-bZPVDa9/uqOQex/J0MEvk6xdijI\"",
30
- "mtime": "2026-11-16T07:10:57.600Z",
31
- "size": 26028,
32
- "path": "../public/assets/styles-DqQrEVt_.css"
33
- },
34
27
  "/assets/routes-BgrRSMVP.js": {
35
28
  "type": "text/javascript; charset=utf-8",
36
29
  "etag": "\"9cab-F1HqYvl8HqsqA3IdMdtqy0sjW/4\"",
37
- "mtime": "2026-11-16T07:10:57.599Z",
30
+ "mtime": "2026-11-16T10:04:07.361Z",
38
31
  "size": 40107,
39
32
  "path": "../public/assets/routes-BgrRSMVP.js"
40
33
  },
34
+ "/assets/styles-DqQrEVt_.css": {
35
+ "type": "text/css; charset=utf-8",
36
+ "etag": "\"65ac-bZPVDa9/uqOQex/J0MEvk6xdijI\"",
37
+ "mtime": "2026-11-16T10:04:07.362Z",
38
+ "size": 26028,
39
+ "path": "../public/assets/styles-DqQrEVt_.css"
40
+ },
41
41
  "/assets/index-CdiJXXIG.js": {
42
42
  "type": "text/javascript; charset=utf-8",
43
43
  "etag": "\"54f38-+c8k8UEQVPFuHY4Mod+ogEthzBI\"",
44
- "mtime": "2026-11-16T07:10:57.598Z",
44
+ "mtime": "2026-11-16T10:04:07.361Z",
45
45
  "size": 347960,
46
46
  "path": "../public/assets/index-CdiJXXIG.js"
47
47
  }
package/README.md CHANGED
@@ -10,6 +10,7 @@ English | [中文](./README.zh.md)
10
10
 
11
11
  [![npm version](https://img.shields.io/npm/v/poon-choi.svg)](https://www.npmjs.com/package/poon-choi)
12
12
  [![npm downloads](https://img.shields.io/npm/dm/poon-choi.svg)](https://www.npmjs.com/package/poon-choi)
13
+ [![0 dependencies](https://img.shields.io/badge/0-green?logo=npm&labelColor=blue&label=dependencies&color=green)](https://www.npmjs.com/package/poon-choi?activeTab=dependencies)
13
14
 
14
15
  **poon-choi** (盆菜) is a Cantonese dish where many ingredients are stacked in one basin and shared from the top down. This tool does the same for images: drop in 1–6 pictures, and it plates them into a single **2.35:1 WeChat cover (900×383)**, plus a **1:1 thumbnail (383×383)**.
15
16
 
package/README.zh.md CHANGED
@@ -10,6 +10,7 @@
10
10
 
11
11
  [![npm version](https://img.shields.io/npm/v/poon-choi.svg)](https://www.npmjs.com/package/poon-choi)
12
12
  [![npm downloads](https://img.shields.io/npm/dm/poon-choi.svg)](https://www.npmjs.com/package/poon-choi)
13
+ [![0 dependencies](https://img.shields.io/badge/0-green?logo=npm&labelColor=blue&label=dependencies&color=green)](https://www.npmjs.com/package/poon-choi?activeTab=dependencies)
13
14
 
14
15
  **poon-choi(盆菜)** 是一道粤菜,多种食材码在同一个盆里,由上至下享用。这个工具也是同理:放入 1–6 张图片,它会自动拼出一张 **2.35:1 的微信封面(900×383)**,同时生成一张 **1:1 的缩略图(383×383)**。
15
16
 
package/bin/cli.ts CHANGED
@@ -2,13 +2,27 @@
2
2
 
3
3
  // vite dev --port 3000
4
4
 
5
- import { spawn } from 'node:child_process';
6
- import { parseArgs } from 'node:util';
7
- import { version, name } from '../package.json';
5
+ import net from 'node:net';
6
+ import { spawn, spawnSync } from 'node:child_process';
7
+ import { parseArgs, styleText } from 'node:util';
8
+ import pkg from '../package.json' with { type: 'json' };
9
+ import { join } from 'node:path';
10
+
11
+ // console.log('pkg:', pkg);
12
+
13
+ const { version, name, description } = pkg;
14
+
15
+ const check = (port: number) =>
16
+ new Promise((res) => {
17
+ const s = net.createServer();
18
+ s.once('error', (e) => res(e.code === 'EADDRINUSE'));
19
+ s.once('listening', () => s.close(() => res(false)));
20
+ s.listen(port);
21
+ });
8
22
 
9
23
  main();
10
24
 
11
- function main() {
25
+ async function main() {
12
26
  const { values } = parseArgs({
13
27
  options: {
14
28
  port: {
@@ -16,11 +30,14 @@ function main() {
16
30
  type: 'string',
17
31
  default: '3000',
18
32
  },
19
-
20
33
  version: {
21
34
  short: 'v',
22
35
  type: 'boolean',
23
- }
36
+ },
37
+ help: {
38
+ short: 'h',
39
+ type: 'boolean',
40
+ },
24
41
  },
25
42
  });
26
43
 
@@ -28,25 +45,61 @@ function main() {
28
45
 
29
46
  const port = Number(values.port);
30
47
  // validate port in a valid range
31
- const valid = port >= 1024 && port <= 65535
48
+ const valid = port >= 1024 && port <= 65535;
49
+
32
50
  if (!valid) {
33
- console.error(`Invalid port number ${values.port}, should be between 1024 and 65535`);
34
- process.exitCode =1;
51
+ console.error(
52
+ `Invalid port number ${values.port}, should be between 1024 and 65535`
53
+ );
54
+ process.exitCode = 1;
35
55
 
36
- return
56
+ return;
37
57
  }
38
58
 
39
- if (true || values.version) {
40
- console.log(`\n${name} v${version}\n\n---\n`);
41
- // return;
59
+ if (values.version || values.help) {
60
+ printHelp(!!values.help);
61
+ return;
42
62
  }
43
63
 
44
- spawn('node', ['.output/server/index.mjs'], {
64
+ console.log(`\n${name} v${version}\n\n---\n`);
65
+
66
+ if (await check(port)) {
67
+ console.error(
68
+ 'port',
69
+ styleText('red', values.port),
70
+ 'in use, try another one.'
71
+ );
72
+ process.exitCode = 1;
73
+
74
+ return;
75
+ }
76
+
77
+ const dirname = import.meta.dirname;
78
+
79
+ spawnSync('node', [join(dirname, '../.output/server/index.mjs')], {
45
80
  stdio: 'inherit',
46
- shell: true,
81
+ // shell: true,
47
82
  env: {
48
83
  ...process.env,
49
84
  PORT: values.port,
50
- }
51
- })
52
- }
85
+ },
86
+ });
87
+ }
88
+
89
+ function printHelp(verbose: boolean) {
90
+ console.log(`\n${name} v${version}`);
91
+
92
+ if (!verbose) {
93
+ return;
94
+ }
95
+
96
+ console.log();
97
+ console.log('>', styleText('green', description), '\n');
98
+
99
+ console.log('Usage: npx poon-choi [options]');
100
+ console.log();
101
+ console.log('Options:');
102
+ console.log(' -p, --port <port> Port to run the server on (default: 3000)');
103
+ console.log(' -v, --version Print version number');
104
+ console.log(' -h, --help Print this help message');
105
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poon-choi",
3
- "version": "0.0.5",
3
+ "version": "1.0.1",
4
4
  "description": "poon-choi 🍲 is a wechat-cover-studio: a cover mosaic tool to generate wechat (2.35:1) cover image using multiple images.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -21,7 +21,7 @@
21
21
  "pub:minor": "npm version minor",
22
22
  "pub:major": "npm version major",
23
23
  "preversion": "cd wechat-cover-studio && npm test && npm run build",
24
- "postversion": "npm publish && git commit -m \"chore: publish\" package.json && git push && git push --tags"
24
+ "postversion": "npm publish && git push && git push --tags"
25
25
  },
26
26
  "dependencies": {},
27
27
  "devDependencies": {},
@@ -30,7 +30,7 @@
30
30
  "type": "git",
31
31
  "url": "git+https://github.com/legend80s/wechat-cover-studio-poon-choi.git"
32
32
  },
33
- "homepage": "https://github.com/legend80s/wechat-cover-studio-poon-choi/blob/main/wechat-cover-studio/README.md",
33
+ "homepage": "https://github.com/legend80s/wechat-cover-studio-poon-choi",
34
34
  "keywords": [
35
35
  "wechat",
36
36
  "cover",