Skip to content

Commit

Permalink
support-sdk-folder-in-emiiter (#1613)
Browse files Browse the repository at this point in the history
* support-sdk-folder-in-emiiter

* fix src path
  • Loading branch information
qiaozha authored Oct 18, 2022
1 parent de52519 commit 786c402
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/cadl-typescript/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export const RLCOptionsSchema: JSONSchemaType<RLCOptions> = {
},
nullable: true
},
azureArm: { type: "boolean", nullable: true }
azureArm: { type: "boolean", nullable: true },
"sdk-folder": { type: "string", nullable: true }
},
required: []
};
Expand Down
2 changes: 1 addition & 1 deletion packages/cadl-typescript/src/transform/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import { transformSchemas } from "./transformSchemas.js";
import { transformRLCOptions } from "./transfromRLCOptions.js";

export async function transformRLCModel(program: Program, emitterOptions: RLCOptions): Promise<RLCModel> {
const srcPath = join(program.compilerOptions.outputPath ?? "", "src");
const options: RLCOptions = transformRLCOptions(program, emitterOptions);
const srcPath = join(program.compilerOptions.outputPath ?? "", "src");
const libraryName = normalizeName(
options?.title ?? getServiceTitle(program),
NameType.Class
Expand Down
4 changes: 4 additions & 0 deletions packages/cadl-typescript/src/transform/transfromRLCOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Program
} from "@cadl-lang/compiler";
import { getAuthentication } from "@cadl-lang/rest/http";
import { isAbsolute } from "path";

export function transformRLCOptions(program: Program, options: RLCOptions): RLCOptions {
const config = options;
Expand All @@ -18,6 +19,9 @@ export function transformRLCOptions(program: Program, options: RLCOptions): RLCO
config.packageDetails.scopeName = nameParts[0]?.replace("@", "");
}
}
if (options["sdk-folder"] && isAbsolute(options["sdk-folder"])) {
program.compilerOptions.outputPath = options["sdk-folder"];
}
const securityInfo = processAuth(program);
config.addCredentials =
!securityInfo && config.addCredentials === false
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 @@ -89,6 +89,7 @@ export interface RLCOptions {
productDocLink?: string;
serviceInfo?: ServiceInfo;
azureArm?: boolean;
"sdk-folder"?: string;
}

export interface ServiceInfo {
Expand Down

0 comments on commit 786c402

Please sign in to comment.