@lukoweb/apitogo 0.1.3 → 0.1.5
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 +538 -147
- package/package.json +2 -2
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 = (path31) => stat(path31).then(() => true).catch(() => false);
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
137
|
|
|
@@ -3816,7 +3816,7 @@ import {
|
|
|
3816
3816
|
// package.json
|
|
3817
3817
|
var package_default = {
|
|
3818
3818
|
name: "@lukoweb/apitogo",
|
|
3819
|
-
version: "0.1.
|
|
3819
|
+
version: "0.1.4",
|
|
3820
3820
|
type: "module",
|
|
3821
3821
|
sideEffects: [
|
|
3822
3822
|
"**/*.css",
|
|
@@ -3890,7 +3890,6 @@ var package_default = {
|
|
|
3890
3890
|
"generate:types": "tsx scripts/generate-types.js && tsx scripts/generate-flat-config.js",
|
|
3891
3891
|
"build:standalone": "vite build --mode standalone --config vite.standalone.config.ts --log-level=error",
|
|
3892
3892
|
prepublishOnly: "tsx scripts/generate-publish-exports.ts",
|
|
3893
|
-
postpublish: "git checkout -- package.json",
|
|
3894
3893
|
clean: "rm -rf dist",
|
|
3895
3894
|
codegen: "graphql-codegen --config ./src/codegen.ts"
|
|
3896
3895
|
},
|
|
@@ -4001,9 +4000,9 @@ var package_default = {
|
|
|
4001
4000
|
shiki: "3.23.0",
|
|
4002
4001
|
sitemap: "9.0.1",
|
|
4003
4002
|
"strip-ansi": "7.2.0",
|
|
4003
|
+
tar: "7.5.10",
|
|
4004
4004
|
"tailwind-merge": "3.5.0",
|
|
4005
4005
|
tailwindcss: "4.2.1",
|
|
4006
|
-
tar: "7.5.10",
|
|
4007
4006
|
"tw-animate-css": "1.4.0",
|
|
4008
4007
|
unified: "11.0.5",
|
|
4009
4008
|
"unist-util-visit": "5.1.0",
|
|
@@ -4067,6 +4066,127 @@ var package_default = {
|
|
|
4067
4066
|
mermaid: {
|
|
4068
4067
|
optional: true
|
|
4069
4068
|
}
|
|
4069
|
+
},
|
|
4070
|
+
publishConfig: {
|
|
4071
|
+
exports: {
|
|
4072
|
+
".": {
|
|
4073
|
+
types: "./dist/declarations/index.d.ts",
|
|
4074
|
+
default: "./src/index.ts"
|
|
4075
|
+
},
|
|
4076
|
+
"./package.json": "./package.json",
|
|
4077
|
+
"./ui/*": {
|
|
4078
|
+
types: "./dist/declarations/lib/ui/*.d.ts",
|
|
4079
|
+
default: "./src/lib/ui/*.tsx"
|
|
4080
|
+
},
|
|
4081
|
+
"./ui/*.js": {
|
|
4082
|
+
types: "./dist/declarations/lib/ui/*.d.ts",
|
|
4083
|
+
default: "./src/lib/ui/*.tsx"
|
|
4084
|
+
},
|
|
4085
|
+
"./client": {
|
|
4086
|
+
types: "./client.d.ts"
|
|
4087
|
+
},
|
|
4088
|
+
"./auth/clerk": {
|
|
4089
|
+
types: "./dist/declarations/lib/authentication/providers/clerk.d.ts",
|
|
4090
|
+
default: "./src/lib/authentication/providers/clerk.tsx"
|
|
4091
|
+
},
|
|
4092
|
+
"./auth/auth0": {
|
|
4093
|
+
types: "./dist/declarations/lib/authentication/providers/auth0.d.ts",
|
|
4094
|
+
default: "./src/lib/authentication/providers/auth0.tsx"
|
|
4095
|
+
},
|
|
4096
|
+
"./auth/openid": {
|
|
4097
|
+
types: "./dist/declarations/lib/authentication/providers/openid.d.ts",
|
|
4098
|
+
default: "./src/lib/authentication/providers/openid.tsx"
|
|
4099
|
+
},
|
|
4100
|
+
"./auth/supabase": {
|
|
4101
|
+
types: "./dist/declarations/lib/authentication/providers/supabase.d.ts",
|
|
4102
|
+
default: "./src/lib/authentication/providers/supabase.tsx"
|
|
4103
|
+
},
|
|
4104
|
+
"./auth/azureb2c": {
|
|
4105
|
+
types: "./dist/declarations/lib/authentication/providers/azureb2c.d.ts",
|
|
4106
|
+
default: "./src/lib/authentication/providers/azureb2c.tsx"
|
|
4107
|
+
},
|
|
4108
|
+
"./auth/firebase": {
|
|
4109
|
+
types: "./dist/declarations/lib/authentication/providers/firebase.d.ts",
|
|
4110
|
+
default: "./src/lib/authentication/providers/firebase.tsx"
|
|
4111
|
+
},
|
|
4112
|
+
"./plugins": {
|
|
4113
|
+
types: "./dist/declarations/lib/core/plugins.d.ts",
|
|
4114
|
+
default: "./src/lib/core/plugins.ts"
|
|
4115
|
+
},
|
|
4116
|
+
"./plugins/api-keys": {
|
|
4117
|
+
types: "./dist/declarations/lib/plugins/api-keys/index.d.ts",
|
|
4118
|
+
default: "./src/lib/plugins/api-keys/index.tsx"
|
|
4119
|
+
},
|
|
4120
|
+
"./plugins/markdown": {
|
|
4121
|
+
types: "./dist/declarations/lib/plugins/markdown/index.d.ts",
|
|
4122
|
+
default: "./src/lib/plugins/markdown/index.tsx"
|
|
4123
|
+
},
|
|
4124
|
+
"./plugins/openapi": {
|
|
4125
|
+
types: "./dist/declarations/lib/plugins/openapi/index.d.ts",
|
|
4126
|
+
default: "./src/lib/plugins/openapi/index.tsx"
|
|
4127
|
+
},
|
|
4128
|
+
"./plugins/custom-pages": {
|
|
4129
|
+
types: "./dist/declarations/lib/plugins/custom-pages/index.d.ts",
|
|
4130
|
+
default: "./src/lib/plugins/custom-pages/index.tsx"
|
|
4131
|
+
},
|
|
4132
|
+
"./plugins/search-inkeep": {
|
|
4133
|
+
types: "./dist/declarations/lib/plugins/search-inkeep/index.d.ts",
|
|
4134
|
+
default: "./src/lib/plugins/search-inkeep/index.tsx"
|
|
4135
|
+
},
|
|
4136
|
+
"./plugins/search-pagefind": {
|
|
4137
|
+
types: "./dist/declarations/lib/plugins/search-pagefind/index.d.ts",
|
|
4138
|
+
default: "./src/lib/plugins/search-pagefind/index.tsx"
|
|
4139
|
+
},
|
|
4140
|
+
"./plugins/api-catalog": {
|
|
4141
|
+
types: "./dist/declarations/lib/plugins/api-catalog/index.d.ts",
|
|
4142
|
+
default: "./src/lib/plugins/api-catalog/index.tsx"
|
|
4143
|
+
},
|
|
4144
|
+
"./components": {
|
|
4145
|
+
types: "./dist/declarations/lib/components/index.d.ts",
|
|
4146
|
+
default: "./src/lib/components/index.ts"
|
|
4147
|
+
},
|
|
4148
|
+
"./mermaid": {
|
|
4149
|
+
types: "./dist/declarations/lib/components/Mermaid.d.ts",
|
|
4150
|
+
default: "./src/lib/components/Mermaid.tsx"
|
|
4151
|
+
},
|
|
4152
|
+
"./router": {
|
|
4153
|
+
types: "./dist/declarations/lib/core/router.d.ts",
|
|
4154
|
+
default: "./src/lib/core/router.ts"
|
|
4155
|
+
},
|
|
4156
|
+
"./react-query": {
|
|
4157
|
+
types: "./dist/declarations/lib/core/react-query.d.ts",
|
|
4158
|
+
default: "./src/lib/core/react-query.ts"
|
|
4159
|
+
},
|
|
4160
|
+
"./icons": {
|
|
4161
|
+
types: "./dist/declarations/lib/icons.d.ts",
|
|
4162
|
+
default: "./src/lib/icons.ts"
|
|
4163
|
+
},
|
|
4164
|
+
"./vite": {
|
|
4165
|
+
types: "./dist/declarations/vite/index.d.ts",
|
|
4166
|
+
default: "./src/vite/index.ts"
|
|
4167
|
+
},
|
|
4168
|
+
"./app/*": {
|
|
4169
|
+
types: "./dist/declarations/app/*.d.ts",
|
|
4170
|
+
default: "./src/app/*"
|
|
4171
|
+
},
|
|
4172
|
+
"./hooks": {
|
|
4173
|
+
types: "./dist/declarations/lib/hooks/index.d.ts",
|
|
4174
|
+
default: "./src/lib/hooks/index.ts"
|
|
4175
|
+
},
|
|
4176
|
+
"./main.css": "./src/app/main.css",
|
|
4177
|
+
"./processors/*": {
|
|
4178
|
+
types: "./dist/declarations/lib/plugins/openapi/processors/*.d.ts",
|
|
4179
|
+
default: "./src/lib/plugins/openapi/processors/*.ts"
|
|
4180
|
+
},
|
|
4181
|
+
"./with-zuplo": {
|
|
4182
|
+
types: "./dist/declarations/zuplo/with-zuplo.d.ts",
|
|
4183
|
+
default: "./src/zuplo/with-zuplo.ts"
|
|
4184
|
+
},
|
|
4185
|
+
"./testing": {
|
|
4186
|
+
types: "./dist/declarations/lib/testing/index.d.ts",
|
|
4187
|
+
default: "./src/lib/testing/index.tsx"
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4070
4190
|
}
|
|
4071
4191
|
};
|
|
4072
4192
|
|
|
@@ -4407,14 +4527,14 @@ var flattenAllOf = (schema2) => {
|
|
|
4407
4527
|
};
|
|
4408
4528
|
|
|
4409
4529
|
// src/lib/util/traverse.ts
|
|
4410
|
-
var traverse = (specification, transform,
|
|
4411
|
-
const transformed = transform(specification,
|
|
4530
|
+
var traverse = (specification, transform, path31 = []) => {
|
|
4531
|
+
const transformed = transform(specification, path31);
|
|
4412
4532
|
if (typeof transformed !== "object" || transformed === null) {
|
|
4413
4533
|
return transformed;
|
|
4414
4534
|
}
|
|
4415
4535
|
const result = Array.isArray(transformed) ? [] : {};
|
|
4416
4536
|
for (const [key, value] of Object.entries(transformed)) {
|
|
4417
|
-
const currentPath = [...
|
|
4537
|
+
const currentPath = [...path31, key];
|
|
4418
4538
|
if (Array.isArray(value)) {
|
|
4419
4539
|
result[key] = value.map(
|
|
4420
4540
|
(item, index) => typeof item === "object" && item != null ? traverse(item, transform, [...currentPath, index.toString()]) : item
|
|
@@ -4442,9 +4562,9 @@ var resolveLocalRef = (schema2, ref) => {
|
|
|
4442
4562
|
if (schemaCache?.has(ref)) {
|
|
4443
4563
|
return schemaCache.get(ref);
|
|
4444
4564
|
}
|
|
4445
|
-
const
|
|
4565
|
+
const path31 = ref.split("/").slice(1);
|
|
4446
4566
|
let current = schema2;
|
|
4447
|
-
for (const segment of
|
|
4567
|
+
for (const segment of path31) {
|
|
4448
4568
|
if (!current || typeof current !== "object") {
|
|
4449
4569
|
current = null;
|
|
4450
4570
|
}
|
|
@@ -4463,7 +4583,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4463
4583
|
}
|
|
4464
4584
|
const cloned = structuredClone(schema2);
|
|
4465
4585
|
const visited = /* @__PURE__ */ new Set();
|
|
4466
|
-
const resolve = async (current,
|
|
4586
|
+
const resolve = async (current, path31) => {
|
|
4467
4587
|
if (isIndexableObject(current)) {
|
|
4468
4588
|
if (visited.has(current)) {
|
|
4469
4589
|
return CIRCULAR_REF;
|
|
@@ -4471,7 +4591,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4471
4591
|
visited.add(current);
|
|
4472
4592
|
if (Array.isArray(current)) {
|
|
4473
4593
|
for (let index = 0; index < current.length; index++) {
|
|
4474
|
-
current[index] = await resolve(current[index], `${
|
|
4594
|
+
current[index] = await resolve(current[index], `${path31}/${index}`);
|
|
4475
4595
|
}
|
|
4476
4596
|
} else {
|
|
4477
4597
|
if ("$ref" in current && typeof current.$ref === "string") {
|
|
@@ -4482,13 +4602,13 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4482
4602
|
for (const resolver of resolvers) {
|
|
4483
4603
|
const resolved = await resolver($ref);
|
|
4484
4604
|
if (resolved) {
|
|
4485
|
-
result2 = await resolve(resolved,
|
|
4605
|
+
result2 = await resolve(resolved, path31);
|
|
4486
4606
|
break;
|
|
4487
4607
|
}
|
|
4488
4608
|
}
|
|
4489
4609
|
if (result2 === void 0) {
|
|
4490
4610
|
const resolved = await resolveLocalRef(cloned, $ref);
|
|
4491
|
-
result2 = await resolve(resolved,
|
|
4611
|
+
result2 = await resolve(resolved, path31);
|
|
4492
4612
|
}
|
|
4493
4613
|
if (hasSiblings) {
|
|
4494
4614
|
if (result2 === CIRCULAR_REF) {
|
|
@@ -4501,7 +4621,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4501
4621
|
return result2;
|
|
4502
4622
|
}
|
|
4503
4623
|
for (const key in current) {
|
|
4504
|
-
current[key] = await resolve(current[key], `${
|
|
4624
|
+
current[key] = await resolve(current[key], `${path31}/${key}`);
|
|
4505
4625
|
}
|
|
4506
4626
|
}
|
|
4507
4627
|
visited.delete(current);
|
|
@@ -4540,9 +4660,9 @@ var upgradeSchema = (schema2) => {
|
|
|
4540
4660
|
}
|
|
4541
4661
|
return sub;
|
|
4542
4662
|
});
|
|
4543
|
-
schema2 = traverse(schema2, (sub,
|
|
4663
|
+
schema2 = traverse(schema2, (sub, path31) => {
|
|
4544
4664
|
if (sub.example !== void 0) {
|
|
4545
|
-
if (isSchemaPath(
|
|
4665
|
+
if (isSchemaPath(path31 ?? [])) {
|
|
4546
4666
|
sub.examples = [sub.example];
|
|
4547
4667
|
} else {
|
|
4548
4668
|
sub.examples = {
|
|
@@ -4555,11 +4675,11 @@ var upgradeSchema = (schema2) => {
|
|
|
4555
4675
|
}
|
|
4556
4676
|
return sub;
|
|
4557
4677
|
});
|
|
4558
|
-
schema2 = traverse(schema2, (schema3,
|
|
4678
|
+
schema2 = traverse(schema2, (schema3, path31) => {
|
|
4559
4679
|
if (schema3.type === "object" && schema3.properties !== void 0) {
|
|
4560
|
-
const parentPath =
|
|
4680
|
+
const parentPath = path31?.slice(0, -1);
|
|
4561
4681
|
const isMultipart = parentPath?.some((segment, index) => {
|
|
4562
|
-
return segment === "content" &&
|
|
4682
|
+
return segment === "content" && path31?.[index + 1] === "multipart/form-data";
|
|
4563
4683
|
});
|
|
4564
4684
|
if (isMultipart) {
|
|
4565
4685
|
const entries = Object.entries(schema3.properties);
|
|
@@ -4573,8 +4693,8 @@ var upgradeSchema = (schema2) => {
|
|
|
4573
4693
|
}
|
|
4574
4694
|
return schema3;
|
|
4575
4695
|
});
|
|
4576
|
-
schema2 = traverse(schema2, (schema3,
|
|
4577
|
-
if (
|
|
4696
|
+
schema2 = traverse(schema2, (schema3, path31) => {
|
|
4697
|
+
if (path31?.includes("content") && path31.includes("application/octet-stream")) {
|
|
4578
4698
|
return {};
|
|
4579
4699
|
}
|
|
4580
4700
|
if (schema3.type === "string" && schema3.format === "binary") {
|
|
@@ -4600,11 +4720,11 @@ var upgradeSchema = (schema2) => {
|
|
|
4600
4720
|
}
|
|
4601
4721
|
return sub;
|
|
4602
4722
|
});
|
|
4603
|
-
schema2 = traverse(schema2, (schema3,
|
|
4723
|
+
schema2 = traverse(schema2, (schema3, path31) => {
|
|
4604
4724
|
if (schema3.type === "string" && schema3.format === "byte") {
|
|
4605
|
-
const parentPath =
|
|
4725
|
+
const parentPath = path31?.slice(0, -1);
|
|
4606
4726
|
const contentMediaType = parentPath?.find(
|
|
4607
|
-
(_, index) =>
|
|
4727
|
+
(_, index) => path31?.[index - 1] === "content"
|
|
4608
4728
|
);
|
|
4609
4729
|
return {
|
|
4610
4730
|
type: "string",
|
|
@@ -4616,7 +4736,7 @@ var upgradeSchema = (schema2) => {
|
|
|
4616
4736
|
});
|
|
4617
4737
|
return schema2;
|
|
4618
4738
|
};
|
|
4619
|
-
function isSchemaPath(
|
|
4739
|
+
function isSchemaPath(path31) {
|
|
4620
4740
|
const schemaLocations = [
|
|
4621
4741
|
["components", "schemas"],
|
|
4622
4742
|
"properties",
|
|
@@ -4629,10 +4749,10 @@ function isSchemaPath(path30) {
|
|
|
4629
4749
|
];
|
|
4630
4750
|
return schemaLocations.some((location) => {
|
|
4631
4751
|
if (Array.isArray(location)) {
|
|
4632
|
-
return location.every((segment, index) =>
|
|
4752
|
+
return location.every((segment, index) => path31[index] === segment);
|
|
4633
4753
|
}
|
|
4634
|
-
return
|
|
4635
|
-
}) ||
|
|
4754
|
+
return path31.includes(location);
|
|
4755
|
+
}) || path31.includes("schema") || path31.some((segment) => segment.endsWith("Schema"));
|
|
4636
4756
|
}
|
|
4637
4757
|
|
|
4638
4758
|
// src/lib/oas/parser/index.ts
|
|
@@ -4714,13 +4834,13 @@ var OPENAPI_PROPS = /* @__PURE__ */ new Set([
|
|
|
4714
4834
|
"anyOf",
|
|
4715
4835
|
"oneOf"
|
|
4716
4836
|
]);
|
|
4717
|
-
var handleCircularRefs = (obj, currentPath = /* @__PURE__ */ new WeakSet(), refs = /* @__PURE__ */ new WeakMap(),
|
|
4837
|
+
var handleCircularRefs = (obj, currentPath = /* @__PURE__ */ new WeakSet(), refs = /* @__PURE__ */ new WeakMap(), path31 = [], currentRefPaths = /* @__PURE__ */ new Set()) => {
|
|
4718
4838
|
if (obj === null || typeof obj !== "object") return obj;
|
|
4719
4839
|
const refPath = obj.__$ref;
|
|
4720
4840
|
const isCircular = currentPath.has(obj) || typeof refPath === "string" && currentRefPaths.has(refPath);
|
|
4721
4841
|
if (isCircular) {
|
|
4722
4842
|
if (typeof refPath === "string") return SCHEMA_REF_PREFIX + refPath;
|
|
4723
|
-
const circularProp =
|
|
4843
|
+
const circularProp = path31.find((p) => !OPENAPI_PROPS.has(p)) || path31[0];
|
|
4724
4844
|
return [CIRCULAR_REF, circularProp].filter(Boolean).join(":");
|
|
4725
4845
|
}
|
|
4726
4846
|
if (refs.has(obj)) return refs.get(obj);
|
|
@@ -4730,7 +4850,7 @@ var handleCircularRefs = (obj, currentPath = /* @__PURE__ */ new WeakSet(), refs
|
|
|
4730
4850
|
value,
|
|
4731
4851
|
currentPath,
|
|
4732
4852
|
refs,
|
|
4733
|
-
[...
|
|
4853
|
+
[...path31, key],
|
|
4734
4854
|
currentRefPaths
|
|
4735
4855
|
);
|
|
4736
4856
|
const result = Array.isArray(obj) ? obj.map((item, i) => recurse(item, i.toString())) : Object.fromEntries(
|
|
@@ -4765,7 +4885,7 @@ var resolveExtensions = (obj) => Object.fromEntries(
|
|
|
4765
4885
|
var getAllTags = (schema2) => {
|
|
4766
4886
|
const rootTags = schema2.tags ?? [];
|
|
4767
4887
|
const operations = Object.values(schema2.paths ?? {}).flatMap(
|
|
4768
|
-
(
|
|
4888
|
+
(path31) => HttpMethods.map((k) => path31?.[k]).filter((op) => op != null)
|
|
4769
4889
|
);
|
|
4770
4890
|
const operationTags = new Set(operations.flatMap((op) => op.tags ?? []));
|
|
4771
4891
|
const hasUntaggedOperations = operations.some(
|
|
@@ -4820,7 +4940,7 @@ var getAllSlugs = (ops, schemaTags = []) => {
|
|
|
4820
4940
|
var getOperationSlugKey = (op) => [op.path, op.method, op.operationId, op.summary].filter(Boolean).join("-");
|
|
4821
4941
|
var getAllOperations = (paths) => {
|
|
4822
4942
|
const operations = Object.entries(paths ?? {}).flatMap(
|
|
4823
|
-
([
|
|
4943
|
+
([path31, value]) => HttpMethods.flatMap((method) => {
|
|
4824
4944
|
if (!value?.[method]) return [];
|
|
4825
4945
|
const operation = value[method];
|
|
4826
4946
|
const pathParameters = value.parameters ?? [];
|
|
@@ -4840,7 +4960,7 @@ var getAllOperations = (paths) => {
|
|
|
4840
4960
|
return {
|
|
4841
4961
|
...operation,
|
|
4842
4962
|
method,
|
|
4843
|
-
path:
|
|
4963
|
+
path: path31,
|
|
4844
4964
|
parameters,
|
|
4845
4965
|
servers,
|
|
4846
4966
|
tags: operation.tags ?? []
|
|
@@ -5198,8 +5318,8 @@ var Schema = builder.objectRef("Schema").implement({
|
|
|
5198
5318
|
}),
|
|
5199
5319
|
paths: t.field({
|
|
5200
5320
|
type: [PathItem],
|
|
5201
|
-
resolve: (root) => Object.entries(root.paths ?? {}).map(([
|
|
5202
|
-
path:
|
|
5321
|
+
resolve: (root) => Object.entries(root.paths ?? {}).map(([path31, value]) => ({
|
|
5322
|
+
path: path31,
|
|
5203
5323
|
// biome-ignore lint/style/noNonNullAssertion: value is guaranteed to be defined
|
|
5204
5324
|
methods: Object.keys(value)
|
|
5205
5325
|
}))
|
|
@@ -5346,7 +5466,7 @@ init_joinUrl();
|
|
|
5346
5466
|
|
|
5347
5467
|
// src/vite/api/schema-codegen.ts
|
|
5348
5468
|
var unescapeJsonPointer = (uri) => decodeURIComponent(uri.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
5349
|
-
var getSegmentsFromPath = (
|
|
5469
|
+
var getSegmentsFromPath = (path31) => path31.split("/").slice(1).map(unescapeJsonPointer);
|
|
5350
5470
|
var createLocalRefMap = (obj) => {
|
|
5351
5471
|
const refMap = /* @__PURE__ */ new Map();
|
|
5352
5472
|
const siblingsMap = /* @__PURE__ */ new Map();
|
|
@@ -5377,16 +5497,16 @@ var replaceMarkers = (code, mergedRefs) => code.replace(/"__refMap:(.*?)"/g, '__
|
|
|
5377
5497
|
/"__refMap\+Siblings:(.*?)"/g,
|
|
5378
5498
|
(_, key) => mergedRefs.get(key) ?? `__refMap["${key}"]`
|
|
5379
5499
|
);
|
|
5380
|
-
var lookup = (schema2,
|
|
5381
|
-
const parts = getSegmentsFromPath(
|
|
5500
|
+
var lookup = (schema2, path31, filePath) => {
|
|
5501
|
+
const parts = getSegmentsFromPath(path31);
|
|
5382
5502
|
let val = schema2;
|
|
5383
5503
|
for (const part of parts) {
|
|
5384
5504
|
while (val.$ref?.startsWith("#/")) {
|
|
5385
|
-
val = val.$ref ===
|
|
5505
|
+
val = val.$ref === path31 ? val : lookup(schema2, val.$ref, filePath);
|
|
5386
5506
|
}
|
|
5387
5507
|
if (val[part] === void 0) {
|
|
5388
5508
|
throw new Error(
|
|
5389
|
-
`Error in ${filePath ?? "code generation"}: Could not find path segment ${part} in path: ${
|
|
5509
|
+
`Error in ${filePath ?? "code generation"}: Could not find path segment ${part} in path: ${path31}`
|
|
5390
5510
|
);
|
|
5391
5511
|
}
|
|
5392
5512
|
val = val[part];
|
|
@@ -5631,8 +5751,8 @@ var SchemaManager = class {
|
|
|
5631
5751
|
}
|
|
5632
5752
|
}
|
|
5633
5753
|
};
|
|
5634
|
-
getLatestSchema = (
|
|
5635
|
-
getSchemasForPath = (
|
|
5754
|
+
getLatestSchema = (path31) => this.processedSchemas[path31]?.at(0);
|
|
5755
|
+
getSchemasForPath = (path31) => this.processedSchemas[path31];
|
|
5636
5756
|
getSchemaImports = () => Object.values(this.processedSchemas).flat().filter((s) => s.importKey);
|
|
5637
5757
|
getUrlToFilePathMap = () => {
|
|
5638
5758
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -7721,14 +7841,14 @@ async function generateSitemap({
|
|
|
7721
7841
|
|
|
7722
7842
|
// src/vite/prerender/utils.ts
|
|
7723
7843
|
init_joinUrl();
|
|
7724
|
-
var resolveRoutePath = (
|
|
7725
|
-
const segments =
|
|
7844
|
+
var resolveRoutePath = (path31) => {
|
|
7845
|
+
const segments = path31.split("/");
|
|
7726
7846
|
if (segments.some((s) => s.startsWith(":") && !s.endsWith("?"))) {
|
|
7727
7847
|
return void 0;
|
|
7728
7848
|
}
|
|
7729
7849
|
return segments.filter((s) => !s.startsWith(":")).join("/") || void 0;
|
|
7730
7850
|
};
|
|
7731
|
-
var isSkipped = (
|
|
7851
|
+
var isSkipped = (path31) => path31.includes("*") || /^\d+$/.test(path31);
|
|
7732
7852
|
var resolveRoutes = (routes, parentPath = "") => routes.flatMap((route) => {
|
|
7733
7853
|
if (route.path && isSkipped(route.path)) return [];
|
|
7734
7854
|
const routePath = route.path ? resolveRoutePath(route.path) : void 0;
|
|
@@ -8309,16 +8429,109 @@ var build_default = {
|
|
|
8309
8429
|
}
|
|
8310
8430
|
};
|
|
8311
8431
|
|
|
8432
|
+
// src/cli/deploy/handler.ts
|
|
8433
|
+
import { access, readFile as readFile4 } from "node:fs/promises";
|
|
8434
|
+
import path25 from "node:path";
|
|
8435
|
+
import { create as createTar } from "tar";
|
|
8436
|
+
var DEPLOY_ENDPOINT = "http://localhost:3000/deploy";
|
|
8437
|
+
var ARCHIVE_NAME = "dist.tgz";
|
|
8438
|
+
var createDeploymentArchive = async (dir) => {
|
|
8439
|
+
const distDir = path25.join(dir, "dist");
|
|
8440
|
+
await access(distDir);
|
|
8441
|
+
const archivePath = path25.join(dir, ARCHIVE_NAME);
|
|
8442
|
+
await createTar(
|
|
8443
|
+
{
|
|
8444
|
+
cwd: dir,
|
|
8445
|
+
file: archivePath,
|
|
8446
|
+
gzip: true,
|
|
8447
|
+
portable: true
|
|
8448
|
+
},
|
|
8449
|
+
["dist"]
|
|
8450
|
+
);
|
|
8451
|
+
return archivePath;
|
|
8452
|
+
};
|
|
8453
|
+
async function deploy(argv) {
|
|
8454
|
+
await build({ ...argv, preview: void 0 });
|
|
8455
|
+
const dir = path25.resolve(process.cwd(), argv.dir);
|
|
8456
|
+
const deploymentToken = argv.deploymentToken?.trim();
|
|
8457
|
+
try {
|
|
8458
|
+
if (!deploymentToken) {
|
|
8459
|
+
throw new Error("A deployment token is required.");
|
|
8460
|
+
}
|
|
8461
|
+
printDiagnosticsToConsole("Creating deployment archive...");
|
|
8462
|
+
const archivePath = await createDeploymentArchive(dir);
|
|
8463
|
+
printDiagnosticsToConsole(`Uploading ${path25.basename(archivePath)}...`);
|
|
8464
|
+
const archiveBuffer = await readFile4(archivePath);
|
|
8465
|
+
const formData = new FormData();
|
|
8466
|
+
formData.append(
|
|
8467
|
+
"file",
|
|
8468
|
+
new Blob([archiveBuffer], { type: "application/gzip" }),
|
|
8469
|
+
path25.basename(archivePath)
|
|
8470
|
+
);
|
|
8471
|
+
formData.append("deploymentToken", deploymentToken);
|
|
8472
|
+
const response = await fetch(DEPLOY_ENDPOINT, {
|
|
8473
|
+
method: "POST",
|
|
8474
|
+
body: formData
|
|
8475
|
+
});
|
|
8476
|
+
const responseText = await response.text();
|
|
8477
|
+
if (!response.ok) {
|
|
8478
|
+
throw new Error(
|
|
8479
|
+
`Deploy failed with ${response.status}: ${JSON.stringify(textOrJson(responseText))}`
|
|
8480
|
+
);
|
|
8481
|
+
}
|
|
8482
|
+
printResultToConsole(`Deployment uploaded to ${DEPLOY_ENDPOINT}`);
|
|
8483
|
+
if (responseText.trim()) {
|
|
8484
|
+
printDiagnosticsToConsole(
|
|
8485
|
+
JSON.stringify(textOrJson(responseText), null, 2)
|
|
8486
|
+
);
|
|
8487
|
+
}
|
|
8488
|
+
} catch (error) {
|
|
8489
|
+
await printCriticalFailureToConsoleAndExit(
|
|
8490
|
+
error instanceof Error ? error.message : String(error)
|
|
8491
|
+
);
|
|
8492
|
+
}
|
|
8493
|
+
}
|
|
8494
|
+
|
|
8495
|
+
// src/cli/cmds/deploy.ts
|
|
8496
|
+
var deploy_default = {
|
|
8497
|
+
desc: "Build, archive, and deploy",
|
|
8498
|
+
command: "deploy [deploymentToken]",
|
|
8499
|
+
builder: (yargs2) => yargs2.positional("deploymentToken", {
|
|
8500
|
+
type: "string",
|
|
8501
|
+
describe: "Deployment token sent to the deploy endpoint"
|
|
8502
|
+
}).option("dir", {
|
|
8503
|
+
type: "string",
|
|
8504
|
+
describe: "The directory containing your project",
|
|
8505
|
+
default: ".",
|
|
8506
|
+
normalize: true,
|
|
8507
|
+
hidden: true
|
|
8508
|
+
}).option("experimental-ssr", {
|
|
8509
|
+
type: "boolean",
|
|
8510
|
+
describe: "Build for server-side rendering (experimental)",
|
|
8511
|
+
default: false
|
|
8512
|
+
}).option("adapter", {
|
|
8513
|
+
type: "string",
|
|
8514
|
+
describe: "SSR adapter (node, cloudflare, vercel)",
|
|
8515
|
+
choices: ["node", "cloudflare", "vercel"],
|
|
8516
|
+
default: "node"
|
|
8517
|
+
}),
|
|
8518
|
+
handler: async (argv) => {
|
|
8519
|
+
process.env.NODE_ENV = "production";
|
|
8520
|
+
await captureEvent({ argv, event: "apitogo deploy" });
|
|
8521
|
+
await deploy(argv);
|
|
8522
|
+
}
|
|
8523
|
+
};
|
|
8524
|
+
|
|
8312
8525
|
// src/cli/dev/handler.ts
|
|
8313
8526
|
init_joinUrl();
|
|
8314
|
-
import
|
|
8527
|
+
import path28 from "node:path";
|
|
8315
8528
|
|
|
8316
8529
|
// src/vite/dev-server.ts
|
|
8317
8530
|
init_logger();
|
|
8318
8531
|
import fs3 from "node:fs/promises";
|
|
8319
8532
|
import http from "node:http";
|
|
8320
8533
|
import https from "node:https";
|
|
8321
|
-
import
|
|
8534
|
+
import path27 from "node:path";
|
|
8322
8535
|
import { createHttpTerminator } from "http-terminator";
|
|
8323
8536
|
import {
|
|
8324
8537
|
createServer as createViteServer,
|
|
@@ -8351,7 +8564,7 @@ init_loader();
|
|
|
8351
8564
|
// src/vite/pagefind-dev-index.ts
|
|
8352
8565
|
init_invariant();
|
|
8353
8566
|
init_joinUrl();
|
|
8354
|
-
import
|
|
8567
|
+
import path26 from "node:path";
|
|
8355
8568
|
import { createIndex as createIndex2 } from "pagefind";
|
|
8356
8569
|
import { isRunnableDevEnvironment } from "vite";
|
|
8357
8570
|
async function* buildPagefindDevIndex(vite, config2) {
|
|
@@ -8404,7 +8617,7 @@ async function* buildPagefindDevIndex(vite, config2) {
|
|
|
8404
8617
|
path: urlPath
|
|
8405
8618
|
};
|
|
8406
8619
|
}
|
|
8407
|
-
const outputPath =
|
|
8620
|
+
const outputPath = path26.join(vite.config.publicDir, "pagefind");
|
|
8408
8621
|
await pagefindIndex.writeFiles({ outputPath });
|
|
8409
8622
|
yield { type: "complete", success: true, indexed };
|
|
8410
8623
|
}
|
|
@@ -8423,9 +8636,9 @@ var DevServer = class {
|
|
|
8423
8636
|
this.protocol = "https";
|
|
8424
8637
|
const { dir } = this.options;
|
|
8425
8638
|
const [key, cert, ca] = await Promise.all([
|
|
8426
|
-
fs3.readFile(
|
|
8427
|
-
fs3.readFile(
|
|
8428
|
-
config2.https.ca ? fs3.readFile(
|
|
8639
|
+
fs3.readFile(path27.resolve(dir, config2.https.key)),
|
|
8640
|
+
fs3.readFile(path27.resolve(dir, config2.https.cert)),
|
|
8641
|
+
config2.https.ca ? fs3.readFile(path27.resolve(dir, config2.https.ca)) : void 0
|
|
8429
8642
|
]);
|
|
8430
8643
|
return https.createServer({ key, cert, ca });
|
|
8431
8644
|
}
|
|
@@ -8452,7 +8665,7 @@ var DevServer = class {
|
|
|
8452
8665
|
// built-in transform middleware which would treat the path as a static asset.
|
|
8453
8666
|
name: "apitogo:entry-client",
|
|
8454
8667
|
configureServer(server2) {
|
|
8455
|
-
const entryPath =
|
|
8668
|
+
const entryPath = path27.posix.join(
|
|
8456
8669
|
server2.config.base,
|
|
8457
8670
|
"/__z/entry.client.tsx"
|
|
8458
8671
|
);
|
|
@@ -8525,13 +8738,13 @@ var DevServer = class {
|
|
|
8525
8738
|
`Server-side rendering ${this.options.ssr ? "enabled" : "disabled"}`
|
|
8526
8739
|
);
|
|
8527
8740
|
if (config2.search?.type === "pagefind") {
|
|
8528
|
-
const pagefindPath =
|
|
8741
|
+
const pagefindPath = path27.join(
|
|
8529
8742
|
vite.config.publicDir,
|
|
8530
8743
|
"pagefind/pagefind.js"
|
|
8531
8744
|
);
|
|
8532
8745
|
const exists = await fs3.stat(pagefindPath).catch(() => false);
|
|
8533
8746
|
if (!exists) {
|
|
8534
|
-
await fs3.mkdir(
|
|
8747
|
+
await fs3.mkdir(path27.dirname(pagefindPath), { recursive: true });
|
|
8535
8748
|
await fs3.writeFile(pagefindPath, 'throw new Error("NOT_BUILT_YET");');
|
|
8536
8749
|
}
|
|
8537
8750
|
}
|
|
@@ -8625,7 +8838,7 @@ init_package_json();
|
|
|
8625
8838
|
async function dev(argv) {
|
|
8626
8839
|
const packageJson2 = getZudokuPackageJson();
|
|
8627
8840
|
process.env.NODE_ENV = "development";
|
|
8628
|
-
const dir =
|
|
8841
|
+
const dir = path28.resolve(process.cwd(), argv.dir);
|
|
8629
8842
|
const server = new DevServer({
|
|
8630
8843
|
dir,
|
|
8631
8844
|
argPort: argv.port,
|
|
@@ -8707,55 +8920,261 @@ var dev_default = {
|
|
|
8707
8920
|
}
|
|
8708
8921
|
};
|
|
8709
8922
|
|
|
8710
|
-
// src/cli/
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
}
|
|
8727
|
-
|
|
8923
|
+
// src/cli/cmds/preview.ts
|
|
8924
|
+
var previewCommand = {
|
|
8925
|
+
desc: "Preview production build",
|
|
8926
|
+
command: "preview",
|
|
8927
|
+
builder: (yargs2) => yargs2.option("dir", {
|
|
8928
|
+
type: "string",
|
|
8929
|
+
describe: "The directory containing your project",
|
|
8930
|
+
default: ".",
|
|
8931
|
+
normalize: true,
|
|
8932
|
+
hidden: true
|
|
8933
|
+
}).option("port", {
|
|
8934
|
+
type: "number",
|
|
8935
|
+
describe: "The port to run the local server on"
|
|
8936
|
+
}),
|
|
8937
|
+
handler: async (argv) => {
|
|
8938
|
+
process.env.NODE_ENV = "production";
|
|
8939
|
+
await captureEvent({ argv, event: "apitogo preview" });
|
|
8940
|
+
await preview(argv);
|
|
8941
|
+
}
|
|
8942
|
+
};
|
|
8943
|
+
var preview_default = previewCommand;
|
|
8944
|
+
|
|
8945
|
+
// src/cli/sync-config/handler.ts
|
|
8946
|
+
import { readFile as readFile5, writeFile as writeFile6 } from "node:fs/promises";
|
|
8947
|
+
import path29 from "node:path";
|
|
8948
|
+
import { glob as glob4 } from "glob";
|
|
8949
|
+
var CONFIG_FILENAMES = [
|
|
8950
|
+
"apitogo.config.tsx",
|
|
8951
|
+
"apitogo.config.ts",
|
|
8952
|
+
"apitogo.config.jsx",
|
|
8953
|
+
"apitogo.config.js",
|
|
8954
|
+
"apitogo.config.mjs",
|
|
8955
|
+
"zudoku.config.tsx",
|
|
8956
|
+
"zudoku.config.ts",
|
|
8957
|
+
"zudoku.config.jsx",
|
|
8958
|
+
"zudoku.config.js",
|
|
8959
|
+
"zudoku.config.mjs"
|
|
8960
|
+
];
|
|
8961
|
+
var createTreeNode = () => ({ docs: [], children: /* @__PURE__ */ new Map() });
|
|
8962
|
+
var toPosixPath2 = (value) => value.split(path29.sep).join(path29.posix.sep);
|
|
8963
|
+
var toRoutePath = (relativeFile, pagesDir) => {
|
|
8964
|
+
const relativeNoExt = relativeFile.replace(/\.mdx?$/, "");
|
|
8965
|
+
const withoutPagesPrefix = relativeNoExt.replace(
|
|
8966
|
+
new RegExp(`^${pagesDir.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/?`),
|
|
8967
|
+
""
|
|
8728
8968
|
);
|
|
8729
|
-
|
|
8969
|
+
const normalized = withoutPagesPrefix.replace(/\/index$/, "");
|
|
8970
|
+
return `/${normalized || "index"}`;
|
|
8730
8971
|
};
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
const
|
|
8972
|
+
var titleCase = (value) => value.split(/[-_\s]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
8973
|
+
var docSortRank = (docPath) => {
|
|
8974
|
+
const lastSegment = docPath.split("/").at(-1) ?? docPath;
|
|
8975
|
+
if (lastSegment === "introduction") return 0;
|
|
8976
|
+
if (lastSegment === "getting-started") return 1;
|
|
8977
|
+
if (lastSegment === "index") return 2;
|
|
8978
|
+
return 3;
|
|
8979
|
+
};
|
|
8980
|
+
var sortDocPaths = (docPaths) => [...docPaths].sort((a, b) => {
|
|
8981
|
+
const rankDiff = docSortRank(a) - docSortRank(b);
|
|
8982
|
+
if (rankDiff !== 0) return rankDiff;
|
|
8983
|
+
return a.localeCompare(b);
|
|
8984
|
+
});
|
|
8985
|
+
var sortDirectoryNames = (names) => [...names].sort((a, b) => a.localeCompare(b));
|
|
8986
|
+
var buildTree = (routePaths) => {
|
|
8987
|
+
const root = createTreeNode();
|
|
8988
|
+
for (const routePath of routePaths) {
|
|
8989
|
+
const segments = routePath.replace(/^\//, "").split("/").filter(Boolean);
|
|
8990
|
+
const directorySegments = segments.slice(0, -1);
|
|
8991
|
+
let current = root;
|
|
8992
|
+
for (const segment of directorySegments) {
|
|
8993
|
+
let child = current.children.get(segment);
|
|
8994
|
+
if (!child) {
|
|
8995
|
+
child = createTreeNode();
|
|
8996
|
+
current.children.set(segment, child);
|
|
8997
|
+
}
|
|
8998
|
+
current = child;
|
|
8999
|
+
}
|
|
9000
|
+
current.docs.push(routePath);
|
|
9001
|
+
}
|
|
9002
|
+
return root;
|
|
9003
|
+
};
|
|
9004
|
+
var treeToNavigationItems = (node) => {
|
|
9005
|
+
const docs = sortDocPaths(node.docs);
|
|
9006
|
+
const categories = sortDirectoryNames([...node.children.keys()]).map((directoryName) => {
|
|
9007
|
+
const childNode = node.children.get(directoryName);
|
|
9008
|
+
if (!childNode) {
|
|
9009
|
+
throw new Error(`Missing child node for directory '${directoryName}'.`);
|
|
9010
|
+
}
|
|
9011
|
+
return {
|
|
9012
|
+
type: "category",
|
|
9013
|
+
label: titleCase(directoryName),
|
|
9014
|
+
items: treeToNavigationItems(childNode)
|
|
9015
|
+
};
|
|
9016
|
+
});
|
|
9017
|
+
return [...docs, ...categories];
|
|
9018
|
+
};
|
|
9019
|
+
var formatNavigationItem = (item, indentLevel) => {
|
|
9020
|
+
const indent = " ".repeat(indentLevel);
|
|
9021
|
+
if (typeof item === "string") {
|
|
9022
|
+
return `${indent}"${item}"`;
|
|
9023
|
+
}
|
|
9024
|
+
const items = item.items.map((subItem) => formatNavigationItem(subItem, indentLevel + 2));
|
|
9025
|
+
return [
|
|
9026
|
+
`${indent}{`,
|
|
9027
|
+
`${indent} type: "category",`,
|
|
9028
|
+
`${indent} label: "${item.label}",`,
|
|
9029
|
+
`${indent} items: [`,
|
|
9030
|
+
items.join(",\n"),
|
|
9031
|
+
`${indent} ],`,
|
|
9032
|
+
`${indent}}`
|
|
9033
|
+
].join("\n");
|
|
9034
|
+
};
|
|
9035
|
+
var buildNavigationCode = (items) => {
|
|
9036
|
+
const docsItems = items.map((item) => formatNavigationItem(item, 3));
|
|
9037
|
+
const documentationItems = [
|
|
9038
|
+
...docsItems,
|
|
9039
|
+
[
|
|
9040
|
+
" {",
|
|
9041
|
+
' type: "category",',
|
|
9042
|
+
' label: "Useful Links",',
|
|
9043
|
+
" collapsible: false,",
|
|
9044
|
+
' icon: "link",',
|
|
9045
|
+
" items: [",
|
|
9046
|
+
" {",
|
|
9047
|
+
' type: "link",',
|
|
9048
|
+
' icon: "book",',
|
|
9049
|
+
' label: "APIToGo",',
|
|
9050
|
+
' to: "https://apitogo.com",',
|
|
9051
|
+
" },",
|
|
9052
|
+
" ],",
|
|
9053
|
+
" },"
|
|
9054
|
+
].join("\n")
|
|
9055
|
+
];
|
|
9056
|
+
return [
|
|
9057
|
+
"[",
|
|
9058
|
+
" {",
|
|
9059
|
+
' type: "category",',
|
|
9060
|
+
' label: "Documentation",',
|
|
9061
|
+
" items: [",
|
|
9062
|
+
documentationItems.join(",\n"),
|
|
9063
|
+
" ],",
|
|
9064
|
+
" },",
|
|
9065
|
+
" {",
|
|
9066
|
+
' type: "link",',
|
|
9067
|
+
' to: "/api",',
|
|
9068
|
+
' label: "API Reference",',
|
|
9069
|
+
" },",
|
|
9070
|
+
"]"
|
|
9071
|
+
].join("\n");
|
|
9072
|
+
};
|
|
9073
|
+
var buildRedirectsCode = (firstDocPath) => `[{ from: "/", to: "${firstDocPath}" }]`;
|
|
9074
|
+
var findMatchingBracket = (source, startIndex) => {
|
|
9075
|
+
let depth = 0;
|
|
9076
|
+
let inSingleQuote = false;
|
|
9077
|
+
let inDoubleQuote = false;
|
|
9078
|
+
let inTemplate = false;
|
|
9079
|
+
let inLineComment = false;
|
|
9080
|
+
let inBlockComment = false;
|
|
9081
|
+
for (let index = startIndex; index < source.length; index++) {
|
|
9082
|
+
const char = source[index];
|
|
9083
|
+
const next = source[index + 1];
|
|
9084
|
+
const prev = source[index - 1];
|
|
9085
|
+
if (inLineComment) {
|
|
9086
|
+
if (char === "\n") inLineComment = false;
|
|
9087
|
+
continue;
|
|
9088
|
+
}
|
|
9089
|
+
if (inBlockComment) {
|
|
9090
|
+
if (prev === "*" && char === "/") inBlockComment = false;
|
|
9091
|
+
continue;
|
|
9092
|
+
}
|
|
9093
|
+
if (!inSingleQuote && !inDoubleQuote && !inTemplate) {
|
|
9094
|
+
if (char === "/" && next === "/") {
|
|
9095
|
+
inLineComment = true;
|
|
9096
|
+
index++;
|
|
9097
|
+
continue;
|
|
9098
|
+
}
|
|
9099
|
+
if (char === "/" && next === "*") {
|
|
9100
|
+
inBlockComment = true;
|
|
9101
|
+
index++;
|
|
9102
|
+
continue;
|
|
9103
|
+
}
|
|
9104
|
+
}
|
|
9105
|
+
if (!inDoubleQuote && !inTemplate && char === "'" && prev !== "\\") {
|
|
9106
|
+
inSingleQuote = !inSingleQuote;
|
|
9107
|
+
continue;
|
|
9108
|
+
}
|
|
9109
|
+
if (!inSingleQuote && !inTemplate && char === '"' && prev !== "\\") {
|
|
9110
|
+
inDoubleQuote = !inDoubleQuote;
|
|
9111
|
+
continue;
|
|
9112
|
+
}
|
|
9113
|
+
if (!inSingleQuote && !inDoubleQuote && char === "`" && prev !== "\\") {
|
|
9114
|
+
inTemplate = !inTemplate;
|
|
9115
|
+
continue;
|
|
9116
|
+
}
|
|
9117
|
+
if (inSingleQuote || inDoubleQuote || inTemplate) continue;
|
|
9118
|
+
if (char === "[") depth++;
|
|
9119
|
+
if (char === "]") depth--;
|
|
9120
|
+
if (depth === 0) return index;
|
|
9121
|
+
}
|
|
9122
|
+
throw new Error("Could not find matching closing bracket.");
|
|
9123
|
+
};
|
|
9124
|
+
var replaceArrayProperty = (source, propertyName, replacement) => {
|
|
9125
|
+
const propertyIndex = source.indexOf(`${propertyName}:`);
|
|
9126
|
+
if (propertyIndex === -1) {
|
|
9127
|
+
throw new Error(`Could not find '${propertyName}' in config file.`);
|
|
9128
|
+
}
|
|
9129
|
+
const arrayStart = source.indexOf("[", propertyIndex);
|
|
9130
|
+
if (arrayStart === -1) {
|
|
9131
|
+
throw new Error(`Could not find array start for '${propertyName}'.`);
|
|
9132
|
+
}
|
|
9133
|
+
const arrayEnd = findMatchingBracket(source, arrayStart);
|
|
9134
|
+
return `${source.slice(0, arrayStart)}${replacement}${source.slice(arrayEnd + 1)}`;
|
|
9135
|
+
};
|
|
9136
|
+
var findConfigPath = async (dir) => {
|
|
9137
|
+
for (const filename of CONFIG_FILENAMES) {
|
|
9138
|
+
const fullPath = path29.join(dir, filename);
|
|
9139
|
+
try {
|
|
9140
|
+
await readFile5(fullPath, "utf8");
|
|
9141
|
+
return fullPath;
|
|
9142
|
+
} catch {
|
|
9143
|
+
}
|
|
9144
|
+
}
|
|
9145
|
+
throw new Error("No APIToGo config file found in the project root.");
|
|
9146
|
+
};
|
|
9147
|
+
async function syncConfig(argv) {
|
|
9148
|
+
const dir = path29.resolve(process.cwd(), argv.dir);
|
|
9149
|
+
const pagesDir = toPosixPath2(argv.pagesDir.replace(/^[./]+/, "").replace(/\/+$/, ""));
|
|
8734
9150
|
try {
|
|
8735
|
-
|
|
8736
|
-
const
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
formData.append(
|
|
8741
|
-
"file",
|
|
8742
|
-
new Blob([archiveBuffer], { type: "application/gzip" }),
|
|
8743
|
-
path28.basename(archivePath)
|
|
8744
|
-
);
|
|
8745
|
-
const response = await fetch(DEPLOY_ENDPOINT, {
|
|
8746
|
-
method: "POST",
|
|
8747
|
-
body: formData
|
|
9151
|
+
const configPath = await findConfigPath(dir);
|
|
9152
|
+
const pageFiles = await glob4(`${pagesDir}/**/*.{md,mdx}`, {
|
|
9153
|
+
cwd: dir,
|
|
9154
|
+
ignore: ["**/node_modules/**", "**/.git/**", "**/dist/**"],
|
|
9155
|
+
posix: true
|
|
8748
9156
|
});
|
|
8749
|
-
const
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
);
|
|
8754
|
-
}
|
|
8755
|
-
printResultToConsole(`Deployment uploaded to ${DEPLOY_ENDPOINT}`);
|
|
8756
|
-
if (responseText.trim()) {
|
|
8757
|
-
printDiagnosticsToConsole(JSON.stringify(textOrJson(responseText), null, 2));
|
|
9157
|
+
const routePaths = sortDocPaths(
|
|
9158
|
+
pageFiles.map((file) => toRoutePath(file, pagesDir))
|
|
9159
|
+
);
|
|
9160
|
+
if (routePaths.length === 0) {
|
|
9161
|
+
throw new Error(`No .md or .mdx files found under '${pagesDir}'.`);
|
|
8758
9162
|
}
|
|
9163
|
+
const tree = buildTree(routePaths);
|
|
9164
|
+
const navigationItems = treeToNavigationItems(tree);
|
|
9165
|
+
const originalConfig = await readFile5(configPath, "utf8");
|
|
9166
|
+
const withNavigation = replaceArrayProperty(
|
|
9167
|
+
originalConfig,
|
|
9168
|
+
"navigation",
|
|
9169
|
+
buildNavigationCode(navigationItems)
|
|
9170
|
+
);
|
|
9171
|
+
const withRedirects = replaceArrayProperty(
|
|
9172
|
+
withNavigation,
|
|
9173
|
+
"redirects",
|
|
9174
|
+
buildRedirectsCode(routePaths[0])
|
|
9175
|
+
);
|
|
9176
|
+
await writeFile6(configPath, withRedirects, "utf8");
|
|
9177
|
+
printResultToConsole(`Updated ${path29.basename(configPath)} from ${pagesDir}/`);
|
|
8759
9178
|
} catch (error) {
|
|
8760
9179
|
await printCriticalFailureToConsoleAndExit(
|
|
8761
9180
|
error instanceof Error ? error.message : String(error)
|
|
@@ -8763,58 +9182,30 @@ async function deploy(argv) {
|
|
|
8763
9182
|
}
|
|
8764
9183
|
}
|
|
8765
9184
|
|
|
8766
|
-
// src/cli/cmds/
|
|
8767
|
-
var
|
|
8768
|
-
desc: "
|
|
8769
|
-
command: "
|
|
9185
|
+
// src/cli/cmds/sync-config.ts
|
|
9186
|
+
var sync_config_default = {
|
|
9187
|
+
desc: "Regenerate navigation from the pages folder",
|
|
9188
|
+
command: "sync-config",
|
|
8770
9189
|
builder: (yargs2) => yargs2.option("dir", {
|
|
8771
9190
|
type: "string",
|
|
8772
9191
|
describe: "The directory containing your project",
|
|
8773
9192
|
default: ".",
|
|
8774
9193
|
normalize: true,
|
|
8775
9194
|
hidden: true
|
|
8776
|
-
}).option("
|
|
8777
|
-
type: "boolean",
|
|
8778
|
-
describe: "Build for server-side rendering (experimental)",
|
|
8779
|
-
default: false
|
|
8780
|
-
}).option("adapter", {
|
|
9195
|
+
}).option("pages-dir", {
|
|
8781
9196
|
type: "string",
|
|
8782
|
-
describe: "
|
|
8783
|
-
|
|
8784
|
-
default: "node"
|
|
9197
|
+
describe: "Directory to scan for md/mdx pages",
|
|
9198
|
+
default: "pages"
|
|
8785
9199
|
}),
|
|
8786
9200
|
handler: async (argv) => {
|
|
8787
|
-
|
|
8788
|
-
await
|
|
8789
|
-
await deploy(argv);
|
|
9201
|
+
await captureEvent({ argv, event: "apitogo sync-config" });
|
|
9202
|
+
await syncConfig(argv);
|
|
8790
9203
|
}
|
|
8791
9204
|
};
|
|
8792
9205
|
|
|
8793
|
-
// src/cli/cmds/preview.ts
|
|
8794
|
-
var previewCommand = {
|
|
8795
|
-
desc: "Preview production build",
|
|
8796
|
-
command: "preview",
|
|
8797
|
-
builder: (yargs2) => yargs2.option("dir", {
|
|
8798
|
-
type: "string",
|
|
8799
|
-
describe: "The directory containing your project",
|
|
8800
|
-
default: ".",
|
|
8801
|
-
normalize: true,
|
|
8802
|
-
hidden: true
|
|
8803
|
-
}).option("port", {
|
|
8804
|
-
type: "number",
|
|
8805
|
-
describe: "The port to run the local server on"
|
|
8806
|
-
}),
|
|
8807
|
-
handler: async (argv) => {
|
|
8808
|
-
process.env.NODE_ENV = "production";
|
|
8809
|
-
await captureEvent({ argv, event: "apitogo preview" });
|
|
8810
|
-
await preview(argv);
|
|
8811
|
-
}
|
|
8812
|
-
};
|
|
8813
|
-
var preview_default = previewCommand;
|
|
8814
|
-
|
|
8815
9206
|
// src/cli/common/outdated.ts
|
|
8816
9207
|
import { existsSync as existsSync2, mkdirSync } from "node:fs";
|
|
8817
|
-
import { readFile as
|
|
9208
|
+
import { readFile as readFile6, writeFile as writeFile7 } from "node:fs/promises";
|
|
8818
9209
|
import { join } from "node:path";
|
|
8819
9210
|
import colors10 from "picocolors";
|
|
8820
9211
|
import { gt } from "semver";
|
|
@@ -8864,12 +9255,12 @@ function box(message, {
|
|
|
8864
9255
|
|
|
8865
9256
|
// src/cli/common/xdg/lib.ts
|
|
8866
9257
|
import { homedir } from "node:os";
|
|
8867
|
-
import
|
|
9258
|
+
import path30 from "node:path";
|
|
8868
9259
|
function defineDirectoryWithFallback(xdgName, fallback) {
|
|
8869
9260
|
if (process.env[xdgName]) {
|
|
8870
9261
|
return process.env[xdgName];
|
|
8871
9262
|
} else {
|
|
8872
|
-
return
|
|
9263
|
+
return path30.join(homedir(), fallback);
|
|
8873
9264
|
}
|
|
8874
9265
|
}
|
|
8875
9266
|
var XDG_CONFIG_HOME = defineDirectoryWithFallback(
|
|
@@ -8884,15 +9275,15 @@ var XDG_STATE_HOME = defineDirectoryWithFallback(
|
|
|
8884
9275
|
"XDG_DATA_HOME",
|
|
8885
9276
|
".local/state"
|
|
8886
9277
|
);
|
|
8887
|
-
var ZUDOKU_XDG_CONFIG_HOME =
|
|
9278
|
+
var ZUDOKU_XDG_CONFIG_HOME = path30.join(
|
|
8888
9279
|
XDG_CONFIG_HOME,
|
|
8889
9280
|
CLI_XDG_FOLDER_NAME
|
|
8890
9281
|
);
|
|
8891
|
-
var ZUDOKU_XDG_DATA_HOME =
|
|
9282
|
+
var ZUDOKU_XDG_DATA_HOME = path30.join(
|
|
8892
9283
|
XDG_DATA_HOME,
|
|
8893
9284
|
CLI_XDG_FOLDER_NAME
|
|
8894
9285
|
);
|
|
8895
|
-
var ZUDOKU_XDG_STATE_HOME =
|
|
9286
|
+
var ZUDOKU_XDG_STATE_HOME = path30.join(
|
|
8896
9287
|
XDG_STATE_HOME,
|
|
8897
9288
|
CLI_XDG_FOLDER_NAME
|
|
8898
9289
|
);
|
|
@@ -8941,7 +9332,7 @@ async function getVersionCheckInfo() {
|
|
|
8941
9332
|
let versionCheckInfo;
|
|
8942
9333
|
if (existsSync2(versionCheckPath)) {
|
|
8943
9334
|
try {
|
|
8944
|
-
versionCheckInfo = await
|
|
9335
|
+
versionCheckInfo = await readFile6(versionCheckPath, "utf-8").then(
|
|
8945
9336
|
JSON.parse
|
|
8946
9337
|
);
|
|
8947
9338
|
} catch {
|
|
@@ -8966,7 +9357,7 @@ async function getVersionCheckInfo() {
|
|
|
8966
9357
|
lastCheck: Date.now(),
|
|
8967
9358
|
latestVersion
|
|
8968
9359
|
};
|
|
8969
|
-
await
|
|
9360
|
+
await writeFile7(
|
|
8970
9361
|
versionCheckPath,
|
|
8971
9362
|
JSON.stringify(versionCheckInfo),
|
|
8972
9363
|
"utf-8"
|
|
@@ -9046,7 +9437,7 @@ var cli = yargs(hideBin(process.argv)).option("zuplo", {
|
|
|
9046
9437
|
process.env.ZUPLO = "1";
|
|
9047
9438
|
printDiagnosticsToConsole("Running in Zuplo mode");
|
|
9048
9439
|
}
|
|
9049
|
-
}).middleware(warnPackageVersionMismatch).command(build_default).command(dev_default).command(deploy_default).command(preview_default).demandCommand().strictCommands().version(packageJson?.version).fail(false).help();
|
|
9440
|
+
}).middleware(warnPackageVersionMismatch).command(build_default).command(dev_default).command(deploy_default).command(preview_default).command(sync_config_default).demandCommand().strictCommands().version(packageJson?.version).fail(false).help();
|
|
9050
9441
|
try {
|
|
9051
9442
|
void warnIfOutdatedVersion(packageJson?.version);
|
|
9052
9443
|
await cli.argv;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lukoweb/apitogo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css",
|
|
@@ -252,9 +252,9 @@
|
|
|
252
252
|
"shiki": "3.23.0",
|
|
253
253
|
"sitemap": "9.0.1",
|
|
254
254
|
"strip-ansi": "7.2.0",
|
|
255
|
+
"tar": "7.5.10",
|
|
255
256
|
"tailwind-merge": "3.5.0",
|
|
256
257
|
"tailwindcss": "4.2.1",
|
|
257
|
-
"tar": "7.5.10",
|
|
258
258
|
"tw-animate-css": "1.4.0",
|
|
259
259
|
"unified": "11.0.5",
|
|
260
260
|
"unist-util-visit": "5.1.0",
|