mirror of https://github.com/abpframework/abp
parent
152665d420
commit
e894ee6be4
@ -0,0 +1,20 @@
|
||||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
||||
import { Tree, readProjectConfiguration } from '@nx/devkit';
|
||||
|
||||
import { changeThemeGenerator } from './generator';
|
||||
import { ChangeThemeGeneratorSchema } from './schema';
|
||||
|
||||
describe('change-theme generator', () => {
|
||||
let tree: Tree;
|
||||
const options: ChangeThemeGeneratorSchema = { name: 'test' };
|
||||
|
||||
beforeEach(() => {
|
||||
tree = createTreeWithEmptyWorkspace();
|
||||
});
|
||||
|
||||
it('should run successfully', async () => {
|
||||
await changeThemeGenerator(tree, options);
|
||||
const config = readProjectConfiguration(tree, 'test');
|
||||
expect(config).toBeDefined();
|
||||
});
|
||||
});
|
@ -0,0 +1,22 @@
|
||||
import { Tree } from '@nx/devkit';
|
||||
import { wrapAngularDevkitSchematic } from '@nx/devkit/ngcli-adapter';
|
||||
import { ChangeThemeGeneratorSchema } from './schema';
|
||||
import { ThemeOptionsEnum } from './theme-options.enum';
|
||||
|
||||
export async function changeThemeGenerator(host: Tree, schema: ChangeThemeGeneratorSchema) {
|
||||
const runAngularLibrarySchematic = wrapAngularDevkitSchematic(
|
||||
'@abp/ng.schematics',
|
||||
'change-theme',
|
||||
);
|
||||
|
||||
await runAngularLibrarySchematic(host, {
|
||||
...schema,
|
||||
});
|
||||
|
||||
return () => {
|
||||
const destTheme = Object.values(ThemeOptionsEnum).find((t, i) => i + 1 === schema.name);
|
||||
console.log(`✅️ theme changed to ${destTheme}`);
|
||||
};
|
||||
}
|
||||
|
||||
export default changeThemeGenerator;
|
@ -0,0 +1,3 @@
|
||||
export * from './theme-options.enum';
|
||||
export * from './schema';
|
||||
export * from './generator';
|
@ -0,0 +1,4 @@
|
||||
export interface ChangeThemeGeneratorSchema {
|
||||
name: number;
|
||||
targetOption: string;
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/schema",
|
||||
"$id": "SchematicsABPThemeChanger",
|
||||
"title": "ABP Theme Style Generator API Schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "The name of theme will change.",
|
||||
"type": "number",
|
||||
"$default": {
|
||||
"$source": "argv",
|
||||
"index": 0
|
||||
},
|
||||
"enum": [1, 2, 3, 4],
|
||||
"x-prompt": {
|
||||
"message": "Which theme would you like to use?",
|
||||
"type": "list",
|
||||
"items": [
|
||||
{ "value": 1, "label": "Basic" },
|
||||
{ "value": 2, "label": "Lepton" },
|
||||
{ "value": 3, "label": "LeptonXLite" },
|
||||
{ "value": 4, "label": "LeptonX" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"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",
|
||||
"$default": {
|
||||
"$source": "argv",
|
||||
"index": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["name", "targetProject"]
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
// this enum create by https://raw.githubusercontent.com/abpframework/abp/rel-7.4/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Theme.cs
|
||||
|
||||
export enum ThemeOptionsEnum {
|
||||
Basic = 1,
|
||||
Lepton = 2,
|
||||
LeptonXLite = 3,
|
||||
LeptonX = 4,
|
||||
}
|
@ -1 +1,3 @@
|
||||
export * from './generators/generate-proxy'
|
||||
export * from './generators/change-theme';
|
||||
export * from './generators/generate-proxy';
|
||||
export * from './generators/update-version';
|
||||
|
Loading…
Reference in new issue