@formigio/fazemos-cli 0.10.5 → 0.10.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/dist/index.js CHANGED
@@ -3536,6 +3536,7 @@ templates
3536
3536
  .option('--pipeline-input <name>', 'Pipeline-level input name (use instead of --source-step/--source-output)')
3537
3537
  .option('--description <desc>', 'What this data is used for')
3538
3538
  .option('--optional', 'Mark as not required (default: required)')
3539
+ .option('--required-value <value>', 'Require the upstream output to have this value before dispatching. Comma-separate multiple accepted values. Example: --required-value approved Example: --required-value "published,skipped"')
3539
3540
  .action(async (templateId, opts) => {
3540
3541
  try {
3541
3542
  const hasSrc = opts.sourceStep || opts.sourceOutput;
@@ -3601,14 +3602,24 @@ templates
3601
3602
  }
3602
3603
  if (opts.description)
3603
3604
  input.description = opts.description;
3605
+ if (opts.requiredValue !== undefined) {
3606
+ const parts = opts.requiredValue.split(',').map((v) => v.trim()).filter((v) => v.length > 0);
3607
+ input.required_value = parts.length === 1 ? parts[0] : parts;
3608
+ }
3604
3609
  step.inputs.push(input);
3605
3610
  await api('PUT', `/api/pipeline-templates/${templateId}`, { definition: t.definition });
3606
3611
  if (opts.sourceStep) {
3607
3612
  const srcStep = findStepById(t.definition, opts.sourceStep);
3608
- console.log(chalk.green(`Added input ← ${opts.name} ← ${srcStep.name}.${opts.sourceOutput} to ${step.name}`));
3613
+ let msg = `Added input ← ${opts.name} ← ${srcStep.name}.${opts.sourceOutput} to ${step.name}`;
3614
+ if (opts.requiredValue !== undefined)
3615
+ msg += `\n Required value: ${opts.requiredValue}`;
3616
+ console.log(chalk.green(msg));
3609
3617
  }
3610
3618
  else {
3611
- console.log(chalk.green(`Added input ← ${opts.name} ← pipeline.${opts.pipelineInput} to ${step.name}`));
3619
+ let msg = `Added input ← ${opts.name} ← pipeline.${opts.pipelineInput} to ${step.name}`;
3620
+ if (opts.requiredValue !== undefined)
3621
+ msg += `\n Required value: ${opts.requiredValue}`;
3622
+ console.log(chalk.green(msg));
3612
3623
  }
3613
3624
  }
3614
3625
  catch (err) {
@@ -7287,12 +7298,16 @@ docs
7287
7298
  handleScopedError(err);
7288
7299
  }
7289
7300
  });
7290
- // Only auto-parse when invoked as the entry point (i.e. `node dist/index.js ...`
7291
- // or `npx tsx src/index.ts ...`). When imported as a module — by tests using
7292
- // `vi.mock` to intercept `api()` and asserting on `program.parseAsync(...)`
7293
- // skip auto-parse so the test controls invocation.
7294
- const isMainModule = import.meta.url === `file://${process.argv[1]}`;
7295
- if (isMainModule)
7301
+ // Skip auto-parse only when running under Vitest (which sets process.env.VITEST).
7302
+ // Tests import `program` and drive it via `program.parseAsync(...)` after mocking
7303
+ // `./api.js`. In every other context direct invocation, npx tsx, OR the bin
7304
+ // shim that does `import('../dist/index.js')` — auto-parse must run, otherwise
7305
+ // the CLI produces no output.
7306
+ //
7307
+ // Earlier `import.meta.url === file://${process.argv[1]}` check was wrong: the
7308
+ // bin shim's argv[1] is the shim path, not the dist/index.js path, so the guard
7309
+ // returned false and silently skipped parse.
7310
+ if (!process.env.VITEST)
7296
7311
  program.parse();
7297
7312
  export { program };
7298
7313
  //# sourceMappingURL=index.js.map