+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion labs/demo-app/src/platform/project/ProjectRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ export class ProjectRepo extends Repository<ProjectFileTypes, "web"> {
fileTypes: new TypeboxFileTypes(),
});
(this as any)[Symbol.toStringTag] = `ProjectRepo("/project/repo/")`;
this.fileTypes.set(ProjectFileTypes);
this.fs.fileTypes.set(ProjectFileTypes);
}
}
4 changes: 2 additions & 2 deletions labs/demo-app/src/platform/project/openRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function openRepo() {

setTimeout(async () => {
console.log("TESTING WRITE FILE");
await repo.write<"db">("backend/db/main/_.db.json", (data) => {
await repo.fs.write<"db">("backend/db/main/_.db.json", (data) => {
data.db.name = "maing";
data.db.dialect = "sqlite";
// delete data.db.mysql;
Expand All @@ -21,7 +21,7 @@ export async function openRepo() {

setTimeout(async () => {
console.log("TESTING READ FILE");
const { data } = await repo.get("backend/db/main/_.db.json");
const { data } = await repo.fs.get("backend/db/main/_.db.json");
console.log("DATA", data);
}, 6000);

Expand Down
20 changes: 11 additions & 9 deletions labs/demo-server/src/api/project/repo/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default apiController(function projectRepoFsApi(api, options) {
},
async function fsAdd({ body }, rep) {
const res = await transaction((repo, out) =>
repo.add(body.to, "data" in body ? { data: body.data } : {}, out),
repo.fs.add(body.to, "data" in body ? { data: body.data } : {}, out),
);
rep.status(200).send(res);
},
Expand All @@ -64,9 +64,9 @@ export default apiController(function projectRepoFsApi(api, options) {
async function fsGetJsonData({ body }, rep) {
const { repo } = projectService;
const { from } = body;
const entry = repo.findPathEntry(from)!;
const entry = repo.fs.findPathEntry(from)!;
// TODO: Respond with a 404 if (!entry)...
const data = repo.data(entry);
const data = repo.fs.data(entry);
// CONSIDER: Should we compare client `ctime` to signal no-change here?
rep.status(200).send({ id: entry.id, data });
},
Expand All @@ -86,7 +86,7 @@ export default apiController(function projectRepoFsApi(api, options) {
},
async function fsMove({ body }, rep) {
const res = await transaction((repo, out) =>
repo.move(body.from, body.to, out),
repo.fs.move(body.from, body.to, out),
);
rep.status(200).send(res);
},
Expand All @@ -105,7 +105,9 @@ export default apiController(function projectRepoFsApi(api, options) {
},
},
async function fsRemove({ body }, rep) {
const res = await transaction((repo, out) => repo.remove(body.from, out));
const res = await transaction((repo, out) =>
repo.fs.remove(body.from, out),
);
rep.status(200).send(res);
},
);
Expand All @@ -124,16 +126,16 @@ export default apiController(function projectRepoFsApi(api, options) {
},
async function fsWrite({ body }, rep) {
const res = await transaction(async (repo, out) => {
// await repo.write(body.to, (data) => {});
let entry = repo.findPathEntry(body.to);
// await repo.fs.write(body.to, (data) => {});
let entry = repo.fs.findPathEntry(body.to);
if (!entry) {
throw new Error(`Entry not found "${body.to}".`);
}
if ("patches" in body) {
if (!body.patches || !body.undo) {
throw new Error(`Need data or patches to write to "${body.to}".`);
}
entry = await repo.patch(
entry = await repo.fs.patch(
entry,
{
ctime: body.ctime!,
Expand All @@ -146,7 +148,7 @@ export default apiController(function projectRepoFsApi(api, options) {
} else if (typeof body.data === "undefined") {
throw new Error(`Need data or patches to write to "${body.to}".`);
} else {
entry = await repo.write(entry, body.data, out);
entry = await repo.fs.write(entry, body.data, out);
return entry;
}
});
Expand Down
2 changes: 1 addition & 1 deletion labs/demo-server/src/platform/project/ProjectRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ProjectRepo extends Repository<ProjectFileTypes, "fs"> {
fileTypes: new TypeboxFileTypes(),
});
(this as any)[Symbol.toStringTag] = `ProjectRepo("${configFilePath}")`;
this.fileTypes.set(ProjectFileTypes);
this.fs.fileTypes.set(ProjectFileTypes);
// this.server = new Server<ProjectFileTypes>(this);
}
}
38 changes: 19 additions & 19 deletions labs/demo-server/src/tests/designer-files-lab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ const REPO_PATH = Path.join(

describe.sequential("Starter lab", () => {
let repo = null! as ProjectRepo;
let addedDir = null! as Awaited<ReturnType<ProjectRepo["add"]>>;
let addedFile = null! as Awaited<ReturnType<ProjectRepo["add"]>>;
let addedDir = null! as Awaited<ReturnType<ProjectRepo["fs"]["add"]>>;
let addedFile = null! as Awaited<ReturnType<ProjectRepo["fs"]["add"]>>;

test("Open repo", async () => {
console.log(`OPENING repo`, REPO_PATH);

repo = new ProjectRepo(REPO_PATH);
await repo.open();

await repo.printDirectory();
await repo.fs.printDirectory();
});
test("Finding db models", async () => {
console.log("FINDING db models...");

const nodes = await repo.findTypes("db");
const nodes = await repo.fs.findTypes("db");
expect(nodes.length).toBeGreaterThanOrEqual(1);

console.log("FOUND", nodes.length, "nodes");
Expand All @@ -36,12 +36,12 @@ describe.sequential("Starter lab", () => {
});
test("Adding directory", async () => {
console.log("ADDING DIRECTORY...");
addedDir = await repo.add("tests");
addedDir = await repo.fs.add("tests");
console.log("ADDED DIRECTORY", addedDir.id, addedDir.name);
});
test("Adding file", async () => {
console.log("ADDING FILE...");
addedFile = await repo.add("my.db.json", {
addedFile = await repo.fs.add("my.db.json", {
parent: addedDir,
data: {
a: { name: "a" },
Expand All @@ -50,26 +50,26 @@ describe.sequential("Starter lab", () => {
},
});
console.log("ADDED FILE", addedFile.id, addedFile.name, addedFile.pId);
await repo.printDirectory();
await repo.fs.printDirectory();
});
test("Moving directory", async () => {
// await timeoutAsync(500);
console.log("MOVING DIRECTORY...", addedDir.id);
addedDir = await repo.move(addedDir, "backend/things/tests");
addedDir = await repo.fs.move(addedDir, "backend/things/tests");
console.log("MOVED DIRECTORY", addedDir.id, "to", addedDir.pId);
await repo.printDirectory();
await repo.fs.printDirectory();
});
test("Renaming directory", async () => {
// await timeoutAsync(500);
console.log("RENAMING DIRECTORY...", addedDir.id);
addedDir = await repo.rename(addedDir, "testing");
addedDir = await repo.fs.rename(addedDir, "testing");
console.log("RENAMED DIRECTORY...", addedDir.id, addedDir.name);
await repo.printDirectory();
await repo.fs.printDirectory();
});
test("Writing file", async () => {
// await timeoutAsync(500);
console.log("WRITING TO FILE", addedFile.name, addedFile.ctime);
addedFile = await repo.write(
addedFile = await repo.fs.write(
addedFile,
(data: Record<"a" | "b" | "c", { name: string }>) => {
data.a.name = "A";
Expand All @@ -78,21 +78,21 @@ describe.sequential("Starter lab", () => {
},
);
console.log("WROTE TO FILE", addedFile.name, addedFile.ctime);
await repo.printDirectory();
await repo.fs.printDirectory();
});
test("Removing directory", async () => {
console.log("REMOVING DIRECTORY...", addedDir.id, addedDir.name);
addedDir = await repo.remove("backend/things");
addedDir = await repo.fs.remove("backend/things");
console.log("REMOVED DIRECTORY...", addedDir.id, addedDir.name);
await repo.printDirectory();
await repo.fs.printDirectory();
});
test("Add and remove deep directory", async () => {
console.log("TRY MKDIR...");
const deepDir = await repo.add("frontend/app1/foo/bar");
await repo.printDirectory();
const deepDir = await repo.fs.add("frontend/app1/foo/bar");
await repo.fs.printDirectory();
console.log("REMOVING MKDIR...");
await repo.remove({ id: deepDir.pId! });
await repo.printDirectory();
await repo.fs.remove({ id: deepDir.pId! });
await repo.fs.printDirectory();
});
test("Closing db", async () => {
console.log("CLOSING repo", REPO_PATH);
Expand Down
2 changes: 1 addition & 1 deletion labs/designer-files/design/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for help.

# JRFS
# .jrfs/**/*.ids.json
# .jrfs/**/*.idx.json

# Dependencies
node_modules/
Expand Down
25 changes: 0 additions & 25 deletions labs/designer-files/design/.jrfs/projectDb.ids.json

This file was deleted.

28 changes: 28 additions & 0 deletions labs/designer-files/design/.jrfs/projectDb.idx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"rid": "inlxvq7pbxfmru3m",
"node": {
"assets": "d5l4qpznsa",
"assets/sample-content.md": "f7o2x7chgk",
"backend": "dhnifxb5z4",
"backend/_.dir.json": "fcn700q0jd",
"backend/api-server": "dtiasag8x3",
"backend/api-server/_.server.json": "fozhjbesr1",
"backend/api-server/api": "d9vdtuuktk",
"backend/api-server/api/bar": "dei0vnhlck",
"backend/api-server/api/bar/_.api.json": "fnopxvq87x",
"backend/api-server/api/foo": "dg2ydfhu03",
"backend/api-server/api/foo/_.api.json": "frrkj314pd",
"backend/db": "dve3gc3m5z",
"backend/db/main": "dsf6qz79qc",
"backend/db/main/_.db.json": "fmruxyq7e6",
"backend/db/main/tables": "dwkliyycjm",
"backend/db/main/tables/roles.db-table.json": "finly15s12",
"backend/db/main/tables/users.db-table.json": "f2ekcmhfnz",
"frontend": "dwsrqz3h7m",
"frontend/_.dir.json": "ft7pbxl1zy",
"frontend/app1": "d2vjryywjv",
"frontend/app1/_.app.json": "flxnde1g1y",
"frontend/app2": "dge6a0pyki",
"frontend/app2/_.app.json": "ffdamcyian"
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@types/node": "^20.14.8",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"chalk": "^5.3.0",
"datauri-cli": "^4.1.0",
"delay-cli": "^2.0.0",
"esbuild": "^0.21.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jrfs/core",
"version": "0.0.4",
"version": "0.1.0",
"description": "JRFS core library.",
"repository": "github:jrfso/jrfs",
"homepage": "https://github.com/jrfso/jrfs/tree/master/packages/core",
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载