@gql.tada/cli-utils 1.9.0 → 1.9.2

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.
@@ -10,7 +10,7 @@ import p from "node:fs/promises";
10
10
 
11
11
  import { emitKeypressEvents as h } from "node:readline";
12
12
 
13
- import { printSchema as g, parse as m, Kind as v, print as y, visit as w, getNamedType as S, isListType as $, getNullableType as b, TypeInfo as x, visitInParallel as E, visitWithTypeInfo as C, isObjectType as k, isInterfaceType as O } from "graphql";
13
+ import { printSchema as g, parse as m, Kind as v, print as y, visit as w, getNamedType as S, isListType as $, getNullableType as b, TypeInfo as x, visitInParallel as C, visitWithTypeInfo as E, isObjectType as k, isInterfaceType as O } from "graphql";
14
14
 
15
15
  import * as N from "node:crypto";
16
16
 
@@ -41,9 +41,9 @@ var B = -1;
41
41
 
42
42
  var _ = /^(-h|--help)(?:=([0-9]+))?$/;
43
43
 
44
- var R = /^(--[a-z]+(?:-[a-z]+)*|-[a-zA-Z]+)$/;
44
+ var j = /^(--[a-z]+(?:-[a-z]+)*|-[a-zA-Z]+)$/;
45
45
 
46
- var j = /^-[a-zA-Z]{2,}$/;
46
+ var R = /^-[a-zA-Z]{2,}$/;
47
47
 
48
48
  var L = /^([^=]+)=([\s\S]*)$/;
49
49
 
@@ -384,13 +384,13 @@ function runMachineInternal(t, r, a = !1) {
384
384
  }
385
385
  }
