@baic/yolk-cli 2.1.0-alpha.251 → 2.1.0-alpha.253
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/README.md +4 -4
- package/compiled/commander/index.d.ts +109 -39
- package/compiled/commander/package.json +1 -1
- package/es/yolk.js +1 -1
- package/lib/yolk.js +1 -1
- package/package.json +11 -11
- package/templates/taro-miniprogram/.gitignore.tpl +6 -1
- package/templates/umi-mobile/.gitignore.tpl +5 -0
- package/templates/umi-mobile/package.json.tpl +3 -2
- package/templates/umi-mobile/tsconfig.json +5 -0
- package/templates/umi-mobile/yest.config.ts +10 -0
- package/templates/umi-mobile-h5+app/.gitignore.tpl +5 -0
- package/templates/umi-mobile-h5+app/package.json.tpl +2 -1
- package/templates/umi-mobile-h5+app/tsconfig.json +5 -0
- package/templates/umi-mobile-h5+app/yest.config.ts +10 -0
- package/templates/umi-mobile-native/.gitignore.tpl +5 -0
- package/templates/umi-mobile-native/package.json.tpl +2 -1
- package/templates/umi-mobile-native/tsconfig.json +5 -0
- package/templates/umi-mobile-native/yest.config.ts +10 -0
- package/templates/umi-mobile-uni-app/.gitignore.tpl +5 -0
- package/templates/umi-mobile-uni-app/package.json.tpl +2 -1
- package/templates/umi-mobile-uni-app/tsconfig.json +5 -0
- package/templates/umi-mobile-uni-app/yest.config.ts +10 -0
- package/templates/umi-web/.gitignore.tpl +5 -0
- package/templates/umi-web/package.json.tpl +2 -1
- package/templates/umi-web/tsconfig.json +5 -0
- package/templates/umi-web/yest.config.ts +8 -0
- package/templates/umi-web-screen/.gitignore.tpl +5 -0
- package/templates/umi-web-screen/package.json.tpl +2 -1
- package/templates/umi-web-screen/tsconfig.json +5 -0
- package/templates/umi-web-screen/yest.config.ts +8 -0
package/README.md
CHANGED
|
@@ -3,25 +3,25 @@
|
|
|
3
3
|
## 脚手架
|
|
4
4
|
|
|
5
5
|
```shell
|
|
6
|
-
|
|
6
|
+
npm install -g @baic/yolk-cli
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
## 初始化项目
|
|
10
10
|
|
|
11
11
|
```shell
|
|
12
|
-
|
|
12
|
+
yolk init
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## 启动项目
|
|
16
16
|
|
|
17
17
|
```shell
|
|
18
|
-
|
|
18
|
+
yolk start
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## 编译项目
|
|
22
22
|
|
|
23
23
|
```shell
|
|
24
|
-
|
|
24
|
+
yolk build
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## .yolkrc
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export declare interface AddHelpTextContext {
|
|
1
|
+
export declare interface AddHelpTextContext {
|
|
2
|
+
// passed to text function used with .addHelpText()
|
|
2
3
|
error: boolean;
|
|
3
4
|
command: Command;
|
|
4
5
|
}
|
|
@@ -95,7 +96,10 @@ export declare class Command {
|
|
|
95
96
|
* @param opts - configuration options
|
|
96
97
|
* @returns new command
|
|
97
98
|
*/
|
|
98
|
-
command(
|
|
99
|
+
command(
|
|
100
|
+
nameAndArgs: string,
|
|
101
|
+
opts?: CommandOptions,
|
|
102
|
+
): ReturnType<this['createCommand']>;
|
|
99
103
|
/**
|
|
100
104
|
* Define a command, implemented in a separate executable file.
|
|
101
105
|
*
|
|
@@ -114,7 +118,11 @@ export declare class Command {
|
|
|
114
118
|
* @param opts - configuration options
|
|
115
119
|
* @returns `this` command for chaining
|
|
116
120
|
*/
|
|
117
|
-
command(
|
|
121
|
+
command(
|
|
122
|
+
nameAndArgs: string,
|
|
123
|
+
description: string,
|
|
124
|
+
opts?: ExecutableCommandOptions,
|
|
125
|
+
): this;
|
|
118
126
|
|
|
119
127
|
/**
|
|
120
128
|
* Factory routine to create a new unattached command.
|
|
@@ -155,7 +163,12 @@ export declare class Command {
|
|
|
155
163
|
*
|
|
156
164
|
* @returns `this` command for chaining
|
|
157
165
|
*/
|
|
158
|
-
argument<T>(
|
|
166
|
+
argument<T>(
|
|
167
|
+
flags: string,
|
|
168
|
+
description: string,
|
|
169
|
+
fn: (value: string, previous: T) => T,
|
|
170
|
+
defaultValue?: T,
|
|
171
|
+
): this;
|
|
159
172
|
argument(name: string, description?: string, defaultValue?: unknown): this;
|
|
160
173
|
|
|
161
174
|
/**
|
|
@@ -205,7 +218,13 @@ export declare class Command {
|
|
|
205
218
|
/**
|
|
206
219
|
* Add hook for life cycle event.
|
|
207
220
|
*/
|
|
208
|
-
hook(
|
|
221
|
+
hook(
|
|
222
|
+
event: HookEvent,
|
|
223
|
+
listener: (
|
|
224
|
+
thisCommand: Command,
|
|
225
|
+
actionCommand: Command,
|
|
226
|
+
) => void | Promise<void>,
|
|
227
|
+
): this;
|
|
209
228
|
|
|
210
229
|
/**
|
|
211
230
|
* Register callback to use as replacement for calling process.exit.
|
|
@@ -305,10 +324,24 @@ export declare class Command {
|
|
|
305
324
|
*
|
|
306
325
|
* @returns `this` command for chaining
|
|
307
326
|
*/
|
|
308
|
-
option(
|
|
309
|
-
|
|
327
|
+
option(
|
|
328
|
+
flags: string,
|
|
329
|
+
description?: string,
|
|
330
|
+
defaultValue?: string | boolean | string[],
|
|
331
|
+
): this;
|
|
332
|
+
option<T>(
|
|
333
|
+
flags: string,
|
|
334
|
+
description: string,
|
|
335
|
+
parseArg: (value: string, previous: T) => T,
|
|
336
|
+
defaultValue?: T,
|
|
337
|
+
): this;
|
|
310
338
|
/** @deprecated since v7, instead use choices or a custom function */
|
|
311
|
-
option(
|
|
339
|
+
option(
|
|
340
|
+
flags: string,
|
|
341
|
+
description: string,
|
|
342
|
+
regexp: RegExp,
|
|
343
|
+
defaultValue?: string | boolean | string[],
|
|
344
|
+
): this;
|
|
312
345
|
|
|
313
346
|
/**
|
|
314
347
|
* Define a required option, which must have a value after parsing. This usually means
|
|
@@ -316,10 +349,24 @@ export declare class Command {
|
|
|
316
349
|
*
|
|
317
350
|
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
|
|
318
351
|
*/
|
|
319
|
-
requiredOption(
|
|
320
|
-
|
|
352
|
+
requiredOption(
|
|
353
|
+
flags: string,
|
|
354
|
+
description?: string,
|
|
355
|
+
defaultValue?: string | boolean | string[],
|
|
356
|
+
): this;
|
|
357
|
+
requiredOption<T>(
|
|
358
|
+
flags: string,
|
|
359
|
+
description: string,
|
|
360
|
+
parseArg: (value: string, previous: T) => T,
|
|
361
|
+
defaultValue?: T,
|
|
362
|
+
): this;
|
|
321
363
|
/** @deprecated since v7, instead use choices or a custom function */
|
|
322
|
-
requiredOption(
|
|
364
|
+
requiredOption(
|
|
365
|
+
flags: string,
|
|
366
|
+
description: string,
|
|
367
|
+
regexp: RegExp,
|
|
368
|
+
defaultValue?: string | boolean | string[],
|
|
369
|
+
): this;
|
|
323
370
|
|
|
324
371
|
/**
|
|
325
372
|
* Factory routine to create a new unattached option.
|
|
@@ -344,7 +391,9 @@ export declare class Command {
|
|
|
344
391
|
* @returns `this` command for chaining
|
|
345
392
|
*/
|
|
346
393
|
storeOptionsAsProperties<T extends OptionValues>(): this & T;
|
|
347
|
-
storeOptionsAsProperties<T extends OptionValues>(
|
|
394
|
+
storeOptionsAsProperties<T extends OptionValues>(
|
|
395
|
+
storeAsProperties: true,
|
|
396
|
+
): this & T;
|
|
348
397
|
storeOptionsAsProperties(storeAsProperties?: boolean): this;
|
|
349
398
|
|
|
350
399
|
/**
|
|
@@ -360,7 +409,11 @@ export declare class Command {
|
|
|
360
409
|
/**
|
|
361
410
|
* Store option value and where the value came from.
|
|
362
411
|
*/
|
|
363
|
-
setOptionValueWithSource(
|
|
412
|
+
setOptionValueWithSource(
|
|
413
|
+
key: string,
|
|
414
|
+
value: unknown,
|
|
415
|
+
source: OptionValueSource,
|
|
416
|
+
): this;
|
|
364
417
|
|
|
365
418
|
/**
|
|
366
419
|
* Get source of option value.
|
|
@@ -424,38 +477,49 @@ export declare class Command {
|
|
|
424
477
|
/**
|
|
425
478
|
* Parse `argv`, setting options and invoking commands when defined.
|
|
426
479
|
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
480
|
+
* Use parseAsync instead of parse if any of your action handlers are async.
|
|
481
|
+
*
|
|
482
|
+
* Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
|
|
483
|
+
*
|
|
484
|
+
* Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
|
|
485
|
+
* - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
|
|
486
|
+
* - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
|
|
487
|
+
* - `'user'`: just user arguments
|
|
429
488
|
*
|
|
430
489
|
* @example
|
|
431
490
|
* ```
|
|
432
|
-
* program.parse(process.argv
|
|
433
|
-
* program.parse(); //
|
|
491
|
+
* program.parse(); // parse process.argv and auto-detect electron and special node flags
|
|
492
|
+
* program.parse(process.argv); // assume argv[0] is app and argv[1] is script
|
|
434
493
|
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
435
494
|
* ```
|
|
436
495
|
*
|
|
437
496
|
* @returns `this` command for chaining
|
|
438
497
|
*/
|
|
439
|
-
parse(argv?: readonly string[],
|
|
498
|
+
parse(argv?: readonly string[], parseOptions?: ParseOptions): this;
|
|
440
499
|
|
|
441
500
|
/**
|
|
442
501
|
* Parse `argv`, setting options and invoking commands when defined.
|
|
443
502
|
*
|
|
444
|
-
*
|
|
503
|
+
* Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
|
|
445
504
|
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
505
|
+
* Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
|
|
506
|
+
* - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
|
|
507
|
+
* - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
|
|
508
|
+
* - `'user'`: just user arguments
|
|
448
509
|
*
|
|
449
510
|
* @example
|
|
450
511
|
* ```
|
|
451
|
-
* program.parseAsync(process.argv
|
|
452
|
-
* program.parseAsync(); //
|
|
453
|
-
* program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
512
|
+
* await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
|
|
513
|
+
* await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
|
|
514
|
+
* await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
454
515
|
* ```
|
|
455
516
|
*
|
|
456
517
|
* @returns Promise
|
|
457
518
|
*/
|
|
458
|
-
parseAsync(
|
|
519
|
+
parseAsync(
|
|
520
|
+
argv?: readonly string[],
|
|
521
|
+
parseOptions?: ParseOptions,
|
|
522
|
+
): Promise<this>;
|
|
459
523
|
|
|
460
524
|
/**
|
|
461
525
|
* Parse options from `argv` removing known options,
|
|
@@ -630,7 +694,10 @@ export declare class Command {
|
|
|
630
694
|
* and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
|
|
631
695
|
*/
|
|
632
696
|
addHelpText(position: AddHelpTextPosition, text: string): this;
|
|
633
|
-
addHelpText(
|
|
697
|
+
addHelpText(
|
|
698
|
+
position: AddHelpTextPosition,
|
|
699
|
+
text: (context: AddHelpTextContext) => string,
|
|
700
|
+
): this;
|
|
634
701
|
|
|
635
702
|
/**
|
|
636
703
|
* Add a listener (callback) for when events occur. (Implemented using EventEmitter.)
|
|
@@ -649,7 +716,6 @@ export declare class CommanderError extends Error {
|
|
|
649
716
|
* @param exitCode - suggested exit code which could be used with process.exit
|
|
650
717
|
* @param code - an id string representing the error
|
|
651
718
|
* @param message - human-readable description of the error
|
|
652
|
-
* @constructor
|
|
653
719
|
*/
|
|
654
720
|
constructor(exitCode: number, code: string, message: string);
|
|
655
721
|
}
|
|
@@ -667,7 +733,8 @@ export declare function createCommand(name?: string): Command;
|
|
|
667
733
|
|
|
668
734
|
export declare function createOption(flags: string, description?: string): Option_2;
|
|
669
735
|
|
|
670
|
-
export declare interface ErrorOptions {
|
|
736
|
+
export declare interface ErrorOptions {
|
|
737
|
+
// optional parameter for error()
|
|
671
738
|
/** an id string representing the error */
|
|
672
739
|
code?: string;
|
|
673
740
|
/** suggested exit code which could be used with process.exit */
|
|
@@ -729,7 +796,12 @@ export declare class Help {
|
|
|
729
796
|
* Wrap the given string to width characters per line, with lines after the first indented.
|
|
730
797
|
* Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
|
|
731
798
|
*/
|
|
732
|
-
wrap(
|
|
799
|
+
wrap(
|
|
800
|
+
str: string,
|
|
801
|
+
width: number,
|
|
802
|
+
indent: number,
|
|
803
|
+
minColumnWidth?: number,
|
|
804
|
+
): string;
|
|
733
805
|
|
|
734
806
|
/** Generate the built-in help text. */
|
|
735
807
|
formatHelp(cmd: Command, helper: Help): string;
|
|
@@ -737,7 +809,8 @@ export declare class Help {
|
|
|
737
809
|
|
|
738
810
|
export declare type HelpConfiguration = Partial<Help>;
|
|
739
811
|
|
|
740
|
-
export declare interface HelpContext {
|
|
812
|
+
export declare interface HelpContext {
|
|
813
|
+
// optional parameter for .help() and .outputHelp()
|
|
741
814
|
error: boolean;
|
|
742
815
|
}
|
|
743
816
|
|
|
@@ -747,14 +820,15 @@ declare class InvalidArgumentError extends CommanderError {
|
|
|
747
820
|
/**
|
|
748
821
|
* Constructs the InvalidArgumentError class
|
|
749
822
|
* @param message - explanation of why argument is invalid
|
|
750
|
-
* @constructor
|
|
751
823
|
*/
|
|
752
824
|
constructor(message: string);
|
|
753
825
|
}
|
|
754
826
|
export { InvalidArgumentError }
|
|
755
827
|
export { InvalidArgumentError as InvalidOptionArgumentError }
|
|
756
828
|
|
|
757
|
-
declare type LiteralUnion<LiteralType, BaseType extends string | number> =
|
|
829
|
+
declare type LiteralUnion<LiteralType, BaseType extends string | number> =
|
|
830
|
+
| LiteralType
|
|
831
|
+
| (BaseType & Record<never, never>);
|
|
758
832
|
|
|
759
833
|
declare class Option_2 {
|
|
760
834
|
flags: string;
|
|
@@ -826,11 +900,6 @@ declare class Option_2 {
|
|
|
826
900
|
*/
|
|
827
901
|
env(name: string): this;
|
|
828
902
|
|
|
829
|
-
/**
|
|
830
|
-
* Calculate the full description, including defaultValue etc.
|
|
831
|
-
*/
|
|
832
|
-
fullDescription(): string;
|
|
833
|
-
|
|
834
903
|
/**
|
|
835
904
|
* Set the custom handler for processing CLI option arguments into option values.
|
|
836
905
|
*/
|
|
@@ -873,7 +942,9 @@ export { Option_2 as Option }
|
|
|
873
942
|
|
|
874
943
|
export declare type OptionValues = Record<string, any>;
|
|
875
944
|
|
|
876
|
-
export declare type OptionValueSource =
|
|
945
|
+
export declare type OptionValueSource =
|
|
946
|
+
| LiteralUnion<'default' | 'config' | 'env' | 'cli' | 'implied', string>
|
|
947
|
+
| undefined;
|
|
877
948
|
|
|
878
949
|
export declare interface OutputConfiguration {
|
|
879
950
|
writeOut?(str: string): void;
|
|
@@ -881,7 +952,6 @@ export declare interface OutputConfiguration {
|
|
|
881
952
|
getOutHelpWidth?(): number;
|
|
882
953
|
getErrHelpWidth?(): number;
|
|
883
954
|
outputError?(str: string, write: (str: string) => void): void;
|
|
884
|
-
|
|
885
955
|
}
|
|
886
956
|
|
|
887
957
|
export declare interface ParseOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"commander","version":"12.1.0","author":"TJ Holowaychuk <tj@vision-media.ca>","license":"MIT","_lastModified":"
|
|
1
|
+
{"name":"commander","version":"12.1.0","author":"TJ Holowaychuk <tj@vision-media.ca>","license":"MIT","_lastModified":"2025-06-05T07:08:22.152Z"}
|
package/es/yolk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
import e from"@babel/runtime/helpers/defineProperty";function t(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function o(o){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?t(Object(i),!0).forEach((function(t){e(o,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach((function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))}))}return o}import{execSync as r}from"node:child_process";import{chmodSync as i,copyFileSync as a,existsSync as n,readFileSync as s,statSync as c,writeFileSync as m}from"node:fs";import p from"node:os";import{basename as d,dirname as l,join as u,relative as g}from"node:path";import{floor as f,isString as y}from"lodash";import{globSync as h}from"glob";import v from"inquirer";import*as b from"miniprogram-ci";import{mkdirpSync as $}from"mkdirp";import{program as j}from"../compiled/commander";import k from"../compiled/mustache";import O from"../package.json";import{breakExit as w,cwd as P,ENCODING as x,error as D,execCommand as S,getPackageJSON as E,getProjectConfigJSON as q,getYolkConfig as _,info as Q,ready as N,rimrafSync as F,warn as K}from"./_util";const L="##### CREATED BY YOLK #####",R=(e,t,o)=>{v.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:"taro-miniprogram template",value:"taro-miniprogram"}]},{type:"input",name:"projectName",message:"\u9879\u76ee\u540d\u79f0",default:d(d(process.cwd()))},{type:"list",name:"packageManager",message:"\u9009\u62e9\u5305\u7ba1\u7406\u5668(\u9ed8\u8ba4\uff1apnpm\uff0c\u63a8\u8350\uff1apnpm)",default:"default",choices:[{name:"\u9ed8\u8ba4\u5b89\u88c5",value:"default"},{name:"\u8df3\u8fc7\u5b89\u88c5",value:!1},{name:"pnpm install",value:"pnpm"},{name:"yarn install",value:"yarn"},{name:"npm install",value:"npm"}]}]).then((({type:r,projectName:i,packageManager:p})=>{const f={projectName:i,packageManager:"default"===p?"pnpm":p,yolkVersion:O.version};if("umi-mobile-uni-app"===r)return void K("\u6682\u4e0d\u652f\u6301");const y=t||u(__dirname,`../templates/${r}`);N(`\u590d\u5236\u6a21\u7248 ${d(y)}`);const v=h("**/*",{cwd:y,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(v.forEach((t=>{if(!y)return;const o=u(y,t);if(!c(o).isDirectory())if(t.endsWith(".tpl")){const r=s(o,x),i=u(e,t.replace(/\.tpl$/,"")),a=k.render(r,f);$(l(i)),N(`\u521b\u5efa ${g(e,i)}`),m(i,a,x)}else{N(`\u521b\u5efa ${t}`);const r=u(e,t);$(l(r)),a(o,r)}})),N("\u590d\u5236\u6a21\u7248 success!"),o&&n(y)&&F(y)&&N(`\u7f13\u5b58\u5220\u9664 success! ${d(y||"")}`),p)switch(N("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),p){case"default":case"pnpm":S({command:"pnpm",args:["install"]});break;case"yarn":S({command:"yarn",args:["install"]});break;case"npm":S({command:"npm",args:["install"]});break;default:}N("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},M=(e,t)=>R(e,t,!0),B=()=>n(u(P,"project.config.json")),I=()=>{let e=n(u(P,"node_modules/.bin/max"));if(!e)try{e=n(require.resolve("@umijs/max"))}catch(t){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test(r("umi -v").toString())}catch(t){}if(!e){const o=u(P,"node_modules","umi","package.json");if(n(o))try{const t=JSON.parse(s(o,x))||{};e=t.version&&+t.version.split(".")[0]>3}catch(t){}}return e},U=()=>{const e=u(P,"project.config.json");if(n(e)){const t=require(e);return t.appid}return""},W=()=>n(u(P,"project.tt.json"))&&0===U().indexOf("tt"),A=()=>0===U().indexOf("20"),T=()=>{const e=_(),t=u(P,".husky/pre-commit"),o=u(P,".git/"),r=u(P,".git/hooks"),a=u(r,"pre-commit"),c=n(t),d=n(o),l=n(r),g=n(a),f=!1!==e.initPreCommit&&!c,y=[L,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",L].join(p.EOL),h=e=>{let t=e||"";return t&&t.indexOf(L)>=0&&(t=`${t.substring(0,t.indexOf(L))}${t.substring(t.lastIndexOf(L)+L.length)}`.replace(/(\r|\n)+$/gu,"")),t};if(d)if(f)if(l||($(r),N("create .git/hooks")),g){try{i(a,"777")}catch(v){D(`chmod ${a} failed: ${v.message}`)}const e=h(s(a,x).toString());m(a,(e.indexOf("#!/")<0?["#!/bin/sh"]:[]).concat([e,y]).filter((e=>!!e)).join(p.EOL),x)}else m(a,["#!/bin/sh",y].join(p.EOL),x),N("create pre-commit");else if(g){const e=h(s(a,x).toString());m(a,e,x)}},V=()=>{K("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),S({command:"lint-staged",args:["-c",require.resolve("./lintstagedrc")]})},X=({mAppid:e,mProject:t,mPrivateKeyPath:i,mVersion:a,mDesc:s,mRobot:c,mQrcodeFormat:m,mQrcodeOutputDest:p,mPagePath:d,mSearchQuery:l})=>{let g="";try{g=n(u(P,".git"))?r("git log -1 --pretty=format:%H").toString():""}catch(D){}const f=q(),y=e||f.appid,h=t||u(P,"dist"),v=i||u(P,`private.${y}.key`);if(n(h)){if(n(v)){const e=E(),t=a||e.version||f.version||"1.0.0",r=s||e.description||f.description,i=`${g?` commit: ${g};`:""}${r?` description: ${r};`:""}`;g&&Q(`commit: ${g}`),Q(`dist: ${h}`),Q(`key: ${v}`),Q(`appid: ${y}`),Q(`version: ${t}`),Q(`desc: ${i}`);const n=new b.Project({appid:y,type:"miniProgram",projectPath:h,privateKeyPath:v,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:y,options:{project:n,version:t,desc:i,setting:o(o({},f.setting),{},{es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1}),robot:c,qrcodeFormat:m,qrcodeOutputDest:p,pagePath:d,searchQuery:l}}}throw Error(`\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(${v})`)}throw Error(`\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(${h})`)},C=()=>{let e="";try{e=r(`npm view ${O.name} version`,{timeout:3e3}).toString().replace(/\n/g,"")}catch(t){}Q(`yolk version: ${O.version}${e&&e!==O.version?`(latest\uff1a${e})`:""}`),Q(`node version: ${process.version}`),Q(`platform: ${p.platform()}`),Q(`memory: ${f(p.freemem()/1024/1024)} MB(${f(p.totalmem()/1024/1024)} MB)`)},H=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"),J=/(\w+)=('(.*)'|"(.*)"|(.*))/giu,Y=e=>{process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";const t=[];return null===e||void 0===e||e.forEach((e=>{if(J.test(e)){const[t,o]=e.split("=");process.env[t]=o,Q(`\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a${t}=${o}`)}else t.push(e)})),t},G=()=>{T(),process.argv.length>2?(j.version(O.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),j.command("init").description("\u521d\u59cb\u5316\u9879\u76ee").option("--clone <template>","\u5982\u679c\u9700\u8981\uff0c\u53ef\u901a\u8fc7git clone\u62c9\u53d6\u6a21\u7248\uff0c\u9ed8\u8ba4\u53d6cli\u9ed8\u8ba4\u6a21\u7248").action((({clone:e},{args:t})=>{if(C(),N("yolk init \u5f00\u59cb"),e){const o=".yolk",r=u(P,o);n(r)&&F(r)&&N(`\u7f13\u5b58\u5220\u9664 success! ${r}`),S({command:"git",args:["clone","-b","master","--depth","1",e,o].concat(t)}),M(P,r)}else R(P)})),j.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{C();const o=Y(t);B()?W()?S({command:"taro",args:["build","--type","tt","--watch"].concat(o)}):A()?S({command:"taro",args:["build","--type","alipay","--watch"].concat(o)}):S({command:"taro",args:["build","--type","weapp","--watch"].concat(o)}):e?S({command:"dumi",args:["dev"].concat(o)}):I()?S({command:"max",args:["dev"].concat(o)}):S({command:"umi",args:["dev"].concat(o)})})),j.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{C();const o=Y(t);B()?W()?S({command:"taro",args:["build","--type","tt"].concat(o)}):A()?S({command:"taro",args:["build","--type","alipay"].concat(o)}):S({command:"taro",args:["build","--type","weapp"].concat(o)}):e?S({command:"dumi",args:["build"].concat(o)}):I()?S({command:"max",args:["setup"].concat(o),complete:()=>S({command:"max",args:["build"].concat(o)}),exit:!1}):S({command:"umi",args:["build"].concat(o)})})),j.command("init-pre-commit").description("\u521d\u59cb\u5316 commit hook").action(T),j.command("pre-commit").description("\u6267\u884ccommit hook").action(V),H(j.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((e=>{if(B())if(W());else if(A());else{const{appid:t,options:{project:o,version:r,desc:i,setting:a,robot:n}}=X(e);Q(`${t} \u4e0a\u4f20\u5f00\u59cb`),b.upload({project:o,version:r,desc:i,setting:a,robot:n,onProgressUpdate:e=>{if(y(e))Q(`task: ${e}`);else{const{status:t,message:o}=e;Q(`task(${t}): ${o}`)}}}).then((()=>{N(`${t} \u4e0a\u4f20\u5b8c\u6210`)}))}else D("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),H(j.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((e=>{if(B())if(W());else if(A());else{const{appid:t,options:{project:o,version:r,desc:i,setting:a,robot:n,qrcodeFormat:s,qrcodeOutputDest:c,pagePath:m,searchQuery:p}}=X(e);Q(`${t} \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb`),b.preview({project:o,version:r,desc:i,setting:a,robot:n,qrcodeFormat:s,qrcodeOutputDest:c,pagePath:m,searchQuery:p,onProgressUpdate:e=>{if(y(e))Q(`task: ${e}`);else{const{status:t,message:o}=e;Q(`task(${t}): ${o}`)}}}).then((()=>{N(`${t} \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210`)}))}else D("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),j.command("exec").description("\u6267\u884cts\u6587\u4ef6").argument("<path>","\u6267\u884c\u7684ts\u6587\u4ef6").action(((e,t,{args:o})=>{const r=Y(o);S({command:"tsx",args:[e].concat(r)})})),j.command("test").description("\u6267\u884c\u6d4b\u8bd5").option("--config","\u914d\u7f6e\u6587\u4ef6\u5730\u5740").option("--framework <framework>","\u6d4b\u8bd5\u6846\u67b6").action((({config:e},{args:t})=>{const o=Y(t);S({command:"yest",args:["run"].concat(e?["--config",e]:[]).concat(o),exit:!1})})),j.parse(process.argv)):w()};G();
|
|
2
|
+
import e from"@babel/runtime/helpers/defineProperty";function t(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function o(o){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?t(Object(i),!0).forEach((function(t){e(o,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach((function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))}))}return o}import{execSync as r}from"node:child_process";import{chmodSync as i,copyFileSync as a,existsSync as n,readFileSync as c,statSync as s,writeFileSync as m}from"node:fs";import p from"node:os";import{basename as d,dirname as l,join as u,relative as g}from"node:path";import{floor as f,isString as y}from"lodash";import{globSync as h}from"glob";import v from"inquirer";import*as b from"miniprogram-ci";import{mkdirpSync as $}from"mkdirp";import{program as k}from"../compiled/commander";import j from"../compiled/mustache";import O from"../package.json";import{breakExit as w,cwd as P,ENCODING as x,error as D,execCommand as S,getPackageJSON as E,getProjectConfigJSON as q,getYolkConfig as _,info as Q,ready as N,rimrafSync as F,warn as K}from"./_util";const L="##### CREATED BY YOLK #####",R=(e,t,o)=>{v.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:"taro-miniprogram template",value:"taro-miniprogram"}]},{type:"input",name:"projectName",message:"\u9879\u76ee\u540d\u79f0",default:d(d(process.cwd()))},{type:"list",name:"packageManager",message:"\u9009\u62e9\u5305\u7ba1\u7406\u5668(\u9ed8\u8ba4\uff1apnpm\uff0c\u63a8\u8350\uff1apnpm)",default:"default",choices:[{name:"\u9ed8\u8ba4\u5b89\u88c5",value:"default"},{name:"\u8df3\u8fc7\u5b89\u88c5",value:!1},{name:"pnpm install",value:"pnpm"},{name:"yarn install",value:"yarn"},{name:"npm install",value:"npm"}]}]).then((({type:r,projectName:i,packageManager:p})=>{const f={projectName:i,packageManager:"default"===p?"pnpm":p,yolkVersion:O.version};if("umi-mobile-uni-app"===r)return void K("\u6682\u4e0d\u652f\u6301");const y=t||u(__dirname,`../templates/${r}`);N(`\u590d\u5236\u6a21\u7248 ${d(y)}`);const v=h("**/*",{cwd:y,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(v.forEach((t=>{if(!y)return;const o=u(y,t);if(!s(o).isDirectory())if(t.endsWith(".tpl")){const r=c(o,x),i=u(e,t.replace(/\.tpl$/,"")),a=j.render(r,f);$(l(i)),N(`\u521b\u5efa ${g(e,i)}`),m(i,a,x)}else{N(`\u521b\u5efa ${t}`);const r=u(e,t);$(l(r)),a(o,r)}})),N("\u590d\u5236\u6a21\u7248 success!"),o&&n(y)&&F(y)&&N(`\u7f13\u5b58\u5220\u9664 success! ${d(y||"")}`),p)switch(N("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),p){case"default":case"pnpm":S({command:"pnpm",args:["install"]});break;case"yarn":S({command:"yarn",args:["install"]});break;case"npm":S({command:"npm",args:["install"]});break;default:}N("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},M=(e,t)=>R(e,t,!0),B=()=>n(u(P,"project.config.json")),I=()=>{let e=n(u(P,"node_modules/.bin/max"));if(!e)try{e=n(require.resolve("@umijs/max"))}catch(t){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test(r("umi -v").toString())}catch(t){}if(!e){const o=u(P,"node_modules","umi","package.json");if(n(o))try{const t=JSON.parse(c(o,x))||{};e=t.version&&+t.version.split(".")[0]>3}catch(t){}}return e},U=()=>{const e=u(P,"project.config.json");if(n(e)){const t=require(e);return t.appid}return""},W=()=>n(u(P,"project.tt.json"))&&0===U().indexOf("tt"),A=()=>0===U().indexOf("20"),T=()=>{const e=_(),t=u(P,".husky/pre-commit"),o=u(P,".git/"),r=u(P,".git/hooks"),a=u(r,"pre-commit"),s=n(t),d=n(o),l=n(r),g=n(a),f=!1!==e.initPreCommit&&!s,y=[L,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",L].join(p.EOL),h=e=>{let t=e||"";return t&&t.indexOf(L)>=0&&(t=`${t.substring(0,t.indexOf(L))}${t.substring(t.lastIndexOf(L)+L.length)}`.replace(/(\r|\n)+$/gu,"")),t};if(d)if(f)if(l||($(r),N("create .git/hooks")),g){try{i(a,"777")}catch(v){D(`chmod ${a} failed: ${v.message}`)}const e=h(c(a,x).toString());m(a,(e.indexOf("#!/")<0?["#!/bin/sh"]:[]).concat([e,y]).filter((e=>!!e)).join(p.EOL),x)}else m(a,["#!/bin/sh",y].join(p.EOL),x),N("create pre-commit");else if(g){const e=h(c(a,x).toString());m(a,e,x)}},V=()=>{K("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),S({command:"lint-staged",args:["-c",require.resolve("./lintstagedrc")]})},X=({mAppid:e,mProject:t,mPrivateKeyPath:i,mVersion:a,mDesc:c,mRobot:s,mQrcodeFormat:m,mQrcodeOutputDest:p,mPagePath:d,mSearchQuery:l})=>{let g="";try{g=n(u(P,".git"))?r("git log -1 --pretty=format:%H").toString():""}catch(D){}const f=q(),y=e||f.appid,h=t||u(P,"dist"),v=i||u(P,`private.${y}.key`);if(n(h)){if(n(v)){const e=E(),t=a||e.version||f.version||"1.0.0",r=c||e.description||f.description,i=`${g?` commit: ${g};`:""}${r?` description: ${r};`:""}`;g&&Q(`commit: ${g}`),Q(`dist: ${h}`),Q(`key: ${v}`),Q(`appid: ${y}`),Q(`version: ${t}`),Q(`desc: ${i}`);const n=new b.Project({appid:y,type:"miniProgram",projectPath:h,privateKeyPath:v,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:y,options:{project:n,version:t,desc:i,setting:o(o({},f.setting),{},{es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1}),robot:s,qrcodeFormat:m,qrcodeOutputDest:p,pagePath:d,searchQuery:l}}}throw Error(`\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(${v})`)}throw Error(`\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(${h})`)},C=()=>{let e="";try{e=r(`npm view ${O.name} version`,{timeout:3e3}).toString().replace(/\n/g,"")}catch(t){}Q(`yolk version: ${O.version}${e&&e!==O.version?`(latest\uff1a${e})`:""}`),Q(`node version: ${process.version}`),Q(`platform: ${p.platform()}`),Q(`memory: ${f(p.freemem()/1024/1024)} MB(${f(p.totalmem()/1024/1024)} MB)`)},H=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"),J=/(\w+)=('(.*)'|"(.*)"|(.*))/giu,Y=e=>{process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";const t=[];return null===e||void 0===e||e.forEach((e=>{if(J.test(e)){const[t,o]=e.split("=");process.env[t]=o,Q(`\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a${t}=${o}`)}else t.push(e)})),t},G=()=>{T(),process.argv.length>2?(k.version(O.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),k.command("init").description("\u521d\u59cb\u5316\u9879\u76ee").option("--clone <template>","\u5982\u679c\u9700\u8981\uff0c\u53ef\u901a\u8fc7git clone\u62c9\u53d6\u6a21\u7248\uff0c\u9ed8\u8ba4\u53d6cli\u9ed8\u8ba4\u6a21\u7248").action((({clone:e},{args:t})=>{if(C(),N("yolk init \u5f00\u59cb"),e){const o=".yolk",r=u(P,o);n(r)&&F(r)&&N(`\u7f13\u5b58\u5220\u9664 success! ${r}`),S({command:"git",args:["clone","-b","master","--depth","1",e,o].concat(t)}),M(P,r)}else R(P)})),k.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{C();const o=Y(t);B()?W()?S({command:"taro",args:["build","--type","tt","--watch"].concat(o)}):A()?S({command:"taro",args:["build","--type","alipay","--watch"].concat(o)}):S({command:"taro",args:["build","--type","weapp","--watch"].concat(o)}):e?S({command:"dumi",args:["dev"].concat(o)}):I()?S({command:"max",args:["dev"].concat(o)}):S({command:"umi",args:["dev"].concat(o)})})),k.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{C();const o=Y(t);B()?W()?S({command:"taro",args:["build","--type","tt"].concat(o)}):A()?S({command:"taro",args:["build","--type","alipay"].concat(o)}):S({command:"taro",args:["build","--type","weapp"].concat(o)}):e?S({command:"dumi",args:["build"].concat(o)}):I()?S({command:"max",args:["setup"].concat(o),complete:()=>S({command:"max",args:["build"].concat(o)}),exit:!1}):S({command:"umi",args:["build"].concat(o)})})),k.command("init-pre-commit").description("\u521d\u59cb\u5316 commit hook").action(T),k.command("pre-commit").description("\u6267\u884ccommit hook").action(V),H(k.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((e=>{if(B())if(W());else if(A());else{const{appid:t,options:{project:o,version:r,desc:i,setting:a,robot:n}}=X(e);Q(`${t} \u4e0a\u4f20\u5f00\u59cb`),b.upload({project:o,version:r,desc:i,setting:a,robot:n,onProgressUpdate:e=>{if(y(e))Q(`task: ${e}`);else{const{status:t,message:o}=e;Q(`task(${t}): ${o}`)}}}).then((()=>{N(`${t} \u4e0a\u4f20\u5b8c\u6210`)}))}else D("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),H(k.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((e=>{if(B())if(W());else if(A());else{const{appid:t,options:{project:o,version:r,desc:i,setting:a,robot:n,qrcodeFormat:c,qrcodeOutputDest:s,pagePath:m,searchQuery:p}}=X(e);Q(`${t} \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb`),b.preview({project:o,version:r,desc:i,setting:a,robot:n,qrcodeFormat:c,qrcodeOutputDest:s,pagePath:m,searchQuery:p,onProgressUpdate:e=>{if(y(e))Q(`task: ${e}`);else{const{status:t,message:o}=e;Q(`task(${t}): ${o}`)}}}).then((()=>{N(`${t} \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210`)}))}else D("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),k.command("exec").description("\u6267\u884cts\u6587\u4ef6").argument("<path>","\u6267\u884c\u7684ts\u6587\u4ef6").action(((e,t,{args:o})=>{const r=Y(o);S({command:"tsx",args:[e].concat(r)})})),k.command("test").description("\u6267\u884c\u6d4b\u8bd5").option("--framework <framework>","\u6d4b\u8bd5\u6846\u67b6(jest|vitest)").option("--config <config>","\u914d\u7f6e\u6587\u4ef6\u5730\u5740").option("--fcmd <fcmd>","\u6d4b\u8bd5\u6846\u67b6\u9700\u8981\u6267\u884c\u7684\u547d\u4ee4<\u6ce8\uff1a\u8bf7\u653e\u5728\u6700\u540e\u5b9a\u4e49>").action((({config:e,framework:t,fcmd:o},{args:r})=>{const i=Y(r);S({command:"yest",args:["run"].concat(e?["--config",e]:[]).concat(t?["--framework",t]:[]).concat(o?["--fcmd",o]:[]).concat(i),exit:!1})})),k.parse(process.argv)):w()};G();
|
package/lib/yolk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
"use strict";var e=require("@babel/runtime/helpers/interopRequireDefault"),t=e(require("@babel/runtime/helpers/defineProperty")),o=require("node:child_process"),r=require("node:fs"),n=e(require("node:os")),i=require("node:path"),a=require("lodash"),c=require("glob"),s=e(require("inquirer")),m=y(require("miniprogram-ci")),p=require("mkdirp"),d=require("../compiled/commander"),l=e(require("../compiled/mustache")),u=e(require("../package.json")),f=require("./_util");function g(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,o=new WeakMap;return(g=function(e){return e?o:t})(e)}function y(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var o=g(t);if(o&&o.has(e))return o.get(e);var r={__proto__:null},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var a=n?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,o&&o.set(e,r),r}function b(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function v(e){for(var o=1;o<arguments.length;o++){var r=null!=arguments[o]?arguments[o]:{};o%2?b(Object(r),!0).forEach((function(o){(0,t.default)(e,o,r[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}const h="##### CREATED BY YOLK #####",j=(e,t,o)=>{s.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:"taro-miniprogram template",value:"taro-miniprogram"}]},{type:"input",name:"projectName",message:"\u9879\u76ee\u540d\u79f0",default:(0,i.basename)((0,i.basename)(process.cwd()))},{type:"list",name:"packageManager",message:"\u9009\u62e9\u5305\u7ba1\u7406\u5668(\u9ed8\u8ba4\uff1apnpm\uff0c\u63a8\u8350\uff1apnpm)",default:"default",choices:[{name:"\u9ed8\u8ba4\u5b89\u88c5",value:"default"},{name:"\u8df3\u8fc7\u5b89\u88c5",value:!1},{name:"pnpm install",value:"pnpm"},{name:"yarn install",value:"yarn"},{name:"npm install",value:"npm"}]}]).then((({type:n,projectName:a,packageManager:s})=>{const m={projectName:a,packageManager:"default"===s?"pnpm":s,yolkVersion:u.default.version};if("umi-mobile-uni-app"===n)return void(0,f.warn)("\u6682\u4e0d\u652f\u6301");const d=t||(0,i.join)(__dirname,`../templates/${n}`);(0,f.ready)(`\u590d\u5236\u6a21\u7248 ${(0,i.basename)(d)}`);const g=(0,c.globSync)("**/*",{cwd:d,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(g.forEach((t=>{if(!d)return;const o=(0,i.join)(d,t);if(!(0,r.statSync)(o).isDirectory())if(t.endsWith(".tpl")){const n=(0,r.readFileSync)(o,f.ENCODING),a=(0,i.join)(e,t.replace(/\.tpl$/,"")),c=l.default.render(n,m);(0,p.mkdirpSync)((0,i.dirname)(a)),(0,f.ready)(`\u521b\u5efa ${(0,i.relative)(e,a)}`),(0,r.writeFileSync)(a,c,f.ENCODING)}else{(0,f.ready)(`\u521b\u5efa ${t}`);const n=(0,i.join)(e,t);(0,p.mkdirpSync)((0,i.dirname)(n)),(0,r.copyFileSync)(o,n)}})),(0,f.ready)("\u590d\u5236\u6a21\u7248 success!"),o&&(0,r.existsSync)(d)&&(0,f.rimrafSync)(d)&&(0,f.ready)(`\u7f13\u5b58\u5220\u9664 success! ${(0,i.basename)(d||"")}`),s)switch((0,f.ready)("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),s){case"default":case"pnpm":(0,f.execCommand)({command:"pnpm",args:["install"]});break;case"yarn":(0,f.execCommand)({command:"yarn",args:["install"]});break;case"npm":(0,f.execCommand)({command:"npm",args:["install"]});break;default:}(0,f.ready)("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},x=(e,t)=>j(e,t,!0),w=()=>(0,r.existsSync)((0,i.join)(f.cwd,"project.config.json")),S=()=>{let e=(0,r.existsSync)((0,i.join)(f.cwd,"node_modules/.bin/max"));if(!e)try{e=(0,r.existsSync)(require.resolve("@umijs/max"))}catch(t){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test((0,o.execSync)("umi -v").toString())}catch(t){}if(!e){const o=(0,i.join)(f.cwd,"node_modules","umi","package.json");if((0,r.existsSync)(o))try{const t=JSON.parse((0,r.readFileSync)(o,f.ENCODING))||{};e=t.version&&+t.version.split(".")[0]>3}catch(t){}}return e},O=()=>{const e=(0,i.join)(f.cwd,"project.config.json");if((0,r.existsSync)(e)){const t=require(e);return t.appid}return""},k=()=>(0,r.existsSync)((0,i.join)(f.cwd,"project.tt.json"))&&0===O().indexOf("tt"),$=()=>0===O().indexOf("20"),P=()=>{const e=(0,f.getYolkConfig)(),t=(0,i.join)(f.cwd,".husky/pre-commit"),o=(0,i.join)(f.cwd,".git/"),a=(0,i.join)(f.cwd,".git/hooks"),c=(0,i.join)(a,"pre-commit"),s=(0,r.existsSync)(t),m=(0,r.existsSync)(o),d=(0,r.existsSync)(a),l=(0,r.existsSync)(c),u=!1!==e.initPreCommit&&!s,g=[h,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",h].join(n.default.EOL),y=e=>{let t=e||"";return t&&t.indexOf(h)>=0&&(t=`${t.substring(0,t.indexOf(h))}${t.substring(t.lastIndexOf(h)+h.length)}`.replace(/(\r|\n)+$/gu,"")),t};if(m)if(u)if(d||((0,p.mkdirpSync)(a),(0,f.ready)("create .git/hooks")),l){try{(0,r.chmodSync)(c,"777")}catch(b){(0,f.error)(`chmod ${c} failed: ${b.message}`)}const e=y((0,r.readFileSync)(c,f.ENCODING).toString());(0,r.writeFileSync)(c,(e.indexOf("#!/")<0?["#!/bin/sh"]:[]).concat([e,g]).filter((e=>!!e)).join(n.default.EOL),f.ENCODING)}else(0,r.writeFileSync)(c,["#!/bin/sh",g].join(n.default.EOL),f.ENCODING),(0,f.ready)("create pre-commit");else if(l){const e=y((0,r.readFileSync)(c,f.ENCODING).toString());(0,r.writeFileSync)(c,e,f.ENCODING)}},C=()=>{(0,f.warn)("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),(0,f.execCommand)({command:"lint-staged",args:["-c",require.resolve("./lintstagedrc")]})},q=({mAppid:e,mProject:t,mPrivateKeyPath:n,mVersion:a,mDesc:c,mRobot:s,mQrcodeFormat:p,mQrcodeOutputDest:d,mPagePath:l,mSearchQuery:u})=>{let g="";try{g=(0,r.existsSync)((0,i.join)(f.cwd,".git"))?(0,o.execSync)("git log -1 --pretty=format:%H").toString():""}catch(x){}const y=(0,f.getProjectConfigJSON)(),b=e||y.appid,h=t||(0,i.join)(f.cwd,"dist"),j=n||(0,i.join)(f.cwd,`private.${b}.key`);if((0,r.existsSync)(h)){if((0,r.existsSync)(j)){const e=(0,f.getPackageJSON)(),t=a||e.version||y.version||"1.0.0",o=c||e.description||y.description,r=`${g?` commit: ${g};`:""}${o?` description: ${o};`:""}`;g&&(0,f.info)(`commit: ${g}`),(0,f.info)(`dist: ${h}`),(0,f.info)(`key: ${j}`),(0,f.info)(`appid: ${b}`),(0,f.info)(`version: ${t}`),(0,f.info)(`desc: ${r}`);const n=new m.Project({appid:b,type:"miniProgram",projectPath:h,privateKeyPath:j,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:b,options:{project:n,version:t,desc:r,setting:v(v({},y.setting),{},{es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1}),robot:s,qrcodeFormat:p,qrcodeOutputDest:d,pagePath:l,searchQuery:u}}}throw Error(`\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(${j})`)}throw Error(`\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(${h})`)},D=()=>{let e="";try{e=(0,o.execSync)(`npm view ${u.default.name} version`,{timeout:3e3}).toString().replace(/\n/g,"")}catch(t){}(0,f.info)(`yolk version: ${u.default.version}${e&&e!==u.default.version?`(latest\uff1a${e})`:""}`),(0,f.info)(`node version: ${process.version}`),(0,f.info)(`platform: ${n.default.platform()}`),(0,f.info)(`memory: ${(0,a.floor)(n.default.freemem()/1024/1024)} MB(${(0,a.floor)(n.default.totalmem()/1024/1024)} MB)`)},N=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"),E=/(\w+)=('(.*)'|"(.*)"|(.*))/giu,_=e=>{process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";const t=[];return null===e||void 0===e||e.forEach((e=>{if(E.test(e)){const[t,o]=e.split("=");process.env[t]=o,(0,f.info)(`\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a${t}=${o}`)}else t.push(e)})),t},F=()=>{P(),process.argv.length>2?(d.program.version(u.default.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),d.program.command("init").description("\u521d\u59cb\u5316\u9879\u76ee").option("--clone <template>","\u5982\u679c\u9700\u8981\uff0c\u53ef\u901a\u8fc7git clone\u62c9\u53d6\u6a21\u7248\uff0c\u9ed8\u8ba4\u53d6cli\u9ed8\u8ba4\u6a21\u7248").action((({clone:e},{args:t})=>{if(D(),(0,f.ready)("yolk init \u5f00\u59cb"),e){const o=".yolk",n=(0,i.join)(f.cwd,o);(0,r.existsSync)(n)&&(0,f.rimrafSync)(n)&&(0,f.ready)(`\u7f13\u5b58\u5220\u9664 success! ${n}`),(0,f.execCommand)({command:"git",args:["clone","-b","master","--depth","1",e,o].concat(t)}),x(f.cwd,n)}else j(f.cwd)})),d.program.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{D();const o=_(t);w()?k()?(0,f.execCommand)({command:"taro",args:["build","--type","tt","--watch"].concat(o)}):$()?(0,f.execCommand)({command:"taro",args:["build","--type","alipay","--watch"].concat(o)}):(0,f.execCommand)({command:"taro",args:["build","--type","weapp","--watch"].concat(o)}):e?(0,f.execCommand)({command:"dumi",args:["dev"].concat(o)}):S()?(0,f.execCommand)({command:"max",args:["dev"].concat(o)}):(0,f.execCommand)({command:"umi",args:["dev"].concat(o)})})),d.program.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{D();const o=_(t);w()?k()?(0,f.execCommand)({command:"taro",args:["build","--type","tt"].concat(o)}):$()?(0,f.execCommand)({command:"taro",args:["build","--type","alipay"].concat(o)}):(0,f.execCommand)({command:"taro",args:["build","--type","weapp"].concat(o)}):e?(0,f.execCommand)({command:"dumi",args:["build"].concat(o)}):S()?(0,f.execCommand)({command:"max",args:["setup"].concat(o),complete:()=>(0,f.execCommand)({command:"max",args:["build"].concat(o)}),exit:!1}):(0,f.execCommand)({command:"umi",args:["build"].concat(o)})})),d.program.command("init-pre-commit").description("\u521d\u59cb\u5316 commit hook").action(P),d.program.command("pre-commit").description("\u6267\u884ccommit hook").action(C),N(d.program.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((e=>{if(w())if(k());else if($());else{const{appid:t,options:{project:o,version:r,desc:n,setting:i,robot:c}}=q(e);(0,f.info)(`${t} \u4e0a\u4f20\u5f00\u59cb`),m.upload({project:o,version:r,desc:n,setting:i,robot:c,onProgressUpdate:e=>{if((0,a.isString)(e))(0,f.info)(`task: ${e}`);else{const{status:t,message:o}=e;(0,f.info)(`task(${t}): ${o}`)}}}).then((()=>{(0,f.ready)(`${t} \u4e0a\u4f20\u5b8c\u6210`)}))}else(0,f.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),N(d.program.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((e=>{if(w())if(k());else if($());else{const{appid:t,options:{project:o,version:r,desc:n,setting:i,robot:c,qrcodeFormat:s,qrcodeOutputDest:p,pagePath:d,searchQuery:l}}=q(e);(0,f.info)(`${t} \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb`),m.preview({project:o,version:r,desc:n,setting:i,robot:c,qrcodeFormat:s,qrcodeOutputDest:p,pagePath:d,searchQuery:l,onProgressUpdate:e=>{if((0,a.isString)(e))(0,f.info)(`task: ${e}`);else{const{status:t,message:o}=e;(0,f.info)(`task(${t}): ${o}`)}}}).then((()=>{(0,f.ready)(`${t} \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210`)}))}else(0,f.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),d.program.command("exec").description("\u6267\u884cts\u6587\u4ef6").argument("<path>","\u6267\u884c\u7684ts\u6587\u4ef6").action(((e,t,{args:o})=>{const r=_(o);(0,f.execCommand)({command:"tsx",args:[e].concat(r)})})),d.program.command("test").description("\u6267\u884c\u6d4b\u8bd5").option("--config","\u914d\u7f6e\u6587\u4ef6\u5730\u5740").option("--framework <framework>","\u6d4b\u8bd5\u6846\u67b6").action((({config:e},{args:t})=>{const o=_(t);(0,f.execCommand)({command:"yest",args:["run"].concat(e?["--config",e]:[]).concat(o),exit:!1})})),d.program.parse(process.argv)):(0,f.breakExit)()};F();
|
|
2
|
+
"use strict";var e=require("@babel/runtime/helpers/interopRequireDefault"),t=e(require("@babel/runtime/helpers/defineProperty")),o=require("node:child_process"),r=require("node:fs"),n=e(require("node:os")),i=require("node:path"),a=require("lodash"),c=require("glob"),s=e(require("inquirer")),m=y(require("miniprogram-ci")),p=require("mkdirp"),d=require("../compiled/commander"),l=e(require("../compiled/mustache")),u=e(require("../package.json")),f=require("./_util");function g(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,o=new WeakMap;return(g=function(e){return e?o:t})(e)}function y(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var o=g(t);if(o&&o.has(e))return o.get(e);var r={__proto__:null},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var a=n?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,o&&o.set(e,r),r}function b(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function v(e){for(var o=1;o<arguments.length;o++){var r=null!=arguments[o]?arguments[o]:{};o%2?b(Object(r),!0).forEach((function(o){(0,t.default)(e,o,r[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}const h="##### CREATED BY YOLK #####",j=(e,t,o)=>{s.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:"taro-miniprogram template",value:"taro-miniprogram"}]},{type:"input",name:"projectName",message:"\u9879\u76ee\u540d\u79f0",default:(0,i.basename)((0,i.basename)(process.cwd()))},{type:"list",name:"packageManager",message:"\u9009\u62e9\u5305\u7ba1\u7406\u5668(\u9ed8\u8ba4\uff1apnpm\uff0c\u63a8\u8350\uff1apnpm)",default:"default",choices:[{name:"\u9ed8\u8ba4\u5b89\u88c5",value:"default"},{name:"\u8df3\u8fc7\u5b89\u88c5",value:!1},{name:"pnpm install",value:"pnpm"},{name:"yarn install",value:"yarn"},{name:"npm install",value:"npm"}]}]).then((({type:n,projectName:a,packageManager:s})=>{const m={projectName:a,packageManager:"default"===s?"pnpm":s,yolkVersion:u.default.version};if("umi-mobile-uni-app"===n)return void(0,f.warn)("\u6682\u4e0d\u652f\u6301");const d=t||(0,i.join)(__dirname,`../templates/${n}`);(0,f.ready)(`\u590d\u5236\u6a21\u7248 ${(0,i.basename)(d)}`);const g=(0,c.globSync)("**/*",{cwd:d,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(g.forEach((t=>{if(!d)return;const o=(0,i.join)(d,t);if(!(0,r.statSync)(o).isDirectory())if(t.endsWith(".tpl")){const n=(0,r.readFileSync)(o,f.ENCODING),a=(0,i.join)(e,t.replace(/\.tpl$/,"")),c=l.default.render(n,m);(0,p.mkdirpSync)((0,i.dirname)(a)),(0,f.ready)(`\u521b\u5efa ${(0,i.relative)(e,a)}`),(0,r.writeFileSync)(a,c,f.ENCODING)}else{(0,f.ready)(`\u521b\u5efa ${t}`);const n=(0,i.join)(e,t);(0,p.mkdirpSync)((0,i.dirname)(n)),(0,r.copyFileSync)(o,n)}})),(0,f.ready)("\u590d\u5236\u6a21\u7248 success!"),o&&(0,r.existsSync)(d)&&(0,f.rimrafSync)(d)&&(0,f.ready)(`\u7f13\u5b58\u5220\u9664 success! ${(0,i.basename)(d||"")}`),s)switch((0,f.ready)("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),s){case"default":case"pnpm":(0,f.execCommand)({command:"pnpm",args:["install"]});break;case"yarn":(0,f.execCommand)({command:"yarn",args:["install"]});break;case"npm":(0,f.execCommand)({command:"npm",args:["install"]});break;default:}(0,f.ready)("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},w=(e,t)=>j(e,t,!0),x=()=>(0,r.existsSync)((0,i.join)(f.cwd,"project.config.json")),S=()=>{let e=(0,r.existsSync)((0,i.join)(f.cwd,"node_modules/.bin/max"));if(!e)try{e=(0,r.existsSync)(require.resolve("@umijs/max"))}catch(t){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test((0,o.execSync)("umi -v").toString())}catch(t){}if(!e){const o=(0,i.join)(f.cwd,"node_modules","umi","package.json");if((0,r.existsSync)(o))try{const t=JSON.parse((0,r.readFileSync)(o,f.ENCODING))||{};e=t.version&&+t.version.split(".")[0]>3}catch(t){}}return e},O=()=>{const e=(0,i.join)(f.cwd,"project.config.json");if((0,r.existsSync)(e)){const t=require(e);return t.appid}return""},k=()=>(0,r.existsSync)((0,i.join)(f.cwd,"project.tt.json"))&&0===O().indexOf("tt"),$=()=>0===O().indexOf("20"),P=()=>{const e=(0,f.getYolkConfig)(),t=(0,i.join)(f.cwd,".husky/pre-commit"),o=(0,i.join)(f.cwd,".git/"),a=(0,i.join)(f.cwd,".git/hooks"),c=(0,i.join)(a,"pre-commit"),s=(0,r.existsSync)(t),m=(0,r.existsSync)(o),d=(0,r.existsSync)(a),l=(0,r.existsSync)(c),u=!1!==e.initPreCommit&&!s,g=[h,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",h].join(n.default.EOL),y=e=>{let t=e||"";return t&&t.indexOf(h)>=0&&(t=`${t.substring(0,t.indexOf(h))}${t.substring(t.lastIndexOf(h)+h.length)}`.replace(/(\r|\n)+$/gu,"")),t};if(m)if(u)if(d||((0,p.mkdirpSync)(a),(0,f.ready)("create .git/hooks")),l){try{(0,r.chmodSync)(c,"777")}catch(b){(0,f.error)(`chmod ${c} failed: ${b.message}`)}const e=y((0,r.readFileSync)(c,f.ENCODING).toString());(0,r.writeFileSync)(c,(e.indexOf("#!/")<0?["#!/bin/sh"]:[]).concat([e,g]).filter((e=>!!e)).join(n.default.EOL),f.ENCODING)}else(0,r.writeFileSync)(c,["#!/bin/sh",g].join(n.default.EOL),f.ENCODING),(0,f.ready)("create pre-commit");else if(l){const e=y((0,r.readFileSync)(c,f.ENCODING).toString());(0,r.writeFileSync)(c,e,f.ENCODING)}},C=()=>{(0,f.warn)("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),(0,f.execCommand)({command:"lint-staged",args:["-c",require.resolve("./lintstagedrc")]})},q=({mAppid:e,mProject:t,mPrivateKeyPath:n,mVersion:a,mDesc:c,mRobot:s,mQrcodeFormat:p,mQrcodeOutputDest:d,mPagePath:l,mSearchQuery:u})=>{let g="";try{g=(0,r.existsSync)((0,i.join)(f.cwd,".git"))?(0,o.execSync)("git log -1 --pretty=format:%H").toString():""}catch(w){}const y=(0,f.getProjectConfigJSON)(),b=e||y.appid,h=t||(0,i.join)(f.cwd,"dist"),j=n||(0,i.join)(f.cwd,`private.${b}.key`);if((0,r.existsSync)(h)){if((0,r.existsSync)(j)){const e=(0,f.getPackageJSON)(),t=a||e.version||y.version||"1.0.0",o=c||e.description||y.description,r=`${g?` commit: ${g};`:""}${o?` description: ${o};`:""}`;g&&(0,f.info)(`commit: ${g}`),(0,f.info)(`dist: ${h}`),(0,f.info)(`key: ${j}`),(0,f.info)(`appid: ${b}`),(0,f.info)(`version: ${t}`),(0,f.info)(`desc: ${r}`);const n=new m.Project({appid:b,type:"miniProgram",projectPath:h,privateKeyPath:j,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:b,options:{project:n,version:t,desc:r,setting:v(v({},y.setting),{},{es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1}),robot:s,qrcodeFormat:p,qrcodeOutputDest:d,pagePath:l,searchQuery:u}}}throw Error(`\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(${j})`)}throw Error(`\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(${h})`)},D=()=>{let e="";try{e=(0,o.execSync)(`npm view ${u.default.name} version`,{timeout:3e3}).toString().replace(/\n/g,"")}catch(t){}(0,f.info)(`yolk version: ${u.default.version}${e&&e!==u.default.version?`(latest\uff1a${e})`:""}`),(0,f.info)(`node version: ${process.version}`),(0,f.info)(`platform: ${n.default.platform()}`),(0,f.info)(`memory: ${(0,a.floor)(n.default.freemem()/1024/1024)} MB(${(0,a.floor)(n.default.totalmem()/1024/1024)} MB)`)},N=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"),E=/(\w+)=('(.*)'|"(.*)"|(.*))/giu,_=e=>{process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";const t=[];return null===e||void 0===e||e.forEach((e=>{if(E.test(e)){const[t,o]=e.split("=");process.env[t]=o,(0,f.info)(`\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a${t}=${o}`)}else t.push(e)})),t},F=()=>{P(),process.argv.length>2?(d.program.version(u.default.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),d.program.command("init").description("\u521d\u59cb\u5316\u9879\u76ee").option("--clone <template>","\u5982\u679c\u9700\u8981\uff0c\u53ef\u901a\u8fc7git clone\u62c9\u53d6\u6a21\u7248\uff0c\u9ed8\u8ba4\u53d6cli\u9ed8\u8ba4\u6a21\u7248").action((({clone:e},{args:t})=>{if(D(),(0,f.ready)("yolk init \u5f00\u59cb"),e){const o=".yolk",n=(0,i.join)(f.cwd,o);(0,r.existsSync)(n)&&(0,f.rimrafSync)(n)&&(0,f.ready)(`\u7f13\u5b58\u5220\u9664 success! ${n}`),(0,f.execCommand)({command:"git",args:["clone","-b","master","--depth","1",e,o].concat(t)}),w(f.cwd,n)}else j(f.cwd)})),d.program.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{D();const o=_(t);x()?k()?(0,f.execCommand)({command:"taro",args:["build","--type","tt","--watch"].concat(o)}):$()?(0,f.execCommand)({command:"taro",args:["build","--type","alipay","--watch"].concat(o)}):(0,f.execCommand)({command:"taro",args:["build","--type","weapp","--watch"].concat(o)}):e?(0,f.execCommand)({command:"dumi",args:["dev"].concat(o)}):S()?(0,f.execCommand)({command:"max",args:["dev"].concat(o)}):(0,f.execCommand)({command:"umi",args:["dev"].concat(o)})})),d.program.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:t})=>{D();const o=_(t);x()?k()?(0,f.execCommand)({command:"taro",args:["build","--type","tt"].concat(o)}):$()?(0,f.execCommand)({command:"taro",args:["build","--type","alipay"].concat(o)}):(0,f.execCommand)({command:"taro",args:["build","--type","weapp"].concat(o)}):e?(0,f.execCommand)({command:"dumi",args:["build"].concat(o)}):S()?(0,f.execCommand)({command:"max",args:["setup"].concat(o),complete:()=>(0,f.execCommand)({command:"max",args:["build"].concat(o)}),exit:!1}):(0,f.execCommand)({command:"umi",args:["build"].concat(o)})})),d.program.command("init-pre-commit").description("\u521d\u59cb\u5316 commit hook").action(P),d.program.command("pre-commit").description("\u6267\u884ccommit hook").action(C),N(d.program.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((e=>{if(x())if(k());else if($());else{const{appid:t,options:{project:o,version:r,desc:n,setting:i,robot:c}}=q(e);(0,f.info)(`${t} \u4e0a\u4f20\u5f00\u59cb`),m.upload({project:o,version:r,desc:n,setting:i,robot:c,onProgressUpdate:e=>{if((0,a.isString)(e))(0,f.info)(`task: ${e}`);else{const{status:t,message:o}=e;(0,f.info)(`task(${t}): ${o}`)}}}).then((()=>{(0,f.ready)(`${t} \u4e0a\u4f20\u5b8c\u6210`)}))}else(0,f.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),N(d.program.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((e=>{if(x())if(k());else if($());else{const{appid:t,options:{project:o,version:r,desc:n,setting:i,robot:c,qrcodeFormat:s,qrcodeOutputDest:p,pagePath:d,searchQuery:l}}=q(e);(0,f.info)(`${t} \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb`),m.preview({project:o,version:r,desc:n,setting:i,robot:c,qrcodeFormat:s,qrcodeOutputDest:p,pagePath:d,searchQuery:l,onProgressUpdate:e=>{if((0,a.isString)(e))(0,f.info)(`task: ${e}`);else{const{status:t,message:o}=e;(0,f.info)(`task(${t}): ${o}`)}}}).then((()=>{(0,f.ready)(`${t} \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210`)}))}else(0,f.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),d.program.command("exec").description("\u6267\u884cts\u6587\u4ef6").argument("<path>","\u6267\u884c\u7684ts\u6587\u4ef6").action(((e,t,{args:o})=>{const r=_(o);(0,f.execCommand)({command:"tsx",args:[e].concat(r)})})),d.program.command("test").description("\u6267\u884c\u6d4b\u8bd5").option("--framework <framework>","\u6d4b\u8bd5\u6846\u67b6(jest|vitest)").option("--config <config>","\u914d\u7f6e\u6587\u4ef6\u5730\u5740").option("--fcmd <fcmd>","\u6d4b\u8bd5\u6846\u67b6\u9700\u8981\u6267\u884c\u7684\u547d\u4ee4<\u6ce8\uff1a\u8bf7\u653e\u5728\u6700\u540e\u5b9a\u4e49>").action((({config:e,framework:t,fcmd:o},{args:r})=>{const n=_(r);(0,f.execCommand)({command:"yest",args:["run"].concat(e?["--config",e]:[]).concat(t?["--framework",t]:[]).concat(o?["--fcmd",o]:[]).concat(n),exit:!1})})),d.program.parse(process.argv)):(0,f.breakExit)()};F();
|
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.253",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/303394539/yolk.git"
|
|
@@ -25,25 +25,25 @@
|
|
|
25
25
|
"prebundle": "father prebundle"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@baic/biome-config-yolk": "2.1.0-alpha.
|
|
29
|
-
"@baic/eslint-config-yolk": "2.1.0-alpha.
|
|
30
|
-
"@baic/prettier-config-yolk": "2.1.0-alpha.
|
|
31
|
-
"@baic/stylelint-config-yolk": "2.1.0-alpha.
|
|
32
|
-
"@baic/yolk-test": "2.1.0-alpha.
|
|
28
|
+
"@baic/biome-config-yolk": "2.1.0-alpha.253",
|
|
29
|
+
"@baic/eslint-config-yolk": "2.1.0-alpha.253",
|
|
30
|
+
"@baic/prettier-config-yolk": "2.1.0-alpha.253",
|
|
31
|
+
"@baic/stylelint-config-yolk": "2.1.0-alpha.253",
|
|
32
|
+
"@baic/yolk-test": "2.1.0-alpha.253",
|
|
33
33
|
"@democrance/imagemin-lint-staged": "5.0.x",
|
|
34
34
|
"@types/lodash": "4.x",
|
|
35
35
|
"chalk": "4.x",
|
|
36
36
|
"eslint": "8.x",
|
|
37
37
|
"glob": "10.4.x",
|
|
38
38
|
"inquirer": "8.x",
|
|
39
|
-
"lint-staged": "16.
|
|
39
|
+
"lint-staged": "16.1.x",
|
|
40
40
|
"lodash": "4.x",
|
|
41
|
-
"miniprogram-ci": "1.
|
|
41
|
+
"miniprogram-ci": "2.1.14",
|
|
42
42
|
"mkdirp": "3.0.x",
|
|
43
43
|
"postcss": "8.5.x",
|
|
44
44
|
"postcss-less": "6.0.x",
|
|
45
45
|
"postcss-scss": "4.0.x",
|
|
46
|
-
"prettier": "
|
|
46
|
+
"prettier": "3.x",
|
|
47
47
|
"rimraf": "5.0.x",
|
|
48
48
|
"stylelint": "14.x",
|
|
49
49
|
"tsx": "4.x"
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"mustache": "4.2.x"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
|
-
"node": ">=
|
|
59
|
+
"node": ">=18"
|
|
60
60
|
},
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "99c0d66dccff7fab3820638a851b2f0c499ac438"
|
|
65
65
|
}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
"name": "{{ projectName }}",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"start": "yolk start",
|
|
6
|
-
"build": "yolk build"
|
|
6
|
+
"build": "yolk build",
|
|
7
|
+
"test": "yolk test"
|
|
7
8
|
},
|
|
8
9
|
"dependencies": {
|
|
9
10
|
"@baic/preset-yolk-umi-mobile": "~{{ yolkVersion }}"
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
},
|
|
17
18
|
"pnpm": {
|
|
18
19
|
"peerDependencyRules": {
|
|
19
|
-
"ignoreMissing": "*"
|
|
20
|
+
"ignoreMissing": ["*"]
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineConfig } from '@baic/yolk-test';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
moduleNameMapper: {
|
|
5
|
+
'\\.\\./\\.\\./\\.\\./components/(.*)$':
|
|
6
|
+
'<rootDir>/node_modules/antd-mobile/cjs/components/$1',
|
|
7
|
+
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
|
|
8
|
+
'<rootDir>/node_modules/@ant-design/tools/lib/jest/imagePreprocessor',
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineConfig } from '@baic/yolk-test';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
moduleNameMapper: {
|
|
5
|
+
'\\.\\./\\.\\./\\.\\./components/(.*)$':
|
|
6
|
+
'<rootDir>/node_modules/antd-mobile/cjs/components/$1',
|
|
7
|
+
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
|
|
8
|
+
'<rootDir>/node_modules/@ant-design/tools/lib/jest/imagePreprocessor',
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineConfig } from '@baic/yolk-test';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
moduleNameMapper: {
|
|
5
|
+
'\\.\\./\\.\\./\\.\\./components/(.*)$':
|
|
6
|
+
'<rootDir>/node_modules/antd-mobile/cjs/components/$1',
|
|
7
|
+
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
|
|
8
|
+
'<rootDir>/node_modules/@ant-design/tools/lib/jest/imagePreprocessor',
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineConfig } from '@baic/yolk-test';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
moduleNameMapper: {
|
|
5
|
+
'\\.\\./\\.\\./\\.\\./components/(.*)$':
|
|
6
|
+
'<rootDir>/node_modules/antd-mobile/cjs/components/$1',
|
|
7
|
+
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
|
|
8
|
+
'<rootDir>/node_modules/@ant-design/tools/lib/jest/imagePreprocessor',
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineConfig } from '@baic/yolk-test';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
moduleNameMapper: {
|
|
5
|
+
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
|
|
6
|
+
'<rootDir>/node_modules/@ant-design/tools/lib/jest/imagePreprocessor',
|
|
7
|
+
},
|
|
8
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineConfig } from '@baic/yolk-test';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
moduleNameMapper: {
|
|
5
|
+
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
|
|
6
|
+
'<rootDir>/node_modules/@ant-design/tools/lib/jest/imagePreprocessor',
|
|
7
|
+
},
|
|
8
|
+
});
|