jja 0.0.0 → 1.0.1
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 +13 -0
- package/README.md +44 -2
- package/bin/index.js +3 -0
- package/mjs/index.mjs +1 -0
- package/mjs/src/clearScreen.mjs +1 -0
- package/mjs/src/command.mjs +1 -0
- package/mjs/src/git.mjs +1 -0
- package/mjs/src/package.mjs +1 -0
- package/mjs/src/remove.mjs +1 -0
- package/mjs/src/todo/runOther.mjs +1 -0
- package/mjs/src/update.mjs +1 -0
- package/package.json +28 -16
- package/index.js +0 -24
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright (c) <2024> <earthnut.dev>
|
|
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,45 @@
|
|
|
1
|
-
#
|
|
1
|
+
# jja
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[&label=版本号&labelColor=rgb(73,73,228)&color=rgb(0,0,0)>)](https://www.npmjs.com/package/jja) [&color=rgb(0,0,0)>)](https://www.npmjs.com/package/jja) [&color=rgb(0,0,0)>)](https://www.npmjs.com/package/jja) [&label=月下载量&labelColor=rgb(194,112,210)&color=rgb(0,0,0)>)](https://www.npmjs.com/package/jja) [&color=rgb(0,0,0)>)](https://www.npmjs.com/package/jja)
|
|
4
|
+
|
|
5
|
+
[&label=最后推码&labelColor=rgb(255,165,0)&color=rgb(0,0,0)>)](https://github.com/earthnutDev/jja) [&color=rgb(0,0,0)>)](https://github.com/earthnutDev/jja) [&color=rgb(0,0,0)>)](https://coveralls.io/github/earthnutDev/jja?branch=main) [&color=rgb(0,0,0)>)](https://codecov.io/gh/earthnutDev/jja)
|
|
6
|
+
|
|
7
|
+
[>)](https://github.com/earthnutDev/jja/blob/main/CHANGELOG.md) [>)](https://github.com/earthnutDev/jja/issues)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 安装
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install --save-dev jja
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 命令
|
|
18
|
+
|
|
19
|
+
定义了两个命令,一个是 remove ,另一个是 update
|
|
20
|
+
|
|
21
|
+
### `remove`
|
|
22
|
+
|
|
23
|
+
你可以使用 `npx jja rm <filename> <filename> <...>` 的模式进行移除文件或文件夹,而不再担心“我的 windows 命令在 macos 上没法用呀!!”、“我在 windows 上移除文件夹,文件不存在报错” (不好吧,我就是为了解决这两个问题才呕心沥血加了这个小功能,希望你能喜欢)
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npx jja rm <filename>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
如果不想显示该过程的 `log` 信息,可以使用 `-i` 忽略掉:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx jja rm -i filename
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### `update`
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx jja up
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
升级前尽量保证你的功能完善,且 git 目录干净
|
|
42
|
+
|
|
43
|
+
## 文档地址
|
|
44
|
+
|
|
45
|
+
参看 [https://earthnut.dev/jja/](https://earthnut.dev/jja/)
|
package/bin/index.js
ADDED
package/mjs/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{runOther as r}from"./src/todo/runOther.mjs";import a from"./src/command.mjs";import e,{removeBind as t}from"./src/remove.mjs";import c,{updateBind as s}from"./src/update.mjs";import{packageBind as m,packageManage as i}from"./src/package.mjs";import{clearScreenBind as o,clearScreen as n}from"./src/clearScreen.mjs";import p,{gitBind as f}from"./src/git.mjs";a.bind({...t,...s,...m,...o,...f}).run().isEnd.end;const u=a.args.$arrMap;!async function a(){if(0==u.length)return;const t=u.shift();if(null!=t){switch(Object.keys(t)[0]){case"remove":await e(t.remove);break;case"update":await c(t.update);break;case"clearScreen":case"clearTerminal":await n();break;case"package":await i(t.package);break;case"runOther":await r(t.runOther);break;case"git":await p(t.git)}await a()}}();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isWindows as e}from"a-node-tools";import{execSync as r}from"node:child_process";const c={"clearScreen <cls> (清理终端显示屏幕,同 clearTerminal )":"","clearTerminal <clear> (清理终端显示屏幕,同 clearScreen )":""};async function o(){r(e?"cls":"clear",{stdio:[0,1,2]})}export{o as clearScreen,c as clearScreenBind};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Command as a}from"a-command";var m=new a("jja");export{m as default};
|
package/mjs/src/git.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{question as t,selection as o}from"a-command";import{getDirectoryBy as a,_p as i,runOtherCode as e,readFileToJsonSync as r,pathJoin as c}from"a-node-tools";import n from"./command.mjs";import s from"color-pen";import{isPlainObject as g}from"a-type-of-js";const m={"git (一些关于 git 的操作)":[`commit (git 提交代码,是 ${s.red("commit")} 提交啊,不是 ${s.hex("#666")("push")} 推送)`,"merge (合并两个分支)","tag (给提交打上 tag)"]};async function u(a){g(a)&&(a={value:[]}),a.commit?await d(a.commit.join(" ")):a.merge?await async function(a){if(""==a){const o=await e("git branch -a");console.log(o.data),a=await t({text:"请输入要合并分支的名称",private:!0})}const i=await o({data:["正常快进合并","非快进合并 (--no-ff)","多提交记录合并为一条 (--squash)"],private:!0},"number");await e(`git merge ${a} ${["","--no-ff","--squash"][i]}`)}(a.merge.join("")):a.tag?await async function(){await l(await t({text:"请输入待标记的信息",private:!0}))}():n.help("git")}async function d(o="版本维护",r=!1){const c=a(".git","directory");if(null==c)return i(s.hex("#ff0")("not a git repository(当前目录非 git 储存库)"));const n=await e({code:"git add .",cwd:c});if(!n.success)return null!=console.log(n.error);const g=await e({code:"git status",cwd:c});if(!/nothing to commit, working tree clean/.test(g.data||"")){const a=await e({code:"git add .",cwd:c});if(!a.success)return null!=console.log(a.error);""==o.trim()&&(o=await t({text:"请输入提交信息",private:!0}));const i=await e({code:`git commit -m "${o}"`,cwd:c});return i.success?(i.error&&console.log(i.error),await e({code:"git push",cwd:c}),r&&await l(o),!0):null!=console.log(i.error)}return!1}async function l(t){const o=a("package.json","file",process.cwd());if(null==o)return!0;const i=r(c(o,"package.json")).version;if(!i)return!0;await e({code:`git tag -a v${i} -m '${t}'`,cwd:o}),await e({code:"git push origin --tag",cwd:o})}export{u as default,m as gitBind,d as gitCommit};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getDirectoryBy as e,_p as n,readFileToJsonSync as t,pathJoin as a,runOtherCode as o,getNpmPkgInfo as s,cursorMoveUp as i,cursorAfterClear as c}from"a-node-tools";import r from"./command.mjs";import p from"color-pen";const f={"package <pkg> (包管理)":["--diff <-d> (分析当下包的差异,该功能很鸡肋,因为线上更新比较慢)",`--upDependencies <-u> (更新依赖,跟 ${p.random("npm update")} 一样)`]};async function l(e){e["--upDependencies"]?await u(!0):e["--diff"]?await m(!0):r.help("package")}async function u(s=!0){const r=e("package.json","file");if(null==r)return n("当前目录下不存在 package.json 文件");const f=t(a(r,"package.json")).dependencies||{};if(s&&n(p.green("初始化完成,等待下一步命令")),Object.keys(f).length>0){let e="npm install --save";for(let n=Object.keys(f),t=n.length,a=0;a<t;a++){e+=` ${n[a]}@latest `}await o(e)}var l;s&&n(p.cyan("正在更新 dev 依赖")),await o("npm update --save"),s&&(l="开发依赖更新完毕",i(),c(),n(l))}async function m(o=!1){const i=e("package.json","file");if(null==i)return[];const c=t(a(i,"package.json"))||{},r=c.name,f=c.version;if(!f)return n(p.hex("#25f9aa")(`未检测到当前包 ${r} 的版本号`)),[];const l=await s(r);if(0==Object.keys(l).length)return[f];if(l.name!==r)return[f];if(o){const e=p.hex("#931")(`当前包本地版本为: ${f}`);n(e);let t=`${" ".repeat(6)}线上版本为:${l.version}`;t+=l.version==f?"":p.hex("#668")("(线上更新有延迟)"),n(p.hex("#399")(t));const a=new Date(l.capsule.lastPublish.time).getTime();n(a.toString())}return[f,l.version]}export{m as diffPackage,f as packageBind,l as packageManage,u as updateDependence};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pen as o}from"color-pen";import{_p as e,isWindows as c,fileExist as r,runOtherCode as i}from"a-node-tools";const s={"remove <rm> (做一个简单的兼容的移除文件或文件夹的命令)":["--ignore <-i> (不打印日志(默认打印的))","--subdirectories <-s> (这是一个危险的命令,用于 windows 下递归删除执行命令下所有的给定文件名称)"]},a={log:!1,subdirectories:!1};async function t(r){const i=r.value||[],s=r["--ignore"],t=r["--subdirectories"];for(s&&(a.log=!0,i.concat(s)),t&&(a.subdirectories=!0,i.concat(t)),a.log||e(o.brightCyan("当前系统为: ".concat(c?"windows":"linux/mac"))),0==i.length&&e(o.random("没有待清理的文件/文件夹"));i.length;)await n(i.pop())}async function n(c){!a.log&&e(o.hex("#336")(`当前清理文件为 ${c}`));const i=r(c);!a.log&&e(o.hex("#666")(`正在检测 ${c} 文件/夹是否存在`)),i?await l(u,[c,i]):!a.log&&e(o.yellow(`${c} 文件不存在`))}async function l(c,r,i=5){return!await Reflect.apply(c,void 0,r)&&i--?(e(o.green("执行失败,现在重试中")),await l(c,r,i)):await Reflect.apply(c,void 0,r)}async function u(r,s){!a.log&&e(o.hex("#aaa")(` ${r} 文件/夹存在,准备删除`));let t={error:null};return c?s.isDirectory()?(t=await i(`rd /q /s ${r.replace(/\//,"\\")}`),d(r,t.success)):s.isFile()&&(t=await i({code:`del ${a.subdirectories?"/s":""} /q ${r.replace(/\//,"\\")}`}),d(r,t.success)):(t=await i({code:`rm -rf ${r.replace(/\\/,"/")}`}),d(r,t.success)),!!t.success||void 0!==console.log(t.error)}function d(o,c){e(`清理 ${o} 文件${c?"完成":"失败"}`)}export{t as default,s as removeBind};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileToJsonSync as n,runOtherCode as t}from"a-node-tools";async function o(o){const{value:a}=o;if(0==a.length)return;const r=n("package.json").scripts;if(1==a.length&&r[a[0]])return await t(`npm run ${a[0]}`);await t(a.join(" "))}export{o as runOther};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{runOtherCode as t,_p as n,getDirectoryBy as e}from"a-node-tools";import{question as i,selection as a}from"a-command";import o from"./command.mjs";import{gitCommit as r}from"./git.mjs";import{updateDependence as p,diffPackage as m}from"./package.mjs";import c from"color-pen";const s=c.green,l={"update <up> (做一个简单的 npm 升级程序,对,简单的)":["--ignore <-i> (不建议你这么用,你会发现你像个傻子一样在那等结果)",`--dependencies <-d> (更新依赖,跟 ${c.random("npm update")} 一样)`,"--npm-publish <-n> (用于 npm 包的升级(自带 git 清理,不三克))"]},u={npmUpdate:!1,log:!0,gitCommit:!1};async function $(l){if(0==Object.keys(l).length)return o.help("update");const $=l["--npm-publish"],f=Boolean(l["--dependencies"]);if(u.log=!l["--ignore"],$)return u.npmUpdate=!0,await async function(){g(c.hex("#9ff")("开始初始化")),"更新"==await i({text:"更新依赖",tip:["跳过","更新"],private:!0})&&await p(u.log),g(c.hex("#666")("请等待更新包(你的 package.json 的 scripts 最好有 build 命令)"));const l=await t("npm run build");l.success||(console.log(l.error),o.end);g(s("打包完成")),await async function(){if(null==e("package.json","file"))return n("当前工作目录下或父级存在 package.json");const i=await m();if(i.length<2)return 1==i.length;if(i[0]!=i[1])return n(`当前版本为:${c.cyan(i[0])}\n线上版本为: ${c.brightRed(i[1])}\n请保持一致`);g("请选择本次更新版本的类型");const o=i[0];let r,p=0,l=0,u=0;i[0].includes("-")?[p,r]=o.split("-"):p=o;[p,l,u]=p.split("."),p=Number(p),l=Number(l),u=Number(u);const $=await a([`bug (patch) v${o} -> ${p}.${l}.${null==r?u+1:u}`,`新内容 (minor) v${o} -> ${p}.${l+1}.0`,`大换代 (major) v${o} -> ${p+1}.0.0`,`测试版本 (prepatch) v${o} -> ${p}.${l}.${u+1}-0`,`内测版本 (preminor) v${o} -> ${p}.${l+1}.0-0`,`公测版本 (premajor) v${o} -> ${p+1}.0.0-0`,`测试迭代 (prerelease) v${o} -> ${p}.${l}.${null==r?u+1:u}-${null==r?0:Number(r)+1}`]);return g(s("请等待整理版本内容")),await t(`npm version ${$.replace(/.*\((.*)\).*/,"$1")} --no-git-tag-version --force`),!0}()||o.end;if(g(s("版本整理完毕,准备上到 npm")),"提交"==await i({text:"是否需要提交代码?",tip:["跳过","提交"]})){const t=await i({text:"提交说明",private:!0});await async function(t){g(c.cyan("正在整理 git 内容")),await r(t,!0)?(u.gitCommit=!0,g(s("git 内容整理完毕"))):g("git 工作区很干净")}(t)}await t("npm publish"),g(s("上推 npm 包完毕"))}();f&&await p(u.log)}function g(t){return u.log&&n(t),!0}export{$ as default,l as updateBind};
|
package/package.json
CHANGED
|
@@ -1,31 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jja",
|
|
3
|
-
"version": "0.0.0",
|
|
4
3
|
"type": "module",
|
|
5
|
-
"
|
|
6
|
-
"author":
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
"version": "1.0.1",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "earthnut",
|
|
7
|
+
"email": "earthnut.dev@outlook.com",
|
|
8
|
+
"url": "https://earthnut.dev"
|
|
9
|
+
},
|
|
10
|
+
"description": "一些在终端的执行动作",
|
|
10
11
|
"files": [
|
|
11
|
-
"
|
|
12
|
+
"bin",
|
|
13
|
+
"mjs"
|
|
12
14
|
],
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/lmssee/npm-earthnut-vue/issues"
|
|
15
|
-
},
|
|
16
15
|
"keywords": [
|
|
17
|
-
"
|
|
16
|
+
"ixxx",
|
|
17
|
+
"jja"
|
|
18
18
|
],
|
|
19
|
+
"license": "ISC",
|
|
19
20
|
"repository": {
|
|
20
21
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/
|
|
22
|
+
"url": "git+https://github.com/earthnutDev/jja.git"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://earthnut.dev/jja",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/earthnutDev/jja/issues",
|
|
27
|
+
"email": "earthnut.dev@outlook.com"
|
|
22
28
|
},
|
|
23
29
|
"publishConfig": {
|
|
24
30
|
"access": "public",
|
|
25
|
-
"registry": "https://registry.npmjs.org"
|
|
31
|
+
"registry": "https://registry.npmjs.org/"
|
|
26
32
|
},
|
|
27
33
|
"dependencies": {
|
|
28
|
-
"a-
|
|
29
|
-
"
|
|
34
|
+
"a-command": ">=0.1.0 <1.0.0",
|
|
35
|
+
"a-js-tools": ">=0.1.3 <1.0.0",
|
|
36
|
+
"a-node-tools": ">=0.1.2 <1.0.0",
|
|
37
|
+
"a-type-of-js": ">=0.1.6",
|
|
38
|
+
"color-pen": ">=0.1.1 <1.0.0"
|
|
39
|
+
},
|
|
40
|
+
"bin": {
|
|
41
|
+
"jja": "bin/index.js"
|
|
30
42
|
}
|
|
31
|
-
}
|
|
43
|
+
}
|
package/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { readFileToJsonSync } from "a-node-tools";
|
|
2
|
-
import { default as pen } from "color-pen";
|
|
3
|
-
import { writeFileSync } from "node:fs";
|
|
4
|
-
|
|
5
|
-
const fileInfo = readFileToJsonSync("./info.json");
|
|
6
|
-
|
|
7
|
-
const npmLists = fileInfo.objects
|
|
8
|
-
.map((i) => i.package.name)
|
|
9
|
-
.filter((name) => name.length < 4)
|
|
10
|
-
.sort()
|
|
11
|
-
.reduce((accumulator, currentName, i) => {
|
|
12
|
-
// const pkgName = pen.hex(i % 255)(currentName);
|
|
13
|
-
// if (i % 3 === 2) {
|
|
14
|
-
// accumulator += pen(`${currentName.padEnd(36, " ")}\n${" ".repeat(4)}`);
|
|
15
|
-
// } else {
|
|
16
|
-
// accumulator += `${currentName.padEnd(36, " ")}`;
|
|
17
|
-
// }
|
|
18
|
-
accumulator += `${currentName.padEnd(3, " ")}\n`;
|
|
19
|
-
return accumulator;
|
|
20
|
-
}, " ".repeat(4));
|
|
21
|
-
|
|
22
|
-
console.log(npmLists);
|
|
23
|
-
|
|
24
|
-
writeFileSync("./npm-lists.txt", npmLists);
|