Skip to content

Commit b3498ba

Browse files
Copilotv-jiaodi
andauthored
fix: keep metadata.json update when skipping metadata generation for manual convenience layer packages
Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/e5114d0a-43a9-42c5-ae32-15aee00ebba0 Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
1 parent 8dbda44 commit b3498ba

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

packages/typespec-ts/src/index.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -451,19 +451,16 @@ export async function $onEmit(context: EmitContext) {
451451
const rlcClient: RLCModel = rlcCodeModels[0];
452452
const option = dpgContext.rlcOptions!;
453453
// When generateMetadata is explicitly false and the sources are generated
454-
// into a path containing "generated" (e.g. src/generated), this package
454+
// into a path ending with "generated" (e.g. src/generated), this package
455455
// has a manual convenience layer. Skip all metadata/test file generation
456456
// to avoid unexpected modifications to files like package.json, README.md,
457-
// warp.config.yml, and snippets.spec.ts.
458-
if (option.generateMetadata === false) {
459-
const sourcesDir =
460-
dpgContext.generationPathDetail?.rlcSourcesDir ??
461-
dpgContext.generationPathDetail?.modularSourcesDir ??
462-
"";
463-
if (basename(sourcesDir) === "generated") {
464-
return;
465-
}
466-
}
457+
// warp.config.yml, and snippets.spec.ts. metadata.json is still updated.
458+
const sourcesDir =
459+
dpgContext.generationPathDetail?.rlcSourcesDir ??
460+
dpgContext.generationPathDetail?.modularSourcesDir ??
461+
"";
462+
const hasManualConvenienceLayer =
463+
option.generateMetadata === false && basename(sourcesDir) === "generated";
467464
const isAzureFlavor = isAzurePackage({ options: option });
468465
// Generate metadata
469466
const existingPackageFilePath = join(
@@ -498,7 +495,7 @@ export async function $onEmit(context: EmitContext) {
498495
}
499496
}
500497

501-
if (shouldGenerateMetadata) {
498+
if (shouldGenerateMetadata && !hasManualConvenienceLayer) {
502499
const commonBuilders = [
503500
buildRollupConfig,
504501
buildApiExtractorConfig,
@@ -598,7 +595,7 @@ export async function $onEmit(context: EmitContext) {
598595
);
599596
}
600597
}
601-
} else if (hasPackageFile) {
598+
} else if (hasPackageFile && !hasManualConvenienceLayer) {
602599
const updateBuilders = [];
603600
let modularPackageInfo = {};
604601

0 commit comments

Comments
 (0)