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

[V15] Updated dotnet template for Umbraco Packages with Bellisima #17108

Merged

Conversation

warrenbuckley
Copy link
Contributor

@warrenbuckley warrenbuckley commented Sep 21, 2024

Summary

  • Renames umbraco-package to umbraco-extension
  • Adds tooling for Vite, TypeScript and similar that the Umbraco HQ core team uses to help align with tutorials etc

This PR is to rework & reopen the work that @leekelleher done from the previous years community teams day
#14975


Install Command

dotnet new install umbraco-extension --name TestingProject

Example usage

# Create solution
dotnet new sln --name "MyProject"

# Create Umbraco Website Project
dotnet new umbraco --name "MyProject.Website" --friendly-name "Administrator" --email "admin@example.com" --password "1234567890" --development-database-type SQLite

# Add the Website project to the SLN
dotnet sln add "MyProject.Website"

# Create the extension project
dotnet new umbraco-extension --name "MyProject.Extensions" --include-example --site-domain "https://localhost:5000"

# Add the extension project to the SLN
dotnet sln add "MyProject.Extensions"

# Add the extension project as a reference
dotnet add ".\MyProject.Website\MyProject.Website.csproj" reference ".\MyProject.Extensions\MyProject.Extensions.csproj"

# Change Directory to JS clientside
cd ".\MyProject.Extensions\Client"

# NPM install (Remember you need to be on node 20.0+)
npm install

# Build TypeScript & compile into MyProject.Extensions RCL
npm run build

# Move back upto root of project
cd "..\..\"

# dotnet run (Which does a build)
dotnet run --project "MyProject.Website"

Copy link

Hi there @warrenbuckley, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@LottePitcher
Copy link
Contributor

LottePitcher commented Sep 25, 2024

If you were extending/customising the backoffice of a project in v13 and earlier, you could just add your code into a folder in App_Plugins - there was no need for front-end build steps as you deployed the source files. This package template really was a (very simple) start to people building actual packages: it wasn't needed by people looking to just customise a specific Umbraco backoffice.

In v14+ you definitely do not want to have your source files for your own extensions in App_Plugins, and so I think that the template being proposed here is arguably a template for extending the backoffice, not for building a package.

So in light of that would renaming the template from umbracopackage to umbracoextension make sense? e.g.

dotnet new umbracoextension -n MyWebsite.Extensions

It would also differentiate this template from community templates that are designed for developing packages - that come with test sites, and a head-start on publishing to nuget etc. Whereas this core template is showing good practise for extending the backoffice. That extension might turn into a package to be distributed, but equally it might just be for a specific Umbraco project.

@warrenbuckley
Copy link
Contributor Author

@LottePitcher the rename of the dotnet new template makes total sense to me.
One thing I am unclear on though from your comments is that should this template not do the TypeScript, Vite stuff and just be an RCL that has an umbraco-package.json file and use vanilla JS to avoid tooling problems or have I misunderstood?

@LottePitcher
Copy link
Contributor

@warrenbuckley I think the tooling setup (Vite etc) is still a good idea as it gets you started a good way, and it's the approach that backend devs with less front-end experience will need more help with. I don't think anyone would recommend using VanillaJS unless you were just building something incredibly simple.

@warrenbuckley warrenbuckley marked this pull request as ready for review October 3, 2024 16:39
@warrenbuckley
Copy link
Contributor Author

@umbraco/packages-team take a look at this PR please gang

@warrenbuckley
Copy link
Contributor Author

I would also appreciate any opinions from the front end gang @leekelleher @nielslyngsoe @madsrasmussen @iOvergaard as well to ensure this is a-okay or needs stuff doing.

@warrenbuckley warrenbuckley requested a review from jemayn October 4, 2024 10:47
warrenbuckley and others added 8 commits October 31, 2024 17:12
Checks if it can connect to it first and prompts user to ensure Umbraco site running or perhaps they need to change the URL in package.json for the node script
safeNamespace uses the one built in and then safeName, depends on the cleaned namespace to then use a custom transform (forms) to then use a regex replace on . and _ to ensure we have a nicer name still for namespaces, class names, URL/routes for the swagger etc...
@LottePitcher
Copy link
Contributor

Just putting a note here that I'm currently working on this template so hold off on any reviews right now please!

Copy link
Contributor

@LottePitcher LottePitcher left a comment

Choose a reason for hiding this comment

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

@warrenbuckley and I have done final tweaks to this today at the UK Festival hackathon.
@nul800sebastiaan has done a test with a .nupkg file and agrees that this is looks good to go!

