@baic/yolk-cli 2.1.0-alpha.233 → 2.1.0-alpha.234
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/_util.js +105 -1
- package/es/index.js +11 -1
- package/es/yolk.js +479 -1
- package/lib/_util.js +132 -1
- package/lib/index.js +4 -1
- package/lib/yolk.js +458 -1
- package/package.json +23 -23
- package/templates/miniprogram/.gitignore.tpl +0 -3
- package/templates/umi-mobile/.gitignore.tpl +0 -3
- package/templates/umi-mobile-h5+app/.gitignore.tpl +0 -3
- package/templates/umi-mobile-native/.gitignore.tpl +0 -3
- package/templates/umi-mobile-uni-app/.gitignore.tpl +0 -3
- package/templates/umi-web/.gitignore.tpl +0 -3
- package/templates/umi-web-screen/.gitignore.tpl +0 -3
- package/es/.lintstagedrc.js +0 -76
- package/es/.prettierrc.js +0 -24
- package/lib/.lintstagedrc.js +0 -76
- package/lib/.prettierrc.js +0 -24
package/es/_util.js
CHANGED
|
@@ -1 +1,105 @@
|
|
|
1
|
-
|
|
1
|
+
var m = /* @__PURE__ */ ((t) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(t, {
|
|
2
|
+
get: (e, o) => (typeof require < "u" ? require : e)[o]
|
|
3
|
+
}) : t)(function(t) {
|
|
4
|
+
if (typeof require < "u")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw new Error('Dynamic require of "' + t + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// src/_util.ts
|
|
10
|
+
import { spawn as k } from "node:child_process";
|
|
11
|
+
import r from "node:fs";
|
|
12
|
+
import a from "node:path";
|
|
13
|
+
import {
|
|
14
|
+
rimrafSync as u,
|
|
15
|
+
windowsSync as d
|
|
16
|
+
} from "@baic/yolk-prebundle/compiled/rimraf";
|
|
17
|
+
import c from "chalk";
|
|
18
|
+
import { globSync as x } from "glob";
|
|
19
|
+
import { program as h } from "../compiled/commander";
|
|
20
|
+
var i = process.cwd(), l = console, p = "utf-8", C = (t) => t && l.log(c.yellow("warn -"), t), P = (t) => t && l.log(c.red("error -"), t), j = (t) => t && l.log(c.green("ready -"), t), _ = (t) => t && l.log(c.blue("info -"), t), S = () => process.platform === "win32", N = (t) => S() ? `${t}.cmd` : t, $ = (t) => S() ? d(t) : u(t), b = () => {
|
|
21
|
+
j("yolk complete!"), process.exit(0);
|
|
22
|
+
}, w = () => {
|
|
23
|
+
C("yolk break!"), process.exit(0);
|
|
24
|
+
}, G = ({
|
|
25
|
+
command: t,
|
|
26
|
+
args: e,
|
|
27
|
+
complete: o,
|
|
28
|
+
close: n,
|
|
29
|
+
exit: s = !0
|
|
30
|
+
}) => {
|
|
31
|
+
let f = k(N(t), e || [], {
|
|
32
|
+
stdio: "inherit"
|
|
33
|
+
}).on("close", (y) => {
|
|
34
|
+
y ? (n && n(), P("yolk close!"), process.exit(y)) : (o && o(), s && b());
|
|
35
|
+
});
|
|
36
|
+
process.on("SIGINT", () => {
|
|
37
|
+
h.exitOverride(), f.kill(), w();
|
|
38
|
+
});
|
|
39
|
+
}, O = () => {
|
|
40
|
+
let t = x("*.yolkrc*", {
|
|
41
|
+
cwd: i,
|
|
42
|
+
dot: !0
|
|
43
|
+
});
|
|
44
|
+
if (!t.length)
|
|
45
|
+
return {};
|
|
46
|
+
let e = a.join(i, t[0]);
|
|
47
|
+
if (r.existsSync(e))
|
|
48
|
+
try {
|
|
49
|
+
return JSON.parse(r.readFileSync(e, p)) || {};
|
|
50
|
+
} catch (o) {
|
|
51
|
+
return o(o.message || ".yolkrc转换错误"), {};
|
|
52
|
+
}
|
|
53
|
+
else
|
|
54
|
+
return {};
|
|
55
|
+
}, q = () => {
|
|
56
|
+
let t = a.join(i, "project.config.json");
|
|
57
|
+
if (r.existsSync(t))
|
|
58
|
+
try {
|
|
59
|
+
return JSON.parse(r.readFileSync(t, p)) || {};
|
|
60
|
+
} catch (e) {
|
|
61
|
+
return e(e.message || "project.config.json转换错误"), {};
|
|
62
|
+
}
|
|
63
|
+
else
|
|
64
|
+
return {};
|
|
65
|
+
}, B = () => {
|
|
66
|
+
let t = a.join(i, "package.json");
|
|
67
|
+
if (r.existsSync(t))
|
|
68
|
+
try {
|
|
69
|
+
return JSON.parse(r.readFileSync(t, p)) || {};
|
|
70
|
+
} catch (e) {
|
|
71
|
+
return e(e.message || "package.json转换错误"), {};
|
|
72
|
+
}
|
|
73
|
+
else
|
|
74
|
+
return {};
|
|
75
|
+
}, g = (t) => {
|
|
76
|
+
let e = O(), o = "";
|
|
77
|
+
try {
|
|
78
|
+
o = m.resolve(`@baic/${t}-config-yolk`);
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
let n = x(`*.${t}rc*`, {
|
|
82
|
+
cwd: i,
|
|
83
|
+
dot: !0
|
|
84
|
+
}), s = n == null ? void 0 : n[0];
|
|
85
|
+
return e.strict === !1 && s && r.existsSync(s) ? s : r.existsSync(o) ? o : s;
|
|
86
|
+
}, D = () => g("eslint"), T = () => g("stylelint"), W = () => g("prettier"), z = () => g("biome");
|
|
87
|
+
export {
|
|
88
|
+
p as ENCODING,
|
|
89
|
+
w as breakExit,
|
|
90
|
+
b as completeExit,
|
|
91
|
+
P as error,
|
|
92
|
+
G as execCommand,
|
|
93
|
+
z as getBiomeConfigPath,
|
|
94
|
+
g as getConfigFilePath,
|
|
95
|
+
D as getEsLintConfigPath,
|
|
96
|
+
B as getPackageJSON,
|
|
97
|
+
W as getPrettierConfigPath,
|
|
98
|
+
q as getProjectConfigJSON,
|
|
99
|
+
T as getStyleLintConfigPath,
|
|
100
|
+
O as getYolkConfig,
|
|
101
|
+
_ as info,
|
|
102
|
+
j as ready,
|
|
103
|
+
$ as rimrafSync,
|
|
104
|
+
C as warn
|
|
105
|
+
};
|
package/es/index.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
require
|
|
2
|
+
var r = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, {
|
|
3
|
+
get: (i, n) => (typeof require < "u" ? require : i)[n]
|
|
4
|
+
}) : e)(function(e) {
|
|
5
|
+
if (typeof require < "u")
|
|
6
|
+
return require.apply(this, arguments);
|
|
7
|
+
throw new Error('Dynamic require of "' + e + '" is not supported');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// src/index.ts
|
|
11
|
+
r("../compiled/v8-compile-cache");
|
|
12
|
+
r("./yolk");
|
package/es/yolk.js
CHANGED
|
@@ -1,2 +1,480 @@
|
|
|
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 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"node:child_process";import{chmodSync as s,copyFileSync as p,existsSync as u,readFileSync as d,statSync as l,writeFileSync as f}from"node:fs";import g from"node:os";import{basename as v,dirname as y,join as h,relative as F}from"node: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(!l(o).isDirectory())if(t.endsWith(".tpl")){var r=d(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(d(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&&d(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=d(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,d=e.mPagePath,l=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:d,searchQuery:l}}}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,d=n.pagePath,l=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:d,searchQuery:l,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.command("exec").description("\u6267\u884cts\u6587\u4ef6").argument("<path>","\u6267\u884c\u7684ts\u6587\u4ef6").action((function(e){B({command:"tsx",args:[e]})})),w.parse(process.argv)):x()};ee();
|
|
2
|
+
var C = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, {
|
|
3
|
+
get: (o, t) => (typeof require < "u" ? require : o)[t]
|
|
4
|
+
}) : e)(function(e) {
|
|
5
|
+
if (typeof require < "u")
|
|
6
|
+
return require.apply(this, arguments);
|
|
7
|
+
throw new Error('Dynamic require of "' + e + '" is not supported');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// src/yolk.ts
|
|
11
|
+
import { execSync as A } from "node:child_process";
|
|
12
|
+
import {
|
|
13
|
+
chmodSync as M,
|
|
14
|
+
copyFileSync as te,
|
|
15
|
+
existsSync as l,
|
|
16
|
+
readFileSync as q,
|
|
17
|
+
statSync as oe,
|
|
18
|
+
writeFileSync as R
|
|
19
|
+
} from "node:fs";
|
|
20
|
+
import x from "node:os";
|
|
21
|
+
import { basename as E, dirname as U, join as a, relative as ie } from "node:path";
|
|
22
|
+
import H from "lodash/floor";
|
|
23
|
+
import B from "lodash/isString";
|
|
24
|
+
import { globSync as ne } from "glob";
|
|
25
|
+
import re from "inquirer";
|
|
26
|
+
import * as P from "miniprogram-ci";
|
|
27
|
+
import { mkdirpSync as T } from "mkdirp";
|
|
28
|
+
import { program as v } from "../compiled/commander";
|
|
29
|
+
import se from "../compiled/mustache";
|
|
30
|
+
import O from "../package.json";
|
|
31
|
+
import {
|
|
32
|
+
breakExit as ae,
|
|
33
|
+
ENCODING as k,
|
|
34
|
+
error as J,
|
|
35
|
+
execCommand as n,
|
|
36
|
+
getPackageJSON as me,
|
|
37
|
+
getProjectConfigJSON as ce,
|
|
38
|
+
getYolkConfig as pe,
|
|
39
|
+
info as s,
|
|
40
|
+
ready as m,
|
|
41
|
+
rimrafSync as X,
|
|
42
|
+
warn as w
|
|
43
|
+
} from "./_util";
|
|
44
|
+
var d = process.cwd(), S = "##### CREATED BY YOLK #####", z = (e, o, t) => {
|
|
45
|
+
re.prompt([
|
|
46
|
+
{
|
|
47
|
+
type: "list",
|
|
48
|
+
name: "type",
|
|
49
|
+
message: "选择模版",
|
|
50
|
+
default: "web",
|
|
51
|
+
choices: [
|
|
52
|
+
{ name: "web template(umi framework)", value: "umi-web" },
|
|
53
|
+
{
|
|
54
|
+
name: "web big screen template(umi framework)",
|
|
55
|
+
value: "umi-web-screen"
|
|
56
|
+
},
|
|
57
|
+
{ name: "mobile template(umi framework)", value: "umi-mobile" },
|
|
58
|
+
{
|
|
59
|
+
name: "mobile HBuilderX h5+app template(umi framework)",
|
|
60
|
+
value: "umi-mobile-h5+app"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "mobile HBuilderX uni-app template(umi framework)",
|
|
64
|
+
value: "umi-mobile-uni-app"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "mobile native template(umi framework)",
|
|
68
|
+
value: "umi-mobile-native"
|
|
69
|
+
},
|
|
70
|
+
{ name: "miniprogram template", value: "miniprogram" }
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: "input",
|
|
75
|
+
name: "projectName",
|
|
76
|
+
message: "项目名称",
|
|
77
|
+
default: E(E(process.cwd()))
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
type: "list",
|
|
81
|
+
name: "dependenciesInstallType",
|
|
82
|
+
message: "选择依赖安装方式(默认:pnpm,推荐:pnpm)",
|
|
83
|
+
default: "default",
|
|
84
|
+
choices: [
|
|
85
|
+
{ name: "默认安装", value: "default" },
|
|
86
|
+
{ name: "跳过安装", value: !1 },
|
|
87
|
+
{ name: "pnpm install", value: "pnpm" },
|
|
88
|
+
{ name: "yarn install", value: "yarn" },
|
|
89
|
+
{ name: "npm install", value: "npm" }
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
]).then(({ type: i, projectName: c, dependenciesInstallType: g }) => {
|
|
93
|
+
let u = {
|
|
94
|
+
projectName: c,
|
|
95
|
+
dependenciesInstallType: g === "default" ? "pnpm" : g,
|
|
96
|
+
yolkVersion: O.version
|
|
97
|
+
};
|
|
98
|
+
if (i === "umi-mobile-uni-app") {
|
|
99
|
+
w("暂不支持");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
let r = o || a(__dirname, `../templates/${i}`);
|
|
103
|
+
if (m(`复制模版 ${E(r)}`), ne("**/*", {
|
|
104
|
+
cwd: r,
|
|
105
|
+
dot: !0,
|
|
106
|
+
ignore: [
|
|
107
|
+
"**/node_modules/**",
|
|
108
|
+
"**/.git/**",
|
|
109
|
+
"**/.DS_Store",
|
|
110
|
+
"**/.idea/**"
|
|
111
|
+
]
|
|
112
|
+
}).forEach((f) => {
|
|
113
|
+
if (!r)
|
|
114
|
+
return;
|
|
115
|
+
let y = a(r, f);
|
|
116
|
+
if (!oe(y).isDirectory())
|
|
117
|
+
if (f.endsWith(".tpl")) {
|
|
118
|
+
let p = q(y, k), h = a(e, f.replace(/\.tpl$/, "")), b = se.render(p, u);
|
|
119
|
+
T(U(h)), m(`创建 ${ie(e, h)}`), R(h, b, k);
|
|
120
|
+
} else {
|
|
121
|
+
m(`创建 ${f}`);
|
|
122
|
+
let p = a(e, f);
|
|
123
|
+
T(U(p)), te(y, p);
|
|
124
|
+
}
|
|
125
|
+
}), m("复制模版 success!"), t && l(r) && X(r) && m(`缓存删除 success! ${E(r || "")}`), g)
|
|
126
|
+
switch (m("初始化依赖包"), g) {
|
|
127
|
+
case "default":
|
|
128
|
+
case "pnpm":
|
|
129
|
+
n({
|
|
130
|
+
command: "pnpm",
|
|
131
|
+
args: ["install"]
|
|
132
|
+
});
|
|
133
|
+
break;
|
|
134
|
+
case "yarn":
|
|
135
|
+
n({
|
|
136
|
+
command: "yarn",
|
|
137
|
+
args: ["install"]
|
|
138
|
+
});
|
|
139
|
+
break;
|
|
140
|
+
case "npm":
|
|
141
|
+
n({
|
|
142
|
+
command: "npm",
|
|
143
|
+
args: ["install"]
|
|
144
|
+
});
|
|
145
|
+
break;
|
|
146
|
+
default:
|
|
147
|
+
}
|
|
148
|
+
m("可查阅<<https://303394539.github.io/yolk-docs/>>了解相关文档");
|
|
149
|
+
});
|
|
150
|
+
}, le = (e, o) => z(e, o, !0), N = () => l(a(d, "project.config.json")), G = () => {
|
|
151
|
+
let e = l(a(d, "node_modules/.bin/max"));
|
|
152
|
+
if (!e)
|
|
153
|
+
try {
|
|
154
|
+
e = l(C.resolve("@umijs/max"));
|
|
155
|
+
} catch {
|
|
156
|
+
}
|
|
157
|
+
if (!e)
|
|
158
|
+
try {
|
|
159
|
+
e = /umi@4\.(\d+)\.(\d+)/.test(A("umi -v").toString());
|
|
160
|
+
} catch {
|
|
161
|
+
}
|
|
162
|
+
if (!e) {
|
|
163
|
+
let o = a(d, "node_modules", "umi", "package.json");
|
|
164
|
+
if (l(o))
|
|
165
|
+
try {
|
|
166
|
+
let t = JSON.parse(q(o, k)) || {};
|
|
167
|
+
e = t.version && +t.version.split(".")[0] > 3;
|
|
168
|
+
} catch {
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return e;
|
|
172
|
+
}, Z = () => {
|
|
173
|
+
let e = a(d, "project.config.json");
|
|
174
|
+
return l(e) ? C(e).appid : "";
|
|
175
|
+
}, D = () => l(a(d, "project.tt.json")) && Z().indexOf("tt") === 0, _ = () => Z().indexOf("20") === 0, de = () => {
|
|
176
|
+
let e = a(d, ".git/"), o = a(d, ".git/hooks"), t = a(o, "pre-commit"), i = l(e), c = l(t), g = c && q(t, k).includes(S);
|
|
177
|
+
if (i)
|
|
178
|
+
if (c) {
|
|
179
|
+
if (!g) {
|
|
180
|
+
try {
|
|
181
|
+
M(t, "777");
|
|
182
|
+
} catch (r) {
|
|
183
|
+
J(`chmod ${t} failed: ${r.message}`);
|
|
184
|
+
}
|
|
185
|
+
let u = q(t).toString();
|
|
186
|
+
R(
|
|
187
|
+
t,
|
|
188
|
+
[
|
|
189
|
+
u,
|
|
190
|
+
u.includes("#!/") ? "" : "#!/bin/sh",
|
|
191
|
+
S,
|
|
192
|
+
"npx yolk pre-commit",
|
|
193
|
+
"RESULT=$?",
|
|
194
|
+
"[ $RESULT -ne 0 ] && exit 1",
|
|
195
|
+
"exit 0",
|
|
196
|
+
S
|
|
197
|
+
].join(x.EOL),
|
|
198
|
+
k
|
|
199
|
+
), m("write pre-commit hook");
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
T(o), R(
|
|
203
|
+
t,
|
|
204
|
+
[
|
|
205
|
+
"#!/bin/sh",
|
|
206
|
+
S,
|
|
207
|
+
"npx yolk pre-commit",
|
|
208
|
+
"RESULT=$?",
|
|
209
|
+
"[ $RESULT -ne 0 ] && exit 1",
|
|
210
|
+
"exit 0",
|
|
211
|
+
S
|
|
212
|
+
].join(x.EOL),
|
|
213
|
+
k
|
|
214
|
+
), m("create pre-commit hook");
|
|
215
|
+
try {
|
|
216
|
+
M(t, "777");
|
|
217
|
+
} catch (u) {
|
|
218
|
+
J(`chmod ${t} failed: ${u.message}`);
|
|
219
|
+
}
|
|
220
|
+
m("write pre-commit hook");
|
|
221
|
+
}
|
|
222
|
+
}, ge = async () => {
|
|
223
|
+
let e = pe(), o = e.strict !== !1, t = e.eslintIgnore, i = e.stylelintIgnore;
|
|
224
|
+
w("统一代码规范,进行严格的语法检查。"), o && (w("git commit 禁止 lint 的 ignore 行为"), i && w(`通过 .yolkrc 配置 stylelintIgnore: ${i}。`), t && w(`通过 .yolkrc 配置 eslintIgnore: ${t}。`)), n({
|
|
225
|
+
command: "lint-staged",
|
|
226
|
+
args: ["-c", C.resolve("./.lintstagedrc")]
|
|
227
|
+
});
|
|
228
|
+
}, V = ({
|
|
229
|
+
mAppid: e,
|
|
230
|
+
mProject: o,
|
|
231
|
+
mPrivateKeyPath: t,
|
|
232
|
+
mVersion: i,
|
|
233
|
+
mDesc: c,
|
|
234
|
+
mRobot: g,
|
|
235
|
+
mQrcodeFormat: u,
|
|
236
|
+
mQrcodeOutputDest: r,
|
|
237
|
+
mPagePath: $,
|
|
238
|
+
mSearchQuery: f
|
|
239
|
+
}) => {
|
|
240
|
+
let y = l(a(d, ".git")) ? A("git log -1 --pretty=format:%H").toString() : "", p = ce(), h = e || p.appid, b = o || a(d, "dist"), j = t || a(d, `private.${h}.key`);
|
|
241
|
+
if (l(b))
|
|
242
|
+
if (l(j)) {
|
|
243
|
+
let F = me(), Q = i || F.version || p.version || "1.0.0", K = c || F.description || p.description, L = `${y ? ` commit: ${y};` : ""}${K ? ` description: ${K};` : ""}`;
|
|
244
|
+
y && s(`commit: ${y}`), s(`dist: ${b}`), s(`key: ${j}`), s(`appid: ${h}`), s(`version: ${Q}`), s(`desc: ${L}`);
|
|
245
|
+
let ee = new P.Project({
|
|
246
|
+
appid: h,
|
|
247
|
+
type: "miniProgram",
|
|
248
|
+
projectPath: b,
|
|
249
|
+
privateKeyPath: j,
|
|
250
|
+
ignores: [
|
|
251
|
+
"node_modules/**/*",
|
|
252
|
+
"**/*.txt",
|
|
253
|
+
"**/*.key",
|
|
254
|
+
"**/*.less",
|
|
255
|
+
"**/*.sass",
|
|
256
|
+
"**/*.scss",
|
|
257
|
+
"**/*.css",
|
|
258
|
+
"**/*.jsx",
|
|
259
|
+
"**/*.ts",
|
|
260
|
+
"**/*.tsx",
|
|
261
|
+
"**/*.md"
|
|
262
|
+
]
|
|
263
|
+
});
|
|
264
|
+
return {
|
|
265
|
+
appid: h,
|
|
266
|
+
options: {
|
|
267
|
+
project: ee,
|
|
268
|
+
version: Q,
|
|
269
|
+
desc: L,
|
|
270
|
+
setting: {
|
|
271
|
+
...p.setting,
|
|
272
|
+
es6: !1,
|
|
273
|
+
es7: !1,
|
|
274
|
+
minifyJS: !1,
|
|
275
|
+
minifyWXML: !1,
|
|
276
|
+
minifyWXSS: !1,
|
|
277
|
+
minify: !1
|
|
278
|
+
},
|
|
279
|
+
robot: g,
|
|
280
|
+
qrcodeFormat: u,
|
|
281
|
+
qrcodeOutputDest: r,
|
|
282
|
+
pagePath: $,
|
|
283
|
+
searchQuery: f
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
} else
|
|
287
|
+
throw Error(`没有找到上传密钥(${j})`);
|
|
288
|
+
else
|
|
289
|
+
throw Error(`没有找到dist目录(${b})`);
|
|
290
|
+
}, I = () => {
|
|
291
|
+
let e = "";
|
|
292
|
+
try {
|
|
293
|
+
e = A(`npm view ${O.name} version`, {
|
|
294
|
+
timeout: 3e3
|
|
295
|
+
}).toString().replace(/\n/g, "");
|
|
296
|
+
} catch {
|
|
297
|
+
}
|
|
298
|
+
s(
|
|
299
|
+
`yolk version: ${O.version}${e && e !== O.version ? `(last:${e})` : ""}`
|
|
300
|
+
), s(`node version: ${process.version}`), s(`platform: ${x.platform()}`), s(
|
|
301
|
+
`memory: ${H(x.freemem() / 1024 / 1024)} MB(${H(
|
|
302
|
+
x.totalmem() / 1024 / 1024
|
|
303
|
+
)} MB)`
|
|
304
|
+
);
|
|
305
|
+
}, W = (e) => e.option("--appid, --mAppid <appid>", "小程序appid").option("--project, --mProject <project>", "小程序上传工程目录").option(
|
|
306
|
+
"--privateKeyPath, --mPrivateKeyPath <privateKeyPath>",
|
|
307
|
+
"小程序上传key文件,默认:{当前目录}/private.{appid}.key"
|
|
308
|
+
).option("--version, --mVersion <version>", "小程序上传版本号").option("--desc, --mDesc <desc>", "小程序上传描述").option("--robot, --mRobot <robot>", "小程序上传ci机器人1~30").option(
|
|
309
|
+
"--qrcodeFormat, --mQrcodeFormat <qrcodeFormat>",
|
|
310
|
+
'小程序预览返回二维码文件的格式 "image" 或 "base64", 默认值 "terminal" 供调试用'
|
|
311
|
+
).option(
|
|
312
|
+
"--qrcodeOutputDest, --mQrcodeOutputDest <qrcodeOutputDest>",
|
|
313
|
+
"小程序预览二维码文件保存路径"
|
|
314
|
+
).option("--pagePath, --mPagePath <pagePath>", "小程序预览预览页面路径").option(
|
|
315
|
+
"--searchQuery, --mSearchQuery <searchQuery>",
|
|
316
|
+
"小程序预览预览页面路径启动参数"
|
|
317
|
+
), ue = /(\w+)=('(.*)'|"(.*)"|(.*))/giu, Y = (e) => {
|
|
318
|
+
process.env.DID_YOU_KNOW = "none", process.env.VITE_CJS_IGNORE_WARNING = "true";
|
|
319
|
+
let o = [];
|
|
320
|
+
return e == null || e.forEach((t) => {
|
|
321
|
+
if (ue.test(t)) {
|
|
322
|
+
let [i, c] = t.split("=");
|
|
323
|
+
process.env[i] = c, s(`设置环境变量:${i}=${c}`);
|
|
324
|
+
} else
|
|
325
|
+
o.push(t);
|
|
326
|
+
}), o;
|
|
327
|
+
}, fe = () => {
|
|
328
|
+
de(), process.argv.length > 2 ? (v.version(O.version, "-v,--version", "输出版本号").usage("[command] [options]"), v.command("init").description("初始化项目").option(
|
|
329
|
+
"--clone <template>",
|
|
330
|
+
"如果需要,可通过git clone拉取模版,默认取cli默认模版"
|
|
331
|
+
).action(({ clone: e }, { args: o }) => {
|
|
332
|
+
if (I(), m("yolk init 开始"), e) {
|
|
333
|
+
let t = ".yolk", i = a(d, t);
|
|
334
|
+
l(i) && X(i) && m(`缓存删除 success! ${i}`), n({
|
|
335
|
+
command: "git",
|
|
336
|
+
args: [
|
|
337
|
+
"clone",
|
|
338
|
+
"-b",
|
|
339
|
+
"master",
|
|
340
|
+
"--depth",
|
|
341
|
+
"1",
|
|
342
|
+
e,
|
|
343
|
+
t
|
|
344
|
+
].concat(o)
|
|
345
|
+
}), le(d, i);
|
|
346
|
+
} else
|
|
347
|
+
z(d);
|
|
348
|
+
}), v.command("start").description("启动项目").option("--docs", "文档模式").action(({ docs: e }, { args: o }) => {
|
|
349
|
+
I();
|
|
350
|
+
let t = Y(o);
|
|
351
|
+
N() ? D() ? n({
|
|
352
|
+
command: "taro",
|
|
353
|
+
args: ["build", "--type", "tt", "--watch"].concat(t)
|
|
354
|
+
}) : _() ? n({
|
|
355
|
+
command: "taro",
|
|
356
|
+
args: ["build", "--type", "alipay", "--watch"].concat(t)
|
|
357
|
+
}) : n({
|
|
358
|
+
command: "taro",
|
|
359
|
+
args: ["build", "--type", "weapp", "--watch"].concat(t)
|
|
360
|
+
}) : e ? n({
|
|
361
|
+
command: "dumi",
|
|
362
|
+
args: ["dev"].concat(t)
|
|
363
|
+
}) : G() ? n({
|
|
364
|
+
command: "max",
|
|
365
|
+
args: ["dev"].concat(t)
|
|
366
|
+
}) : n({
|
|
367
|
+
command: "umi",
|
|
368
|
+
args: ["dev"].concat(t)
|
|
369
|
+
});
|
|
370
|
+
}), v.command("build").description("编译项目").option("--docs", "文档模式").action(({ docs: e }, { args: o }) => {
|
|
371
|
+
I();
|
|
372
|
+
let t = Y(o);
|
|
373
|
+
N() ? D() ? n({
|
|
374
|
+
command: "taro",
|
|
375
|
+
args: ["build", "--type", "tt"].concat(t)
|
|
376
|
+
}) : _() ? n({
|
|
377
|
+
command: "taro",
|
|
378
|
+
args: ["build", "--type", "alipay"].concat(t)
|
|
379
|
+
}) : n({
|
|
380
|
+
command: "taro",
|
|
381
|
+
args: ["build", "--type", "weapp"].concat(t)
|
|
382
|
+
}) : e ? n({
|
|
383
|
+
command: "dumi",
|
|
384
|
+
args: ["build"].concat(t)
|
|
385
|
+
}) : G() ? n({
|
|
386
|
+
command: "max",
|
|
387
|
+
args: ["setup"].concat(t),
|
|
388
|
+
complete: () => n({
|
|
389
|
+
command: "max",
|
|
390
|
+
args: ["build"].concat(t)
|
|
391
|
+
}),
|
|
392
|
+
exit: !1
|
|
393
|
+
}) : n({
|
|
394
|
+
command: "umi",
|
|
395
|
+
args: ["build"].concat(t)
|
|
396
|
+
});
|
|
397
|
+
}), v.command("pre-commit").description("执行commit hook").action(ge), W(
|
|
398
|
+
v.command("miniprogram-upload").description("使用 miniprogram-ci 上传小程序")
|
|
399
|
+
).action((e) => {
|
|
400
|
+
if (N()) {
|
|
401
|
+
if (!D()) {
|
|
402
|
+
if (!_()) {
|
|
403
|
+
let {
|
|
404
|
+
appid: o,
|
|
405
|
+
options: { project: t, version: i, desc: c, setting: g, robot: u }
|
|
406
|
+
} = V(e);
|
|
407
|
+
s(`${o} 上传开始`), P.upload({
|
|
408
|
+
project: t,
|
|
409
|
+
version: i,
|
|
410
|
+
desc: c,
|
|
411
|
+
setting: g,
|
|
412
|
+
robot: u,
|
|
413
|
+
onProgressUpdate: (r) => {
|
|
414
|
+
if (B(r))
|
|
415
|
+
s(`task: ${r}`);
|
|
416
|
+
else {
|
|
417
|
+
let { status: $, message: f } = r;
|
|
418
|
+
s(`task(${$}): ${f}`);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}).then(() => {
|
|
422
|
+
m(`${o} 上传完成`);
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
} else
|
|
427
|
+
J("非小程序项目目录");
|
|
428
|
+
}), W(
|
|
429
|
+
v.command("miniprogram-preview").description("使用 miniprogram-ci 预览小程序")
|
|
430
|
+
).action((e) => {
|
|
431
|
+
if (N()) {
|
|
432
|
+
if (!D()) {
|
|
433
|
+
if (!_()) {
|
|
434
|
+
let {
|
|
435
|
+
appid: o,
|
|
436
|
+
options: {
|
|
437
|
+
project: t,
|
|
438
|
+
version: i,
|
|
439
|
+
desc: c,
|
|
440
|
+
setting: g,
|
|
441
|
+
robot: u,
|
|
442
|
+
qrcodeFormat: r,
|
|
443
|
+
qrcodeOutputDest: $,
|
|
444
|
+
pagePath: f,
|
|
445
|
+
searchQuery: y
|
|
446
|
+
}
|
|
447
|
+
} = V(e);
|
|
448
|
+
s(`${o} 上传预览开始`), P.preview({
|
|
449
|
+
project: t,
|
|
450
|
+
version: i,
|
|
451
|
+
desc: c,
|
|
452
|
+
setting: g,
|
|
453
|
+
robot: u,
|
|
454
|
+
qrcodeFormat: r,
|
|
455
|
+
qrcodeOutputDest: $,
|
|
456
|
+
pagePath: f,
|
|
457
|
+
searchQuery: y,
|
|
458
|
+
onProgressUpdate: (p) => {
|
|
459
|
+
if (B(p))
|
|
460
|
+
s(`task: ${p}`);
|
|
461
|
+
else {
|
|
462
|
+
let { status: h, message: b } = p;
|
|
463
|
+
s(`task(${h}): ${b}`);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}).then(() => {
|
|
467
|
+
m(`${o} 上传预览完成`);
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
} else
|
|
472
|
+
J("非小程序项目目录");
|
|
473
|
+
}), v.command("exec").description("执行ts文件").argument("<path>", "执行的ts文件").action((e) => {
|
|
474
|
+
n({
|
|
475
|
+
command: "tsx",
|
|
476
|
+
args: [e]
|
|
477
|
+
});
|
|
478
|
+
}), v.parse(process.argv)) : ae();
|
|
479
|
+
};
|
|
480
|
+
fe();
|