-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
80 lines (59 loc) · 2.2 KB
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const { pick } = require('@ntks/toolbox');
const { resolveRootPath, ensureDirExists, copyFileDeeply, rm, cp, saveData, execute, copyThemeAssets } = require('./helper');
const prjRoot = resolveRootPath();
const srcRoot = `${prjRoot}/src`;
const distRoot = `${prjRoot}/dist`;
function copyMetaFiles(dirName) {
const distDir = `${distRoot}/${dirName}`;
const readmeTemplate = `# [Lime](https://ourai.github.io/lime/)
A simple, readable, responsive theme that:
- audience experience first design
- born for blogs, personal websites and API docs
- supports most of PC and mobile modern web browsers
## Getting Started
Please follow the documentation [on the website](https://ourai.github.io/lime/).
`;
saveData(`${distDir}/README.md`, readmeTemplate);
cp(`${prjRoot}/CHANGELOG.md`, `${distDir}/`);
}
function copyJekyllFiles() {
const jekyllSrcRoot = `${srcRoot}/jekyll`;
const jekyllDistRoot = `${distRoot}/jekyll`;
ensureDirExists(jekyllDistRoot, true);
['_includes', '_layouts'].forEach(dirName => {
const distPath = `${jekyllDistRoot}/${dirName}/ksio`;
ensureDirExists(distPath, true);
copyFileDeeply(`${jekyllSrcRoot}/${dirName}/ksio`, distPath);
});
copyThemeAssets(`${jekyllDistRoot}/_assets`);
copyMetaFiles('jekyll');
}
function copyHexoFiles() {
const hexoSrcRoot = `${srcRoot}/hexo/themes/lime`;
const hexoDistRoot = `${distRoot}/hexo`;
ensureDirExists(hexoDistRoot, true);
copyFileDeeply(hexoSrcRoot, hexoDistRoot, ['source']);
rm(`${hexoDistRoot}/*/_local`);
copyThemeAssets(`${hexoDistRoot}/source`, true);
const pkgFields = pick(require(`${prjRoot}/package.json`), ['version', 'description', 'repository', 'author', 'license', 'bugs', 'homepage', 'dependencies', 'peerDependencies']);
saveData(`${hexoDistRoot}/package.json`, JSON.stringify({
name: 'hexo-theme-lime',
main: 'package.json',
keywords: ['hexo', 'theme', 'lime', 'knosys', 'ksio'],
...pkgFields,
}, null, 2));
copyMetaFiles('hexo');
}
module.exports = {
execute: (type = 'doc') => {
if (type === 'doc') {
return execute('generate');
}
if (type === 'jekyll') {
return copyJekyllFiles();
}
if (type === 'hexo') {
return copyHexoFiles();
}
},
};