386
386
  if (!l) {
387
- for (var [x, {to: E, reducer: C}] of p.dynamics) {
387
+ for (var [x, {to: C, reducer: E}] of p.dynamics) {
388
388
  if (execute(W, x, f, s, c)) {
389
389
  u.push({
390
- node: E,
391
- state: void 0 !== C ? execute(K, C, f, s, c) : f
390
+ node: C,
391
+ state: void 0 !== E ? execute(K, E, f, s, c) : f
392
392
  });
393
- debug(` Dynamic transition to ${E} found (via ${x})`);
393
+ debug(` Dynamic transition to ${C} found (via ${x})`);
394
394
  }
395
395
  }
396
396
  }
@@ -564,15 +564,15 @@ var W = {
564
564
  isOptionLike: (t, r) => !t.ignoreOptions && "-" !== r && r.startsWith("-"),
565
565
  isNotOptionLike: (t, r) => t.ignoreOptions || "-" === r || !r.startsWith("-"),
566
566
  isOption: (t, r, a, n) => !t.ignoreOptions && r === n,
567
- isBatchOption: (t, r, a, n) => !t.ignoreOptions && j.test(r) && [ ...r.slice(1) ].every((t => n.has(`-${t}`))),
567
+ isBatchOption: (t, r, a, n) => !t.ignoreOptions && R.test(r) && [ ...r.slice(1) ].every((t => n.has(`-${t}`))),
568
568
  isBoundOption: (t, r, a, n, i) => {
569
569
  var o = r.match(L);
570
- return !t.ignoreOptions && !!o && R.test(o[1]) && n.has(o[1]) && i.filter((t => t.nameSet.includes(o[1]))).every((t => t.allowBinding));
570
+ return !t.ignoreOptions && !!o && j.test(o[1]) && n.has(o[1]) && i.filter((t => t.nameSet.includes(o[1]))).every((t => t.allowBinding));
571
571
  },
572
572
  isNegatedOption: (t, r, a, n) => !t.ignoreOptions && r === `--no-${n.slice(2)}`,
573
573
  isHelp: (t, r) => !t.ignoreOptions && _.test(r),
574
- isUnsupportedOption: (t, r, a, n) => !t.ignoreOptions && r.startsWith("-") && R.test(r) && !n.has(r),
575
- isInvalidOption: (t, r) => !t.ignoreOptions && r.startsWith("-") && !R.test(r)
574
+ isUnsupportedOption: (t, r, a, n) => !t.ignoreOptions && r.startsWith("-") && j.test(r) && !n.has(r),
575
+ isInvalidOption: (t, r) => !t.ignoreOptions && r.startsWith("-") && !j.test(r)
576
576
  };
577
577
 
578
578
  var K = {
@@ -1070,20 +1070,20 @@ class CommandBuilder {
1070
1070
  }
1071
1071
  var b = v;
1072
1072
  for (var x = 0; x < this.arity.trailing.length; ++x) {
1073
- var E = injectNode(t, {
1073
+ var C = injectNode(t, {
1074
1074
  dynamics: [],
1075
1075
  shortcuts: [],
1076
1076
  statics: {}
1077
1077
  });
1078
1078
  if (!this.arity.proxy) {
1079
- this.registerOptions(t, E);
1079
+ this.registerOptions(t, C);
1080
1080
  }
1081
1081
  if (x + 1 < this.arity.trailing.length) {
1082
- registerStatic(t, E, M.EndOfInput, F.ErrorNode, [ "setError", "Not enough positional arguments" ]);
1083
- registerStatic(t, E, M.EndOfPartialInput, F.SuccessNode, [ "setSelectedIndex", this.cliIndex ]);
1082
+ registerStatic(t, C, M.EndOfInput, F.ErrorNode, [ "setError", "Not enough positional arguments" ]);
1083
+ registerStatic(t, C, M.EndOfPartialInput, F.SuccessNode, [ "setSelectedIndex", this.cliIndex ]);
1084
1084
  }
1085
- registerDynamic(t, b, "isNotOptionLike", E, "pushPositional");
1086
- b = E;
1085
+ registerDynamic(t, b, "isNotOptionLike", C, "pushPositional");
1086
+ b = C;
1087
1087
  }
1088
1088
  registerDynamic(t, b, i, F.ErrorNode, [ "setError", "Extraneous positional argument" ]);
1089
1089
  registerStatic(t, b, M.EndOfInput, F.SuccessNode, [ "setSelectedIndex", this.cliIndex ]);
@@ -1579,10 +1579,10 @@ class Cli {
1579
1579
  var x = null !== $ ? $.trim() : "General commands";
1580
1580
  d += "\n";
1581
1581
  d += `${this.format(r).header(`${x}`)}\n`;
1582
- for (var {commandClass: E, usage: C} of b) {
1583
- var k = E.usage.description || "undocumented";
1582
+ for (var {commandClass: C, usage: E} of b) {
1583
+ var k = C.usage.description || "undocumented";
1584
1584
  d += "\n";
1585
- d += ` ${this.format(r).bold(C)}\n`;
1585
+ d += ` ${this.format(r).bold(E)}\n`;
1586
1586
  d += ` ${formatMarkdownish(k, {
1587
1587
  format: this.format(r),
1588
1588
  paragraphs: !1
@@ -1638,13 +1638,13 @@ class Cli {
1638
1638
  if (I.length > 0) {
1639
1639
  d += "\n";
1640
1640
  d += `${this.format(r).header("Examples")}\n`;
1641
- for (var [R, j] of I) {
1641
+ for (var [j, R] of I) {
1642
1642
  d += "\n";
1643
- d += formatMarkdownish(R, {
1643
+ d += formatMarkdownish(j, {
1644
1644
  format: this.format(r),
1645
1645
  paragraphs: !1
1646
1646
  });
1647
- d += `${j.replace(/^/m, ` ${this.format(r).bold(n)}`).replace(/\$0/g, this.binaryName)}\n`;
1647
+ d += `${R.replace(/^/m, ` ${this.format(r).bold(n)}`).replace(/\$0/g, this.binaryName)}\n`;
1648
1648
  }
1649
1649
  }
1650
1650
  }
@@ -2786,12 +2786,17 @@ function initTTY(t = {}) {
2786
2786
  });
2787
2787
  }
2788
2788
  function cleanup() {
2789
- if (t.isTTY) {
2790
- t.setRawMode(!1);
2789
+ try {
2790
+ if (t.isTTY) {
2791
+ t.setRawMode(!1);
2792
+ }
2793
+ t.removeListener("keypress", onKeypress);
2794
+ if ("function" == typeof t.unref) {
2795
+ t.unref();
2796
+ }
2797
+ } catch {} finally {
2798
+ a.complete();
2791
2799
  }
2792
- a.complete();
2793
- t.removeListener("keypress", onKeypress);
2794
- t.unref();
2795
2800
  }
2796
2801
  if (t.isTTY) {
2797
2802
  t.setRawMode(!0);
@@ -3051,14 +3056,27 @@ async function* run$6(t, r) {
3051
3056
  if (a.length > 1 && (r.output || t.pipeTo)) {
3052
3057
  throw errorMessage$1("Output path was specified, while multiple projects are configured.\n" + hint(`You can only output all projects to their ${code('"tadaOutputLocation"')} options\nwhen multiple projects are set up through ${code('"references"')}.`));
3053
3058
  }
3054
- for (var n of a) {
3059
+ var n = new Set;
3060
+ for (var i of a) {
3061
+ var o = outputDestinations(i);
3062
+ if (o.length && o.every((t => n.has(t)))) {
3063
+ continue;
3064
+ }
3065
+ for (var s of o) {
3066
+ n.add(s);
3067
+ }
3055
3068
  if (a.length > 1) {
3056
- yield projectHeader(n.label);
3069
+ yield projectHeader(i.label);
3057
3070
  }
3058
- yield* runProject$3(t, r, n);
3071
+ yield* runProject$3(t, r, i);
3059
3072
  }
3060
3073
  }
3061
3074
 
3075
+ function outputDestinations(r) {
3076
+ var {pluginConfig: a, projectPath: n} = r;
3077
+ return ("schemas" in a ? a.schemas.map((t => t.tadaOutputLocation)) : [ a.tadaOutputLocation ]).filter((t => !!t)).map((r => t.resolve(n, r)));
3078
+ }
3079
+
3062
3080
  async function* runProject$3(r, a, n) {
3063
3081
  var {pluginConfig: i, projectPath: o} = n;
3064
3082
  var d = s(i);
@@ -3332,25 +3350,25 @@ async function* runProject$2(r, a, n, i) {
3332
3350
  }
3333
3351
  var b = {};
3334
3352
  for (var x of s.schemas) {
3335
- var {name: E, tadaPersistedLocation: C} = x;
3336
- if (!C) {
3337
- throw errorMessage$1(`No output path was specified to write the '${E}' schema to.\n` + hint(`You have to set ${code('"tadaPersistedLocation"')} in each schema configuration.`));
3353
+ var {name: C, tadaPersistedLocation: E} = x;
3354
+ if (!E) {
3355
+ throw errorMessage$1(`No output path was specified to write the '${C}' schema to.\n` + hint(`You have to set ${code('"tadaPersistedLocation"')} in each schema configuration.`));
3338
3356
  }
3339
3357
  try {
3340
- b[E] = 0;
3358
+ b[C] = 0;
3341
3359
  var k = {};
3342
3360
  for (var O of u) {
3343
- if (O.schemaName === E) {
3361
+ if (O.schemaName === C) {
3344
3362
  k[O.hashKey] = O.document;
3345
- b[E]++;
3363
+ b[C]++;
3346
3364
  }
3347
3365
  }
3348
- if (b[E]) {
3366
+ if (b[C]) {
3349
3367
  var N = JSON.stringify(k, null, 2);
3350
- await writeOutput(t.resolve(l, C), N);
3368
+ await writeOutput(t.resolve(l, E), N);
3351
3369
  }
3352
3370
  } catch (t) {
3353
- throw externalError(`Something went wrong while writing the '${E}' schema's persisted manifest file.`, t);
3371
+ throw externalError(`Something went wrong while writing the '${C}' schema's persisted manifest file.`, t);
3354
3372
  }
3355
3373
  }
3356
3374
  if (d && a.failOnWarn) {
@@ -4047,23 +4065,23 @@ async function* runProject$1(r, a, n, i) {
4047
4065
  if (a.output) {
4048
4066
  throw errorMessage$1("Output path was specified, while multiple schemas are configured.\n" + hint(`You can only output all schemas to their ${code('"tadaTurboLocation"')} options\nwhen multiple ${code("schemas")} are set up.`));
4049
4067
  }
4050
- var E = {};
4051
4068
  var C = {};
4069
+ var E = {};
4052
4070
  for (var k of s.schemas) {
4053
4071
  var {name: O, tadaTurboLocation: N} = k;
4054
4072
  if (!N) {
4055
4073
  throw errorMessage$1(`No output path was specified to write the '${O}' type cache to.\n` + hint(`You have to set ${code('"tadaTurboLocation"')} in each schema configuration.`));
4056
4074
  }
4057
4075
  try {
4058
- E[O] = 0;
4059
4076
  C[O] = 0;
4077
+ E[O] = 0;
4060
4078
  var T = [];
4061
4079
  for (var I of p) {
4062
4080
  if (I.schemaName === O) {
4063
4081
  T.push(I);
4064
- E[O]++;
4082
+ C[O]++;
4065
4083
  if (I.isCached) {
4066
- C[O]++;
4084
+ E[O]++;
4067
4085
  }
4068
4086
  }
4069
4087
  }
@@ -4083,7 +4101,7 @@ async function* runProject$1(r, a, n, i) {
4083
4101
  failed: !0
4084
4102
  };
4085
4103
  } else {
4086
- yield infoSummary$1(g, E, C);
4104
+ yield infoSummary$1(g, C, E);
4087
4105
  }
4088
4106
  }
4089
4107
  return {
@@ -4574,7 +4592,7 @@ class ScanContext {
4574
4592
  }
4575
4593
  }
4576
4594
 
4577
- var Ee = {
4595
+ var Ce = {
4578
4596
  name: "field-usage",
4579
4597
  description: "Used fields, keyed by schema coordinate, with their reach.",
4580
4598
  create(t) {
@@ -4659,8 +4677,8 @@ var Ee = {
4659
4677
  for (var x of $.areas) {
4660
4678
  y.add(x);
4661
4679
  }
4662
- for (var E of $.entryPoints) {
4663
- w.add(E);
4680
+ for (var C of $.entryPoints) {
4681
+ w.add(C);
4664
4682
  }
4665
4683
  }
4666
4684
  l.push({
@@ -4694,7 +4712,7 @@ var Ee = {
4694
4712
  }
4695
4713
  };
4696
4714
 
4697
- var Ce = [ Ee, {
4715
+ var Ee = [ Ce, {
4698
4716
  name: "input-usage",
4699
4717
  description: "Usage counts for enum values and input-object fields.",
4700
4718
  create(t) {
@@ -5266,7 +5284,7 @@ var Ne = 8;
5266
5284
 
5267
5285
  var Te = 24;
5268
5286
 
5269
- var Ie = new Map(Ce.map((t => [ t.name, t.description ])));
5287
+ var Ie = new Map(Ee.map((t => [ t.name, t.description ])));
5270
5288
 
5271
5289
  var truncate = (t, r) => t.length <= r ? t : r > 1 ? t.slice(0, r - 1) + oe.Ellipsis : oe.Ellipsis;
5272
5290
 
@@ -5460,7 +5478,7 @@ async function* runProject(r, a, n) {
5460
5478
  throw externalError("Could not scan files", t);
5461
5479
  }
5462
5480
  var $;
5463
- var {context: b, rules: k} = function analyze(t, r = Ce) {
5481
+ var {context: b, rules: k} = function analyze(t, r = Ee) {
5464
5482
  var a = new ScanContext(t);
5465
5483
  var n = r.map((t => ({
5466
5484
  name: t.name,
@@ -5473,11 +5491,11 @@ async function* runProject(r, a, n) {
5473
5491
  }
5474
5492
  var l = new x(o);
5475
5493
  a.setTypeInfo(l);
5476
- var c = E([ a.trackingVisitor(), ...n.map((({instance: t}) => t.visitor)) ]);
5494
+ var c = C([ a.trackingVisitor(), ...n.map((({instance: t}) => t.visitor)) ]);
5477
5495
  w({
5478
5496
  kind: v.DOCUMENT,
5479
5497
  definitions: s
5480
- }, C(l, c));
5498
+ }, E(l, c));
5481
5499
  }
5482
5500
  var u = {};
5483
5501
  for (var {name: d, instance: f} of n) {
@@ -5744,11 +5762,11 @@ class CheckCommand extends Command {
5744
5762
  }
5745
5763
  }
5746
5764
 
5747
- var Re = new Intl.Collator(0, {
5765
+ var je = new Intl.Collator(0, {
5748
5766
  numeric: 1
5749
5767
  }).compare;
5750
5768
 
5751
- var je = {
5769
+ var Re = {
5752
5770
  typescript_embed_lsp: "5.5.0",
5753
5771
  typescript: "4.1.0",
5754
5772
  tada: "1.0.0",
@@ -5760,7 +5778,7 @@ var semverComply = (t, r) => {
5760
5778
  return a ? function semiver(t, r, a) {
5761
5779
  t = t.split(".");
5762
5780
  r = r.split(".");
5763
- return Re(t[0], r[0]) || Re(t[1], r[1]) || (r[2] = r.slice(2).join("."), (a = /[.-]/.test(t[2] = t.slice(2).join("."))) == /[.-]/.test(r[2]) ? Re(t[2], r[2]) : a ? -1 : 1);
5781
+ return je(t[0], r[0]) || je(t[1], r[1]) || (r[2] = r.slice(2).join("."), (a = /[.-]/.test(t[2] = t.slice(2).join("."))) == /[.-]/.test(r[2]) ? je(t[2], r[2]) : a ? -1 : 1);
5764
5782
  }(a[0], r) >= 0 : !1;
5765
5783
  };
5766
5784
 
@@ -7472,14 +7490,14 @@ async function* run() {
7472
7490
  if (!a) {
7473
7491
  yield failedTask(at.CHECK_TS_VERSION);
7474
7492
  throw errorMessage(`A version of ${code("typescript")} was not found in your dependencies.\n` + hint(`Is ${code("typescript")} installed in this package?`));
7475
- } else if (!semverComply(a, je.typescript)) {
7493
+ } else if (!semverComply(a, Re.typescript)) {
7476
7494
  yield failedTask(at.CHECK_TS_VERSION);
7477
- throw errorMessage(`The version of ${code("typescript")} in your dependencies is out of date.\n` + hint(`${code("gql.tada")} requires at least ${bold(je.typescript)}`));
7495
+ throw errorMessage(`The version of ${code("typescript")} in your dependencies is out of date.\n` + hint(`${code("gql.tada")} requires at least ${bold(Re.typescript)}`));
7478
7496
  }
7479
7497
  yield completedTask(at.CHECK_TS_VERSION);
7480
7498
  yield runningTask(at.CHECK_DEPENDENCIES);
7481
7499
  await delay();
7482
- var l = semverComply(a, je.typescript_embed_lsp);
7500
+ var l = semverComply(a, Re.typescript_embed_lsp);
7483
7501
  if (!l) {
7484
7502
  var c = await (async t => {
7485
7503
  var r = "@0no-co/graphqlsp";
@@ -7496,9 +7514,9 @@ async function* run() {
7496
7514
  if (!c) {
7497
7515
  yield failedTask(at.CHECK_DEPENDENCIES);
7498
7516
  throw errorMessage(`A version of ${code("@0no-co/graphqlsp")} was not found in your dependencies.\n` + hint(`Is ${code("@0no-co/graphqlsp")} installed?`));
7499
- } else if (!semverComply(c, je.lsp)) {
7517
+ } else if (!semverComply(c, Re.lsp)) {
7500
7518
  yield failedTask(at.CHECK_DEPENDENCIES);
7501
- throw errorMessage(`The version of ${code("@0no-co/graphqlsp")} in your dependencies is out of date.\n` + hint(`${code("gql.tada")} requires at least ${bold(je.lsp)}`));
7519
+ throw errorMessage(`The version of ${code("@0no-co/graphqlsp")} in your dependencies is out of date.\n` + hint(`${code("gql.tada")} requires at least ${bold(Re.lsp)}`));
7502
7520
  }
7503
7521
  }
7504
7522
  var u = await (async t => {
@@ -7518,7 +7536,7 @@ async function* run() {
7518
7536
  throw errorMessage(`A version of ${code("gql.tada")} was not found in your dependencies.\n` + hint(`Is ${code("gql.tada")} installed?`));
7519
7537
  } else if (!semverComply(u, "1.0.0")) {
7520
7538
  yield failedTask(at.CHECK_DEPENDENCIES);
7521
- throw errorMessage(`The version of ${code("gql.tada")} in your dependencies is out of date.\n` + hint(`It's recommended to upgrade ${code("gql.tada")} to at least ${bold(je.lsp)}`));
7539
+ throw errorMessage(`The version of ${code("gql.tada")} in your dependencies is out of date.\n` + hint(`It's recommended to upgrade ${code("gql.tada")} to at least ${bold(Re.lsp)}`));
7522
7540
  }
7523
7541
  yield completedTask(at.CHECK_DEPENDENCIES);
7524
7542
  yield runningTask(at.CHECK_TSCONFIG);
@@ -7673,5 +7691,5 @@ var nt = Object.assign((async function _main() {
7673
7691
  await t.runExit(process.argv.slice(2));
7674
7692
  }), Fe);
7675
7693
 
7676
- export { je as M, generatePersisted as a, generateSchema as b, generateTurbo as c, scan as d, generateOutput as g, nt as m, programFactory as p, semverComply as s };
7694
+ export { Re as M, generatePersisted as a, generateSchema as b, generateTurbo as c, scan as d, generateOutput as g, nt as m, programFactory as p, semverComply as s };
7677
7695
  //# sourceMappingURL=index-chunk.mjs.map