Skip to content

Commit

Permalink
Record schema creation and modification times
Browse files Browse the repository at this point in the history
We get this from the git history. It would be possible to record author
information too.
  • Loading branch information
amrc-benmorrow committed Oct 15, 2024
1 parent bd6adf8 commit d7fe50c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.git
deploy/node_modules
deploy/schemas.json
validate/node_modules
10 changes: 10 additions & 0 deletions deploy/bin/find-schemas.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import fs from "fs";
import $fs from "fs/promises";
import $path from "path";

import Walk from "@root/walk";
import git from "isomorphic-git";

const ignore = new Set([
".git", ".githooks", ".github",
Expand Down Expand Up @@ -81,10 +83,18 @@ for (const sch of schemas.values()) {
if (!sch.uuid)
continue;

const changes = (await git.log({
fs,
dir: "..",
filepath: $path.relative("..", sch.path),
})).map(l => l.commit.author.timestamp);

configs[sch.uuid] = {
metadata: {
name: sch.name,
version: sch.version,
created: changes.at(-1),
modified: changes.at(0),
},
schema: {
...fixup(sch.json),
Expand Down
3 changes: 2 additions & 1 deletion deploy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"license": "ISC",
"dependencies": {
"@amrc-factoryplus/service-client": "^1.3.6",
"@root/walk": "^1.1.0"
"@root/walk": "^1.1.0",
"isomorphic-git": "^1.27.1"
}
}

0 comments on commit d7fe50c

Please sign in to comment.