Dotnet new templates: Fix placeholders and port in umbraco-extension template#20956
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes critical template placeholder inconsistencies in the umbraco-extension template that prevented it from building when the -ex (include example) parameter was used. The issues were introduced in PR #20386 and affected the auto-generated TypeScript API client files.
Key Changes:
- Corrected service class name from
WebsiteClientServicetoUmbracoExtensionServiceto align with template replacement patterns - Fixed API URL paths from
/umbraco/websiteclient/api/...to/umbraco/umbracoextension/api/...to match controller routes - Updated default port from
44394to44339to match template configuration
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| templates/UmbracoExtension/Client/src/api/types.gen.ts | Updated port from 44394 to 44339 and corrected API URL paths from websiteclient to umbracoextension |
| templates/UmbracoExtension/Client/src/api/sdk.gen.ts | Renamed service class from WebsiteClientService to UmbracoExtensionService and fixed API URL paths |
| templates/UmbracoExtension/Client/src/api/client.gen.ts | Updated baseUrl port from 44394 to 44339 |
umbraco-extension template
AndyButland
left a comment
There was a problem hiding this comment.
I've replayed your testing steps @LottePitcher and all the builds now work for me too - thanks for catching this and making the update. Also for noting workarounds for the meantime, as this will need to come in 17.1.
Do you think you might transfer some of the testing steps you've noted in this PR into a README.md file that you save in the root of the \templates folder please? Can see they might be useful in future for anyone else having to make and test changes to these templates.
|
Until this fix is released, anyone running
Now re-start your Umbraco website and the example dashboard should work! |
|
@AndyButland thanks for the suggestion - I've added a readme in the |
|
Thanks @LottePitcher - yes, I think this will be helpful for anyone working with these moving forward. |
…` template (#20956) * reset placeholders and port number in umbraco-extension template * add readme instructions on how to test templates locally
The
umbraco-extensiontemplate can be called with a-exparameter to include an example dashboard in the extension project. If this parameter is used then the extension project created by the template does not build. And this 'end-to-end' example is very useful for people to see how everything is wired up!These errors result from changes made in #20386
Replicating the issue (with 17 RC4)
In an empty folder open the command prompt and run
As using an RC you need to make some manual changes (downside of how the versioning is configured)
MyExtension/MyExtensions.csproj- lines 17-20, manually set package reference versions (* -> 17.0.0-rc4)MyExtension/Client/package.json- line 13, manually set the version number (^* -> ^17.0.0-rc4)The
npm run buildstep will fail. This is because the template has aWebsiteClientServicenot aUmbracoExtensionServiceclass specified inClient/src/api/sdk.gen.ts. The class needs to be calledUmbracoExtensionServiceso that when the template runs it will get replaced with the name (-n) parameter.You can fix this manually in your created project by changing the class name in
sdk.gen.tstoMyExtensionServiceNow
npm run buildshould work.Now test the example dashboard in the website. The buttons in the dashboard won't work because it's making calls to urls such as
umbraco/websiteclient/apiwhereas the urls should reflect the name (-n) parameter when the template ran.You can fix this manually by finding the occurrences of
websiteclient/apiand changing them to bemyextension/apiRebuild and now the dashboard buttons should work!
BTW the final test is that hey api re-generation works … With the website still running:
Which it did - hey api reported successful re-generation 😅
This PR
This PR resets the incorrect instances of
WebsiteClientandwebsiteclientback toUmbracoExtensionandumbracoextensionIt also resets the port number in the template to be consistently 44339 as that's the port number that the template is configured to replace, if the template is ran with the
--site-domainparameterTesting Done
I have tested these changes locally. Just to clarify I did this by (in the
templatesfolder of my fork):Having installed the templates from my local nuget package, I then re-ran the rest of the testing steps above:
npm run buildworksnpm run generate-clientworkSo this is PR now tested😅