@toloka-platform/sdk 0.26.0 → 0.26.1
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/cli/toloka.js +178 -176
- package/dist/cli/toloka.js.jsc +0 -0
- package/dist/cli/toloka.js.jsc.sha256 +1 -1
- package/dist/cli/toloka.js.sha256 +1 -1
- package/package.json +2 -2
- package/skills/catalog.json +6 -6
- package/skills/toloka-build/SKILL.md +8 -6
- package/skills/toloka-build/references/workflow-and-cli.md +6 -6
- package/src/cli/check.ts +60 -30
- package/src/cli/commands/source.ts +14 -6
- package/src/cli/pipeline-selector.ts +68 -0
- package/src/cli/project.ts +47 -27
- package/src/cli/runs.ts +9 -0
- package/src/cli/source.ts +16 -2
package/src/cli/runs.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { TolokaState } from "../state";
|
|
|
5
5
|
import type { RunItem, RunJob } from "../index";
|
|
6
6
|
import { assertCli } from "./cli-error";
|
|
7
7
|
import { apiErrorDetails } from "./format-error";
|
|
8
|
+
import { matchesNormalizedPipelineName } from "./pipeline-selector";
|
|
8
9
|
|
|
9
10
|
export type PipelineRef = {
|
|
10
11
|
readonly pipelineId: string;
|
|
@@ -183,6 +184,14 @@ const resolveToken = (token: string, live: readonly PipelineRef[]): PipelineRef
|
|
|
183
184
|
);
|
|
184
185
|
if (basename !== undefined) return basename;
|
|
185
186
|
|
|
187
|
+
const normalized = live.filter((ref) => matchesNormalizedPipelineName(token, ref));
|
|
188
|
+
const byNormalizedName = uniqueMatch(
|
|
189
|
+
normalized,
|
|
190
|
+
`Multiple pipelines match ${token}: ${normalized.map(formatPipelineChoice).join(", ")}.`,
|
|
191
|
+
unknown,
|
|
192
|
+
);
|
|
193
|
+
if (byNormalizedName !== undefined) return byNormalizedName;
|
|
194
|
+
|
|
186
195
|
assertCli(
|
|
187
196
|
false,
|
|
188
197
|
unknown,
|
package/src/cli/source.ts
CHANGED
|
@@ -56,8 +56,22 @@ export async function findSourceRoot(startDirectory: string): Promise<string | u
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
const sourceDirectoryOf = (sourceRoot: string, modulePath: string) =>
|
|
60
|
+
relative(sourceRoot, dirname(modulePath)).split(sep).join("/");
|
|
61
|
+
|
|
62
|
+
export async function listPipelineSourceDirectories(sourceRoot: string): Promise<string[]> {
|
|
60
63
|
const modulePaths = await findPipelineModules(join(sourceRoot, "pipelines"));
|
|
64
|
+
return modulePaths.map((modulePath) => sourceDirectoryOf(sourceRoot, modulePath));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export async function loadProjectSource(
|
|
68
|
+
sourceRoot: string,
|
|
69
|
+
sourceDirectories?: readonly string[],
|
|
70
|
+
): Promise<ProjectSource> {
|
|
71
|
+
const selected = sourceDirectories === undefined ? undefined : new Set(sourceDirectories);
|
|
72
|
+
const modulePaths = (await findPipelineModules(join(sourceRoot, "pipelines"))).filter(
|
|
73
|
+
(modulePath) => selected === undefined || selected.has(sourceDirectoryOf(sourceRoot, modulePath)),
|
|
74
|
+
);
|
|
61
75
|
const pipelines = await Promise.all(
|
|
62
76
|
modulePaths.map(async (modulePath) => {
|
|
63
77
|
const moduleStat = await stat(modulePath);
|
|
@@ -71,7 +85,7 @@ export async function loadProjectSource(sourceRoot: string): Promise<ProjectSour
|
|
|
71
85
|
);
|
|
72
86
|
const definition: unknown = Reflect.get(module, "default");
|
|
73
87
|
validatePipelineDefinition(definition);
|
|
74
|
-
const sourceDirectory =
|
|
88
|
+
const sourceDirectory = sourceDirectoryOf(sourceRoot, modulePath);
|
|
75
89
|
return {
|
|
76
90
|
sourceDirectory,
|
|
77
91
|
name: basename(sourceDirectory),
|