meocli 0.1.2 → 0.1.4

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)
@@ -117,7 +117,7 @@ $ npm install -g meocli
117
117
  $ me COMMAND
118
118
  running command...
119
119
  $ me (--version)
120
- meocli/0.1.2 win32-x64 node-v24.12.0
120
+ meocli/0.1.4 win32-x64 node-v24.12.0
121
121
  $ me --help [COMMAND]
122
122
  USAGE
123
123
  $ me COMMAND
@@ -166,7 +166,7 @@ EXAMPLES
166
166
  hello friend from oclif! (./src/commands/hello/index.ts)
167
167
  ```
168
168
 
169
- _See code: [src/commands/hello/index.ts](https://github.com/meme2046/meocli/blob/v0.1.2/src/commands/hello/index.ts)_
169
+ _See code: [src/commands/hello/index.ts](https://github.com/meme2046/meocli/blob/v0.1.4/src/commands/hello/index.ts)_
170
170
 
171
171
  ## `me hello world`
172
172
 
@@ -184,7 +184,7 @@ EXAMPLES
184
184
  hello world! (./src/commands/hello/world.ts)
185
185
  ```
186
186
 
187
- _See code: [src/commands/hello/world.ts](https://github.com/meme2046/meocli/blob/v0.1.2/src/commands/hello/world.ts)_
187
+ _See code: [src/commands/hello/world.ts](https://github.com/meme2046/meocli/blob/v0.1.4/src/commands/hello/world.ts)_
188
188
 
189
189
  ## `me help [COMMAND]`
190
190
 
@@ -524,7 +524,7 @@ EXAMPLES
524
524
  $ me prettier ./src/file.ts --config ./.prettierrc.yaml
525
525
  ```
526
526
 
527
- _See code: [src/commands/prettier/index.ts](https://github.com/meme2046/meocli/blob/v0.1.2/src/commands/prettier/index.ts)_
527
+ _See code: [src/commands/prettier/index.ts](https://github.com/meme2046/meocli/blob/v0.1.4/src/commands/prettier/index.ts)_
528
528
 
529
529
  ## `me prettier reset`
530
530
 
@@ -544,5 +544,5 @@ EXAMPLES
544
544
  $ me prettier reset --verbose
545
545
  ```
546
546
 
547
- _See code: [src/commands/prettier/reset.ts](https://github.com/meme2046/meocli/blob/v0.1.2/src/commands/prettier/reset.ts)_
547
+ _See code: [src/commands/prettier/reset.ts](https://github.com/meme2046/meocli/blob/v0.1.4/src/commands/prettier/reset.ts)_
548
548
  <!-- commandsstop -->
@@ -141,7 +141,7 @@ export default class Prettier extends Command {
141
141
  if (stderr) {
142
142
  this.warn(stderr);
143
143
  }
144
- this.log(`Successfully formatted ${filePath}`);
144
+ this.log(`✔ Formatted ${filePath}`);
145
145
  }
146
146
  detectPackageManager() {
147
147
  // 检查项目根目录是否存在 pnpm-lock.yaml 来判断是否使用 pnpm
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import lodash from "lodash";
2
+ const { isNaN, isNumber } = 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' }
@@ -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,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 }));
@@ -155,5 +155,5 @@
155
155
  ]
156
156
  }
157
157
  },
158
- "version": "0.1.2"
158
+ "version": "0.1.4"
159
159
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "meocli",
3
- "description": "A new CLI generated with oclif",
4
- "version": "0.1.2",
3
+ "description": "Node CLI generated with oclif, Integrate Prettier",
4
+ "version": "0.1.4",
5
5
  "author": "meme2046",
6
6
  "bin": {
7
7
  "me": "./bin/run.js"
@@ -15,7 +15,7 @@
15
15
  "debug": "^4.4.3",
16
16
  "execa": "^9.6.1",
17
17
  "js-yaml": "^4.1.1",
18
- "npm-check-updates": "^19.3.1",
18
+ "lodash": "^4.17.21",
19
19
  "prettier": "^3.8.0",
20
20
  "prettier-plugin-nginx": "^1.0.3",
21
21
  "prettier-plugin-sh": "^0.18.0",
@@ -27,6 +27,7 @@
27
27
  "@oclif/test": "^4",
28
28
  "@types/chai": "^4",
29
29
  "@types/js-yaml": "^4.0.9",
30
+ "@types/lodash": "^4.17.23",
30
31
  "@types/mocha": "^10",
31
32
  "@types/node": "^18",
32
33
  "chai": "^4",
@@ -34,6 +35,7 @@
34
35
  "eslint-config-oclif": "^6",
35
36
  "eslint-config-prettier": "^10",
36
37
  "mocha": "^10",
38
+ "npm-check-updates": "^19.3.1",
37
39
  "oclif": "^4",
38
40
  "shx": "^0.3.3",
39
41
  "ts-node": "^10",
@@ -49,7 +51,9 @@
49
51
  ],
50
52
  "homepage": "https://github.com/meme2046/meocli",
51
53
  "keywords": [
52
- "oclif"
54
+ "oclif",
55
+ "prettier",
56
+ "formatter"
53
57
  ],
54
58
  "license": "MIT",
55
59
  "main": "dist/index.js",