From c56ceced243ef2fcbd9497ae07154b4bdb7924d8 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Wed, 26 Oct 2022 09:54:15 +0300 Subject: [PATCH 1/6] Fix #12213 --- .../packages/schematics/src/collection.json | 6 + .../src/commands/change-theme/index.ts | 86 +++++++ .../src/commands/change-theme/model.ts | 4 + .../src/commands/change-theme/schema.json | 30 +++ .../src/commands/change-theme/style-map.ts | 226 ++++++++++++++++++ .../change-theme/theme-options.enum.ts | 6 + .../src/commands/create-lib/schema.json | 2 +- npm/ng-packs/scripts/build-schematics.ts | 1 + 8 files changed, 360 insertions(+), 1 deletion(-) create mode 100644 npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts create mode 100644 npm/ng-packs/packages/schematics/src/commands/change-theme/model.ts create mode 100644 npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json create mode 100644 npm/ng-packs/packages/schematics/src/commands/change-theme/style-map.ts create mode 100644 npm/ng-packs/packages/schematics/src/commands/change-theme/theme-options.enum.ts diff --git a/npm/ng-packs/packages/schematics/src/collection.json b/npm/ng-packs/packages/schematics/src/collection.json index 8441a786b08..16f148d78a1 100644 --- a/npm/ng-packs/packages/schematics/src/collection.json +++ b/npm/ng-packs/packages/schematics/src/collection.json @@ -29,6 +29,12 @@ "description": "ABP Create Library Schematics", "factory": "./commands/create-lib", "schema": "./commands/create-lib/schema.json" + }, + "change-theme": { + "description": "ABP Change Styles of Theme Schematics", + "factory": "./commands/change-theme", + "schema": "./commands/change-theme/schema.json" + } } } diff --git a/npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts b/npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts new file mode 100644 index 00000000000..375c8ae97d1 --- /dev/null +++ b/npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts @@ -0,0 +1,86 @@ +import { Rule, SchematicContext, SchematicsException, Tree } from '@angular-devkit/schematics'; +import { isLibrary, updateWorkspace, WorkspaceDefinition } from '../../utils'; +import { allStyles, StyleDefinition, styleMap } from './style-map'; +import { ProjectDefinition } from '@angular-devkit/core/src/workspace'; +import { JsonArray, JsonValue } from '@angular-devkit/core'; +import { ChangeThemeOptions } from './model'; + +export default function (_options: ChangeThemeOptions): Rule { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + return async (_: Tree, __: SchematicContext) => { + const targetThemeName = _options.name; + const selectedProject = _options.targetProject; + if (!targetThemeName) { + throw new SchematicsException('The theme name does not selected'); + } + + return updateWorkspace(storedWorkspace => { + updateProjectStyle(selectedProject, storedWorkspace, targetThemeName); + }); + }; +} + +function updateProjectStyle( + projectName: string, + workspace: WorkspaceDefinition, + targetThemeName: string, +) { + const project = workspace.projects.get(projectName); + + if (!project) { + throw new SchematicsException('The target project does not selected'); + } + + const isProjectLibrary = isLibrary(project); + if (isProjectLibrary) { + throw new SchematicsException('The library project does not supported'); + } + + const targetOption = getProjectTargetOptions(project, 'build'); + const styles = targetOption.styles as (string | { input: string })[]; + + const sanitizedStyles = removeThemeBasedStyles(styles); + + const newStyles = getStylesOfSelectedTheme(targetThemeName); + targetOption.styles = [...newStyles, ...sanitizedStyles] as JsonArray; +} + +export function getProjectTargetOptions( + project: ProjectDefinition, + buildTarget: string, +): Record { + const options = project.targets?.get(buildTarget)?.options; + + if (!options) { + throw new SchematicsException( + `Cannot determine project target configuration for: ${buildTarget}.`, + ); + } + + return options; +} + +export function removeThemeBasedStyles(styles: (string | object)[]) { + return styles.filter(s => !allStyles.some(x => styleCompareFn(s, x))); +} + +export const styleCompareFn = (item1: string | object, item2: string | object) => { + const type1 = typeof item1; + const type2 = typeof item1; + + if (type1 !== type2) { + return false; + } + + if (type1 === 'string') { + return item1 === item2; + } + const o1 = item1 as { bundleName?: string }; + const o2 = item2 as { bundleName?: string }; + + return o1.bundleName && o2.bundleName && o1.bundleName == o2.bundleName; +}; + +export function getStylesOfSelectedTheme(theme: string): StyleDefinition[] { + return styleMap[theme]; +} diff --git a/npm/ng-packs/packages/schematics/src/commands/change-theme/model.ts b/npm/ng-packs/packages/schematics/src/commands/change-theme/model.ts new file mode 100644 index 00000000000..9bcda1d9b9c --- /dev/null +++ b/npm/ng-packs/packages/schematics/src/commands/change-theme/model.ts @@ -0,0 +1,4 @@ +export type ChangeThemeOptions = { + name: string; + targetProject: string; +}; diff --git a/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json b/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json new file mode 100644 index 00000000000..bbf90809125 --- /dev/null +++ b/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/schema", + "$id": "SchematicsABPModuleTemplateCreator", + "title": "ABP Theme Style Generator API Schema", + "type": "object", + "properties": { + "name": { + "description": "The file extension or preprocessor to use for style files.", + "type": "string", + "default": "basic", + "enum": ["basic", "lepton", "leptonx-lite", "leptonx"], + "x-prompt": { + "message": "Which theme would you like to use?", + "type": "list", + "items": [ + { "value": "basic", "label": "basic" }, + { "value": "lepton", "label": "lepton" }, + { "value": "leptonx-lite", "label": "leptonx-lite" }, + { "value": "leptonx", "label": "leptonx" } + ] + } + }, + "targetProject": { + "description": "The name of the project will change the style", + "type": "string", + "x-prompt": "Please enter the project name" + } + }, + "required": ["name"] +} diff --git a/npm/ng-packs/packages/schematics/src/commands/change-theme/style-map.ts b/npm/ng-packs/packages/schematics/src/commands/change-theme/style-map.ts new file mode 100644 index 00000000000..06074dab78e --- /dev/null +++ b/npm/ng-packs/packages/schematics/src/commands/change-theme/style-map.ts @@ -0,0 +1,226 @@ +import { ThemeOptionsEnum } from './theme-options.enum'; + +export type StyleDefinition = + | { + input: string; + inject: boolean; + bundleName: string; + } + | string; + +export type StyleMapType = { + [key: string]: StyleDefinition[]; +}; + +export const styleMap: StyleMapType = { + [ThemeOptionsEnum.basic]: [ + { + input: 'node_modules/bootstrap/dist/css/bootstrap.rtl.min.css', + inject: false, + bundleName: 'bootstrap-rtl.min', + }, + { + input: 'node_modules/bootstrap/dist/css/bootstrap.min.css', + inject: true, + bundleName: 'bootstrap-ltr.min', + }, + ], + [ThemeOptionsEnum['leptonx-lite']]: [ + { + input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/bootstrap-dim.css', + inject: false, + bundleName: 'bootstrap-dim', + }, + { + input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/ng-bundle.css', + inject: false, + bundleName: 'ng-bundle', + }, + { + input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/side-menu/layout-bundle.css', + inject: false, + bundleName: 'layout-bundle', + }, + { + input: 'node_modules/@abp/ng.theme.lepton-x/assets/css/abp-bundle.css', + inject: false, + bundleName: 'abp-bundle', + }, + { + input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/bootstrap-dim.rtl.css', + inject: false, + bundleName: 'bootstrap-dim.rtl', + }, + { + input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/ng-bundle.rtl.css', + inject: false, + bundleName: 'ng-bundle.rtl', + }, + { + input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/side-menu/layout-bundle.rtl.css', + inject: false, + bundleName: 'layout-bundle.rtl', + }, + { + input: 'node_modules/@abp/ng.theme.lepton-x/assets/css/abp-bundle.rtl.css', + inject: false, + bundleName: 'abp-bundle.rtl', + }, + ], + [ThemeOptionsEnum.lepton]: [ + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton1.min.css', + inject: false, + bundleName: 'lepton1', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton2.min.css', + inject: false, + bundleName: 'lepton2', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton3.min.css', + inject: false, + bundleName: 'lepton3', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton4.min.css', + inject: false, + bundleName: 'lepton4', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton5.min.css', + inject: false, + bundleName: 'lepton5', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton6.min.css', + inject: false, + bundleName: 'lepton6', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton1.rtl.min.css', + inject: false, + bundleName: 'lepton1.rtl', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton2.rtl.min.css', + inject: false, + bundleName: 'lepton2.rtl', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton3.rtl.min.css', + inject: false, + bundleName: 'lepton3.rtl', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton4.rtl.min.css', + inject: false, + bundleName: 'lepton4.rtl', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton5.rtl.min.css', + inject: false, + bundleName: 'lepton5.rtl', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton6.rtl.min.css', + inject: false, + bundleName: 'lepton6.rtl', + }, + ], + [ThemeOptionsEnum.leptonx]: [ + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/dark.css', + inject: false, + bundleName: 'dark', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/light.css', + inject: false, + bundleName: 'light', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/dim.css', + inject: false, + bundleName: 'dim', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-dim.css', + inject: false, + bundleName: 'bootstrap-dim', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-dark.css', + inject: false, + bundleName: 'bootstrap-dark', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-light.css', + inject: false, + bundleName: 'bootstrap-light', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/ng-bundle.css', + inject: false, + bundleName: 'ng-bundle', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/side-menu/layout-bundle.css', + inject: false, + bundleName: 'layout-bundle', + }, + { + input: 'node_modules/@volosoft/abp.ng.theme.lepton-x/assets/css/abp-bundle.css', + inject: false, + bundleName: 'abp-bundle', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/dark.rtl.css', + inject: false, + bundleName: 'dark.rtl', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/light.rtl.css', + inject: false, + bundleName: 'light.rtl', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/dim.rtl.css', + inject: false, + bundleName: 'dim.rtl', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-dim.rtl.css', + inject: false, + bundleName: 'bootstrap-dim.rtl', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-dark.rtl.css', + inject: false, + bundleName: 'bootstrap-dark.rtl', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-light.rtl.css', + inject: false, + bundleName: 'bootstrap-light.rtl', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/ng-bundle.rtl.css', + inject: false, + bundleName: 'ng-bundle.rtl', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/side-menu/layout-bundle.rtl.css', + inject: false, + bundleName: 'layout-bundle.rtl', + }, + { + input: 'node_modules/@volosoft/abp.ng.theme.lepton-x/assets/css/abp-bundle.rtl.css', + inject: false, + bundleName: 'abp-bundle.rtl', + }, + ], +}; + +export const allStyles = Object.values(styleMap).reduce((acc, val) => [...acc, ...val], []); diff --git a/npm/ng-packs/packages/schematics/src/commands/change-theme/theme-options.enum.ts b/npm/ng-packs/packages/schematics/src/commands/change-theme/theme-options.enum.ts new file mode 100644 index 00000000000..2904d99b8a3 --- /dev/null +++ b/npm/ng-packs/packages/schematics/src/commands/change-theme/theme-options.enum.ts @@ -0,0 +1,6 @@ +export const ThemeOptionsEnum = Object.freeze({ + basic: 'basic', + lepton: 'lepton', + 'leptonx-lite': 'leptonx-lite', + leptonx: 'leptonx', +}); diff --git a/npm/ng-packs/packages/schematics/src/commands/create-lib/schema.json b/npm/ng-packs/packages/schematics/src/commands/create-lib/schema.json index 64d64c1d80b..38d7fb13a6b 100644 --- a/npm/ng-packs/packages/schematics/src/commands/create-lib/schema.json +++ b/npm/ng-packs/packages/schematics/src/commands/create-lib/schema.json @@ -15,7 +15,7 @@ }, "isSecondaryEntrypoint": { "description": "Is secondary entrypoint", - "type": "boolean", + "type": "boole∂an", "$default": false, "x-prompt": "Is secondary entrypoint?" }, diff --git a/npm/ng-packs/scripts/build-schematics.ts b/npm/ng-packs/scripts/build-schematics.ts index 8884ca95712..6690b272b3d 100644 --- a/npm/ng-packs/scripts/build-schematics.ts +++ b/npm/ng-packs/scripts/build-schematics.ts @@ -21,6 +21,7 @@ class FileCopy { const PACKAGE_TO_BUILD = 'schematics'; const FILES_TO_COPY_AFTER_BUILD: (FileCopy | string)[] = [ { src: 'src/commands/create-lib/schema.json', dest: 'commands/create-lib/schema.json' }, + { src: 'src/commands/change-theme/schema.json', dest: 'commands/change-theme/schema.json' }, { src: 'src/commands/create-lib/files-package', dest: 'commands/create-lib/files-package' }, { src: 'src/commands/create-lib/files-secondary-entrypoint', From 527912444e20db0fcd3c94d5a9b8b9e7c8358755 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Wed, 26 Oct 2022 10:09:56 +0300 Subject: [PATCH 2/6] fix typo --- .../packages/schematics/src/commands/create-lib/schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/schematics/src/commands/create-lib/schema.json b/npm/ng-packs/packages/schematics/src/commands/create-lib/schema.json index 38d7fb13a6b..64d64c1d80b 100644 --- a/npm/ng-packs/packages/schematics/src/commands/create-lib/schema.json +++ b/npm/ng-packs/packages/schematics/src/commands/create-lib/schema.json @@ -15,7 +15,7 @@ }, "isSecondaryEntrypoint": { "description": "Is secondary entrypoint", - "type": "boole∂an", + "type": "boolean", "$default": false, "x-prompt": "Is secondary entrypoint?" }, From 696f8a2a042f6adebe01739ebddddb3e96027853 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Wed, 26 Oct 2022 12:05:02 +0300 Subject: [PATCH 3/6] Change input theme selection value to enum(number) --- .../src/commands/change-theme/index.ts | 15 +- .../src/commands/change-theme/model.ts | 4 +- .../src/commands/change-theme/schema.json | 14 +- .../src/commands/change-theme/style-map.ts | 425 +++++++++--------- .../change-theme/theme-options.enum.ts | 14 +- 5 files changed, 236 insertions(+), 236 deletions(-) diff --git a/npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts b/npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts index 375c8ae97d1..22f32be3531 100644 --- a/npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts +++ b/npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts @@ -1,12 +1,12 @@ import { Rule, SchematicContext, SchematicsException, Tree } from '@angular-devkit/schematics'; import { isLibrary, updateWorkspace, WorkspaceDefinition } from '../../utils'; -import { allStyles, StyleDefinition, styleMap } from './style-map'; +import { allStyles, styleMap } from './style-map'; import { ProjectDefinition } from '@angular-devkit/core/src/workspace'; import { JsonArray, JsonValue } from '@angular-devkit/core'; import { ChangeThemeOptions } from './model'; +import { ThemeOptionsEnum } from './theme-options.enum'; export default function (_options: ChangeThemeOptions): Rule { - // eslint-disable-next-line @typescript-eslint/no-unused-vars return async (_: Tree, __: SchematicContext) => { const targetThemeName = _options.name; const selectedProject = _options.targetProject; @@ -23,7 +23,7 @@ export default function (_options: ChangeThemeOptions): Rule { function updateProjectStyle( projectName: string, workspace: WorkspaceDefinition, - targetThemeName: string, + targetThemeName: ThemeOptionsEnum, ) { const project = workspace.projects.get(projectName); @@ -41,7 +41,10 @@ function updateProjectStyle( const sanitizedStyles = removeThemeBasedStyles(styles); - const newStyles = getStylesOfSelectedTheme(targetThemeName); + const newStyles = styleMap.get(targetThemeName); + if (!newStyles) { + throw new SchematicsException('The theme does not found'); + } targetOption.styles = [...newStyles, ...sanitizedStyles] as JsonArray; } @@ -80,7 +83,3 @@ export const styleCompareFn = (item1: string | object, item2: string | object) = return o1.bundleName && o2.bundleName && o1.bundleName == o2.bundleName; }; - -export function getStylesOfSelectedTheme(theme: string): StyleDefinition[] { - return styleMap[theme]; -} diff --git a/npm/ng-packs/packages/schematics/src/commands/change-theme/model.ts b/npm/ng-packs/packages/schematics/src/commands/change-theme/model.ts index 9bcda1d9b9c..ca553c50c71 100644 --- a/npm/ng-packs/packages/schematics/src/commands/change-theme/model.ts +++ b/npm/ng-packs/packages/schematics/src/commands/change-theme/model.ts @@ -1,4 +1,6 @@ +import { ThemeOptionsEnum } from './theme-options.enum'; + export type ChangeThemeOptions = { - name: string; + name: ThemeOptionsEnum; targetProject: string; }; diff --git a/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json b/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json index bbf90809125..1544620881f 100644 --- a/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json +++ b/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json @@ -6,17 +6,17 @@ "properties": { "name": { "description": "The file extension or preprocessor to use for style files.", - "type": "string", - "default": "basic", - "enum": ["basic", "lepton", "leptonx-lite", "leptonx"], + "type": "integer", + "default": 1, + "enum": [1, 2, 3, 4], "x-prompt": { "message": "Which theme would you like to use?", "type": "list", "items": [ - { "value": "basic", "label": "basic" }, - { "value": "lepton", "label": "lepton" }, - { "value": "leptonx-lite", "label": "leptonx-lite" }, - { "value": "leptonx", "label": "leptonx" } + { "value": 1, "label": "Basic" }, + { "value": 2, "label": "Lepton" }, + { "value": 3, "label": "LeptonXLite" }, + { "value": 4, "label": "LeptonX" } ] } }, diff --git a/npm/ng-packs/packages/schematics/src/commands/change-theme/style-map.ts b/npm/ng-packs/packages/schematics/src/commands/change-theme/style-map.ts index 06074dab78e..aa5f17b21a7 100644 --- a/npm/ng-packs/packages/schematics/src/commands/change-theme/style-map.ts +++ b/npm/ng-packs/packages/schematics/src/commands/change-theme/style-map.ts @@ -8,219 +8,216 @@ export type StyleDefinition = } | string; -export type StyleMapType = { - [key: string]: StyleDefinition[]; -}; +export const styleMap = new Map(); -export const styleMap: StyleMapType = { - [ThemeOptionsEnum.basic]: [ - { - input: 'node_modules/bootstrap/dist/css/bootstrap.rtl.min.css', - inject: false, - bundleName: 'bootstrap-rtl.min', - }, - { - input: 'node_modules/bootstrap/dist/css/bootstrap.min.css', - inject: true, - bundleName: 'bootstrap-ltr.min', - }, - ], - [ThemeOptionsEnum['leptonx-lite']]: [ - { - input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/bootstrap-dim.css', - inject: false, - bundleName: 'bootstrap-dim', - }, - { - input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/ng-bundle.css', - inject: false, - bundleName: 'ng-bundle', - }, - { - input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/side-menu/layout-bundle.css', - inject: false, - bundleName: 'layout-bundle', - }, - { - input: 'node_modules/@abp/ng.theme.lepton-x/assets/css/abp-bundle.css', - inject: false, - bundleName: 'abp-bundle', - }, - { - input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/bootstrap-dim.rtl.css', - inject: false, - bundleName: 'bootstrap-dim.rtl', - }, - { - input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/ng-bundle.rtl.css', - inject: false, - bundleName: 'ng-bundle.rtl', - }, - { - input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/side-menu/layout-bundle.rtl.css', - inject: false, - bundleName: 'layout-bundle.rtl', - }, - { - input: 'node_modules/@abp/ng.theme.lepton-x/assets/css/abp-bundle.rtl.css', - inject: false, - bundleName: 'abp-bundle.rtl', - }, - ], - [ThemeOptionsEnum.lepton]: [ - { - input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton1.min.css', - inject: false, - bundleName: 'lepton1', - }, - { - input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton2.min.css', - inject: false, - bundleName: 'lepton2', - }, - { - input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton3.min.css', - inject: false, - bundleName: 'lepton3', - }, - { - input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton4.min.css', - inject: false, - bundleName: 'lepton4', - }, - { - input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton5.min.css', - inject: false, - bundleName: 'lepton5', - }, - { - input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton6.min.css', - inject: false, - bundleName: 'lepton6', - }, - { - input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton1.rtl.min.css', - inject: false, - bundleName: 'lepton1.rtl', - }, - { - input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton2.rtl.min.css', - inject: false, - bundleName: 'lepton2.rtl', - }, - { - input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton3.rtl.min.css', - inject: false, - bundleName: 'lepton3.rtl', - }, - { - input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton4.rtl.min.css', - inject: false, - bundleName: 'lepton4.rtl', - }, - { - input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton5.rtl.min.css', - inject: false, - bundleName: 'lepton5.rtl', - }, - { - input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton6.rtl.min.css', - inject: false, - bundleName: 'lepton6.rtl', - }, - ], - [ThemeOptionsEnum.leptonx]: [ - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/dark.css', - inject: false, - bundleName: 'dark', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/light.css', - inject: false, - bundleName: 'light', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/dim.css', - inject: false, - bundleName: 'dim', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-dim.css', - inject: false, - bundleName: 'bootstrap-dim', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-dark.css', - inject: false, - bundleName: 'bootstrap-dark', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-light.css', - inject: false, - bundleName: 'bootstrap-light', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/ng-bundle.css', - inject: false, - bundleName: 'ng-bundle', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/side-menu/layout-bundle.css', - inject: false, - bundleName: 'layout-bundle', - }, - { - input: 'node_modules/@volosoft/abp.ng.theme.lepton-x/assets/css/abp-bundle.css', - inject: false, - bundleName: 'abp-bundle', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/dark.rtl.css', - inject: false, - bundleName: 'dark.rtl', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/light.rtl.css', - inject: false, - bundleName: 'light.rtl', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/dim.rtl.css', - inject: false, - bundleName: 'dim.rtl', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-dim.rtl.css', - inject: false, - bundleName: 'bootstrap-dim.rtl', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-dark.rtl.css', - inject: false, - bundleName: 'bootstrap-dark.rtl', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-light.rtl.css', - inject: false, - bundleName: 'bootstrap-light.rtl', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/ng-bundle.rtl.css', - inject: false, - bundleName: 'ng-bundle.rtl', - }, - { - input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/side-menu/layout-bundle.rtl.css', - inject: false, - bundleName: 'layout-bundle.rtl', - }, - { - input: 'node_modules/@volosoft/abp.ng.theme.lepton-x/assets/css/abp-bundle.rtl.css', - inject: false, - bundleName: 'abp-bundle.rtl', - }, - ], -}; +styleMap.set(ThemeOptionsEnum.Basic, [ + { + input: 'node_modules/bootstrap/dist/css/bootstrap.rtl.min.css', + inject: false, + bundleName: 'bootstrap-rtl.min', + }, + { + input: 'node_modules/bootstrap/dist/css/bootstrap.min.css', + inject: true, + bundleName: 'bootstrap-ltr.min', + }, +]); -export const allStyles = Object.values(styleMap).reduce((acc, val) => [...acc, ...val], []); +styleMap.set(ThemeOptionsEnum.Lepton, [ + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton1.min.css', + inject: false, + bundleName: 'lepton1', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton2.min.css', + inject: false, + bundleName: 'lepton2', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton3.min.css', + inject: false, + bundleName: 'lepton3', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton4.min.css', + inject: false, + bundleName: 'lepton4', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton5.min.css', + inject: false, + bundleName: 'lepton5', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton6.min.css', + inject: false, + bundleName: 'lepton6', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton1.rtl.min.css', + inject: false, + bundleName: 'lepton1.rtl', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton2.rtl.min.css', + inject: false, + bundleName: 'lepton2.rtl', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton3.rtl.min.css', + inject: false, + bundleName: 'lepton3.rtl', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton4.rtl.min.css', + inject: false, + bundleName: 'lepton4.rtl', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton5.rtl.min.css', + inject: false, + bundleName: 'lepton5.rtl', + }, + { + input: 'node_modules/@volo/abp.ng.theme.lepton/dist/global/styles/lepton6.rtl.min.css', + inject: false, + bundleName: 'lepton6.rtl', + }, +]); +styleMap.set(ThemeOptionsEnum.LeptonX, [ + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/dark.css', + inject: false, + bundleName: 'dark', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/light.css', + inject: false, + bundleName: 'light', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/dim.css', + inject: false, + bundleName: 'dim', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-dim.css', + inject: false, + bundleName: 'bootstrap-dim', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-dark.css', + inject: false, + bundleName: 'bootstrap-dark', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-light.css', + inject: false, + bundleName: 'bootstrap-light', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/ng-bundle.css', + inject: false, + bundleName: 'ng-bundle', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/side-menu/layout-bundle.css', + inject: false, + bundleName: 'layout-bundle', + }, + { + input: 'node_modules/@volosoft/abp.ng.theme.lepton-x/assets/css/abp-bundle.css', + inject: false, + bundleName: 'abp-bundle', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/dark.rtl.css', + inject: false, + bundleName: 'dark.rtl', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/light.rtl.css', + inject: false, + bundleName: 'light.rtl', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/dim.rtl.css', + inject: false, + bundleName: 'dim.rtl', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-dim.rtl.css', + inject: false, + bundleName: 'bootstrap-dim.rtl', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-dark.rtl.css', + inject: false, + bundleName: 'bootstrap-dark.rtl', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/bootstrap-light.rtl.css', + inject: false, + bundleName: 'bootstrap-light.rtl', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/ng-bundle.rtl.css', + inject: false, + bundleName: 'ng-bundle.rtl', + }, + { + input: 'node_modules/@volosoft/ngx-lepton-x/assets/css/side-menu/layout-bundle.rtl.css', + inject: false, + bundleName: 'layout-bundle.rtl', + }, + { + input: 'node_modules/@volosoft/abp.ng.theme.lepton-x/assets/css/abp-bundle.rtl.css', + inject: false, + bundleName: 'abp-bundle.rtl', + }, +]); +styleMap.set(ThemeOptionsEnum.LeptonXLite, [ + { + input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/bootstrap-dim.css', + inject: false, + bundleName: 'bootstrap-dim', + }, + { + input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/ng-bundle.css', + inject: false, + bundleName: 'ng-bundle', + }, + { + input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/side-menu/layout-bundle.css', + inject: false, + bundleName: 'layout-bundle', + }, + { + input: 'node_modules/@abp/ng.theme.lepton-x/assets/css/abp-bundle.css', + inject: false, + bundleName: 'abp-bundle', + }, + { + input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/bootstrap-dim.rtl.css', + inject: false, + bundleName: 'bootstrap-dim.rtl', + }, + { + input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/ng-bundle.rtl.css', + inject: false, + bundleName: 'ng-bundle.rtl', + }, + { + input: 'node_modules/@volo/ngx-lepton-x.lite/assets/css/side-menu/layout-bundle.rtl.css', + inject: false, + bundleName: 'layout-bundle.rtl', + }, + { + input: 'node_modules/@abp/ng.theme.lepton-x/assets/css/abp-bundle.rtl.css', + inject: false, + bundleName: 'abp-bundle.rtl', + }, +]); +// the code written by Github co-pilot. thank go-pilot. You are the best sidekick. +export const allStyles = Array.from(styleMap.values()).reduce((acc, val) => [...acc, ...val], []); diff --git a/npm/ng-packs/packages/schematics/src/commands/change-theme/theme-options.enum.ts b/npm/ng-packs/packages/schematics/src/commands/change-theme/theme-options.enum.ts index 2904d99b8a3..6e2f863674b 100644 --- a/npm/ng-packs/packages/schematics/src/commands/change-theme/theme-options.enum.ts +++ b/npm/ng-packs/packages/schematics/src/commands/change-theme/theme-options.enum.ts @@ -1,6 +1,8 @@ -export const ThemeOptionsEnum = Object.freeze({ - basic: 'basic', - lepton: 'lepton', - 'leptonx-lite': 'leptonx-lite', - leptonx: 'leptonx', -}); +// this enum create by https://raw.githubusercontent.com/abpframework/abp/rel-6.0/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Theme.cs + +export enum ThemeOptionsEnum { + Basic = 1, + Lepton = 2, + LeptonXLite = 3, + LeptonX = 4, +} From 178f9392ce37ac769bfa3cc8a950b9e82f9f8752 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Wed, 26 Oct 2022 12:17:28 +0300 Subject: [PATCH 4/6] Change package-name --- .../packages/schematics/src/commands/change-theme/schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json b/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json index 1544620881f..327e0526350 100644 --- a/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json +++ b/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/schema", - "$id": "SchematicsABPModuleTemplateCreator", + "$id": "SchematicsABPThemeChanger", "title": "ABP Theme Style Generator API Schema", "type": "object", "properties": { From 8a36e890cb399d2382eecee737433229b8763c18 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Wed, 26 Oct 2022 13:17:29 +0300 Subject: [PATCH 5/6] Change description --- .../packages/schematics/src/commands/change-theme/schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json b/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json index 327e0526350..f38cc0037b6 100644 --- a/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json +++ b/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json @@ -5,7 +5,7 @@ "type": "object", "properties": { "name": { - "description": "The file extension or preprocessor to use for style files.", + "description": "The name of theme will change.", "type": "integer", "default": 1, "enum": [1, 2, 3, 4], @@ -21,7 +21,7 @@ } }, "targetProject": { - "description": "The name of the project will change the style", + "description": "The name of the project will change the style.The project type must be 'application'", "type": "string", "x-prompt": "Please enter the project name" } From ae166d426266354800e3c587fb08dc8e0e047ee6 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Wed, 26 Oct 2022 17:27:05 +0300 Subject: [PATCH 6/6] minor fix --- .../src/commands/change-theme/schema.json | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json b/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json index f38cc0037b6..6eb6bc71a5c 100644 --- a/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json +++ b/npm/ng-packs/packages/schematics/src/commands/change-theme/schema.json @@ -6,8 +6,11 @@ "properties": { "name": { "description": "The name of theme will change.", - "type": "integer", - "default": 1, + "type": "number", + "$default": { + "$source": "argv", + "index": 0 + }, "enum": [1, 2, 3, 4], "x-prompt": { "message": "Which theme would you like to use?", @@ -23,7 +26,11 @@ "targetProject": { "description": "The name of the project will change the style.The project type must be 'application'", "type": "string", - "x-prompt": "Please enter the project name" + "x-prompt": "Please enter the project name", + "$default": { + "$source": "argv", + "index": 1 + } } }, "required": ["name"]