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