@dashai/cli 0.18.0 → 0.18.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/bin.js CHANGED
@@ -9722,6 +9722,32 @@ init_api_client();
9722
9722
  init_config();
9723
9723
  init_manifest_io();
9724
9724
  init_output();
9725
+ var SMART_DASH_RE = /^[‒–—―−]/;
9726
+ function strayArgsError(stray, usage) {
9727
+ if (!stray || stray.length === 0) return null;
9728
+ const lines = [
9729
+ `Unexpected argument${stray.length > 1 ? "s" : ""} ${stray.map((s) => `"${s}"`).join(", ")} \u2014 ${usage}`
9730
+ ];
9731
+ if (stray.some((s) => SMART_DASH_RE.test(s))) {
9732
+ lines.push(
9733
+ `A token starts with a typographic dash (\u2013 / \u2014) instead of ASCII "--". If this command was copy-pasted, the editor/chat likely rewrote the double hyphen \u2014 retype the flag by hand (e.g. ${code("--grant")}, ${code("--full-access")}).`
9734
+ );
9735
+ }
9736
+ if (stray.some((s) => /^(module|datahub):/.test(s))) {
9737
+ lines.push(
9738
+ `Grant specs must be passed via the (repeatable) ${code("--grant")} flag, e.g. ${code("--grant module:employees:create,read")}.`
9739
+ );
9740
+ }
9741
+ if (stray.some((s) => s.startsWith("--"))) {
9742
+ lines.push(
9743
+ `Tokens after a bare ${code("--")} separator are treated as plain arguments, not flags \u2014 remove the ${code("--")}.`
9744
+ );
9745
+ }
9746
+ lines.push(
9747
+ "Refusing to continue: silently ignoring these arguments is how grantless (deny-all) keys get minted by accident."
9748
+ );
9749
+ return lines.join("\n ");
9750
+ }
9725
9751
  function loadContext4(opts) {
9726
9752
  const cfg = readConfig();
9727
9753
  if (!cfg) {
@@ -9787,6 +9813,14 @@ async function resolveInstallKind(ctx) {
9787
9813
  return void 0;
9788
9814
  }
9789
9815
  async function apiKeysListCommand(options) {
9816
+ const strayErr = strayArgsError(
9817
+ options.stray,
9818
+ "`dashwise api-keys list` takes no positional arguments."
9819
+ );
9820
+ if (strayErr) {
9821
+ fail(strayErr);
9822
+ return 1;
9823
+ }
9790
9824
  let ctx;
9791
9825
  try {
9792
9826
  ctx = loadContext4(options);
@@ -9837,6 +9871,20 @@ async function apiKeysListCommand(options) {
9837
9871
  return 0;
9838
9872
  }
9839
9873
  async function apiKeysCreateCommand(nameArg, options) {
9874
+ if (nameArg !== void 0 && SMART_DASH_RE.test(nameArg)) {
9875
+ fail(
9876
+ `"${nameArg}" was read as the key NAME but looks like a flag typed with a typographic dash (\u2013 / \u2014) instead of ASCII "--". If this command was copy-pasted, the editor/chat likely rewrote the double hyphen \u2014 retype the flag by hand (e.g. ${code("--grant")}, ${code("--full-access")}).`
9877
+ );
9878
+ return 1;
9879
+ }
9880
+ const strayErr = strayArgsError(
9881
+ options.stray,
9882
+ "`dashwise api-keys create` takes a single <name>."
9883
+ );
9884
+ if (strayErr) {
9885
+ fail(strayErr);
9886
+ return 1;
9887
+ }
9840
9888
  const name = nameArg ?? options.name;
9841
9889
  if (!name) {
9842
9890
  fail("Usage: `dashwise api-keys create <name>` (e.g. `dashwise api-keys create production`)");
@@ -9925,6 +9973,14 @@ async function apiKeysCreateCommand(nameArg, options) {
9925
9973
  return 0;
9926
9974
  }
9927
9975
  async function apiKeysRevokeCommand(keyIdArg, options) {
9976
+ const strayErr = strayArgsError(
9977
+ options.stray,
9978
+ "`dashwise api-keys revoke` takes a single <key-id> \u2014 extra ids would be silently skipped."
9979
+ );
9980
+ if (strayErr) {
9981
+ fail(strayErr);
9982
+ return 1;
9983
+ }
9928
9984
  if (!keyIdArg) {
9929
9985
  fail("Usage: `dashwise api-keys revoke <key-id>` \u2014 id from `dashwise api-keys list`");
9930
9986
  return 1;
@@ -11760,14 +11816,19 @@ apiKeysCmd.command("list").description(
11760
11816
  "--install <id>",
11761
11817
  "Target a specific installation id instead of the cached dev install (production installs included). Find ids via `dashwise module status <slug>`.",
11762
11818
  parseIntOption
11763
- ).option("--all", "Include revoked + expired keys in the output.").option("--json", "Emit JSON instead of the human-friendly table.").action(async (cmdOpts) => {
11764
- process.exitCode = await apiKeysListCommand({
11765
- ...cmdOpts.dir !== void 0 ? { dir: cmdOpts.dir } : {},
11766
- ...cmdOpts.install !== void 0 ? { install: cmdOpts.install } : {},
11767
- ...cmdOpts.all !== void 0 ? { all: cmdOpts.all } : {},
11768
- ...cmdOpts.json !== void 0 ? { json: cmdOpts.json } : {}
11769
- });
11770
- });
11819
+ ).option("--all", "Include revoked + expired keys in the output.").option("--json", "Emit JSON instead of the human-friendly table.").action(
11820
+ async (cmdOpts, cmd) => {
11821
+ process.exitCode = await apiKeysListCommand({
11822
+ ...cmdOpts.dir !== void 0 ? { dir: cmdOpts.dir } : {},
11823
+ ...cmdOpts.install !== void 0 ? { install: cmdOpts.install } : {},
11824
+ ...cmdOpts.all !== void 0 ? { all: cmdOpts.all } : {},
11825
+ ...cmdOpts.json !== void 0 ? { json: cmdOpts.json } : {},
11826
+ // Operands commander would otherwise SILENTLY drop (default
11827
+ // allowExcessArguments) — the command hard-errors on them.
11828
+ ...cmd.args.length > 0 ? { stray: cmd.args } : {}
11829
+ });
11830
+ }
11831
+ );
11771
11832
  apiKeysCmd.command("create [name]").description(
11772
11833
  "Mint a new API key. The plaintext key is displayed ONCE \u2014 save it then."
11773
11834
  ).option("--dir <path>", "Project root (default: current directory).").option(
@@ -11790,7 +11851,8 @@ apiKeysCmd.command("create [name]").description(
11790
11851
  "--raw-only",
11791
11852
  "Print only the plaintext key on stdout; chatter goes to stderr. Useful for shell capture: `KEY=$(dashwise api-keys create prod --raw-only)`"
11792
11853
  ).action(
11793
- async (nameArg, cmdOpts) => {
11854
+ async (nameArg, cmdOpts, cmd) => {
11855
+ const stray = cmd.args.slice(1);
11794
11856
  process.exitCode = await apiKeysCreateCommand(nameArg, {
11795
11857
  ...cmdOpts.dir !== void 0 ? { dir: cmdOpts.dir } : {},
11796
11858
  ...cmdOpts.install !== void 0 ? { install: cmdOpts.install } : {},
@@ -11798,7 +11860,8 @@ apiKeysCmd.command("create [name]").description(
11798
11860
  ...cmdOpts.grant !== void 0 && cmdOpts.grant.length > 0 ? { grant: cmdOpts.grant } : {},
11799
11861
  ...cmdOpts.fullAccess !== void 0 ? { fullAccess: cmdOpts.fullAccess } : {},
11800
11862
  ...cmdOpts.expires !== void 0 ? { expires: cmdOpts.expires } : {},
11801
- ...cmdOpts.rawOnly !== void 0 ? { rawOnly: cmdOpts.rawOnly } : {}
11863
+ ...cmdOpts.rawOnly !== void 0 ? { rawOnly: cmdOpts.rawOnly } : {},
11864
+ ...stray.length > 0 ? { stray } : {}
11802
11865
  });
11803
11866
  }
11804
11867
  );
@@ -11809,11 +11872,13 @@ apiKeysCmd.command("revoke [key-id]").description(
11809
11872
  "Target a specific installation id instead of the cached dev install (production installs included). Find ids via `dashwise module status <slug>`.",
11810
11873
  parseIntOption
11811
11874
  ).option("-y, --yes", "Skip the per-key confirmation message (for CI / scripts).").action(
11812
- async (keyIdArg, cmdOpts) => {
11875
+ async (keyIdArg, cmdOpts, cmd) => {
11876
+ const stray = cmd.args.slice(1);
11813
11877
  process.exitCode = await apiKeysRevokeCommand(keyIdArg, {
11814
11878
  ...cmdOpts.dir !== void 0 ? { dir: cmdOpts.dir } : {},
11815
11879
  ...cmdOpts.install !== void 0 ? { install: cmdOpts.install } : {},
11816
- ...cmdOpts.yes !== void 0 ? { yes: cmdOpts.yes } : {}
11880
+ ...cmdOpts.yes !== void 0 ? { yes: cmdOpts.yes } : {},
11881
+ ...stray.length > 0 ? { stray } : {}
11817
11882
  });
11818
11883
  }
11819
11884
  );
@@ -12160,7 +12225,7 @@ fieldCmd.command("set-type <table-slug> <field-slug> <new-type>").description(
12160
12225
  }
12161
12226
  })();
12162
12227
  function getVersion() {
12163
- return "0.18.0";
12228
+ return "0.18.1";
12164
12229
  }
12165
12230
  function parseIntOption(value) {
12166
12231
  const n = Number.parseInt(value, 10);