build project in command line

This commit is contained in:
codetypes committed 2025-01-25 21:55:00 +08:00
1 parent da41704322
commit a0d0ca0ca9
5 files changed
+110 -11

No files matched your search

+18
View File
@@ -1,3 +1,4 @@
import * as fs from "fs";
import path from "path";
const Path = path;
@@ -6,6 +7,7 @@ declare module "path" {
interface PlatformPath {
basenameWithoutExt(path: string): string;
posixPath(path: string): string;
ls(path: string, recursive?: boolean): string[];
}
}
@@ -17,4 +19,20 @@ path.posixPath = (str: string) => {
return path.normalize(str).replace(/\\/g, "/");
};
const readdir = (dir: string, recursive: boolean, callback: (file: string) => void) => {
fs.readdirSync(dir).forEach((file) => {
file = Path.posixPath(dir + "/" + file);
callback(file);
if (recursive && fs.statSync(file).isDirectory()) {
readdir(file, recursive, callback);
}
});
};
path.ls = (dir: string, recursive?: boolean) => {
const paths: string[] = [];
readdir(dir, recursive ?? false, (file) => paths.push(file));
return paths.sort();
};
export default Path;
+16 -5
View File
@@ -1,10 +1,21 @@
import { Context, NodeDef } from "@/behavior3/src/behavior3";
import { Context, Node, NodeDef } from "@/behavior3/src/behavior3";
import { DeepReadonly } from "../behavior3/src/behavior3/context";
class NodeContext extends Context {
loadTree(path: string): Promise<Node> {
throw new Error("Method not implemented.");
}
}
export const zhNodeDef = () => {
const context = new Context();
const defs: NodeDef[] = [];
for (const v of context.processResolvers.values()) {
const descriptor = v.descriptor;
const context = new (class extends Context {
loadTree(path: string): Promise<Node> {
throw new Error("Method not implemented.");
}
})();
const defs: DeepReadonly<NodeDef>[] = [];
for (const k in context.nodeDefs) {
const descriptor = context.nodeDefs[k];
defs.push(descriptor);
}
defs.sort((a, b) => a.name.localeCompare(b.name));