diff --git a/scripts/fresh.js b/scripts/fresh.js index 32a4c02..2e5cea8 100644 --- a/scripts/fresh.js +++ b/scripts/fresh.js @@ -13,6 +13,9 @@ const args = parseArgs({ registry: { type: "string", }, + gypsum: { + type: "string", + }, dir: { type: "string", } @@ -21,7 +24,7 @@ const args = parseArgs({ const dir = utils.required(args, "dir"); const { db_paths, db_tokenizable } = utils.parseConfigurations(utils.required(args, "config"), dir); -const { list_projects, list_assets, list_versions, find_latest, read_summary, read_metadata } = utils.chooseSourceFunctions(utils.optional(args, "registry")); +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 diff --git a/scripts/manual.js b/scripts/manual.js index a78bd06..66f0de7 100644 --- a/scripts/manual.js +++ b/scripts/manual.js @@ -13,6 +13,9 @@ const args = parseArgs({ registry: { type: "string", }, + gypsum: { + type: "string", + }, dir: { type: "string", }, @@ -29,7 +32,7 @@ const args = parseArgs({ }); const { db_paths, db_tokenizable } = utils.parseConfigurations(utils.required(args, "config"), utils.required(args, "dir")); -const { list_projects, list_assets, list_versions, find_latest, read_summary, read_metadata } = utils.chooseSourceFunctions(utils.required(args, "registry")); +const { list_projects, list_assets, list_versions, find_latest, read_summary, read_metadata } = utils.chooseSourceFunctions(utils.optional(args, "registry"), utils.optional(args, "gypsum")); await manualHandler( db_paths, diff --git a/scripts/update.js b/scripts/update.js index db1b35a..e8fb77a 100644 --- a/scripts/update.js +++ b/scripts/update.js @@ -21,7 +21,7 @@ const args = parseArgs({ const dir = utils.required(args, "dir"); const { db_paths, db_tokenizable } = utils.parseConfigurations(utils.required(args, "config"), dir); -const { list_logs, read_log, read_metadata, find_latest } = utils.chooseSourceFunctions(utils.optional(args, "registry")); +const { list_logs, read_log, read_metadata, find_latest } = utils.chooseSourceFunctions(utils.optional(args, "registry"), utils.optional(args, "gypsum")); let lastmod_path = path.join(dir, "modified"); let lastmod = new Date(Number(fs.readFileSync(lastmod_path))); diff --git a/scripts/utils.js b/scripts/utils.js index 1237a90..06b6415 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -1,4 +1,5 @@ import * as local from "../src/local/index.js"; +import * as gypsum from "../src/gypsum/index.js"; import * as fs from "fs"; import * as path from "path"; @@ -13,8 +14,8 @@ export function parseConfigurations(configs, dir) { return { db_paths, db_tokenizable }; } -export function chooseSourceFunctions(registry) { - if (registry) { +export function chooseSourceFunctions(registry, gypsum_url) { + if (registry !== null) { return { list_projects: () => local.listProjects(registry), list_assets: (project) => local.listAssets(registry, project), @@ -25,8 +26,19 @@ export function chooseSourceFunctions(registry) { read_metadata: (project, asset, version, to_extract) => local.readMetadata(registry, project, asset, version, to_extract), find_latest: (project, asset) => local.fetchLatest(registry, project, asset), }; + } else if (gypsum_url !== null) { + return { + list_projects: () => gypsum.listProjects(gypsum_url), + list_assets: (project) => gypsum.listAssets(gypsum_url, project), + list_versions: (project, asset) => gypsum.listVersions(gypsum_url, project, asset), + list_logs: since => gypsum.listLogs(gypsum_url, since), + read_log: name => gypsum.readLog(gypsum_url, name), + read_summary: (project, asset, version) => gypsum.readSummary(gypsum_url, project, asset, version), + read_metadata: (project, asset, version, to_extract) => gypsum.readMetadata(gypsum_url, project, asset, version, to_extract), + find_latest: (project, asset) => gypsum.fetchLatest(gypsum_url, project, asset), + }; } else { - throw new Error("non-registry arguments are not yet supported"); + throw new Error("one of 'registry' or 'gypsum' must be provided"); } }