@o2b/meta 1.0.0-dev.5 → 1.0.0-dev.7
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/dist/cli.js +104 -97
- package/dist/cli.js.map +1 -1
- package/dist/index.d.mts +41 -117
- package/dist/index.d.ts +41 -117
- package/dist/index.js +133 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -84
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -12,30 +12,38 @@ var frontmatter = z2.object({
|
|
|
12
12
|
description: z2.string(),
|
|
13
13
|
last_modified: z2.string()
|
|
14
14
|
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
15
|
+
var baseNode = z2.object({
|
|
16
|
+
path: relPath,
|
|
17
|
+
name: z2.string()
|
|
18
|
+
});
|
|
19
|
+
var fileNode = baseNode.extend({
|
|
20
|
+
type: z2.literal("file"),
|
|
21
|
+
frontmatter
|
|
22
|
+
});
|
|
23
|
+
var dirNode = baseNode.extend({
|
|
24
|
+
type: z2.literal("dir"),
|
|
25
|
+
files: z2.array(fileNode),
|
|
26
|
+
dirs: z2.lazy(() => dirNode.array())
|
|
27
|
+
});
|
|
28
|
+
var fileTree = z2.union([dirNode, fileNode]);
|
|
29
|
+
var id = z2.number().int();
|
|
30
|
+
var normedFileNode = fileNode.extend({
|
|
31
|
+
id
|
|
32
|
+
});
|
|
33
|
+
var normedDirNode = baseNode.extend({
|
|
34
|
+
id,
|
|
35
|
+
type: z2.literal("dir"),
|
|
36
|
+
files: z2.array(id),
|
|
37
|
+
dirs: z2.array(id)
|
|
38
|
+
});
|
|
39
|
+
var normedFileTree = z2.object({
|
|
40
|
+
id,
|
|
41
|
+
files: z2.array(id),
|
|
42
|
+
dirs: z2.lazy(() => z2.array(normedFileTree))
|
|
43
|
+
});
|
|
36
44
|
|
|
37
45
|
// src/core/sync/mirror.ts
|
|
38
|
-
import { copyFileSync, existsSync, mkdirSync
|
|
46
|
+
import { copyFileSync, existsSync, mkdirSync } from "fs";
|
|
39
47
|
import { join } from "path";
|
|
40
48
|
function mirror(filetree, srcPath, destPath) {
|
|
41
49
|
function aux(filetree2) {
|
|
@@ -55,23 +63,13 @@ function mirror(filetree, srcPath, destPath) {
|
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
65
|
aux(filetree);
|
|
58
|
-
generateFileTree(filetree, destPath);
|
|
59
|
-
}
|
|
60
|
-
function generateFileTree(filetree, destPath) {
|
|
61
|
-
const jsonFilePath = join(destPath, "o2bFileTree.json");
|
|
62
|
-
writeFileSync(jsonFilePath, JSON.stringify(filetree, null, 2), "utf-8");
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
// src/core/sync/scan.ts
|
|
66
|
-
import { lstatSync as
|
|
67
|
-
import { basename, join as
|
|
69
|
+
import { lstatSync as lstatSync2, readdirSync as readdirSync2, readFileSync } from "fs";
|
|
70
|
+
import { basename, join as join2 } from "path";
|
|
68
71
|
import matter from "gray-matter";
|
|
69
72
|
|
|
70
|
-
// src/utils/ignore.ts
|
|
71
|
-
import { existsSync as existsSync2, lstatSync as lstatSync2, readFileSync } from "fs";
|
|
72
|
-
import { join as join2 } from "path";
|
|
73
|
-
import ignore from "ignore";
|
|
74
|
-
|
|
75
73
|
// src/utils/path.ts
|
|
76
74
|
import { lstatSync, readdirSync } from "fs";
|
|
77
75
|
import { isAbsolute, relative, resolve } from "path";
|
|
@@ -90,79 +88,121 @@ function isObsidianDirectory(path) {
|
|
|
90
88
|
return true;
|
|
91
89
|
}
|
|
92
90
|
|
|
93
|
-
// src/utils/ignore.ts
|
|
94
|
-
var VaultIgnorer = class {
|
|
95
|
-
ign;
|
|
96
|
-
rootPath;
|
|
97
|
-
constructor(rootPath) {
|
|
98
|
-
this.rootPath = rootPath;
|
|
99
|
-
this.ign = ignore();
|
|
100
|
-
this.ign.add([".*"]);
|
|
101
|
-
}
|
|
102
|
-
load() {
|
|
103
|
-
const ignorePath = join2(this.rootPath, ".o2bignore");
|
|
104
|
-
if (existsSync2(ignorePath))
|
|
105
|
-
this.ign.add(readFileSync(ignorePath).toString());
|
|
106
|
-
}
|
|
107
|
-
ignore(path) {
|
|
108
|
-
if (path === this.rootPath) return false;
|
|
109
|
-
if (!existsSync2(path)) throw new Error("somethings wrong!");
|
|
110
|
-
const stat = lstatSync2(path);
|
|
111
|
-
const relPath2 = toRelPath(this.rootPath, path) + (stat.isDirectory() ? "/" : "");
|
|
112
|
-
return this.ign.ignores(relPath2);
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
91
|
// src/core/sync/scan.ts
|
|
117
92
|
function scan(rootPath, ign) {
|
|
118
93
|
function aux(path) {
|
|
119
94
|
if (ign == null ? void 0 : ign.ignore(path)) return null;
|
|
120
|
-
const stat =
|
|
95
|
+
const stat = lstatSync2(path);
|
|
121
96
|
const name = basename(path);
|
|
122
|
-
if (stat.
|
|
123
|
-
const { dirs, files } = readdirSync2(path).reduce(
|
|
124
|
-
(acc, entry) => {
|
|
125
|
-
const node = aux(toAbsPath(join3(path, entry)));
|
|
126
|
-
if ((node == null ? void 0 : node.type) === "dir") acc.dirs.push(node);
|
|
127
|
-
if ((node == null ? void 0 : node.type) === "file") acc.files.push(node);
|
|
128
|
-
return acc;
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
dirs: [],
|
|
132
|
-
files: []
|
|
133
|
-
}
|
|
134
|
-
);
|
|
97
|
+
if (stat.isFile() && name.endsWith(".md")) {
|
|
135
98
|
return {
|
|
136
99
|
path: toRelPath(rootPath, path),
|
|
137
100
|
name,
|
|
138
|
-
type: "
|
|
139
|
-
|
|
140
|
-
files
|
|
101
|
+
type: "file",
|
|
102
|
+
frontmatter: fetchFrontmatter(path, stat.mtime)
|
|
141
103
|
};
|
|
142
104
|
}
|
|
143
|
-
if (stat.
|
|
105
|
+
if (stat.isDirectory()) {
|
|
106
|
+
const dirs = [];
|
|
107
|
+
const files = [];
|
|
108
|
+
const entries = readdirSync2(path);
|
|
109
|
+
for (const entry of entries) {
|
|
110
|
+
const fullPath = toAbsPath(join2(path, entry));
|
|
111
|
+
const node = aux(fullPath);
|
|
112
|
+
if ((node == null ? void 0 : node.type) === "dir") dirs.push(node);
|
|
113
|
+
if ((node == null ? void 0 : node.type) === "file") files.push(node);
|
|
114
|
+
}
|
|
144
115
|
return {
|
|
145
116
|
path: toRelPath(rootPath, path),
|
|
146
117
|
name,
|
|
147
|
-
type: "
|
|
148
|
-
|
|
118
|
+
type: "dir",
|
|
119
|
+
dirs,
|
|
120
|
+
files
|
|
149
121
|
};
|
|
150
122
|
}
|
|
151
123
|
return null;
|
|
152
124
|
}
|
|
153
125
|
return aux(rootPath);
|
|
154
126
|
}
|
|
155
|
-
function
|
|
156
|
-
const { data
|
|
127
|
+
function fetchFrontmatter(path, mtime) {
|
|
128
|
+
const { data } = matter(readFileSync(path, "utf-8"));
|
|
157
129
|
return {
|
|
158
130
|
title: basename(path).replace(/\.md$/, ""),
|
|
159
131
|
description: "No description provided.",
|
|
160
|
-
last_modified:
|
|
161
|
-
|
|
162
|
-
...srcFrontmatter
|
|
132
|
+
last_modified: mtime.toISOString().split("T")[0],
|
|
133
|
+
...data
|
|
163
134
|
};
|
|
164
135
|
}
|
|
165
136
|
|
|
137
|
+
// src/utils/id.ts
|
|
138
|
+
var idCounter = (start = 0) => {
|
|
139
|
+
let count = start;
|
|
140
|
+
return () => count++;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// src/core/sync/normalize.ts
|
|
144
|
+
function normalize(fileTree2) {
|
|
145
|
+
const dirNodes = [];
|
|
146
|
+
const fileNodes = [];
|
|
147
|
+
const fileId = idCounter();
|
|
148
|
+
const dirId = idCounter();
|
|
149
|
+
function aux(dir) {
|
|
150
|
+
const id2 = dirId();
|
|
151
|
+
const files = dir.files.map((file) => {
|
|
152
|
+
const id3 = fileId();
|
|
153
|
+
fileNodes.push({ id: id3, ...file });
|
|
154
|
+
return id3;
|
|
155
|
+
});
|
|
156
|
+
const dirs = dir.dirs.map((dir2) => aux(dir2));
|
|
157
|
+
dirNodes.push({ ...dir, id: id2, files, dirs: dirs.map((dir2) => dir2.id) });
|
|
158
|
+
return {
|
|
159
|
+
id: id2,
|
|
160
|
+
files,
|
|
161
|
+
dirs
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
const normedFileTree2 = aux(fileTree2);
|
|
165
|
+
return {
|
|
166
|
+
dirNodes,
|
|
167
|
+
fileNodes,
|
|
168
|
+
fileTree: normedFileTree2
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// src/utils/file.ts
|
|
173
|
+
import { writeFileSync as writeFileSync2 } from "fs";
|
|
174
|
+
import { join as join3 } from "path";
|
|
175
|
+
function generateJson(content, name, destPath) {
|
|
176
|
+
const jsonFilePath = join3(destPath, `${name}.json`);
|
|
177
|
+
writeFileSync2(jsonFilePath, JSON.stringify(content, null, 2), "utf-8");
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// src/utils/ignore.ts
|
|
181
|
+
import { existsSync as existsSync2, lstatSync as lstatSync3, readFileSync as readFileSync2 } from "fs";
|
|
182
|
+
import { join as join4 } from "path";
|
|
183
|
+
import ignore from "ignore";
|
|
184
|
+
var VaultIgnorer = class {
|
|
185
|
+
ign;
|
|
186
|
+
rootPath;
|
|
187
|
+
constructor(rootPath) {
|
|
188
|
+
this.rootPath = rootPath;
|
|
189
|
+
this.ign = ignore();
|
|
190
|
+
this.ign.add([".*"]);
|
|
191
|
+
}
|
|
192
|
+
load() {
|
|
193
|
+
const ignorePath = join4(this.rootPath, ".o2bignore");
|
|
194
|
+
if (existsSync2(ignorePath))
|
|
195
|
+
this.ign.add(readFileSync2(ignorePath).toString());
|
|
196
|
+
}
|
|
197
|
+
ignore(path) {
|
|
198
|
+
if (path === this.rootPath) return false;
|
|
199
|
+
if (!existsSync2(path)) throw new Error("somethings wrong!");
|
|
200
|
+
const stat = lstatSync3(path);
|
|
201
|
+
const relPath2 = toRelPath(this.rootPath, path) + (stat.isDirectory() ? "/" : "");
|
|
202
|
+
return this.ign.ignores(relPath2);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
166
206
|
// src/runO2B.ts
|
|
167
207
|
function runO2B(config) {
|
|
168
208
|
const { srcPath, destPath, ignore: ignore2 } = config;
|
|
@@ -171,11 +211,17 @@ function runO2B(config) {
|
|
|
171
211
|
if (ignore2) ign.load();
|
|
172
212
|
const fileTree2 = scan(srcPath, ign);
|
|
173
213
|
if (fileTree2 === null) throw new Error("No content in vault");
|
|
214
|
+
if (fileTree2.type !== "dir") throw new Error("No Vault?!");
|
|
174
215
|
mirror(fileTree2, srcPath, destPath);
|
|
216
|
+
const { fileTree: normedFileTree2, dirNodes, fileNodes } = normalize(fileTree2);
|
|
217
|
+
generateJson(normedFileTree2, "fileTree", destPath);
|
|
218
|
+
generateJson(dirNodes, "dirNodes", destPath);
|
|
219
|
+
generateJson(fileNodes, "fileNodes", destPath);
|
|
175
220
|
}
|
|
176
221
|
export {
|
|
177
222
|
runO2B as default,
|
|
178
|
-
|
|
179
|
-
|
|
223
|
+
normedDirNode as dirNodeSchema,
|
|
224
|
+
normedFileNode as fileNodeScheam,
|
|
225
|
+
normedFileTree as fileTreeSchema
|
|
180
226
|
};
|
|
181
227
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/filetree.ts","../src/types/path.ts","../src/core/sync/mirror.ts","../src/core/sync/scan.ts","../src/utils/ignore.ts","../src/utils/path.ts","../src/runO2B.ts"],"sourcesContent":["import z from \"zod\";\nimport { relPath, type RelPath } from \"./path\";\n\nconst frontmatter = z.object({\n title: z.string(),\n description: z.string(),\n last_modified: z.string(),\n});\n\nfunction createFileTreeSchema<P extends typeof relPath | z.ZodString>(path: P) {\n type BaseNode = z.infer<typeof baseNode>;\n const baseNode = z.object({\n path,\n name: z.string(),\n });\n\n type FileNodeOutput = z.infer<typeof fileNode>;\n type FileNodeInput = z.input<typeof fileNode>;\n const fileNode = baseNode.extend({\n type: z.literal(\"file\"),\n frontmatter: frontmatter,\n });\n\n // https://v3.zod.dev/?id=recursive-types\n type DirNodeOutput = BaseNode & {\n type: \"dir\";\n files: FileNodeOutput[];\n dirs: DirNodeOutput[];\n };\n type DirNodeInput = z.input<typeof baseNode> & {\n type: \"dir\";\n files: FileNodeInput[];\n dirs: DirNodeInput[];\n };\n\n const dirNode: z.ZodType<DirNodeOutput, z.ZodTypeDef, DirNodeInput> =\n baseNode.extend({\n type: z.literal(\"dir\"),\n files: z.array(fileNode),\n dirs: z.lazy(() => dirNode.array()),\n });\n\n const fileTree = z.union([fileNode, dirNode]);\n\n return { fileTree, dirNode, fileNode };\n}\n\nconst defaultSchema = createFileTreeSchema(relPath);\nconst jsonSchema = createFileTreeSchema(z.string());\n\nexport const fileTree = defaultSchema.fileTree;\nexport const jsonFileTree = jsonSchema.fileTree;\n\nexport type FileTree = z.infer<typeof defaultSchema.fileTree>;\nexport type FileNode = z.infer<typeof defaultSchema.fileNode>;\nexport type DirNode = z.infer<typeof defaultSchema.dirNode>;\nexport type Frontmatter = z.infer<typeof frontmatter>;\n","import z from \"zod\";\n\ntype AbsPath = z.infer<typeof absPath>;\nconst absPath = z.string().brand<\"absPath\">();\n\ntype RelPath = z.infer<typeof relPath>;\nconst relPath = z.string().brand<\"relpath\">();\n\nexport { type AbsPath, type RelPath, absPath, relPath };\n","import { copyFileSync, existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { AbsPath, FileTree } from \"../../types\";\n\nexport function mirror(\n\tfiletree: FileTree,\n\tsrcPath: AbsPath,\n\tdestPath: AbsPath,\n) {\n\tfunction aux(filetree: FileTree) {\n\t\tconst from = join(srcPath, filetree.path);\n\t\tconst to = join(destPath, filetree.path);\n\n\t\tif (filetree.type === \"dir\") {\n\t\t\tif (!existsSync(to)) mkdirSync(to, { recursive: true });\n\n\t\t\tfiletree.files.forEach((file) => {\n\t\t\t\taux(file);\n\t\t\t});\n\n\t\t\tfiletree.dirs.forEach((dir) => {\n\t\t\t\taux(dir);\n\t\t\t});\n\t\t}\n\n\t\tif (filetree.type === \"file\") {\n\t\t\tcopyFileSync(from, to);\n\t\t}\n\t}\n\n\taux(filetree);\n\tgenerateFileTree(filetree, destPath);\n}\n\nfunction generateFileTree(filetree: FileTree, destPath: AbsPath) {\n\tconst jsonFilePath = join(destPath, \"o2bFileTree.json\");\n\twriteFileSync(jsonFilePath, JSON.stringify(filetree, null, 2), \"utf-8\");\n}\n","import { lstatSync, readdirSync, readFileSync } from \"node:fs\";\nimport { basename, join } from \"node:path\";\nimport matter from \"gray-matter\";\nimport type {\n\tAbsPath,\n\tDirNode,\n\tFileNode,\n\tFileTree,\n\tFrontmatter,\n} from \"../../types\";\nimport { toAbsPath, toRelPath, type VaultIgnorer } from \"../../utils\";\n\nexport function scan(rootPath: AbsPath, ign: VaultIgnorer): FileTree | null {\n\tfunction aux(path: AbsPath): FileTree | null {\n\t\tif (ign?.ignore(path)) return null;\n\n\t\tconst stat = lstatSync(path);\n\t\tconst name = basename(path);\n\n\t\tif (stat.isDirectory()) {\n\t\t\tconst { dirs, files } = readdirSync(path).reduce(\n\t\t\t\t(acc, entry) => {\n\t\t\t\t\tconst node = aux(toAbsPath(join(path, entry)));\n\n\t\t\t\t\tif (node?.type === \"dir\") acc.dirs.push(node);\n\t\t\t\t\tif (node?.type === \"file\") acc.files.push(node);\n\n\t\t\t\t\treturn acc;\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdirs: [] as DirNode[],\n\t\t\t\t\tfiles: [] as FileNode[],\n\t\t\t\t},\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tpath: toRelPath(rootPath, path),\n\t\t\t\tname,\n\t\t\t\ttype: \"dir\",\n\t\t\t\tdirs,\n\t\t\t\tfiles,\n\t\t\t};\n\t\t}\n\n\t\tif (stat.isFile() && name.endsWith(\".md\")) {\n\t\t\treturn {\n\t\t\t\tpath: toRelPath(rootPath, path),\n\t\t\t\tname,\n\t\t\t\ttype: \"file\",\n\t\t\t\tfrontmatter: getFrontmatter(path),\n\t\t\t};\n\t\t}\n\n\t\treturn null;\n\t}\n\n\treturn aux(rootPath);\n}\n\nfunction getFrontmatter(path: AbsPath): Frontmatter {\n\tconst { data: srcFrontmatter } = matter(readFileSync(path, \"utf-8\"));\n\treturn {\n\t\ttitle: basename(path).replace(/\\.md$/, \"\"),\n\t\tdescription: \"No description provided.\",\n\t\tlast_modified: lstatSync(path).mtime.toLocaleDateString(\"sv-SE\"), // \"sv-SE\" (스웨덴어)는 YYYY-MM-DD 형식으로 출력되는 유명한 트릭입니다.\n\t\t...srcFrontmatter,\n\t};\n}\n","import { existsSync, lstatSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport ignore, { type Ignore } from \"ignore\";\nimport type { AbsPath } from \"../types\";\nimport { toRelPath } from \"./path\";\n\nexport class VaultIgnorer {\n\tprivate ign: Ignore;\n\tprivate rootPath: AbsPath;\n\n\tconstructor(rootPath: AbsPath) {\n\t\tthis.rootPath = rootPath;\n\t\tthis.ign = ignore();\n\n\t\tthis.ign.add([\".*\"]);\n\t}\n\n\tpublic load() {\n\t\tconst ignorePath = join(this.rootPath, \".o2bignore\");\n\t\tif (existsSync(ignorePath))\n\t\t\tthis.ign.add(readFileSync(ignorePath).toString());\n\t}\n\n\tpublic ignore(path: AbsPath): boolean {\n\t\tif (path === this.rootPath) return false;\n\n\t\tif (!existsSync(path)) throw new Error(\"somethings wrong!\");\n\n\t\tconst stat = lstatSync(path);\n\n\t\tconst relPath =\n\t\t\ttoRelPath(this.rootPath, path) + (stat.isDirectory() ? \"/\" : \"\");\n\n\t\treturn this.ign.ignores(relPath);\n\t}\n}\n","import { lstatSync, readdirSync } from \"node:fs\";\nimport { isAbsolute, relative, resolve } from \"node:path\";\nimport { absPath, relPath, type AbsPath, type RelPath } from \"../types\";\n\nfunction toAbsPath(path: string): AbsPath {\n if (!isAbsolute(path)) path = resolve(path);\n return absPath.parse(path);\n}\n\nfunction toRelPath(from: AbsPath, to: AbsPath): RelPath {\n return relPath.parse(relative(from, to));\n}\n\nfunction isObsidianDirectory(path: AbsPath) {\n const stat = lstatSync(path);\n\n if (!stat.isDirectory()) return false;\n\n const obsMetaDir = readdirSync(path, { withFileTypes: true })\n .filter((node) => node.isDirectory())\n .filter((node) => node.name === \".obsidian\");\n\n if (obsMetaDir.length !== 1) return false;\n\n return true;\n}\n\nexport { toAbsPath, toRelPath, isObsidianDirectory };\n","import { mirror, scan } from \"./core/sync\";\nimport type { Config } from \"./types\";\nimport { isObsidianDirectory, VaultIgnorer } from \"./utils\";\n\nexport default function runO2B(config: Config) {\n const { srcPath, destPath, ignore } = config;\n if (!isObsidianDirectory(srcPath)) throw new Error(\"Not a obsidian vault\");\n\n const ign = new VaultIgnorer(srcPath);\n if (ignore) ign.load();\n\n const fileTree = scan(srcPath, ign);\n if (fileTree === null) throw new Error(\"No content in vault\");\n\n mirror(fileTree, srcPath, destPath);\n}\n"],"mappings":";AAAA,OAAOA,QAAO;;;ACAd,OAAO,OAAO;AAGd,IAAM,UAAU,EAAE,OAAO,EAAE,MAAiB;AAG5C,IAAM,UAAU,EAAE,OAAO,EAAE,MAAiB;;;ADH5C,IAAM,cAAcC,GAAE,OAAO;AAAA,EAC3B,OAAOA,GAAE,OAAO;AAAA,EAChB,aAAaA,GAAE,OAAO;AAAA,EACtB,eAAeA,GAAE,OAAO;AAC1B,CAAC;AAED,SAAS,qBAA6D,MAAS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,QAAM,EAAE,MAAM,eAAe,IAAI,OAAOC,cAAa,MAAM,OAAO,CAAC;AACnE,SAAO;AAAA,IACN,OAAO,SAAS,IAAI,EAAE,QAAQ,SAAS,EAAE;AAAA,IACzC,aAAa;AAAA,IACb,eAAeH,WAAU,IAAI,EAAE,MAAM,mBAAmB,OAAO;AAAA;AAAA,IAC/D,GAAG;AAAA,EACJ;AACD;;;AG/De,SAAR,OAAwB,QAAgB;AAC7C,QAAM,EAAE,SAAS,UAAU,QAAAI,QAAO,IAAI;AACtC,MAAI,CAAC,oBAAoB,OAAO,EAAG,OAAM,IAAI,MAAM,sBAAsB;AAEzE,QAAM,MAAM,IAAI,aAAa,OAAO;AACpC,MAAIA,QAAQ,KAAI,KAAK;AAErB,QAAMC,YAAW,KAAK,SAAS,GAAG;AAClC,MAAIA,cAAa,KAAM,OAAM,IAAI,MAAM,qBAAqB;AAE5D,SAAOA,WAAU,SAAS,QAAQ;AACpC;","names":["z","z","fileTree","filetree","lstatSync","readdirSync","readFileSync","join","existsSync","lstatSync","join","join","existsSync","lstatSync","relPath","lstatSync","readdirSync","join","readFileSync","ignore","fileTree"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/filetree.ts","../src/types/path.ts","../src/core/sync/mirror.ts","../src/core/sync/scan.ts","../src/utils/path.ts","../src/utils/id.ts","../src/core/sync/normalize.ts","../src/utils/file.ts","../src/utils/ignore.ts","../src/runO2B.ts"],"sourcesContent":["import z from \"zod\";\nimport { relPath, type RelPath } from \"@o2bTypes/path\";\n\n/* ********** Schemas ********** */\n\nconst frontmatter = z.object({\n title: z.string(),\n description: z.string(),\n last_modified: z.string(),\n});\n\nconst baseNode = z.object({\n path: relPath,\n name: z.string(),\n});\n\nconst fileNode = baseNode.extend({\n type: z.literal(\"file\"),\n frontmatter: frontmatter,\n});\n\nconst dirNode: z.ZodType<DirNodeOutput, z.ZodTypeDef, DirNodeInput> =\n baseNode.extend({\n type: z.literal(\"dir\"),\n files: z.array(fileNode),\n dirs: z.lazy(() => dirNode.array()),\n });\n\nconst fileTree = z.union([dirNode, fileNode]);\n\n/* ********** Types ********** */\n\ntype BaseNodeOutput = z.infer<typeof baseNode>;\ntype BaseNodeInput = z.input<typeof baseNode>;\n\ntype FileNodeOutput = z.infer<typeof fileNode>;\ntype FileNodeInput = z.input<typeof fileNode>;\n\n// https://v3.zod.dev/?id=recursive-types\ntype DirNodeOutput = BaseNodeOutput & {\n type: \"dir\";\n files: FileNodeOutput[];\n dirs: DirNodeOutput[];\n};\ntype DirNodeInput = BaseNodeInput & {\n type: \"dir\";\n files: FileNodeInput[];\n dirs: DirNodeInput[];\n};\n\nexport type FileTree = z.infer<typeof fileTree>;\nexport type DirNode = DirNodeOutput;\nexport type FileNode = FileNodeOutput;\nexport type Frontmatter = z.infer<typeof frontmatter>;\n\n/* ********** Normalized ********** */\n\nconst id = z.number().int();\n\nexport const normedFileNode = fileNode.extend({\n id,\n});\n\nexport const normedDirNode = baseNode.extend({\n id,\n type: z.literal(\"dir\"),\n files: z.array(id),\n dirs: z.array(id),\n});\n\nexport type NormedFileTree = {\n id: Id;\n files: Id[];\n dirs: NormedFileTree[];\n};\nexport const normedFileTree: z.ZodType<NormedFileTree> = z.object({\n id,\n files: z.array(id),\n dirs: z.lazy(() => z.array(normedFileTree)),\n});\n\ntype Id = z.infer<typeof id>;\nexport type NormedFileNode = z.infer<typeof normedFileNode>;\nexport type NormedDirNode = z.infer<typeof normedDirNode>;\n","import z from \"zod\";\n\ntype AbsPath = z.infer<typeof absPath>;\nconst absPath = z.string().brand<\"absPath\">();\n\ntype RelPath = z.infer<typeof relPath>;\nconst relPath = z.string().brand<\"relpath\">();\n\nexport { type AbsPath, type RelPath, absPath, relPath };\n","import { copyFileSync, existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { AbsPath } from \"@o2bTypes/path\";\nimport type { FileTree } from \"@o2bTypes/filetree\";\n\nexport function mirror(\n filetree: FileTree,\n srcPath: AbsPath,\n destPath: AbsPath,\n) {\n function aux(filetree: FileTree) {\n const from = join(srcPath, filetree.path);\n const to = join(destPath, filetree.path);\n\n if (filetree.type === \"dir\") {\n if (!existsSync(to)) mkdirSync(to, { recursive: true });\n\n filetree.files.forEach((file) => {\n aux(file);\n });\n\n filetree.dirs.forEach((dir) => {\n aux(dir);\n });\n }\n\n if (filetree.type === \"file\") {\n copyFileSync(from, to);\n }\n }\n\n aux(filetree);\n}\n","import { lstatSync, readdirSync, readFileSync } from \"node:fs\";\nimport { basename, join } from \"node:path\";\nimport matter from \"gray-matter\";\nimport type {\n DirNode,\n FileNode,\n FileTree,\n Frontmatter,\n} from \"@o2bTypes/filetree\";\nimport { toAbsPath, toRelPath } from \"@utils/path\";\nimport { AbsPath } from \"@o2bTypes/path\";\nimport { VaultIgnorer } from \"@utils/ignore\";\n\nexport function scan(rootPath: AbsPath, ign: VaultIgnorer): FileTree | null {\n function aux(path: AbsPath): FileTree | null {\n if (ign?.ignore(path)) return null;\n\n const stat = lstatSync(path);\n const name = basename(path);\n\n if (stat.isFile() && name.endsWith(\".md\")) {\n return {\n path: toRelPath(rootPath, path),\n name,\n type: \"file\",\n frontmatter: fetchFrontmatter(path, stat.mtime),\n };\n }\n\n if (stat.isDirectory()) {\n const dirs: DirNode[] = [];\n const files: FileNode[] = [];\n const entries = readdirSync(path);\n\n for (const entry of entries) {\n const fullPath = toAbsPath(join(path, entry));\n const node = aux(fullPath);\n\n if (node?.type === \"dir\") dirs.push(node);\n if (node?.type === \"file\") files.push(node);\n }\n\n return {\n path: toRelPath(rootPath, path),\n name,\n type: \"dir\",\n dirs,\n files,\n };\n }\n\n return null;\n }\n\n return aux(rootPath);\n}\n\nfunction fetchFrontmatter(path: AbsPath, mtime: Date): Frontmatter {\n const { data } = matter(readFileSync(path, \"utf-8\"));\n return {\n title: basename(path).replace(/\\.md$/, \"\"),\n description: \"No description provided.\",\n last_modified: mtime.toISOString().split(\"T\")[0],\n ...data,\n };\n}\n","import { lstatSync, readdirSync } from \"node:fs\";\nimport { isAbsolute, relative, resolve } from \"node:path\";\nimport { absPath, relPath, type AbsPath, type RelPath } from \"@o2bTypes/path\";\n\nfunction toAbsPath(path: string): AbsPath {\n if (!isAbsolute(path)) path = resolve(path);\n return absPath.parse(path);\n}\n\nfunction toRelPath(from: AbsPath, to: AbsPath): RelPath {\n return relPath.parse(relative(from, to));\n}\n\nfunction isObsidianDirectory(path: AbsPath) {\n const stat = lstatSync(path);\n\n if (!stat.isDirectory()) return false;\n\n const obsMetaDir = readdirSync(path, { withFileTypes: true })\n .filter((node) => node.isDirectory())\n .filter((node) => node.name === \".obsidian\");\n\n if (obsMetaDir.length !== 1) return false;\n\n return true;\n}\n\nexport { toAbsPath, toRelPath, isObsidianDirectory };\n","import { Id } from \"@o2bTypes/filetree\";\n\nexport const idCounter: (start?: number) => () => Id = (start: number = 0) => {\n let count = start;\n return () => count++;\n};\n","import {\n DirNode,\n NormedDirNode,\n NormedFileNode,\n NormedFileTree,\n} from \"@o2bTypes/filetree\";\nimport { idCounter } from \"@utils/id\";\n\nexport function normalize(fileTree: DirNode): {\n fileTree: NormedFileTree;\n dirNodes: NormedDirNode[];\n fileNodes: NormedFileNode[];\n} {\n const dirNodes: NormedDirNode[] = [];\n const fileNodes: NormedFileNode[] = [];\n\n const fileId = idCounter();\n const dirId = idCounter();\n\n function aux(dir: DirNode): NormedFileTree {\n const id = dirId();\n\n const files = dir.files.map((file) => {\n const id = fileId();\n fileNodes.push({ id, ...file });\n return id;\n });\n\n const dirs = dir.dirs.map((dir) => aux(dir));\n dirNodes.push({ ...dir, id, files, dirs: dirs.map((dir) => dir.id) });\n\n return {\n id,\n files,\n dirs,\n };\n }\n const normedFileTree = aux(fileTree);\n\n return {\n dirNodes,\n fileNodes,\n fileTree: normedFileTree,\n };\n}\n","import { writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { AbsPath } from \"@o2bTypes/path\";\n\nexport function generateJson(\n content: unknown,\n name: string,\n destPath: AbsPath,\n) {\n const jsonFilePath = join(destPath, `${name}.json`);\n writeFileSync(jsonFilePath, JSON.stringify(content, null, 2), \"utf-8\");\n}\n","import { existsSync, lstatSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport ignore, { type Ignore } from \"ignore\";\n\nimport type { AbsPath } from \"@o2bTypes/path\";\nimport { toRelPath } from \"@utils/path\";\n\nexport class VaultIgnorer {\n private ign: Ignore;\n private rootPath: AbsPath;\n\n constructor(rootPath: AbsPath) {\n this.rootPath = rootPath;\n this.ign = ignore();\n\n this.ign.add([\".*\"]);\n }\n\n public load() {\n const ignorePath = join(this.rootPath, \".o2bignore\");\n if (existsSync(ignorePath))\n this.ign.add(readFileSync(ignorePath).toString());\n }\n\n public ignore(path: AbsPath): boolean {\n if (path === this.rootPath) return false;\n\n if (!existsSync(path)) throw new Error(\"somethings wrong!\");\n\n const stat = lstatSync(path);\n\n const relPath =\n toRelPath(this.rootPath, path) + (stat.isDirectory() ? \"/\" : \"\");\n\n return this.ign.ignores(relPath);\n }\n}\n","import { mirror, scan, normalize } from \"@core/sync\";\nimport type { Config } from \"@o2bTypes/config\";\nimport { generateJson } from \"@utils/file\";\nimport { isObsidianDirectory } from \"@utils/path\";\nimport { VaultIgnorer } from \"@utils/ignore\";\n\nexport default function runO2B(config: Config) {\n const { srcPath, destPath, ignore } = config;\n\n if (!isObsidianDirectory(srcPath)) throw new Error(\"Not a obsidian vault\");\n\n const ign = new VaultIgnorer(srcPath);\n if (ignore) ign.load();\n\n const fileTree = scan(srcPath, ign);\n if (fileTree === null) throw new Error(\"No content in vault\");\n if (fileTree.type !== \"dir\") throw new Error(\"No Vault?!\");\n\n mirror(fileTree, srcPath, destPath);\n const { fileTree: normedFileTree, dirNodes, fileNodes } = normalize(fileTree);\n\n generateJson(normedFileTree, \"fileTree\", destPath);\n generateJson(dirNodes, \"dirNodes\", destPath);\n generateJson(fileNodes, \"fileNodes\", destPath);\n}\n"],"mappings":";AAAA,OAAOA,QAAO;;;AC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AACpC,QAAI,SAAS,KAAK,SAAU,QAAO;AAEnC,QAAI,CAACD,YAAW,IAAI,EAAG,OAAM,IAAI,MAAM,mBAAmB;AAE1D,UAAM,OAAOE,WAAU,IAAI;AAE3B,UAAMC,WACJ,UAAU,KAAK,UAAU,IAAI,KAAK,KAAK,YAAY,IAAI,MAAM;AAE/D,WAAO,KAAK,IAAI,QAAQA,QAAO;AAAA,EACjC;AACF;;;AC9Be,SAAR,OAAwB,QAAgB;AAC7C,QAAM,EAAE,SAAS,UAAU,QAAAC,QAAO,IAAI;AAEtC,MAAI,CAAC,oBAAoB,OAAO,EAAG,OAAM,IAAI,MAAM,sBAAsB;AAEzE,QAAM,MAAM,IAAI,aAAa,OAAO;AACpC,MAAIA,QAAQ,KAAI,KAAK;AAErB,QAAMC,YAAW,KAAK,SAAS,GAAG;AAClC,MAAIA,cAAa,KAAM,OAAM,IAAI,MAAM,qBAAqB;AAC5D,MAAIA,UAAS,SAAS,MAAO,OAAM,IAAI,MAAM,YAAY;AAEzD,SAAOA,WAAU,SAAS,QAAQ;AAClC,QAAM,EAAE,UAAUC,iBAAgB,UAAU,UAAU,IAAI,UAAUD,SAAQ;AAE5E,eAAaC,iBAAgB,YAAY,QAAQ;AACjD,eAAa,UAAU,YAAY,QAAQ;AAC3C,eAAa,WAAW,aAAa,QAAQ;AAC/C;","names":["z","z","filetree","lstatSync","readdirSync","join","lstatSync","readdirSync","join","fileTree","id","dir","normedFileTree","writeFileSync","join","existsSync","lstatSync","readFileSync","join","join","existsSync","readFileSync","lstatSync","relPath","ignore","fileTree","normedFileTree"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o2b/meta",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.7",
|
|
4
4
|
"description": "filetree generator for o2b",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"bin": {
|
|
16
|
-
"o2b-meta": "
|
|
16
|
+
"o2b-meta": "dist/cli.js"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "tsup",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@vitest/ui": "^4.0.16",
|
|
34
34
|
"tsup": "^8.5.1",
|
|
35
35
|
"typescript": "^5.9.3",
|
|
36
|
+
"vite-tsconfig-paths": "^6.0.5",
|
|
36
37
|
"vitest": "^4.0.16",
|
|
37
38
|
"zod": "^3.25.76"
|
|
38
39
|
},
|