webanvil 0.0.0 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/run +1 -1
- package/lib/commands/build.d.ts +3 -0
- package/lib/commands/build.d.ts.map +1 -0
- package/lib/commands/build.js +37 -0
- package/lib/commands/serve.d.ts +3 -0
- package/lib/commands/serve.d.ts.map +1 -0
- package/lib/commands/serve.js +38 -0
- package/lib/commons/io/core/File.d.ts +11 -0
- package/lib/commons/io/core/File.d.ts.map +1 -0
- package/lib/commons/io/core/File.js +23 -0
- package/lib/commons/io/core/Path.d.ts +30 -0
- package/lib/commons/io/core/Path.d.ts.map +1 -0
- package/lib/commons/io/core/Path.js +122 -0
- package/lib/commons/io/sync/fs.d.ts +11 -0
- package/lib/commons/io/sync/fs.d.ts.map +1 -0
- package/lib/commons/io/sync/fs.js +46 -0
- package/lib/commons/io/sync/index.d.ts +5 -0
- package/lib/commons/io/sync/index.d.ts.map +1 -0
- package/lib/commons/io/sync/index.js +9 -0
- package/lib/commons/io/sync/path.d.ts +4 -0
- package/lib/commons/io/sync/path.d.ts.map +1 -0
- package/lib/commons/io/sync/path.js +13 -0
- package/lib/core/Configuration.d.ts +35 -0
- package/lib/core/Configuration.d.ts.map +1 -0
- package/lib/core/Configuration.js +55 -0
- package/lib/core/EventEmitter.d.ts +14 -0
- package/lib/core/EventEmitter.d.ts.map +1 -0
- package/lib/core/EventEmitter.js +42 -0
- package/lib/core/Page.d.ts +14 -0
- package/lib/core/Page.d.ts.map +1 -0
- package/lib/core/Page.js +34 -0
- package/lib/core/Plugin.d.ts +13 -0
- package/lib/core/Plugin.d.ts.map +1 -0
- package/lib/core/Plugin.js +12 -0
- package/lib/core/Renderer/Renderer.d.ts +8 -0
- package/lib/core/Renderer/Renderer.d.ts.map +1 -0
- package/lib/core/Renderer/Renderer.js +9 -0
- package/lib/core/Renderer/index.d.ts +8 -0
- package/lib/core/Renderer/index.d.ts.map +1 -0
- package/lib/core/Renderer/index.js +18 -0
- package/lib/index.js +0 -1
- package/lib/main.d.ts +1 -0
- package/lib/main.d.ts.map +1 -1
- package/lib/main.js +35 -1
- package/lib/plugins/outlinecss.d.ts +4 -0
- package/lib/plugins/outlinecss.d.ts.map +1 -0
- package/lib/plugins/outlinecss.js +34 -0
- package/lib/renderers/EJSRenderer.d.ts +7 -0
- package/lib/renderers/EJSRenderer.d.ts.map +1 -0
- package/lib/renderers/EJSRenderer.js +34 -0
- package/package.json +9 -5
package/bin/run
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["build.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,8BAA4B;AAMhD,wBAA8B,KAAK,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BjF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = build;
|
|
4
|
+
const sync_1 = require("../commons/io/sync");
|
|
5
|
+
const nodepath = require("path");
|
|
6
|
+
const Renderer_1 = require("../core/Renderer");
|
|
7
|
+
const Page_1 = require("../core/Page");
|
|
8
|
+
const EventEmitter_1 = require("../core/EventEmitter");
|
|
9
|
+
async function build(configuration) {
|
|
10
|
+
const pages = sync_1.fs.deepdir(configuration.directories.pages)
|
|
11
|
+
.filter(pathname => pathname.base.includes(configuration.renderer.extension))
|
|
12
|
+
.map(pathname => Page_1.default.from(pathname));
|
|
13
|
+
const renderer = Renderer_1.default.from(configuration);
|
|
14
|
+
const emitter = new EventEmitter_1.default();
|
|
15
|
+
// Todo: Disable `outlinecss` plugin
|
|
16
|
+
// const signals = []
|
|
17
|
+
// for (const plugin of configuration.plugins) {
|
|
18
|
+
// signals.push(plugin.install(emitter, configuration))
|
|
19
|
+
// }
|
|
20
|
+
sync_1.fs.rm(configuration.directories.output);
|
|
21
|
+
for (const page of pages) {
|
|
22
|
+
const html = renderer.render(page);
|
|
23
|
+
const output = page.path
|
|
24
|
+
.replace(configuration.directories.pages, "");
|
|
25
|
+
if (output.base === "index.html") {
|
|
26
|
+
sync_1.fs.write(sync_1.path.join(configuration.directories.output, output), html);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const basename = nodepath.basename(String(output), ".html");
|
|
30
|
+
sync_1.fs.write(sync_1.path.join(configuration.directories.output, basename, "index.html"), html);
|
|
31
|
+
}
|
|
32
|
+
sync_1.fs.cp(configuration.directories.public, configuration.directories.output);
|
|
33
|
+
}
|
|
34
|
+
emitter.emit(EventEmitter_1.Event.END);
|
|
35
|
+
// await Promise.all(signals)
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["serve.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,8BAA4B;AAIhD,wBAA8B,KAAK,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CA2BjF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = serve;
|
|
4
|
+
const bs = require("browser-sync");
|
|
5
|
+
const index_1 = require("../commons/io/sync/index");
|
|
6
|
+
const build_1 = require("./build");
|
|
7
|
+
async function serve(configuration) {
|
|
8
|
+
await (0, build_1.default)(configuration);
|
|
9
|
+
const browser = bs.create();
|
|
10
|
+
const rebuild = async () => {
|
|
11
|
+
return (0, build_1.default)(configuration);
|
|
12
|
+
};
|
|
13
|
+
const reload = async () => {
|
|
14
|
+
browser.reload();
|
|
15
|
+
};
|
|
16
|
+
browser.watch(index_1.path.join(configuration.directories.public, `**/*`).full)
|
|
17
|
+
.on("change", run(reload));
|
|
18
|
+
browser.watch(index_1.path.join(configuration.directories.pages, `**/*`).full)
|
|
19
|
+
.on("change", run(rebuild, reload));
|
|
20
|
+
browser.watch(index_1.path.join(configuration.directories.partials, `**/*`).full)
|
|
21
|
+
.on("change", run(rebuild, reload));
|
|
22
|
+
browser.watch(index_1.path.join(configuration.directories.layouts, `**/*`).full)
|
|
23
|
+
.on("change", run(rebuild, reload));
|
|
24
|
+
browser.watch(index_1.path.join(configuration.directories.styles, `**/*`).full)
|
|
25
|
+
.on("change", run(rebuild, reload));
|
|
26
|
+
browser.init({
|
|
27
|
+
server: configuration.directories.output.full,
|
|
28
|
+
open: false
|
|
29
|
+
});
|
|
30
|
+
return new Promise(() => void 0);
|
|
31
|
+
}
|
|
32
|
+
const run = (...jobs) => {
|
|
33
|
+
return (...varargs) => {
|
|
34
|
+
return jobs.reduce((accumulator, job) => {
|
|
35
|
+
return accumulator.then(job);
|
|
36
|
+
}, Promise.resolve(varargs[0]));
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Path from "./Path";
|
|
2
|
+
export default class File {
|
|
3
|
+
private readonly _path;
|
|
4
|
+
private readonly _content;
|
|
5
|
+
constructor(path: Path, content: string);
|
|
6
|
+
get path(): Path;
|
|
7
|
+
get content(): string;
|
|
8
|
+
toString(): string;
|
|
9
|
+
valueOf(): string;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=File.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"File.d.ts","sourceRoot":"","sources":["File.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAA;AAGzB,MAAM,CAAC,OAAO,OAAO,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAM;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;gBAErB,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM;IAKvC,IAAW,IAAI,IAAI,IAAI,CAEtB;IAED,IAAW,OAAO,IAAI,MAAM,CAE3B;IAEM,QAAQ;IAIR,OAAO,IAAI,MAAM;CAG3B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class File {
|
|
4
|
+
_path;
|
|
5
|
+
_content;
|
|
6
|
+
constructor(path, content) {
|
|
7
|
+
this._path = path;
|
|
8
|
+
this._content = content;
|
|
9
|
+
}
|
|
10
|
+
get path() {
|
|
11
|
+
return this._path;
|
|
12
|
+
}
|
|
13
|
+
get content() {
|
|
14
|
+
return this._content;
|
|
15
|
+
}
|
|
16
|
+
toString() {
|
|
17
|
+
return this.content;
|
|
18
|
+
}
|
|
19
|
+
valueOf() {
|
|
20
|
+
return this.toString();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = File;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as nodeutil from "util";
|
|
2
|
+
export type PathStruct = {
|
|
3
|
+
dir?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
ext?: string;
|
|
6
|
+
};
|
|
7
|
+
export type PathLike = Path | string;
|
|
8
|
+
export default class Path {
|
|
9
|
+
private readonly _dir;
|
|
10
|
+
private readonly _name;
|
|
11
|
+
private readonly _ext;
|
|
12
|
+
static from(path: PathLike | PathStruct, ...segments: PathLike[]): Path;
|
|
13
|
+
constructor(pathname: string);
|
|
14
|
+
replace(path: PathLike | PathStruct, replaceValue?: string): Path;
|
|
15
|
+
join(...segments: PathLike[]): Path;
|
|
16
|
+
from(to: PathLike): Path;
|
|
17
|
+
to(from: PathLike): Path;
|
|
18
|
+
get full(): string;
|
|
19
|
+
get base(): string;
|
|
20
|
+
get name(): string;
|
|
21
|
+
set name(value: string);
|
|
22
|
+
get ext(): string;
|
|
23
|
+
set ext(value: string);
|
|
24
|
+
get dir(): string;
|
|
25
|
+
set dir(value: string);
|
|
26
|
+
toString(): string;
|
|
27
|
+
valueOf(): string;
|
|
28
|
+
[nodeutil.inspect.custom](): string;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=Path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Path.d.ts","sourceRoot":"","sources":["Path.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,MAAM,CAAA;AAGhC,MAAM,MAAM,UAAU,GAClB;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEjD,MAAM,MAAM,QAAQ,GAChB,IAAI,GAAG,MAAM,CAAA;AAEjB,MAAM,CAAC,OAAO,OAAO,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAQ;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAQ;WAEf,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,EAAE,GAAG,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI;gBAelE,QAAQ,EAAE,MAAM;IAOrB,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IAiBjE,IAAI,CAAC,GAAG,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI;IAInC,IAAI,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI;IAIxB,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAI/B,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,IAAI,CAAC,KAAK,EAAE,MAAM,EAE5B;IAED,IAAW,GAAG,IAAI,MAAM,CAEvB;IAED,IAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAE3B;IAED,IAAW,GAAG,IAAI,MAAM,CAEvB;IAED,IAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAE3B;IAwCM,QAAQ;IAIR,OAAO,IAAI,MAAM;IAIjB,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM;CAG7C"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const nodepath = require("path");
|
|
4
|
+
const nodeutil = require("util");
|
|
5
|
+
class Path {
|
|
6
|
+
_dir;
|
|
7
|
+
_name;
|
|
8
|
+
_ext;
|
|
9
|
+
static from(path, ...segments) {
|
|
10
|
+
if (path instanceof Path) {
|
|
11
|
+
return segments.reduce((pathname, segment) => pathname.join(segment), path);
|
|
12
|
+
}
|
|
13
|
+
else if (typeof path === "string") {
|
|
14
|
+
return new Path(nodepath.join(path, ...segments.map(String)));
|
|
15
|
+
}
|
|
16
|
+
else if (typeof path === "object") {
|
|
17
|
+
return new Path(nodepath.join(path.dir ?? "", `${path.name ?? ""}${path.ext ?? ""}`));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
throw new TypeError("[TODO] Invalid pathname");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
constructor(pathname) {
|
|
24
|
+
const { dir, name, ext } = nodepath.parse(pathname);
|
|
25
|
+
this._dir = dir;
|
|
26
|
+
this._name = name;
|
|
27
|
+
this._ext = ext;
|
|
28
|
+
}
|
|
29
|
+
replace(path, replaceValue) {
|
|
30
|
+
if (path instanceof Path || typeof path === "string") {
|
|
31
|
+
return new Path(String(this.full)
|
|
32
|
+
.replace(String(path), replaceValue ?? ""));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
let { dir, name, ext } = path;
|
|
36
|
+
if (ext?.charAt(0) === ".") {
|
|
37
|
+
ext = ext.slice(1);
|
|
38
|
+
}
|
|
39
|
+
return new Path(nodepath.join(dir ?? this._dir, `${name ?? this._name}.${ext ?? this._ext}`));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
join(...segments) {
|
|
43
|
+
return new Path(nodepath.join(this.full, ...segments.map(String)));
|
|
44
|
+
}
|
|
45
|
+
from(to) {
|
|
46
|
+
return new Path(nodepath.relative(String(this), String(to)));
|
|
47
|
+
}
|
|
48
|
+
to(from) {
|
|
49
|
+
return new Path(nodepath.relative(String(from), String(this)));
|
|
50
|
+
}
|
|
51
|
+
get full() {
|
|
52
|
+
return nodepath.join(this._dir, this.base);
|
|
53
|
+
}
|
|
54
|
+
get base() {
|
|
55
|
+
return `${this._name}${this._ext}`;
|
|
56
|
+
}
|
|
57
|
+
get name() {
|
|
58
|
+
return this._name;
|
|
59
|
+
}
|
|
60
|
+
set name(value) {
|
|
61
|
+
this.replace({ name: value });
|
|
62
|
+
}
|
|
63
|
+
get ext() {
|
|
64
|
+
return this._ext;
|
|
65
|
+
}
|
|
66
|
+
set ext(value) {
|
|
67
|
+
this.replace({ ext: value });
|
|
68
|
+
}
|
|
69
|
+
get dir() {
|
|
70
|
+
return this._dir;
|
|
71
|
+
}
|
|
72
|
+
set dir(value) {
|
|
73
|
+
this.replace({ dir: value });
|
|
74
|
+
}
|
|
75
|
+
// public path(): string {
|
|
76
|
+
// return nodepath.join(this._dir, this.base())
|
|
77
|
+
// }
|
|
78
|
+
//
|
|
79
|
+
// public base(): string {
|
|
80
|
+
// return `${this._name}${this._ext}`
|
|
81
|
+
// }
|
|
82
|
+
//
|
|
83
|
+
// public name(): string
|
|
84
|
+
// public name(value: string): Path
|
|
85
|
+
// public name(value?: string): PathLike {
|
|
86
|
+
// if (value) {
|
|
87
|
+
// return this.replace({ name: value })
|
|
88
|
+
// } else {
|
|
89
|
+
// return this._name
|
|
90
|
+
// }
|
|
91
|
+
// }
|
|
92
|
+
//
|
|
93
|
+
// public ext(): string
|
|
94
|
+
// public ext(value: string): Path
|
|
95
|
+
// public ext(value?: string): PathLike {
|
|
96
|
+
// if (value) {
|
|
97
|
+
// return this.replace({ ext: value })
|
|
98
|
+
// } else {
|
|
99
|
+
// return this._ext
|
|
100
|
+
// }
|
|
101
|
+
// }
|
|
102
|
+
//
|
|
103
|
+
// public dir(): string
|
|
104
|
+
// public dir(value: string): Path
|
|
105
|
+
// public dir(value?: string): PathLike {
|
|
106
|
+
// if (value) {
|
|
107
|
+
// return this.replace({ dir: value })
|
|
108
|
+
// } else {
|
|
109
|
+
// return this._dir
|
|
110
|
+
// }
|
|
111
|
+
// }
|
|
112
|
+
toString() {
|
|
113
|
+
return this.full;
|
|
114
|
+
}
|
|
115
|
+
valueOf() {
|
|
116
|
+
return this.toString();
|
|
117
|
+
}
|
|
118
|
+
[nodeutil.inspect.custom]() {
|
|
119
|
+
return this.valueOf();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.default = Path;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Path, { PathLike } from "../core/Path";
|
|
2
|
+
import File from "../core/File";
|
|
3
|
+
export declare const dir: (path: PathLike) => Path[];
|
|
4
|
+
export declare const deepdir: (path: PathLike) => Path[];
|
|
5
|
+
export declare const mkdir: (path: PathLike) => void;
|
|
6
|
+
export declare const exists: (path: PathLike) => boolean;
|
|
7
|
+
export declare const read: (path: PathLike) => File;
|
|
8
|
+
export declare const write: (path: PathLike, content: string) => void;
|
|
9
|
+
export declare const rm: (path: PathLike) => void;
|
|
10
|
+
export declare const cp: (source: PathLike, destination: PathLike) => void;
|
|
11
|
+
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["fs.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,IAAI,MAAM,cAAc,CAAA;AAG/B,eAAO,MAAM,GAAG,GAAI,MAAM,QAAQ,KAAG,IAAI,EAGxC,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,MAAM,QAAQ,KAAG,IAAI,EAG5C,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,MAAM,QAAQ,KAAG,IAEtC,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,MAAM,QAAQ,KAAG,OAEvC,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,MAAM,QAAQ,KAAG,IAGrC,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,MAAM,QAAQ,EAAE,SAAS,MAAM,KAAG,IAGvD,CAAA;AAED,eAAO,MAAM,EAAE,GAAI,MAAM,QAAQ,KAAG,IAInC,CAAA;AAED,eAAO,MAAM,EAAE,GAAI,QAAQ,QAAQ,EAAE,aAAa,QAAQ,SAIzD,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cp = exports.rm = exports.write = exports.read = exports.exists = exports.mkdir = exports.deepdir = exports.dir = void 0;
|
|
4
|
+
const nodefs = require("fs");
|
|
5
|
+
const Path_1 = require("../core/Path");
|
|
6
|
+
const File_1 = require("../core/File");
|
|
7
|
+
const dir = (path) => {
|
|
8
|
+
const dirents = nodefs.readdirSync(String(path), { encoding: "utf-8" });
|
|
9
|
+
return dirents.map(dirent => Path_1.default.from(path, dirent));
|
|
10
|
+
};
|
|
11
|
+
exports.dir = dir;
|
|
12
|
+
const deepdir = (path) => {
|
|
13
|
+
const dirents = nodefs.readdirSync(String(path), { encoding: "utf-8", recursive: true });
|
|
14
|
+
return dirents.map(dirent => Path_1.default.from(path, dirent));
|
|
15
|
+
};
|
|
16
|
+
exports.deepdir = deepdir;
|
|
17
|
+
const mkdir = (path) => {
|
|
18
|
+
nodefs.mkdirSync(String(path), { recursive: true });
|
|
19
|
+
};
|
|
20
|
+
exports.mkdir = mkdir;
|
|
21
|
+
const exists = (path) => {
|
|
22
|
+
return nodefs.existsSync(String(path));
|
|
23
|
+
};
|
|
24
|
+
exports.exists = exists;
|
|
25
|
+
const read = (path) => {
|
|
26
|
+
const content = nodefs.readFileSync(String(path), "utf-8");
|
|
27
|
+
return new File_1.default(Path_1.default.from(path), content);
|
|
28
|
+
};
|
|
29
|
+
exports.read = read;
|
|
30
|
+
const write = (path, content) => {
|
|
31
|
+
(0, exports.mkdir)(Path_1.default.from(path).dir);
|
|
32
|
+
nodefs.writeFileSync(String(path), content, "utf-8");
|
|
33
|
+
};
|
|
34
|
+
exports.write = write;
|
|
35
|
+
const rm = (path) => {
|
|
36
|
+
if ((0, exports.exists)(path)) {
|
|
37
|
+
nodefs.rmSync(String(path), { recursive: true });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.rm = rm;
|
|
41
|
+
const cp = (source, destination) => {
|
|
42
|
+
if ((0, exports.exists)(source)) {
|
|
43
|
+
nodefs.cpSync(String(source), String(destination), { recursive: true });
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.cp = cp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,KAAK,EAAE,MAAM,MAAM,CAAA;AAC1B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.path = exports.fs = exports.Path = exports.File = void 0;
|
|
4
|
+
var File_1 = require("../core/File");
|
|
5
|
+
Object.defineProperty(exports, "File", { enumerable: true, get: function () { return File_1.default; } });
|
|
6
|
+
var Path_1 = require("../core/Path");
|
|
7
|
+
Object.defineProperty(exports, "Path", { enumerable: true, get: function () { return Path_1.default; } });
|
|
8
|
+
exports.fs = require("./fs");
|
|
9
|
+
exports.path = require("./path");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["path.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAG7C,eAAO,MAAM,GAAG,YAEf,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,GAAG,MAAM,QAAQ,EAAE,SAEvC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.join = exports.cwd = void 0;
|
|
4
|
+
const nodepath = require("path");
|
|
5
|
+
const Path_1 = require("../core/Path");
|
|
6
|
+
const cwd = () => {
|
|
7
|
+
return new Path_1.default(process.cwd());
|
|
8
|
+
};
|
|
9
|
+
exports.cwd = cwd;
|
|
10
|
+
const join = (...path) => {
|
|
11
|
+
return new Path_1.default(nodepath.join(...path.map(String)));
|
|
12
|
+
};
|
|
13
|
+
exports.join = join;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Path } from "../commons/io/sync";
|
|
2
|
+
import Plugin from "./Plugin";
|
|
3
|
+
export declare enum TemplateEngine {
|
|
4
|
+
EJS = "ejs"
|
|
5
|
+
}
|
|
6
|
+
export declare enum FileExtension {
|
|
7
|
+
HTML = "html"
|
|
8
|
+
}
|
|
9
|
+
export type RendererConfiguration = {
|
|
10
|
+
engine: TemplateEngine;
|
|
11
|
+
extension: FileExtension;
|
|
12
|
+
};
|
|
13
|
+
export type DirectoriesConfiguration = {
|
|
14
|
+
root: Path;
|
|
15
|
+
output: Path;
|
|
16
|
+
public: Path;
|
|
17
|
+
pages: Path;
|
|
18
|
+
styles: Path;
|
|
19
|
+
partials: Path;
|
|
20
|
+
layouts: Path;
|
|
21
|
+
};
|
|
22
|
+
type Configuration = {
|
|
23
|
+
renderer: RendererConfiguration;
|
|
24
|
+
directories: DirectoriesConfiguration;
|
|
25
|
+
plugins: Plugin[];
|
|
26
|
+
};
|
|
27
|
+
export type PlainConfiguration = {
|
|
28
|
+
renderer: Record<keyof RendererConfiguration, string>;
|
|
29
|
+
directories: Record<keyof DirectoriesConfiguration, string>;
|
|
30
|
+
};
|
|
31
|
+
declare namespace Configuration {
|
|
32
|
+
const from: (configuration: Partial<PlainConfiguration>) => Configuration;
|
|
33
|
+
}
|
|
34
|
+
export default Configuration;
|
|
35
|
+
//# sourceMappingURL=Configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["Configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,IAAI,EAAE,2BAAyB;AAC9C,OAAO,MAAM,iBAAqB;AAIlC,oBAAY,cAAc;IACtB,GAAG,QAAQ;CACd;AAED,oBAAY,aAAa;IACrB,IAAI,SAAS;CAChB;AAED,MAAM,MAAM,qBAAqB,GAAG;IAChC,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,aAAa,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACnC,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,IAAI,CAAA;IACZ,MAAM,EAAE,IAAI,CAAA;IACZ,KAAK,EAAE,IAAI,CAAA;IACX,MAAM,EAAE,IAAI,CAAA;IACZ,QAAQ,EAAE,IAAI,CAAA;IACd,OAAO,EAAE,IAAI,CAAA;CAChB,CAAA;AAED,KAAK,aAAa,GAAG;IACjB,QAAQ,EAAE,qBAAqB,CAAA;IAC/B,WAAW,EAAE,wBAAwB,CAAA;IACrC,OAAO,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC,MAAM,qBAAqB,EAAE,MAAM,CAAC,CAAA;IACrD,WAAW,EAAE,MAAM,CAAC,MAAM,wBAAwB,EAAE,MAAM,CAAC,CAAA;CAC9D,CAAA;AAkBD,kBAAU,aAAa,CAAC;IACb,MAAM,IAAI,GAAI,eAAe,OAAO,CAAC,kBAAkB,CAAC,KAAG,aAuBjE,CAAA;CACJ;AAGD,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileExtension = exports.TemplateEngine = void 0;
|
|
4
|
+
const sync_1 = require("../commons/io/sync");
|
|
5
|
+
const outlinecss_1 = require("../plugins/outlinecss");
|
|
6
|
+
var TemplateEngine;
|
|
7
|
+
(function (TemplateEngine) {
|
|
8
|
+
TemplateEngine["EJS"] = "ejs";
|
|
9
|
+
})(TemplateEngine || (exports.TemplateEngine = TemplateEngine = {}));
|
|
10
|
+
var FileExtension;
|
|
11
|
+
(function (FileExtension) {
|
|
12
|
+
FileExtension["HTML"] = "html";
|
|
13
|
+
})(FileExtension || (exports.FileExtension = FileExtension = {}));
|
|
14
|
+
const defaults = {
|
|
15
|
+
renderer: {
|
|
16
|
+
engine: "ejs",
|
|
17
|
+
extension: ".html"
|
|
18
|
+
},
|
|
19
|
+
directories: {
|
|
20
|
+
root: ".",
|
|
21
|
+
output: "./build",
|
|
22
|
+
public: "./source/public",
|
|
23
|
+
pages: "./source/pages",
|
|
24
|
+
styles: "./source/styles",
|
|
25
|
+
partials: "./source/templates/partials",
|
|
26
|
+
layouts: "./source/templates/layouts"
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var Configuration;
|
|
30
|
+
(function (Configuration) {
|
|
31
|
+
Configuration.from = (configuration) => {
|
|
32
|
+
const renderer = {
|
|
33
|
+
...defaults.renderer,
|
|
34
|
+
...configuration.renderer
|
|
35
|
+
};
|
|
36
|
+
const directories = {
|
|
37
|
+
...defaults.directories,
|
|
38
|
+
...configuration.directories
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
...defaults,
|
|
42
|
+
...configuration,
|
|
43
|
+
renderer: {
|
|
44
|
+
engine: renderer.engine,
|
|
45
|
+
extension: renderer.extension,
|
|
46
|
+
},
|
|
47
|
+
directories: Object.fromEntries(Object.entries(directories)
|
|
48
|
+
.map(([property, value]) => [property, sync_1.path.join(sync_1.path.cwd(), value)])),
|
|
49
|
+
plugins: [
|
|
50
|
+
outlinecss_1.default
|
|
51
|
+
]
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
})(Configuration || (Configuration = {}));
|
|
55
|
+
exports.default = Configuration;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare enum Event {
|
|
2
|
+
END = "end"
|
|
3
|
+
}
|
|
4
|
+
export type EventSubscriber = (...args: unknown[]) => void;
|
|
5
|
+
declare class EventEmitter {
|
|
6
|
+
private readonly events;
|
|
7
|
+
on(event: Event, subscriber: EventSubscriber): void;
|
|
8
|
+
off(event: Event, listener: EventSubscriber): void;
|
|
9
|
+
emit(event: Event, ...args: unknown[]): void;
|
|
10
|
+
once(event: Event, subscriber: EventSubscriber): void;
|
|
11
|
+
removeAllListeners(event?: Event): void;
|
|
12
|
+
}
|
|
13
|
+
export default EventEmitter;
|
|
14
|
+
//# sourceMappingURL=EventEmitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventEmitter.d.ts","sourceRoot":"","sources":["EventEmitter.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK;IACb,GAAG,QAAQ;CACd;AAED,MAAM,MAAM,eAAe,GACvB,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;AAGhC,cAAM,YAAY;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAE3D,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,GAAG,IAAI;IAOnD,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI;IASlD,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM5C,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,GAAG,IAAI;IAQrD,kBAAkB,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI;CAOjD;AAGD,eAAe,YAAY,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Event = void 0;
|
|
4
|
+
var Event;
|
|
5
|
+
(function (Event) {
|
|
6
|
+
Event["END"] = "end";
|
|
7
|
+
})(Event || (exports.Event = Event = {}));
|
|
8
|
+
class EventEmitter {
|
|
9
|
+
events = new Map();
|
|
10
|
+
on(event, subscriber) {
|
|
11
|
+
if (!this.events.has(event)) {
|
|
12
|
+
this.events.set(event, []);
|
|
13
|
+
}
|
|
14
|
+
this.events.get(event).push(subscriber);
|
|
15
|
+
}
|
|
16
|
+
off(event, listener) {
|
|
17
|
+
if (this.events.has(event)) {
|
|
18
|
+
this.events.set(event, this.events.get(event).filter((l) => l !== listener));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
emit(event, ...args) {
|
|
22
|
+
if (this.events.has(event)) {
|
|
23
|
+
this.events.get(event).forEach((listener) => listener(...args));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
once(event, subscriber) {
|
|
27
|
+
const onceWrapper = (...args) => {
|
|
28
|
+
this.off(event, onceWrapper);
|
|
29
|
+
subscriber(...args);
|
|
30
|
+
};
|
|
31
|
+
this.on(event, onceWrapper);
|
|
32
|
+
}
|
|
33
|
+
removeAllListeners(event) {
|
|
34
|
+
if (event) {
|
|
35
|
+
this.events.delete(event);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this.events.clear();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = EventEmitter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Path, PathLike } from "../commons/io/sync/index";
|
|
2
|
+
export default class Page {
|
|
3
|
+
private readonly _path;
|
|
4
|
+
private readonly _content;
|
|
5
|
+
private readonly _layout;
|
|
6
|
+
private readonly _data;
|
|
7
|
+
static from(pathname: PathLike): Page;
|
|
8
|
+
constructor(pathname: PathLike, content: string, layout: string, data: Record<string, unknown>);
|
|
9
|
+
get path(): Path;
|
|
10
|
+
get content(): string;
|
|
11
|
+
get data(): Record<string, unknown>;
|
|
12
|
+
get layout(): string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=Page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["Page.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAY,iCAA+B;AAGlE,MAAM,CAAC,OAAO,OAAO,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAM;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAyB;WAEjC,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;gBAMhC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAO9F,IAAW,IAAI,IAAI,IAAI,CAEtB;IAED,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,IAAW,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzC;IAED,IAAW,MAAM,IAAI,MAAM,CAE1B;CACJ"}
|
package/lib/core/Page.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const matter = require("gray-matter");
|
|
4
|
+
const index_1 = require("../commons/io/sync/index");
|
|
5
|
+
class Page {
|
|
6
|
+
_path;
|
|
7
|
+
_content;
|
|
8
|
+
_layout;
|
|
9
|
+
_data;
|
|
10
|
+
static from(pathname) {
|
|
11
|
+
const file = index_1.fs.read(pathname);
|
|
12
|
+
const { content, data: { layout, ...data } } = matter(file.content);
|
|
13
|
+
return new Page(pathname, content, layout, data);
|
|
14
|
+
}
|
|
15
|
+
constructor(pathname, content, layout, data) {
|
|
16
|
+
this._path = index_1.path.join(pathname);
|
|
17
|
+
this._content = content;
|
|
18
|
+
this._layout = layout;
|
|
19
|
+
this._data = data;
|
|
20
|
+
}
|
|
21
|
+
get path() {
|
|
22
|
+
return this._path;
|
|
23
|
+
}
|
|
24
|
+
get content() {
|
|
25
|
+
return this._content;
|
|
26
|
+
}
|
|
27
|
+
get data() {
|
|
28
|
+
return this._data;
|
|
29
|
+
}
|
|
30
|
+
get layout() {
|
|
31
|
+
return this._layout;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.default = Page;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Configuration from "./Configuration";
|
|
2
|
+
import EventEmitter from "./EventEmitter";
|
|
3
|
+
interface Plugin {
|
|
4
|
+
name: string;
|
|
5
|
+
install(events: EventEmitter, configuration: Configuration): any;
|
|
6
|
+
}
|
|
7
|
+
export declare const Signal: () => {
|
|
8
|
+
signal: Promise<unknown>;
|
|
9
|
+
resolve: (_?: unknown) => void;
|
|
10
|
+
reject: (_?: unknown) => void;
|
|
11
|
+
};
|
|
12
|
+
export default Plugin;
|
|
13
|
+
//# sourceMappingURL=Plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["Plugin.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,wBAA4B;AAChD,OAAO,YAAY,uBAA2B;AAG9C,UAAU,MAAM;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,GAAG,GAAG,CAAA;CACnE;AAED,eAAO,MAAM,MAAM;;kBACI,OAAO,KAAG,IAAI;iBACf,OAAO,KAAG,IAAI;CAMnC,CAAA;AAGD,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Signal = void 0;
|
|
4
|
+
const Signal = () => {
|
|
5
|
+
let resolve = (_) => void 0, reject = (_) => void 0;
|
|
6
|
+
const signal = new Promise((_resolve, _reject) => {
|
|
7
|
+
resolve = _resolve;
|
|
8
|
+
reject = _reject;
|
|
9
|
+
});
|
|
10
|
+
return { signal, resolve, reject };
|
|
11
|
+
};
|
|
12
|
+
exports.Signal = Signal;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Configuration from "../Configuration";
|
|
2
|
+
import Page from "../Page";
|
|
3
|
+
export default abstract class Renderer {
|
|
4
|
+
protected readonly _configuration: Configuration;
|
|
5
|
+
constructor(configuration: Configuration);
|
|
6
|
+
abstract render(page: Page): string;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=Renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Renderer.d.ts","sourceRoot":"","sources":["Renderer.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,yBAA4B;AAChD,OAAO,IAAI,gBAAmB;AAG9B,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,QAAQ;IAClC,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAA;gBAEpC,aAAa,EAAE,aAAa;aAIxB,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;CAC7C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as Renderer } from "./Renderer";
|
|
2
|
+
import Configuration from "../Configuration";
|
|
3
|
+
import Renderer from "./Renderer";
|
|
4
|
+
declare namespace RendererFactory {
|
|
5
|
+
const from: (configuration: Configuration) => Renderer;
|
|
6
|
+
}
|
|
7
|
+
export default RendererFactory;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEhD,OAAO,aAAa,yBAA4B;AAEhD,OAAO,QAAQ,MAAM,YAAY,CAAA;AAGjC,kBAAU,eAAe,CAAC;IACf,MAAM,IAAI,GAAI,eAAe,aAAa,KAAG,QAOnD,CAAA;CACJ;AAGD,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Renderer = void 0;
|
|
4
|
+
var Renderer_1 = require("./Renderer");
|
|
5
|
+
Object.defineProperty(exports, "Renderer", { enumerable: true, get: function () { return Renderer_1.default; } });
|
|
6
|
+
const EJSRenderer_1 = require("../../renderers/EJSRenderer");
|
|
7
|
+
var RendererFactory;
|
|
8
|
+
(function (RendererFactory) {
|
|
9
|
+
RendererFactory.from = (configuration) => {
|
|
10
|
+
const { engine } = configuration.renderer;
|
|
11
|
+
switch (engine) {
|
|
12
|
+
case EJSRenderer_1.default.engine:
|
|
13
|
+
default:
|
|
14
|
+
return new EJSRenderer_1.default(configuration);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
})(RendererFactory || (RendererFactory = {}));
|
|
18
|
+
exports.default = RendererFactory;
|
package/lib/index.js
CHANGED
package/lib/main.d.ts
CHANGED
package/lib/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":"AASA,wBAAsB,IAAI,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAuBhE"}
|
package/lib/main.js
CHANGED
|
@@ -1,2 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.main = main;
|
|
4
|
+
const Configuration_1 = require("./core/Configuration");
|
|
5
|
+
const build_1 = require("./commands/build");
|
|
6
|
+
const serve_1 = require("./commands/serve");
|
|
7
|
+
const minimist = require("minimist");
|
|
8
|
+
const DEFAULT_OUTPUT = "./website-dist";
|
|
9
|
+
const DEFAULT_ENTRY = "./website";
|
|
10
|
+
async function main(...varargs) {
|
|
11
|
+
const options = minimist(varargs, {
|
|
12
|
+
alias: { o: "output", e: "entry" },
|
|
13
|
+
default: { output: DEFAULT_OUTPUT, entry: DEFAULT_ENTRY }
|
|
14
|
+
});
|
|
15
|
+
const [command] = varargs;
|
|
16
|
+
const directories = {
|
|
17
|
+
root: ".",
|
|
18
|
+
output: options.output,
|
|
19
|
+
public: `${options.entry}/public`,
|
|
20
|
+
pages: `${options.entry}/pages`,
|
|
21
|
+
styles: `${options.entry}/styles`,
|
|
22
|
+
partials: `${options.entry}/templates/partials`,
|
|
23
|
+
layouts: `${options.entry}/templates/layouts`
|
|
24
|
+
};
|
|
25
|
+
const configuration = Configuration_1.default.from({ directories });
|
|
26
|
+
switch (command) {
|
|
27
|
+
default:
|
|
28
|
+
case "build":
|
|
29
|
+
return await (0, build_1.default)(configuration);
|
|
30
|
+
case "serve":
|
|
31
|
+
return (0, serve_1.default)(configuration);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
main(...process.argv.slice(2))
|
|
35
|
+
.then(code => console.log(code))
|
|
36
|
+
.catch(error => console.log(error));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outlinecss.d.ts","sourceRoot":"","sources":["outlinecss.ts"],"names":[],"mappings":"AAAA,OAAO,MAAkB,uBAAqB;AAgB9C,QAAA,MAAM,MAAM,EAAE,MAqBb,CAAA;AAGD,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Plugin_1 = require("../core/Plugin");
|
|
4
|
+
const EventEmitter_1 = require("../core/EventEmitter");
|
|
5
|
+
const sync_1 = require("../commons/io/sync");
|
|
6
|
+
const requireFromParent = (moduleName) => {
|
|
7
|
+
try {
|
|
8
|
+
const modulePath = require.resolve(moduleName, { paths: [process.cwd()] });
|
|
9
|
+
return require(modulePath);
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
console.error(`Module "${moduleName}" not found in parent package.`);
|
|
13
|
+
throw err;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const plugin = {
|
|
17
|
+
name: "outlinecss",
|
|
18
|
+
install(emitter, configuration) {
|
|
19
|
+
const { signal, resolve } = (0, Plugin_1.Signal)();
|
|
20
|
+
emitter.on(EventEmitter_1.Event.END, async () => {
|
|
21
|
+
const { directories } = configuration;
|
|
22
|
+
const outline = requireFromParent("outlinecss");
|
|
23
|
+
if (outline) {
|
|
24
|
+
const entry = sync_1.path.join(directories.styles, "./main.scss").full;
|
|
25
|
+
const output = sync_1.path.join(directories.output, "assets", `${directories.styles.base}.css`).full;
|
|
26
|
+
const tokens = sync_1.path.join(directories.styles, "./tokens").full;
|
|
27
|
+
await outline.build({ entry, output, tokens });
|
|
28
|
+
resolve();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return signal;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.default = plugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EJSRenderer.d.ts","sourceRoot":"","sources":["EJSRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,qBAAmB;AAC9B,OAAO,QAAQ,MAAM,2BAA2B,CAAA;AAIhD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,QAAQ;IAC7C,gBAAuB,MAAM,SAAQ;IAE9B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;CA8BpC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Renderer_1 = require("../core/Renderer/Renderer");
|
|
4
|
+
const index_1 = require("../commons/io/sync/index");
|
|
5
|
+
class EJSRenderer extends Renderer_1.default {
|
|
6
|
+
static engine = "ejs";
|
|
7
|
+
render(page) {
|
|
8
|
+
const { directories, renderer } = this._configuration;
|
|
9
|
+
const ejs = require(EJSRenderer.engine);
|
|
10
|
+
const [, ext] = page.layout.split(".");
|
|
11
|
+
const layout = index_1.fs.read(index_1.path.join(directories.layouts, page.layout)
|
|
12
|
+
.replace({ ext: ext ?? renderer.extension }));
|
|
13
|
+
const include = (pathname, data) => {
|
|
14
|
+
const [, ext] = pathname.split(".");
|
|
15
|
+
const file = index_1.fs.read(index_1.path.join(directories.partials, pathname)
|
|
16
|
+
.replace({ ext: ext ?? renderer.extension }));
|
|
17
|
+
return ejs.render(file.content, { ...page.data, ...data, include });
|
|
18
|
+
};
|
|
19
|
+
return ejs.render(layout.content, {
|
|
20
|
+
title: page.data.title ?? "",
|
|
21
|
+
body: ejs.render(page.content, { ...page.data, include }, {
|
|
22
|
+
views: [
|
|
23
|
+
String(directories.partials)
|
|
24
|
+
]
|
|
25
|
+
}),
|
|
26
|
+
include
|
|
27
|
+
}, {
|
|
28
|
+
views: [
|
|
29
|
+
String(directories.partials)
|
|
30
|
+
]
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.default = EJSRenderer;
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webanvil",
|
|
3
3
|
"description": "A zero configuration static site generator that just works.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"bin": {
|
|
8
8
|
"webanvil": "bin/run"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"
|
|
12
|
-
"build
|
|
13
|
-
"build:
|
|
11
|
+
"serve:website": "npx webanvil serve",
|
|
12
|
+
"build": "npm run build:library && npm run build:website",
|
|
13
|
+
"build:library": "npm run clean && tsc --build",
|
|
14
|
+
"build:website": "npx webanvil",
|
|
14
15
|
"clean": "tsc --build --clean",
|
|
15
16
|
"preprepare": "ts-patch install",
|
|
16
17
|
"prepack": "npm run build"
|
|
@@ -18,17 +19,20 @@
|
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"browser-sync": "^3.0.3",
|
|
20
21
|
"gray-matter": "^4.0.3",
|
|
22
|
+
"minimist": "^1.2.8",
|
|
21
23
|
"rollup": "^4.34.6"
|
|
22
24
|
},
|
|
23
25
|
"devDependencies": {
|
|
24
26
|
"@open-wc/rollup-plugin-html": "^1.2.5",
|
|
25
27
|
"@types/browser-sync": "^2.29.0",
|
|
28
|
+
"@types/minimist": "^1.2.5",
|
|
26
29
|
"@types/node": "^22.4.0",
|
|
27
30
|
"ejs": "^3.1.10",
|
|
28
31
|
"ts-patch": "^3.2.1",
|
|
29
32
|
"tslib": "^2.6.3",
|
|
30
33
|
"typescript": "^5.5.4",
|
|
31
|
-
"typescript-transform-paths": "^3.4.11"
|
|
34
|
+
"typescript-transform-paths": "^3.4.11",
|
|
35
|
+
"webanvil": "^0.0.1"
|
|
32
36
|
},
|
|
33
37
|
"author": "Mateusz Pietrzak",
|
|
34
38
|
"license": "MIT",
|