-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[V15] Updated dotnet template for Umbraco Packages with Bellisima #17108
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
Merged
nul800sebastiaan
merged 62 commits into
umbraco:v15/dev
from
warrenbuckley:v15/dotnet-package-bellisima
Nov 8, 2024
Merged
Changes from all commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
605e611
[WIP] Create Umbraco/Bellissima Package
leekelleher 5ab1338
Removes existing 'UmbracoPackage'
warrenbuckley 02fb723
Rename existing UmbracoPackageRCL to UmbracoPackage
warrenbuckley 50d8bb1
Drop the mentions of RCL in the identifiers
warrenbuckley 55b0bf9
CodeQL GitHub Action is complaining due to V15 wanting v9 .NET
warrenbuckley 9a649d0
Merge remote-tracking branch 'origin/contrib' into v15/dotnet-package…
warrenbuckley 87c968a
Rename UmbracoPackage template to UmbracoExtension
warrenbuckley b65b77c
Remove package lock as npm install by the OS should generate this and…
warrenbuckley c1c695a
Move JS clientside stuff into a folder called Client
warrenbuckley daa820d
Add in .VSCode recommened extensions file to get the useful Lit Exten…
warrenbuckley e724482
For now remove the example dashboard & prop editor
warrenbuckley 58ccd12
Add a simple entrypoint
warrenbuckley b143174
Fix path for primary output after rename
warrenbuckley 7319c86
Use link suggested from Lotte
warrenbuckley 5cb7c28
Use backofficeEntryPoint as entryPoint is deprecated
warrenbuckley cc51289
Update the umbraco-package.json to opt into telemetry as per PR sugge…
warrenbuckley 7851e4f
Improve commented code to include a link to docs
warrenbuckley 48281a4
Improve readme from suggestions
warrenbuckley f03d7b8
Updates package.json to use latest Vite & TS
warrenbuckley 76052c0
Adds the base property suggestion from Jacob & puts in a comment as t…
warrenbuckley 7758208
Work in progress from hackathon day/afternoon
warrenbuckley ab6383e
Merge branch 'v15/dev' into v15/dotnet-package-bellisima
warrenbuckley 8649dd5
Merge branch 'v15/dev' into v15/dotnet-package-bellisima
warrenbuckley 6f8c53b
Adds in new property/flag/switch for dotnet new template
warrenbuckley de4c4e2
Warren cant spell Whether 🙈
warrenbuckley 327fdeb
Update template.json to exclude the sample files if flag is not set/f…
warrenbuckley 681e9c2
Make SLN happy/build
warrenbuckley 4bde1f8
Conditional content in files for IncludeExample flag/switch
warrenbuckley d149b30
Need to include the content otherwise it doesnt get packed by nuget
warrenbuckley 7478db7
Fix the path for the openapi-ts-config.ts file to be included/excluded
warrenbuckley de7f8ed
Use the project name from the dotnet new to help name manifests
warrenbuckley a9a3466
Update namespaces so they get updated when dotnet new templatge is ru…
warrenbuckley 369c397
Updated example
warrenbuckley 3bf5618
Fix up VS Code recommended extension for Lit VSCode
warrenbuckley c96fa4e
Fix up build - as we dont use the imported UmbCurrentUserContext
warrenbuckley 3bf96cd
Remove the relative path to the JSON schema as unable to know path to…
warrenbuckley 30b86d8
Merge branch 'v15/dev' into v15/dotnet-package-bellisima
warrenbuckley f076ab3
Merge branch 'v15/dev' into v15/dotnet-package-bellisima
warrenbuckley 882a2a1
Merge branch 'v15/dev' into v15/dotnet-package-bellisima
warrenbuckley c5a0efd
Typo fix as spooted by Rich
warrenbuckley 1c550a3
Update templates/UmbracoExtension/.template.config/template.json
warrenbuckley 6bbdd9b
Adds a --site-domain flag/switch to use for setting the domain prefix
warrenbuckley 93327b8
Rename stuff so its not 'example' & only have ping if include-example…
warrenbuckley ebef2c1
As agreed with Lotte makes sense we always generate OpenAPI & TS client
warrenbuckley 271e6a6
Update umbraco-extension description
LottePitcher ddcb094
Generic node script to generate the TS client
warrenbuckley 66f925a
Merge branch 'v15/dotnet-package-bellisima' of https://github.com/war…
warrenbuckley 68ad0cd
Generated API has conditional stuff in now to have just Ping or the m…
warrenbuckley 424ff2b
Adds symbols safeNamespace and safeName
warrenbuckley 9ca3121
Merge branch 'v15/dev' into v15/dotnet-package-bellisima
warrenbuckley bf85f5a
Merge branch 'v15/dev' into v15/dotnet-package-bellisima
warrenbuckley 4d8e0fe
change to use Umbraco.Extension as sourcename - check \.template.conf…
LottePitcher 95ae476
use '-sd' as shortname for site-domain as otherwise shows up as '-p:d'
LottePitcher a12fb66
fix typescript build error when not including examples
LottePitcher c0a4d6f
use provided name for API description as always being added
LottePitcher 36ef916
Missing renames of Contrioller stuff with Lotte @ hackathon
warrenbuckley 6097f92
We missed the ctor
warrenbuckley 208d52a
Titlecase the API URLs for Swagger/API Controller
warrenbuckley 70454f1
dashboard tweaks
LottePitcher e1a4d8a
Merge branch 'v15/dev' into v15/dotnet-package-bellisima
warrenbuckley bd067b1
Missing [Server] on Whats the Time Modal/UUI-box
warrenbuckley fd6c105
Merge branch 'v15/dotnet-package-bellisima' of https://github.com/war…
warrenbuckley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/ide.host.json", | ||
| "order": 0, | ||
| "icon": "../../icon.png", | ||
| "description": { | ||
| "id": "umbraco-extension", | ||
| "text": "Umbraco Extension - A Razor Class Library project for building Umbraco extensions." | ||
| }, | ||
| "symbolInfo": [ | ||
| { | ||
| "id": "UmbracoVersion", | ||
| "isVisible": true | ||
| }, | ||
| { | ||
| "id": "SupportPagesAndViews", | ||
| "isVisible": true, | ||
| "persistenceScope": "templateGroup" | ||
| }, | ||
| { | ||
| "id": "IncludeExample", | ||
| "isVisible": true, | ||
| "description": { | ||
| "text": "Whether to include an example dashboard and supporting code" | ||
| } | ||
| }, | ||
| { | ||
| "id": "SiteDomain", | ||
| "isVisible": true, | ||
| "defaultValue": "https://localhost:5000", | ||
| "description": { | ||
| "text": "If using the --include-example then you can supply the domain prefix such as 'https://localhost:5000' to communicate with the Umbraco website for generating the TypeScript OpenAPI client" | ||
| } | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Customising the umbraco-extension template | ||
|
|
||
| ## Source Name | ||
|
|
||
| The source name is set to `Umbraco.Extension` | ||
|
|
||
| The templating engine will rename any folder or file whose name contains `Umbraco.Extension` replacing it with the provided name. | ||
|
|
||
| The templating engine will replace the text in any file as follows: | ||
|
|
||
| - `Umbraco.Extension` with the safe namespace for the provided name | ||
| - `Umbraco_Extension` with the safe default class name for the provided name | ||
| - `umbraco.extension` with the safe namespace for the provided name, in lower case | ||
| - `umbraco_extension` with the safe default class name for the provided name, in lower case | ||
|
|
||
| ## Custom Replacements | ||
|
|
||
| The following custom placeholders have been configured in `template.json`: | ||
|
|
||
| - `UmbracoExtension` will be replaced with the safe namespace but without . or _ | ||
| - `umbracoextension` will be replaced with the safe namespace but without . or _ , in lower case | ||
| - `umbraco-extension` will be replaced with the kebab case transform of the provided name | ||
| - `Umbraco Extension` will be replaced with a 'friendly' version of the provided name, e.g. MyProject > My Project. NB it will render a trailing space so you don't need to add one. | ||
|
|
||
| The first three custom placeholders have been configured to replace the text in both files and filenames. |
170 changes: 170 additions & 0 deletions
170
templates/UmbracoExtension/.template.config/template.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/template.json", | ||
| "author": "Umbraco HQ", | ||
| "classifications": [ | ||
| "Web", | ||
| "CMS", | ||
| "Umbraco", | ||
| "Extension", | ||
| "Plugin", | ||
| "Razor Class Library" | ||
| ], | ||
| "name": "Umbraco Extension", | ||
| "description": "A Razor Class Library project for building Umbraco extensions.", | ||
| "groupIdentity": "Umbraco.Templates.UmbracoExtension", | ||
| "identity": "Umbraco.Templates.UmbracoExtension", | ||
| "shortName": "umbraco-extension", | ||
| "tags": { | ||
| "language": "C#", | ||
| "type": "project" | ||
| }, | ||
| "sourceName": "Umbraco.Extension", | ||
| "defaultName": "Umbraco.Extension", | ||
| "preferNameDirectory": true, | ||
| "symbols": { | ||
| "Framework": { | ||
| "displayName": "Framework", | ||
| "description": "The target framework for the project.", | ||
| "type": "parameter", | ||
| "datatype": "choice", | ||
| "choices": [ | ||
| { | ||
| "displayName": ".NET 9.0", | ||
| "description": "Target net9.0", | ||
| "choice": "net9.0" | ||
| } | ||
| ], | ||
| "defaultValue": "net9.0", | ||
| "replaces": "net9.0" | ||
| }, | ||
| "UmbracoVersion": { | ||
| "displayName": "Umbraco version", | ||
| "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": "*", | ||
| "replaces": "UMBRACO_VERSION_FROM_TEMPLATE" | ||
| }, | ||
| "SkipRestore": { | ||
| "displayName": "Skip restore", | ||
| "description": "If specified, skips the automatic restore of the project on create.", | ||
| "type": "parameter", | ||
| "datatype": "bool", | ||
| "defaultValue": "false" | ||
| }, | ||
| "SupportPagesAndViews": { | ||
| "type": "parameter", | ||
| "datatype": "bool", | ||
| "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": "umbraco-extension", | ||
| "fileRename": "umbraco-extension", | ||
| "valueTransform": "kebabCase" | ||
| }, | ||
| "SafeName": { | ||
| "type": "derived", | ||
| "valueSource": "name", | ||
| "valueTransform": "safe_namespace" | ||
| }, | ||
| "SafeCleanName": { | ||
| "type": "derived", | ||
| "valueSource": "SafeName", | ||
| "replaces": "UmbracoExtension", | ||
| "fileRename": "UmbracoExtension", | ||
| "valueTransform": "removePunctuation" | ||
| }, | ||
| "SafeCleanNameLower": { | ||
| "type": "derived", | ||
| "valueSource": "SafeCleanName", | ||
| "replaces": "umbracoextension", | ||
| "fileRename": "umbracoextension", | ||
| "valueTransform": "lowerCase" | ||
| }, | ||
| "SafeCleanNameFriendly": { | ||
| "type": "derived", | ||
| "valueSource": "SafeCleanName", | ||
| "replaces": "Umbraco Extension", | ||
| "valueTransform": "pascalCaseToSpaces" | ||
| }, | ||
| "IncludeExample": { | ||
| "displayName": "Include Example Code", | ||
| "description": "Whether to include an example dashboard and other code to get started with.", | ||
| "type": "parameter", | ||
| "datatype": "bool", | ||
| "defaultValue": "false" | ||
| }, | ||
| "SiteDomain": { | ||
| "displayName": "Site Domain", | ||
| "description": "If using the --include-example then you can supply the domain prefix such as 'https://localhost:5000' to communicate with the Umbraco website for generating the TypeScript OpenAPI client", | ||
| "type": "parameter", | ||
| "datatype": "string", | ||
| "defaultValue": "https://localhost:5000", | ||
| "replaces": "https://localhost:44339" | ||
| } | ||
| }, | ||
| "forms": { | ||
| "removePunctuation": { | ||
| "identifier": "replace", | ||
| "pattern": "[\\._]", | ||
| "replacement": "" | ||
| }, | ||
| "pascalCaseToSpaces": { | ||
| "identifier": "replace", | ||
| "pattern": "([A-Z][a-z]+)", | ||
| "replacement": "$1 " | ||
| } | ||
| }, | ||
| "primaryOutputs": [ | ||
| { | ||
| "path": "Umbraco.Extension.csproj" | ||
| } | ||
| ], | ||
| "postActions": [ | ||
| { | ||
| "id": "restore", | ||
| "condition": "(!SkipRestore)", | ||
| "description": "Restore NuGet packages required by this project.", | ||
| "manualInstructions": [ | ||
| { | ||
| "text": "Run 'dotnet restore'" | ||
| } | ||
| ], | ||
| "actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025", | ||
| "continueOnError": true | ||
| }, | ||
| { | ||
| "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", | ||
| "args": { | ||
| "executable": "powershell", | ||
| "args": "cd Client;npm install;npm run build;", | ||
| "redirectStandardError": false, | ||
| "redirectStandardOutput": false | ||
| }, | ||
| "manualInstructions": [ | ||
| { | ||
| "text": "From the 'Client' folder run 'npm install' and then 'npm run build'" | ||
| } | ||
| ], | ||
| "continueOnError": true, | ||
| "description ": "Installs node modules" | ||
| } | ||
| ], | ||
| "sources": [ | ||
| { | ||
| "modifiers": [ | ||
| { | ||
| "condition": "(!IncludeExample)", | ||
| "exclude": [ | ||
| "[Cc]lient/src/dashboards/**", | ||
| "[Cc]lient/src/api/schemas.gen.ts" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "recommendations": [ | ||
| "runem.lit-plugin" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "name": "umbraco-extension", | ||
| "private": true, | ||
| "version": "0.0.0", | ||
| "type": "module", | ||
| "scripts": { | ||
| "watch": "tsc && vite build --watch", | ||
| "build": "tsc && vite build", | ||
| "generate-client": "node scripts/generate-openapi.js https://localhost:44339/umbraco/swagger/umbracoextension/swagger.json" | ||
| }, | ||
| "devDependencies": { | ||
| "@hey-api/client-fetch": "^0.4.2", | ||
| "@hey-api/openapi-ts": "^0.53.11", | ||
| "@umbraco-cms/backoffice": "^UMBRACO_VERSION_FROM_TEMPLATE", | ||
| "chalk": "^5.3.0", | ||
| "cross-env": "^7.0.3", | ||
| "node-fetch": "^3.3.2", | ||
| "typescript": "^5.6.3", | ||
| "vite": "^5.4.9" | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
templates/UmbracoExtension/Client/public/umbraco-package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "id": "Umbraco.Extension", | ||
| "name": "Umbraco.Extension", | ||
| "version": "0.0.0", | ||
| "allowPackageTelemetry": true, | ||
| "extensions": [ | ||
| { | ||
| "name": "Umbraco ExtensionBundle", | ||
| "alias": "Umbraco.Extension.Bundle", | ||
| "type": "bundle", | ||
| "js": "/App_Plugins/UmbracoExtension/umbraco-extension.js" | ||
| } | ||
| ] | ||
| } |
48 changes: 48 additions & 0 deletions
48
templates/UmbracoExtension/Client/scripts/generate-openapi.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import fetch from 'node-fetch'; | ||
| import chalk from 'chalk'; | ||
| import { createClient } from '@hey-api/openapi-ts'; | ||
|
|
||
| // Start notifying user we are generating the TypeScript client | ||
| console.log(chalk.green("Generating OpenAPI client...")); | ||
|
|
||
| const swaggerUrl = process.argv[2]; | ||
| if (swaggerUrl === undefined) { | ||
| console.error(chalk.red(`ERROR: Missing URL to OpenAPI spec`)); | ||
| console.error(`Please provide the URL to the OpenAPI spec as the first argument found in ${chalk.yellow('package.json')}`); | ||
| console.error(`Example: node generate-openapi.js ${chalk.yellow('https://localhost:44331/umbraco/swagger/REPLACE_ME/swagger.json')}`); | ||
| process.exit(); | ||
| } | ||
|
|
||
| // Needed to ignore self-signed certificates from running Umbraco on https on localhost | ||
| process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; | ||
|
|
||
| // Start checking to see if we can connect to the OpenAPI spec | ||
| console.log("Ensure your Umbraco instance is running"); | ||
| console.log(`Fetching OpenAPI definition from ${chalk.yellow(swaggerUrl)}`); | ||
|
|
||
| fetch(swaggerUrl).then(response => { | ||
| if (!response.ok) { | ||
| console.error(chalk.red(`ERROR: OpenAPI spec returned with a non OK (200) response: ${response.status} ${response.statusText}`)); | ||
| console.error(`The URL to your Umbraco instance may be wrong or the instance is not running`); | ||
| console.error(`Please verify or change the URL in the ${chalk.yellow('package.json')} for the script ${chalk.yellow('generate-openapi')}`); | ||
| return; | ||
| } | ||
|
|
||
| console.log(`OpenAPI spec fetched successfully`); | ||
| console.log(`Calling ${chalk.yellow('hey-api')} to generate TypeScript client`); | ||
|
|
||
| createClient({ | ||
| client: '@hey-api/client-fetch', | ||
| input: swaggerUrl, | ||
| output: 'src/api', | ||
| services: { | ||
| asClass: true, | ||
| } | ||
| }); | ||
|
|
||
| }) | ||
| .catch(error => { | ||
| console.error(`ERROR: Failed to connect to the OpenAPI spec: ${chalk.red(error.message)}`); | ||
| console.error(`The URL to your Umbraco instance may be wrong or the instance is not running`); | ||
| console.error(`Please verify or change the URL in the ${chalk.yellow('package.json')} for the script ${chalk.yellow('generate-openapi')}`); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // This file is auto-generated by @hey-api/openapi-ts | ||
| //#if(IncludeExample) | ||
| export * from './schemas.gen'; | ||
| //#endif | ||
| export * from './services.gen'; | ||
| export * from './types.gen'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.