Skip to content

Commit

Permalink
Support sample.env generation in rlc-common for typespec-ts (#2845)
Browse files Browse the repository at this point in the history
* Support sample.env generation in rlc-common for typespec-ts

* lint fix

* update

* update

* update

* update

* Update index.ts

* Update buildSampleEnvFile.ts

* update

---------

Co-authored-by: Mary Gao <yanmeigao1210@gmail.com>
  • Loading branch information
kazrael2119 and MaryGao authored Oct 10, 2024
1 parent 6a05181 commit 8033f60
Show file tree
Hide file tree
Showing 39 changed files with 62 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# App registration secret for AAD authentication
AZURE_CLIENT_SECRET=
AZURE_CLIENT_ID=
AZURE_TENANT_ID=
# Feel free to add your own environment variables.
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
21 changes: 21 additions & 0 deletions packages/rlc-common/src/metadata/buildSampleEnvFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { RLCModel } from "../interfaces.js";

const sampleEnvText = `
# Feel free to add your own environment variables.
`;

export function buildSampleEnvFile(model: RLCModel) {
if (
(model.options?.generateMetadata === true ||
model.options?.generateSample === true) &&
model.options?.flavor === "azure"
) {
const filePath = "sample.env";
return {
path: filePath,
content: sampleEnvText.trim()
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Feel free to add your own environment variables.
6 changes: 4 additions & 2 deletions packages/typespec-ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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 @@ -338,7 +339,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

0 comments on commit 8033f60

Please # to comment.