-
Notifications
You must be signed in to change notification settings - Fork 0
/
fresh.js
executable file
·37 lines (32 loc) · 1.3 KB
/
fresh.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env node
import { freshHandler } from "../src/handlers/freshHandler.js";
import { parseArgs } from "node:util";
import * as fs from "fs";
import * as path from "path";
import * as utils from "./utils.js";
const args = parseArgs({
options: {
class: {
type: "string",
multiple: true,
},
registry: {
type: "string",
},
gypsum: {
type: "string",
},
dir: {
type: "string",
}
}
});
const dir = utils.required(args, "dir");
const db_paths = utils.parseConfigurations(utils.required(args, "class"), dir);
const { list_projects, list_assets, list_versions, find_latest, read_summary, read_metadata } = utils.chooseSourceFunctions(utils.optional(args, "registry"), utils.optional(args, "gypsum"));
// Creating the timestamp here, just so that if there are any operations
// between now and completion of the index, we catch them in the updates. This
// is okay as all logged operations are idempotent from our perspective; we're
// just (re)aligning with whatever's in the bucket.
fs.writeFileSync(path.join(dir, "modified"), String((new Date).getTime()))
await freshHandler(db_paths, list_projects, list_assets, list_versions, find_latest, read_summary, read_metadata, { verbose: true });