pl-preset 0.0.8 → 0.0.9

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
@@ -16,7 +16,7 @@ plp
16
16
 
17
17
  ### prettier
18
18
 
19
- 默认以prettier作为代码格式化工具,自动生成配置信息
19
+ prettier作为代码格式化工具,在项目根目录下生成.prettierrc文件
20
20
 
21
21
  ### Git设置
22
22
 
@@ -34,7 +34,7 @@ plp
34
34
 
35
35
  支持选择javascript、typescript,自动生成eslint相关配置进行校验
36
36
 
37
- ### 样式语音
37
+ ### 样式语言
38
38
 
39
39
  支持选择css、less、scss,自动生成stylelint配置对代码进行校验
40
40
 
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var e=require("commander"),s=require("chalk"),t=require("fs-extra"),r=require("path"),n=require("inquirer"),o=require("fs"),c=require("ejs"),l=require("child_process"),i=require("ora");function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p,u,d,g,m,y,S,h,f,v,w,j,k,F,_={};function b(){if(u)return p;u=1;return p={SupportedEditor:{vscode:1,others:0},SupportedLanguage:{javascript:1,typescript:2,others:0},SupportedStyleSheets:{css:1,less:2,scss:3,others:0},SupportedFramework:{vue2:1,vue3:2,react:3,others:0}}}function L(){if(g)return d;g=1;const e=t,n=s,l=r,i=o,a=c,{SupportedEditor:p,SupportedLanguage:u,SupportedStyleSheets:m,SupportedFramework:y}=b();return d={apply:s=>{console.log(n.blue("生成编辑器设置..."));const{editorType:t}=s;t!==p.others&&t===p.VSCode&&(({language:s,framework:t,styleSheets:r,includeHtml:n})=>{const o=l.resolve(__dirname,"../template/.vscode/settings.json"),c=a.render(i.readFileSync(o,"utf-8"),{supportedLanguage:u,language:s,styleSheets:r,supportedStyleSheets:m,framework:t,supportedFramework:y,html:n}),p=l.resolve(process.cwd(),"./.vscode/settings.json");e.ensureFileSync(p),i.writeFileSync(p,c,"utf-8");const d=l.resolve(__dirname,"../template/.vscode/extensions.json"),g=a.render(i.readFileSync(d,"utf-8"),{style:r!==m.others,vue:t===y.vue2||t===y.vue3}),S=l.resolve(process.cwd(),"./.vscode/extensions.json");e.ensureFileSync(S),i.writeFileSync(S,g,"utf-8")})(s)}}}function O(){if(v)return f;v=1;const e=c,n=r,l=o,i=t,a=s,{SupportedLanguage:p,SupportedStyleSheets:u,SupportedFramework:d}=b();return f={apply:({framework:s,styleSheets:t,language:r})=>{if(r!==p.others){console.log(a.blue("生成 ESLint 配置文件..."));try{(()=>{const t="module"===i.readJSONSync(n.resolve(process.cwd(),"./package.json")).type?"eslint.config.cjs":"eslint.config.js",o=n.resolve(__dirname,"../template/eslint.config.js"),c=e.render(l.readFileSync(o,"utf-8"),{language:r,framework:s,supportedFramework:d,supportedLanguage:p}),a=n.resolve(process.cwd(),"./",t);i.ensureFileSync(a),i.writeFileSync(a,c,"utf-8")})()}catch(e){throw new Error("生成ESLint配置文件失败: ",e.message)}}if(t!==u.others){console.log(a.blue("生成 Stylelint 配置文件..."));try{(()=>{const r=n.resolve(__dirname,"../template/.stylelintrc.js"),o=e.render(l.readFileSync(r,"utf-8"),{supportedStyleSheets:u,styleSheets:t,vue:s===d.vue2||s===d.vue3}),c=n.resolve(process.cwd(),"./.stylelintrc.js");i.ensureFileSync(c),i.writeFileSync(c,o,"utf-8")})()}catch(e){throw new Error("生成Stylelint配置文件失败: ",e.message)}}}}}function x(){if(F)return k;F=1;const e=s,a=t,p=r,u=n,{SupportedEditor:d,SupportedLanguage:g,SupportedStyleSheets:f,SupportedFramework:v}=b(),{apply:_}=L(),{apply:x}=function(){if(y)return m;y=1;const e=r,s=t,{SupportedStyleSheets:n}=b();return m={apply:({styleSheets:t,isUseGit:r,isNeedChangeLog:o})=>{if(!r||!o)return;const c=e.resolve(process.cwd(),"./package.json"),l=s.readJsonSync(c);if(l.scripts=Object.assign({},l.scripts,{c:"cz"}),l.config=Object.assign({},l.config,{commitizen:{path:"cz-conventional-changelog"}}),l["lint-staged"]={"*.{js,ts,tsx,jsx}":"eslint"},t!==n.others&&(l["lint-staged"]["*.{css,less,scss}"]="stylelint"),o){l.scripts=Object.assign({},l.scripts,{clog:"conventional-changelog -n ./.changelogrc.js -p angular -i CHANGELOG.md -s"});const t=e.resolve(__dirname,"../template/.changelogrc.js");s.copyFileSync(t,e.resolve(process.cwd(),"./.changelogrc.js"))}s.writeJsonSync(c,l,{spaces:"\t"});const i=e.resolve(__dirname,"../template/.czrc");s.copyFileSync(i,e.resolve(process.cwd(),"./.czrc"));const a=e.resolve(__dirname,"../template/commitlint.config.js");s.copyFileSync(a,e.resolve(process.cwd(),"./commitlint.config.js"));const p=e.resolve(__dirname,"../template/.husky");s.copySync(p,e.resolve(process.cwd(),"./.husky"))}}}(),{apply:q}=function(){if(h)return S;h=1;const e=t,n=s,l=r,i=o,a=c,{SupportedStyleSheets:p}=b();return S={apply:({styleSheets:s})=>{console.log(n.blue("生成 Prettier 配置文件..."));const t=l.resolve(__dirname,"../template/.prettierrc"),r=a.render(i.readFileSync(t,"utf-8"),{supportedStyleSheets:p,styleSheets:s}),o=l.resolve(process.cwd(),"./.prettierrc");e.ensureFileSync(o),i.writeFileSync(o,r,"utf-8")}}}(),{apply:E}=O(),{apply:z}=function(){if(j)return w;j=1;const{exec:e}=l,n=t,o=r,c=s,a=i,{SupportedLanguage:p,SupportedFramework:u,SupportedStyleSheets:d}=b(),g=[["prettier","^3.6.2"]],m=[["@commitlint/cli","^19.8.1"],["@commitlint/config-conventional","^19.8.1"],["@commitlint/prompt-cli","^20.1.0"],["commitizen","^4.3.1"],["cz-conventional-changelog","^3.3.0"],["husky","^9.1.7"],["lint-staged","^16.1.2"]],y=[["conventional-changelog-cli","^4.1.0"]],S=[["stylelint-config-html","^1.1.0"]],h=[["eslint","^9.39.1"],["eslint-config-prettier","^9.1.2"],["eslint-plugin-prettier","^5.5.4"],["@babel/eslint-parser","^7.12.16"],["@babel/preset-env","^7.28.5"]],f=[["@typescript-eslint/eslint-plugin","^8.46.3"],["@typescript-eslint/parser","^8.46.3"]],v=[["stylelint","^15.10.3"],["stylelint-config-recess-order","^4.6.0"],["stylelint-config-standard","^34.0.0"]],k=[["postcss-scss","^4.0.9"],["stylelint-config-recommended-scss","^12.0.0"],["stylelint-scss","^5.3.2"]],F=[["postcss-less","^6.0.0"],["stylelint-config-recommended-less","^2.0.0"],["stylelint-less","^1.0.6"]],_=[["postcss-html","^1.8.0"],["eslint-plugin-vue","^9.33.0"],["stylelint-config-html","^1.1.0"],["vue-eslint-parser","^9.4.3"]],L=[["postcss-html","^1.8.0"],["stylelint-config-html","^1.1.0"],["eslint-plugin-vue","^9.33.0"],["vue-eslint-parser","^9.4.3"]],O=[["eslint-plugin-react","^7.37.5"],["eslint-plugin-react-hooks","^5.2.0"]];return w={apply:({language:s,framework:t,styleSheets:r,includeHtml:l,isUseGit:i,isNeedChangeLog:w})=>{console.log(c.blue("安装依赖包..."));const j=g.slice();i&&(j.push(...m),w&&j.push(...y)),l&&j.push(...S),s!==p.others&&j.push(...h),s===p.typescript&&j.push(...f),t===u.vue2?j.push(..._):t===u.vue3?j.push(...L):t===u.react&&j.push(...O),r!==d.others&&(j.push(...v),r===d.scss?j.push(...k):r===d.less&&j.push(...F));const b=o.join(process.cwd(),"package.json");if(!n.existsSync(b))return void console.log(c.red("缺少package.json文件"));const x=n.readJSONSync(b),q=x.devDependencies=x.devDependencies||{},E=x.dependencies=x.dependencies||{};for(let[e,s]of j)q[e]=s,delete E[e];n.writeJSONSync(b,x,{encoding:"utf-8",spaces:"\t"});const z=["pnpm-lock.yaml","yarn.lock","package-lock.json"];let N="npm install";for(const e of z)if(n.existsSync(o.resolve(process.cwd(),`./${e}`))){"pnpm-lock.yaml"===e?N="pnpm install":"yarn.lock"===e&&(N="yarn install");break}const G=a(">>>>>> 安装依赖 >>>>>>\n").start();e(N,(e,s,t)=>{e&&(console.log(c.red(e)),G.fail("安装失败")),G.succeed("安装完成")}).on("close",e=>{0===e?G.succeed("安装完成"):G.fail("安装失败")})}},w}();return k={run:async()=>{const s=p.resolve(process.cwd(),"./package.json");if(!a.existsSync(s))return void console.log(e.red("请在工程目录下执行命令"));const t=p.resolve(process.cwd(),".editorconfig");if(a.existsSync(t)){(await u.prompt([{type:"confirm",name:"remove",message:"默认采用Prettier进行代码格式化,项目中检测到的.editorconfig文件可能会造成干扰,是否删除:",default:!1}])).remove&&a.removeSync(t)}const r=await u.prompt([{type:"confirm",name:"isUseGit",message:"是否使用git作为代码仓库:",default:!0},{type:"confirm",name:"isNeedChangeLog",message:"是否需要生成changelog:",default:!1,when:e=>!0===e.isUseGit},{type:"list",name:"editor",message:"请选择使用的编辑器:",choices:()=>Object.entries(d).map(([e,s])=>({name:e,value:s}))},{type:"list",name:"language",message:"请选择编程语音:",choices:()=>Object.entries(g).map(([e,s])=>({name:e,value:s}))},{type:"list",name:"styleSheets",message:"请选择样式语言:",choices:()=>Object.entries(f).map(([e,s])=>({name:e,value:s}))},{type:"list",name:"framework",message:"请选择编程框架:",choices:()=>Object.entries(v).map(([e,s])=>({name:e,value:s}))},{type:"confirm",name:"includeHtml",message:"是否包含html:",default:!1}]);try{_(r)}catch(s){console.log(e.red("编辑器配置生成失败:"),s)}try{x(r)}catch(s){console.log(e.red("配置git校验失败:"),s)}try{q(r)}catch(s){console.log(e.red("Prettier配置生成失败:"),s)}try{E(r)}catch(s){console.log(e.red(s))}try{z(r)}catch(s){console.log(e.red("依赖安装失败:"),s)}}}}var q,E={version:"0.0.8"};var z=a(function(){if(q)return _;q=1;const{program:s}=e,{run:t}=x(),r=E;return s.version(r.version),s.usage("<command>"),s.command("default",{isDefault:!0}).action(()=>{t()}),s.parse(process.argv),_}());module.exports=z;
2
+ "use strict";var e=require("commander"),s=require("chalk"),t=require("fs-extra"),r=require("path"),n=require("inquirer"),o=require("fs"),c=require("ejs"),l=require("child_process"),i=require("ora");function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p,u,d,g,y,m,S,h,f,v,w,j,k,F,_={};function b(){if(u)return p;u=1;return p={SupportedEditor:{vscode:1,others:0},SupportedLanguage:{javascript:1,typescript:2,others:0},SupportedStyleSheets:{css:1,less:2,scss:3,others:0},SupportedFramework:{vue2:1,vue3:2,react:3,others:0}}}function L(){if(g)return d;g=1;const e=t,n=s,l=r,i=o,a=c,{SupportedEditor:p,SupportedLanguage:u,SupportedStyleSheets:y,SupportedFramework:m}=b();return d={apply:s=>{console.log(n.blue("生成编辑器设置..."));const{editorType:t}=s;t!==p.others&&t===p.VSCode&&(({language:s,framework:t,styleSheets:r,includeHtml:n})=>{const o=l.resolve(__dirname,"../template/.vscode/settings.json"),c=a.render(i.readFileSync(o,"utf-8"),{supportedLanguage:u,language:s,styleSheets:r,supportedStyleSheets:y,framework:t,supportedFramework:m,html:n}),p=l.resolve(process.cwd(),"./.vscode/settings.json");e.ensureFileSync(p),i.writeFileSync(p,c,"utf-8");const d=l.resolve(__dirname,"../template/.vscode/extensions.json"),g=a.render(i.readFileSync(d,"utf-8"),{style:r!==y.others,vue:t===m.vue2||t===m.vue3}),S=l.resolve(process.cwd(),"./.vscode/extensions.json");e.ensureFileSync(S),i.writeFileSync(S,g,"utf-8")})(s)}}}function O(){if(v)return f;v=1;const e=c,n=r,l=o,i=t,a=s,{SupportedLanguage:p,SupportedStyleSheets:u,SupportedFramework:d}=b();return f={apply:({framework:s,styleSheets:t,language:r})=>{if(r!==p.others){console.log(a.blue("生成 ESLint 配置文件..."));try{(()=>{const t="module"===i.readJSONSync(n.resolve(process.cwd(),"./package.json")).type?"eslint.config.cjs":"eslint.config.js",o=n.resolve(__dirname,"../template/eslint.config.js"),c=e.render(l.readFileSync(o,"utf-8"),{language:r,framework:s,supportedFramework:d,supportedLanguage:p}),a=n.resolve(process.cwd(),"./",t);i.ensureFileSync(a),i.writeFileSync(a,c,"utf-8")})()}catch(e){throw new Error("生成ESLint配置文件失败: ",e.message)}}if(t!==u.others){console.log(a.blue("生成 Stylelint 配置文件..."));try{(()=>{const r=n.resolve(__dirname,"../template/.stylelintrc.js"),o=e.render(l.readFileSync(r,"utf-8"),{supportedStyleSheets:u,styleSheets:t,vue:s===d.vue2||s===d.vue3}),c=n.resolve(process.cwd(),"./.stylelintrc.js");i.ensureFileSync(c),i.writeFileSync(c,o,"utf-8")})()}catch(e){throw new Error("生成Stylelint配置文件失败: ",e.message)}}}}}function x(){if(F)return k;F=1;const e=s,a=t,p=r,u=n,{SupportedEditor:d,SupportedLanguage:g,SupportedStyleSheets:f,SupportedFramework:v}=b(),{apply:_}=L(),{apply:x}=function(){if(m)return y;m=1;const e=r,s=t,{SupportedStyleSheets:n}=b();return y={apply:({styleSheets:t,isUseGit:r,isNeedChangeLog:o})=>{if(!r||!o)return;const c=e.resolve(process.cwd(),"./package.json"),l=s.readJsonSync(c);if(l.scripts=Object.assign({},l.scripts,{c:"cz"}),l["lint-staged"]={"*.{js,ts,tsx,jsx}":"eslint"},t!==n.others&&(l["lint-staged"]["*.{css,less,scss}"]="stylelint"),o){l.scripts=Object.assign({},l.scripts,{clog:"conventional-changelog -n ./.changelogrc.js -p angular -i CHANGELOG.md -s"});const t=e.resolve(__dirname,"../template/.changelogrc.js");s.copyFileSync(t,e.resolve(process.cwd(),"./.changelogrc.js"))}s.writeJsonSync(c,l,{spaces:"\t"});const i=e.resolve(__dirname,"../template/.czrc");s.copyFileSync(i,e.resolve(process.cwd(),"./.czrc"));const a=e.resolve(__dirname,"../template/commitlint.config.js");s.copyFileSync(a,e.resolve(process.cwd(),"./commitlint.config.js"));const p=e.resolve(__dirname,"../template/.husky");s.copySync(p,e.resolve(process.cwd(),"./.husky"))}}}(),{apply:q}=function(){if(h)return S;h=1;const e=t,n=s,l=r,i=o,a=c,{SupportedStyleSheets:p}=b();return S={apply:({styleSheets:s})=>{console.log(n.blue("生成 Prettier 配置文件..."));const t=l.resolve(__dirname,"../template/.prettierrc"),r=a.render(i.readFileSync(t,"utf-8"),{supportedStyleSheets:p,styleSheets:s}),o=l.resolve(process.cwd(),"./.prettierrc");e.ensureFileSync(o),i.writeFileSync(o,r,"utf-8")}}}(),{apply:E}=O(),{apply:N}=function(){if(j)return w;j=1;const{exec:e}=l,n=t,o=r,c=s,a=i,{SupportedLanguage:p,SupportedFramework:u,SupportedStyleSheets:d}=b(),g=[["prettier","^3.6.2"]],y=[["@commitlint/cli","^19.8.1"],["@commitlint/config-conventional","^19.8.1"],["@commitlint/prompt-cli","^20.1.0"],["commitizen","^4.3.1"],["cz-conventional-changelog","^3.3.0"],["husky","^9.1.7"],["lint-staged","^16.1.2"]],m=[["conventional-changelog-cli","^4.1.0"]],S=[["stylelint-config-html","^1.1.0"]],h=[["eslint","^9.39.1"],["eslint-config-prettier","^9.1.2"],["eslint-plugin-prettier","^5.5.4"],["@babel/eslint-parser","^7.12.16"],["@babel/preset-env","^7.28.5"]],f=[["@typescript-eslint/eslint-plugin","^8.46.3"],["@typescript-eslint/parser","^8.46.3"]],v=[["stylelint","^15.10.3"],["stylelint-config-recess-order","^4.6.0"],["stylelint-config-standard","^34.0.0"]],k=[["postcss-scss","^4.0.9"],["stylelint-config-recommended-scss","^12.0.0"],["stylelint-scss","^5.3.2"]],F=[["postcss-less","^6.0.0"],["stylelint-config-recommended-less","^2.0.0"],["stylelint-less","^1.0.6"]],_=[["postcss-html","^1.8.0"],["eslint-plugin-vue","^9.33.0"],["stylelint-config-html","^1.1.0"],["vue-eslint-parser","^9.4.3"]],L=[["postcss-html","^1.8.0"],["stylelint-config-html","^1.1.0"],["eslint-plugin-vue","^9.33.0"],["vue-eslint-parser","^9.4.3"]],O=[["eslint-plugin-react","^7.37.5"],["eslint-plugin-react-hooks","^5.2.0"]];return w={apply:({language:s,framework:t,styleSheets:r,includeHtml:l,isUseGit:i,isNeedChangeLog:w})=>{console.log(c.blue("安装依赖包..."));const j=g.slice();i&&(j.push(...y),w&&j.push(...m)),l&&j.push(...S),s!==p.others&&j.push(...h),s===p.typescript&&j.push(...f),t===u.vue2?j.push(..._):t===u.vue3?j.push(...L):t===u.react&&j.push(...O),r!==d.others&&(j.push(...v),r===d.scss?j.push(...k):r===d.less&&j.push(...F));const b=o.join(process.cwd(),"package.json");if(!n.existsSync(b))return void console.log(c.red("缺少package.json文件"));const x=n.readJSONSync(b),q=x.devDependencies=x.devDependencies||{},E=x.dependencies=x.dependencies||{};for(let[e,s]of j)q[e]=s,delete E[e];n.writeJSONSync(b,x,{encoding:"utf-8",spaces:"\t"});const N=["pnpm-lock.yaml","yarn.lock","package-lock.json"];let G="npm install";for(const e of N)if(n.existsSync(o.resolve(process.cwd(),`./${e}`))){"pnpm-lock.yaml"===e?G="pnpm install":"yarn.lock"===e&&(G="yarn install");break}const z=a(">>>>>> 安装依赖 >>>>>>\n").start();e(G,e=>{e&&(console.log(c.red(e)),z.fail("安装失败")),z.succeed("安装完成")}).on("close",e=>{0===e?z.succeed("安装完成"):z.fail("安装失败")})}},w}();return k={run:async()=>{const s=p.resolve(process.cwd(),"./package.json");if(!a.existsSync(s))return void console.log(e.red("请在工程目录下执行命令"));const t=p.resolve(process.cwd(),".editorconfig");if(a.existsSync(t)){(await u.prompt([{type:"confirm",name:"remove",message:"默认采用Prettier进行代码格式化,项目中检测到的.editorconfig文件可能会造成干扰,是否删除:",default:!1}])).remove&&a.removeSync(t)}const r=await u.prompt([{type:"confirm",name:"isUseGit",message:"是否使用git作为代码仓库:",default:!0},{type:"confirm",name:"isNeedChangeLog",message:"是否需要生成changelog:",default:!1,when:e=>!0===e.isUseGit},{type:"list",name:"editor",message:"请选择使用的编辑器:",choices:()=>Object.entries(d).map(([e,s])=>({name:e,value:s}))},{type:"list",name:"language",message:"请选择编程语音:",choices:()=>Object.entries(g).map(([e,s])=>({name:e,value:s}))},{type:"list",name:"styleSheets",message:"请选择样式语言:",choices:()=>Object.entries(f).map(([e,s])=>({name:e,value:s}))},{type:"list",name:"framework",message:"请选择编程框架:",choices:()=>Object.entries(v).map(([e,s])=>({name:e,value:s}))},{type:"confirm",name:"includeHtml",message:"是否包含html:",default:!1}]);try{_(r)}catch(s){console.log(e.red("编辑器配置生成失败:"),s)}try{x(r)}catch(s){console.log(e.red("配置git校验失败:"),s)}try{q(r)}catch(s){console.log(e.red("Prettier配置生成失败:"),s)}try{E(r)}catch(s){console.log(e.red(s))}try{N(r)}catch(s){console.log(e.red("依赖安装失败:"),s)}}}}var q,E={version:"0.0.9"};var N=a(function(){if(q)return _;q=1;const{program:s}=e,{run:t}=x(),r=E;return s.version(r.version),s.usage("<command>"),s.command("default",{isDefault:!0}).action(()=>{t()}),s.parse(process.argv),_}());module.exports=N;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pl-preset",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "bin": {
5
5
  "plp": "dist/cli.js"
