调整了dependency构建过程中的输出信息

This commit is contained in:
Xu Chang 2025-02-06 12:48:32 +08:00
parent 357e67a48e
commit ac944def9e
2 changed files with 209 additions and 39 deletions

View File

@ -865,69 +865,150 @@ function buildDependency(rebuild) {
];
const program = ts.createProgram(templateFileList, {});
const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });
let output = true;
if (!isModule) {
const initDevFile = join(cwd, 'src', 'initialize.frontend.ts');
if ((0, fs_1.existsSync)(initDevFile) && !rebuild) {
console.log(`[${initDevFile}]文件已经存在,无需构建启动文件`);
if ((0, fs_1.existsSync)(initDevFile)) {
let tips = `[${initDevFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建';
}
console.log(tips);
}
else {
if (output) {
outputIntializeDev(cwd, dependencies, briefNames, program.getSourceFile(templateFileList[0]), printer, initDevFile);
}
output = true;
const initProdFile = join(cwd, 'src', 'initialize.server.ts');
if ((0, fs_1.existsSync)(initProdFile) && !rebuild) {
console.log(`[${initProdFile}]文件已经存在,无需构建启动文件`);
let tips = `[${initProdFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建';
}
console.log(tips);
}
else {
if (output) {
outputIntializeProd(cwd, dependencies, briefNames, program.getSourceFile(templateFileList[1]), printer, initProdFile);
}
output = true;
const initFeaturesFile = join(cwd, 'src', 'initializeFeatures.ts');
if ((0, fs_1.existsSync)(initFeaturesFile) && !rebuild) {
console.log(`[${initFeaturesFile}]文件已经存在,无需构建启动文件`);
let tips = `[${initFeaturesFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建,注意如果自定义过初始化过程,需要重新输入';
}
console.log(tips);
}
else {
if (output) {
outputIntializeFeatures(cwd, dependencies, briefNames, program.getSourceFile(templateFileList[2]), printer, initFeaturesFile);
}
}
output = true;
const runtimeCxtFile = join(cwd, 'src', 'types', 'RuntimeCxt.ts');
if ((0, fs_1.existsSync)(runtimeCxtFile) && !rebuild) {
console.log(`[${runtimeCxtFile}]文件已经存在,无需构建启动文件`);
let tips = `[${runtimeCxtFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建';
}
console.log(tips);
}
else {
if (output) {
outputRuntimeCxt(dependencies, briefNames, program.getSourceFile(templateFileList[3]), printer, runtimeCxtFile);
}
output = true;
const dependentExceptionsFile = join(cwd, 'src', 'types', 'DependentExceptions.ts');
if ((0, fs_1.existsSync)(dependentExceptionsFile) && !rebuild) {
console.log(`[${dependentExceptionsFile}]文件已经存在,无需构建启动文件`);
let tips = `[${dependentExceptionsFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建';
}
console.log(tips);
}
else {
if (output) {
outputDependentExceptions(dependencies, briefNames, program.getSourceFile(templateFileList[4]), printer, dependentExceptionsFile);
}
output = true;
const polyfillDtsFile = join(cwd, 'typings', 'polyfill.d.ts');
if ((0, fs_1.existsSync)(polyfillDtsFile) && !rebuild) {
console.log(`[${polyfillDtsFile}]文件已经存在,无需构建启动文件`);
let tips = `[${polyfillDtsFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建';
}
console.log(tips);
}
else {
if (output) {
outputPolyfillDts(dependencies, briefNames, program.getSourceFile(templateFileList[5]), printer, polyfillDtsFile);
}
output = true;
const featureIndexFile = join(cwd, 'src', 'features', 'index.ts');
if ((0, fs_1.existsSync)(featureIndexFile) && !rebuild) {
console.log(`[${featureIndexFile}]文件已经存在,无需构建启动文件`);
let tips = `[${featureIndexFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建';
}
console.log(tips);
}
else {
outputFeatureIndex(dependencies, briefNames, program.getSourceFile(templateFileList[6]), printer, featureIndexFile, isModule);
}
output = true;
let contextFile = join(cwd, 'src', 'context', 'BackendRuntimeContext.ts');
if ((0, fs_1.existsSync)(contextFile) && !rebuild) {
console.log(`[${contextFile}]文件已经存在,无需构建启动文件`);
let tips = `[${contextFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建,注意如果自定义过上下文的其它方法或属性,需要重新输入';
}
console.log(tips);
}
else {
if (output) {
outputContext(depGraph, program.getSourceFile(templateFileList[7]), printer, contextFile);
}
output = true;
contextFile = join(cwd, 'src', 'context', 'FrontendRuntimeContext.ts');
if ((0, fs_1.existsSync)(contextFile) && !rebuild) {
console.log(`[${contextFile}]文件已经存在,无需构建启动文件`);
let tips = `[${contextFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建,注意如果自定义过上下文的其它方法或属性,需要重新输入';
}
console.log(tips);
}
else {
if (output) {
outputContext(depGraph, program.getSourceFile(templateFileList[8]), printer, contextFile);
}
// 把各个依赖项目的一些初始化的文件拷贝过去

View File

@ -1683,79 +1683,168 @@ export default function buildDependency(rebuild?: boolean) {
const program = ts.createProgram(templateFileList, {});
const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });
let output = true;
if (!isModule) {
const initDevFile = join(cwd, 'src', 'initialize.frontend.ts');
if (existsSync(initDevFile) && !rebuild) {
console.log(`[${initDevFile}]文件已经存在,无需构建启动文件`);
if (existsSync(initDevFile)) {
let tips = `[${initDevFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建';
}
console.log(tips);
}
else {
if (output) {
outputIntializeDev(cwd, dependencies, briefNames, program.getSourceFile(templateFileList[0])!, printer, initDevFile);
}
output = true;
const initProdFile = join(cwd, 'src', 'initialize.server.ts');
if (existsSync(initProdFile) && !rebuild) {
console.log(`[${initProdFile}]文件已经存在,无需构建启动文件`);
let tips = `[${initProdFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建';
}
console.log(tips);
}
else {
if (output) {
outputIntializeProd(cwd, dependencies, briefNames, program.getSourceFile(templateFileList[1])!, printer, initProdFile);
}
output = true;
const initFeaturesFile = join(cwd, 'src', 'initializeFeatures.ts');
if (existsSync(initFeaturesFile) && !rebuild) {
console.log(`[${initFeaturesFile}]文件已经存在,无需构建启动文件`);
let tips = `[${initFeaturesFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建,注意如果自定义过初始化过程,需要重新输入';
}
console.log(tips);
}
else {
if (output) {
outputIntializeFeatures(cwd, dependencies, briefNames, program.getSourceFile(templateFileList[2])!, printer, initFeaturesFile);
}
}
output = true;
const runtimeCxtFile = join(cwd, 'src', 'types', 'RuntimeCxt.ts');
if (existsSync(runtimeCxtFile) && !rebuild) {
console.log(`[${runtimeCxtFile}]文件已经存在,无需构建启动文件`);
let tips = `[${runtimeCxtFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建';
}
console.log(tips);
}
else {
if (output) {
outputRuntimeCxt(dependencies, briefNames, program.getSourceFile(templateFileList[3])!, printer, runtimeCxtFile);
}
output = true;
const dependentExceptionsFile = join(cwd, 'src', 'types', 'DependentExceptions.ts');
if (existsSync(dependentExceptionsFile) && !rebuild) {
console.log(`[${dependentExceptionsFile}]文件已经存在,无需构建启动文件`);
let tips = `[${dependentExceptionsFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建';
}
console.log(tips);
}
else {
if (output) {
outputDependentExceptions(dependencies, briefNames, program.getSourceFile(templateFileList[4])!, printer, dependentExceptionsFile);
}
output = true;
const polyfillDtsFile = join(cwd, 'typings', 'polyfill.d.ts');
if (existsSync(polyfillDtsFile) && !rebuild) {
console.log(`[${polyfillDtsFile}]文件已经存在,无需构建启动文件`);
let tips = `[${polyfillDtsFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建';
}
console.log(tips);
}
else {
if (output) {
outputPolyfillDts(dependencies, briefNames, program.getSourceFile(templateFileList[5])!, printer, polyfillDtsFile);
}
output = true;
const featureIndexFile = join(cwd, 'src', 'features', 'index.ts');
if (existsSync(featureIndexFile) && !rebuild) {
console.log(`[${featureIndexFile}]文件已经存在,无需构建启动文件`);
let tips = `[${featureIndexFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建';
}
console.log(tips);
}
else {
outputFeatureIndex(dependencies, briefNames, program.getSourceFile(templateFileList[6])!, printer, featureIndexFile, isModule);
}
output = true;
let contextFile = join(cwd, 'src', 'context', 'BackendRuntimeContext.ts');
if (existsSync(contextFile) && !rebuild) {
console.log(`[${contextFile}]文件已经存在,无需构建启动文件`);
let tips = `[${contextFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建,注意如果自定义过上下文的其它方法或属性,需要重新输入';
}
console.log(tips);
}
else {
if (output) {
outputContext(depGraph, program.getSourceFile(templateFileList[7])!, printer, contextFile);
}
output = true;
contextFile = join(cwd, 'src', 'context', 'FrontendRuntimeContext.ts');
if (existsSync(contextFile) && !rebuild) {
console.log(`[${contextFile}]文件已经存在,无需构建启动文件`);
let tips = `[${contextFile}]文件已经存在`;
if (!rebuild) {
tips += ',忽略构建。';
output = false;
}
else {
tips += ',将重新构建,注意如果自定义过上下文的其它方法或属性,需要重新输入';
}
console.log(tips);
}
else {
if (output) {
outputContext(depGraph, program.getSourceFile(templateFileList[8])!, printer, contextFile);
}