在create时增加了Example的框架(未完成)

This commit is contained in:
Xu Chang 2024-10-27 12:26:07 +08:00
parent 6b01e3718b
commit 0ba50f58a1
4 changed files with 30 additions and 6 deletions

View File

@ -35,12 +35,19 @@ const prompt = [
type: 'confirm',
message: 'add oak-general-business into dependency?',
default: true,
}, {
},
{
name: 'moreDeps',
type: 'input',
message: 'do you have more dependent oak-family libraries? type their names, use comma as separator.',
default: '',
}
},
{
name: 'example',
type: 'confirm',
message: 'load an initial example about personal blog? It will load correspond Entities/Pages/Components/Checkers and etc.',
default: true,
},
];
/**
* 将项目的依赖关系加入
@ -152,7 +159,7 @@ async function create(dirName, cmd) {
prompt.unshift(nameOption, titleOption);
const isDev = cmd.dev ? true : false;
const isModule = cmd.module ? true : false;
const { name, version, title, description, useOgb, moreDeps } = await inquirer_1.default.prompt(prompt);
const { name, version, title, description, useOgb, moreDeps, example } = await inquirer_1.default.prompt(prompt);
// 获取tsconfig.json内容
const tsconfigJson = (0, template_1.tsConfigJsonContent)();
const tsConfigBuildJson = (0, template_1.tsConfigBuildJsonContent)();
@ -244,6 +251,9 @@ async function create(dirName, cmd) {
// 创建package.json
(0, file_handle_1.checkFileExistsAndCreate)(packageJsonPath, packageJson, enum_1.checkFileExistsAndCreateType.FILE);
(0, rename_1.renameProject)(rootPath, name, title, DEFAULT_PROJECT_NAME, DEFAULT_PROJECT_TITLE);
if (example) {
// todo: copy template example files
}
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`Ok, type 'npm install' to install libs, then start!`)}`);
}
catch (err) {

1
lib/interface.d.ts vendored
View File

@ -24,6 +24,7 @@ export interface PromptInput {
description: string;
title: string;
useOgb: boolean;
example: boolean;
moreDeps: string;
}
/**

View File

@ -66,12 +66,19 @@ const prompt = [
type: 'confirm',
message: 'add oak-general-business into dependency?',
default: true,
}, {
},
{
name: 'moreDeps',
type: 'input',
message: 'do you have more dependent oak-family libraries? type their names, use comma as separator.',
default: '',
}
},
{
name: 'example',
type: 'confirm',
message: 'load an initial example about personal blog? It will load correspond Entities/Pages/Components/Checkers and etc.',
default: true,
},
];
/**
@ -236,7 +243,7 @@ export async function create(dirName: string, cmd: any) {
const isDev = cmd.dev ? true : false;
const isModule = cmd.module ? true : false;
const { name, version, title, description, useOgb, moreDeps }: PromptInput = await inquirer.prompt(
const { name, version, title, description, useOgb, moreDeps, example }: PromptInput = await inquirer.prompt(
prompt
);
@ -380,6 +387,11 @@ export async function create(dirName: string, cmd: any) {
);
renameProject(rootPath, name, title, DEFAULT_PROJECT_NAME, DEFAULT_PROJECT_TITLE);
if (example) {
// todo: copy template example files
}
Success(
`${success(
`Ok, type 'npm install' to install libs, then start!`

View File

@ -27,6 +27,7 @@ export interface PromptInput {
description: string,
title: string,
useOgb: boolean;
example: boolean;
moreDeps: string;
}