Skip to content

Commit

Permalink
chore: update create-farm sub framework choose (#1286)
Browse files Browse the repository at this point in the history
* chore: update create-farm sub framework choose

* chore: update create-farm sub framework choose

* chore: update create-farm sub framework choose

* chore: update create-farm sub framework choose

* chore: update create-farm sub framework choose

* chore: update readme

* chore: remove submodules
  • Loading branch information
ErKeLost authored May 7, 2024
1 parent 5283e28 commit f5b7721
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-llamas-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-farm": patch
---

update choose framework ways
28 changes: 24 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributing to Farm
# Contribution Guide

Thank you for your interest in contributing to Farm!. Before submitting your contribution, please make sure to take a moment and read through the following guidelines.

Expand Down Expand Up @@ -28,7 +28,7 @@ Please feel free to open an issue using the [feature request template](https://g

- Run `cargo test` and make sure that it passes.

- If you've changed some packages And prepare for an updated version, you should output `npx changset` in the root directory.
- If you've changed some packages And prepare for an updated version, you should output `npx changeset` in the root directory. we should try our best to keep releasing the `patch version`. If there are no major changes, please choose to update the `patch version`.

- When you are done with your work, verify that it works locally with `pnpm run ready`

Expand Down Expand Up @@ -57,6 +57,16 @@ Please feel free to open an issue using the [feature request template](https://g

- [Pnpm](https://pnpm.io) **version 8+**


### IDE

We recommend that you use vscode for development and recommend two necessary plugins that you need to install

- `rust-analyzer` support rust language
- `biome` farm use biome to detect and format the code

You can install them in the extension

### Setup Other Dependencies

- Install [protoc](https://grpc.io/docs/protoc-installation/) for building `sass-embedded`.
Expand All @@ -65,10 +75,10 @@ Please feel free to open an issue using the [feature request template](https://g

## Start running

Farm development is very simple. You only need to execute pnpm bootstrap in the root directory for development.
Farm development is very simple. You only need to execute `pnpm bootstrap` in the root directory for development.

```bash
$ pnpm bootstrap # install the dependencies of the project
$ pnpm bootstrap
```

- use `pnpm bootstrap` to install dependencies and build core packages with series of initialization operations.
Expand All @@ -79,6 +89,16 @@ $ pnpm bootstrap # install the dependencies of the project

- If you changed Rust code in `crates`, run `npm run build:rs` under `packages/core` again to get the latest binary.

When you are developing node side code, the root directory executes pnpm start to debug the code in real time, and when you are developing rust side code, the root directory executes pnpm start:rs to debug the code in real time.

```ts
// node side
pnpm start

// rust side
pnpm start:rs
```

## Testing

We also need to test two parts, a set of `Rust` tests and a set of `Node` tests. Make sure all the tests pass before you submit the code.
Expand Down
21 changes: 20 additions & 1 deletion CONTRIBUTING.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

- 使用 `cargo test` 确保所有测试均能通过。

- 如果您已经更改了一些包并准备更新版本,则您应该在根目录中输出`npx changeset` 用来发布新版本并且提交。
- 如果您已经更改了一些包并准备更新版本,则您应该在根目录中输出`npx changeset` 用来发布新版本并且提交。 我们应该尽量保持发布 `patch` 版本, 如果没有重大更改的情况下,请选择 更新 `patch` 版本

- 当你完成你的工作后,请通过 `pnpm run ready` 来验证是否可以在本地正常运行

Expand Down Expand Up @@ -53,6 +53,15 @@

- 确保您的 [Pnpm](https://pnpm.io) 版本在 **8** 以上。

### IDE

我们推荐使用 `vscode` 进行开发, 并且我们推荐两个必要的插件

- `rust-analyzer` 支持 `rust` 语言。
- `biome` 使用 `biome` 进行格式化和检查代码。

你可以在扩展中安装它们

### 其他依赖

- 在构建 `sass-embedded` 需要用到 [protoc](https://grpc.io/docs/protoc-installation/) 所以您的本地开发环境还需要安装 [protoc](https://grpc.io/docs/protoc-installation/)
Expand All @@ -75,6 +84,16 @@ $ pnpm bootstrap # install the dependencies of the project with series of initia

- 如果您更改了`crates`中的 `Rust` 代码,请再次运行 `Packages/core` 下的 `npm run build:rs` 以获取最新的二进制代码。

当你在开发 node 侧代码时, 根目录执行 pnpm start 就可以实时调试代码了,当你在开发 rust 侧代码时, 根目录执行 pnpm start:rs 就可以实时调试代码了

```bash
// node side
pnpm start

// rust side
pnpm start:rs
```

## 测试

我们还需要测试两个部分,一套 `Rust` 测试,一套 `Node` 测试,在您提交代码之前,请确保所有测试均能通过。
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ See [Contributing Guide](https://github.com/farm-fe/farm/blob/main/CONTRIBUTING.

- Wechat group

<br><img src="https://github.com/ErKeLost/react/assets/66500121/4e56602d-dbe6-4dd1-a91c-cb5a881b3418" width="30%" />
<br><img src="https://github.com/ErKeLost/react/assets/66500121/f81839ab-a6e8-4298-830c-cae2213fe0b4" width="30%" />

- QQ group

<br><img src="https://github.com/ErKeLost/react/assets/66500121/a9312045-584b-44fa-87b3-2827372ae849" width="30%" />

## Contributors

Expand Down
6 changes: 5 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ Farm 远快于业界常用的 JS 构建工具,在 benchmark 测试中,Farm

- 微信交流群

<br><img src="https://github.com/ErKeLost/react/assets/66500121/4e56602d-dbe6-4dd1-a91c-cb5a881b3418" width="30%" />
<br><img src="https://github.com/ErKeLost/react/assets/66500121/f81839ab-a6e8-4298-830c-cae2213fe0b4" width="30%" />

- QQ 群

<br><img src="https://github.com/ErKeLost/react/assets/66500121/a9312045-584b-44fa-87b3-2827372ae849" width="30%" />

## 感谢贡献者们做出的努力

Expand Down
36 changes: 10 additions & 26 deletions packages/create-farm/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import fs from 'node:fs';
import path from 'node:path';
import spawn from 'cross-spawn';
import minimist from 'minimist';
import prompts from 'prompts';

Expand All @@ -11,6 +10,10 @@ import { colors } from './utils/color.js';
import createSpawnCmd from './utils/createSpawnCmd.js';
import { loadWithRocketGradient } from './utils/gradient.js';
import { shouldUsePnpm, shouldUseYarn } from './utils/packageManager.js';
import {
frameworkPromptsChoices,
getSubFrameworkPromptsChoices
} from './utils/prompts.js';

interface IResultType {
packageName?: string;
Expand Down Expand Up @@ -108,25 +111,7 @@ async function createFarm() {
name: 'framework',
message: 'Select a framework:',
initial: 0,
choices: [
{
title: colors.cyan('React'),
value: 'react'
},
{ title: colors.green('Vue'), value: 'vue' },
{
title: colors.cyan('Preact'),
value: 'preact'
},
{ title: colors.blue('Solid'), value: 'solid' },
{ title: colors.orange('Svelte'), value: 'svelte' },
{
title: colors.yellow('Vanilla'),
value: 'vanilla'
},
{ title: colors.red('Lit'), value: 'lit' },
{ title: colors.orange('Tauri'), value: 'tauri' }
]
choices: frameworkPromptsChoices
},
{
type: pkgInfo || skipInstall ? null : 'select',
Expand Down Expand Up @@ -158,14 +143,13 @@ async function createFarm() {
return;
}
const { framework = argFramework, packageManager } = result;
let chooseFramework: IResultType['framework'] = framework;
if (framework === 'tauri') {
const tauriOption = await prompts(tauriTemplate as prompts.PromptObject[]);
chooseFramework = `tauri/${tauriOption['tauri-framework']}`;
}
const frameworkPrompts = getSubFrameworkPromptsChoices(framework);
const options = await prompts(frameworkPrompts as any);

await copyTemplate(targetDir, {
framework: chooseFramework,
framework: options.subFramework
? `${framework}/${options.subFramework}`
: framework,
projectName: targetDir,
packageManager
});
Expand Down
41 changes: 41 additions & 0 deletions packages/create-farm/utils/prompts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { colors } from './color.js';

const allFramework = new Map([
['tauri', ['lit', 'tauri', 'electron']],
['ssr', ['lit', 'tauri', 'electron']],
['electron', ['lit', 'tauri', 'electron']]
]);

export const frameworkPromptsChoices = [
{
title: colors.cyan('React'),
value: 'react'
},
{ title: colors.green('Vue'), value: 'vue' },
{
title: colors.cyan('Preact'),
value: 'preact'
},
{ title: colors.blue('Solid'), value: 'solid' },
{ title: colors.orange('Svelte'), value: 'svelte' },
{
title: colors.yellow('Vanilla'),
value: 'vanilla'
},
{ title: colors.red('Lit'), value: 'lit' },
{ title: colors.orange('Tauri'), value: 'tauri' }
];

export function getSubFrameworkPromptsChoices(framework: string) {
const filterFramework = allFramework.get(framework);
const choices = frameworkPromptsChoices.filter(
(item) => !filterFramework?.includes(item.value)
);

return {
type: filterFramework ? 'select' : null,
name: 'subFramework',
message: 'Select a framework:',
choices
};
}

0 comments on commit f5b7721

Please sign in to comment.