pjj 0.2.0 → 0.2.2
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/{index.mjs → bin.mjs} +0 -0
- package/package.json +7 -8
- package/src/colorText.mjs +11 -2
- package/src/main.mjs +3 -2
- package/bin.js +0 -4
package/{index.mjs → bin.mjs}
RENAMED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pjj",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"description": "禁止在项目的根目录执行 npm publish,防止意外发布。该脚本命令需在 `prepublishOnly` ` 钩子中配置",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@qqi/dev-log": ">=0.1.0 <1.0.0",
|
|
9
|
-
"a-command": ">=2.1.
|
|
10
|
-
"a-js-tools": ">=0.
|
|
11
|
-
"a-node-tools": ">=2.2.
|
|
12
|
-
"color-pen": "
|
|
9
|
+
"a-command": ">=2.1.5 <3.0.0",
|
|
10
|
+
"a-js-tools": ">=0.6.0 <1.0.0",
|
|
11
|
+
"a-node-tools": ">=2.2.1 <3.0.0",
|
|
12
|
+
"color-pen": ">=1.2.2 <2.0.0"
|
|
13
13
|
},
|
|
14
14
|
"author": {
|
|
15
15
|
"name": "🥜",
|
|
@@ -17,9 +17,8 @@
|
|
|
17
17
|
"url": "https://earthnut.dev"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"bin.js",
|
|
21
20
|
"src",
|
|
22
|
-
"
|
|
21
|
+
"bin.mjs"
|
|
23
22
|
],
|
|
24
23
|
"keywords": [
|
|
25
24
|
"pjj"
|
|
@@ -38,6 +37,6 @@
|
|
|
38
37
|
"registry": "https://registry.npmjs.org/"
|
|
39
38
|
},
|
|
40
39
|
"bin": {
|
|
41
|
-
"pjj": "bin.
|
|
40
|
+
"pjj": "bin.mjs"
|
|
42
41
|
}
|
|
43
42
|
}
|
package/src/colorText.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dog } from './dog.mjs';
|
|
1
2
|
import { truncateStringWithChar, strInTerminalLength, pen } from 'color-pen';
|
|
2
3
|
import { noColor } from './command.mjs';
|
|
3
4
|
import { dataStore } from './data-store.mjs';
|
|
@@ -13,10 +14,18 @@ import { getRandomInt } from 'a-js-tools';
|
|
|
13
14
|
*/
|
|
14
15
|
function colorText(str) {
|
|
15
16
|
const { screenWith, safeWidth } = dataStore;
|
|
17
|
+
dog('开始计算文本长度');
|
|
16
18
|
/** 安全区空白 */
|
|
17
19
|
const blankSpace = ' '.repeat(safeWidth);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
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
|
+
}
|
|
20
29
|
return computerStr
|
|
21
30
|
.split('')
|
|
22
31
|
.map(char => noColor ? char : pen.number(getRandomInt(1, 225)).bgBlack(char))
|
package/src/main.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { line } from './line.mjs';
|
|
|
5
5
|
import { _p } from 'a-node-tools';
|
|
6
6
|
import { dog } from './dog.mjs';
|
|
7
7
|
import { blackSpace } from './blackSpace.mjs';
|
|
8
|
+
import { isNode } from 'a-js-tools';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* 空行
|
|
@@ -14,7 +15,7 @@ const space = '\n'.repeat(3);
|
|
|
14
15
|
* 主程序入口
|
|
15
16
|
*/
|
|
16
17
|
function main() {
|
|
17
|
-
if (
|
|
18
|
+
if (isNode() && process.env.npm_lifecycle_event === script) {
|
|
18
19
|
_p(space);
|
|
19
20
|
_p(line());
|
|
20
21
|
_p();
|
|
@@ -29,7 +30,7 @@ function main() {
|
|
|
29
30
|
command.error();
|
|
30
31
|
}
|
|
31
32
|
else {
|
|
32
|
-
dog.error(
|
|
33
|
+
dog.error(isNode() && process.env.npm_lifecycle_event);
|
|
33
34
|
const m = ' 所以,看见这段文本,说明你哪里 ❌ 了 ';
|
|
34
35
|
_p('====================================');
|
|
35
36
|
_p('跳过了禁止发布,而且该命令可能不会显示在终端\n');
|
package/bin.js
DELETED