chore: turn cn comment to en for common space (#376)

This commit is contained in:
tecvan
2025-07-31 12:42:03 +08:00
committed by GitHub
parent f7d73cd391
commit a1f3a9aead
40 changed files with 390 additions and 390 deletions

View File

@@ -41,7 +41,7 @@ export const updateDTS = (
) => {
const start = Date.now();
// 初始化一个 ts-morph 项目
// Initialize a ts-morph project
const project = new Project({
compilerOptions: {
incremental: true,
@@ -51,19 +51,19 @@ export const updateDTS = (
noEmitOnError: true,
},
});
// 添加想要解析的文件
// Add the file you want to parse
const file = project.addSourceFileAtPath(inputFileName);
// 获取你想要解析的变量
// Get the variable you want to parse
const envs = file.getVariableDeclarationOrThrow(envVarName);
// 获取 envs 变量的初始值
// Get the initial value of the envs variable
const initializer = envs.getInitializerIfKindOrThrow(
SyntaxKind.ObjectLiteralExpression,
);
// 获取 envs 对象的属性
// Get the properties of the envs object
const properties = initializer.getProperties();
// 创建一个新的文件,用来保存生成的类型定义
// Create a new file to hold the generated type definition
const typeDefs = project.createSourceFile(
outputFileName,
`// 基于${inputFileName}自动生成,请勿手动修改`,
@@ -81,7 +81,7 @@ export const updateDTS = (
});
};
// 遍历每一个属性
// Iterate through each attribute
properties.forEach(property => {
if (
property instanceof PropertyAssignment ||
@@ -93,9 +93,9 @@ export const updateDTS = (
const type = expression.getType();
if (type.isObject()) {
// 如果类型是一个对象类型,获取其属性
// If the type is an object type, obtain its properties
const spreadProperties = type.getProperties();
// 遍历属性
// traversal properties
for (const spreadProperty of spreadProperties) {
const declaration = spreadProperty.getDeclarations()?.[0];
if (declaration) {
@@ -113,7 +113,7 @@ export const updateDTS = (
}
}
});
// 保存文件
// Save file
typeDefs.addVariableStatements(
declarations
.sort((a, b) => (a.name > b.name ? 1 : -1))