Closed Alancere closed 1 month ago
Hi @Alancere did you add the new directory to your tsp-location.yaml?
Hi @Alancere did you add the new directory to your tsp-location.yaml?
my tsp-location.yaml
directory: specification/azurestackhci/AzureStackHCI.StackHCIVM.Management
commit: 9a88bba565544d5907aaee7b10170fd770572904
repo: Azure/azure-rest-api-specs
additionalDirectories:
- specification/azurestackhci/Operations.Management
@Alancere this issue is due to the emitter-package.json not having all of the dependencies you need to be able to run the code. Here is an example of a properly configured emitter-package.json: https://github.com/Azure/azure-sdk-for-python/blob/main/eng/emitter-package.json
What does your emitter-package.json look like? You will probably need to specify additional libraries in it. tsp-client uses emitter-package.json to install necessary libraries to compile a typespec project.
@Alancere this issue is due to the emitter-package.json not having all of the dependencies you need to be able to run the code. Here is an example of a properly configured emitter-package.json: https://github.com/Azure/azure-sdk-for-python/blob/main/eng/emitter-package.json
What does your emitter-package.json look like? You will probably need to specify additional libraries in it. tsp-client uses emitter-package.json to install necessary libraries to compile a typespec project.
my emitter-package.json, please check if I am missing any dependencies.
{
"main": "dist/src/index.js",
"dependencies": {
"@azure-tools/typespec-go": "0.1.0"
},
"devDependencies": {
"@azure-tools/typespec-autorest": "0.44.0",
"@azure-tools/typespec-azure-core": "0.44.0",
"@azure-tools/typespec-azure-resource-manager": "0.44.0",
"@azure-tools/typespec-azure-rulesets": "0.44.0",
"@azure-tools/typespec-client-generator-core": "0.44.0",
"@typespec/compiler": "0.58.0",
"@typespec/http": "0.58.0",
"@typespec/openapi": "0.58.0",
"@typespec/rest": "0.58.0",
"@typespec/versioning": "0.58.0"
}
}
Should typespec project directory
and additionalDirectories
share a package.json
instead of only existing in directory?
Looks like you have the packages that are being reported as missing. Are you sure you're running the code from a branch that has the emitter-package.json configured? Also are your emitter-package.json and emitter-package-lock.json in sync? The tool will give preference to the lock file for installing packages. I'll try to generate this package and report back here with what I find.
Yes, sharing the package.json is expected. We expect azure specs in the specs repository to use the package.json that's at the root of the repo, so both your directory and additional directories should work with the same package.json if the tsp compiled with all related directories.
You shouldnt have a custom package.json btw in the specs repo, you should only rely on the one at the root. https://github.com/Azure/azure-rest-api-specs/blob/main/package.json
You shouldnt have a custom package.json btw in the specs repo, you should only rely on the one at the root. https://github.com/Azure/azure-rest-api-specs/blob/main/package.json
Sorry for my wording. What I meant was that the TempTypeSpecFiles
directory should share a package.json.
Fix it like this: https://github.com/Alancere/azure-sdk-tools/commit/c77de0dd28b1576a5fc19c097cd912354b4274c1?
So I looked into the tsp spec to see why we're having issues with the additional directory scenario in this case...First of all, I noticed that the tspconfig.yaml of this spec needs to be improved to follow this example: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml and you should configure the typespec-go options you need to get it to run. However, I dont think that's the cause of the import error, it's odd that it wont work for this spec meanwhile it does for others. I think it might have to do with how other tsp projects are configured and the imports arent done through the additional directory. Going to ping some tsp folks to better understand the error, but your fix might be ok to implement to resolve this issue. I'll have to test it out a bit more though
So this issue is happening here because of the configuration of the Operations.Management/ tsp and how it directly imports the libraries instead of relying on the imports of the main package under AzureStackHCI.StackHCIVM.Management/ which seems to be the main difference between this tsp project and others that have specified additional directories. I'm moving the package.json + package-lock.json up to the TempTypeSpecFiles/ directory as you suggested. I have a PR open to address this issue, once it's merged I'll release an updated version of tsp-client that you'll be able to use for this project.
By the way, doesnt seem like you need the main.tsp in your Operations.Management/ directory since it isnt defining a standalone service.
Add additionalDirectories to the current tspconfig.yaml
error:![image](https://github.com/Azure/azure-sdk-tools/assets/46921893/96a301b7-374c-4c00-8971-844de8eb8109)
TempTypeSpecFiles:![image](https://github.com/Azure/azure-sdk-tools/assets/46921893/e7d2a76a-7914-4b97-b176-396739acd67f)