@o3r/schematics
Version:
Schematics module of the Otter framework
108 lines • 4.21 kB
TypeScript
import { Rule, type SchematicContext, type TaskId, Tree } from '@angular-devkit/schematics';
import { NodeDependencyType } from '@schematics/angular/utility/dependencies';
import type { SupportedPackageManagers } from '../../utility';
/**
* Options to be passed to the ng add task
*/
export interface NgAddSchematicOptions {
/** Name of the project */
projectName?: string | null;
/** Skip the run of the linter*/
skipLinter?: boolean;
/** Skip the install process */
skipInstall?: boolean;
[x: string]: any;
}
export interface DependencyInManifest {
/**
* Range of the dependency
* @default 'latest'
*/
range?: string;
/**
* Types of the dependency
* @default [NodeDependencyType.Default]
*/
types?: NodeDependencyType[];
}
export interface DependencyToAdd {
/** Enforce this dependency to be applied to Workspace's manifest only */
toWorkspaceOnly?: boolean;
/** List of dependency to register in manifest */
inManifest: DependencyInManifest[];
/** ng-add schematic option dedicated to the package */
ngAddOptions?: NgAddSchematicOptions;
/** Determine if the dependency require to be installed */
requireInstall?: boolean;
/**
* Enforce the usage of tilde instead of caret in a dependency range
* If not specified, the context option value will be used
*/
enforceTildeRange?: boolean;
}
export interface SetupDependenciesOptions {
/** Map of dependencies to install */
dependencies: Record<string, DependencyToAdd>;
/**
* Pattern of list of the dependency for which the ng-add run process is required
*/
ngAddToRun?: (RegExp | string)[];
/**
* Will skip install in the end of the package.json update.
* if `undefined`, the installation will be process only if a ngAdd run is required.
* If `true` the install will not run in any case
* @default undefined
*/
skipInstall?: boolean;
/** Project Name */
projectName?: string;
/** default ng-add schematic option */
ngAddOptions?: NgAddSchematicOptions;
/** Enforce install package manager */
packageManager?: SupportedPackageManagers;
/** Task will run after the given task ID (if specified) */
runAfterTasks?: TaskId[];
/** Callback to run after the task ID is calculated */
scheduleTaskCallback?: (taskIds?: TaskId[]) => void;
/** Working directory for the installation process only */
workingDirectory?: string;
/**
* Enforce the usage of tilde instead of caret in a dependency range
* @default true
*/
enforceTildeRange?: boolean;
}
/** Result of the Setup Dependencies task scheduling process */
export interface SetupDependenciesResult {
/** List of the task ID resulting of the install process */
taskIds: TaskId[];
}
/**
* Determine if the context has information regarding the setup dependencies process
* @param context Schematic context
*/
export declare const hasSetupInformation: (context: SchematicContext) => context is SchematicContext & {
setupDependencies: SetupDependenciesResult;
};
/**
* Retrieve the package install configuration
* This is a workaround to ng-add to add the dependency to the sub-package
* @param packageJsonPath Path to the module package.json file
* @param tree Tree to read the file
* @param projectName Name of the project
* @param devDependencyOnly If true, the dependency will be added as devDependency
* @param exactO3rVersion Use a pinned version of the o3r package
*/
export declare const getPackageInstallConfig: (packageJsonPath: string, tree: Tree, projectName?: string, devDependencyOnly?: boolean, exactO3rVersion?: boolean) => Record<string, DependencyToAdd>;
/**
* Replace the caret ranges by tilde ranges
* @param range Range to replace
*/
export declare const enforceTildeRange: (range?: string) => string | undefined;
/**
* Setup dependency to a repository.
* Will run manually the ngAdd schematics according to the parameters and install the packages if required
* @param options
*/
export declare const setupDependencies: (options: SetupDependenciesOptions) => Rule;
//# sourceMappingURL=dependencies.d.ts.map