UNPKG

@spartacus/schematics

Version:
122 lines (121 loc) 4.56 kB
import { ExecutionOptions, Rule, SchematicContext, TaskId, Tree } from '@angular-devkit/schematics'; import { RunSchematicTaskOptions } from '@angular-devkit/schematics/tasks/run-schematic/options'; import { NodeDependency } from '@schematics/angular/utility/dependencies'; import { Import } from './new-module-utils'; export interface LibraryOptions extends Partial<ExecutionOptions> { project: string; lazy?: boolean; features?: string[]; options?: LibraryOptions; } export interface FeatureConfig { /** * The folder in which we will generate the feature module. E.g. app/spartacus/features/__organization__ (__NOTE__: just the `organization` part should be provided.). */ folderName: string; /** * Used as the generated feature module's file name. * Also, used as the lazy loading's feature name if the `lazyLoadingChunk` config is not provided. */ moduleName: string; /** * The feature module configuration. */ featureModule: Module; /** * The root module configuration. */ rootModule?: Module; /** * The lazy loading chunk's name. It's usually a constant imported from a library. */ lazyLoadingChunk?: Import; /** * Translation chunk configuration */ i18n?: I18NConfig; /** * Styling configuration */ styles?: StylingConfig; /** * Assets configuration */ assets?: AssetsConfig; /** * An optional custom configuration to provide to the generated module. */ customConfig?: CustomConfig | CustomConfig[]; /** * Dependency management for the library */ dependencyManagement?: DependencyManagement; } /** * Dependency management for the library */ export interface DependencyManagement { /** * The name of the feature that's currently being installed. */ featureName: string; /** * Contains the feature dependencies. * The key is a Spartacus scope, while the value is an array of its features. */ featureDependencies: Record<string, string[]>; } export interface CustomConfig { import: Import[]; content: string; } export interface Module { name: string; importPath: string; content?: string; } export interface I18NConfig { resources: string; chunks: string; importPath: string; } export interface StylingConfig { scssFileName: string; importStyle: string; } export interface AssetsConfig { input: string; output?: string; glob: string; } export declare const packageSubFeaturesMapping: Record<string, string[]>; export declare function shouldAddFeature(feature: string, features?: string[]): boolean; export declare function prepareCliPackageAndSubFeature(features: string[]): Record<string, string[]>; export declare function getPackageBySubFeature(subFeature: string): string; export declare function addLibraryFeature<T extends LibraryOptions>(options: T, config: FeatureConfig): Rule; export declare function checkAppStructure(tree: Tree, project: string): boolean; export declare function addLibraryStyles(stylingConfig: StylingConfig, options: LibraryOptions): Rule; export declare function createNodePackageInstallationTask(context: SchematicContext): TaskId; export declare function installPackageJsonDependencies(): Rule; export declare function addPackageJsonDependencies(dependencies: NodeDependency[], packageJson: any): Rule; export declare function addPackageJsonDependenciesForLibrary<OPTIONS extends LibraryOptions>(dependencies: Record<string, string>, options: OPTIONS): Rule; export declare function dependencyExists(dependency: NodeDependency, packageJson: any): boolean; export declare function configureB2bFeatures<T extends LibraryOptions>(options: T, packageJson: any): Rule; /** * A helper method that creates the default options for the given Spartacus' libraries. * * All `features` options will be set to an empty array, meaning that no features should be installed. * * @param spartacusLibraries * @param options * @returns */ export declare function createSpartacusFeatureOptionsForLibrary<OPTIONS extends LibraryOptions>(options: OPTIONS, cliFeatures: Record<string, string[]>, interactive?: boolean): { feature: string; options: LibraryOptions; }[]; export declare function addSchematicsTasks(featureOptions: { feature: string; options: LibraryOptions; }[], context: SchematicContext): void; export declare function runExternalSpartacusLibrary(taskOptions: RunSchematicTaskOptions<LibraryOptions>): Rule;