goatly 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +853 -1
- package/bin/goatly.js +91 -0
- package/dist/cli/index.js +234 -0
- package/dist/compat/gatsby-node-entry.js +16 -0
- package/dist/compat/gatsby-package.json +6 -0
- package/dist/compat/md5-file.js +47 -0
- package/dist/compat-apis.json +72 -0
- package/dist/compat-apis.json.js +62 -0
- package/dist/graphql.js +3 -0
- package/dist/node/actions/index.js +619 -0
- package/dist/node/actions/job-store.js +180 -0
- package/dist/node/actions/jobs.js +174 -0
- package/dist/node/api-runner.js +258 -0
- package/dist/node/bootstrap.js +539 -0
- package/dist/node/build/assets.js +110 -0
- package/dist/node/build/incremental.js +208 -0
- package/dist/node/build/index.js +752 -0
- package/dist/node/build/memory-governor.js +448 -0
- package/dist/node/build/output-dirs.js +70 -0
- package/dist/node/build/page-data.js +40 -0
- package/dist/node/build/page-files.js +54 -0
- package/dist/node/build/partitioned-state.js +258 -0
- package/dist/node/build/query-worker.js +536 -0
- package/dist/node/build/query-workers.js +832 -0
- package/dist/node/build/render-worker.js +131 -0
- package/dist/node/build/state.js +24 -0
- package/dist/node/build/timing-breakdown.js +155 -0
- package/dist/node/build/worker-pool.js +236 -0
- package/dist/node/cache-layout.js +99 -0
- package/dist/node/cache.js +1430 -0
- package/dist/node/compat/chokidar-shim.js +148 -0
- package/dist/node/compat/core-utils-lmdb.js +145 -0
- package/dist/node/compat/create-node-id-shim.js +1 -0
- package/dist/node/compat/module-hooks.js +245 -0
- package/dist/node/compat/redux-shim.js +1 -0
- package/dist/node/config/index.js +162 -0
- package/dist/node/config/not-found-pages.js +95 -0
- package/dist/node/datastore/codec.js +144 -0
- package/dist/node/datastore/index.js +127 -0
- package/dist/node/datastore/logfile/cache.js +89 -0
- package/dist/node/datastore/logfile/index.js +1329 -0
- package/dist/node/datastore/logfile/record.js +71 -0
- package/dist/node/datastore/types.js +1 -0
- package/dist/node/develop/express-compat.js +207 -0
- package/dist/node/develop/graphiql.js +22 -0
- package/dist/node/develop/hydration-report.js +41 -0
- package/dist/node/develop/index.js +618 -0
- package/dist/node/develop/local-url.js +10 -0
- package/dist/node/develop/ssr-runner.js +66 -0
- package/dist/node/gql.js +5 -0
- package/dist/node/index.js +15 -0
- package/dist/node/info.js +270 -0
- package/dist/node/internal-plugins/data-bridge.js +196 -0
- package/dist/node/internal-plugins/page-creator.js +318 -0
- package/dist/node/loader/import-module.js +160 -0
- package/dist/node/node-helpers.js +66 -0
- package/dist/node/not-found-pages.js +220 -0
- package/dist/node/plugins/api-list.js +12 -0
- package/dist/node/plugins/load-plugins.js +427 -0
- package/dist/node/plugins/resolve-plugin.js +79 -0
- package/dist/node/plugins/static-exports.js +64 -0
- package/dist/node/query/compile.js +326 -0
- package/dist/node/query/dependencies.js +45 -0
- package/dist/node/query/execute.js +417 -0
- package/dist/node/query/extract.js +372 -0
- package/dist/node/query/gql-tada-introspection.js +124 -0
- package/dist/node/query/graphql-env.js +231 -0
- package/dist/node/query/graphql-runner.js +79 -0
- package/dist/node/redux/actions.js +1 -0
- package/dist/node/redux/index.js +133 -0
- package/dist/node/redux/node-changes.js +128 -0
- package/dist/node/redux/reducers.js +193 -0
- package/dist/node/redux/state.js +71 -0
- package/dist/node/renderer.js +124 -0
- package/dist/node/reporter-transports.js +259 -0
- package/dist/node/reporter.js +497 -0
- package/dist/node/schema/date.js +539 -0
- package/dist/node/schema/extensions.js +315 -0
- package/dist/node/schema/index.js +542 -0
- package/dist/node/schema/infer.js +388 -0
- package/dist/node/schema/inline-objects.js +128 -0
- package/dist/node/schema/naming.js +20 -0
- package/dist/node/schema/node-model.js +207 -0
- package/dist/node/schema/query-engine.js +1808 -0
- package/dist/node/schema/resolver-kinds.js +7 -0
- package/dist/node/schema/resolvers.js +273 -0
- package/dist/node/schema/type-builders.js +45 -0
- package/dist/node/schema/types.js +241 -0
- package/dist/node/serve.js +90 -0
- package/dist/node/site-page-nodes.js +277 -0
- package/dist/node/types.js +1 -0
- package/dist/node/utils/content-digest.js +107 -0
- package/dist/node/utils/create-node-id.js +51 -0
- package/dist/node/utils/env.js +24 -0
- package/dist/node/utils/fs-retry.js +74 -0
- package/dist/node/utils/memory-signals.js +410 -0
- package/dist/node/utils/memory.js +400 -0
- package/dist/node/utils/murmurhash.js +32 -0
- package/dist/node/utils/parser.js +33 -0
- package/dist/node/utils/partition-hash.js +19 -0
- package/dist/node/utils/paths.js +122 -0
- package/dist/node/utils/resolver.js +48 -0
- package/dist/node/utils/runtime.js +5 -0
- package/dist/node/utils/serializable.js +41 -0
- package/dist/node/utils/strings.js +41 -0
- package/dist/node/vite/config.js +289 -0
- package/dist/node/vite/paths.js +12 -0
- package/dist/node/vite/plugin-deps.js +232 -0
- package/dist/node/vite/plugin.js +281 -0
- package/dist/node/vite/react-compiler.js +362 -0
- package/dist/node/vite/source-files.js +83 -0
- package/dist/node/vite/static-image.js +136 -0
- package/dist/node/vite/styled-components.js +73 -0
- package/dist/node/vite/transforms.js +299 -0
- package/dist/node/wasm-data/host.js +406 -0
- package/dist/node/wasm-data/lower.js +406 -0
- package/dist/node/wasm-data/runner.js +79 -0
- package/dist/node/wasm-data/worker.js +95 -0
- package/dist/reporter.js +5 -0
- package/dist/runtime/api-runner.js +81 -0
- package/dist/runtime/app.js +256 -0
- package/dist/runtime/client-entry.js +4 -0
- package/dist/runtime/client.js +383 -0
- package/dist/runtime/default-html.js +31 -0
- package/dist/runtime/head-markup.js +100 -0
- package/dist/runtime/head-sync.js +101 -0
- package/dist/runtime/head-tags.js +45 -0
- package/dist/runtime/hydration-report.js +111 -0
- package/dist/runtime/index.js +12 -0
- package/dist/runtime/link.js +293 -0
- package/dist/runtime/loader.js +449 -0
- package/dist/runtime/not-found.js +61 -0
- package/dist/runtime/page-renderer.js +35 -0
- package/dist/runtime/preamble.js +47 -0
- package/dist/runtime/react-compat.js +14 -0
- package/dist/runtime/renderer-shared.js +10 -0
- package/dist/runtime/renderers/react-client.js +14 -0
- package/dist/runtime/renderers/react-server.js +99 -0
- package/dist/runtime/renderers/react.js +17 -0
- package/dist/runtime/renderers/types.js +1 -0
- package/dist/runtime/root-error-handlers.js +29 -0
- package/dist/runtime/router/history.js +132 -0
- package/dist/runtime/router/index.js +240 -0
- package/dist/runtime/router/utils.js +118 -0
- package/dist/runtime/script.js +110 -0
- package/dist/runtime/scroll.js +40 -0
- package/dist/runtime/slice.js +11 -0
- package/dist/runtime/ssr.js +240 -0
- package/dist/runtime/static-query.js +47 -0
- package/dist/utils.js +4 -0
- package/package.json +105 -3
- package/types/graphql-tada.d.ts +223 -0
- package/types/graphql.d.ts +2 -0
- package/types/index.d.ts +2287 -0
- package/types/node.d.ts +380 -0
- package/types/reporter.d.ts +187 -0
- package/types/router.d.ts +102 -0
- package/types/vendor/gql-tada.d.ts +2529 -0
package/bin/goatly.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import os from "node:os"
|
|
3
|
+
import v8 from "node:v8"
|
|
4
|
+
import { spawn } from "node:child_process"
|
|
5
|
+
|
|
6
|
+
/** the heap limit Node gives every thread when nobody chose one (worker threads too) */
|
|
7
|
+
const nodeHeapMb = v8.getHeapStatistics().heap_size_limit / 1048576
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* V8's default heap limit (about 2 GB, 4 GB with 15 GB of memory or more) is too small for the main
|
|
11
|
+
* thread of sites with 100k+ pages. Unless a limit was chosen (`--max-old-space-size` in
|
|
12
|
+
* NODE_OPTIONS or the node arguments, or GOATLY_HEAP_LIMIT=<MB>|off), Node is restarted with a
|
|
13
|
+
* heap limit of 75% of the available memory. Worker threads get their limits from the build
|
|
14
|
+
* (src/node/utils/memory.ts): it is told Node's default (GOATLY_NODE_HEAP_MB), which the
|
|
15
|
+
* restarted process can no longer see. Bun has no fixed heap limit.
|
|
16
|
+
*/
|
|
17
|
+
function heapLimitMb() {
|
|
18
|
+
const setting = process.env.GOATLY_HEAP_LIMIT
|
|
19
|
+
if (setting === "off" || process.env.GOATLY_RESPAWNED) return 0
|
|
20
|
+
if (typeof process.versions.bun === "string") return 0
|
|
21
|
+
// (as V8 accepts it: `-` or `_` between the words, a share of the memory with `-percentage`, and
|
|
22
|
+
// NODE_OPTIONS may double-quote it – the same check as src/node/utils/memory.ts)
|
|
23
|
+
const chosen = [...process.execArgv, ...(process.env.NODE_OPTIONS ?? "").split(/\s+/)].some(
|
|
24
|
+
(arg) => /^"?--max[-_]old[-_]space[-_]size([-_]percentage)?=/.test(arg),
|
|
25
|
+
)
|
|
26
|
+
if (chosen) return 0
|
|
27
|
+
if (setting && Number(setting) > 0) return Math.round(Number(setting))
|
|
28
|
+
const constrained =
|
|
29
|
+
typeof process.constrainedMemory === "function" ? process.constrainedMemory() : 0
|
|
30
|
+
const memory = constrained > 0 ? Math.min(constrained, os.totalmem()) : os.totalmem()
|
|
31
|
+
const target = Math.floor((memory / 1048576) * 0.75)
|
|
32
|
+
return target > nodeHeapMb * 1.25 ? target : 0
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const limit = heapLimitMb()
|
|
36
|
+
if (limit) {
|
|
37
|
+
// Windows can't deliver signals to another process (kill() terminates it there): the child gets
|
|
38
|
+
// an IPC channel to send them as messages (see src/cli/index.ts), and when this process ends
|
|
39
|
+
// without stopping it (terminated), the channel closes and develop stops like on SIGTERM. A
|
|
40
|
+
// parent of this process with an IPC channel gets its messages forwarded on every platform.
|
|
41
|
+
const ipc = process.platform === "win32" || Boolean(process.send)
|
|
42
|
+
const child = spawn(
|
|
43
|
+
process.execPath,
|
|
44
|
+
[`--max-old-space-size=${limit}`, ...process.execArgv, ...process.argv.slice(1)],
|
|
45
|
+
{
|
|
46
|
+
stdio: ipc ? ["inherit", "inherit", "inherit", "ipc"] : "inherit",
|
|
47
|
+
env: {
|
|
48
|
+
...process.env,
|
|
49
|
+
GOATLY_RESPAWNED: "1",
|
|
50
|
+
GOATLY_NODE_HEAP_MB: String(Math.round(nodeHeapMb)),
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
)
|
|
54
|
+
// Ctrl+C reaches the whole process group (the child included): just wait for the child
|
|
55
|
+
process.on("SIGINT", () => {})
|
|
56
|
+
const forward = (signal) =>
|
|
57
|
+
process.platform === "win32"
|
|
58
|
+
? child.connected && child.send({ type: "goatly:signal", signal }, () => {})
|
|
59
|
+
: child.kill(signal)
|
|
60
|
+
for (const signal of ["SIGTERM", "SIGHUP"]) process.on(signal, () => forward(signal))
|
|
61
|
+
if (process.send) {
|
|
62
|
+
process.on("message", (message) => child.connected && child.send(message, () => {}))
|
|
63
|
+
process.on("disconnect", () => child.connected && child.disconnect())
|
|
64
|
+
}
|
|
65
|
+
child.on("exit", (code, signal) => {
|
|
66
|
+
// V8 aborts the whole process when one allocation doesn't fit into a heap (no recovery possible).
|
|
67
|
+
// Windows has no signals: Node's abort there exits with code 134 (as abort() is reported on POSIX)
|
|
68
|
+
if (signal === "SIGABRT" || (process.platform === "win32" && code === 134))
|
|
69
|
+
console.error(
|
|
70
|
+
'\nThe build was aborted. If the output above says "JavaScript heap out of memory", a thread' +
|
|
71
|
+
" ran out of memory: GOATLY_HEAP_LIMIT=<MB> raises the heap limit of the main" +
|
|
72
|
+
" thread, GOATLY_WORKER_HEAP_MB=<MB> the one of worker threads. If the machine" +
|
|
73
|
+
" itself ran out of memory (other processes use it, too), raising them doesn't help:" +
|
|
74
|
+
" GOATLY_MEMORY_RESERVE_MB=<MB> keeps more of it free.",
|
|
75
|
+
)
|
|
76
|
+
// (the kernel's out-of-memory killer, usually)
|
|
77
|
+
if (signal === "SIGKILL")
|
|
78
|
+
console.error(
|
|
79
|
+
"\nThe build was killed – most likely by the kernel because the machine (or container) ran" +
|
|
80
|
+
" out of memory. Query workers follow the free memory, but memory other processes take" +
|
|
81
|
+
" faster than they can give it back still runs out: GOATLY_MEMORY_RESERVE_MB=<MB>" +
|
|
82
|
+
" keeps more of it free, fewer workers (`renderWorkers`) need less.",
|
|
83
|
+
)
|
|
84
|
+
if (signal) {
|
|
85
|
+
process.removeAllListeners(signal)
|
|
86
|
+
process.kill(process.pid, signal)
|
|
87
|
+
} else process.exit(code ?? 1)
|
|
88
|
+
})
|
|
89
|
+
} else {
|
|
90
|
+
import("../dist/cli/index.js").then((m) => m.run(process.argv.slice(2)))
|
|
91
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import reporter from "../node/reporter.js";
|
|
2
|
+
import { runtimeName } from "../node/utils/runtime.js";
|
|
3
|
+
import pc from "picocolors";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import { parseArgs } from "node:util";
|
|
7
|
+
// src/cli/index.ts
|
|
8
|
+
/**
|
|
9
|
+
* The signal a parent process sends over its IPC channel (`{ type: "goatly:signal",
|
|
10
|
+
* signal: "SIGTERM" }`), for platforms that can't deliver signals to another process (Windows).
|
|
11
|
+
*/
|
|
12
|
+
function ipcSignal(message) {
|
|
13
|
+
if (!message || typeof message !== "object") return void 0;
|
|
14
|
+
const { type, signal } = message;
|
|
15
|
+
return type === "goatly:signal" && typeof signal === "string" ? signal : void 0;
|
|
16
|
+
}
|
|
17
|
+
const HELP = `
|
|
18
|
+
${pc.bold("goatly")} – Gatsby compatible static site generator (Vite + Rolldown + React 18/19)
|
|
19
|
+
|
|
20
|
+
Usage: goatly <command> [options]
|
|
21
|
+
(also available as "gatsby" when installed as an alias)
|
|
22
|
+
|
|
23
|
+
Commands:
|
|
24
|
+
develop Start the development server
|
|
25
|
+
build Build the site for production
|
|
26
|
+
serve Serve the production build
|
|
27
|
+
clean Wipe the .cache and public directories
|
|
28
|
+
info Print environment details for bug reports
|
|
29
|
+
|
|
30
|
+
Options:
|
|
31
|
+
-H, --host <host> Host (develop/serve) [default: localhost]
|
|
32
|
+
-p, --port <port> Port (develop: 8000, serve: 9000)
|
|
33
|
+
--prefix-paths Build/serve with the configured pathPrefix
|
|
34
|
+
--verbose Verbose logging
|
|
35
|
+
--json Print "info" as JSON
|
|
36
|
+
-o, --open Open the site in the browser (develop/serve)
|
|
37
|
+
-h, --help Show help
|
|
38
|
+
-v, --version Show the version
|
|
39
|
+
`;
|
|
40
|
+
const OPTIONS = {
|
|
41
|
+
host: {
|
|
42
|
+
type: "string",
|
|
43
|
+
short: "H"
|
|
44
|
+
},
|
|
45
|
+
port: {
|
|
46
|
+
type: "string",
|
|
47
|
+
short: "p"
|
|
48
|
+
},
|
|
49
|
+
"prefix-paths": { type: "boolean" },
|
|
50
|
+
verbose: { type: "boolean" },
|
|
51
|
+
open: {
|
|
52
|
+
type: "boolean",
|
|
53
|
+
short: "o"
|
|
54
|
+
},
|
|
55
|
+
help: {
|
|
56
|
+
type: "boolean",
|
|
57
|
+
short: "h"
|
|
58
|
+
},
|
|
59
|
+
version: {
|
|
60
|
+
type: "boolean",
|
|
61
|
+
short: "v"
|
|
62
|
+
},
|
|
63
|
+
json: { type: "boolean" },
|
|
64
|
+
https: {
|
|
65
|
+
type: "boolean",
|
|
66
|
+
short: "S"
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const COMMANDS = [
|
|
70
|
+
"develop",
|
|
71
|
+
"build",
|
|
72
|
+
"serve",
|
|
73
|
+
"clean",
|
|
74
|
+
"info"
|
|
75
|
+
];
|
|
76
|
+
/** options parseArgs collected although nobody declared them (it runs with `strict: false`) */
|
|
77
|
+
function unknownOptions(values) {
|
|
78
|
+
return Object.keys(values).filter((name) => !(name in OPTIONS)).map((name) => name.length === 1 ? `-${name}` : `--${name}`);
|
|
79
|
+
}
|
|
80
|
+
/** the closest command to a mistyped one (at most 2 edits away), for "did you mean" hints */
|
|
81
|
+
function suggestCommand(input) {
|
|
82
|
+
let best;
|
|
83
|
+
for (const command of COMMANDS) {
|
|
84
|
+
const distance = editDistance(input.toLowerCase(), command);
|
|
85
|
+
if (distance <= 2 && (!best || distance < best.distance)) best = {
|
|
86
|
+
command,
|
|
87
|
+
distance
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return best?.command;
|
|
91
|
+
}
|
|
92
|
+
function editDistance(a, b) {
|
|
93
|
+
let previous = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
94
|
+
for (let i = 1; i <= a.length; i++) {
|
|
95
|
+
const current = [i];
|
|
96
|
+
for (let j = 1; j <= b.length; j++) current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
97
|
+
previous = current;
|
|
98
|
+
}
|
|
99
|
+
return previous[b.length];
|
|
100
|
+
}
|
|
101
|
+
function packageVersion() {
|
|
102
|
+
const file = new URL("../../package.json", import.meta.url);
|
|
103
|
+
try {
|
|
104
|
+
return JSON.parse(fs.readFileSync(file, "utf8")).version;
|
|
105
|
+
} catch {
|
|
106
|
+
return "unknown";
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async function loadReporterModule(directory, specifier) {
|
|
110
|
+
const { importModule, normalizeModuleExports } = await import("../node/loader/import-module.js");
|
|
111
|
+
const { resolveModule } = await import("../node/utils/resolver.js");
|
|
112
|
+
const mod = normalizeModuleExports(await importModule(specifier.startsWith(".") || path.isAbsolute(specifier) ? path.resolve(directory, specifier) : resolveModule(specifier, directory)));
|
|
113
|
+
let transports = mod?.default ?? mod;
|
|
114
|
+
if (typeof transports === "function") transports = await transports();
|
|
115
|
+
reporter.setTransports(transports);
|
|
116
|
+
}
|
|
117
|
+
async function run(argv) {
|
|
118
|
+
const { values, positionals } = parseArgs({
|
|
119
|
+
args: argv,
|
|
120
|
+
allowPositionals: true,
|
|
121
|
+
strict: false,
|
|
122
|
+
options: OPTIONS
|
|
123
|
+
});
|
|
124
|
+
const command = positionals[0];
|
|
125
|
+
if (values.version) {
|
|
126
|
+
console.log(packageVersion());
|
|
127
|
+
process.exit(0);
|
|
128
|
+
}
|
|
129
|
+
if (values.help || !command) {
|
|
130
|
+
console.log(HELP);
|
|
131
|
+
process.exit(command ? 0 : 1);
|
|
132
|
+
}
|
|
133
|
+
if (!COMMANDS.includes(command)) {
|
|
134
|
+
const suggestion = suggestCommand(command);
|
|
135
|
+
console.error(`Unknown command "${command}".${suggestion ? ` Did you mean "${suggestion}"?` : ""} Run "goatly --help" for the list of commands.`);
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
process.env.gatsby_executing_command = command;
|
|
139
|
+
for (const option of unknownOptions(values)) reporter.warn(`Unknown option ${option}. It will be ignored.`);
|
|
140
|
+
const directory = process.cwd();
|
|
141
|
+
const verbose = !!values.verbose;
|
|
142
|
+
if (verbose) reporter.setVerbose(true);
|
|
143
|
+
try {
|
|
144
|
+
if (process.env.GOATLY_REPORTER) await loadReporterModule(directory, process.env.GOATLY_REPORTER);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
reporter.panic(`Could not load the reporter module GOATLY_REPORTER=${process.env.GOATLY_REPORTER}`, e);
|
|
147
|
+
}
|
|
148
|
+
reporter.verbose(`running on ${runtimeName}`);
|
|
149
|
+
try {
|
|
150
|
+
switch (command) {
|
|
151
|
+
case "build": {
|
|
152
|
+
const { build } = await import("../node/build/index.js");
|
|
153
|
+
await build({
|
|
154
|
+
directory,
|
|
155
|
+
prefixPaths: !!values["prefix-paths"],
|
|
156
|
+
verbose
|
|
157
|
+
});
|
|
158
|
+
await reporter.flush();
|
|
159
|
+
process.exit(0);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case "develop": {
|
|
163
|
+
const { develop } = await import("../node/develop/index.js");
|
|
164
|
+
let server;
|
|
165
|
+
let closing = false;
|
|
166
|
+
const onMessage = (message) => {
|
|
167
|
+
const signal = ipcSignal(message);
|
|
168
|
+
if (signal === "SIGINT" || signal === "SIGTERM") shutdown(signal);
|
|
169
|
+
};
|
|
170
|
+
const onDisconnect = () => closing || shutdown("SIGTERM");
|
|
171
|
+
const shutdown = (signal) => {
|
|
172
|
+
if (!server) {
|
|
173
|
+
process.off("SIGINT", shutdown);
|
|
174
|
+
process.off("SIGTERM", shutdown);
|
|
175
|
+
process.off("message", onMessage);
|
|
176
|
+
process.off("disconnect", onDisconnect);
|
|
177
|
+
process.kill(process.pid, signal);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (closing) process.exit(130);
|
|
181
|
+
closing = true;
|
|
182
|
+
setTimeout(() => process.exit(0), 6e4).unref();
|
|
183
|
+
server.close().catch((e) => reporter.error("Could not shut down the development server", e)).finally(async () => {
|
|
184
|
+
await reporter.flush();
|
|
185
|
+
process.exit(0);
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
process.on("SIGINT", shutdown);
|
|
189
|
+
process.on("SIGTERM", shutdown);
|
|
190
|
+
if (process.send) {
|
|
191
|
+
process.on("message", onMessage);
|
|
192
|
+
process.on("disconnect", onDisconnect);
|
|
193
|
+
}
|
|
194
|
+
await develop({
|
|
195
|
+
directory,
|
|
196
|
+
host: values.host ?? "localhost",
|
|
197
|
+
port: Number(values.port ?? 8e3),
|
|
198
|
+
verbose,
|
|
199
|
+
open: !!values.open,
|
|
200
|
+
prefixPaths: !!values["prefix-paths"],
|
|
201
|
+
onReady: (s) => server = s
|
|
202
|
+
});
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
case "serve": {
|
|
206
|
+
const { serve } = await import("../node/serve.js");
|
|
207
|
+
await serve({
|
|
208
|
+
directory,
|
|
209
|
+
host: values.host ?? "localhost",
|
|
210
|
+
port: Number(values.port ?? 9e3),
|
|
211
|
+
prefixPaths: !!values["prefix-paths"],
|
|
212
|
+
open: !!values.open
|
|
213
|
+
});
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
case "clean":
|
|
217
|
+
for (const dir of [".cache", "public"]) fs.rmSync(path.join(directory, dir), {
|
|
218
|
+
recursive: true,
|
|
219
|
+
force: true
|
|
220
|
+
});
|
|
221
|
+
reporter.success("Deleted .cache and public directories");
|
|
222
|
+
break;
|
|
223
|
+
case "info": {
|
|
224
|
+
const { collectInfo, formatInfo } = await import("../node/info.js");
|
|
225
|
+
const info = collectInfo(directory);
|
|
226
|
+
process.stdout.write(values.json ? JSON.stringify(info, null, 2) + "\n" : formatInfo(info));
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
} catch (e) {
|
|
231
|
+
reporter.panic(e);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
export { run, suggestCommand, unknownOptions };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import reporter from "../node/reporter.js";
|
|
2
|
+
// src/compat/gatsby-node-entry.ts
|
|
3
|
+
/**
|
|
4
|
+
* What `require("gatsby")` resolves to inside Node.js code (gatsby-node, plugins).
|
|
5
|
+
* Gatsby's real entry is the browser runtime; in Node only a few helpers make sense.
|
|
6
|
+
*/
|
|
7
|
+
function graphql(strings, ...values) {
|
|
8
|
+
if (typeof strings === "string") return strings;
|
|
9
|
+
return strings.reduce((acc, s, i) => acc + s + (i < values.length ? String(values[i]) : ""), "");
|
|
10
|
+
}
|
|
11
|
+
function withPrefix(path, prefix = "") {
|
|
12
|
+
if (!path.startsWith("/") || path.startsWith("//")) return path;
|
|
13
|
+
return `${prefix.replace(/\/$/, "")}${path}`;
|
|
14
|
+
}
|
|
15
|
+
const withAssetPrefix = withPrefix;
|
|
16
|
+
export { graphql, reporter, withAssetPrefix, withPrefix };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
// src/compat/md5-file.ts
|
|
4
|
+
/**
|
|
5
|
+
* Drop-in replacement for `gatsby-core-utils`' md5File (used by gatsby-source-filesystem).
|
|
6
|
+
* The original creates one hash-wasm instance per file; with tens of thousands of files hashed
|
|
7
|
+
* concurrently this exhausts the process' memory mappings (Gatsby itself grinds to a halt).
|
|
8
|
+
* Native `node:crypto` produces the same hex digest, faster and without WebAssembly memories.
|
|
9
|
+
* Concurrency is bounded so that huge directories don't run into EMFILE.
|
|
10
|
+
*/
|
|
11
|
+
const MAX_OPEN = 64;
|
|
12
|
+
let open = 0;
|
|
13
|
+
const waiting = [];
|
|
14
|
+
function acquire() {
|
|
15
|
+
if (open < MAX_OPEN) {
|
|
16
|
+
open++;
|
|
17
|
+
return Promise.resolve();
|
|
18
|
+
}
|
|
19
|
+
return new Promise((resolve) => waiting.push(() => (open++, resolve())));
|
|
20
|
+
}
|
|
21
|
+
function release() {
|
|
22
|
+
open--;
|
|
23
|
+
waiting.shift()?.();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* regular files up to one chunk of a read stream are read and hashed at once, without thread pool
|
|
27
|
+
* round trips (larger ones stay streamed: read synchronously, they were slower on a cold page
|
|
28
|
+
* cache, where reading no longer overlapped hashing)
|
|
29
|
+
*/
|
|
30
|
+
const WHOLE_FILE_MAX = 65536;
|
|
31
|
+
async function md5File(filePath) {
|
|
32
|
+
const stats = fs.statSync(filePath);
|
|
33
|
+
if (stats.isFile() && stats.size <= 65536) return createHash("md5").update(fs.readFileSync(filePath)).digest("hex");
|
|
34
|
+
await acquire();
|
|
35
|
+
try {
|
|
36
|
+
return await new Promise((resolve, reject) => {
|
|
37
|
+
const hash = createHash("md5");
|
|
38
|
+
const input = fs.createReadStream(filePath);
|
|
39
|
+
input.on("error", reject);
|
|
40
|
+
input.on("data", (chunk) => hash.update(chunk));
|
|
41
|
+
input.on("end", () => resolve(hash.digest("hex")));
|
|
42
|
+
});
|
|
43
|
+
} finally {
|
|
44
|
+
release();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export { WHOLE_FILE_MAX, md5File };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ssr": {
|
|
3
|
+
"replaceRenderer": {},
|
|
4
|
+
"onRenderBody": {},
|
|
5
|
+
"onPreRenderHTML": {},
|
|
6
|
+
"wrapPageElement": {},
|
|
7
|
+
"wrapRootElement": {}
|
|
8
|
+
},
|
|
9
|
+
"browser": {
|
|
10
|
+
"onClientEntry": {},
|
|
11
|
+
"onInitialClientRender": {},
|
|
12
|
+
"onPreRouteUpdate": {},
|
|
13
|
+
"onRouteUpdateDelayed": {},
|
|
14
|
+
"onRouteUpdate": {},
|
|
15
|
+
"shouldUpdateScroll": {},
|
|
16
|
+
"registerServiceWorker": {},
|
|
17
|
+
"wrapPageElement": {},
|
|
18
|
+
"wrapRootElement": {},
|
|
19
|
+
"onPrefetchPathname": {},
|
|
20
|
+
"onPostPrefetchPathname": {},
|
|
21
|
+
"disableCorePrefetching": {},
|
|
22
|
+
"replaceHydrateFunction": {},
|
|
23
|
+
"onServiceWorkerInstalled": {},
|
|
24
|
+
"onServiceWorkerUpdateFound": {},
|
|
25
|
+
"onServiceWorkerUpdateReady": {},
|
|
26
|
+
"onServiceWorkerActive": {},
|
|
27
|
+
"onServiceWorkerRedundant": {},
|
|
28
|
+
"onCaughtError": {},
|
|
29
|
+
"onUncaughtError": {}
|
|
30
|
+
},
|
|
31
|
+
"node": {
|
|
32
|
+
"resolvableExtensions": {},
|
|
33
|
+
"createPages": {},
|
|
34
|
+
"createPagesStatefully": {},
|
|
35
|
+
"sourceNodes": {},
|
|
36
|
+
"onCreateNode": {},
|
|
37
|
+
"shouldOnCreateNode": {
|
|
38
|
+
"version": "5.0.0"
|
|
39
|
+
},
|
|
40
|
+
"onCreatePage": {},
|
|
41
|
+
"setFieldsOnGraphQLNodeType": {},
|
|
42
|
+
"createSchemaCustomization": {
|
|
43
|
+
"version": "2.12.0"
|
|
44
|
+
},
|
|
45
|
+
"createResolvers": {
|
|
46
|
+
"version": "2.2.0"
|
|
47
|
+
},
|
|
48
|
+
"preprocessSource": {},
|
|
49
|
+
"onCreateBabelConfig": {},
|
|
50
|
+
"onCreateWebpackConfig": {},
|
|
51
|
+
"onPreInit": {},
|
|
52
|
+
"onPluginInit": {
|
|
53
|
+
"version": "3.9.0"
|
|
54
|
+
},
|
|
55
|
+
"onPreBootstrap": {},
|
|
56
|
+
"onPostBootstrap": {},
|
|
57
|
+
"onPreBuild": {},
|
|
58
|
+
"onPostBuild": {},
|
|
59
|
+
"onPreExtractQueries": {},
|
|
60
|
+
"onCreateDevServer": {},
|
|
61
|
+
"pluginOptionsSchema": {
|
|
62
|
+
"version": "2.25.0"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"features": [
|
|
66
|
+
"image-cdn",
|
|
67
|
+
"graphql-typegen",
|
|
68
|
+
"content-file-path",
|
|
69
|
+
"stateful-source-nodes",
|
|
70
|
+
"adapters"
|
|
71
|
+
]
|
|
72
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/compat-apis.json
|
|
2
|
+
var ssr = {
|
|
3
|
+
"replaceRenderer": {},
|
|
4
|
+
"onRenderBody": {},
|
|
5
|
+
"onPreRenderHTML": {},
|
|
6
|
+
"wrapPageElement": {},
|
|
7
|
+
"wrapRootElement": {}
|
|
8
|
+
};
|
|
9
|
+
var browser = {
|
|
10
|
+
"onClientEntry": {},
|
|
11
|
+
"onInitialClientRender": {},
|
|
12
|
+
"onPreRouteUpdate": {},
|
|
13
|
+
"onRouteUpdateDelayed": {},
|
|
14
|
+
"onRouteUpdate": {},
|
|
15
|
+
"shouldUpdateScroll": {},
|
|
16
|
+
"registerServiceWorker": {},
|
|
17
|
+
"wrapPageElement": {},
|
|
18
|
+
"wrapRootElement": {},
|
|
19
|
+
"onPrefetchPathname": {},
|
|
20
|
+
"onPostPrefetchPathname": {},
|
|
21
|
+
"disableCorePrefetching": {},
|
|
22
|
+
"replaceHydrateFunction": {},
|
|
23
|
+
"onServiceWorkerInstalled": {},
|
|
24
|
+
"onServiceWorkerUpdateFound": {},
|
|
25
|
+
"onServiceWorkerUpdateReady": {},
|
|
26
|
+
"onServiceWorkerActive": {},
|
|
27
|
+
"onServiceWorkerRedundant": {},
|
|
28
|
+
"onCaughtError": {},
|
|
29
|
+
"onUncaughtError": {}
|
|
30
|
+
};
|
|
31
|
+
var node = {
|
|
32
|
+
"resolvableExtensions": {},
|
|
33
|
+
"createPages": {},
|
|
34
|
+
"createPagesStatefully": {},
|
|
35
|
+
"sourceNodes": {},
|
|
36
|
+
"onCreateNode": {},
|
|
37
|
+
"shouldOnCreateNode": { "version": "5.0.0" },
|
|
38
|
+
"onCreatePage": {},
|
|
39
|
+
"setFieldsOnGraphQLNodeType": {},
|
|
40
|
+
"createSchemaCustomization": { "version": "2.12.0" },
|
|
41
|
+
"createResolvers": { "version": "2.2.0" },
|
|
42
|
+
"preprocessSource": {},
|
|
43
|
+
"onCreateBabelConfig": {},
|
|
44
|
+
"onCreateWebpackConfig": {},
|
|
45
|
+
"onPreInit": {},
|
|
46
|
+
"onPluginInit": { "version": "3.9.0" },
|
|
47
|
+
"onPreBootstrap": {},
|
|
48
|
+
"onPostBootstrap": {},
|
|
49
|
+
"onPreBuild": {},
|
|
50
|
+
"onPostBuild": {},
|
|
51
|
+
"onPreExtractQueries": {},
|
|
52
|
+
"onCreateDevServer": {},
|
|
53
|
+
"pluginOptionsSchema": { "version": "2.25.0" }
|
|
54
|
+
};
|
|
55
|
+
var features = [
|
|
56
|
+
"image-cdn",
|
|
57
|
+
"graphql-typegen",
|
|
58
|
+
"content-file-path",
|
|
59
|
+
"stateful-source-nodes",
|
|
60
|
+
"adapters"
|
|
61
|
+
];
|
|
62
|
+
export { browser, features, node, ssr };
|
package/dist/graphql.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { BREAK, BreakingChangeType, DEFAULT_DEPRECATION_REASON, DangerousChangeType, DirectiveLocation, ExecutableDefinitionsRule, FieldsOnCorrectTypeRule, FragmentsOnCompositeTypesRule, GRAPHQL_MAX_INT, GRAPHQL_MIN_INT, GraphQLBoolean, GraphQLDeprecatedDirective, GraphQLDirective, GraphQLEnumType, GraphQLError, GraphQLFloat, GraphQLID, GraphQLIncludeDirective, GraphQLInputObjectType, GraphQLInt, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLOneOfDirective, GraphQLScalarType, GraphQLSchema, GraphQLSkipDirective, GraphQLSpecifiedByDirective, GraphQLString, GraphQLUnionType, Kind, KnownArgumentNamesRule, KnownDirectivesRule, KnownFragmentNamesRule, KnownTypeNamesRule, Lexer, Location, LoneAnonymousOperationRule, LoneSchemaDefinitionRule, MaxIntrospectionDepthRule, NoDeprecatedCustomRule, NoFragmentCyclesRule, NoSchemaIntrospectionCustomRule, NoUndefinedVariablesRule, NoUnusedFragmentsRule, NoUnusedVariablesRule, OperationTypeNode, OverlappingFieldsCanBeMergedRule, PossibleFragmentSpreadsRule, PossibleTypeExtensionsRule, ProvidedRequiredArgumentsRule, ScalarLeafsRule, SchemaMetaFieldDef, SingleFieldSubscriptionsRule, Source, Token, TokenKind, TypeInfo, TypeKind, TypeMetaFieldDef, TypeNameMetaFieldDef, UniqueArgumentDefinitionNamesRule, UniqueArgumentNamesRule, UniqueDirectiveNamesRule, UniqueDirectivesPerLocationRule, UniqueEnumValueNamesRule, UniqueFieldDefinitionNamesRule, UniqueFragmentNamesRule, UniqueInputFieldNamesRule, UniqueOperationNamesRule, UniqueOperationTypesRule, UniqueTypeNamesRule, UniqueVariableNamesRule, ValidationContext, ValuesOfCorrectTypeRule, VariablesAreInputTypesRule, VariablesInAllowedPositionRule, __Directive, __DirectiveLocation, __EnumValue, __Field, __InputValue, __Schema, __Type, __TypeKind, assertAbstractType, assertCompositeType, assertDirective, assertEnumType, assertEnumValueName, assertInputObjectType, assertInputType, assertInterfaceType, assertLeafType, assertListType, assertName, assertNamedType, assertNonNullType, assertNullableType, assertObjectType, assertOutputType, assertScalarType, assertSchema, assertType, assertUnionType, assertValidName, assertValidSchema, assertWrappingType, astFromValue, buildASTSchema, buildClientSchema, buildSchema, coerceInputValue, concatAST, createSourceEventStream, defaultFieldResolver, defaultTypeResolver, doTypesOverlap, execute, executeSync, extendSchema, findBreakingChanges, findDangerousChanges, formatError, getArgumentValues, getDirectiveValues, getEnterLeaveForKind, getIntrospectionQuery, getLocation, getNamedType, getNullableType, getOperationAST, getOperationRootType, getVariableValues, getVisitFn, graphql, graphqlSync, introspectionFromSchema, introspectionTypes, isAbstractType, isCompositeType, isConstValueNode, isDefinitionNode, isDirective, isEnumType, isEqualType, isExecutableDefinitionNode, isInputObjectType, isInputType, isInterfaceType, isIntrospectionType, isLeafType, isListType, isNamedType, isNonNullType, isNullableType, isObjectType, isOutputType, isRequiredArgument, isRequiredInputField, isScalarType, isSchema, isSchemaCoordinateNode, isSelectionNode, isSpecifiedDirective, isSpecifiedScalarType, isType, isTypeDefinitionNode, isTypeExtensionNode, isTypeNode, isTypeSubTypeOf, isTypeSystemDefinitionNode, isTypeSystemExtensionNode, isUnionType, isValidNameError, isValueNode, isWrappingType, lexicographicSortSchema, locatedError, parse, parseConstValue, parseSchemaCoordinate, parseType, parseValue, print, printError, printIntrospectionSchema, printLocation, printSchema, printSourceLocation, printType, recommendedRules, resolveASTSchemaCoordinate, resolveObjMapThunk, resolveReadonlyArrayThunk, resolveSchemaCoordinate, responsePathAsArray, separateOperations, specifiedDirectives, specifiedRules, specifiedScalarTypes, stripIgnoredCharacters, subscribe, syntaxError, typeFromAST, validate, validateSchema, valueFromAST, valueFromASTUntyped, version, versionInfo, visit, visitInParallel, visitWithTypeInfo } from "./node/gql.js";
|
|
2
|
+
import { GraphQLJSON } from "graphql-compose";
|
|
3
|
+
export { BREAK, BreakingChangeType, DEFAULT_DEPRECATION_REASON, DangerousChangeType, DirectiveLocation, ExecutableDefinitionsRule, FieldsOnCorrectTypeRule, FragmentsOnCompositeTypesRule, GRAPHQL_MAX_INT, GRAPHQL_MIN_INT, GraphQLBoolean, GraphQLDeprecatedDirective, GraphQLDirective, GraphQLEnumType, GraphQLError, GraphQLFloat, GraphQLID, GraphQLIncludeDirective, GraphQLInputObjectType, GraphQLInt, GraphQLInterfaceType, GraphQLJSON, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLOneOfDirective, GraphQLScalarType, GraphQLSchema, GraphQLSkipDirective, GraphQLSpecifiedByDirective, GraphQLString, GraphQLUnionType, Kind, KnownArgumentNamesRule, KnownDirectivesRule, KnownFragmentNamesRule, KnownTypeNamesRule, Lexer, Location, LoneAnonymousOperationRule, LoneSchemaDefinitionRule, MaxIntrospectionDepthRule, NoDeprecatedCustomRule, NoFragmentCyclesRule, NoSchemaIntrospectionCustomRule, NoUndefinedVariablesRule, NoUnusedFragmentsRule, NoUnusedVariablesRule, OperationTypeNode, OverlappingFieldsCanBeMergedRule, PossibleFragmentSpreadsRule, PossibleTypeExtensionsRule, ProvidedRequiredArgumentsRule, ScalarLeafsRule, SchemaMetaFieldDef, SingleFieldSubscriptionsRule, Source, Token, TokenKind, TypeInfo, TypeKind, TypeMetaFieldDef, TypeNameMetaFieldDef, UniqueArgumentDefinitionNamesRule, UniqueArgumentNamesRule, UniqueDirectiveNamesRule, UniqueDirectivesPerLocationRule, UniqueEnumValueNamesRule, UniqueFieldDefinitionNamesRule, UniqueFragmentNamesRule, UniqueInputFieldNamesRule, UniqueOperationNamesRule, UniqueOperationTypesRule, UniqueTypeNamesRule, UniqueVariableNamesRule, ValidationContext, ValuesOfCorrectTypeRule, VariablesAreInputTypesRule, VariablesInAllowedPositionRule, __Directive, __DirectiveLocation, __EnumValue, __Field, __InputValue, __Schema, __Type, __TypeKind, assertAbstractType, assertCompositeType, assertDirective, assertEnumType, assertEnumValueName, assertInputObjectType, assertInputType, assertInterfaceType, assertLeafType, assertListType, assertName, assertNamedType, assertNonNullType, assertNullableType, assertObjectType, assertOutputType, assertScalarType, assertSchema, assertType, assertUnionType, assertValidName, assertValidSchema, assertWrappingType, astFromValue, buildASTSchema, buildClientSchema, buildSchema, coerceInputValue, concatAST, createSourceEventStream, defaultFieldResolver, defaultTypeResolver, doTypesOverlap, execute, executeSync, extendSchema, findBreakingChanges, findDangerousChanges, formatError, getArgumentValues, getDirectiveValues, getEnterLeaveForKind, getIntrospectionQuery, getLocation, getNamedType, getNullableType, getOperationAST, getOperationRootType, getVariableValues, getVisitFn, graphql, graphqlSync, introspectionFromSchema, introspectionTypes, isAbstractType, isCompositeType, isConstValueNode, isDefinitionNode, isDirective, isEnumType, isEqualType, isExecutableDefinitionNode, isInputObjectType, isInputType, isInterfaceType, isIntrospectionType, isLeafType, isListType, isNamedType, isNonNullType, isNullableType, isObjectType, isOutputType, isRequiredArgument, isRequiredInputField, isScalarType, isSchema, isSchemaCoordinateNode, isSelectionNode, isSpecifiedDirective, isSpecifiedScalarType, isType, isTypeDefinitionNode, isTypeExtensionNode, isTypeNode, isTypeSubTypeOf, isTypeSystemDefinitionNode, isTypeSystemExtensionNode, isUnionType, isValidNameError, isValueNode, isWrappingType, lexicographicSortSchema, locatedError, parse, parseConstValue, parseSchemaCoordinate, parseType, parseValue, print, printError, printIntrospectionSchema, printLocation, printSchema, printSourceLocation, printType, recommendedRules, resolveASTSchemaCoordinate, resolveObjMapThunk, resolveReadonlyArrayThunk, resolveSchemaCoordinate, responsePathAsArray, separateOperations, specifiedDirectives, specifiedRules, specifiedScalarTypes, stripIgnoredCharacters, subscribe, syntaxError, typeFromAST, validate, validateSchema, valueFromAST, valueFromASTUntyped, version, versionInfo, visit, visitInParallel, visitWithTypeInfo };
|