@baic/yolk-cli 2.1.0-alpha.247 → 2.1.0-alpha.249

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.
Files changed (107) hide show
  1. package/es/_util.d.ts +8 -6
  2. package/es/_util.js +1 -1
  3. package/es/index.d.ts +1 -0
  4. package/es/index.js +1 -1
  5. package/es/lintstagedrc.js +1 -1
  6. package/es/yolk.d.ts +1 -1
  7. package/es/yolk.js +1 -1
  8. package/lib/_util.d.ts +8 -6
  9. package/lib/_util.js +1 -1
  10. package/lib/index.d.ts +1 -0
  11. package/lib/index.js +1 -1
  12. package/lib/lintstagedrc.js +1 -1
  13. package/lib/yolk.d.ts +1 -1
  14. package/lib/yolk.js +1 -1
  15. package/package.json +13 -13
  16. package/templates/taro-miniprogram/.eslintignore +4 -0
  17. package/templates/{miniprogram → taro-miniprogram}/.eslintrc.js +1 -0
  18. package/templates/{miniprogram → taro-miniprogram}/.prettierrc.js +1 -0
  19. package/templates/taro-miniprogram/.stylelintignore +4 -0
  20. package/templates/taro-miniprogram/.stylelintrc.js +4 -0
  21. package/templates/taro-miniprogram/src/constants.ts +1 -0
  22. package/templates/umi-mobile/.eslintignore +6 -0
  23. package/templates/umi-mobile/.eslintrc.js +1 -0
  24. package/templates/umi-mobile/.prettierrc.js +1 -0
  25. package/templates/umi-mobile/.stylelintignore +6 -0
  26. package/templates/umi-mobile/.stylelintrc.js +4 -0
  27. package/templates/umi-mobile-h5+app/.eslintignore +6 -0
  28. package/templates/umi-mobile-h5+app/.eslintrc.js +1 -0
  29. package/templates/umi-mobile-h5+app/.prettierrc.js +1 -0
  30. package/templates/umi-mobile-h5+app/.stylelintignore +6 -0
  31. package/templates/umi-mobile-h5+app/.stylelintrc.js +4 -0
  32. package/templates/umi-mobile-native/.eslintignore +6 -0
  33. package/templates/umi-mobile-native/.eslintrc.js +1 -0
  34. package/templates/umi-mobile-native/.prettierrc.js +1 -0
  35. package/templates/umi-mobile-native/.stylelintignore +6 -0
  36. package/templates/umi-mobile-native/.stylelintrc.js +4 -0
  37. package/templates/umi-mobile-native/src/common/bluetooth.ts +3 -3
  38. package/templates/umi-mobile-uni-app/.eslintignore +6 -0
  39. package/templates/umi-mobile-uni-app/.eslintrc.js +1 -0
  40. package/templates/umi-mobile-uni-app/.prettierrc.js +1 -0
  41. package/templates/umi-mobile-uni-app/.stylelintignore +6 -0
  42. package/templates/umi-mobile-uni-app/.stylelintrc.js +4 -0
  43. package/templates/umi-mobile-uni-app/uni-app/common/constants.ts +3 -3
  44. package/templates/umi-web/.eslintignore +6 -0
  45. package/templates/umi-web/.eslintrc.js +1 -0
  46. package/templates/umi-web/.prettierrc.js +1 -0
  47. package/templates/umi-web/.stylelintignore +6 -0
  48. package/templates/umi-web/.stylelintrc.js +4 -0
  49. package/templates/umi-web-screen/.eslintignore +6 -0
  50. package/templates/umi-web-screen/.eslintrc.js +1 -0
  51. package/templates/umi-web-screen/.prettierrc.js +1 -0
  52. package/templates/umi-web-screen/.stylelintignore +6 -0
  53. package/templates/umi-web-screen/.stylelintrc.js +4 -0
  54. package/templates/umi-web-screen/src/constants.ts +4 -4
  55. package/templates/umi-web-screen/src/layouts/controller/index.tsx +1 -1
  56. package/templates/umi-web-screen/src/pages/template/controller/index.tsx +1 -1
  57. package/compiled/v8-compile-cache/index.js +0 -1
  58. package/compiled/v8-compile-cache/package.json +0 -1
  59. package/es/postinstall.d.ts +0 -2
  60. package/es/postinstall.js +0 -2
  61. package/lib/postinstall.d.ts +0 -2
  62. package/lib/postinstall.js +0 -2
  63. package/templates/miniprogram/.stylelintrc +0 -3
  64. package/templates/miniprogram/src/constants.ts +0 -1
  65. package/templates/umi-mobile/.stylelintrc +0 -3
  66. package/templates/umi-mobile-h5+app/.stylelintrc +0 -3
  67. package/templates/umi-mobile-native/.stylelintrc +0 -3
  68. package/templates/umi-mobile-uni-app/.stylelintrc +0 -3
  69. package/templates/umi-web/.stylelintrc +0 -3
  70. package/templates/umi-web-screen/.stylelintrc +0 -3
  71. /package/templates/{miniprogram → taro-miniprogram}/.gitignore.tpl +0 -0
  72. /package/templates/{miniprogram → taro-miniprogram}/.npmrc.tpl +0 -0
  73. /package/templates/{miniprogram → taro-miniprogram}/.prettierignore +0 -0
  74. /package/templates/{miniprogram → taro-miniprogram}/LICENSE +0 -0
  75. /package/templates/{miniprogram → taro-miniprogram}/README.md.tpl +0 -0
  76. /package/templates/{miniprogram → taro-miniprogram}/babel.config.js +0 -0
  77. /package/templates/{miniprogram → taro-miniprogram}/biome.json +0 -0
  78. /package/templates/{miniprogram → taro-miniprogram}/config/index.ts.tpl +0 -0
  79. /package/templates/{miniprogram → taro-miniprogram}/global.d.ts +0 -0
  80. /package/templates/{miniprogram → taro-miniprogram}/package.json.tpl +0 -0
  81. /package/templates/{miniprogram → taro-miniprogram}/project.config.json.tpl +0 -0
  82. /package/templates/{miniprogram → taro-miniprogram}/project.tt.json.tpl +0 -0
  83. /package/templates/{miniprogram → taro-miniprogram}/src/app.config.ts +0 -0
  84. /package/templates/{miniprogram → taro-miniprogram}/src/app.scss +0 -0
  85. /package/templates/{miniprogram → taro-miniprogram}/src/app.tsx +0 -0
  86. /package/templates/{miniprogram → taro-miniprogram}/src/common/request.ts +0 -0
  87. /package/templates/{miniprogram → taro-miniprogram}/src/common/util.ts +0 -0
  88. /package/templates/{miniprogram → taro-miniprogram}/src/components/index.ts +0 -0
  89. /package/templates/{miniprogram → taro-miniprogram}/src/hooks/index.ts +0 -0
  90. /package/templates/{miniprogram → taro-miniprogram}/src/images/empty.gif +0 -0
  91. /package/templates/{miniprogram → taro-miniprogram}/src/index.html +0 -0
  92. /package/templates/{miniprogram → taro-miniprogram}/src/pages/demo/examples/Input.tsx +0 -0
  93. /package/templates/{miniprogram → taro-miniprogram}/src/pages/demo/examples/MobileInput.tsx +0 -0
  94. /package/templates/{miniprogram → taro-miniprogram}/src/pages/demo/examples/MoneyInput.tsx +0 -0
  95. /package/templates/{miniprogram → taro-miniprogram}/src/pages/demo/examples/NumberInput.tsx +0 -0
  96. /package/templates/{miniprogram → taro-miniprogram}/src/pages/demo/examples/Textarea.tsx +0 -0
  97. /package/templates/{miniprogram → taro-miniprogram}/src/pages/demo/examples/TimerButton.tsx +0 -0
  98. /package/templates/{miniprogram → taro-miniprogram}/src/pages/demo/examples/usePreload.tsx +0 -0
  99. /package/templates/{miniprogram → taro-miniprogram}/src/pages/demo/index.config.ts +0 -0
  100. /package/templates/{miniprogram → taro-miniprogram}/src/pages/demo/index.tsx +0 -0
  101. /package/templates/{miniprogram → taro-miniprogram}/src/pages/demo/style.scss +0 -0
  102. /package/templates/{miniprogram → taro-miniprogram}/src/pages/index/index.config.ts +0 -0
  103. /package/templates/{miniprogram → taro-miniprogram}/src/pages/index/index.tsx +0 -0
  104. /package/templates/{miniprogram → taro-miniprogram}/src/pages/index/style.scss +0 -0
  105. /package/templates/{miniprogram → taro-miniprogram}/src/theme.scss +0 -0
  106. /package/templates/{miniprogram → taro-miniprogram}/src/types/user.d.ts +0 -0
  107. /package/templates/{miniprogram → taro-miniprogram}/tsconfig.json +0 -0
package/es/_util.d.ts CHANGED
@@ -1,10 +1,12 @@
1
+ /// <reference types="node" />
1
2
  export type YolkConfig = {
2
3
  strict?: boolean;
3
4
  eslintIgnorePattern?: string;
4
5
  stylelintIgnorePattern?: string;
6
+ initPreCommit?: boolean;
5
7
  };
6
8
  export declare const cwd: string;
7
- export declare const ENCODING = "utf-8";
9
+ export declare const ENCODING: BufferEncoding;
8
10
  export declare const warn: (text?: string) => void | "" | undefined;
9
11
  export declare const error: (text?: string) => void | "" | undefined;
10
12
  export declare const ready: (text?: string) => void | "" | undefined;
@@ -14,15 +16,15 @@ export declare const completeExit: () => never;
14
16
  export declare const breakExit: () => never;
15
17
  export declare const execCommand: ({ command, args, complete, close, exit, }: {
16
18
  command: string;
17
- args?: string[];
18
- complete?: () => void;
19
- close?: () => void;
20
- exit?: boolean;
19
+ args?: string[] | undefined;
20
+ complete?: (() => void) | undefined;
21
+ close?: (() => void) | undefined;
22
+ exit?: boolean | undefined;
21
23
  }) => void;
22
24
  export declare const getYolkConfig: () => YolkConfig;
23
25
  export declare const getProjectConfigJSON: () => any;
24
26
  export declare const getPackageJSON: () => any;
25
- export declare const getConfigFilePath: (type: "eslint" | "stylelint" | "prettier" | "biome") => string;
27
+ export declare const getConfigFilePath: (type: 'eslint' | 'stylelint' | 'prettier' | 'biome') => string;
26
28
  export declare const getEsLintConfigPath: () => string;
27
29
  export declare const getStyleLintConfigPath: () => string;
28
30
  export declare const getPrettierConfigPath: () => string;
