zixulu 1.65.4 → 1.65.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils/addAntd.js +8 -10
- package/dist/utils/addAntd.js.map +2 -2
- package/dist/utils/addPrettier.js +4 -3
- package/dist/utils/addPrettier.js.map +2 -2
- package/dist/utils/writeJson.js +1 -1
- package/dist/utils/writeJson.js.map +2 -2
- package/package.json +1 -1
- package/src/utils/addAntd.ts +8 -10
- package/src/utils/addPrettier.ts +4 -3
- package/src/utils/writeJson.ts +1 -1
package/dist/utils/addAntd.js
CHANGED
|
@@ -47,7 +47,7 @@ async function addAntd() {
|
|
|
47
47
|
if (packageJson.dependencies.next) {
|
|
48
48
|
await (0, import_addDependency.addDependency)({ package: "@ant-design/nextjs-registry" });
|
|
49
49
|
await (0, import_promises.writeFile)(
|
|
50
|
-
(0, import_path.join)(componentDir, "
|
|
50
|
+
(0, import_path.join)(componentDir, "Registry.tsx"),
|
|
51
51
|
`"use client"
|
|
52
52
|
|
|
53
53
|
import { FC, ReactNode } from "react"
|
|
@@ -55,12 +55,11 @@ import { AntdRegistry } from "@ant-design/nextjs-registry"
|
|
|
55
55
|
import { ConfigProvider } from "antd"
|
|
56
56
|
import zhCN from "antd/locale/zh_CN"
|
|
57
57
|
|
|
58
|
-
export interface
|
|
58
|
+
export interface RegistryProps {
|
|
59
59
|
children?: ReactNode
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const
|
|
63
|
-
const { children } = props
|
|
62
|
+
const Registry: FC<RegistryProps> = ({ children }) => {
|
|
64
63
|
|
|
65
64
|
return (
|
|
66
65
|
<AntdRegistry hashPriority="high">
|
|
@@ -69,23 +68,22 @@ const AntdNextRegistry: FC<AntdNextRegistryProps> = props => {
|
|
|
69
68
|
)
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
export default
|
|
71
|
+
export default Registry
|
|
73
72
|
`
|
|
74
73
|
);
|
|
75
74
|
} else {
|
|
76
75
|
await (0, import_promises.writeFile)(
|
|
77
|
-
(0, import_path.join)(componentDir, "
|
|
76
|
+
(0, import_path.join)(componentDir, "Registry.tsx"),
|
|
78
77
|
`import { StyleProvider } from "@ant-design/cssinjs"
|
|
79
78
|
import { ConfigProvider } from "antd"
|
|
80
79
|
import zhCN from "antd/locale/zh_CN"
|
|
81
80
|
import { FC, ReactNode } from "react"
|
|
82
81
|
|
|
83
|
-
export
|
|
82
|
+
export interface RegistryProps {
|
|
84
83
|
children?: ReactNode
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
const
|
|
88
|
-
const { children } = props
|
|
86
|
+
const Registry: FC<RegistryProps> = ({ children }) => {
|
|
89
87
|
|
|
90
88
|
return (
|
|
91
89
|
<StyleProvider hashPriority="high">
|
|
@@ -94,7 +92,7 @@ const AntdRegistry: FC<AntdRegistryProps> = props => {
|
|
|
94
92
|
)
|
|
95
93
|
}
|
|
96
94
|
|
|
97
|
-
export default
|
|
95
|
+
export default Registry
|
|
98
96
|
`
|
|
99
97
|
);
|
|
100
98
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/addAntd.ts"],
|
|
4
|
-
"sourcesContent": ["import { mkdir, readdir, writeFile } from \"fs/promises\"\nimport { join } from \"path\"\nimport consola from \"consola\"\n\nimport { addDependency } from \"./addDependency\"\nimport { readPackageJson } from \"./readPackageJson\"\n\n/**\n * 添加 antd 相关配置\n * 包括安装依赖、创建必要组件等\n */\nexport async function addAntd() {\n consola.start(\"开始添加 antd 配置\")\n await addDependency({ package: [\"@ant-design/cssinjs\", \"@ant-design/icons\", \"antd\"] })\n const dir = await readdir(\".\")\n const componentDir = dir.includes(\"src\") ? \"src/components\" : \"components\"\n await mkdir(componentDir, { recursive: true })\n const packageJson = await readPackageJson()\n if (packageJson.dependencies.next) {\n await addDependency({ package: \"@ant-design/nextjs-registry\" })\n await writeFile(\n join(componentDir, \"
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA0C;AAC1C,kBAAqB;AACrB,qBAAoB;AAEpB,2BAA8B;AAC9B,6BAAgC;AAMhC,eAAsB,UAAU;AAC5B,iBAAAA,QAAQ,MAAM,cAAc;AAC5B,YAAM,oCAAc,EAAE,SAAS,CAAC,uBAAuB,qBAAqB,MAAM,EAAE,CAAC;AACrF,QAAM,MAAM,UAAM,yBAAQ,GAAG;AAC7B,QAAM,eAAe,IAAI,SAAS,KAAK,IAAI,mBAAmB;AAC9D,YAAM,uBAAM,cAAc,EAAE,WAAW,KAAK,CAAC;AAC7C,QAAM,cAAc,UAAM,wCAAgB;AAC1C,MAAI,YAAY,aAAa,MAAM;AAC/B,cAAM,oCAAc,EAAE,SAAS,8BAA8B,CAAC;AAC9D,cAAM;AAAA,UACF,kBAAK,cAAc,
|
|
4
|
+
"sourcesContent": ["import { mkdir, readdir, writeFile } from \"fs/promises\"\nimport { join } from \"path\"\nimport consola from \"consola\"\n\nimport { addDependency } from \"./addDependency\"\nimport { readPackageJson } from \"./readPackageJson\"\n\n/**\n * 添加 antd 相关配置\n * 包括安装依赖、创建必要组件等\n */\nexport async function addAntd() {\n consola.start(\"开始添加 antd 配置\")\n await addDependency({ package: [\"@ant-design/cssinjs\", \"@ant-design/icons\", \"antd\"] })\n const dir = await readdir(\".\")\n const componentDir = dir.includes(\"src\") ? \"src/components\" : \"components\"\n await mkdir(componentDir, { recursive: true })\n const packageJson = await readPackageJson()\n if (packageJson.dependencies.next) {\n await addDependency({ package: \"@ant-design/nextjs-registry\" })\n await writeFile(\n join(componentDir, \"Registry.tsx\"),\n `\"use client\"\n\nimport { FC, ReactNode } from \"react\"\nimport { AntdRegistry } from \"@ant-design/nextjs-registry\"\nimport { ConfigProvider } from \"antd\"\nimport zhCN from \"antd/locale/zh_CN\"\n\nexport interface RegistryProps {\n children?: ReactNode\n}\n\nconst Registry: FC<RegistryProps> = ({ children }) => {\n\n return (\n <AntdRegistry hashPriority=\"high\">\n <ConfigProvider locale={zhCN}>{children}</ConfigProvider>\n </AntdRegistry>\n )\n}\n\nexport default Registry\n`,\n )\n } else {\n await writeFile(\n join(componentDir, \"Registry.tsx\"),\n `import { StyleProvider } from \"@ant-design/cssinjs\"\nimport { ConfigProvider } from \"antd\"\nimport zhCN from \"antd/locale/zh_CN\"\nimport { FC, ReactNode } from \"react\"\n\nexport interface RegistryProps {\n children?: ReactNode\n}\n\nconst Registry: FC<RegistryProps> = ({ children }) => {\n\n return (\n <StyleProvider hashPriority=\"high\">\n <ConfigProvider locale={zhCN}>{children}</ConfigProvider>\n </StyleProvider>\n )\n}\n\nexport default Registry\n`,\n )\n }\n consola.success(\"添加 antd 配置成功\")\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA0C;AAC1C,kBAAqB;AACrB,qBAAoB;AAEpB,2BAA8B;AAC9B,6BAAgC;AAMhC,eAAsB,UAAU;AAC5B,iBAAAA,QAAQ,MAAM,cAAc;AAC5B,YAAM,oCAAc,EAAE,SAAS,CAAC,uBAAuB,qBAAqB,MAAM,EAAE,CAAC;AACrF,QAAM,MAAM,UAAM,yBAAQ,GAAG;AAC7B,QAAM,eAAe,IAAI,SAAS,KAAK,IAAI,mBAAmB;AAC9D,YAAM,uBAAM,cAAc,EAAE,WAAW,KAAK,CAAC;AAC7C,QAAM,cAAc,UAAM,wCAAgB;AAC1C,MAAI,YAAY,aAAa,MAAM;AAC/B,cAAM,oCAAc,EAAE,SAAS,8BAA8B,CAAC;AAC9D,cAAM;AAAA,UACF,kBAAK,cAAc,cAAc;AAAA,MACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAsBJ;AAAA,EACJ,OAAO;AACH,cAAM;AAAA,UACF,kBAAK,cAAc,cAAc;AAAA,MACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAoBJ;AAAA,EACJ;AACA,iBAAAA,QAAQ,QAAQ,cAAc;AAClC;",
|
|
6
6
|
"names": ["consola"]
|
|
7
7
|
}
|
|
@@ -51,7 +51,7 @@ const config = {
|
|
|
51
51
|
tabWidth: 4,
|
|
52
52
|
arrowParens: "avoid",
|
|
53
53
|
printWidth: 160,
|
|
54
|
-
plugins: ["
|
|
54
|
+
plugins: ["prettier-plugin-organize-imports"],
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export default config
|
|
@@ -66,7 +66,7 @@ generated
|
|
|
66
66
|
.generated
|
|
67
67
|
`;
|
|
68
68
|
function getPrettierConfig({ tailwind, atAlias, next, react }) {
|
|
69
|
-
const plugins = ["@
|
|
69
|
+
const plugins = ["@ianvs/prettier-plugin-sort-imports"];
|
|
70
70
|
if (tailwind)
|
|
71
71
|
plugins.push("prettier-plugin-tailwindcss");
|
|
72
72
|
const prettierConfigText = `// @ts-check
|
|
@@ -173,7 +173,7 @@ async function addPrettier() {
|
|
|
173
173
|
await (0, import_promises.writeFile)(".prettierrc.mjs", getPrettierConfig({ tailwind, atAlias, next, react }), "utf-8");
|
|
174
174
|
await (0, import_promises.writeFile)(".prettierignore", ignoreConfig, "utf-8");
|
|
175
175
|
const config2 = {
|
|
176
|
-
package: ["prettier", "@
|
|
176
|
+
package: ["prettier", "@ianvs/prettier-plugin-sort-imports", "glob", "prettier-plugin-organize-imports"],
|
|
177
177
|
type: "devDependencies"
|
|
178
178
|
};
|
|
179
179
|
if (tailwind)
|
|
@@ -182,6 +182,7 @@ async function addPrettier() {
|
|
|
182
182
|
const packageJson2 = await (0, import_readPackageJson.readPackageJson)();
|
|
183
183
|
packageJson2.scripts ??= {};
|
|
184
184
|
packageJson2.scripts.format = "prettier --config prettier.config.mjs --write . && prettier --config .prettierrc.mjs --write .";
|
|
185
|
+
packageJson2.scripts.fg = 'npm run format && git add . && git commit -m "✨feature: format"';
|
|
185
186
|
await (0, import_writePackageJson.writePackageJson)({ data: packageJson2 });
|
|
186
187
|
await (0, import_installDependceny.installDependceny)();
|
|
187
188
|
import_consola.default.success("添加 prettier 配置成功");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/addPrettier.ts"],
|
|
4
|
-
"sourcesContent": ["import { writeFile } from \"fs/promises\"\nimport consola from \"consola\"\n\nimport { AddDependenciesConfig, addDependency } from \"./addDependency\"\nimport { getDependcy } from \"./getDependcy\"\nimport { hasDependency } from \"./hasDependency\"\nimport { installDependceny } from \"./installDependceny\"\nimport { readPackageJson } from \"./readPackageJson\"\nimport { readTsConfig } from \"./readTsConfig\"\nimport { writePackageJson } from \"./writePackageJson\"\n\nconst originalConfig = `// @ts-check\n\n/**\n * @type {import(\"prettier\").Options}\n */\nconst config = {\n semi: false,\n tabWidth: 4,\n arrowParens: \"avoid\",\n printWidth: 160,\n plugins: [\"
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA0B;AAC1B,qBAAoB;AAEpB,2BAAqD;AAErD,2BAA8B;AAC9B,+BAAkC;AAClC,6BAAgC;AAChC,0BAA6B;AAC7B,8BAAiC;AAEjC,IAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBvB,IAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4Bd,SAAS,kBAAkB,EAAE,UAAU,SAAS,MAAM,MAAM,GAA4B;AAC3F,QAAM,UAAU,CAAC,
|
|
4
|
+
"sourcesContent": ["import { writeFile } from \"fs/promises\"\nimport consola from \"consola\"\n\nimport { AddDependenciesConfig, addDependency } from \"./addDependency\"\nimport { getDependcy } from \"./getDependcy\"\nimport { hasDependency } from \"./hasDependency\"\nimport { installDependceny } from \"./installDependceny\"\nimport { readPackageJson } from \"./readPackageJson\"\nimport { readTsConfig } from \"./readTsConfig\"\nimport { writePackageJson } from \"./writePackageJson\"\n\nconst originalConfig = `// @ts-check\n\n/**\n * @type {import(\"prettier\").Options}\n */\nconst config = {\n semi: false,\n tabWidth: 4,\n arrowParens: \"avoid\",\n printWidth: 160,\n plugins: [\"prettier-plugin-organize-imports\"],\n}\n\nexport default config\n`\n\nconst ignoreConfig = `node_modules\npublic\ndist\nbuild\ngenerated\n.next\n.vscode\n.generated\n`\n\n/**\n * prettier 配置生成器参数\n */\nexport type GetPrettierConfigParams = {\n /** 是否使用 tailwind */\n tailwind: boolean\n /** 是否使用了本地 @images 类似的别名 */\n atAlias: boolean\n /** 是否是 next 项目 */\n next: boolean\n /** 是否是 react 项目 */\n react: boolean\n}\n\n/**\n * 生成 prettier 配置文件内容\n * @param params 配置参数\n */\nexport function getPrettierConfig({ tailwind, atAlias, next, react }: GetPrettierConfigParams) {\n const plugins = [\"@ianvs/prettier-plugin-sort-imports\"]\n\n if (tailwind) plugins.push(\"prettier-plugin-tailwindcss\")\n\n const prettierConfigText = `// @ts-check\n${\n atAlias\n ? `\nimport { readFileSync } from \"fs\"`\n : \"\"\n}\nimport { parse } from \"path\"\nimport { globSync } from \"glob\"\n\n/**\n * 数组去重\n * @template T - 数组的元素类型\n * @param {T[]} array - 输入的数组\n * @return {T[]} 新数组\n */\nfunction unique(array) {\n return Array.from(new Set(array))\n}\n\nconst jsExts = [\".js\", \".jsx\", \".ts\", \".tsx\", \".cjs\", \".mjs\", \".cts\", \".mts\", \".vue\"]\n\nconst assetExts = unique(\n globSync(\"**/*\", { ignore: [\"node_modules/**\"${next ? `, \".next/**\"` : \"\"}], withFileTypes: true, cwd: import.meta.dirname })\n .filter(path => path.isFile() && !jsExts.some(ext => path.name.toLowerCase().endsWith(ext)))\n .map(path => parse(path.name).ext.slice(1))\n .filter(ext => ext !== \"\"),\n)\n\nconst assetExtsRegStr = \\`\\\\\\\\.(\\${assetExts.join(\"|\")}|\\${assetExts.join(\"|\").toUpperCase()})\\`\n\nconst assetQueryRegStr = \"(\\\\\\\\?[a-zA-Z0-9]+)?\"\n${\n atAlias\n ? `\nconst namespaces = unique(\n unique(\n globSync(\"**/package.json\", { withFileTypes: true, cwd: import.meta.dirname })\n .filter(path => path.isFile())\n .map(path => path.fullpath()),\n )\n .map(path => JSON.parse(readFileSync(path, \"utf8\")))\n .map(json =>\n Object.keys({\n ...json.dependencies,\n ...json.devDependencies,\n ...json.peerDependencies,\n ...json.optionalDependencies,\n }),\n )\n .flat()\n .filter(dep => dep.startsWith(\"@\"))\n .map(dep => dep.split(\"/\")[0].slice(1)),\n)\n`\n : \"\"\n}\nconst folders = unique(\n globSync(\"**/*\", { withFileTypes: true, cwd: import.meta.dirname, ignore: [\"node_modules/**\"${next ? `, \".next/**\"` : \"\"}] })\n .filter(path => path.isDirectory())\n .map(path => path.name),\n).sort()\n\n/**\n * @type {import(\"prettier\").Options}\n */\nconst config = {\n semi: false,\n tabWidth: 4,\n arrowParens: \"avoid\",\n printWidth: 160,\n plugins: [${plugins.map(plugin => `\"${plugin}\"`).join(\", \")}],\n importOrder: [${\n react\n ? `\n \"^react(/.+)?$\",\n \"^react-dom(/.+)?$\",\n \"^react-native(/.+)?$\",`\n : \"\"\n }\n \"<BUILTIN_MODULES>\",\n ${atAlias ? `\\`^@(\\${namespaces.join(\"|\")})/\\`,` : `\"^@[^/]\",`}\n \"<THIRD_PARTY_MODULES>\",\n ...folders.map(folder => [\"\", \\`^@/?\\${folder}(.+?(?<!\\${assetExtsRegStr}\\${assetQueryRegStr}))?$\\`]).flat(),\n \"\",\n \\`^@/.+?(?<!\\${assetExtsRegStr}\\${assetQueryRegStr})$\\`,\n \\`^\\\\\\\\.{1,2}/.+?(?<!\\${assetExtsRegStr}\\${assetQueryRegStr})$\\`,\n \"\",\n \\`^@/.+?\\${assetExtsRegStr}\\${assetQueryRegStr}$\\`,\n \\`^\\\\\\\\.{1,2}/.+?\\${assetExtsRegStr}\\${assetQueryRegStr}$\\`,\n ],\n importOrderParserPlugins: [\"typescript\", \"jsx\", \"decorators-legacy\"],\n importOrderTypeScriptVersion: \"5.0.0\",\n importOrderCaseSensitive: true,\n}\n\nexport default config\n`\n return prettierConfigText\n}\n\n/**\n * 添加 prettier 相关配置\n * 包括安装依赖、创建配置文件等\n */\nexport async function addPrettier() {\n consola.start(\"开始添加 prettier 配置\")\n const packageJson = await readPackageJson()\n const tailwind =\n Object.keys(packageJson.dependencies ?? {}).includes(\"tailwindcss\") || Object.keys(packageJson.devDependencies ?? {}).includes(\"tailwindcss\")\n let atAlias = false\n try {\n const config = await readTsConfig()\n atAlias = Object.keys(config.compilerOptions?.paths ?? {}).some(path => /^@[a-zA-Z]/.test(path))\n } catch (error) {}\n const next = await hasDependency(\"next\")\n const react = await hasDependency(\"react\")\n await writeFile(\"prettier.config.mjs\", originalConfig, \"utf-8\")\n await writeFile(\".prettierrc.mjs\", getPrettierConfig({ tailwind, atAlias, next, react }), \"utf-8\")\n await writeFile(\".prettierignore\", ignoreConfig, \"utf-8\")\n const config2: AddDependenciesConfig = {\n package: [\"prettier\", \"@ianvs/prettier-plugin-sort-imports\", \"glob\", \"prettier-plugin-organize-imports\"],\n type: \"devDependencies\",\n }\n if (tailwind) (config2.package as string[]).push(\"prettier-plugin-tailwindcss\")\n await addDependency(config2)\n const packageJson2 = await readPackageJson()\n packageJson2.scripts ??= {}\n packageJson2.scripts.format = \"prettier --config prettier.config.mjs --write . && prettier --config .prettierrc.mjs --write .\"\n packageJson2.scripts.fg = \"npm run format && git add . && git commit -m \\\"✨feature: format\\\"\"\n await writePackageJson({ data: packageJson2 })\n await installDependceny()\n consola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|
24
24
|
module.exports = __toCommonJS(writeJson_exports);
|
|
25
25
|
var import_promises = require("fs/promises");
|
|
26
26
|
async function writeJson({ data, output }) {
|
|
27
|
-
await (0, import_promises.writeFile)(output, JSON.stringify(data, void 0, 4), "utf-8");
|
|
27
|
+
await (0, import_promises.writeFile)(output, JSON.stringify(data, void 0, 4) + "\n", "utf-8");
|
|
28
28
|
}
|
|
29
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
30
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/writeJson.ts"],
|
|
4
|
-
"sourcesContent": ["import { writeFile } from \"fs/promises\"\n\nexport type WriteJsonConfig = {\n data: Record<string, any> | any[]\n output: string\n}\n\nexport async function writeJson({ data, output }: WriteJsonConfig): Promise<void> {\n await writeFile(output, JSON.stringify(data, undefined, 4), \"utf-8\")\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA0B;AAO1B,eAAsB,UAAU,EAAE,MAAM,OAAO,GAAmC;AAC9E,YAAM,2BAAU,QAAQ,KAAK,UAAU,MAAM,QAAW,CAAC,
|
|
4
|
+
"sourcesContent": ["import { writeFile } from \"fs/promises\"\n\nexport type WriteJsonConfig = {\n data: Record<string, any> | any[]\n output: string\n}\n\nexport async function writeJson({ data, output }: WriteJsonConfig): Promise<void> {\n await writeFile(output, JSON.stringify(data, undefined, 4) + \"\\n\", \"utf-8\")\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA0B;AAO1B,eAAsB,UAAU,EAAE,MAAM,OAAO,GAAmC;AAC9E,YAAM,2BAAU,QAAQ,KAAK,UAAU,MAAM,QAAW,CAAC,IAAI,MAAM,OAAO;AAC9E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
package/src/utils/addAntd.ts
CHANGED
|
@@ -19,7 +19,7 @@ export async function addAntd() {
|
|
|
19
19
|
if (packageJson.dependencies.next) {
|
|
20
20
|
await addDependency({ package: "@ant-design/nextjs-registry" })
|
|
21
21
|
await writeFile(
|
|
22
|
-
join(componentDir, "
|
|
22
|
+
join(componentDir, "Registry.tsx"),
|
|
23
23
|
`"use client"
|
|
24
24
|
|
|
25
25
|
import { FC, ReactNode } from "react"
|
|
@@ -27,12 +27,11 @@ import { AntdRegistry } from "@ant-design/nextjs-registry"
|
|
|
27
27
|
import { ConfigProvider } from "antd"
|
|
28
28
|
import zhCN from "antd/locale/zh_CN"
|
|
29
29
|
|
|
30
|
-
export interface
|
|
30
|
+
export interface RegistryProps {
|
|
31
31
|
children?: ReactNode
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const
|
|
35
|
-
const { children } = props
|
|
34
|
+
const Registry: FC<RegistryProps> = ({ children }) => {
|
|
36
35
|
|
|
37
36
|
return (
|
|
38
37
|
<AntdRegistry hashPriority="high">
|
|
@@ -41,23 +40,22 @@ const AntdNextRegistry: FC<AntdNextRegistryProps> = props => {
|
|
|
41
40
|
)
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
export default
|
|
43
|
+
export default Registry
|
|
45
44
|
`,
|
|
46
45
|
)
|
|
47
46
|
} else {
|
|
48
47
|
await writeFile(
|
|
49
|
-
join(componentDir, "
|
|
48
|
+
join(componentDir, "Registry.tsx"),
|
|
50
49
|
`import { StyleProvider } from "@ant-design/cssinjs"
|
|
51
50
|
import { ConfigProvider } from "antd"
|
|
52
51
|
import zhCN from "antd/locale/zh_CN"
|
|
53
52
|
import { FC, ReactNode } from "react"
|
|
54
53
|
|
|
55
|
-
export
|
|
54
|
+
export interface RegistryProps {
|
|
56
55
|
children?: ReactNode
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
const
|
|
60
|
-
const { children } = props
|
|
58
|
+
const Registry: FC<RegistryProps> = ({ children }) => {
|
|
61
59
|
|
|
62
60
|
return (
|
|
63
61
|
<StyleProvider hashPriority="high">
|
|
@@ -66,7 +64,7 @@ const AntdRegistry: FC<AntdRegistryProps> = props => {
|
|
|
66
64
|
)
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
export default
|
|
67
|
+
export default Registry
|
|
70
68
|
`,
|
|
71
69
|
)
|
|
72
70
|
}
|
package/src/utils/addPrettier.ts
CHANGED
|
@@ -19,7 +19,7 @@ const config = {
|
|
|
19
19
|
tabWidth: 4,
|
|
20
20
|
arrowParens: "avoid",
|
|
21
21
|
printWidth: 160,
|
|
22
|
-
plugins: ["
|
|
22
|
+
plugins: ["prettier-plugin-organize-imports"],
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export default config
|
|
@@ -54,7 +54,7 @@ export type GetPrettierConfigParams = {
|
|
|
54
54
|
* @param params 配置参数
|
|
55
55
|
*/
|
|
56
56
|
export function getPrettierConfig({ tailwind, atAlias, next, react }: GetPrettierConfigParams) {
|
|
57
|
-
const plugins = ["@
|
|
57
|
+
const plugins = ["@ianvs/prettier-plugin-sort-imports"]
|
|
58
58
|
|
|
59
59
|
if (tailwind) plugins.push("prettier-plugin-tailwindcss")
|
|
60
60
|
|
|
@@ -179,7 +179,7 @@ export async function addPrettier() {
|
|
|
179
179
|
await writeFile(".prettierrc.mjs", getPrettierConfig({ tailwind, atAlias, next, react }), "utf-8")
|
|
180
180
|
await writeFile(".prettierignore", ignoreConfig, "utf-8")
|
|
181
181
|
const config2: AddDependenciesConfig = {
|
|
182
|
-
package: ["prettier", "@
|
|
182
|
+
package: ["prettier", "@ianvs/prettier-plugin-sort-imports", "glob", "prettier-plugin-organize-imports"],
|
|
183
183
|
type: "devDependencies",
|
|
184
184
|
}
|
|
185
185
|
if (tailwind) (config2.package as string[]).push("prettier-plugin-tailwindcss")
|
|
@@ -187,6 +187,7 @@ export async function addPrettier() {
|
|
|
187
187
|
const packageJson2 = await readPackageJson()
|
|
188
188
|
packageJson2.scripts ??= {}
|
|
189
189
|
packageJson2.scripts.format = "prettier --config prettier.config.mjs --write . && prettier --config .prettierrc.mjs --write ."
|
|
190
|
+
packageJson2.scripts.fg = "npm run format && git add . && git commit -m \"✨feature: format\""
|
|
190
191
|
await writePackageJson({ data: packageJson2 })
|
|
191
192
|
await installDependceny()
|
|
192
193
|
consola.success("添加 prettier 配置成功")
|
package/src/utils/writeJson.ts
CHANGED
|
@@ -6,5 +6,5 @@ export type WriteJsonConfig = {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export async function writeJson({ data, output }: WriteJsonConfig): Promise<void> {
|
|
9
|
-
await writeFile(output, JSON.stringify(data, undefined, 4), "utf-8")
|
|
9
|
+
await writeFile(output, JSON.stringify(data, undefined, 4) + "\n", "utf-8")
|
|
10
10
|
}
|