Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sample.env generation in rlc-common for typespec-ts #2807

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/rlc-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export * from "./metadata/buildTsConfig.js";
export * from "./metadata/buildESLintConfig.js";
export * from "./metadata/buildLicenseFile.js";
export * from "./metadata/buildVitestConfig.js";
export * from "./metadata/buildSampleEnvFile.js";
export * from "./buildSerializeHelper.js";
export * from "./helpers/apiVersionUtil.js";
export * from "./buildLogger.js";
Expand Down
23 changes: 23 additions & 0 deletions packages/rlc-common/src/metadata/buildSampleEnvFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { RLCModel } from "../interfaces.js";

const sampleEnvText = `
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
Copy link
Member

@MaryGao MaryGao Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check if this is still recommanded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file works well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HarshaNalluru could you hep check if tthis is expected as of the security concern of spring groove

AZURE_CLIENT_ID=
AZURE_TENANT_ID=
`;

export function buildSampleEnvFile(model: RLCModel) {
MaryGao marked this conversation as resolved.
Show resolved Hide resolved
if (
model.options?.generateMetadata === true ||
model.options?.generateSample === true
kazrael2119 marked this conversation as resolved.
Show resolved Hide resolved
) {
const filePath = "sample.env";
return {
path: filePath,
content: sampleEnvText.trim()
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
6 changes: 4 additions & 2 deletions packages/typespec-ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ import {
getClientName,
hasUnexpectedHelper,
isAzurePackage,
updatePackageFile
updatePackageFile,
buildSampleEnvFile
} from "@azure-tools/rlc-common";
import { buildModels, buildModelsOptions } from "./modular/emitModels.js";
import {
Expand Down Expand Up @@ -323,7 +324,8 @@ export async function $onEmit(context: EmitContext) {
buildRollupConfig,
buildApiExtractorConfig,
buildReadmeFile,
buildLicenseFile
buildLicenseFile,
buildSampleEnvFile
];
if (option.moduleKind === "esm") {
commonBuilders.push((model) => buildVitestConfig(model, "node"));
Expand Down
Loading