package/es/_util.js CHANGED
@@ -1 +1 @@
1
- var m=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});import{spawn as k}from"node:child_process";import r from"node:fs";import g from"node:path";import c from"chalk";import{globSync as x}from"glob";import{rimrafSync as u,windowsSync as d}from"rimraf";import{program as h}from"../compiled/commander";var i=process.cwd(),a=console,p="utf-8",P=t=>t&&a.log(c.yellow("warn -"),t),C=t=>t&&a.log(c.red("error -"),t),$=t=>t&&a.log(c.green("ready -"),t),j=t=>t&&a.log(c.blue("info -"),t),S=()=>process.platform==="win32",N=t=>S()?`${t}.cmd`:t,G=t=>S()?d(t):u(t),b=()=>{j("yolk complete!"),process.exit(0)},w=()=>{P("yolk break!"),process.exit(0)},q=({command:t,args:e,complete:o,close:n,exit:s=!0})=>{let f=k(N(t),e||[],{stdio:"inherit"}).on("close",y=>{y?(n&&n(),C("yolk close!"),process.exit(y)):(o&&o(),s&&b())});process.on("SIGINT",()=>{h.exitOverride(),f.kill(),w()})},O=()=>{let t=x("*.yolkrc*",{cwd:i,dot:!0});if(!t.length)return{};let e=g.join(i,t[0]);if(r.existsSync(e))try{return JSON.parse(r.readFileSync(e,p))||{}}catch(o){return o(o.message||".yolkrc转换错误"),{}}else return{}},B=()=>{let t=g.join(i,"project.config.json");if(r.existsSync(t))try{return JSON.parse(r.readFileSync(t,p))||{}}catch(e){return e(e.message||"project.config.json转换错误"),{}}else return{}},D=()=>{let t=g.join(i,"package.json");if(r.existsSync(t))try{return JSON.parse(r.readFileSync(t,p))||{}}catch(e){return e(e.message||"package.json转换错误"),{}}else return{}},l=t=>{let e=O(),o="";try{o=m.resolve(`@baic/${t}-config-yolk`)}catch{}let n=x(`*.${t}rc*`,{cwd:i,dot:!0}),s=n==null?void 0:n[0];return e.strict===!1&&s&&r.existsSync(s)?s:r.existsSync(o)?o:s},T=()=>l("eslint"),W=()=>l("stylelint"),z=()=>l("prettier"),A=()=>l("biome");export{p as ENCODING,w as breakExit,b as completeExit,i as cwd,C as error,q as execCommand,A as getBiomeConfigPath,l as getConfigFilePath,T as getEsLintConfigPath,D as getPackageJSON,z as getPrettierConfigPath,B as getProjectConfigJSON,W as getStyleLintConfigPath,O as getYolkConfig,j as info,$ as ready,G as rimrafSync,P as warn};
1
+ import{spawn as o}from"node:child_process";import{existsSync as r,readFileSync as e}from"node:fs";import{join as t}from"node:path";import n from"chalk";import{globSync as c}from"glob";import{rimrafSync as i,windowsSync as s}from"rimraf";import{program as p}from"../compiled/commander";export const cwd=process.cwd();const a=console;export const ENCODING="utf-8";export const warn=o=>o&&a.log(n.yellow("warn -"),o);export const error=o=>o&&a.log(n.red("error -"),o);export const ready=o=>o&&a.log(n.green("ready -"),o);export const info=o=>o&&a.log(n.blue("info -"),o);const l=()=>"win32"===process.platform,g=o=>l()?`${o}.cmd`:o;export const rimrafSync=o=>l()?s(o):i(o);export const completeExit=()=>{info("yolk complete!"),process.exit(0)};export const breakExit=()=>{warn("yolk break!"),process.exit(0)};export const execCommand=({command:r,args:e,complete:t,close:n,exit:c=!0})=>{const i=o(g(r),e||[],{stdio:"inherit"}).on("close",(o=>{o?(n&&n(),error("yolk close!"),process.exit(o)):(t&&t(),c&&completeExit())}));process.on("SIGINT",(()=>{p.exitOverride(),i.kill(),breakExit()}))};export const getYolkConfig=()=>{const o=c("*.yolkrc*",{cwd:cwd,dot:!0});if(!o.length)return{};const n=t(cwd,o[0]);if(!r(n))return{};try{return JSON.parse(e(n,ENCODING))||{}}catch(error){return error(error.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}};export const getProjectConfigJSON=()=>{const o=t(cwd,"project.config.json");if(!r(o))return{};try{return JSON.parse(e(o,ENCODING))||{}}catch(error){return error(error.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}};export const getPackageJSON=()=>{const o=t(cwd,"package.json");if(!r(o))return{};try{return JSON.parse(e(o,ENCODING))||{}}catch(error){return error(error.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}};export const getConfigFilePath=o=>{const e=getYolkConfig();let t="";try{t=require.resolve(`@baic/${o}-config-yolk`)}catch(error){}const n=c(`*.${o}rc*`,{cwd:cwd,dot:!0}),i=null===n||void 0===n?void 0:n[0];return!1===e.strict&&i&&r(i)?i:r(t)?t:i};export const getEsLintConfigPath=()=>getConfigFilePath("eslint");export const getStyleLintConfigPath=()=>getConfigFilePath("stylelint");export const getPrettierConfigPath=()=>getConfigFilePath("prettier");export const getBiomeConfigPath=()=>getConfigFilePath("biome");
package/es/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  #! /usr/bin/env node
2
+ import './yolk';
package/es/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #! /usr/bin/env node
2
- var r=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(i,n)=>(typeof require<"u"?require:i)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});r("../compiled/v8-compile-cache");r("./yolk");
2
+ import"./yolk";
@@ -1 +1 @@
1
- var i=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,m)=>(typeof require<"u"?require:e)[m]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var $=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var P=$((I,u)=>{var{join:s}=i("node:path"),{getBiomeConfigPath:d,getEsLintConfigPath:f,getPrettierConfigPath:y,getStyleLintConfigPath:j,getYolkConfig:C}=i("./_util"),h=["**/node_modules/**","**/build/**","**/dist/**","**/lib/**","**/es/**","**/mock/**","**/test/**","**/public/**","**/assets/**","**/.umi/**","**/.umi-production/**","**/h5+app/**","**/*uni*/**","**/android/**","**/ios/**","**/*.ignore/**"],{strict:p=!0,eslintIgnorePattern:r,stylelintIgnorePattern:a}=C(),c=s(process.cwd(),"node_modules",".cache"),n=`prettier --write --cache --cache-strategy=content --cache-location=${s(c,".prettiercache")} --config ${y()} --no-error-on-unmatched-pattern`,l=`eslint --fix ${p?"--no-inline-config":""} --no-error-on-unmatched-pattern --cache --cache-strategy=content --cache-location=${s(c,".eslintcache")} --config ${f()} ${h.concat(r?[r]:[]).map(t=>`--ignore-pattern ${t}`).join(" ")}`,o=`stylelint --fix ${p?"--ignore-disables":""} --allow-empty-input --cache --cache-strategy=content --cache-location=${s(c,".stylelintcache")} --config ${j()} ${h.concat(a?[a]:[]).map(t=>`--ignore-pattern ${t}`).join(" ")}`,x=`biome check --write --unsafe --no-errors-on-unmatched --log-level=error --files-ignore-unknown=true --config-path=${d()}`,g={"*.{md,json,jsonc}":[n],"*.css":[n,`${o} --custom-syntax postcss`],"*.less":[n,`${o} --custom-syntax postcss-less`],"*.{sass,scss}":[n,`${o} --custom-syntax postcss-scss`],"*.{js,jsx,cjs,mjs}":[n,l],"*.{ts,tsx,cts,mts}":[`${n} --parser=typescript`,l]};u.exports={...g,[`!(${Object.keys(g).join("|")})`]:[x]}});export default P();
1
+ import e from"@babel/runtime/helpers/defineProperty";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function n(n){for(var o=1;o<arguments.length;o++){var r=null!=arguments[o]?arguments[o]:{};o%2?t(Object(r),!0).forEach((function(t){e(n,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}))}return n}const{join:o}=require("node:path"),{getBiomeConfigPath:r,getEsLintConfigPath:c,getPrettierConfigPath:s,getStyleLintConfigPath:i,getYolkConfig:a}=require("./_util"),p=["**/node_modules/**","**/build/**","**/dist/**","**/lib/**","**/es/**","**/mock/**","**/test/**","**/public/**","**/assets/**","**/.umi/**","**/.umi-production/**","**/h5+app/**","**/*uni*/**","**/android/**","**/ios/**","**/*.ignore/**"],{strict:l=!0,eslintIgnorePattern:u,stylelintIgnorePattern:g}=a(),h=o(process.cwd(),"node_modules",".cache"),f=`prettier --write --cache --cache-strategy=content --cache-location=${o(h,".prettiercache")} --config ${s()} --no-error-on-unmatched-pattern`,m=`eslint --fix ${l?"--no-inline-config":""} --no-error-on-unmatched-pattern --cache --cache-strategy=content --cache-location=${o(h,".eslintcache")} --config ${c()} ${p.concat(u?[u]:[]).map((e=>`--ignore-pattern ${e}`)).join(" ")}`,y=`stylelint --fix ${l?"--ignore-disables":""} --allow-empty-input --cache --cache-strategy=content --cache-location=${o(h,".stylelintcache")} --config ${i()} ${p.concat(g?[g]:[]).map((e=>`--ignore-pattern ${e}`)).join(" ")}`,b=`biome check --write --unsafe --no-errors-on-unmatched --log-level=error --files-ignore-unknown=true --config-path=${r()}`,j={"*.{md,json,jsonc}":[f],"*.css":[f,`${y} --custom-syntax postcss`],"*.less":[f,`${y} --custom-syntax postcss-less`],"*.{sass,scss}":[f,`${y} --custom-syntax postcss-scss`],"*.{js,jsx,cjs,mjs}":[f,m],"*.{ts,tsx,cts,mts}":[`${f} --parser=typescript`,m]};module.exports=n(n({},j),{},{[`!(${Object.keys(j).join("|")})`]:[b]});
package/es/yolk.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  #! /usr/bin/env node
2
- export declare const initPreCommit: () => void;
2
+ export {};
package/es/yolk.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #! /usr/bin/env node
2
- var w=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(o,t)=>(typeof require<"u"?require:o)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{execSync as Q}from"node:child_process";import{chmodSync as ee,copyFileSync as te,existsSync as c,readFileSync as T,statSync as oe,writeFileSync as J}from"node:fs";import D from"node:os";import{basename as j,dirname as M,join as m,relative as ie}from"node:path";import G from"lodash/floor";import H from"lodash/isString";import{globSync as re}from"glob";import ne from"inquirer";import*as S from"miniprogram-ci";import{mkdirpSync as A}from"mkdirp";import{program as v}from"../compiled/commander";import ae from"../compiled/mustache";import x from"../package.json";import{breakExit as se,cwd as d,ENCODING as k,error as F,execCommand as r,getPackageJSON as me,getProjectConfigJSON as ce,info as a,ready as l,rimrafSync as W,warn as X}from"./_util";var P="##### CREATED BY YOLK #####",Y=(e,o,t)=>{ne.prompt([{type:"list",name:"type",message:"选择模版",default:"web",choices:[{name:"web template(umi framework)",value:"umi-web"},{name:"web big screen template(umi framework)",value:"umi-web-screen"},{name:"mobile template(umi framework)",value:"umi-mobile"},{name:"mobile HBuilderX h5+app template(umi framework)",value:"umi-mobile-h5+app"},{name:"mobile HBuilderX uni-app template(umi framework)",value:"umi-mobile-uni-app"},{name:"mobile native template(umi framework)",value:"umi-mobile-native"},{name:"miniprogram template",value:"miniprogram"}]},{type:"input",name:"projectName",message:"项目名称",default:j(j(process.cwd()))},{type:"list",name:"packageManager",message:"选择包管理器(默认:pnpm,推荐:pnpm)",default:"default",choices:[{name:"默认安装",value:"default"},{name:"跳过安装",value:!1},{name:"pnpm install",value:"pnpm"},{name:"yarn install",value:"yarn"},{name:"npm install",value:"npm"}]}]).then(({type:n,projectName:u,packageManager:g})=>{let s={projectName:u,packageManager:g==="default"?"pnpm":g,yolkVersion:x.version};if(n==="umi-mobile-uni-app"){X("暂不支持");return}let i=o||m(__dirname,`../templates/${n}`);if(l(`复制模版 ${j(i)}`),re("**/*",{cwd:i,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]}).forEach(f=>{if(!i)return;let y=m(i,f);if(!oe(y).isDirectory())if(f.endsWith(".tpl")){let p=T(y,k),h=m(e,f.replace(/\.tpl$/,"")),b=ae.render(p,s);A(M(h)),l(`创建 ${ie(e,h)}`),J(h,b,k)}else{l(`创建 ${f}`);let p=m(e,f);A(M(p)),te(y,p)}}),l("复制模版 success!"),t&&c(i)&&W(i)&&l(`缓存删除 success! ${j(i||"")}`),g)switch(l("初始化依赖包"),g){case"default":case"pnpm":r({command:"pnpm",args:["install"]});break;case"yarn":r({command:"yarn",args:["install"]});break;case"npm":r({command:"npm",args:["install"]});break;default:}l("可查阅<<https://303394539.github.io/yolk-docs/>>了解相关文档")})},pe=(e,o)=>Y(e,o,!0),C=()=>c(m(d,"project.config.json")),U=()=>{let e=c(m(d,"node_modules/.bin/max"));if(!e)try{e=c(w.resolve("@umijs/max"))}catch{}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test(Q("umi -v").toString())}catch{}if(!e){let o=m(d,"node_modules","umi","package.json");if(c(o))try{let t=JSON.parse(T(o,k))||{};e=t.version&&+t.version.split(".")[0]>3}catch{}}return e},z=()=>{let e=m(d,"project.config.json");return c(e)?w(e).appid:""},N=()=>c(m(d,"project.tt.json"))&&z().indexOf("tt")===0,E=()=>z().indexOf("20")===0,le=()=>{let e=m(d,".git/"),o=m(d,".git/hooks"),t=m(o,"pre-commit"),n=c(e),u=c(o),g=c(t);if(n){u||(A(o),l("create .git/hooks")),g||(J(t,"",k),l("create pre-commit"));try{ee(t,"777")}catch(i){F(`chmod ${t} failed: ${i.message}`)}let s=T(t,k).toString();s.indexOf(P)>=0&&(s=`${s.substring(0,s.indexOf(P))}${s.substring(s.lastIndexOf(P)+P.length)}`.replace(/(\r|\n)+$/gu,"")),J(t,(s.indexOf("#!/")<0?["#!/bin/sh"]:[]).concat([s,P,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",P]).filter(i=>!!i).join(D.EOL),k)}},de=async()=>{X("统一代码规范,进行严格的语法检查。"),r({command:"lint-staged",args:["-c",w.resolve("./lintstagedrc")]})},B=({mAppid:e,mProject:o,mPrivateKeyPath:t,mVersion:n,mDesc:u,mRobot:g,mQrcodeFormat:s,mQrcodeOutputDest:i,mPagePath:$,mSearchQuery:f})=>{let y="";try{y=c(m(d,".git"))?Q("git log -1 --pretty=format:%H").toString():""}catch{}let p=ce(),h=e||p.appid,b=o||m(d,"dist"),O=t||m(d,`private.${h}.key`);if(c(b))if(c(O)){let _=me(),K=n||_.version||p.version||"1.0.0",R=u||_.description||p.description,I=`${y?` commit: ${y};`:""}${R?` description: ${R};`:""}`;y&&a(`commit: ${y}`),a(`dist: ${b}`),a(`key: ${O}`),a(`appid: ${h}`),a(`version: ${K}`),a(`desc: ${I}`);let Z=new S.Project({appid:h,type:"miniProgram",projectPath:b,privateKeyPath:O,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:h,options:{project:Z,version:K,desc:I,setting:{...p.setting,es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1},robot:g,qrcodeFormat:s,qrcodeOutputDest:i,pagePath:$,searchQuery:f}}}else throw Error(`没有找到上传密钥(${O})`);else throw Error(`没有找到dist目录(${b})`)},q=()=>{let e="";try{e=Q(`npm view ${x.name} version`,{timeout:3e3}).toString().replace(/\n/g,"")}catch{}a(`yolk version: ${x.version}${e&&e!==x.version?`(last:${e})`:""}`),a(`node version: ${process.version}`),a(`platform: ${D.platform()}`),a(`memory: ${G(D.freemem()/1024/1024)} MB(${G(D.totalmem()/1024/1024)} MB)`)},L=e=>e.option("--appid, --mAppid <appid>","小程序appid").option("--project, --mProject <project>","小程序上传工程目录").option("--privateKeyPath, --mPrivateKeyPath <privateKeyPath>","小程序上传key文件,默认:{当前目录}/private.{appid}.key").option("--version, --mVersion <version>","小程序上传版本号").option("--desc, --mDesc <desc>","小程序上传描述").option("--robot, --mRobot <robot>","小程序上传ci机器人1~30").option("--qrcodeFormat, --mQrcodeFormat <qrcodeFormat>",'小程序预览返回二维码文件的格式 "image" 或 "base64", 默认值 "terminal" 供调试用').option("--qrcodeOutputDest, --mQrcodeOutputDest <qrcodeOutputDest>","小程序预览二维码文件保存路径").option("--pagePath, --mPagePath <pagePath>","小程序预览预览页面路径").option("--searchQuery, --mSearchQuery <searchQuery>","小程序预览预览页面路径启动参数"),ue=/(\w+)=('(.*)'|"(.*)"|(.*))/giu,V=e=>{process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";let o=[];return e==null||e.forEach(t=>{if(ue.test(t)){let[n,u]=t.split("=");process.env[n]=u,a(`设置环境变量:${n}=${u}`)}else o.push(t)}),o},ge=()=>{le(),process.argv.length>2?(v.version(x.version,"-v,--version","输出版本号").usage("[command] [options]"),v.command("init").description("初始化项目").option("--clone <template>","如果需要,可通过git clone拉取模版,默认取cli默认模版").action(({clone:e},{args:o})=>{if(q(),l("yolk init 开始"),e){let t=".yolk",n=m(d,t);c(n)&&W(n)&&l(`缓存删除 success! ${n}`),r({command:"git",args:["clone","-b","master","--depth","1",e,t].concat(o)}),pe(d,n)}else Y(d)}),v.command("start").description("启动项目").option("--docs","文档模式").action(({docs:e},{args:o})=>{q();let t=V(o);C()?N()?r({command:"taro",args:["build","--type","tt","--watch"].concat(t)}):E()?r({command:"taro",args:["build","--type","alipay","--watch"].concat(t)}):r({command:"taro",args:["build","--type","weapp","--watch"].concat(t)}):e?r({command:"dumi",args:["dev"].concat(t)}):U()?r({command:"max",args:["dev"].concat(t)}):r({command:"umi",args:["dev"].concat(t)})}),v.command("build").description("编译项目").option("--docs","文档模式").action(({docs:e},{args:o})=>{q();let t=V(o);C()?N()?r({command:"taro",args:["build","--type","tt"].concat(t)}):E()?r({command:"taro",args:["build","--type","alipay"].concat(t)}):r({command:"taro",args:["build","--type","weapp"].concat(t)}):e?r({command:"dumi",args:["build"].concat(t)}):U()?r({command:"max",args:["setup"].concat(t),complete:()=>r({command:"max",args:["build"].concat(t)}),exit:!1}):r({command:"umi",args:["build"].concat(t)})}),v.command("pre-commit").description("执行commit hook").action(de),L(v.command("miniprogram-upload").description("使用 miniprogram-ci 上传小程序")).action(e=>{if(C()){if(!N()){if(!E()){let{appid:o,options:{project:t,version:n,desc:u,setting:g,robot:s}}=B(e);a(`${o} 上传开始`),S.upload({project:t,version:n,desc:u,setting:g,robot:s,onProgressUpdate:i=>{if(H(i))a(`task: ${i}`);else{let{status:$,message:f}=i;a(`task(${$}): ${f}`)}}}).then(()=>{l(`${o} 上传完成`)})}}}else F("非小程序项目目录")}),L(v.command("miniprogram-preview").description("使用 miniprogram-ci 预览小程序")).action(e=>{if(C()){if(!N()){if(!E()){let{appid:o,options:{project:t,version:n,desc:u,setting:g,robot:s,qrcodeFormat:i,qrcodeOutputDest:$,pagePath:f,searchQuery:y}}=B(e);a(`${o} 上传预览开始`),S.preview({project:t,version:n,desc:u,setting:g,robot:s,qrcodeFormat:i,qrcodeOutputDest:$,pagePath:f,searchQuery:y,onProgressUpdate:p=>{if(H(p))a(`task: ${p}`);else{let{status:h,message:b}=p;a(`task(${h}): ${b}`)}}}).then(()=>{l(`${o} 上传预览完成`)})}}}else F("非小程序项目目录")}),v.command("exec").description("执行ts文件").argument("<path>","执行的ts文件").action(e=>{r({command:"tsx",args:[e]})}),v.parse(process.argv)):se()};ge();export{le as initPreCommit};
2
+ import e from"@babel/runtime/helpers/defineProperty";function t(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function o(o){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?t(Object(i),!0).forEach((function(t){e(o,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach((function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))}))}return o}import{execSync as r}from"node:child_process";import{chmodSync as i,copyFileSync as a,existsSync as n,readFileSync as s,statSync as m,writeFileSync as c}from"node:fs";import p from"node:os";import{basename as d,dirname as l,join as u,relative as g}from"node:path";import{floor as f,isString as y}from"lodash";import{globSync as h}from"glob";import v from"inquirer";import*as b from"miniprogram-ci";import{mkdirpSync as $}from"mkdirp";import{program as j}from"../compiled/commander";import O from"../compiled/mustache";import k from"../package.json";import{breakExit as P,cwd as w,ENCODING as x,error as D,execCommand as S,getPackageJSON as E,getProjectConfigJSON as q,getYolkConfig as _,info as Q,ready as N,rimrafSync as F,warn as K}from"./_util";const L="##### CREATED BY YOLK #####",R=(e,t,o)=>{v.prompt([{type:"list",name:"type",message:"\u9009\u62e9\u6a21\u7248",default:"web",choices:[{name:"web template(umi framework)",value:"umi-web"},{name:"web big screen template(umi framework)",value:"umi-web-screen"},{name:"mobile template(umi framework)",value:"umi-mobile"},{name:"mobile HBuilderX h5+app template(umi framework)",value:"umi-mobile-h5+app"},{name:"mobile HBuilderX uni-app template(umi framework)",value:"umi-mobile-uni-app"},{name:"mobile native template(umi framework)",value:"umi-mobile-native"},{name:"taro-miniprogram template",value:"taro-miniprogram"}]},{type:"input",name:"projectName",message:"\u9879\u76ee\u540d\u79f0",default:d(d(process.cwd()))},{type:"list",name:"packageManager",message:"\u9009\u62e9\u5305\u7ba1\u7406\u5668(\u9ed8\u8ba4\uff1apnpm\uff0c\u63a8\u8350\uff1apnpm)",default:"default",choices:[{name:"\u9ed8\u8ba4\u5b89\u88c5",value:"default"},{name:"\u8df3\u8fc7\u5b89\u88c5",value:!1},{name:"pnpm install",value:"pnpm"},{name:"yarn install",value:"yarn"},{name:"npm install",value:"npm"}]}]).then((({type:r,projectName:i,packageManager:p})=>{const f={projectName:i,packageManager:"default"===p?"pnpm":p,yolkVersion:k.version};if("umi-mobile-uni-app"===r)return void K("\u6682\u4e0d\u652f\u6301");const y=t||u(__dirname,`../templates/${r}`);N(`\u590d\u5236\u6a21\u7248 ${d(y)}`);const v=h("**/*",{cwd:y,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(v.forEach((t=>{if(!y)return;const o=u(y,t);if(!m(o).isDirectory())if(t.endsWith(".tpl")){const r=s(o,x),i=u(e,t.replace(/\.tpl$/,"")),a=O.render(r,f);$(l(i)),N(`\u521b\u5efa ${g(e,i)}`),c(i,a,x)}else{N(`\u521b\u5efa ${t}`);const r=u(e,t);$(l(r)),a(o,r)}})),N("\u590d\u5236\u6a21\u7248 success!"),o&&n(y)&&F(y)&&N(`\u7f13\u5b58\u5220\u9664 success! ${d(y||"")}`),p)switch(N("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),p){case"default":case"pnpm":S({command:"pnpm",args:["install"]});break;case"yarn":S({command:"yarn",args:["install"]});break;case"npm":S({command:"npm",args:["install"]});break;default:}N("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},M=(e,t)=>R(e,t,!0),B=()=>n(u(w,"project.config.json")),I=()=>{let e=n(u(w,"node_modules/.bin/max"));if(!e)try{e=n(require.resolve("@umijs/max"))}catch(t){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test(r("umi -v").toString())}catch(t){}if(!e){const o=u(w,"node_modules","umi","package.json");if(n(o))try{const t=JSON.parse(s(o,x))||{};e=t.version&&+t.version.split(".")[0]>3}catch(t){}}return e},U=()=>{const e=u(w,"project.config.json");if(n(e)){const t=require(e);return t.appid}return""},W=()=>n(u(w,"project.tt.json"))&&0===U().indexOf("tt"),A=()=>0===U().indexOf("20"),T=()=>{const e=_(),t=u(w,".husky/pre-commit"),o=u(w,".git/"),r=u(w,".git/hooks"),a=u(r,"pre-commit"),m=n(t),d=n(o),l=n(r),g=n(a),f=!1!==e.initPreCommit&&!m,y=[L,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",L].join(p.EOL),h=e=>{let t=e||"";return t&&t.indexOf(L)>=0&&(t=`${t.substring(0,t.indexOf(L))}${t.substring(t.lastIndexOf(L)+L.length)}`.replace(/(\r|\n)+$/gu,"")),t};if(d)if(f)if(l||($(r),N("create .git/hooks")),g){try{i(a,"777")}catch(v){D(`chmod ${a} failed: ${v.message}`)}const e=h(s(a,x).toString());c(a,(e.indexOf("#!/")<0?["#!/bin/sh"]:[]).concat([e,y]).filter((e=>!!e)).join(p.EOL),x)}else c(a,["#!/bin/sh",y].join(p.EOL),x),N("create pre-commit");else if(g){const e=h(s(a,x).toString());c(a,e,x)}},V=()=>{K("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),S({command:"lint-staged",args:["-c",require.resolve("./lintstagedrc")]})},X=({mAppid:e,mProject:t,mPrivateKeyPath:i,mVersion:a,mDesc:s,mRobot:m,mQrcodeFormat:c,mQrcodeOutputDest:p,mPagePath:d,mSearchQuery:l})=>{let g="";try{g=n(u(w,".git"))?r("git log -1 --pretty=format:%H").toString():""}catch(D){}const f=q(),y=e||f.appid,h=t||u(w,"dist"),v=i||u(w,`private.${y}.key`);if(n(h)){if(n(v)){const e=E(),t=a||e.version||f.version||"1.0.0",r=s||e.description||f.description,i=`${g?` commit: ${g};`:""}${r?` description: ${r};`:""}`;g&&Q(`commit: ${g}`),Q(`dist: ${h}`),Q(`key: ${v}`),Q(`appid: ${y}`),Q(`version: ${t}`),Q(`desc: ${i}`);const n=new b.Project({appid:y,type:"miniProgram",projectPath:h,privateKeyPath:v,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:y,options:{project:n,version:t,desc:i,setting:o(o({},f.setting),{},{es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1}),robot:m,qrcodeFormat:c,qrcodeOutputDest:p,pagePath:d,searchQuery:l}}}throw Error(`\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(${v})`)}throw Error(`\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(${h})`)},C=()=>{let e="";try{e=r(`npm view ${k.name} version`,{timeout:3e3}).toString().replace(/\n/g,"")}catch(t){}Q(`yolk version: ${k.version}${e&&e!==k.version?`(latest\uff1a${e})`:""}`),Q(`node version: ${process.version}`),Q(`platform: ${p.platform()}`),Q(`memory: ${f(p.freemem()/1024/1024)} MB(${f(p.totalmem()/1024/1024)} MB)`)},H=e=>e.option("--appid, --mAppid <appid>","\u5c0f\u7a0b\u5e8fappid").option("--project, --mProject <project>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u5de5\u7a0b\u76ee\u5f55").option("--privateKeyPath, --mPrivateKeyPath <privateKeyPath>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20key\u6587\u4ef6\uff0c\u9ed8\u8ba4\uff1a{\u5f53\u524d\u76ee\u5f55}/private.{appid}.key").option("--version, --mVersion <version>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u7248\u672c\u53f7").option("--desc, --mDesc <desc>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u63cf\u8ff0").option("--robot, --mRobot <robot>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20ci\u673a\u5668\u4eba1~30").option("--qrcodeFormat, --mQrcodeFormat <qrcodeFormat>",'\u5c0f\u7a0b\u5e8f\u9884\u89c8\u8fd4\u56de\u4e8c\u7ef4\u7801\u6587\u4ef6\u7684\u683c\u5f0f "image" \u6216 "base64"\uff0c \u9ed8\u8ba4\u503c "terminal" \u4f9b\u8c03\u8bd5\u7528').option("--qrcodeOutputDest, --mQrcodeOutputDest <qrcodeOutputDest>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u4e8c\u7ef4\u7801\u6587\u4ef6\u4fdd\u5b58\u8def\u5f84").option("--pagePath, --mPagePath <pagePath>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84").option("--searchQuery, --mSearchQuery <searchQuery>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84\u542f\u52a8\u53c2\u6570"),J=/(\w+)=('(.*)'|"(.*)"|(.*))/giu,Y=e=>{process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";const t=[];return null===e||void 0===e||e.forEach((e=>{if(J.test(e)){const[t,o]=e.split("=");process.env[t]=o,Q(`\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a${t}=${o}`)}else t.push(e)})),t},G=()=>{T(),process.argv.length>2?(j.version(k.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),j.command("init").description("\u521d\u59cb\u5316\u9879\u76ee").option("--clone <template>","\u5982\u679c\u9700\u8981\uff0c\u53ef\u901a\u8fc7git clone\u62c9\u53d6\u6a21\u7248\uff0c\u9ed8\u8ba4\u53d6cli\u9ed8\u8ba4\u6a21\u7248").action((({clone:e},{args:t})=>{if(C(),N("yolk init \u5f00\u59cb"),e){const o=".yolk",r=u(w,o);n(r)&&F(r)&&N(`\u7f13\u5b58\u5220\u9664 success! ${r}`),S({command:"git",args:["clone","-b","master","--depth","1",e,o].concat(t)}),M(w,r)}else R(w)})),j.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{C();const o=Y(t);B()?W()?S({command:"taro",args:["build","--type","tt","--watch"].concat(o)}):A()?S({command:"taro",args:["build","--type","alipay","--watch"].concat(o)}):S({command:"taro",args:["build","--type","weapp","--watch"].concat(o)}):e?S({command:"dumi",args:["dev"].concat(o)}):I()?S({command:"max",args:["dev"].concat(o)}):S({command:"umi",args:["dev"].concat(o)})})),j.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{C();const o=Y(t);B()?W()?S({command:"taro",args:["build","--type","tt"].concat(o)}):A()?S({command:"taro",args:["build","--type","alipay"].concat(o)}):S({command:"taro",args:["build","--type","weapp"].concat(o)}):e?S({command:"dumi",args:["build"].concat(o)}):I()?S({command:"max",args:["setup"].concat(o),complete:()=>S({command:"max",args:["build"].concat(o)}),exit:!1}):S({command:"umi",args:["build"].concat(o)})})),j.command("init-pre-commit").description("\u521d\u59cb\u5316 commit hook").action(T),j.command("pre-commit").description("\u6267\u884ccommit hook").action(V),H(j.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((e=>{if(B())if(W());else if(A());else{const{appid:t,options:{project:o,version:r,desc:i,setting:a,robot:n}}=X(e);Q(`${t} \u4e0a\u4f20\u5f00\u59cb`),b.upload({project:o,version:r,desc:i,setting:a,robot:n,onProgressUpdate:e=>{if(y(e))Q(`task: ${e}`);else{const{status:t,message:o}=e;Q(`task(${t}): ${o}`)}}}).then((()=>{N(`${t} \u4e0a\u4f20\u5b8c\u6210`)}))}else D("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),H(j.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((e=>{if(B())if(W());else if(A());else{const{appid:t,options:{project:o,version:r,desc:i,setting:a,robot:n,qrcodeFormat:s,qrcodeOutputDest:m,pagePath:c,searchQuery:p}}=X(e);Q(`${t} \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb`),b.preview({project:o,version:r,desc:i,setting:a,robot:n,qrcodeFormat:s,qrcodeOutputDest:m,pagePath:c,searchQuery:p,onProgressUpdate:e=>{if(y(e))Q(`task: ${e}`);else{const{status:t,message:o}=e;Q(`task(${t}): ${o}`)}}}).then((()=>{N(`${t} \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210`)}))}else D("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),j.command("exec").description("\u6267\u884cts\u6587\u4ef6").argument("<path>","\u6267\u884c\u7684ts\u6587\u4ef6").action(((e,t,{args:o})=>{const r=Y(o);S({command:"tsx",args:[e].concat(r)})})),j.command("test").description("\u6267\u884c\u6d4b\u8bd5").action((()=>{S({command:"ytest",args:["run"]})})),j.parse(process.argv)):P()};G();
package/lib/_util.d.ts CHANGED
@@ -1,10 +1,12 @@
1
+ /// <reference types="node" />
1
2
  export type YolkConfig = {
2
3
  strict?: boolean;
3
4
  eslintIgnorePattern?: string;
4
5
  stylelintIgnorePattern?: string;
6
+ initPreCommit?: boolean;
5
7
  };
6
8
  export declare const cwd: string;
7
- export declare const ENCODING = "utf-8";
9
+ export declare const ENCODING: BufferEncoding;
8
10
  export declare const warn: (text?: string) => void | "" | undefined;
9
11
  export declare const error: (text?: string) => void | "" | undefined;
10
12
  export declare const ready: (text?: string) => void | "" | undefined;
@@ -14,15 +16,15 @@ export declare const completeExit: () => never;
14
16
  export declare const breakExit: () => never;
15
17
  export declare const execCommand: ({ command, args, complete, close, exit, }: {
16
18
  command: string;
17
- args?: string[];
18
- complete?: () => void;
19
- close?: () => void;
20
- exit?: boolean;
19
+ args?: string[] | undefined;
20
+ complete?: (() => void) | undefined;
21
+ close?: (() => void) | undefined;
22
+ exit?: boolean | undefined;
21
23
  }) => void;
22
24
  export declare const getYolkConfig: () => YolkConfig;
23
25
  export declare const getProjectConfigJSON: () => any;
24
26
  export declare const getPackageJSON: () => any;
25
- export declare const getConfigFilePath: (type: "eslint" | "stylelint" | "prettier" | "biome") => string;
27
+ export declare const getConfigFilePath: (type: 'eslint' | 'stylelint' | 'prettier' | 'biome') => string;
26
28
  export declare const getEsLintConfigPath: () => string;
27
29
  export declare const getStyleLintConfigPath: () => string;
28
30
  export declare const getPrettierConfigPath: () => string;
package/lib/_util.js CHANGED
@@ -1 +1 @@
1
- var J=Object.create;var l=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var L=(t,e)=>{for(var o in e)l(t,o,{get:e[o],enumerable:!0})},u=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of v(e))!F.call(t,r)&&r!==o&&l(t,r,{get:()=>e[r],enumerable:!(n=I(e,r))||n.enumerable});return t};var m=(t,e,o)=>(o=t!=null?J(E(t)):{},u(e||!t||!t.__esModule?l(o,"default",{value:t,enumerable:!0}):o,t)),Y=t=>u(l({},"__esModule",{value:!0}),t);var H={};L(H,{ENCODING:()=>y,breakExit:()=>w,completeExit:()=>b,cwd:()=>i,error:()=>C,execCommand:()=>q,getBiomeConfigPath:()=>A,getConfigFilePath:()=>a,getEsLintConfigPath:()=>T,getPackageJSON:()=>D,getPrettierConfigPath:()=>z,getProjectConfigJSON:()=>B,getStyleLintConfigPath:()=>W,getYolkConfig:()=>O,info:()=>j,ready:()=>_,rimrafSync:()=>G,warn:()=>P});module.exports=Y(H);var d=require("node:child_process"),s=m(require("node:fs")),g=m(require("node:path")),c=m(require("chalk")),x=require("glob"),p=require("rimraf"),h=require("../compiled/commander"),i=process.cwd(),f=console,y="utf-8",P=t=>t&&f.log(c.default.yellow("warn -"),t),C=t=>t&&f.log(c.default.red("error -"),t),_=t=>t&&f.log(c.default.green("ready -"),t),j=t=>t&&f.log(c.default.blue("info -"),t),N=()=>process.platform==="win32",$=t=>N()?`${t}.cmd`:t,G=t=>N()?(0,p.windowsSync)(t):(0,p.rimrafSync)(t),b=()=>{j("yolk complete!"),process.exit(0)},w=()=>{P("yolk break!"),process.exit(0)},q=({command:t,args:e,complete:o,close:n,exit:r=!0})=>{let S=(0,d.spawn)($(t),e||[],{stdio:"inherit"}).on("close",k=>{k?(n&&n(),C("yolk close!"),process.exit(k)):(o&&o(),r&&b())});process.on("SIGINT",()=>{h.program.exitOverride(),S.kill(),w()})},O=()=>{let t=(0,x.globSync)("*.yolkrc*",{cwd:i,dot:!0});if(!t.length)return{};let e=g.default.join(i,t[0]);if(s.default.existsSync(e))try{return JSON.parse(s.default.readFileSync(e,y))||{}}catch(o){return o(o.message||".yolkrc转换错误"),{}}else return{}},B=()=>{let t=g.default.join(i,"project.config.json");if(s.default.existsSync(t))try{return JSON.parse(s.default.readFileSync(t,y))||{}}catch(e){return e(e.message||"project.config.json转换错误"),{}}else return{}},D=()=>{let t=g.default.join(i,"package.json");if(s.default.existsSync(t))try{return JSON.parse(s.default.readFileSync(t,y))||{}}catch(e){return e(e.message||"package.json转换错误"),{}}else return{}},a=t=>{let e=O(),o="";try{o=require.resolve(`@baic/${t}-config-yolk`)}catch{}let n=(0,x.globSync)(`*.${t}rc*`,{cwd:i,dot:!0}),r=n==null?void 0:n[0];return e.strict===!1&&r&&s.default.existsSync(r)?r:s.default.existsSync(o)?o:r},T=()=>a("eslint"),W=()=>a("stylelint"),z=()=>a("prettier"),A=()=>a("biome");0&&(module.exports={ENCODING,breakExit,completeExit,cwd,error,execCommand,getBiomeConfigPath,getConfigFilePath,getEsLintConfigPath,getPackageJSON,getPrettierConfigPath,getProjectConfigJSON,getStyleLintConfigPath,getYolkConfig,info,ready,rimrafSync,warn});
1
+ "use strict";var e=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.warn=exports.rimrafSync=exports.ready=exports.info=exports.getYolkConfig=exports.getStyleLintConfigPath=exports.getProjectConfigJSON=exports.getPrettierConfigPath=exports.getPackageJSON=exports.getEsLintConfigPath=exports.getConfigFilePath=exports.getBiomeConfigPath=exports.execCommand=exports.error=exports.cwd=exports.completeExit=exports.breakExit=exports.ENCODING=void 0;var t=require("node:child_process"),r=require("node:fs"),o=require("node:path"),s=e(require("chalk")),n=require("glob"),c=require("rimraf"),i=require("../compiled/commander");const a=exports.cwd=process.cwd(),p=console,l=exports.ENCODING="utf-8",x=e=>e&&p.log(s.default.yellow("warn -"),e);exports.warn=x;const g=e=>e&&p.log(s.default.red("error -"),e);exports.error=g;const f=e=>e&&p.log(s.default.green("ready -"),e);exports.ready=f;const d=e=>e&&p.log(s.default.blue("info -"),e);exports.info=d;const u=()=>"win32"===process.platform,y=e=>u()?`${e}.cmd`:e,m=e=>u()?(0,c.windowsSync)(e):(0,c.rimrafSync)(e);exports.rimrafSync=m;const S=()=>{d("yolk complete!"),process.exit(0)};exports.completeExit=S;const h=()=>{x("yolk break!"),process.exit(0)};exports.breakExit=h;const C=({command:e,args:r,complete:o,close:s,exit:n=!0})=>{const c=(0,t.spawn)(y(e),r||[],{stdio:"inherit"}).on("close",(e=>{e?(s&&s(),g("yolk close!"),process.exit(e)):(o&&o(),n&&S())}));process.on("SIGINT",(()=>{i.program.exitOverride(),c.kill(),h()}))};exports.execCommand=C;const k=()=>{const e=(0,n.globSync)("*.yolkrc*",{cwd:a,dot:!0});if(!e.length)return{};const t=(0,o.join)(a,e[0]);if(!(0,r.existsSync)(t))return{};try{return JSON.parse((0,r.readFileSync)(t,l))||{}}catch(g){return g(g.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}};exports.getYolkConfig=k;const P=()=>{const e=(0,o.join)(a,"project.config.json");if(!(0,r.existsSync)(e))return{};try{return JSON.parse((0,r.readFileSync)(e,l))||{}}catch(g){return g(g.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}};exports.getProjectConfigJSON=P;const w=()=>{const e=(0,o.join)(a,"package.json");if(!(0,r.existsSync)(e))return{};try{return JSON.parse((0,r.readFileSync)(e,l))||{}}catch(g){return g(g.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}};exports.getPackageJSON=w;const b=e=>{const t=k();let o="";try{o=require.resolve(`@baic/${e}-config-yolk`)}catch(g){}const s=(0,n.globSync)(`*.${e}rc*`,{cwd:a,dot:!0}),c=null===s||void 0===s?void 0:s[0];return!1===t.strict&&c&&(0,r.existsSync)(c)?c:(0,r.existsSync)(o)?o:c};exports.getConfigFilePath=b;const j=()=>b("eslint");exports.getEsLintConfigPath=j;const N=()=>b("stylelint");exports.getStyleLintConfigPath=N;const O=()=>b("prettier");exports.getPrettierConfigPath=O;const q=()=>b("biome");exports.getBiomeConfigPath=q;
package/lib/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  #! /usr/bin/env node
2
+ import './yolk';
package/lib/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #! /usr/bin/env node
2
- require("../compiled/v8-compile-cache");require("./yolk");
2
+ "use strict";require("./yolk");
@@ -1 +1 @@
1
- var{join:e}=require("node:path"),{getBiomeConfigPath:h,getEsLintConfigPath:p,getPrettierConfigPath:u,getStyleLintConfigPath:m,getYolkConfig:$}=require("./_util"),l=["**/node_modules/**","**/build/**","**/dist/**","**/lib/**","**/es/**","**/mock/**","**/test/**","**/public/**","**/assets/**","**/.umi/**","**/.umi-production/**","**/h5+app/**","**/*uni*/**","**/android/**","**/ios/**","**/*.ignore/**"],{strict:g=!0,eslintIgnorePattern:c,stylelintIgnorePattern:i}=$(),o=e(process.cwd(),"node_modules",".cache"),t=`prettier --write --cache --cache-strategy=content --cache-location=${e(o,".prettiercache")} --config ${u()} --no-error-on-unmatched-pattern`,r=`eslint --fix ${g?"--no-inline-config":""} --no-error-on-unmatched-pattern --cache --cache-strategy=content --cache-location=${e(o,".eslintcache")} --config ${p()} ${l.concat(c?[c]:[]).map(n=>`--ignore-pattern ${n}`).join(" ")}`,s=`stylelint --fix ${g?"--ignore-disables":""} --allow-empty-input --cache --cache-strategy=content --cache-location=${e(o,".stylelintcache")} --config ${m()} ${l.concat(i?[i]:[]).map(n=>`--ignore-pattern ${n}`).join(" ")}`,d=`biome check --write --unsafe --no-errors-on-unmatched --log-level=error --files-ignore-unknown=true --config-path=${h()}`,a={"*.{md,json,jsonc}":[t],"*.css":[t,`${s} --custom-syntax postcss`],"*.less":[t,`${s} --custom-syntax postcss-less`],"*.{sass,scss}":[t,`${s} --custom-syntax postcss-scss`],"*.{js,jsx,cjs,mjs}":[t,r],"*.{ts,tsx,cts,mts}":[`${t} --parser=typescript`,r]};module.exports={...a,[`!(${Object.keys(a).join("|")})`]:[d]};
1
+ "use strict";var e=require("@babel/runtime/helpers/interopRequireDefault"),t=e(require("@babel/runtime/helpers/defineProperty"));function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(n){(0,t.default)(e,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}const{join:o}=require("node:path"),{getBiomeConfigPath:c,getEsLintConfigPath:s,getPrettierConfigPath:i,getStyleLintConfigPath:a,getYolkConfig:l}=require("./_util"),p=["**/node_modules/**","**/build/**","**/dist/**","**/lib/**","**/es/**","**/mock/**","**/test/**","**/public/**","**/assets/**","**/.umi/**","**/.umi-production/**","**/h5+app/**","**/*uni*/**","**/android/**","**/ios/**","**/*.ignore/**"],{strict:u=!0,eslintIgnorePattern:g,stylelintIgnorePattern:h}=l(),f=o(process.cwd(),"node_modules",".cache"),m=`prettier --write --cache --cache-strategy=content --cache-location=${o(f,".prettiercache")} --config ${i()} --no-error-on-unmatched-pattern`,y=`eslint --fix ${u?"--no-inline-config":""} --no-error-on-unmatched-pattern --cache --cache-strategy=content --cache-location=${o(f,".eslintcache")} --config ${s()} ${p.concat(g?[g]:[]).map((e=>`--ignore-pattern ${e}`)).join(" ")}`,b=`stylelint --fix ${u?"--ignore-disables":""} --allow-empty-input --cache --cache-strategy=content --cache-location=${o(f,".stylelintcache")} --config ${a()} ${p.concat(h?[h]:[]).map((e=>`--ignore-pattern ${e}`)).join(" ")}`,j=`biome check --write --unsafe --no-errors-on-unmatched --log-level=error --files-ignore-unknown=true --config-path=${c()}`,d={"*.{md,json,jsonc}":[m],"*.css":[m,`${b} --custom-syntax postcss`],"*.less":[m,`${b} --custom-syntax postcss-less`],"*.{sass,scss}":[m,`${b} --custom-syntax postcss-scss`],"*.{js,jsx,cjs,mjs}":[m,y],"*.{ts,tsx,cts,mts}":[`${m} --parser=typescript`,y]};module.exports=r(r({},d),{},{[`!(${Object.keys(d).join("|")})`]:[j]});
package/lib/yolk.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  #! /usr/bin/env node
2
- export declare const initPreCommit: () => void;
2
+ export {};
package/lib/yolk.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #! /usr/bin/env node
2
- var W=Object.create;var x=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var ee=(t,i)=>{for(var o in i)x(t,o,{get:i[o],enumerable:!0})},Q=(t,i,o,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let m of Y(i))!Z.call(t,m)&&m!==o&&x(t,m,{get:()=>i[m],enumerable:!(a=X(i,m))||a.enumerable});return t};var y=(t,i,o)=>(o=t!=null?W(z(t)):{},Q(i||!t||!t.__esModule?x(o,"default",{value:t,enumerable:!0}):o,t)),te=t=>Q(x({},"__esModule",{value:!0}),t);var ae={};ee(ae,{initPreCommit:()=>L});module.exports=te(ae);var N=require("node:child_process"),r=require("node:fs"),k=y(require("node:os")),n=require("node:path"),_=y(require("lodash/floor")),q=y(require("lodash/isString")),M=require("glob"),G=y(require("inquirer")),P=y(require("miniprogram-ci")),C=require("mkdirp"),f=require("../compiled/commander"),H=y(require("../compiled/mustache")),$=y(require("../package.json")),e=require("./_util"),b="##### CREATED BY YOLK #####",U=(t,i,o)=>{G.default.prompt([{type:"list",name:"type",message:"选择模版",default:"web",choices:[{name:"web template(umi framework)",value:"umi-web"},{name:"web big screen template(umi framework)",value:"umi-web-screen"},{name:"mobile template(umi framework)",value:"umi-mobile"},{name:"mobile HBuilderX h5+app template(umi framework)",value:"umi-mobile-h5+app"},{name:"mobile HBuilderX uni-app template(umi framework)",value:"umi-mobile-uni-app"},{name:"mobile native template(umi framework)",value:"umi-mobile-native"},{name:"miniprogram template",value:"miniprogram"}]},{type:"input",name:"projectName",message:"项目名称",default:(0,n.basename)((0,n.basename)(process.cwd()))},{type:"list",name:"packageManager",message:"选择包管理器(默认:pnpm,推荐:pnpm)",default:"default",choices:[{name:"默认安装",value:"default"},{name:"跳过安装",value:!1},{name:"pnpm install",value:"pnpm"},{name:"yarn install",value:"yarn"},{name:"npm install",value:"npm"}]}]).then(({type:a,projectName:m,packageManager:l})=>{let c={projectName:m,packageManager:l==="default"?"pnpm":l,yolkVersion:$.default.version};if(a==="umi-mobile-uni-app"){(0,e.warn)("暂不支持");return}let s=i||(0,n.join)(__dirname,`../templates/${a}`);if((0,e.ready)(`复制模版 ${(0,n.basename)(s)}`),(0,M.globSync)("**/*",{cwd:s,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]}).forEach(d=>{if(!s)return;let u=(0,n.join)(s,d);if(!(0,r.statSync)(u).isDirectory())if(d.endsWith(".tpl")){let p=(0,r.readFileSync)(u,e.ENCODING),g=(0,n.join)(t,d.replace(/\.tpl$/,"")),h=H.default.render(p,c);(0,C.mkdirpSync)((0,n.dirname)(g)),(0,e.ready)(`创建 ${(0,n.relative)(t,g)}`),(0,r.writeFileSync)(g,h,e.ENCODING)}else{(0,e.ready)(`创建 ${d}`);let p=(0,n.join)(t,d);(0,C.mkdirpSync)((0,n.dirname)(p)),(0,r.copyFileSync)(u,p)}}),(0,e.ready)("复制模版 success!"),o&&(0,r.existsSync)(s)&&(0,e.rimrafSync)(s)&&(0,e.ready)(`缓存删除 success! ${(0,n.basename)(s||"")}`),l)switch((0,e.ready)("初始化依赖包"),l){case"default":case"pnpm":(0,e.execCommand)({command:"pnpm",args:["install"]});break;case"yarn":(0,e.execCommand)({command:"yarn",args:["install"]});break;case"npm":(0,e.execCommand)({command:"npm",args:["install"]});break;default:}(0,e.ready)("可查阅<<https://303394539.github.io/yolk-docs/>>了解相关文档")})},oe=(t,i)=>U(t,i,!0),O=()=>(0,r.existsSync)((0,n.join)(e.cwd,"project.config.json")),T=()=>{let t=(0,r.existsSync)((0,n.join)(e.cwd,"node_modules/.bin/max"));if(!t)try{t=(0,r.existsSync)(require.resolve("@umijs/max"))}catch{}if(!t)try{t=/umi@4\.(\d+)\.(\d+)/.test((0,N.execSync)("umi -v").toString())}catch{}if(!t){let i=(0,n.join)(e.cwd,"node_modules","umi","package.json");if((0,r.existsSync)(i))try{let o=JSON.parse((0,r.readFileSync)(i,e.ENCODING))||{};t=o.version&&+o.version.split(".")[0]>3}catch{}}return t},B=()=>{let t=(0,n.join)(e.cwd,"project.config.json");return(0,r.existsSync)(t)?require(t).appid:""},w=()=>(0,r.existsSync)((0,n.join)(e.cwd,"project.tt.json"))&&B().indexOf("tt")===0,j=()=>B().indexOf("20")===0,L=()=>{let t=(0,n.join)(e.cwd,".git/"),i=(0,n.join)(e.cwd,".git/hooks"),o=(0,n.join)(i,"pre-commit"),a=(0,r.existsSync)(t),m=(0,r.existsSync)(i),l=(0,r.existsSync)(o);if(a){m||((0,C.mkdirpSync)(i),(0,e.ready)("create .git/hooks")),l||((0,r.writeFileSync)(o,"",e.ENCODING),(0,e.ready)("create pre-commit"));try{(0,r.chmodSync)(o,"777")}catch(s){(0,e.error)(`chmod ${o} failed: ${s.message}`)}let c=(0,r.readFileSync)(o,e.ENCODING).toString();c.indexOf(b)>=0&&(c=`${c.substring(0,c.indexOf(b))}${c.substring(c.lastIndexOf(b)+b.length)}`.replace(/(\r|\n)+$/gu,"")),(0,r.writeFileSync)(o,(c.indexOf("#!/")<0?["#!/bin/sh"]:[]).concat([c,b,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",b]).filter(s=>!!s).join(k.default.EOL),e.ENCODING)}},ie=async()=>{(0,e.warn)("统一代码规范,进行严格的语法检查。"),(0,e.execCommand)({command:"lint-staged",args:["-c",require.resolve("./lintstagedrc")]})},K=({mAppid:t,mProject:i,mPrivateKeyPath:o,mVersion:a,mDesc:m,mRobot:l,mQrcodeFormat:c,mQrcodeOutputDest:s,mPagePath:v,mSearchQuery:d})=>{let u="";try{u=(0,r.existsSync)((0,n.join)(e.cwd,".git"))?(0,N.execSync)("git log -1 --pretty=format:%H").toString():""}catch{}let p=(0,e.getProjectConfigJSON)(),g=t||p.appid,h=i||(0,n.join)(e.cwd,"dist"),S=o||(0,n.join)(e.cwd,`private.${g}.key`);if((0,r.existsSync)(h))if((0,r.existsSync)(S)){let E=(0,e.getPackageJSON)(),J=a||E.version||p.version||"1.0.0",A=m||E.description||p.description,F=`${u?` commit: ${u};`:""}${A?` description: ${A};`:""}`;u&&(0,e.info)(`commit: ${u}`),(0,e.info)(`dist: ${h}`),(0,e.info)(`key: ${S}`),(0,e.info)(`appid: ${g}`),(0,e.info)(`version: ${J}`),(0,e.info)(`desc: ${F}`);let V=new P.Project({appid:g,type:"miniProgram",projectPath:h,privateKeyPath:S,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:g,options:{project:V,version:J,desc:F,setting:{...p.setting,es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1},robot:l,qrcodeFormat:c,qrcodeOutputDest:s,pagePath:v,searchQuery:d}}}else throw Error(`没有找到上传密钥(${S})`);else throw Error(`没有找到dist目录(${h})`)},D=()=>{let t="";try{t=(0,N.execSync)(`npm view ${$.default.name} version`,{timeout:3e3}).toString().replace(/\n/g,"")}catch{}(0,e.info)(`yolk version: ${$.default.version}${t&&t!==$.default.version?`(last:${t})`:""}`),(0,e.info)(`node version: ${process.version}`),(0,e.info)(`platform: ${k.default.platform()}`),(0,e.info)(`memory: ${(0,_.default)(k.default.freemem()/1024/1024)} MB(${(0,_.default)(k.default.totalmem()/1024/1024)} MB)`)},R=t=>t.option("--appid, --mAppid <appid>","小程序appid").option("--project, --mProject <project>","小程序上传工程目录").option("--privateKeyPath, --mPrivateKeyPath <privateKeyPath>","小程序上传key文件,默认:{当前目录}/private.{appid}.key").option("--version, --mVersion <version>","小程序上传版本号").option("--desc, --mDesc <desc>","小程序上传描述").option("--robot, --mRobot <robot>","小程序上传ci机器人1~30").option("--qrcodeFormat, --mQrcodeFormat <qrcodeFormat>",'小程序预览返回二维码文件的格式 "image" 或 "base64", 默认值 "terminal" 供调试用').option("--qrcodeOutputDest, --mQrcodeOutputDest <qrcodeOutputDest>","小程序预览二维码文件保存路径").option("--pagePath, --mPagePath <pagePath>","小程序预览预览页面路径").option("--searchQuery, --mSearchQuery <searchQuery>","小程序预览预览页面路径启动参数"),re=/(\w+)=('(.*)'|"(.*)"|(.*))/giu,I=t=>{process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";let i=[];return t==null||t.forEach(o=>{if(re.test(o)){let[a,m]=o.split("=");process.env[a]=m,(0,e.info)(`设置环境变量:${a}=${m}`)}else i.push(o)}),i},ne=()=>{L(),process.argv.length>2?(f.program.version($.default.version,"-v,--version","输出版本号").usage("[command] [options]"),f.program.command("init").description("初始化项目").option("--clone <template>","如果需要,可通过git clone拉取模版,默认取cli默认模版").action(({clone:t},{args:i})=>{if(D(),(0,e.ready)("yolk init 开始"),t){let o=".yolk",a=(0,n.join)(e.cwd,o);(0,r.existsSync)(a)&&(0,e.rimrafSync)(a)&&(0,e.ready)(`缓存删除 success! ${a}`),(0,e.execCommand)({command:"git",args:["clone","-b","master","--depth","1",t,o].concat(i)}),oe(e.cwd,a)}else U(e.cwd)}),f.program.command("start").description("启动项目").option("--docs","文档模式").action(({docs:t},{args:i})=>{D();let o=I(i);O()?w()?(0,e.execCommand)({command:"taro",args:["build","--type","tt","--watch"].concat(o)}):j()?(0,e.execCommand)({command:"taro",args:["build","--type","alipay","--watch"].concat(o)}):(0,e.execCommand)({command:"taro",args:["build","--type","weapp","--watch"].concat(o)}):t?(0,e.execCommand)({command:"dumi",args:["dev"].concat(o)}):T()?(0,e.execCommand)({command:"max",args:["dev"].concat(o)}):(0,e.execCommand)({command:"umi",args:["dev"].concat(o)})}),f.program.command("build").description("编译项目").option("--docs","文档模式").action(({docs:t},{args:i})=>{D();let o=I(i);O()?w()?(0,e.execCommand)({command:"taro",args:["build","--type","tt"].concat(o)}):j()?(0,e.execCommand)({command:"taro",args:["build","--type","alipay"].concat(o)}):(0,e.execCommand)({command:"taro",args:["build","--type","weapp"].concat(o)}):t?(0,e.execCommand)({command:"dumi",args:["build"].concat(o)}):T()?(0,e.execCommand)({command:"max",args:["setup"].concat(o),complete:()=>(0,e.execCommand)({command:"max",args:["build"].concat(o)}),exit:!1}):(0,e.execCommand)({command:"umi",args:["build"].concat(o)})}),f.program.command("pre-commit").description("执行commit hook").action(ie),R(f.program.command("miniprogram-upload").description("使用 miniprogram-ci 上传小程序")).action(t=>{if(O()){if(!w()){if(!j()){let{appid:i,options:{project:o,version:a,desc:m,setting:l,robot:c}}=K(t);(0,e.info)(`${i} 上传开始`),P.upload({project:o,version:a,desc:m,setting:l,robot:c,onProgressUpdate:s=>{if((0,q.default)(s))(0,e.info)(`task: ${s}`);else{let{status:v,message:d}=s;(0,e.info)(`task(${v}): ${d}`)}}}).then(()=>{(0,e.ready)(`${i} 上传完成`)})}}}else(0,e.error)("非小程序项目目录")}),R(f.program.command("miniprogram-preview").description("使用 miniprogram-ci 预览小程序")).action(t=>{if(O()){if(!w()){if(!j()){let{appid:i,options:{project:o,version:a,desc:m,setting:l,robot:c,qrcodeFormat:s,qrcodeOutputDest:v,pagePath:d,searchQuery:u}}=K(t);(0,e.info)(`${i} 上传预览开始`),P.preview({project:o,version:a,desc:m,setting:l,robot:c,qrcodeFormat:s,qrcodeOutputDest:v,pagePath:d,searchQuery:u,onProgressUpdate:p=>{if((0,q.default)(p))(0,e.info)(`task: ${p}`);else{let{status:g,message:h}=p;(0,e.info)(`task(${g}): ${h}`)}}}).then(()=>{(0,e.ready)(`${i} 上传预览完成`)})}}}else(0,e.error)("非小程序项目目录")}),f.program.command("exec").description("执行ts文件").argument("<path>","执行的ts文件").action(t=>{(0,e.execCommand)({command:"tsx",args:[t]})}),f.program.parse(process.argv)):(0,e.breakExit)()};ne();0&&(module.exports={initPreCommit});
2
+ "use strict";var e=require("@babel/runtime/helpers/interopRequireDefault"),t=e(require("@babel/runtime/helpers/defineProperty")),o=require("node:child_process"),r=require("node:fs"),n=e(require("node:os")),i=require("node:path"),a=require("lodash"),c=require("glob"),s=e(require("inquirer")),m=y(require("miniprogram-ci")),p=require("mkdirp"),d=require("../compiled/commander"),l=e(require("../compiled/mustache")),u=e(require("../package.json")),f=require("./_util");function g(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,o=new WeakMap;return(g=function(e){return e?o:t})(e)}function y(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var o=g(t);if(o&&o.has(e))return o.get(e);var r={__proto__:null},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var a=n?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,o&&o.set(e,r),r}function b(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function v(e){for(var o=1;o<arguments.length;o++){var r=null!=arguments[o]?arguments[o]:{};o%2?b(Object(r),!0).forEach((function(o){(0,t.default)(e,o,r[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}const h="##### CREATED BY YOLK #####",j=(e,t,o)=>{s.default.prompt([{type:"list",name:"type",message:"\u9009\u62e9\u6a21\u7248",default:"web",choices:[{name:"web template(umi framework)",value:"umi-web"},{name:"web big screen template(umi framework)",value:"umi-web-screen"},{name:"mobile template(umi framework)",value:"umi-mobile"},{name:"mobile HBuilderX h5+app template(umi framework)",value:"umi-mobile-h5+app"},{name:"mobile HBuilderX uni-app template(umi framework)",value:"umi-mobile-uni-app"},{name:"mobile native template(umi framework)",value:"umi-mobile-native"},{name:"taro-miniprogram template",value:"taro-miniprogram"}]},{type:"input",name:"projectName",message:"\u9879\u76ee\u540d\u79f0",default:(0,i.basename)((0,i.basename)(process.cwd()))},{type:"list",name:"packageManager",message:"\u9009\u62e9\u5305\u7ba1\u7406\u5668(\u9ed8\u8ba4\uff1apnpm\uff0c\u63a8\u8350\uff1apnpm)",default:"default",choices:[{name:"\u9ed8\u8ba4\u5b89\u88c5",value:"default"},{name:"\u8df3\u8fc7\u5b89\u88c5",value:!1},{name:"pnpm install",value:"pnpm"},{name:"yarn install",value:"yarn"},{name:"npm install",value:"npm"}]}]).then((({type:n,projectName:a,packageManager:s})=>{const m={projectName:a,packageManager:"default"===s?"pnpm":s,yolkVersion:u.default.version};if("umi-mobile-uni-app"===n)return void(0,f.warn)("\u6682\u4e0d\u652f\u6301");const d=t||(0,i.join)(__dirname,`../templates/${n}`);(0,f.ready)(`\u590d\u5236\u6a21\u7248 ${(0,i.basename)(d)}`);const g=(0,c.globSync)("**/*",{cwd:d,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(g.forEach((t=>{if(!d)return;const o=(0,i.join)(d,t);if(!(0,r.statSync)(o).isDirectory())if(t.endsWith(".tpl")){const n=(0,r.readFileSync)(o,f.ENCODING),a=(0,i.join)(e,t.replace(/\.tpl$/,"")),c=l.default.render(n,m);(0,p.mkdirpSync)((0,i.dirname)(a)),(0,f.ready)(`\u521b\u5efa ${(0,i.relative)(e,a)}`),(0,r.writeFileSync)(a,c,f.ENCODING)}else{(0,f.ready)(`\u521b\u5efa ${t}`);const n=(0,i.join)(e,t);(0,p.mkdirpSync)((0,i.dirname)(n)),(0,r.copyFileSync)(o,n)}})),(0,f.ready)("\u590d\u5236\u6a21\u7248 success!"),o&&(0,r.existsSync)(d)&&(0,f.rimrafSync)(d)&&(0,f.ready)(`\u7f13\u5b58\u5220\u9664 success! ${(0,i.basename)(d||"")}`),s)switch((0,f.ready)("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),s){case"default":case"pnpm":(0,f.execCommand)({command:"pnpm",args:["install"]});break;case"yarn":(0,f.execCommand)({command:"yarn",args:["install"]});break;case"npm":(0,f.execCommand)({command:"npm",args:["install"]});break;default:}(0,f.ready)("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},x=(e,t)=>j(e,t,!0),w=()=>(0,r.existsSync)((0,i.join)(f.cwd,"project.config.json")),S=()=>{let e=(0,r.existsSync)((0,i.join)(f.cwd,"node_modules/.bin/max"));if(!e)try{e=(0,r.existsSync)(require.resolve("@umijs/max"))}catch(t){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test((0,o.execSync)("umi -v").toString())}catch(t){}if(!e){const o=(0,i.join)(f.cwd,"node_modules","umi","package.json");if((0,r.existsSync)(o))try{const t=JSON.parse((0,r.readFileSync)(o,f.ENCODING))||{};e=t.version&&+t.version.split(".")[0]>3}catch(t){}}return e},O=()=>{const e=(0,i.join)(f.cwd,"project.config.json");if((0,r.existsSync)(e)){const t=require(e);return t.appid}return""},$=()=>(0,r.existsSync)((0,i.join)(f.cwd,"project.tt.json"))&&0===O().indexOf("tt"),k=()=>0===O().indexOf("20"),P=()=>{const e=(0,f.getYolkConfig)(),t=(0,i.join)(f.cwd,".husky/pre-commit"),o=(0,i.join)(f.cwd,".git/"),a=(0,i.join)(f.cwd,".git/hooks"),c=(0,i.join)(a,"pre-commit"),s=(0,r.existsSync)(t),m=(0,r.existsSync)(o),d=(0,r.existsSync)(a),l=(0,r.existsSync)(c),u=!1!==e.initPreCommit&&!s,g=[h,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",h].join(n.default.EOL),y=e=>{let t=e||"";return t&&t.indexOf(h)>=0&&(t=`${t.substring(0,t.indexOf(h))}${t.substring(t.lastIndexOf(h)+h.length)}`.replace(/(\r|\n)+$/gu,"")),t};if(m)if(u)if(d||((0,p.mkdirpSync)(a),(0,f.ready)("create .git/hooks")),l){try{(0,r.chmodSync)(c,"777")}catch(b){(0,f.error)(`chmod ${c} failed: ${b.message}`)}const e=y((0,r.readFileSync)(c,f.ENCODING).toString());(0,r.writeFileSync)(c,(e.indexOf("#!/")<0?["#!/bin/sh"]:[]).concat([e,g]).filter((e=>!!e)).join(n.default.EOL),f.ENCODING)}else(0,r.writeFileSync)(c,["#!/bin/sh",g].join(n.default.EOL),f.ENCODING),(0,f.ready)("create pre-commit");else if(l){const e=y((0,r.readFileSync)(c,f.ENCODING).toString());(0,r.writeFileSync)(c,e,f.ENCODING)}},C=()=>{(0,f.warn)("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),(0,f.execCommand)({command:"lint-staged",args:["-c",require.resolve("./lintstagedrc")]})},q=({mAppid:e,mProject:t,mPrivateKeyPath:n,mVersion:a,mDesc:c,mRobot:s,mQrcodeFormat:p,mQrcodeOutputDest:d,mPagePath:l,mSearchQuery:u})=>{let g="";try{g=(0,r.existsSync)((0,i.join)(f.cwd,".git"))?(0,o.execSync)("git log -1 --pretty=format:%H").toString():""}catch(x){}const y=(0,f.getProjectConfigJSON)(),b=e||y.appid,h=t||(0,i.join)(f.cwd,"dist"),j=n||(0,i.join)(f.cwd,`private.${b}.key`);if((0,r.existsSync)(h)){if((0,r.existsSync)(j)){const e=(0,f.getPackageJSON)(),t=a||e.version||y.version||"1.0.0",o=c||e.description||y.description,r=`${g?` commit: ${g};`:""}${o?` description: ${o};`:""}`;g&&(0,f.info)(`commit: ${g}`),(0,f.info)(`dist: ${h}`),(0,f.info)(`key: ${j}`),(0,f.info)(`appid: ${b}`),(0,f.info)(`version: ${t}`),(0,f.info)(`desc: ${r}`);const n=new m.Project({appid:b,type:"miniProgram",projectPath:h,privateKeyPath:j,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:b,options:{project:n,version:t,desc:r,setting:v(v({},y.setting),{},{es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1}),robot:s,qrcodeFormat:p,qrcodeOutputDest:d,pagePath:l,searchQuery:u}}}throw Error(`\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(${j})`)}throw Error(`\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(${h})`)},D=()=>{let e="";try{e=(0,o.execSync)(`npm view ${u.default.name} version`,{timeout:3e3}).toString().replace(/\n/g,"")}catch(t){}(0,f.info)(`yolk version: ${u.default.version}${e&&e!==u.default.version?`(latest\uff1a${e})`:""}`),(0,f.info)(`node version: ${process.version}`),(0,f.info)(`platform: ${n.default.platform()}`),(0,f.info)(`memory: ${(0,a.floor)(n.default.freemem()/1024/1024)} MB(${(0,a.floor)(n.default.totalmem()/1024/1024)} MB)`)},N=e=>e.option("--appid, --mAppid <appid>","\u5c0f\u7a0b\u5e8fappid").option("--project, --mProject <project>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u5de5\u7a0b\u76ee\u5f55").option("--privateKeyPath, --mPrivateKeyPath <privateKeyPath>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20key\u6587\u4ef6\uff0c\u9ed8\u8ba4\uff1a{\u5f53\u524d\u76ee\u5f55}/private.{appid}.key").option("--version, --mVersion <version>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u7248\u672c\u53f7").option("--desc, --mDesc <desc>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u63cf\u8ff0").option("--robot, --mRobot <robot>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20ci\u673a\u5668\u4eba1~30").option("--qrcodeFormat, --mQrcodeFormat <qrcodeFormat>",'\u5c0f\u7a0b\u5e8f\u9884\u89c8\u8fd4\u56de\u4e8c\u7ef4\u7801\u6587\u4ef6\u7684\u683c\u5f0f "image" \u6216 "base64"\uff0c \u9ed8\u8ba4\u503c "terminal" \u4f9b\u8c03\u8bd5\u7528').option("--qrcodeOutputDest, --mQrcodeOutputDest <qrcodeOutputDest>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u4e8c\u7ef4\u7801\u6587\u4ef6\u4fdd\u5b58\u8def\u5f84").option("--pagePath, --mPagePath <pagePath>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84").option("--searchQuery, --mSearchQuery <searchQuery>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84\u542f\u52a8\u53c2\u6570"),E=/(\w+)=('(.*)'|"(.*)"|(.*))/giu,_=e=>{process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";const t=[];return null===e||void 0===e||e.forEach((e=>{if(E.test(e)){const[t,o]=e.split("=");process.env[t]=o,(0,f.info)(`\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a${t}=${o}`)}else t.push(e)})),t},F=()=>{P(),process.argv.length>2?(d.program.version(u.default.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),d.program.command("init").description("\u521d\u59cb\u5316\u9879\u76ee").option("--clone <template>","\u5982\u679c\u9700\u8981\uff0c\u53ef\u901a\u8fc7git clone\u62c9\u53d6\u6a21\u7248\uff0c\u9ed8\u8ba4\u53d6cli\u9ed8\u8ba4\u6a21\u7248").action((({clone:e},{args:t})=>{if(D(),(0,f.ready)("yolk init \u5f00\u59cb"),e){const o=".yolk",n=(0,i.join)(f.cwd,o);(0,r.existsSync)(n)&&(0,f.rimrafSync)(n)&&(0,f.ready)(`\u7f13\u5b58\u5220\u9664 success! ${n}`),(0,f.execCommand)({command:"git",args:["clone","-b","master","--depth","1",e,o].concat(t)}),x(f.cwd,n)}else j(f.cwd)})),d.program.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{D();const o=_(t);w()?$()?(0,f.execCommand)({command:"taro",args:["build","--type","tt","--watch"].concat(o)}):k()?(0,f.execCommand)({command:"taro",args:["build","--type","alipay","--watch"].concat(o)}):(0,f.execCommand)({command:"taro",args:["build","--type","weapp","--watch"].concat(o)}):e?(0,f.execCommand)({command:"dumi",args:["dev"].concat(o)}):S()?(0,f.execCommand)({command:"max",args:["dev"].concat(o)}):(0,f.execCommand)({command:"umi",args:["dev"].concat(o)})})),d.program.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{D();const o=_(t);w()?$()?(0,f.execCommand)({command:"taro",args:["build","--type","tt"].concat(o)}):k()?(0,f.execCommand)({command:"taro",args:["build","--type","alipay"].concat(o)}):(0,f.execCommand)({command:"taro",args:["build","--type","weapp"].concat(o)}):e?(0,f.execCommand)({command:"dumi",args:["build"].concat(o)}):S()?(0,f.execCommand)({command:"max",args:["setup"].concat(o),complete:()=>(0,f.execCommand)({command:"max",args:["build"].concat(o)}),exit:!1}):(0,f.execCommand)({command:"umi",args:["build"].concat(o)})})),d.program.command("init-pre-commit").description("\u521d\u59cb\u5316 commit hook").action(P),d.program.command("pre-commit").description("\u6267\u884ccommit hook").action(C),N(d.program.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((e=>{if(w())if($());else if(k());else{const{appid:t,options:{project:o,version:r,desc:n,setting:i,robot:c}}=q(e);(0,f.info)(`${t} \u4e0a\u4f20\u5f00\u59cb`),m.upload({project:o,version:r,desc:n,setting:i,robot:c,onProgressUpdate:e=>{if((0,a.isString)(e))(0,f.info)(`task: ${e}`);else{const{status:t,message:o}=e;(0,f.info)(`task(${t}): ${o}`)}}}).then((()=>{(0,f.ready)(`${t} \u4e0a\u4f20\u5b8c\u6210`)}))}else(0,f.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),N(d.program.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((e=>{if(w())if($());else if(k());else{const{appid:t,options:{project:o,version:r,desc:n,setting:i,robot:c,qrcodeFormat:s,qrcodeOutputDest:p,pagePath:d,searchQuery:l}}=q(e);(0,f.info)(`${t} \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb`),m.preview({project:o,version:r,desc:n,setting:i,robot:c,qrcodeFormat:s,qrcodeOutputDest:p,pagePath:d,searchQuery:l,onProgressUpdate:e=>{if((0,a.isString)(e))(0,f.info)(`task: ${e}`);else{const{status:t,message:o}=e;(0,f.info)(`task(${t}): ${o}`)}}}).then((()=>{(0,f.ready)(`${t} \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210`)}))}else(0,f.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),d.program.command("exec").description("\u6267\u884cts\u6587\u4ef6").argument("<path>","\u6267\u884c\u7684ts\u6587\u4ef6").action(((e,t,{args:o})=>{const r=_(o);(0,f.execCommand)({command:"tsx",args:[e].concat(r)})})),d.program.command("test").description("\u6267\u884c\u6d4b\u8bd5").action((()=>{(0,f.execCommand)({command:"ytest",args:["run"]})})),d.program.parse(process.argv)):(0,f.breakExit)()};F();
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@baic/yolk-cli",
3
- "version": "2.1.0-alpha.247",
3
+ "version": "2.1.0-alpha.249",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/303394539/yolk.git"
7
7
  },
8
8
  "license": "MIT",
9
9
  "author": "Baic <303394539@qq.com>",
10
- "main": "lib/index.js",
11
- "module": "es/index.js",
12
- "typings": "lib/index.d.ts",
10
+ "main": "./lib/index.js",
11
+ "module": "./es/index.js",
12
+ "typings": "./lib/index.d.ts",
13
13
  "bin": {
14
- "yolk": "lib/index.js"
14
+ "yolk": "./lib/index.js"
15
15
  },
16
16
  "files": [
17
17
  "compiled",
@@ -25,17 +25,18 @@
25
25
  "prebundle": "father prebundle"
26
26
  },
27
27
  "dependencies": {
28
- "@baic/biome-config-yolk": "2.1.0-alpha.247",
29
- "@baic/eslint-config-yolk": "2.1.0-alpha.247",
30
- "@baic/prettier-config-yolk": "2.1.0-alpha.247",
31
- "@baic/stylelint-config-yolk": "2.1.0-alpha.247",
28
+ "@baic/biome-config-yolk": "2.1.0-alpha.249",
29
+ "@baic/eslint-config-yolk": "2.1.0-alpha.249",
30
+ "@baic/prettier-config-yolk": "2.1.0-alpha.249",
31
+ "@baic/stylelint-config-yolk": "2.1.0-alpha.249",
32
+ "@baic/yolk-test": "2.1.0-alpha.249",
32
33
  "@democrance/imagemin-lint-staged": "5.0.x",
33
34
  "@types/lodash": "4.x",
34
35
  "chalk": "4.x",
35
36
  "eslint": "8.x",
36
37
  "glob": "10.4.x",
37
38
  "inquirer": "8.x",
38
- "lint-staged": "15.5.x",
39
+ "lint-staged": "16.0.x",
39
40
  "lodash": "4.x",
40
41
  "miniprogram-ci": "1.9.x",
41
42
  "mkdirp": "3.0.x",
@@ -52,8 +53,7 @@
52
53
  "@types/lint-staged": "13.3.x",
53
54
  "@types/mustache": "4.2.x",
54
55
  "commander": "12.1.x",
55
- "mustache": "4.2.x",
56
- "v8-compile-cache": "2.4.x"
56
+ "mustache": "4.2.x"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=16"
@@ -61,5 +61,5 @@
61
61
  "publishConfig": {
62
62
  "access": "public"
63
63
  },
64
- "gitHead": "424e4d43e1b623896828eaf51bd3a40cab070159"
64
+ "gitHead": "122719917fbb04b4869c5080b3012f2ee99ae19a"
65
65
  }
@@ -0,0 +1,4 @@
1
+ node_modules/
2
+ /public/
3
+ /build/
4
+ /dist/
@@ -1,3 +1,4 @@
1
+ /** @type {import('eslint').Linter.BaseConfig} */
1
2
  module.exports = {
2
3
  extends: '@baic/eslint-config-yolk',
3
4
  parserOptions: {
@@ -1 +1,2 @@
1
+ /** @type {import('prettier').Config} */
1
2
  module.exports = require('@baic/prettier-config-yolk');
@@ -0,0 +1,4 @@
1
+ node_modules/
2
+ /public/
3
+ /build/
4
+ /dist/
@@ -0,0 +1,4 @@
1
+ /** @type {import('stylelint').Config} */
2
+ module.exports = {
3
+ extends: '@baic/stylelint-config-yolk',
4
+ };
@@ -0,0 +1 @@
1
+ export const REQUEST_HOST: string = '';
@@ -0,0 +1,6 @@
1
+ .umi
2
+ .umi-production
3
+ node_modules/
4
+ /public/
5
+ /build/
6
+ /dist/
@@ -1,3 +1,4 @@
1
+ /** @type {import('eslint').Linter.BaseConfig} */
1
2
  module.exports = {
2
3
  extends: '@baic/eslint-config-yolk',
3
4
  parserOptions: {
@@ -1 +1,2 @@
1
+ /** @type {import('prettier').Config} */
1
2
  module.exports = require('@baic/prettier-config-yolk');
@@ -0,0 +1,6 @@
1
+ .umi
2
+ .umi-production
3
+ node_modules/
4
+ /public/
5
+ /build/
6
+ /dist/
@@ -0,0 +1,4 @@
1
+ /** @type {import('stylelint').Config} */
2
+ module.exports = {
3
+ extends: '@baic/stylelint-config-yolk',
4
+ };
@@ -0,0 +1,6 @@
1
+ .umi
2
+ .umi-production
3
+ node_modules/
4
+ /public/
5
+ /build/
6
+ /dist/
@@ -1,3 +1,4 @@
1
+ /** @type {import('eslint').Linter.BaseConfig} */
1
2
  module.exports = {
2
3
  extends: '@baic/eslint-config-yolk',
3
4
  parserOptions: {
@@ -1 +1,2 @@
1
+ /** @type {import('prettier').Config} */
1
2
  module.exports = require('@baic/prettier-config-yolk');
@@ -0,0 +1,6 @@
1
+ .umi
2
+ .umi-production
3
+ node_modules/
4
+ /public/
5
+ /build/
6
+ /dist/
@@ -0,0 +1,4 @@
1
+ /** @type {import('stylelint').Config} */
2
+ module.exports = {
3
+ extends: '@baic/stylelint-config-yolk',
4
+ };
@@ -0,0 +1,6 @@
1
+ .umi
2
+ .umi-production
3
+ node_modules/
4
+ /public/
5
+ /build/
6
+ /dist/
@@ -1,3 +1,4 @@
1
+ /** @type {import('eslint').Linter.BaseConfig} */
1
2
  module.exports = {
2
3
  extends: '@baic/eslint-config-yolk',
3
4
  parserOptions: {
@@ -1 +1,2 @@
1
+ /** @type {import('prettier').Config} */
1
2
  module.exports = require('@baic/prettier-config-yolk');
@@ -0,0 +1,6 @@
1
+ .umi
2
+ .umi-production
3
+ node_modules/
4
+ /public/
5
+ /build/
6
+ /dist/
@@ -0,0 +1,4 @@
1
+ /** @type {import('stylelint').Config} */
2
+ module.exports = {
3
+ extends: '@baic/stylelint-config-yolk',
4
+ };
@@ -26,11 +26,11 @@ class Bluetooth {
26
26
 
27
27
  // private connectedDeviceId: string = '';
28
28
 
29
- private listenServicesTimeoutId?: NodeJS.Timeout;
29
+ private listenServicesTimeoutId?: any;
30
30
 
31
- private writeTimeoutId?: NodeJS.Timeout;
31
+ private writeTimeoutId?: any;
32
32
 
33
- private readTimeoutId?: NodeJS.Timeout;
33
+ private readTimeoutId?: any;
34
34
 
35
35
  private isNotifyInterval?: boolean;
36
36
 
@@ -0,0 +1,6 @@
1
+ .umi
2
+ .umi-production
3
+ node_modules/
4
+ /public/
5
+ /build/
6
+ /dist/
@@ -1,3 +1,4 @@
1
+ /** @type {import('eslint').Linter.BaseConfig} */
1
2
  module.exports = {
2
3
  extends: '@baic/eslint-config-yolk',
3
4
  parserOptions: {
@@ -1 +1,2 @@
1
+ /** @type {import('prettier').Config} */
1
2
  module.exports = require('@baic/prettier-config-yolk');
@@ -0,0 +1,6 @@
1
+ .umi
2
+ .umi-production
3
+ node_modules/
4
+ /public/
5
+ /build/
6
+ /dist/
@@ -0,0 +1,4 @@
1
+ /** @type {import('stylelint').Config} */
2
+ module.exports = {
3
+ extends: '@baic/stylelint-config-yolk',
4
+ };
@@ -1,5 +1,5 @@
1
- export const NAME = 'demo';
1
+ export const NAME: string = 'demo';
2
2
 
3
- export const REQUEST_HOST = 'https://xxx';
3
+ export const REQUEST_HOST: string = 'https://xxx';
4
4
 
5
- export const H5_INDEX = `${REQUEST_HOST}/#/`;
5
+ export const H5_INDEX: string = `${REQUEST_HOST}/#/`;
@@ -0,0 +1,6 @@
1
+ .umi
2
+ .umi-production
3
+ node_modules/
4
+ /public/
5
+ /build/
6
+ /dist/
@@ -1,3 +1,4 @@
1
+ /** @type {import('eslint').Linter.BaseConfig} */
1
2
  module.exports = {
2
3
  extends: '@baic/eslint-config-yolk',
3
4
  parserOptions: {
@@ -1 +1,2 @@
1
+ /** @type {import('prettier').Config} */
1
2
  module.exports = require('@baic/prettier-config-yolk');
@@ -0,0 +1,6 @@
1
+ .umi
2
+ .umi-production
3
+ node_modules/
4
+ /public/
5
+ /build/
6
+ /dist/
@@ -0,0 +1,4 @@
1
+ /** @type {import('stylelint').Config} */
2
+ module.exports = {
3
+ extends: '@baic/stylelint-config-yolk',
4
+ };
@@ -0,0 +1,6 @@
1
+ .umi
2
+ .umi-production
3
+ node_modules/
4
+ /public/
5
+ /build/
6
+ /dist/
@@ -1,3 +1,4 @@
1
+ /** @type {import('eslint').Linter.BaseConfig} */
1
2
  module.exports = {
2
3
  extends: '@baic/eslint-config-yolk',
3
4
  parserOptions: {
@@ -1 +1,2 @@
1
+ /** @type {import('prettier').Config} */
1
2
  module.exports = require('@baic/prettier-config-yolk');
@@ -0,0 +1,6 @@
1
+ .umi
2
+ .umi-production
3
+ node_modules/
4
+ /public/
5
+ /build/
6
+ /dist/
@@ -0,0 +1,4 @@
1
+ /** @type {import('stylelint').Config} */
2
+ module.exports = {
3
+ extends: '@baic/stylelint-config-yolk',
4
+ };
@@ -1,7 +1,7 @@
1
- export const RootFontSize = 14;
1
+ export const RootFontSize: number = 14;
2
2
 
3
- export const RootWinWidth = 1920;
3
+ export const RootWinWidth: number = 1920;
4
4
 
5
- export const RootWinHeight = 1080;
5
+ export const RootWinHeight: number = 1080;
6
6
 
7
- export const BGColor = '#020217';
7
+ export const BGColor: string = '#020217';
@@ -37,7 +37,7 @@ const Component = ({ children }: Props) => {
37
37
  */
38
38
  const [size, winWidth, winHeight] = useSize();
39
39
  const [visible, setVisible] = useState<boolean>(true);
40
- const timeoutIDRef = useRef<NodeJS.Timeout>();
40
+ const timeoutIDRef = useRef<any>(void 0);
41
41
  useEffect(() => {
42
42
  const rect = `${winWidth}x${winHeight}`;
43
43
  const reloadRect = window.sessionStorage.getItem('reload.rect') || rect;
@@ -33,7 +33,7 @@ const Component = ({ children }: Props) => {
33
33
  const [size] = useSize();
34
34
 
35
35
  // ref
36
- const timeoutID = useRef<NodeJS.Timeout>();
36
+ const timeoutID = useRef<any>(void 0);
37
37
 
38
38
  // data
39
39
  const [data, setData] = useState<Data>({});
@@ -1 +0,0 @@
1
- (function(){"use strict";var e={322:function(e,t,r){const s=r(188);const i=r(113);const o=r(147);const n=r(17);const c=r(144);const a=r(37);const l=Object.prototype.hasOwnProperty;class FileSystemBlobStore{constructor(e,t){const r=t?slashEscape(t+"."):"";this._blobFilename=n.join(e,r+"BLOB");this._mapFilename=n.join(e,r+"MAP");this._lockFilename=n.join(e,r+"LOCK");this._directory=e;this._load()}has(e,t){if(l.call(this._memoryBlobs,e)){return this._invalidationKeys[e]===t}else if(l.call(this._storedMap,e)){return this._storedMap[e][0]===t}return false}get(e,t){if(l.call(this._memoryBlobs,e)){if(this._invalidationKeys[e]===t){return this._memoryBlobs[e]}}else if(l.call(this._storedMap,e)){const r=this._storedMap[e];if(r[0]===t){return this._storedBlob.slice(r[1],r[2])}}}set(e,t,r){this._invalidationKeys[e]=t;this._memoryBlobs[e]=r;this._dirty=true}delete(e){if(l.call(this._memoryBlobs,e)){this._dirty=true;delete this._memoryBlobs[e]}if(l.call(this._invalidationKeys,e)){this._dirty=true;delete this._invalidationKeys[e]}if(l.call(this._storedMap,e)){this._dirty=true;delete this._storedMap[e]}}isDirty(){return this._dirty}save(){const e=this._getDump();const t=Buffer.concat(e[0]);const r=JSON.stringify(e[1]);try{mkdirpSync(this._directory);o.writeFileSync(this._lockFilename,"LOCK",{flag:"wx"})}catch(e){return false}try{o.writeFileSync(this._blobFilename,t);o.writeFileSync(this._mapFilename,r)}finally{o.unlinkSync(this._lockFilename)}return true}_load(){try{this._storedBlob=o.readFileSync(this._blobFilename);this._storedMap=JSON.parse(o.readFileSync(this._mapFilename))}catch(e){this._storedBlob=Buffer.alloc(0);this._storedMap={}}this._dirty=false;this._memoryBlobs={};this._invalidationKeys={}}_getDump(){const e=[];const t={};let r=0;function push(s,i,o){e.push(o);t[s]=[i,r,r+o.length];r+=o.length}for(const e of Object.keys(this._memoryBlobs)){const t=this._memoryBlobs[e];const r=this._invalidationKeys[e];push(e,r,t)}for(const e of Object.keys(this._storedMap)){if(l.call(t,e))continue;const r=this._storedMap[e];const s=this._storedBlob.slice(r[1],r[2]);push(e,r[0],s)}return[e,t]}}class NativeCompileCache{constructor(){this._cacheStore=null;this._previousModuleCompile=null}setCacheStore(e){this._cacheStore=e}install(){const e=this;const t=typeof require.resolve.paths==="function";this._previousModuleCompile=s.prototype._compile;s.prototype._compile=function(r,i){const o=this;function require(e){return o.require(e)}function resolve(e,t){return s._resolveFilename(e,o,false,t)}require.resolve=resolve;if(t){resolve.paths=function paths(e){return s._resolveLookupPaths(e,o,true)}}require.main=process.mainModule;require.extensions=s._extensions;require.cache=s._cache;const c=n.dirname(i);const a=e._moduleCompile(i,r);const l=[o.exports,require,o,i,c,process,global,Buffer];return a.apply(o.exports,l)}}uninstall(){s.prototype._compile=this._previousModuleCompile}_moduleCompile(e,t){var r=t.length;if(r>=2){if(t.charCodeAt(0)===35&&t.charCodeAt(1)===33/*!*/){if(r===2){t=""}else{var o=2;for(;o<r;++o){var n=t.charCodeAt(o);if(n===10||n===13)break}if(o===r){t=""}else{t=t.slice(o)}}}}var a=s.wrap(t);var l=i.createHash("sha1").update(t,"utf8").digest("hex");var h=this._cacheStore.get(e,l);var p=new c.Script(a,{filename:e,lineOffset:0,displayErrors:true,cachedData:h,produceCachedData:true});if(p.cachedDataProduced){this._cacheStore.set(e,l,p.cachedData)}else if(p.cachedDataRejected){this._cacheStore.delete(e)}var u=p.runInThisContext({filename:e,lineOffset:0,columnOffset:0,displayErrors:true});return u}}function mkdirpSync(e){_mkdirpSync(n.resolve(e),511)}function _mkdirpSync(e,t){try{o.mkdirSync(e,t)}catch(t){if(t.code==="ENOENT"){_mkdirpSync(n.dirname(e));_mkdirpSync(e)}else{try{const r=o.statSync(e);if(!r.isDirectory()){throw t}}catch(e){throw t}}}}function slashEscape(e){const t={"\\":"zB",":":"zC","/":"zS","\0":"z0",z:"zZ"};const r=/[\\:/\x00z]/g;return e.replace(r,(e=>t[e]))}function supportsCachedData(){const e=new c.Script('""',{produceCachedData:true});return e.cachedDataProduced===true}function getCacheDir(){const e=process.env.V8_COMPILE_CACHE_CACHE_DIR;if(e){return e}const t=typeof process.getuid==="function"?"v8-compile-cache-"+process.getuid():"v8-compile-cache";const r=process.arch;const s=typeof process.versions.v8==="string"?process.versions.v8:typeof process.versions.chakracore==="string"?"chakracore-"+process.versions.chakracore:"node-"+process.version;const i=n.join(a.tmpdir(),t,r,s);return i}function getMainName(){const e=require.main&&typeof require.main.filename==="string"?require.main.filename:process.cwd();return e}if(!process.env.DISABLE_V8_COMPILE_CACHE&&supportsCachedData()){const e=getCacheDir();const t=getMainName();const r=new FileSystemBlobStore(e,t);const s=new NativeCompileCache;s.setCacheStore(r);s.install();process.once("exit",(()=>{if(r.isDirty()){r.save()}s.uninstall()}))}e.exports.__TEST__={FileSystemBlobStore:FileSystemBlobStore,NativeCompileCache:NativeCompileCache,mkdirpSync:mkdirpSync,slashEscape:slashEscape,supportsCachedData:supportsCachedData,getCacheDir:getCacheDir,getMainName:getMainName}},113:function(e){e.exports=require("crypto")},147:function(e){e.exports=require("fs")},188:function(e){e.exports=require("module")},37:function(e){e.exports=require("os")},17:function(e){e.exports=require("path")},144:function(e){e.exports=require("vm")}};var t={};function __nccwpck_require__(r){var s=t[r];if(s!==undefined){return s.exports}var i=t[r]={exports:{}};var o=true;try{e[r](i,i.exports,__nccwpck_require__);o=false}finally{if(o)delete t[r]}return i.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(322);module.exports=r})();
@@ -1 +0,0 @@
1
- {"name":"v8-compile-cache","version":"2.4.0","author":"Andres Suarez <zertosh@gmail.com>","license":"MIT","_lastModified":"2024-04-08T03:40:35.538Z"}
@@ -1,2 +0,0 @@
1
- #! /usr/bin/env node
2
- export {};
package/es/postinstall.js DELETED
@@ -1,2 +0,0 @@
1
- #! /usr/bin/env node
2
- import{initPreCommit as i}from"./yolk";i();
@@ -1,2 +0,0 @@
1
- #! /usr/bin/env node
2
- export {};
@@ -1,2 +0,0 @@
1
- #! /usr/bin/env node
2
- var i=require("./yolk");(0,i.initPreCommit)();
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@baic/stylelint-config-yolk"
3
- }
@@ -1 +0,0 @@
1
- export const REQUEST_HOST = '';
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@baic/stylelint-config-yolk"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@baic/stylelint-config-yolk"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@baic/stylelint-config-yolk"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@baic/stylelint-config-yolk"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@baic/stylelint-config-yolk"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@baic/stylelint-config-yolk"
3
- }