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 customization process part2 #1967

Merged
merged 44 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9d5881a
Update the code structure
MaryGao Aug 8, 2023
7207b5d
Remove commented out codes
MaryGao Aug 8, 2023
2b00178
Code refactor
MaryGao Aug 8, 2023
ad35497
Use the calculated generation dir
MaryGao Aug 8, 2023
a2fc5d6
Update to use the generation path for modular
MaryGao Aug 8, 2023
a20ce42
Remove comments
MaryGao Aug 8, 2023
89ad9fc
Fix lint issue
MaryGao Aug 8, 2023
94e79ec
Update the generated folder with src prefix
MaryGao Aug 9, 2023
890aab5
Add sources folder to trigger the smoke test
MaryGao Aug 9, 2023
b4080b2
Change the copy info
MaryGao Aug 9, 2023
c03c07a
Merge branch 'main' into support-customization-process-part2
MaryGao Aug 10, 2023
b8d60f6
Always generate metadata in rlc-common
MaryGao Aug 10, 2023
ad14bd0
Refactor code structure for metadata generation
MaryGao Aug 10, 2023
b58bc6a
Add comments
MaryGao Aug 10, 2023
c94ef20
Rename the generated code
MaryGao Aug 10, 2023
8ec4ab6
Override the package.json and tsconfig as modular one
MaryGao Aug 11, 2023
1011af8
update the files
MaryGao Aug 11, 2023
ecd3e24
Merge remote-tracking branch 'origin/main' into support-customization…
MaryGao Aug 11, 2023
3bce460
Resolve conflicts
MaryGao Aug 11, 2023
5b7f99a
Update the test cases
MaryGao Aug 11, 2023
47583d8
Fix
MaryGao Aug 11, 2023
6f5ae84
Refresh smoke testing
MaryGao Aug 11, 2023
0e2793c
Regenerate integration testing
MaryGao Aug 11, 2023
d2477cc
Fix the browser file missing issue
MaryGao Aug 11, 2023
d377cc0
Refresh again
MaryGao Aug 11, 2023
4fb4808
Update the files in integration testing
MaryGao Aug 11, 2023
298d5cc
Fix lint issues
MaryGao Aug 11, 2023
89e8f72
Update the generation logic in autorest
MaryGao Aug 11, 2023
cc25f84
Try to fix the folder creation error
MaryGao Aug 11, 2023
e56e944
Revert changes in autorestOptions
MaryGao Aug 13, 2023
ecea2c0
Revert changes in generateRestLevel
MaryGao Aug 13, 2023
4f7c3cb
Regenerate the code in autorest
MaryGao Aug 13, 2023
01cf8d7
update package.json files
MaryGao Aug 13, 2023
467becb
Update the test cases
MaryGao Aug 14, 2023
2b5698f
Revert changes
MaryGao Aug 14, 2023
d5f5e7b
Refactor to remove the program param
MaryGao Aug 15, 2023
e22c75e
Rename the param name to emitterOptions
MaryGao Aug 15, 2023
bdb342d
Merge remote-tracking branch 'origin/main' into support-customization…
MaryGao Aug 15, 2023
8c188b8
Resolve the conflicts
MaryGao Aug 15, 2023
85cb4f5
Fix build failure
MaryGao Aug 15, 2023
0b76416
Merge remote-tracking branch 'origin/main' into support-customization…
MaryGao Aug 15, 2023
8076f8c
Add the case for combined as any to fix openai issue
MaryGao Aug 15, 2023
088c3f9
Refresh the open ai to the latest tsp
MaryGao Aug 15, 2023
930ab6a
Enable testing files for openai
MaryGao Aug 15, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,30 @@ export async function generateRestLevelClient() {
// then transform CodeModel to RLCModel
const rlcModels = transform(model);

// buildReadmeFile
generateFileByBuilder(project, buildReadmeFile, rlcModels);
// buildLicenseFile
generateFileByBuilder(project, buildLicenseFile, rlcModels);
// buildApiExtractorConfig
generateFileByBuilder(project, buildApiExtractorConfig, rlcModels);
// buildRollupConfig
generateFileByBuilder(project, buildRollupConfig, rlcModels);
// buildEsLintConfig
generateFileByBuilder(project, buildEsLintConfig, rlcModels);
// buildKarmaConfigFile
generateFileByBuilder(project, buildKarmaConfigFile, rlcModels);
// buildEnvFile
generateFileByBuilder(project, buildEnvFile, rlcModels);
// buildEnvBrowserFile
generateFileByBuilder(project, buildEnvBrowserFile, rlcModels);
// buildRecordedClientFile
generateFileByBuilder(project, buildRecordedClientFile, rlcModels);
// buildSampleTest
generateFileByBuilder(project, buildSampleTest, rlcModels);
if (generateMetadata) {
// buildReadmeFile
generateFileByBuilder(project, buildReadmeFile, rlcModels);
// buildLicenseFile
generateFileByBuilder(project, buildLicenseFile, rlcModels);
// buildApiExtractorConfig
generateFileByBuilder(project, buildApiExtractorConfig, rlcModels);
// buildRollupConfig
generateFileByBuilder(project, buildRollupConfig, rlcModels);
// buildEsLintConfig
generateFileByBuilder(project, buildEsLintConfig, rlcModels);
}
if (generateTest) {
// buildKarmaConfigFile
generateFileByBuilder(project, buildKarmaConfigFile, rlcModels);
// buildEnvFile
generateFileByBuilder(project, buildEnvFile, rlcModels);
// buildEnvBrowserFile
generateFileByBuilder(project, buildEnvBrowserFile, rlcModels);
// buildRecordedClientFile
generateFileByBuilder(project, buildRecordedClientFile, rlcModels);
// buildSampleTest
generateFileByBuilder(project, buildSampleTest, rlcModels);
}

// buildResponseTypes
generateFileByBuilder(project, buildResponseTypes, rlcModels);
Expand Down Expand Up @@ -124,20 +128,22 @@ export async function generateRestLevelClient() {
generateSampleEnv(project);
}

// buildPackageFile
generateFileByBuilder(
project,
buildPackageFile,
rlcModels,
hasRLCSamplesGenerated
);
// buildTsConfig
generateFileByBuilder(
project,
buildTsConfig,
rlcModels,
hasRLCSamplesGenerated
);
if (generateMetadata) {
// buildPackageFile
generateFileByBuilder(
project,
buildPackageFile,
rlcModels,
hasRLCSamplesGenerated
);
// buildTsConfig
generateFileByBuilder(
project,
buildTsConfig,
rlcModels,
hasRLCSamplesGenerated
);
}

// Save the source files to the virtual filesystem
project.saveSync();
Expand Down
5 changes: 3 additions & 2 deletions packages/autorest.typescript/src/utils/autorestOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,9 @@ async function getPackageDetails(
const name = normalizeName(model.language.default.name, NameType.File);
// TODO: Look for an existing package.json and
const packageName: string = (await host.getValue("package-name")) || name;
const packageNameParts: RegExpMatchArray | null =
packageName.match(/(^@(.*)\/)?(.*)/);
const packageNameParts: RegExpMatchArray | null = packageName.match(
/(^@(.*)\/)?(.*)/
);
if (!packageNameParts) {
throw new Error("Expecting valid package name");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"build:samples": "echo skipped.",
"build:test": "echo skipped.",
"build:debug": "echo skipped.",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
"execute:samples": "echo skipped",
"extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
Copy link
Member Author

Choose a reason for hiding this comment

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

Small fix when there is no sample folder included.

Copy link
Member

Choose a reason for hiding this comment

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

is this trying to completely ignore the samples-dev folder?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the small fix, sample folder should be ignored if there is no samples generated.

Should not be ignored if there is samples generated.

"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"test/**/*.ts\" \"samples-dev/**/*.ts\"",

Copy link
Member

Choose a reason for hiding this comment

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

can you point to me where you add this check in the codegen side ?

Copy link
Member Author

Choose a reason for hiding this comment

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

"generate:client": "autorest --typescript swagger/README.md && npm run format",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"build:samples": "echo skipped.",
"build:test": "echo skipped.",
"build:debug": "echo skipped.",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
"execute:samples": "echo skipped",
"extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"generate:client": "autorest --typescript swagger/README.md && npm run format",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"build:samples": "echo skipped.",
"build:test": "echo skipped.",
"build:debug": "tsc -p . && dev-tool run bundle && api-extractor run --local",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
"execute:samples": "echo skipped",
"extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"generate:client": "autorest --typescript swagger/README.md && npm run format",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"build:samples": "echo skipped.",
"build:test": "echo skipped.",
"build:debug": "echo skipped.",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
"execute:samples": "echo skipped",
"extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"generate:client": "autorest --typescript swagger/README.md && npm run format",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"build:samples": "echo skipped.",
"build:test": "echo skipped.",
"build:debug": "echo skipped.",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
"execute:samples": "echo skipped",
"extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"generate:client": "autorest --typescript swagger/README.md && npm run format",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"build:samples": "echo skipped.",
"build:test": "echo skipped.",
"build:debug": "echo skipped.",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
"execute:samples": "echo skipped",
"extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"generate:client": "autorest --typescript swagger/README.md && npm run format",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"build:samples": "echo skipped.",
"build:test": "echo skipped.",
"build:debug": "echo skipped.",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
"execute:samples": "echo skipped",
"extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"generate:client": "autorest --typescript swagger/README.md && npm run format",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"build:samples": "echo skipped.",
"build:test": "echo skipped.",
"build:debug": "echo skipped.",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
"execute:samples": "echo skipped",
"extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"generate:client": "autorest --typescript swagger/README.md && npm run format",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"build:samples": "echo skipped.",
"build:test": "echo skipped.",
"build:debug": "echo skipped.",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
"execute:samples": "echo skipped",
"extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ",
"generate:client": "autorest --typescript swagger/README.md && npm run format",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
Expand Down
13 changes: 8 additions & 5 deletions packages/rlc-common/src/buildPollingHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface LroDetail {
clientOverload?: boolean;
overloadMap?: ResponseMap[];
importedResponses?: string[];
isModularLibrary?: boolean;
}

interface ResponseMap {
Expand All @@ -21,19 +22,20 @@ export function buildPollingHelper(model: RLCModel) {
if (!hasPollingOperations(model)) {
return;
}
let overloadDetail: LroDetail = buildOverloadDetail(model);
let lroDetail: LroDetail = buildLroHelperDetail(model);
const readmeFileContents = hbs.compile(pollingContent, { noEscape: true });
const { srcPath } = model;
return {
path: path.join(srcPath, "pollingHelper.ts"),
content: readmeFileContents(overloadDetail)
content: readmeFileContents(lroDetail)
};
}

function buildOverloadDetail(model: RLCModel): LroDetail {
function buildLroHelperDetail(model: RLCModel): LroDetail {
if (!model.helperDetails?.clientLroOverload) {
return {
clientOverload: false
clientOverload: false,
isModularLibrary: model.options?.isModularLibrary
};
}
const mapDetail = [];
Expand Down Expand Up @@ -69,6 +71,7 @@ function buildOverloadDetail(model: RLCModel): LroDetail {
return {
clientOverload: responses.size > 0 && mapDetail.length > 0,
importedResponses: Array.from(responses),
overloadMap: mapDetail
overloadMap: mapDetail,
isModularLibrary: model.options?.isModularLibrary
};
}
12 changes: 12 additions & 0 deletions packages/rlc-common/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,19 @@ export interface RLCOptions {
credentialKeyHeaderName?: string;
customHttpAuthHeaderName?: string;
customHttpAuthSharedKeyPrefix?: string;
/**
* Three possible values:
* - undefined, the default behavior which means we would generate metadata if the package.json file is absent
* - true, which means we would always generate new files or override existing files
* - false, which means we would not generate any files no matter there exists or not
*/
generateMetadata?: boolean;
/**
* Three possible values:
* - undefined, the default behavior which means we would generate test if there is no `test` folder
* - true, which means we would always generate new files or override existing files
* - false, which means we would not generate any files no matter there exists or not
*/
generateTest?: boolean;
generateSample?: boolean;
azureSdkForJs?: boolean;
Expand Down
12 changes: 6 additions & 6 deletions packages/rlc-common/src/metadata/buildApiExtractorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { Project } from "ts-morph";
import { RLCModel } from "../interfaces.js";

export function buildApiExtractorConfig(model: RLCModel) {
const generateMetadata = Boolean(model.options?.generateMetadata);
if (!generateMetadata) {
return;
}
const { generateTest, packageDetails } = model.options || {};
let { generateTest, packageDetails, isModularLibrary } = model.options || {};
// Take the undefined as true by default
generateTest = generateTest === true || generateTest === undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Can we have some automatical check if the tests exist or not ?

Copy link
Member Author

@MaryGao MaryGao Aug 15, 2023

Choose a reason for hiding this comment

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

We do this automatical check in emitter side, https://github.com/Azure/autorest.typescript/pull/1967/files#diff-3d0e467e1b9edbc8377b86fbeaac71ce5bc0ddc8260bee5e56a777360cf19398R236-R242.

In common layer we also need to check if we need to generate test relevant stuff so we have the dependency of generateTest.

const project = new Project();
const config = {
$schema:
"https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
mainEntryPointFilePath: `./types${generateTest ? "/src" : ""}/index.d.ts`,
mainEntryPointFilePath: `./types${
generateTest || isModularLibrary ? "/src" : ""
Copy link
Member

Choose a reason for hiding this comment

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

why isModularLibrary can have impact on this mainEntryPointFilePath ?

Copy link
Member Author

Choose a reason for hiding this comment

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

For modular the generated index.d.ts would be in types/src folder.

Copy link
Member

Choose a reason for hiding this comment

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

even if we don't generate tests and samples ?

Copy link
Member Author

@MaryGao MaryGao Aug 15, 2023

Choose a reason for hiding this comment

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

Yes, this is because in modular tsconfig.json we by default add below option which would always intro a src folder in dist-ems folder.

"rootDir": "."

https://www.typescriptlang.org/tsconfig#rootDir

}/index.d.ts`,
docModel: {
enabled: true
},
Expand Down
6 changes: 1 addition & 5 deletions packages/rlc-common/src/metadata/buildESLintConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ const esLintConfig = {
}
};

export function buildEsLintConfig(model: RLCModel) {
const generateMetadata = Boolean(model.options?.generateMetadata);
if (!generateMetadata) {
return;
}
export function buildEsLintConfig() {
const project = new Project();
const filePath = ".eslintrc.json";
const configFile = project.createSourceFile(
Expand Down
6 changes: 1 addition & 5 deletions packages/rlc-common/src/metadata/buildLicenseFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
`;

export function buildLicenseFile(model: RLCModel) {
const generateMetadata = Boolean(model.options?.generateMetadata);
if (!generateMetadata) {
return;
}
export function buildLicenseFile() {
return {
path: "LICENSE",
content: mitLicenseText.trim()
Expand Down
13 changes: 7 additions & 6 deletions packages/rlc-common/src/metadata/buildPackageFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ let hasLRO = false;
let clientFilePaths: string[] = [];

export function buildPackageFile(model: RLCModel, hasSamplesGenerated = false) {
const generateMetadata = Boolean(model.options?.generateMetadata);
if (!generateMetadata) {
return;
}
const project = new Project();
const filePath = "package.json";
const packageJsonContents = restLevelPackage(model, hasSamplesGenerated);
Expand Down Expand Up @@ -53,7 +49,7 @@ function restLevelPackage(model: RLCModel, hasSamplesGenerated: boolean) {
hasPaging = hasPaging || hasPagingOperations(model);
hasLRO = hasLRO || hasPollingOperations(model);

const {
let {
packageDetails,
generateTest,
generateSample,
Expand All @@ -73,6 +69,11 @@ function restLevelPackage(model: RLCModel, hasSamplesGenerated: boolean) {
return;
}

// Take the undefined as true by default
generateTest = generateTest === true || generateTest === undefined;
generateSample =
(generateSample === true || generateSample === undefined) &&
hasSamplesGenerated;
const clientPackageName = packageDetails.name;
let apiRefUrlQueryParameter: string = "";
packageDetails.version = packageDetails.version ?? "1.0.0-beta.1";
Expand Down Expand Up @@ -295,7 +296,7 @@ function restLevelPackage(model: RLCModel, hasSamplesGenerated: boolean) {
};
}

if (generateSample && hasSamplesGenerated) {
if (generateSample) {
packageInfo["//sampleConfiguration"] = {
productName: model.options.serviceInfo?.title ?? model.libraryName,
productSlugs: ["azure"],
Expand Down
5 changes: 0 additions & 5 deletions packages/rlc-common/src/metadata/buildReadmeFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ interface Metadata {
}

export function buildReadmeFile(model: RLCModel) {
const generateMetadata = Boolean(model.options?.generateMetadata);
if (!generateMetadata) {
return;
}

const metadata = createMetadata(model) ?? {};
const readmeFileContents = hbs.compile(readmeTemplate, { noEscape: true });
return {
Expand Down
Loading
Loading