opencode-synced 0.1.1 → 0.3.0
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/index.js +28 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,7 +11,9 @@ var __export = (target, all) => {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// src/index.ts
|
|
14
|
+
import fs4 from "fs/promises";
|
|
14
15
|
import path5 from "path";
|
|
16
|
+
import { fileURLToPath } from "url";
|
|
15
17
|
|
|
16
18
|
// node_modules/zod/v4/classic/external.js
|
|
17
19
|
var exports_external = {};
|
|
@@ -13746,12 +13748,34 @@ function parseFrontmatter(content) {
|
|
|
13746
13748
|
}
|
|
13747
13749
|
return { frontmatter, body: body.trim() };
|
|
13748
13750
|
}
|
|
13751
|
+
function getModuleDir() {
|
|
13752
|
+
if (typeof import.meta.dir === "string") {
|
|
13753
|
+
return import.meta.dir;
|
|
13754
|
+
}
|
|
13755
|
+
return path5.dirname(fileURLToPath(import.meta.url));
|
|
13756
|
+
}
|
|
13757
|
+
async function scanMdFiles(dir) {
|
|
13758
|
+
const files = [];
|
|
13759
|
+
async function walk(currentDir) {
|
|
13760
|
+
const entries = await fs4.readdir(currentDir, { withFileTypes: true });
|
|
13761
|
+
for (const entry of entries) {
|
|
13762
|
+
const fullPath = path5.join(currentDir, entry.name);
|
|
13763
|
+
if (entry.isDirectory()) {
|
|
13764
|
+
await walk(fullPath);
|
|
13765
|
+
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
13766
|
+
files.push(fullPath);
|
|
13767
|
+
}
|
|
13768
|
+
}
|
|
13769
|
+
}
|
|
13770
|
+
await walk(dir);
|
|
13771
|
+
return files;
|
|
13772
|
+
}
|
|
13749
13773
|
async function loadCommands() {
|
|
13750
13774
|
const commands = [];
|
|
13751
|
-
const commandDir = path5.join(
|
|
13752
|
-
const
|
|
13753
|
-
for
|
|
13754
|
-
const content = await
|
|
13775
|
+
const commandDir = path5.join(getModuleDir(), "command");
|
|
13776
|
+
const files = await scanMdFiles(commandDir);
|
|
13777
|
+
for (const file2 of files) {
|
|
13778
|
+
const content = await fs4.readFile(file2, "utf-8");
|
|
13755
13779
|
const { frontmatter, body } = parseFrontmatter(content);
|
|
13756
13780
|
const relativePath = path5.relative(commandDir, file2);
|
|
13757
13781
|
const name = relativePath.replace(/\.md$/, "").replace(/\//g, "-");
|