houdini 0.17.5 → 0.17.7
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/.turbo/turbo-compile.log +2 -2
- package/.turbo/turbo-typedefs.log +2 -2
- package/CHANGELOG.md +14 -0
- package/build/cmd/init.d.ts +2 -2
- package/build/cmd-cjs/index.js +222 -188
- package/build/cmd-esm/index.js +222 -188
- package/build/codegen-cjs/index.js +84 -31
- package/build/codegen-esm/index.js +84 -31
- package/build/lib/constants.d.ts +7 -0
- package/build/lib/fs.d.ts +2 -0
- package/build/lib-cjs/index.js +87 -32
- package/build/lib-esm/index.js +86 -32
- package/build/runtime/cache/subscription.d.ts +2 -1
- package/build/runtime/lib/network.d.ts +4 -2
- package/build/runtime-cjs/cache/cache.js +5 -3
- package/build/runtime-cjs/cache/subscription.d.ts +2 -1
- package/build/runtime-cjs/cache/subscription.js +6 -4
- package/build/runtime-cjs/cache/tests/subscriptions.test.js +101 -0
- package/build/runtime-cjs/lib/network.d.ts +4 -2
- package/build/runtime-cjs/lib/network.js +8 -4
- package/build/runtime-esm/cache/cache.js +5 -3
- package/build/runtime-esm/cache/subscription.d.ts +2 -1
- package/build/runtime-esm/cache/subscription.js +6 -4
- package/build/runtime-esm/cache/tests/subscriptions.test.js +101 -0
- package/build/runtime-esm/lib/network.d.ts +4 -2
- package/build/runtime-esm/lib/network.js +8 -4
- package/build/test-cjs/index.js +86 -33
- package/build/test-esm/index.js +86 -33
- package/build/vite-cjs/index.js +86 -33
- package/build/vite-esm/index.js +86 -33
- package/package.json +1 -1
- package/src/cmd/init.ts +169 -187
- package/src/codegen/generators/runtime/index.ts +2 -2
- package/src/lib/config.ts +3 -2
- package/src/lib/constants.ts +10 -0
- package/src/lib/fs.ts +59 -12
- package/src/runtime/cache/cache.ts +3 -1
- package/src/runtime/cache/subscription.ts +6 -4
- package/src/runtime/cache/tests/subscriptions.test.ts +115 -0
- package/src/runtime/lib/network.ts +11 -5
package/build/cmd-cjs/index.js
CHANGED
|
@@ -17831,8 +17831,8 @@ var require_graceful_fs = __commonJS({
|
|
|
17831
17831
|
}
|
|
17832
17832
|
var fs$copyFile = fs4.copyFile;
|
|
17833
17833
|
if (fs$copyFile)
|
|
17834
|
-
fs4.copyFile =
|
|
17835
|
-
function
|
|
17834
|
+
fs4.copyFile = copyFile2;
|
|
17835
|
+
function copyFile2(src, dest, flags, cb) {
|
|
17836
17836
|
if (typeof flags === "function") {
|
|
17837
17837
|
cb = flags;
|
|
17838
17838
|
flags = 0;
|
|
@@ -18505,7 +18505,7 @@ var require_copy = __commonJS({
|
|
|
18505
18505
|
}
|
|
18506
18506
|
function onFile(srcStat, destStat, src, dest, opts, cb) {
|
|
18507
18507
|
if (!destStat)
|
|
18508
|
-
return
|
|
18508
|
+
return copyFile2(srcStat, src, dest, opts, cb);
|
|
18509
18509
|
return mayCopyFile(srcStat, src, dest, opts, cb);
|
|
18510
18510
|
}
|
|
18511
18511
|
function mayCopyFile(srcStat, src, dest, opts, cb) {
|
|
@@ -18513,14 +18513,14 @@ var require_copy = __commonJS({
|
|
|
18513
18513
|
fs3.unlink(dest, (err) => {
|
|
18514
18514
|
if (err)
|
|
18515
18515
|
return cb(err);
|
|
18516
|
-
return
|
|
18516
|
+
return copyFile2(srcStat, src, dest, opts, cb);
|
|
18517
18517
|
});
|
|
18518
18518
|
} else if (opts.errorOnExist) {
|
|
18519
18519
|
return cb(new Error(`'${dest}' already exists`));
|
|
18520
18520
|
} else
|
|
18521
18521
|
return cb();
|
|
18522
18522
|
}
|
|
18523
|
-
function
|
|
18523
|
+
function copyFile2(srcStat, src, dest, opts, cb) {
|
|
18524
18524
|
fs3.copyFile(src, dest, (err) => {
|
|
18525
18525
|
if (err)
|
|
18526
18526
|
return cb(err);
|
|
@@ -18703,18 +18703,18 @@ var require_copy_sync = __commonJS({
|
|
|
18703
18703
|
}
|
|
18704
18704
|
function onFile(srcStat, destStat, src, dest, opts) {
|
|
18705
18705
|
if (!destStat)
|
|
18706
|
-
return
|
|
18706
|
+
return copyFile2(srcStat, src, dest, opts);
|
|
18707
18707
|
return mayCopyFile(srcStat, src, dest, opts);
|
|
18708
18708
|
}
|
|
18709
18709
|
function mayCopyFile(srcStat, src, dest, opts) {
|
|
18710
18710
|
if (opts.overwrite) {
|
|
18711
18711
|
fs3.unlinkSync(dest);
|
|
18712
|
-
return
|
|
18712
|
+
return copyFile2(srcStat, src, dest, opts);
|
|
18713
18713
|
} else if (opts.errorOnExist) {
|
|
18714
18714
|
throw new Error(`'${dest}' already exists`);
|
|
18715
18715
|
}
|
|
18716
18716
|
}
|
|
18717
|
-
function
|
|
18717
|
+
function copyFile2(srcStat, src, dest, opts) {
|
|
18718
18718
|
fs3.copyFileSync(src, dest);
|
|
18719
18719
|
if (opts.preserveTimestamps)
|
|
18720
18720
|
handleTimestamps(srcStat.mode, src, dest);
|
|
@@ -68623,10 +68623,11 @@ var InMemorySubscriptions = class {
|
|
|
68623
68623
|
parent,
|
|
68624
68624
|
selection: selection2,
|
|
68625
68625
|
variables,
|
|
68626
|
-
subscribers
|
|
68626
|
+
subscribers,
|
|
68627
|
+
parentType
|
|
68627
68628
|
}) {
|
|
68628
68629
|
for (const fieldSelection of Object.values(selection2)) {
|
|
68629
|
-
const { keyRaw, fields } = fieldSelection;
|
|
68630
|
+
const { type: linkedType, keyRaw, fields } = fieldSelection;
|
|
68630
68631
|
const key = evaluateKey(keyRaw, variables);
|
|
68631
68632
|
for (const spec of subscribers) {
|
|
68632
68633
|
this.addFieldSubscription({
|
|
@@ -68634,7 +68635,7 @@ var InMemorySubscriptions = class {
|
|
|
68634
68635
|
key,
|
|
68635
68636
|
selection: fieldSelection,
|
|
68636
68637
|
spec,
|
|
68637
|
-
parentType
|
|
68638
|
+
parentType,
|
|
68638
68639
|
variables
|
|
68639
68640
|
});
|
|
68640
68641
|
}
|
|
@@ -68649,7 +68650,8 @@ var InMemorySubscriptions = class {
|
|
|
68649
68650
|
parent: linkedRecord,
|
|
68650
68651
|
selection: fields,
|
|
68651
68652
|
variables,
|
|
68652
|
-
subscribers
|
|
68653
|
+
subscribers,
|
|
68654
|
+
parentType: linkedType
|
|
68653
68655
|
});
|
|
68654
68656
|
}
|
|
68655
68657
|
}
|
|
@@ -68829,7 +68831,7 @@ var CacheInternal = class {
|
|
|
68829
68831
|
this.cache = cache;
|
|
68830
68832
|
this.lifetimes = lifetimes;
|
|
68831
68833
|
try {
|
|
68832
|
-
this._disabled = process.env.
|
|
68834
|
+
this._disabled = process.env.HOUDINI_TEST !== "true";
|
|
68833
68835
|
} catch {
|
|
68834
68836
|
this._disabled = typeof globalThis.window === "undefined";
|
|
68835
68837
|
}
|
|
@@ -68927,7 +68929,8 @@ var CacheInternal = class {
|
|
|
68927
68929
|
parent: linkedID,
|
|
68928
68930
|
selection: fields,
|
|
68929
68931
|
subscribers: currentSubscribers,
|
|
68930
|
-
variables
|
|
68932
|
+
variables,
|
|
68933
|
+
parentType: linkedType
|
|
68931
68934
|
});
|
|
68932
68935
|
toNotify.push(...currentSubscribers);
|
|
68933
68936
|
}
|
|
@@ -69033,7 +69036,8 @@ var CacheInternal = class {
|
|
|
69033
69036
|
parent: id,
|
|
69034
69037
|
selection: fields,
|
|
69035
69038
|
subscribers: currentSubscribers,
|
|
69036
|
-
variables
|
|
69039
|
+
variables,
|
|
69040
|
+
parentType: linkedType
|
|
69037
69041
|
});
|
|
69038
69042
|
}
|
|
69039
69043
|
}
|
|
@@ -69318,6 +69322,14 @@ var CompiledMutationKind = "HoudiniMutation" /* Mutation */;
|
|
|
69318
69322
|
var CompiledQueryKind = "HoudiniQuery" /* Query */;
|
|
69319
69323
|
var CompiledSubscriptionKind = "HoudiniSubscription" /* Subscription */;
|
|
69320
69324
|
|
|
69325
|
+
// src/lib/constants.ts
|
|
69326
|
+
var siteURL = "https://houdinigraphql.com";
|
|
69327
|
+
var houdini_mode = {
|
|
69328
|
+
get is_testing() {
|
|
69329
|
+
return process.env.HOUDINI_TEST === "true";
|
|
69330
|
+
}
|
|
69331
|
+
};
|
|
69332
|
+
|
|
69321
69333
|
// src/lib/error.ts
|
|
69322
69334
|
var HoudiniError = class extends Error {
|
|
69323
69335
|
filepath = null;
|
|
@@ -69341,6 +69353,8 @@ var HoudiniError = class extends Error {
|
|
|
69341
69353
|
var fs_exports = {};
|
|
69342
69354
|
__export(fs_exports, {
|
|
69343
69355
|
access: () => access,
|
|
69356
|
+
copyFile: () => copyFile,
|
|
69357
|
+
copyFileSync: () => copyFileSync,
|
|
69344
69358
|
existsSync: () => existsSync,
|
|
69345
69359
|
glob: () => glob,
|
|
69346
69360
|
mkdir: () => mkdir,
|
|
@@ -69410,8 +69424,50 @@ function importPath(target) {
|
|
|
69410
69424
|
}
|
|
69411
69425
|
|
|
69412
69426
|
// src/lib/fs.ts
|
|
69427
|
+
function copyFileSync(src, dest) {
|
|
69428
|
+
if (houdini_mode.is_testing) {
|
|
69429
|
+
try {
|
|
69430
|
+
if (src.includes("build/runtime") || dest.includes("build/runtime")) {
|
|
69431
|
+
import_fs_extra.default.copyFileSync(src, dest);
|
|
69432
|
+
return;
|
|
69433
|
+
}
|
|
69434
|
+
import_memfs.fs.copyFileSync(src, dest);
|
|
69435
|
+
return;
|
|
69436
|
+
} catch (e2) {
|
|
69437
|
+
return null;
|
|
69438
|
+
}
|
|
69439
|
+
}
|
|
69440
|
+
try {
|
|
69441
|
+
import_fs_extra.default.copyFileSync(src, dest);
|
|
69442
|
+
return;
|
|
69443
|
+
} catch (e2) {
|
|
69444
|
+
}
|
|
69445
|
+
return null;
|
|
69446
|
+
}
|
|
69447
|
+
async function copyFile(src, dest) {
|
|
69448
|
+
if (houdini_mode.is_testing) {
|
|
69449
|
+
try {
|
|
69450
|
+
if (src.includes("build/runtime") || dest.includes("build/runtime")) {
|
|
69451
|
+
await import_promises.default.copyFile(src, dest);
|
|
69452
|
+
return;
|
|
69453
|
+
}
|
|
69454
|
+
await import_memfs.fs.copyFile(src, dest, (err) => {
|
|
69455
|
+
throw err;
|
|
69456
|
+
});
|
|
69457
|
+
return;
|
|
69458
|
+
} catch (e2) {
|
|
69459
|
+
return null;
|
|
69460
|
+
}
|
|
69461
|
+
}
|
|
69462
|
+
try {
|
|
69463
|
+
await import_promises.default.copyFile(src, dest);
|
|
69464
|
+
return;
|
|
69465
|
+
} catch (e2) {
|
|
69466
|
+
}
|
|
69467
|
+
return null;
|
|
69468
|
+
}
|
|
69413
69469
|
async function readFile(filepath) {
|
|
69414
|
-
if (
|
|
69470
|
+
if (houdini_mode.is_testing) {
|
|
69415
69471
|
try {
|
|
69416
69472
|
if (filepath.includes("build/runtime")) {
|
|
69417
69473
|
return await import_promises.default.readFile(filepath, "utf-8");
|
|
@@ -69428,7 +69484,7 @@ async function readFile(filepath) {
|
|
|
69428
69484
|
return null;
|
|
69429
69485
|
}
|
|
69430
69486
|
function readFileSync(filepath) {
|
|
69431
|
-
if (
|
|
69487
|
+
if (houdini_mode.is_testing) {
|
|
69432
69488
|
try {
|
|
69433
69489
|
if (filepath.includes("build/runtime")) {
|
|
69434
69490
|
return import_fs_extra.default.readFileSync(filepath, "utf-8");
|
|
@@ -69449,13 +69505,13 @@ async function writeFile(filepath, data) {
|
|
|
69449
69505
|
if (data === existingFileData) {
|
|
69450
69506
|
return;
|
|
69451
69507
|
}
|
|
69452
|
-
if (
|
|
69508
|
+
if (houdini_mode.is_testing) {
|
|
69453
69509
|
return import_memfs.fs.writeFileSync(filepath, data);
|
|
69454
69510
|
}
|
|
69455
69511
|
return await import_promises.default.writeFile(filepath, data, "utf8");
|
|
69456
69512
|
}
|
|
69457
69513
|
async function access(filepath) {
|
|
69458
|
-
if (
|
|
69514
|
+
if (!houdini_mode.is_testing) {
|
|
69459
69515
|
return await import_promises.default.access(filepath);
|
|
69460
69516
|
}
|
|
69461
69517
|
if (filepath.includes("build/runtime")) {
|
|
@@ -69464,25 +69520,25 @@ async function access(filepath) {
|
|
|
69464
69520
|
return import_memfs.fs.statSync(filepath);
|
|
69465
69521
|
}
|
|
69466
69522
|
async function mkdirp(filepath) {
|
|
69467
|
-
if (
|
|
69523
|
+
if (!houdini_mode.is_testing) {
|
|
69468
69524
|
return await import_fs_extra.default.mkdirp(filepath);
|
|
69469
69525
|
}
|
|
69470
69526
|
return import_memfs.fs.mkdirpSync(filepath);
|
|
69471
69527
|
}
|
|
69472
69528
|
async function mkdirpSync(filepath) {
|
|
69473
|
-
if (
|
|
69529
|
+
if (!houdini_mode.is_testing) {
|
|
69474
69530
|
return import_fs_extra.default.mkdirpSync(filepath);
|
|
69475
69531
|
}
|
|
69476
69532
|
return import_memfs.fs.mkdirpSync(filepath);
|
|
69477
69533
|
}
|
|
69478
69534
|
async function mkdir(filepath) {
|
|
69479
|
-
if (
|
|
69535
|
+
if (!houdini_mode.is_testing) {
|
|
69480
69536
|
return await import_promises.default.mkdir(filepath);
|
|
69481
69537
|
}
|
|
69482
69538
|
return import_memfs.fs.mkdirSync(filepath);
|
|
69483
69539
|
}
|
|
69484
69540
|
async function rmdir(filepath) {
|
|
69485
|
-
if (
|
|
69541
|
+
if (!houdini_mode.is_testing) {
|
|
69486
69542
|
return await import_promises.default.rm(filepath, {
|
|
69487
69543
|
recursive: true
|
|
69488
69544
|
});
|
|
@@ -69490,7 +69546,7 @@ async function rmdir(filepath) {
|
|
|
69490
69546
|
return await (0, import_util.promisify)(import_memfs.fs.rmdir)(filepath);
|
|
69491
69547
|
}
|
|
69492
69548
|
async function stat(filepath) {
|
|
69493
|
-
if (
|
|
69549
|
+
if (!houdini_mode.is_testing) {
|
|
69494
69550
|
return await import_promises.default.stat(filepath);
|
|
69495
69551
|
}
|
|
69496
69552
|
if (filepath.includes("build/runtime")) {
|
|
@@ -69499,13 +69555,13 @@ async function stat(filepath) {
|
|
|
69499
69555
|
return import_memfs.fs.statSync(filepath);
|
|
69500
69556
|
}
|
|
69501
69557
|
function existsSync(dirPath) {
|
|
69502
|
-
if (
|
|
69558
|
+
if (!houdini_mode.is_testing) {
|
|
69503
69559
|
return import_fs_extra.default.existsSync(dirPath);
|
|
69504
69560
|
}
|
|
69505
69561
|
return import_memfs.fs.existsSync(dirPath);
|
|
69506
69562
|
}
|
|
69507
69563
|
async function readdir(filepath) {
|
|
69508
|
-
if (
|
|
69564
|
+
if (!houdini_mode.is_testing) {
|
|
69509
69565
|
return await import_promises.default.readdir(filepath);
|
|
69510
69566
|
}
|
|
69511
69567
|
if (filepath.includes("build/runtime")) {
|
|
@@ -69518,7 +69574,7 @@ async function readdir(filepath) {
|
|
|
69518
69574
|
}
|
|
69519
69575
|
}
|
|
69520
69576
|
async function remove(filepath) {
|
|
69521
|
-
if (
|
|
69577
|
+
if (!houdini_mode.is_testing) {
|
|
69522
69578
|
return await import_promises.default.rm(filepath);
|
|
69523
69579
|
}
|
|
69524
69580
|
return import_memfs.vol.rmSync(filepath);
|
|
@@ -70992,7 +71048,7 @@ var Config = class {
|
|
|
70992
71048
|
return locationFound;
|
|
70993
71049
|
}
|
|
70994
71050
|
get runtimeSource() {
|
|
70995
|
-
const relative2 =
|
|
71051
|
+
const relative2 = houdini_mode.is_testing ? join2(currentDir, "..", "..") : this.findModule();
|
|
70996
71052
|
const which = this.module === "esm" ? "esm" : "cjs";
|
|
70997
71053
|
return resolve(relative2, "build", `runtime-${which}`);
|
|
70998
71054
|
}
|
|
@@ -71070,7 +71126,7 @@ var Config = class {
|
|
|
71070
71126
|
return join2(this.pluginDirectory(name2), "runtime");
|
|
71071
71127
|
}
|
|
71072
71128
|
pluginDirectory(name2) {
|
|
71073
|
-
return
|
|
71129
|
+
return houdini_mode.is_testing ? resolve("../../../", name2) : join2(this.rootDir, "plugins", name2);
|
|
71074
71130
|
}
|
|
71075
71131
|
get houdiniDirective() {
|
|
71076
71132
|
return "houdini";
|
|
@@ -71536,9 +71592,6 @@ function ensureImports({
|
|
|
71536
71592
|
return Array.isArray(importID) ? toImport : toImport[0];
|
|
71537
71593
|
}
|
|
71538
71594
|
|
|
71539
|
-
// src/lib/constants.ts
|
|
71540
|
-
var siteURL = "https://houdinigraphql.com";
|
|
71541
|
-
|
|
71542
71595
|
// src/lib/cleanupFiles.ts
|
|
71543
71596
|
async function cleanupFiles(pathFolder, listOfObj) {
|
|
71544
71597
|
const listFile = await readdir(pathFolder);
|
|
@@ -73589,7 +73642,7 @@ async function runtimeGenerator(config2) {
|
|
|
73589
73642
|
]);
|
|
73590
73643
|
}
|
|
73591
73644
|
async function generatePluginRuntime(config2, plugin) {
|
|
73592
|
-
if (
|
|
73645
|
+
if (houdini_mode.is_testing) {
|
|
73593
73646
|
return;
|
|
73594
73647
|
}
|
|
73595
73648
|
const source = path_exports.join(
|
|
@@ -75995,9 +76048,11 @@ async function generate(args = {
|
|
|
75995
76048
|
}
|
|
75996
76049
|
|
|
75997
76050
|
// src/cmd/init.ts
|
|
76051
|
+
var import_child_process = require("child_process");
|
|
75998
76052
|
var import_graphql31 = __toESM(require_graphql2(), 1);
|
|
75999
76053
|
var import_prompts = __toESM(require_prompts3(), 1);
|
|
76000
|
-
async function init(_path, args
|
|
76054
|
+
async function init(_path, args) {
|
|
76055
|
+
const force_remote_endpoint = args.force_remote_endpoint || false;
|
|
76001
76056
|
try {
|
|
76002
76057
|
await fs_exports.stat(path_exports.resolve("./src"));
|
|
76003
76058
|
} catch {
|
|
@@ -76016,25 +76071,39 @@ async function init(_path, args, withRunningCheck = true) {
|
|
|
76016
76071
|
}, {});
|
|
76017
76072
|
}
|
|
76018
76073
|
const targetPath = _path ? path_exports.resolve(_path) : process.cwd();
|
|
76019
|
-
|
|
76020
|
-
|
|
76021
|
-
|
|
76022
|
-
|
|
76023
|
-
|
|
76024
|
-
|
|
76025
|
-
|
|
76026
|
-
|
|
76027
|
-
|
|
76028
|
-
|
|
76029
|
-
|
|
76030
|
-
|
|
76074
|
+
if (!force_remote_endpoint) {
|
|
76075
|
+
let use_git = false;
|
|
76076
|
+
let dir = targetPath;
|
|
76077
|
+
do {
|
|
76078
|
+
if (fs_exports.existsSync(path_exports.join(dir, ".git"))) {
|
|
76079
|
+
use_git = true;
|
|
76080
|
+
break;
|
|
76081
|
+
}
|
|
76082
|
+
} while (dir !== (dir = path_exports.dirname(dir)));
|
|
76083
|
+
if (use_git) {
|
|
76084
|
+
const status = (0, import_child_process.execSync)("git status --porcelain", { stdio: "pipe" }).toString();
|
|
76085
|
+
if (status) {
|
|
76086
|
+
const message = "Your git working directory is dirty \u2014 we recommend committing your changes before running this migration.\n";
|
|
76087
|
+
console.error(message);
|
|
76088
|
+
const { confirm } = await (0, import_prompts.default)({
|
|
76089
|
+
message: "Continue anyway?",
|
|
76090
|
+
name: "confirm",
|
|
76091
|
+
type: "confirm",
|
|
76092
|
+
initial: false
|
|
76093
|
+
});
|
|
76094
|
+
if (!confirm) {
|
|
76095
|
+
process.exit(1);
|
|
76096
|
+
}
|
|
76097
|
+
}
|
|
76098
|
+
}
|
|
76031
76099
|
}
|
|
76032
|
-
let
|
|
76100
|
+
let url = "http://localhost:5173/api/graphql";
|
|
76101
|
+
const { is_remote_endpoint } = force_remote_endpoint ? { is_remote_endpoint: true } : await (0, import_prompts.default)(
|
|
76033
76102
|
{
|
|
76034
|
-
message: "
|
|
76035
|
-
name: "
|
|
76036
|
-
type: "
|
|
76037
|
-
initial:
|
|
76103
|
+
message: "Will you use a remote GraphQL API?",
|
|
76104
|
+
name: "is_remote_endpoint",
|
|
76105
|
+
type: "confirm",
|
|
76106
|
+
initial: true
|
|
76038
76107
|
},
|
|
76039
76108
|
{
|
|
76040
76109
|
onCancel() {
|
|
@@ -76042,29 +76111,61 @@ async function init(_path, args, withRunningCheck = true) {
|
|
|
76042
76111
|
}
|
|
76043
76112
|
}
|
|
76044
76113
|
);
|
|
76045
|
-
|
|
76046
|
-
|
|
76047
|
-
|
|
76048
|
-
|
|
76049
|
-
|
|
76050
|
-
|
|
76114
|
+
let schemaPath = is_remote_endpoint ? "./schema.graphql" : "path/to/src/lib/**/*.graphql";
|
|
76115
|
+
if (is_remote_endpoint) {
|
|
76116
|
+
const { url_remote } = await (0, import_prompts.default)(
|
|
76117
|
+
{
|
|
76118
|
+
message: "What's the URL for your api?",
|
|
76119
|
+
name: "url_remote",
|
|
76120
|
+
type: "text",
|
|
76121
|
+
initial: "http://localhost:4000/graphql"
|
|
76051
76122
|
},
|
|
76052
|
-
|
|
76053
|
-
|
|
76054
|
-
|
|
76055
|
-
|
|
76056
|
-
|
|
76057
|
-
|
|
76058
|
-
|
|
76123
|
+
{
|
|
76124
|
+
onCancel() {
|
|
76125
|
+
process.exit(1);
|
|
76126
|
+
}
|
|
76127
|
+
}
|
|
76128
|
+
);
|
|
76129
|
+
url = url_remote;
|
|
76130
|
+
try {
|
|
76131
|
+
const response = await fetch(url, {
|
|
76132
|
+
method: "POST",
|
|
76133
|
+
headers: {
|
|
76134
|
+
"Content-Type": "application/json",
|
|
76135
|
+
...headers
|
|
76136
|
+
},
|
|
76137
|
+
body: JSON.stringify({
|
|
76138
|
+
query: (0, import_graphql31.getIntrospectionQuery)()
|
|
76139
|
+
})
|
|
76140
|
+
});
|
|
76141
|
+
if (response.status !== 200) {
|
|
76142
|
+
console.log("\u274C That URL is not accepting GraphQL queries. Please try again.");
|
|
76143
|
+
return await init(_path, { ...args, force_remote_endpoint: true });
|
|
76144
|
+
}
|
|
76145
|
+
await response.json();
|
|
76146
|
+
} catch (e2) {
|
|
76147
|
+
console.log("\u274C Something went wrong: " + e2.message);
|
|
76148
|
+
return await init(_path, { ...args, force_remote_endpoint: true });
|
|
76059
76149
|
}
|
|
76060
|
-
|
|
76061
|
-
|
|
76062
|
-
|
|
76063
|
-
|
|
76150
|
+
} else {
|
|
76151
|
+
const answers = await (0, import_prompts.default)(
|
|
76152
|
+
{
|
|
76153
|
+
message: "Where is your schema located?",
|
|
76154
|
+
name: "schema_path",
|
|
76155
|
+
type: "text",
|
|
76156
|
+
initial: schemaPath
|
|
76157
|
+
},
|
|
76158
|
+
{
|
|
76159
|
+
onCancel() {
|
|
76160
|
+
process.exit(1);
|
|
76161
|
+
}
|
|
76162
|
+
}
|
|
76163
|
+
);
|
|
76164
|
+
schemaPath = answers.schema_path;
|
|
76064
76165
|
}
|
|
76065
|
-
const { framework, typescript, module: module2 } = await detectTools(targetPath);
|
|
76166
|
+
const { framework, typescript, module: module2, package_manager } = await detectTools(targetPath);
|
|
76066
76167
|
console.log();
|
|
76067
|
-
console.log("\u{1F50E}
|
|
76168
|
+
console.log("\u{1F50E} Here's what we found:");
|
|
76068
76169
|
if (framework === "kit") {
|
|
76069
76170
|
console.log("\u2728 SvelteKit");
|
|
76070
76171
|
} else {
|
|
@@ -76087,21 +76188,20 @@ async function init(_path, args, withRunningCheck = true) {
|
|
|
76087
76188
|
);
|
|
76088
76189
|
process.exit(1);
|
|
76089
76190
|
}
|
|
76090
|
-
const schemaPath = "./schema.graphql";
|
|
76091
76191
|
const sourceDir = path_exports.join(targetPath, "src");
|
|
76092
76192
|
const configPath = path_exports.join(targetPath, "houdini.config.js");
|
|
76093
76193
|
const houdiniClientPath = typescript ? path_exports.join(sourceDir, "client.ts") : path_exports.join(sourceDir, "client.js");
|
|
76094
76194
|
const houdiniClientImport = "./src/client";
|
|
76095
76195
|
console.log("\u{1F6A7} Generating project files...");
|
|
76096
76196
|
await updatePackageJSON(targetPath);
|
|
76097
|
-
|
|
76197
|
+
if (is_remote_endpoint) {
|
|
76198
|
+
await pullSchema(url, path_exports.join(targetPath, schemaPath), headers);
|
|
76199
|
+
}
|
|
76098
76200
|
await writeConfigFile({
|
|
76099
|
-
targetPath,
|
|
76100
76201
|
configPath,
|
|
76101
76202
|
schemaPath,
|
|
76102
|
-
framework,
|
|
76103
76203
|
module: module2,
|
|
76104
|
-
url,
|
|
76204
|
+
url: is_remote_endpoint ? url : null,
|
|
76105
76205
|
houdiniClientImport
|
|
76106
76206
|
});
|
|
76107
76207
|
await fs_exports.writeFile(houdiniClientPath, networkFile(url, typescript));
|
|
@@ -76116,10 +76216,19 @@ async function init(_path, args, withRunningCheck = true) {
|
|
|
76116
76216
|
await tjsConfig(targetPath, framework);
|
|
76117
76217
|
console.log();
|
|
76118
76218
|
console.log("\u{1F3A9} Welcome to Houdini!");
|
|
76219
|
+
let cmd_install = "npm i";
|
|
76220
|
+
let cmd_run = "npm run dev";
|
|
76221
|
+
if (package_manager === "pnpm") {
|
|
76222
|
+
cmd_install = "pnpm i";
|
|
76223
|
+
cmd_run = "pnpm dev";
|
|
76224
|
+
} else if (package_manager === "yarn") {
|
|
76225
|
+
cmd_install = "yarn";
|
|
76226
|
+
cmd_run = "yarn dev";
|
|
76227
|
+
}
|
|
76119
76228
|
console.log(`
|
|
76120
76229
|
\u{1F449} Next Steps
|
|
76121
|
-
1\uFE0F\u20E3 Finalize your installation:
|
|
76122
|
-
2\uFE0F\u20E3 Start your application:
|
|
76230
|
+
1\uFE0F\u20E3 Finalize your installation: ${logGreen(cmd_install)}
|
|
76231
|
+
2\uFE0F\u20E3 Start your application: ${logGreen(cmd_run)}
|
|
76123
76232
|
`);
|
|
76124
76233
|
}
|
|
76125
76234
|
var networkFile = (url, typescript) => `import { HoudiniClient${typescript ? ", type RequestHandlerArgs" : ""} } from '$houdini';
|
|
@@ -76147,17 +76256,16 @@ async function fetchQuery({
|
|
|
76147
76256
|
export default new HoudiniClient(fetchQuery);
|
|
76148
76257
|
`;
|
|
76149
76258
|
var writeConfigFile = async ({
|
|
76150
|
-
targetPath,
|
|
76151
76259
|
configPath,
|
|
76152
76260
|
schemaPath,
|
|
76153
|
-
framework,
|
|
76154
76261
|
module: module2,
|
|
76155
76262
|
url,
|
|
76156
76263
|
houdiniClientImport
|
|
76157
76264
|
}) => {
|
|
76158
|
-
const config2 = {
|
|
76159
|
-
|
|
76160
|
-
|
|
76265
|
+
const config2 = {};
|
|
76266
|
+
if (url !== null) {
|
|
76267
|
+
config2.apiUrl = url;
|
|
76268
|
+
}
|
|
76161
76269
|
if (schemaPath !== "./schema.graphql") {
|
|
76162
76270
|
config2.schemaPath = schemaPath;
|
|
76163
76271
|
}
|
|
@@ -76170,17 +76278,18 @@ var writeConfigFile = async ({
|
|
|
76170
76278
|
}
|
|
76171
76279
|
};
|
|
76172
76280
|
const configObj = JSON.stringify(config2, null, 4);
|
|
76173
|
-
const
|
|
76174
|
-
|
|
76281
|
+
const content_base = `/// <references types="houdini-svelte">
|
|
76282
|
+
|
|
76283
|
+
/** @type {import('houdini').ConfigFile} */
|
|
76284
|
+
const config = ${configObj}`;
|
|
76285
|
+
const content = module2 === "esm" ? `${content_base}
|
|
76175
76286
|
|
|
76176
76287
|
export default config
|
|
76177
|
-
` :
|
|
76178
|
-
const config = ${configObj}
|
|
76288
|
+
` : `${content_base}}
|
|
76179
76289
|
|
|
76180
76290
|
module.exports = config
|
|
76181
76291
|
`;
|
|
76182
76292
|
await updateFile({
|
|
76183
|
-
projectPath: targetPath,
|
|
76184
76293
|
filepath: configPath,
|
|
76185
76294
|
content
|
|
76186
76295
|
});
|
|
@@ -76221,24 +76330,6 @@ async function tjsConfig(targetPath, framework) {
|
|
|
76221
76330
|
}
|
|
76222
76331
|
async function updateViteConfig(targetPath, framework, typescript) {
|
|
76223
76332
|
const viteConfigPath = path_exports.join(targetPath, `vite.config${typescript ? ".ts" : ".js"}`);
|
|
76224
|
-
const oldViteConfig1 = `import { sveltekit } from '@sveltejs/kit/vite';
|
|
76225
|
-
|
|
76226
|
-
/** @type {import('vite').UserConfig} */
|
|
76227
|
-
const config = {
|
|
76228
|
-
plugins: [sveltekit()]
|
|
76229
|
-
};
|
|
76230
|
-
|
|
76231
|
-
export default config;
|
|
76232
|
-
`;
|
|
76233
|
-
const oldViteConfig2 = `import { sveltekit } from '@sveltejs/kit/vite';
|
|
76234
|
-
import type { UserConfig } from 'vite';
|
|
76235
|
-
|
|
76236
|
-
const config: UserConfig = {
|
|
76237
|
-
plugins: [sveltekit()]
|
|
76238
|
-
};
|
|
76239
|
-
|
|
76240
|
-
export default config;
|
|
76241
|
-
`;
|
|
76242
76333
|
const viteConfigKit = `import { sveltekit } from '@sveltejs/kit/vite';
|
|
76243
76334
|
import houdini from 'houdini/vite';
|
|
76244
76335
|
|
|
@@ -76293,17 +76384,13 @@ export default config;
|
|
|
76293
76384
|
}
|
|
76294
76385
|
if (typescript) {
|
|
76295
76386
|
await updateFile({
|
|
76296
|
-
projectPath: targetPath,
|
|
76297
76387
|
filepath: viteConfigPath,
|
|
76298
|
-
content: framework === "kit" ? viteConfigKitTs : viteConfigSvelteTs
|
|
76299
|
-
old: [oldViteConfig1, oldViteConfig2]
|
|
76388
|
+
content: framework === "kit" ? viteConfigKitTs : viteConfigSvelteTs
|
|
76300
76389
|
});
|
|
76301
76390
|
} else {
|
|
76302
76391
|
await updateFile({
|
|
76303
|
-
projectPath: targetPath,
|
|
76304
76392
|
filepath: viteConfigPath,
|
|
76305
|
-
content: framework === "kit" ? viteConfigKit : viteConfigSvelte
|
|
76306
|
-
old: [oldViteConfig1, oldViteConfig2]
|
|
76393
|
+
content: framework === "kit" ? viteConfigKit : viteConfigSvelte
|
|
76307
76394
|
});
|
|
76308
76395
|
}
|
|
76309
76396
|
}
|
|
@@ -76326,40 +76413,11 @@ const config = {
|
|
|
76326
76413
|
}
|
|
76327
76414
|
};
|
|
76328
76415
|
|
|
76329
|
-
export default config;
|
|
76330
|
-
`;
|
|
76331
|
-
const oldSvelteConfig1 = `import adapter from '@sveltejs/adapter-auto';
|
|
76332
|
-
import preprocess from 'svelte-preprocess';
|
|
76333
|
-
|
|
76334
|
-
/** @type {import('@sveltejs/kit').Config} */
|
|
76335
|
-
const config = {
|
|
76336
|
-
// Consult https://github.com/sveltejs/svelte-preprocess
|
|
76337
|
-
// for more information about preprocessors
|
|
76338
|
-
preprocess: preprocess(),
|
|
76339
|
-
|
|
76340
|
-
kit: {
|
|
76341
|
-
adapter: adapter()
|
|
76342
|
-
}
|
|
76343
|
-
};
|
|
76344
|
-
|
|
76345
|
-
export default config;
|
|
76346
|
-
`;
|
|
76347
|
-
const oldSvelteConfig2 = `import adapter from '@sveltejs/adapter-auto';
|
|
76348
|
-
|
|
76349
|
-
/** @type {import('@sveltejs/kit').Config} */
|
|
76350
|
-
const config = {
|
|
76351
|
-
kit: {
|
|
76352
|
-
adapter: adapter()
|
|
76353
|
-
}
|
|
76354
|
-
};
|
|
76355
|
-
|
|
76356
76416
|
export default config;
|
|
76357
76417
|
`;
|
|
76358
76418
|
await updateFile({
|
|
76359
|
-
projectPath: targetPath,
|
|
76360
76419
|
filepath: svelteConfigPath,
|
|
76361
|
-
content: newContent
|
|
76362
|
-
old: [oldSvelteConfig1, oldSvelteConfig2]
|
|
76420
|
+
content: newContent
|
|
76363
76421
|
});
|
|
76364
76422
|
}
|
|
76365
76423
|
async function updateSvelteMainJs(targetPath) {
|
|
@@ -76367,6 +76425,7 @@ async function updateSvelteMainJs(targetPath) {
|
|
|
76367
76425
|
const newContent = `import client from "../client";
|
|
76368
76426
|
import './app.css'
|
|
76369
76427
|
import App from './App.svelte'
|
|
76428
|
+
import { logGreen } from '@kitql/helper'
|
|
76370
76429
|
|
|
76371
76430
|
client.init();
|
|
76372
76431
|
|
|
@@ -76374,22 +76433,11 @@ const app = new App({
|
|
|
76374
76433
|
target: document.getElementById('app')
|
|
76375
76434
|
})
|
|
76376
76435
|
|
|
76377
|
-
export default app
|
|
76378
|
-
`;
|
|
76379
|
-
const oldContent = `import './app.css'
|
|
76380
|
-
import App from './App.svelte'
|
|
76381
|
-
|
|
76382
|
-
const app = new App({
|
|
76383
|
-
target: document.getElementById('app')
|
|
76384
|
-
})
|
|
76385
|
-
|
|
76386
76436
|
export default app
|
|
76387
76437
|
`;
|
|
76388
76438
|
await updateFile({
|
|
76389
|
-
projectPath: targetPath,
|
|
76390
76439
|
filepath: svelteMainJsPath,
|
|
76391
|
-
content: newContent
|
|
76392
|
-
old: [oldContent]
|
|
76440
|
+
content: newContent
|
|
76393
76441
|
});
|
|
76394
76442
|
}
|
|
76395
76443
|
async function updatePackageJSON(targetPath) {
|
|
@@ -76401,9 +76449,9 @@ async function updatePackageJSON(targetPath) {
|
|
|
76401
76449
|
}
|
|
76402
76450
|
packageJSON.devDependencies = {
|
|
76403
76451
|
...packageJSON.devDependencies,
|
|
76404
|
-
houdini: "^0.17.
|
|
76405
|
-
"houdini-svelte": "^0.17.
|
|
76406
|
-
graphql: "^15.
|
|
76452
|
+
houdini: "^0.17.7",
|
|
76453
|
+
"houdini-svelte": "^0.17.7",
|
|
76454
|
+
graphql: "^15.8.0"
|
|
76407
76455
|
};
|
|
76408
76456
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|
|
76409
76457
|
}
|
|
@@ -76419,7 +76467,6 @@ async function graphqlRCFile(targetPath) {
|
|
|
76419
76467
|
- ./$houdini/graphql/documents.gql
|
|
76420
76468
|
`;
|
|
76421
76469
|
await updateFile({
|
|
76422
|
-
projectPath: targetPath,
|
|
76423
76470
|
filepath: target,
|
|
76424
76471
|
content
|
|
76425
76472
|
});
|
|
@@ -76427,7 +76474,9 @@ async function graphqlRCFile(targetPath) {
|
|
|
76427
76474
|
async function gitIgnore(targetPath) {
|
|
76428
76475
|
const filepath = path_exports.join(targetPath, ".gitignore");
|
|
76429
76476
|
const existing = await fs_exports.readFile(filepath) || "";
|
|
76430
|
-
|
|
76477
|
+
if (!existing.includes("\n$houdini\n")) {
|
|
76478
|
+
await fs_exports.writeFile(filepath, existing + "\n$houdini\n");
|
|
76479
|
+
}
|
|
76431
76480
|
}
|
|
76432
76481
|
async function detectTools(cwd) {
|
|
76433
76482
|
try {
|
|
@@ -76454,41 +76503,26 @@ async function detectTools(cwd) {
|
|
|
76454
76503
|
typescript = true;
|
|
76455
76504
|
} catch {
|
|
76456
76505
|
}
|
|
76506
|
+
let package_manager = "npm";
|
|
76507
|
+
let dir = cwd;
|
|
76508
|
+
do {
|
|
76509
|
+
if (fs_exports.existsSync(path_exports.join(dir, "pnpm-lock.yaml"))) {
|
|
76510
|
+
package_manager = "pnpm";
|
|
76511
|
+
break;
|
|
76512
|
+
}
|
|
76513
|
+
if (fs_exports.existsSync(path_exports.join(dir, "yarn.lock"))) {
|
|
76514
|
+
package_manager = "yarn";
|
|
76515
|
+
break;
|
|
76516
|
+
}
|
|
76517
|
+
} while (dir !== (dir = path_exports.dirname(dir)));
|
|
76457
76518
|
return {
|
|
76458
76519
|
typescript,
|
|
76459
76520
|
framework,
|
|
76460
|
-
module: packageJSON["type"] === "module" ? "esm" : "commonjs"
|
|
76521
|
+
module: packageJSON["type"] === "module" ? "esm" : "commonjs",
|
|
76522
|
+
package_manager
|
|
76461
76523
|
};
|
|
76462
76524
|
}
|
|
76463
|
-
async function updateFile({
|
|
76464
|
-
projectPath,
|
|
76465
|
-
filepath,
|
|
76466
|
-
old = [],
|
|
76467
|
-
content
|
|
76468
|
-
}) {
|
|
76469
|
-
const existingContents = await fs_exports.readFile(filepath);
|
|
76470
|
-
if (existingContents && !old.includes(existingContents)) {
|
|
76471
|
-
const relPath = path_exports.relative(projectPath, filepath);
|
|
76472
|
-
console.log();
|
|
76473
|
-
console.log(`\u26A0\uFE0F ${relPath} already exists. We'd like to replace it with:
|
|
76474
|
-
|
|
76475
|
-
${content}`);
|
|
76476
|
-
const { done } = await (0, import_prompts.default)(
|
|
76477
|
-
{
|
|
76478
|
-
name: "done",
|
|
76479
|
-
type: "confirm",
|
|
76480
|
-
message: "Should we overwrite the file? If not, please update it manually."
|
|
76481
|
-
},
|
|
76482
|
-
{
|
|
76483
|
-
onCancel() {
|
|
76484
|
-
process.exit(1);
|
|
76485
|
-
}
|
|
76486
|
-
}
|
|
76487
|
-
);
|
|
76488
|
-
if (!done) {
|
|
76489
|
-
return;
|
|
76490
|
-
}
|
|
76491
|
-
}
|
|
76525
|
+
async function updateFile({ filepath, content }) {
|
|
76492
76526
|
await fs_exports.writeFile(filepath, content);
|
|
76493
76527
|
}
|
|
76494
76528
|
|