@yeoman/namespace
Version:
Namespace parsing for yeoman's generator/environment stack
72 lines (71 loc) • 2.5 kB
TypeScript
export declare const ENTRYPOINT_GENERATOR_NAME = "app";
type ParsedNamespace = {
complete: string;
scope?: string;
unscoped: string;
generator?: string;
instanceId?: string;
semver?: string;
method?: string;
flags?: string;
};
export declare class YeomanNamespace<GeneratorPropertyType extends string | undefined = undefined | string> implements ParsedNamespace {
_original: string;
scope?: string;
unscoped: string;
generator: GeneratorPropertyType;
instanceId?: string;
semver?: string;
methods?: string[];
flags?: string;
command?: any;
constructor(parsed: ParsedNamespace);
get _scopeAddition(): string;
get generatorName(): string;
get instanceName(): string;
get complete(): string;
get packageNamespace(): string;
get namespace(): string;
set namespace(namespace: string);
get unscopedNamespace(): string;
get id(): string;
get generatorHint(): string;
get versionedHint(): string;
with(newValues: Partial<ParsedNamespace>): YeomanNamespace<string | undefined>;
toString(): string;
private _semverAddition;
private _update;
}
/**
* Convert a namespace to a namespace object
*/
export declare function toNamespace(namespace: string | YeomanNamespace): YeomanNamespace | undefined;
/**
* Convert a package name to a namespace object
*
* @throws if not a valid generator package name (starts with 'generator-')
*/
export declare function namespaceFromPackageName(packageName: string): YeomanNamespace;
/**
* Convert a namespace to a namespace object
*
* @throws if not a valid namespace
*/
export declare function requireNamespace(namespace: YeomanNamespace, options: {
allowPackageOnlyNamespace: false;
}): YeomanNamespace<string>;
export declare function requireNamespace<T extends YeomanNamespace>(namespace: T, options?: {
allowPackageOnlyNamespace: true | undefined;
}): T;
export declare function requireNamespace(namespace: string, options: {
allowPackageOnlyNamespace: false;
}): YeomanNamespace<string>;
export declare function requireNamespace(namespace: string, options?: {
allowPackageOnlyNamespace: true | undefined;
}): YeomanNamespace;
/**
* Test if the object is an YeomanNamespace instance.
*/
export declare function isNamespaceObject(namespace: unknown): namespace is YeomanNamespace;
export declare function hasGenerator(value: YeomanNamespace<string | undefined>): value is YeomanNamespace<string>;
export {};