pjj 0.2.5 → 0.2.8

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/LICENSE CHANGED
@@ -1,4 +1,6 @@
1
- Copyright (c) <2025> <earthnut.dev@outlook.com>
1
+ # MIT License
2
+
3
+ Copyright (c) <2025> <earthnut.dev>
2
4
 
3
5
  Permission to use, copy, modify, and/or distribute this software for any
4
6
  purpose with or without fee is hereby granted, provided that the above
@@ -10,4 +12,14 @@ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
12
  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
13
  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
14
  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
17
+ # MIT 许可证
18
+
19
+ 版权所有 (c) [2025] [花生亻]
20
+
21
+ 特此免费授予任何获得本软件及相关文档文件(以下简称“软件”)副本的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、再许可和/或出售该软件副本的权利,并允许向其提供该软件的人这样做,但须遵守以下条件:
22
+
23
+ 上述版权声明和本许可声明应包含在所有副本或软件的重要部分中。
24
+
25
+ 软件按“原样”提供,不附带任何形式的明示或暗示的保证,包括但不限于适销性、特定用途适用性和不侵权的保证。在任何情况下,作者或版权持有人均不对因合同、侵权或其他方式引起的任何索赔、损害或其他责任负责,无论是在与软件或软件的使用或其他交易有关的任何诉讼中。
package/README.md CHANGED
@@ -1,9 +1,7 @@
1
- # pjj
1
+ # ​​publish job jamming​
2
2
 
3
3
  ## [![version](<https://img.shields.io/npm/v/pjj.svg?logo=npm&logoColor=rgb(0,0,0)&label=版本号&labelColor=rgb(73,73,228)&color=rgb(0,0,0)>)](https://www.npmjs.com/package/pjj) [![issues 提交](<https://img.shields.io/badge/issues-提交-rgb(255,0,63)?logo=github>)](https://github.com/earthnutDev/pjj/issues)
4
4
 
5
- _发现个更简单的方法,直接在 `package.json` 中添加 `private: true` 更简单粗暴_
6
-
7
5
  禁止在项目的根目录执行 npm publish,防止意外发布。该脚本命令仅允许在 `prepublishOnly` ` 钩子中执行。
8
6
 
9
7
  因为我的项目都是打包到 `dist` 目录下,然后再 `cd dist` 在 dist 目录下执行 `npm publish`,所以需要禁止在根目录执行 `npm publish`。
package/bin.mjs CHANGED
@@ -2,9 +2,11 @@
2
2
  import { dog } from './src/dog.mjs';
3
3
  import { main } from './src/main.mjs';
4
4
 
5
- try {
6
- main();
7
- }
8
- catch (error) {
9
- dog.error(error);
10
- }
5
+ (() => {
6
+ try {
7
+ main();
8
+ }
9
+ catch (error) {
10
+ dog.error(error);
11
+ }
12
+ })();
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "pjj",
3
3
  "type": "module",
4
- "version": "0.2.5",
4
+ "version": "0.2.8",
5
5
  "description": "禁止在项目的根目录执行 npm publish,防止意外发布。该脚本命令需在 `prepublishOnly` ` 钩子中配置",
6
- "license": "ISC",
6
+ "license": "MIT",
7
7
  "dependencies": {
8
- "@qqi/dev-log": ">=0.3.2 <1.0.0",
9
- "a-command": "^2.1.8",
10
- "a-js-tools": ">=0.6.1 <1.0.0",
11
- "a-node-tools": "^3.1.4",
12
- "color-pen": "^2.0.2"
8
+ "@qqi/dev-log": "^0.3.5",
9
+ "a-command": "^2.2.2",
10
+ "a-js-tools": "^0.6.2",
11
+ "a-node-tools": "^4.1.2",
12
+ "a-type-of-js": "^0.3.0",
13
+ "color-pen": "^2.0.9"
13
14
  },
