Skip to content

Commit a4dd424

Browse files
committed
feat: 新增 create 命令 lin-ui 版本号输入功能,默认最新版本
1 parent daef37c commit a4dd424

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

lib/create.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const prompt = [
2828
type: 'confirm',
2929
name: 'openLoading',
3030
message: '是否开启按需加载?'
31-
}
31+
},
3232
];
3333
/**
3434
* @name 获取linui最新版本号
@@ -58,13 +58,20 @@ async function create(dirName) {
5858
default: dirName
5959
};
6060
prompt.unshift(nameOption);
61-
const { name, version, description, openLoading } = await inquirer_1.default.prompt(prompt);
62-
// 获取linui最新版本号
6361
const linuiversion = await getLinUiVersion();
62+
const versionOption = {
63+
type: 'input',
64+
name: 'linVersion',
65+
message: `请输入您期望安装的 LinUI 版本(默认为最新版)`,
66+
default: linuiversion
67+
};
68+
prompt.push(versionOption);
69+
const { name, version, description, openLoading, linVersion } = await inquirer_1.default.prompt(prompt);
70+
// 获取linui最新版本号
6471
// 获取微信小程序稳定基础版本库
6572
const miniVersion = await getMiniVersion();
6673
// 获取package.json内容
67-
const packageJson = template_1.packageJsonContent({ name, linuiversion, version, description, cliversion: config_1.CLI_VERSION, cliname: config_1.CLI_NAME });
74+
const packageJson = template_1.packageJsonContent({ name, linuiversion: linVersion, version, description, cliversion: config_1.CLI_VERSION, cliname: config_1.CLI_NAME });
6875
// 获取project.config.json内容
6976
const projectConfig = template_1.projectConfigContent(openLoading, config_1.USER_CONFIG_FILE_NAME, name, miniVersion);
7077
// 获取lin.config.json内容

lib/interface.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface PromptInput {
4343
version: string;
4444
description: string;
4545
openLoading: boolean;
46+
linVersion: string;
4647
}
4748
/**
4849
* @name project.config.json

src/create.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const prompt = [
2525
type: 'confirm',
2626
name: 'openLoading',
2727
message: '是否开启按需加载?'
28-
}
28+
},
2929
]
3030

3131
/**
@@ -58,14 +58,21 @@ export default async function create(dirName: string) {
5858
default: dirName
5959
}
6060
prompt.unshift(nameOption)
61+
const linuiversion = await getLinUiVersion()
62+
const versionOption = {
63+
type: 'input',
64+
name: 'linVersion',
65+
message: `请输入您期望安装的 LinUI 版本(默认为最新版)`,
66+
default: linuiversion
67+
}
68+
prompt.push(versionOption)
6169

62-
const { name, version, description, openLoading }: PromptInput = await inquirer.prompt(prompt)
70+
const { name, version, description, openLoading, linVersion }: PromptInput = await inquirer.prompt(prompt)
6371
// 获取linui最新版本号
64-
const linuiversion = await getLinUiVersion()
6572
// 获取微信小程序稳定基础版本库
6673
const miniVersion = await getMiniVersion()
6774
// 获取package.json内容
68-
const packageJson = packageJsonContent({ name, linuiversion, version, description, cliversion: CLI_VERSION, cliname: CLI_NAME })
75+
const packageJson = packageJsonContent({ name, linuiversion: linVersion, version, description, cliversion: CLI_VERSION, cliname: CLI_NAME })
6976
// 获取project.config.json内容
7077
const projectConfig = projectConfigContent(openLoading, USER_CONFIG_FILE_NAME, name, miniVersion)
7178
// 获取lin.config.json内容

src/interface.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export interface PromptInput {
4646
name: string,
4747
version: string,
4848
description: string,
49-
openLoading: boolean
49+
openLoading: boolean,
50+
linVersion: string
5051
}
5152

5253
/**

0 commit comments

Comments
 (0)