@nul800sebastiaan nul800sebastiaan merged commit 2f4b198 into umbraco:v15/dev Nov 8, 2024
14 of 17 checks passed
nul800sebastiaan pushed a commit that referenced this pull request Nov 8, 2024
…7108)

* [WIP] Create Umbraco/Bellissima Package

* Removes existing 'UmbracoPackage'

This is because the RCL based one will be the only one going forward

* Rename existing UmbracoPackageRCL to UmbracoPackage

* Drop the mentions of RCL in the identifiers

* CodeQL GitHub Action is complaining due to V15 wanting v9 .NET

* Rename UmbracoPackage template to UmbracoExtension

As this will only scaffold an extension and not other bits for a package such as Nuget, Github Actions & other things needed to be done to ship out a package

* Remove package lock as npm install by the OS should generate this and can differ between Windows, Linux/OSX

* Move JS clientside stuff into a folder called Client

Will allow us to ignore the folder if or when doing a dotnet pack with a rule in CSProj

* Add in .VSCode recommened extensions file to get the useful Lit Extension for completions in VSCode

* For now remove the example dashboard & prop editor

* Add a simple entrypoint

* Fix path for primary output after rename

* Use link suggested from Lotte

* Use backofficeEntryPoint as entryPoint is deprecated

* Update the umbraco-package.json to opt into telemetry as per PR suggestion

* Improve commented code to include a link to docs

* Improve readme from suggestions

* Updates package.json to use latest Vite & TS

Copies the tsconfig from the default scaffolding of vite lit-ts CLI

* Adds the base property suggestion from Jacob & puts in a comment as to what its used for

* Work in progress from hackathon day/afternoon

* Hey-API generating a HTTP Client had changed and was a PITA to figure out what had changed

Things to do for next time:
Include these files if they include --include-samples flag

* constants.ts
* Controllers/
* Composers/
* client/src/api
* client/src/dashboards/
* client/src/entrypoints

Change file contents
* client/src/bundle.manifests.ts
* client/src/package.json (extra dependencies)

* Adds in new property/flag/switch for dotnet new template

* Warren cant spell Whether 🙈

* Update template.json to exclude the sample files if flag is not set/false

* Make SLN happy/build

* Conditional content in files for IncludeExample flag/switch

* Need to include the content otherwise it doesnt get packed by nuget

* Fix the path for the openapi-ts-config.ts file to be included/excluded

* Use the project name from the dotnet new to help name manifests

* Update namespaces so they get updated when dotnet new templatge is run with the --name

* Updated example

* Fix up VS Code recommended extension for Lit VSCode

Should be .json not a .ts

* Fix up build - as we dont use the imported UmbCurrentUserContext

* Remove the relative path to the JSON schema as unable to know path to the web project

* Typo fix as spooted by Rich

* Update templates/UmbracoExtension/.template.config/template.json

Co-authored-by: Lotte Pitcher <LottePitcher@users.noreply.github.com>

* Adds a --site-domain flag/switch to use for setting the domain prefix

Sets a default value of https://localhost:5000
We have no way of knowing what URL/domain the site is running at for the Umbraco website project

* Rename stuff so its not 'example' & only have ping if include-examples is not set

* As agreed with Lotte makes sense we always generate OpenAPI & TS client

* Update umbraco-extension description

* Generic node script to generate the TS client

Checks if it can connect to it first and prompts user to ensure Umbraco site running or perhaps they need to change the URL in package.json for the node script

* Generated API has conditional stuff in now to have just Ping or the more examples based on switch/flag

* Adds symbols safeNamespace and safeName

safeNamespace uses the one built in and then safeName, depends on the cleaned namespace to then use a custom transform (forms) to then use a regex replace on . and _ to ensure we have a nicer name still for namespaces, class names, URL/routes for the swagger etc...

* change to use Umbraco.Extension as sourcename - check \.template.config\readme.md for 'placeholder' guidance

* use '-sd' as shortname for site-domain as otherwise shows up as '-p:d'

* fix typescript build error  when not including examples

* use provided name for API description as always being added

* Missing renames of Contrioller stuff with Lotte @ hackathon

* We missed the ctor

* Titlecase the API URLs for Swagger/API Controller

* dashboard tweaks

* Missing [Server] on Whats the Time Modal/UUI-box

---------

Co-authored-by: leekelleher <leekelleher@gmail.com>
Co-authored-by: Lotte Pitcher <LottePitcher@users.noreply.github.com>
Co-authored-by: Lotte Pitcher <github@lottepitcher.co.uk>
(cherry picked from commit 2f4b198)
@nul800sebastiaan
Copy link
Member

Thanks everyone for this great work! Merged and cherry-picked for 15.0.0 in 60393b7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants