@galaxy-tool-util/cli 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/summarize.d.ts +31 -0
- package/dist/commands/summarize.d.ts.map +1 -0
- package/dist/commands/summarize.js +85 -0
- package/dist/commands/summarize.js.map +1 -0
- package/dist/programs/galaxy-tool-cache.d.ts.map +1 -1
- package/dist/programs/galaxy-tool-cache.js +2 -0
- package/dist/programs/galaxy-tool-cache.js.map +1 -1
- package/package.json +1 -1
- package/spec/galaxy-tool-cache.json +25 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ParsedTool } from "@galaxy-tool-util/schema";
|
|
2
|
+
export interface SummarizeOptions {
|
|
3
|
+
version?: string;
|
|
4
|
+
output?: string;
|
|
5
|
+
cacheDir?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface GalaxyToolSummaryManifest {
|
|
8
|
+
schema_version: 1;
|
|
9
|
+
tool_id: string;
|
|
10
|
+
tool_version: string | null;
|
|
11
|
+
cache_key: string;
|
|
12
|
+
source: {
|
|
13
|
+
kind: "toolshed" | "galaxy" | "local" | "orphan" | "unknown";
|
|
14
|
+
label: string;
|
|
15
|
+
url: string;
|
|
16
|
+
cached_at: string | null;
|
|
17
|
+
};
|
|
18
|
+
artifacts: {
|
|
19
|
+
parsed_tool_path: string;
|
|
20
|
+
raw_tool_source_path: string | null;
|
|
21
|
+
};
|
|
22
|
+
parsed_tool: ParsedTool;
|
|
23
|
+
input_schemas: {
|
|
24
|
+
workflow_step: unknown | null;
|
|
25
|
+
workflow_step_linked: unknown | null;
|
|
26
|
+
};
|
|
27
|
+
warnings: string[];
|
|
28
|
+
}
|
|
29
|
+
export declare function buildToolSummaryManifest(toolId: string, opts: SummarizeOptions): Promise<GalaxyToolSummaryManifest | null>;
|
|
30
|
+
export declare function runSummarize(toolId: string, opts: SummarizeOptions): Promise<void>;
|
|
31
|
+
//# sourceMappingURL=summar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0 +1,85 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { writeFile } from "node:fs/promises";
|
|
3
|
+
import { getCacheDir, makeNodeToolCache } from "@galaxy-tool-util/core/node";
|
|
4
|
+
import { createFieldModel, } from "@galaxy-tool-util/schema";
|
|
5
|
+
import * as JSONSchema from "effect/JSONSchema";
|
|
6
|
+
import { isResolveError, loadCachedTool } from "./resolve-tool.js";
|
|
7
|
+
function sourceKind(label) {
|
|
8
|
+
if (label === "api")
|
|
9
|
+
return "toolshed";
|
|
10
|
+
if (label === "galaxy" || label === "local" || label === "orphan")
|
|
11
|
+
return label;
|
|
12
|
+
return "unknown";
|
|
13
|
+
}
|
|
14
|
+
function inputSchemaFor(tool, rep, warnings) {
|
|
15
|
+
const bundle = {
|
|
16
|
+
parameters: tool.inputs,
|
|
17
|
+
};
|
|
18
|
+
const effectSchema = createFieldModel(bundle, rep);
|
|
19
|
+
if (effectSchema === undefined) {
|
|
20
|
+
warnings.push(`${rep} input schema could not be generated for this tool`);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
return JSONSchema.make(effectSchema);
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
warnings.push(`${rep} input schema generation failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export async function buildToolSummaryManifest(toolId, opts) {
|
|
32
|
+
const cacheDir = getCacheDir(opts.cacheDir);
|
|
33
|
+
const cache = makeNodeToolCache({ cacheDir });
|
|
34
|
+
await cache.index.load();
|
|
35
|
+
const result = await loadCachedTool(cache, toolId, opts.version);
|
|
36
|
+
if (isResolveError(result)) {
|
|
37
|
+
if (result.kind === "no_version") {
|
|
38
|
+
console.error(`No version specified for tool: ${toolId}`);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.error(`Tool not found in cache: ${toolId}. Run 'galaxy-tool-cache add' first.`);
|
|
42
|
+
}
|
|
43
|
+
process.exitCode = 1;
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const indexEntry = (await cache.index.listAll()).find((entry) => entry.cache_key === result.key);
|
|
47
|
+
const warnings = [];
|
|
48
|
+
const manifest = {
|
|
49
|
+
schema_version: 1,
|
|
50
|
+
tool_id: result.tool.id,
|
|
51
|
+
tool_version: result.tool.version,
|
|
52
|
+
cache_key: result.key,
|
|
53
|
+
source: {
|
|
54
|
+
kind: sourceKind(indexEntry?.source),
|
|
55
|
+
label: indexEntry?.source ?? "unknown",
|
|
56
|
+
url: indexEntry?.source_url ?? "",
|
|
57
|
+
cached_at: indexEntry?.cached_at ?? null,
|
|
58
|
+
},
|
|
59
|
+
artifacts: {
|
|
60
|
+
parsed_tool_path: join(cacheDir, `${result.key}.json`),
|
|
61
|
+
raw_tool_source_path: null,
|
|
62
|
+
},
|
|
63
|
+
parsed_tool: result.tool,
|
|
64
|
+
input_schemas: {
|
|
65
|
+
workflow_step: inputSchemaFor(result.tool, "workflow_step", warnings),
|
|
66
|
+
workflow_step_linked: inputSchemaFor(result.tool, "workflow_step_linked", warnings),
|
|
67
|
+
},
|
|
68
|
+
warnings,
|
|
69
|
+
};
|
|
70
|
+
return manifest;
|
|
71
|
+
}
|
|
72
|
+
export async function runSummarize(toolId, opts) {
|
|
73
|
+
const manifest = await buildToolSummaryManifest(toolId, opts);
|
|
74
|
+
if (manifest === null)
|
|
75
|
+
return;
|
|
76
|
+
const output = `${JSON.stringify(manifest, null, 2)}\n`;
|
|
77
|
+
if (opts.output) {
|
|
78
|
+
await writeFile(opts.output, output);
|
|
79
|
+
console.log(`Summary written to ${opts.output}`);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
process.stdout.write(output);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=summarize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summarize.js","sourceRoot":"","sources":["../../src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H,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"galaxy-tool-cache.d.ts","sourceRoot":"","sources":["../../src/programs/galaxy-tool-cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuBzC,wBAAgB,2BAA2B,IAAI,OAAO,CAErD"}
|
|
@@ -4,6 +4,7 @@ import { runInfo } from "../commands/info.js";
|
|
|
4
4
|
import { runClear } from "../commands/clear.js";
|
|
5
5
|
import { runPopulateWorkflow } from "../commands/populate-workflow.js";
|
|
6
6
|
import { runSchema } from "../commands/schema.js";
|
|
7
|
+
import { runSummarize } from "../commands/summarize.js";
|
|
7
8
|
import { runStructuralSchema } from "../commands/structural-schema.js";
|
|
8
9
|
import { buildProgramFromSpec } from "../spec/build-program.js";
|
|
9
10
|
import { galaxyToolCacheSpec } from "../meta/specs.js";
|
|
@@ -13,6 +14,7 @@ const handlers = {
|
|
|
13
14
|
info: runInfo,
|
|
14
15
|
clear: runClear,
|
|
15
16
|
schema: runSchema,
|
|
17
|
+
summarize: runSummarize,
|
|
16
18
|
populateWorkflow: runPopulateWorkflow,
|
|
17
19
|
structuralSchema: runStructuralSchema,
|
|
18
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"galaxy-tool-cache.js","sourceRoot":"","sources":["../../src/programs/galaxy-tool-cache.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;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AAS;IACjB,SAAS,EAAE,YAAY;IACvB,gBAAgB,EAAE,mBAAmB;IACrC,gBAAgB,EAAE,mBAAmB;CACtC,CAAC;AAEF,MAAM,UAAU,2BAA2B;IACzC,OAAO,oBAAoB,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;AAC7D,CAAC"}
|
package/package.json
CHANGED
|
@@ -111,6 +111,31 @@
|
|
|
111
111
|
}
|
|
112
112
|
]
|
|
113
113
|
},
|
|
114
|
+
{
|
|
115
|
+
"name": "summarize",
|
|
116
|
+
"description": "Emit a deterministic summary manifest for a cached Galaxy tool",
|
|
117
|
+
"handler": "summarize",
|
|
118
|
+
"args": [
|
|
119
|
+
{
|
|
120
|
+
"raw": "<tool_id>",
|
|
121
|
+
"description": "Tool ID"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"options": [
|
|
125
|
+
{
|
|
126
|
+
"flags": "--version <ver>",
|
|
127
|
+
"description": "Tool version"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"flags": "--output <file>",
|
|
131
|
+
"description": "Output file (default: stdout)"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"flags": "--cache-dir <dir>",
|
|
135
|
+
"description": "Cache directory"
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
},
|
|
114
139
|
{
|
|
115
140
|
"name": "populate-workflow",
|
|
116
141
|
"description": "Scan a workflow and cache all referenced tools",
|