@baic/yolk-cli 2.1.0-alpha.212 → 2.1.0-alpha.214

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 (63) hide show
  1. package/es/yolk.js +1 -1
  2. package/lib/yolk.js +1 -1
  3. package/package.json +3 -4
  4. package/templates/umi-mobile-uni-app/.eslintrc.js +7 -0
  5. package/templates/umi-mobile-uni-app/.gitignore.tpl +37 -0
  6. package/templates/umi-mobile-uni-app/.npmrc.tpl +2 -0
  7. package/templates/umi-mobile-uni-app/.prettierignore +12 -0
  8. package/templates/umi-mobile-uni-app/.prettierrc.js +1 -0
  9. package/templates/umi-mobile-uni-app/.stylelintrc +3 -0
  10. package/templates/umi-mobile-uni-app/.umirc.ts.tpl +7 -0
  11. package/templates/umi-mobile-uni-app/LICENSE +21 -0
  12. package/templates/umi-mobile-uni-app/README.md.tpl +34 -0
  13. package/templates/umi-mobile-uni-app/package.json.tpl +16 -0
  14. package/templates/umi-mobile-uni-app/public/favicon.ico +0 -0
  15. package/templates/umi-mobile-uni-app/src/app.tsx +19 -0
  16. package/templates/umi-mobile-uni-app/src/common/request.ts +3 -0
  17. package/templates/umi-mobile-uni-app/src/common/util.ts +7 -0
  18. package/templates/umi-mobile-uni-app/src/components/index.ts +0 -0
  19. package/templates/umi-mobile-uni-app/src/global.less +3 -0
  20. package/templates/umi-mobile-uni-app/src/layouts/index.tsx +3 -0
  21. package/templates/umi-mobile-uni-app/src/pages/404.tsx +9 -0
  22. package/templates/umi-mobile-uni-app/src/pages/demo/examples/BarCode.tsx +3 -0
  23. package/templates/umi-mobile-uni-app/src/pages/demo/examples/Iconfont.tsx +17 -0
  24. package/templates/umi-mobile-uni-app/src/pages/demo/examples/Input.tsx +15 -0
  25. package/templates/umi-mobile-uni-app/src/pages/demo/examples/List/1.tsx +11 -0
  26. package/templates/umi-mobile-uni-app/src/pages/demo/examples/List/2.tsx +29 -0
  27. package/templates/umi-mobile-uni-app/src/pages/demo/examples/List/3.tsx +29 -0
  28. package/templates/umi-mobile-uni-app/src/pages/demo/examples/List/4.tsx +54 -0
  29. package/templates/umi-mobile-uni-app/src/pages/demo/examples/List/mock.ts +30 -0
  30. package/templates/umi-mobile-uni-app/src/pages/demo/examples/Loading.tsx +11 -0
  31. package/templates/umi-mobile-uni-app/src/pages/demo/examples/NumberInput/1.tsx +15 -0
  32. package/templates/umi-mobile-uni-app/src/pages/demo/examples/NumberInput/2.tsx +15 -0
  33. package/templates/umi-mobile-uni-app/src/pages/demo/examples/NumberInput/3.tsx +15 -0
  34. package/templates/umi-mobile-uni-app/src/pages/demo/examples/NumberInput/4.tsx +15 -0
  35. package/templates/umi-mobile-uni-app/src/pages/demo/examples/PagingList/1.tsx +5 -0
  36. package/templates/umi-mobile-uni-app/src/pages/demo/examples/QrCode.tsx +3 -0
  37. package/templates/umi-mobile-uni-app/src/pages/demo/examples/Required.tsx +3 -0
  38. package/templates/umi-mobile-uni-app/src/pages/demo/examples/TimerButton.tsx +3 -0
  39. package/templates/umi-mobile-uni-app/src/pages/demo/examples/usePreload.tsx +9 -0
  40. package/templates/umi-mobile-uni-app/src/pages/demo/index.tsx +87 -0
  41. package/templates/umi-mobile-uni-app/src/pages/index.tsx +1 -0
  42. package/templates/umi-mobile-uni-app/src/types/user.d.ts +3 -0
  43. package/templates/umi-mobile-uni-app/tsconfig.json +3 -0
  44. package/templates/umi-mobile-uni-app/typings.d.ts +1 -0
  45. package/templates/umi-mobile-uni-app/uni-app/AndroidManifest.xml +8 -0
  46. package/templates/umi-mobile-uni-app/uni-app/App.vue +28 -0
  47. package/templates/umi-mobile-uni-app/uni-app/androidPrivacy.json +22 -0
  48. package/templates/umi-mobile-uni-app/uni-app/assets/apple-app-site-association +11 -0
  49. package/templates/umi-mobile-uni-app/uni-app/common/constants.ts +5 -0
  50. package/templates/umi-mobile-uni-app/uni-app/common/request.ts +118 -0
  51. package/templates/umi-mobile-uni-app/uni-app/common/util.ts +27 -0
  52. package/templates/umi-mobile-uni-app/uni-app/components/webview/webview.vue +61 -0
  53. package/templates/umi-mobile-uni-app/uni-app/hybrid/html/error.html +24 -0
  54. package/templates/umi-mobile-uni-app/uni-app/images/index.ts +2 -0
  55. package/templates/umi-mobile-uni-app/uni-app/index.html +20 -0
  56. package/templates/umi-mobile-uni-app/uni-app/info.plist +6 -0
  57. package/templates/umi-mobile-uni-app/uni-app/main.js +22 -0
  58. package/templates/umi-mobile-uni-app/uni-app/manifest.json +207 -0
  59. package/templates/umi-mobile-uni-app/uni-app/pages/index/index.vue +17 -0
  60. package/templates/umi-mobile-uni-app/uni-app/pages/webview/index.vue +19 -0
  61. package/templates/umi-mobile-uni-app/uni-app/pages.json +22 -0
  62. package/templates/umi-mobile-uni-app/uni-app/uni.promisify.adaptor.js +16 -0
  63. package/templates/umi-mobile-uni-app/uni-app/uni.scss +76 -0
