chore: turn cn comment to en for common space (#376)
This commit is contained in:
4
common/_templates/rspack-web/env/index.ts
vendored
4
common/_templates/rspack-web/env/index.ts
vendored
@@ -16,8 +16,8 @@
|
||||
|
||||
const { NODE_ENV } = process.env;
|
||||
|
||||
const IS_DEV_MODE = NODE_ENV === 'development'; // 本地环境
|
||||
const IS_PRODUCT_MODE = NODE_ENV === 'production'; // 生产环境
|
||||
const IS_DEV_MODE = NODE_ENV === 'development'; // local environment
|
||||
const IS_PRODUCT_MODE = NODE_ENV === 'production'; // production environment
|
||||
|
||||
const IS_CI = process.env.CI === 'true';
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user