From 5d879d5989dcdda6b856865f908b46db57828097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Fra=C5=9B?= Date: Wed, 11 Dec 2024 13:50:06 +0100 Subject: [PATCH] fix: No default values when installing packages with 'no-interactive' mode (#19760) --- docs/libs/creating-lib.md | 40 +++++++++++++++++++ .../cart/schematics/add-cart/schema.json | 7 ++++ .../schematics/add-checkout/schema.json | 1 + .../schematics/add-organization/schema.json | 7 ++++ .../add-product-multi-dimensional/schema.json | 4 ++ .../schematics/add-product/schema.json | 1 + .../schematics/add-tracking/schema.json | 1 + .../user/schematics/add-user/schema.json | 1 + .../opf/schematics/add-opf/schema.json | 8 ++++ .../s4om/schematics/add-s4om/schema.json | 1 + .../schematics/src/add-spartacus/schema.json | 18 +++++++++ 11 files changed, 89 insertions(+) diff --git a/docs/libs/creating-lib.md b/docs/libs/creating-lib.md index 6a0c6ec307d..4068212fa03 100644 --- a/docs/libs/creating-lib.md +++ b/docs/libs/creating-lib.md @@ -402,6 +402,46 @@ There are couple of required changes to make sure schematics will work properly - `projects/storefrontapp/tsconfig.server.json`, - `projects/storefrontapp/tsconfig.app.prod.json` - add new feature lib schema.json elements in schematics folder - `feature-libs\\schematics\add-\schema.json` where the `lib-name` is the name of the new library + - if the library includes several features and some of them should be installed by default, add them to the `default` array (for 'no-interactive' mode) and add them `checked: true` flag (for interactive prompt). Please note the `Feature1` in the following example: + ```json + { + "$schema": "http://json-schema.org/schema", + "id": "ExampleSchematics", + "title": "Example Schematics", + "type": "object", + "properties": { + "features": { + "type": "array", + "uniqueItems": true, + "default": ["Feature1"], + "items": { + "enum": [ + "Feature1", + "Feature2", + ], + "type": "string" + }, + "x-prompt": { + "message": "Which features would you like to set up?", + "type": "list", + "items": [ + { + "value": "Feature1", + "label": "Feature 1", + "checked": true + }, + { + "value": "Feature2", + "label": "Feature 2", + }, + ] + } + }, + ... + } + } + ``` + Values from `x-prompt.items` with `checked: true` should reflect the features that will be installed by default in 'no-interactive' mode (`default` array). - add new feature chain method to 'shouldAddFeature' and function to add it - `feature-libs\\schematics\add-\index.ts` where the `lib-name` is the name of the new library - create new feature lib module in - `projects/storefrontapp/src/app/spartacus/features` - create your schematics configuration in e.g. `projects/schematics/src/shared/lib-configs/asm-schematics-config.ts` and add it to the `projects/schematics/src/shared/schematics-config-mappings.ts` file. diff --git a/feature-libs/cart/schematics/add-cart/schema.json b/feature-libs/cart/schematics/add-cart/schema.json index f409acf3c72..a47b26aa7d0 100644 --- a/feature-libs/cart/schematics/add-cart/schema.json +++ b/feature-libs/cart/schematics/add-cart/schema.json @@ -24,6 +24,13 @@ "features": { "type": "array", "uniqueItems": true, + "default": [ + "Cart", + "WishList", + "Saved-Cart", + "Quick-Order", + "Import-Export" + ], "items": { "enum": [ "Cart", diff --git a/feature-libs/checkout/schematics/add-checkout/schema.json b/feature-libs/checkout/schematics/add-checkout/schema.json index a2d5a49bc0f..2b0fc6427c1 100644 --- a/feature-libs/checkout/schematics/add-checkout/schema.json +++ b/feature-libs/checkout/schematics/add-checkout/schema.json @@ -24,6 +24,7 @@ "features": { "type": "array", "uniqueItems": true, + "default": ["Checkout"], "items": { "enum": [ "Checkout", diff --git a/feature-libs/organization/schematics/add-organization/schema.json b/feature-libs/organization/schematics/add-organization/schema.json index 298a5e636f8..3fed48166d5 100644 --- a/feature-libs/organization/schematics/add-organization/schema.json +++ b/feature-libs/organization/schematics/add-organization/schema.json @@ -24,6 +24,13 @@ "features": { "type": "array", "uniqueItems": true, + "default": [ + "Administration", + "Order-Approval", + "Account-Summary", + "Organization-User-Registration", + "Unit-Order" + ], "items": { "enum": [ "Administration", diff --git a/feature-libs/product-multi-dimensional/schematics/add-product-multi-dimensional/schema.json b/feature-libs/product-multi-dimensional/schematics/add-product-multi-dimensional/schema.json index ab3e5122425..3d0aa43c00e 100644 --- a/feature-libs/product-multi-dimensional/schematics/add-product-multi-dimensional/schema.json +++ b/feature-libs/product-multi-dimensional/schematics/add-product-multi-dimensional/schema.json @@ -24,6 +24,10 @@ "features": { "type": "array", "uniqueItems": true, + "default": [ + "Product-Multi-Dimensional-Selector", + "Product-Multi-Dimensional-List" + ], "items": { "enum": [ "Product-Multi-Dimensional-Selector", diff --git a/feature-libs/product/schematics/add-product/schema.json b/feature-libs/product/schematics/add-product/schema.json index 0642cd03033..b0f25fec565 100644 --- a/feature-libs/product/schematics/add-product/schema.json +++ b/feature-libs/product/schematics/add-product/schema.json @@ -24,6 +24,7 @@ "features": { "type": "array", "uniqueItems": true, + "default": ["Product-Variants", "Image-Zoom", "Future-Stock"], "items": { "enum": [ "Bulk-Pricing", diff --git a/feature-libs/tracking/schematics/add-tracking/schema.json b/feature-libs/tracking/schematics/add-tracking/schema.json index 7d9ba05f14a..8b47e65ca07 100644 --- a/feature-libs/tracking/schematics/add-tracking/schema.json +++ b/feature-libs/tracking/schematics/add-tracking/schema.json @@ -24,6 +24,7 @@ "features": { "type": "array", "uniqueItems": true, + "default": ["Personalization"], "items": { "enum": ["Personalization", "TMS-GTM", "TMS-AEPL"], "type": "string" diff --git a/feature-libs/user/schematics/add-user/schema.json b/feature-libs/user/schematics/add-user/schema.json index 64203941093..89e0a5185ba 100644 --- a/feature-libs/user/schematics/add-user/schema.json +++ b/feature-libs/user/schematics/add-user/schema.json @@ -25,6 +25,7 @@ "features": { "type": "array", "uniqueItems": true, + "default": ["User-Account", "User-Profile"], "items": { "enum": ["User-Account", "User-Profile"], "type": "string" diff --git a/integration-libs/opf/schematics/add-opf/schema.json b/integration-libs/opf/schematics/add-opf/schema.json index 905fc4d2830..fb00e63aa2d 100644 --- a/integration-libs/opf/schematics/add-opf/schema.json +++ b/integration-libs/opf/schematics/add-opf/schema.json @@ -24,6 +24,14 @@ "features": { "type": "array", "uniqueItems": true, + "default": [ + "OPF-Checkout", + "OPF-Base", + "OPF-Payment", + "OPF-Cta", + "OPF-Global-Functions", + "OPF-Quick-Buy" + ], "items": { "enum": [ "OPF-Checkout", diff --git a/integration-libs/s4om/schematics/add-s4om/schema.json b/integration-libs/s4om/schematics/add-s4om/schema.json index 6d80c0614cc..9bbe54dd498 100644 --- a/integration-libs/s4om/schematics/add-s4om/schema.json +++ b/integration-libs/s4om/schematics/add-s4om/schema.json @@ -24,6 +24,7 @@ "features": { "type": "array", "uniqueItems": true, + "default": ["S4HANA-Order-Management"], "x-prompt": { "message": "Which S/4 HANA Order Management features would you like to set up?", "type": "list", diff --git a/projects/schematics/src/add-spartacus/schema.json b/projects/schematics/src/add-spartacus/schema.json index 4a1f38d9714..eeda0d0ace2 100644 --- a/projects/schematics/src/add-spartacus/schema.json +++ b/projects/schematics/src/add-spartacus/schema.json @@ -14,6 +14,24 @@ "features": { "type": "array", "uniqueItems": true, + "default": [ + "ASM", + "ASM-Customer-360", + "Cart", + "WishList", + "Checkout", + "Order", + "Import-Export", + "Saved-Cart", + "Quick-Order", + "Image-Zoom", + "Product-Variants", + "SmartEdit", + "Store-Finder", + "Personalization", + "User-Account", + "User-Profile" + ], "items": { "enum": [ "ASM",