houdini 0.17.3 → 0.17.4

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.
@@ -1,5 +1,5 @@
1
- houdini:compile: cache hit, replaying output 69787885aa876706
1
+ houdini:compile: cache hit, replaying output 24d20c3f6edd07b2
2
2
  houdini:compile:
3
- houdini:compile: > houdini@0.17.3 compile /home/runner/work/houdini/houdini/packages/houdini
3
+ houdini:compile: > houdini@0.17.4 compile /home/runner/work/houdini/houdini/packages/houdini
4
4
  houdini:compile: > scripts build
5
5
  houdini:compile:
@@ -1,5 +1,5 @@
1
- houdini:typedefs: cache hit, replaying output b9d6d27ef3474182
1
+ houdini:typedefs: cache hit, replaying output b15056a5c2c67185
2
2
  houdini:typedefs:
3
- houdini:typedefs: > houdini@0.17.3 typedefs /home/runner/work/houdini/houdini/packages/houdini
3
+ houdini:typedefs: > houdini@0.17.4 typedefs /home/runner/work/houdini/houdini/packages/houdini
4
4
  houdini:typedefs: > scripts typedefs
5
5
  houdini:typedefs:
package/CHANGELOG.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # houdini
2
2
 
3
- ## 0.17.3
3
+ ## 0.17.4
4
4
 
5
- ## 0.17.2
5
+ ### 🐛 Fixes
6
+
7
+ - [#649](https://github.com/HoudiniGraphql/houdini/pull/649) [`13e6ea8`](https://github.com/HoudiniGraphql/houdini/commit/13e6ea87c23d1a3f99ce1a0c1054ebcec30ce83f) Thanks [@jycouet](https://github.com/jycouet)! - Update init cmd to accomodate new kit template
6
8
 
7
9
  ## 0.17.1
8
10
 
9
- ### Patch Changes
11
+ ### 🐛 Fixes
10
12
 
11
13
  - [#630](https://github.com/HoudiniGraphql/houdini/pull/630) [`02d8fc4`](https://github.com/HoudiniGraphql/houdini/commit/02d8fc47f71980bd2b6492162b8e57808447bdbc) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - Add shebang to executable
12
14
 
@@ -72403,8 +72403,12 @@ async function loadSchemaFile(schemaPath) {
72403
72403
  )
72404
72404
  });
72405
72405
  }
