pjj 0.0.0 → 0.1.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/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) <2025> <earthnut.dev@outlook.com>
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any
4
+ purpose with or without fee is hereby granted, provided that the above
5
+ copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,77 @@
1
- # 这个名被我占用了
1
+ # pjj
2
2
 
3
- 但是你如果有需要,可以 [邮我转让](mailto:earthnut.dev@outlook.com)
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) [![NPM Last Update](<https://img.shields.io/npm/last-update/pjj?logo=npm&label=版本最后更新&labelColor=rgb(255,36,63)&color=rgb(0,0,0)>)](https://www.npmjs.com/package/pjj) [![📦 size](<https://img.shields.io/bundlephobia/minzip/pjj.svg?logo=npm&label=压缩包大小&labelColor=rgb(201,158,140)&color=rgb(0,0,0)>)](https://www.npmjs.com/package/pjj) [![downloads](<https://img.shields.io/npm/dm/pjj.svg?logo=npm&logoColor=rgb(0,0,0)&label=月下载量&labelColor=rgb(194,112,210)&color=rgb(0,0,0)>)](https://www.npmjs.com/package/pjj) [![downloads](<https://img.shields.io/npm/dt/pjj.svg?logo=npm&label=总下载量&labelColor=rgb(107,187,124)&color=rgb(0,0,0)>)](https://www.npmjs.com/package/pjj)
4
+
5
+ [![last commit](<https://img.shields.io/github/last-commit/earthnutDev/pjj.svg?logo=github&logoColor=rgb(0,0,0)&label=最后推码&labelColor=rgb(255,165,0)&color=rgb(0,0,0)>)](https://github.com/earthnutDev/pjj) [![GitHub commit activity](<https://img.shields.io/github/commit-activity/y/earthnutDev/pjj.svg?logo=github&label=推码数&labelColor=rgb(128,0,128)&color=rgb(0,0,0)>)](https://github.com/earthnutDev/pjj) [![Coverage Status](<https://img.shields.io/coverallsCoverage/github/earthnutDev/pjj?logo=coveralls&label=coveralls&labelColor=rgb(12, 244, 39)&color=rgb(0,0,0)>)](https://coveralls.io/github/earthnutDev/pjj?branch=main) [![codecov](<https://img.shields.io/codecov/c/github/earthnutDev/pjj/main?logo=codecov&label=codecov&labelColor=rgb(7, 245, 245)&color=rgb(0,0,0)>)](https://codecov.io/gh/earthnutDev/pjj)
6
+
7
+ [![查看 📔 日志](<https://img.shields.io/badge/👀-日_%20_志-rgb(0,125,206)>)](https://github.com/earthnutDev/pjj/blob/main/CHANGELOG.md) [![bug 🙋‍♂️ 提交](<https://img.shields.io/badge/☣️-bug_%20_提交-rgb(255,0,63)>)](https://github.com/earthnutDev/pjj/issues)
8
+
9
+ ---
10
+
11
+ _发现个更简单的方法,直接在 `package.json` 中添加 `private: true` 更简单粗暴_
12
+
13
+ 禁止在项目的根目录执行 npm publish,防止意外发布。该脚本命令仅允许在 `prepublishOnly` ` 钩子中执行。
14
+
15
+ 因为我的项目都是打包到 `dist` 目录下,然后再 `cd dist` 在 dist 目录下执行 `npm publish`,所以需要禁止在根目录执行 `npm publish`。
16
+
17
+ 因为偶尔会忘记在 `dist` 目录下执行 `npm publish`,所以需要该脚本命令。
18
+
19
+ _我构建后的 `package.json` 🀄️不包含 `scripts` 字段,所以仅考虑根目录禁止执行 `npm publish`_
20
+
21
+ ## 安装
22
+
23
+ ```bash
24
+ npm install pjj --save-dev
25
+ ```
26
+
27
+ ## 使用
28
+
29
+ ### 常规使用
30
+
31
+ ```json
32
+ {
33
+ "scripts": {
34
+ "prepublishOnly": "pjj"
35
+ }
36
+ }
37
+ ```
38
+
39
+ ### 替换掉默认文本
40
+
41
+ ```json
42
+ {
43
+ "scripts": {
44
+ "prepublishOnly": "pjj -m '请在 dist 目录下执行 npm publish'"
45
+ }
46
+ }
47
+ ```
48
+
49
+ ### 替换掉默认文本并使用黑色(默认)文本颜色
50
+
51
+ ```json
52
+ {
53
+ "scripts": {
54
+ "prepublishOnly": "pjj -m '请在 dist 目录下执行 npm publish' -b"
55
+ }
56
+ }
57
+ ```
58
+
59
+ 需要注意
60
+
61
+ - 添加了 `-s` 命令用于替换默认 prepublishOnly,但是还不知道怎么用,慎用
62
+ - 在使用命令 `pjj` 时,需保证在项目中进行了安装
63
+ - 只要将该命令配置到 `"prepublishOnly": "pjj"` 时,总会在执行 `npm publish` 时阻止执行 `npm publish`
64
+ - 该命令仅适用于 `npm publish`
65
+ - 使用该命令请不要使用 `npx` 调用,除非配置 `-s npx` 命令
66
+
67
+ ```json
68
+ {
69
+ "scripts": {
70
+ "prepublishOnly": "npx pjj -s npx"
71
+ }
72
+ }
73
+ ```
74
+
75
+ ## 文档地址
76
+
77
+ 参看 [https://earthnut.dev/pjj/](https://earthnut.dev/pjj/)
package/bin/pjj.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ import '../mjs/index.mjs';
package/mjs/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { main } from './src/main.mjs';
2
+
3
+ main();
package/mjs/src/cn.mjs ADDED
@@ -0,0 +1,3 @@
1
+ const cn = process.env.LANG?.toLocaleLowerCase().includes('zh');
2
+
3
+ export { cn };
@@ -0,0 +1,25 @@
1
+ import { pen } from 'color-pen';
2
+ import { noColor } from './command.mjs';
3
+
4
+ /**
5
+ *
6
+ * @description 生成随机颜色文本
7
+ * @param str 字符串
8
+ * @param text 是否不使用颜色
9
+ *
10
+ *
11
+ */
12
+ function colorText(str, text = true) {
13
+ return `${' '.repeat(7)}${str}${' '.repeat(7)}`
14
+ .split('')
15
+ .map(char => noColor
16
+ ? text
17
+ ? char
18
+ : pen.hide(char)
19
+ : text
20
+ ? pen.random.bgBlack(char)
21
+ : pen.random.bgBlack.hide(char))
22
+ .join('');
23
+ }
24
+
25
+ export { colorText };
@@ -0,0 +1,31 @@
1
+ import { Command } from 'a-command';
2
+ import { cn } from './cn.mjs';
3
+
4
+ /** 创建一个命令 */
5
+ const command = new Command('pjj');
6
+ command
7
+ .bind({
8
+ 'message <-m> (添加自定义的命令消息)': [],
9
+ 'black <-b> (显示为黑色(默认)文本)': [],
10
+ 'script <-s> (触发的勾子,默认为 prepublishOnly)': [],
11
+ })
12
+ .run().isEnd.end;
13
+ /**
14
+ * 命令参数映射
15
+ */
16
+ const argMap = command.args.$map;
17
+ /**
18
+ * 命令参数值
19
+ */
20
+ const message = argMap.message && argMap.message.value && argMap.message.value.length > 0
21
+ ? argMap.message.value.join('\n')
22
+ : cn
23
+ ? '禁止在项目的根目录下执行 npm publish 命令'
24
+ : 'It is forbidden to execute the npm publish command in the root directory of the project';
25
+ /// 没有颜色
26
+ const noColor = argMap.black !== undefined;
27
+ const script = argMap.script && argMap.script.value && argMap.script.value.length > 0
28
+ ? argMap.script.value[0]
29
+ : 'prepublishOnly';
30
+
31
+ export { command, message, noColor, script };
@@ -0,0 +1,18 @@
1
+ import pen from 'color-pen';
2
+ import { cn } from './cn.mjs';
3
+ import { noColor } from './command.mjs';
4
+
5
+ /**
6
+ *
7
+ * @description 生成分割线
8
+ *
9
+ */
10
+ function line() {
11
+ let str = '';
12
+ for (let i = 0; i < (cn ? 54 : 101); i++) {
13
+ str += noColor ? '=' : pen.random('=');
14
+ }
15
+ return str;
16
+ }
17
+
18
+ export { line };
@@ -0,0 +1,40 @@
1
+ import pen from 'color-pen';
2
+ import { colorText } from './colorText.mjs';
3
+ import { script, message } from './command.mjs';
4
+ import { line } from './line.mjs';
5
+ import { _p } from 'a-node-tools';
6
+
7
+ /**
8
+ * 空行
9
+ */
10
+ const space = '\n'.repeat(3);
11
+ /**
12
+ * 主程序入口
13
+ */
14
+ function main() {
15
+ if (process && process.env && process.env.npm_lifecycle_event === script) {
16
+ _p(space);
17
+ _p(line());
18
+ _p(colorText(message, false));
19
+ _p(colorText(message, false));
20
+ _p(colorText(message));
21
+ _p(colorText(message, false));
22
+ _p(colorText(message, false));
23
+ _p(line());
24
+ _p(space);
25
+ end();
26
+ }
27
+ else {
28
+ const m = ' 所以,看见这段文本,说明你哪里 ❌ 了 ';
29
+ _p('====================================');
30
+ _p('跳过了禁止发布,而且该命令可能不会显示在终端\n');
31
+ _p(pen.hide.brightRed.bgBlack(m));
32
+ _p(pen.bold.blink.brightRed.bgBlack(m));
33
+ _p(pen.hide.brightRed.bgBlack(m));
34
+ _p('\n====================================');
35
+ }
36
+ }
37
+ /** 命令结束回调 */
38
+ const end = () => process.exit(1);
39
+
40
+ export { end, main };
package/package.json CHANGED
@@ -1,26 +1,49 @@
1
1
  {
2
2
  "name": "pjj",
3
- "version": "0.0.0",
4
- "main": "index.js",
5
- "author": "lmssee <lmssee@outlook.com> (https://lmssee.com)",
6
- "homepage": "https://earthnut.dev/vue",
7
- "license": "ISC",
8
- "description": "但是你如果有需要,可以邮我转让 <earthnut.dev@outlook.com>",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "module": "./mjs/index.mjs",
6
+ "author": {
7
+ "name": "earthnut",
8
+ "email": "earthnut.dev@outlook.com",
9
+ "url": "https://earthnut.dev"
10
+ },
11
+ "description": "禁止在项目的根目录执行 npm publish,防止意外发布。该脚本命令仅允许在 `prepublishOnly` ` 钩子中执行。",
9
12
  "files": [
10
- "index.js"
13
+ "mjs",
14
+ "bin"
11
15
  ],
12
- "bugs": {
13
- "url": "https://github.com/lmssee/npm-earthnut-vue/issues"
16
+ "exports": {
17
+ ".": {
18
+ "import": {
19
+ "default": "./mjs/index.mjs",
20
+ "types": "./types/index.d.ts"
21
+ }
22
+ }
14
23
  },
15
24
  "keywords": [
16
- "earthnut"
25
+ "pjj"
17
26
  ],
27
+ "license": "ISC",
28
+ "homepage": "https://earthnut.dev/pjj",
29
+ "bugs": {
30
+ "url": "https://github.com/earthnutDev/gtu/issues",
31
+ "email": "earthnut.dev@outlook.com"
32
+ },
18
33
  "repository": {
19
34
  "type": "git",
20
- "url": "git+https://github.com/lmssee/npm-earthnut-vue.git"
35
+ "url": "git+https://github.com/earthnutDev/pjj.git"
21
36
  },
22
37
  "publishConfig": {
23
38
  "access": "public",
24
- "registry": "https://registry.npmjs.org"
39
+ "registry": "https://registry.npmjs.org/"
40
+ },
41
+ "dependencies": {
42
+ "a-command": "^0.0.8",
43
+ "a-node-tools": "^0.1.0",
44
+ "color-pen": "^0.1.0"
45
+ },
46
+ "bin": {
47
+ "pjj": "bin/pjj.js"
25
48
  }
26
- }
49
+ }
package/index.js DELETED
@@ -1 +0,0 @@
1
- console.log("hello ,iggg!");