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

Open
wants to merge 20 commits into
base: v15/dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
605e611
[WIP] Create Umbraco/Bellissima Package
leekelleher Sep 22, 2023
5ab1338
Removes existing 'UmbracoPackage'
warrenbuckley Sep 21, 2024
02fb723
Rename existing UmbracoPackageRCL to UmbracoPackage
warrenbuckley Sep 21, 2024
50d8bb1
Drop the mentions of RCL in the identifiers
warrenbuckley Sep 21, 2024
55b0bf9
CodeQL GitHub Action is complaining due to V15 wanting v9 .NET
warrenbuckley Sep 21, 2024
9a649d0
Merge remote-tracking branch 'origin/contrib' into v15/dotnet-package…
warrenbuckley Oct 3, 2024
87c968a
Rename UmbracoPackage template to UmbracoExtension
warrenbuckley Oct 3, 2024
b65b77c
Remove package lock as npm install by the OS should generate this and…
warrenbuckley Oct 3, 2024
c1c695a
Move JS clientside stuff into a folder called Client
warrenbuckley Oct 3, 2024
daa820d
Add in .VSCode recommened extensions file to get the useful Lit Exten…
warrenbuckley Oct 3, 2024
e724482
For now remove the example dashboard & prop editor
warrenbuckley Oct 3, 2024
58ccd12
Add a simple entrypoint
warrenbuckley Oct 3, 2024
b143174
Fix path for primary output after rename
warrenbuckley Oct 3, 2024
7319c86
Use link suggested from Lotte
warrenbuckley Oct 3, 2024
5cb7c28
Use backofficeEntryPoint as entryPoint is deprecated
warrenbuckley Oct 3, 2024
cc51289
Update the umbraco-package.json to opt into telemetry as per PR sugge…
warrenbuckley Oct 4, 2024
7851e4f
Improve commented code to include a link to docs
warrenbuckley Oct 4, 2024
48281a4
Improve readme from suggestions
warrenbuckley Oct 4, 2024
f03d7b8
Updates package.json to use latest Vite & TS
warrenbuckley Oct 4, 2024
76052c0
Adds the base property suggestion from Jacob & puts in a comment as t…
warrenbuckley Oct 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion templates/Umbraco.Templates.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<Content Include="UmbracoPackage\**" Exclude="bin;obj" />
<Content Include="UmbracoPackageRcl\**" Exclude="bin;obj" />
<Content Include="UmbracoProject\**" Exclude="bin;obj" />
<Content Include="UmbracoDockerCompose\**" Exclude="bin;obj"/>
<Content Include="UmbracoDockerCompose\**" Exclude="bin;obj" />
<Content Include="..\src\Umbraco.Web.UI\Views\Partials\blocklist\**">
<Link>UmbracoProject\Views\Partials\blocklist\%(RecursiveDir)%(Filename)%(Extension)</Link>
<PackagePath>UmbracoProject\Views\Partials\blocklist</PackagePath>
Expand All @@ -32,6 +32,13 @@
<Link>UmbracoProject\Views\_ViewImports.cshtml</Link>
<PackagePath>UmbracoProject\Views</PackagePath>
</Content>
<Content Include="UmbracoExtension\.template.config\dotnetcli.host.json" />
<Content Include="UmbracoExtension\.template.config\ide.host.json" />
<Content Include="UmbracoExtension\.template.config\template.json" />
</ItemGroup>
<ItemGroup>
<None Include="UmbracoExtension\Client\.vscode\extensions.ts" />
<None Include="UmbracoExtension\UmbracoExtension.csproj" />
</ItemGroup>
<!-- Update template.json files with the default UmbracoVersion value set to the current build version -->
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"order": 0,
"icon": "../../icon.png",
"description": {
"id": "UmbracoPackageRcl",
"text": "Umbraco Package RCL - An empty Umbraco package/plugin (Razor Class Library)."
"id": "UmbracoExtension",
"text": "Umbraco Extension - An empty Umbraco extension/plugin (Razor Class Library)."
},
"symbolInfo": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
"Web",
"CMS",
"Umbraco",
"Package",
"Extension",
"Plugin",
"Razor Class Library"
],
"name": "Umbraco Package RCL",
"description": "An empty Umbraco package/plugin (Razor Class Library).",
"groupIdentity": "Umbraco.Templates.UmbracoPackageRcl",
"identity": "Umbraco.Templates.UmbracoPackageRcl.CSharp",
"shortName": "umbracopackage-rcl",
"name": "Umbraco Extension",
"description": "An empty Umbraco extension (Razor Class Library).",
"groupIdentity": "Umbraco.Templates.UmbracoExtension",
"identity": "Umbraco.Templates.UmbracoExtension",
"shortName": "umbraco-extension",
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "UmbracoPackage",
"defaultName": "UmbracoPackage1",
"sourceName": "UmbracoExtension",
"defaultName": "UmbracoExtension1",
"preferNameDirectory": true,
"symbols": {
"Framework": {
Expand All @@ -39,7 +39,7 @@
},
"UmbracoVersion": {
"displayName": "Umbraco version",
"description": "The version of Umbraco.Cms to add as PackageReference.",
"description": "The version of Umbraco.Cms to add as PackageReference. By default it installs the latest non pre-release version",
"type": "parameter",
"datatype": "string",
"defaultValue": "*",
Expand All @@ -58,11 +58,17 @@
"defaultValue": "false",
"displayName": "Support pages and views",
"description": "Whether to support adding traditional Razor pages and Views to this library."
},
"kebabCasedName": {
"type": "derived",
"valueSource": "name",
"replaces": "PROJECT_NAME_KEBABCASE_FOR_NPM",
"valueTransform": "kebabCase"
}
},
"primaryOutputs": [
{
"path": "UmbracoPackage.csproj"
"path": "UmbracoExtension.csproj"
}
],
"postActions": [
Expand Down
5 changes: 5 additions & 0 deletions templates/UmbracoExtension/Client/.vscode/extensions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"runem.lit-plugin"
]
}
15 changes: 15 additions & 0 deletions templates/UmbracoExtension/Client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "PROJECT_NAME_KEBABCASE_FOR_NPM",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "tsc && vite build --watch",
"build": "tsc && vite build"
},
"devDependencies": {
"@umbraco-cms/backoffice": "^UMBRACO_VERSION_FROM_TEMPLATE",
"typescript": "^5.5.3",
"vite": "^5.4.8"
}
}
15 changes: 15 additions & 0 deletions templates/UmbracoExtension/Client/public/umbraco-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "../../umbraco-package-schema.json",
"id": "UmbracoExtension",
"name": "UmbracoExtension",
"version": "0.0.0",
"allowPackageTelemetry": true,
"extensions": [
{
"name": "UmbracoExtension EntryPoint",
"alias": "PROJECT_NAME_KEBABCASE_FOR_NPM.entrypoint",
"type": "backofficeEntryPoint",
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like both would work, but the example you have in your entry point file looks more like the bundle type than the backofficeEntryPoint type. Maybe someone on the Backoffice team has thoughts on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK Bundles is for registering manifests only, where an entrypoint you may do other logic inside it.
Such as to do the AUTH stuff with the C# OpenAPI spec or perhaps unregister/exclude extensions etc...

But lets wait for someone from the frontend core crew to chime in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nielslyngsoe @iOvergaard any thoughts ?

Copy link
Member

Choose a reason for hiding this comment

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

Hi @warrenbuckley
I would say use the EntryPoint for what the entry point is needed for, but do not use it to registere more manifests. For that its better to use the Bundle.
Main reason begin a bundle knows the extensions it registres. Meaning if later and that could be milliseconds later, it knows how to unregisters it self. Useful if someone decides to unregister it.

So my opinion would be, in order to be the most correct as you can, then make both, one bundle and one entry point so people can see how the can execute code up front and use the bundle to lead the way for more extensions. :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

You have got the facts correct, @warrenbuckley. I would recommend sticking with the backofficeEntryPoint.

Copy link
Contributor Author

@warrenbuckley warrenbuckley Oct 4, 2024

Choose a reason for hiding this comment

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

Seems overkill don't you think @nielslyngsoe & @iOvergaard to have the following and is more concepts to teach/get across unless this really is THE WAY

umbraco-package.json -> backofficeEntryPoint -> bundle

Copy link
Member

@nielslyngsoe nielslyngsoe Oct 4, 2024

Choose a reason for hiding this comment

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

Just to confirm you got everything right in your above comment. :-)

But I would still suggest this style:
umbraco-package.json -> bundle -> backofficeEntryPoint

Meaning anything additionally begin added would go to the bundle:
umbraco-package.json -> bundle -> dashboard

In this way avoiding to use the entry-point to do registration of other extension-manifest. Meaning the entry-point is purely needed for the act of running some JS code. Then if people then dont need to run code, they can ignore that specific type.

I think that is the most correct style.

This is based on an interest in registering extensions via JS. If you dont mind doing it in JSON. Then you can skip the bundle, to do additional registrations as of the umbraco-package.json.

But my point begin, I'm not a fan of show casing people that they should registere extensions by calling extensionRegistry.registerMany

"js": "/App_Plugins/UmbracoExtension/PROJECT_NAME_KEBABCASE_FOR_NPM.js"
}
]
}
15 changes: 15 additions & 0 deletions templates/UmbracoExtension/Client/src/entrypoint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { UmbEntryPointOnInit } from '@umbraco-cms/backoffice/extension-api';

