mantra/gulp/Settings.ts

260 lines
5.3 KiB
TypeScript
Raw Normal View History

2021-05-11 19:49:46 +00:00
import { dirname, join } from "upath";
2019-10-07 11:48:01 +00:00
/**
* 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";
2019-10-07 16:59:23 +00:00
/**
* The path to the root of the theme-source.
*/
private themeSource = "Theme";
/**
* The path to save the css-code to.
*/
private stylePath = "css";
2019-10-07 17:09:35 +00:00
/**
* The path to the root of the template-source.
*/
private templateSource = "Templates";
/**
* The path to save the templates to.
*/
private templatePath = "templates";
2019-10-07 15:50:06 +00:00
/**
* The path to the test-directory.
*/
private testPath = "test";
/**
* The path to the test-website.
*/
private testWebsitePath = "website";
2019-10-07 20:03:44 +00:00
/**
* The name of the theme.
*/
private themeName = "mantra";
2019-10-07 11:48:01 +00:00
/**
* 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.
*/
2021-05-11 00:56:38 +00:00
public get Debug(): boolean
2019-10-07 11:48:01 +00:00
{
return this.Target === "Debug";
}
/**
* Creates a path relative to the root of the solution.
*
* @param path
* The path to join.
*
2021-05-11 00:56:38 +00:00
* @returns
2019-10-07 11:48:01 +00:00
* The joined path.
*/
2021-05-11 00:56:38 +00:00
public RootPath(...path: string[]): string
2019-10-07 11:48:01 +00:00
{
2021-05-11 19:49:46 +00:00
return join(dirname(__dirname), ...path);
2019-10-07 11:48:01 +00:00
}
/**
* Creates a path relative to the root of the source-code.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
2021-05-11 00:56:38 +00:00
public SourceRoot(...path: string[]): string
2019-10-07 11:48:01 +00:00
{
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.
*/
2021-05-11 00:56:38 +00:00
public TypeScriptProjectRoot(...path: string[]): string
2019-10-07 11:48:01 +00:00
{
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.
*/
2021-05-11 00:56:38 +00:00
public TypeScriptSourceRoot(...path: string[]): string
2019-10-07 11:48:01 +00:00
{
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.
*/
2021-05-11 00:56:38 +00:00
public LibraryPath(...path: string[]): string
2019-10-07 11:48:01 +00:00
{
return this.RootPath(this.libraryPath, ...path);
}
2019-10-07 15:50:06 +00:00
2019-10-07 16:59:23 +00:00
/**
* Creates a path relative to the root of the theme-source.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
2021-05-11 00:56:38 +00:00
public ThemeSource(...path: string[]): string
2019-10-07 16:59:23 +00:00
{
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.
*/
2021-05-11 00:56:38 +00:00
public StylePath(...path: string[]): string
2019-10-07 16:59:23 +00:00
{
return this.RootPath(this.stylePath, ...path);
}
2019-10-07 17:09:35 +00:00
/**
* Creates a path relative to the root of the template-source.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
2021-05-11 00:56:38 +00:00
public TemplateSource(...path: string[]): string
2019-10-07 17:09:35 +00:00
{
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.
*/
2021-05-11 00:56:38 +00:00
public TemplatePath(...path: string[]): string
2019-10-07 17:09:35 +00:00
{
return this.RootPath(this.templatePath, ...path);
}
2019-10-07 15:50:06 +00:00
/**
* Creates a path relative to the test-directory.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
2021-05-11 00:56:38 +00:00
public TestPath(...path: string[]): string
2019-10-07 15:50:06 +00:00
{
return this.RootPath(this.testPath, ...path);
}
/**
* Creates a path relative to the test-website.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
2021-05-11 00:56:38 +00:00
public TestWebsitePath(...path: string[]): string
2019-10-07 15:50:06 +00:00
{
return this.TestPath(this.testWebsitePath, ...path);
}
2019-10-07 20:03:44 +00:00
/**
* Creates a path relative to the test-theme.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
2021-05-11 00:56:38 +00:00
public TestThemePath(...path: string[]): string
2019-10-07 20:03:44 +00:00
{
return this.TestWebsitePath("themes", this.themeName, ...path);
}
2021-05-11 00:56:38 +00:00
}