meocli 0.1.3 → 0.1.5

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
@@ -1,6 +1,6 @@
1
1
  # meocli
2
2
 
3
- A new CLI generated with oclif
3
+ Node CLI generated with oclif, Integrate Prettier
4
4
 
5
5
  [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
6
6
  [![Version](https://img.shields.io/npm/v/meocli.svg)](https://npmjs.org/package/meocli)
@@ -23,9 +23,8 @@ A new CLI generated with oclif
23
23
  $ pnpm ncu # 检查更新
24
24
  $ pnpm ncu -u # 升级更新
25
25
  <!-- demo -->
26
- $ pnpm run dev hello world
27
- $ pnpm run prod hello world
28
- $ pnpm run dev hello foo -f bar
26
+ $ pnpm run dev hello foo
27
+ $ pnpm run prod hello foo -f bar
29
28
  <!-- prettier -->
30
29
  $ pnpm run dev prettier ./tmp/test.svg --verbose
31
30
  $ pnpm run dev prettier ./tmp/test.json --config=auto --ignore=auto
@@ -117,7 +116,7 @@ $ npm install -g meocli
117
116
  $ me COMMAND
118
117
  running command...
119
118
  $ me (--version)
120
- meocli/0.1.3 win32-x64 node-v24.12.0
119
+ meocli/0.1.5 win32-x64 node-v24.13.0
121
120
  $ me --help [COMMAND]
122
121
  USAGE
123
122
  $ me COMMAND
@@ -128,6 +127,7 @@ USAGE
128
127
  # Commands
129
128
 
130
129
  <!-- commands -->
130
+ * [`me env [FILEPATH]`](#me-env-filepath)
131
131
  * [`me hello PERSON`](#me-hello-person)
132
132
  * [`me hello world`](#me-hello-world)
133
133
  * [`me help [COMMAND]`](#me-help-command)
@@ -144,29 +144,52 @@ USAGE
144
144
  * [`me prettier FILEPATH`](#me-prettier-filepath)
145
145
  * [`me prettier reset`](#me-prettier-reset)
146
146
 
147
+ ## `me env [FILEPATH]`
148
+
149
+ 读取.env环境变量,返回DotenvParseOutput:{[name: string]: string;}
150
+
151
+ ```
152
+ USAGE
153
+ $ me env [FILEPATH] [-v]
154
+
155
+ ARGUMENTS
156
+ [FILEPATH] [default: .env] .env文件路径,不传默认值为.env
157
+
158
+ FLAGS
159
+ -v, --verbose Show verbose output
160
+
161
+ DESCRIPTION
162
+ 读取.env环境变量,返回DotenvParseOutput:{[name: string]: string;}
163
+
164
+ EXAMPLES
165
+ me env .env
166
+ ```
167
+
168
+ _See code: [src/commands/env/index.ts](https://github.com/meme2046/meocli/blob/v0.1.5/src/commands/env/index.ts)_
169
+
147
170
  ## `me hello PERSON`
148
171
 
149
172
  Say hello
150
173
 
151
174
  ```
152
175
  USAGE
153
- $ me hello PERSON -f <value>
176
+ $ me hello PERSON [-f <value>]
154
177
 
155
178
  ARGUMENTS
156
179
  PERSON Person to say hello to
157
180
 
158
181
  FLAGS
159
- -f, --from=<value> (required) Who is saying hello
182
+ -f, --from=<value> [default: meocli] Who is saying hello
160
183
 
161
184
  DESCRIPTION
162
185
  Say hello
163
186
 
164
187
  EXAMPLES
165
- $ me hello friend --from oclif
166
- hello friend from oclif! (./src/commands/hello/index.ts)
188
+ me hello friend --from oclif
189
+ hello friend --from oclif (./src/commands/hello/index.ts)
167
190
  ```
168
191
 
169
- _See code: [src/commands/hello/index.ts](https://github.com/meme2046/meocli/blob/v0.1.3/src/commands/hello/index.ts)_
192
+ _See code: [src/commands/hello/index.ts](https://github.com/meme2046/meocli/blob/v0.1.5/src/commands/hello/index.ts)_
170
193
 
171
194
  ## `me hello world`
172
195
 
@@ -184,7 +207,7 @@ EXAMPLES
184
207
  hello world! (./src/commands/hello/world.ts)
185
208
  ```
186
209
 
187
- _See code: [src/commands/hello/world.ts](https://github.com/meme2046/meocli/blob/v0.1.3/src/commands/hello/world.ts)_
210
+ _See code: [src/commands/hello/world.ts](https://github.com/meme2046/meocli/blob/v0.1.5/src/commands/hello/world.ts)_
188
211
 
189
212
  ## `me help [COMMAND]`
190
213
 
@@ -204,7 +227,7 @@ DESCRIPTION
204
227
  Display help for me.
205
228
  ```
206
229
 
207
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.36/src/commands/help.ts)_
230
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.37/src/commands/help.ts)_
208
231
 
209
232
  ## `me plugins`
210
233
 
@@ -227,7 +250,7 @@ EXAMPLES
227
250
  $ me plugins
228
251
  ```
229
252
 
230
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.54/src/commands/plugins/index.ts)_
253
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.55/src/commands/plugins/index.ts)_
231
254
 
232
255
  ## `me plugins add PLUGIN`
233
256
 
@@ -301,7 +324,7 @@ EXAMPLES
301
324
  $ me plugins inspect myplugin
302
325
  ```
303
326
 
304
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.54/src/commands/plugins/inspect.ts)_
327
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.55/src/commands/plugins/inspect.ts)_
305
328
 
306
329
  ## `me plugins install PLUGIN`
307
330
 
@@ -350,7 +373,7 @@ EXAMPLES
350
373
  $ me plugins install someuser/someplugin
351
374
  ```
352
375
 
353
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.54/src/commands/plugins/install.ts)_
376
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.55/src/commands/plugins/install.ts)_
354
377
 
355
378
  ## `me plugins link PATH`
356
379
 
@@ -381,7 +404,7 @@ EXAMPLES
381
404
  $ me plugins link myplugin
382
405
  ```
383
406
 
384
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.54/src/commands/plugins/link.ts)_
407
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.55/src/commands/plugins/link.ts)_
385
408
 
386
409
  ## `me plugins remove [PLUGIN]`
387
410
 
@@ -422,7 +445,7 @@ FLAGS
422
445
  --reinstall Reinstall all plugins after uninstalling.
423
446
  ```
424
447
 
425
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.54/src/commands/plugins/reset.ts)_
448
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.55/src/commands/plugins/reset.ts)_
426
449
 
427
450
  ## `me plugins uninstall [PLUGIN]`
428
451
 
@@ -450,7 +473,7 @@ EXAMPLES
450
473
  $ me plugins uninstall myplugin
451
474
  ```
452
475
 
453
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.54/src/commands/plugins/uninstall.ts)_
476
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.55/src/commands/plugins/uninstall.ts)_
454
477
 
455
478
  ## `me plugins unlink [PLUGIN]`
456
479
 
@@ -494,7 +517,7 @@ DESCRIPTION
494
517
  Update installed plugins.
495
518
  ```
496
519
 
497
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.54/src/commands/plugins/update.ts)_
520
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.55/src/commands/plugins/update.ts)_
498
521
 
499
522
  ## `me prettier FILEPATH`
500
523
 
@@ -502,7 +525,7 @@ Use Prettier to format file,集成:『@prettier/plugin-xml、prettier-plugin-tom
502
525
 
503
526
  ```
504
527
  USAGE
505
- $ me prettier FILEPATH [-c <value>] [--ignore <value>] [-v]
528
+ $ me prettier FILEPATH [-c <value>] [-i <value>] [-v]
506
529
 
507
530
  ARGUMENTS
508
531
  FILEPATH file path that need to be formatted by Prettier
@@ -510,9 +533,9 @@ ARGUMENTS
510
533
  FLAGS
511
534
  -c, --config=<value> [default: built_in] built_in:使用内置规则(默认值), 传入路径则是使用自定义配置,
512
535
  auto:自动检测config file
513
- -v, --verbose Show verbose output
514
- --ignore=<value> [default: built_in] built_in:使用内置规则(默认值), 传入路径则是使用自定义规则,
536
+ -i, --ignore=<value> [default: built_in] built_in:使用内置规则(默认值), 传入路径则是使用自定义规则,
515
537
  auto:自动检测ignore file
538
+ -v, --verbose Show verbose output
516
539
 
517
540
  DESCRIPTION
518
541
  Use Prettier to format
@@ -524,7 +547,7 @@ EXAMPLES
524
547
  $ me prettier ./src/file.ts --config ./.prettierrc.yaml
525
548
  ```
526
549
 
527
- _See code: [src/commands/prettier/index.ts](https://github.com/meme2046/meocli/blob/v0.1.3/src/commands/prettier/index.ts)_
550
+ _See code: [src/commands/prettier/index.ts](https://github.com/meme2046/meocli/blob/v0.1.5/src/commands/prettier/index.ts)_
528
551
 
529
552
  ## `me prettier reset`
530
553
 
@@ -544,5 +567,5 @@ EXAMPLES
544
567
  $ me prettier reset --verbose
545
568
  ```
546
569
 
547
- _See code: [src/commands/prettier/reset.ts](https://github.com/meme2046/meocli/blob/v0.1.3/src/commands/prettier/reset.ts)_
570
+ _See code: [src/commands/prettier/reset.ts](https://github.com/meme2046/meocli/blob/v0.1.5/src/commands/prettier/reset.ts)_
548
571
  <!-- commandsstop -->
@@ -0,0 +1,13 @@
1
+ import { Command } from "@oclif/core";
2
+ import dotenv from "dotenv";
3
+ export default class Env extends Command {
4
+ static args: {
5
+ filePath: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static description: string;
8
+ static examples: string[];
9
+ static flags: {
10
+ verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ run(): Promise<dotenv.DotenvParseOutput | undefined>;
13
+ }
@@ -0,0 +1,46 @@
1
+ import { Args, Command, Flags } from "@oclif/core";
2
+ import dotenv from "dotenv";
3
+ import { existsSync } from "node:fs";
4
+ import { require } from "../../lib/commonjs.js";
5
+ export default class Env extends Command {
6
+ static args = {
7
+ filePath: Args.string({
8
+ default: ".env",
9
+ description: ".env文件路径,不传默认值为.env",
10
+ required: false,
11
+ }),
12
+ };
13
+ static description = "读取.env环境变量,返回DotenvParseOutput:{[name: string]: string;}";
14
+ static examples = [
15
+ `
16
+ <%= config.bin %> <%= command.id %> .env
17
+ `,
18
+ ];
19
+ static flags = {
20
+ verbose: Flags.boolean({
21
+ char: "v",
22
+ default: false,
23
+ description: "Show verbose output",
24
+ }),
25
+ };
26
+ async run() {
27
+ const { args, flags } = await this.parse(Env);
28
+ const { filePath } = args;
29
+ const { verbose } = flags;
30
+ if (!existsSync(filePath)) {
31
+ this.log(`✘ 『${filePath}』 not found!`);
32
+ return undefined;
33
+ }
34
+ if (verbose) {
35
+ process.env.DEBUG = "oclif:me:env";
36
+ require("debug").enable(process.env.DEBUG);
37
+ }
38
+ const envConfig = dotenv.config({
39
+ path: filePath,
40
+ }).parsed;
41
+ if (envConfig) {
42
+ this.debug(`✔『${filePath}』\n`, envConfig);
43
+ }
44
+ return envConfig;
45
+ }
46
+ }
@@ -1,4 +1,4 @@
1
- import { Command } from '@oclif/core';
1
+ import { Command } from "@oclif/core";
2
2
  export default class Hello extends Command {
3
3
  static args: {
4
4
  person: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
@@ -1,19 +1,28 @@
1
- import { Args, Command, Flags } from '@oclif/core';
1
+ import { Args, Command, Flags } from "@oclif/core";
2
2
  export default class Hello extends Command {
3
3
  static args = {
4
- person: Args.string({ description: 'Person to say hello to', required: true }),
4
+ person: Args.string({
5
+ description: "Person to say hello to",
6
+ required: true,
7
+ }),
5
8
  };
6
- static description = 'Say hello';
9
+ static description = "Say hello";
7
10
  static examples = [
8
- `<%= config.bin %> <%= command.id %> friend --from oclif
9
- hello friend from oclif! (./src/commands/hello/index.ts)
10
- `,
11
+ `
12
+ <%= config.bin %> <%= command.id %> friend --from oclif
13
+ hello friend --from oclif (./src/commands/hello/index.ts)
14
+ `,
11
15
  ];
12
16
  static flags = {
13
- from: Flags.string({ char: 'f', description: 'Who is saying hello', required: true }),
17
+ from: Flags.string({
18
+ char: "f",
19
+ default: "meocli",
20
+ description: "Who is saying hello",
21
+ required: false,
22
+ }),
14
23
  };
15
24
  async run() {
16
25
  const { args, flags } = await this.parse(Hello);
17
- this.log(`hello ${args.person} from ${flags.from}! (./src/commands/hello/index.ts)`);
26
+ this.log(`✔ Hello ${args.person} from ${flags.from}! (./src/commands/hello/index.ts)`);
18
27
  }
19
28
  }
@@ -27,6 +27,7 @@ export default class Prettier extends Command {
27
27
  required: false,
28
28
  }),
29
29
  ignore: Flags.string({
30
+ char: "i",
30
31
  default: "built_in",
31
32
  description: "built_in:使用内置规则(默认值), 传入路径则是使用自定义规则, auto:自动检测ignore file",
32
33
  required: false,
@@ -141,7 +142,7 @@ export default class Prettier extends Command {
141
142
  if (stderr) {
142
143
  this.warn(stderr);
143
144
  }
144
- this.log(`Successfully formatted ${filePath}`);
145
+ this.log(`✔ Formatted ${filePath}`);
145
146
  }
146
147
  detectPackageManager() {
147
148
  // 检查项目根目录是否存在 pnpm-lock.yaml 来判断是否使用 pnpm
@@ -0,0 +1 @@
1
+ export declare const effective: (src: string) => string;
@@ -0,0 +1,2 @@
1
+ export const effective = (src) => src.replace(/\.0+$|(\.[0-9]*[1-9])0+$/, "$1");
2
+ // src.replace(/(\.\d*[1-9])0+$/, "$1").replace(/\.0+$/, "")
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import * as d3Format from "d3-format";
2
+ import lodash from "lodash";
3
+ import { effective } from "../lib/effective.js";
4
+ const { formatPrefix } = d3Format;
5
+ const { replace } = lodash;
6
+ function formatNumberWithUnit(num, precision = 2) {
7
+ // 获取d3默认的前缀格式化器
8
+ const formatter = formatPrefix(`,.${precision}`, num);
9
+ return effective(replace(formatter(num), "G", "B"));
10
+ }
11
+ console.log(formatNumberWithUnit(1));
12
+ console.log(formatNumberWithUnit(150_123)); // 输出: 150.1k
13
+ console.log(formatNumberWithUnit(23_200_000)); // 输出: 23.2M
14
+ console.log(formatNumberWithUnit(1_600_000_000)); // 输出: 1.6B
15
+ console.log(formatNumberWithUnit(123_456, 2)); // 输出: 123.46k(自定义精度)
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import dotenv from "dotenv";
2
+ const envConfig = dotenv.config({
3
+ path: "d:/.env",
4
+ }).parsed;
5
+ console.log(`✅MYSQL_HOST: ${envConfig?.MYSQL_HOST}`);
6
+ console.log(`📋 All .env variables:`, envConfig);
7
+ if (envConfig) {
8
+ for (const [key, value] of Object.entries(envConfig)) {
9
+ console.log(`✅${key}: ${value}`);
10
+ }
11
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,39 @@
1
+ import lodash from "lodash";
2
+ const { flatMap, isNaN, isNumber, map, round, toNumber } = lodash;
3
+ console.log(isNumber("123"));
4
+ console.log(isNumber(null));
5
+ console.log(isNumber(1));
6
+ console.log(Number(""));
7
+ console.log(isNaN(Number("a")));
8
+ console.log(Number("123"));
9
+ // 测试用例1:正常情况
10
+ const A = { a: "1", b: "2", c: "3" };
11
+ const B = { a: "11", b: "22", d: "44" };
12
+ // 只保留A中存在的键,且B中值不为undefined或空字符串
13
+ const pickedB = lodash.pick(B, Object.keys(A));
14
+ const filteredB = lodash.pickBy(pickedB, (value) => value !== undefined && value !== "");
15
+ const result = { ...A, ...filteredB };
16
+ console.log(result); // 输出:{ a: '11', b: '22', c: '3' }
17
+ // 测试用例2:包含undefined和空字符串
18
+ const A2 = { a: "1", b: "2", c: "3" };
19
+ const B2 = { a: undefined, b: "", c: "33", d: "44" };
20
+ const pickedB2 = lodash.pick(B2, Object.keys(A2));
21
+ const filteredB2 = lodash.pickBy(pickedB2, (value) => value !== undefined && value !== "");
22
+ const result2 = { ...A2, ...filteredB2 };
23
+ console.log(result2); // 输出:{ a: '1', b: '2', c: '33' }
24
+ console.log(round(123, -1));
25
+ console.log(flatMap([1, 2, 3], (num) => [num, num * 2]));
26
+ console.log(Number(""));
27
+ if (Number("")) {
28
+ console.log("真");
29
+ }
30
+ else {
31
+ console.log("假");
32
+ }
33
+ // 原始数组
34
+ const strArr = ["1", "2", "3"];
35
+ // 转换为数字数组
36
+ const numArr = map(strArr, Number);
37
+ console.log(numArr);
38
+ console.log(Number(""));
39
+ console.log(isNumber(toNumber("")));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ const d = Math.random() * 1000 + 500;
2
+ console.log(d);
3
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import lodash from "lodash";
2
+ const { isEmpty, isNull } = lodash;
3
+ console.log(isNull(null));
4
+ // => true
5
+ console.log(isNull(""));
6
+ console.log(isEmpty([1, 2, 3]));
7
+ console.log("------");
8
+ console.log(isEmpty(""));
9
+ console.log(isEmpty(null));
10
+ console.log(isEmpty(true));
11
+ console.log(isEmpty(1));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import lodash from "lodash";
2
+ const { toNumber } = lodash;
3
+ const a = "89425.38000000";
4
+ const b = "89431.81002100";
5
+ console.log(Number(a));
6
+ console.log(Number(b));
7
+ console.log(toNumber(a));
8
+ console.log(toNumber(b));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import lodash from "lodash";
2
+ const { pick, pickBy } = lodash;
3
+ function mergeNonEmpty(b, a) {
4
+ const pickedB = pick(b, Object.keys(a));
5
+ const filteredB = pickBy(pickedB, (v) => v);
6
+ // 会被排除的值(假值):
7
+ // - undefined
8
+ // - null
9
+ // - "" (空字符串)
10
+ // - false
11
+ // - 0
12
+ // - NaN
13
+ // - 0n (BigInt 零)
14
+ // 不会被排除的值(真值):
15
+ // - -1 (非零数字都是真值)
16
+ // - 非空字符串
17
+ // - 非空对象
18
+ // - 非空数组
19
+ // - true
20
+ return { ...a, ...filteredB };
21
+ }
22
+ console.log(mergeNonEmpty({ a: 123, price: 1234 }, { a: 3, b: 4, e: undefined, price: 0 }));
23
+ console.log(Object.keys({ a: 3, b: 4, e: undefined, price: 0 }));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import lodash from "lodash";
2
+ const { isNaN, slice } = lodash;
3
+ const list = [1, 2, 3, 55, 6];
4
+ console.log(slice(list, -2));
5
+ const a = [1, 2, 3, 4, 5];
6
+ // 访问不存在的索引 8,不会异常,返回 undefined
7
+ const result = a[8];
8
+ console.log(result); // 输出:undefined
9
+ console.log(typeof result); // 输出:undefined
10
+ console.log(isNaN(0)); // 输出:false
11
+ console.log([
12
+ "#4DAF4A",
13
+ "#E41A1C",
14
+ "#00C9C9",
15
+ "#7863FF",
16
+ "#1783FF",
17
+ "#F0884D",
18
+ "#D580FF",
19
+ "#57534D",
20
+ "#8200DB",
21
+ "#78716B",
22
+ ].slice(0, 3));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import dayjs from "dayjs";
2
+ console.log(dayjs().valueOf());
@@ -0,0 +1,4 @@
1
+ export declare const AVATAR_SRC: Record<string, string>;
2
+ export declare const IMG_SRC: Record<string, string>;
3
+ export declare const SVG_SRC: Record<string, string>;
4
+ export declare const ICON_SRC: Record<string, string>;
@@ -0,0 +1,123 @@
1
+ export const AVATAR_SRC = {
2
+ "6": "https://arweave.net/gh6dERw6YTSdb7HRYzZYA9WV1dg82J1I3I9fYzmomtU",
3
+ "34": "https://arweave.net/MdDHWgrX6J-6JgPR5LaFm50mvuFy8z-hLS3QXrRG_j8",
4
+ "38": "https://arweave.net/WLMz-0yWZhTi_inTmRL4fbyDzVKP1Qk9Tx2VDeFXl4s",
5
+ "46": "https://arweave.net/giw4W_wu2pXWdSfsBzjvRFcP5JmXLnleVzzOgJhgPzE",
6
+ "50": "https://arweave.net/OI7oKNP6TeAzCDXCRlfSrS-baom670bhozdEq3kiqUs",
7
+ "52": "https://arweave.net/Hy9GIxy1dfj0RbVzQCs6MnRDGPfhUtHFUY6bLZE3zb8",
8
+ "64": "https://arweave.net/A6Wq__dWOYTcIYmPrZyDGWHIwEtzO_oVTzkqfEnMnq8",
9
+ "65": "https://arweave.net/XU2GHzPO5LdvGsC9FvgJkMt0uV0tUREDYDihibPaszA",
10
+ "71": "https://arweave.net/M7-A45M71tdpd7p30s1zYtmxmgVZ0Vl8olkpxoRZg1c",
11
+ "73": "https://arweave.net/RMpV1-nhxoJxbkb7t87_Eg8wCzosomhF8hTey2R44qg",
12
+ "75": "https://arweave.net/pYfo28vgb1fXvaXdhtVbWeK78WD9_2zPTMoAt45eZzE",
13
+ "79": "https://arweave.net/YzZB_FCsmpdABmIzgbu0TkiE5PJAM1jfrZNXirkmVN4",
14
+ "80": "https://arweave.net/uoyT7Lb1zK5KZl7WVJ4-pkLaSoPvSjP377UqjLL16EA",
15
+ "81": "https://arweave.net/H1xDFDB7naLnRgeRUliVjOKrsQbWB_Uorl_QCtqjbWI",
16
+ "82": "https://arweave.net/BucAzz46YALpbKjHqsnlAgouDHlQxz6PnNlw2vengpU",
17
+ "84": "https://arweave.net/XLnzK9JO-Vi6UUGl4FAUSSe2dsHk3PFrlY8uZekir7k",
18
+ "94": "https://arweave.net/B71iMgEtvHptds7Qde3bQIiCC2kyP8kgUIKZE6RcnGo",
19
+ "95": "https://arweave.net/rOysZMiykbMV9r1CgkBd1x6hHoHTWWQxwU8Gq7PoU9A",
20
+ "96": "https://arweave.net/iTHsm2tFuK66u3yj8LvjvWuAL3-Z9mbYJzzOJvnQw2Y",
21
+ "98": "https://arweave.net/Ziy9tW38o7gGpilNkkhZiakyD9fqRwvOW2WY3IIw1do",
22
+ "100": "https://arweave.net/_0bEu-PTlOBW6gjEj0Irgdy_sD5QQeml8BsM4Pq9DbY",
23
+ bot: "https://arweave.net/tcD72fbKvbllrqQdHKaPyx42FlSSDdDqkm8Z1GEAcjs",
24
+ btc: "https://arweave.net/8eSQ-IslxWW04eTuh2G5vOncXKVLKtXxlKC6vyCemQE",
25
+ go: "https://arweave.net/__hs2Fm-jF-7yS7MnRkIRVrAdOrdn6iC4-Twxe8e1ps",
26
+ jks: "https://arweave.net/UPVr-n2J3oijcSx8cCalnNas1KxZVNaHiPmfDxPqTm0",
27
+ shadcn: "https://github.com/shadcn.png",
28
+ };
29
+ export const IMG_SRC = {
30
+ AU888: "https://baidu-finance.cdn.bcebos.com/imgs/icons/0530/futures_ab_GOLD.png",
31
+ binance: "https://arweave.net/8fUAyHBwxo_1YHybFGN_jI0bTUXW5736AO8vrlVZ0qQ",
32
+ bitget: "https://arweave.net/_p6Lp4BoYCcCzmKL-nNkQZFotuzgh7WXJuGRFgjWnEE",
33
+ bitget1: "https://arweave.net/Ki99DzArKbeSS1JtojXj-QyQKZr35s32W8IkRUrDsi8",
34
+ BTCUSDT: "https://coin-images.coingecko.com/coins/images/1/large/bitcoin.png",
35
+ coinbase: "https://arweave.net/XCNPLlObUE_n1Taa1iS_9D4_w-KHmXZVfLWI-bMIshA",
36
+ ETHUSDT: "https://coin-images.coingecko.com/coins/images/279/large/ethereum.png",
37
+ L1: "https://arweave.net/mJQhNY4Ia1obLHgGvf_DKcAobINcDEm6RbyCbCEnteU", // Level1 基础行情
38
+ NLS: "https://arweave.net/1A0Jrarna-hux7sirCX0moYedkUqixmJLB1T59Wx6Ew",
39
+ nodejs: "https://arweave.net/bsMsYyZlCGSZXHuwZ4BReNk1t-xFcg7KYAPHvXBx5jA",
40
+ okx: "https://arweave.net/zScW1JHznosuXYIQQUjmgAMYekN_esRyJby12ck5UAs",
41
+ SH: "https://arweave.net/zbcDqHBR69HECkU04pJe2cMb9UZdkaw368Z9-7Ooie0", // 上海证券交易所
42
+ typescript: "https://arweave.net/ojizDdSfAMkWFEG_L_NyxR4BWTY13MZLjC42WekTA1o",
43
+ US: "https://arweave.net/yAB9AibGUbrgn0oNiB8Zgw9S0aFwIbnz8gqW52UjM5M",
44
+ USDCNH: "https://arweave.net/qIGswQTXG_7jNU0RflLi8Qt-2FTC5ccbpWoOmMm7u5Q",
45
+ WH: "https://arweave.net/Y7ZsOW9u9VZf7fDQLa4tJcjDcACNBXe8L_-PPl5qy6A", // 外汇
46
+ XAUTUSDT: "https://coin-images.coingecko.com/coins/images/10481/large/Tether_Gold.png",
47
+ 币安人生USDT: "https://coin-images.coingecko.com/coins/images/69848/large/%E5%B8%81%E5%AE%89%E4%BA%BA%E7%94%9F.png",
48
+ };
49
+ export const SVG_SRC = {
50
+ "000001": "https://baidu-finance.cdn.bcebos.com/imgs/icons/index_000001.svg",
51
+ "399300": "https://baidu-finance.cdn.bcebos.com/imgs/logo/indices/d0c11e7e09802a02888fcf5be5af8769.svg",
52
+ "399905": "https://baidu-finance.cdn.bcebos.com/imgs/logo/indices/62f226489b7e56c90b9e14e0d4fc7531.svg",
53
+ "600519": "https://arweave.net/K9W8zYbRg6HtBHW1wS273_2td2UOvHS27G9u_Z4ffIc",
54
+ AG888: "https://arweave.net/cME70JrezZj1FjE-sjkS_QIjMGwWx_U3gV3uTfJPKqQ",
55
+ ar: "https://arweave.net/CoPs0amqzT8swk9g1S4w_EmRm1YdcBbHFlHzZyLBA20",
56
+ beta: "https://arweave.net/KCAbhCpxYWfb7mZ3uPF9wQyGyaDYPHwn0zbR7nTXC80",
57
+ binance: "https://arweave.net/p1KeuJwiAPizd-8DBYAm1_14J3YlsfPu9evxf3M8Cto",
58
+ bitget: "https://arweave.net/HtmiQ-7AxOkhNtIjKzDBVTlgJv-dCSaDw-TqGeoVQQc",
59
+ btc: "https://arweave.net/arZDUcYsIe1iaUUiponcag3VY1AHyOII8F6IAavF_Vg",
60
+ btc1: "https://arweave.net/tKw5i4aX1IxOa89y-ojxFroGjBgxsfkfi1aIsKXeMuY",
61
+ coinbase: "https://arweave.net/0AL19pT7O6o0P-C_7HrGfn0j1FjGOtNzw6ltMk991BM",
62
+ eth: "https://arweave.net/CVvypM6_AP45YQKuYkvtSK2RtkeI_iOcfvdDR_WpgK0",
63
+ fil: "https://arweave.net/56IhfXT0GW8ko-OEOgnsL7y4haqIA1pCFXAc0VwIIiw",
64
+ gate: "https://arweave.net/xZueBl_L9E1e5N6rNwCC1Q1jdC6Be8viYMncB3d-C0E",
65
+ IXIC: "https://baidu-finance.cdn.bcebos.com/imgs/logo/indices/bbed2a87be06d1318a5c035e45c0f54c.svg",
66
+ line: "https://arweave.net/mfUS0iPbauAXqPYb0mRNYDCJhVQn8uKwG_HHqzYhANc",
67
+ metamask: "https://arweave.net/0ID-EgMR5jZQLj-JGfS2ql1FFaRr-Wvs3VoKRU4VWEU",
68
+ okx: "https://arweave.net/mbBFb3EXGFjrSG12tLfekPwccVuAVbUd3mEnCUjrt_M",
69
+ react: "https://arweave.net/NzS63egtcFF4PWAlKouHNqU05BdvWpIdD-TdaI0U2IY",
70
+ shadcn: "https://arweave.net/-2hSbOI-O2qs3u9d_yf4ylmV3AeSG739b-MaYghh8TA",
71
+ sol: "https://arweave.net/cGqOWiKeBCH1xO97fbs7Pi4assSD3aBudpuCtamWLy4",
72
+ solana: "https://arweave.net/cGqOWiKeBCH1xO97fbs7Pi4assSD3aBudpuCtamWLy4",
73
+ uni: "https://arweave.net/Awt6roS1V9fE9UvVp80x30bYPG-BAmV6Ex-CPz_TXVE",
74
+ vite: "https://arweave.net/IrKrystwNWLNEto65vp2Uk4LUsSfArXUAheSibRbA80",
75
+ };
76
+ export const ICON_SRC = {
77
+ "arrow-down": "https://arweave.net/-YGdFIvjFnQLPSANObNjyEGPFHvlMSMgpRVRGNsh2Tk",
78
+ "arrow-left": "https://arweave.net/_jJZIrnJMbYX_u4kHjwbHPlEjqTMQnTV4dW6z7c8v0A",
79
+ "arrow-right": "https://arweave.net/EMScQgcwVo1tRT-OhBgLW6-4ihQW8GrJNlhobHNMnnQ",
80
+ "arrow-up": "https://arweave.net/RBsQshBEQuJuF8hkyGRVVD3hP02NisXYqZ8oQfzaTG4",
81
+ chevron: "https://arweave.net/iU7ygwR3S3oAt6EVezM5Ab4l2q5OLwYxCS2G5jTDNsE",
82
+ copy: "https://arweave.net/OA0m_3us8t5skksCF-w4vT_klbAZvbfb7SRo_cgG7_k",
83
+ copy1: "https://arweave.net/6GqPMXgkxUEqtzYuJtZ7JlzSbsMNLp_-Me034MneZNw",
84
+ date: "https://arweave.net/Za54QBVo3UNSk8NpeH5jUdaI1VxYU9SSqH1_30vgHgg",
85
+ delete: "https://arweave.net/UwaZB8vdRdKX_Qs4rwC-KRP8eoPiANkYFJDyehMy81M",
86
+ edit: "https://arweave.net/2p7Uk63-5feqnC_J9Cpbs5nO3SvZsA6QEMzoUoqxkPQ",
87
+ eye: "https://arweave.net/yzGwWAq26yjRpDquLw4-48EtEq6LYnK6YCeAGC1EP8E",
88
+ home: "https://arweave.net/Pk5G6pbsp4UhkhynGMMvzqbhceU3X4e2IZLb1WouCo4",
89
+ kill: "https://arweave.net/hXolAnKzsjjlY69gcBxHWUOXFUyUrVqzGe3wPIV38Wc",
90
+ loading1: "https://arweave.net/ZnecWXdwgPXzNHC4NVOEKYi8T2wRQr8E31MH5C_s8uM",
91
+ loading2: "https://arweave.net/7Sc0hFWDM0wDHcu8-ArBSYZdyifw2Yk7xXiee7nJbLU",
92
+ loading3: "https://arweave.net/nNkZ4MZ_w0PwoMrsVX4bqRGbj-qgSDvrHLCDly9H3qA",
93
+ loading4: "https://arweave.net/FBR8S5bU6VICjCgf4F_7-_xC5OWsrwjqmru4T5wvlJU",
94
+ menu: "https://arweave.net/n5CWNGfFcKZiG8leIPn8PRZyOgUn02DBJXLG8xT-0sI",
95
+ menu1: "https://arweave.net/1GP8qNhG-JaAocFryihGI3QRwZ1Pb-eK6OlItqowRQg",
96
+ menu2: "https://arweave.net/Pozej2qroiuAy5gVRBmXrj-p3ioIz8tghQhHwRKLddo",
97
+ moon: "https://arweave.net/1MfkG19dwKaxQbA3wxkpSdNyTupuzHa9sXKoIreq3hQ",
98
+ ok: "https://arweave.net/iErSf5Cjt3Y_pXJxDJgKWBX5D16D2j4nslCrWSc8qpQ",
99
+ plus: "https://arweave.net/Z1KXoUsfbzVPm0tYBnv9AAmjHqg7EEJV6yM4cHPuJwA",
100
+ processing: "https://arweave.net/K6C7eMOM7pEESPSgsqR07EP4hUnfz0tQG138M6vpOyY",
101
+ refresh: "https://arweave.net/HCNMbsyzQDClZPDydPJH3VskQBONC6Ljnds2DWLE_Eo",
102
+ refresh1: "https://arweave.net/IFrj-BVQlhSrXgaDbmbbCRrGOnCVLKVhAepAwOW0AEs",
103
+ rocket: "https://arweave.net/S5Zja0AsszmLKAXNEcB0-GOucTcOnxhUVuYyuxW-L-k",
104
+ search: "https://arweave.net/W8A8Lbrd99c47uFqxvBiDNrGHWSpS8v26IGaGew4KyM",
105
+ sun: "https://arweave.net/cKUO-f2K_mG5NEt8REnrNBLLxwLE0RELwLqCb0yBCtg",
106
+ theme: "https://arweave.net/0QLtpZJuOdyvhf3lrW-FbHQ6gfh69pCY1G1fYaGAU9A",
107
+ "vertical-dots": "https://arweave.net/MCAQ2CskvsJu3Q_Ns9Hcwu8kV20CU0Qj1NTvOB-vLr0",
108
+ yes: "https://arweave.net/i-hGRM_wFXrpNFJRjvsx4oOzl6v3vlW3WZDEqsbla-4",
109
+ };
110
+ // 列表文件支持 csv 和 txt。使用 csv 格式时必须包含表头行,仅支持字段 url(待迁移 url)、key(迁移后的文件名)和 md5(数据内容校验值),仅支持小写且仅 url 为必需。
111
+ // 使用 txt 格式时,每一行表示一个要迁移的文件 URL。
112
+ // for (const [key, url] of Object.entries(AVATAR_SRC)) {
113
+ // console.log(`${url},${key}.png`);
114
+ // }
115
+ // for (const [key, url] of Object.entries(IMG_SRC)) {
116
+ // console.log(`${url},${key}.png`);
117
+ // }
118
+ // for (const [key, url] of Object.entries(SVG_SRC)) {
119
+ // console.log(`${url},${key}.svg`);
120
+ // }
121
+ for (const [key, url] of Object.entries(ICON_SRC)) {
122
+ console.log(`${url},${key}.svg`);
123
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,65 @@
1
+ import lodash from "lodash";
2
+ import fs from "node:fs";
3
+ import { EMA, MACD, SMA } from "trading-signals";
4
+ const { isNull, round, toNumber } = lodash;
5
+ // 从文件读取binance K线数据
6
+ const jsonData = JSON.parse(fs.readFileSync("d:/github/meme2046/meocli/tmp/tmp.json", "utf8"));
7
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
+ function testSMA() {
9
+ // 提取收盘价数据(每个K线数组的第4个元素,索引为4)
10
+ const closePrices = jsonData.map((kline) => toNumber(kline[4]));
11
+ // 创建SMA实例,设置周期为7
12
+ const sma = new SMA(7);
13
+ const smaResults = [];
14
+ // 实现批量添加数据的方法
15
+ // function updateSMA(sma: SMA, prices: number[]): (null | number)[] {
16
+ // const results: (null | number)[] = [];
17
+ // for (const price of prices) {
18
+ // sma.add(price);
19
+ // const result = sma.getResult();
20
+ // results.push(result);
21
+ // }
22
+ // return results;
23
+ // }
24
+ // 使用批量更新方法
25
+ // const smaResults2 = updateSMA(new SMA(7), closePrices);
26
+ // console.log("批量更新SMA(7)结果长度:", smaResults2.length);
27
+ // console.log("批量更新最后一个SMA(7)结果:", smaResults2.at(-1));
28
+ // 添加所有收盘价数据
29
+ for (const price of closePrices) {
30
+ sma.add(price);
31
+ const result = sma.getResult();
32
+ if (isNull(result)) {
33
+ smaResults.push(null);
34
+ }
35
+ else {
36
+ smaResults.push(round(result, 2));
37
+ }
38
+ }
39
+ return smaResults;
40
+ }
41
+ function testMACD() {
42
+ // 提取收盘价数据
43
+ const closePrices = jsonData.map((kline) => toNumber(kline[4]));
44
+ // 创建MACD实例 (参数: short=12, long=26, signal=9)
45
+ const short = new EMA(12);
46
+ const long = new EMA(26);
47
+ const signal = new EMA(9);
48
+ const macd = new MACD(short, long, signal);
49
+ const macdResults = [];
50
+ // 添加所有收盘价数据
51
+ for (const price of closePrices) {
52
+ macd.add(price);
53
+ const result = macd.getResult();
54
+ macdResults.push(result);
55
+ }
56
+ return macdResults;
57
+ }
58
+ // const smaResults = testSMA();
59
+ // 获取SMA结果
60
+ // console.log("SMA(7)结果长度:", smaResults.length);
61
+ // console.log("最后5个SMA(7)结果:", smaResults.slice(-5));
62
+ // 测试MACD
63
+ const macdResults = testMACD();
64
+ console.log("\nMACD结果长度:", macdResults.length);
65
+ console.log("最后一个MACD结果:", macdResults.at(-1));
@@ -1,5 +1,44 @@
1
1
  {
2
2
  "commands": {
3
+ "env": {
4
+ "aliases": [],
5
+ "args": {
6
+ "filePath": {
7
+ "default": ".env",
8
+ "description": ".env文件路径,不传默认值为.env",
9
+ "name": "filePath",
10
+ "required": false
11
+ }
12
+ },
13
+ "description": "读取.env环境变量,返回DotenvParseOutput:{[name: string]: string;}",
14
+ "examples": [
15
+ "\n <%= config.bin %> <%= command.id %> .env\n "
16
+ ],
17
+ "flags": {
18
+ "verbose": {
19
+ "char": "v",
20
+ "description": "Show verbose output",
21
+ "name": "verbose",
22
+ "allowNo": false,
23
+ "type": "boolean"
24
+ }
25
+ },
26
+ "hasDynamicHelp": false,
27
+ "hiddenAliases": [],
28
+ "id": "env",
29
+ "pluginAlias": "meocli",
30
+ "pluginName": "meocli",
31
+ "pluginType": "core",
32
+ "strict": true,
33
+ "enableJsonFlag": false,
34
+ "isESM": true,
35
+ "relativePath": [
36
+ "dist",
37
+ "commands",
38
+ "env",
39
+ "index.js"
40
+ ]
41
+ },
3
42
  "hello": {
4
43
  "aliases": [],
5
44
  "args": {
@@ -11,14 +50,15 @@
11
50
  },
12
51
  "description": "Say hello",
13
52
  "examples": [
14
- "<%= config.bin %> <%= command.id %> friend --from oclif\nhello friend from oclif! (./src/commands/hello/index.ts)\n"
53
+ "\n <%= config.bin %> <%= command.id %> friend --from oclif\n hello friend --from oclif (./src/commands/hello/index.ts)\n "
15
54
  ],
16
55
  "flags": {
17
56
  "from": {
18
57
  "char": "f",
19
58
  "description": "Who is saying hello",
20
59
  "name": "from",
21
- "required": true,
60
+ "required": false,
61
+ "default": "meocli",
22
62
  "hasDynamicHelp": false,
23
63
  "multiple": false,
24
64
  "type": "option"
@@ -90,6 +130,7 @@
90
130
  "type": "option"
91
131
  },
92
132
  "ignore": {
133
+ "char": "i",
93
134
  "description": "built_in:使用内置规则(默认值), 传入路径则是使用自定义规则, auto:自动检测ignore file",
94
135
  "name": "ignore",
95
136
  "required": false,
@@ -155,5 +196,5 @@
155
196
  ]
156
197
  }
157
198
  },
158
- "version": "0.1.3"
199
+ "version": "0.1.5"
159
200
  }
package/package.json CHANGED
@@ -1,32 +1,38 @@
1
1
  {
2
2
  "name": "meocli",
3
- "description": "node CLI generated with oclif, Integrate Prettier",
4
- "version": "0.1.3",
3
+ "description": "Node CLI generated with oclif, Integrate Prettier",
4
+ "version": "0.1.5",
5
5
  "author": "meme2046",
6
6
  "bin": {
7
7
  "me": "./bin/run.js"
8
8
  },
9
9
  "bugs": "https://github.com/meme2046/meocli/issues",
10
10
  "dependencies": {
11
- "@oclif/core": "^4",
11
+ "@oclif/core": "^4.8.0",
12
12
  "@oclif/plugin-help": "^6",
13
13
  "@oclif/plugin-plugins": "^5",
14
14
  "@prettier/plugin-xml": "^3.4.2",
15
+ "d3-format": "^3.1.2",
16
+ "dayjs": "^1.11.19",
15
17
  "debug": "^4.4.3",
18
+ "dotenv": "^17.2.3",
16
19
  "execa": "^9.6.1",
17
20
  "js-yaml": "^4.1.1",
18
- "npm-check-updates": "^19.3.1",
19
- "prettier": "^3.8.0",
21
+ "lodash": "^4.17.23",
22
+ "prettier": "^3.8.1",
20
23
  "prettier-plugin-nginx": "^1.0.3",
21
24
  "prettier-plugin-sh": "^0.18.0",
22
- "prettier-plugin-toml": "^2.0.6"
25
+ "prettier-plugin-toml": "^2.0.6",
26
+ "trading-signals": "^7.4.3"
23
27
  },
24
28
  "devDependencies": {
25
29
  "@eslint/compat": "^1",
26
30
  "@oclif/prettier-config": "^0.2.1",
27
31
  "@oclif/test": "^4",
28
32
  "@types/chai": "^4",
33
+ "@types/d3-format": "^3.0.4",
29
34
  "@types/js-yaml": "^4.0.9",
35
+ "@types/lodash": "^4.17.23",
30
36
  "@types/mocha": "^10",
31
37
  "@types/node": "^18",
32
38
  "chai": "^4",
@@ -34,6 +40,7 @@
34
40
  "eslint-config-oclif": "^6",
35
41
  "eslint-config-prettier": "^10",
36
42
  "mocha": "^10",
43
+ "npm-check-updates": "^19.3.2",
37
44
  "oclif": "^4",
38
45
  "shx": "^0.3.3",
39
46
  "ts-node": "^10",
@@ -51,7 +58,7 @@
51
58
  "keywords": [
52
59
  "oclif",
53
60
  "prettier",
54
- "formatting"
61
+ "formatter"
55
62
  ],
56
63
  "license": "MIT",
57
64
  "main": "dist/index.js",
@@ -75,6 +82,7 @@
75
82
  "types": "dist/index.d.ts",
76
83
  "scripts": {
77
84
  "ncu": "ncu --target minor --reject webpack,shx",
85
+ "tsv": "tsc -v",
78
86
  "dev": "node --no-deprecation --no-warnings --disable-warning=ExperimentalWarning --loader ts-node/esm bin/dev.js",
79
87
  "prod": "node bin/run.js",
80
88
  "build": "shx rm -rf dist && tsc -b",