6
6
  },
@@ -60,17 +60,6 @@
60
60
  "inquirer": "^8.2.4",
61
61
  "ora": "^5.4.1"
62
62
  },
63
- "husky": {
64
- "hooks": {
65
- "pre-commit": "lint-staged",
66
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
67
- }
68
- },
69
- "config": {
70
- "commitizen": {
71
- "path": "cz-conventional-changelog"
72
- }
73
- },
74
63
  "lint-staged": {
75
64
  "*.{js,ts,tsx,jsx}": "eslint"
76
65
  }
@@ -1,9 +1,36 @@
1
+ // 内容格式模板
2
+ const mainTemplate = `{{> header}}
3
+
4
+ {{#each commitGroups}}
5
+
6
+ {{#if title}}
7
+ ### {{title}}
8
+
9
+ {{/if}}
10
+ {{#each commits}}
11
+ {{> commit root=@root}}
12
+ {{/each}}
13
+ {{/each}}
14
+ `
15
+
16
+ const headerPartial = `{{#if isPatch}}##{{else}}#{{/if}} {{#if @root.linkCompare}}[{{version}}]({{@root.host}}/{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}/compare/{{previousTag}}...{{currentTag}}){{else}}{{version}}{{/if}}{{#if title}} "{{title}}"{{/if}}{{#if date}} ({{date}}){{/if}}`
17
+ const commitPartial = `* {{#if message}}{{message}}{{else}}{{header}}{{/if}}
18
+
19
+ {{~!-- commit hash --}} {{#if @root.linkReferences}}([{{shortHash}}]({{#if @root.host}}{{@root.host}}/{{/if}}{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}/{{@root.commit}}/{{hash}})){{else}}{{hash~}}{{/if}}
20
+
21
+ {{~!-- commit references --}}{{#if references}}, closes{{~#each references}} {{#if @root.linkReferences}}[{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}#{{this.issue}}]({{#if @root.host}}{{@root.host}}/{{/if}}{{#if this.repository}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}{{else}}{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}{{/if}}/{{@root.issue}}/{{this.issue}}){{else}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}#{{this.issue}}{{/if}}{{/each}}{{/if}}
22
+ `
1
23
  // 需要输出到changelog的提交类型
