Skip to content

Commit

Permalink
chore(script): import KnoSys
Browse files Browse the repository at this point in the history
  • Loading branch information
ourai committed Apr 11, 2024
1 parent 23a990e commit 5610e0f
Show file tree
Hide file tree
Showing 10 changed files with 334 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .knosysrc → .knosys/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"command": "./bin",
"command": "./.knosys/scripts",
"site": {
"default": {
"alias": "lime",
Expand Down
5 changes: 2 additions & 3 deletions bin/build.js → .knosys/scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const { resolve: resolvePath } = require('path');
const { pick } = require('@ntks/toolbox');

const { ensureDirExists, copyFileDeeply, rm, cp, saveData, execute, copyThemeAssets } = require('./helper');
const { resolveRootPath, ensureDirExists, copyFileDeeply, rm, cp, saveData, execute, copyThemeAssets } = require('./helper');

const prjRoot = resolvePath(__dirname, '..');
const prjRoot = resolveRootPath();
const srcRoot = `${prjRoot}/src`;
const distRoot = `${prjRoot}/dist`;

Expand Down
2 changes: 1 addition & 1 deletion bin/copy.js → .knosys/scripts/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { copyThemeAssets } = require('./helper');

module.exports = {
execute: (type = 'jekyll') => {
const srcRoot = resolvePath(__dirname, '../src');
const srcRoot = resolvePath(__dirname, '../../src');

if (type === 'jekyll') {
return copyThemeAssets(`${srcRoot}/jekyll/_assets`);
Expand Down
2 changes: 1 addition & 1 deletion bin/deploy.js → .knosys/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { execSync } = require('child_process');

const { rm, execute } = require('./helper');

const prjRoot = resolvePath(__dirname, '..');
const prjRoot = resolvePath(__dirname, '../..');
const distRoot = `${prjRoot}/dist`;

function zipTheme(dirName) {
Expand Down
9 changes: 3 additions & 6 deletions bin/helper.js → .knosys/scripts/helper/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
const { resolve: resolvePath } = require('path');
const { readFileSync } = require('fs');
const knosysUtils = require('./knosys');

const rootPath = resolvePath(__dirname, '..');
const knosysUtils = require(resolvePath(rootPath, JSON.parse(readFileSync(resolvePath(rootPath, '.knosysrc'), 'utf8').toString().trim()).$path));
const { ensureDirExists, copyFileDeeply, readData, saveData } = knosysUtils;
const { resolveRootPath, ensureDirExists, copyFileDeeply, readData, saveData } = knosysUtils;

function copyThemeAssets(distRoot, polyfill) {
['fonts', 'images', 'javascripts', 'stylesheets'].forEach(dirName => {
const assetsPath = `${distRoot}/${dirName}`;

ensureDirExists(assetsPath);

const srcPath = `${rootPath}/src/shared/${dirName}`;
const srcPath = `${resolveRootPath()}/src/shared/${dirName}`;
const distPath = `${distRoot}/${dirName}/ksio`;

ensureDirExists(distPath, true);
Expand Down
1 change: 1 addition & 0 deletions .knosys/scripts/helper/knosys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { ...require('@knosys/sdk'), ...require('ksio') };
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/serve.js → .knosys/scripts/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { execute } = require('./helper');
module.exports = {
execute: (type = 'jekyll') => {
if (type === 'hexo') {
return execSync('npm run server', { cwd: resolvePath(__dirname, '../src/hexo'), stdio: 'inherit' });
return execSync('npm run server', { cwd: resolvePath(__dirname, '../../src/hexo'), stdio: 'inherit' });
}

execute('site', 'serve');
Expand Down
318 changes: 318 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5610e0f

Please sign in to comment.