create-a-npm 0.0.4 → 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/LICENSE +13 -1
- package/bin.mjs +2 -0
- package/package.json +29 -49
- package/src/ask-for-name/carryRange.mjs +1 -0
- package/src/ask-for-name/createCatalog.mjs +1 -0
- package/src/ask-for-name/index.mjs +1 -0
- package/src/ask-for-name/nameIsNotEligible.mjs +1 -0
- package/src/ask-for-name/read-name.mjs +1 -0
- package/src/command.mjs +1 -0
- package/src/createChild/createChangeLog.mjs +1 -0
- package/src/createChild/createIndex.mjs +1 -0
- package/src/createChild/createLicense.mjs +1 -0
- package/src/createChild/createPackage.mjs +1 -0
- package/src/createChild/createReadMe.mjs +1 -0
- package/src/createChild/createRollup.mjs +1 -0
- package/src/createChild/createRollupEg.mjs +1 -0
- package/src/createChild/createScripts.mjs +1 -0
- package/src/createChild/createTest.mjs +1 -0
- package/src/createChild/createTs.mjs +1 -0
- package/src/createChild/index.mjs +1 -0
- package/src/createNpm.mjs +1 -0
- package/src/createRange/createAction.mjs +1 -0
- package/src/createRange/createLicense.mjs +1 -0
- package/src/createRange/createPackage.mjs +1 -0
- package/src/createRange/createReadMe.mjs +1 -0
- package/src/createRange/createScripts/checkVersionInstall.mjs +1 -0
- package/src/createRange/createScripts/detectChanges.mjs +1 -0
- package/src/createRange/createScripts/index.mjs +1 -0
- package/src/createRange/createScripts/pub.mjs +1 -0
- package/src/createRange/createScripts/workflowDispatch.mjs +1 -0
- package/src/createRange/createTs.mjs +1 -0
- package/src/createRange/eslint-config.mjs +1 -0
- package/src/createRange/git-ignore.mjs +1 -0
- package/src/createRange/index.mjs +1 -0
- package/src/createRange/markdown.mjs +1 -0
- package/src/createRange/prettier.mjs +1 -0
- package/src/custom/appendDiy.mjs +1 -0
- package/src/custom/askForDependencies.mjs +1 -0
- package/src/custom/askForInitDependencies.mjs +1 -0
- package/src/custom/askForLastConfig.mjs +1 -0
- package/src/custom/askForWithBin.mjs +1 -0
- package/src/custom/choose-email/choose.mjs +1 -0
- package/src/custom/choose-email/createByName.mjs +1 -0
- package/src/custom/choose-email/getGitConfigUserEmail.mjs +1 -0
- package/src/custom/choose-email/index.mjs +1 -0
- package/src/custom/choose-email/readInputEmail.mjs +1 -0
- package/src/custom/choose-url/choose.mjs +1 -0
- package/src/custom/choose-url/createByName.mjs +1 -0
- package/src/custom/choose-url/index.mjs +1 -0
- package/src/custom/choose-url/readInputUrl.mjs +1 -0
- package/src/custom/choose-user-name/choose.mjs +1 -0
- package/src/custom/choose-user-name/getGitConfigUserName.mjs +1 -0
- package/src/custom/choose-user-name/getMachineUserName.mjs +1 -0
- package/src/custom/choose-user-name/index.mjs +1 -0
- package/src/custom/choose-user-name/readInputUserName.mjs +1 -0
- package/src/custom/index.mjs +1 -0
- package/src/custom/readLocalValue.mjs +1 -0
- package/src/data-store/eslintText.mjs +1 -0
- package/src/data-store/gitIgnoreText.mjs +1 -0
- package/src/data-store/index.mjs +1 -0
- package/src/data-store/licenseText.mjs +1 -0
- package/src/data-store/origin-dependencies.mjs +1 -0
- package/src/data-store/prettierText.mjs +1 -0
- package/src/dog.mjs +1 -0
- package/src/installDependencies.mjs +1 -0
- package/src/main.mjs +1 -0
- package/src/qqi.mjs +1 -0
- package/src/simple/createAction.mjs +1 -0
- package/src/simple/createPub.mjs +1 -0
- package/src/simple/createRollupEg.mjs +1 -0
- package/src/simple/eslint.mjs +1 -0
- package/src/simple/gitIgnore.mjs +1 -0
- package/src/simple/index.mjs +1 -0
- package/src/simple/markdown.mjs +1 -0
- package/src/simple/package.mjs +1 -0
- package/src/simple/prettier.mjs +1 -0
- package/src/simple/rollup.mjs +1 -0
- package/src/simple/tsconfig.mjs +1 -0
- package/src/utils.mjs +1 -0
- package/src/waiting.mjs +1 -0
- package/README.md +0 -20
- package/bin/index.js +0 -3
- package/mjs/index.mjs +0 -17
- package/mjs/src/askForName.mjs +0 -90
- package/mjs/src/command.mjs +0 -17
- package/mjs/src/createNpm.mjs +0 -38
- package/mjs/src/custom.mjs +0 -40
- package/mjs/src/data.mjs +0 -65
- package/mjs/src/library/index.mjs +0 -26
- package/mjs/src/library/indexTs.mjs +0 -23
- package/mjs/src/library/srcIndexTs.mjs +0 -14
- package/mjs/src/package/eslint.mjs +0 -24
- package/mjs/src/package/index.mjs +0 -21
- package/mjs/src/package/package.mjs +0 -74
- package/mjs/src/package/prettier.mjs +0 -53
- package/mjs/src/package/readme.mjs +0 -54
- package/mjs/src/package/rollup.mjs +0 -116
- package/mjs/src/package/tsconfig.mjs +0 -48
- package/mjs/src/test/index.mjs +0 -31
- package/mjs/src/test/testFunction.mjs +0 -25
- package/mjs/src/tools.mjs +0 -25
- package/types/index.d.ts +0 -1
- package/types/src/askForName.d.ts +0 -4
- package/types/src/command.d.ts +0 -11
- package/types/src/createNpm.d.ts +0 -4
- package/types/src/custom.d.ts +0 -21
- package/types/src/data.d.ts +0 -25
- package/types/src/library/index.d.ts +0 -4
- package/types/src/library/indexTs.d.ts +0 -2
- package/types/src/library/srcIndexTs.d.ts +0 -2
- package/types/src/library/testFunction.d.ts +0 -7
- package/types/src/package/eslint.d.ts +0 -5
- package/types/src/package/index.d.ts +0 -5
- package/types/src/package/package.d.ts +0 -2
- package/types/src/package/prettier.d.ts +0 -8
- package/types/src/package/readme.d.ts +0 -6
- package/types/src/package/rollup.d.ts +0 -8
- package/types/src/package/tsconfig.d.ts +0 -8
- package/types/src/test/index.d.ts +0 -8
- package/types/src/test/testFunction.d.ts +0 -9
- package/types/src/tools.d.ts +0 -14
package/LICENSE
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
# MIT License
|
|
2
2
|
|
|
3
|
+
Copyright (c) <2024> <earthnut.dev>
|
|
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
|
|
5
7
|
copyright notice and this permission notice appear in all copies.
|
|
@@ -11,3 +13,13 @@ 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
15
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
|
|
17
|
+
# MIT 许可证
|
|
18
|
+
|
|
19
|
+
版权所有 (c) [2024] [花生亻]
|
|
20
|
+
|
|
21
|
+
特此免费授予任何获得本软件及相关文档文件(以下简称“软件”)副本的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、再许可和/或出售该软件副本的权利,并允许向其提供该软件的人这样做,但须遵守以下条件:
|
|
22
|
+
|
|
23
|
+
上述版权声明和本许可声明应包含在所有副本或软件的重要部分中。
|
|
24
|
+
|
|
25
|
+
软件按“原样”提供,不附带任何形式的明示或暗示的保证,包括但不限于适销性、特定用途适用性和不侵权的保证。在任何情况下,作者或版权持有人均不对因合同、侵权或其他方式引起的任何索赔、损害或其他责任负责,无论是在与软件或软件的使用或其他交易有关的任何诉讼中。
|
package/bin.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,68 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-a-npm",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "一个一键生成一个符合特定规则 <就是一个简单的代码模板库> 的 npm 包",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@color-pen/static": "^1.0.0",
|
|
9
|
+
"@qqi/dev-log": "^1.0.4",
|
|
10
|
+
"a-command": "^2.3.8",
|
|
11
|
+
"a-js-tools": "^1.0.0",
|
|
12
|
+
"a-node-tools": "^4.2.6",
|
|
13
|
+
"a-type-of-js": "^1.0.1",
|
|
14
|
+
"color-pen": "^2.0.10",
|
|
15
|
+
"colored-table": "^0.0.2",
|
|
16
|
+
"qqi": "^0.0.4"
|
|
17
|
+
},
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "🥜",
|
|
20
|
+
"email": "earthnut.dev@outlook.com",
|
|
21
|
+
"url": "https://earthnut.dev"
|
|
18
22
|
},
|
|
19
23
|
"files": [
|
|
20
|
-
"
|
|
21
|
-
"mjs
|
|
22
|
-
"types/"
|
|
24
|
+
"src",
|
|
25
|
+
"bin.mjs"
|
|
23
26
|
],
|
|
24
27
|
"keywords": [
|
|
25
|
-
"
|
|
26
|
-
"create-a-
|
|
28
|
+
"crate-a-npm",
|
|
29
|
+
"create-a-pkg",
|
|
30
|
+
"earthnut"
|
|
27
31
|
],
|
|
28
|
-
"license": "ISC",
|
|
29
32
|
"repository": {
|
|
30
33
|
"type": "git",
|
|
31
|
-
"url": "git+https://github.com/
|
|
34
|
+
"url": "git+https://github.com/earthnutDev/create-a-npm.git"
|
|
32
35
|
},
|
|
33
|
-
"homepage": "https://
|
|
36
|
+
"homepage": "https://earthnut.dev/create-a-npm",
|
|
34
37
|
"bugs": {
|
|
35
|
-
"url": "https://github.com/
|
|
36
|
-
"email": "
|
|
38
|
+
"url": "https://github.com/earthnutDev/create-a-npm/issues",
|
|
39
|
+
"email": "earthnut.dev@outlook.com"
|
|
37
40
|
},
|
|
38
41
|
"publishConfig": {
|
|
39
42
|
"access": "public",
|
|
40
43
|
"registry": "https://registry.npmjs.org/"
|
|
41
44
|
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"@eslint/js": "^9.9.1",
|
|
44
|
-
"@rollup/plugin-commonjs": "^25.0.8",
|
|
45
|
-
"@rollup/plugin-json": "^6.1.0",
|
|
46
|
-
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
47
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
48
|
-
"@rollup/plugin-typescript": "^11.1.6",
|
|
49
|
-
"@types/node": "^20.16.2",
|
|
50
|
-
"eslint": "^8.57.0",
|
|
51
|
-
"eslint-config-prettier": "^9.1.0",
|
|
52
|
-
"globals": "^15.9.0",
|
|
53
|
-
"prettier": "^3.3.3",
|
|
54
|
-
"rollup": "^4.21.1",
|
|
55
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
56
|
-
"rollup-plugin-copy": "^3.5.0",
|
|
57
|
-
"typescript": "^5.5.4",
|
|
58
|
-
"typescript-eslint": "^7.18.0"
|
|
59
|
-
},
|
|
60
45
|
"bin": {
|
|
61
|
-
"create-a-npm": "bin
|
|
62
|
-
},
|
|
63
|
-
"dependencies": {
|
|
64
|
-
"a-command": "^0.0.4",
|
|
65
|
-
"a-js-tools": "^0.0.0",
|
|
66
|
-
"a-node-tools": "^0.0.5"
|
|
46
|
+
"create-a-npm": "bin.mjs"
|
|
67
47
|
}
|
|
68
|
-
}
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isUndefined as a}from"a-type-of-js";import{greenPen as o}from"color-pen";import{command as e}from"../command.mjs";import{dataStore as r}from"../data-store/index.mjs";import{exitProgram as t}from"../utils.mjs";async function i(i){const m=await e.selection({info:"检测到当前文件包含域",data:[{value:0,label:"子包模式",tip:`默认您是在${o(i.replace(/^@(.*)\/.*$/,"$1").concat("/packages"))}目录下`},{value:1,label:"嵌套模式",tip:`默认为您创建 ${o(i.replace(/@/,"").replace(/\//,"/packages/"))}`}]});if(a(m))return await t();r.carryRange=Boolean(m)}export{i as carryRange};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{waiting as t}from"../waiting.mjs";import{command as r}from"../command.mjs";import{isUndefined as o}from"a-type-of-js";import{dirEmpty as a,getNpmPkgInfo as i}from"a-node-tools";import{brightRedPen as m,magentaPen as e,hexPen as n}from"color-pen";import{dataStore as s}from"../data-store/index.mjs";import{mkdirSync as p}from"node:fs";import{exitProgram as c}from"../utils.mjs";import{dog as f,dun as d}from"../dog.mjs";import{carryRange as u}from"./carryRange.mjs";async function g(g){s.childPkg=s.carryRange=!1,g.startsWith("@")&&(s.childPkg=!0,await u(g));const l=g.startsWith("@")?s.carryRange?g.replace(/@/,"").replace(/\//,"/packages/"):g.replace(/^.*\/(.*)$/,"$1"):g;f("获取当前的目录",l);const j=a(l);if(0==j){const t=["更换为其他名称","直接退出"],a=await r.question({text:`当前目录下存在非空同名文件夹(${m(g)})`,tip:t});return!(!o(a)&&a!==t[1])&&await c()}t.run({info:"正在检测 npm 是否有该同名包"});const w=d&&await i(g)||{data:void 0};if(t.destroyed(),f("获取线上的 npm 包数据",w),w.data){const t=["更改为其他名称","忽视并继续","直接退出"],a=await r.question({text:n("#f63")`当前包名称(${e(g)})已经存在于 npm 中`,tip:t});if(o(a)||a===t[2])return await c();if(a===t[0])return!1}return s.name=g,-1===j&&p(l,{recursive:!0}),!0}export{g as createCatalog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dog as t}from"../dog.mjs";import{command as a}from"../command.mjs";import{isBusinessEmptyString as m,isFalse as o}from"a-type-of-js";import{readName as r}from"./read-name.mjs";import{createCatalog as e}from"./createCatalog.mjs";import{nameIsNotEligible as i}from"./nameIsNotEligible.mjs";import{sleep as s}from"a-js-tools";async function n(f=!0){let g=f&&a.args.$original[0]||"";if(t("当前获取的输入名称",g),m(g)&&(g=await r()),g=g.trim().replace(/\s+/gm,"-"),m(g)||/^[^a-z@]/.test(g)||/^[a-z0-9][a-z0-9.\-_]*\/[a-z0-9.\-_]*$/.test(g)||g.length>212||/[A-Z]/gm.test(g)||/\s/.test(g)||/.*\/.*\/.*/.test(g)||/^[@a-z].*@.*$/gm.test(g)||/^[^a-z0-9@/\-_.]+$/gm.test(g))return await i(),await s(100),await n(!1);const p=await e(g);return o(p)?await n(!1):void 0}export{n as askForName};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hexPen as o}from"color-pen";import{command as t}from"../command.mjs";import{isUndefined as m}from"a-type-of-js";import{exitProgram as r}from"../utils.mjs";async function i(){const i=["重新输入","退出"],f=await t.question({text:o("#f63")("您的输入为字符非法")+"重新输入或退出",tip:i});if(m(f)||f===i[1])return await r()}export{i as nameIsNotEligible};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isUndefined as e}from"a-type-of-js";import{command as r}from"../command.mjs";import{exitProgram as i}from"../utils.mjs";import{magentaPen as o}from"color-pen";async function n(){const n=await r.question({text:"您即将创建的包名",tip:"请使用空格/连字符(-)做分隔符",minLen:1,maxLen:212,verify:[{reg:/^[a-z@]/,info:"首字符应为小写英文字符或 @"},{reg:/[A-Z]/,info:"不应当有大些英文字符",inverse:!0},{reg:/^[^@].*\/.*/,info:`仅当为范围时才可以包含 ${o`/`} 符号`,inverse:!0},{reg:/.*\/.*\/.*/,info:`仅只能包含一个 ${o`/`} 符号`,inverse:!0},{reg:/^[@a-z].*@.*$/,info:`${o`@`} 仅允许在首位出现`,inverse:!0},{reg:/^[a-z0-9@/\-_.]+$/,info:`仅允许 ${o`-`}、${o`_`} 字符出现`}]});return e(n)?await i("您选择退出,清稍等"):n}export{n as readName};
|
package/src/command.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Command as n}from"a-command";const m=new n("create-a-npm");m.run().isEnd(!0);export{m as command};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as t}from"node:fs";import{dataStore as e}from"../data-store/index.mjs";function n(){const n=(()=>{const t=new Date;return`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`})();t(e.pkgFile("CHANGELOG.md"),`# 更新日志 📔\n\n## v0.0.0 (${n})\n`)}export{n as createChangeLog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mkdirSync as e,writeFileSync as n}from"node:fs";import{dataStore as o}from"../data-store/index.mjs";function s(){const{dependencies:s}=o.local,i=s.includes("typescript");e(o.pkgFile("src"),{recursive:!0}),n(o.pkgFile("index."+(i?"ts":"js")),(0!==o.bin?"#!/usr/bin/env node\n\n":"")+"export { sayHello } from './src/index';"),n(o.pkgFile("src/index."+(i?"ts":"js")),"\n \rexport function sayHello() {\n console.log('哈喽');\n }\n ")}export{s as createIndex};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as o}from"node:fs";import{dataStore as t}from"../data-store/index.mjs";import{licenseText as e}from"../data-store/licenseText.mjs";function r(){o(t.pkgFile("LICENSE"),e())}export{r as createLicense};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeJsonFile as e}from"a-node-tools";import{dataStore as n}from"../data-store/index.mjs";function o(){const{dependencies:o}=n.local,p=o.includes("typescript"),s={type:"module",version:"0.0.0",name:n.name,description:"写点什么吧,空白只本应存在于虚空",scripts:{b:"rollup --config rollup.config.js"+(p||1!==n.bin?" && tsc -p tsconfig.types.json":""),build:"npm run b && npm run clean:package",test:"jja rm .eg && rollup --config rollup.config.eg.js && node .eg/index.mjs","push:version":"gvv",push:"gvv",diff:"jja pkg --diff=官方",vjj:"vjj",prepublishOnly:"pjj","clean:package":"node scripts/clean-package-json.js"},license:"MIT"};e(n.pkgFile("package.json"),s)}export{o as createPackage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as o}from"node:fs";import{dataStore as s}from"../data-store/index.mjs";function e(){const{author:e}=s.local,{name:n,url:m}=e;o(s.pkgFile("README.md"),`# ${s.name}\n\r\n[&label=版本号&labelColor=rgb(73,73,228)&color=rgb(0,0,0)>)](https://www.npmjs.com/package/${s.name}) [?logo=github>)](https://github.com/${n.replace(/\s+/g,"_")}/${s.name}/issues)\n \n## 文档地址\n\n参看 [${m}/${s.name}](${m}/${s.name})`)}export{e as createReadMe};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as n}from"node:fs";import{dataStore as e}from"../data-store/index.mjs";function o(){const{dependencies:o}=e.local,r=o.includes("typescript");n(e.pkgFile("rollup.config.js"),`${r?"import typescript from '@rollup/plugin-typescript';":"+++++"}\nimport resolve from '@rollup/plugin-node-resolve';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport cleanup from 'rollup-plugin-cleanup';\nimport copy from 'rollup-plugin-copy';\nimport { external } from '@qqi/rollup-external';\n\nexport default {\n input: './index.${r?"ts":"js"}',\n output: \n ${1!==e.bin?"[{\n format: 'es',\n entryFileNames: '[name].mjs',\n preserveModules: true,\n sourcemap: false,\n exports: 'named',\n dir: 'dist/',\n },{\n format: 'cjs',\n entryFileNames: '[name].cjs',\n preserveModules: true,\n sourcemap: false,\n exports: 'named',\n dir: 'dist/',\n },],":"{\n format: 'es',\n entryFileNames: '[name].mjs',\n preserveModules: false,\n sourcemap: false,\n exports: 'named',\n dir: 'dist/',\n },"}\n // 配置需要排除的或包含包\n external: external(),\n plugins: [\n resolve(),\n commonjs(),\n json(),\n ${r?"typescript({\n tsconfig: './tsconfig.rollup.json',\n exclude: ['node_modules', 'test'],\n }),":"+++"}\n // 去除无用代码\n cleanup(),\n copy({\n targets: [\n { src: 'README.md', dest: 'dist' },\n { src: 'LICENSE', dest: 'dist' },\n ],\n }),\n ],\n};\n`.replace(/\+{2,}\n?/gm,""))}export{o as createRollup};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as n}from"node:fs";import{dataStore as o}from"../data-store/index.mjs";function e(){const{dependencies:e}=o.local,r=e.includes("typescript");n(o.pkgFile("rollup.config.eg.js"),`${r?"import typescript from '@rollup/plugin-typescript';":""}\nimport resolve from '@rollup/plugin-node-resolve';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport cleanup from 'rollup-plugin-cleanup';\nimport { external } from '@qqi/rollup-external';\n\n/** 生成 npm 文件的打包配置文件 */\nexport default {\n input: './eg/index.${r?"ts":"js"}',\n output:{\n format: 'es',\n entryFileNames: '[name].mjs',\n preserveModules: false,\n sourcemap: false,\n exports: 'named',\n dir: '.eg/',\n },\n // 配置需要排除的包\n external: external({ ignore: ['node:'] }),\n plugins: [\n resolve(),\n commonjs(),\n // 可打包 json 内容\n json(),\n ${r?"\ntypescript({\ntsconfig: './tsconfig.rollup.json',\n}),\n":""}\n // 去除无用代码\n cleanup(),\n ],\n};\n`)}export{e as createRollupEg};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pathJoin as n}from"a-node-tools";import{mkdirSync as e,writeFileSync as s}from"node:fs";import{dataStore as t}from"../data-store/index.mjs";function i(){e(n(t.pkgFile("scripts")),{recursive:!0});const{author:i}=t.local,o=t.name.replace(/^@/,"");s(t.pkgFile("scripts/clean-package-json.js"),`\nimport {\n pathJoin,\n readFileToJsonSync,\n getDirectoryBy,\n writeJsonFile,\n} from 'a-node-tools';\n\nlet packageJson = readFileToJsonSync('./package.json');\n\n['scripts', 'devDependencies', 'lint-staged', 'private'].forEach(\n key => delete packageJson[key],\n);\n\npackageJson = {\n main: 'index.cjs',\n module: 'index.mjs',\n types: 'index.d.ts',\n ...packageJson,\n publishConfig: {\n access: 'public',\n registry: 'https://registry.npmjs.org/',\n },\n files: ['index.d.ts', 'index.mjs', 'index.cjs', 'src'],\n exports: {\n '.': {\n import: {\n default: './index.mjs',\n types: './index.d.ts',\n },\n require: {\n default: './index.cjs',\n types: './index.d.ts',\n },\n },\n },\n repository: {\n type: 'git',\n url: 'git+https://github.com/${i.name}/${o}.git',\n },\n author: {\n name: '${i.name}',\n email: '${i.email}',\n url: '${i.url}',\n },\n browserslist: ['node>=18.0.0'],\n engines: {\n node: '>=18.0.0',\n },\n keywords: ['${o}'],\n homepage: '${i.url}',\n bugs: {\n url: 'https://github.com/${i.name}/${o}/issues',\n email: '${i.email}',\n },${0!==t.bin?`\n bin: {\n ${t.name} : './bin.mjs',\n },\n `:""}\n};\n\n{\n const distPath = getDirectoryBy('dist', 'directory');\n\n const distPackagePath = pathJoin(distPath, './dist/package.json');\n\n writeJsonFile(distPackagePath, packageJson);\n}\n`)}export{i as createScripts};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mkdirSync as e,writeFileSync as o}from"node:fs";import{dataStore as i}from"../data-store/index.mjs";function n(){const{dependencies:n}=i.local,s=n.includes("typescript")?"ts":"js";e(i.pkgFile("eg"),{recursive:!0}),o(i.pkgFile("eg/index."+s),"import { sayHello } from '../index';\n sayHello(); \n")}export{n as createTest};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as n}from"node:fs";import{dataStore as e}from"../data-store/index.mjs";function t(){1!==e.bin&&n(e.pkgFile("tsconfig.types.json"),'/** 该文件打包前使用 */\n{\n "extends": "../../tsconfig.base.json",\n "compilerOptions": {\n "emitDeclarationOnly": true,\n "declaration": true,\n "declarationDir": "dist/"\n // "types": ["node"],\n },\n "exclude": ["node_modules", "dist", "**/*.test.ts", "eg", "jest.setup.ts"]\n}\n'),n(e.pkgFile("tsconfig.rollup.json"),'{\n "extends": "./tsconfig.types.json",\n "compilerOptions": {\n "declarationDir": null,\n "declaration": false\n },\n "include": ["eg", "eg/*.ts", "src/**/*.ts", "./index.ts"],\n "exclude": ["node_modules", "**/*.test.ts"]\n}\n')}export{t as createTs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dataStore as e}from"../data-store/index.mjs";import{createTs as r}from"./createTs.mjs";import{createRollup as m}from"./createRollup.mjs";import{createReadMe as o}from"./createReadMe.mjs";import{createPackage as t}from"./createPackage.mjs";import{createLicense as s}from"./createLicense.mjs";import{createIndex as i}from"./createIndex.mjs";import{createChangeLog as p}from"./createChangeLog.mjs";import{writeFileSync as c}from"node:fs";import{createScripts as a}from"./createScripts.mjs";import{createTest as f}from"./createTest.mjs";import{createRollupEg as n}from"./createRollupEg.mjs";function j(){const{dependencies:j}=e.local;j.includes("typescript")&&r(),m(),n(),o(),t(),s(),i(),p(),c(e.pkgFile("todo.md"),"# 代办\n\n"),a(),f()}export{j as createChild};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{askForName as m}from"./ask-for-name/index.mjs";import i from"./custom/index.mjs";import{packageIndex as o}from"./simple/index.mjs";import{dataStore as r}from"./data-store/index.mjs";import{dog as e}from"./dog.mjs";import{createRange as t}from"./createRange/index.mjs";import{createChild as a}from"./createChild/index.mjs";async function n(){return e("开始构建应用"),""==r.name?(await m(),await i(),void await n()):r.childPkg?(r.carryRange&&t(),void a()):void o()}export{n as createNpm};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mkdirSync as n,writeFileSync as e}from"node:fs";import{dataStore as s}from"../data-store/index.mjs";function t(){const t=".github/workflows";n(s.rangeFile(t),{recursive:!0}),e(s.rangeFile(t,"发布.yml"),"name: 发布到 npm\non:\n push:\n branches: '*'\n paths:\n - 'packages/**' # 主包更新\n - 'package.json' # 全局依赖\n\n workflow_dispatch: # 手动触发\n inputs:\n version:\n description: '触发原因(选填)'\n required: false\n default: '手动触发'\n ref:\n description: '分支(选填)'\n required: false\n default: ''\n type: string\n package:\n description: '子包'\n required: true\n type: choice\n options:\n - core\n - all\n default: 'all'\n\njobs:\n pub:\n # 在提交的代码包含 `version` 字样时才运行该动作\n # 或者手动触发\n name: |\n 发布到 npm\n runs-on: ubuntu-latest\n permissions:\n packages: write\n contents: write\n id-token: write\n # 复合条件判断(自动触发检查提交信息,手动触发直接放行)\n # contains 函数\n # startsWith 函数\n # endsWith 函数\n if: |\n (github.event_name == 'push' && startsWith(github.event.head_commit.message, 'version')) ||\n github.event_name == 'workflow_dispatch'\n steps:\n - name: 代码检出\n uses: actions/checkout@v4\n with:\n ref: ${{ github.event.inputs.ref || github.ref_name }}\n fetch-depth: 0\n\n - name: 初始化 Node 并设定 Node 版本\n uses: actions/setup-node@v4\n with:\n node-version: 22.x\n registry-url: https://registry.npmjs.org\n\n - name: 安装全局依赖\n run: |\n npm ci\n cd scripts\n chmod +x detect_changes.sh workflow_dispatch.sh pub.sh\n # chmod +x scripts/detect_changes.sh\n # chmod +x scripts/workflow_dispatch.sh\n # chmod +x scripts/pub.sh\n\n - name: 检测子包变更情况(推送代码时触发)\n if: github.event_name == 'push'\n id: detect-changes\n run: |\n ./scripts/detect_changes.sh\n\n - name: 检测子包变更情况(手动触发时触发)\n if: github.event_name == 'workflow_dispatch'\n id: workflow-changes\n env:\n INPUT_PACKAGE: ${{ github.event.inputs.package }}\n run: |\n ./scripts/workflow_dispatch.sh\n\n - name: 设置工作根路径\n run: |\n echo \"REPO_ROOT=$(pwd)\" >> $GITHUB_ENV\n\n - name: 发布到 npm\n if: ${{ env.update_packages && env.update_packages != '' }}\n env:\n NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}\n UPDATE_PACKAGES: ${{ env.update_packages }}\n REPO_ROOT: ${{ env.REPO_ROOT }}\n run: |\n ./scripts/pub.sh\n\n ")}export{t as createAction};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as o}from"node:fs";import{dataStore as e}from"../data-store/index.mjs";import{licenseText as r}from"../data-store/licenseText.mjs";function t(){o(e.rangeFile("LICENSE"),r())}export{t as createLicense};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeJsonFile as e}from"a-node-tools";import{dataStore as s}from"../data-store/index.mjs";function i(){const{dependencies:i}=s.local,t={name:s.name.replace(/^@(.*)\/.*$/,"$1")+"-root",version:"0.0.0",type:"module",private:!0,description:"改了这里。毕竟,你有自己的话要说",scripts:{diff:"jja pkg --diff=官方",vjj:"vjj",push:"gvv","push:version":"gvv",prepublishOnly:"pjj"},devDependencies:s.buildDevDependencies()};i.includes("husky")&&i.includes("prettier")&&(t["lint-staged"]={"*.{js,ts}":["prettier --write"]},t.scripts.prepare="husky"),i.includes("eslint")&&(t.scripts.eslint="jja cls && eslint packages"),i.includes("prettier")&&(t.scripts.prettier="jja cls && prettier . --write"),e(s.rangeFile("package.json"),t)}export{i as createPackage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as n}from"node:fs";import{dataStore as o}from"../data-store/index.mjs";function r(){n(o.rangeFile("README.md"),"# 你会更改这里的内容的\n \n毕竟,我猜你有很多话要说\n记录下来,哪怕不会有人看见\n ")}export{r as createReadMe};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as n}from"node:fs";import{dataStore as e}from"../../data-store/index.mjs";function i(){n(e.rangeFile("scripts/check_version_install.sh"),'#!/bin/bash\n\ninstall_check_version() {\n # 在子项目的直接\n if ! npm list -g --depth=0 | grep -q " ${CHECK_VERSION}"; then \n echo "当前未全局安装 \'${CHECK_VERSION}\',即将进行安装"\n npm install ${CHECK_VERSION} --global\n else \n echo "包 ${CHECK_VERSION} 已全局安装"\n fi\n}')}export{i as checkVersionInstall};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as n}from"node:fs";import{dataStore as A}from"../../data-store/index.mjs";function e(){n(A.rangeFile("scripts/detect_changes.sh"),'#!/bin/bash\n\n# 获取上一次提交的 SHA\nPREVIOUS_COMMIT=$(git rev-parse HEAD^)\nCURRENT_COMMIT=$(git rev-parse HEAD)\n\n# 获取变更的文件列表\nCHANGED_FILES=$(git diff --name-only $PREVIOUS_COMMIT $CURRENT_COMMIT)\n\n# 初始化变更的包数组\nCHANGED_PACKAGE_ARRAY=()\n\necho "开始循环调用验证函数"\n\nmain() {\n # 遍历变更的文件,找出变更的 packages 下的直接子文件夹\n for file in $CHANGED_FILES; do\n if [[ $file == packages/* ]]; then\n PACKAGE_DIR=$(echo $file | cut -d\'/\' -f2)\n # 如果其不存在于数组之中\n if [[ ! " ${CHANGED_PACKAGE_ARRAY[@]} " =~ " ${PACKAGE_DIR} " ]]; then\n CHANGED_PACKAGE_ARRAY+=("$PACKAGE_DIR") # 文件变更数组添加元素\n fi\n fi\n done\n \n # 将数组转为逗号分隔的字符串\n CHANGED_PACKAGES=$(IFS=,; echo "${CHANGED_PACKAGE_ARRAY[*]}")\n \n # 将变更的数据输出到步骤输出值中\n # echo "update_packages=$CHANGED_PACKAGES" >> $GITHUB_OUTPUT \n # 将变更的包字符串输出到环境变量\n echo "update_packages=$CHANGED_PACKAGES" >> $GITHUB_ENV\n \n printf "\\e[31m检测文件变更的包信息处理完成 \\e[m$CHANGED_PACKAGES \\n"\n}\necho "准备好了么"\nmain\necho "哈哈,执行 🎊 🎊 🎊"\n')}export{e as detectChanges};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mkdirSync as r}from"node:fs";import{dataStore as o}from"../../data-store/index.mjs";import{checkVersionInstall as m}from"./checkVersionInstall.mjs";import{detectChanges as t}from"./detectChanges.mjs";import{pub as s}from"./pub.mjs";import{workflowDispatch as e}from"./workflowDispatch.mjs";function i(){r(o.rangeFile("scripts"),{recursive:!0}),m(),t(),s(),e()}export{i as createScripts};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as n}from"node:fs";import{dataStore as e}from"../../data-store/index.mjs";function i(){n(e.rangeFile("scripts/pub.sh"),'#!/bin/bash\n\n# 获取环境变量中的变更包字符串\nUPDATE_PACKAGES=$UPDATE_PACKAGES\n# 执行根路径\nREPO_ROOT=$REPO_ROOT\n# 发布异常的包\nPUB_ERROR=()\nCHECK_VERSION="@qqi/check-version"\n# 读取版本检测是否可用\nsource ./scripts/check_version_install.sh \necho "工作根路径 $REPO_ROOT"\nPACKAGES_DIR="${REPO_ROOT}/packages"\n# 将字符串转为数组\nIFS=\',\' read -r -a PACKAGE_ARRAY <<< "$UPDATE_PACKAGES"\n \nupdate_version() {\n local input="$1"\n local NAME=$(echo "${input//-/ }" | tr -s \' \') # 替换 - 为空格并删除重复的空格\n local CWD="${PACKAGES_DIR}/$input"\n\n local tag=""\n cd $REPO_ROOT # 每次需要手动更新到根下才能正确的校验版本号\n if ! tag=$(npx "${CHECK_VERSION}" n=${input} 2>&1); then\n echo "未通过版本校验:$tag"\n return 0 \n fi\n echo "获取 ${NAME} 的发布标签为 ${tag}"\n\n if [ ! -d "$CWD" ]; then \n echo "进入项目 $NAME 故障,路径为 ${CWD}"\n return 0\n fi\n cd "$CWD"\n\n # 依赖安装 \n npm ci\n if ! npm run build; then \n echo "构建 $NAME 失败" \n PUB_ERROR+=("$input")\n return 0\n fi\n local BUILD_DIST="${CWD}/dist"\n if [ ! -d "${BUILD_DIST}" ]; then\n echo "未找到 $NAME dist 构建:${BUILD_DIST}"\n PUB_ERROR+=("$input")\n return 0\n fi\n cd "${BUILD_DIST}" \n \n echo "开始发布 $NAME npm 包 ${tag} 版本"\n if ! npm publish --provenance --access public --tag "${tag}" ; then\n echo "💥💥💥 $NAME 发布到 npm 💥💥💥"\n PUB_ERROR+=("$input")\n else \n echo "🪧 $package 发布终结 🫧🫧🫧🫧🫧🫧"\n fi\n}\n\nmain() {\n # 校验版本可用情况\n if [ ! -d "$PACKAGES_DIR" ]; then\n echo "没有找到 ${PACKAGES_DIR}"\n exit 0\n fi\n echo "☁️ 来"\n install_check_version # 检查版本包安装校验\n # 遍历变更的包数组,进行 npm 包推送\n # "${ARR[@]}" 引用数组所有元素\n # "${!ARR[@]}" 引用数组所有索引 ${ARR[$index]}\n # "${#ARR[@]}" 数组长度 \n for package in "${PACKAGE_ARRAY[@]}"; do\n echo "当前执行的推送为 $package"\n update_version "$package"\n done\n\n}\n\necho "准备好了么"\nmain\nif [ ${#PUB_ERROR[@]} -gt 0 ]; then \n echo "发布包 ${PUB_ERROR[@]} 异常 "\nelse \n echo "所有发布均已成功:${PACKAGE_ARRAY[@]}"\n echo "🚀🚀 发布成功,完结 🎉🎉 撒花 🎉🎉"\nfi')}export{i as pub};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as n}from"node:fs";import{dataStore as A}from"../../data-store/index.mjs";function e(){n(A.rangeFile("scripts/workflow_dispatch.sh"),'#!/bin/bash\n\n# 从环境变量中获取手动触发要更新的包数据\nINPUT_PACKAGE=$INPUT_PACKAGE\n# 初始化变更的包数组\nCHANGED_PACKAGE_ARRAY=()\n# 初始化最终要更新的包的数组\nUPDATE_PACKAGE_ARRAY=()\n\n# 读取 packages 下直接子文件夹名并放入到数组 CHANGED_PACKAGE_ARRAY 中 \nwhile IFS= read -r PACKAGE_DIR; do \n PACKAGE_DIR=$(echo "${PACKAGE_DIR// /?}" | tr -s \'?\') # 保护我方空格\n CHANGED_PACKAGE_ARRAY+=("$PACKAGE_DIR")\ndone < <(find packages -mindepth 1 -maxdepth 1 -type d -exec basename {} \\;)\n\ncheck_version() {\n local input="$1"\n local NAME=$(echo "${input//-/ }" | tr -s \' \') # 替换 - 为空格并删除重复的空白字符\n echo "输入:${input}"\n echo "使用:${NAME}"\n \n # 该包是否由手动触发选择\n if [ "$INPUT_PACKAGE" = "all" ] || [ "$INPUT_PACKAGE" = "${input}" ]; then\n echo "手动触发发布且包含 ${NAME}"\n UPDATE_PACKAGE_ARRAY+=("$input")\n return 0\n else\n echo "该包 ${input} 未在手动触发选择"\n return 0\n fi\n}\n\n\nmain() {\n for PACKAGE_NAME in ${CHANGED_PACKAGE_ARRAY[@]}; do \n check_version "$PACKAGE_NAME"\n done\n\n echo "校验版本数据完毕 ${UPDATE_PACKAGE_ARRAY}"\n\n # 将数组转为逗号分隔的字符串\n UPDATE_PACKAGES=$(IFS=,; echo "${UPDATE_PACKAGE_ARRAY[*]}")\n\n # 将变更的包字符串输出到环境变量\n # echo "update_packages=$UPDATE_PACKAGES" >> $GITHUB_OUTPUT \n echo "update_packages=$UPDATE_PACKAGES" >> $GITHUB_ENV\n\n printf "\\e[38;5;164m手动触发的包为 \\e[m$UPDATE_PACKAGES \\n"\n}\necho "准备好了么"\nmain\necho "哈哈,执行 🎊 🎊 🎊"\n')}export{e as workflowDispatch};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as e}from"node:fs";import{dataStore as n}from"../data-store/index.mjs";function s(){e(n.rangeFile("tsconfig.json"),'{\n "extends": "./tsconfig.base.json",\n "include": [\n "packages/**/index.ts",\n "packages/**/src/**/*.ts",\n "packages/**/eg/**/*.ts"\n ],\n "exclude": [\n "node_modules",\n "packages/**/node_modules",\n "packages/**/**/*.test.ts",\n "jest.setup.ts"\n ]\n}\n'),e(n.rangeFile("tsconfig.base.json"),'{\n "compilerOptions": {\n "baseUrl": ".",\n "jsx": "preserve",\n "strict": false,\n "target": "ESNext",\n "module": "ESNext",\n "skipLibCheck": true,\n "esModuleInterop": true,\n "moduleResolution": "Bundler",\n "allowSyntheticDefaultImports": true,\n "isolatedModules": true,\n "lib": ["ESNext", "DOM"],\n "sourceMap": false\n }\n}\n')}export{s as createTs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{eslintText as o}from"../data-store/eslintText.mjs";import{writeFileSync as t}from"node:fs";import{dataStore as e}from"../data-store/index.mjs";function r(){t(e.rangeFile("eslint.config.js"),o())}export{r as eslintConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{gitIgnoreText as o}from"../data-store/gitIgnoreText.mjs";import{writeFileSync as r}from"node:fs";import{dataStore as t}from"../data-store/index.mjs";function e(){r(t.rangeFile(".gitignore"),o())}export{e as gitIgnore};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dataStore as r}from"../data-store/index.mjs";import{createAction as e}from"./createAction.mjs";import{createTs as m}from"./createTs.mjs";import{createReadMe as t}from"./createReadMe.mjs";import{createPackage as o}from"./createPackage.mjs";import{createLicense as i}from"./createLicense.mjs";import{eslintConfig as s}from"./eslint-config.mjs";import{prettier as c}from"./prettier.mjs";import{markdown as n}from"./markdown.mjs";import{gitIgnore as p}from"./git-ignore.mjs";import{createScripts as a}from"./createScripts/index.mjs";function f(){const{dependencies:f}=r.local;f.includes("action")&&(e(),a()),f.includes("typescript")&&m(),t(),o(),i(),f.includes("eslint")&&s(),f.includes("prettier")&&c(),n(),p()}export{f as createRange};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as n}from"node:fs";import{dataStore as o}from"../data-store/index.mjs";function e(){n(o.rangeFile(".markdownlint.json"),'{\n "MD024": false,\n "MD013": false\n}\n')}export{e as markdown};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as r}from"node:fs";import{dataStore as t}from"../data-store/index.mjs";import{gitIgnoreText as e}from"../data-store/gitIgnoreText.mjs";import{prettierText as o}from"../data-store/prettierText.mjs";function i(){r(t.rangeFile(".prettierrc"),o()),r(t.rangeFile(".prettierignore"),e())}export{i as prettier};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(t){const e=Symbol("diy");return t.push({label:"手动输入值",value:e,tip:"使用其他输入名称"}),e}export{t as appendDiy};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{originDependencies as e}from"../data-store/origin-dependencies.mjs";import{isUndefined as i}from"a-type-of-js";import{greenPen as t}from"color-pen";import{command as o}from"../command.mjs";import{dataStore as r}from"../data-store/index.mjs";import{dog as p}from"../dog.mjs";import{qqi as c}from"../qqi.mjs";async function n(){const{local:n}=r,s=n.dependencies,a=[{value:"rollup",tip:"该项为必须项",label:"打包工具 rollup",checked:!0,disable:!0},{value:"typescript",tip:"如果使用 typescript 建议使用该项",label:"使用 "+t`typescript`,checked:s.includes("typescript")},...[["eslint",`使用代码问题工具 ${t`eslint`}`],["prettier",`格式化代码 ${t`prettier`}`],["husky",`git 提交 hook 管理 ${t`husky`}`],["action",`CI/CD 使用自动化构建、发布 ${t`github action`} `]].map((e=>({value:e[0],label:e[1],checked:s.includes(e[0])})))],l=await o.selection({data:a,kind:"check",info:"请选择要使用的辅助功能"});p("用户选择的依赖",l),i(l)?n.dependencies=e:(n.dependencies=l,c.available&&(p("执行储存的数据",n),c.write("config",n)))}export{n as askForDependencies};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isUndefined as t}from"a-type-of-js";import{command as o}from"../command.mjs";import{dataStore as m}from"../data-store/index.mjs";async function i(){const i=["安装","跳过"],a=await o.question({text:"是否安装依赖",tip:i});t(a)||a===i[1]||(m.install=!0)}export{i as askForInitDependencies};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{enArr as e}from"a-js-tools";import{isUndefined as o,isArray as r,isBusinessEmptyString as t,isEmptyArray as i}from"a-type-of-js";import{command as a}from"../command.mjs";import{dataStore as n}from"../data-store/index.mjs";import{dog as m}from"../dog.mjs";import{qqi as s}from"../qqi.mjs";import{exitProgram as c}from"../utils.mjs";async function f(){const f=["name","email","url"],{local:d}=n;if(!s.available)return f;const l=s.read("config");if(o(l?.author))return f;r(l?.dependencies)&&(d.dependencies=l.dependencies);const{author:p}=l,u=Object.keys(p).filter((e=>!t(p[e])&&(d.author[e]=p[e])&&!0)).map((e=>({value:e,label:`${e} : ${p[e]}`,checked:!0})));if(i(u))return f;const j=await a.selection({info:"以下为上次使用配置,选中的项将跳过配置",data:u,kind:"check"});return o(j)?await c():(m("选项的值",j),e.difference(f,j))}export{f as askForLastConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isUndefined as o}from"a-type-of-js";import{greenPen as a}from"color-pen";import{command as t}from"../command.mjs";import{dataStore as i}from"../data-store/index.mjs";async function e(){const e=await t.selection({info:"请选择开发模式",data:[{value:0,label:"仅是可用库",tip:"当前仅是使用的库,譬如:"+a`a-js-tools`},{value:1,label:"仅是可执行库",tip:"当前仅包含可执行内容,譬如:"+a`jja`},{value:2,label:"库 + bin",tip:"即包含可执行又包含可导出使用内容,譬如:"+a`qqi`}]});o(e)||(i.bin=e)}export{e as askForWithBin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isUndefined as o,isType as a}from"a-type-of-js";import{brightBlackPen as m}from"color-pen";import{command as i}from"../../command.mjs";import{dataStore as t}from"../../data-store/index.mjs";import{dun as r,dog as l}from"../../dog.mjs";import{qqi as e}from"../../qqi.mjs";import{exitProgram as f}from"../../utils.mjs";import{readInputEmail as p}from"./readInputEmail.mjs";async function n(n,s){const{author:c}=t.local,j=c.email;let d=await i.selection({data:n,info:"请选择您的通讯邮箱"});if(o(d))return await f();a(d,(o=>o===s))&&(d=await p()),r||l(m("获取当前的用户名 "),d),l("是否执行写入",e.available),t.package.author.email=c.email=d,e.available&&j!==d&&(l("写入的值",t.local),e.write("config",t.local))}export{n as choose};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isBusinessEmptyString as o}from"a-type-of-js";import{dataStore as t}from"../../data-store/index.mjs";function e(e){const{author:a}=t.local;if(o(a.name))return;const r=`${a.name.replace(/\s+/g,"_")}@outlook.com`;e.push({value:r,label:r,tip:"该值由 name 值合成而来"})}export{e as createByName};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{runOtherCode as t}from"a-node-tools";import{isBusinessEmptyString as o}from"a-type-of-js";import{exitProgram as a}from"../../utils.mjs";async function i(i){const r=await t("git config user.email");if(!r.success)return await a("获取本地的 git config user.email 出错\n".concat(r.error||r.data));const e=r.data.replace(/\n$/,"")||"";o(e)||i.push({value:e,tip:"该值从 git 全局配置读取",label:e})}export{i as getGitConfigUserEmail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getGitConfigUserEmail as m}from"./getGitConfigUserEmail.mjs";import{appendDiy as o}from"../appendDiy.mjs";import{choose as r}from"./choose.mjs";import{createByName as t}from"./createByName.mjs";import{readLocalValue as a}from"../readLocalValue.mjs";async function i(){const i=[];await m(i),t(i),a(i,"email");const e=o(i);await r(i,e)}export{i as chooseEmail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isUndefined as t}from"a-type-of-js";import{command as o}from"../../command.mjs";import{exitProgram as m}from"../../utils.mjs";async function i(){const i=await o.question({text:"请输入您将配置的邮箱",maxLen:50,minLen:5,verify:[{reg:/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,info:"需符合邮箱基本模式"}]});return t(i)?await m():i}export{i as readInputEmail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isUndefined as o,isType as r}from"a-type-of-js";import{brightBlackPen as a}from"color-pen";import{command as t}from"../../command.mjs";import{dataStore as m}from"../../data-store/index.mjs";import{dun as i,dog as l}from"../../dog.mjs";import{qqi as e}from"../../qqi.mjs";import{exitProgram as f}from"../../utils.mjs";import{readInputUrl as p}from"./readInputUrl.mjs";async function n(n,s){const{author:c}=m.local,u=c.url;let j=await t.selection({data:n,info:"请配置您的个人网站"});if(o(j))return await f();r(j,(o=>o===s))&&(j=await p()),i||l(a("获取当前的网址 "),j),l("是否执行写入",e.available),m.package.author.url=c.url=j,e.available&&u!==j&&(l("写入的值",m.local),e.write("config",m.local))}export{n as choose};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isBusinessEmptyString as o}from"a-type-of-js";import{dataStore as t}from"../../data-store/index.mjs";function e(e){const{author:a}=t.local;if(o(a.name))return;const r=`${a.name.replace(/\s+/g,"_")}.github.io`;e.push({value:r,label:r,tip:"该值由 name 值合成而来"})}export{e as createByName};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createByName as o}from"./createByName.mjs";import{appendDiy as m}from"../appendDiy.mjs";import{choose as r}from"./choose.mjs";import{readLocalValue as t}from"../readLocalValue.mjs";async function a(){const a=[];o(a),t(a,"url");const e=m(a);await r(a,e)}export{a as chooseUrl};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isUndefined as t}from"a-type-of-js";import{command as o}from"../../command.mjs";import{exitProgram as m}from"../../utils.mjs";async function i(){const i=await o.question({text:"请输入您将配置的网址",maxLen:50,minLen:5,verify:[{reg:/^https?:\/{2}.+/,info:"需符合网址基本模式"}]});return t(i)?await m():i}export{i as readInputUrl};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isUndefined as o,isType as a}from"a-type-of-js";import{brightBlackPen as m}from"color-pen";import{command as r}from"../../command.mjs";import{dataStore as t}from"../../data-store/index.mjs";import{dun as i,dog as e}from"../../dog.mjs";import{qqi as n}from"../../qqi.mjs";import{exitProgram as l}from"../../utils.mjs";import{readInputUserName as f}from"./readInputUserName.mjs";async function p(p,s){const{author:c}=t.local,j=c.name;let d=await r.selection({data:p,info:"请选择要使用的用户名"});if(o(d))return await l();a(d,(o=>o===s))&&(d=await f()),i||e(m("获取当前的用户名 "),d),e("是否执行写入",n.available),t.package.author.name=c.name=d,n.available&&j!==d&&(e("写入的值",t.local),n.write("config",t.local))}export{p as choose};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{runOtherCode as o}from"a-node-tools";import{isBusinessEmptyString as t}from"a-type-of-js";async function a(a){const e=await o("git config user.name");if(e.success){const o=e.data?.replace(/\n$/,"")||"";t(o)||a.push({label:`${o}`,value:o,tip:"由 git 全局配置读取"})}}export{a as getGitConfigUserName};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{userInfo as e}from"node:os";function o(o){const s=process.env.USER??process.env.USERNAME??e().username;o.push({label:`${s}`,value:s,tip:"设备用户名"})}export{o as getMachineUsername};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getGitConfigUserName as m}from"./getGitConfigUserName.mjs";import{getMachineUsername as o}from"./getMachineUserName.mjs";import{appendDiy as r}from"../appendDiy.mjs";import{choose as t}from"./choose.mjs";import{readLocalValue as a}from"../readLocalValue.mjs";async function e(){const e=[];await m(e),o(e);const i=r(e);a(e,"name"),await t(e,i)}export{e as chooseUserName};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isUndefined as t}from"a-type-of-js";import{command as o}from"../../command.mjs";import{exitProgram as m}from"../../utils.mjs";async function r(){const r=await o.question({text:"请输入您将配置的用户名",maxLen:16});return t(r)?await m():r}export{r as readInputUserName};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{chooseUserName as o}from"./choose-user-name/index.mjs";import{chooseEmail as i}from"./choose-email/index.mjs";import{chooseUrl as m}from"./choose-url/index.mjs";import{askForLastConfig as a}from"./askForLastConfig.mjs";import{dog as s}from"../dog.mjs";import{askForDependencies as e}from"./askForDependencies.mjs";import{askForInitDependencies as r}from"./askForInitDependencies.mjs";import{askForWithBin as t}from"./askForWithBin.mjs";async function n(){const n=await a();s("获取需要更改的项",n),n.includes("name")&&await o(),n.includes("email")&&await i(),n.includes("url")&&await m(),await t(),await e(),await r()}export{n as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isBusinessEmptyString as o}from"a-type-of-js";import{greenPen as r}from"color-pen";import{dataStore as t}from"../data-store/index.mjs";import{qqi as i}from"../qqi.mjs";function e(e,a){if(!i.available)return;const f=i.read("config"),n=f?.author?.[a]??"";if(o(n))return;t.local.author[a]=n;let l=!1;for(const o in e){const t=e[o];if(t.value===n){t.tip+=r`(上次使用该值)`,l=!0,e.unshift(e.splice(Number(o),1)[0]);break}}l||e.unshift({label:`${n}`,value:n,tip:"上次使用"})}export{e as readLocalValue};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dataStore as n}from"./index.mjs";function e(){const{dependencies:e}=n.local,r="++++",o=e.includes("prettier"),s=e.includes("typescript");return`import globals from 'globals';\nimport pluginJs from '@eslint/js';\n${o?"import tseslint from 'typescript-eslint';":r}\n${s?"import eslintConfigPrettier from 'eslint-config-prettier';":r}\nimport jsdocPlugin from 'eslint-plugin-jsdoc';\n\nexport default [\n { files: ['**/*.{js,mjs,cjs${s?".ts":""}}'] },\n { languageOptions: { globals: globals.browser } },\n pluginJs.configs.recommended,\n ${s?"...tseslint.configs.recommended,":r}\n\n {\n plugins: {\n jsdoc: jsdocPlugin,\n },\n rules: {\n // 基础规则\n 'jsdoc/check-alignment': 'error',\n 'jsdoc/check-param-names': 'error',\n 'jsdoc/check-tag-names': [\n 'error',\n {\n // 配置允许的标签\n definedTags: ['packageDocumentation'],\n },\n ],\n 'jsdoc/check-types': 'error',\n\n ${s?"\n // TypeScript 适配规则\n 'jsdoc/no-types': 'error',\n 'jsdoc/require-param-type': 'off', // 使用 TS 类型\n 'jsdoc/require-returns-type': 'off', // 使用 TS 类型":""}\n\n // 文档质量规则\n 'jsdoc/require-description': [\n 'error',\n {\n contexts: ['TSInterfaceDeclaration', 'TSTypeAliasDeclaration'],\n },\n ],\n 'jsdoc/require-jsdoc': [\n 'warn',\n {\n require: {\n FunctionDeclaration: true,\n MethodDefinition: true,\n ClassDeclaration: true,\n },\n },\n ],\n },\n },\n ${o?"eslintConfigPrettier,":r}\n];\n`.replace(/\+{3,}\n?/gm,"")}export{e as eslintText};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n(){return"\n node_modules\n dist\n *.tgz\n coverage\n .DS_Store\n .eg"}export{n as gitIgnoreText};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{initializeFile as e,getDirectoryBy as l,readFileToJsonSync as n,pathJoin as i}from"a-node-tools";import{originDependencies as p}from"./origin-dependencies.mjs";const[s]=e();let r=l("package.json","file",s);null==r&&(r=process.cwd());const t=n(i(r,"package.json")),c={cwd:"",range:"",pkgFile(...e){return i(this.cwd,...e)},rangeFile(...e){return i(this.range,...e)},get name(){return this.package.name},set name(e){this.childPkg?this.carryRange?(this.range=e.replace(/^@(.*)\/.*$/g,"$1"),this.cwd=e.replace(/@/,"").replace(/\//,"/packages/")):this.cwd=e.replace(/^.*\/(.*)$/g,"$1"):this.cwd=e,this.package.name=e},bin:0,local:{author:{name:"",email:"",url:""},dependencies:p},package:{name:"",version:"0.0.0",description:"",author:{name:"",email:"",url:""},dependencies:t?.dependencies||{},devDependencies:t?.devDependencies||{}},install:!1,carryRange:!1,childPkg:!1,buildDevDependencies(){const{dependencies:e}=this.local,{devDependencies:l,dependencies:n}=this.package,i={"@qqi/check-version":l["@qqi/check-version"]||"^1.0.2","@qqi/rollup-external":l["@qqi/rollup-external"]||"^1.0.5","@rollup/plugin-commonjs":l["@rollup/plugin-commonjs"]||"^28.0.3","@rollup/plugin-json":l["@rollup/plugin-json"]||"^6.1.0","@rollup/plugin-node-resolve":l["@rollup/plugin-node-resolve"]||"^16.0.1","@rollup/plugin-terser":l["@rollup/plugin-terser"]||"^0.4.4","a-command":n["a-command"]||"^2.3.8","a-node-tools":n["a-node-tools"]||"^4.2.6",gvv:l.gvv||"^0.0.7",jja:l.jja||"^2.3.8",pjj:l.pjj||"^1.0.1",vjj:l.vjj||"^1.0.5",rollup:l.rollup||"^4.43.0","rollup-plugin-cleanup":l["rollup-plugin-cleanup"]||"^3.2.1","rollup-plugin-copy":l["rollup-plugin-copy"]||"^3.5.0"};return e.includes("husky")&&e.includes("prettier")&&(i.husky=l.husky||"^9.1.7",i["lint-staged"]=l["lint-staged"]||"^16.1.0"),e.includes("eslint")&&(i.eslint=l.eslint||"^9.28.0",i["eslint-plugin-jsdoc"]=l["eslint-plugin-jsdoc"]||"^50.8.0",i.globals=l.globals||"^16.2.0",i["@eslint/js"]=l["@eslint/js"]||"^9.28.0",e.includes("typescript")&&(i["typescript-eslint"]=l["typescript-eslint"]||"^5.8.3"),e.includes("prettier")&&(i["eslint-config-prettier"]=l["eslint-config-prettier"]||"^5.8.3")),e.includes("prettier")&&(i.prettier=l.prettier||"^3.5.3"),e.includes("typescript")&&(i["@types/node"]=l["@types/node"]||"^24.0.1",i["@rollup/plugin-typescript"]=l["@rollup/plugin-typescript"]||"^12.1.2",i.typescript=l.typescript||"^5.8.3"),i}};export{c as dataStore};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dataStore as n}from"./index.mjs";const E=()=>{const E=(new Date).getFullYear(),{name:T}=n.local.author;return`# MIT License\n \nCopyright (c) <${E}> <${T}>\n\nPermission to use, copy, modify, and/or distribute this software for any \npurpose with or without fee is hereby granted, provided that the above \ncopyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES \nWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF \nMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR \nANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN \nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF \nOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\n# MIT 许可证\n\n版权所有 (c) [${E}] [${T}]\n\n特此免费授予任何获得本软件及相关文档文件(以下简称“软件”)副本的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、再许可和/或出售该软件副本的权利,并允许向其提供该软件的人这样做,但须遵守以下条件:\n\n上述版权声明和本许可声明应包含在所有副本或软件的重要部分中。\n\n软件按“原样”提供,不附带任何形式的明示或暗示的保证,包括但不限于适销性、特定用途适用性和不侵权的保证。在任何情况下,作者或版权持有人均不对因合同、侵权或其他方式引起的任何索赔、损害或其他责任负责,无论是在与软件或软件的使用或其他交易有关的任何诉讼中。`};export{E as licenseText};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=["husky","action","rollup","typescript","eslint","prettier"];export{t as originDependencies};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n(){return'{\n "printWidth": 80,\n "tabWidth": 2,\n "useTabs": false,\n "semi": true,\n "singleQuote": true,\n "trailingComma": "all",\n "bracketSpacing": true,\n "arrowParens": "avoid",\n "endOfLine": "auto"\n}'}export{n as prettierText};
|
package/src/dog.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Dog as e}from"@qqi/dev-log";import{isFalse as o}from"a-type-of-js";const t=new e({name:"create a npm",type:!1}),p=o(t.type);export{t as dog,p as dun};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{runOtherCode as i}from"a-node-tools";import{dataStore as t}from"./data-store/index.mjs";async function n(){t.childPkg&&await i({code:"npm install",cwd:t.rangeFile(""),printLog:!0,waiting:"请稍等,正在安装依赖"}),await i({code:"npm install",cwd:t.pkgFile(""),printLog:!0,waiting:"请稍等,正在安装依赖"})}export{n as installDependencies};
|
package/src/main.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pathJoin as t,writeJsonFile as r,colorLine as o,_p as m}from"a-node-tools";import{askForName as i}from"./ask-for-name/index.mjs";import{createNpm as a}from"./createNpm.mjs";import n from"./custom/index.mjs";import{dog as s}from"./dog.mjs";import{unlinkSync as e}from"node:fs";import{exitProgram as l}from"./utils.mjs";import{dataStore as p}from"./data-store/index.mjs";import{installDependencies as c}from"./installDependencies.mjs";import{greenPen as d,magentaPen as f,brightBlackPen as w,brightGreenPen as $}from"color-pen";(async()=>{try{try{const o=t("test_write"+Date.now());r(o,{}),e(o)}catch(t){return s.error(t),console.log(t),await l("您没有当前目录的写文件的权限,请确认后再试")}o("华丽开始分割",!0),await i(),await n(),await a(),p.install&&await c(),p.childPkg?(m(d`创建项目完毕`),m(`请 cd 到 ${f`./${p.range}`} 目录下`),m(),p.install||m(`执行 ${w`npm install`}`),m(w`简单测试使用 ${$`npm test`}`),m(w`简单打包使用 ${$`npm run build`}`)):(m(d`创建项目完毕`),m(`请 cd 到 ${f(p.cwd)} 目录下`),m(),p.install||m(`执行 ${w`npm install`}`),m(w`简单测试使用 ${$`npm test`}`),m(w`简单打包使用 ${$`npm run build`}`)),await l("")}catch(t){s.error(t)}})();
|
package/src/qqi.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{QQI as e}from"qqi";const o=new e("create-a-npm");export{o as qqi};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mkdirSync as n,writeFileSync as e}from"node:fs";import{dataStore as t}from"../data-store/index.mjs";function s(){const s=".github/workflows";n(t.pkgFile(s),{recursive:!0}),e(t.pkgFile(s,"发布.yml"),"name: 发布到 npm\non:\n push:\n branches: '*'\n workflow_dispatch: # 手动触发\n inputs:\n version:\n description: '触发原因(选填)'\n required: false\n default: '手动触发'\n type: string\n ref:\n description: '发布的分支(选填)'\n required: false\n default: ''\n type: string\n\njobs:\n pub:\n # 在提交的代码包含 `version` 字样时才运行该动作\n # 或者手动触发\n name: |\n 发布到 npm\n runs-on: ubuntu-latest\n permissions:\n packages: write\n contents: write\n id-token: write\n # 复合条件判断(自动触发检查提交信息,手动触发直接放行)\n # startsWith(github.event.head_commit.message, 'version')\n # contains(github.event.inputs.version, '手动触发')\n # endsWith(github.event.head_commit.message, 'version')\n if: |\n (github.event_name == 'push' && startsWith(github.event.head_commit.message, 'version')) ||\n github.event_name == 'workflow_dispatch'\n steps:\n - name: 代码检出\n uses: actions/checkout@v4\n with:\n ref: ${{ github.event.inputs.ref || github.ref_name }}\n fetch-depth: 1\n\n - name: 初始化 Node 并设定 Node 版本\n uses: actions/setup-node@v4\n with:\n node-version: 22.x\n registry-url: https://registry.npmjs.org\n\n - name: 发布到 npm\n env:\n NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}\n run: |\n chmod +x ./scripts/pub.sh\n ./scripts/pub.sh\n")}export{s as createAction};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pathJoin as n}from"a-node-tools";import{mkdirSync as e,writeFileSync as i}from"node:fs";import{dataStore as t}from"../data-store/index.mjs";function o(){e(n(t.pkgFile("scripts")),{recursive:!0}),i(t.pkgFile("scripts","pub.sh"),'#!/bin/bash\n\nCHECK_VERSION="@qqi/check-version"\n# 安装 \ninstall_check_version() {\n if ! npm list -g --depth=0 | grep -q " ${CHECK_VERSION}"; then \n echo "当前未全局安装 \'${CHECK_VERSION}\',即将进行安装"\n npm install ${CHECK_VERSION} --global\n else \n echo "包 ${CHECK_VERSION} 已全局安装"\n fi\n}\n\ntag=""\ninstall_check_version\nif ! tag=$(npx "${CHECK_VERSION}" c=. 2>&1); then\n echo "未通过版本校验:$tag"\n exit 0\nfi\necho "获取🉐发布标签为 ${tag}"\n# 依赖安装\nnpm ci\n# 构建项目\nif ! npm run build; then \n echo "构建失败" \n exit 0\nfi\n\n# 切换到构建目录\nif [ ! -d "dist" ]; then \n echo "未找到 dist 构建码"\n exit 0\nfi\n\n# 确保脚本在遇见错误时立即退出\nset -e\n\ncd "dist"\necho "开始发布 npm 包 ${tag} 版本"\nif ! npm publish --provenance --access public --tag "${tag}"; then\n echo "发布失败" \n exit 1\nfi\necho "🚀🚀 发布成功,完结 🎉🎉 撒花 🎉🎉"\n\n')}export{o as createPub};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as n}from"node:fs";import{dataStore as e}from"../data-store/index.mjs";function o(){const{dependencies:o}=e.local,r=o.includes("typescript");n(e.pkgFile("rollup.config.eg.js"),`${r?"import typescript from '@rollup/plugin-typescript';":""}\nimport resolve from '@rollup/plugin-node-resolve';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport cleanup from 'rollup-plugin-cleanup';\nimport { external } from '@qqi/rollup-external';\n\n/** 生成 npm 文件的打包配置文件 */\nexport default {\n input: './eg/index.${r?"ts":"js"}',\n output: {\n format: 'es',\n entryFileNames: '[name].mjs',\n preserveModules: false,\n sourcemap: false,\n exports: 'named',\n dir: '.eg/',\n },\n // 配置需要排除的包\n external: external({ ignore: ['node:'] }),\n plugins: [\n resolve(),\n commonjs(),\n // 可打包 json 内容\n json(),\n ${r?"typescript(),":""}\n // 去除无用代码\n cleanup(),\n ],\n};\n `)}export{o as createRollupEg};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as o}from"node:fs";import{dataStore as t}from"../data-store/index.mjs";import{eslintText as e}from"../data-store/eslintText.mjs";function i(){o(t.pkgFile("eslint.config.js"),e())}export{i as eslintConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as o}from"node:fs";import{dataStore as t}from"../data-store/index.mjs";import{gitIgnoreText as r}from"../data-store/gitIgnoreText.mjs";function e(){o(t.pkgFile(".gitignore"),r())}export{e as gitIgnore};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dataStore as r}from"../data-store/index.mjs";import{eslintConfig as e}from"./eslint.mjs";import{packageJson as m}from"./package.mjs";import{prettier as t}from"./prettier.mjs";import{rollup as o}from"./rollup.mjs";import{tsconfigJson as i}from"./tsconfig.mjs";import{createRollupEg as s}from"./createRollupEg.mjs";import{createReadMe as c}from"../createChild/createReadMe.mjs";import{createLicense as p}from"../createChild/createLicense.mjs";import{createChangeLog as a}from"../createChild/createChangeLog.mjs";import{markdown as n}from"./markdown.mjs";import{gitIgnore as f}from"./gitIgnore.mjs";import{createTest as l}from"../createChild/createTest.mjs";import{createIndex as d}from"../createChild/createIndex.mjs";import{createScripts as j}from"../createChild/createScripts.mjs";import{createAction as u}from"./createAction.mjs";import{createPub as g}from"./createPub.mjs";function h(){const{dependencies:h}=r.local;h.includes("action")&&(u(),g()),h.includes("typescript")&&i(),o(),s(),c(),m(),p(),d(),h.includes("eslint")&&e(),h.includes("prettier")&&t(),n(),a(),f(),j(),l()}export{h as packageIndex};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as n}from"node:fs";import{dataStore as o}from"../data-store/index.mjs";function e(){n(o.pkgFile(".markdownlint.json"),'{\n "MD024": false,\n "MD013": false\n}\n')}export{e as markdown};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dataStore as e}from"../data-store/index.mjs";import{writeToJsonFile as s}from"../utils.mjs";function i(){const{dependencies:i}=e.local,n=i.includes("typescript"),p={name:e.name,version:"0.0.0",type:"module",private:!0,description:"",scripts:{b:"rollup --config rollup.config.js"+(1!==e.bin&&n?" && tsc -p tsconfig.types.json":""),build:"jja cls rm dist && npm run b && npm run clean:package","clean:package":"node scripts/clean-package-json.js",diff:"jja pkg --diff=官方",prepublishOnly:"pjj",push:"gvv","push:version":"gvv",test:"jja rm .eg && rollup --config rollup.config.eg.js && node .eg/index.mjs",vjj:"vjj"},license:"MIT",devDependencies:e.buildDevDependencies()};i.includes("husky")&&i.includes("prettier")&&(p["lint-staged"]={"*.{js,ts}":["prettier --write"]},p.scripts.prepare="husky"),i.includes("eslint")&&(p.scripts.eslint="jja cls && eslint packages"),i.includes("prettier")&&(p.scripts.prettier="jja cls && prettier . --write"),s("package.json",p)}export{i as packageJson};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as r}from"node:fs";import{dataStore as t}from"../data-store/index.mjs";import{gitIgnoreText as e}from"../data-store/gitIgnoreText.mjs";import{prettierText as o}from"../data-store/prettierText.mjs";function i(){r(t.pkgFile(".prettierignore"),e()),r(t.pkgFile(".prettierrc"),o())}export{i as prettier};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dataStore as n}from"../data-store/index.mjs";import{writeFileSync as e}from"node:fs";function r(){const{dependencies:r}=n.local,o=r.includes("typescript");e(n.pkgFile("rollup.config.js"),`${o?"import typescript from '@rollup/plugin-typescript'":""};\nimport resolve from '@rollup/plugin-node-resolve';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport cleanup from 'rollup-plugin-cleanup';\nimport copy from 'rollup-plugin-copy';\nimport { external } from '@qqi/rollup-external';\n\nexport default {\n input: './index.${o?"ts":"js"}',\n output: ${1!==n.bin?"[\n {\n format: 'es',\n entryFileNames: '[name].mjs',\n preserveModules: true,\n sourcemap: false,\n exports: 'named',\n dir: 'dist/',\n },\n {\n format: 'cjs',\n entryFileNames: '[name].cjs',\n preserveModules: true,\n sourcemap: false,\n exports: 'named',\n dir: 'dist/',\n },\n ],":"{\n format: 'es',\n entryFileNames: '[name].mjs',\n preserveModules: false,\n sourcemap: false,\n exports: 'named',\n dir: 'dist/',\n },"}\n // 配置需要排除或包含的包\n external: external(),\n plugins: [\n resolve(),\n commonjs(),\n json(),${o?"typescript(),":""}\n cleanup(),\n copy({\n targets: [\n { src: 'README.md', dest: 'dist' },\n { src: 'LICENSE', dest: 'dist' },\n ],\n }),\n ],\n};`)}export{r as rollup};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeToJsonFile as e}from"../utils.mjs";function t(){s(),o(),n()}function s(){e("tsconfig.base.json",{compilerOptions:{baseUrl:".",jsx:"preserve",strict:!0,target:"ESNext",module:"ESNext",skipLibCheck:!0,esModuleInterop:!0,moduleResolution:"Bundler",allowSyntheticDefaultImports:!0,isolatedModules:!0,lib:["ESNext","DOM"],sourceMap:!1}})}function o(){e("tsconfig.json",{extends:"./tsconfig.base.json",include:["index.ts","src/**/*.ts","**.d.ts","test/**/*.ts"],exclude:["node_modules","dist"]})}function n(){e("tsconfig.types.json",{extends:"./tsconfig.base.json",compilerOptions:{emitDeclarationOnly:!0,declaration:!0,declarationDir:"dist/"},exclude:["node_modules","test","dist","eg"]})}export{o as _tsconfigJson,s as tsconfigBaseJson,t as tsconfigJson,n as tsconfigTypesJson};
|
package/src/utils.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{typewrite as o,cursorAfterClear as r,cursorShow as t,colorLine as m,writeJsonFile as i}from"a-node-tools";import{dataStore as n}from"./data-store/index.mjs";import"color-pen";import{command as e}from"./command.mjs";import{waiting as a}from"./waiting.mjs";function p(o,r){i(n.pkgFile(o),r)}async function d(i="好的,正在做退出前最后的工作,请稍等"){return await o(i),a.destroyed(),r(),t(),m("终结线",!0),e.end()}export{d as exitProgram,p as writeToJsonFile};
|
package/src/waiting.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{waitingTips as o}from"a-node-tools";const t=o({show:!1});export{t as waiting};
|
package/README.md
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# create a node package module
|
|
2
|
-
|
|
3
|
-
This package is used to generate a node package based on `typescript`, built using `rollup`, formatted using `prettier`, and checked using `eslint`
|
|
4
|
-
|
|
5
|
-
## install
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
npm install -g create-a-npm
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## use
|
|
12
|
-
|
|
13
|
-
```sh
|
|
14
|
-
# Non essential installation
|
|
15
|
-
npm create a-npm
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Other languages
|
|
19
|
-
|
|
20
|
-
[English](https://github.com/lmssee/createANpm/blob/main/README.md) [中文](https://github.com/lmssee/createANpm/blob/main/自述文件.md)
|
package/bin/index.js
DELETED
package/mjs/index.mjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import askForName from './src/askForName.mjs';
|
|
2
|
-
import { createNpm } from './src/createNpm.mjs';
|
|
3
|
-
import custom from './src/custom.mjs';
|
|
4
|
-
|
|
5
|
-
/****************************************************************************
|
|
6
|
-
* @Author lmssee
|
|
7
|
-
* @Email lmssee@outlook.com
|
|
8
|
-
* @FileName index.ts
|
|
9
|
-
* @Date 周三 08/28/2024
|
|
10
|
-
* @Description 包源文件的跟文件,该文件暴露相应的接口
|
|
11
|
-
****************************************************************************/
|
|
12
|
-
/// 设定包名
|
|
13
|
-
await askForName();
|
|
14
|
-
/// 参看是否自定义包的内容,这里会自定义是否使用 eslint 等相关内容
|
|
15
|
-
await custom();
|
|
16
|
-
/// 开始包创建
|
|
17
|
-
await createNpm();
|