@baic/yolk-cli 2.1.0-alpha.133 → 2.1.0-alpha.135
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/compiled/commander/package.json +1 -1
- package/compiled/mustache/package.json +1 -1
- package/es/.lintstagedrc.js +49 -0
- package/es/_util.d.ts +26 -0
- package/es/_util.js +1 -0
- package/es/index.d.ts +3 -0
- package/es/yolk.d.ts +2 -0
- package/es/yolk.js +1 -1
- package/lib/.lintstagedrc.js +49 -0
- package/lib/_util.d.ts +26 -0
- package/lib/_util.js +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/yolk.d.ts +2 -0
- package/lib/yolk.js +1 -1
- package/package.json +11 -14
- package/templates/miniprogram/project.config.json.tpl +1 -1
- package/templates/miniprogram/tsconfig.json +1 -26
- package/templates/umi-mobile/src/pages/demo/index.tsx +3 -3
- package/templates/umi-mobile-h5+app/src/pages/demo/index.tsx +3 -3
- package/templates/umi-mobile-native/android/app/build.gradle +19 -4
- package/templates/umi-mobile-native/android/app/libs/Bluetooth-release.aar +0 -0
- package/templates/umi-mobile-native/android/gradle.properties +1 -1
- package/templates/umi-mobile-native/src/common/bluetooth.ts +6 -6
- package/templates/umi-mobile-native/src/common/bridge.ts +6 -6
- package/templates/umi-mobile-native/src/pages/demo/index.tsx +3 -3
- package/templates/umi-web/src/pages/demo/index.tsx +3 -3
- package/templates/umi-web-screen/src/components/resize-container/index.tsx +5 -5
- package/compiled/glob/index.d.ts +0 -102
- package/compiled/glob/index.js +0 -2222
- package/compiled/glob/package.json +0 -1
- package/compiled/minimatch/index.d.ts +0 -312
- package/compiled/minimatch/index.js +0 -1292
- package/compiled/minimatch/package.json +0 -1
- package/compiled/mkdirp/index.d.ts +0 -114
- package/compiled/mkdirp/index.js +0 -348
- package/compiled/mkdirp/package.json +0 -1
- package/compiled/prettier/index.d.ts +0 -904
- package/compiled/prettier/index.js +0 -49376
- package/compiled/prettier/package.json +0 -1
- package/compiled/rimraf/index.d.ts +0 -48
- package/compiled/rimraf/index.js +0 -449
- package/compiled/rimraf/package.json +0 -1
- package/compiled/staged-git-files/index.js +0 -267
- package/compiled/staged-git-files/package.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"commander","version":"6.2.1","author":"TJ Holowaychuk <tj@vision-media.ca>","license":"MIT","_lastModified":"2023-
|
|
1
|
+
{"name":"commander","version":"6.2.1","author":"TJ Holowaychuk <tj@vision-media.ca>","license":"MIT","_lastModified":"2023-06-07T03:22:06.033Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"mustache","version":"4.2.0","author":"mustache.js Authors <http://github.com/janl/mustache.js>","license":"MIT","_lastModified":"2023-
|
|
1
|
+
{"name":"mustache","version":"4.2.0","author":"mustache.js Authors <http://github.com/janl/mustache.js>","license":"MIT","_lastModified":"2023-06-07T03:22:06.100Z"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const {
|
|
2
|
+
getYolkConfig,
|
|
3
|
+
getEsLintConfigPath,
|
|
4
|
+
getStyleLintConfigPath,
|
|
5
|
+
} = require('./_util');
|
|
6
|
+
|
|
7
|
+
const defaultIgnore = [
|
|
8
|
+
'**/node_modules/**',
|
|
9
|
+
'**/build/**',
|
|
10
|
+
'**/dist/**',
|
|
11
|
+
'**/lib/**',
|
|
12
|
+
'**/es/**',
|
|
13
|
+
'**/mock/**',
|
|
14
|
+
'**/test/**',
|
|
15
|
+
'**/public/**',
|
|
16
|
+
'**/assets/**',
|
|
17
|
+
'**/.umi/**',
|
|
18
|
+
'**/.umi-production/**',
|
|
19
|
+
'**/h5+app/**',
|
|
20
|
+
'**/android/**',
|
|
21
|
+
'**/ios/**',
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const yolkConfig = getYolkConfig();
|
|
25
|
+
const isStrict = yolkConfig.strict !== false;
|
|
26
|
+
|
|
27
|
+
const prettierCLI = 'prettier --write';
|
|
28
|
+
const eslintCLI = `eslint --fix ${
|
|
29
|
+
isStrict ? '--no-inline-config' : ''
|
|
30
|
+
} --no-error-on-unmatched-pattern --config ${getEsLintConfigPath()} --ignore-pattern ${defaultIgnore.join(
|
|
31
|
+
',',
|
|
32
|
+
)}`;
|
|
33
|
+
const stylelintCLI = `stylelint --fix ${
|
|
34
|
+
isStrict ? '--ignore-disables' : ''
|
|
35
|
+
} '--allow-empty-input' --config ${getStyleLintConfigPath()} --ignore-pattern ${defaultIgnore.join(
|
|
36
|
+
',',
|
|
37
|
+
)}`;
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
'*.{md,json}': [prettierCLI],
|
|
41
|
+
'*.css': [prettierCLI, `${stylelintCLI} --custom-syntax postcss`],
|
|
42
|
+
'*.less': [prettierCLI, `${stylelintCLI} --custom-syntax postcss-less`],
|
|
43
|
+
'*.{sass,scss}': [
|
|
44
|
+
prettierCLI,
|
|
45
|
+
`${stylelintCLI} --custom-syntax postcss-scss`,
|
|
46
|
+
],
|
|
47
|
+
'*.{js,jsx}': [prettierCLI, eslintCLI],
|
|
48
|
+
'*.{ts,tsx}': [`${prettierCLI} --parser=typescript`, eslintCLI],
|
|
49
|
+
};
|
package/es/_util.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import ora from 'ora';
|
|
2
|
+
export type YolkConfig = {
|
|
3
|
+
strict?: boolean;
|
|
4
|
+
eslintIgnore?: string | string[] | RegExp | RegExp[];
|
|
5
|
+
stylelintIgnore?: string | string[] | RegExp | RegExp[];
|
|
6
|
+
};
|
|
7
|
+
export declare const ENCODING = "utf-8";
|
|
8
|
+
export declare const warn: (text?: string) => "" | ora.Ora | undefined;
|
|
9
|
+
export declare const fail: (text?: string) => "" | ora.Ora | undefined;
|
|
10
|
+
export declare const succeed: (text?: string) => "" | ora.Ora | undefined;
|
|
11
|
+
export declare const info: (text?: string) => "" | ora.Ora | undefined;
|
|
12
|
+
export declare const completeExit: () => never;
|
|
13
|
+
export declare const breakExit: () => never;
|
|
14
|
+
export declare const execCommand: ({ command, args, complete, close, exit, }: {
|
|
15
|
+
command: string;
|
|
16
|
+
args?: string[] | undefined;
|
|
17
|
+
complete?: (() => void) | undefined;
|
|
18
|
+
close?: (() => void) | undefined;
|
|
19
|
+
exit?: boolean | undefined;
|
|
20
|
+
}) => void;
|
|
21
|
+
export declare const getYolkConfig: () => YolkConfig;
|
|
22
|
+
export declare const getPrettierConfig: () => any;
|
|
23
|
+
export declare const getProjectConfigJSON: () => any;
|
|
24
|
+
export declare const getPackageJSON: () => any;
|
|
25
|
+
export declare const getEsLintConfigPath: () => string;
|
|
26
|
+
export declare const getStyleLintConfigPath: () => string;
|
package/es/_util.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"fs";import e from"path";import{spawn as t}from"child_process";import{globSync as o}from"glob";import n from"ora";import i from"../compiled/commander";var c=process.cwd();export var ENCODING="utf-8";var a=n();export var warn=function(r){return r&&a.warn(Buffer.from(r,ENCODING).toString())};export var fail=function(r){return r&&a.fail(Buffer.from(r,ENCODING).toString())};export var succeed=function(r){return r&&a.succeed(Buffer.from(r,ENCODING).toString())};export var info=function(r){return r&&a.info(Buffer.from(r,ENCODING).toString())};var s=function(r){return"win32"===process.platform?"".concat(r,".cmd"):r};export var completeExit=function(){succeed("yolk complete!"),process.exit(0)};export var breakExit=function(){warn("yolk break!"),process.exit(0)};export var execCommand=function(r){var e=r.command,o=r.args,n=r.complete,c=r.close,a=r.exit,f=void 0===a||a,u=t(s(e),o||[],{stdio:"inherit"}).on("close",(function(r){r?(c&&c(),fail("yolk close!"),process.exit(r)):(n&&n(),f&&completeExit())}));process.on("SIGINT",(function(){i.runningCommand&&i.runningCommand.kill("SIGKILL"),u.kill(),breakExit()}))};export var getYolkConfig=function(){var t=o("*.yolkrc*",{cwd:c,dot:!0});if(!t.length)return{};var n=e.join(c,t[0]);if(!r.existsSync(n))return{};try{return JSON.parse(r.readFileSync(n,ENCODING))||{}}catch(i){return fail(i.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}};export var getPrettierConfig=function(){var t=e.join(c,".prettierrc");if(r.existsSync(t))try{return JSON.parse(r.readFileSync(t,ENCODING))||{}}catch(o){return fail(o.message||".prettierrc\u8f6c\u6362\u9519\u8bef"),{}}return require("./.prettierrc")};export var getProjectConfigJSON=function(){var t=e.join(c,"project.config.json");if(!r.existsSync(t))return{};try{return JSON.parse(r.readFileSync(t,ENCODING))||{}}catch(o){return fail(o.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}};export var getPackageJSON=function(){var t=e.join(c,"package.json");if(!r.existsSync(t))return{};try{return JSON.parse(r.readFileSync(t,ENCODING))||{}}catch(o){return fail(o.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}};export var getEsLintConfigPath=function(){var e=getYolkConfig(),t="";try{t=require.resolve("@baic/eslint-config-yolk")}catch(a){}var n=o("*.eslintrc*",{cwd:c,dot:!0}),i=n[0];return!1===e.strict&&i&&r.existsSync(i)?i:r.existsSync(t)?t:i};export var getStyleLintConfigPath=function(){var e=getYolkConfig(),t="";try{t=require.resolve("@baic/stylelint-config-yolk")}catch(a){}var n=o("*.stylelintrc*",{cwd:c,dot:!0}),i=n[0];return!1===e.strict&&i&&r.existsSync(i)?i:r.existsSync(t)?t:i};
|
package/es/index.d.ts
ADDED
package/es/yolk.d.ts
ADDED
package/es/yolk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
import e from"@babel/runtime/helpers/esm/toArray";import t from"@babel/runtime/helpers/esm/toConsumableArray";import n from"@babel/runtime/helpers/esm/defineProperty";import o from"lodash/isString";import r from"lodash/pick";import c from"lodash/floor";import i from"lodash/chunk";function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function a(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?s(Object(o),!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):s(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}import{execSync as m,spawn as l}from"child_process";import p from"fs";import u from"os";import f from"path";import d from"inquirer";import*as y from"miniprogram-ci";import g from"ora";import h from"../compiled/commander";import v from"../compiled/glob";import b from"../compiled/minimatch";import j from"../compiled/mkdirp";import S from"../compiled/mustache";import{format as x}from"../compiled/prettier";import k from"../compiled/rimraf";import w from"../package.json";var O=require("../compiled/staged-git-files"),P=process.cwd(),D="##### CREATED BY YOLK #####",_={ts:"typescript",tsx:"typescript",less:"less",sass:"scss",scss:"scss",css:"css"},F="utf-8",I=20,E=["**/node_modules/**","**/.umi/**","**/.umi-production/**","**/build/**","**/dist/**","**/lib/**","**/es/**","**/public/**","**/assets/**","**/h5+app/**","**/android/**","**/ios/**","**/mock/**","**/yolk*/**"],N=g(),B=function(e){return e&&N.warn(Buffer.from(e,F).toString())},q=function(e){return e&&N.fail(Buffer.from(e,F).toString())},K=function(e){return e&&N.succeed(Buffer.from(e,F).toString())},$=function(e){return e&&N.info(Buffer.from(e,F).toString())},U=function(e){return"win32"===process.platform?"".concat(e,".cmd"):e},A=function(){K("yolk complete!"),process.exit(0)},Q=function(){B("yolk break!"),process.exit(0)},R=function(e){var t=e.command,n=e.args,o=e.complete,r=e.close,c=e.exit,i=void 0===c||c,s=l(U(t),n||[],{stdio:"inherit"}).on("close",(function(e){e?(r&&r(),q("yolk close!"),process.exit(e)):(o&&o(),i&&A())}));process.on("SIGINT",(function(){h.runningCommand&&h.runningCommand.kill("SIGKILL"),s.kill(),Q()}))},T=function(e,t,n){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:f.basename(f.basename(process.cwd()))},{type:"list",name:"dependenciesInstallType",message:"\u9009\u62e9\u4f9d\u8d56\u5b89\u88c5\u65b9\u5f0f",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(o){var r={projectName:o.projectName,dependenciesInstallType:o.dependenciesInstallType,yolkVersion:w.version},c=t||f.join(__dirname,"../templates/".concat(o.type));K("\u590d\u5236\u6a21\u7248 ".concat(f.basename(c)));var i=v.sync("**/*",{cwd:c,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(i.forEach((function(t){if(c){var n=f.join(c,t);if(!p.statSync(n).isDirectory())if(t.endsWith(".tpl")){var o=p.readFileSync(n,F),i=f.join(e,t.replace(/\.tpl$/,"")),s=S.render(o,r);j.sync(f.dirname(i)),K("\u521b\u5efa ".concat(f.relative(e,i))),p.writeFileSync(i,s,F)}else{K("\u521b\u5efa ".concat(t));var a=f.join(e,t);j.sync(f.dirname(a)),p.copyFileSync(n,a)}}})),K("\u590d\u5236\u6a21\u7248 success!"),n&&p.existsSync(c)&&k(c,(function(){K("\u7f13\u5b58\u5220\u9664 success! ".concat(f.basename(c||"")))})),o.dependenciesInstallType)switch(K("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),o.dependenciesInstallType){case"default":case"pnpm":R({command:"pnpm",args:["install"]});break;case"yarn":R({command:"yarn",args:["install"]});break;case"npm":R({command:"npm",args:["install"]});break;default:}K("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},Y=function(e,t){return T(e,t,!0)},W=function(){var e=v.sync("*.yolkrc*",{cwd:P,dot:!0});if(!e.length)return{};var t=f.join(P,e[0]);if(!p.existsSync(t))return{};try{return JSON.parse(p.readFileSync(t,F))||{}}catch(n){return q(n.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}},L=function(){var e=f.join(P,".prettierrc");if(p.existsSync(e))try{return JSON.parse(p.readFileSync(e,F))||{}}catch(t){return q(t.message||".prettierrc\u8f6c\u6362\u9519\u8bef"),{}}return require("./.prettierrc")},C=function(){var e=f.join(P,"project.config.json");if(!p.existsSync(e))return{};try{return JSON.parse(p.readFileSync(e,F))||{}}catch(t){return q(t.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}},J=function(){var e=f.join(P,"package.json");if(!p.existsSync(e))return{};try{return JSON.parse(p.readFileSync(e,F))||{}}catch(t){return q(t.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}},V=function(){return p.existsSync(f.join(P,"project.config.json"))},G=function(){var e=p.existsSync(f.join(P,"node_modules/.bin/max"));if(!e)try{e=p.existsSync(require.resolve("@umijs/max"))}catch(o){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test(m("umi -v").toString())}catch(o){}if(!e){var t=f.join(P,"node_modules","umi","package.json");if(p.existsSync(t))try{var n=JSON.parse(p.readFileSync(t,F))||{};e=n.version&&+n.version.split(".")[0]>3}catch(o){}}return e},H=function(){var e=f.join(P,"project.config.json");if(p.existsSync(e)){var t=require(e);return t.appid}return""},M=function(){return p.existsSync(f.join(P,"project.tt.json"))&&0===H().indexOf("tt")},X=function(){return 0===H().indexOf("20")},z=function(){var e=W(),t="";try{t=require.resolve("@baic/eslint-config-yolk")}catch(r){}var n=v.sync("*.eslintrc*",{cwd:P,dot:!0}),o=n[0];return!1===e.strict&&o&&p.existsSync(o)?o:p.existsSync(t)?t:o},Z=function(){var e=W(),t="";try{t=require.resolve("@baic/stylelint-config-yolk")}catch(r){}var n=v.sync("*.stylelintrc*",{cwd:P,dot:!0}),o=n[0];return!1===e.strict&&o&&p.existsSync(o)?o:p.existsSync(t)?t:o},ee=function(){var e=f.join(P,".git/"),t=f.join(P,".git/hooks"),n=f.join(t,"pre-commit"),o=p.existsSync(e),r=p.existsSync(n),c=r&&p.readFileSync(n,F).includes(D);if(o&&(!r||!c)){j.sync(t),p.writeFileSync(n,["#!/usr/bin/env bash","npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",D].join(u.EOL),F);try{p.chmodSync(n,"777")}catch(i){q("chmod ".concat(n," failed: ").concat(i.message))}K("Create pre-commit hook")}},te=function(){var e=W(),n=!1!==e.strict,o=e.eslintIgnore,r=e.stylelintIgnore;O().then((function(e){var c=function(o){return new Promise((function(c,s){var m=Z();if(m){var l=e.map((function(e){return e.filename})).filter((function(e){return/^(src|tests)/i.test(e)})).filter((function(e){return{css:/\.cs{2}$/i,less:/\.les{2}$/i,sass:/\.sas{2}$/i,scss:/\.scs{2}$/i}[o].test(e)})).filter((function(e){var t=f.join(P,e);return p.existsSync(t)})).filter((function(e){return E.every((function(t){return!b(e,t,{matchBase:!0})}))})).filter((function(e){return"string"===typeof r?!b(e,r,{matchBase:!0}):r instanceof RegExp?!r.test(e):!Array.isArray(r)||r.every((function(t){return"string"===typeof t?!b(e,t,{matchBase:!0}):!(t instanceof RegExp)||!t.test(e)}))}));if(l.length)if(l.forEach((function(e){if(e&&p.existsSync(e)){var t=f.extname(e).replace(/^\./,""),n=p.readFileSync(e,F),o=x(n,a({parser:_[t]},L()));p.writeFileSync(e,o,F)}})),K("".concat(o," - ").concat(l.length," files prettier success!")),l.length>=I){var u=[];i(l,I).forEach((function(e){u.push(new Promise((function(r,c){R({command:"stylelint",args:[n?"--ignore-disables":"","--allow-empty-input","--custom-syntax","postcss-".concat(o),"--config",m].concat(t(e)),complete:r,close:c,exit:!1})})))}));var d=0,y=function e(){d<u.length?u[d].then((function(){d++,e()})).catch(s):(K("".concat(o," - ").concat(l.length," files stylelint success!")),c())};y()}else l.length&&R({command:"stylelint",args:[n?"--ignore-disables":"","--allow-empty-input","--custom-syntax","postcss-".concat(o),"--config",m].concat(t(l)),complete:function(){K("".concat(o," - ").concat(l.length," files stylelint success!")),c()},close:s,exit:!1});else c()}else q("\u6ca1\u6709 stylelintrc \u6587\u4ef6\uff0c".concat(o," files prettier fail!")),c()}))},s=function(r){return new Promise((function(c,s){var m=z();if(m){var l=e.map((function(e){return e.filename})).filter((function(e){return/^(src|tests)/i.test(e)})).filter((function(e){return{js:/\.js$/i,jsx:/\.jsx$/i,ts:/\.ts$/i,tsx:/\.tsx$/i}[r].test(e)})).filter((function(e){var t=f.join(P,e);return p.existsSync(t)})).filter((function(e){return E.every((function(t){return!b(e,t,{matchBase:!0})}))})).filter((function(e){return"string"===typeof o?!b(e,o,{matchBase:!0}):o instanceof RegExp?!o.test(e):!Array.isArray(o)||o.every((function(t){return"string"===typeof t?!b(e,t,{matchBase:!0}):!(t instanceof RegExp)||!t.test(e)}))}));if(l.length)if(l.forEach((function(e){if(e&&p.existsSync(e)){var t=f.extname(e).replace(/^\./,""),n=p.readFileSync(e,F),o=x(n,a({parser:_[t]},L()));p.writeFileSync(e,o,F)}})),K("".concat(r," - ").concat(l.length," files prettier success!")),l.length>=I){var u=[];i(l,I).forEach((function(e){u.push(new Promise((function(o,r){R({command:"eslint",args:[n?"--no-inline-config --no-ignore":"","--no-error-on-unmatched-pattern","--config",m].concat(t(e)),complete:o,close:r,exit:!1})})))}));var d=0,y=function e(){d<u.length?u[d].then((function(){d++,e()})).catch(s):(K("".concat(r," - ").concat(l.length," files eslint success!")),c())};y()}else l.length&&R({command:"eslint",args:[n?"--no-inline-config --no-ignore":"","--no-error-on-unmatched-pattern","--config",m].concat(t(l)),complete:function(){K("".concat(r," - ").concat(l.length," files eslint success!")),c()},close:s,exit:!1});else c()}else q("\u6ca1\u6709 eslintrc \u6587\u4ef6\uff0c".concat(r," files eslint fail!")),c()}))};B("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),n&&(B("git commit \u7981\u6b62 lint \u7684 ignore \u884c\u4e3a"),r&&B("\u901a\u8fc7 .yolkrc \u914d\u7f6e stylelintIgnore: ".concat(r,"\u3002")),o&&B("\u901a\u8fc7 .yolkrc \u914d\u7f6e eslintIgnore: ".concat(o,"\u3002"))),c("css").then((function(){return c("less")})).then((function(){return c("sass")})).then((function(){return c("scss")})).then((function(){return s("js")})).then((function(){return s("jsx")})).then((function(){return s("ts")})).then((function(){return s("tsx")})).then(A).catch(A)}))},ne=function(e){var t=e.mAppid,n=e.mProject,o=e.mPrivateKeyPath,r=e.mVersion,c=e.mDesc,i=e.mRobot,s=e.mQrcodeFormat,a=e.mQrcodeOutputDest,l=e.mPagePath,u=e.mSearchQuery,d=p.existsSync(f.join(P,".git"))?m("git log -1 --pretty=format:%H").toString():"",g=C(),h=t||g.appid,v=n||f.join(P,"dist"),b=o||f.join(P,"private.".concat(h,".key"));if(p.existsSync(v)){if(p.existsSync(b)){var j=J(),S=r||j.version||g.version||"1.0.0",x=c||j.description||g.description,k="".concat(d?" commit: ".concat(d,";"):"").concat(x?" description: ".concat(x,";"):"");d&&$("commit: ".concat(d)),$("dist: ".concat(v)),$("key: ".concat(b)),$("appid: ".concat(h)),$("version: ".concat(S)),$("desc: ".concat(k));var w=new y.Project({appid:h,type:"miniProgram",projectPath:v,privateKeyPath:b,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:h,options:{project:w,version:S,desc:k,setting:g.setting,robot:i,qrcodeFormat:s,qrcodeOutputDest:a,pagePath:l,searchQuery:u}}}throw Error("\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(".concat(b,")"))}throw Error("\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(".concat(v,")"))},oe=function(){ee(),process.argv.length>2?h.version(w.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]").option("--clone","\u901a\u8fc7git clone\u62c9\u53d6\u6a21\u7248").option("--template <template>","\u6a21\u7248\u540d\u79f0\u6216\u8005clone\u6a21\u5f0f\u7684git\u5730\u5740").option("--docs","\u542f\u52a8\u6587\u6863\u6a21\u5f0f").option("--mAppid <appid>","\u5c0f\u7a0b\u5e8fappid").option("--mProject <project>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u5de5\u7a0b\u76ee\u5f55").option("--mPrivateKeyPath <privateKeyPath>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20key\u6587\u4ef6").option("--mVersion <version>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u7248\u672c\u53f7").option("--mDesc <desc>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u63cf\u8ff0").option("--mRobot <robot>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20ci\u673a\u5668\u4eba1~30").option("--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("--mQrcodeOutputDest <qrcodeOutputDest>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u4e8c\u7ef4\u7801\u6587\u4ef6\u4fdd\u5b58\u8def\u5f84").option("--mPagePath <pagePath>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84").option("--mSearchQuery <searchQuery>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84\u542f\u52a8\u53c2\u6570").action((function(t,n){var i=e(n),s=i[0],m=i.slice(1),l=t.clone,d=t.template,g=t.docs;if(s)switch($("yolk version: ".concat(w.version)),$("node version: ".concat(process.version)),$("platform: ".concat(u.platform())),$("memory: ".concat(c(u.freemem()/1024/1024)," MB(").concat(c(u.totalmem()/1024/1024)," MB)")),s){case"init":if(K("yolk ".concat(s," \u5f00\u59cb")),l)if(d){var h=".yolk",v=f.join(P,h);p.existsSync(v)&&k(v,(function(){K("\u7f13\u5b58\u5220\u9664 success! ".concat(v))})),R({command:"git",args:["clone","-b","master","--depth","1",d,h].concat(m)}),Y(P,v)}else q("--clone \u6a21\u5f0f\u5fc5\u987b\u6709--template");else T(P);break;case"start":V()?M()?R({command:"taro",args:["build","--type","tt","--watch"].concat(m)}):X()?R({command:"taro",args:["build","--type","alipay","--watch"].concat(m)}):R({command:"taro",args:["build","--type","weapp","--watch"].concat(m)}):g?(process.env.DID_YOU_KNOW="none",R({command:"dumi",args:["dev"].concat(m)})):G()?(process.env.DID_YOU_KNOW="none",R({command:"max",args:["dev"].concat(m)})):(process.env.DID_YOU_KNOW="none",R({command:"umi",args:["dev"].concat(m)}));break;case"build":V()?M()?R({command:"taro",args:["build","--type","tt"].concat(m)}):X()?R({command:"taro",args:["build","--type","alipay"].concat(m)}):R({command:"taro",args:["build","--type","weapp"].concat(m)}):g?(process.env.DID_YOU_KNOW="none",R({command:"dumi",args:["build"].concat(m)})):G()?(process.env.DID_YOU_KNOW="none",R({command:"max",args:["setup"].concat(m),complete:function(){return R({command:"max",args:["build"].concat(m)})},exit:!1})):(process.env.DID_YOU_KNOW="none",R({command:"umi",args:["build"].concat(m)}));break;case"pre-commit":te();break;case"miniprogram-upload":if(V())if(M());else if(X());else{var b=ne(t),j=b.appid,S=b.options;$("".concat(j,"\u4e0a\u4f20\u5f00\u59cb")),y.upload(a(a({},r(S,["project","version","desc","setting","robot"])),{},{onProgressUpdate:function(e){if(o(e))$("task: ".concat(e));else{var t=e.status,n=e.message;$("task(".concat(t,"): ").concat(n))}}})).then((function(){K("".concat(j,"\u4e0a\u4f20\u5b8c\u6210"))}))}break;case"miniprogram-preview":if(V())if(M());else if(X());else{var x=ne(t),O=x.appid,D=x.options;$("".concat(O,"\u4e0a\u4f20\u9884\u89c8\u5f00\u59cb")),y.preview(a(a({},r(D,["project","version","desc","setting","robot","qrcodeFormat","qrcodeOutputDest","pagePath","searchQuery"])),{},{onProgressUpdate:function(e){if(o(e))$("task: ".concat(e));else{var t=e.status,n=e.message;$("task(".concat(t,"): ").concat(n))}}})).then((function(){K("".concat(O,"\u4e0a\u4f20\u9884\u89c8\u5b8c\u6210"))}))}break;default:Q()}})).parse(process.argv):Q()};oe();
|
|
2
|
+
import e from"@babel/runtime/helpers/esm/defineProperty";import t from"@babel/runtime/helpers/esm/toArray";import o from"@babel/runtime/helpers/esm/asyncToGenerator";import n from"lodash/pick";import r from"lodash/isString";import a from"lodash/floor";function i(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function c(t){for(var o=1;o<arguments.length;o++){var n=null!=arguments[o]?arguments[o]:{};o%2?i(Object(n),!0).forEach((function(o){e(t,o,n[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}import s from"@babel/runtime/regenerator";import{execSync as m}from"child_process";import p from"fs";import l from"os";import d from"path";import{globSync as u}from"glob";import f from"inquirer";import*as y from"miniprogram-ci";import{mkdirpSync as g}from"mkdirp";import{rimrafSync as v}from"rimraf";import b from"../compiled/commander";import h from"../compiled/mustache";import j from"../package.json";import{ENCODING as O,fail as k,getPackageJSON as w,getProjectConfigJSON as S,getYolkConfig as P,info as x,succeed as D,warn as _,execCommand as I,breakExit as F}from"./_util";var K=process.cwd(),q="##### CREATED BY YOLK #####",E=function(e,t,o){f.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:d.basename(d.basename(process.cwd()))},{type:"list",name:"dependenciesInstallType",message:"\u9009\u62e9\u4f9d\u8d56\u5b89\u88c5\u65b9\u5f0f",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(n){var r={projectName:n.projectName,dependenciesInstallType:n.dependenciesInstallType,yolkVersion:j.version},a=t||d.join(__dirname,"../templates/".concat(n.type));D("\u590d\u5236\u6a21\u7248 ".concat(d.basename(a)));var i=u("**/*",{cwd:a,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(i.forEach((function(t){if(a){var o=d.join(a,t);if(!p.statSync(o).isDirectory())if(t.endsWith(".tpl")){var n=p.readFileSync(o,O),i=d.join(e,t.replace(/\.tpl$/,"")),c=h.render(n,r);g(d.dirname(i)),D("\u521b\u5efa ".concat(d.relative(e,i))),p.writeFileSync(i,c,O)}else{D("\u521b\u5efa ".concat(t));var s=d.join(e,t);g(d.dirname(s)),p.copyFileSync(o,s)}}})),D("\u590d\u5236\u6a21\u7248 success!"),o&&p.existsSync(a)&&v(a)&&D("\u7f13\u5b58\u5220\u9664 success! ".concat(d.basename(a||""))),n.dependenciesInstallType)switch(D("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),n.dependenciesInstallType){case"default":case"pnpm":I({command:"pnpm",args:["install"]});break;case"yarn":I({command:"yarn",args:["install"]});break;case"npm":I({command:"npm",args:["install"]});break;default:}D("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},N=function(e,t){return E(e,t,!0)},U=function(){return p.existsSync(d.join(K,"project.config.json"))},Q=function(){var e=p.existsSync(d.join(K,"node_modules/.bin/max"));if(!e)try{e=p.existsSync(require.resolve("@umijs/max"))}catch(n){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test(m("umi -v").toString())}catch(n){}if(!e){var t=d.join(K,"node_modules","umi","package.json");if(p.existsSync(t))try{var o=JSON.parse(p.readFileSync(t,O))||{};e=o.version&&+o.version.split(".")[0]>3}catch(n){}}return e},T=function(){var e=d.join(K,"project.config.json");if(p.existsSync(e)){var t=require(e);return t.appid}return""},Y=function(){return p.existsSync(d.join(K,"project.tt.json"))&&0===T().indexOf("tt")},W=function(){return 0===T().indexOf("20")},R=function(){var e=d.join(K,".git/"),t=d.join(K,".git/hooks"),o=d.join(t,"pre-commit"),n=p.existsSync(e),r=p.existsSync(o),a=r&&p.readFileSync(o,O).includes(q);if(n&&(!r||!a)){g(t),p.writeFileSync(o,["#!/usr/bin/env bash","npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",q].join(l.EOL),O);try{p.chmodSync(o,"777")}catch(i){k("chmod ".concat(o," failed: ").concat(i.message))}D("Create pre-commit hook")}},A=function(){var e=o(s.mark((function e(){var t,o,n,r;return s.wrap((function(e){while(1)switch(e.prev=e.next){case 0:t=P(),o=!1!==t.strict,n=t.eslintIgnore,r=t.stylelintIgnore,_("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),o&&(_("git commit \u7981\u6b62 lint \u7684 ignore \u884c\u4e3a"),r&&_("\u901a\u8fc7 .yolkrc \u914d\u7f6e stylelintIgnore: ".concat(r,"\u3002")),n&&_("\u901a\u8fc7 .yolkrc \u914d\u7f6e eslintIgnore: ".concat(n,"\u3002"))),I({command:"lint-staged",args:["-c",require.resolve("./.lintstagedrc")]});case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),B=function(e){var t=e.mAppid,o=e.mProject,n=e.mPrivateKeyPath,r=e.mVersion,a=e.mDesc,i=e.mRobot,c=e.mQrcodeFormat,s=e.mQrcodeOutputDest,l=e.mPagePath,u=e.mSearchQuery,f=p.existsSync(d.join(K,".git"))?m("git log -1 --pretty=format:%H").toString():"",g=S(),v=t||g.appid,b=o||d.join(K,"dist"),h=n||d.join(K,"private.".concat(v,".key"));if(p.existsSync(b)){if(p.existsSync(h)){var j=w(),O=r||j.version||g.version||"1.0.0",k=a||j.description||g.description,P="".concat(f?" commit: ".concat(f,";"):"").concat(k?" description: ".concat(k,";"):"");f&&x("commit: ".concat(f)),x("dist: ".concat(b)),x("key: ".concat(h)),x("appid: ".concat(v)),x("version: ".concat(O)),x("desc: ".concat(P));var D=new y.Project({appid:v,type:"miniProgram",projectPath:b,privateKeyPath:h,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:v,options:{project:D,version:O,desc:P,setting:g.setting,robot:i,qrcodeFormat:c,qrcodeOutputDest:s,pagePath:l,searchQuery:u}}}throw Error("\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(".concat(h,")"))}throw Error("\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(".concat(b,")"))},L=function(){R(),process.argv.length>2?b.version(j.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]").option("--clone","\u901a\u8fc7git clone\u62c9\u53d6\u6a21\u7248").option("--template <template>","\u6a21\u7248\u540d\u79f0\u6216\u8005clone\u6a21\u5f0f\u7684git\u5730\u5740").option("--docs","\u542f\u52a8\u6587\u6863\u6a21\u5f0f").option("--mAppid <appid>","\u5c0f\u7a0b\u5e8fappid").option("--mProject <project>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u5de5\u7a0b\u76ee\u5f55").option("--mPrivateKeyPath <privateKeyPath>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20key\u6587\u4ef6").option("--mVersion <version>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u7248\u672c\u53f7").option("--mDesc <desc>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u63cf\u8ff0").option("--mRobot <robot>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20ci\u673a\u5668\u4eba1~30").option("--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("--mQrcodeOutputDest <qrcodeOutputDest>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u4e8c\u7ef4\u7801\u6587\u4ef6\u4fdd\u5b58\u8def\u5f84").option("--mPagePath <pagePath>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84").option("--mSearchQuery <searchQuery>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84\u542f\u52a8\u53c2\u6570").action((function(e,o){var i=t(o),s=i[0],m=i.slice(1),u=e.clone,f=e.template,g=e.docs;if(s)switch(x("yolk version: ".concat(j.version)),x("node version: ".concat(process.version)),x("platform: ".concat(l.platform())),x("memory: ".concat(a(l.freemem()/1024/1024)," MB(").concat(a(l.totalmem()/1024/1024)," MB)")),s){case"init":if(D("yolk ".concat(s," \u5f00\u59cb")),u)if(f){var b=".yolk",h=d.join(K,b);p.existsSync(h)&&v(h)&&D("\u7f13\u5b58\u5220\u9664 success! ".concat(h)),I({command:"git",args:["clone","-b","master","--depth","1",f,b].concat(m)}),N(K,h)}else k("--clone \u6a21\u5f0f\u5fc5\u987b\u6709--template");else E(K);break;case"start":U()?Y()?I({command:"taro",args:["build","--type","tt","--watch"].concat(m)}):W()?I({command:"taro",args:["build","--type","alipay","--watch"].concat(m)}):I({command:"taro",args:["build","--type","weapp","--watch"].concat(m)}):g?(process.env.DID_YOU_KNOW="none",I({command:"dumi",args:["dev"].concat(m)})):Q()?(process.env.DID_YOU_KNOW="none",I({command:"max",args:["dev"].concat(m)})):(process.env.DID_YOU_KNOW="none",I({command:"umi",args:["dev"].concat(m)}));break;case"build":U()?Y()?I({command:"taro",args:["build","--type","tt"].concat(m)}):W()?I({command:"taro",args:["build","--type","alipay"].concat(m)}):I({command:"taro",args:["build","--type","weapp"].concat(m)}):g?(process.env.DID_YOU_KNOW="none",I({command:"dumi",args:["build"].concat(m)})):Q()?(process.env.DID_YOU_KNOW="none",I({command:"max",args:["setup"].concat(m),complete:function(){return I({command:"max",args:["build"].concat(m)})},exit:!1})):(process.env.DID_YOU_KNOW="none",I({command:"umi",args:["build"].concat(m)}));break;case"pre-commit":A();break;case"miniprogram-upload":if(U())if(Y());else if(W());else{var O=B(e),w=O.appid,S=O.options;x("".concat(w,"\u4e0a\u4f20\u5f00\u59cb")),y.upload(c(c({},n(S,["project","version","desc","setting","robot"])),{},{onProgressUpdate:function(e){if(r(e))x("task: ".concat(e));else{var t=e.status,o=e.message;x("task(".concat(t,"): ").concat(o))}}})).then((function(){D("".concat(w,"\u4e0a\u4f20\u5b8c\u6210"))}))}break;case"miniprogram-preview":if(U())if(Y());else if(W());else{var P=B(e),_=P.appid,q=P.options;x("".concat(_,"\u4e0a\u4f20\u9884\u89c8\u5f00\u59cb")),y.preview(c(c({},n(q,["project","version","desc","setting","robot","qrcodeFormat","qrcodeOutputDest","pagePath","searchQuery"])),{},{onProgressUpdate:function(e){if(r(e))x("task: ".concat(e));else{var t=e.status,o=e.message;x("task(".concat(t,"): ").concat(o))}}})).then((function(){D("".concat(_,"\u4e0a\u4f20\u9884\u89c8\u5b8c\u6210"))}))}break;default:F()}})).parse(process.argv):F()};L();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const {
|
|
2
|
+
getYolkConfig,
|
|
3
|
+
getEsLintConfigPath,
|
|
4
|
+
getStyleLintConfigPath,
|
|
5
|
+
} = require('./_util');
|
|
6
|
+
|
|
7
|
+
const defaultIgnore = [
|
|
8
|
+
'**/node_modules/**',
|
|
9
|
+
'**/build/**',
|
|
10
|
+
'**/dist/**',
|
|
11
|
+
'**/lib/**',
|
|
12
|
+
'**/es/**',
|
|
13
|
+
'**/mock/**',
|
|
14
|
+
'**/test/**',
|
|
15
|
+
'**/public/**',
|
|
16
|
+
'**/assets/**',
|
|
17
|
+
'**/.umi/**',
|
|
18
|
+
'**/.umi-production/**',
|
|
19
|
+
'**/h5+app/**',
|
|
20
|
+
'**/android/**',
|
|
21
|
+
'**/ios/**',
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const yolkConfig = getYolkConfig();
|
|
25
|
+
const isStrict = yolkConfig.strict !== false;
|
|
26
|
+
|
|
27
|
+
const prettierCLI = 'prettier --write';
|
|
28
|
+
const eslintCLI = `eslint --fix ${
|
|
29
|
+
isStrict ? '--no-inline-config' : ''
|
|
30
|
+
} --no-error-on-unmatched-pattern --config ${getEsLintConfigPath()} --ignore-pattern ${defaultIgnore.join(
|
|
31
|
+
',',
|
|
32
|
+
)}`;
|
|
33
|
+
const stylelintCLI = `stylelint --fix ${
|
|
34
|
+
isStrict ? '--ignore-disables' : ''
|
|
35
|
+
} '--allow-empty-input' --config ${getStyleLintConfigPath()} --ignore-pattern ${defaultIgnore.join(
|
|
36
|
+
',',
|
|
37
|
+
)}`;
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
'*.{md,json}': [prettierCLI],
|
|
41
|
+
'*.css': [prettierCLI, `${stylelintCLI} --custom-syntax postcss`],
|
|
42
|
+
'*.less': [prettierCLI, `${stylelintCLI} --custom-syntax postcss-less`],
|
|
43
|
+
'*.{sass,scss}': [
|
|
44
|
+
prettierCLI,
|
|
45
|
+
`${stylelintCLI} --custom-syntax postcss-scss`,
|
|
46
|
+
],
|
|
47
|
+
'*.{js,jsx}': [prettierCLI, eslintCLI],
|
|
48
|
+
'*.{ts,tsx}': [`${prettierCLI} --parser=typescript`, eslintCLI],
|
|
49
|
+
};
|
package/lib/_util.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import ora from 'ora';
|
|
2
|
+
export type YolkConfig = {
|
|
3
|
+
strict?: boolean;
|
|
4
|
+
eslintIgnore?: string | string[] | RegExp | RegExp[];
|
|
5
|
+
stylelintIgnore?: string | string[] | RegExp | RegExp[];
|
|
6
|
+
};
|
|
7
|
+
export declare const ENCODING = "utf-8";
|
|
8
|
+
export declare const warn: (text?: string) => "" | ora.Ora | undefined;
|
|
9
|
+
export declare const fail: (text?: string) => "" | ora.Ora | undefined;
|
|
10
|
+
export declare const succeed: (text?: string) => "" | ora.Ora | undefined;
|
|
11
|
+
export declare const info: (text?: string) => "" | ora.Ora | undefined;
|
|
12
|
+
export declare const completeExit: () => never;
|
|
13
|
+
export declare const breakExit: () => never;
|
|
14
|
+
export declare const execCommand: ({ command, args, complete, close, exit, }: {
|
|
15
|
+
command: string;
|
|
16
|
+
args?: string[] | undefined;
|
|
17
|
+
complete?: (() => void) | undefined;
|
|
18
|
+
close?: (() => void) | undefined;
|
|
19
|
+
exit?: boolean | undefined;
|
|
20
|
+
}) => void;
|
|
21
|
+
export declare const getYolkConfig: () => YolkConfig;
|
|
22
|
+
export declare const getPrettierConfig: () => any;
|
|
23
|
+
export declare const getProjectConfigJSON: () => any;
|
|
24
|
+
export declare const getPackageJSON: () => any;
|
|
25
|
+
export declare const getEsLintConfigPath: () => string;
|
|
26
|
+
export declare const getStyleLintConfigPath: () => string;
|
package/lib/_util.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,i=(e,r)=>{for(var n in r)t(e,n,{get:r[n],enumerable:!0})},s=(e,o,i,s)=>{if(o&&"object"===typeof o||"function"===typeof o)for(let a of n(o))c.call(e,a)||a===i||t(e,a,{get:()=>o[a],enumerable:!(s=r(o,a))||s.enumerable});return e},a=(r,n,c)=>(c=null!=r?e(o(r)):{},s(!n&&r&&r.__esModule?c:t(c,"default",{value:r,enumerable:!0}),r)),l=e=>s(t({},"__esModule",{value:!0}),e),u={};i(u,{ENCODING:()=>b,breakExit:()=>P,completeExit:()=>N,execCommand:()=>q,fail:()=>x,getEsLintConfigPath:()=>_,getPackageJSON:()=>I,getPrettierConfig:()=>v,getProjectConfigJSON:()=>J,getStyleLintConfigPath:()=>B,getYolkConfig:()=>C,info:()=>h,succeed:()=>k,warn:()=>O}),module.exports=l(u);var f=a(require("fs")),d=a(require("path")),g=require("child_process"),y=require("glob"),p=a(require("ora")),m=a(require("../compiled/commander")),S=process.cwd(),b="utf-8",j=(0,p.default)(),O=e=>e&&j.warn(Buffer.from(e,b).toString()),x=e=>e&&j.fail(Buffer.from(e,b).toString()),k=e=>e&&j.succeed(Buffer.from(e,b).toString()),h=e=>e&&j.info(Buffer.from(e,b).toString()),w=e=>"win32"===process.platform?`${e}.cmd`:e,N=()=>{k("yolk complete!"),process.exit(0)},P=()=>{O("yolk break!"),process.exit(0)},q=({command:e,args:t,complete:r,close:n,exit:o=!0})=>{const c=(0,g.spawn)(w(e),t||[],{stdio:"inherit"}).on("close",(e=>{e?(n&&n(),x("yolk close!"),process.exit(e)):(r&&r(),o&&N())}));process.on("SIGINT",(()=>{m.default.runningCommand&&m.default.runningCommand.kill("SIGKILL"),c.kill(),P()}))},C=()=>{const e=(0,y.globSync)("*.yolkrc*",{cwd:S,dot:!0});if(!e.length)return{};const t=d.default.join(S,e[0]);if(!f.default.existsSync(t))return{};try{return JSON.parse(f.default.readFileSync(t,b))||{}}catch(r){return x(r.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}},v=()=>{const e=d.default.join(S,".prettierrc");if(f.default.existsSync(e))try{return JSON.parse(f.default.readFileSync(e,b))||{}}catch(t){return x(t.message||".prettierrc\u8f6c\u6362\u9519\u8bef"),{}}return require("./.prettierrc")},J=()=>{const e=d.default.join(S,"project.config.json");if(!f.default.existsSync(e))return{};try{return JSON.parse(f.default.readFileSync(e,b))||{}}catch(t){return x(t.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}},I=()=>{const e=d.default.join(S,"package.json");if(!f.default.existsSync(e))return{};try{return JSON.parse(f.default.readFileSync(e,b))||{}}catch(t){return x(t.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}},_=()=>{const e=C();let t="";try{t=require.resolve("@baic/eslint-config-yolk")}catch(o){}const r=(0,y.globSync)("*.eslintrc*",{cwd:S,dot:!0}),n=r[0];return!1===e.strict&&n&&f.default.existsSync(n)?n:f.default.existsSync(t)?t:n},B=()=>{const e=C();let t="";try{t=require.resolve("@baic/stylelint-config-yolk")}catch(o){}const r=(0,y.globSync)("*.stylelintrc*",{cwd:S,dot:!0}),n=r[0];return!1===e.strict&&n&&f.default.existsSync(n)?n:f.default.existsSync(t)?t:n};
|
package/lib/index.d.ts
ADDED
package/lib/yolk.d.ts
ADDED
package/lib/yolk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
var e=Object.create,t=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,n=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty,o=(e,n,o,r)=>{if(n&&"object"===typeof n||"function"===typeof n)for(let c of a(n))i.call(e,c)||c===o||t(e,c,{get:()=>n[c],enumerable:!(r=s(n,c))||r.enumerable});return e},r=(s,a,i)=>(i=null!=s?e(n(s)):{},o(!a&&s&&s.__esModule?i:t(i,"default",{value:s,enumerable:!0}),s)),c=e=>o(t({},"__esModule",{value:!0}),e),l={};module.exports=c(l);var d=require("child_process"),u=r(require("fs")),m=r(require("os")),p=r(require("path")),f=r(require("lodash")),y=r(require("inquirer")),g=r(require("miniprogram-ci")),h=r(require("ora")),$=r(require("../compiled/commander")),b=r(require("../compiled/glob")),x=r(require("../compiled/minimatch")),S=r(require("../compiled/mkdirp")),j=r(require("../compiled/mustache")),v=require("../compiled/prettier"),k=r(require("../compiled/rimraf")),w=r(require("../package.json")),O=require("../compiled/staged-git-files"),q=process.cwd(),P="##### CREATED BY YOLK #####",_={ts:"typescript",tsx:"typescript",less:"less",sass:"scss",scss:"scss",css:"css"},D="utf-8",F=20,I=["**/node_modules/**","**/.umi/**","**/.umi-production/**","**/build/**","**/dist/**","**/lib/**","**/es/**","**/public/**","**/assets/**","**/h5+app/**","**/android/**","**/ios/**","**/mock/**","**/yolk*/**"],E=(0,h.default)(),N=e=>e&&E.warn(Buffer.from(e,D).toString()),B=e=>e&&E.fail(Buffer.from(e,D).toString()),K=e=>e&&E.succeed(Buffer.from(e,D).toString()),U=e=>e&&E.info(Buffer.from(e,D).toString()),Q=e=>"win32"===process.platform?`${e}.cmd`:e,R=()=>{K("yolk complete!"),process.exit(0)},T=()=>{N("yolk break!"),process.exit(0)},Y=({command:e,args:t,complete:s,close:a,exit:n=!0})=>{const i=(0,d.spawn)(Q(e),t||[],{stdio:"inherit"}).on("close",(e=>{e?(a&&a(),B("yolk close!"),process.exit(e)):(s&&s(),n&&R())}));process.on("SIGINT",(()=>{$.default.runningCommand&&$.default.runningCommand.kill("SIGKILL"),i.kill(),T()}))},A=(e,t,s)=>{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:p.default.basename(p.default.basename(process.cwd()))},{type:"list",name:"dependenciesInstallType",message:"\u9009\u62e9\u4f9d\u8d56\u5b89\u88c5\u65b9\u5f0f",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((a=>{const n={projectName:a.projectName,dependenciesInstallType:a.dependenciesInstallType,yolkVersion:w.default.version},i=t||p.default.join(__dirname,`../templates/${a.type}`);K(`\u590d\u5236\u6a21\u7248 ${p.default.basename(i)}`);const o=b.default.sync("**/*",{cwd:i,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(o.forEach((t=>{if(!i)return;const s=p.default.join(i,t);if(!u.default.statSync(s).isDirectory())if(t.endsWith(".tpl")){const a=u.default.readFileSync(s,D),i=p.default.join(e,t.replace(/\.tpl$/,"")),o=j.default.render(a,n);S.default.sync(p.default.dirname(i)),K(`\u521b\u5efa ${p.default.relative(e,i)}`),u.default.writeFileSync(i,o,D)}else{K(`\u521b\u5efa ${t}`);const a=p.default.join(e,t);S.default.sync(p.default.dirname(a)),u.default.copyFileSync(s,a)}})),K("\u590d\u5236\u6a21\u7248 success!"),s&&u.default.existsSync(i)&&(0,k.default)(i,(()=>{K(`\u7f13\u5b58\u5220\u9664 success! ${p.default.basename(i||"")}`)})),a.dependenciesInstallType)switch(K("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),a.dependenciesInstallType){case"default":case"pnpm":Y({command:"pnpm",args:["install"]});break;case"yarn":Y({command:"yarn",args:["install"]});break;case"npm":Y({command:"npm",args:["install"]});break;default:}K("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},W=(e,t)=>A(e,t,!0),L=()=>{const e=b.default.sync("*.yolkrc*",{cwd:q,dot:!0});if(!e.length)return{};const t=p.default.join(q,e[0]);if(!u.default.existsSync(t))return{};try{return JSON.parse(u.default.readFileSync(t,D))||{}}catch(s){return B(s.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}},J=()=>{const e=p.default.join(q,".prettierrc");if(u.default.existsSync(e))try{return JSON.parse(u.default.readFileSync(e,D))||{}}catch(t){return B(t.message||".prettierrc\u8f6c\u6362\u9519\u8bef"),{}}return require("./.prettierrc")},C=()=>{const e=p.default.join(q,"project.config.json");if(!u.default.existsSync(e))return{};try{return JSON.parse(u.default.readFileSync(e,D))||{}}catch(t){return B(t.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}},M=()=>{const e=p.default.join(q,"package.json");if(!u.default.existsSync(e))return{};try{return JSON.parse(u.default.readFileSync(e,D))||{}}catch(t){return B(t.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}},V=()=>u.default.existsSync(p.default.join(q,"project.config.json")),G=()=>{let e=u.default.existsSync(p.default.join(q,"node_modules/.bin/max"));if(!e)try{e=u.default.existsSync(require.resolve("@umijs/max"))}catch(t){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test((0,d.execSync)("umi -v").toString())}catch(t){}if(!e){const s=p.default.join(q,"node_modules","umi","package.json");if(u.default.existsSync(s))try{const t=JSON.parse(u.default.readFileSync(s,D))||{};e=t.version&&+t.version.split(".")[0]>3}catch(t){}}return e},H=()=>{const e=p.default.join(q,"project.config.json");if(u.default.existsSync(e)){const t=require(e);return t.appid}return""},X=()=>u.default.existsSync(p.default.join(q,"project.tt.json"))&&0===H().indexOf("tt"),z=()=>0===H().indexOf("20"),Z=()=>{const e=L();let t="";try{t=require.resolve("@baic/eslint-config-yolk")}catch(n){}const s=b.default.sync("*.eslintrc*",{cwd:q,dot:!0}),a=s[0];return!1===e.strict&&a&&u.default.existsSync(a)?a:u.default.existsSync(t)?t:a},ee=()=>{const e=L();let t="";try{t=require.resolve("@baic/stylelint-config-yolk")}catch(n){}const s=b.default.sync("*.stylelintrc*",{cwd:q,dot:!0}),a=s[0];return!1===e.strict&&a&&u.default.existsSync(a)?a:u.default.existsSync(t)?t:a},te=()=>{const e=p.default.join(q,".git/"),t=p.default.join(q,".git/hooks"),s=p.default.join(t,"pre-commit"),a=u.default.existsSync(e),n=u.default.existsSync(s),i=n&&u.default.readFileSync(s,D).includes(P);if(a&&(!n||!i)){S.default.sync(t),u.default.writeFileSync(s,["#!/usr/bin/env bash","npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",P].join(m.default.EOL),D);try{u.default.chmodSync(s,"777")}catch(o){B(`chmod ${s} failed: ${o.message}`)}K("Create pre-commit hook")}},se=()=>{const e=L(),t=!1!==e.strict,s=e.eslintIgnore,a=e.stylelintIgnore;O().then((e=>{const n=s=>new Promise(((n,i)=>{const o=ee();if(o){const r=e.map((e=>e.filename)).filter((e=>/^(src|tests)/i.test(e))).filter((e=>({css:/\.cs{2}$/i,less:/\.les{2}$/i,sass:/\.sas{2}$/i,scss:/\.scs{2}$/i}[s].test(e)))).filter((e=>{const t=p.default.join(q,e);return u.default.existsSync(t)})).filter((e=>I.every((t=>!(0,x.default)(e,t,{matchBase:!0}))))).filter((e=>"string"===typeof a?!(0,x.default)(e,a,{matchBase:!0}):a instanceof RegExp?!a.test(e):!Array.isArray(a)||a.every((t=>"string"===typeof t?!(0,x.default)(e,t,{matchBase:!0}):!(t instanceof RegExp)||!t.test(e)))));if(r.length)if(r.forEach((e=>{if(e&&u.default.existsSync(e)){const t=p.default.extname(e).replace(/^\./,""),s=u.default.readFileSync(e,D),a=(0,v.format)(s,{parser:_[t],...J()});u.default.writeFileSync(e,a,D)}})),K(`${s} - ${r.length} files prettier success!`),r.length>=F){const e=[];f.default.chunk(r,F).forEach((a=>{e.push(new Promise(((e,n)=>{Y({command:"stylelint",args:[t?"--ignore-disables":"","--allow-empty-input","--custom-syntax",`postcss-${s}`,"--config",o,...a],complete:e,close:n,exit:!1})})))}));let a=0;const c=()=>{a<e.length?e[a].then((()=>{a++,c()})).catch(i):(K(`${s} - ${r.length} files stylelint success!`),n())};c()}else r.length&&Y({command:"stylelint",args:[t?"--ignore-disables":"","--allow-empty-input","--custom-syntax",`postcss-${s}`,"--config",o,...r],complete:()=>{K(`${s} - ${r.length} files stylelint success!`),n()},close:i,exit:!1});else n()}else B(`\u6ca1\u6709 stylelintrc \u6587\u4ef6\uff0c${s} files prettier fail!`),n()})),i=a=>new Promise(((n,i)=>{const o=Z();if(o){const r=e.map((e=>e.filename)).filter((e=>/^(src|tests)/i.test(e))).filter((e=>({js:/\.js$/i,jsx:/\.jsx$/i,ts:/\.ts$/i,tsx:/\.tsx$/i}[a].test(e)))).filter((e=>{const t=p.default.join(q,e);return u.default.existsSync(t)})).filter((e=>I.every((t=>!(0,x.default)(e,t,{matchBase:!0}))))).filter((e=>"string"===typeof s?!(0,x.default)(e,s,{matchBase:!0}):s instanceof RegExp?!s.test(e):!Array.isArray(s)||s.every((t=>"string"===typeof t?!(0,x.default)(e,t,{matchBase:!0}):!(t instanceof RegExp)||!t.test(e)))));if(r.length)if(r.forEach((e=>{if(e&&u.default.existsSync(e)){const t=p.default.extname(e).replace(/^\./,""),s=u.default.readFileSync(e,D),a=(0,v.format)(s,{parser:_[t],...J()});u.default.writeFileSync(e,a,D)}})),K(`${a} - ${r.length} files prettier success!`),r.length>=F){const e=[];f.default.chunk(r,F).forEach((s=>{e.push(new Promise(((e,a)=>{Y({command:"eslint",args:[t?"--no-inline-config --no-ignore":"","--no-error-on-unmatched-pattern","--config",o,...s],complete:e,close:a,exit:!1})})))}));let s=0;const c=()=>{s<e.length?e[s].then((()=>{s++,c()})).catch(i):(K(`${a} - ${r.length} files eslint success!`),n())};c()}else r.length&&Y({command:"eslint",args:[t?"--no-inline-config --no-ignore":"","--no-error-on-unmatched-pattern","--config",o,...r],complete:()=>{K(`${a} - ${r.length} files eslint success!`),n()},close:i,exit:!1});else n()}else B(`\u6ca1\u6709 eslintrc \u6587\u4ef6\uff0c${a} files eslint fail!`),n()}));N("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),t&&(N("git commit \u7981\u6b62 lint \u7684 ignore \u884c\u4e3a"),a&&N(`\u901a\u8fc7 .yolkrc \u914d\u7f6e stylelintIgnore: ${a}\u3002`),s&&N(`\u901a\u8fc7 .yolkrc \u914d\u7f6e eslintIgnore: ${s}\u3002`)),n("css").then((()=>n("less"))).then((()=>n("sass"))).then((()=>n("scss"))).then((()=>i("js"))).then((()=>i("jsx"))).then((()=>i("ts"))).then((()=>i("tsx"))).then(R).catch(R)}))},ae=({mAppid:e,mProject:t,mPrivateKeyPath:s,mVersion:a,mDesc:n,mRobot:i,mQrcodeFormat:o,mQrcodeOutputDest:r,mPagePath:c,mSearchQuery:l})=>{const m=u.default.existsSync(p.default.join(q,".git"))?(0,d.execSync)("git log -1 --pretty=format:%H").toString():"",f=C(),y=e||f.appid,h=t||p.default.join(q,"dist"),$=s||p.default.join(q,`private.${y}.key`);if(u.default.existsSync(h)){if(u.default.existsSync($)){const e=M(),t=a||e.version||f.version||"1.0.0",s=n||e.description||f.description,d=`${m?` commit: ${m};`:""}${s?` description: ${s};`:""}`;m&&U(`commit: ${m}`),U(`dist: ${h}`),U(`key: ${$}`),U(`appid: ${y}`),U(`version: ${t}`),U(`desc: ${d}`);const u=new g.Project({appid:y,type:"miniProgram",projectPath:h,privateKeyPath:$,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:y,options:{project:u,version:t,desc:d,setting:f.setting,robot:i,qrcodeFormat:o,qrcodeOutputDest:r,pagePath:c,searchQuery:l}}}throw Error(`\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(${$})`)}throw Error(`\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(${h})`)},ne=()=>{te(),process.argv.length>2?$.default.version(w.default.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]").option("--clone","\u901a\u8fc7git clone\u62c9\u53d6\u6a21\u7248").option("--template <template>","\u6a21\u7248\u540d\u79f0\u6216\u8005clone\u6a21\u5f0f\u7684git\u5730\u5740").option("--docs","\u542f\u52a8\u6587\u6863\u6a21\u5f0f").option("--mAppid <appid>","\u5c0f\u7a0b\u5e8fappid").option("--mProject <project>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u5de5\u7a0b\u76ee\u5f55").option("--mPrivateKeyPath <privateKeyPath>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20key\u6587\u4ef6").option("--mVersion <version>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u7248\u672c\u53f7").option("--mDesc <desc>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u63cf\u8ff0").option("--mRobot <robot>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20ci\u673a\u5668\u4eba1~30").option("--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("--mQrcodeOutputDest <qrcodeOutputDest>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u4e8c\u7ef4\u7801\u6587\u4ef6\u4fdd\u5b58\u8def\u5f84").option("--mPagePath <pagePath>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84").option("--mSearchQuery <searchQuery>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84\u542f\u52a8\u53c2\u6570").action(((e,t)=>{const[s,...a]=t,{clone:n,template:i,docs:o}=e;if(s)switch(U(`yolk version: ${w.default.version}`),U(`node version: ${process.version}`),U(`platform: ${m.default.platform()}`),U(`memory: ${f.default.floor(m.default.freemem()/1024/1024)} MB(${f.default.floor(m.default.totalmem()/1024/1024)} MB)`),s){case"init":if(K(`yolk ${s} \u5f00\u59cb`),n)if(i){const e=".yolk",t=p.default.join(q,e);u.default.existsSync(t)&&(0,k.default)(t,(()=>{K(`\u7f13\u5b58\u5220\u9664 success! ${t}`)})),Y({command:"git",args:["clone","-b","master","--depth","1",i,e].concat(a)}),W(q,t)}else B("--clone \u6a21\u5f0f\u5fc5\u987b\u6709--template");else A(q);break;case"start":V()?X()?Y({command:"taro",args:["build","--type","tt","--watch"].concat(a)}):z()?Y({command:"taro",args:["build","--type","alipay","--watch"].concat(a)}):Y({command:"taro",args:["build","--type","weapp","--watch"].concat(a)}):o?(process.env.DID_YOU_KNOW="none",Y({command:"dumi",args:["dev"].concat(a)})):G()?(process.env.DID_YOU_KNOW="none",Y({command:"max",args:["dev"].concat(a)})):(process.env.DID_YOU_KNOW="none",Y({command:"umi",args:["dev"].concat(a)}));break;case"build":V()?X()?Y({command:"taro",args:["build","--type","tt"].concat(a)}):z()?Y({command:"taro",args:["build","--type","alipay"].concat(a)}):Y({command:"taro",args:["build","--type","weapp"].concat(a)}):o?(process.env.DID_YOU_KNOW="none",Y({command:"dumi",args:["build"].concat(a)})):G()?(process.env.DID_YOU_KNOW="none",Y({command:"max",args:["setup"].concat(a),complete:()=>Y({command:"max",args:["build"].concat(a)}),exit:!1})):(process.env.DID_YOU_KNOW="none",Y({command:"umi",args:["build"].concat(a)}));break;case"pre-commit":se();break;case"miniprogram-upload":if(V())if(X());else if(z());else{const{appid:t,options:s}=ae(e);U(`${t}\u4e0a\u4f20\u5f00\u59cb`),g.upload({...f.default.pick(s,["project","version","desc","setting","robot"]),onProgressUpdate:e=>{if(f.default.isString(e))U(`task: ${e}`);else{const{status:t,message:s}=e;U(`task(${t}): ${s}`)}}}).then((()=>{K(`${t}\u4e0a\u4f20\u5b8c\u6210`)}))}break;case"miniprogram-preview":if(V())if(X());else if(z());else{const{appid:t,options:s}=ae(e);U(`${t}\u4e0a\u4f20\u9884\u89c8\u5f00\u59cb`),g.preview({...f.default.pick(s,["project","version","desc","setting","robot","qrcodeFormat","qrcodeOutputDest","pagePath","searchQuery"]),onProgressUpdate:e=>{if(f.default.isString(e))U(`task: ${e}`);else{const{status:t,message:s}=e;U(`task(${t}): ${s}`)}}}).then((()=>{K(`${t}\u4e0a\u4f20\u9884\u89c8\u5b8c\u6210`)}))}break;default:T()}})).parse(process.argv):T()};ne();
|
|
2
|
+
var e=Object.create,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty,r=(e,n,r,s)=>{if(n&&"object"===typeof n||"function"===typeof n)for(let c of o(n))i.call(e,c)||c===r||t(e,c,{get:()=>n[c],enumerable:!(s=a(n,c))||s.enumerable});return e},s=(a,o,i)=>(i=null!=a?e(n(a)):{},r(!o&&a&&a.__esModule?i:t(i,"default",{value:a,enumerable:!0}),a)),c=require("child_process"),m=s(require("fs")),d=s(require("os")),l=s(require("path")),p=require("lodash"),u=require("glob"),f=s(require("inquirer")),y=s(require("miniprogram-ci")),g=require("mkdirp"),b=require("rimraf"),v=s(require("../compiled/commander")),h=s(require("../compiled/mustache")),x=s(require("../package.json")),j=require("./_util"),k=process.cwd(),S="##### CREATED BY YOLK #####",$=(e,t,a)=>{f.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:l.default.basename(l.default.basename(process.cwd()))},{type:"list",name:"dependenciesInstallType",message:"\u9009\u62e9\u4f9d\u8d56\u5b89\u88c5\u65b9\u5f0f",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((o=>{const n={projectName:o.projectName,dependenciesInstallType:o.dependenciesInstallType,yolkVersion:x.default.version},i=t||l.default.join(__dirname,`../templates/${o.type}`);(0,j.succeed)(`\u590d\u5236\u6a21\u7248 ${l.default.basename(i)}`);const r=(0,u.globSync)("**/*",{cwd:i,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(r.forEach((t=>{if(!i)return;const a=l.default.join(i,t);if(!m.default.statSync(a).isDirectory())if(t.endsWith(".tpl")){const o=m.default.readFileSync(a,j.ENCODING),i=l.default.join(e,t.replace(/\.tpl$/,"")),r=h.default.render(o,n);(0,g.mkdirpSync)(l.default.dirname(i)),(0,j.succeed)(`\u521b\u5efa ${l.default.relative(e,i)}`),m.default.writeFileSync(i,r,j.ENCODING)}else{(0,j.succeed)(`\u521b\u5efa ${t}`);const o=l.default.join(e,t);(0,g.mkdirpSync)(l.default.dirname(o)),m.default.copyFileSync(a,o)}})),(0,j.succeed)("\u590d\u5236\u6a21\u7248 success!"),a&&m.default.existsSync(i)&&(0,b.rimrafSync)(i)&&(0,j.succeed)(`\u7f13\u5b58\u5220\u9664 success! ${l.default.basename(i||"")}`),o.dependenciesInstallType)switch((0,j.succeed)("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),o.dependenciesInstallType){case"default":case"pnpm":(0,j.execCommand)({command:"pnpm",args:["install"]});break;case"yarn":(0,j.execCommand)({command:"yarn",args:["install"]});break;case"npm":(0,j.execCommand)({command:"npm",args:["install"]});break;default:}(0,j.succeed)("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},O=(e,t)=>$(e,t,!0),w=()=>m.default.existsSync(l.default.join(k,"project.config.json")),D=()=>{let e=m.default.existsSync(l.default.join(k,"node_modules/.bin/max"));if(!e)try{e=m.default.existsSync(require.resolve("@umijs/max"))}catch(t){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test((0,c.execSync)("umi -v").toString())}catch(t){}if(!e){const a=l.default.join(k,"node_modules","umi","package.json");if(m.default.existsSync(a))try{const t=JSON.parse(m.default.readFileSync(a,j.ENCODING))||{};e=t.version&&+t.version.split(".")[0]>3}catch(t){}}return e},C=()=>{const e=l.default.join(k,"project.config.json");if(m.default.existsSync(e)){const t=require(e);return t.appid}return""},P=()=>m.default.existsSync(l.default.join(k,"project.tt.json"))&&0===C().indexOf("tt"),q=()=>0===C().indexOf("20"),N=()=>{const e=l.default.join(k,".git/"),t=l.default.join(k,".git/hooks"),a=l.default.join(t,"pre-commit"),o=m.default.existsSync(e),n=m.default.existsSync(a),i=n&&m.default.readFileSync(a,j.ENCODING).includes(S);if(o&&(!n||!i)){(0,g.mkdirpSync)(t),m.default.writeFileSync(a,["#!/usr/bin/env bash","npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",S].join(d.default.EOL),j.ENCODING);try{m.default.chmodSync(a,"777")}catch(r){(0,j.fail)(`chmod ${a} failed: ${r.message}`)}(0,j.succeed)("Create pre-commit hook")}},_=async()=>{const e=(0,j.getYolkConfig)(),t=!1!==e.strict,a=e.eslintIgnore,o=e.stylelintIgnore;(0,j.warn)("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),t&&((0,j.warn)("git commit \u7981\u6b62 lint \u7684 ignore \u884c\u4e3a"),o&&(0,j.warn)(`\u901a\u8fc7 .yolkrc \u914d\u7f6e stylelintIgnore: ${o}\u3002`),a&&(0,j.warn)(`\u901a\u8fc7 .yolkrc \u914d\u7f6e eslintIgnore: ${a}\u3002`)),(0,j.execCommand)({command:"lint-staged",args:["-c",require.resolve("./.lintstagedrc")]})},I=({mAppid:e,mProject:t,mPrivateKeyPath:a,mVersion:o,mDesc:n,mRobot:i,mQrcodeFormat:r,mQrcodeOutputDest:s,mPagePath:d,mSearchQuery:p})=>{const u=m.default.existsSync(l.default.join(k,".git"))?(0,c.execSync)("git log -1 --pretty=format:%H").toString():"",f=(0,j.getProjectConfigJSON)(),g=e||f.appid,b=t||l.default.join(k,"dist"),v=a||l.default.join(k,`private.${g}.key`);if(m.default.existsSync(b)){if(m.default.existsSync(v)){const e=(0,j.getPackageJSON)(),t=o||e.version||f.version||"1.0.0",a=n||e.description||f.description,c=`${u?` commit: ${u};`:""}${a?` description: ${a};`:""}`;u&&(0,j.info)(`commit: ${u}`),(0,j.info)(`dist: ${b}`),(0,j.info)(`key: ${v}`),(0,j.info)(`appid: ${g}`),(0,j.info)(`version: ${t}`),(0,j.info)(`desc: ${c}`);const m=new y.Project({appid:g,type:"miniProgram",projectPath:b,privateKeyPath:v,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:g,options:{project:m,version:t,desc:c,setting:f.setting,robot:i,qrcodeFormat:r,qrcodeOutputDest:s,pagePath:d,searchQuery:p}}}throw Error(`\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(${v})`)}throw Error(`\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(${b})`)},E=()=>{N(),process.argv.length>2?v.default.version(x.default.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]").option("--clone","\u901a\u8fc7git clone\u62c9\u53d6\u6a21\u7248").option("--template <template>","\u6a21\u7248\u540d\u79f0\u6216\u8005clone\u6a21\u5f0f\u7684git\u5730\u5740").option("--docs","\u542f\u52a8\u6587\u6863\u6a21\u5f0f").option("--mAppid <appid>","\u5c0f\u7a0b\u5e8fappid").option("--mProject <project>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u5de5\u7a0b\u76ee\u5f55").option("--mPrivateKeyPath <privateKeyPath>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20key\u6587\u4ef6").option("--mVersion <version>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u7248\u672c\u53f7").option("--mDesc <desc>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u63cf\u8ff0").option("--mRobot <robot>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20ci\u673a\u5668\u4eba1~30").option("--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("--mQrcodeOutputDest <qrcodeOutputDest>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u4e8c\u7ef4\u7801\u6587\u4ef6\u4fdd\u5b58\u8def\u5f84").option("--mPagePath <pagePath>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84").option("--mSearchQuery <searchQuery>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84\u542f\u52a8\u53c2\u6570").action(((e,t)=>{const[a,...o]=t,{clone:n,template:i,docs:r}=e;if(a)switch((0,j.info)(`yolk version: ${x.default.version}`),(0,j.info)(`node version: ${process.version}`),(0,j.info)(`platform: ${d.default.platform()}`),(0,j.info)(`memory: ${(0,p.floor)(d.default.freemem()/1024/1024)} MB(${(0,p.floor)(d.default.totalmem()/1024/1024)} MB)`),a){case"init":if((0,j.succeed)(`yolk ${a} \u5f00\u59cb`),n)if(i){const e=".yolk",t=l.default.join(k,e);m.default.existsSync(t)&&(0,b.rimrafSync)(t)&&(0,j.succeed)(`\u7f13\u5b58\u5220\u9664 success! ${t}`),(0,j.execCommand)({command:"git",args:["clone","-b","master","--depth","1",i,e].concat(o)}),O(k,t)}else(0,j.fail)("--clone \u6a21\u5f0f\u5fc5\u987b\u6709--template");else $(k);break;case"start":w()?P()?(0,j.execCommand)({command:"taro",args:["build","--type","tt","--watch"].concat(o)}):q()?(0,j.execCommand)({command:"taro",args:["build","--type","alipay","--watch"].concat(o)}):(0,j.execCommand)({command:"taro",args:["build","--type","weapp","--watch"].concat(o)}):r?(process.env.DID_YOU_KNOW="none",(0,j.execCommand)({command:"dumi",args:["dev"].concat(o)})):D()?(process.env.DID_YOU_KNOW="none",(0,j.execCommand)({command:"max",args:["dev"].concat(o)})):(process.env.DID_YOU_KNOW="none",(0,j.execCommand)({command:"umi",args:["dev"].concat(o)}));break;case"build":w()?P()?(0,j.execCommand)({command:"taro",args:["build","--type","tt"].concat(o)}):q()?(0,j.execCommand)({command:"taro",args:["build","--type","alipay"].concat(o)}):(0,j.execCommand)({command:"taro",args:["build","--type","weapp"].concat(o)}):r?(process.env.DID_YOU_KNOW="none",(0,j.execCommand)({command:"dumi",args:["build"].concat(o)})):D()?(process.env.DID_YOU_KNOW="none",(0,j.execCommand)({command:"max",args:["setup"].concat(o),complete:()=>(0,j.execCommand)({command:"max",args:["build"].concat(o)}),exit:!1})):(process.env.DID_YOU_KNOW="none",(0,j.execCommand)({command:"umi",args:["build"].concat(o)}));break;case"pre-commit":_();break;case"miniprogram-upload":if(w())if(P());else if(q());else{const{appid:t,options:a}=I(e);(0,j.info)(`${t}\u4e0a\u4f20\u5f00\u59cb`),y.upload({...(0,p.pick)(a,["project","version","desc","setting","robot"]),onProgressUpdate:e=>{if((0,p.isString)(e))(0,j.info)(`task: ${e}`);else{const{status:t,message:a}=e;(0,j.info)(`task(${t}): ${a}`)}}}).then((()=>{(0,j.succeed)(`${t}\u4e0a\u4f20\u5b8c\u6210`)}))}break;case"miniprogram-preview":if(w())if(P());else if(q());else{const{appid:t,options:a}=I(e);(0,j.info)(`${t}\u4e0a\u4f20\u9884\u89c8\u5f00\u59cb`),y.preview({...(0,p.pick)(a,["project","version","desc","setting","robot","qrcodeFormat","qrcodeOutputDest","pagePath","searchQuery"]),onProgressUpdate:e=>{if((0,p.isString)(e))(0,j.info)(`task: ${e}`);else{const{status:t,message:a}=e;(0,j.info)(`task(${t}): ${a}`)}}}).then((()=>{(0,j.succeed)(`${t}\u4e0a\u4f20\u9884\u89c8\u5b8c\u6210`)}))}break;default:(0,j.breakExit)()}})).parse(process.argv):(0,j.breakExit)()};E();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baic/yolk-cli",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.135",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/303394539/yolk.git"
|
|
@@ -27,31 +27,28 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@babel/runtime": "~7.x",
|
|
29
29
|
"@types/inquirer": "~8.x",
|
|
30
|
+
"@types/lint-staged": "~13.2.x",
|
|
30
31
|
"@types/lodash": "~4.x",
|
|
31
|
-
"
|
|
32
|
+
"glob": "~10.x",
|
|
32
33
|
"inquirer": "~8.x",
|
|
34
|
+
"lint-staged": "~13.2.x",
|
|
33
35
|
"lodash": "~4.x",
|
|
34
36
|
"miniprogram-ci": "~1.9.x",
|
|
37
|
+
"mkdirp": "~3.0.x",
|
|
35
38
|
"ora": "5.4.1",
|
|
36
|
-
"
|
|
39
|
+
"postcss": "~8.x",
|
|
40
|
+
"postcss-less": "~6.x",
|
|
41
|
+
"postcss-scss": "~4.x",
|
|
42
|
+
"rimraf": "~5.0.x",
|
|
37
43
|
"v8-compile-cache": "~2.3.x"
|
|
38
44
|
},
|
|
39
45
|
"devDependencies": {
|
|
40
|
-
"@types/glob": "~8.x",
|
|
41
|
-
"@types/minimatch": "~5.1.x",
|
|
42
|
-
"@types/mkdirp": "~1.0.x",
|
|
43
46
|
"@types/mustache": "~4.2.x",
|
|
44
|
-
"@types/rimraf": "~3.0.x",
|
|
45
47
|
"commander": "~6.x",
|
|
46
|
-
"
|
|
47
|
-
"minimatch": "~5.1.x",
|
|
48
|
-
"mkdirp": "~1.0.x",
|
|
49
|
-
"mustache": "~4.2.x",
|
|
50
|
-
"rimraf": "~3.0.x",
|
|
51
|
-
"staged-git-files": "~1.3.x"
|
|
48
|
+
"mustache": "~4.2.x"
|
|
52
49
|
},
|
|
53
50
|
"publishConfig": {
|
|
54
51
|
"access": "public"
|
|
55
52
|
},
|
|
56
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "6e12c4022bbfc2a15ec66a286b2f0a9e037fad37"
|
|
57
54
|
}
|
|
@@ -1,28 +1,3 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"target": "es2017",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"removeComments": false,
|
|
6
|
-
"preserveConstEnums": true,
|
|
7
|
-
"moduleResolution": "node",
|
|
8
|
-
"experimentalDecorators": true,
|
|
9
|
-
"noImplicitAny": false,
|
|
10
|
-
"allowSyntheticDefaultImports": true,
|
|
11
|
-
"outDir": "lib",
|
|
12
|
-
"noUnusedLocals": true,
|
|
13
|
-
"noUnusedParameters": true,
|
|
14
|
-
"strictNullChecks": true,
|
|
15
|
-
"sourceMap": true,
|
|
16
|
-
"baseUrl": ".",
|
|
17
|
-
"rootDir": ".",
|
|
18
|
-
"jsx": "react",
|
|
19
|
-
"allowJs": true,
|
|
20
|
-
"resolveJsonModule": true,
|
|
21
|
-
"typeRoots": ["node_modules/@types", "global.d.ts"],
|
|
22
|
-
"paths": {
|
|
23
|
-
"@/*": ["src/*"]
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"exclude": ["node_modules", "dist"],
|
|
27
|
-
"compileOnSave": false
|
|
2
|
+
"extends": "@baic/yolk-taro/tsconfig.json"
|
|
28
3
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isFunction, isObject } from 'lodash';
|
|
2
2
|
|
|
3
3
|
import type { FunctionComponent } from 'react';
|
|
4
4
|
import { createElement } from 'react';
|
|
@@ -56,14 +56,14 @@ export default () => {
|
|
|
56
56
|
<Tabs defaultActiveKey={keys[0]}>
|
|
57
57
|
{keys.map((key) => {
|
|
58
58
|
const tab = tabs[key];
|
|
59
|
-
if (
|
|
59
|
+
if (isFunction(tab)) {
|
|
60
60
|
return (
|
|
61
61
|
<Tab key={key} title={key}>
|
|
62
62
|
{createElement(tab)}
|
|
63
63
|
</Tab>
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
|
-
if (
|
|
66
|
+
if (isObject(tab)) {
|
|
67
67
|
const keys2 = Object.keys(tab);
|
|
68
68
|
return (
|
|
69
69
|
<Tab key={key} title={key}>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { isFunction, isObject } from 'lodash';
|
|
4
4
|
|
|
5
5
|
import { Tabs, Collapse } from 'antd-mobile';
|
|
6
6
|
|
|
@@ -55,14 +55,14 @@ export default () => {
|
|
|
55
55
|
<Tabs defaultActiveKey={keys[0]}>
|
|
56
56
|
{keys.map((key) => {
|
|
57
57
|
const tab = tabs[key];
|
|
58
|
-
if (
|
|
58
|
+
if (isFunction(tab)) {
|
|
59
59
|
return (
|
|
60
60
|
<Tab key={key} title={key}>
|
|
61
61
|
{React.createElement(tab)}
|
|
62
62
|
</Tab>
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
|
-
if (
|
|
65
|
+
if (isObject(tab)) {
|
|
66
66
|
const keys2 = Object.keys(tab);
|
|
67
67
|
return (
|
|
68
68
|
<Tab key={key} title={key}>
|
|
@@ -7,13 +7,13 @@ android {
|
|
|
7
7
|
|
|
8
8
|
defaultConfig {
|
|
9
9
|
applicationId "plus.H5ECA1DEE"
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
minSdkVersion 21
|
|
11
|
+
targetSdkVersion 25
|
|
12
12
|
versionCode 100
|
|
13
13
|
versionName '1.0.0'
|
|
14
14
|
multiDexEnabled true
|
|
15
15
|
ndk {
|
|
16
|
-
abiFilters 'armeabi-v7a'
|
|
16
|
+
abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a'
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -51,16 +51,31 @@ android {
|
|
|
51
51
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
52
52
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
packagingOptions {
|
|
56
|
+
exclude 'resources.arsc'
|
|
57
|
+
exclude 'AndroidManifest.xml'
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
aaptOptions {
|
|
61
|
+
additionalParameters '--auto-add-overlay'
|
|
62
|
+
ignoreAssetsPattern "!.svn:!.git:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
lint {
|
|
66
|
+
checkReleaseBuilds false
|
|
67
|
+
}
|
|
54
68
|
}
|
|
55
69
|
|
|
56
70
|
dependencies {
|
|
57
71
|
// base
|
|
58
72
|
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
|
|
59
|
-
implementation 'androidx.appcompat:appcompat:1.
|
|
73
|
+
implementation 'androidx.appcompat:appcompat:1.4.1'
|
|
60
74
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
|
61
75
|
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
|
62
76
|
implementation 'com.facebook.fresco:fresco:2.6.0'
|
|
63
77
|
implementation 'com.facebook.fresco:animated-gif:2.6.0'
|
|
64
78
|
implementation 'com.github.bumptech.glide:glide:4.13.1'
|
|
65
79
|
implementation 'com.alibaba:fastjson:1.1.46.android'
|
|
80
|
+
implementation 'androidx.webkit:webkit:1.4.0'
|
|
66
81
|
}
|
|
Binary file
|
|
@@ -15,8 +15,8 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
|
|
15
15
|
# Android operating system, and which are packaged with your app"s APK
|
|
16
16
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
|
17
17
|
android.useAndroidX=true
|
|
18
|
+
android.enableJetifier=true
|
|
18
19
|
# Enables namespacing of each library's R class so that its R class includes only the
|
|
19
20
|
# resources declared in the library itself and none from the library's dependencies,
|
|
20
21
|
# thereby reducing the size of the R class for that library
|
|
21
22
|
android.nonTransitiveRClass=true
|
|
22
|
-
android.useNewApkCreator=false
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isFunction, unionBy } from 'lodash';
|
|
2
2
|
|
|
3
3
|
import { Toast } from 'antd-mobile';
|
|
4
4
|
|
|
@@ -112,7 +112,7 @@ class Bluetooth {
|
|
|
112
112
|
content: '蓝牙设备断开',
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
if (
|
|
115
|
+
if (isFunction(e)) {
|
|
116
116
|
e({ connected, deviceId });
|
|
117
117
|
}
|
|
118
118
|
});
|
|
@@ -123,7 +123,7 @@ class Bluetooth {
|
|
|
123
123
|
) {
|
|
124
124
|
const { bluetooth } = window.plus || {};
|
|
125
125
|
bluetooth.onBluetoothDeviceFound(({ devices = [] }) => {
|
|
126
|
-
this.devices =
|
|
126
|
+
this.devices = unionBy(
|
|
127
127
|
this.devices.concat(
|
|
128
128
|
devices.filter(
|
|
129
129
|
({ name }: plus.Bluetooth.BluetoothDeviceInfo) =>
|
|
@@ -132,7 +132,7 @@ class Bluetooth {
|
|
|
132
132
|
),
|
|
133
133
|
'deviceId',
|
|
134
134
|
);
|
|
135
|
-
if (
|
|
135
|
+
if (isFunction(e)) {
|
|
136
136
|
e({ devices: this.devices });
|
|
137
137
|
}
|
|
138
138
|
});
|
|
@@ -142,7 +142,7 @@ class Bluetooth {
|
|
|
142
142
|
const { bluetooth } = window.plus || {};
|
|
143
143
|
const { notifyInterval = 200 } = this.options;
|
|
144
144
|
bluetooth.onBLECharacteristicValueChange(({ value }) => {
|
|
145
|
-
if (
|
|
145
|
+
if (isFunction(onChange)) {
|
|
146
146
|
if (notifyInterval > 0) {
|
|
147
147
|
if (!this.isNotifyInterval) {
|
|
148
148
|
onChange(value);
|
|
@@ -222,7 +222,7 @@ class Bluetooth {
|
|
|
222
222
|
deviceId,
|
|
223
223
|
serviceId,
|
|
224
224
|
characteristicId,
|
|
225
|
-
value:
|
|
225
|
+
value: isFunction(onWriteValue) ? onWriteValue() : new ArrayBuffer(0),
|
|
226
226
|
});
|
|
227
227
|
if (writeInterval > 0) {
|
|
228
228
|
this.writeTimeoutId = setTimeout(
|