Fix package.json dependency migration when moving from Swagger to TypeSpec modular#3811
Fix package.json dependency migration when moving from Swagger to TypeSpec modular#3811
Conversation
…e-client when moving from Swagger to TypeSpec modular Co-authored-by: kazrael2119 <98569699+kazrael2119@users.noreply.github.com>
|
@copilot when generateMetadata is true, we will call buildPackageFile, in this case, generateMetadata is false, emitter will not run buildPackageFile. so we need additionally update them |
…-parser) to updatePackageFile when generateMetadata is false Co-authored-by: kazrael2119 <98569699+kazrael2119@users.noreply.github.com>
Fixed in 9e41525. The |
|
@copilot we need to have a check to compare origin packageJson with the one from getAzureMonorepoDependencies function in |
…es canonical set and update inconsistencies Co-authored-by: kazrael2119 <98569699+kazrael2119@users.noreply.github.com>
Done in 1b63394. |
Co-authored-by: kazrael2119 <98569699+kazrael2119@users.noreply.github.com>
When
tsp-clientruns against an existing Swagger-generated package, it preservespackage.json, causinggenerateMetadata: false. TheupdatePackageFilepath was invoked but never migrated@azure/core-client→@azure-rest/core-clientor updated the full set of modular dependencies, resulting in compile errors in the newly generated modular code.Changes
packages/typespec-ts/src/index.ts— In theelse if (hasPackageFile)branch, pass format-specific additional dependencies (e.g.fast-xml-parser: ^4.5.0when XML serialization is used) toupdatePackageFile. Standard monorepo deps like@azure/core-utilare no longer passed manually — they are now handled by the canonicalgetAzureMonorepoDependenciescomparison.packages/rlc-common/src/metadata/buildPackageFile.ts— ExtendedupdatePackageFileto handle Swagger→TypeSpec migration for Azure monorepo modular packages:getAzureMonorepoDependenciesto get the canonical expected dependency setpackage.jsondependencies against the canonical set; update any dep that is missing or at a wrong version (canonical version wins)@azure/core-client(Swagger/autorest-only dep) when found in modular packages@azure/core-client→@azure-rest/core-clientmigrationgetAzureMonorepoDependenciescomparisonpackages/rlc-common/test/integration/packageJson.spec.ts— Added tests for:@azure/core-client, adds/updates all standard deps to canonical versions)@azure-rest/core-clientto canonical version even if it already exists at a different versionfast-xml-parser) merged into the canonical setExample
Before (Swagger-generated
package.json, kept bytsp-client):{ "dependencies": { "@azure/core-client": "^1.9.3", "@azure/core-auth": "^1.0.0", "@azure/core-rest-pipeline": "^1.5.0", "tslib": "^2.6.2" } }After
updatePackageFileruns during modular TypeSpec generation:{ "dependencies": { "@azure-rest/core-client": "^2.3.1", "@azure/core-auth": "^1.9.0", "@azure/core-rest-pipeline": "^1.20.0", "@azure/core-util": "^1.12.0", "@azure/logger": "^1.2.0", "tslib": "^2.8.1" } }Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.