pjj 0.2.6 → 1.0.0

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,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/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "pjj",
3
3
  "type": "module",
4
- "version": "0.2.6",
4
+ "version": "1.0.0",
5
5
  "description": "禁止在项目的根目录执行 npm publish,防止意外发布。该脚本命令需在 `prepublishOnly` ` 钩子中配置",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
- "@qqi/dev-log": "^0.3.3",
9
- "a-command": "^2.1.9",
10
- "a-js-tools": "^0.6.2",
11
- "a-node-tools": "^3.1.5",
12
- "color-pen": "^2.0.3"
8
+ "@qqi/dev-log": "^1.0.0",
9
+ "a-command": "^2.2.4",
10
+ "a-js-tools": "^1.0.0",
11
+ "a-node-tools": "^4.2.0",
12
+ "a-type-of-js": "^1.0.0",
13
+ "color-pen": "^2.0.10"
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, numberPen } 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 : numberPen(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
  }