@lukoweb/apitogo 0.1.18 → 0.1.20
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/dist/cli/cli.js +292 -142
- package/package.json +1 -1
- package/src/config/validators/NavigationSchema.ts +352 -352
- package/src/lib/shiki.ts +179 -179
- package/src/vite/dev-server.ts +13 -10
- package/src/vite/pagefind-dev-stub.ts +17 -0
- package/src/vite/plugin-search.ts +13 -1
package/dist/cli/cli.js
CHANGED
|
@@ -131,7 +131,7 @@ import { stat } from "node:fs/promises";
|
|
|
131
131
|
var fileExists;
|
|
132
132
|
var init_file_exists = __esm({
|
|
133
133
|
"src/config/file-exists.ts"() {
|
|
134
|
-
fileExists = (
|
|
134
|
+
fileExists = (path35) => stat(path35).then(() => true).catch(() => false);
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
137
|
|
|
@@ -3590,7 +3590,7 @@ __export(llms_exports, {
|
|
|
3590
3590
|
generateLlmsTxtFiles: () => generateLlmsTxtFiles
|
|
3591
3591
|
});
|
|
3592
3592
|
import { writeFile as writeFile4 } from "node:fs/promises";
|
|
3593
|
-
import
|
|
3593
|
+
import path22 from "node:path";
|
|
3594
3594
|
import colors6 from "picocolors";
|
|
3595
3595
|
async function generateLlmsTxtFiles({
|
|
3596
3596
|
markdownFileInfos,
|
|
@@ -3625,7 +3625,7 @@ async function generateLlmsTxtFiles({
|
|
|
3625
3625
|
}
|
|
3626
3626
|
}
|
|
3627
3627
|
const llmsTxt2 = llmsTxtParts.join("\n");
|
|
3628
|
-
await writeFile4(
|
|
3628
|
+
await writeFile4(path22.join(baseOutputDir, "llms.txt"), llmsTxt2, "utf-8");
|
|
3629
3629
|
if (process.env.APITOGO_JSON_ONLY !== "1") {
|
|
3630
3630
|
console.log(colors6.blue("\u2713 generated llms.txt"));
|
|
3631
3631
|
}
|
|
@@ -3653,7 +3653,7 @@ ${info.content}
|
|
|
3653
3653
|
}
|
|
3654
3654
|
const llmsFull = llmsFullParts.join("\n");
|
|
3655
3655
|
await writeFile4(
|
|
3656
|
-
|
|
3656
|
+
path22.join(baseOutputDir, "llms-full.txt"),
|
|
3657
3657
|
llmsFull,
|
|
3658
3658
|
"utf-8"
|
|
3659
3659
|
);
|
|
@@ -3674,11 +3674,11 @@ import { hideBin } from "yargs/helpers";
|
|
|
3674
3674
|
import yargs from "yargs/yargs";
|
|
3675
3675
|
|
|
3676
3676
|
// src/cli/build/handler.ts
|
|
3677
|
-
import
|
|
3677
|
+
import path26 from "node:path";
|
|
3678
3678
|
|
|
3679
3679
|
// src/vite/build.ts
|
|
3680
3680
|
import { mkdir as mkdir5, readFile as readFile3, rename, rm as rm2, writeFile as writeFile5 } from "node:fs/promises";
|
|
3681
|
-
import
|
|
3681
|
+
import path24 from "node:path";
|
|
3682
3682
|
import { build as esbuild } from "esbuild";
|
|
3683
3683
|
import { build as viteBuild, mergeConfig as mergeConfig3 } from "vite";
|
|
3684
3684
|
|
|
@@ -3811,7 +3811,7 @@ init_invariant();
|
|
|
3811
3811
|
init_joinUrl();
|
|
3812
3812
|
|
|
3813
3813
|
// src/vite/config.ts
|
|
3814
|
-
import
|
|
3814
|
+
import path19 from "node:path";
|
|
3815
3815
|
import dotenv from "dotenv";
|
|
3816
3816
|
import colors4 from "picocolors";
|
|
3817
3817
|
import {
|
|
@@ -3822,7 +3822,7 @@ import {
|
|
|
3822
3822
|
// package.json
|
|
3823
3823
|
var package_default = {
|
|
3824
3824
|
name: "@lukoweb/apitogo",
|
|
3825
|
-
version: "0.1.
|
|
3825
|
+
version: "0.1.20",
|
|
3826
3826
|
type: "module",
|
|
3827
3827
|
sideEffects: [
|
|
3828
3828
|
"**/*.css",
|
|
@@ -4533,14 +4533,14 @@ var flattenAllOf = (schema2) => {
|
|
|
4533
4533
|
};
|
|
4534
4534
|
|
|
4535
4535
|
// src/lib/util/traverse.ts
|
|
4536
|
-
var traverse = (specification, transform,
|
|
4537
|
-
const transformed = transform(specification,
|
|
4536
|
+
var traverse = (specification, transform, path35 = []) => {
|
|
4537
|
+
const transformed = transform(specification, path35);
|
|
4538
4538
|
if (typeof transformed !== "object" || transformed === null) {
|
|
4539
4539
|
return transformed;
|
|
4540
4540
|
}
|
|
4541
4541
|
const result = Array.isArray(transformed) ? [] : {};
|
|
4542
4542
|
for (const [key, value] of Object.entries(transformed)) {
|
|
4543
|
-
const currentPath = [...
|
|
4543
|
+
const currentPath = [...path35, key];
|
|
4544
4544
|
if (Array.isArray(value)) {
|
|
4545
4545
|
result[key] = value.map(
|
|
4546
4546
|
(item, index) => typeof item === "object" && item != null ? traverse(item, transform, [...currentPath, index.toString()]) : item
|
|
@@ -4568,9 +4568,9 @@ var resolveLocalRef = (schema2, ref) => {
|
|
|
4568
4568
|
if (schemaCache?.has(ref)) {
|
|
4569
4569
|
return schemaCache.get(ref);
|
|
4570
4570
|
}
|
|
4571
|
-
const
|
|
4571
|
+
const path35 = ref.split("/").slice(1);
|
|
4572
4572
|
let current = schema2;
|
|
4573
|
-
for (const segment of
|
|
4573
|
+
for (const segment of path35) {
|
|
4574
4574
|
if (!current || typeof current !== "object") {
|
|
4575
4575
|
current = null;
|
|
4576
4576
|
}
|
|
@@ -4589,7 +4589,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4589
4589
|
}
|
|
4590
4590
|
const cloned = structuredClone(schema2);
|
|
4591
4591
|
const visited = /* @__PURE__ */ new Set();
|
|
4592
|
-
const resolve = async (current,
|
|
4592
|
+
const resolve = async (current, path35) => {
|
|
4593
4593
|
if (isIndexableObject(current)) {
|
|
4594
4594
|
if (visited.has(current)) {
|
|
4595
4595
|
return CIRCULAR_REF;
|
|
@@ -4597,7 +4597,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4597
4597
|
visited.add(current);
|
|
4598
4598
|
if (Array.isArray(current)) {
|
|
4599
4599
|
for (let index = 0; index < current.length; index++) {
|
|
4600
|
-
current[index] = await resolve(current[index], `${
|
|
4600
|
+
current[index] = await resolve(current[index], `${path35}/${index}`);
|
|
4601
4601
|
}
|
|
4602
4602
|
} else {
|
|
4603
4603
|
if ("$ref" in current && typeof current.$ref === "string") {
|
|
@@ -4608,13 +4608,13 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4608
4608
|
for (const resolver of resolvers) {
|
|
4609
4609
|
const resolved = await resolver($ref);
|
|
4610
4610
|
if (resolved) {
|
|
4611
|
-
result2 = await resolve(resolved,
|
|
4611
|
+
result2 = await resolve(resolved, path35);
|
|
4612
4612
|
break;
|
|
4613
4613
|
}
|
|
4614
4614
|
}
|
|
4615
4615
|
if (result2 === void 0) {
|
|
4616
4616
|
const resolved = await resolveLocalRef(cloned, $ref);
|
|
4617
|
-
result2 = await resolve(resolved,
|
|
4617
|
+
result2 = await resolve(resolved, path35);
|
|
4618
4618
|
}
|
|
4619
4619
|
if (hasSiblings) {
|
|
4620
4620
|
if (result2 === CIRCULAR_REF) {
|
|
@@ -4627,7 +4627,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4627
4627
|
return result2;
|
|
4628
4628
|
}
|
|
4629
4629
|
for (const key in current) {
|
|
4630
|
-
current[key] = await resolve(current[key], `${
|
|
4630
|
+
current[key] = await resolve(current[key], `${path35}/${key}`);
|
|
4631
4631
|
}
|
|
4632
4632
|
}
|
|
4633
4633
|
visited.delete(current);
|
|
@@ -4666,9 +4666,9 @@ var upgradeSchema = (schema2) => {
|
|
|
4666
4666
|
}
|
|
4667
4667
|
return sub;
|
|
4668
4668
|
});
|
|
4669
|
-
schema2 = traverse(schema2, (sub,
|
|
4669
|
+
schema2 = traverse(schema2, (sub, path35) => {
|
|
4670
4670
|
if (sub.example !== void 0) {
|
|
4671
|
-
if (isSchemaPath(
|
|
4671
|
+
if (isSchemaPath(path35 ?? [])) {
|
|
4672
4672
|
sub.examples = [sub.example];
|
|
4673
4673
|
} else {
|
|
4674
4674
|
sub.examples = {
|
|
@@ -4681,11 +4681,11 @@ var upgradeSchema = (schema2) => {
|
|
|
4681
4681
|
}
|
|
4682
4682
|
return sub;
|
|
4683
4683
|
});
|
|
4684
|
-
schema2 = traverse(schema2, (schema3,
|
|
4684
|
+
schema2 = traverse(schema2, (schema3, path35) => {
|
|
4685
4685
|
if (schema3.type === "object" && schema3.properties !== void 0) {
|
|
4686
|
-
const parentPath =
|
|
4686
|
+
const parentPath = path35?.slice(0, -1);
|
|
4687
4687
|
const isMultipart = parentPath?.some((segment, index) => {
|
|
4688
|
-
return segment === "content" &&
|
|
4688
|
+
return segment === "content" && path35?.[index + 1] === "multipart/form-data";
|
|
4689
4689
|
});
|
|
4690
4690
|
if (isMultipart) {
|
|
4691
4691
|
const entries = Object.entries(schema3.properties);
|
|
@@ -4699,8 +4699,8 @@ var upgradeSchema = (schema2) => {
|
|
|
4699
4699
|
}
|
|
4700
4700
|
return schema3;
|
|
4701
4701
|
});
|
|
4702
|
-
schema2 = traverse(schema2, (schema3,
|
|
4703
|
-
if (
|
|
4702
|
+
schema2 = traverse(schema2, (schema3, path35) => {
|
|
4703
|
+
if (path35?.includes("content") && path35.includes("application/octet-stream")) {
|
|
4704
4704
|
return {};
|
|
4705
4705
|
}
|
|
4706
4706
|
if (schema3.type === "string" && schema3.format === "binary") {
|
|
@@ -4726,11 +4726,11 @@ var upgradeSchema = (schema2) => {
|
|
|
4726
4726
|
}
|
|
4727
4727
|
return sub;
|
|
4728
4728
|
});
|
|
4729
|
-
schema2 = traverse(schema2, (schema3,
|
|
4729
|
+
schema2 = traverse(schema2, (schema3, path35) => {
|
|
4730
4730
|
if (schema3.type === "string" && schema3.format === "byte") {
|
|
4731
|
-
const parentPath =
|
|
4731
|
+
const parentPath = path35?.slice(0, -1);
|
|
4732
4732
|
const contentMediaType = parentPath?.find(
|
|
4733
|
-
(_, index) =>
|
|
4733
|
+
(_, index) => path35?.[index - 1] === "content"
|
|
4734
4734
|
);
|
|
4735
4735
|
return {
|
|
4736
4736
|
type: "string",
|
|
@@ -4742,7 +4742,7 @@ var upgradeSchema = (schema2) => {
|
|
|
4742
4742
|
});
|
|
4743
4743
|
return schema2;
|
|
4744
4744
|
};
|
|
4745
|
-
function isSchemaPath(
|
|
4745
|
+
function isSchemaPath(path35) {
|
|
4746
4746
|
const schemaLocations = [
|
|
4747
4747
|
["components", "schemas"],
|
|
4748
4748
|
"properties",
|
|
@@ -4755,10 +4755,10 @@ function isSchemaPath(path33) {
|
|
|
4755
4755
|
];
|
|
4756
4756
|
return schemaLocations.some((location) => {
|
|
4757
4757
|
if (Array.isArray(location)) {
|
|
4758
|
-
return location.every((segment, index) =>
|
|
4758
|
+
return location.every((segment, index) => path35[index] === segment);
|
|
4759
4759
|
}
|
|
4760
|
-
return
|
|
4761
|
-
}) ||
|
|
4760
|
+
return path35.includes(location);
|
|
4761
|
+
}) || path35.includes("schema") || path35.some((segment) => segment.endsWith("Schema"));
|
|
4762
4762
|
}
|
|
4763
4763
|
|
|
4764
4764
|
// src/lib/oas/parser/index.ts
|
|
@@ -4840,13 +4840,13 @@ var OPENAPI_PROPS = /* @__PURE__ */ new Set([
|
|
|
4840
4840
|
"anyOf",
|
|
4841
4841
|
"oneOf"
|
|
4842
4842
|
]);
|
|
4843
|
-
var handleCircularRefs = (obj, currentPath = /* @__PURE__ */ new WeakSet(), refs = /* @__PURE__ */ new WeakMap(),
|
|
4843
|
+
var handleCircularRefs = (obj, currentPath = /* @__PURE__ */ new WeakSet(), refs = /* @__PURE__ */ new WeakMap(), path35 = [], currentRefPaths = /* @__PURE__ */ new Set()) => {
|
|
4844
4844
|
if (obj === null || typeof obj !== "object") return obj;
|
|
4845
4845
|
const refPath = obj.__$ref;
|
|
4846
4846
|
const isCircular = currentPath.has(obj) || typeof refPath === "string" && currentRefPaths.has(refPath);
|
|
4847
4847
|
if (isCircular) {
|
|
4848
4848
|
if (typeof refPath === "string") return SCHEMA_REF_PREFIX + refPath;
|
|
4849
|
-
const circularProp =
|
|
4849
|
+
const circularProp = path35.find((p) => !OPENAPI_PROPS.has(p)) || path35[0];
|
|
4850
4850
|
return [CIRCULAR_REF, circularProp].filter(Boolean).join(":");
|
|
4851
4851
|
}
|
|
4852
4852
|
if (refs.has(obj)) return refs.get(obj);
|
|
@@ -4856,7 +4856,7 @@ var handleCircularRefs = (obj, currentPath = /* @__PURE__ */ new WeakSet(), refs
|
|
|
4856
4856
|
value,
|
|
4857
4857
|
currentPath,
|
|
4858
4858
|
refs,
|
|
4859
|
-
[...
|
|
4859
|
+
[...path35, key],
|
|
4860
4860
|
currentRefPaths
|
|
4861
4861
|
);
|
|
4862
4862
|
const result = Array.isArray(obj) ? obj.map((item, i) => recurse(item, i.toString())) : Object.fromEntries(
|
|
@@ -4891,7 +4891,7 @@ var resolveExtensions = (obj) => Object.fromEntries(
|
|
|
4891
4891
|
var getAllTags = (schema2) => {
|
|
4892
4892
|
const rootTags = schema2.tags ?? [];
|
|
4893
4893
|
const operations = Object.values(schema2.paths ?? {}).flatMap(
|
|
4894
|
-
(
|
|
4894
|
+
(path35) => HttpMethods.map((k) => path35?.[k]).filter((op) => op != null)
|
|
4895
4895
|
);
|
|
4896
4896
|
const operationTags = new Set(operations.flatMap((op) => op.tags ?? []));
|
|
4897
4897
|
const hasUntaggedOperations = operations.some(
|
|
@@ -4946,7 +4946,7 @@ var getAllSlugs = (ops, schemaTags = []) => {
|
|
|
4946
4946
|
var getOperationSlugKey = (op) => [op.path, op.method, op.operationId, op.summary].filter(Boolean).join("-");
|
|
4947
4947
|
var getAllOperations = (paths) => {
|
|
4948
4948
|
const operations = Object.entries(paths ?? {}).flatMap(
|
|
4949
|
-
([
|
|
4949
|
+
([path35, value]) => HttpMethods.flatMap((method) => {
|
|
4950
4950
|
if (!value?.[method]) return [];
|
|
4951
4951
|
const operation = value[method];
|
|
4952
4952
|
const pathParameters = value.parameters ?? [];
|
|
@@ -4966,7 +4966,7 @@ var getAllOperations = (paths) => {
|
|
|
4966
4966
|
return {
|
|
4967
4967
|
...operation,
|
|
4968
4968
|
method,
|
|
4969
|
-
path:
|
|
4969
|
+
path: path35,
|
|
4970
4970
|
parameters,
|
|
4971
4971
|
servers,
|
|
4972
4972
|
tags: operation.tags ?? []
|
|
@@ -5324,8 +5324,8 @@ var Schema = builder.objectRef("Schema").implement({
|
|
|
5324
5324
|
}),
|
|
5325
5325
|
paths: t.field({
|
|
5326
5326
|
type: [PathItem],
|
|
5327
|
-
resolve: (root) => Object.entries(root.paths ?? {}).map(([
|
|
5328
|
-
path:
|
|
5327
|
+
resolve: (root) => Object.entries(root.paths ?? {}).map(([path35, value]) => ({
|
|
5328
|
+
path: path35,
|
|
5329
5329
|
// biome-ignore lint/style/noNonNullAssertion: value is guaranteed to be defined
|
|
5330
5330
|
methods: Object.keys(value)
|
|
5331
5331
|
}))
|
|
@@ -5472,7 +5472,7 @@ init_joinUrl();
|
|
|
5472
5472
|
|
|
5473
5473
|
// src/vite/api/schema-codegen.ts
|
|
5474
5474
|
var unescapeJsonPointer = (uri) => decodeURIComponent(uri.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
5475
|
-
var getSegmentsFromPath = (
|
|
5475
|
+
var getSegmentsFromPath = (path35) => path35.split("/").slice(1).map(unescapeJsonPointer);
|
|
5476
5476
|
var createLocalRefMap = (obj) => {
|
|
5477
5477
|
const refMap = /* @__PURE__ */ new Map();
|
|
5478
5478
|
const siblingsMap = /* @__PURE__ */ new Map();
|
|
@@ -5503,16 +5503,16 @@ var replaceMarkers = (code, mergedRefs) => code.replace(/"__refMap:(.*?)"/g, '__
|
|
|
5503
5503
|
/"__refMap\+Siblings:(.*?)"/g,
|
|
5504
5504
|
(_, key) => mergedRefs.get(key) ?? `__refMap["${key}"]`
|
|
5505
5505
|
);
|
|
5506
|
-
var lookup = (schema2,
|
|
5507
|
-
const parts = getSegmentsFromPath(
|
|
5506
|
+
var lookup = (schema2, path35, filePath) => {
|
|
5507
|
+
const parts = getSegmentsFromPath(path35);
|
|
5508
5508
|
let val = schema2;
|
|
5509
5509
|
for (const part of parts) {
|
|
5510
5510
|
while (val.$ref?.startsWith("#/")) {
|
|
5511
|
-
val = val.$ref ===
|
|
5511
|
+
val = val.$ref === path35 ? val : lookup(schema2, val.$ref, filePath);
|
|
5512
5512
|
}
|
|
5513
5513
|
if (val[part] === void 0) {
|
|
5514
5514
|
throw new Error(
|
|
5515
|
-
`Error in ${filePath ?? "code generation"}: Could not find path segment ${part} in path: ${
|
|
5515
|
+
`Error in ${filePath ?? "code generation"}: Could not find path segment ${part} in path: ${path35}`
|
|
5516
5516
|
);
|
|
5517
5517
|
}
|
|
5518
5518
|
val = val[part];
|
|
@@ -5757,8 +5757,8 @@ var SchemaManager = class {
|
|
|
5757
5757
|
}
|
|
5758
5758
|
}
|
|
5759
5759
|
};
|
|
5760
|
-
getLatestSchema = (
|
|
5761
|
-
getSchemasForPath = (
|
|
5760
|
+
getLatestSchema = (path35) => this.processedSchemas[path35]?.at(0);
|
|
5761
|
+
getSchemasForPath = (path35) => this.processedSchemas[path35];
|
|
5762
5762
|
getSchemaImports = () => Object.values(this.processedSchemas).flat().filter((s) => s.importKey);
|
|
5763
5763
|
getUrlToFilePathMap = () => {
|
|
5764
5764
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -7322,15 +7322,41 @@ var plugin_mdx_default = viteMdxPlugin;
|
|
|
7322
7322
|
|
|
7323
7323
|
// src/vite/plugin-search.ts
|
|
7324
7324
|
init_loader();
|
|
7325
|
+
import path18 from "node:path";
|
|
7326
|
+
|
|
7327
|
+
// src/vite/pagefind-dev-stub.ts
|
|
7328
|
+
import fs3 from "node:fs/promises";
|
|
7329
|
+
import path17 from "node:path";
|
|
7330
|
+
var NOT_BUILT_YET = 'throw new Error("NOT_BUILT_YET");';
|
|
7331
|
+
async function ensurePagefindDevStub(publicDir) {
|
|
7332
|
+
const pagefindPath = path17.join(publicDir, "pagefind/pagefind.js");
|
|
7333
|
+
const exists = await fs3.stat(pagefindPath).catch(() => false);
|
|
7334
|
+
if (!exists) {
|
|
7335
|
+
await fs3.mkdir(path17.dirname(pagefindPath), { recursive: true });
|
|
7336
|
+
await fs3.writeFile(pagefindPath, NOT_BUILT_YET);
|
|
7337
|
+
}
|
|
7338
|
+
}
|
|
7339
|
+
|
|
7340
|
+
// src/vite/plugin-search.ts
|
|
7325
7341
|
var viteSearchPlugin = () => {
|
|
7326
7342
|
const virtualModuleId4 = "virtual:zudoku-search-plugin";
|
|
7327
7343
|
const resolvedVirtualModuleId4 = `\0${virtualModuleId4}`;
|
|
7344
|
+
let resolvedViteConfig;
|
|
7328
7345
|
return {
|
|
7329
7346
|
name: "zudoku-search-plugin",
|
|
7347
|
+
async configResolved(config2) {
|
|
7348
|
+
resolvedViteConfig = config2;
|
|
7349
|
+
if (config2.publicDir && getCurrentConfig()?.search?.type === "pagefind") {
|
|
7350
|
+
await ensurePagefindDevStub(config2.publicDir);
|
|
7351
|
+
}
|
|
7352
|
+
},
|
|
7330
7353
|
resolveId(id) {
|
|
7331
7354
|
if (id === virtualModuleId4) {
|
|
7332
7355
|
return resolvedVirtualModuleId4;
|
|
7333
7356
|
}
|
|
7357
|
+
if (id === "/pagefind/pagefind.js" && resolvedViteConfig?.publicDir) {
|
|
7358
|
+
return path18.join(resolvedViteConfig.publicDir, "pagefind/pagefind.js");
|
|
7359
|
+
}
|
|
7334
7360
|
},
|
|
7335
7361
|
async load(id) {
|
|
7336
7362
|
if (id !== resolvedVirtualModuleId4) return;
|
|
@@ -7466,8 +7492,8 @@ function vitePlugin() {
|
|
|
7466
7492
|
}
|
|
7467
7493
|
|
|
7468
7494
|
// src/vite/config.ts
|
|
7469
|
-
var getAppClientEntryPath = () =>
|
|
7470
|
-
var getAppServerEntryPath = () =>
|
|
7495
|
+
var getAppClientEntryPath = () => path19.posix.join(getZudokuRootDir(), "src/app/entry.client.tsx");
|
|
7496
|
+
var getAppServerEntryPath = () => path19.posix.join(getZudokuRootDir(), "src/app/entry.server.tsx");
|
|
7471
7497
|
var hasLoggedCdnInfo = false;
|
|
7472
7498
|
var MEDIA_REGEX = /\.(a?png|jpe?g|gif|bmp|svg|webp|tiff|ico|webm|ogg|mp3|wav|m4a|avif|mp4)/i;
|
|
7473
7499
|
var defineEnvVars = (vars) => Object.fromEntries(
|
|
@@ -7497,7 +7523,7 @@ async function getViteConfig(dir, configEnv) {
|
|
|
7497
7523
|
);
|
|
7498
7524
|
if (ZuploEnv.isZuplo) {
|
|
7499
7525
|
dotenv.config({
|
|
7500
|
-
path:
|
|
7526
|
+
path: path19.resolve(config2.__meta.rootDir, "../.env.zuplo"),
|
|
7501
7527
|
quiet: true
|
|
7502
7528
|
});
|
|
7503
7529
|
}
|
|
@@ -7554,8 +7580,8 @@ async function getViteConfig(dir, configEnv) {
|
|
|
7554
7580
|
ssr: configEnv.isSsrBuild,
|
|
7555
7581
|
sourcemap: true,
|
|
7556
7582
|
target: "es2022",
|
|
7557
|
-
outDir:
|
|
7558
|
-
|
|
7583
|
+
outDir: path19.resolve(
|
|
7584
|
+
path19.join(
|
|
7559
7585
|
dir,
|
|
7560
7586
|
"dist",
|
|
7561
7587
|
config2.basePath ?? "",
|
|
@@ -7574,7 +7600,7 @@ async function getViteConfig(dir, configEnv) {
|
|
|
7574
7600
|
},
|
|
7575
7601
|
experimental: {
|
|
7576
7602
|
renderBuiltUrl(filename) {
|
|
7577
|
-
if (cdnUrl?.base && [".js", ".css"].includes(
|
|
7603
|
+
if (cdnUrl?.base && [".js", ".css"].includes(path19.extname(filename))) {
|
|
7578
7604
|
return joinUrl(cdnUrl.base, filename);
|
|
7579
7605
|
}
|
|
7580
7606
|
if (cdnUrl?.media && MEDIA_REGEX.test(filename)) {
|
|
@@ -7587,7 +7613,7 @@ async function getViteConfig(dir, configEnv) {
|
|
|
7587
7613
|
esbuildOptions: {
|
|
7588
7614
|
target: "es2022"
|
|
7589
7615
|
},
|
|
7590
|
-
entries: [
|
|
7616
|
+
entries: [path19.posix.join(getZudokuRootDir(), "src/{app,lib}/**")],
|
|
7591
7617
|
exclude: ["@lukoweb/apitogo"],
|
|
7592
7618
|
include: [
|
|
7593
7619
|
"react-dom/client",
|
|
@@ -7686,7 +7712,7 @@ init_package_json();
|
|
|
7686
7712
|
init_joinUrl();
|
|
7687
7713
|
import assert from "node:assert";
|
|
7688
7714
|
import { cp, mkdir as mkdir3, writeFile as writeFile3 } from "node:fs/promises";
|
|
7689
|
-
import
|
|
7715
|
+
import path20 from "node:path";
|
|
7690
7716
|
var pkgJson = getZudokuPackageJson();
|
|
7691
7717
|
function generateOutput({
|
|
7692
7718
|
config: config2,
|
|
@@ -7743,9 +7769,9 @@ async function writeOutput(dir, {
|
|
|
7743
7769
|
rewrites
|
|
7744
7770
|
}) {
|
|
7745
7771
|
const output = generateOutput({ config: config2, redirects, rewrites });
|
|
7746
|
-
const outputDir = process.env.VERCEL ?
|
|
7772
|
+
const outputDir = process.env.VERCEL ? path20.join(dir, ".vercel/output") : path20.join(dir, "dist/.output");
|
|
7747
7773
|
await mkdir3(outputDir, { recursive: true });
|
|
7748
|
-
const outputFile =
|
|
7774
|
+
const outputFile = path20.join(outputDir, "config.json");
|
|
7749
7775
|
await writeFile3(outputFile, JSON.stringify(output, null, 2), "utf-8");
|
|
7750
7776
|
if (process.env.VERCEL) {
|
|
7751
7777
|
console.log("Wrote Vercel output to", outputDir);
|
|
@@ -7757,7 +7783,7 @@ init_logger();
|
|
|
7757
7783
|
init_file_exists();
|
|
7758
7784
|
import { readFile as readFile2, rm } from "node:fs/promises";
|
|
7759
7785
|
import os from "node:os";
|
|
7760
|
-
import
|
|
7786
|
+
import path23 from "node:path";
|
|
7761
7787
|
import { pathToFileURL } from "node:url";
|
|
7762
7788
|
import { createIndex } from "pagefind";
|
|
7763
7789
|
import colors7 from "picocolors";
|
|
@@ -7799,7 +7825,7 @@ function throttle(fn) {
|
|
|
7799
7825
|
init_joinUrl();
|
|
7800
7826
|
import { createWriteStream, existsSync } from "node:fs";
|
|
7801
7827
|
import { mkdir as mkdir4 } from "node:fs/promises";
|
|
7802
|
-
import
|
|
7828
|
+
import path21 from "node:path";
|
|
7803
7829
|
import colors5 from "picocolors";
|
|
7804
7830
|
import { SitemapStream } from "sitemap";
|
|
7805
7831
|
async function generateSitemap({
|
|
@@ -7813,11 +7839,11 @@ async function generateSitemap({
|
|
|
7813
7839
|
return;
|
|
7814
7840
|
}
|
|
7815
7841
|
const sitemap = new SitemapStream({ hostname: config2.siteUrl });
|
|
7816
|
-
const outputDir =
|
|
7842
|
+
const outputDir = path21.resolve(baseOutputDir, config2.outDir ?? "");
|
|
7817
7843
|
if (!existsSync(outputDir)) {
|
|
7818
7844
|
await mkdir4(outputDir, { recursive: true });
|
|
7819
7845
|
}
|
|
7820
|
-
const sitemapOutputPath =
|
|
7846
|
+
const sitemapOutputPath = path21.join(outputDir, "sitemap.xml");
|
|
7821
7847
|
const writeStream = createWriteStream(sitemapOutputPath);
|
|
7822
7848
|
sitemap.pipe(writeStream);
|
|
7823
7849
|
let lastmod;
|
|
@@ -7847,14 +7873,14 @@ async function generateSitemap({
|
|
|
7847
7873
|
|
|
7848
7874
|
// src/vite/prerender/utils.ts
|
|
7849
7875
|
init_joinUrl();
|
|
7850
|
-
var resolveRoutePath = (
|
|
7851
|
-
const segments =
|
|
7876
|
+
var resolveRoutePath = (path35) => {
|
|
7877
|
+
const segments = path35.split("/");
|
|
7852
7878
|
if (segments.some((s) => s.startsWith(":") && !s.endsWith("?"))) {
|
|
7853
7879
|
return void 0;
|
|
7854
7880
|
}
|
|
7855
7881
|
return segments.filter((s) => !s.startsWith(":")).join("/") || void 0;
|
|
7856
7882
|
};
|
|
7857
|
-
var isSkipped = (
|
|
7883
|
+
var isSkipped = (path35) => path35.includes("*") || /^\d+$/.test(path35);
|
|
7858
7884
|
var resolveRoutes = (routes, parentPath = "") => routes.flatMap((route) => {
|
|
7859
7885
|
if (route.path && isSkipped(route.path)) return [];
|
|
7860
7886
|
const routePath = route.path ? resolveRoutePath(route.path) : void 0;
|
|
@@ -7903,12 +7929,12 @@ var prerender = async ({
|
|
|
7903
7929
|
serverConfigFilename,
|
|
7904
7930
|
writeRedirects = true
|
|
7905
7931
|
}) => {
|
|
7906
|
-
const distDir =
|
|
7932
|
+
const distDir = path23.join(dir, "dist", basePath);
|
|
7907
7933
|
const serverConfigPath = pathToFileURL(
|
|
7908
|
-
|
|
7934
|
+
path23.join(distDir, "server", serverConfigFilename)
|
|
7909
7935
|
).href;
|
|
7910
7936
|
const entryServerPath = pathToFileURL(
|
|
7911
|
-
|
|
7937
|
+
path23.join(distDir, "server/entry.server.js")
|
|
7912
7938
|
).href;
|
|
7913
7939
|
const rawConfig = await import(serverConfigPath).then(
|
|
7914
7940
|
(m) => m.default
|
|
@@ -7993,7 +8019,7 @@ var prerender = async ({
|
|
|
7993
8019
|
})
|
|
7994
8020
|
);
|
|
7995
8021
|
const pagefindWriteResult = await pagefindIndex?.writeFiles({
|
|
7996
|
-
outputPath:
|
|
8022
|
+
outputPath: path23.join(distDir, "pagefind")
|
|
7997
8023
|
});
|
|
7998
8024
|
const seconds = ((performance.now() - start) / 1e3).toFixed(1);
|
|
7999
8025
|
const message = `\u2713 finished prerendering ${paths.length} routes in ${seconds} seconds using ${maxThreads} workers`;
|
|
@@ -8025,7 +8051,7 @@ var prerender = async ({
|
|
|
8025
8051
|
const { generateLlmsTxtFiles: generateLlmsTxtFiles2 } = await Promise.resolve().then(() => (init_llms(), llms_exports));
|
|
8026
8052
|
const docsConfig = DocsConfigSchema2.parse(config2.docs);
|
|
8027
8053
|
const llmsConfig = docsConfig.llms ?? {};
|
|
8028
|
-
const markdownInfoPath =
|
|
8054
|
+
const markdownInfoPath = path23.join(
|
|
8029
8055
|
dir,
|
|
8030
8056
|
"node_modules/.apitogo/markdown-info.json"
|
|
8031
8057
|
);
|
|
@@ -8116,7 +8142,7 @@ async function runBuild(options) {
|
|
|
8116
8142
|
html,
|
|
8117
8143
|
basePath: config2.basePath
|
|
8118
8144
|
});
|
|
8119
|
-
await rm2(
|
|
8145
|
+
await rm2(path24.join(clientOutDir, "index.html"), { force: true });
|
|
8120
8146
|
} else {
|
|
8121
8147
|
await runPrerender({
|
|
8122
8148
|
dir,
|
|
@@ -8140,7 +8166,7 @@ var runPrerender = async (options) => {
|
|
|
8140
8166
|
serverConfigFilename,
|
|
8141
8167
|
writeRedirects: process.env.VERCEL === void 0
|
|
8142
8168
|
});
|
|
8143
|
-
const indexHtml =
|
|
8169
|
+
const indexHtml = path24.join(clientOutDir, "index.html");
|
|
8144
8170
|
if (!workerResults.find((r) => r.outputPath === indexHtml)) {
|
|
8145
8171
|
await writeFile5(indexHtml, html, "utf-8");
|
|
8146
8172
|
}
|
|
@@ -8150,15 +8176,15 @@ var runPrerender = async (options) => {
|
|
|
8150
8176
|
for (const statusPage of statusPages) {
|
|
8151
8177
|
await rename(
|
|
8152
8178
|
statusPage,
|
|
8153
|
-
|
|
8179
|
+
path24.join(dir, DIST_DIR, path24.basename(statusPage))
|
|
8154
8180
|
);
|
|
8155
8181
|
}
|
|
8156
8182
|
await rm2(serverOutDir, { recursive: true, force: true });
|
|
8157
8183
|
if (process.env.VERCEL) {
|
|
8158
|
-
await mkdir5(
|
|
8184
|
+
await mkdir5(path24.join(dir, ".vercel/output/static"), { recursive: true });
|
|
8159
8185
|
await rename(
|
|
8160
|
-
|
|
8161
|
-
|
|
8186
|
+
path24.join(dir, DIST_DIR),
|
|
8187
|
+
path24.join(dir, ".vercel/output/static")
|
|
8162
8188
|
);
|
|
8163
8189
|
}
|
|
8164
8190
|
await writeOutput(dir, {
|
|
@@ -8168,7 +8194,7 @@ var runPrerender = async (options) => {
|
|
|
8168
8194
|
});
|
|
8169
8195
|
if (ZuploEnv.isZuplo && issuer) {
|
|
8170
8196
|
await writeFile5(
|
|
8171
|
-
|
|
8197
|
+
path24.join(dir, DIST_DIR, ".output/zuplo.json"),
|
|
8172
8198
|
JSON.stringify({ issuer }, null, 2),
|
|
8173
8199
|
"utf-8"
|
|
8174
8200
|
);
|
|
@@ -8180,10 +8206,10 @@ var runPrerender = async (options) => {
|
|
|
8180
8206
|
};
|
|
8181
8207
|
var bundleSSREntry = async (options) => {
|
|
8182
8208
|
const { dir, adapter, serverOutDir, serverConfigFilename, html, basePath } = options;
|
|
8183
|
-
const tempEntryPath =
|
|
8209
|
+
const tempEntryPath = path24.join(dir, "__ssr-entry.ts");
|
|
8184
8210
|
const packageRoot = getZudokuRootDir();
|
|
8185
8211
|
const templateContent = await readFile3(
|
|
8186
|
-
|
|
8212
|
+
path24.join(packageRoot, "src/vite/ssr-templates", `${adapter}.ts`),
|
|
8187
8213
|
"utf-8"
|
|
8188
8214
|
);
|
|
8189
8215
|
const entryContent = templateContent.replace('"__TEMPLATE__"', JSON.stringify(html)).replace('"__CONFIG_FILE__"', JSON.stringify(`./${serverConfigFilename}`)).replace(
|
|
@@ -8198,9 +8224,9 @@ var bundleSSREntry = async (options) => {
|
|
|
8198
8224
|
platform: adapter === "node" ? "node" : "neutral",
|
|
8199
8225
|
target: "es2022",
|
|
8200
8226
|
format: "esm",
|
|
8201
|
-
outfile:
|
|
8227
|
+
outfile: path24.join(serverOutDir, "entry.js"),
|
|
8202
8228
|
external: ["./entry.server.js", `./${serverConfigFilename}`],
|
|
8203
|
-
nodePaths: [
|
|
8229
|
+
nodePaths: [path24.join(packageRoot, "node_modules")],
|
|
8204
8230
|
banner: { js: "// Bundled SSR entry" }
|
|
8205
8231
|
});
|
|
8206
8232
|
} finally {
|
|
@@ -8221,6 +8247,7 @@ var VERSION_CHECK_FILE = "version.json";
|
|
|
8221
8247
|
var SENTRY_DSN = void 0;
|
|
8222
8248
|
var MAX_WAIT_PENDING_TIME_MS = 1e3;
|
|
8223
8249
|
var POST_HOG_CAPTURE_KEY = void 0;
|
|
8250
|
+
var DEPLOY_SERVER_API_KEY = "qRVLTP22TFStdN6";
|
|
8224
8251
|
|
|
8225
8252
|
// src/cli/common/output.ts
|
|
8226
8253
|
function printDiagnosticsToConsole(message) {
|
|
@@ -8254,11 +8281,11 @@ function textOrJson(text) {
|
|
|
8254
8281
|
init_package_json();
|
|
8255
8282
|
|
|
8256
8283
|
// src/cli/preview/handler.ts
|
|
8257
|
-
import
|
|
8284
|
+
import path25 from "node:path";
|
|
8258
8285
|
import { preview as vitePreview } from "vite";
|
|
8259
8286
|
var DEFAULT_PREVIEW_PORT = 4e3;
|
|
8260
8287
|
async function preview(argv) {
|
|
8261
|
-
const dir =
|
|
8288
|
+
const dir = path25.resolve(process.cwd(), argv.dir);
|
|
8262
8289
|
const viteConfig = await getViteConfig(dir, {
|
|
8263
8290
|
command: "serve",
|
|
8264
8291
|
mode: "production",
|
|
@@ -8299,7 +8326,7 @@ async function build(argv) {
|
|
|
8299
8326
|
printDiagnosticsToConsole("");
|
|
8300
8327
|
printDiagnosticsToConsole("");
|
|
8301
8328
|
}
|
|
8302
|
-
const dir =
|
|
8329
|
+
const dir = path26.resolve(process.cwd(), argv.dir);
|
|
8303
8330
|
try {
|
|
8304
8331
|
await runBuild({
|
|
8305
8332
|
dir,
|
|
@@ -8459,7 +8486,7 @@ var build_default = {
|
|
|
8459
8486
|
// src/cli/configure-github-workflow/handler.ts
|
|
8460
8487
|
import { constants } from "node:fs";
|
|
8461
8488
|
import { access, mkdir as mkdir6, writeFile as writeFile6 } from "node:fs/promises";
|
|
8462
|
-
import
|
|
8489
|
+
import path27 from "node:path";
|
|
8463
8490
|
var APITOGO_DEPLOY_WORKFLOW_YAML = `name: Build and Deploy
|
|
8464
8491
|
|
|
8465
8492
|
on:
|
|
@@ -8469,11 +8496,12 @@ on:
|
|
|
8469
8496
|
pull_request:
|
|
8470
8497
|
branches:
|
|
8471
8498
|
- main
|
|
8499
|
+
types: [opened, synchronize, reopened, closed]
|
|
8472
8500
|
workflow_dispatch:
|
|
8473
8501
|
|
|
8474
8502
|
jobs:
|
|
8475
8503
|
preview:
|
|
8476
|
-
if: github.event_name == 'pull_request'
|
|
8504
|
+
if: github.event_name == 'pull_request' && github.event.action != 'closed'
|
|
8477
8505
|
runs-on: ubuntu-latest
|
|
8478
8506
|
|
|
8479
8507
|
environment:
|
|
@@ -8520,6 +8548,23 @@ jobs:
|
|
|
8520
8548
|
|
|
8521
8549
|
echo "url=$URL" >> "$GITHUB_OUTPUT"
|
|
8522
8550
|
|
|
8551
|
+
cleanup-preview:
|
|
8552
|
+
if: github.event_name == 'pull_request' && github.event.action == 'closed'
|
|
8553
|
+
runs-on: ubuntu-latest
|
|
8554
|
+
|
|
8555
|
+
steps:
|
|
8556
|
+
- name: Install APIToGo CLI
|
|
8557
|
+
run: npm install -g @lukoweb/apitogo@latest
|
|
8558
|
+
|
|
8559
|
+
- name: Remove preview deployment
|
|
8560
|
+
env:
|
|
8561
|
+
APITOGO_TOKEN: \${{ secrets.APITOGO_TOKEN }}
|
|
8562
|
+
shell: bash
|
|
8563
|
+
run: |
|
|
8564
|
+
ENV_NAME=preview-pr-\${{ github.event.pull_request.number }}
|
|
8565
|
+
|
|
8566
|
+
apitogo remove --deployment-token="$APITOGO_TOKEN" --env=$ENV_NAME --json-only
|
|
8567
|
+
|
|
8523
8568
|
production:
|
|
8524
8569
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
8525
8570
|
runs-on: ubuntu-latest
|
|
@@ -8552,9 +8597,9 @@ jobs:
|
|
|
8552
8597
|
run: apitogo deploy --deployment-token="$APITOGO_TOKEN" --json-only
|
|
8553
8598
|
`;
|
|
8554
8599
|
async function configureGithubWorkflow(argv) {
|
|
8555
|
-
const dir =
|
|
8556
|
-
const workflowDir =
|
|
8557
|
-
const workflowPath =
|
|
8600
|
+
const dir = path27.resolve(process.cwd(), argv.dir);
|
|
8601
|
+
const workflowDir = path27.join(dir, ".github", "workflows");
|
|
8602
|
+
const workflowPath = path27.join(workflowDir, "apitogo-deploy.yml");
|
|
8558
8603
|
try {
|
|
8559
8604
|
try {
|
|
8560
8605
|
await access(workflowPath, constants.F_OK);
|
|
@@ -8600,11 +8645,18 @@ var configure_github_workflow_default = {
|
|
|
8600
8645
|
init_logger();
|
|
8601
8646
|
function isDeployJsonOnlyArgv() {
|
|
8602
8647
|
const args = process.argv;
|
|
8603
|
-
|
|
8604
|
-
|
|
8648
|
+
let cmdIdx = -1;
|
|
8649
|
+
for (const cmd of ["deploy", "remove"]) {
|
|
8650
|
+
const i = args.indexOf(cmd);
|
|
8651
|
+
if (i !== -1) {
|
|
8652
|
+
cmdIdx = i;
|
|
8653
|
+
break;
|
|
8654
|
+
}
|
|
8655
|
+
}
|
|
8656
|
+
if (cmdIdx === -1) {
|
|
8605
8657
|
return false;
|
|
8606
8658
|
}
|
|
8607
|
-
return args.slice(
|
|
8659
|
+
return args.slice(cmdIdx).some((a) => a === "--json-only" || a.startsWith("--json-only="));
|
|
8608
8660
|
}
|
|
8609
8661
|
function isJsonOnlyDeployEnv() {
|
|
8610
8662
|
return process.env.APITOGO_JSON_ONLY === "1";
|
|
@@ -8620,15 +8672,14 @@ function applyJsonOnlyDeployQuietMode() {
|
|
|
8620
8672
|
|
|
8621
8673
|
// src/cli/deploy/handler.ts
|
|
8622
8674
|
import { access as access2, readFile as readFile4 } from "node:fs/promises";
|
|
8623
|
-
import
|
|
8675
|
+
import path28 from "node:path";
|
|
8624
8676
|
import { create as createTar } from "tar";
|
|
8625
|
-
var DEPLOY_ENDPOINT = "https://
|
|
8626
|
-
var DEPLOY_API_KEY = "qRVLTP22TFStdN6";
|
|
8677
|
+
var DEPLOY_ENDPOINT = "https://deploy-server-dotnet2-b3fkcaaraydbckfe.canadacentral-01.azurewebsites.net/deploy";
|
|
8627
8678
|
var ARCHIVE_NAME = "dist.tgz";
|
|
8628
8679
|
var createDeploymentArchive = async (dir) => {
|
|
8629
|
-
const distDir =
|
|
8680
|
+
const distDir = path28.join(dir, "dist");
|
|
8630
8681
|
await access2(distDir);
|
|
8631
|
-
const archivePath =
|
|
8682
|
+
const archivePath = path28.join(dir, ARCHIVE_NAME);
|
|
8632
8683
|
await createTar(
|
|
8633
8684
|
{
|
|
8634
8685
|
cwd: dir,
|
|
@@ -8642,7 +8693,7 @@ var createDeploymentArchive = async (dir) => {
|
|
|
8642
8693
|
};
|
|
8643
8694
|
async function deploy(argv) {
|
|
8644
8695
|
await build({ ...argv, preview: void 0 });
|
|
8645
|
-
const dir =
|
|
8696
|
+
const dir = path28.resolve(process.cwd(), argv.dir);
|
|
8646
8697
|
const deploymentToken = argv.deploymentToken?.trim() || process.env.npm_config_deployment_token?.trim();
|
|
8647
8698
|
const env = argv.env?.trim() || process.env.npm_config_env?.trim() || "production";
|
|
8648
8699
|
try {
|
|
@@ -8655,7 +8706,7 @@ async function deploy(argv) {
|
|
|
8655
8706
|
const archivePath = await createDeploymentArchive(dir);
|
|
8656
8707
|
if (!isJsonOnlyDeployEnv()) {
|
|
8657
8708
|
printDiagnosticsToConsole(
|
|
8658
|
-
`Uploading ${
|
|
8709
|
+
`Uploading ${path28.basename(archivePath)} to ${env}...`
|
|
8659
8710
|
);
|
|
8660
8711
|
}
|
|
8661
8712
|
const archiveBuffer = await readFile4(archivePath);
|
|
@@ -8663,7 +8714,7 @@ async function deploy(argv) {
|
|
|
8663
8714
|
formData.append(
|
|
8664
8715
|
"file",
|
|
8665
8716
|
new Blob([archiveBuffer], { type: "application/gzip" }),
|
|
8666
|
-
|
|
8717
|
+
path28.basename(archivePath)
|
|
8667
8718
|
);
|
|
8668
8719
|
formData.append("deploymentToken", deploymentToken);
|
|
8669
8720
|
formData.append("env", env);
|
|
@@ -8674,7 +8725,7 @@ async function deploy(argv) {
|
|
|
8674
8725
|
const response = await fetch(deployUrl, {
|
|
8675
8726
|
method: "POST",
|
|
8676
8727
|
headers: {
|
|
8677
|
-
"x-api-key":
|
|
8728
|
+
"x-api-key": DEPLOY_SERVER_API_KEY
|
|
8678
8729
|
},
|
|
8679
8730
|
body: formData
|
|
8680
8731
|
});
|
|
@@ -8748,14 +8799,14 @@ var deploy_default = {
|
|
|
8748
8799
|
|
|
8749
8800
|
// src/cli/dev/handler.ts
|
|
8750
8801
|
init_joinUrl();
|
|
8751
|
-
import
|
|
8802
|
+
import path31 from "node:path";
|
|
8752
8803
|
|
|
8753
8804
|
// src/vite/dev-server.ts
|
|
8754
8805
|
init_logger();
|
|
8755
|
-
import
|
|
8806
|
+
import fs4 from "node:fs/promises";
|
|
8756
8807
|
import http from "node:http";
|
|
8757
8808
|
import https from "node:https";
|
|
8758
|
-
import
|
|
8809
|
+
import path30 from "node:path";
|
|
8759
8810
|
import { createHttpTerminator } from "http-terminator";
|
|
8760
8811
|
import {
|
|
8761
8812
|
createServer as createViteServer,
|
|
@@ -8788,7 +8839,7 @@ init_loader();
|
|
|
8788
8839
|
// src/vite/pagefind-dev-index.ts
|
|
8789
8840
|
init_invariant();
|
|
8790
8841
|
init_joinUrl();
|
|
8791
|
-
import
|
|
8842
|
+
import path29 from "node:path";
|
|
8792
8843
|
import { createIndex as createIndex2 } from "pagefind";
|
|
8793
8844
|
import { isRunnableDevEnvironment } from "vite";
|
|
8794
8845
|
async function* buildPagefindDevIndex(vite, config2) {
|
|
@@ -8841,7 +8892,7 @@ async function* buildPagefindDevIndex(vite, config2) {
|
|
|
8841
8892
|
path: urlPath
|
|
8842
8893
|
};
|
|
8843
8894
|
}
|
|
8844
|
-
const outputPath =
|
|
8895
|
+
const outputPath = path29.join(vite.config.publicDir, "pagefind");
|
|
8845
8896
|
await pagefindIndex.writeFiles({ outputPath });
|
|
8846
8897
|
yield { type: "complete", success: true, indexed };
|
|
8847
8898
|
}
|
|
@@ -8860,9 +8911,9 @@ var DevServer = class {
|
|
|
8860
8911
|
this.protocol = "https";
|
|
8861
8912
|
const { dir } = this.options;
|
|
8862
8913
|
const [key, cert, ca] = await Promise.all([
|
|
8863
|
-
|
|
8864
|
-
|
|
8865
|
-
config2.https.ca ?
|
|
8914
|
+
fs4.readFile(path30.resolve(dir, config2.https.key)),
|
|
8915
|
+
fs4.readFile(path30.resolve(dir, config2.https.cert)),
|
|
8916
|
+
config2.https.ca ? fs4.readFile(path30.resolve(dir, config2.https.ca)) : void 0
|
|
8866
8917
|
]);
|
|
8867
8918
|
return https.createServer({ key, cert, ca });
|
|
8868
8919
|
}
|
|
@@ -8878,6 +8929,13 @@ var DevServer = class {
|
|
|
8878
8929
|
this.options.argPort ?? config2.port ?? DEFAULT_DEV_PORT
|
|
8879
8930
|
);
|
|
8880
8931
|
const server = await this.createNodeServer(config2);
|
|
8932
|
+
if (config2.search?.type === "pagefind" && viteConfig.publicDir !== false) {
|
|
8933
|
+
const publicRoot = path30.resolve(
|
|
8934
|
+
this.options.dir,
|
|
8935
|
+
typeof viteConfig.publicDir === "string" ? viteConfig.publicDir : "public"
|
|
8936
|
+
);
|
|
8937
|
+
await ensurePagefindDevStub(publicRoot);
|
|
8938
|
+
}
|
|
8881
8939
|
const mergedViteConfig = mergeConfig4(viteConfig, {
|
|
8882
8940
|
server: {
|
|
8883
8941
|
hmr: { server }
|
|
@@ -8889,7 +8947,7 @@ var DevServer = class {
|
|
|
8889
8947
|
// built-in transform middleware which would treat the path as a static asset.
|
|
8890
8948
|
name: "apitogo:entry-client",
|
|
8891
8949
|
configureServer(server2) {
|
|
8892
|
-
const entryPath =
|
|
8950
|
+
const entryPath = path30.posix.join(
|
|
8893
8951
|
server2.config.base,
|
|
8894
8952
|
"/__z/entry.client.tsx"
|
|
8895
8953
|
);
|
|
@@ -8961,16 +9019,8 @@ var DevServer = class {
|
|
|
8961
9019
|
printDiagnosticsToConsole(
|
|
8962
9020
|
`Server-side rendering ${this.options.ssr ? "enabled" : "disabled"}`
|
|
8963
9021
|
);
|
|
8964
|
-
if (config2.search?.type === "pagefind") {
|
|
8965
|
-
|
|
8966
|
-
vite.config.publicDir,
|
|
8967
|
-
"pagefind/pagefind.js"
|
|
8968
|
-
);
|
|
8969
|
-
const exists = await fs3.stat(pagefindPath).catch(() => false);
|
|
8970
|
-
if (!exists) {
|
|
8971
|
-
await fs3.mkdir(path28.dirname(pagefindPath), { recursive: true });
|
|
8972
|
-
await fs3.writeFile(pagefindPath, 'throw new Error("NOT_BUILT_YET");');
|
|
8973
|
-
}
|
|
9022
|
+
if (config2.search?.type === "pagefind" && vite.config.publicDir) {
|
|
9023
|
+
await ensurePagefindDevStub(vite.config.publicDir);
|
|
8974
9024
|
}
|
|
8975
9025
|
vite.middlewares.use(async (req, res) => {
|
|
8976
9026
|
const url = req.originalUrl ?? req.url ?? "/";
|
|
@@ -9062,7 +9112,7 @@ init_package_json();
|
|
|
9062
9112
|
async function dev(argv) {
|
|
9063
9113
|
const packageJson2 = getZudokuPackageJson();
|
|
9064
9114
|
process.env.NODE_ENV = "development";
|
|
9065
|
-
const dir =
|
|
9115
|
+
const dir = path31.resolve(process.cwd(), argv.dir);
|
|
9066
9116
|
const server = new DevServer({
|
|
9067
9117
|
dir,
|
|
9068
9118
|
argPort: argv.port,
|
|
@@ -9145,15 +9195,16 @@ var dev_default = {
|
|
|
9145
9195
|
};
|
|
9146
9196
|
|
|
9147
9197
|
// src/cli/make-config/handler.ts
|
|
9148
|
-
import {
|
|
9149
|
-
import
|
|
9198
|
+
import { constants as constants3 } from "node:fs";
|
|
9199
|
+
import { access as access4, mkdir as mkdir7, readFile as readFile6, writeFile as writeFile8 } from "node:fs/promises";
|
|
9200
|
+
import path33 from "node:path";
|
|
9150
9201
|
import { glob as glob5 } from "glob";
|
|
9151
9202
|
|
|
9152
9203
|
// src/cli/make-config/scaffold-project.ts
|
|
9153
9204
|
init_package_json();
|
|
9154
|
-
import { access as access3, readFile as readFile5, writeFile as writeFile7 } from "node:fs/promises";
|
|
9155
9205
|
import { constants as constants2 } from "node:fs";
|
|
9156
|
-
import
|
|
9206
|
+
import { access as access3, readFile as readFile5, writeFile as writeFile7 } from "node:fs/promises";
|
|
9207
|
+
import path32 from "node:path";
|
|
9157
9208
|
import { glob as glob4 } from "glob";
|
|
9158
9209
|
var OPENAPI_GLOBS = [
|
|
9159
9210
|
"apis/openapi.json",
|
|
@@ -9213,9 +9264,9 @@ var findMatchingCurly = (source, startIndex) => {
|
|
|
9213
9264
|
}
|
|
9214
9265
|
throw new Error("Could not find matching closing brace for object.");
|
|
9215
9266
|
};
|
|
9216
|
-
var toPosix = (p) => p.split(
|
|
9267
|
+
var toPosix = (p) => p.split(path32.sep).join("/");
|
|
9217
9268
|
var sanitizePackageName = (dir) => {
|
|
9218
|
-
const base =
|
|
9269
|
+
const base = path32.basename(path32.resolve(dir));
|
|
9219
9270
|
const s = base.toLowerCase().replace(/[^a-z0-9-_.]/g, "-").replace(/^-+|-+$/g, "");
|
|
9220
9271
|
return s || "apitogo-site";
|
|
9221
9272
|
};
|
|
@@ -9225,7 +9276,7 @@ var apitogoVersionRange = () => {
|
|
|
9225
9276
|
};
|
|
9226
9277
|
async function findOpenApiSpecPath(dir) {
|
|
9227
9278
|
for (const rel of OPENAPI_GLOBS) {
|
|
9228
|
-
const full =
|
|
9279
|
+
const full = path32.join(dir, rel);
|
|
9229
9280
|
try {
|
|
9230
9281
|
await access3(full, constants2.R_OK);
|
|
9231
9282
|
return toPosix(rel);
|
|
@@ -9240,7 +9291,7 @@ async function findOpenApiSpecPath(dir) {
|
|
|
9240
9291
|
return extra[0] ? toPosix(extra[0]) : null;
|
|
9241
9292
|
}
|
|
9242
9293
|
async function ensurePackageJson(dir) {
|
|
9243
|
-
const pkgPath =
|
|
9294
|
+
const pkgPath = path32.join(dir, "package.json");
|
|
9244
9295
|
const apitogoVer = apitogoVersionRange();
|
|
9245
9296
|
const baseDeps = {
|
|
9246
9297
|
react: ">=19.0.0",
|
|
@@ -9280,7 +9331,9 @@ async function ensurePackageJson(dir) {
|
|
|
9280
9331
|
try {
|
|
9281
9332
|
pkg = JSON.parse(raw);
|
|
9282
9333
|
} catch {
|
|
9283
|
-
throw new Error(
|
|
9334
|
+
throw new Error(
|
|
9335
|
+
"package.json exists but is not valid JSON; fix or remove it and run again."
|
|
9336
|
+
);
|
|
9284
9337
|
}
|
|
9285
9338
|
pkg.scripts = {
|
|
9286
9339
|
...typeof pkg.scripts === "object" && pkg.scripts !== null ? pkg.scripts : {}
|
|
@@ -9301,7 +9354,7 @@ async function ensurePackageJson(dir) {
|
|
|
9301
9354
|
return false;
|
|
9302
9355
|
}
|
|
9303
9356
|
async function ensureTsconfigJson(dir) {
|
|
9304
|
-
const tsPath =
|
|
9357
|
+
const tsPath = path32.join(dir, "tsconfig.json");
|
|
9305
9358
|
try {
|
|
9306
9359
|
await access3(tsPath, constants2.R_OK);
|
|
9307
9360
|
return false;
|
|
@@ -9383,7 +9436,7 @@ var CONFIG_FILENAMES = [
|
|
|
9383
9436
|
];
|
|
9384
9437
|
var DEFAULT_NEW_CONFIG_FILENAME = "apitogo.config.tsx";
|
|
9385
9438
|
var createTreeNode = () => ({ docs: [], children: /* @__PURE__ */ new Map() });
|
|
9386
|
-
var toPosixPath2 = (value) => value.split(
|
|
9439
|
+
var toPosixPath2 = (value) => value.split(path33.sep).join(path33.posix.sep);
|
|
9387
9440
|
var toRoutePath = (relativeFile, pagesDir) => {
|
|
9388
9441
|
const relativeNoExt = relativeFile.replace(/\.mdx?$/, "");
|
|
9389
9442
|
const withoutPagesPrefix = relativeNoExt.replace(
|
|
@@ -9626,9 +9679,20 @@ const config: ApitogoConfig = {
|
|
|
9626
9679
|
export default config;
|
|
9627
9680
|
`;
|
|
9628
9681
|
};
|
|
9682
|
+
var ensureApitogoDeployWorkflow = async (dir) => {
|
|
9683
|
+
const workflowPath = path33.join(dir, ".github", "workflows", "apitogo-deploy.yml");
|
|
9684
|
+
try {
|
|
9685
|
+
await access4(workflowPath, constants3.F_OK);
|
|
9686
|
+
return false;
|
|
9687
|
+
} catch {
|
|
9688
|
+
}
|
|
9689
|
+
await mkdir7(path33.join(dir, ".github", "workflows"), { recursive: true });
|
|
9690
|
+
await writeFile8(workflowPath, APITOGO_DEPLOY_WORKFLOW_YAML, "utf8");
|
|
9691
|
+
return true;
|
|
9692
|
+
};
|
|
9629
9693
|
var findExistingConfigPath = async (dir) => {
|
|
9630
9694
|
for (const filename of CONFIG_FILENAMES) {
|
|
9631
|
-
const fullPath =
|
|
9695
|
+
const fullPath = path33.join(dir, filename);
|
|
9632
9696
|
try {
|
|
9633
9697
|
await readFile6(fullPath, "utf8");
|
|
9634
9698
|
return fullPath;
|
|
@@ -9638,7 +9702,7 @@ var findExistingConfigPath = async (dir) => {
|
|
|
9638
9702
|
return null;
|
|
9639
9703
|
};
|
|
9640
9704
|
async function makeConfig(argv) {
|
|
9641
|
-
const dir =
|
|
9705
|
+
const dir = path33.resolve(process.cwd(), argv.dir);
|
|
9642
9706
|
const pagesDir = toPosixPath2(
|
|
9643
9707
|
argv.pagesDir.replace(/^[./]+/, "").replace(/\/+$/, "")
|
|
9644
9708
|
);
|
|
@@ -9647,7 +9711,9 @@ async function makeConfig(argv) {
|
|
|
9647
9711
|
const createdPackageJson = await ensurePackageJson(dir);
|
|
9648
9712
|
const createdTsconfig = await ensureTsconfigJson(dir);
|
|
9649
9713
|
if (createdPackageJson) {
|
|
9650
|
-
printDiagnosticsToConsole(
|
|
9714
|
+
printDiagnosticsToConsole(
|
|
9715
|
+
"Created package.json with dev, build, and preview scripts."
|
|
9716
|
+
);
|
|
9651
9717
|
}
|
|
9652
9718
|
if (createdTsconfig) {
|
|
9653
9719
|
printDiagnosticsToConsole("Created tsconfig.json.");
|
|
@@ -9655,7 +9721,7 @@ async function makeConfig(argv) {
|
|
|
9655
9721
|
let configPath = await findExistingConfigPath(dir);
|
|
9656
9722
|
let createdNew = false;
|
|
9657
9723
|
if (!configPath) {
|
|
9658
|
-
configPath =
|
|
9724
|
+
configPath = path33.join(dir, DEFAULT_NEW_CONFIG_FILENAME);
|
|
9659
9725
|
await writeFile8(
|
|
9660
9726
|
configPath,
|
|
9661
9727
|
buildNewConfigContents(pagesDir, openApiSpecPath),
|
|
@@ -9696,8 +9762,14 @@ async function makeConfig(argv) {
|
|
|
9696
9762
|
await writeFile8(configPath, withRedirects, "utf8");
|
|
9697
9763
|
const action = createdNew ? "Initialized" : "Updated";
|
|
9698
9764
|
printResultToConsole(
|
|
9699
|
-
`${action} ${
|
|
9765
|
+
`${action} ${path33.basename(configPath)} from ${pagesDir}/ (navigation and redirects; other top-level settings preserved unless newly scaffolded).`
|
|
9700
9766
|
);
|
|
9767
|
+
const createdWorkflow = await ensureApitogoDeployWorkflow(dir);
|
|
9768
|
+
if (createdWorkflow) {
|
|
9769
|
+
printDiagnosticsToConsole(
|
|
9770
|
+
"Created .github/workflows/apitogo-deploy.yml (preview + production; removes preview when a PR is closed)."
|
|
9771
|
+
);
|
|
9772
|
+
}
|
|
9701
9773
|
if (createdPackageJson) {
|
|
9702
9774
|
printDiagnosticsToConsole(
|
|
9703
9775
|
"Next: run npm install (or pnpm install / yarn) in this directory, then npm run dev."
|
|
@@ -9753,6 +9825,84 @@ var previewCommand = {
|
|
|
9753
9825
|
};
|
|
9754
9826
|
var preview_default = previewCommand;
|
|
9755
9827
|
|
|
9828
|
+
// src/cli/remove/handler.ts
|
|
9829
|
+
var REMOVE_ENDPOINT = "https://deploy-server-dotnet2-b3fkcaaraydbckfe.canadacentral-01.azurewebsites.net/remove";
|
|
9830
|
+
async function remove(argv) {
|
|
9831
|
+
const deploymentToken = argv.deploymentToken?.trim() || process.env.npm_config_deployment_token?.trim();
|
|
9832
|
+
const env = argv.env?.trim() || process.env.npm_config_env?.trim() || "production";
|
|
9833
|
+
try {
|
|
9834
|
+
if (!deploymentToken) {
|
|
9835
|
+
throw new Error("A deployment token is required.");
|
|
9836
|
+
}
|
|
9837
|
+
if (!isJsonOnlyDeployEnv()) {
|
|
9838
|
+
printDiagnosticsToConsole(`Removing deployment from ${env}...`);
|
|
9839
|
+
}
|
|
9840
|
+
const formData = new FormData();
|
|
9841
|
+
formData.append("deploymentToken", deploymentToken);
|
|
9842
|
+
formData.append("env", env);
|
|
9843
|
+
const removeUrl = new URL(REMOVE_ENDPOINT);
|
|
9844
|
+
if (argv.jsonOnly) {
|
|
9845
|
+
removeUrl.searchParams.set("jsonOnly", "true");
|
|
9846
|
+
}
|
|
9847
|
+
const response = await fetch(removeUrl, {
|
|
9848
|
+
method: "POST",
|
|
9849
|
+
headers: {
|
|
9850
|
+
"x-api-key": DEPLOY_SERVER_API_KEY
|
|
9851
|
+
},
|
|
9852
|
+
body: formData
|
|
9853
|
+
});
|
|
9854
|
+
const responseText = await response.text();
|
|
9855
|
+
if (!response.ok) {
|
|
9856
|
+
throw new Error(
|
|
9857
|
+
`Remove failed with ${response.status}: ${JSON.stringify(textOrJson(responseText))}`
|
|
9858
|
+
);
|
|
9859
|
+
}
|
|
9860
|
+
if (isJsonOnlyDeployEnv()) {
|
|
9861
|
+
const parsed = responseText.trim() ? textOrJson(responseText) : {};
|
|
9862
|
+
console.log(JSON.stringify(parsed));
|
|
9863
|
+
return;
|
|
9864
|
+
}
|
|
9865
|
+
printResultToConsole(`Removal request sent to ${removeUrl.href}`);
|
|
9866
|
+
if (responseText.trim()) {
|
|
9867
|
+
printDiagnosticsToConsole(
|
|
9868
|
+
JSON.stringify(textOrJson(responseText), null, 2)
|
|
9869
|
+
);
|
|
9870
|
+
}
|
|
9871
|
+
} catch (error) {
|
|
9872
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9873
|
+
if (isJsonOnlyDeployEnv()) {
|
|
9874
|
+
printJsonOnlyErrorAndExit(message);
|
|
9875
|
+
} else {
|
|
9876
|
+
await printCriticalFailureToConsoleAndExit(message);
|
|
9877
|
+
}
|
|
9878
|
+
}
|
|
9879
|
+
}
|
|
9880
|
+
|
|
9881
|
+
// src/cli/cmds/remove.ts
|
|
9882
|
+
var remove_default = {
|
|
9883
|
+
desc: "Remove a deployment from the target environment",
|
|
9884
|
+
command: "remove",
|
|
9885
|
+
builder: (yargs2) => yargs2.option("deployment-token", {
|
|
9886
|
+
type: "string",
|
|
9887
|
+
describe: "Deployment token sent to the remove endpoint"
|
|
9888
|
+
}).option("env", {
|
|
9889
|
+
type: "string",
|
|
9890
|
+
describe: "Target environment name sent to the remove API (e.g. production, preview, preview-a, preview-b)",
|
|
9891
|
+
default: "production"
|
|
9892
|
+
}).option("json-only", {
|
|
9893
|
+
type: "boolean",
|
|
9894
|
+
describe: "JSON-only output on stdout; adds ?jsonOnly=true to the remove request",
|
|
9895
|
+
default: false
|
|
9896
|
+
}),
|
|
9897
|
+
handler: async (argv) => {
|
|
9898
|
+
if (argv.jsonOnly) {
|
|
9899
|
+
applyJsonOnlyDeployQuietMode();
|
|
9900
|
+
}
|
|
9901
|
+
await captureEvent({ argv, event: "apitogo remove" });
|
|
9902
|
+
await remove(argv);
|
|
9903
|
+
}
|
|
9904
|
+
};
|
|
9905
|
+
|
|
9756
9906
|
// src/cli/common/outdated.ts
|
|
9757
9907
|
import { existsSync as existsSync2, mkdirSync } from "node:fs";
|
|
9758
9908
|
import { readFile as readFile7, writeFile as writeFile9 } from "node:fs/promises";
|
|
@@ -9805,12 +9955,12 @@ function box(message, {
|
|
|
9805
9955
|
|
|
9806
9956
|
// src/cli/common/xdg/lib.ts
|
|
9807
9957
|
import { homedir } from "node:os";
|
|
9808
|
-
import
|
|
9958
|
+
import path34 from "node:path";
|
|
9809
9959
|
function defineDirectoryWithFallback(xdgName, fallback) {
|
|
9810
9960
|
if (process.env[xdgName]) {
|
|
9811
9961
|
return process.env[xdgName];
|
|
9812
9962
|
} else {
|
|
9813
|
-
return
|
|
9963
|
+
return path34.join(homedir(), fallback);
|
|
9814
9964
|
}
|
|
9815
9965
|
}
|
|
9816
9966
|
var XDG_CONFIG_HOME = defineDirectoryWithFallback(
|
|
@@ -9825,15 +9975,15 @@ var XDG_STATE_HOME = defineDirectoryWithFallback(
|
|
|
9825
9975
|
"XDG_DATA_HOME",
|
|
9826
9976
|
".local/state"
|
|
9827
9977
|
);
|
|
9828
|
-
var ZUDOKU_XDG_CONFIG_HOME =
|
|
9978
|
+
var ZUDOKU_XDG_CONFIG_HOME = path34.join(
|
|
9829
9979
|
XDG_CONFIG_HOME,
|
|
9830
9980
|
CLI_XDG_FOLDER_NAME
|
|
9831
9981
|
);
|
|
9832
|
-
var ZUDOKU_XDG_DATA_HOME =
|
|
9982
|
+
var ZUDOKU_XDG_DATA_HOME = path34.join(
|
|
9833
9983
|
XDG_DATA_HOME,
|
|
9834
9984
|
CLI_XDG_FOLDER_NAME
|
|
9835
9985
|
);
|
|
9836
|
-
var ZUDOKU_XDG_STATE_HOME =
|
|
9986
|
+
var ZUDOKU_XDG_STATE_HOME = path34.join(
|
|
9837
9987
|
XDG_STATE_HOME,
|
|
9838
9988
|
CLI_XDG_FOLDER_NAME
|
|
9839
9989
|
);
|
|
@@ -9997,7 +10147,7 @@ var cli = yargs(hideBin(process.argv)).option("zuplo", {
|
|
|
9997
10147
|
process.env.ZUPLO = "1";
|
|
9998
10148
|
printDiagnosticsToConsole("Running in Zuplo mode");
|
|
9999
10149
|
}
|
|
10000
|
-
}).middleware(warnPackageVersionMismatch).command(build_default).command(configure_github_workflow_default).command(dev_default).command(deploy_default).command(preview_default).command(make_config_default).demandCommand().strictCommands().version(packageJson?.version).fail(false).help();
|
|
10150
|
+
}).middleware(warnPackageVersionMismatch).command(build_default).command(configure_github_workflow_default).command(dev_default).command(deploy_default).command(remove_default).command(preview_default).command(make_config_default).demandCommand().strictCommands().version(packageJson?.version).fail(false).help();
|
|
10001
10151
|
try {
|
|
10002
10152
|
void warnIfOutdatedVersion(packageJson?.version);
|
|
10003
10153
|
await cli.argv;
|