Forráskód Böngészése

【create】更新 create-stdf 版本至 0.2.5,优化 README 文件中的命令示例,修正模板名称,调整图标使用方式的描述。

dufu1991 1 éve
szülő
commit
61725cc9c8

+ 36 - 34
packages/create-stdf/README.md

@@ -9,7 +9,7 @@ A CLI for creating new [STDF](https://stdf.design) projects. Just run...
 <!-- :::code-groups -->
 <!-- pnpm -->
 ```sh
-pnpm create stdf
+pnpm create stdf@latest
 ```
 <!-- :: -->
 <!-- npm -->
@@ -23,18 +23,18 @@ npx create-stdf@latest
 <!-- :: -->
 <!-- bun -->
 ```sh
-bun create stdf
+bun create stdf@latest
 ```
 <!-- :: -->
 <!-- yarn -->
 ```sh
-yarn create stdf
+yarn create stdf@latest
 ```
 <!-- ::: -->
 
 ...and follow the prompts.
 
-You can also directly specify the project name and the template you want to use via additional command line options. For example, to create a new project named `my-app` using the **SvelteKit & Tailwind & TypeScript & STDF & stdf-icon** template, run:
+You can also directly specify the project name and the template you want to use via additional command line options. For example, to create a new project named `my-app` using the **SvelteKit & Tailwind & TypeScript & STDF** template, run:
 
 <!-- :::code-groups -->
 <!-- pnpm -->
@@ -58,66 +58,59 @@ yarn create stdf my-app
 ```
 <!-- ::: -->
 
-If you want to use the **SvelteKit & Tailwind & STDF & stdf-icon** template, run:
+If you want to use the **SvelteKit & Tailwind & STDF** template, run:
 
 <!-- :::code-groups -->
 <!-- pnpm -->
 ```sh
-pnpm create stdf my-app --template skts
+pnpm create stdf my-app --template skt
 # or
-pnpm create stdf my-app -t skts
+pnpm create stdf my-app -t skt
 ```
 <!-- :: -->
 <!-- npm -->
 ```sh
-npm create stdf@latest my-app --template skts
+npm create stdf@latest my-app --template skt
 # or
-npm create stdf@latest my-app -t skts
+npm create stdf@latest my-app -t skt
 ```
 <!-- :: -->
 <!-- bun -->
 ```sh
-bun create stdf my-app --template skts
+bun create stdf my-app --template skt
 # or
-bun create stdf my-app -t skts
+bun create stdf my-app -t skt
 ```
 <!-- :: -->
 <!-- yarn -->
 ```sh
-yarn create stdf my-app --template skts
+yarn create stdf my-app --template skt
 # or
-yarn create stdf my-app -t skts
+yarn create stdf my-app -t skt
 ```
 <!-- ::: -->
 
-Template presets include:
-
-| Abbreviation | Template                                                | Description     |
-| ------------ | ------------------------------------------------------- | --------------- |
-| sktts        | SvelteKit & Tailwind & TypeScript & stdf-icon           | Default         |
-| skts         | SvelteKit & Tailwind & stdf-icon                        | -               |
-| sktti        | SvelteKit & Tailwind & TypeScript & iconify             | -               |
-| skti         | SvelteKit & Tailwind & iconify                          | -               |
-| skttsi       | SvelteKit & Tailwind & TypeScript & stdf-icon & iconify | -               |
-| sktsi        | SvelteKit & Tailwind & stdf-icon & iconify              | -               |
-| skuts        | SvelteKit & UnoCSS & TypeScript & stdf-icon             | Not adapted yet |
-| skus         | SvelteKit & UnoCSS & stdf-icon                          | Not adapted yet |
-| skuti        | SvelteKit & UnoCSS & TypeScript & iconify               | Not adapted yet |
-| skui         | SvelteKit & UnoCSS & iconify                            | Not adapted yet |
-| skutsi       | SvelteKit & UnoCSS & TypeScript & stdf-icon & iconify   | Not adapted yet |
-| skusi        | SvelteKit & UnoCSS & stdf-icon & iconify                | Not adapted yet |
-
 # Options
 
 | Option          | Type   | Default | Description                                    |
 | --------------- | ------ | ------- | ---------------------------------------------- |
 | -               | string | -       | The name of the project, you can direct input. |
-| -t / --template | string | sktts   | The template to use.                           |
-| -l / --language | string | en_US   | The language of the prompts.                   |
+| -t / --template | `'sktt'\|'skt'\|'skut'\|'sku'` | `'sktt'` | The template to use.                           |
+| -l / --language | `'en_US'\|'zh_CN'\|'zh_TW'\|'ja_JP'\|'ko_KR'\|'es_ES'\|'ru_RU'\|'fr_FR'\|'de_DE'\|'it_IT'` | `'en_US'` | The language of the prompts.                   |
+| -i / --icon-usage | `'stdf-icon'\|'iconify'\|'both'\|'none'` | `'stdf-icon'` | The icon usage method.                         |
+
+# Template presets
 
-# Supported Languages
+| Abbreviation | Template                                                | Description     |
+| ------------ | ------------------------------------------------------- | --------------- |
+| sktt        | SvelteKit & Tailwind & TypeScript           | Default         |
+| skt         | SvelteKit & Tailwind                         | -               |
+| skut        | SvelteKit & UnoCSS & TypeScript             | Not adapted yet |
+| sku         | SvelteKit & UnoCSS                         | Not adapted yet |
+
+# Language presets
 
-| Code  | Language              |
+| Abbreviation  | Language              |
 | ----- | --------------------- |
 | en_US | English (US)          |
 | zh_CN | Chinese (Simplified)  |
@@ -130,6 +123,15 @@ Template presets include:
 | de_DE | German                |
 | it_IT | Italian               |
 
+# Icon usage presets
+
+| Abbreviation | Description                                                           |
+| --------- | -------------------------------------------------------------- |
+| stdf-icon | Use `rollup-plugin-stdf-icon` to manage icons.                  |
+| iconify   | Use `iconify` to manage icons.                                  |
+| both      | Use both `rollup-plugin-stdf-icon` and `iconify` to manage icons. |
+| none      | Do not use any tool to manage icons.                                       |
+
 For example:
 
 <!-- :::code-groups -->

+ 40 - 38
packages/create-stdf/README_CN.md

@@ -1,6 +1,6 @@
 [English](https://github.com/any-tdf/stdf/blob/main/packages/create-stdf/README.md)
 
-> v0.2.2 之后支持选择图标使用方式,使用 `stdf-icon` 或 `iconify`。
+> v0.2.2 之后支持选择图标使用方式,支持 `stdf-icon` 或 `iconify`。
 
 # create-stdf
 
@@ -9,7 +9,7 @@
 <!-- :::code-groups -->
 <!-- pnpm -->
 ```sh
-pnpm create stdf
+pnpm create stdf@latest
 ```
 <!-- :: -->
 <!-- npm -->
@@ -23,18 +23,18 @@ npx create-stdf@latest
 <!-- :: -->
 <!-- bun -->
 ```sh
-bun create stdf
+bun create stdf@latest
 ```
 <!-- :: -->
 <!-- yarn -->
 ```sh
-yarn create stdf
+yarn create stdf@latest
 ```
 <!-- ::: -->
 
 ...然后按照提示进行操作。
 
-你也可以通过额外的命令行选项直接指定项目名称和要使用的模板。例如,如果要使用 **SvelteKit & Tailwind & TypeScript & STDF & stdf-icon** 模板创建一个名为 `my-app` 的新项目,请运行:
+你也可以通过额外的命令行选项直接指定项目名称和要使用的模板。例如,如果要使用 **SvelteKit & Tailwind & TypeScript & STDF** 模板创建一个名为 `my-app` 的新项目,请运行:
 
 <!-- :::code-groups -->
 <!-- pnpm -->
@@ -58,66 +58,59 @@ yarn create stdf my-app
 ```
 <!-- ::: -->
 
-如果要使用 **SvelteKit & Tailwind & STDF & stdf-icon** 模板,请运行:
+如果要使用 **SvelteKit & Tailwind & STDF** 模板,请运行:
 
 <!-- :::code-groups -->
 <!-- pnpm -->
 ```sh
-pnpm create stdf my-app --template skts
+pnpm create stdf my-app --template skt
 # 或
-pnpm create stdf my-app -t skts
+pnpm create stdf my-app -t skt
 ```
 <!-- :: -->
 <!-- npm -->
 ```sh
-npm create stdf@latest my-app --template skts
+npm create stdf@latest my-app --template skt
 # 或
-npm create stdf@latest my-app -t skts
+npm create stdf@latest my-app -t skt
 ```
 <!-- :: -->
 <!-- bun -->
 ```sh
-bun create stdf my-app --template skts
+bun create stdf my-app --template skt
 # 或
-bun create stdf my-app -t skts
+bun create stdf my-app -t skt
 ```
 <!-- :: -->
 <!-- yarn -->
 ```sh
-yarn create stdf my-app --template skts
+yarn create stdf my-app --template skt
 # 或
-yarn create stdf my-app -t skts
+yarn create stdf my-app -t skt
 ```
 <!-- ::: -->
 
-模板预设包括:
-
-| 简写   | 模板                                                    | 描述     |
-| ------ | ------------------------------------------------------- | -------- |
-| sktts  | SvelteKit & Tailwind & TypeScript & stdf-icon           | 默认     |
-| skts   | SvelteKit & Tailwind & stdf-icon                        | -        |
-| sktti  | SvelteKit & Tailwind & TypeScript & iconify             | -        |
-| skti   | SvelteKit & Tailwind & iconify                          | -        |
-| skttsi | SvelteKit & Tailwind & TypeScript & stdf-icon & iconify | -        |
-| sktsi  | SvelteKit & Tailwind & stdf-icon & iconify              | -        |
-| skuts  | SvelteKit & UnoCSS & TypeScript & stdf-icon             | 暂未适配 |
-| skus   | SvelteKit & UnoCSS & stdf-icon                          | 暂未适配 |
-| skuti  | SvelteKit & UnoCSS & TypeScript & iconify               | 暂未适配 |
-| skui   | SvelteKit & UnoCSS & iconify                            | 暂未适配 |
-| skutsi | SvelteKit & UnoCSS & TypeScript & stdf-icon & iconify   | 暂未适配 |
-| skusi  | SvelteKit & UnoCSS & stdf-icon & iconify                | 暂未适配 |
-
 # 命令选项
 
-| 命令            | 类型   | 默认  | 描述                                                       |
-| --------------- | ------ | ----- | ---------------------------------------------------------- |
-| -               | string | -     | 项目名称,可以直接输入。                                   |
-| -t / --template | string | sktts | 要使用的模板。 |
-| -l / --language | string | en_US | 提示语言。                                                 |
+| 命令              | 类型                                                                                       | 默认          | 描述                     |
+| ----------------- | ------------------------------------------------------------------------------------------ | ------------- | ------------------------ |
+| -                 | string                                                                                     | -             | 项目名称,可以直接输入。 |
+| -t / --template   | `'sktt'\|'skt'\|'skut'\|'sku'`                                                             | `'sktt'`      | 要使用的模板。           |
+| -l / --language   | `'en_US'\|'zh_CN'\|'zh_TW'\|'ja_JP'\|'ko_KR'\|'es_ES'\|'ru_RU'\|'fr_FR'\|'de_DE'\|'it_IT'` | `'en_US'`     | 提示语言。               |
+| -i / --icon-usage | `'stdf-icon'\|'iconify'\|'both'\|'none'`                                                   | `'stdf-icon'` | 图标使用方式。           |
+
+# 模板预设
+
+| 简写 | 模板                              | 描述     |
+| ---- | --------------------------------- | -------- |
+| sktt | SvelteKit & Tailwind & TypeScript | 默认     |
+| skt  | SvelteKit & Tailwind              | -        |
+| skut | SvelteKit & UnoCSS & TypeScript   | 暂未适配 |
+| sku  | SvelteKit & UnoCSS                | 暂未适配 |
 
-# 支持的语言
+# 语言预设
 
-| 代码  | 语言         |
+| 简写  | 语言         |
 | ----- | ------------ |
 | en_US | 英语(美式) |
 | zh_CN | 中文(简体) |
@@ -130,6 +123,15 @@ yarn create stdf my-app -t skts
 | de_DE | 德语         |
 | it_IT | 意大利语     |
 
+# 图标使用方式预设
+
+| 简写      | 描述                                                           |
+| --------- | -------------------------------------------------------------- |
+| stdf-icon | 使用 `rollup-plugin-stdf-icon` 插件管理图标。                  |
+| iconify   | 使用 `iconify` 插件管理图标。                                  |
+| both      | 同时使用 `rollup-plugin-stdf-icon` 和 `iconify` 插件管理图标。 |
+| none      | 不使用任何工具管理图标。                                       |
+
 例如:
 
 <!-- :::code-groups -->

+ 1 - 1
packages/create-stdf/package.json

@@ -1,6 +1,6 @@
 {
 	"name": "create-stdf",
-	"version": "0.2.4",
+	"version": "0.2.5",
 	"description": "A CLI for creating new STDF projects",
 	"bin": {
 		"create-stdf": "index.js"

+ 3 - 2
packages/create-stdf/src/index.js

@@ -312,9 +312,10 @@ function createFunc(projectName, templateItem, iconUsageItem, packageManagerItem
 				fs.writeFileSync(`${projectDir}/src/routes/+page.svelte`, pageSvelteLines.join('\n'), 'utf-8');
 			};
 			const addStdfIconFun = async () => {
+				const isTs = templateItem.value.includes('tt') || templateItem.value.includes('ut');
 				const rollupPluginStdfIconV = await getLatestVersion('rollup-plugin-stdf-icon');
 				packageJson.devDependencies['rollup-plugin-stdf-icon'] = `^${rollupPluginStdfIconV}`;
-				const viteConfig = fs.readFileSync(`${projectDir}/vite.config.js`, 'utf-8');
+				const viteConfig = fs.readFileSync(`${projectDir}/vite.config.${isTs ? 'ts' : 'js'}`, 'utf-8');
 				const viteConfigLines = viteConfig.split('\n');
 				viteConfigLines.splice(1, 0, `import svgSprite from 'rollup-plugin-stdf-icon';`);
 				const viteStdfIconSnippet = fs.readFileSync(new URL('../snippet/vite-stdf-icon.txt', import.meta.url), 'utf-8');
@@ -325,7 +326,7 @@ function createFunc(projectName, templateItem, iconUsageItem, packageManagerItem
 					1,
 					viteStdfIconSnippet
 				);
-				fs.writeFileSync(`${projectDir}/vite.config.js`, viteConfigLines.join('\n'), 'utf-8');
+				fs.writeFileSync(`${projectDir}/vite.config.${isTs ? 'ts' : 'js'}`, viteConfigLines.join('\n'), 'utf-8');
 				// 将 snippet/svgs 整个目录复制到 ${projectDir}/src/lib 目录下
 				// Copy the snippet/svgs directory to the ${projectDir}/src/lib directory
 				fs.copySync(new URL('../snippet/svgs', import.meta.url).pathname, `${projectDir}/src/lib/svgs`);