@swmansion/argent 0.22.1 → 0.22.2-next.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.
Binary file
Binary file
Binary file
Binary file
package/dist/cli-cmds.mjs CHANGED
@@ -7210,7 +7210,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
7210
7210
  var SESSION_ID2 = randomUUID5();
7211
7211
  function readCliVersion() {
7212
7212
  if (true) {
7213
- return "0.22.1";
7213
+ return "0.22.2-next.1";
7214
7214
  }
7215
7215
  return "0.0.0";
7216
7216
  }
@@ -7814,6 +7814,20 @@ function isScalarType(type) {
7814
7814
  function isJsonField(prop) {
7815
7815
  return prop?.type === "object" || prop?.type === "array" && !isScalarType(prop.items?.type);
7816
7816
  }
7817
+ function isRetiredField(prop) {
7818
+ return prop.not !== void 0 && Object.keys(prop.not).length === 0;
7819
+ }
7820
+ function retirementGuidance(prop) {
7821
+ return (prop.description ?? "").replace(/^Retired:\s*/, "");
7822
+ }
7823
+ function retiredFieldFor(flag, properties) {
7824
+ const bare = flag.endsWith("-json") ? flag.slice(0, -"-json".length) : flag;
7825
+ for (const name of [flag, bare, bare.startsWith("no-") ? bare.slice(3) : bare]) {
7826
+ const prop = properties[name];
7827
+ if (prop !== void 0) return isRetiredField(prop) ? name : void 0;
7828
+ }
7829
+ return void 0;
7830
+ }
7817
7831
  function flagNameFor(name, prop) {
7818
7832
  return isJsonField(prop) ? `--${name}-json` : `--${name}`;
7819
7833
  }
@@ -7893,6 +7907,13 @@ function parseFlags(argv, schema) {
7893
7907
  } else {
7894
7908
  flag = tok.slice(2);
7895
7909
  }
7910
+ const retiredField = retiredFieldFor(flag, properties);
7911
+ if (retiredField !== void 0) {
7912
+ const guidance = retirementGuidance(properties[retiredField]);
7913
+ throw new FlagParseException(
7914
+ `--${retiredField} is retired${guidance ? `: ${guidance}` : ""}`
7915
+ );
7916
+ }
7896
7917
  if (flag === "args" && properties.args === void 0) {
7897
7918
  const { value: value2, nextIndex: nextIndex2 } = inlineValue !== void 0 ? { value: inlineValue, nextIndex: i2 } : takeNext(i2, "args");
7898
7919
  rawArgs = value2;
@@ -7984,19 +8005,25 @@ function formatSchemaUsage(schema) {
7984
8005
  const lines = [];
7985
8006
  const entries = Object.entries(schema.properties);
7986
8007
  if (entries.length === 0) return " (no parameters)";
8008
+ const live = entries.filter(([, prop]) => !isRetiredField(prop));
7987
8009
  let maxFlagLen = 0;
7988
- for (const [name, prop] of entries) {
8010
+ for (const [name, prop] of live) {
7989
8011
  const display = renderFlagName(name, prop);
7990
8012
  if (display.length > maxFlagLen) maxFlagLen = display.length;
7991
8013
  }
7992
- for (const [name, prop] of entries) {
8014
+ for (const [name, prop] of live) {
7993
8015
  const flag = renderFlagName(name, prop).padEnd(maxFlagLen, " ");
7994
8016
  const typeLabel = renderType(prop);
7995
8017
  const req = required.has(name) ? " (required)" : "";
7996
8018
  const desc = prop.description ? ` ${prop.description}` : "";
7997
8019
  lines.push(` ${flag} ${typeLabel}${req}${desc}`);
7998
8020
  }
7999
- if (entries.some(([, prop]) => prop.type === "boolean")) {
8021
+ for (const [name, prop] of entries) {
8022
+ if (!isRetiredField(prop)) continue;
8023
+ const desc = retirementGuidance(prop);
8024
+ lines.push(` Retired: ${name}${desc ? ` - ${desc}` : ""}`);
8025
+ }
8026
+ if (live.some(([, prop]) => prop.type === "boolean")) {
8000
8027
  lines.push(
8001
8028
  "",
8002
8029
  " Booleans: --flag, --flag true, or --flag 1 sets true; --flag false, --flag 0, --flag=false, or --no-flag sets false."
@@ -8024,9 +8051,12 @@ function renderType(prop) {
8024
8051
 
8025
8052
  // ../argent-cli/src/run-validation.ts
8026
8053
  function findMissingRequired(payload, schema) {
8027
- const required = new Set(schema?.required ?? []);
8054
+ const properties = schema?.properties ?? {};
8055
+ const required = new Set(
8056
+ (schema?.required ?? []).filter((name) => !isRetiredField(properties[name] ?? {}))
8057
+ );
8028
8058
  if (required.size === 0) return [];
8029
- const declared = Object.keys(schema?.properties ?? {});
8059
+ const declared = Object.keys(properties);
8030
8060
  const names = [...declared.filter((n2) => required.has(n2))];
8031
8061
  for (const name of required) {
8032
8062
  if (!names.includes(name)) names.push(name);
@@ -8055,7 +8085,9 @@ function describeServerValidationFailure(err, payload, schema) {
8055
8085
  const properties = schema?.properties ?? {};
8056
8086
  const addressesThisTool = (issue) => issue.path.length === 0 || typeof issue.path[0] === "string" && Object.hasOwn(properties, issue.path[0]);
8057
8087
  if (!parsed.every(addressesThisTool)) return null;
8058
- const required = new Set(schema?.required ?? []);
8088
+ const required = new Set(
8089
+ (schema?.required ?? []).filter((name) => !isRetiredField(properties[name] ?? {}))
8090
+ );
8059
8091
  const missing = [];
8060
8092
  const invalid = [];
8061
8093
  for (const issue of parsed) {
@@ -8259,15 +8291,14 @@ Examples:
8259
8291
  process.exit(1);
8260
8292
  }
8261
8293
  const schema = meta.inputSchema;
8262
- const failValidation = async (report, stage) => {
8263
- const summary = formatValidationError(report, schema);
8294
+ const failInvocation = async (summary, report, failure) => {
8264
8295
  if (json) {
8265
8296
  console.error(
8266
8297
  JSON.stringify(
8267
8298
  {
8268
8299
  error: summary,
8269
- missing: missingFlagNames(report, schema),
8270
- issues: report.rawIssues ?? []
8300
+ missing: report ? missingFlagNames(report, schema) : [],
8301
+ issues: report?.rawIssues ?? []
8271
8302
  },
8272
8303
  null,
8273
8304
  2
@@ -8279,28 +8310,25 @@ Examples:
8279
8310
  printToolHelp(meta);
8280
8311
  }
8281
8312
  await trackRunFailure(toolName, startedAt, {
8282
- error_code: FAILURE_CODES.CLI_RUN_INPUT_VALIDATION_FAILED,
8283
- failure_stage: stage,
8313
+ ...failure,
8284
8314
  failure_area: "cli",
8285
8315
  error_kind: "validation"
8286
8316
  });
8287
8317
  process.exit(2);
8288
8318
  };
8319
+ const failValidation = (report, stage) => failInvocation(formatValidationError(report, schema), report, {
8320
+ error_code: FAILURE_CODES.CLI_RUN_INPUT_VALIDATION_FAILED,
8321
+ failure_stage: stage
8322
+ });
8289
8323
  let parsed;
8290
8324
  try {
8291
8325
  parsed = parseFlags(argvForFlags, schema);
8292
8326
  } catch (err) {
8293
8327
  if (err instanceof FlagParseException) {
8294
- console.error(`Error: ${err.message}
8295
- `);
8296
- printToolHelp(meta);
8297
- await trackRunFailure(toolName, startedAt, {
8328
+ await failInvocation(err.message, null, {
8298
8329
  error_code: FAILURE_CODES.CLI_RUN_FLAG_PARSE_FAILED,
8299
- failure_stage: "cli_run_parse_flags",
8300
- failure_area: "cli",
8301
- error_kind: "validation"
8330
+ failure_stage: "cli_run_parse_flags"
8302
8331
  });
8303
- process.exit(2);
8304
8332
  }
8305
8333
  throw err;
8306
8334
  }
@@ -16428,7 +16428,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
16428
16428
  var SESSION_ID = randomUUID4();
16429
16429
  function readCliVersion() {
16430
16430
  if (true) {
16431
- return "0.22.1";
16431
+ return "0.22.2-next.1";
16432
16432
  }
16433
16433
  return "0.0.0";
16434
16434
  }