// load up the manifests here
export const onInit: UmbEntryPointOnInit = (_host, _extensionRegistry) => {

console.log('Hello from my extension 🎉');

// We can use extensionRegistry to register one or manifests/extensions via code
// as opposed to a very long umbraco-package.json file
// https://docs.umbraco.com/umbraco-cms/customizing/extending-overview/extension-types/backoffice-entry-point
//_extensionRegistry.registerMany([
//]);


};
24 changes: 24 additions & 0 deletions templates/UmbracoExtension/Client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES2020",
"experimentalDecorators": true,
"useDefineForClassFields": false,
"module": "ESNext",
"lib": [ "ES2020", "DOM", "DOM.Iterable" ],
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": [ "src" ]
}
24 changes: 24 additions & 0 deletions templates/UmbracoExtension/Client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig } from "vite";

export default defineConfig({
build: {
lib: {
entry: "src/entrypoint.ts", // Entrypoint file (registers other manifests)
formats: ["es"],
fileName: "PROJECT_NAME_KEBABCASE_FOR_NPM",
},
outDir: "../wwwroot/App_Plugins/UmbracoExtension", // your web component will be saved in this location
emptyOutDir: true,
sourcemap: true,
rollupOptions: {
external: [/^@umbraco/],
},
},

// Used to allow serving SVG, images & other assets from /Client/public
// Such as <img src="/logo.jpg" />
// or
// import imageUrl from '/logo.jpg';
// <img src=${imageUrl} />
base: '/App_Plugins/UmbracoExtension',
});
38 changes: 38 additions & 0 deletions templates/UmbracoExtension/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
_ _ _
| | | | | |
__| | ___ | |_ _ __ ___| |_ _ __ _____ __
/ _` |/ _ \| __| '_ \ / _ \ __| | '_ \ / _ \ \ /\ / /
| (_| | (_) | |_| | | | __/ |_ | | | | __/\ V V /
\__,_|\___/ \__|_| |_|\___|\__| |_| |_|\___| \_/\_/ _ _
| | | | (_)
_ _ _ __ ___ | |__ _ __ __ _ ___ ___ _____ _| |_ ___ _ __ ___ _ ___ _ __
| | | | '_ ` _ \| '_ \| '__/ _` |/ __/ _ \ / _ \ \/ / __/ _ \ '_ \/ __| |/ _ \| '_ \
| |_| | | | | | | |_) | | | (_| | (_| (_) | | __/> <| || __/ | | \__ \ | (_) | | | |
\__,_|_| |_| |_|_.__/|_| \__,_|\___\___/ \___/_/\_\\__\___|_| |_|___/_|\___/|_| |_|


== Requirements ==
* Node LTS Version 20.17.0+
* Use a tool such as NVM (Node Version Manager) for your OS to help manage multiple versions of Node

== Node Version Manager tools ==
* https://github.com/coreybutler/nvm-windows
* https://github.com/nvm-sh/nvm
* https://docs.volta.sh/guide/getting-started

== Steps ==
* Open a terminal inside the `\Client` folder
* Run `npm install` to install all the dependencies
* Run `npm run build` to build the project
* The build output is copied to `wwwroot\App_Plugins\UmbracoExtension\PROJECT_NAME_KEBABCASE_FOR_NPM.js`

== File Watching ==
* Add this Razor Class Library Project as a project reference to an Umbraco Website project
* From the `\Client` folder run the command `npm run watch` this will monitor the changes to the *.ts files and rebuild the project
* With the Umbraco website project running the Razor Class Library Project will refresh the browser when the build is complete

== Suggestion ==
* Use VSCode as the editor of choice as it has good tooling support for TypeScript and it will recommend a VSCode Extension for good Lit WebComponent completions

== Other Resources ==
* Umbraco Docs - https://docs.umbraco.com/umbraco-cms/customizing/extend-and-customize-editing-experience
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AddRazorSupportForMvc Condition="'$(SupportPagesAndViews)' == 'True'">true</AddRazorSupportForMvc>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">UmbracoPackage</RootNamespace>
<StaticWebAssetBasePath>App_Plugins/UmbracoPackage</StaticWebAssetBasePath>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">UmbracoExtension</RootNamespace>
<StaticWebAssetBasePath>/</StaticWebAssetBasePath>
</PropertyGroup>

<PropertyGroup>
<PackageId>UmbracoPackage</PackageId>
<Product>UmbracoPackage</Product>
<Title>UmbracoPackage</Title>
<Description>...</Description>
<PackageTags>umbraco plugin package</PackageTags>
<PackageId>UmbracoExtension</PackageId>
<Product>UmbracoExtension</Product>
<Title>UmbracoExtension</Title>
</PropertyGroup>

<ItemGroup Condition="'$(SupportPagesAndViews)' == 'True'">
Expand All @@ -24,4 +22,13 @@
<PackageReference Include="Umbraco.Cms.Web.Website" Version="UMBRACO_VERSION_FROM_TEMPLATE" />
<PackageReference Include="Umbraco.Cms.Web.Common" Version="UMBRACO_VERSION_FROM_TEMPLATE" />
</ItemGroup>

<ItemGroup>
<!-- Dont include the client folder as part of packaging nuget build -->
<Content Remove="Client\**" />

<!-- However make the Umbraco-package.json not part of the nuget package but visible to the solution -->
<None Include="Client\public\umbraco-package.json" Pack="false" />
</ItemGroup>

</Project>
18 changes: 0 additions & 18 deletions templates/UmbracoPackage/.template.config/dotnetcli.host.json

This file was deleted.

15 changes: 0 additions & 15 deletions templates/UmbracoPackage/.template.config/ide.host.json

This file was deleted.

Loading
Loading