72406
- if (!stat(schemaPath)) {
72407
- throw new Error(`Schema file does not exist! Create it using houdini generate -p`);
72406
+ try {
72407
+ await stat(schemaPath);
72408
+ } catch {
72409
+ throw new HoudiniError({
72410
+ message: `Schema file does not exist! Create it using houdini pull-schema`
72411
+ });
72408
72412
  }
72409
72413
  const contents = await readFile(schemaPath);
72410
72414
  if (schemaPath.endsWith("gql") || schemaPath.endsWith("graphql")) {
@@ -72419,6 +72423,7 @@ async function loadSchemaFile(schemaPath) {
72419
72423
  var pendingConfigPromise = null;
72420
72424
  async function getConfig({
72421
72425
  configPath = DEFAULT_CONFIG_PATH,
72426
+ noSchema,
72422
72427
  ...extraConfig
72423
72428
  } = {}) {
72424
72429
  if (_config) {
@@ -72435,7 +72440,7 @@ async function getConfig({
72435
72440
  resolve2 = res;
72436
72441
  reject = rej;
72437
72442
  });
72438
- const configFile = await readConfigFile(configPath);
72443
+ let configFile = await readConfigFile(configPath);
72439
72444
  if (!configFile.plugins) {
72440
72445
  throw new HoudiniError({
72441
72446
  message: "Welcome to 0.17.0! Please following the migration guide here: http://www.houdinigraphql.com/guides/release-notes#0170"
@@ -72460,7 +72465,7 @@ This will prevent your schema from being pulled.`
72460
72465
  schemaOk = await pullSchema(_config.apiUrl, _config.schemaPath);
72461
72466
  }
72462
72467
  }
72463
- if (schemaOk) {
72468
+ if (schemaOk && !noSchema) {
72464
72469
  _config.schema = await loadSchemaFile(_config.schemaPath);
72465
72470
  }
72466
72471
  }
@@ -72632,6 +72637,10 @@ async function parseJS(str) {
72632
72637
  end: str.length
72633
72638
  };
72634
72639
  }
72640
+ function parseJSON(str) {
72641
+ str = str.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m2, g) => g ? "" : m2);
72642
+ return JSON.parse(str);
72643
+ }
72635
72644
 
72636
72645
  // src/lib/imports.ts
72637
72646
  var recast = __toESM(require_main2(), 1);
@@ -76945,7 +76954,6 @@ async function collectDocuments(config2) {
76945
76954
  }
76946
76955
  }
76947
76956
  } catch (err) {
76948
- console.log(err);
76949
76957
  throw new HoudiniError({ ...err, filepath });
76950
76958
  }
76951
76959
  })
@@ -77060,7 +77068,7 @@ function logStyled(kind, stat3, logLevel, plugin) {
77060
77068
 
77061
77069
  // src/cmd/pullSchema.ts
77062
77070
  async function pullSchema_default(args) {
77063
- const config2 = await getConfig();
77071
+ const config2 = await getConfig({ noSchema: true });
77064
77072
  if (!config2.apiUrl) {
77065
77073
  console.log(
77066
77074
  "\u274C Your project does not have a remote endpoint configured. Please provide one with the `apiUrl` value in your houdini.config.js file."
@@ -77101,15 +77109,11 @@ async function generate(args = {
77101
77109
  if (args.log) {
77102
77110
  extraConfig.logLevel = args.log;
77103
77111
  }
77104
- config2 = await getConfig(extraConfig);
77105
- if (args.output) {
77106
- config2.persistedQueryPath = args.output;
77107
- }
77108
- if (args.persistOutput) {
77109
- console.log("\u26A0\uFE0F --persist-output has been replaced by --output (abbreviated -o)");
77110
- config2.persistedQueryPath = args.persistOutput;
77111
- }
77112
77112
  try {
77113
+ config2 = await getConfig(extraConfig);
77114
+ if (args.output) {
77115
+ config2.persistedQueryPath = args.output;
77116
+ }
77113
77117
  if (args.pullSchema && config2.apiUrl) {
77114
77118
  if (args.pullHeader) {
77115
77119
  console.log("\u26A0\uFE0F --pull-headers has been replaced by --headers (abbreviated -h)");
@@ -77119,8 +77123,7 @@ async function generate(args = {
77119
77123
  }
77120
77124
  await compile(config2);
77121
77125
  } catch (e2) {
77122
- const errors = Array.isArray(e2) ? e2 : [e2];
77123
- formatErrors(errors, function(error) {
77126
+ formatErrors(e2, function(error) {
77124
77127
  if (args.verbose && "stack" in error && error.stack) {
77125
77128
  console.error(error.stack.split("\n").slice(1).join("\n"));
77126
77129
  }
@@ -77264,7 +77267,7 @@ async function fetchQuery({
77264
77267
  variables = {},
77265
77268
  metadata
77266
77269
  }${typescript ? ": RequestHandlerArgs" : ""}) {
77267
- const url = import.meta.env.VITE_GRAPHQL_ENDPOINT || '${url}';
77270
+ const url = '${url}';
77268
77271
  const result = await fetch(url, {
77269
77272
  method: 'POST',
77270
77273
  headers: {
@@ -77333,9 +77336,9 @@ async function tjsConfig(targetPath, framework) {
77333
77336
  }
77334
77337
  }
77335
77338
  try {
77336
- const tjsConfigFile = await fs_exports.readFile(configFile);
77339
+ let tjsConfigFile = await fs_exports.readFile(configFile);
77337
77340
  if (tjsConfigFile) {
77338
- var tjsConfig2 = JSON.parse(tjsConfigFile);
77341
+ var tjsConfig2 = parseJSON(tjsConfigFile);
77339
77342
  }
77340
77343
  if (framework === "kit") {
77341
77344
  tjsConfig2.compilerOptions.rootDirs = [".", "./.svelte-kit/types", "./$houdini/types"];
@@ -77535,8 +77538,8 @@ async function updatePackageJSON(targetPath) {
77535
77538
  }
77536
77539
  packageJSON.devDependencies = {
77537
77540
  ...packageJSON.devDependencies,
77538
- houdini: "^0.17.3",
77539
- "houdini-svelte": "^0.17.3",
77541
+ houdini: "^0.17.4",
77542
+ "houdini-svelte": "^0.17.4",
77540
77543
  graphql: "^15.5.0"
77541
77544
  };
77542
77545
  await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
@@ -77644,6 +77647,12 @@ program2.command("pull-schema").usage("[options]").description("pull the latest
77644
77647
  "headers to use when pulling your schema. Should be passed as KEY=VALUE"
77645
77648
  ).action(pullSchema_default);
77646
77649
  program2.parse();
77650
+ process.on("unhandledRejection", (error) => {
77651
+ if ("description" in error) {
77652
+ } else {
77653
+ console.log(error);
77654
+ }
77655
+ });
77647
77656
  /*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
77648
77657
  /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
77649
77658
  /*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
@@ -72408,8 +72408,12 @@ async function loadSchemaFile(schemaPath) {
72408
72408
  )
72409
72409
  });
72410
72410
  }
72411
- if (!stat(schemaPath)) {
72412
- throw new Error(`Schema file does not exist! Create it using houdini generate -p`);
72411
+ try {
72412
+ await stat(schemaPath);
72413
+ } catch {
72414
+ throw new HoudiniError({
72415
+ message: `Schema file does not exist! Create it using houdini pull-schema`
72416
+ });
72413
72417
  }
72414
72418
  const contents = await readFile(schemaPath);
72415
72419
  if (schemaPath.endsWith("gql") || schemaPath.endsWith("graphql")) {
@@ -72424,6 +72428,7 @@ async function loadSchemaFile(schemaPath) {
72424
72428
  var pendingConfigPromise = null;
72425
72429
  async function getConfig({
72426
72430
  configPath = DEFAULT_CONFIG_PATH,
72431
+ noSchema,
72427
72432
  ...extraConfig
72428
72433
  } = {}) {
72429
72434
  if (_config) {
@@ -72440,7 +72445,7 @@ async function getConfig({
72440
72445
  resolve2 = res;
72441
72446
  reject = rej;
72442
72447
  });
72443
- const configFile = await readConfigFile(configPath);
72448
+ let configFile = await readConfigFile(configPath);
72444
72449
  if (!configFile.plugins) {
72445
72450
  throw new HoudiniError({
72446
72451
  message: "Welcome to 0.17.0! Please following the migration guide here: http://www.houdinigraphql.com/guides/release-notes#0170"
@@ -72465,7 +72470,7 @@ This will prevent your schema from being pulled.`
72465
72470
  schemaOk = await pullSchema(_config.apiUrl, _config.schemaPath);
72466
72471
  }
72467
72472
  }
72468
- if (schemaOk) {
72473
+ if (schemaOk && !noSchema) {
72469
72474
  _config.schema = await loadSchemaFile(_config.schemaPath);
72470
72475
  }
72471
72476
  }
@@ -72637,6 +72642,10 @@ async function parseJS(str) {
72637
72642
  end: str.length
72638
72643
  };
72639
72644
  }
72645
+ function parseJSON(str) {
72646
+ str = str.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m2, g) => g ? "" : m2);
72647
+ return JSON.parse(str);
72648
+ }
72640
72649
 
72641
72650
  // src/lib/imports.ts
72642
72651
  var recast = __toESM(require_main2(), 1);
@@ -76950,7 +76959,6 @@ async function collectDocuments(config2) {
76950
76959
  }
76951
76960
  }
76952
76961
  } catch (err) {
76953
- console.log(err);
76954
76962
  throw new HoudiniError({ ...err, filepath });
76955
76963
  }
76956
76964
  })