2
24
  const types = ['feat', 'fix']
3
25
 
4
26
  module.exports = {
5
27
  writerOpts: {
28
+ mainTemplate,
29
+ headerPartial,
30
+ commitPartial,
6
31
  transform: commit => {
32
+ commit.shortHash = commit.hash.substring(0, 8)
33
+
7
34
  if (types.includes(commit.type)) {
8
35
  return commit
9
36
  }
@@ -12,9 +39,6 @@ module.exports = {
12
39
  },
13
40
  // 自定义分组
14
41
  groupBy: 'type',
15
- commitGroupsSort: (a, b) => {
16
- return types.indexOf(a.title) - types.indexOf(b.title)
17
- },
18
42
  // 提交排序
19
43
  commitsSort: ['scope', 'subject']
20
44
  }
@@ -20,6 +20,27 @@ module.exports = {
20
20
  <%_ } _%>
21
21
  ],
22
22
  <%_ } _%>
23
+ <%_ if (vue || styleSheets == supportedStyleSheets.less || styleSheets == supportedStyleSheets.scss) { _%>
24
+ overrides: [
25
+ <%_ if (vue) { _%>
26
+ {
27
+ files: ['**/*.vue'],
28
+ customSyntax: 'postcss-html'
29
+ }<%= styleSheets == supportedStyleSheets.less || styleSheets == supportedStyleSheets.scss ? ',' : ''%>
30
+ <%_ } _%>
31
+ <%_ if (styleSheets == supportedStyleSheets.less) { _%>
32
+ {
33
+ files: ['**/*.less'],
34
+ customSyntax: 'postcss-less'
35
+ }
36
+ <%_ } else if (styleSheets == supportedStyleSheets.scss) { _%>
37
+ {
38
+ files: ['**/*.scss'],
39
+ customSyntax: 'postcss-scss'
40
+ }
41
+ <%_ } _%>
42
+ ],
43
+ <%_ } _%>
23
44
  rules: {
24
45
  <%_ if (styleSheets == supportedStyleSheets.scss) { _%>
25
46
  // SCSS嵌套语法检查
@@ -106,24 +127,5 @@ module.exports = {
106
127
  // 规则集大括号里的内容排序方式
107
128
  'order/properties-order': null,
108
129
  'order/properties-alphabetical-order': true
109
- },
110
- overrides: [
111
- <%_ if (vue) { _%>
112
- {
113
- files: ['**/*.vue'],
114
- customSyntax: 'postcss-html'
115
- }<%= styleSheets == supportedStyleSheets.less || styleSheets == supportedStyleSheets.scss ? ',' : ''%>
116
- <%_ } _%>
117
- <%_ if (styleSheets == supportedStyleSheets.less) { _%>
118
- {
119
- files: ['**/*.less'],
120
- customSyntax: 'postcss-less'
121
- }
122
- <%_ } else if (styleSheets == supportedStyleSheets.scss) { _%>
123
- {
124
- files: ['**/*.scss'],
125
- customSyntax: 'postcss-scss'
126
- }
127
- <%_ } _%>
128
- ]
130
+ }
129
131
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "recommendations": [
3
3
  "esbenp.prettier-vscode",
4
- "dbaeumer.vscode-eslint",
5
4
  <%_ if (style) { _%>
6
5
  "stylelint.vscode-stylelint",
7
6
  <%_ } _%>
8
7
  <%_ if (vue) { _%>
9
- "octref.vetur"
8
+ "octref.vetur",
10
9
  <%_ } _%>
10
+ "dbaeumer.vscode-eslint"
11
11
  ]
12
12
  }
