Skip to content

Commit

Permalink
Fix tsp rlc logger.ts generation (#2904)
Browse files Browse the repository at this point in the history
* fix tsp rlc logger.ts generation

* update

* resolve comment

* fix issue

---------

Co-authored-by: Qiaoqiao Zhang <[email protected]>
  • Loading branch information
kazrael2119 and qiaozha authored Nov 13, 2024
1 parent ff9e2dd commit f8429c7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
16 changes: 9 additions & 7 deletions packages/rlc-common/src/buildLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ export function buildLogger(model: RLCModel) {
return undefined;
}
const project = new Project();
const { srcPath } = model;
const { srcPath, rlcSourceDir } = model;
const { packageDetails } = model.options;
const filePath = path.join(
srcPath.substring(
0,
srcPath.includes("generated") && !srcPath.includes("src")
? srcPath.lastIndexOf("generated") + 10
: srcPath.lastIndexOf("src") + 4
),
model.options.sourceFrom == "Swagger"
? srcPath.substring(
0,
srcPath.includes("generated") && !srcPath.includes("src")
? srcPath.lastIndexOf("generated") + 10
: srcPath.lastIndexOf("src") + 4
)
: rlcSourceDir!,
`logger.ts`
);
const loggerFile = project.createSourceFile("logger.ts", undefined, {
Expand Down
1 change: 1 addition & 0 deletions packages/rlc-common/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface RLCModel {
urlInfo?: UrlInfo;
telemetryOptions?: TelemetryInfo;
sampleGroups?: RLCSampleGroup[];
rlcSourceDir?: string;
}

export interface ImportInfo {
Expand Down
4 changes: 3 additions & 1 deletion packages/typespec-ts/src/transform/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export async function transformRLCModel(
): Promise<RLCModel> {
const program = dpgContext.program;
const options: RLCOptions = dpgContext.rlcOptions!;
const rlcSourceDir = dpgContext.generationPathDetail?.rlcSourcesDir;
const srcPath = path.join(
dpgContext.generationPathDetail?.rlcSourcesDir ?? "",
options.batch && options.batch.length > 1
Expand Down Expand Up @@ -100,7 +101,8 @@ export async function transformRLCModel(
importInfo: {
internalImports: importSet,
runtimeImports: buildRuntimeImports(options.flavor)
}
},
rlcSourceDir
};
model.sampleGroups = transformSampleGroups(
model,
Expand Down

0 comments on commit f8429c7

Please sign in to comment.