Skip to content

优化 vue 模板#5

Open
xiaou66 wants to merge 6 commits into
ZToolsCenter:mainfrom
xiaou66:main
Open

优化 vue 模板#5
xiaou66 wants to merge 6 commits into
ZToolsCenter:mainfrom
xiaou66:main

Conversation

@xiaou66

@xiaou66 xiaou66 commented Jun 15, 2026

Copy link
Copy Markdown

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the plugin project discovery logic into a centralized discoverPluginProject module, supporting multiple layouts (src-ztools, root, and public), and updates the publish and pull workflows to use it. It also updates the Vue-Vite template's TypeScript configuration to use project references. The review feedback suggests adding defensive checks when parsing plugin.json to prevent runtime errors if the JSON is not an object, and removing trailing commas in tsconfig.node.json to ensure compatibility with strict JSON parsers.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/plugin-project.ts
Comment on lines +76 to +83
function readPluginConfig(pluginJsonPath: string): PluginConfig {
try {
const content = fs.readFileSync(pluginJsonPath, 'utf-8')
return JSON.parse(content) as PluginConfig
} catch (error) {
throw new Error(`读取 plugin.json 失败: ${(error as Error).message}`)
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

在解析 plugin.json 时,JSON.parse 可能会返回 null、数组或非对象类型(例如,如果文件内容是 null 或非对象字符串)。建议在返回前添加防御性检查,确保解析后的内容是一个非空的键值对对象,以避免后续属性访问时抛出运行时错误。

function readPluginConfig(pluginJsonPath: string): PluginConfig {
  try {
    const content = fs.readFileSync(pluginJsonPath, 'utf-8')
    const config = JSON.parse(content)
    if (!config || typeof config !== 'object' || Array.isArray(config)) {
      throw new Error('内容不是一个有效的 JSON 对象')
    }
    return config as PluginConfig
  } catch (error) {
    throw new Error(`读取 plugin.json 失败: ${(error as Error).message}`)
  }
}

Comment on lines +1 to +20
{
"extends": "@tsconfig/node22/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*",
"eslint.config.*",
"uno.config.ts",
],
"compilerOptions": {
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",

"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node", "@ztools-center/ztools-api-types"],
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

tsconfig.node.json 中存在尾随逗号(如第 10 行和第 18 行)。虽然 TypeScript 编译器和部分现代工具支持带有尾随逗号的 JSON(JSONC),但标准的 JSON 规范并不允许尾随逗号。为了确保与所有第三方工具、IDE 以及严格的 JSON 解析器的最大兼容性,建议移除这些尾随逗号。

Suggested change
{
"extends": "@tsconfig/node22/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*",
"eslint.config.*",
"uno.config.ts",
],
"compilerOptions": {
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node", "@ztools-center/ztools-api-types"],
}
}
{
"extends": "@tsconfig/node22/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*",
"eslint.config.*",
"uno.config.ts"
],
"compilerOptions": {
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node", "@ztools-center/ztools-api-types"]
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant