@omni-oss/create-jobs 0.0.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/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/create-jobs.cjs +1 -0
- package/dist/create-jobs.mjs +15 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +6 -0
- package/dist/schemas.d.ts +324 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/utils-CSiXyoWV.mjs +96 -0
- package/dist/utils-DeP5M93O.js +1 -0
- package/dist/utils.d.ts +26 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +34 -0
- package/project.omni.yaml +29 -0
- package/src/cli/index.ts +31 -0
- package/src/index.ts +2 -0
- package/src/schemas.ts +172 -0
- package/src/utils.ts +95 -0
- package/tsconfig.json +3 -0
- package/tsconfig.project.json +5 -0
- package/tsconfig.types.json +3 -0
- package/vite.config.ts +30 -0
- package/vitest.config.integration.ts +12 -0
- package/vitest.config.unit.ts +13 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o=require("node:fs/promises"),c=require("@commander-js/extra-typings"),r=require("./utils-DeP5M93O.js"),l=new c.Command;l.argument("<input>","The input file to read from.").option("-o, --output <output>","The output file to write to.").action(async(n,t)=>{const u=await o.readFile(n,"utf-8"),a=JSON.parse(u),e=r.TaskResultArraySchema.safeParse(a);if(e.success){const i=e.data,s=r.createJobs(i);t.output?await o.writeFile(t.output,JSON.stringify(s,null,2)):console.log(s)}else console.error(e.error),process.exit(1)}).parseAsync();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import s from "node:fs/promises";
|
|
2
|
+
import { Command as c } from "@commander-js/extra-typings";
|
|
3
|
+
import { T as u, c as l } from "./utils-CSiXyoWV.mjs";
|
|
4
|
+
const p = new c();
|
|
5
|
+
p.argument("<input>", "The input file to read from.").option("-o, --output <output>", "The output file to write to.").action(async (r, e) => {
|
|
6
|
+
const a = await s.readFile(r, "utf-8"), i = JSON.parse(a), t = u.safeParse(i);
|
|
7
|
+
if (t.success) {
|
|
8
|
+
const n = t.data, o = l(n);
|
|
9
|
+
e.output ? await s.writeFile(
|
|
10
|
+
e.output,
|
|
11
|
+
JSON.stringify(o, null, 2)
|
|
12
|
+
) : console.log(o);
|
|
13
|
+
} else
|
|
14
|
+
console.error(t.error), process.exit(1);
|
|
15
|
+
}).parseAsync();
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./utils-DeP5M93O.js");exports.TaskResultArraySchema=e.TaskResultArraySchema;exports.TaskResultSchema=e.TaskResultSchema;exports.createJobs=e.createJobs;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Defines the structure for the duration object.
|
|
4
|
+
*/
|
|
5
|
+
declare const ElapsedSchema: z.ZodObject<{
|
|
6
|
+
secs: z.ZodNumber;
|
|
7
|
+
nanos: z.ZodNumber;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
/**
|
|
10
|
+
* Defines the metadata for the project/task details.
|
|
11
|
+
*/
|
|
12
|
+
declare const MetaSchema: z.ZodObject<{
|
|
13
|
+
type: z.ZodOptional<z.ZodString>;
|
|
14
|
+
language: z.ZodOptional<z.ZodString>;
|
|
15
|
+
targets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
16
|
+
runner: z.ZodString;
|
|
17
|
+
build_flags: z.ZodOptional<z.ZodString>;
|
|
18
|
+
test_flags: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strip>>>;
|
|
20
|
+
release: z.ZodOptional<z.ZodObject<{
|
|
21
|
+
npm: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
github: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
}, z.core.$strip>>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
/**
|
|
26
|
+
* Defines the details of the task that was run or skipped.
|
|
27
|
+
*/
|
|
28
|
+
declare const TaskSchema: z.ZodObject<{
|
|
29
|
+
task_name: z.ZodString;
|
|
30
|
+
task_command: z.ZodString;
|
|
31
|
+
project_name: z.ZodString;
|
|
32
|
+
project_dir: z.ZodString;
|
|
33
|
+
full_task_name: z.ZodString;
|
|
34
|
+
dependencies: z.ZodArray<z.ZodString>;
|
|
35
|
+
enabled: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
36
|
+
interactive: z.ZodBoolean;
|
|
37
|
+
persistent: z.ZodBoolean;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
/**
|
|
40
|
+
* Schema for a task that successfully completed.
|
|
41
|
+
* Note: 'elapsed', 'exit_code', 'hash', and 'cache_hit' are required here.
|
|
42
|
+
*/
|
|
43
|
+
declare const CompletedTaskSchema: z.ZodObject<{
|
|
44
|
+
status: z.ZodLiteral<"completed">;
|
|
45
|
+
hash: z.ZodString;
|
|
46
|
+
task: z.ZodObject<{
|
|
47
|
+
task_name: z.ZodString;
|
|
48
|
+
task_command: z.ZodString;
|
|
49
|
+
project_name: z.ZodString;
|
|
50
|
+
project_dir: z.ZodString;
|
|
51
|
+
full_task_name: z.ZodString;
|
|
52
|
+
dependencies: z.ZodArray<z.ZodString>;
|
|
53
|
+
enabled: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
54
|
+
interactive: z.ZodBoolean;
|
|
55
|
+
persistent: z.ZodBoolean;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
exit_code: z.ZodNumber;
|
|
58
|
+
elapsed: z.ZodObject<{
|
|
59
|
+
secs: z.ZodNumber;
|
|
60
|
+
nanos: z.ZodNumber;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
cache_hit: z.ZodBoolean;
|
|
63
|
+
details: z.ZodObject<{
|
|
64
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
type: z.ZodOptional<z.ZodString>;
|
|
66
|
+
language: z.ZodOptional<z.ZodString>;
|
|
67
|
+
targets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
68
|
+
runner: z.ZodString;
|
|
69
|
+
build_flags: z.ZodOptional<z.ZodString>;
|
|
70
|
+
test_flags: z.ZodOptional<z.ZodString>;
|
|
71
|
+
}, z.core.$strip>>>;
|
|
72
|
+
release: z.ZodOptional<z.ZodObject<{
|
|
73
|
+
npm: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
+
github: z.ZodOptional<z.ZodBoolean>;
|
|
75
|
+
}, z.core.$strip>>;
|
|
76
|
+
}, z.core.$strip>>;
|
|
77
|
+
output_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
/**
|
|
81
|
+
* Schema for a task that was skipped.
|
|
82
|
+
* Note: 'skip_reason' is required here, and fields like 'hash' or 'elapsed' are omitted.
|
|
83
|
+
*/
|
|
84
|
+
declare const SkippedTaskSchema: z.ZodObject<{
|
|
85
|
+
status: z.ZodLiteral<"skipped">;
|
|
86
|
+
task: z.ZodObject<{
|
|
87
|
+
task_name: z.ZodString;
|
|
88
|
+
task_command: z.ZodString;
|
|
89
|
+
project_name: z.ZodString;
|
|
90
|
+
project_dir: z.ZodString;
|
|
91
|
+
full_task_name: z.ZodString;
|
|
92
|
+
dependencies: z.ZodArray<z.ZodString>;
|
|
93
|
+
enabled: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
94
|
+
interactive: z.ZodBoolean;
|
|
95
|
+
persistent: z.ZodBoolean;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
skip_reason: z.ZodString;
|
|
98
|
+
details: z.ZodObject<{
|
|
99
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
100
|
+
type: z.ZodOptional<z.ZodString>;
|
|
101
|
+
language: z.ZodOptional<z.ZodString>;
|
|
102
|
+
targets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
103
|
+
runner: z.ZodString;
|
|
104
|
+
build_flags: z.ZodOptional<z.ZodString>;
|
|
105
|
+
test_flags: z.ZodOptional<z.ZodString>;
|
|
106
|
+
}, z.core.$strip>>>;
|
|
107
|
+
release: z.ZodOptional<z.ZodObject<{
|
|
108
|
+
npm: z.ZodOptional<z.ZodBoolean>;
|
|
109
|
+
github: z.ZodOptional<z.ZodBoolean>;
|
|
110
|
+
}, z.core.$strip>>;
|
|
111
|
+
}, z.core.$strip>>;
|
|
112
|
+
output_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
113
|
+
}, z.core.$strip>;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
/**
|
|
116
|
+
* The primary schema for a single task result, using a discriminated union
|
|
117
|
+
* based on the 'status' field to correctly type the required fields.
|
|
118
|
+
*/
|
|
119
|
+
export declare const TaskResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
120
|
+
status: z.ZodLiteral<"completed">;
|
|
121
|
+
hash: z.ZodString;
|
|
122
|
+
task: z.ZodObject<{
|
|
123
|
+
task_name: z.ZodString;
|
|
124
|
+
task_command: z.ZodString;
|
|
125
|
+
project_name: z.ZodString;
|
|
126
|
+
project_dir: z.ZodString;
|
|
127
|
+
full_task_name: z.ZodString;
|
|
128
|
+
dependencies: z.ZodArray<z.ZodString>;
|
|
129
|
+
enabled: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
130
|
+
interactive: z.ZodBoolean;
|
|
131
|
+
persistent: z.ZodBoolean;
|
|
132
|
+
}, z.core.$strip>;
|
|
133
|
+
exit_code: z.ZodNumber;
|
|
134
|
+
elapsed: z.ZodObject<{
|
|
135
|
+
secs: z.ZodNumber;
|
|
136
|
+
nanos: z.ZodNumber;
|
|
137
|
+
}, z.core.$strip>;
|
|
138
|
+
cache_hit: z.ZodBoolean;
|
|
139
|
+
details: z.ZodObject<{
|
|
140
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
141
|
+
type: z.ZodOptional<z.ZodString>;
|
|
142
|
+
language: z.ZodOptional<z.ZodString>;
|
|
143
|
+
targets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
144
|
+
runner: z.ZodString;
|
|
145
|
+
build_flags: z.ZodOptional<z.ZodString>;
|
|
146
|
+
test_flags: z.ZodOptional<z.ZodString>;
|
|
147
|
+
}, z.core.$strip>>>;
|
|
148
|
+
release: z.ZodOptional<z.ZodObject<{
|
|
149
|
+
npm: z.ZodOptional<z.ZodBoolean>;
|
|
150
|
+
github: z.ZodOptional<z.ZodBoolean>;
|
|
151
|
+
}, z.core.$strip>>;
|
|
152
|
+
}, z.core.$strip>>;
|
|
153
|
+
output_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
154
|
+
}, z.core.$strip>;
|
|
155
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
156
|
+
status: z.ZodLiteral<"skipped">;
|
|
157
|
+
task: z.ZodObject<{
|
|
158
|
+
task_name: z.ZodString;
|
|
159
|
+
task_command: z.ZodString;
|
|
160
|
+
project_name: z.ZodString;
|
|
161
|
+
project_dir: z.ZodString;
|
|
162
|
+
full_task_name: z.ZodString;
|
|
163
|
+
dependencies: z.ZodArray<z.ZodString>;
|
|
164
|
+
enabled: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
165
|
+
interactive: z.ZodBoolean;
|
|
166
|
+
persistent: z.ZodBoolean;
|
|
167
|
+
}, z.core.$strip>;
|
|
168
|
+
skip_reason: z.ZodString;
|
|
169
|
+
details: z.ZodObject<{
|
|
170
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
171
|
+
type: z.ZodOptional<z.ZodString>;
|
|
172
|
+
language: z.ZodOptional<z.ZodString>;
|
|
173
|
+
targets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
174
|
+
runner: z.ZodString;
|
|
175
|
+
build_flags: z.ZodOptional<z.ZodString>;
|
|
176
|
+
test_flags: z.ZodOptional<z.ZodString>;
|
|
177
|
+
}, z.core.$strip>>>;
|
|
178
|
+
release: z.ZodOptional<z.ZodObject<{
|
|
179
|
+
npm: z.ZodOptional<z.ZodBoolean>;
|
|
180
|
+
github: z.ZodOptional<z.ZodBoolean>;
|
|
181
|
+
}, z.core.$strip>>;
|
|
182
|
+
}, z.core.$strip>>;
|
|
183
|
+
output_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
184
|
+
}, z.core.$strip>;
|
|
185
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
186
|
+
status: z.ZodLiteral<"errored">;
|
|
187
|
+
task: z.ZodObject<{
|
|
188
|
+
task_name: z.ZodString;
|
|
189
|
+
task_command: z.ZodString;
|
|
190
|
+
project_name: z.ZodString;
|
|
191
|
+
project_dir: z.ZodString;
|
|
192
|
+
full_task_name: z.ZodString;
|
|
193
|
+
dependencies: z.ZodArray<z.ZodString>;
|
|
194
|
+
enabled: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
195
|
+
interactive: z.ZodBoolean;
|
|
196
|
+
persistent: z.ZodBoolean;
|
|
197
|
+
}, z.core.$strip>;
|
|
198
|
+
error: z.ZodString;
|
|
199
|
+
details: z.ZodObject<{
|
|
200
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
201
|
+
type: z.ZodOptional<z.ZodString>;
|
|
202
|
+
language: z.ZodOptional<z.ZodString>;
|
|
203
|
+
targets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
204
|
+
runner: z.ZodString;
|
|
205
|
+
build_flags: z.ZodOptional<z.ZodString>;
|
|
206
|
+
test_flags: z.ZodOptional<z.ZodString>;
|
|
207
|
+
}, z.core.$strip>>>;
|
|
208
|
+
release: z.ZodOptional<z.ZodObject<{
|
|
209
|
+
npm: z.ZodOptional<z.ZodBoolean>;
|
|
210
|
+
github: z.ZodOptional<z.ZodBoolean>;
|
|
211
|
+
}, z.core.$strip>>;
|
|
212
|
+
}, z.core.$strip>>;
|
|
213
|
+
output_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
214
|
+
}, z.core.$strip>;
|
|
215
|
+
}, z.core.$strip>], "status">;
|
|
216
|
+
/**
|
|
217
|
+
* The final schema for the root array of task results.
|
|
218
|
+
*/
|
|
219
|
+
export declare const TaskResultArraySchema: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
220
|
+
status: z.ZodLiteral<"completed">;
|
|
221
|
+
hash: z.ZodString;
|
|
222
|
+
task: z.ZodObject<{
|
|
223
|
+
task_name: z.ZodString;
|
|
224
|
+
task_command: z.ZodString;
|
|
225
|
+
project_name: z.ZodString;
|
|
226
|
+
project_dir: z.ZodString;
|
|
227
|
+
full_task_name: z.ZodString;
|
|
228
|
+
dependencies: z.ZodArray<z.ZodString>;
|
|
229
|
+
enabled: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
230
|
+
interactive: z.ZodBoolean;
|
|
231
|
+
persistent: z.ZodBoolean;
|
|
232
|
+
}, z.core.$strip>;
|
|
233
|
+
exit_code: z.ZodNumber;
|
|
234
|
+
elapsed: z.ZodObject<{
|
|
235
|
+
secs: z.ZodNumber;
|
|
236
|
+
nanos: z.ZodNumber;
|
|
237
|
+
}, z.core.$strip>;
|
|
238
|
+
cache_hit: z.ZodBoolean;
|
|
239
|
+
details: z.ZodObject<{
|
|
240
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
241
|
+
type: z.ZodOptional<z.ZodString>;
|
|
242
|
+
language: z.ZodOptional<z.ZodString>;
|
|
243
|
+
targets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
244
|
+
runner: z.ZodString;
|
|
245
|
+
build_flags: z.ZodOptional<z.ZodString>;
|
|
246
|
+
test_flags: z.ZodOptional<z.ZodString>;
|
|
247
|
+
}, z.core.$strip>>>;
|
|
248
|
+
release: z.ZodOptional<z.ZodObject<{
|
|
249
|
+
npm: z.ZodOptional<z.ZodBoolean>;
|
|
250
|
+
github: z.ZodOptional<z.ZodBoolean>;
|
|
251
|
+
}, z.core.$strip>>;
|
|
252
|
+
}, z.core.$strip>>;
|
|
253
|
+
output_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
254
|
+
}, z.core.$strip>;
|
|
255
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
256
|
+
status: z.ZodLiteral<"skipped">;
|
|
257
|
+
task: z.ZodObject<{
|
|
258
|
+
task_name: z.ZodString;
|
|
259
|
+
task_command: z.ZodString;
|
|
260
|
+
project_name: z.ZodString;
|
|
261
|
+
project_dir: z.ZodString;
|
|
262
|
+
full_task_name: z.ZodString;
|
|
263
|
+
dependencies: z.ZodArray<z.ZodString>;
|
|
264
|
+
enabled: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
265
|
+
interactive: z.ZodBoolean;
|
|
266
|
+
persistent: z.ZodBoolean;
|
|
267
|
+
}, z.core.$strip>;
|
|
268
|
+
skip_reason: z.ZodString;
|
|
269
|
+
details: z.ZodObject<{
|
|
270
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
271
|
+
type: z.ZodOptional<z.ZodString>;
|
|
272
|
+
language: z.ZodOptional<z.ZodString>;
|
|
273
|
+
targets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
274
|
+
runner: z.ZodString;
|
|
275
|
+
build_flags: z.ZodOptional<z.ZodString>;
|
|
276
|
+
test_flags: z.ZodOptional<z.ZodString>;
|
|
277
|
+
}, z.core.$strip>>>;
|
|
278
|
+
release: z.ZodOptional<z.ZodObject<{
|
|
279
|
+
npm: z.ZodOptional<z.ZodBoolean>;
|
|
280
|
+
github: z.ZodOptional<z.ZodBoolean>;
|
|
281
|
+
}, z.core.$strip>>;
|
|
282
|
+
}, z.core.$strip>>;
|
|
283
|
+
output_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
284
|
+
}, z.core.$strip>;
|
|
285
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
286
|
+
status: z.ZodLiteral<"errored">;
|
|
287
|
+
task: z.ZodObject<{
|
|
288
|
+
task_name: z.ZodString;
|
|
289
|
+
task_command: z.ZodString;
|
|
290
|
+
project_name: z.ZodString;
|
|
291
|
+
project_dir: z.ZodString;
|
|
292
|
+
full_task_name: z.ZodString;
|
|
293
|
+
dependencies: z.ZodArray<z.ZodString>;
|
|
294
|
+
enabled: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
295
|
+
interactive: z.ZodBoolean;
|
|
296
|
+
persistent: z.ZodBoolean;
|
|
297
|
+
}, z.core.$strip>;
|
|
298
|
+
error: z.ZodString;
|
|
299
|
+
details: z.ZodObject<{
|
|
300
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
301
|
+
type: z.ZodOptional<z.ZodString>;
|
|
302
|
+
language: z.ZodOptional<z.ZodString>;
|
|
303
|
+
targets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
304
|
+
runner: z.ZodString;
|
|
305
|
+
build_flags: z.ZodOptional<z.ZodString>;
|
|
306
|
+
test_flags: z.ZodOptional<z.ZodString>;
|
|
307
|
+
}, z.core.$strip>>>;
|
|
308
|
+
release: z.ZodOptional<z.ZodObject<{
|
|
309
|
+
npm: z.ZodOptional<z.ZodBoolean>;
|
|
310
|
+
github: z.ZodOptional<z.ZodBoolean>;
|
|
311
|
+
}, z.core.$strip>>;
|
|
312
|
+
}, z.core.$strip>>;
|
|
313
|
+
output_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
314
|
+
}, z.core.$strip>;
|
|
315
|
+
}, z.core.$strip>], "status">>;
|
|
316
|
+
export type Elapsed = z.infer<typeof ElapsedSchema>;
|
|
317
|
+
export type Meta = z.infer<typeof MetaSchema>;
|
|
318
|
+
export type Task = z.infer<typeof TaskSchema>;
|
|
319
|
+
export type CompletedTaskResult = z.infer<typeof CompletedTaskSchema>;
|
|
320
|
+
export type SkippedTaskResult = z.infer<typeof SkippedTaskSchema>;
|
|
321
|
+
export type TaskResult = z.infer<typeof TaskResultSchema>;
|
|
322
|
+
export type TaskResultArray = z.infer<typeof TaskResultArraySchema>;
|
|
323
|
+
export {};
|
|
324
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;GAEG;AACH,QAAA,MAAM,aAAa;;;iBAWjB,CAAC;AAmBH;;GAEG;AACH,QAAA,MAAM,UAAU;;;;;;;;;;;;iBAcd,CAAC;AAUH;;GAEG;AACH,QAAA,MAAM,UAAU;;;;;;;;;;iBAwBd,CAAC;AAIH;;;GAGG;AACH,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmBvB,CAAC;AASH;;;GAGG;AACH,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAOrB,CAAC;AAIH;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAQxB,CAAC;AAEN;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAEkB,CAAC;AAIrD,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAC9C,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAC9C,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAClE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { z as e } from "zod";
|
|
2
|
+
const c = e.object({
|
|
3
|
+
secs: e.number().int().nonnegative().describe("The number of whole seconds elapsed."),
|
|
4
|
+
nanos: e.number().int().nonnegative().describe("The number of nanoseconds elapsed.")
|
|
5
|
+
}), l = e.object({
|
|
6
|
+
runner: e.string().describe("The runner to use for the target."),
|
|
7
|
+
build_flags: e.string().optional().describe("The build flags to use for the target."),
|
|
8
|
+
test_flags: e.string().optional().describe("The test flags to use for the target.")
|
|
9
|
+
}), d = e.object({
|
|
10
|
+
npm: e.boolean().optional().describe("Whether to publish to npm."),
|
|
11
|
+
github: e.boolean().optional().describe("Whether to publish to github.")
|
|
12
|
+
}), u = e.object({
|
|
13
|
+
type: e.string().optional().describe("The type of project (e.g., library, service, application)."),
|
|
14
|
+
language: e.string().optional().describe("The primary language of the project."),
|
|
15
|
+
targets: e.record(e.string(), l).optional().describe("The targets to build."),
|
|
16
|
+
release: d.optional()
|
|
17
|
+
}), o = e.object({
|
|
18
|
+
meta: u.optional(),
|
|
19
|
+
output_files: e.array(e.string()).optional().describe("The output files generated.")
|
|
20
|
+
}), n = e.object({
|
|
21
|
+
task_name: e.string().describe("The short name of the task (e.g., 'test', 'build')."),
|
|
22
|
+
task_command: e.string().describe("The command executed for the task."),
|
|
23
|
+
project_name: e.string().describe("The name of the project."),
|
|
24
|
+
project_dir: e.string().describe("The absolute directory path of the project."),
|
|
25
|
+
full_task_name: e.string().describe("The fully qualified task name (e.g., 'omni_utils#test')."),
|
|
26
|
+
dependencies: e.array(e.string()).describe("A list of dependent task names."),
|
|
27
|
+
enabled: e.boolean().or(e.string()).optional().describe(
|
|
28
|
+
"Whether the task is enabled by configuration. Either a boolean or a tera template string that evaluates to a boolean."
|
|
29
|
+
),
|
|
30
|
+
interactive: e.boolean().describe("Whether the task is interactive."),
|
|
31
|
+
persistent: e.boolean().describe("Whether the task is persistent.")
|
|
32
|
+
}), h = e.object({
|
|
33
|
+
status: e.literal("completed"),
|
|
34
|
+
hash: e.string().describe(
|
|
35
|
+
"The task's content hash (Base64 encoded string). Used for caching."
|
|
36
|
+
),
|
|
37
|
+
task: n,
|
|
38
|
+
exit_code: e.number().int().describe(
|
|
39
|
+
"The exit code of the executed command (typically 0 for success)."
|
|
40
|
+
),
|
|
41
|
+
elapsed: c.describe("The duration the task took to execute."),
|
|
42
|
+
cache_hit: e.boolean().describe("Indicates if the result was pulled from cache."),
|
|
43
|
+
details: o
|
|
44
|
+
}), p = e.object({
|
|
45
|
+
status: e.literal("errored"),
|
|
46
|
+
task: n,
|
|
47
|
+
error: e.string().describe("The error message."),
|
|
48
|
+
details: o
|
|
49
|
+
}), b = e.object({
|
|
50
|
+
status: e.literal("skipped"),
|
|
51
|
+
task: n,
|
|
52
|
+
skip_reason: e.string().describe("The reason the task was skipped (e.g., 'disabled')."),
|
|
53
|
+
details: o
|
|
54
|
+
}), m = e.discriminatedUnion("status", [
|
|
55
|
+
h,
|
|
56
|
+
b,
|
|
57
|
+
p
|
|
58
|
+
]).describe(
|
|
59
|
+
"Schema for a single task execution result (completed or skipped)."
|
|
60
|
+
), f = e.array(m).describe("An array of task execution results.");
|
|
61
|
+
function k(a) {
|
|
62
|
+
const s = {
|
|
63
|
+
test: {
|
|
64
|
+
rust: [],
|
|
65
|
+
typescript: []
|
|
66
|
+
},
|
|
67
|
+
build: {
|
|
68
|
+
rust: [],
|
|
69
|
+
typescript: []
|
|
70
|
+
},
|
|
71
|
+
publish: {
|
|
72
|
+
npm: [],
|
|
73
|
+
rust_github: []
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
for (const t of a) {
|
|
77
|
+
if (t.status === "skipped")
|
|
78
|
+
continue;
|
|
79
|
+
const r = t.task;
|
|
80
|
+
r.task_name === "test" && (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?.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?.release?.npm && s.publish.npm.push(i(t)), t.details.meta?.release?.github && t.details.meta?.language === "rust" && s.publish.rust_github.push(i(t));
|
|
81
|
+
}
|
|
82
|
+
return s;
|
|
83
|
+
}
|
|
84
|
+
function i(a) {
|
|
85
|
+
return {
|
|
86
|
+
task_name: a.task.task_name,
|
|
87
|
+
project_name: a.task.project_name,
|
|
88
|
+
output_files: a.details.output_files ?? [],
|
|
89
|
+
meta: a.details.meta ?? {}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
f as T,
|
|
94
|
+
m as a,
|
|
95
|
+
k as c
|
|
96
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("zod"),l=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.")}),d=e.z.object({runner:e.z.string().describe("The runner to use for the target."),build_flags:e.z.string().optional().describe("The build flags to use for the target."),test_flags:e.z.string().optional().describe("The test flags to use for the target.")}),u=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.")}),h=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(),d).optional().describe("The targets to build."),release:u.optional()}),o=e.z.object({meta:h.optional(),output_files:e.z.array(e.z.string()).optional().describe("The output files generated.")}),n=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.")}),p=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:n,exit_code:e.z.number().int().describe("The exit code of the executed command (typically 0 for success)."),elapsed:l.describe("The duration the task took to execute."),cache_hit:e.z.boolean().describe("Indicates if the result was pulled from cache."),details:o}),b=e.z.object({status:e.z.literal("errored"),task:n,error:e.z.string().describe("The error message."),details:o}),m=e.z.object({status:e.z.literal("skipped"),task:n,skip_reason:e.z.string().describe("The reason the task was skipped (e.g., 'disabled')."),details:o}),c=e.z.discriminatedUnion("status",[p,m,b]).describe("Schema for a single task execution result (completed or skipped)."),g=e.z.array(c).describe("An array of task execution results.");function f(a){const s={test:{rust:[],typescript:[]},build:{rust:[],typescript:[]},publish:{npm:[],rust_github:[]}};for(const t of a){if(t.status==="skipped")continue;const r=t.task;r.task_name==="test"&&(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?.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?.release?.npm&&s.publish.npm.push(i(t)),t.details.meta?.release?.github&&t.details.meta?.language==="rust"&&s.publish.rust_github.push(i(t))}return s}function i(a){return{task_name:a.task.task_name,project_name:a.task.project_name,output_files:a.details.output_files??[],meta:a.details.meta??{}}}exports.TaskResultArraySchema=g;exports.TaskResultSchema=c;exports.createJobs=f;
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Meta, TaskResultArray } from './schemas';
|
|
2
|
+
export type Job = {
|
|
3
|
+
task_name: string;
|
|
4
|
+
project_name: string;
|
|
5
|
+
output_files: string[];
|
|
6
|
+
meta: Meta;
|
|
7
|
+
};
|
|
8
|
+
export type Jobs = {
|
|
9
|
+
test: TestJobs;
|
|
10
|
+
build: BuildJobs;
|
|
11
|
+
publish: PublishJobs;
|
|
12
|
+
};
|
|
13
|
+
export type TestJobs = {
|
|
14
|
+
rust: Job[];
|
|
15
|
+
typescript: Job[];
|
|
16
|
+
};
|
|
17
|
+
export type BuildJobs = {
|
|
18
|
+
rust: Job[];
|
|
19
|
+
typescript: Job[];
|
|
20
|
+
};
|
|
21
|
+
export type PublishJobs = {
|
|
22
|
+
npm: Job[];
|
|
23
|
+
rust_github: Job[];
|
|
24
|
+
};
|
|
25
|
+
export declare function createJobs(results: TaskResultArray): Jobs;
|
|
26
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,eAAe,EAAE,MAAM,WAAW,CAAC;AAEnE,MAAM,MAAM,GAAG,GAAG;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,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,WAAW,EAAE,GAAG,EAAE,CAAC;CACtB,CAAC;AAEF,wBAAgB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAuDzD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@omni-oss/create-jobs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"bin": "./dist/create-jobs.mjs",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": {
|
|
12
|
+
"development": "./src/index.ts",
|
|
13
|
+
"default": "./dist/index.mjs"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"development": "./src/index.ts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"zod": "^4.3.6",
|
|
23
|
+
"commander": "^14.0.3",
|
|
24
|
+
"@commander-js/extra-typings": "14.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@omni-oss/tsconfig": "^0.1.0",
|
|
28
|
+
"@omni-oss/vite-config": "^0.1.0",
|
|
29
|
+
"@omni-oss/vitest-config": "^0.0.0",
|
|
30
|
+
"typescript": "^5.9.3",
|
|
31
|
+
"@types/node": "25.2.0",
|
|
32
|
+
"@types/bun": "^1.3.8"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/omni-oss/omni/refs/heads/json-schemas/project-latest.json
|
|
2
|
+
name: "@omni-oss/create-jobs"
|
|
3
|
+
|
|
4
|
+
extends:
|
|
5
|
+
- "@workspace/omni/presets/ts-vite-script.omni.yaml"
|
|
6
|
+
|
|
7
|
+
tasks:
|
|
8
|
+
test:unit:
|
|
9
|
+
enabled: true
|
|
10
|
+
|
|
11
|
+
test:integration:
|
|
12
|
+
enabled: true
|
|
13
|
+
|
|
14
|
+
test:
|
|
15
|
+
enabled: true
|
|
16
|
+
|
|
17
|
+
build:
|
|
18
|
+
enabled: true
|
|
19
|
+
|
|
20
|
+
publish:
|
|
21
|
+
enabled: true
|
|
22
|
+
|
|
23
|
+
meta:
|
|
24
|
+
publish: true
|
|
25
|
+
|
|
26
|
+
dependencies:
|
|
27
|
+
- "@omni-oss/tsconfig"
|
|
28
|
+
- "@omni-oss/vite-config"
|
|
29
|
+
- "@omni-oss/vitest-config"
|
package/src/cli/index.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import fsAsync from "node:fs/promises";
|
|
2
|
+
import { Command } from "@commander-js/extra-typings";
|
|
3
|
+
import { createJobs, TaskResultArraySchema } from "..";
|
|
4
|
+
|
|
5
|
+
const command = new Command();
|
|
6
|
+
|
|
7
|
+
command
|
|
8
|
+
.argument("<input>", "The input file to read from.")
|
|
9
|
+
.option("-o, --output <output>", "The output file to write to.")
|
|
10
|
+
.action(async (input, options) => {
|
|
11
|
+
const inputFile = await fsAsync.readFile(input, "utf-8");
|
|
12
|
+
const results = JSON.parse(inputFile);
|
|
13
|
+
const result = TaskResultArraySchema.safeParse(results);
|
|
14
|
+
|
|
15
|
+
if (result.success) {
|
|
16
|
+
const data = result.data;
|
|
17
|
+
const processed = createJobs(data);
|
|
18
|
+
if (options.output) {
|
|
19
|
+
await fsAsync.writeFile(
|
|
20
|
+
options.output,
|
|
21
|
+
JSON.stringify(processed, null, 2),
|
|
22
|
+
);
|
|
23
|
+
} else {
|
|
24
|
+
console.log(processed);
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
console.error(result.error);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
.parseAsync();
|
package/src/index.ts
ADDED
package/src/schemas.ts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
// --- Nested Schemas ---
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Defines the structure for the duration object.
|
|
7
|
+
*/
|
|
8
|
+
const ElapsedSchema = z.object({
|
|
9
|
+
secs: z
|
|
10
|
+
.number()
|
|
11
|
+
.int()
|
|
12
|
+
.nonnegative()
|
|
13
|
+
.describe("The number of whole seconds elapsed."),
|
|
14
|
+
nanos: z
|
|
15
|
+
.number()
|
|
16
|
+
.int()
|
|
17
|
+
.nonnegative()
|
|
18
|
+
.describe("The number of nanoseconds elapsed."),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const TargetSchema = z.object({
|
|
22
|
+
runner: z.string().describe("The runner to use for the target."),
|
|
23
|
+
build_flags: z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("The build flags to use for the target."),
|
|
27
|
+
test_flags: z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("The test flags to use for the target."),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const ReleaseSchema = z.object({
|
|
34
|
+
npm: z.boolean().optional().describe("Whether to publish to npm."),
|
|
35
|
+
github: z.boolean().optional().describe("Whether to publish to github."),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Defines the metadata for the project/task details.
|
|
40
|
+
*/
|
|
41
|
+
const MetaSchema = z.object({
|
|
42
|
+
type: z
|
|
43
|
+
.string()
|
|
44
|
+
.optional()
|
|
45
|
+
.describe("The type of project (e.g., library, service, application)."),
|
|
46
|
+
language: z
|
|
47
|
+
.string()
|
|
48
|
+
.optional()
|
|
49
|
+
.describe("The primary language of the project."),
|
|
50
|
+
targets: z
|
|
51
|
+
.record(z.string(), TargetSchema)
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("The targets to build."),
|
|
54
|
+
release: ReleaseSchema.optional(),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const DetailsSchema = z.object({
|
|
58
|
+
meta: MetaSchema.optional(),
|
|
59
|
+
output_files: z
|
|
60
|
+
.array(z.string())
|
|
61
|
+
.optional()
|
|
62
|
+
.describe("The output files generated."),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Defines the details of the task that was run or skipped.
|
|
67
|
+
*/
|
|
68
|
+
const TaskSchema = z.object({
|
|
69
|
+
task_name: z
|
|
70
|
+
.string()
|
|
71
|
+
.describe("The short name of the task (e.g., 'test', 'build')."),
|
|
72
|
+
task_command: z.string().describe("The command executed for the task."),
|
|
73
|
+
project_name: z.string().describe("The name of the project."),
|
|
74
|
+
project_dir: z
|
|
75
|
+
.string()
|
|
76
|
+
.describe("The absolute directory path of the project."),
|
|
77
|
+
full_task_name: z
|
|
78
|
+
.string()
|
|
79
|
+
.describe("The fully qualified task name (e.g., 'omni_utils#test')."),
|
|
80
|
+
dependencies: z
|
|
81
|
+
.array(z.string())
|
|
82
|
+
.describe("A list of dependent task names."),
|
|
83
|
+
enabled: z
|
|
84
|
+
.boolean()
|
|
85
|
+
.or(z.string())
|
|
86
|
+
.optional()
|
|
87
|
+
.describe(
|
|
88
|
+
"Whether the task is enabled by configuration. Either a boolean or a tera template string that evaluates to a boolean.",
|
|
89
|
+
),
|
|
90
|
+
interactive: z.boolean().describe("Whether the task is interactive."),
|
|
91
|
+
persistent: z.boolean().describe("Whether the task is persistent."),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// --- Discriminant Schemas (Union Members) ---
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Schema for a task that successfully completed.
|
|
98
|
+
* Note: 'elapsed', 'exit_code', 'hash', and 'cache_hit' are required here.
|
|
99
|
+
*/
|
|
100
|
+
const CompletedTaskSchema = z.object({
|
|
101
|
+
status: z.literal("completed"),
|
|
102
|
+
hash: z
|
|
103
|
+
.string()
|
|
104
|
+
.describe(
|
|
105
|
+
"The task's content hash (Base64 encoded string). Used for caching.",
|
|
106
|
+
),
|
|
107
|
+
task: TaskSchema,
|
|
108
|
+
exit_code: z
|
|
109
|
+
.number()
|
|
110
|
+
.int()
|
|
111
|
+
.describe(
|
|
112
|
+
"The exit code of the executed command (typically 0 for success).",
|
|
113
|
+
),
|
|
114
|
+
elapsed: ElapsedSchema.describe("The duration the task took to execute."),
|
|
115
|
+
cache_hit: z
|
|
116
|
+
.boolean()
|
|
117
|
+
.describe("Indicates if the result was pulled from cache."),
|
|
118
|
+
details: DetailsSchema,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const ErroredTaskSchema = z.object({
|
|
122
|
+
status: z.literal("errored"),
|
|
123
|
+
task: TaskSchema,
|
|
124
|
+
error: z.string().describe("The error message."),
|
|
125
|
+
details: DetailsSchema,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Schema for a task that was skipped.
|
|
130
|
+
* Note: 'skip_reason' is required here, and fields like 'hash' or 'elapsed' are omitted.
|
|
131
|
+
*/
|
|
132
|
+
const SkippedTaskSchema = z.object({
|
|
133
|
+
status: z.literal("skipped"),
|
|
134
|
+
task: TaskSchema,
|
|
135
|
+
skip_reason: z
|
|
136
|
+
.string()
|
|
137
|
+
.describe("The reason the task was skipped (e.g., 'disabled')."),
|
|
138
|
+
details: DetailsSchema,
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// --- Root Schema ---
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The primary schema for a single task result, using a discriminated union
|
|
145
|
+
* based on the 'status' field to correctly type the required fields.
|
|
146
|
+
*/
|
|
147
|
+
export const TaskResultSchema = z
|
|
148
|
+
.discriminatedUnion("status", [
|
|
149
|
+
CompletedTaskSchema,
|
|
150
|
+
SkippedTaskSchema,
|
|
151
|
+
ErroredTaskSchema,
|
|
152
|
+
])
|
|
153
|
+
.describe(
|
|
154
|
+
"Schema for a single task execution result (completed or skipped).",
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* The final schema for the root array of task results.
|
|
159
|
+
*/
|
|
160
|
+
export const TaskResultArraySchema = z
|
|
161
|
+
.array(TaskResultSchema)
|
|
162
|
+
.describe("An array of task execution results.");
|
|
163
|
+
|
|
164
|
+
// --- TypeScript Types (Inferred) ---
|
|
165
|
+
|
|
166
|
+
export type Elapsed = z.infer<typeof ElapsedSchema>;
|
|
167
|
+
export type Meta = z.infer<typeof MetaSchema>;
|
|
168
|
+
export type Task = z.infer<typeof TaskSchema>;
|
|
169
|
+
export type CompletedTaskResult = z.infer<typeof CompletedTaskSchema>;
|
|
170
|
+
export type SkippedTaskResult = z.infer<typeof SkippedTaskSchema>;
|
|
171
|
+
export type TaskResult = z.infer<typeof TaskResultSchema>;
|
|
172
|
+
export type TaskResultArray = z.infer<typeof TaskResultArraySchema>;
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { Meta, TaskResult, TaskResultArray } from "./schemas";
|
|
2
|
+
|
|
3
|
+
export type Job = {
|
|
4
|
+
task_name: string;
|
|
5
|
+
project_name: string;
|
|
6
|
+
output_files: string[];
|
|
7
|
+
meta: Meta;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type Jobs = {
|
|
11
|
+
test: TestJobs;
|
|
12
|
+
build: BuildJobs;
|
|
13
|
+
publish: PublishJobs;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type TestJobs = {
|
|
17
|
+
rust: Job[];
|
|
18
|
+
typescript: Job[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type BuildJobs = {
|
|
22
|
+
rust: Job[];
|
|
23
|
+
typescript: Job[];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type PublishJobs = {
|
|
27
|
+
npm: Job[];
|
|
28
|
+
rust_github: Job[];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export function createJobs(results: TaskResultArray): Jobs {
|
|
32
|
+
const jobs: Jobs = {
|
|
33
|
+
test: {
|
|
34
|
+
rust: [],
|
|
35
|
+
typescript: [],
|
|
36
|
+
},
|
|
37
|
+
build: {
|
|
38
|
+
rust: [],
|
|
39
|
+
typescript: [],
|
|
40
|
+
},
|
|
41
|
+
publish: {
|
|
42
|
+
npm: [],
|
|
43
|
+
rust_github: [],
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
for (const result of results) {
|
|
48
|
+
if (result.status === "skipped") {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const task = result.task;
|
|
53
|
+
if (task.task_name === "test") {
|
|
54
|
+
if (result.details.meta?.language === "rust") {
|
|
55
|
+
jobs.test.rust.push(jobFromResult(result));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (result.details.meta?.language === "typescript") {
|
|
59
|
+
jobs.test.typescript.push(jobFromResult(result));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (task.task_name === "build") {
|
|
64
|
+
if (result.details.meta?.language === "rust") {
|
|
65
|
+
jobs.build.rust.push(jobFromResult(result));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (result.details.meta?.language === "typescript") {
|
|
69
|
+
jobs.build.typescript.push(jobFromResult(result));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (task.task_name === "publish" && result.details.meta?.release?.npm) {
|
|
74
|
+
jobs.publish.npm.push(jobFromResult(result));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (
|
|
78
|
+
result.details.meta?.release?.github &&
|
|
79
|
+
result.details.meta?.language === "rust"
|
|
80
|
+
) {
|
|
81
|
+
jobs.publish.rust_github.push(jobFromResult(result));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return jobs;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function jobFromResult(result: TaskResult): Job {
|
|
89
|
+
return {
|
|
90
|
+
task_name: result.task.task_name,
|
|
91
|
+
project_name: result.task.project_name,
|
|
92
|
+
output_files: result.details.output_files ?? [],
|
|
93
|
+
meta: result.details.meta ?? {},
|
|
94
|
+
};
|
|
95
|
+
}
|
package/tsconfig.json
ADDED
package/vite.config.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import createBaseConfig from "@omni-oss/vite-config/script";
|
|
2
|
+
import { mergeConfig, type UserConfig } from "vite";
|
|
3
|
+
import { dependencies } from "./package.json";
|
|
4
|
+
|
|
5
|
+
const baseConfig = createBaseConfig({
|
|
6
|
+
generateTypes: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const externalNodeDeps = ["node:path", "node:fs", "node:fs/promises"];
|
|
10
|
+
|
|
11
|
+
export default mergeConfig(baseConfig, {
|
|
12
|
+
build: {
|
|
13
|
+
minify: "esbuild",
|
|
14
|
+
lib: {
|
|
15
|
+
entry: {
|
|
16
|
+
"create-jobs": "src/cli/index.ts",
|
|
17
|
+
index: "src/index.ts",
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
formats: ["es", "cjs"],
|
|
21
|
+
fileName: (format, entryName) =>
|
|
22
|
+
`${entryName || "create-jobs"}.${format === "cjs" ? "cjs" : "mjs"}`,
|
|
23
|
+
name: "CreateJobs",
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
rollupOptions: {
|
|
27
|
+
external: [...Object.keys(dependencies), ...externalNodeDeps],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
} satisfies UserConfig);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { mergeConfig, type UserWorkspaceConfig } from "vitest/config";
|
|
2
|
+
import baseConfig from "./vite.config";
|
|
3
|
+
import integrationTestConfig from "@omni-oss/vitest-config/integration";
|
|
4
|
+
|
|
5
|
+
export default mergeConfig(mergeConfig(baseConfig, integrationTestConfig), {
|
|
6
|
+
test: {
|
|
7
|
+
testTimeout: 1000,
|
|
8
|
+
include: [
|
|
9
|
+
"./src/**/__tests__/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
|
|
10
|
+
],
|
|
11
|
+
},
|
|
12
|
+
} satisfies UserWorkspaceConfig);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mergeConfig, type UserWorkspaceConfig } from "vitest/config";
|
|
2
|
+
import baseConfig from "./vite.config";
|
|
3
|
+
import unitTestConfig from "@omni-oss/vitest-config/unit";
|
|
4
|
+
|
|
5
|
+
export default mergeConfig(mergeConfig(baseConfig, unitTestConfig), {
|
|
6
|
+
test: {
|
|
7
|
+
testTimeout: 1000,
|
|
8
|
+
include: ["./src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
|
|
9
|
+
exclude: [
|
|
10
|
+
"./src/**/__tests__/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
|
|
11
|
+
],
|
|
12
|
+
},
|
|
13
|
+
} satisfies UserWorkspaceConfig);
|