clyops-jobs 0.7.0 → 0.9.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.
Files changed (2) hide show
  1. package/clyops-jobs.cjs +18 -6
  2. package/package.json +2 -2
package/clyops-jobs.cjs CHANGED
@@ -179,12 +179,13 @@ function stamp(file) {
179
179
  return `${s.mtimeMs}:${s.size}`;
180
180
  }
181
181
  var cache = /* @__PURE__ */ new Map();
182
+ var PROBE_TIMEOUT_MS = 3e4;
182
183
  function loadSchema(file, opts = {}) {
183
184
  const key = stamp(file);
184
185
  const hit = cache.get(file);
185
186
  if (hit && hit.stamp === key) return hit.schema;
186
187
  const schema = new Promise((resolve5, reject) => {
187
- (0, import_node_child_process.execFile)(file, ["--help-json-schema"], { cwd: opts.cwd, timeout: opts.timeoutMs ?? 5e3, maxBuffer: 16 << 20 }, (err, stdout) => {
188
+ (0, import_node_child_process.execFile)(file, ["--help-json-schema"], { cwd: opts.cwd, timeout: opts.timeoutMs ?? PROBE_TIMEOUT_MS, maxBuffer: 16 << 20 }, (err, stdout) => {
188
189
  if (err) return reject(new Error(`${file} does not provide --help-json-schema: ${err.message}`));
189
190
  const start2 = stdout.indexOf("{");
190
191
  const end = stdout.lastIndexOf("}");
@@ -200,7 +201,9 @@ function loadSchema(file, opts = {}) {
200
201
  }
201
202
  });
202
203
  });
203
- schema.catch(() => cache.delete(file));
204
+ schema.catch(() => {
205
+ if (cache.get(file)?.schema === schema) cache.delete(file);
206
+ });
204
207
  cache.set(file, { stamp: key, schema });
205
208
  return schema;
206
209
  }
@@ -230,6 +233,9 @@ var InputError = class extends Error {
230
233
  function isPathValued(validation, type) {
231
234
  return type === "path" || validation === "path" || validation.startsWith("file:") || validation.startsWith("dir:");
232
235
  }
236
+ function isBareProgram(validation, value) {
237
+ return validation === "file:executable" && value !== "" && !value.includes("/") && !(process.platform === "win32" && value.includes("\\"));
238
+ }
233
239
  var TRUE = /^(true|1|yes|on)$/i;
234
240
  var FALSE = /^(false|0|no|off)$/i;
235
241
  function toArgv(schema, input, opts = {}) {
@@ -244,9 +250,10 @@ function toArgv(schema, input, opts = {}) {
244
250
  }
245
251
  return void 0;
246
252
  };
247
- const text = (value, pathValued, name = "") => {
253
+ const text = (value, pathValued, name = "", validation = "") => {
248
254
  let s = typeof value === "object" ? JSON.stringify(value) : String(value);
249
255
  if (opts.render) s = opts.render(s);
256
+ if (isBareProgram(validation, s)) return s;
250
257
  if (pathValued && opts.base && !["", "-", "disabled", "false"].includes(s) && !(0, import_node_path2.isAbsolute)(s) && !/^[a-z][a-z0-9+.-]*:\/\//i.test(s)) {
251
258
  s = (0, import_node_path2.resolve)(opts.base, s);
252
259
  }
@@ -273,11 +280,11 @@ function toArgv(schema, input, opts = {}) {
273
280
  continue;
274
281
  }
275
282
  if (opts.secretEnv && option.secret && !option.isArray) {
276
- out.env[option.variableName] = text(found.value, isPathValued(option.validation, option.type), `--${option.name}`);
283
+ out.env[option.variableName] = text(found.value, isPathValued(option.validation, option.type), `--${option.name}`, option.validation);
277
284
  continue;
278
285
  }
279
286
  for (const item of Array.isArray(found.value) ? found.value : [found.value]) {
280
- out.argv.push(`--${option.name}`, text(item, isPathValued(option.validation, option.type), `--${option.name}`));
287
+ out.argv.push(`--${option.name}`, text(item, isPathValued(option.validation, option.type), `--${option.name}`, option.validation));
281
288
  }
282
289
  }
283
290
  const explicit = Array.isArray(opts.positionals) ? opts.positionals : void 0;
@@ -288,6 +295,11 @@ function toArgv(schema, input, opts = {}) {
288
295
  let skipped = [];
289
296
  for (const argument of schema.arguments) {
290
297
  const found = pick(argument);
298
+ if (found && opts.controlled?.includes(argument.name)) {
299
+ out.controlled.push(found.key);
300
+ skipped.push(argument);
301
+ continue;
302
+ }
291
303
  if (!found || found.value === null || found.value === void 0) {
292
304
  skipped.push(argument);
293
305
  continue;
@@ -298,7 +310,7 @@ function toArgv(schema, input, opts = {}) {
298
310
  }
299
311
  skipped = [];
300
312
  const values = Array.isArray(found.value) ? found.value : [found.value];
301
- positionals.push(...values.map((v) => text(v, isPathValued(argument.validation), argument.name)));
313
+ positionals.push(...values.map((v) => text(v, isPathValued(argument.validation), argument.name, argument.validation)));
302
314
  }
303
315
  }
304
316
  if (positionals.some((p) => p.startsWith("-"))) out.argv.push("--", ...positionals);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clyops-jobs",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Run clyops tools as jobs: config-bound functions, templated invocation, artifacts, job records and a queue.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "typescript": "^5.6.0"
39
39
  },
40
40
  "dependencies": {
41
- "clyops-tools": "0.7.0"
41
+ "clyops-tools": "0.9.0"
42
42
  },
43
43
  "homepage": "https://clyops.io/node-tools.html",
44
44
  "scripts": {