@gql.tada/cli-utils 1.7.0 → 1.7.1-canary-e193732bfa456bacf50b007ae7a2ca1396f62733

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @gql.tada/cli-utils
2
2
 
3
+ ## 1.7.1-canary-e193732bfa456bacf50b007ae7a2ca1396f62733
4
+
5
+ ### Patch Changes
6
+
7
+ - ⚠️ Fix external scalars in the `graphql` definition files,
8
+ we will collect the imports and rewrite them into the
9
+ cached file
10
+ Submitted by [@JoviDeCroock](https://github.com/JoviDeCroock) (See [#472](https://github.com/0no-co/gql.tada/pull/472))
11
+
3
12
  ## 1.7.0
4
13
 
5
14
  ### Minor Changes
@@ -3811,118 +3811,141 @@ async function* run$3(e, r) {
3811
3811
  } catch (e) {
3812
3812
  throw externalError("Failed to load configuration.", e);
3813
3813
  }
3814
- var s = i({
3814
+ var s = O.dirname(n.configPath);
3815
+ var l;
3816
+ if ("schema" in a) {
3817
+ if (!r.output && e.pipeTo) {
3818
+ l = e.pipeTo;
3819
+ } else if (r.output) {
3820
+ l = O.resolve(process.cwd(), r.output);
3821
+ } else if (a.tadaTurboLocation) {
3822
+ l = O.resolve(s, a.tadaTurboLocation);
3823
+ } else if (a.tadaOutputLocation) {
3824
+ l = O.resolve(s, a.tadaOutputLocation, "..", "graphql-cache.d.ts");
3825
+ yield function hintMessage$1(e) {
3826
+ return error([ cmd(De.Style, [ he.Yellow, he.Bold ]), `${ye.Warning} Note: `, cmd(De.Style, he.Reset), `${e.trim()}\n\n` ]);
3827
+ }(`No output location was specified.\nThe turbo cache will by default be saved as ${code('"graphql-cache.d.ts"')}.\n` + hint(`To change this, add a ${code('"tadaTurboLocation"')} in your configuration,\npass an ${code("--output")} argument to this command,\nor pipe this command to an output file.`));
3828
+ } else {
3829
+ throw errorMessage$1("No output path was specified to write the output file to.\n" + hint(`You have to either set ${code('"tadaTurboLocation"')} in your configuration,\npass an ${code("--output")} argument to this command,\nor pipe this command to an output file.`));
3830
+ }
3831
+ }
3832
+ var c = i({
3815
3833
  rootPath: n.rootPath,
3816
3834
  configPath: n.configPath,
3817
- pluginConfig: a
3835
+ pluginConfig: a,
3836
+ turboOutputPath: "string" == typeof l ? l : void 0
3818
3837
  });
3819
- var l = [];
3820
- var c = 0;
3821
- var D = 0;
3822
- var d = 0;
3838
+ var D = [];
3839
+ var d = [];
3840
+ var f = 0;
3841
+ var p = 0;
3842
+ var h = 0;
3823
3843
  try {
3824
3844
  if (e.isInteractive) {
3825
3845
  yield runningTurbo();
3826
3846
  }
3827
- for await (var f of s) {
3828
- if ("EXTERNAL_WARNING" === f.kind) {
3847
+ for await (var g of c) {
3848
+ if ("EXTERNAL_WARNING" === g.kind) {
3829
3849
  yield experimentMessage(`${code(".vue")} and ${code(".svelte")} file support is experimental.`);
3830
- } else if ("FILE_COUNT" === f.kind) {
3831
- D = f.fileCount;
3850
+ } else if ("FILE_COUNT" === g.kind) {
3851
+ p = g.fileCount;
3852
+ } else if ("GRAPHQL_SOURCES" === g.kind) {
3853
+ d = g.sources;
3832
3854
  } else {
3833
- d++;
3834
- l.push(...f.documents);
3835
- c += f.warnings.length;
3836
- if (f.warnings.length) {
3837
- var p = warningFile(f.filePath);
3838
- for (var h of f.warnings) {
3839
- p += (g = h, text([ ke, cmd(De.Style, he.BrightBlack), `${g.line}:${g.col}`, me.Tab, cmd(De.Style, he.Foreground), indent(g.message.trim(), text([ ke, me.Tab ])), me.Newline ]));
3840
- warningGithub(h);
3855
+ h++;
3856
+ D.push(...g.documents);
3857
+ f += g.warnings.length;
3858
+ if (g.warnings.length) {
3859
+ var m = warningFile(g.filePath);
3860
+ for (var E of g.warnings) {
3861
+ m += (w = E, text([ ke, cmd(De.Style, he.BrightBlack), `${w.line}:${w.col}`, me.Tab, cmd(De.Style, he.Foreground), indent(w.message.trim(), text([ ke, me.Tab ])), me.Newline ]));
3862
+ warningGithub(E);
3841
3863
  }
3842
- yield p + "\n";
3864
+ yield m + "\n";
3843
3865
  }
3844
3866
  }
3845
3867
  if (e.isInteractive) {
3846
- yield runningTurbo(d, D);
3868
+ yield runningTurbo(h, p);
3847
3869
  }
3848
3870
  }
3849
3871
  } catch (e) {
3850
3872
  throw externalError("Could not build cache", e);
3851
3873
  }
3852
- var g;
3853
- var m = O.dirname(n.configPath);
3874
+ var w;
3854
3875
  if ("schema" in a) {
3855
- var E;
3856
- if (!r.output && e.pipeTo) {
3857
- E = e.pipeTo;
3858
- } else if (r.output) {
3859
- E = O.resolve(process.cwd(), r.output);
3860
- } else if (a.tadaTurboLocation) {
3861
- E = O.resolve(m, a.tadaTurboLocation);
3862
- } else if (a.tadaOutputLocation) {
3863
- E = O.resolve(m, a.tadaOutputLocation, "..", "graphql-cache.d.ts");
3864
- yield function hintMessage$1(e) {
3865
- return error([ cmd(De.Style, [ he.Yellow, he.Bold ]), `${ye.Warning} Note: `, cmd(De.Style, he.Reset), `${e.trim()}\n\n` ]);
3866
- }(`No output location was specified.\nThe turbo cache will by default be saved as ${code('"graphql-cache.d.ts"')}.\n` + hint(`To change this, add a ${code('"tadaTurboLocation"')} in your configuration,\npass an ${code("--output")} argument to this command,\nor pipe this command to an output file.`));
3867
- } else {
3868
- throw errorMessage$1("No output path was specified to write the output file to.\n" + hint(`You have to either set ${code('"tadaTurboLocation"')} in your configuration,\npass an ${code("--output")} argument to this command,\nor pipe this command to an output file.`));
3869
- }
3870
- if (c && r.failOnWarn) {
3871
- throw warningSummary(c);
3876
+ if (f && r.failOnWarn) {
3877
+ throw warningSummary(f);
3872
3878
  }
3873
3879
  try {
3874
- var w = {};
3875
- for (var S of l) {
3876
- w[S.argumentKey] = S.documentType;
3880
+ var S = {};
3881
+ for (var b of D) {
3882
+ S[b.argumentKey] = b.documentType;
3877
3883
  }
3878
- var b = createCacheContents(w);
3879
- await writeOutput(E, b);
3884
+ var B = createCacheContents(S, d, l);
3885
+ await writeOutput(l, B);
3880
3886
  } catch (e) {
3881
3887
  throw externalError("Something went wrong while writing the type cache file", e);
3882
3888
  }
3883
- yield infoSummary$1(c, l.length);
3889
+ yield infoSummary$1(f, D.length);
3884
3890
  } else {
3885
3891
  if (r.output) {
3886
3892
  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.`));
3887
3893
  }
3888
- var B = {};
3889
- for (var k of a.schemas) {
3890
- var {name: I, tadaTurboLocation: M} = k;
3891
- if (!M) {
3892
- throw errorMessage$1(`No output path was specified to write the '${I}' type cache to.\n` + hint(`You have to set ${code('"tadaTurboLocation"')} in each schema configuration.`));
3894
+ var k = {};
3895
+ for (var I of a.schemas) {
3896
+ var {name: M, tadaTurboLocation: _} = I;
3897
+ if (!_) {
3898
+ throw errorMessage$1(`No output path was specified to write the '${M}' type cache to.\n` + hint(`You have to set ${code('"tadaTurboLocation"')} in each schema configuration.`));
3893
3899
  }
3894
3900
  try {
3895
- B[I] = 0;
3896
- var _ = {};
3897
- for (var U of l) {
3898
- if (U.schemaName === I) {
3899
- _[U.argumentKey] = U.documentType;
3900
- B[I]++;
3901
+ k[M] = 0;
3902
+ var U = {};
3903
+ for (var G of D) {
3904
+ if (G.schemaName === M) {
3905
+ U[G.argumentKey] = G.documentType;
3906
+ k[M]++;
3901
3907
  }
3902
3908
  }
3903
- var G = createCacheContents(_);
3904
- await writeOutput(O.resolve(m, M), G);
3909
+ var H = O.resolve(s, _);
3910
+ var V = createCacheContents(U, d, H);
3911
+ await writeOutput(H, V);
3905
3912
  } catch (e) {
3906
- throw externalError(`Something went wrong while writing the '${I}' schema's type cache file.`, e);
3913
+ throw externalError(`Something went wrong while writing the '${M}' schema's type cache file.`, e);
3907
3914
  }
3908
3915
  }
3909
- if (c && r.failOnWarn) {
3910
- throw warningSummary(c);
3916
+ if (f && r.failOnWarn) {
3917
+ throw warningSummary(f);
3911
3918
  } else {
3912
- yield infoSummary$1(c, B);
3919
+ yield infoSummary$1(f, k);
3913
3920
  }
3914
3921
  }
3915
3922
  }
3916
3923
 
3917
- function createCacheContents(e) {
3918
- var t = "";
3919
- for (var r in e) {
3920
- if (t) {
3921
- t += "\n";
3924
+ function createCacheContents(e, t, r) {
3925
+ var i = "";
3926
+ for (var n in e) {
3927
+ if (i) {
3928
+ i += "\n";
3929
+ }
3930
+ i += ` ${n}:\n ${e[n]};`;
3931
+ }
3932
+ var a = "import type { TadaDocumentNode, $tada } from 'gql.tada';\n";
3933
+ var s = "string" == typeof r || r && "object" == typeof r && "toString" in r && !("writable" in r);
3934
+ var l = new Set;
3935
+ for (var c of t) {
3936
+ for (var D of c.imports) {
3937
+ if (s) {
3938
+ var d = r.toString();
3939
+ var f = O.dirname(c.absolutePath);
3940
+ if (O.resolve(f, D.specifier) === O.resolve(d) || l.has(D.specifier)) {
3941
+ continue;
3942
+ }
3943
+ l.add(D.specifier);
3944
+ }
3945
+ a += D.importClause + "\n";
3922
3946
  }
3923
- t += ` ${r}:\n ${e[r]};`;
3924
3947
  }
3925
- return Te + "import type { TadaDocumentNode, $tada } from 'gql.tada';\n\ndeclare module 'gql.tada' {\n interface setupCache {\n" + t + "\n }\n}\n";
3948
+ return Te + a + "\ndeclare module 'gql.tada' {\n interface setupCache {\n" + i + "\n }\n}\n";
3926
3949
  }
3927
3950
 
3928
3951
  class TurboCommand extends Command {
@@ -5280,6 +5303,29 @@ var programFactory = e => {
5280
5303
  }
5281
5304
  return d;
5282
5305
  },
5306
+ resolveModuleName(e, t, r) {
5307
+ if (!e.startsWith(".")) {
5308
+ return e;
5309
+ }
5310
+ var i = s.resolveModuleName(e, t, c, D.compilerHost);
5311
+ if (i.resolvedModule) {
5312
+ var n = i.resolvedModule.resolvedFileName;
5313
+ var a = O.dirname(r);
5314
+ var l = O.relative(a, n);
5315
+ if (!l.startsWith(".")) {
5316
+ l = "./" + l;
5317
+ }
5318
+ return l.replace(/\\/g, "/");
5319
+ }
5320
+ var d = O.dirname(t);
5321
+ var f = O.dirname(r);
5322
+ var p = O.resolve(d, e);
5323
+ var h = O.relative(f, p);
5324
+ if (!h.startsWith(".")) {
5325
+ h = "./" + h;
5326
+ }
5327
+ return h.replace(/\\/g, "/");
5328
+ },
5283
5329
  build() {
5284
5330
  (() => {
5285
5331
  if ("stackTraceLimit" in Error && Error.stackTraceLimit < 25) {