vowel 0.1.2 → 0.1.3
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/.cache.json +1 -0
- package/bin.js +48 -3
- package/package.json +5 -1
- package/server.js +6 -5
- package/src/lib/components/Frontmatter.svelte +0 -2
- package/src/lib/components/FrontmatterProperty.svelte +0 -2
- package/src/lib/components/Markdown/Image.svelte +2 -2
- package/src/lib/components/Page.svelte +0 -2
- package/src/lib/utilities/mutateMarkdownAST.js +1 -1
- package/src/lib/utilities/mutateMarkdownFrontmatter.js +1 -1
- package/src/lib/utilities/processMarkdownFiles.js +7 -2
- package/src/routes/[...path]/+layout.server.js +5 -5
- package/svelte.config.js +8 -3
- package/vite.config.js +4 -2
package/.cache.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
package/bin.js
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
import { execSync, spawn } from 'child_process';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import url from 'node:url';
|
|
6
|
+
import pc from 'picocolors';
|
|
7
|
+
import mri from 'mri';
|
|
8
|
+
import filterConsole from 'filter-console';
|
|
9
|
+
import process from 'process';
|
|
10
|
+
import readline from 'readline';
|
|
11
|
+
import logUpdate from 'log-update';
|
|
12
|
+
|
|
13
|
+
const args = mri(process.argv);
|
|
6
14
|
|
|
7
15
|
// Directory where the module is
|
|
8
16
|
const binURL = import.meta.url;
|
|
@@ -12,17 +20,54 @@ const binDirName = path.dirname(binFilePath);
|
|
|
12
20
|
// Directory where the command was called
|
|
13
21
|
const homeDir = process.cwd();
|
|
14
22
|
|
|
23
|
+
const spawnArgs = ['./server.js', '--directory', homeDir];
|
|
24
|
+
if (args.build) spawnArgs.push('--build');
|
|
25
|
+
|
|
26
|
+
if (!args.verbose) {
|
|
27
|
+
filterConsole(['jsconfig', 'vite', 'Vite', 'tsconfig', `--host`]);
|
|
28
|
+
console.log(`\n\n`);
|
|
29
|
+
}
|
|
30
|
+
|
|
15
31
|
// Args: File to run, home directory,
|
|
16
|
-
const child = spawn('node',
|
|
32
|
+
const child = spawn('node', spawnArgs, {
|
|
17
33
|
cwd: binDirName
|
|
18
34
|
});
|
|
19
35
|
|
|
36
|
+
let processedFiles = 0;
|
|
37
|
+
let foundFiles = 0;
|
|
38
|
+
const std = process.stdout;
|
|
39
|
+
|
|
20
40
|
child.stdout.on('data', (data) => {
|
|
21
|
-
|
|
41
|
+
const message = data.toString();
|
|
42
|
+
if (message.match('fileread')) {
|
|
43
|
+
processedFiles++;
|
|
44
|
+
logUpdate(pc.green(` Files read: ${processedFiles}/${foundFiles}`));
|
|
45
|
+
} else if (message.startsWith('filesfound')) {
|
|
46
|
+
const count = Number(message.split(':').at(-1).slice(0, -1));
|
|
47
|
+
foundFiles += count;
|
|
48
|
+
} else if (message.startsWith('loaded')) {
|
|
49
|
+
logUpdate(pc.green(` Files read: ${foundFiles}/${foundFiles}`));
|
|
50
|
+
console.log(`\n\n`);
|
|
51
|
+
processedFiles = 0;
|
|
52
|
+
foundFiles = 0;
|
|
53
|
+
} else if (message.match('http://localhost:')) {
|
|
54
|
+
const url = message.match(/http:\/\/localhost:\S+/);
|
|
55
|
+
console.log(
|
|
56
|
+
pc.bgCyan(
|
|
57
|
+
pc.bold(`
|
|
58
|
+
|
|
59
|
+
Website: ${url}
|
|
60
|
+
`)
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
console.log(`\n`);
|
|
64
|
+
} else {
|
|
65
|
+
console.log(pc.blue(data));
|
|
66
|
+
}
|
|
22
67
|
});
|
|
23
68
|
|
|
24
69
|
child.stderr.on('data', (data) => {
|
|
25
|
-
console.error(
|
|
70
|
+
console.error(pc.red(data));
|
|
26
71
|
});
|
|
27
72
|
|
|
28
73
|
child.on('close', (code) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vowel",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"bin": "./bin.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -20,10 +20,14 @@
|
|
|
20
20
|
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.3",
|
|
21
21
|
"any-date-parser": "^1.5.4",
|
|
22
22
|
"change-case": "^5.4.1",
|
|
23
|
+
"filter-console": "^1.0.0",
|
|
23
24
|
"js-yaml": "^4.1.0",
|
|
25
|
+
"loading-cli": "^1.1.2",
|
|
26
|
+
"log-update": "^6.0.0",
|
|
24
27
|
"milligram": "^1.4.1",
|
|
25
28
|
"object-path": "^0.11.8",
|
|
26
29
|
"open-props": "^1.6.13",
|
|
30
|
+
"picocolors": "^1.0.1",
|
|
27
31
|
"prettier": "^3.0.0",
|
|
28
32
|
"prettier-plugin-svelte": "^3.0.0",
|
|
29
33
|
"remark": "^15.0.1",
|
package/server.js
CHANGED
|
@@ -3,17 +3,18 @@ import { createServer, build } from 'vite';
|
|
|
3
3
|
import { writeFile, mkdir, readFile } from 'fs/promises';
|
|
4
4
|
import { existsSync } from 'fs';
|
|
5
5
|
import { dirname, join } from 'path';
|
|
6
|
+
import mri from 'mri';
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
+
const args = mri(process.argv);
|
|
9
|
+
const { build: isBuild, directory } = args;
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
const isBuild = process.argv[2] === 'build';
|
|
11
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
11
12
|
|
|
12
13
|
// If this is not a build, read the process argument
|
|
13
14
|
const arg = !isBuild ? process.argv[2] : false;
|
|
14
15
|
|
|
15
16
|
// Check if this is a user (process argument) or package dev (cwd)
|
|
16
|
-
const $home =
|
|
17
|
+
const $home = isBuild ? join(process.cwd(), 'content') : directory;
|
|
17
18
|
|
|
18
19
|
const define = {
|
|
19
20
|
$home
|
|
@@ -73,7 +74,7 @@ async function runServer() {
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
// If build mode
|
|
76
|
-
if (isBuild
|
|
77
|
+
if (isBuild) {
|
|
77
78
|
buildProject();
|
|
78
79
|
} else {
|
|
79
80
|
runServer();
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
let { page, content = true, link, level = 0, website = {}, format = 'html' } = $props();
|
|
6
6
|
let { ast, title, date, image, imputedProperties } = $derived(page || {});
|
|
7
7
|
|
|
8
|
-
console.log(`Page format: ${format}`);
|
|
9
|
-
|
|
10
8
|
const dateObject = date?.type === 'date' && new Date(date.output);
|
|
11
9
|
// TODO: Add conditional logic for format = 'xml'
|
|
12
10
|
</script>
|
|
@@ -37,7 +37,7 @@ export default async function mutateMarkdownAST(ast, cache) {
|
|
|
37
37
|
delete node.children;
|
|
38
38
|
} catch (error) {
|
|
39
39
|
node.value = url;
|
|
40
|
-
console.log(`Error on URL in content: ${url}`);
|
|
40
|
+
// console.log(`Error on URL in content: ${url}`);
|
|
41
41
|
}
|
|
42
42
|
} else {
|
|
43
43
|
node.metadata = cache[node.value];
|
|
@@ -89,7 +89,7 @@ export default async function mutateMarkdownFrontmatter(frontmatter, cache) {
|
|
|
89
89
|
input
|
|
90
90
|
};
|
|
91
91
|
} catch (e) {
|
|
92
|
-
console.error(`Error on URL in frontmatter: ${frontmatter[key]}`);
|
|
92
|
+
// console.error(`Error on URL in frontmatter: ${frontmatter[key]}`);
|
|
93
93
|
frontmatter[key] = {
|
|
94
94
|
type: 'string',
|
|
95
95
|
output: input,
|
|
@@ -103,6 +103,8 @@ async function readFolder(folderPath, parents, cache) {
|
|
|
103
103
|
|
|
104
104
|
let files = (await fs.readdir(folderPath, { withFileTypes: true })).filter(filterFiles);
|
|
105
105
|
|
|
106
|
+
console.log(`filesfound:${files.length}`);
|
|
107
|
+
|
|
106
108
|
const promises = files.map(async (file) => await readFile(file, parents, cache, folderPath));
|
|
107
109
|
|
|
108
110
|
const folder = (await Promise.all(promises)).reduce((acc, obj) => ({ ...acc, ...obj }), {});
|
|
@@ -134,7 +136,8 @@ async function readFile(file, parents, cache, folderPath) {
|
|
|
134
136
|
|
|
135
137
|
const { ast, frontmatter, imputedProperties } = await readMarkdownFile(filePath, cache);
|
|
136
138
|
const loadTime = (performance.now() - startLoad).toFixed(2);
|
|
137
|
-
console.log(`📄 ${shortPath} (${loadTime}ms)`);
|
|
139
|
+
// console.log(`📄 ${shortPath} (${loadTime}ms)`);
|
|
140
|
+
console.log('fileread');
|
|
138
141
|
if (frontmatter.published == false) return;
|
|
139
142
|
if (file.name === 'home.md' || file.name === 'settings.md') {
|
|
140
143
|
const key = file.name === 'home.md' ? '$' : '_';
|
|
@@ -173,7 +176,7 @@ async function readFile(file, parents, cache, folderPath) {
|
|
|
173
176
|
const folder = await readFolder(path.join(folderPath, file.name), url, cache);
|
|
174
177
|
|
|
175
178
|
const loadTime = (performance.now() - startLoad).toFixed(2);
|
|
176
|
-
console.log(`📁 ${shortPath} (${loadTime}ms)`);
|
|
179
|
+
// console.log(`📁 ${shortPath} (${loadTime}ms)`);
|
|
177
180
|
|
|
178
181
|
if (!folder.hasOwnProperty('$')) {
|
|
179
182
|
const $ = DefaultFile(url);
|
|
@@ -208,5 +211,7 @@ export default async function processMarkdownFiles(cache) {
|
|
|
208
211
|
const [homeDir] = $home;
|
|
209
212
|
const folder = await readFolder(homeDir, '', cache);
|
|
210
213
|
|
|
214
|
+
console.log('loaded');
|
|
215
|
+
|
|
211
216
|
return { folder, finalCache: cache };
|
|
212
217
|
}
|
|
@@ -22,15 +22,15 @@ async function checkFileExists(filePath, homeDir) {
|
|
|
22
22
|
|
|
23
23
|
/** @type {import('./$types').PageLoad} */
|
|
24
24
|
export async function load() {
|
|
25
|
-
const startLoad = performance.now();
|
|
25
|
+
// const startLoad = performance.now();
|
|
26
26
|
const now = Date.now();
|
|
27
27
|
const contentCacheDuration = 60000; // Cache for 1 minute
|
|
28
28
|
const initialURLCache = await loadCache($home[0]);
|
|
29
29
|
|
|
30
30
|
const cssExists = await checkFileExists(normalize('/assets/styles.css'), $home[0]);
|
|
31
31
|
|
|
32
|
-
if (cssExists) console.log('Found CSS file at /assets/styles.css');
|
|
33
|
-
else console.log('No CSS file found as /assets/styles.css');
|
|
32
|
+
// if (cssExists) console.log('Found CSS file at /assets/styles.css');
|
|
33
|
+
// else console.log('No CSS file found as /assets/styles.css');
|
|
34
34
|
|
|
35
35
|
const faviconExists = await checkFileExists(normalize('/assets/favicon.png'), $home[0]);
|
|
36
36
|
|
|
@@ -51,7 +51,7 @@ export async function load() {
|
|
|
51
51
|
console.log('Using content cache');
|
|
52
52
|
data = contentCache;
|
|
53
53
|
} else {
|
|
54
|
-
console.log('Not using content cache');
|
|
54
|
+
// console.log('Not using content cache');
|
|
55
55
|
data = await processMarkdownFiles(initialURLCache);
|
|
56
56
|
contentCache = data;
|
|
57
57
|
contentCacheTime = now;
|
|
@@ -64,7 +64,7 @@ export async function load() {
|
|
|
64
64
|
writeCache(finalCache, $home[0]);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
console.log(`Load time: ${(performance.now() - startLoad).toFixed(2)} ms`);
|
|
67
|
+
// console.log(`Load time: ${(performance.now() - startLoad).toFixed(2)} ms`);
|
|
68
68
|
|
|
69
69
|
const folderName = basename($home[0]);
|
|
70
70
|
|
package/svelte.config.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import adapter from '@sveltejs/adapter-static';
|
|
2
2
|
import path, { join } from 'path';
|
|
3
|
+
import mri from 'mri';
|
|
4
|
+
|
|
5
|
+
const args = mri(process.argv);
|
|
6
|
+
|
|
7
|
+
const isDev = args._.includes('dev');
|
|
3
8
|
|
|
4
9
|
const demoDir = process.cwd() + '/content';
|
|
5
|
-
const NPMRunDev = process.argv[2] === 'dev';
|
|
6
|
-
const isBuild = process.argv[2] === 'build';
|
|
7
|
-
const receivedHomePath =
|
|
10
|
+
// const NPMRunDev = process.argv[2] === 'dev';
|
|
11
|
+
// const isBuild = process.argv[2] === 'build';
|
|
12
|
+
const receivedHomePath = isDev || args.build ? false : args.directory;
|
|
8
13
|
const homeDir = receivedHomePath || demoDir;
|
|
9
14
|
const relativePathToHome = path.relative(process.cwd(), homeDir);
|
|
10
15
|
|
package/vite.config.js
CHANGED
|
@@ -2,11 +2,14 @@ import { sveltekit } from '@sveltejs/kit/vite';
|
|
|
2
2
|
import { defineConfig } from 'vite';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { readMarkdownFile, loadCache } from './src/lib/utilities/index';
|
|
5
|
+
import mri from 'mri';
|
|
6
|
+
|
|
7
|
+
const args = mri(process.argv);
|
|
5
8
|
|
|
6
9
|
const demoDir = process.cwd() + '/content';
|
|
7
10
|
const NPMRunDev = process.argv[2] === 'dev';
|
|
8
11
|
const isBuild = process.argv[2] === 'build';
|
|
9
|
-
const receivedHomePath = NPMRunDev || isBuild ? false :
|
|
12
|
+
const receivedHomePath = NPMRunDev || isBuild ? false : args.directory;
|
|
10
13
|
|
|
11
14
|
const homeDir = receivedHomePath || demoDir;
|
|
12
15
|
|
|
@@ -19,7 +22,6 @@ export default defineConfig({
|
|
|
19
22
|
// Hot reload markdown
|
|
20
23
|
name: 'markdown:watch',
|
|
21
24
|
configureServer(server) {
|
|
22
|
-
console.log(`Root directory: ${homeDir}`);
|
|
23
25
|
server.watcher.add(homeDir);
|
|
24
26
|
server.watcher.on('change', async (homePath, stats) => {
|
|
25
27
|
if (homePath.endsWith('.md')) {
|