@kwaeri/node-kit-project-generator
Version:
The @kwaeri/node-kit-project-generator component module of the @kwaeri/node-kit platform.
165 lines (164 loc) • 5.55 kB
text/typescript
/**
* SPDX-PackageName: kwaeri/node-kit-project-generator
* SPDX-PackageVersion: 0.9.0
* SPDX-FileCopyrightText: © 2014 - 2022 Richard Winters <kirvedx@gmail.com> and contributors
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR MIT
*/
import { NodeKitOptions } from '@kwaeri/standards-types';
import { ServiceProviderSubscriptions, ServiceProviderHelpText, ServiceEventBits, ServicePromiseBits } from '@kwaeri/service';
import { GeneratorServiceProvider } from '@kwaeri/generator';
/**
* @typedef {Object} AssessmentOptions
* @param {string} type
* @param {string} path
* @param {string} host
* @param {string} cachePath
* @param {string} metadataPath
* @param {string} latestCommitsQuery
*/
export type AssessmentOptions = {
type: string;
path: string;
host: string;
cachePath: string;
metadataPath: string;
latestCommitsQuery: string;
};
/**
* @typedef {Object} AssessmentBits
* @param {boolean} cacheValidated
* @param {boolean} remoteValidated
* @param {boolean} deferToCache
* @param {GitLabCommitBits} commit
* @param {GitLabCommitBits} localCommit
*/
export type AssessmentBits = {
cacheValidated: boolean;
remoteValidated: boolean;
deferToCache: boolean;
preferRemote: boolean;
commit: GitLabCommitBits | undefined;
localCommit: GitLabCommitBits | undefined;
};
/**
* @typedef {Object} GitLabCommitBits
* @param {string} id
*/
export type GitLabCommitBits = {
id: string;
};
export declare const PARAMATERIZATION: {
TYPE: {
rest: string;
react: string;
mvc: string;
xrm: string;
typescript: string;
javascript: string;
};
};
export declare const TEMPLATE_CONSTANT_OPTIONS: {
REST_PROJECT: {
JAVASCRIPT: number;
TYPESCRIPT: number;
};
REACT_PROJECT: {
JAVASCRIPT: number;
TYPESCRIPT: number;
};
MVC_PROJECT: {
JAVASCRIPT: number;
TYPESCRIPT: number;
};
};
export declare const TEMPLATE_CONSTANTS: {
REST_PROJECT: {
JAVASCRIPT: number;
TYPESCRIPT: number;
};
REACT_PROJECT: {
JAVASCRIPT: number;
TYPESCRIPT: number;
};
MVC_PROJECT: {
JAVASCRIPT: number;
TYPESCRIPT: number;
};
XRM_PROJECT: number;
};
export type ProjectGeneratorOptions = {
type: string;
language: string;
path: string;
};
/**
* ProjectGenerator
*
* Extends the {@link GeneratorServiceProvider } class, which implements the { BaseGenerator }
* Interface.
*/
export declare class NodeKitProjectGenerator extends GeneratorServiceProvider {
/**
* Class constructor
*/
constructor(handler?: (data: ServiceEventBits) => void, configuration?: NodeKitOptions);
getServiceProviderSubscriptions(options?: any): ServiceProviderSubscriptions;
getServiceProviderSubscriptionHelpText<T extends ServiceProviderHelpText>(options?: any): T;
/**
* Method to resettle the { NodeKitProjectGeneratorOptions }. Essentially we
* begin to populate the project configuration with what information we can
* from the user's command. We can [will] also launch the wizard from here.
*
* @param { NodeKitOptions } options
*
* @returns { NodeKitOptions } The options object, with the configuration partially populated with user-provided information
*/
assembleOptions(options: NodeKitOptions): NodeKitOptions;
renderService<T>(options: NodeKitOptions): Promise<T>;
/**
* Method to generate a project infrastructure fed by a repository tree.
*
* If a cached source of the requested resource exists locally, and its commit
* id matches the latest commit id for its respective remote, this method
* prefers the local cache. If a cached source exists locally and any error
* occurs when an attempt to fetch its remote occurs, this method defers to
* the local cache. In any other case, the remote resource is preferred.
*
* @param { Object } options The options required for generating a project infrastructure (i.e. type and path)
*
* @returns { Promise<FilesystemPromise|ClientHttp2Promise> }
*/
createProject(options: ProjectGeneratorOptions): Promise<ServicePromiseBits>;
/**
* Method to determine whether to prefer or defer to cache - or to prefer remote
* sources.
*
* @param { ...AssessmentOptions } options
*
* @returns {AssessmentBits} An {@link AssessmentBits} object.
*/
assessRoute(options: AssessmentOptions): Promise<AssessmentBits>;
/**
* Method to fetch project sources from local cache
*
* @param { string } type
* @param { string } path
* @param { string } cachePath
* @param { GitLabCommitBits } localCommit
* @returns { ServicePromiseBits }
*/
fetchFromCache(type: string, path: string, cachePath: string, localCommit: GitLabCommitBits): Promise<ServicePromiseBits>;
/**
* Method to fetch project sources from a remote resource
*
* @param { string } type
* @param { string } path
* @param { string } host
* @param { string } baseTreeQuery
* @param { string } baseFilesQuery
* @param { string } cachePath
* @param { GitLabCommitBits } commit
* @returns { ServicePromiseBits }
*/
fetchFromRemote(type: string, path: string, host: string, baseTreeQuery: string, baseFilesQuery: string, cachePath: string, metadataPath: string, commit: GitLabCommitBits): Promise<ServicePromiseBits>;
}