@baic/yolk-cli 2.1.0-alpha.246 → 2.1.0-alpha.248

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 (69) 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 +7 -8
  16. package/templates/miniprogram/.eslintignore +4 -0
  17. package/templates/miniprogram/.eslintrc.js +1 -0
  18. package/templates/miniprogram/.prettierrc.js +1 -0
  19. package/templates/miniprogram/.stylelintignore +4 -0
  20. package/templates/miniprogram/.stylelintrc.js +4 -0
  21. package/templates/miniprogram/src/constants.ts +1 -1
  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/umi-mobile/.stylelintrc +0 -3
  65. package/templates/umi-mobile-h5+app/.stylelintrc +0 -3
  66. package/templates/umi-mobile-native/.stylelintrc +0 -3
  67. package/templates/umi-mobile-uni-app/.stylelintrc +0 -3
  68. package/templates/umi-web/.stylelintrc +0 -3
  69. package/templates/umi-web-screen/.stylelintrc +0 -3
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
+ var r=(r=>"undefined"!==typeof require?require:"undefined"!==typeof Proxy?new Proxy(r,{get:(r,e)=>("undefined"!==typeof require?require:r)[e]}):r)((function(r){if("undefined"!==typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')}));import{spawn as e}from"node:child_process";import{existsSync as o,readFileSync as t}from"node:fs";import{join as n}from"node:path";import i from"chalk";import{globSync as c}from"glob";import{rimrafSync as s,windowsSync as p}from"rimraf";import{program as l}from"../compiled/commander";var a=process.cwd(),f=console,m="utf-8",u=r=>r&&f.log(i.yellow("warn -"),r),d=r=>r&&f.log(i.red("error -"),r),y=r=>r&&f.log(i.green("ready -"),r),g=r=>r&&f.log(i.blue("info -"),r),h=()=>"win32"===process.platform,k=r=>h()?`${r}.cmd`:r,w=r=>h()?p(r):s(r),x=()=>{g("yolk complete!"),process.exit(0)},q=()=>{u("yolk break!"),process.exit(0)},j=({command:r,args:o,complete:t,close:n,exit:i=!0})=>{const c=e(k(r),o||[],{stdio:"inherit"}).on("close",(r=>{r?(n&&n(),d("yolk close!"),process.exit(r)):(t&&t(),i&&x())}));process.on("SIGINT",(()=>{l.exitOverride(),c.kill(),q()}))},b=()=>{const r=c("*.yolkrc*",{cwd:a,dot:!0});if(!r.length)return{};const e=n(a,r[0]);if(!o(e))return{};try{return JSON.parse(t(e,m))||{}}catch(i){return i(i.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}},v=()=>{const r=n(a,"project.config.json");if(!o(r))return{};try{return JSON.parse(t(r,m))||{}}catch(e){return e(e.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}},S=()=>{const r=n(a,"package.json");if(!o(r))return{};try{return JSON.parse(t(r,m))||{}}catch(e){return e(e.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}},N=e=>{const t=b();let n="";try{n=r.resolve(`@baic/${e}-config-yolk`)}catch(p){}const i=c(`*.${e}rc*`,{cwd:a,dot:!0}),s=null==i?void 0:i[0];return!1===t.strict&&s&&o(s)?s:o(n)?n:s},O=()=>N("eslint"),J=()=>N("stylelint"),$=()=>N("prettier"),I=()=>N("biome");export{m as ENCODING,q as breakExit,x as completeExit,a as cwd,d as error,j as execCommand,I as getBiomeConfigPath,N as getConfigFilePath,O as getEsLintConfigPath,S as getPackageJSON,$ as getPrettierConfigPath,v as getProjectConfigJSON,J as getStyleLintConfigPath,b as getYolkConfig,g as info,y as ready,w as rimrafSync,u as warn};
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
+ var e=Object.getOwnPropertyNames,t=(e=>"undefined"!==typeof require?require:"undefined"!==typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!==typeof require?require:e)[t]}):e)((function(e){if("undefined"!==typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')})),n=(t,n)=>function(){return n||(0,t[e(t)[0]])((n={exports:{}}).exports,n),n.exports},o=n({"src/lintstagedrc.js"(e,n){var{join:o}=t("node:path"),{getBiomeConfigPath:s,getEsLintConfigPath:r,getPrettierConfigPath:i,getStyleLintConfigPath:c,getYolkConfig:a}=t("./_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:l,stylelintIgnorePattern:g}=a(),d=o(process.cwd(),"node_modules",".cache"),f=`prettier --write --cache --cache-strategy=content --cache-location=${o(d,".prettiercache")} --config ${i()} --no-error-on-unmatched-pattern`,h=`eslint --fix ${u?"--no-inline-config":""} --no-error-on-unmatched-pattern --cache --cache-strategy=content --cache-location=${o(d,".eslintcache")} --config ${r()} ${p.concat(l?[l]:[]).map((e=>`--ignore-pattern ${e}`)).join(" ")}`,y=`stylelint --fix ${u?"--ignore-disables":""} --allow-empty-input --cache --cache-strategy=content --cache-location=${o(d,".stylelintcache")} --config ${c()} ${p.concat(g?[g]:[]).map((e=>`--ignore-pattern ${e}`)).join(" ")}`,m=`biome check --write --unsafe --no-errors-on-unmatched --log-level=error --files-ignore-unknown=true --config-path=${s()}`,$={"*.{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,h],"*.{ts,tsx,cts,mts}":[`${f} --parser=typescript`,h]};n.exports={...$,[`!(${Object.keys($).join("|")})`]:[m]}}});export default o();
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
+ var e=(e=>"undefined"!==typeof require?require:"undefined"!==typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!==typeof require?require:e)[t]}):e)((function(e){if("undefined"!==typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}));import{execSync as t}from"node:child_process";import{chmodSync as o,copyFileSync as i,existsSync as r,readFileSync as a,statSync as n,writeFileSync as s}from"node:fs";import m from"node:os";import{basename as c,dirname as p,join as d,relative as l}from"node:path";import u from"lodash/floor";import g from"lodash/isString";import{globSync as f}from"glob";import h from"inquirer";import*as y from"miniprogram-ci";import{mkdirpSync as v}from"mkdirp";import{program as $}from"../compiled/commander";import b from"../compiled/mustache";import k from"../package.json";import{breakExit as w,cwd as j,ENCODING as P,error as x,execCommand as O,getPackageJSON as q,getProjectConfigJSON as S,getYolkConfig as D,info as E,ready as _,rimrafSync as Q,warn as N}from"./_util";var F="##### CREATED BY YOLK #####",K=(e,t,o)=>{h.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:"miniprogram template",value:"miniprogram"}]},{type:"input",name:"projectName",message:"\u9879\u76ee\u540d\u79f0",default:c(c(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:m,projectName:u,packageManager:g})=>{const h={projectName:u,packageManager:"default"===g?"pnpm":g,yolkVersion:k.version};if("umi-mobile-uni-app"===m)return void N("\u6682\u4e0d\u652f\u6301");const y=t||d(__dirname,`../templates/${m}`);_(`\u590d\u5236\u6a21\u7248 ${c(y)}`);const $=f("**/*",{cwd:y,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if($.forEach((t=>{if(!y)return;const o=d(y,t);if(!n(o).isDirectory())if(t.endsWith(".tpl")){const i=a(o,P),r=d(e,t.replace(/\.tpl$/,"")),n=b.render(i,h);v(p(r)),_(`\u521b\u5efa ${l(e,r)}`),s(r,n,P)}else{_(`\u521b\u5efa ${t}`);const r=d(e,t);v(p(r)),i(o,r)}})),_("\u590d\u5236\u6a21\u7248 success!"),o&&r(y)&&Q(y)&&_(`\u7f13\u5b58\u5220\u9664 success! ${c(y||"")}`),g)switch(_("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),g){case"default":case"pnpm":O({command:"pnpm",args:["install"]});break;case"yarn":O({command:"yarn",args:["install"]});break;case"npm":O({command:"npm",args:["install"]});break;default:}_("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},L=(e,t)=>K(e,t,!0),R=()=>r(d(j,"project.config.json")),M=()=>{let o=r(d(j,"node_modules/.bin/max"));if(!o)try{o=r(e.resolve("@umijs/max"))}catch(i){}if(!o)try{o=/umi@4\.(\d+)\.(\d+)/.test(t("umi -v").toString())}catch(i){}if(!o){const e=d(j,"node_modules","umi","package.json");if(r(e))try{const t=JSON.parse(a(e,P))||{};o=t.version&&+t.version.split(".")[0]>3}catch(i){}}return o},B=()=>{const t=d(j,"project.config.json");if(r(t)){const o=e(t);return o.appid}return""},I=()=>r(d(j,"project.tt.json"))&&0===B().indexOf("tt"),U=()=>0===B().indexOf("20"),W=()=>{const e=D(),t=d(j,".husky/pre-commit"),i=d(j,".git/"),n=d(j,".git/hooks"),c=d(n,"pre-commit"),p=r(t),l=r(i),u=r(n),g=r(c),f=!1!==e.initPreCommit&&!p,h=[F,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",F].join(m.EOL),y=e=>{let t=e||"";return t&&t.indexOf(F)>=0&&(t=`${t.substring(0,t.indexOf(F))}${t.substring(t.lastIndexOf(F)+F.length)}`.replace(/(\r|\n)+$/gu,"")),t};if(l)if(f)if(u||(v(n),_("create .git/hooks")),g){try{o(c,"777")}catch($){x(`chmod ${c} failed: ${$.message}`)}const e=y(a(c,P).toString());s(c,(e.indexOf("#!/")<0?["#!/bin/sh"]:[]).concat([e,h]).filter((e=>!!e)).join(m.EOL),P)}else s(c,["#!/bin/sh",h].join(m.EOL),P),_("create pre-commit");else if(g){const e=y(a(c,P).toString());s(c,e,P)}},A=()=>{N("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),O({command:"lint-staged",args:["-c",e.resolve("./lintstagedrc")]})},T=({mAppid:e,mProject:o,mPrivateKeyPath:i,mVersion:a,mDesc:n,mRobot:s,mQrcodeFormat:m,mQrcodeOutputDest:c,mPagePath:p,mSearchQuery:l})=>{let u="";try{u=r(d(j,".git"))?t("git log -1 --pretty=format:%H").toString():""}catch($){}const g=S(),f=e||g.appid,h=o||d(j,"dist"),v=i||d(j,`private.${f}.key`);if(r(h)){if(r(v)){const e=q(),t=a||e.version||g.version||"1.0.0",o=n||e.description||g.description,i=`${u?` commit: ${u};`:""}${o?` description: ${o};`:""}`;u&&E(`commit: ${u}`),E(`dist: ${h}`),E(`key: ${v}`),E(`appid: ${f}`),E(`version: ${t}`),E(`desc: ${i}`);const r=new y.Project({appid:f,type:"miniProgram",projectPath:h,privateKeyPath:v,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:f,options:{project:r,version:t,desc:i,setting:{...g.setting,es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1},robot:s,qrcodeFormat:m,qrcodeOutputDest:c,pagePath:p,searchQuery:l}}}throw Error(`\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(${v})`)}throw Error(`\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(${h})`)},V=()=>{let e="";try{e=t(`npm view ${k.name} version`,{timeout:3e3}).toString().replace(/\n/g,"")}catch(o){}E(`yolk version: ${k.version}${e&&e!==k.version?`(latest\uff1a${e})`:""}`),E(`node version: ${process.version}`),E(`platform: ${m.platform()}`),E(`memory: ${u(m.freemem()/1024/1024)} MB(${u(m.totalmem()/1024/1024)} MB)`)},X=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"),C=/(\w+)=('(.*)'|"(.*)"|(.*))/giu,H=e=>{process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";const t=[];return null==e||e.forEach((e=>{if(C.test(e)){const[t,o]=e.split("=");process.env[t]=o,E(`\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a${t}=${o}`)}else t.push(e)})),t},J=()=>{W(),process.argv.length>2?($.version(k.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),$.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(V(),_("yolk init \u5f00\u59cb"),e){const o=".yolk",i=d(j,o);r(i)&&Q(i)&&_(`\u7f13\u5b58\u5220\u9664 success! ${i}`),O({command:"git",args:["clone","-b","master","--depth","1",e,o].concat(t)}),L(j,i)}else K(j)})),$.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{V();const o=H(t);R()?I()?O({command:"taro",args:["build","--type","tt","--watch"].concat(o)}):U()?O({command:"taro",args:["build","--type","alipay","--watch"].concat(o)}):O({command:"taro",args:["build","--type","weapp","--watch"].concat(o)}):e?O({command:"dumi",args:["dev"].concat(o)}):M()?O({command:"max",args:["dev"].concat(o)}):O({command:"umi",args:["dev"].concat(o)})})),$.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{V();const o=H(t);R()?I()?O({command:"taro",args:["build","--type","tt"].concat(o)}):U()?O({command:"taro",args:["build","--type","alipay"].concat(o)}):O({command:"taro",args:["build","--type","weapp"].concat(o)}):e?O({command:"dumi",args:["build"].concat(o)}):M()?O({command:"max",args:["setup"].concat(o),complete:()=>O({command:"max",args:["build"].concat(o)}),exit:!1}):O({command:"umi",args:["build"].concat(o)})})),$.command("init-pre-commit").description("\u521d\u59cb\u5316 commit hook").action(W),$.command("pre-commit").description("\u6267\u884ccommit hook").action(A),X($.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((e=>{if(R())if(I());else if(U());else{const{appid:t,options:{project:o,version:i,desc:r,setting:a,robot:n}}=T(e);E(`${t} \u4e0a\u4f20\u5f00\u59cb`),y.upload({project:o,version:i,desc:r,setting:a,robot:n,onProgressUpdate:e=>{if(g(e))E(`task: ${e}`);else{const{status:t,message:o}=e;E(`task(${t}): ${o}`)}}}).then((()=>{_(`${t} \u4e0a\u4f20\u5b8c\u6210`)}))}else x("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),X($.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((e=>{if(R())if(I());else if(U());else{const{appid:t,options:{project:o,version:i,desc:r,setting:a,robot:n,qrcodeFormat:s,qrcodeOutputDest:m,pagePath:c,searchQuery:p}}=T(e);E(`${t} \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb`),y.preview({project:o,version:i,desc:r,setting:a,robot:n,qrcodeFormat:s,qrcodeOutputDest:m,pagePath:c,searchQuery:p,onProgressUpdate:e=>{if(g(e))E(`task: ${e}`);else{const{status:t,message:o}=e;E(`task(${t}): ${o}`)}}}).then((()=>{_(`${t} \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210`)}))}else x("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),$.command("exec").description("\u6267\u884cts\u6587\u4ef6").argument("<path>","\u6267\u884c\u7684ts\u6587\u4ef6").action((e=>{O({command:"tsx",args:[e]})})),$.parse(process.argv)):w()};J();
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
+ var e=Object.create,r=Object.defineProperty,t=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,i=(e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})},s=(e,n,i,s)=>{if(n&&"object"===typeof n||"function"===typeof n)for(let l of o(n))c.call(e,l)||l===i||r(e,l,{get:()=>n[l],enumerable:!(s=t(n,l))||s.enumerable});return e},l=(t,o,c)=>(c=null!=t?e(n(t)):{},s(!o&&t&&t.__esModule?c:r(c,"default",{value:t,enumerable:!0}),t)),a=e=>s(r({},"__esModule",{value:!0}),e),g={};i(g,{ENCODING:()=>O,breakExit:()=>v,completeExit:()=>q,cwd:()=>b,error:()=>k,execCommand:()=>J,getBiomeConfigPath:()=>L,getConfigFilePath:()=>I,getEsLintConfigPath:()=>$,getPackageJSON:()=>F,getPrettierConfigPath:()=>G,getProjectConfigJSON:()=>E,getStyleLintConfigPath:()=>D,getYolkConfig:()=>_,info:()=>x,ready:()=>w,rimrafSync:()=>N,warn:()=>h}),module.exports=a(g);var u=require("node:child_process"),f=require("node:fs"),y=require("node:path"),d=l(require("chalk")),p=require("glob"),m=require("rimraf"),S=require("../compiled/commander"),b=process.cwd(),j=console,O="utf-8",h=e=>e&&j.log(d.default.yellow("warn -"),e),k=e=>e&&j.log(d.default.red("error -"),e),w=e=>e&&j.log(d.default.green("ready -"),e),x=e=>e&&j.log(d.default.blue("info -"),e),P=()=>"win32"===process.platform,C=e=>P()?`${e}.cmd`:e,N=e=>P()?(0,m.windowsSync)(e):(0,m.rimrafSync)(e),q=()=>{x("yolk complete!"),process.exit(0)},v=()=>{h("yolk break!"),process.exit(0)},J=({command:e,args:r,complete:t,close:o,exit:n=!0})=>{const c=(0,u.spawn)(C(e),r||[],{stdio:"inherit"}).on("close",(e=>{e?(o&&o(),k("yolk close!"),process.exit(e)):(t&&t(),n&&q())}));process.on("SIGINT",(()=>{S.program.exitOverride(),c.kill(),v()}))},_=()=>{const e=(0,p.globSync)("*.yolkrc*",{cwd:b,dot:!0});if(!e.length)return{};const r=(0,y.join)(b,e[0]);if(!(0,f.existsSync)(r))return{};try{return JSON.parse((0,f.readFileSync)(r,O))||{}}catch(t){return t(t.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}},E=()=>{const e=(0,y.join)(b,"project.config.json");if(!(0,f.existsSync)(e))return{};try{return JSON.parse((0,f.readFileSync)(e,O))||{}}catch(r){return r(r.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}},F=()=>{const e=(0,y.join)(b,"package.json");if(!(0,f.existsSync)(e))return{};try{return JSON.parse((0,f.readFileSync)(e,O))||{}}catch(r){return r(r.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}},I=e=>{const r=_();let t="";try{t=require.resolve(`@baic/${e}-config-yolk`)}catch(c){}const o=(0,p.globSync)(`*.${e}rc*`,{cwd:b,dot:!0}),n=null==o?void 0:o[0];return!1===r.strict&&n&&(0,f.existsSync)(n)?n:(0,f.existsSync)(t)?t:n},$=()=>I("eslint"),D=()=>I("stylelint"),G=()=>I("prettier"),L=()=>I("biome");
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
+ var r=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
+ var{join:e}=require("node:path"),{getBiomeConfigPath:t,getEsLintConfigPath:n,getPrettierConfigPath:s,getStyleLintConfigPath:o,getYolkConfig:c}=require("./_util"),i=["**/node_modules/**","**/build/**","**/dist/**","**/lib/**","**/es/**","**/mock/**","**/test/**","**/public/**","**/assets/**","**/.umi/**","**/.umi-production/**","**/h5+app/**","**/*uni*/**","**/android/**","**/ios/**","**/*.ignore/**"],{strict:a=!0,eslintIgnorePattern:r,stylelintIgnorePattern:l}=c(),g=e(process.cwd(),"node_modules",".cache"),h=`prettier --write --cache --cache-strategy=content --cache-location=${e(g,".prettiercache")} --config ${s()} --no-error-on-unmatched-pattern`,p=`eslint --fix ${a?"--no-inline-config":""} --no-error-on-unmatched-pattern --cache --cache-strategy=content --cache-location=${e(g,".eslintcache")} --config ${n()} ${i.concat(r?[r]:[]).map((e=>`--ignore-pattern ${e}`)).join(" ")}`,u=`stylelint --fix ${a?"--ignore-disables":""} --allow-empty-input --cache --cache-strategy=content --cache-location=${e(g,".stylelintcache")} --config ${o()} ${i.concat(l?[l]:[]).map((e=>`--ignore-pattern ${e}`)).join(" ")}`,m=`biome check --write --unsafe --no-errors-on-unmatched --log-level=error --files-ignore-unknown=true --config-path=${t()}`,$={"*.{md,json,jsonc}":[h],"*.css":[h,`${u} --custom-syntax postcss`],"*.less":[h,`${u} --custom-syntax postcss-less`],"*.{sass,scss}":[h,`${u} --custom-syntax postcss-scss`],"*.{js,jsx,cjs,mjs}":[h,p],"*.{ts,tsx,cts,mts}":[`${h} --parser=typescript`,p]};module.exports={...$,[`!(${Object.keys($).join("|")})`]:[m]};
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
+ var e=Object.create,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,i=Object.getPrototypeOf,r=Object.prototype.hasOwnProperty,n=(e,i,n,c)=>{if(i&&"object"===typeof i||"function"===typeof i)for(let s of a(i))r.call(e,s)||s===n||t(e,s,{get:()=>i[s],enumerable:!(c=o(i,s))||c.enumerable});return e},c=(o,a,r)=>(r=null!=o?e(i(o)):{},n(!a&&o&&o.__esModule?r:t(r,"default",{value:o,enumerable:!0}),o)),s=require("node:child_process"),m=require("node:fs"),d=c(require("node:os")),p=require("node:path"),l=c(require("lodash/floor")),u=c(require("lodash/isString")),g=require("glob"),y=c(require("inquirer")),f=c(require("miniprogram-ci")),h=require("mkdirp"),b=require("../compiled/commander"),v=c(require("../compiled/mustache")),x=c(require("../package.json")),S=require("./_util"),j="##### CREATED BY YOLK #####",w=(e,t,o)=>{y.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:"miniprogram template",value:"miniprogram"}]},{type:"input",name:"projectName",message:"\u9879\u76ee\u540d\u79f0",default:(0,p.basename)((0,p.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:a,projectName:i,packageManager:r})=>{const n={projectName:i,packageManager:"default"===r?"pnpm":r,yolkVersion:x.default.version};if("umi-mobile-uni-app"===a)return void(0,S.warn)("\u6682\u4e0d\u652f\u6301");const c=t||(0,p.join)(__dirname,`../templates/${a}`);(0,S.ready)(`\u590d\u5236\u6a21\u7248 ${(0,p.basename)(c)}`);const s=(0,g.globSync)("**/*",{cwd:c,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(s.forEach((t=>{if(!c)return;const o=(0,p.join)(c,t);if(!(0,m.statSync)(o).isDirectory())if(t.endsWith(".tpl")){const a=(0,m.readFileSync)(o,S.ENCODING),i=(0,p.join)(e,t.replace(/\.tpl$/,"")),r=v.default.render(a,n);(0,h.mkdirpSync)((0,p.dirname)(i)),(0,S.ready)(`\u521b\u5efa ${(0,p.relative)(e,i)}`),(0,m.writeFileSync)(i,r,S.ENCODING)}else{(0,S.ready)(`\u521b\u5efa ${t}`);const a=(0,p.join)(e,t);(0,h.mkdirpSync)((0,p.dirname)(a)),(0,m.copyFileSync)(o,a)}})),(0,S.ready)("\u590d\u5236\u6a21\u7248 success!"),o&&(0,m.existsSync)(c)&&(0,S.rimrafSync)(c)&&(0,S.ready)(`\u7f13\u5b58\u5220\u9664 success! ${(0,p.basename)(c||"")}`),r)switch((0,S.ready)("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),r){case"default":case"pnpm":(0,S.execCommand)({command:"pnpm",args:["install"]});break;case"yarn":(0,S.execCommand)({command:"yarn",args:["install"]});break;case"npm":(0,S.execCommand)({command:"npm",args:["install"]});break;default:}(0,S.ready)("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},$=(e,t)=>w(e,t,!0),k=()=>(0,m.existsSync)((0,p.join)(S.cwd,"project.config.json")),O=()=>{let e=(0,m.existsSync)((0,p.join)(S.cwd,"node_modules/.bin/max"));if(!e)try{e=(0,m.existsSync)(require.resolve("@umijs/max"))}catch(t){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test((0,s.execSync)("umi -v").toString())}catch(t){}if(!e){const o=(0,p.join)(S.cwd,"node_modules","umi","package.json");if((0,m.existsSync)(o))try{const t=JSON.parse((0,m.readFileSync)(o,S.ENCODING))||{};e=t.version&&+t.version.split(".")[0]>3}catch(t){}}return e},C=()=>{const e=(0,p.join)(S.cwd,"project.config.json");if((0,m.existsSync)(e)){const t=require(e);return t.appid}return""},P=()=>(0,m.existsSync)((0,p.join)(S.cwd,"project.tt.json"))&&0===C().indexOf("tt"),q=()=>0===C().indexOf("20"),N=()=>{const e=(0,S.getYolkConfig)(),t=(0,p.join)(S.cwd,".husky/pre-commit"),o=(0,p.join)(S.cwd,".git/"),a=(0,p.join)(S.cwd,".git/hooks"),i=(0,p.join)(a,"pre-commit"),r=(0,m.existsSync)(t),n=(0,m.existsSync)(o),c=(0,m.existsSync)(a),s=(0,m.existsSync)(i),l=!1!==e.initPreCommit&&!r,u=[j,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",j].join(d.default.EOL),g=e=>{let t=e||"";return t&&t.indexOf(j)>=0&&(t=`${t.substring(0,t.indexOf(j))}${t.substring(t.lastIndexOf(j)+j.length)}`.replace(/(\r|\n)+$/gu,"")),t};if(n)if(l)if(c||((0,h.mkdirpSync)(a),(0,S.ready)("create .git/hooks")),s){try{(0,m.chmodSync)(i,"777")}catch(y){(0,S.error)(`chmod ${i} failed: ${y.message}`)}const e=g((0,m.readFileSync)(i,S.ENCODING).toString());(0,m.writeFileSync)(i,(e.indexOf("#!/")<0?["#!/bin/sh"]:[]).concat([e,u]).filter((e=>!!e)).join(d.default.EOL),S.ENCODING)}else(0,m.writeFileSync)(i,["#!/bin/sh",u].join(d.default.EOL),S.ENCODING),(0,S.ready)("create pre-commit");else if(s){const e=g((0,m.readFileSync)(i,S.ENCODING).toString());(0,m.writeFileSync)(i,e,S.ENCODING)}},D=()=>{(0,S.warn)("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),(0,S.execCommand)({command:"lint-staged",args:["-c",require.resolve("./lintstagedrc")]})},E=({mAppid:e,mProject:t,mPrivateKeyPath:o,mVersion:a,mDesc:i,mRobot:r,mQrcodeFormat:n,mQrcodeOutputDest:c,mPagePath:d,mSearchQuery:l})=>{let u="";try{u=(0,m.existsSync)((0,p.join)(S.cwd,".git"))?(0,s.execSync)("git log -1 --pretty=format:%H").toString():""}catch(v){}const g=(0,S.getProjectConfigJSON)(),y=e||g.appid,h=t||(0,p.join)(S.cwd,"dist"),b=o||(0,p.join)(S.cwd,`private.${y}.key`);if((0,m.existsSync)(h)){if((0,m.existsSync)(b)){const e=(0,S.getPackageJSON)(),t=a||e.version||g.version||"1.0.0",o=i||e.description||g.description,s=`${u?` commit: ${u};`:""}${o?` description: ${o};`:""}`;u&&(0,S.info)(`commit: ${u}`),(0,S.info)(`dist: ${h}`),(0,S.info)(`key: ${b}`),(0,S.info)(`appid: ${y}`),(0,S.info)(`version: ${t}`),(0,S.info)(`desc: ${s}`);const m=new f.Project({appid:y,type:"miniProgram",projectPath:h,privateKeyPath:b,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:y,options:{project:m,version:t,desc:s,setting:{...g.setting,es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1},robot:r,qrcodeFormat:n,qrcodeOutputDest:c,pagePath:d,searchQuery:l}}}throw Error(`\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(${b})`)}throw Error(`\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(${h})`)},F=()=>{let e="";try{e=(0,s.execSync)(`npm view ${x.default.name} version`,{timeout:3e3}).toString().replace(/\n/g,"")}catch(t){}(0,S.info)(`yolk version: ${x.default.version}${e&&e!==x.default.version?`(latest\uff1a${e})`:""}`),(0,S.info)(`node version: ${process.version}`),(0,S.info)(`platform: ${d.default.platform()}`),(0,S.info)(`memory: ${(0,l.default)(d.default.freemem()/1024/1024)} MB(${(0,l.default)(d.default.totalmem()/1024/1024)} MB)`)},_=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"),I=/(\w+)=('(.*)'|"(.*)"|(.*))/giu,Q=e=>{process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";const t=[];return null==e||e.forEach((e=>{if(I.test(e)){const[t,o]=e.split("=");process.env[t]=o,(0,S.info)(`\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a${t}=${o}`)}else t.push(e)})),t},G=()=>{N(),process.argv.length>2?(b.program.version(x.default.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),b.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(F(),(0,S.ready)("yolk init \u5f00\u59cb"),e){const o=".yolk",a=(0,p.join)(S.cwd,o);(0,m.existsSync)(a)&&(0,S.rimrafSync)(a)&&(0,S.ready)(`\u7f13\u5b58\u5220\u9664 success! ${a}`),(0,S.execCommand)({command:"git",args:["clone","-b","master","--depth","1",e,o].concat(t)}),$(S.cwd,a)}else w(S.cwd)})),b.program.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{F();const o=Q(t);k()?P()?(0,S.execCommand)({command:"taro",args:["build","--type","tt","--watch"].concat(o)}):q()?(0,S.execCommand)({command:"taro",args:["build","--type","alipay","--watch"].concat(o)}):(0,S.execCommand)({command:"taro",args:["build","--type","weapp","--watch"].concat(o)}):e?(0,S.execCommand)({command:"dumi",args:["dev"].concat(o)}):O()?(0,S.execCommand)({command:"max",args:["dev"].concat(o)}):(0,S.execCommand)({command:"umi",args:["dev"].concat(o)})})),b.program.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{F();const o=Q(t);k()?P()?(0,S.execCommand)({command:"taro",args:["build","--type","tt"].concat(o)}):q()?(0,S.execCommand)({command:"taro",args:["build","--type","alipay"].concat(o)}):(0,S.execCommand)({command:"taro",args:["build","--type","weapp"].concat(o)}):e?(0,S.execCommand)({command:"dumi",args:["build"].concat(o)}):O()?(0,S.execCommand)({command:"max",args:["setup"].concat(o),complete:()=>(0,S.execCommand)({command:"max",args:["build"].concat(o)}),exit:!1}):(0,S.execCommand)({command:"umi",args:["build"].concat(o)})})),b.program.command("init-pre-commit").description("\u521d\u59cb\u5316 commit hook").action(N),b.program.command("pre-commit").description("\u6267\u884ccommit hook").action(D),_(b.program.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((e=>{if(k())if(P());else if(q());else{const{appid:t,options:{project:o,version:a,desc:i,setting:r,robot:n}}=E(e);(0,S.info)(`${t} \u4e0a\u4f20\u5f00\u59cb`),f.upload({project:o,version:a,desc:i,setting:r,robot:n,onProgressUpdate:e=>{if((0,u.default)(e))(0,S.info)(`task: ${e}`);else{const{status:t,message:o}=e;(0,S.info)(`task(${t}): ${o}`)}}}).then((()=>{(0,S.ready)(`${t} \u4e0a\u4f20\u5b8c\u6210`)}))}else(0,S.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),_(b.program.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((e=>{if(k())if(P());else if(q());else{const{appid:t,options:{project:o,version:a,desc:i,setting:r,robot:n,qrcodeFormat:c,qrcodeOutputDest:s,pagePath:m,searchQuery:d}}=E(e);(0,S.info)(`${t} \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb`),f.preview({project:o,version:a,desc:i,setting:r,robot:n,qrcodeFormat:c,qrcodeOutputDest:s,pagePath:m,searchQuery:d,onProgressUpdate:e=>{if((0,u.default)(e))(0,S.info)(`task: ${e}`);else{const{status:t,message:o}=e;(0,S.info)(`task(${t}): ${o}`)}}}).then((()=>{(0,S.ready)(`${t} \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210`)}))}else(0,S.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),b.program.command("exec").description("\u6267\u884cts\u6587\u4ef6").argument("<path>","\u6267\u884c\u7684ts\u6587\u4ef6").action((e=>{(0,S.execCommand)({command:"tsx",args:[e]})})),b.program.parse(process.argv)):(0,S.breakExit)()};G();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baic/yolk-cli",
3
- "version": "2.1.0-alpha.246",
3
+ "version": "2.1.0-alpha.248",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/303394539/yolk.git"
@@ -25,10 +25,10 @@
25
25
  "prebundle": "father prebundle"
26
26
  },
27
27
  "dependencies": {
28
- "@baic/biome-config-yolk": "2.1.0-alpha.246",
29
- "@baic/eslint-config-yolk": "2.1.0-alpha.246",
30
- "@baic/prettier-config-yolk": "2.1.0-alpha.246",
31
- "@baic/stylelint-config-yolk": "2.1.0-alpha.246",
28
+ "@baic/biome-config-yolk": "2.1.0-alpha.248",
29
+ "@baic/eslint-config-yolk": "2.1.0-alpha.248",
30
+ "@baic/prettier-config-yolk": "2.1.0-alpha.248",
31
+ "@baic/stylelint-config-yolk": "2.1.0-alpha.248",
32
32
  "@democrance/imagemin-lint-staged": "5.0.x",
33
33
  "@types/lodash": "4.x",
34
34
  "chalk": "4.x",
@@ -52,8 +52,7 @@
52
52
  "@types/lint-staged": "13.3.x",
53
53
  "@types/mustache": "4.2.x",
54
54
  "commander": "12.1.x",
55
- "mustache": "4.2.x",
56
- "v8-compile-cache": "2.4.x"
55
+ "mustache": "4.2.x"
57
56
  },
58
57
  "engines": {
59
58
  "node": ">=16"
@@ -61,5 +60,5 @@
61
60
  "publishConfig": {
62
61
  "access": "public"
63
62
  },
64
- "gitHead": "119c2dc8f30704473e129471085ec72a1a6cfacc"
63
+ "gitHead": "96a34e81ec061acebb5ab8cac330bbd3cfe615ed"
65
64
  }
@@ -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
+ };
@@ -1 +1 @@
1
- export const REQUEST_HOST = '';
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,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
- }