@omni-oss/create-jobs 0.1.6 → 0.1.7
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/CHANGELOG.md +12 -0
- package/dist/create-jobs.cjs +1 -1
- package/dist/create-jobs.d.ts +1 -1
- package/dist/create-jobs.d.ts.map +1 -1
- package/dist/create-jobs.mjs +12 -12
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/schemas-BnpD42eF.js +1 -0
- package/dist/{schemas-CeVQC8Uz.mjs → schemas-CySsa0xy.mjs} +56 -52
- package/package.json +2 -2
- package/src/cli/index.ts +2 -1
- package/src/create-jobs.spec.ts +42 -8
- package/src/create-jobs.ts +25 -25
- package/vite.config.ts +6 -1
- package/dist/schemas-CnXDgPym.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
|
|
3
3
|
|
|
4
4
|
- - -
|
|
5
|
+
## @omni-oss/create-jobs-v0.1.7 - 2026-02-10
|
|
6
|
+
#### Bug Fixes
|
|
7
|
+
- generic publish task - (f5d56c4) - Clarence Manuel
|
|
8
|
+
|
|
9
|
+
- - -
|
|
10
|
+
|
|
11
|
+
## @omni-oss/create-jobs-v0.1.6 - 2026-02-09
|
|
12
|
+
#### Bug Fixes
|
|
13
|
+
- (**@omni-oss/create-jobs**) support create jobs via is_*_task meta data - (d95dbca) - Clarence Manuel
|
|
14
|
+
|
|
15
|
+
- - -
|
|
16
|
+
|
|
5
17
|
## @omni-oss/create-jobs-v0.1.5 - 2026-02-09
|
|
6
18
|
#### Bug Fixes
|
|
7
19
|
- (**@omni-oss/create-jobs**) support sanitizing artifact names - (1ed9932) - Clarence Manuel
|
package/dist/create-jobs.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
"use strict";const
|
|
2
|
+
"use strict";const r=require("node:fs/promises"),i=require("@commander-js/extra-typings"),s=require("./schemas-BnpD42eF.js"),l=new i.Command;l.argument("<input>","The input file to read from.").option("-o, --output <output>","The output file to write to.").option("-r, --root <root>","Override the workspace root.").action(async(n,e)=>{const a=await r.readFile(n,"utf-8"),u=JSON.parse(a),t=s.TaskResultArraySchema.safeParse(u);if(t.success){const c=t.data,o=s.createJobs(c,e.root);e.output?await r.writeFile(e.output,JSON.stringify(o,null,2)):console.log(o)}else console.error(t.error),process.exit(1)}).parseAsync();
|
package/dist/create-jobs.d.ts
CHANGED
|
@@ -32,5 +32,5 @@ export type PublishJobs = {
|
|
|
32
32
|
generic: Job[];
|
|
33
33
|
rust_github: Job[];
|
|
34
34
|
};
|
|
35
|
-
export declare function createJobs(results: TaskResultArray): Jobs;
|
|
35
|
+
export declare function createJobs(results: TaskResultArray, rootDir?: string): Jobs;
|
|
36
36
|
//# sourceMappingURL=create-jobs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-jobs.d.ts","sourceRoot":"","sources":["../src/create-jobs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-jobs.d.ts","sourceRoot":"","sources":["../src/create-jobs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAc,eAAe,EAAE,MAAM,WAAW,CAAC;AAEnE,MAAM,MAAM,QAAQ,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,GAAG,GAAG;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE;QACP,SAAS,EAAE,QAAQ,CAAC;QACpB,OAAO,EAAE,QAAQ,CAAC;KACrB,CAAC;IACF,IAAI,EAAE,IAAI,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,WAAW,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,GAAG,EAAE,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACpB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,GAAG,EAAE,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACtB,GAAG,EAAE,GAAG,EAAE,CAAC;IACX,OAAO,EAAE,GAAG,EAAE,CAAC;IACf,WAAW,EAAE,GAAG,EAAE,CAAC;CACtB,CAAC;AAEF,wBAAgB,UAAU,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CA8D3E"}
|
package/dist/create-jobs.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import
|
|
2
|
+
import r from "node:fs/promises";
|
|
3
3
|
import { Command as u } from "@commander-js/extra-typings";
|
|
4
|
-
import { T as c, c as
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const a = await
|
|
8
|
-
if (
|
|
9
|
-
const i =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
JSON.stringify(
|
|
13
|
-
) : console.log(
|
|
4
|
+
import { T as c, c as p } from "./schemas-CySsa0xy.mjs";
|
|
5
|
+
const l = new u();
|
|
6
|
+
l.argument("<input>", "The input file to read from.").option("-o, --output <output>", "The output file to write to.").option("-r, --root <root>", "Override the workspace root.").action(async (s, t) => {
|
|
7
|
+
const a = await r.readFile(s, "utf-8"), n = JSON.parse(a), o = c.safeParse(n);
|
|
8
|
+
if (o.success) {
|
|
9
|
+
const i = o.data, e = p(i, t.root);
|
|
10
|
+
t.output ? await r.writeFile(
|
|
11
|
+
t.output,
|
|
12
|
+
JSON.stringify(e, null, 2)
|
|
13
|
+
) : console.log(e);
|
|
14
14
|
} else
|
|
15
|
-
console.error(
|
|
15
|
+
console.error(o.error), process.exit(1);
|
|
16
16
|
}).parseAsync();
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./schemas-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./schemas-BnpD42eF.js");exports.TaskResultArraySchema=e.TaskResultArraySchema;exports.TaskResultSchema=e.TaskResultSchema;exports.createJobs=e.createJobs;
|
package/dist/index.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("node:path"),u=require("node:process"),e=require("zod");function b(s,a){a||(a=u.cwd());const i={test:{rust:[],typescript:[]},build:{rust:[],typescript:[]},publish:{generic:[],npm:[],rust_github:[]}};for(const t of s){if(t.status==="skipped")continue;const o=t.task;(o.task_name==="test"||t.details.meta?.is_test_task)&&(t.details.meta?.language==="rust"&&i.test.rust.push(r(t,a)),t.details.meta?.language==="typescript"&&i.test.typescript.push(r(t,a))),(o.task_name==="build"||t.details.meta?.is_build_task)&&(t.details.meta?.language==="rust"&&i.build.rust.push(r(t,a)),t.details.meta?.language==="typescript"&&i.build.typescript.push(r(t,a))),(o.task_name==="publish"||t.details.meta?.is_publish_task)&&(t.details.meta?.language==="typescript"?i.publish.npm.push(r(t,a)):t.details.meta?.language==="rust"?i.publish.rust_github.push(r(t,a)):i.publish.generic.push(r(t,a)))}return i}function r(s,a){const i=[],t=[];if(s.details.output_files&&s.details.output_files.length>0)for(const o of s.details.output_files){const l=n.resolve(s.task.project_dir,o);m(s.task.project_dir,l)?t.push(n.relative(s.task.project_dir,l)):i.push(n.relative(a,l))}return{task_name:s.task.task_name,project_name:s.task.project_name,artifacts:{project:{name:`project-${c(s.task.project_name)}__${c(s.task.task_name)}`,files:t,files_count:t.length},workspace:{name:`workspace-${c(s.task.project_name)}__${c(s.task.task_name)}`,files:i,files_count:i.length}},project_dir:n.relative(a,s.task.project_dir),meta:s.details.meta??{}}}function m(s,a){const i=n.relative(s,a);return i&&!i.startsWith("..")&&!n.isAbsolute(i)}function c(s){let a=s.replace(/[/\\?%*:|"<> \x00-\x1f]/g,"_");return a=a.replace(/[.\s]+$/,""),/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i.test(a)&&(a+="_"),a||"unsaved_file"}const f=e.z.object({secs:e.z.number().int().nonnegative().describe("The number of whole seconds elapsed."),nanos:e.z.number().int().nonnegative().describe("The number of nanoseconds elapsed.")}),k=e.z.object({runner:e.z.string().describe("The runner to use for the target.")}),g=e.z.object({npm:e.z.boolean().optional().describe("Whether to publish to npm."),github:e.z.boolean().optional().describe("Whether to publish to github.")}),_=e.z.object({type:e.z.string().optional().describe("The type of project (e.g., library, service, application)."),language:e.z.string().optional().describe("The primary language of the project."),targets:e.z.record(e.z.string(),k).optional().describe("The targets to build."),release:g.optional(),is_publish_task:e.z.boolean().optional().describe("Whether this is a publish job."),is_build_task:e.z.boolean().optional().describe("Whether this is a build job."),is_test_task:e.z.boolean().optional().describe("Whether this is a test job.")}),p=e.z.object({meta:_.optional(),output_files:e.z.array(e.z.string()).optional().describe("The output files generated.")}),d=e.z.object({task_name:e.z.string().describe("The short name of the task (e.g., 'test', 'build')."),task_command:e.z.string().describe("The command executed for the task."),project_name:e.z.string().describe("The name of the project."),project_dir:e.z.string().describe("The absolute directory path of the project."),full_task_name:e.z.string().describe("The fully qualified task name (e.g., 'omni_utils#test')."),dependencies:e.z.array(e.z.string()).describe("A list of dependent task names."),enabled:e.z.boolean().or(e.z.string()).optional().describe("Whether the task is enabled by configuration. Either a boolean or a tera template string that evaluates to a boolean."),interactive:e.z.boolean().describe("Whether the task is interactive."),persistent:e.z.boolean().describe("Whether the task is persistent.")}),z=e.z.object({status:e.z.literal("completed"),hash:e.z.string().describe("The task's content hash (Base64 encoded string). Used for caching."),task:d,exit_code:e.z.number().int().describe("The exit code of the executed command (typically 0 for success)."),elapsed:f.describe("The duration the task took to execute."),cache_hit:e.z.boolean().describe("Indicates if the result was pulled from cache."),details:p}),j=e.z.object({status:e.z.literal("errored"),task:d,error:e.z.string().describe("The error message."),details:p}),T=e.z.object({status:e.z.literal("skipped"),task:d,skip_reason:e.z.string().describe("The reason the task was skipped (e.g., 'disabled')."),details:p}),h=e.z.discriminatedUnion("status",[z,T,j]).describe("Schema for a single task execution result (completed or skipped)."),y=e.z.array(h).describe("An array of task execution results.");exports.TaskResultArraySchema=y;exports.TaskResultSchema=h;exports.createJobs=b;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from "node:path";
|
|
2
|
+
import h from "node:process";
|
|
2
3
|
import { z as e } from "zod";
|
|
3
|
-
function
|
|
4
|
-
|
|
4
|
+
function x(s, a) {
|
|
5
|
+
a || (a = h.cwd());
|
|
6
|
+
const i = {
|
|
5
7
|
test: {
|
|
6
8
|
rust: [],
|
|
7
9
|
typescript: []
|
|
@@ -16,68 +18,70 @@ function y(a) {
|
|
|
16
18
|
rust_github: []
|
|
17
19
|
}
|
|
18
20
|
};
|
|
19
|
-
for (const t of
|
|
21
|
+
for (const t of s) {
|
|
20
22
|
if (t.status === "skipped")
|
|
21
23
|
continue;
|
|
22
|
-
const
|
|
23
|
-
(
|
|
24
|
+
const n = t.task;
|
|
25
|
+
(n.task_name === "test" || t.details.meta?.is_test_task) && (t.details.meta?.language === "rust" && i.test.rust.push(r(t, a)), t.details.meta?.language === "typescript" && i.test.typescript.push(r(t, a))), (n.task_name === "build" || t.details.meta?.is_build_task) && (t.details.meta?.language === "rust" && i.build.rust.push(r(t, a)), t.details.meta?.language === "typescript" && i.build.typescript.push(r(t, a))), (n.task_name === "publish" || t.details.meta?.is_publish_task) && (t.details.meta?.language === "typescript" ? i.publish.npm.push(r(t, a)) : t.details.meta?.language === "rust" ? i.publish.rust_github.push(r(t, a)) : i.publish.generic.push(r(t, a)));
|
|
24
26
|
}
|
|
25
|
-
return
|
|
27
|
+
return i;
|
|
26
28
|
}
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
for (const
|
|
31
|
-
const
|
|
32
|
-
|
|
29
|
+
function r(s, a) {
|
|
30
|
+
const i = [], t = [];
|
|
31
|
+
if (s.details.output_files && s.details.output_files.length > 0)
|
|
32
|
+
for (const n of s.details.output_files) {
|
|
33
|
+
const l = o.resolve(s.task.project_dir, n);
|
|
34
|
+
u(s.task.project_dir, l) ? t.push(
|
|
35
|
+
o.relative(s.task.project_dir, l)
|
|
36
|
+
) : i.push(o.relative(a, l));
|
|
33
37
|
}
|
|
34
38
|
return {
|
|
35
|
-
task_name:
|
|
36
|
-
project_name:
|
|
39
|
+
task_name: s.task.task_name,
|
|
40
|
+
project_name: s.task.project_name,
|
|
37
41
|
artifacts: {
|
|
38
42
|
project: {
|
|
39
|
-
name: `project-${
|
|
43
|
+
name: `project-${c(s.task.project_name)}__${c(s.task.task_name)}`,
|
|
40
44
|
files: t,
|
|
41
45
|
files_count: t.length
|
|
42
46
|
},
|
|
43
47
|
workspace: {
|
|
44
|
-
name: `workspace-${
|
|
45
|
-
files:
|
|
46
|
-
files_count:
|
|
48
|
+
name: `workspace-${c(s.task.project_name)}__${c(s.task.task_name)}`,
|
|
49
|
+
files: i,
|
|
50
|
+
files_count: i.length
|
|
47
51
|
}
|
|
48
52
|
},
|
|
49
|
-
project_dir: a.task.project_dir,
|
|
50
|
-
meta:
|
|
53
|
+
project_dir: o.relative(a, s.task.project_dir),
|
|
54
|
+
meta: s.details.meta ?? {}
|
|
51
55
|
};
|
|
52
56
|
}
|
|
53
|
-
function
|
|
54
|
-
const
|
|
55
|
-
return
|
|
57
|
+
function u(s, a) {
|
|
58
|
+
const i = o.relative(s, a);
|
|
59
|
+
return i && !i.startsWith("..") && !o.isAbsolute(i);
|
|
56
60
|
}
|
|
57
|
-
function
|
|
58
|
-
let
|
|
59
|
-
return
|
|
61
|
+
function c(s) {
|
|
62
|
+
let a = s.replace(/[/\\?%*:|"<> \x00-\x1f]/g, "_");
|
|
63
|
+
return a = a.replace(/[.\s]+$/, ""), /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i.test(a) && (a += "_"), a || "unsaved_file";
|
|
60
64
|
}
|
|
61
|
-
const
|
|
65
|
+
const b = e.object({
|
|
62
66
|
secs: e.number().int().nonnegative().describe("The number of whole seconds elapsed."),
|
|
63
67
|
nanos: e.number().int().nonnegative().describe("The number of nanoseconds elapsed.")
|
|
64
|
-
}),
|
|
68
|
+
}), m = e.object({
|
|
65
69
|
runner: e.string().describe("The runner to use for the target.")
|
|
66
|
-
}),
|
|
70
|
+
}), f = e.object({
|
|
67
71
|
npm: e.boolean().optional().describe("Whether to publish to npm."),
|
|
68
72
|
github: e.boolean().optional().describe("Whether to publish to github.")
|
|
69
|
-
}),
|
|
73
|
+
}), g = e.object({
|
|
70
74
|
type: e.string().optional().describe("The type of project (e.g., library, service, application)."),
|
|
71
75
|
language: e.string().optional().describe("The primary language of the project."),
|
|
72
|
-
targets: e.record(e.string(),
|
|
73
|
-
release:
|
|
76
|
+
targets: e.record(e.string(), m).optional().describe("The targets to build."),
|
|
77
|
+
release: f.optional(),
|
|
74
78
|
is_publish_task: e.boolean().optional().describe("Whether this is a publish job."),
|
|
75
79
|
is_build_task: e.boolean().optional().describe("Whether this is a build job."),
|
|
76
80
|
is_test_task: e.boolean().optional().describe("Whether this is a test job.")
|
|
77
|
-
}), l = e.object({
|
|
78
|
-
meta: m.optional(),
|
|
79
|
-
output_files: e.array(e.string()).optional().describe("The output files generated.")
|
|
80
81
|
}), p = e.object({
|
|
82
|
+
meta: g.optional(),
|
|
83
|
+
output_files: e.array(e.string()).optional().describe("The output files generated.")
|
|
84
|
+
}), d = e.object({
|
|
81
85
|
task_name: e.string().describe("The short name of the task (e.g., 'test', 'build')."),
|
|
82
86
|
task_command: e.string().describe("The command executed for the task."),
|
|
83
87
|
project_name: e.string().describe("The name of the project."),
|
|
@@ -94,32 +98,32 @@ const d = e.object({
|
|
|
94
98
|
hash: e.string().describe(
|
|
95
99
|
"The task's content hash (Base64 encoded string). Used for caching."
|
|
96
100
|
),
|
|
97
|
-
task:
|
|
101
|
+
task: d,
|
|
98
102
|
exit_code: e.number().int().describe(
|
|
99
103
|
"The exit code of the executed command (typically 0 for success)."
|
|
100
104
|
),
|
|
101
|
-
elapsed:
|
|
105
|
+
elapsed: b.describe("The duration the task took to execute."),
|
|
102
106
|
cache_hit: e.boolean().describe("Indicates if the result was pulled from cache."),
|
|
103
|
-
details:
|
|
104
|
-
}),
|
|
107
|
+
details: p
|
|
108
|
+
}), _ = e.object({
|
|
105
109
|
status: e.literal("errored"),
|
|
106
|
-
task:
|
|
110
|
+
task: d,
|
|
107
111
|
error: e.string().describe("The error message."),
|
|
108
|
-
details:
|
|
109
|
-
}),
|
|
112
|
+
details: p
|
|
113
|
+
}), j = e.object({
|
|
110
114
|
status: e.literal("skipped"),
|
|
111
|
-
task:
|
|
115
|
+
task: d,
|
|
112
116
|
skip_reason: e.string().describe("The reason the task was skipped (e.g., 'disabled')."),
|
|
113
|
-
details:
|
|
114
|
-
}),
|
|
117
|
+
details: p
|
|
118
|
+
}), T = e.discriminatedUnion("status", [
|
|
115
119
|
k,
|
|
116
|
-
|
|
117
|
-
|
|
120
|
+
j,
|
|
121
|
+
_
|
|
118
122
|
]).describe(
|
|
119
123
|
"Schema for a single task execution result (completed or skipped)."
|
|
120
|
-
),
|
|
124
|
+
), W = e.array(T).describe("An array of task execution results.");
|
|
121
125
|
export {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
W as T,
|
|
127
|
+
T as a,
|
|
128
|
+
x as c
|
|
125
129
|
};
|
package/package.json
CHANGED
package/src/cli/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ const command = new Command();
|
|
|
8
8
|
command
|
|
9
9
|
.argument("<input>", "The input file to read from.")
|
|
10
10
|
.option("-o, --output <output>", "The output file to write to.")
|
|
11
|
+
.option("-r, --root <root>", "Override the workspace root.")
|
|
11
12
|
.action(async (input, options) => {
|
|
12
13
|
const inputFile = await fsAsync.readFile(input, "utf-8");
|
|
13
14
|
const results = JSON.parse(inputFile);
|
|
@@ -15,7 +16,7 @@ command
|
|
|
15
16
|
|
|
16
17
|
if (result.success) {
|
|
17
18
|
const data = result.data;
|
|
18
|
-
const processed = createJobs(data);
|
|
19
|
+
const processed = createJobs(data, options.root);
|
|
19
20
|
if (options.output) {
|
|
20
21
|
await fsAsync.writeFile(
|
|
21
22
|
options.output,
|
package/src/create-jobs.spec.ts
CHANGED
|
@@ -53,14 +53,14 @@ describe("createJobs", () => {
|
|
|
53
53
|
},
|
|
54
54
|
];
|
|
55
55
|
|
|
56
|
-
const jobs = createJobs(results);
|
|
56
|
+
const jobs = createJobs(results, "/mnt/c/Users/user");
|
|
57
57
|
|
|
58
58
|
expect(jobs.test.rust[0]).toMatchObject({
|
|
59
59
|
project_name: "rust-app",
|
|
60
60
|
task_name: "test",
|
|
61
61
|
artifacts: {
|
|
62
62
|
project: {
|
|
63
|
-
files: ["
|
|
63
|
+
files: ["binary"],
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
66
|
});
|
|
@@ -77,7 +77,12 @@ describe("createJobs", () => {
|
|
|
77
77
|
project_name: "js-pkg",
|
|
78
78
|
project_dir: "/mnt/c/Users/user/project",
|
|
79
79
|
},
|
|
80
|
-
details: {
|
|
80
|
+
details: {
|
|
81
|
+
meta: {
|
|
82
|
+
language: "typescript",
|
|
83
|
+
release: { npm: true },
|
|
84
|
+
},
|
|
85
|
+
},
|
|
81
86
|
},
|
|
82
87
|
{
|
|
83
88
|
status: "success",
|
|
@@ -140,14 +145,14 @@ describe("createJobs", () => {
|
|
|
140
145
|
},
|
|
141
146
|
];
|
|
142
147
|
|
|
143
|
-
const jobs = createJobs(results);
|
|
148
|
+
const jobs = createJobs(results, "/mnt/c/Users/usert");
|
|
144
149
|
|
|
145
150
|
expect(jobs.test.rust[0]).toMatchObject({
|
|
146
151
|
project_name: "minimal",
|
|
147
152
|
task_name: "test",
|
|
148
153
|
artifacts: {
|
|
149
154
|
project: {
|
|
150
|
-
files: ["
|
|
155
|
+
files: ["target/debug/minimal"],
|
|
151
156
|
},
|
|
152
157
|
},
|
|
153
158
|
});
|
|
@@ -169,14 +174,14 @@ describe("createJobs", () => {
|
|
|
169
174
|
},
|
|
170
175
|
];
|
|
171
176
|
|
|
172
|
-
const jobs = createJobs(results);
|
|
177
|
+
const jobs = createJobs(results, "/mnt/c/Users/user");
|
|
173
178
|
|
|
174
179
|
expect(jobs.test.rust[0]).toMatchObject({
|
|
175
180
|
project_name: "minimal",
|
|
176
181
|
task_name: "test",
|
|
177
182
|
artifacts: {
|
|
178
183
|
workspace: {
|
|
179
|
-
files: ["
|
|
184
|
+
files: ["target/debug/minimal"],
|
|
180
185
|
},
|
|
181
186
|
},
|
|
182
187
|
});
|
|
@@ -226,7 +231,11 @@ describe("createJobs", () => {
|
|
|
226
231
|
project_dir: "/mnt/c/Users/user/project",
|
|
227
232
|
},
|
|
228
233
|
details: {
|
|
229
|
-
meta: {
|
|
234
|
+
meta: {
|
|
235
|
+
language: "typescript",
|
|
236
|
+
release: { npm: true },
|
|
237
|
+
is_publish_task: true,
|
|
238
|
+
},
|
|
230
239
|
},
|
|
231
240
|
},
|
|
232
241
|
{
|
|
@@ -334,4 +343,29 @@ describe("createJobs", () => {
|
|
|
334
343
|
expect(jobs.test.rust[0]?.project_name).toBe("rust-app");
|
|
335
344
|
expect(jobs.test.rust[1]?.project_name).toBe("rust-pkg");
|
|
336
345
|
});
|
|
346
|
+
|
|
347
|
+
it("should handle generic publish tasks correctly", () => {
|
|
348
|
+
const results: any[] = [
|
|
349
|
+
{
|
|
350
|
+
status: "success",
|
|
351
|
+
task: {
|
|
352
|
+
task_name: "publish",
|
|
353
|
+
project_name: "rust-pkg",
|
|
354
|
+
project_dir: "/mnt/c/Users/user/project",
|
|
355
|
+
},
|
|
356
|
+
details: {
|
|
357
|
+
meta: {
|
|
358
|
+
release: { github: true },
|
|
359
|
+
is_publish_task: true,
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
];
|
|
364
|
+
|
|
365
|
+
const jobs = createJobs(results);
|
|
366
|
+
|
|
367
|
+
// Checks generic logic: task_name must be "publish" AND meta.release.github must be true
|
|
368
|
+
expect(jobs.publish.generic).toHaveLength(1);
|
|
369
|
+
expect(jobs.publish.generic[0]?.project_name).toBe("rust-pkg");
|
|
370
|
+
});
|
|
337
371
|
});
|
package/src/create-jobs.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import process from "node:process";
|
|
2
3
|
import type { Meta, TaskResult, TaskResultArray } from "./schemas";
|
|
3
4
|
|
|
4
5
|
export type Artifact = {
|
|
@@ -40,7 +41,11 @@ export type PublishJobs = {
|
|
|
40
41
|
rust_github: Job[];
|
|
41
42
|
};
|
|
42
43
|
|
|
43
|
-
export function createJobs(results: TaskResultArray): Jobs {
|
|
44
|
+
export function createJobs(results: TaskResultArray, rootDir?: string): Jobs {
|
|
45
|
+
if (!rootDir) {
|
|
46
|
+
rootDir = process.cwd();
|
|
47
|
+
}
|
|
48
|
+
|
|
44
49
|
const jobs: Jobs = {
|
|
45
50
|
test: {
|
|
46
51
|
rust: [],
|
|
@@ -65,49 +70,42 @@ export function createJobs(results: TaskResultArray): Jobs {
|
|
|
65
70
|
const task = result.task;
|
|
66
71
|
if (task.task_name === "test" || result.details.meta?.is_test_task) {
|
|
67
72
|
if (result.details.meta?.language === "rust") {
|
|
68
|
-
jobs.test.rust.push(jobFromResult(result));
|
|
73
|
+
jobs.test.rust.push(jobFromResult(result, rootDir));
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
if (result.details.meta?.language === "typescript") {
|
|
72
|
-
jobs.test.typescript.push(jobFromResult(result));
|
|
77
|
+
jobs.test.typescript.push(jobFromResult(result, rootDir));
|
|
73
78
|
}
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
if (task.task_name === "build" || result.details.meta?.is_build_task) {
|
|
77
82
|
if (result.details.meta?.language === "rust") {
|
|
78
|
-
jobs.build.rust.push(jobFromResult(result));
|
|
83
|
+
jobs.build.rust.push(jobFromResult(result, rootDir));
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
if (result.details.meta?.language === "typescript") {
|
|
82
|
-
jobs.build.typescript.push(jobFromResult(result));
|
|
87
|
+
jobs.build.typescript.push(jobFromResult(result, rootDir));
|
|
83
88
|
}
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
if (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
result.details.meta?.release?.npm
|
|
90
|
-
) {
|
|
91
|
-
jobs.publish.npm.push(jobFromResult(result));
|
|
92
|
-
} else if (
|
|
93
|
-
result.details.meta?.release?.github &&
|
|
94
|
-
result.details.meta?.language === "rust" &&
|
|
95
|
-
(result.task.task_name === "publish" ||
|
|
96
|
-
result.details.meta.is_publish_task)
|
|
97
|
-
) {
|
|
98
|
-
jobs.publish.rust_github.push(jobFromResult(result));
|
|
99
|
-
} else if (
|
|
100
|
-
result.details.meta?.is_publish_task ||
|
|
101
|
-
result.task.task_name === "publish"
|
|
92
|
+
task.task_name === "publish" ||
|
|
93
|
+
result.details.meta?.is_publish_task
|
|
102
94
|
) {
|
|
103
|
-
|
|
95
|
+
if (result.details.meta?.language === "typescript") {
|
|
96
|
+
jobs.publish.npm.push(jobFromResult(result, rootDir));
|
|
97
|
+
} else if (result.details.meta?.language === "rust") {
|
|
98
|
+
jobs.publish.rust_github.push(jobFromResult(result, rootDir));
|
|
99
|
+
} else {
|
|
100
|
+
jobs.publish.generic.push(jobFromResult(result, rootDir));
|
|
101
|
+
}
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
104
|
|
|
107
105
|
return jobs;
|
|
108
106
|
}
|
|
109
107
|
|
|
110
|
-
function jobFromResult(result: TaskResult): Job {
|
|
108
|
+
function jobFromResult(result: TaskResult, rootDir: string): Job {
|
|
111
109
|
const workspaceArtifacts = [] as string[];
|
|
112
110
|
const projectArtifacts = [] as string[];
|
|
113
111
|
|
|
@@ -116,9 +114,11 @@ function jobFromResult(result: TaskResult): Job {
|
|
|
116
114
|
const fullPath = path.resolve(result.task.project_dir, file);
|
|
117
115
|
|
|
118
116
|
if (isPathInside(result.task.project_dir, fullPath)) {
|
|
119
|
-
projectArtifacts.push(
|
|
117
|
+
projectArtifacts.push(
|
|
118
|
+
path.relative(result.task.project_dir, fullPath),
|
|
119
|
+
);
|
|
120
120
|
} else {
|
|
121
|
-
workspaceArtifacts.push(fullPath);
|
|
121
|
+
workspaceArtifacts.push(path.relative(rootDir, fullPath));
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
@@ -138,7 +138,7 @@ function jobFromResult(result: TaskResult): Job {
|
|
|
138
138
|
files_count: workspaceArtifacts.length,
|
|
139
139
|
},
|
|
140
140
|
},
|
|
141
|
-
project_dir: result.task.project_dir,
|
|
141
|
+
project_dir: path.relative(rootDir, result.task.project_dir),
|
|
142
142
|
meta: result.details.meta ?? {},
|
|
143
143
|
};
|
|
144
144
|
}
|
package/vite.config.ts
CHANGED
|
@@ -6,7 +6,12 @@ const baseConfig = createBaseConfig({
|
|
|
6
6
|
generateTypes: true,
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
const externalNodeDeps = [
|
|
9
|
+
const externalNodeDeps = [
|
|
10
|
+
"node:path",
|
|
11
|
+
"node:fs",
|
|
12
|
+
"node:fs/promises",
|
|
13
|
+
"node:process",
|
|
14
|
+
];
|
|
10
15
|
|
|
11
16
|
export default mergeConfig(baseConfig, {
|
|
12
17
|
build: {
|
package/dist/schemas-CnXDgPym.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const c=require("node:path"),e=require("zod");function d(a){const s={test:{rust:[],typescript:[]},build:{rust:[],typescript:[]},publish:{generic:[],npm:[],rust_github:[]}};for(const t of a){if(t.status==="skipped")continue;const r=t.task;(r.task_name==="test"||t.details.meta?.is_test_task)&&(t.details.meta?.language==="rust"&&s.test.rust.push(i(t)),t.details.meta?.language==="typescript"&&s.test.typescript.push(i(t))),(r.task_name==="build"||t.details.meta?.is_build_task)&&(t.details.meta?.language==="rust"&&s.build.rust.push(i(t)),t.details.meta?.language==="typescript"&&s.build.typescript.push(i(t))),(r.task_name==="publish"||t.details.meta?.is_publish_task)&&t.details.meta?.release?.npm?s.publish.npm.push(i(t)):t.details.meta?.release?.github&&t.details.meta?.language==="rust"&&(t.task.task_name==="publish"||t.details.meta.is_publish_task)?s.publish.rust_github.push(i(t)):(t.details.meta?.is_publish_task||t.task.task_name==="publish")&&s.publish.generic.push(i(t))}return s}function i(a){const s=[],t=[];if(a.details.output_files&&a.details.output_files.length>0)for(const r of a.details.output_files){const n=c.resolve(a.task.project_dir,r);u(a.task.project_dir,n)?t.push(n):s.push(n)}return{task_name:a.task.task_name,project_name:a.task.project_name,artifacts:{project:{name:`project-${o(a.task.project_name)}__${o(a.task.task_name)}`,files:t,files_count:t.length},workspace:{name:`workspace-${o(a.task.project_name)}__${o(a.task.task_name)}`,files:s,files_count:s.length}},project_dir:a.task.project_dir,meta:a.details.meta??{}}}function u(a,s){const t=c.relative(a,s);return t&&!t.startsWith("..")&&!c.isAbsolute(t)}function o(a){let s=a.replace(/[/\\?%*:|"<> \x00-\x1f]/g,"_");return s=s.replace(/[.\s]+$/,""),/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i.test(s)&&(s+="_"),s||"unsaved_file"}const b=e.z.object({secs:e.z.number().int().nonnegative().describe("The number of whole seconds elapsed."),nanos:e.z.number().int().nonnegative().describe("The number of nanoseconds elapsed.")}),m=e.z.object({runner:e.z.string().describe("The runner to use for the target.")}),k=e.z.object({npm:e.z.boolean().optional().describe("Whether to publish to npm."),github:e.z.boolean().optional().describe("Whether to publish to github.")}),f=e.z.object({type:e.z.string().optional().describe("The type of project (e.g., library, service, application)."),language:e.z.string().optional().describe("The primary language of the project."),targets:e.z.record(e.z.string(),m).optional().describe("The targets to build."),release:k.optional(),is_publish_task:e.z.boolean().optional().describe("Whether this is a publish job."),is_build_task:e.z.boolean().optional().describe("Whether this is a build job."),is_test_task:e.z.boolean().optional().describe("Whether this is a test job.")}),l=e.z.object({meta:f.optional(),output_files:e.z.array(e.z.string()).optional().describe("The output files generated.")}),h=e.z.object({task_name:e.z.string().describe("The short name of the task (e.g., 'test', 'build')."),task_command:e.z.string().describe("The command executed for the task."),project_name:e.z.string().describe("The name of the project."),project_dir:e.z.string().describe("The absolute directory path of the project."),full_task_name:e.z.string().describe("The fully qualified task name (e.g., 'omni_utils#test')."),dependencies:e.z.array(e.z.string()).describe("A list of dependent task names."),enabled:e.z.boolean().or(e.z.string()).optional().describe("Whether the task is enabled by configuration. Either a boolean or a tera template string that evaluates to a boolean."),interactive:e.z.boolean().describe("Whether the task is interactive."),persistent:e.z.boolean().describe("Whether the task is persistent.")}),g=e.z.object({status:e.z.literal("completed"),hash:e.z.string().describe("The task's content hash (Base64 encoded string). Used for caching."),task:h,exit_code:e.z.number().int().describe("The exit code of the executed command (typically 0 for success)."),elapsed:b.describe("The duration the task took to execute."),cache_hit:e.z.boolean().describe("Indicates if the result was pulled from cache."),details:l}),_=e.z.object({status:e.z.literal("errored"),task:h,error:e.z.string().describe("The error message."),details:l}),z=e.z.object({status:e.z.literal("skipped"),task:h,skip_reason:e.z.string().describe("The reason the task was skipped (e.g., 'disabled')."),details:l}),p=e.z.discriminatedUnion("status",[g,z,_]).describe("Schema for a single task execution result (completed or skipped)."),j=e.z.array(p).describe("An array of task execution results.");exports.TaskResultArraySchema=j;exports.TaskResultSchema=p;exports.createJobs=d;
|