Normalize typescript-imports
This commit is contained in:
parent
7698a9aab3
commit
fefbad1687
2 changed files with 23 additions and 24 deletions
|
@ -1,4 +1,4 @@
|
||||||
import Path = require("upath");
|
import { dirname, join } from "upath";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides settings for building the project.
|
* Provides settings for building the project.
|
||||||
|
@ -100,7 +100,7 @@ export class Settings
|
||||||
*/
|
*/
|
||||||
public RootPath(...path: string[]): string
|
public RootPath(...path: string[]): string
|
||||||
{
|
{
|
||||||
return Path.join(Path.dirname(__dirname), ...path);
|
return join(dirname(__dirname), ...path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
43
gulpfile.ts
43
gulpfile.ts
|
@ -2,9 +2,8 @@ import { Server, Socket } from "net";
|
||||||
import browserSync = require("browser-sync");
|
import browserSync = require("browser-sync");
|
||||||
import browserify = require("browserify");
|
import browserify = require("browserify");
|
||||||
import logger = require("fancy-log");
|
import logger = require("fancy-log");
|
||||||
import FileSystem = require("fs-extra");
|
import { emptyDir, mkdirp, pathExists, remove } from "fs-extra";
|
||||||
import { TaskFunction } from "gulp";
|
import { dest, parallel, series, src, TaskFunction, watch } from "gulp";
|
||||||
import gulp = require("gulp");
|
|
||||||
import gulpIf = require("gulp-if");
|
import gulpIf = require("gulp-if");
|
||||||
import rename = require("gulp-rename");
|
import rename = require("gulp-rename");
|
||||||
import sass = require("gulp-sass");
|
import sass = require("gulp-sass");
|
||||||
|
@ -13,7 +12,7 @@ import merge = require("merge-stream");
|
||||||
import minimist = require("minimist");
|
import minimist = require("minimist");
|
||||||
import { parseArgsStringToArgv } from "string-argv";
|
import { parseArgsStringToArgv } from "string-argv";
|
||||||
import tsify = require("tsify");
|
import tsify = require("tsify");
|
||||||
import Path = require("upath");
|
import { changeExt, dirname, join, parse, relative } from "upath";
|
||||||
import buffer = require("vinyl-buffer");
|
import buffer = require("vinyl-buffer");
|
||||||
import vinylSourceStream = require("vinyl-source-stream");
|
import vinylSourceStream = require("vinyl-source-stream");
|
||||||
import Watchify = require("watchify");
|
import Watchify = require("watchify");
|
||||||
|
@ -104,16 +103,16 @@ export async function Clean(): Promise<void>
|
||||||
|
|
||||||
for (let directory of directories)
|
for (let directory of directories)
|
||||||
{
|
{
|
||||||
await FileSystem.emptyDir(settings.RootPath(directory));
|
await emptyDir(settings.RootPath(directory));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await FileSystem.pathExists(settings.TestThemePath()))
|
if (await pathExists(settings.TestThemePath()))
|
||||||
{
|
{
|
||||||
await FileSystem.remove(settings.TestThemePath());
|
await remove(settings.TestThemePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
await FileSystem.mkdirp(settings.TestThemePath());
|
await mkdirp(settings.TestThemePath());
|
||||||
await FileSystem.remove(settings.TestThemePath());
|
await remove(settings.TestThemePath());
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
await require("create-symlink")(settings.RootPath(), settings.TestThemePath(), { type: "junction" });
|
await require("create-symlink")(settings.RootPath(), settings.TestThemePath(), { type: "junction" });
|
||||||
}
|
}
|
||||||
|
@ -212,11 +211,11 @@ export async function Build(): Promise<void>
|
||||||
online: false
|
online: false
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.watch(settings.ThemeSource("**"), { usePolling: true }, gulp.series(Theme, BrowserSync("*.css")));
|
watch(settings.ThemeSource("**"), { usePolling: true }, series(Theme, BrowserSync("*.css")));
|
||||||
gulp.watch(settings.TemplateSource("**"), { usePolling: true }, gulp.series(Templates, BrowserSync()));
|
watch(settings.TemplateSource("**"), { usePolling: true }, series(Templates, BrowserSync()));
|
||||||
}
|
}
|
||||||
|
|
||||||
gulp.parallel(Library, Theme, Templates)(
|
parallel(Library, Theme, Templates)(
|
||||||
(error) =>
|
(error) =>
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -254,7 +253,7 @@ export function Library(): NodeJS.ReadWriteStream
|
||||||
};
|
};
|
||||||
|
|
||||||
let files = (tsConfig.files as string[]).map(
|
let files = (tsConfig.files as string[]).map(
|
||||||
(file) => Path.relative(settings.TypeScriptSourceRoot(), settings.TypeScriptProjectRoot(file)));
|
(file) => relative(settings.TypeScriptSourceRoot(), settings.TypeScriptProjectRoot(file)));
|
||||||
|
|
||||||
for (let file of files)
|
for (let file of files)
|
||||||
{
|
{
|
||||||
|
@ -265,11 +264,11 @@ export function Library(): NodeJS.ReadWriteStream
|
||||||
let bundler = browserify(
|
let bundler = browserify(
|
||||||
{
|
{
|
||||||
...optionBase,
|
...optionBase,
|
||||||
basedir: settings.LibraryPath(Path.dirname(file)),
|
basedir: settings.LibraryPath(dirname(file)),
|
||||||
entries: [
|
entries: [
|
||||||
settings.TypeScriptSourceRoot(file)
|
settings.TypeScriptSourceRoot(file)
|
||||||
],
|
],
|
||||||
standalone: Path.join(Path.dirname(file), Path.parse(file).name)
|
standalone: join(dirname(file), parse(file).name)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (settings.Watch)
|
if (settings.Watch)
|
||||||
|
@ -293,11 +292,11 @@ export function Library(): NodeJS.ReadWriteStream
|
||||||
{
|
{
|
||||||
let result = new RegExp(`^(${error["fileName"]})\\((\\d+|\\d+(,\\d+){1,3})\\): .* TS([\\d]+): (.*)$`).exec(message);
|
let result = new RegExp(`^(${error["fileName"]})\\((\\d+|\\d+(,\\d+){1,3})\\): .* TS([\\d]+): (.*)$`).exec(message);
|
||||||
errorMessages.push(message);
|
errorMessages.push(message);
|
||||||
console.log(`${Path.relative(process.cwd(), result[1])}(${result[2]}): ${result[4]} ${result[5]}`);
|
console.log(`${relative(process.cwd(), result[1])}(${result[2]}): ${result[4]} ${result[5]}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
).pipe(
|
).pipe(
|
||||||
vinylSourceStream(Path.changeExt(file, "js"))
|
vinylSourceStream(changeExt(file, "js"))
|
||||||
).pipe(
|
).pipe(
|
||||||
buffer()
|
buffer()
|
||||||
).pipe(
|
).pipe(
|
||||||
|
@ -306,7 +305,7 @@ export function Library(): NodeJS.ReadWriteStream
|
||||||
terser()
|
terser()
|
||||||
)
|
)
|
||||||
).pipe(
|
).pipe(
|
||||||
gulp.dest(settings.LibraryPath())
|
dest(settings.LibraryPath())
|
||||||
).on(
|
).on(
|
||||||
"end",
|
"end",
|
||||||
() =>
|
() =>
|
||||||
|
@ -375,7 +374,7 @@ export function Theme(): NodeJS.ReadWriteStream
|
||||||
console.log("Rebuilding scss-code.");
|
console.log("Rebuilding scss-code.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return gulp.src(
|
return src(
|
||||||
settings.ThemeSource("main.scss"),
|
settings.ThemeSource("main.scss"),
|
||||||
{
|
{
|
||||||
sourcemaps: settings.Debug,
|
sourcemaps: settings.Debug,
|
||||||
|
@ -409,7 +408,7 @@ export function Theme(): NodeJS.ReadWriteStream
|
||||||
parsedPath.basename = "mantra";
|
parsedPath.basename = "mantra";
|
||||||
})
|
})
|
||||||
).pipe(
|
).pipe(
|
||||||
gulp.dest(
|
dest(
|
||||||
settings.StylePath(),
|
settings.StylePath(),
|
||||||
settings.Debug ?
|
settings.Debug ?
|
||||||
{
|
{
|
||||||
|
@ -437,9 +436,9 @@ Theme.description = "Builds the theme.";
|
||||||
*/
|
*/
|
||||||
export function Templates(): NodeJS.ReadWriteStream
|
export function Templates(): NodeJS.ReadWriteStream
|
||||||
{
|
{
|
||||||
return gulp.src(
|
return src(
|
||||||
settings.TemplateSource("**")).pipe(
|
settings.TemplateSource("**")).pipe(
|
||||||
gulp.dest(settings.TemplatePath()));
|
dest(settings.TemplatePath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Templates.description = "Builds the templates.";
|
Templates.description = "Builds the templates.";
|
||||||
|
|
Loading…
Reference in a new issue