@@ -22,7 +22,7 @@ module.exports = [
22
22
  <%_ if(language == supportedLanguage.typescript) { _%>
23
23
  // TypeScript 配置
24
24
  {
25
- files: ['**/*.ts', <%- framework == supportedFramework.react ? '\'**/*.tsx\'' : ''-%>],
25
+ files: [<%- framework == supportedFramework.react ? '\'**/*.tsx\', ' : ''-%>'**/*.ts'],
26
26
  plugins: {
27
27
  <%_ if (framework == supportedFramework.react) { _%>
28
28
  react: reactPlugin,
@@ -40,7 +40,7 @@ module.exports = [
40
40
  jsx: true
41
41
  },
42
42
  <%_ } _%>
43
- project: "./tsconfig.json"
43
+ project: './tsconfig.json'
44
44
  },
45
45
  sourceType: 'module',
46
46
  globals: { ...globals.browser, ...globals.node, ...globals.es2020 }
@@ -124,7 +124,7 @@ module.exports = [
124
124
  <%_ } _%>
125
125
  // 基础 JavaScript 配置
126
126
  {
127
- files: ['**/*.js'<%- framework == supportedFramework.react ? '\', **/*.jsx\'' : '' -%>],
127
+ files: ['**/*.js'<%- framework == supportedFramework.react ? ' ,\'**/*.jsx\'' : '' -%>],
128
128
  languageOptions: {
129
129
  ecmaVersion: 'latest',
130
130
  sourceType: 'module',