yuangs 1.0.1 → 1.0.3

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.
Files changed (4) hide show
  1. package/README.md +20 -20
  2. package/cli.js +52 -0
  3. package/index.js +5 -33
  4. package/package.json +11 -5
package/README.md CHANGED
@@ -1,35 +1,35 @@
1
- # yuangs
1
+ # yuangs CLI
2
2
 
3
- 苑广山的个人工具箱与应用导航。
3
+ 🎨 YGS 的个人命令行工具(彩色版)
4
4
 
5
5
  ## 安装
6
6
 
7
+ 全局安装以在终端任何位置使用:
8
+
7
9
  ```bash
8
- npm install yuangs
10
+ npm install -g yuangs
9
11
  ```
10
12
 
11
- ## 功能
12
-
13
- 包含以下个人应用的快捷访问:
13
+ ## 使用命令
14
14
 
15
- 1. **古诗词 PWA**: [https://wealth.want.biz/shici/index.html](https://wealth.want.biz/shici/index.html)
16
- 2. **英语词典**: [https://wealth.want.biz/pages/dict.html](https://wealth.want.biz/pages/dict.html)
17
- 3. **Pong 游戏**: [https://wealth.want.biz/pages/pong.html](https://wealth.want.biz/pages/pong.html)
15
+ ```bash
16
+ yuangs shici # 打开古诗词 PWA
17
+ yuangs dict # 打开英语词典
18
+ yuangs pong # 打开 Pong 游戏
19
+ yuangs list # 列出所有链接
20
+ yuangs help # 显示帮助
21
+ ```
18
22
 
19
- ## 使用方法
23
+ ## 新特性 (v1.0.3)
20
24
 
21
- ```javascript
22
- const yuangs = require("yuangs");
25
+ ✨ 彩色终端输出,更美观易读!
23
26
 
24
- // 1. 列出所有应用
25
- yuangs.listApps();
27
+ ## 应用列表
26
28
 
27
- // 2. 在浏览器中打开应用 (支持 Mac/Windows/Linux)
28
- yuangs.openShici(); // 打开古诗词
29
- yuangs.openDict(); // 打开词典
30
- yuangs.openPong(); // 打开游戏
31
- ```
29
+ - **古诗词 PWA**: https://wealth.want.biz/shici/index.html
30
+ - **英语词典**: https://wealth.want.biz/pages/dict.html
31
+ - **Pong 游戏**: https://wealth.want.biz/pages/pong.html
32
32
 
33
33
  ## 维护者
34
34
 
35
- - yuanguangshan
35
+ yuanguangshan
package/cli.js ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+
3
+ const yuangs = require('./index.js');
4
+ const chalk = require('chalk');
5
+ const args = process.argv.slice(2);
6
+ const command = args[0];
7
+
8
+ function printHelp() {
9
+ console.log(chalk.bold.cyan('\n🎨 YGS Apps - 个人应用启动器\n'));
10
+ console.log(chalk.white('使用方法:') + chalk.gray(' yuangs <命令>\n'));
11
+ console.log(chalk.bold('命令列表:'));
12
+ console.log(` ${chalk.green('shici')} 打开古诗词 PWA`);
13
+ console.log(` ${chalk.green('dict')} 打开英语词典`);
14
+ console.log(` ${chalk.green('pong')} 打开 Pong 游戏`);
15
+ console.log(` ${chalk.green('list')} 列出所有应用链接`);
16
+ console.log(` ${chalk.green('help')} 显示帮助信息\n`);
17
+ console.log(chalk.gray('示例: yuangs shici\n'));
18
+ }
19
+
20
+ function printSuccess(app, url) {
21
+ console.log(chalk.green(`✓ 正在打开 ${app}...`));
22
+ console.log(chalk.gray(` ${url}`));
23
+ }
24
+
25
+ switch (command) {
26
+ case 'shici':
27
+ printSuccess('古诗词应用', yuangs.urls.shici);
28
+ yuangs.openShici();
29
+ break;
30
+ case 'dict':
31
+ printSuccess('英语词典', yuangs.urls.dict);
32
+ yuangs.openDict();
33
+ break;
34
+ case 'pong':
35
+ printSuccess('Pong 游戏', yuangs.urls.pong);
36
+ yuangs.openPong();
37
+ break;
38
+ case 'list':
39
+ console.log(chalk.bold.cyan('\n📱 YGS Apps 列表\n'));
40
+ console.log(chalk.gray('─────────────────────────────────────────────────'));
41
+ Object.entries(yuangs.urls).forEach(([key, url]) => {
42
+ console.log(` ${chalk.green('●')} ${chalk.bold(key.padEnd(8))} ${chalk.blue(url)}`);
43
+ });
44
+ console.log(chalk.gray('─────────────────────────────────────────────────\n'));
45
+ break;
46
+ case 'help':
47
+ case '--help':
48
+ case '-h':
49
+ default:
50
+ printHelp();
51
+ break;
52
+ }
package/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  const { exec } = require('child_process');
2
- const os = require('os');
3
2
 
4
3
  const APPS = {
5
4
  shici: 'https://wealth.want.biz/shici/index.html',
@@ -7,50 +6,23 @@ const APPS = {
7
6
  pong: 'https://wealth.want.biz/pages/pong.html'
8
7
  };
9
8
 
10
- /**
11
- * 打开 URL 的通用函数
12
- * @param {string} url
13
- */
14
9
  function openUrl(url) {
15
10
  let command;
16
11
  switch (process.platform) {
17
- case 'darwin': // macOS
18
- command = `open "${url}"`;
19
- break;
20
- case 'win32': // Windows
21
- command = `start "${url}"`;
22
- break;
23
- default: // Linux
24
- command = `xdg-open "${url}"`;
25
- break;
12
+ case 'darwin': command = `open "${url}"`; break;
13
+ case 'win32': command = `start "${url}"`; break;
14
+ default: command = `xdg-open "${url}"`; break;
26
15
  }
27
-
28
- console.log(`正在打开: ${url} ...`);
29
- exec(command, (error) => {
30
- if (error) {
31
- console.error(`打开失败: ${error.message}`);
32
- }
33
- });
16
+ exec(command);
34
17
  }
35
18
 
36
19
  module.exports = {
37
- // 导出链接常量
38
20
  urls: APPS,
39
-
40
- // 打开古诗词应用
41
21
  openShici: () => openUrl(APPS.shici),
42
-
43
- // 打开英语词典
44
22
  openDict: () => openUrl(APPS.dict),
45
-
46
- // 打开 Pong 游戏
47
23
  openPong: () => openUrl(APPS.pong),
48
-
49
- // 打印所有应用列表
50
24
  listApps: () => {
51
25
  console.log('--- YGS Apps ---');
52
- console.log(`1. 古诗词 (PWA): ${APPS.shici}`);
53
- console.log(`2. 英语词典: ${APPS.dict}`);
54
- console.log(`3. Pong 游戏: ${APPS.pong}`);
26
+ Object.entries(APPS).forEach(([key, url]) => console.log(`${key}: ${url}`));
55
27
  }
56
28
  };
package/package.json CHANGED
@@ -1,19 +1,25 @@
1
1
  {
2
2
  "name": "yuangs",
3
- "version": "1.0.1",
4
- "description": "苑广山的个人应用集合 (PWA, 词典, 游戏)",
3
+ "version": "1.0.3",
4
+ "description": "苑广山的个人应用集合 CLI(彩色版)",
5
5
  "main": "index.js",
6
+ "bin": {
7
+ "yuangs": "./cli.js"
8
+ },
6
9
  "scripts": {
7
10
  "test": "echo \"Error: no test specified\" && exit 1"
8
11
  },
9
12
  "keywords": [
10
13
  "yuangs",
11
- "pwa",
12
- "game",
13
- "tools"
14
+ "cli",
15
+ "tools",
16
+ "colorful"
14
17
  ],
15
18
  "author": "yuanguangshan",
16
19
  "license": "ISC",
20
+ "dependencies": {
21
+ "chalk": "^4.1.2"
22
+ },
17
23
  "publishConfig": {
18
24
  "access": "public"
19
25
  }