package/es/yolk.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #! /usr/bin/env node
2
- import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/helpers/defineProperty";import o from"@babel/runtime/helpers/asyncToGenerator";import r from"lodash/isString";import n from"lodash/floor";function a(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 c(e){for(var o=1;o<arguments.length;o++){var r=null!=arguments[o]?arguments[o]:{};o%2?a(Object(r),!0).forEach((function(o){t(e,o,r[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}import i from"@babel/runtime/regenerator";import{execSync as m}from"child_process";import{chmodSync as s,copyFileSync as p,existsSync as u,readFileSync as l,statSync as d,writeFileSync as f}from"fs";import g from"os";import{basename as v,dirname as y,join as h,relative as F}from"path";import{globSync as b}from"glob";import D from"inquirer";import*as j from"miniprogram-ci";import{mkdirpSync as k}from"mkdirp";import{program as w}from"../compiled/commander";import O from"../compiled/mustache";import P from"../package.json";import{breakExit as x,ENCODING as E,error as S,execCommand as B,getPackageJSON as _,getProjectConfigJSON as q,getYolkConfig as C,info as I,ready as Q,rimrafSync as T,warn as A}from"./_util";var R=process.cwd(),L="##### CREATED BY YOLK #####",N=function(e,t,o){D.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 native template(umi framework)",value:"umi-mobile-native"},{name:"miniprogram template",value:"miniprogram"}]},{type:"input",name:"projectName",message:"\u9879\u76ee\u540d\u79f0",default:v(v(process.cwd()))},{type:"list",name:"dependenciesInstallType",message:"\u9009\u62e9\u4f9d\u8d56\u5b89\u88c5\u65b9\u5f0f(\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((function(r){var n=r.type,a=r.projectName,c=r.dependenciesInstallType,i={projectName:a,dependenciesInstallType:"default"===c?"pnpm":c,yolkVersion:P.version},m=t||h(__dirname,"../templates/".concat(n));Q("\u590d\u5236\u6a21\u7248 ".concat(v(m)));var s=b("**/*",{cwd:m,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(s.forEach((function(t){if(m){var o=h(m,t);if(!d(o).isDirectory())if(t.endsWith(".tpl")){var r=l(o,E),n=h(e,t.replace(/\.tpl$/,"")),a=O.render(r,i);k(y(n)),Q("\u521b\u5efa ".concat(F(e,n))),f(n,a,E)}else{Q("\u521b\u5efa ".concat(t));var c=h(e,t);k(y(c)),p(o,c)}}})),Q("\u590d\u5236\u6a21\u7248 success!"),o&&u(m)&&T(m)&&Q("\u7f13\u5b58\u5220\u9664 success! ".concat(v(m||""))),c)switch(Q("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),c){case"default":case"pnpm":B({command:"pnpm",args:["install"]});break;case"yarn":B({command:"yarn",args:["install"]});break;case"npm":B({command:"npm",args:["install"]});break;default:}Q("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},K=function(e,t){return N(e,t,!0)},U=function(){return u(h(R,"project.config.json"))},W=function(){var e=u(h(R,"node_modules/.bin/max"));if(!e)try{e=u(require.resolve("@umijs/max"))}catch(r){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test(m("umi -v").toString())}catch(r){}if(!e){var t=h(R,"node_modules","umi","package.json");if(u(t))try{var o=JSON.parse(l(t,E))||{};e=o.version&&+o.version.split(".")[0]>3}catch(r){}}return e},$=function(){var e=h(R,"project.config.json");if(u(e)){var t=require(e);return t.appid}return""},V=function(){return u(h(R,"project.tt.json"))&&0===$().indexOf("tt")},G=function(){return 0===$().indexOf("20")},J=function(){var e=h(R,".git/"),t=h(R,".git/hooks"),o=h(t,"pre-commit"),r=u(e),n=u(o),a=n&&l(o,E).includes(L);if(r)if(n){if(!a){try{s(o,"777")}catch(i){S("chmod ".concat(o," failed: ").concat(i.message))}var c=l(o).toString();f(o,[c,c.includes("#!/")?"":"#!/bin/sh",L,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",L].join(g.EOL),E),Q("write pre-commit hook")}}else{k(t),f(o,["#!/bin/sh",L,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",L].join(g.EOL),E),Q("create pre-commit hook");try{s(o,"777")}catch(i){S("chmod ".concat(o," failed: ").concat(i.message))}Q("write pre-commit hook")}},M=function(){var e=o(i.mark((function e(){var t,o,r,n;return i.wrap((function(e){while(1)switch(e.prev=e.next){case 0:t=C(),o=!1!==t.strict,r=t.eslintIgnore,n=t.stylelintIgnore,A("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),o&&(A("git commit \u7981\u6b62 lint \u7684 ignore \u884c\u4e3a"),n&&A("\u901a\u8fc7 .yolkrc \u914d\u7f6e stylelintIgnore: ".concat(n,"\u3002")),r&&A("\u901a\u8fc7 .yolkrc \u914d\u7f6e eslintIgnore: ".concat(r,"\u3002"))),B({command:"lint-staged",args:["-c",require.resolve("./.lintstagedrc")]});case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),X=function(e){var t=e.mAppid,o=e.mProject,r=e.mPrivateKeyPath,n=e.mVersion,a=e.mDesc,i=e.mRobot,s=e.mQrcodeFormat,p=e.mQrcodeOutputDest,l=e.mPagePath,d=e.mSearchQuery,f=u(h(R,".git"))?m("git log -1 --pretty=format:%H").toString():"",g=q(),v=t||g.appid,y=o||h(R,"dist"),F=r||h(R,"private.".concat(v,".key"));if(u(y)){if(u(F)){var b=_(),D=n||b.version||g.version||"1.0.0",k=a||b.description||g.description,w="".concat(f?" commit: ".concat(f,";"):"").concat(k?" description: ".concat(k,";"):"");f&&I("commit: ".concat(f)),I("dist: ".concat(y)),I("key: ".concat(F)),I("appid: ".concat(v)),I("version: ".concat(D)),I("desc: ".concat(w));var O=new j.Project({appid:v,type:"miniProgram",projectPath:y,privateKeyPath:F,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:v,options:{project:O,version:D,desc:w,setting:c(c({},g.setting),{},{es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1}),robot:i,qrcodeFormat:s,qrcodeOutputDest:p,pagePath:l,searchQuery:d}}}throw Error("\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(".concat(F,")"))}throw Error("\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(".concat(y,")"))},Y=function(){var e="";try{e=m("npm view ".concat(P.name," version"),{timeout:3e3}).toString().replace(/\n/g,"")}catch(t){}I("yolk version: ".concat(P.version).concat(e&&e!==P.version?"(last\uff1a".concat(e,")"):"")),I("node version: ".concat(process.version)),I("platform: ".concat(g.platform())),I("memory: ".concat(n(g.freemem()/1024/1024)," MB(").concat(n(g.totalmem()/1024/1024)," MB)"))},H=function(e){return 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")},z=/([0-9A-Z_a-z\u017F\u212A]+)=('((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)'|"((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)"|((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*))/gi,Z=function(t){process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";var o=[];return null===t||void 0===t||t.forEach((function(t){if(z.test(t)){var r=t.split("="),n=e(r,2),a=n[0],c=n[1];process.env[a]=c,I("\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a".concat(a,"=").concat(c))}else o.push(t)})),o},ee=function(){J(),process.argv.length>2?(w.version(P.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),w.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((function(e,t){var o=e.clone,r=t.args;if(Y(),Q("yolk init \u5f00\u59cb"),o){var n=".yolk",a=h(R,n);u(a)&&T(a)&&Q("\u7f13\u5b58\u5220\u9664 success! ".concat(a)),B({command:"git",args:["clone","-b","master","--depth","1",o,n].concat(r)}),K(R,a)}else N(R)})),w.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((function(e,t){var o=e.docs,r=t.args;Y();var n=Z(r);U()?V()?B({command:"taro",args:["build","--type","tt","--watch"].concat(n)}):G()?B({command:"taro",args:["build","--type","alipay","--watch"].concat(n)}):B({command:"taro",args:["build","--type","weapp","--watch"].concat(n)}):o?B({command:"dumi",args:["dev"].concat(n)}):W()?B({command:"max",args:["dev"].concat(n)}):B({command:"umi",args:["dev"].concat(n)})})),w.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((function(e,t){var o=e.docs,r=t.args;Y();var n=Z(r);U()?V()?B({command:"taro",args:["build","--type","tt"].concat(n)}):G()?B({command:"taro",args:["build","--type","alipay"].concat(n)}):B({command:"taro",args:["build","--type","weapp"].concat(n)}):o?B({command:"dumi",args:["build"].concat(n)}):W()?B({command:"max",args:["setup"].concat(n),complete:function(){return B({command:"max",args:["build"].concat(n)})},exit:!1}):B({command:"umi",args:["build"].concat(n)})})),w.command("pre-commit").description("\u6267\u884ccommit hook").action(M),H(w.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((function(e){if(U())if(V());else if(G());else{var t=X(e),o=t.appid,n=t.options,a=n.project,c=n.version,i=n.desc,m=n.setting,s=n.robot;I("".concat(o," \u4e0a\u4f20\u5f00\u59cb")),j.upload({project:a,version:c,desc:i,setting:m,robot:s,onProgressUpdate:function(e){if(r(e))I("task: ".concat(e));else{var t=e.status,o=e.message;I("task(".concat(t,"): ").concat(o))}}}).then((function(){Q("".concat(o," \u4e0a\u4f20\u5b8c\u6210"))}))}else S("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),H(w.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((function(e){if(U())if(V());else if(G());else{var t=X(e),o=t.appid,n=t.options,a=n.project,c=n.version,i=n.desc,m=n.setting,s=n.robot,p=n.qrcodeFormat,u=n.qrcodeOutputDest,l=n.pagePath,d=n.searchQuery;I("".concat(o," \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb")),j.preview({project:a,version:c,desc:i,setting:m,robot:s,qrcodeFormat:p,qrcodeOutputDest:u,pagePath:l,searchQuery:d,onProgressUpdate:function(e){if(r(e))I("task: ".concat(e));else{var t=e.status,o=e.message;I("task(".concat(t,"): ").concat(o))}}}).then((function(){Q("".concat(o," \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210"))}))}else S("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),w.parse(process.argv)):x()};ee();
2
+ import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/helpers/defineProperty";import o from"@babel/runtime/helpers/asyncToGenerator";import r from"lodash/isString";import n from"lodash/floor";function a(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 i(e){for(var o=1;o<arguments.length;o++){var r=null!=arguments[o]?arguments[o]:{};o%2?a(Object(r),!0).forEach((function(o){t(e,o,r[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}import c from"@babel/runtime/regenerator";import{execSync as m}from"child_process";import{chmodSync as s,copyFileSync as p,existsSync as u,readFileSync as l,statSync as d,writeFileSync as f}from"fs";import g from"os";import{basename as v,dirname as y,join as h,relative as F}from"path";import{globSync as b}from"glob";import D from"inquirer";import*as j from"miniprogram-ci";import{mkdirpSync as k}from"mkdirp";import{program as w}from"../compiled/commander";import O from"../compiled/mustache";import P from"../package.json";import{breakExit as x,ENCODING as E,error as S,execCommand as B,getPackageJSON as _,getProjectConfigJSON as q,getYolkConfig as C,info as I,ready as Q,rimrafSync as T,warn as A}from"./_util";var R=process.cwd(),L="##### CREATED BY YOLK #####",N=function(e,t,o){D.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:v(v(process.cwd()))},{type:"list",name:"dependenciesInstallType",message:"\u9009\u62e9\u4f9d\u8d56\u5b89\u88c5\u65b9\u5f0f(\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((function(r){var n=r.type,a=r.projectName,i=r.dependenciesInstallType,c={projectName:a,dependenciesInstallType:"default"===i?"pnpm":i,yolkVersion:P.version};if("umi-mobile-uni-app"!==n){var m=t||h(__dirname,"../templates/".concat(n));Q("\u590d\u5236\u6a21\u7248 ".concat(v(m)));var s=b("**/*",{cwd:m,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(s.forEach((function(t){if(m){var o=h(m,t);if(!d(o).isDirectory())if(t.endsWith(".tpl")){var r=l(o,E),n=h(e,t.replace(/\.tpl$/,"")),a=O.render(r,c);k(y(n)),Q("\u521b\u5efa ".concat(F(e,n))),f(n,a,E)}else{Q("\u521b\u5efa ".concat(t));var i=h(e,t);k(y(i)),p(o,i)}}})),Q("\u590d\u5236\u6a21\u7248 success!"),o&&u(m)&&T(m)&&Q("\u7f13\u5b58\u5220\u9664 success! ".concat(v(m||""))),i)switch(Q("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),i){case"default":case"pnpm":B({command:"pnpm",args:["install"]});break;case"yarn":B({command:"yarn",args:["install"]});break;case"npm":B({command:"npm",args:["install"]});break;default:}Q("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}else A("\u6682\u4e0d\u652f\u6301")}))},K=function(e,t){return N(e,t,!0)},U=function(){return u(h(R,"project.config.json"))},W=function(){var e=u(h(R,"node_modules/.bin/max"));if(!e)try{e=u(require.resolve("@umijs/max"))}catch(r){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test(m("umi -v").toString())}catch(r){}if(!e){var t=h(R,"node_modules","umi","package.json");if(u(t))try{var o=JSON.parse(l(t,E))||{};e=o.version&&+o.version.split(".")[0]>3}catch(r){}}return e},$=function(){var e=h(R,"project.config.json");if(u(e)){var t=require(e);return t.appid}return""},V=function(){return u(h(R,"project.tt.json"))&&0===$().indexOf("tt")},X=function(){return 0===$().indexOf("20")},G=function(){var e=h(R,".git/"),t=h(R,".git/hooks"),o=h(t,"pre-commit"),r=u(e),n=u(o),a=n&&l(o,E).includes(L);if(r)if(n){if(!a){try{s(o,"777")}catch(c){S("chmod ".concat(o," failed: ").concat(c.message))}var i=l(o).toString();f(o,[i,i.includes("#!/")?"":"#!/bin/sh",L,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",L].join(g.EOL),E),Q("write pre-commit hook")}}else{k(t),f(o,["#!/bin/sh",L,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",L].join(g.EOL),E),Q("create pre-commit hook");try{s(o,"777")}catch(c){S("chmod ".concat(o," failed: ").concat(c.message))}Q("write pre-commit hook")}},H=function(){var e=o(c.mark((function e(){var t,o,r,n;return c.wrap((function(e){while(1)switch(e.prev=e.next){case 0:t=C(),o=!1!==t.strict,r=t.eslintIgnore,n=t.stylelintIgnore,A("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),o&&(A("git commit \u7981\u6b62 lint \u7684 ignore \u884c\u4e3a"),n&&A("\u901a\u8fc7 .yolkrc \u914d\u7f6e stylelintIgnore: ".concat(n,"\u3002")),r&&A("\u901a\u8fc7 .yolkrc \u914d\u7f6e eslintIgnore: ".concat(r,"\u3002"))),B({command:"lint-staged",args:["-c",require.resolve("./.lintstagedrc")]});case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),J=function(e){var t=e.mAppid,o=e.mProject,r=e.mPrivateKeyPath,n=e.mVersion,a=e.mDesc,c=e.mRobot,s=e.mQrcodeFormat,p=e.mQrcodeOutputDest,l=e.mPagePath,d=e.mSearchQuery,f=u(h(R,".git"))?m("git log -1 --pretty=format:%H").toString():"",g=q(),v=t||g.appid,y=o||h(R,"dist"),F=r||h(R,"private.".concat(v,".key"));if(u(y)){if(u(F)){var b=_(),D=n||b.version||g.version||"1.0.0",k=a||b.description||g.description,w="".concat(f?" commit: ".concat(f,";"):"").concat(k?" description: ".concat(k,";"):"");f&&I("commit: ".concat(f)),I("dist: ".concat(y)),I("key: ".concat(F)),I("appid: ".concat(v)),I("version: ".concat(D)),I("desc: ".concat(w));var O=new j.Project({appid:v,type:"miniProgram",projectPath:y,privateKeyPath:F,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:v,options:{project:O,version:D,desc:w,setting:i(i({},g.setting),{},{es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1}),robot:c,qrcodeFormat:s,qrcodeOutputDest:p,pagePath:l,searchQuery:d}}}throw Error("\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(".concat(F,")"))}throw Error("\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(".concat(y,")"))},M=function(){var e="";try{e=m("npm view ".concat(P.name," version"),{timeout:3e3}).toString().replace(/\n/g,"")}catch(t){}I("yolk version: ".concat(P.version).concat(e&&e!==P.version?"(last\uff1a".concat(e,")"):"")),I("node version: ".concat(process.version)),I("platform: ".concat(g.platform())),I("memory: ".concat(n(g.freemem()/1024/1024)," MB(").concat(n(g.totalmem()/1024/1024)," MB)"))},Y=function(e){return 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")},z=/([0-9A-Z_a-z\u017F\u212A]+)=('((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)'|"((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)"|((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*))/gi,Z=function(t){process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";var o=[];return null===t||void 0===t||t.forEach((function(t){if(z.test(t)){var r=t.split("="),n=e(r,2),a=n[0],i=n[1];process.env[a]=i,I("\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a".concat(a,"=").concat(i))}else o.push(t)})),o},ee=function(){G(),process.argv.length>2?(w.version(P.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),w.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((function(e,t){var o=e.clone,r=t.args;if(M(),Q("yolk init \u5f00\u59cb"),o){var n=".yolk",a=h(R,n);u(a)&&T(a)&&Q("\u7f13\u5b58\u5220\u9664 success! ".concat(a)),B({command:"git",args:["clone","-b","master","--depth","1",o,n].concat(r)}),K(R,a)}else N(R)})),w.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((function(e,t){var o=e.docs,r=t.args;M();var n=Z(r);U()?V()?B({command:"taro",args:["build","--type","tt","--watch"].concat(n)}):X()?B({command:"taro",args:["build","--type","alipay","--watch"].concat(n)}):B({command:"taro",args:["build","--type","weapp","--watch"].concat(n)}):o?B({command:"dumi",args:["dev"].concat(n)}):W()?B({command:"max",args:["dev"].concat(n)}):B({command:"umi",args:["dev"].concat(n)})})),w.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((function(e,t){var o=e.docs,r=t.args;M();var n=Z(r);U()?V()?B({command:"taro",args:["build","--type","tt"].concat(n)}):X()?B({command:"taro",args:["build","--type","alipay"].concat(n)}):B({command:"taro",args:["build","--type","weapp"].concat(n)}):o?B({command:"dumi",args:["build"].concat(n)}):W()?B({command:"max",args:["setup"].concat(n),complete:function(){return B({command:"max",args:["build"].concat(n)})},exit:!1}):B({command:"umi",args:["build"].concat(n)})})),w.command("pre-commit").description("\u6267\u884ccommit hook").action(H),Y(w.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((function(e){if(U())if(V());else if(X());else{var t=J(e),o=t.appid,n=t.options,a=n.project,i=n.version,c=n.desc,m=n.setting,s=n.robot;I("".concat(o," \u4e0a\u4f20\u5f00\u59cb")),j.upload({project:a,version:i,desc:c,setting:m,robot:s,onProgressUpdate:function(e){if(r(e))I("task: ".concat(e));else{var t=e.status,o=e.message;I("task(".concat(t,"): ").concat(o))}}}).then((function(){Q("".concat(o," \u4e0a\u4f20\u5b8c\u6210"))}))}else S("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),Y(w.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((function(e){if(U())if(V());else if(X());else{var t=J(e),o=t.appid,n=t.options,a=n.project,i=n.version,c=n.desc,m=n.setting,s=n.robot,p=n.qrcodeFormat,u=n.qrcodeOutputDest,l=n.pagePath,d=n.searchQuery;I("".concat(o," \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb")),j.preview({project:a,version:i,desc:c,setting:m,robot:s,qrcodeFormat:p,qrcodeOutputDest:u,pagePath:l,searchQuery:d,onProgressUpdate:function(e){if(r(e))I("task: ".concat(e));else{var t=e.status,o=e.message;I("task(".concat(t,"): ").concat(o))}}}).then((function(){Q("".concat(o," \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210"))}))}else S("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),w.parse(process.argv)):x()};ee();
package/lib/yolk.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #! /usr/bin/env node
2
- var e=Object.create,o=Object.defineProperty,t=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,a=(e,i,a,c)=>{if(i&&"object"===typeof i||"function"===typeof i)for(let s of r(i))n.call(e,s)||s===a||o(e,s,{get:()=>i[s],enumerable:!(c=t(i,s))||c.enumerable});return e},c=(t,r,n)=>(n=null!=t?e(i(t)):{},a(!r&&t&&t.__esModule?n:o(n,"default",{value:t,enumerable:!0}),t)),s=require("child_process"),m=require("fs"),p=c(require("os")),d=require("path"),l=require("lodash"),u=require("glob"),y=c(require("inquirer")),g=c(require("miniprogram-ci")),f=require("mkdirp"),h=require("../compiled/commander"),v=c(require("../compiled/mustache")),b=c(require("../package.json")),S=require("./_util"),x=process.cwd(),j="##### CREATED BY YOLK #####",$=(e,o,t)=>{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 native template(umi framework)",value:"umi-mobile-native"},{name:"miniprogram template",value:"miniprogram"}]},{type:"input",name:"projectName",message:"\u9879\u76ee\u540d\u79f0",default:(0,d.basename)((0,d.basename)(process.cwd()))},{type:"list",name:"dependenciesInstallType",message:"\u9009\u62e9\u4f9d\u8d56\u5b89\u88c5\u65b9\u5f0f(\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,dependenciesInstallType:n})=>{const a={projectName:i,dependenciesInstallType:"default"===n?"pnpm":n,yolkVersion:b.default.version},c=o||(0,d.join)(__dirname,`../templates/${r}`);(0,S.ready)(`\u590d\u5236\u6a21\u7248 ${(0,d.basename)(c)}`);const s=(0,u.globSync)("**/*",{cwd:c,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(s.forEach((o=>{if(!c)return;const t=(0,d.join)(c,o);if(!(0,m.statSync)(t).isDirectory())if(o.endsWith(".tpl")){const r=(0,m.readFileSync)(t,S.ENCODING),i=(0,d.join)(e,o.replace(/\.tpl$/,"")),n=v.default.render(r,a);(0,f.mkdirpSync)((0,d.dirname)(i)),(0,S.ready)(`\u521b\u5efa ${(0,d.relative)(e,i)}`),(0,m.writeFileSync)(i,n,S.ENCODING)}else{(0,S.ready)(`\u521b\u5efa ${o}`);const r=(0,d.join)(e,o);(0,f.mkdirpSync)((0,d.dirname)(r)),(0,m.copyFileSync)(t,r)}})),(0,S.ready)("\u590d\u5236\u6a21\u7248 success!"),t&&(0,m.existsSync)(c)&&(0,S.rimrafSync)(c)&&(0,S.ready)(`\u7f13\u5b58\u5220\u9664 success! ${(0,d.basename)(c||"")}`),n)switch((0,S.ready)("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),n){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")}))},k=(e,o)=>$(e,o,!0),w=()=>(0,m.existsSync)((0,d.join)(x,"project.config.json")),O=()=>{let e=(0,m.existsSync)((0,d.join)(x,"node_modules/.bin/max"));if(!e)try{e=(0,m.existsSync)(require.resolve("@umijs/max"))}catch(o){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test((0,s.execSync)("umi -v").toString())}catch(o){}if(!e){const t=(0,d.join)(x,"node_modules","umi","package.json");if((0,m.existsSync)(t))try{const o=JSON.parse((0,m.readFileSync)(t,S.ENCODING))||{};e=o.version&&+o.version.split(".")[0]>3}catch(o){}}return e},P=()=>{const e=(0,d.join)(x,"project.config.json");if((0,m.existsSync)(e)){const o=require(e);return o.appid}return""},C=()=>(0,m.existsSync)((0,d.join)(x,"project.tt.json"))&&0===P().indexOf("tt"),q=()=>0===P().indexOf("20"),N=()=>{const e=(0,d.join)(x,".git/"),o=(0,d.join)(x,".git/hooks"),t=(0,d.join)(o,"pre-commit"),r=(0,m.existsSync)(e),i=(0,m.existsSync)(t),n=i&&(0,m.readFileSync)(t,S.ENCODING).includes(j);if(r)if(i){if(!n){try{(0,m.chmodSync)(t,"777")}catch(a){(0,S.error)(`chmod ${t} failed: ${a.message}`)}const e=(0,m.readFileSync)(t).toString();(0,m.writeFileSync)(t,[e,e.includes("#!/")?"":"#!/bin/sh",j,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",j].join(p.default.EOL),S.ENCODING),(0,S.ready)("write pre-commit hook")}}else{(0,f.mkdirpSync)(o),(0,m.writeFileSync)(t,["#!/bin/sh",j,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",j].join(p.default.EOL),S.ENCODING),(0,S.ready)("create pre-commit hook");try{(0,m.chmodSync)(t,"777")}catch(a){(0,S.error)(`chmod ${t} failed: ${a.message}`)}(0,S.ready)("write pre-commit hook")}},D=async()=>{const e=(0,S.getYolkConfig)(),o=!1!==e.strict,t=e.eslintIgnore,r=e.stylelintIgnore;(0,S.warn)("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),o&&((0,S.warn)("git commit \u7981\u6b62 lint \u7684 ignore \u884c\u4e3a"),r&&(0,S.warn)(`\u901a\u8fc7 .yolkrc \u914d\u7f6e stylelintIgnore: ${r}\u3002`),t&&(0,S.warn)(`\u901a\u8fc7 .yolkrc \u914d\u7f6e eslintIgnore: ${t}\u3002`)),(0,S.execCommand)({command:"lint-staged",args:["-c",require.resolve("./.lintstagedrc")]})},E=({mAppid:e,mProject:o,mPrivateKeyPath:t,mVersion:r,mDesc:i,mRobot:n,mQrcodeFormat:a,mQrcodeOutputDest:c,mPagePath:p,mSearchQuery:l})=>{const u=(0,m.existsSync)((0,d.join)(x,".git"))?(0,s.execSync)("git log -1 --pretty=format:%H").toString():"",y=(0,S.getProjectConfigJSON)(),f=e||y.appid,h=o||(0,d.join)(x,"dist"),v=t||(0,d.join)(x,`private.${f}.key`);if((0,m.existsSync)(h)){if((0,m.existsSync)(v)){const e=(0,S.getPackageJSON)(),o=r||e.version||y.version||"1.0.0",t=i||e.description||y.description,s=`${u?` commit: ${u};`:""}${t?` description: ${t};`:""}`;u&&(0,S.info)(`commit: ${u}`),(0,S.info)(`dist: ${h}`),(0,S.info)(`key: ${v}`),(0,S.info)(`appid: ${f}`),(0,S.info)(`version: ${o}`),(0,S.info)(`desc: ${s}`);const m=new g.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:m,version:o,desc:s,setting:{...y.setting,es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1},robot:n,qrcodeFormat:a,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})`)},I=()=>{let e="";try{e=(0,s.execSync)(`npm view ${b.default.name} version`,{timeout:3e3}).toString().replace(/\n/g,"")}catch(o){}(0,S.info)(`yolk version: ${b.default.version}${e&&e!==b.default.version?`(last\uff1a${e})`:""}`),(0,S.info)(`node version: ${process.version}`),(0,S.info)(`platform: ${p.default.platform()}`),(0,S.info)(`memory: ${(0,l.floor)(p.default.freemem()/1024/1024)} MB(${(0,l.floor)(p.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"),F=/(\w+)=('(.*)'|"(.*)"|(.*))/giu,Q=e=>{process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";const o=[];return null==e||e.forEach((e=>{if(F.test(e)){const[o,t]=e.split("=");process.env[o]=t,(0,S.info)(`\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a${o}=${t}`)}else o.push(e)})),o},R=()=>{N(),process.argv.length>2?(h.program.version(b.default.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),h.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:o})=>{if(I(),(0,S.ready)("yolk init \u5f00\u59cb"),e){const t=".yolk",r=(0,d.join)(x,t);(0,m.existsSync)(r)&&(0,S.rimrafSync)(r)&&(0,S.ready)(`\u7f13\u5b58\u5220\u9664 success! ${r}`),(0,S.execCommand)({command:"git",args:["clone","-b","master","--depth","1",e,t].concat(o)}),k(x,r)}else $(x)})),h.program.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:o})=>{I();const t=Q(o);w()?C()?(0,S.execCommand)({command:"taro",args:["build","--type","tt","--watch"].concat(t)}):q()?(0,S.execCommand)({command:"taro",args:["build","--type","alipay","--watch"].concat(t)}):(0,S.execCommand)({command:"taro",args:["build","--type","weapp","--watch"].concat(t)}):e?(0,S.execCommand)({command:"dumi",args:["dev"].concat(t)}):O()?(0,S.execCommand)({command:"max",args:["dev"].concat(t)}):(0,S.execCommand)({command:"umi",args:["dev"].concat(t)})})),h.program.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:o})=>{I();const t=Q(o);w()?C()?(0,S.execCommand)({command:"taro",args:["build","--type","tt"].concat(t)}):q()?(0,S.execCommand)({command:"taro",args:["build","--type","alipay"].concat(t)}):(0,S.execCommand)({command:"taro",args:["build","--type","weapp"].concat(t)}):e?(0,S.execCommand)({command:"dumi",args:["build"].concat(t)}):O()?(0,S.execCommand)({command:"max",args:["setup"].concat(t),complete:()=>(0,S.execCommand)({command:"max",args:["build"].concat(t)}),exit:!1}):(0,S.execCommand)({command:"umi",args:["build"].concat(t)})})),h.program.command("pre-commit").description("\u6267\u884ccommit hook").action(D),_(h.program.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((e=>{if(w())if(C());else if(q());else{const{appid:o,options:{project:t,version:r,desc:i,setting:n,robot:a}}=E(e);(0,S.info)(`${o} \u4e0a\u4f20\u5f00\u59cb`),g.upload({project:t,version:r,desc:i,setting:n,robot:a,onProgressUpdate:e=>{if((0,l.isString)(e))(0,S.info)(`task: ${e}`);else{const{status:o,message:t}=e;(0,S.info)(`task(${o}): ${t}`)}}}).then((()=>{(0,S.ready)(`${o} \u4e0a\u4f20\u5b8c\u6210`)}))}else(0,S.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),_(h.program.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((e=>{if(w())if(C());else if(q());else{const{appid:o,options:{project:t,version:r,desc:i,setting:n,robot:a,qrcodeFormat:c,qrcodeOutputDest:s,pagePath:m,searchQuery:p}}=E(e);(0,S.info)(`${o} \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb`),g.preview({project:t,version:r,desc:i,setting:n,robot:a,qrcodeFormat:c,qrcodeOutputDest:s,pagePath:m,searchQuery:p,onProgressUpdate:e=>{if((0,l.isString)(e))(0,S.info)(`task: ${e}`);else{const{status:o,message:t}=e;(0,S.info)(`task(${o}): ${t}`)}}}).then((()=>{(0,S.ready)(`${o} \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210`)}))}else(0,S.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),h.program.parse(process.argv)):(0,S.breakExit)()};R();
2
+ var e=Object.create,o=Object.defineProperty,t=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,r=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,a=(e,r,a,c)=>{if(r&&"object"===typeof r||"function"===typeof r)for(let s of i(r))n.call(e,s)||s===a||o(e,s,{get:()=>r[s],enumerable:!(c=t(r,s))||c.enumerable});return e},c=(t,i,n)=>(n=null!=t?e(r(t)):{},a(!i&&t&&t.__esModule?n:o(n,"default",{value:t,enumerable:!0}),t)),s=require("child_process"),m=require("fs"),p=c(require("os")),d=require("path"),l=require("lodash"),u=require("glob"),y=c(require("inquirer")),g=c(require("miniprogram-ci")),f=require("mkdirp"),h=require("../compiled/commander"),v=c(require("../compiled/mustache")),b=c(require("../package.json")),S=require("./_util"),x=process.cwd(),j="##### CREATED BY YOLK #####",$=(e,o,t)=>{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,d.basename)((0,d.basename)(process.cwd()))},{type:"list",name:"dependenciesInstallType",message:"\u9009\u62e9\u4f9d\u8d56\u5b89\u88c5\u65b9\u5f0f(\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:i,projectName:r,dependenciesInstallType:n})=>{const a={projectName:r,dependenciesInstallType:"default"===n?"pnpm":n,yolkVersion:b.default.version};if("umi-mobile-uni-app"===i)return void(0,S.warn)("\u6682\u4e0d\u652f\u6301");const c=o||(0,d.join)(__dirname,`../templates/${i}`);(0,S.ready)(`\u590d\u5236\u6a21\u7248 ${(0,d.basename)(c)}`);const s=(0,u.globSync)("**/*",{cwd:c,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(s.forEach((o=>{if(!c)return;const t=(0,d.join)(c,o);if(!(0,m.statSync)(t).isDirectory())if(o.endsWith(".tpl")){const i=(0,m.readFileSync)(t,S.ENCODING),r=(0,d.join)(e,o.replace(/\.tpl$/,"")),n=v.default.render(i,a);(0,f.mkdirpSync)((0,d.dirname)(r)),(0,S.ready)(`\u521b\u5efa ${(0,d.relative)(e,r)}`),(0,m.writeFileSync)(r,n,S.ENCODING)}else{(0,S.ready)(`\u521b\u5efa ${o}`);const i=(0,d.join)(e,o);(0,f.mkdirpSync)((0,d.dirname)(i)),(0,m.copyFileSync)(t,i)}})),(0,S.ready)("\u590d\u5236\u6a21\u7248 success!"),t&&(0,m.existsSync)(c)&&(0,S.rimrafSync)(c)&&(0,S.ready)(`\u7f13\u5b58\u5220\u9664 success! ${(0,d.basename)(c||"")}`),n)switch((0,S.ready)("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),n){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")}))},k=(e,o)=>$(e,o,!0),w=()=>(0,m.existsSync)((0,d.join)(x,"project.config.json")),O=()=>{let e=(0,m.existsSync)((0,d.join)(x,"node_modules/.bin/max"));if(!e)try{e=(0,m.existsSync)(require.resolve("@umijs/max"))}catch(o){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test((0,s.execSync)("umi -v").toString())}catch(o){}if(!e){const t=(0,d.join)(x,"node_modules","umi","package.json");if((0,m.existsSync)(t))try{const o=JSON.parse((0,m.readFileSync)(t,S.ENCODING))||{};e=o.version&&+o.version.split(".")[0]>3}catch(o){}}return e},P=()=>{const e=(0,d.join)(x,"project.config.json");if((0,m.existsSync)(e)){const o=require(e);return o.appid}return""},C=()=>(0,m.existsSync)((0,d.join)(x,"project.tt.json"))&&0===P().indexOf("tt"),q=()=>0===P().indexOf("20"),N=()=>{const e=(0,d.join)(x,".git/"),o=(0,d.join)(x,".git/hooks"),t=(0,d.join)(o,"pre-commit"),i=(0,m.existsSync)(e),r=(0,m.existsSync)(t),n=r&&(0,m.readFileSync)(t,S.ENCODING).includes(j);if(i)if(r){if(!n){try{(0,m.chmodSync)(t,"777")}catch(a){(0,S.error)(`chmod ${t} failed: ${a.message}`)}const e=(0,m.readFileSync)(t).toString();(0,m.writeFileSync)(t,[e,e.includes("#!/")?"":"#!/bin/sh",j,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",j].join(p.default.EOL),S.ENCODING),(0,S.ready)("write pre-commit hook")}}else{(0,f.mkdirpSync)(o),(0,m.writeFileSync)(t,["#!/bin/sh",j,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",j].join(p.default.EOL),S.ENCODING),(0,S.ready)("create pre-commit hook");try{(0,m.chmodSync)(t,"777")}catch(a){(0,S.error)(`chmod ${t} failed: ${a.message}`)}(0,S.ready)("write pre-commit hook")}},D=async()=>{const e=(0,S.getYolkConfig)(),o=!1!==e.strict,t=e.eslintIgnore,i=e.stylelintIgnore;(0,S.warn)("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),o&&((0,S.warn)("git commit \u7981\u6b62 lint \u7684 ignore \u884c\u4e3a"),i&&(0,S.warn)(`\u901a\u8fc7 .yolkrc \u914d\u7f6e stylelintIgnore: ${i}\u3002`),t&&(0,S.warn)(`\u901a\u8fc7 .yolkrc \u914d\u7f6e eslintIgnore: ${t}\u3002`)),(0,S.execCommand)({command:"lint-staged",args:["-c",require.resolve("./.lintstagedrc")]})},E=({mAppid:e,mProject:o,mPrivateKeyPath:t,mVersion:i,mDesc:r,mRobot:n,mQrcodeFormat:a,mQrcodeOutputDest:c,mPagePath:p,mSearchQuery:l})=>{const u=(0,m.existsSync)((0,d.join)(x,".git"))?(0,s.execSync)("git log -1 --pretty=format:%H").toString():"",y=(0,S.getProjectConfigJSON)(),f=e||y.appid,h=o||(0,d.join)(x,"dist"),v=t||(0,d.join)(x,`private.${f}.key`);if((0,m.existsSync)(h)){if((0,m.existsSync)(v)){const e=(0,S.getPackageJSON)(),o=i||e.version||y.version||"1.0.0",t=r||e.description||y.description,s=`${u?` commit: ${u};`:""}${t?` description: ${t};`:""}`;u&&(0,S.info)(`commit: ${u}`),(0,S.info)(`dist: ${h}`),(0,S.info)(`key: ${v}`),(0,S.info)(`appid: ${f}`),(0,S.info)(`version: ${o}`),(0,S.info)(`desc: ${s}`);const m=new g.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:m,version:o,desc:s,setting:{...y.setting,es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1},robot:n,qrcodeFormat:a,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})`)},I=()=>{let e="";try{e=(0,s.execSync)(`npm view ${b.default.name} version`,{timeout:3e3}).toString().replace(/\n/g,"")}catch(o){}(0,S.info)(`yolk version: ${b.default.version}${e&&e!==b.default.version?`(last\uff1a${e})`:""}`),(0,S.info)(`node version: ${process.version}`),(0,S.info)(`platform: ${p.default.platform()}`),(0,S.info)(`memory: ${(0,l.floor)(p.default.freemem()/1024/1024)} MB(${(0,l.floor)(p.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"),F=/(\w+)=('(.*)'|"(.*)"|(.*))/giu,Q=e=>{process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";const o=[];return null==e||e.forEach((e=>{if(F.test(e)){const[o,t]=e.split("=");process.env[o]=t,(0,S.info)(`\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a${o}=${t}`)}else o.push(e)})),o},R=()=>{N(),process.argv.length>2?(h.program.version(b.default.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),h.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:o})=>{if(I(),(0,S.ready)("yolk init \u5f00\u59cb"),e){const t=".yolk",i=(0,d.join)(x,t);(0,m.existsSync)(i)&&(0,S.rimrafSync)(i)&&(0,S.ready)(`\u7f13\u5b58\u5220\u9664 success! ${i}`),(0,S.execCommand)({command:"git",args:["clone","-b","master","--depth","1",e,t].concat(o)}),k(x,i)}else $(x)})),h.program.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:o})=>{I();const t=Q(o);w()?C()?(0,S.execCommand)({command:"taro",args:["build","--type","tt","--watch"].concat(t)}):q()?(0,S.execCommand)({command:"taro",args:["build","--type","alipay","--watch"].concat(t)}):(0,S.execCommand)({command:"taro",args:["build","--type","weapp","--watch"].concat(t)}):e?(0,S.execCommand)({command:"dumi",args:["dev"].concat(t)}):O()?(0,S.execCommand)({command:"max",args:["dev"].concat(t)}):(0,S.execCommand)({command:"umi",args:["dev"].concat(t)})})),h.program.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:o})=>{I();const t=Q(o);w()?C()?(0,S.execCommand)({command:"taro",args:["build","--type","tt"].concat(t)}):q()?(0,S.execCommand)({command:"taro",args:["build","--type","alipay"].concat(t)}):(0,S.execCommand)({command:"taro",args:["build","--type","weapp"].concat(t)}):e?(0,S.execCommand)({command:"dumi",args:["build"].concat(t)}):O()?(0,S.execCommand)({command:"max",args:["setup"].concat(t),complete:()=>(0,S.execCommand)({command:"max",args:["build"].concat(t)}),exit:!1}):(0,S.execCommand)({command:"umi",args:["build"].concat(t)})})),h.program.command("pre-commit").description("\u6267\u884ccommit hook").action(D),_(h.program.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((e=>{if(w())if(C());else if(q());else{const{appid:o,options:{project:t,version:i,desc:r,setting:n,robot:a}}=E(e);(0,S.info)(`${o} \u4e0a\u4f20\u5f00\u59cb`),g.upload({project:t,version:i,desc:r,setting:n,robot:a,onProgressUpdate:e=>{if((0,l.isString)(e))(0,S.info)(`task: ${e}`);else{const{status:o,message:t}=e;(0,S.info)(`task(${o}): ${t}`)}}}).then((()=>{(0,S.ready)(`${o} \u4e0a\u4f20\u5b8c\u6210`)}))}else(0,S.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),_(h.program.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((e=>{if(w())if(C());else if(q());else{const{appid:o,options:{project:t,version:i,desc:r,setting:n,robot:a,qrcodeFormat:c,qrcodeOutputDest:s,pagePath:m,searchQuery:p}}=E(e);(0,S.info)(`${o} \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb`),g.preview({project:t,version:i,desc:r,setting:n,robot:a,qrcodeFormat:c,qrcodeOutputDest:s,pagePath:m,searchQuery:p,onProgressUpdate:e=>{if((0,l.isString)(e))(0,S.info)(`task: ${e}`);else{const{status:o,message:t}=e;(0,S.info)(`task(${o}): ${t}`)}}}).then((()=>{(0,S.ready)(`${o} \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210`)}))}else(0,S.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),h.program.parse(process.argv)):(0,S.breakExit)()};R();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baic/yolk-cli",
3
- "version": "2.1.0-alpha.212",
3
+ "version": "2.1.0-alpha.214",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/303394539/yolk.git"
@@ -25,7 +25,7 @@
25
25
  "prebundle": "father prebundle"
26
26
  },
27
27
  "dependencies": {
28
- "@baic/yolk-prebundle": "^2.1.0-alpha.212",
28
+ "@baic/yolk-prebundle": "^2.1.0-alpha.214",
29
29
  "@democrance/imagemin-lint-staged": "~2.4.x",
30
30
  "@types/inquirer": "8.x",
31
31
  "@types/lint-staged": "~13.x",
@@ -46,7 +46,6 @@
46
46
  "stylelint": "14.x"
47
47
  },
48
48
  "devDependencies": {
49
- "@babel/runtime": "~7.x",
50
49
  "@types/mustache": "~4.2.x",
51
50
  "commander": "~12.x",
52
51
  "mustache": "~4.2.x",
@@ -59,5 +58,5 @@
59
58
  "publishConfig": {
60
59
  "access": "public"
61
60
  },
62
- "gitHead": "531fc6865ce7330c0469618a443f822a44916316"
61
+ "gitHead": "9d25b9b4e483dd6dc4743895f34e7da27851739d"
63
62
  }
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ extends: '@baic/eslint-config-yolk',
3
+ parserOptions: {
4
+ project: './tsconfig.json',
5
+ tsconfigRootDir: __dirname,
6
+ },
7
+ };
@@ -0,0 +1,37 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ node_modules/
5
+ npm-debug.log*
6
+ npm-error.log*
7
+ package-lock.json
8
+ yarn.lock
9
+ yarn-debug.log*
10
+ yarn-error.log*
11
+ pnpm-lock.yaml
12
+
13
+ # production
14
+ /dist
15
+ /build
16
+
17
+ # misc
18
+ .DS_Store
19
+
20
+ # umi
21
+ /src/.umi
22
+ /src/.umi-production
23
+ /src/.umi-test
24
+ /.env.local
25
+ coverage
26
+ .eslintcache
27
+ .stylelintcache
28
+ *less.d.ts*
29
+ *scss.d.ts*
30
+ .mfsu*
31
+
32
+ # ide
33
+ .vscode
34
+
35
+ # h5+app
36
+ /h5+app/unpackage/cache
37
+ /h5+app/unpackage/release
@@ -0,0 +1,2 @@
1
+ strict-peer-dependencies=false
2
+ shamefully-hoist=true
@@ -0,0 +1,12 @@
1
+ **/*.md
2
+ **/*.svg
3
+ **/*.ejs
4
+ **/*.html
5
+ package-lock.json
6
+ yarn.lock
7
+ yarn-debug.log
8
+ yarn-error.log
9
+ pnpm-lock.yaml
10
+ .umi
11
+ .umi-production
12
+ .umi-test
@@ -0,0 +1 @@
1
+ module.exports = require('@baic/prettier-config-yolk');
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "@baic/stylelint-config-yolk"
3
+ }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from '@baic/yolk-umi';
2
+
3
+ export default defineConfig({
4
+ title: '{{ projectName }}',
5
+ hd: {},
6
+ 'uni-app': {},
7
+ });
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Baic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,34 @@
1
+ # web
2
+
3
+ ## Getting Started
4
+
5
+ Install dependencies,
6
+
7
+ {{ #dependenciesInstallType }}
8
+
9
+ ```bash
10
+ $ {{ dependenciesInstallType }} install
11
+ ```
12
+
13
+ {{ /dependenciesInstallType }}
14
+ {{ ^dependenciesInstallType }}
15
+
16
+ ```bash
17
+ $ pnpm install
18
+ ```
19
+
20
+ {{ /dependenciesInstallType }}
21
+
22
+ Start the dev server,
23
+
24
+ ```bash
25
+ $ npm start
26
+ ```
27
+
28
+ Build,
29
+
30
+ ```bash
31
+ $ npm run build
32
+ ```
33
+
34
+ [查阅文档](https://303394539.github.io/yolk-docs/)
@@ -0,0 +1,16 @@
1
+ {
2
+ "private": true,
3
+ "name": "{{ projectName }}",
4
+ "scripts": {
5
+ "start": "yolk start",
6
+ "build": "yolk build"
7
+ },
8
+ "dependencies": {
9
+ "@baic/preset-yolk-umi-mobile": "~{{ yolkVersion }}"
10
+ },
11
+ "pnpm": {
12
+ "peerDependencyRules": {
13
+ "ignoreMissing": "*"
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,19 @@
1
+ import '@baic/yolk-mobile/es/style/index.less';
2
+
3
+ import { Provider } from '@baic/yolk-mobile';
4
+
5
+ import request from '@/common/request';
6
+
7
+ export function rootContainer(container: React.ReactNode) {
8
+ return (
9
+ <Provider
10
+ request={request}
11
+ iconfontScriptUrl={[
12
+ '//at.alicdn.com/t/font_1788044_0dwu4guekcwr.js',
13
+ '//at.alicdn.com/t/font_1788592_a5xf2bdic3u.js',
14
+ ]}
15
+ >
16
+ {container}
17
+ </Provider>
18
+ );
19
+ }
@@ -0,0 +1,3 @@
1
+ import { Request } from '@baic/yolk-mobile';
2
+
3
+ export default new Request();
@@ -0,0 +1,7 @@
1
+ import { Util } from '@baic/yolk-mobile';
2
+
3
+ const util = {
4
+ ...Util,
5
+ };
6
+
7
+ export default util;
@@ -0,0 +1,3 @@
1
+ #yolk-app {
2
+ height: 100%;
3
+ }
@@ -0,0 +1,3 @@
1
+ import { Outlet } from 'umi';
2
+
3
+ export default () => <Outlet />;
@@ -0,0 +1,9 @@
1
+ import { Result } from 'antd-mobile';
2
+
3
+ export default () => (
4
+ <Result
5
+ title="404"
6
+ description="对不起,您访问的页面不存在。"
7
+ status="warning"
8
+ />
9
+ );
@@ -0,0 +1,3 @@
1
+ import { BarCode } from '@baic/yolk-mobile';
2
+
3
+ export default () => <BarCode value="https://www.baidu.com" />;
@@ -0,0 +1,17 @@
1
+ import { Iconfont, Provider } from '@baic/yolk-mobile';
2
+
3
+ export default () => {
4
+ return (
5
+ <Provider
6
+ iconfontScriptUrl={[
7
+ '//at.alicdn.com/t/font_1788044_0dwu4guekcwr.js',
8
+ '//at.alicdn.com/t/font_1788592_a5xf2bdic3u.js',
9
+ ]}
10
+ >
11
+ <Iconfont type="icon-javascript" />
12
+ <Iconfont type="icon-java" />
13
+ <Iconfont type="icon-shoppingcart" />
14
+ <Iconfont type="icon-python" />
15
+ </Provider>
16
+ );
17
+ };
@@ -0,0 +1,15 @@
1
+ import { Form, Input, useForm } from '@baic/yolk-mobile';
2
+
3
+ export default () => {
4
+ const [form] = useForm();
5
+ const { createFormItem } = form;
6
+ return (
7
+ <Form form={form}>
8
+ {createFormItem({
9
+ label: 'Input',
10
+ name: 'Input',
11
+ rules: 'required',
12
+ })(<Input maxLength={5} />)}
13
+ </Form>
14
+ );
15
+ };
@@ -0,0 +1,11 @@
1
+ import { List } from '@baic/yolk-mobile';
2
+
3
+ export default () => {
4
+ return (
5
+ <List header="基础用法">
6
+ <List.Item>1</List.Item>
7
+ <List.Item>2</List.Item>
8
+ <List.Item>3</List.Item>
9
+ </List>
10
+ );
11
+ };
@@ -0,0 +1,29 @@
1
+ import { Image } from 'antd-mobile';
2
+
3
+ import { List } from '@baic/yolk-mobile';
4
+
5
+ import mock from './mock';
6
+
7
+ export default () => {
8
+ return (
9
+ <List header="函数渲染" data={mock}>
10
+ {({ name, avatar, description }) => (
11
+ <List.Item
12
+ key={name}
13
+ prefix={
14
+ <Image
15
+ src={avatar}
16
+ style={{ borderRadius: 20 }}
17
+ fit="cover"
18
+ width={40}
19
+ height={40}
20
+ />
21
+ }
22
+ description={description}
23
+ >
24
+ {name}
25
+ </List.Item>
26
+ )}
27
+ </List>
28
+ );
29
+ };
@@ -0,0 +1,29 @@
1
+ import { Image } from 'antd-mobile';
2
+
3
+ import { List } from '@baic/yolk-mobile';
4
+
5
+ import mock from './mock';
6
+
7
+ export default () => {
8
+ return (
9
+ <List header="拖拽" drag data={mock}>
10
+ {({ name, avatar, description }) => (
11
+ <List.Item
12
+ key={name}
13
+ prefix={
14
+ <Image
15
+ src={avatar}
16
+ style={{ borderRadius: 20 }}
17
+ fit="cover"
18
+ width={40}
19
+ height={40}
20
+ />
21
+ }
22
+ description={description}
23
+ >
24
+ {name}
25
+ </List.Item>
26
+ )}
27
+ </List>
28
+ );
29
+ };
@@ -0,0 +1,54 @@
1
+ import { useCallback, useMemo } from 'react';
2
+
3
+ import { Image } from 'antd-mobile';
4
+
5
+ import { List, ListVirtualizedScrollEvent } from '@baic/yolk-mobile';
6
+
7
+ const rowCount = 100000;
8
+
9
+ const item = {
10
+ avatar:
11
+ 'https://images.unsplash.com/photo-1548532928-b34e3be62fc6?ixlib=rb-1.2.1&q=80&fm=jpg&crop=faces&fit=crop&h=200&w=200&ixid=eyJhcHBfaWQiOjE3Nzg0fQ',
12
+ name: 'Novalee Spicer',
13
+ description: 'Deserunt dolor ea eaque eos',
14
+ };
15
+
16
+ const mock = Array(rowCount).fill(item);
17
+
18
+ export default () => {
19
+ const onScrollHandler = useCallback(async (e: ListVirtualizedScrollEvent) => {
20
+ console.log(e);
21
+ }, []);
22
+ const virtualizedMemo = useMemo(
23
+ () => ({
24
+ height: 500,
25
+ rowHeight: 60,
26
+ onScroll: onScrollHandler,
27
+ }),
28
+ [onScrollHandler],
29
+ );
30
+ return (
31
+ <List header="虚拟化" virtualized={virtualizedMemo} data={mock}>
32
+ {({ name, avatar, description }, index, e) => {
33
+ return (
34
+ <List.Item
35
+ key={e?.key}
36
+ style={e?.style}
37
+ prefix={
38
+ <Image
39
+ src={avatar}
40
+ style={{ borderRadius: 20 }}
41
+ fit="cover"
42
+ width={40}
43
+ height={40}
44
+ />
45
+ }
46
+ description={description}
47
+ >
48
+ {name} {index}
49
+ </List.Item>
50
+ );
51
+ }}
52
+ </List>
53
+ );
54
+ };
@@ -0,0 +1,30 @@
1
+ export default [
2
+ {
3
+ id: '1',
4
+ avatar:
5
+ 'https://images.unsplash.com/photo-1548532928-b34e3be62fc6?ixlib=rb-1.2.1&q=80&fm=jpg&crop=faces&fit=crop&h=200&w=200&ixid=eyJhcHBfaWQiOjE3Nzg0fQ',
6
+ name: 'Novalee Spicer',
7
+ description: 'Deserunt dolor ea eaque eos',
8
+ },
9
+ {
10
+ id: '2',
11
+ avatar:
12
+ 'https://images.unsplash.com/photo-1493666438817-866a91353ca9?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&fit=crop&h=200&w=200&s=b616b2c5b373a80ffc9636ba24f7a4a9',
13
+ name: 'Sara Koivisto',
14
+ description: 'Animi eius expedita, explicabo',
15
+ },
16
+ {
17
+ id: '3',
18
+ avatar:
19
+ 'https://images.unsplash.com/photo-1542624937-8d1e9f53c1b9?ixlib=rb-1.2.1&q=80&fm=jpg&crop=faces&fit=crop&h=200&w=200&ixid=eyJhcHBfaWQiOjE3Nzg0fQ',
20
+ name: 'Marco Gregg',
21
+ description: 'Ab animi cumque eveniet ex harum nam odio omnis',
22
+ },
23
+ {
24
+ id: '4',
25
+ avatar:
26
+ 'https://images.unsplash.com/photo-1546967191-fdfb13ed6b1e?ixlib=rb-1.2.1&q=80&fm=jpg&crop=faces&fit=crop&h=200&w=200&ixid=eyJhcHBfaWQiOjE3Nzg0fQ',
27
+ name: 'Edith Koenig',
28
+ description: 'Commodi earum exercitationem id numquam vitae',
29
+ },
30
+ ];
@@ -0,0 +1,11 @@
1
+ import { Loading } from '@baic/yolk-mobile';
2
+
3
+ export default () => (
4
+ <div
5
+ style={{
6
+ position: 'relative',
7
+ }}
8
+ >
9
+ <Loading />
10
+ </div>
11
+ );
@@ -0,0 +1,15 @@
1
+ import { Form, NumberInput, useForm } from '@baic/yolk-mobile';
2
+
3
+ export default () => {
4
+ const [form] = useForm();
5
+ const { createFormItem } = form;
6
+ return (
7
+ <Form form={form}>
8
+ {createFormItem({
9
+ label: 'default',
10
+ name: 'NumberInput',
11
+ rules: 'required',
12
+ })(<NumberInput />)}
13
+ </Form>
14
+ );
15
+ };
@@ -0,0 +1,15 @@
1
+ import { Form, NumberInput, useForm } from '@baic/yolk-mobile';
2
+
3
+ export default () => {
4
+ const [form] = useForm();
5
+ const { createFormItem } = form;
6
+ return (
7
+ <Form form={form}>
8
+ {createFormItem({
9
+ label: 'decimal',
10
+ name: 'NumberInput',
11
+ rules: 'required',
12
+ })(<NumberInput decimal={3} />)}
13
+ </Form>
14
+ );
15
+ };