@@ -77065,7 +77073,7 @@ function logStyled(kind, stat3, logLevel, plugin) {
77065
77073
 
77066
77074
  // src/cmd/pullSchema.ts
77067
77075
  async function pullSchema_default(args) {
77068
- const config2 = await getConfig();
77076
+ const config2 = await getConfig({ noSchema: true });
77069
77077
  if (!config2.apiUrl) {
77070
77078
  console.log(
77071
77079
  "\u274C Your project does not have a remote endpoint configured. Please provide one with the `apiUrl` value in your houdini.config.js file."
@@ -77106,15 +77114,11 @@ async function generate(args = {
77106
77114
  if (args.log) {
77107
77115
  extraConfig.logLevel = args.log;
77108
77116
  }
77109
- config2 = await getConfig(extraConfig);
77110
- if (args.output) {
77111
- config2.persistedQueryPath = args.output;
77112
- }
77113
- if (args.persistOutput) {
77114
- console.log("\u26A0\uFE0F --persist-output has been replaced by --output (abbreviated -o)");
77115
- config2.persistedQueryPath = args.persistOutput;
77116
- }
77117
77117
  try {
77118
+ config2 = await getConfig(extraConfig);
77119
+ if (args.output) {
77120
+ config2.persistedQueryPath = args.output;
77121
+ }
77118
77122
  if (args.pullSchema && config2.apiUrl) {
77119
77123
  if (args.pullHeader) {
77120
77124
  console.log("\u26A0\uFE0F --pull-headers has been replaced by --headers (abbreviated -h)");
@@ -77124,8 +77128,7 @@ async function generate(args = {
77124
77128
  }
77125
77129
  await compile(config2);
77126
77130
  } catch (e2) {
77127
- const errors = Array.isArray(e2) ? e2 : [e2];
77128
- formatErrors(errors, function(error) {
77131
+ formatErrors(e2, function(error) {
77129
77132
  if (args.verbose && "stack" in error && error.stack) {
77130
77133
  console.error(error.stack.split("\n").slice(1).join("\n"));
77131
77134
  }
@@ -77269,7 +77272,7 @@ async function fetchQuery({
77269
77272
  variables = {},
77270
77273
  metadata
77271
77274
  }${typescript ? ": RequestHandlerArgs" : ""}) {
77272
- const url = import.meta.env.VITE_GRAPHQL_ENDPOINT || '${url}';
77275
+ const url = '${url}';
77273
77276
  const result = await fetch(url, {
77274
77277
  method: 'POST',
77275
77278
  headers: {
@@ -77338,9 +77341,9 @@ async function tjsConfig(targetPath, framework) {
77338
77341
  }
77339
77342
  }
77340
77343
  try {
77341
- const tjsConfigFile = await fs_exports.readFile(configFile);
77344
+ let tjsConfigFile = await fs_exports.readFile(configFile);
77342
77345
  if (tjsConfigFile) {
77343
- var tjsConfig2 = JSON.parse(tjsConfigFile);
77346
+ var tjsConfig2 = parseJSON(tjsConfigFile);
77344
77347
  }
77345
77348
  if (framework === "kit") {
77346
77349
  tjsConfig2.compilerOptions.rootDirs = [".", "./.svelte-kit/types", "./$houdini/types"];
@@ -77540,8 +77543,8 @@ async function updatePackageJSON(targetPath) {
77540
77543
  }
77541
77544
  packageJSON.devDependencies = {
77542
77545
  ...packageJSON.devDependencies,
77543
- houdini: "^0.17.3",
77544
- "houdini-svelte": "^0.17.3",
77546
+ houdini: "^0.17.4",
77547
+ "houdini-svelte": "^0.17.4",
77545
77548
  graphql: "^15.5.0"
77546
77549
  };
77547
77550
  await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
@@ -77649,6 +77652,12 @@ program2.command("pull-schema").usage("[options]").description("pull the latest
77649
77652
  "headers to use when pulling your schema. Should be passed as KEY=VALUE"
77650
77653
  ).action(pullSchema_default);
77651
77654
  program2.parse();
77655
+ process.on("unhandledRejection", (error) => {
77656
+ if ("description" in error) {
77657
+ } else {
77658
+ console.log(error);
77659
+ }
77660
+ });
77652
77661
  /*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
77653
77662
  /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
77654
77663
  /*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
@@ -60848,7 +60848,6 @@ async function collectDocuments(config2) {
60848
60848
  }
60849
60849
  }
60850
60850
  } catch (err) {
60851
- console.log(err);
60852
60851
  throw new HoudiniError({ ...err, filepath });
60853
60852
  }
60854
60853
  })
@@ -60846,7 +60846,6 @@ async function collectDocuments(config2) {
60846
60846
  }
60847
60847
  }
60848
60848
  } catch (err) {
60849
- console.log(err);
60850
60849
  throw new HoudiniError({ ...err, filepath });
60851
60850
  }
60852
60851
  })
@@ -117,7 +117,9 @@ export declare class Config {
117
117
  variableFunctionName(name: string): string;
118
118
  }
119
119
  export declare function readConfigFile(configPath?: string): Promise<ConfigFile>;
120
- export declare function getConfig({ configPath, ...extraConfig }?: PluginConfig): Promise<Config>;
120
+ export declare function getConfig({ configPath, noSchema, ...extraConfig }?: PluginConfig & {
121
+ noSchema?: boolean;
122
+ }): Promise<Config>;
121
123
  export declare enum LogLevel {
122
124
  Full = "full",
123
125
  Summary = "summary",
@@ -5,3 +5,4 @@ export declare type ParsedFile = Maybe<{
5
5
  end: number;
6
6
  }>;
7
7
  export declare function parseJS(str: string): Promise<ParsedFile>;
8
+ export declare function parseJSON(str: string): any;
@@ -58905,6 +58905,7 @@ __export(lib_exports, {
58905
58905
  operation_requires_variables: () => operation_requires_variables,
58906
58906
  parentTypeFromAncestors: () => parentTypeFromAncestors,
58907
58907
  parseJS: () => parseJS,
58908
+ parseJSON: () => parseJSON,
58908
58909
  path: () => path_exports,
58909
58910
  pullSchema: () => pullSchema,
58910
58911
  readConfigFile: () => readConfigFile,
@@ -65676,8 +65677,12 @@ async function loadSchemaFile(schemaPath) {
65676
65677
  )
65677
65678
  });
65678
65679
  }
65679
- if (!stat(schemaPath)) {
65680
- throw new Error(`Schema file does not exist! Create it using houdini generate -p`);
65680
+ try {
65681
+ await stat(schemaPath);
65682
+ } catch {
65683
+ throw new HoudiniError({
65684
+ message: `Schema file does not exist! Create it using houdini pull-schema`
65685
+ });
65681
65686
  }
65682
65687
  const contents = await readFile(schemaPath);
65683
65688
  if (schemaPath.endsWith("gql") || schemaPath.endsWith("graphql")) {
@@ -65692,6 +65697,7 @@ async function loadSchemaFile(schemaPath) {
65692
65697
  var pendingConfigPromise = null;
65693
65698
  async function getConfig({
65694
65699
  configPath = DEFAULT_CONFIG_PATH,
65700
+ noSchema,
65695
65701
  ...extraConfig
65696
65702
  } = {}) {
65697
65703
  if (_config) {
@@ -65708,7 +65714,7 @@ async function getConfig({
65708
65714
  resolve2 = res;
65709
65715
  reject = rej;
65710
65716
  });
65711
- const configFile = await readConfigFile(configPath);
65717
+ let configFile = await readConfigFile(configPath);
65712
65718
  if (!configFile.plugins) {
65713
65719
  throw new HoudiniError({
65714
65720
  message: "Welcome to 0.17.0! Please following the migration guide here: http://www.houdinigraphql.com/guides/release-notes#0170"
@@ -65733,7 +65739,7 @@ This will prevent your schema from being pulled.`
65733
65739
  schemaOk = await pullSchema(_config.apiUrl, _config.schemaPath);
65734
65740
  }
65735
65741
  }
65736
- if (schemaOk) {
65742
+ if (schemaOk && !noSchema) {
65737
65743
  _config.schema = await loadSchemaFile(_config.schemaPath);
65738
65744
  }
65739
65745
  }
@@ -65912,6 +65918,10 @@ async function parseJS(str) {
65912
65918
  end: str.length
65913
65919
  };
65914
65920
  }
65921
+ function parseJSON(str) {
65922
+ str = str.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m2, g) => g ? "" : m2);
65923
+ return JSON.parse(str);
65924
+ }
65915
65925
 
65916
65926
  // src/lib/imports.ts
65917
65927
  var recast = __toESM(require_main2(), 1);
@@ -66167,6 +66177,7 @@ async function find_graphql(config, parsedScript, walker) {
66167
66177
  operation_requires_variables,
66168
66178
  parentTypeFromAncestors,
66169
66179
  parseJS,
66180
+ parseJSON,
66170
66181
  path,
66171
66182
  pullSchema,
66172
66183
  readConfigFile,
@@ -65639,8 +65639,12 @@ async function loadSchemaFile(schemaPath) {
65639
65639
  )
65640
65640
  });
65641
65641
  }
65642
- if (!stat(schemaPath)) {
65643
- throw new Error(`Schema file does not exist! Create it using houdini generate -p`);
65642
+ try {
65643
+ await stat(schemaPath);
65644
+ } catch {
65645
+ throw new HoudiniError({
65646
+ message: `Schema file does not exist! Create it using houdini pull-schema`
65647
+ });
65644
65648
  }
65645
65649
  const contents = await readFile(schemaPath);
65646
65650
  if (schemaPath.endsWith("gql") || schemaPath.endsWith("graphql")) {
@@ -65655,6 +65659,7 @@ async function loadSchemaFile(schemaPath) {
65655
65659
  var pendingConfigPromise = null;
65656
65660
  async function getConfig({
65657
65661
  configPath = DEFAULT_CONFIG_PATH,
65662
+ noSchema,
65658
65663
  ...extraConfig
65659
65664
  } = {}) {
65660
65665
  if (_config) {
@@ -65671,7 +65676,7 @@ async function getConfig({
65671
65676
  resolve2 = res;
65672
65677
  reject = rej;
65673
65678
  });
65674
- const configFile = await readConfigFile(configPath);
65679
+ let configFile = await readConfigFile(configPath);
65675
65680
  if (!configFile.plugins) {
65676
65681
  throw new HoudiniError({
65677
65682
  message: "Welcome to 0.17.0! Please following the migration guide here: http://www.houdinigraphql.com/guides/release-notes#0170"
@@ -65696,7 +65701,7 @@ This will prevent your schema from being pulled.`
65696
65701
  schemaOk = await pullSchema(_config.apiUrl, _config.schemaPath);
65697
65702
  }
65698
65703
  }
65699
- if (schemaOk) {
65704
+ if (schemaOk && !noSchema) {
65700
65705
  _config.schema = await loadSchemaFile(_config.schemaPath);
65701
65706
  }
65702
65707
  }
@@ -65875,6 +65880,10 @@ async function parseJS(str) {
65875
65880
  end: str.length
65876
65881
  };
65877
65882
  }
65883
+ function parseJSON(str) {
65884
+ str = str.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m2, g) => g ? "" : m2);
65885
+ return JSON.parse(str);
65886
+ }
65878
65887
 
65879
65888
  // src/lib/imports.ts
65880
65889
  var recast = __toESM(require_main2(), 1);
@@ -66129,6 +66138,7 @@ export {
66129
66138
  operation_requires_variables,
66130
66139
  parentTypeFromAncestors,
66131
66140
  parseJS,
66141
+ parseJSON,
66132
66142
  path_exports as path,
66133
66143
  pullSchema,
66134
66144
  readConfigFile,
@@ -68556,8 +68556,12 @@ async function loadSchemaFile(schemaPath) {
68556
68556
  )
68557
68557
  });
68558
68558
  }
68559
- if (!stat(schemaPath)) {
68560
- throw new Error(`Schema file does not exist! Create it using houdini generate -p`);
68559
+ try {
68560
+ await stat(schemaPath);
68561
+ } catch {
68562
+ throw new HoudiniError({
68563
+ message: `Schema file does not exist! Create it using houdini pull-schema`
68564
+ });
68561
68565
  }
68562
68566
  const contents = await readFile(schemaPath);
68563
68567
  if (schemaPath.endsWith("gql") || schemaPath.endsWith("graphql")) {
@@ -68572,6 +68576,7 @@ async function loadSchemaFile(schemaPath) {
68572
68576
  var pendingConfigPromise = null;
68573
68577
  async function getConfig({
68574
68578
  configPath = DEFAULT_CONFIG_PATH,
68579
+ noSchema,
68575
68580
  ...extraConfig
68576
68581
  } = {}) {
68577
68582
  if (_config) {
@@ -68588,7 +68593,7 @@ async function getConfig({
68588
68593
  resolve2 = res;
68589
68594
  reject = rej;
68590
68595
  });
68591
- const configFile = await readConfigFile(configPath);
68596
+ let configFile = await readConfigFile(configPath);
68592
68597
  if (!configFile.plugins) {
68593
68598
  throw new HoudiniError({
68594
68599
  message: "Welcome to 0.17.0! Please following the migration guide here: http://www.houdinigraphql.com/guides/release-notes#0170"
@@ -68613,7 +68618,7 @@ This will prevent your schema from being pulled.`
68613
68618
  schemaOk = await pullSchema(_config.apiUrl, _config.schemaPath);
68614
68619
  }
68615
68620
  }
68616
- if (schemaOk) {
68621
+ if (schemaOk && !noSchema) {
68617
68622
  _config.schema = await loadSchemaFile(_config.schemaPath);
68618
68623
  }
68619
68624
  }
@@ -73058,7 +73063,6 @@ async function collectDocuments(config3) {
73058
73063
  }
73059
73064
  }
73060
73065
  } catch (err) {
73061
- console.log(err);
73062
73066
  throw new HoudiniError({ ...err, filepath });
73063
73067
  }
73064
73068
  })
@@ -68550,8 +68550,12 @@ async function loadSchemaFile(schemaPath) {
68550
68550
  )
68551
68551
  });
68552
68552
  }
68553
- if (!stat(schemaPath)) {
68554
- throw new Error(`Schema file does not exist! Create it using houdini generate -p`);
68553
+ try {
68554
+ await stat(schemaPath);
68555
+ } catch {
68556
+ throw new HoudiniError({
68557
+ message: `Schema file does not exist! Create it using houdini pull-schema`
68558
+ });
68555
68559
  }
68556
68560
  const contents = await readFile(schemaPath);
68557
68561
  if (schemaPath.endsWith("gql") || schemaPath.endsWith("graphql")) {
@@ -68566,6 +68570,7 @@ async function loadSchemaFile(schemaPath) {
68566
68570
  var pendingConfigPromise = null;
68567
68571
  async function getConfig({
68568
68572
  configPath = DEFAULT_CONFIG_PATH,
68573
+ noSchema,
68569
68574
  ...extraConfig
68570
68575
  } = {}) {
68571
68576
  if (_config) {
@@ -68582,7 +68587,7 @@ async function getConfig({
68582
68587
  resolve2 = res;
68583
68588
  reject = rej;
68584
68589
  });
68585
- const configFile = await readConfigFile(configPath);
68590
+ let configFile = await readConfigFile(configPath);
68586
68591
  if (!configFile.plugins) {
68587
68592
  throw new HoudiniError({
68588
68593
  message: "Welcome to 0.17.0! Please following the migration guide here: http://www.houdinigraphql.com/guides/release-notes#0170"
@@ -68607,7 +68612,7 @@ This will prevent your schema from being pulled.`
68607
68612
  schemaOk = await pullSchema(_config.apiUrl, _config.schemaPath);
68608
68613
  }
68609
68614
  }
68610
- if (schemaOk) {
68615
+ if (schemaOk && !noSchema) {
68611
68616
  _config.schema = await loadSchemaFile(_config.schemaPath);
68612
68617
  }
68613
68618
  }
@@ -73052,7 +73057,6 @@ async function collectDocuments(config3) {
73052
73057
  }
73053
73058
  }
73054
73059
  } catch (err) {
73055
- console.log(err);
73056
73060
  throw new HoudiniError({ ...err, filepath });
73057
73061
  }
73058
73062
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "0.17.3",
3
+ "version": "0.17.4",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "type": "module",
6
6
  "devDependencies": {
@@ -26,18 +26,12 @@ export async function generate(
26
26
  extraConfig.logLevel = args.log
27
27
  }
28
28
 
29
- // load config
30
- config = await getConfig(extraConfig)
31
- if (args.output) {
32
- config.persistedQueryPath = args.output
33
- }
34
- // backwards compat
35
- if (args.persistOutput) {
36
- console.log('⚠️ --persist-output has been replaced by --output (abbreviated -o)')
37
- config.persistedQueryPath = args.persistOutput
38
- }
39
-
40
29
  try {
30
+ // load config
31
+ config = await getConfig(extraConfig)
32
+ if (args.output) {
33
+ config.persistedQueryPath = args.output
34
+ }
41
35
  // Pull the newest schema if the flag is set
42
36
  if (args.pullSchema && config.apiUrl) {
43
37
  // backwards compat
@@ -51,10 +45,7 @@ export async function generate(
51
45
 
52
46
  await codegen(config)
53
47
  } catch (e) {
54
- // we need an array of errors to loop through
55
- const errors = (Array.isArray(e) ? e : [e]) as Error[]
56
-
57
- formatErrors(errors, function (error) {
48
+ formatErrors(e, function (error) {
58
49
  if (args.verbose && 'stack' in error && error.stack) {
59
50
  console.error(error.stack.split('\n').slice(1).join('\n'))
60
51
  }
package/src/cmd/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Command } from 'commander'
2
2
 
3
- import { LogLevel } from '../lib'
3
+ import { LogLevel, HoudiniError } from '../lib'
4
4
  import { generate } from './generate'
5
5
  import init from './init'
6
6
  import pullSchema from './pullSchema'
@@ -50,3 +50,11 @@ program
50
50
 
51
51
  // start the command
52
52
  program.parse()
53
+
54
+ // silence unhandled houdini errors
55
+ process.on('unhandledRejection', (error: HoudiniError) => {
56
+ if ('description' in error) {
57
+ } else {
58
+ console.log(error)
59
+ }
60
+ })
package/src/cmd/init.ts CHANGED
@@ -2,7 +2,7 @@ import { getIntrospectionQuery } from 'graphql'
2
2
  import fetch from 'node-fetch'
3
3
  import prompts from 'prompts'
4
4
 
5
- import { fs, path, pullSchema } from '../lib'
5
+ import { fs, parseJSON, path, pullSchema } from '../lib'
6
6
  import { ConfigFile } from '../runtime/lib/config'
7
7
 
8
8
  // the init command is responsible for scaffolding a few files
@@ -194,7 +194,7 @@ async function fetchQuery({
194
194
  variables = {},
195
195
  metadata
196
196
  }${typescript ? ': RequestHandlerArgs' : ''}) {
197
- const url = import.meta.env.VITE_GRAPHQL_ENDPOINT || '${url}';
197
+ const url = '${url}';
198
198
  const result = await fetch(url, {
199
199
  method: 'POST',
200
200
  headers: {
@@ -291,9 +291,9 @@ async function tjsConfig(targetPath: string, framework: 'kit' | 'svelte') {
291
291
 
292
292
  // check if the tsconfig.json file exists
293
293
  try {
294
- const tjsConfigFile = await fs.readFile(configFile)
294
+ let tjsConfigFile = await fs.readFile(configFile)
295
295
  if (tjsConfigFile) {
296
- var tjsConfig = JSON.parse(tjsConfigFile)
296
+ var tjsConfig = parseJSON(tjsConfigFile)
297
297
  }
298
298
 
299
299
  // new rootDirs (will overwrite the one in "extends": "./.svelte-kit/tsconfig.json")
@@ -1,7 +1,7 @@
1
1
  import { getConfig, pullSchema, path } from '../lib'
2
2
 
3
3
  export default async function (args: { headers: string[] }) {
4
- const config = await getConfig()
4
+ const config = await getConfig({ noSchema: true })
5
5
 
6
6
  // Check if apiUrl is set in config
7
7
  if (!config.apiUrl) {
@@ -233,7 +233,6 @@ async function collectDocuments(config: Config): Promise<CollectedGraphQLDocumen
233
233
  }
234
234
  }
235
235
  } catch (err) {
236
- console.log(err)
237
236
  throw new HoudiniError({ ...(err as HoudiniError), filepath })
238
237
  }
239
238
  })
package/src/lib/config.ts CHANGED
@@ -724,8 +724,12 @@ async function loadSchemaFile(schemaPath: string): Promise<graphql.GraphQLSchema
724
724
  }
725
725
 
726
726
  // the path has no glob magic, make sure its a real file
727
- if (!fs.stat(schemaPath)) {
728
- throw new Error(`Schema file does not exist! Create it using houdini generate -p`)
727
+ try {
728
+ await fs.stat(schemaPath)
729
+ } catch {
730
+ throw new HoudiniError({
731
+ message: `Schema file does not exist! Create it using houdini pull-schema`,
732
+ })
729
733
  }
730
734
 
731
735
  const contents = (await fs.readFile(schemaPath))!
@@ -750,8 +754,9 @@ let pendingConfigPromise: Promise<Config> | null = null
750
754
  // get the project's current configuration
751
755
  export async function getConfig({
752
756
  configPath = DEFAULT_CONFIG_PATH,
757
+ noSchema,
753
758
  ...extraConfig
754
- }: PluginConfig = {}): Promise<Config> {
759
+ }: PluginConfig & { noSchema?: boolean } = {}): Promise<Config> {
755
760
  if (_config) {
756
761
  return _config
757
762
  }
@@ -770,7 +775,7 @@ export async function getConfig({
770
775
  })
771
776
 
772
777
  // look up the current config file
773
- const configFile = await readConfigFile(configPath)
778
+ let configFile = await readConfigFile(configPath)
774
779
 
775
780
  // if there is a framework specified, tell them they need to change things
776
781
  if (!configFile.plugins) {
@@ -807,7 +812,7 @@ This will prevent your schema from being pulled.`
807
812
  }
808
813
 
809
814
  // the schema is safe to load
810
- if (schemaOk) {
815
+ if (schemaOk && !noSchema) {
811
816
  _config.schema = await loadSchemaFile(_config.schemaPath)
812
817
  }
813
818
  }
@@ -0,0 +1,75 @@
1
+ import { test, expect, describe } from 'vitest'
2
+
3
+ import { parseJSON } from './parse'
4
+
5
+ describe('parse', function () {
6
+ test('parseJSON without comments', async function () {
7
+ const original_file = `{
8
+ "extends": "./.svelte-kit/tsconfig.json",
9
+ "compilerOptions": {
10
+ "allowJs": true,
11
+ "checkJs": true,
12
+ "esModuleInterop": true,
13
+ "forceConsistentCasingInFileNames": true,
14
+ "resolveJsonModule": true,
15
+ "skipLibCheck": true,
16
+ "sourceMap": true,
17
+ "strict": true,
18
+ "noImplicitAny": true
19
+ }
20
+ }
21
+ `
22
+
23
+ const parsed = parseJSON(original_file)
24
+ expect(parsed).toMatchObject({
25
+ extends: './.svelte-kit/tsconfig.json',
26
+ compilerOptions: {
27
+ allowJs: true,
28
+ checkJs: true,
29
+ esModuleInterop: true,
30
+ forceConsistentCasingInFileNames: true,
31
+ resolveJsonModule: true,
32
+ skipLibCheck: true,
33
+ sourceMap: true,
34
+ strict: true,
35
+ noImplicitAny: true,
36
+ },
37
+ })
38
+ })
39
+
40
+ test('parseJSON with comments', async function () {
41
+ const original_file = `{
42
+ "extends": "./.svelte-kit/tsconfig.json",
43
+ "compilerOptions": {
44
+ "allowJs": true,
45
+ // this is a comment
46
+ "checkJs": true,
47
+ "esModuleInterop": true,
48
+ "forceConsistentCasingInFileNames": true,
49
+ "resolveJsonModule": true,
50
+ "skipLibCheck": true,
51
+ "sourceMap": true,
52
+ "strict": true,
53
+ "noImplicitAny": true
54
+ }
55
+ // this is another comment
56
+ }
57
+ `
58
+
59
+ const parsed = parseJSON(original_file)
60
+ expect(parsed).toMatchObject({
61
+ extends: './.svelte-kit/tsconfig.json',
62
+ compilerOptions: {
63
+ allowJs: true,
64
+ checkJs: true,
65
+ esModuleInterop: true,
66
+ forceConsistentCasingInFileNames: true,
67
+ resolveJsonModule: true,
68
+ skipLibCheck: true,
69
+ sourceMap: true,
70
+ strict: true,
71
+ noImplicitAny: true,
72
+ },
73
+ })
74
+ })
75
+ })
package/src/lib/parse.ts CHANGED
@@ -15,3 +15,9 @@ export async function parseJS(str: string): Promise<ParsedFile> {
15
15
  end: str.length,
16
16
  }
17
17
  }
18
+
19
+ export function parseJSON(str: string): any {
20
+ // remove all comments to be able to parse the file, and add stuff to it.
21
+ str = str.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => (g ? '' : m))
22
+ return JSON.parse(str)
23
+ }