mantra/gulp/Settings.ts

260 lines
5.3 KiB
TypeScript

import { dirname, join } from "upath";
/**
* Provides settings for building the project.
*/
export class Settings
{
/**
* A value indicating whether the project should be built in watched mode.
*/
public Watch = false;
/**
* The target of the project-build.
*/
public Target: string;
/**
* The path to the source-code root.
*/
private sourceRoot = "src";
/**
* The path to the root of the typescript-project.
*/
private typeScriptProjectRoot = "App";
/**
* The path to the root of the typescript-source.
*/
private typeScriptSourceRoot = "src";
/**
* The path to save the javascript-code to.
*/
private libraryPath = "javascript";
/**
* The path to the root of the theme-source.
*/
private themeSource = "Theme";
/**
* The path to save the css-code to.
*/
private stylePath = "css";
/**
* The path to the root of the template-source.
*/
private templateSource = "Templates";
/**
* The path to save the templates to.
*/
private templatePath = "templates";
/**
* The path to the test-directory.
*/
private testPath = "test";
/**
* The path to the test-website.
*/
private testWebsitePath = "website";
/**
* The name of the theme.
*/
private themeName = "mantra";
/**
* Initializes a new instance of the `Settings` class.
*
* @param target
* The target of the project-build.
*/
public constructor(target: string)
{
this.Target = target;
}
/**
* A value indicating whether the debug-mode is enabled.
*/
public get Debug(): boolean
{
return this.Target === "Debug";
}
/**
* Creates a path relative to the root of the solution.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public RootPath(...path: string[]): string
{
return join(dirname(__dirname), ...path);
}
/**
* Creates a path relative to the root of the source-code.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public SourceRoot(...path: string[]): string
{
return this.RootPath(this.sourceRoot, ...path);
}
/**
* Creates a path relative to the root of the typescript-project.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public TypeScriptProjectRoot(...path: string[]): string
{
return this.SourceRoot(this.typeScriptProjectRoot, ...path);
}
/**
* Creates a path relative to the root of the typescript-source.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public TypeScriptSourceRoot(...path: string[]): string
{
return this.TypeScriptProjectRoot(this.typeScriptSourceRoot, ...path);
}
/**
* Creates a path relative to the directory to save the javascript-code to.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public LibraryPath(...path: string[]): string
{
return this.RootPath(this.libraryPath, ...path);
}
/**
* Creates a path relative to the root of the theme-source.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public ThemeSource(...path: string[]): string
{
return this.SourceRoot(this.themeSource, ...path);
}
/**
* Creates a path relative to the directory to save the css-code to.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public StylePath(...path: string[]): string
{
return this.RootPath(this.stylePath, ...path);
}
/**
* Creates a path relative to the root of the template-source.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public TemplateSource(...path: string[]): string
{
return this.SourceRoot(this.templateSource, ...path);
}
/**
* Creates a path relative to the directory to save the templates to.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public TemplatePath(...path: string[]): string
{
return this.RootPath(this.templatePath, ...path);
}
/**
* Creates a path relative to the test-directory.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public TestPath(...path: string[]): string
{
return this.RootPath(this.testPath, ...path);
}
/**
* Creates a path relative to the test-website.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public TestWebsitePath(...path: string[]): string
{
return this.TestPath(this.testWebsitePath, ...path);
}
/**
* Creates a path relative to the test-theme.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public TestThemePath(...path: string[]): string
{
return this.TestWebsitePath("themes", this.themeName, ...path);
}
}