14
15
  "author": {
15
16
  "name": "🥜",
package/src/colorText.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import { dog } from './dog.mjs';
2
- import { truncateStringWithChar, strInTerminalLength, pen } from 'color-pen';
3
- import { noColor } from './command.mjs';
2
+ import { bgBlackPen, truncateStringWithChar } from 'color-pen';
4
3
  import { dataStore } from './data-store.mjs';
5
4
  import { getRandomInt } from 'a-js-tools';
6
5
 
@@ -16,20 +15,9 @@ function colorText(str) {
16
15
  const { screenWith, safeWidth } = dataStore;
17
16
  dog('开始计算文本长度');
18
17
  /** 安全区空白 */
19
- const blankSpace = ' '.repeat(safeWidth);
18
+ const blankSpace = bgBlackPen(' '.repeat(safeWidth));
20
19
  dog('空白长度为', safeWidth);
21
- let computerStr = `${blankSpace}${truncateStringWithChar(str, screenWith)}${blankSpace}`;
22
- dog('计算完毕字符串为', computerStr);
23
- const strLen = strInTerminalLength(computerStr);
24
- dog.warn('现在字符串的长度为:', strLen);
25
- dog.warn('终端共可显示长度为:', screenWith);
26
- if (strLen < screenWith) {
27
- computerStr += ' ';
28
- }
29
- return computerStr
30
- .split('')
31
- .map(char => noColor ? char : pen.number(getRandomInt(1, 225)).bgBlack(char))
32
- .join('');
20
+ return `${blankSpace}${[...truncateStringWithChar(str, screenWith - safeWidth * 2)].reduce((previousValue, currentValue) => previousValue + bgBlackPen.number(getRandomInt(1, 225))(currentValue), '')}${blankSpace}`;
33
21
  }
34
22
 
35
23
  export { colorText };
package/src/main.mjs CHANGED
@@ -5,7 +5,7 @@ import { _p } from 'a-node-tools';
5
5
  import { dog } from './dog.mjs';
6
6
  import { blackSpace } from './blackSpace.mjs';
7
7
  import { isNode } from 'a-js-tools';
8
- import { hidePen, boldPen } from 'color-pen';
8
+ import { bgBlackPen } from 'color-pen';
9
9
 
10
10
  /**
11
11
  * 空行
@@ -16,27 +16,29 @@ const space = '\n'.repeat(3);
16
16
  */
17
17
  function main() {
18
18
  if (isNode() && process.env.npm_lifecycle_event === script) {
19
- _p(space);
20
- _p(line());
21
- _p();
22
- blackSpace();
23
- blackSpace();
24
- _p(colorText(message));
25
- blackSpace();
26
- blackSpace();
27
- _p();
28
- _p(line());
29
- _p(space);
19
+ _p(space); //最上面的空白
20
+ _p(line()); // 最上面的彩色线
21
+ _p(); // 一个空行
22
+ blackSpace(); // 黑色背景
23
+ blackSpace(); // 黑色背景
24
+ _p(colorText(message)); // 彩色文本
25
+ blackSpace(); // 黑色背景
26
+ blackSpace(); // 黑色背景
27
+ _p(); // 一个空行
28
+ _p(line()); // 最下面的彩色线
29
+ _p(space); //最下面的空白
30
30
  command.error();
31
31
  }
32
32
  else {
33
+ const pen = bgBlackPen.brightRed;
34
+ const hidePen = pen.hide;
33
35
  dog.error(isNode() && process.env.npm_lifecycle_event);
34
36
  const m = ' 所以,看见这段文本,说明你哪里 ❌ 了 ';
35
37
  _p('====================================');
36
38
  _p('跳过了禁止发布,而且该命令可能不会显示在终端\n');
37
- _p(hidePen.brightRed.bgBlack(m));
38
- _p(boldPen.blink.brightRed.bgBlack(m));
39
- _p(hidePen.brightRed.bgBlack(m));
39
+ _p(hidePen(m));
40
+ _p(pen.blink.bold(m));
41
+ _p(hidePen(m));
40
42
  _p('\n====================================');
41
43
  }
42
44
  }