-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: 完成创建package.json,同时处理了一些其他小改动: (#28) #39
refactor: 完成创建package.json,同时处理了一些其他小改动: (#28) #39
Conversation
Walkthrough这次的代码改动主要包括以下几个方面的重构:
Changes
Uplevel your code reviews with CodeRabbit ProCodeRabbit ProIf you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files selected (4)
- packages/@plugin/plugin-eslint/index.ts (1)
- packages/core/src/index.ts (1)
- packages/core/src/utils/createAppTest.ts (4)
- packages/core/src/utils/packageAPI.ts (1)
Files not reviewed due to errors (2)
- packages/core/src/index.ts (no response)
- packages/core/src/utils/packageAPI.ts (no response)
Files skipped from review due to trivial changes (1)
- packages/@plugin/plugin-eslint/index.ts
Review comments generated (5)
- Review: 5
- LGTM: 0
Tips
Chat with CodeRabbit Bot (@coderabbitai
)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitai
in a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignore
anywhere in the PR description to pause further reviews from the bot.
import { projectSelect } from "./select"; | ||
import isGitInstalled from "./checkGitInstallation"; | ||
// import { createPackageJson } from "./createFile"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { confirm } from "@clack/prompts"; | ||
import chalk from "chalk"; | ||
|
||
import { removeDirectory } from "./fileController"; | ||
// import { removeDirectory } from "./fileController"; | ||
import { projectSelect } from "./select"; | ||
import isGitInstalled from "./checkGitInstallation"; | ||
// import { createPackageJson } from "./createFile"; | ||
import PackageAPI from "./packageAPI"; | ||
import { createFiles } from "./createFiles"; | ||
import { type Preset, getFilesForProject, getNpmForPackage } from "./preset"; | ||
import createSuccessInfo from "./createSuccessInfo"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log(shouldContinue); | ||
|
||
execSync(`mkdir ${rootDirectory}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const preset: Preset = await projectSelect(); | ||
|
||
console.log(rootDirectory); | ||
// 创建package.json | ||
await createFiles(rootDirectory, { | ||
"package.json": "{}", // todo:具体内容待重构 | ||
console.log(chalk.blue(`\n📄 Generating package.json...`)); | ||
const packageContent = { | ||
name: projectName, | ||
version: "0.1.0", | ||
private: true, | ||
devDependencies: {}, | ||
}; | ||
// 遍历 preset.plugins,插入依赖 | ||
Object.keys(preset.plugins).forEach((dep) => { | ||
console.log("dep:", dep); | ||
// todo: 更多的处理依据 preset.plugins[dep] 后续的变化而插入 | ||
let { version } = preset.plugins[dep]; | ||
if (!version) { | ||
version = "latest"; | ||
} | ||
packageContent.devDependencies[dep] = version; | ||
}); | ||
const packageJson = new PackageAPI(rootDirectory); | ||
await packageJson.createPackageJson(packageContent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object.keys(packageContent.devDependencies).forEach(async (dep) => { | ||
console.log(dep, "installed"); | ||
// 进入仓库 | ||
// await execSync(`npm install ${plugin}`) | ||
// await execSync(`npm install ${dep}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
What is the new behavior?
Does this PR introduce a breaking change?
架构升级的部分功能实现
Other information
Summary by CodeRabbit
以下是这些拉取请求的简洁发布说明:
packages/@plugin/plugin-eslint/index.ts:
buildToolConfigs
对象和一个pluginEslint
函数,用于处理不同构建工具的配置。packages/core/src/index.ts:
createApp
函数的调用,添加了一个console.log(pluginOptions, plugin)
语句,并对代码进行了格式化调整。packages/core/src/utils/createAppTest.ts:
package.json
文件,并使用PackageAPI
类来管理package.json
的操作。packages/core/src/utils/packageAPI.ts:
packageAPI
的类,用于创建、读取、更新和删除package.json
文件。请注意,这些发布说明侧重于对最终用户可见的功能,并省略了代码级别的细节。