@lukoweb/apitogo 0.1.99 → 0.1.100
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 +279 -134
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -832,7 +832,7 @@ import { stat } from "node:fs/promises";
|
|
|
832
832
|
var fileExists;
|
|
833
833
|
var init_file_exists = __esm({
|
|
834
834
|
"src/config/file-exists.ts"() {
|
|
835
|
-
fileExists = (
|
|
835
|
+
fileExists = (path71) => stat(path71).then(() => true).catch(() => false);
|
|
836
836
|
}
|
|
837
837
|
});
|
|
838
838
|
|
|
@@ -5628,8 +5628,8 @@ var PlatformApiClient = class {
|
|
|
5628
5628
|
constructor(config2) {
|
|
5629
5629
|
this.config = config2;
|
|
5630
5630
|
}
|
|
5631
|
-
url(
|
|
5632
|
-
return `${this.config.apiUrl}${
|
|
5631
|
+
url(path71) {
|
|
5632
|
+
return `${this.config.apiUrl}${path71.startsWith("/") ? path71 : `/${path71}`}`;
|
|
5633
5633
|
}
|
|
5634
5634
|
headers(extra) {
|
|
5635
5635
|
return {
|
|
@@ -5639,9 +5639,9 @@ var PlatformApiClient = class {
|
|
|
5639
5639
|
...extra
|
|
5640
5640
|
};
|
|
5641
5641
|
}
|
|
5642
|
-
async request(method,
|
|
5642
|
+
async request(method, path71, init4) {
|
|
5643
5643
|
const response = await fetchWithRetry(
|
|
5644
|
-
this.url(
|
|
5644
|
+
this.url(path71),
|
|
5645
5645
|
{
|
|
5646
5646
|
method,
|
|
5647
5647
|
...init4,
|
|
@@ -5841,15 +5841,15 @@ var PlatformApiClient = class {
|
|
|
5841
5841
|
}
|
|
5842
5842
|
);
|
|
5843
5843
|
}
|
|
5844
|
-
deleteDevPortalPage(projectId,
|
|
5845
|
-
const query = new URLSearchParams({ path:
|
|
5844
|
+
deleteDevPortalPage(projectId, path71) {
|
|
5845
|
+
const query = new URLSearchParams({ path: path71 });
|
|
5846
5846
|
return this.request(
|
|
5847
5847
|
"DELETE",
|
|
5848
5848
|
`/api/v1/projects/${projectId}/dev-portal/pages/files?${query.toString()}`
|
|
5849
5849
|
);
|
|
5850
5850
|
}
|
|
5851
|
-
renameDevPortalPage(projectId,
|
|
5852
|
-
const query = new URLSearchParams({ path:
|
|
5851
|
+
renameDevPortalPage(projectId, path71, newName) {
|
|
5852
|
+
const query = new URLSearchParams({ path: path71 });
|
|
5853
5853
|
return this.request(
|
|
5854
5854
|
"POST",
|
|
5855
5855
|
`/api/v1/projects/${projectId}/dev-portal/pages/files/rename?${query.toString()}`,
|
|
@@ -7449,8 +7449,8 @@ function normalizeActionKey(actionKey) {
|
|
|
7449
7449
|
const trimmed = actionKey.trim();
|
|
7450
7450
|
if (trimmed.includes(":")) {
|
|
7451
7451
|
const [method2, ...pathParts] = trimmed.split(":");
|
|
7452
|
-
const
|
|
7453
|
-
return `${method2.toLowerCase()}:${
|
|
7452
|
+
const path72 = pathParts.join(":").trim();
|
|
7453
|
+
return `${method2.toLowerCase()}:${path72.startsWith("/") ? path72 : `/${path72}`}`;
|
|
7454
7454
|
}
|
|
7455
7455
|
const spaceIndex = trimmed.indexOf(" ");
|
|
7456
7456
|
if (spaceIndex <= 0) {
|
|
@@ -7459,8 +7459,8 @@ function normalizeActionKey(actionKey) {
|
|
|
7459
7459
|
);
|
|
7460
7460
|
}
|
|
7461
7461
|
const method = trimmed.slice(0, spaceIndex).trim().toLowerCase();
|
|
7462
|
-
const
|
|
7463
|
-
return `${method}:${
|
|
7462
|
+
const path71 = trimmed.slice(spaceIndex + 1).trim();
|
|
7463
|
+
return `${method}:${path71.startsWith("/") ? path71 : `/${path71}`}`;
|
|
7464
7464
|
}
|
|
7465
7465
|
async function applyGatewayPublicRoutes(client, projectId, routes, options) {
|
|
7466
7466
|
const applied = [];
|
|
@@ -11672,8 +11672,8 @@ function normalizeActionKeyFormat(actionKey) {
|
|
|
11672
11672
|
const trimmed = actionKey.trim();
|
|
11673
11673
|
if (trimmed.includes(":")) {
|
|
11674
11674
|
const [method2, ...pathParts] = trimmed.split(":");
|
|
11675
|
-
const
|
|
11676
|
-
return `${method2.toLowerCase()}:${
|
|
11675
|
+
const path72 = pathParts.join(":").trim();
|
|
11676
|
+
return `${method2.toLowerCase()}:${path72.startsWith("/") ? path72 : `/${path72}`}`;
|
|
11677
11677
|
}
|
|
11678
11678
|
const spaceIndex = trimmed.indexOf(" ");
|
|
11679
11679
|
if (spaceIndex <= 0) {
|
|
@@ -11682,8 +11682,8 @@ function normalizeActionKeyFormat(actionKey) {
|
|
|
11682
11682
|
);
|
|
11683
11683
|
}
|
|
11684
11684
|
const method = trimmed.slice(0, spaceIndex).trim().toLowerCase();
|
|
11685
|
-
const
|
|
11686
|
-
return `${method}:${
|
|
11685
|
+
const path71 = trimmed.slice(spaceIndex + 1).trim();
|
|
11686
|
+
return `${method}:${path71.startsWith("/") ? path71 : `/${path71}`}`;
|
|
11687
11687
|
}
|
|
11688
11688
|
function normalizePublicRoute(route) {
|
|
11689
11689
|
const trimmed = route.trim();
|
|
@@ -12800,7 +12800,7 @@ import {
|
|
|
12800
12800
|
// package.json
|
|
12801
12801
|
var package_default = {
|
|
12802
12802
|
name: "@lukoweb/apitogo",
|
|
12803
|
-
version: "0.1.
|
|
12803
|
+
version: "0.1.100",
|
|
12804
12804
|
type: "module",
|
|
12805
12805
|
sideEffects: [
|
|
12806
12806
|
"**/*.css",
|
|
@@ -13578,14 +13578,14 @@ var flattenAllOf = (schema2) => {
|
|
|
13578
13578
|
};
|
|
13579
13579
|
|
|
13580
13580
|
// src/lib/util/traverse.ts
|
|
13581
|
-
var traverse = (specification, transform,
|
|
13582
|
-
const transformed = transform(specification,
|
|
13581
|
+
var traverse = (specification, transform, path71 = []) => {
|
|
13582
|
+
const transformed = transform(specification, path71);
|
|
13583
13583
|
if (typeof transformed !== "object" || transformed === null) {
|
|
13584
13584
|
return transformed;
|
|
13585
13585
|
}
|
|
13586
13586
|
const result = Array.isArray(transformed) ? [] : {};
|
|
13587
13587
|
for (const [key, value] of Object.entries(transformed)) {
|
|
13588
|
-
const currentPath = [...
|
|
13588
|
+
const currentPath = [...path71, key];
|
|
13589
13589
|
if (Array.isArray(value)) {
|
|
13590
13590
|
result[key] = value.map(
|
|
13591
13591
|
(item, index) => typeof item === "object" && item != null ? traverse(item, transform, [...currentPath, index.toString()]) : item
|
|
@@ -13613,9 +13613,9 @@ var resolveLocalRef = (schema2, ref) => {
|
|
|
13613
13613
|
if (schemaCache?.has(ref)) {
|
|
13614
13614
|
return schemaCache.get(ref);
|
|
13615
13615
|
}
|
|
13616
|
-
const
|
|
13616
|
+
const path71 = ref.split("/").slice(1);
|
|
13617
13617
|
let current = schema2;
|
|
13618
|
-
for (const segment of
|
|
13618
|
+
for (const segment of path71) {
|
|
13619
13619
|
if (!current || typeof current !== "object") {
|
|
13620
13620
|
current = null;
|
|
13621
13621
|
}
|
|
@@ -13634,7 +13634,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
13634
13634
|
}
|
|
13635
13635
|
const cloned = structuredClone(schema2);
|
|
13636
13636
|
const visited = /* @__PURE__ */ new Set();
|
|
13637
|
-
const resolve = async (current,
|
|
13637
|
+
const resolve = async (current, path71) => {
|
|
13638
13638
|
if (isIndexableObject(current)) {
|
|
13639
13639
|
if (visited.has(current)) {
|
|
13640
13640
|
return CIRCULAR_REF;
|
|
@@ -13642,7 +13642,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
13642
13642
|
visited.add(current);
|
|
13643
13643
|
if (Array.isArray(current)) {
|
|
13644
13644
|
for (let index = 0; index < current.length; index++) {
|
|
13645
|
-
current[index] = await resolve(current[index], `${
|
|
13645
|
+
current[index] = await resolve(current[index], `${path71}/${index}`);
|
|
13646
13646
|
}
|
|
13647
13647
|
} else {
|
|
13648
13648
|
if ("$ref" in current && typeof current.$ref === "string") {
|
|
@@ -13653,13 +13653,13 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
13653
13653
|
for (const resolver of resolvers) {
|
|
13654
13654
|
const resolved = await resolver($ref);
|
|
13655
13655
|
if (resolved) {
|
|
13656
|
-
result2 = await resolve(resolved,
|
|
13656
|
+
result2 = await resolve(resolved, path71);
|
|
13657
13657
|
break;
|
|
13658
13658
|
}
|
|
13659
13659
|
}
|
|
13660
13660
|
if (result2 === void 0) {
|
|
13661
13661
|
const resolved = await resolveLocalRef(cloned, $ref);
|
|
13662
|
-
result2 = await resolve(resolved,
|
|
13662
|
+
result2 = await resolve(resolved, path71);
|
|
13663
13663
|
}
|
|
13664
13664
|
if (hasSiblings) {
|
|
13665
13665
|
if (result2 === CIRCULAR_REF) {
|
|
@@ -13672,7 +13672,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
13672
13672
|
return result2;
|
|
13673
13673
|
}
|
|
13674
13674
|
for (const key in current) {
|
|
13675
|
-
current[key] = await resolve(current[key], `${
|
|
13675
|
+
current[key] = await resolve(current[key], `${path71}/${key}`);
|
|
13676
13676
|
}
|
|
13677
13677
|
}
|
|
13678
13678
|
visited.delete(current);
|
|
@@ -13711,9 +13711,9 @@ var upgradeSchema = (schema2) => {
|
|
|
13711
13711
|
}
|
|
13712
13712
|
return sub;
|
|
13713
13713
|
});
|
|
13714
|
-
schema2 = traverse(schema2, (sub,
|
|
13714
|
+
schema2 = traverse(schema2, (sub, path71) => {
|
|
13715
13715
|
if (sub.example !== void 0) {
|
|
13716
|
-
if (isSchemaPath(
|
|
13716
|
+
if (isSchemaPath(path71 ?? [])) {
|
|
13717
13717
|
sub.examples = [sub.example];
|
|
13718
13718
|
} else {
|
|
13719
13719
|
sub.examples = {
|
|
@@ -13726,11 +13726,11 @@ var upgradeSchema = (schema2) => {
|
|
|
13726
13726
|
}
|
|
13727
13727
|
return sub;
|
|
13728
13728
|
});
|
|
13729
|
-
schema2 = traverse(schema2, (schema3,
|
|
13729
|
+
schema2 = traverse(schema2, (schema3, path71) => {
|
|
13730
13730
|
if (schema3.type === "object" && schema3.properties !== void 0) {
|
|
13731
|
-
const parentPath =
|
|
13731
|
+
const parentPath = path71?.slice(0, -1);
|
|
13732
13732
|
const isMultipart = parentPath?.some((segment, index) => {
|
|
13733
|
-
return segment === "content" &&
|
|
13733
|
+
return segment === "content" && path71?.[index + 1] === "multipart/form-data";
|
|
13734
13734
|
});
|
|
13735
13735
|
if (isMultipart) {
|
|
13736
13736
|
const entries = Object.entries(schema3.properties);
|
|
@@ -13744,8 +13744,8 @@ var upgradeSchema = (schema2) => {
|
|
|
13744
13744
|
}
|
|
13745
13745
|
return schema3;
|
|
13746
13746
|
});
|
|
13747
|
-
schema2 = traverse(schema2, (schema3,
|
|
13748
|
-
if (
|
|
13747
|
+
schema2 = traverse(schema2, (schema3, path71) => {
|
|
13748
|
+
if (path71?.includes("content") && path71.includes("application/octet-stream")) {
|
|
13749
13749
|
return {};
|
|
13750
13750
|
}
|
|
13751
13751
|
if (schema3.type === "string" && schema3.format === "binary") {
|
|
@@ -13771,11 +13771,11 @@ var upgradeSchema = (schema2) => {
|
|
|
13771
13771
|
}
|
|
13772
13772
|
return sub;
|
|
13773
13773
|
});
|
|
13774
|
-
schema2 = traverse(schema2, (schema3,
|
|
13774
|
+
schema2 = traverse(schema2, (schema3, path71) => {
|
|
13775
13775
|
if (schema3.type === "string" && schema3.format === "byte") {
|
|
13776
|
-
const parentPath =
|
|
13776
|
+
const parentPath = path71?.slice(0, -1);
|
|
13777
13777
|
const contentMediaType = parentPath?.find(
|
|
13778
|
-
(_, index) =>
|
|
13778
|
+
(_, index) => path71?.[index - 1] === "content"
|
|
13779
13779
|
);
|
|
13780
13780
|
return {
|
|
13781
13781
|
type: "string",
|
|
@@ -13787,7 +13787,7 @@ var upgradeSchema = (schema2) => {
|
|
|
13787
13787
|
});
|
|
13788
13788
|
return schema2;
|
|
13789
13789
|
};
|
|
13790
|
-
function isSchemaPath(
|
|
13790
|
+
function isSchemaPath(path71) {
|
|
13791
13791
|
const schemaLocations = [
|
|
13792
13792
|
["components", "schemas"],
|
|
13793
13793
|
"properties",
|
|
@@ -13800,10 +13800,10 @@ function isSchemaPath(path70) {
|
|
|
13800
13800
|
];
|
|
13801
13801
|
return schemaLocations.some((location) => {
|
|
13802
13802
|
if (Array.isArray(location)) {
|
|
13803
|
-
return location.every((segment, index) =>
|
|
13803
|
+
return location.every((segment, index) => path71[index] === segment);
|
|
13804
13804
|
}
|
|
13805
|
-
return
|
|
13806
|
-
}) ||
|
|
13805
|
+
return path71.includes(location);
|
|
13806
|
+
}) || path71.includes("schema") || path71.some((segment) => segment.endsWith("Schema"));
|
|
13807
13807
|
}
|
|
13808
13808
|
|
|
13809
13809
|
// src/lib/oas/parser/index.ts
|
|
@@ -13885,13 +13885,13 @@ var OPENAPI_PROPS = /* @__PURE__ */ new Set([
|
|
|
13885
13885
|
"anyOf",
|
|
13886
13886
|
"oneOf"
|
|
13887
13887
|
]);
|
|
13888
|
-
var handleCircularRefs = (obj, currentPath = /* @__PURE__ */ new WeakSet(), refs = /* @__PURE__ */ new WeakMap(),
|
|
13888
|
+
var handleCircularRefs = (obj, currentPath = /* @__PURE__ */ new WeakSet(), refs = /* @__PURE__ */ new WeakMap(), path71 = [], currentRefPaths = /* @__PURE__ */ new Set()) => {
|
|
13889
13889
|
if (obj === null || typeof obj !== "object") return obj;
|
|
13890
13890
|
const refPath = obj.__$ref;
|
|
13891
13891
|
const isCircular = currentPath.has(obj) || typeof refPath === "string" && currentRefPaths.has(refPath);
|
|
13892
13892
|
if (isCircular) {
|
|
13893
13893
|
if (typeof refPath === "string") return SCHEMA_REF_PREFIX + refPath;
|
|
13894
|
-
const circularProp =
|
|
13894
|
+
const circularProp = path71.find((p) => !OPENAPI_PROPS.has(p)) || path71[0];
|
|
13895
13895
|
return [CIRCULAR_REF, circularProp].filter(Boolean).join(":");
|
|
13896
13896
|
}
|
|
13897
13897
|
if (refs.has(obj)) return refs.get(obj);
|
|
@@ -13901,7 +13901,7 @@ var handleCircularRefs = (obj, currentPath = /* @__PURE__ */ new WeakSet(), refs
|
|
|
13901
13901
|
value,
|
|
13902
13902
|
currentPath,
|
|
13903
13903
|
refs,
|
|
13904
|
-
[...
|
|
13904
|
+
[...path71, key],
|
|
13905
13905
|
currentRefPaths
|
|
13906
13906
|
);
|
|
13907
13907
|
const result = Array.isArray(obj) ? obj.map((item, i) => recurse(item, i.toString())) : Object.fromEntries(
|
|
@@ -13936,7 +13936,7 @@ var resolveExtensions = (obj) => Object.fromEntries(
|
|
|
13936
13936
|
var getAllTags = (schema2) => {
|
|
13937
13937
|
const rootTags = schema2.tags ?? [];
|
|
13938
13938
|
const operations = Object.values(schema2.paths ?? {}).flatMap(
|
|
13939
|
-
(
|
|
13939
|
+
(path71) => HttpMethods.map((k) => path71?.[k]).filter((op) => op != null)
|
|
13940
13940
|
);
|
|
13941
13941
|
const operationTags = new Set(operations.flatMap((op) => op.tags ?? []));
|
|
13942
13942
|
const hasUntaggedOperations = operations.some(
|
|
@@ -13991,7 +13991,7 @@ var getAllSlugs = (ops, schemaTags = []) => {
|
|
|
13991
13991
|
var getOperationSlugKey = (op) => [op.path, op.method, op.operationId, op.summary].filter(Boolean).join("-");
|
|
13992
13992
|
var getAllOperations = (paths) => {
|
|
13993
13993
|
const operations = Object.entries(paths ?? {}).flatMap(
|
|
13994
|
-
([
|
|
13994
|
+
([path71, value]) => HttpMethods.flatMap((method) => {
|
|
13995
13995
|
if (!value?.[method]) return [];
|
|
13996
13996
|
const operation = value[method];
|
|
13997
13997
|
const pathParameters = value.parameters ?? [];
|
|
@@ -14011,7 +14011,7 @@ var getAllOperations = (paths) => {
|
|
|
14011
14011
|
return {
|
|
14012
14012
|
...operation,
|
|
14013
14013
|
method,
|
|
14014
|
-
path:
|
|
14014
|
+
path: path71,
|
|
14015
14015
|
parameters,
|
|
14016
14016
|
servers,
|
|
14017
14017
|
tags: operation.tags ?? []
|
|
@@ -14369,8 +14369,8 @@ var Schema = builder.objectRef("Schema").implement({
|
|
|
14369
14369
|
}),
|
|
14370
14370
|
paths: t.field({
|
|
14371
14371
|
type: [PathItem],
|
|
14372
|
-
resolve: (root) => Object.entries(root.paths ?? {}).map(([
|
|
14373
|
-
path:
|
|
14372
|
+
resolve: (root) => Object.entries(root.paths ?? {}).map(([path71, value]) => ({
|
|
14373
|
+
path: path71,
|
|
14374
14374
|
// biome-ignore lint/style/noNonNullAssertion: value is guaranteed to be defined
|
|
14375
14375
|
methods: Object.keys(value)
|
|
14376
14376
|
}))
|
|
@@ -14535,7 +14535,7 @@ init_joinUrl();
|
|
|
14535
14535
|
|
|
14536
14536
|
// src/vite/api/schema-codegen.ts
|
|
14537
14537
|
var unescapeJsonPointer = (uri) => decodeURIComponent(uri.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
14538
|
-
var getSegmentsFromPath = (
|
|
14538
|
+
var getSegmentsFromPath = (path71) => path71.split("/").slice(1).map(unescapeJsonPointer);
|
|
14539
14539
|
var createLocalRefMap = (obj) => {
|
|
14540
14540
|
const refMap = /* @__PURE__ */ new Map();
|
|
14541
14541
|
const siblingsMap = /* @__PURE__ */ new Map();
|
|
@@ -14566,16 +14566,16 @@ var replaceMarkers = (code, mergedRefs) => code.replace(/"__refMap:(.*?)"/g, '__
|
|
|
14566
14566
|
/"__refMap\+Siblings:(.*?)"/g,
|
|
14567
14567
|
(_, key) => mergedRefs.get(key) ?? `__refMap["${key}"]`
|
|
14568
14568
|
);
|
|
14569
|
-
var lookup2 = (schema2,
|
|
14570
|
-
const parts = getSegmentsFromPath(
|
|
14569
|
+
var lookup2 = (schema2, path71, filePath) => {
|
|
14570
|
+
const parts = getSegmentsFromPath(path71);
|
|
14571
14571
|
let val = schema2;
|
|
14572
14572
|
for (const part of parts) {
|
|
14573
14573
|
while (val.$ref?.startsWith("#/")) {
|
|
14574
|
-
val = val.$ref ===
|
|
14574
|
+
val = val.$ref === path71 ? val : lookup2(schema2, val.$ref, filePath);
|
|
14575
14575
|
}
|
|
14576
14576
|
if (val[part] === void 0) {
|
|
14577
14577
|
throw new Error(
|
|
14578
|
-
`Error in ${filePath ?? "code generation"}: Could not find path segment ${part} in path: ${
|
|
14578
|
+
`Error in ${filePath ?? "code generation"}: Could not find path segment ${part} in path: ${path71}`
|
|
14579
14579
|
);
|
|
14580
14580
|
}
|
|
14581
14581
|
val = val[part];
|
|
@@ -14820,8 +14820,8 @@ var SchemaManager = class {
|
|
|
14820
14820
|
}
|
|
14821
14821
|
}
|
|
14822
14822
|
};
|
|
14823
|
-
getLatestSchema = (
|
|
14824
|
-
getSchemasForPath = (
|
|
14823
|
+
getLatestSchema = (path71) => this.processedSchemas[path71]?.at(0);
|
|
14824
|
+
getSchemasForPath = (path71) => this.processedSchemas[path71];
|
|
14825
14825
|
getSchemaImports = () => Object.values(this.processedSchemas).flat().filter((s) => s.importKey);
|
|
14826
14826
|
getUrlToFilePathMap = () => {
|
|
14827
14827
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -17279,14 +17279,14 @@ async function generateSitemap({
|
|
|
17279
17279
|
|
|
17280
17280
|
// src/vite/prerender/utils.ts
|
|
17281
17281
|
init_joinUrl();
|
|
17282
|
-
var resolveRoutePath = (
|
|
17283
|
-
const segments =
|
|
17282
|
+
var resolveRoutePath = (path71) => {
|
|
17283
|
+
const segments = path71.split("/");
|
|
17284
17284
|
if (segments.some((s) => s.startsWith(":") && !s.endsWith("?"))) {
|
|
17285
17285
|
return void 0;
|
|
17286
17286
|
}
|
|
17287
17287
|
return segments.filter((s) => !s.startsWith(":")).join("/") || void 0;
|
|
17288
17288
|
};
|
|
17289
|
-
var isSkipped = (
|
|
17289
|
+
var isSkipped = (path71) => path71.includes("*") || /^\d+$/.test(path71);
|
|
17290
17290
|
var resolveRoutes = (routes, parentPath = "") => routes.flatMap((route) => {
|
|
17291
17291
|
if (route.path && isSkipped(route.path)) return [];
|
|
17292
17292
|
const routePath = route.path ? resolveRoutePath(route.path) : void 0;
|
|
@@ -17878,7 +17878,7 @@ var check_default = {
|
|
|
17878
17878
|
// src/cli/make-config/handler.ts
|
|
17879
17879
|
import { constants as constants2 } from "node:fs";
|
|
17880
17880
|
import { access as access8, mkdir as mkdir12, readFile as readFile16, writeFile as writeFile15 } from "node:fs/promises";
|
|
17881
|
-
import
|
|
17881
|
+
import path61 from "node:path";
|
|
17882
17882
|
import { stdin as input2 } from "node:process";
|
|
17883
17883
|
import { glob as glob5 } from "glob";
|
|
17884
17884
|
|
|
@@ -19912,7 +19912,7 @@ function printPlanAddedHint(displayName) {
|
|
|
19912
19912
|
`Plan "${displayName}" added to modules.userPanel.plans.items in apitogo.config.json.`
|
|
19913
19913
|
);
|
|
19914
19914
|
printDiagnosticsToConsole(
|
|
19915
|
-
"New plans
|
|
19915
|
+
"New plans copy includedActionKeys from the local OpenAPI file when present. Set includedActionKeys to restrict, and configure Stripe before publishing paid plans."
|
|
19916
19916
|
);
|
|
19917
19917
|
printDiagnosticsToConsole(`Docs: ${DOCS}/docs/configuration/plans`);
|
|
19918
19918
|
}
|
|
@@ -20368,8 +20368,139 @@ async function ensureThinConfigTsx(dir) {
|
|
|
20368
20368
|
return true;
|
|
20369
20369
|
}
|
|
20370
20370
|
|
|
20371
|
+
// src/cli/platform/helpers/openapi-action-keys.ts
|
|
20372
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "node:fs";
|
|
20373
|
+
import path60 from "node:path";
|
|
20374
|
+
import YAML3 from "yaml";
|
|
20375
|
+
var HTTP_METHODS = [
|
|
20376
|
+
"get",
|
|
20377
|
+
"post",
|
|
20378
|
+
"put",
|
|
20379
|
+
"patch",
|
|
20380
|
+
"delete",
|
|
20381
|
+
"head",
|
|
20382
|
+
"options"
|
|
20383
|
+
];
|
|
20384
|
+
function normalizeOpenApiPathTemplate(pathTemplate) {
|
|
20385
|
+
if (!pathTemplate.trim()) {
|
|
20386
|
+
return "/";
|
|
20387
|
+
}
|
|
20388
|
+
let value = pathTemplate.trim();
|
|
20389
|
+
if (!value.startsWith("/")) {
|
|
20390
|
+
value = `/${value}`;
|
|
20391
|
+
}
|
|
20392
|
+
if (value.length > 1 && value.endsWith("/")) {
|
|
20393
|
+
value = value.replace(/\/+$/, "");
|
|
20394
|
+
}
|
|
20395
|
+
return value;
|
|
20396
|
+
}
|
|
20397
|
+
function resolveRelativeServerBasePath(document) {
|
|
20398
|
+
const serverUrl = document.servers?.[0]?.url;
|
|
20399
|
+
if (!serverUrl || serverUrl === "/") {
|
|
20400
|
+
return null;
|
|
20401
|
+
}
|
|
20402
|
+
return serverUrl.startsWith("/") ? serverUrl.replace(/\/+$/, "") : null;
|
|
20403
|
+
}
|
|
20404
|
+
function combineBasePath(basePath, pathKey) {
|
|
20405
|
+
const normalizedPath = normalizeOpenApiPathTemplate(pathKey);
|
|
20406
|
+
if (!basePath || basePath === "/") {
|
|
20407
|
+
return normalizedPath;
|
|
20408
|
+
}
|
|
20409
|
+
const baseNorm = normalizeOpenApiPathTemplate(basePath);
|
|
20410
|
+
if (normalizedPath === "/") {
|
|
20411
|
+
return baseNorm;
|
|
20412
|
+
}
|
|
20413
|
+
return `${baseNorm.replace(/\/+$/, "")}${normalizedPath}`;
|
|
20414
|
+
}
|
|
20415
|
+
function extractGatewayActionKeysFromOpenApiDocument(document) {
|
|
20416
|
+
if (!document || typeof document !== "object") {
|
|
20417
|
+
return [];
|
|
20418
|
+
}
|
|
20419
|
+
const spec = document;
|
|
20420
|
+
if (!spec.paths || typeof spec.paths !== "object") {
|
|
20421
|
+
return [];
|
|
20422
|
+
}
|
|
20423
|
+
const basePath = resolveRelativeServerBasePath(spec);
|
|
20424
|
+
const keys = /* @__PURE__ */ new Set();
|
|
20425
|
+
for (const [pathKey, pathItem] of Object.entries(spec.paths)) {
|
|
20426
|
+
if (!pathItem || typeof pathItem !== "object") {
|
|
20427
|
+
continue;
|
|
20428
|
+
}
|
|
20429
|
+
const pathTemplate = combineBasePath(basePath, pathKey);
|
|
20430
|
+
for (const method of HTTP_METHODS) {
|
|
20431
|
+
if (!pathItem[method] || typeof pathItem[method] !== "object") {
|
|
20432
|
+
continue;
|
|
20433
|
+
}
|
|
20434
|
+
keys.add(`${method}:${pathTemplate}`);
|
|
20435
|
+
}
|
|
20436
|
+
}
|
|
20437
|
+
return [...keys].sort((a, b) => a.localeCompare(b));
|
|
20438
|
+
}
|
|
20439
|
+
function extractGatewayActionKeysFromOpenApiFile(filePath) {
|
|
20440
|
+
try {
|
|
20441
|
+
const raw = readFileSync3(filePath, "utf8");
|
|
20442
|
+
const ext = path60.extname(filePath).toLowerCase();
|
|
20443
|
+
const parsed = ext === ".json" ? JSON.parse(raw) : YAML3.parse(raw);
|
|
20444
|
+
return extractGatewayActionKeysFromOpenApiDocument(parsed);
|
|
20445
|
+
} catch {
|
|
20446
|
+
return [];
|
|
20447
|
+
}
|
|
20448
|
+
}
|
|
20449
|
+
function resolveConfigOpenApiFilePath(siteDirectory, config2) {
|
|
20450
|
+
const backend = config2.backend;
|
|
20451
|
+
const candidates = [];
|
|
20452
|
+
if (typeof backend?.openApiPath === "string" && backend.openApiPath.trim()) {
|
|
20453
|
+
candidates.push(backend.openApiPath.trim());
|
|
20454
|
+
}
|
|
20455
|
+
const apis = config2.apis;
|
|
20456
|
+
const entries = Array.isArray(apis) ? apis : apis ? [apis] : [];
|
|
20457
|
+
for (const entry of entries) {
|
|
20458
|
+
if (entry && typeof entry === "object" && entry.type === "file" && typeof entry.input === "string") {
|
|
20459
|
+
candidates.push(entry.input);
|
|
20460
|
+
}
|
|
20461
|
+
}
|
|
20462
|
+
for (const candidate of candidates) {
|
|
20463
|
+
const resolved = path60.isAbsolute(candidate) ? candidate : path60.resolve(siteDirectory, candidate);
|
|
20464
|
+
if (existsSync4(resolved)) {
|
|
20465
|
+
return resolved;
|
|
20466
|
+
}
|
|
20467
|
+
}
|
|
20468
|
+
return void 0;
|
|
20469
|
+
}
|
|
20470
|
+
function loadOpenApiActionKeysForSite(siteDirectory, config2) {
|
|
20471
|
+
const filePath = resolveConfigOpenApiFilePath(siteDirectory, config2);
|
|
20472
|
+
if (!filePath) {
|
|
20473
|
+
return [];
|
|
20474
|
+
}
|
|
20475
|
+
return extractGatewayActionKeysFromOpenApiFile(filePath);
|
|
20476
|
+
}
|
|
20477
|
+
function loadOpenApiActionKeysFromSiteDirectory(siteDirectory) {
|
|
20478
|
+
const configPath = path60.join(siteDirectory, "apitogo.config.json");
|
|
20479
|
+
if (!existsSync4(configPath)) {
|
|
20480
|
+
return [];
|
|
20481
|
+
}
|
|
20482
|
+
try {
|
|
20483
|
+
const parsed = JSON.parse(readFileSync3(configPath, "utf8"));
|
|
20484
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
20485
|
+
return [];
|
|
20486
|
+
}
|
|
20487
|
+
return loadOpenApiActionKeysForSite(siteDirectory, parsed);
|
|
20488
|
+
} catch {
|
|
20489
|
+
return [];
|
|
20490
|
+
}
|
|
20491
|
+
}
|
|
20492
|
+
function withDefaultIncludedActionKeys(plan, actionKeys) {
|
|
20493
|
+
if (plan.includedActionKeys && plan.includedActionKeys.length > 0) {
|
|
20494
|
+
return plan;
|
|
20495
|
+
}
|
|
20496
|
+
if (actionKeys.length === 0) {
|
|
20497
|
+
return plan;
|
|
20498
|
+
}
|
|
20499
|
+
return { ...plan, includedActionKeys: actionKeys };
|
|
20500
|
+
}
|
|
20501
|
+
|
|
20371
20502
|
// src/cli/make-config/handler.ts
|
|
20372
|
-
var toPosixPath2 = (value) => value.split(
|
|
20503
|
+
var toPosixPath2 = (value) => value.split(path61.sep).join(path61.posix.sep);
|
|
20373
20504
|
var fileExists3 = async (filePath) => {
|
|
20374
20505
|
try {
|
|
20375
20506
|
await access8(filePath, constants2.F_OK);
|
|
@@ -20427,7 +20558,7 @@ async function persistConfig(config2, ctx) {
|
|
|
20427
20558
|
};
|
|
20428
20559
|
await writeFile15(ctx.jsonPath, `${JSON.stringify(next, null, 2)}
|
|
20429
20560
|
`, "utf8");
|
|
20430
|
-
const tsxPath =
|
|
20561
|
+
const tsxPath = path61.join(ctx.dir, "apitogo.config.tsx");
|
|
20431
20562
|
if (await fileExists3(tsxPath) && tsxRoutes.length > 0) {
|
|
20432
20563
|
const tsxSource = await readFile16(tsxPath, "utf8");
|
|
20433
20564
|
if (isManagedConfigWrapper(tsxSource)) {
|
|
@@ -20454,7 +20585,7 @@ function mergeBackendFlag(config2, backend) {
|
|
|
20454
20585
|
return next;
|
|
20455
20586
|
}
|
|
20456
20587
|
async function makeConfig(argv) {
|
|
20457
|
-
const dir =
|
|
20588
|
+
const dir = path61.resolve(process.cwd(), argv.dir);
|
|
20458
20589
|
const pagesDir = toPosixPath2(
|
|
20459
20590
|
argv.pagesDir.replace(/^[./]+/, "").replace(/\/+$/, "")
|
|
20460
20591
|
);
|
|
@@ -20474,14 +20605,14 @@ async function makeConfig(argv) {
|
|
|
20474
20605
|
printDiagnosticsToConsole("Created tsconfig.json.");
|
|
20475
20606
|
}
|
|
20476
20607
|
await ensurePortalStubFiles(dir);
|
|
20477
|
-
const jsonPath =
|
|
20608
|
+
const jsonPath = path61.join(dir, APITOGO_JSON_FILENAME);
|
|
20478
20609
|
let createdJson = false;
|
|
20479
20610
|
let config2;
|
|
20480
20611
|
if (await fileExists3(jsonPath)) {
|
|
20481
20612
|
config2 = await readJsonConfig(jsonPath);
|
|
20482
20613
|
} else {
|
|
20483
20614
|
config2 = createDefaultApitogoJsonConfig({
|
|
20484
|
-
title: titleFromDirectoryName(
|
|
20615
|
+
title: titleFromDirectoryName(path61.basename(dir)),
|
|
20485
20616
|
pagesDir
|
|
20486
20617
|
});
|
|
20487
20618
|
createdJson = true;
|
|
@@ -20530,8 +20661,8 @@ async function makeConfig(argv) {
|
|
|
20530
20661
|
return;
|
|
20531
20662
|
}
|
|
20532
20663
|
if (action2.kind === "page") {
|
|
20533
|
-
const pagePath =
|
|
20534
|
-
await mkdir12(
|
|
20664
|
+
const pagePath = path61.join(dir, action2.page.relativePath);
|
|
20665
|
+
await mkdir12(path61.dirname(pagePath), { recursive: true });
|
|
20535
20666
|
await writeFile15(
|
|
20536
20667
|
pagePath,
|
|
20537
20668
|
buildStarterDocsPageTsx(action2.page.slug, action2.page.title),
|
|
@@ -20541,7 +20672,10 @@ async function makeConfig(argv) {
|
|
|
20541
20672
|
return;
|
|
20542
20673
|
}
|
|
20543
20674
|
if (action2.kind === "plan") {
|
|
20544
|
-
|
|
20675
|
+
const actionKeys = loadOpenApiActionKeysForSite(dir, config2);
|
|
20676
|
+
config2 = applyPlansToJsonConfig(config2, [
|
|
20677
|
+
withDefaultIncludedActionKeys(action2.planItem, actionKeys)
|
|
20678
|
+
]);
|
|
20545
20679
|
config2 = await persistConfig(config2, persistCtx);
|
|
20546
20680
|
}
|
|
20547
20681
|
}
|
|
@@ -20555,6 +20689,14 @@ async function makeConfig(argv) {
|
|
|
20555
20689
|
if (argv.patch !== void 0) {
|
|
20556
20690
|
const patch = parseJsonObjectFlag(argv.patch, "patch");
|
|
20557
20691
|
if (patch) {
|
|
20692
|
+
const plans = patch.plans;
|
|
20693
|
+
if (Array.isArray(plans)) {
|
|
20694
|
+
const actionKeys = loadOpenApiActionKeysForSite(dir, config2);
|
|
20695
|
+
const keys = actionKeys.length > 0 ? actionKeys : loadOpenApiActionKeysFromSiteDirectory(dir);
|
|
20696
|
+
patch.plans = plans.map(
|
|
20697
|
+
(plan) => isPlainObject3(plan) ? withDefaultIncludedActionKeys(plan, keys) : plan
|
|
20698
|
+
);
|
|
20699
|
+
}
|
|
20558
20700
|
config2 = deepMerge(config2, patch);
|
|
20559
20701
|
changes.push("patch");
|
|
20560
20702
|
}
|
|
@@ -20569,7 +20711,10 @@ async function makeConfig(argv) {
|
|
|
20569
20711
|
if (argv.plan !== void 0) {
|
|
20570
20712
|
const plan = parseJsonObjectFlag(argv.plan, "plan");
|
|
20571
20713
|
if (plan) {
|
|
20572
|
-
|
|
20714
|
+
const actionKeys = loadOpenApiActionKeysForSite(dir, config2);
|
|
20715
|
+
config2 = applyPlansToJsonConfig(config2, [
|
|
20716
|
+
withDefaultIncludedActionKeys(plan, actionKeys)
|
|
20717
|
+
]);
|
|
20573
20718
|
changes.push("plan");
|
|
20574
20719
|
}
|
|
20575
20720
|
}
|
|
@@ -20584,7 +20729,7 @@ async function makeConfig(argv) {
|
|
|
20584
20729
|
if (argv.openapi) {
|
|
20585
20730
|
const wire = await wireDevPortalOpenApi(
|
|
20586
20731
|
dir,
|
|
20587
|
-
|
|
20732
|
+
path61.resolve(dir, argv.openapi)
|
|
20588
20733
|
);
|
|
20589
20734
|
if (wire.status !== "succeeded") {
|
|
20590
20735
|
throw new Error(
|
|
@@ -20613,7 +20758,7 @@ async function makeConfig(argv) {
|
|
|
20613
20758
|
const slug = normalizePageSlug(argv.pageSlug);
|
|
20614
20759
|
const pageTemplate = normalizePageTemplate(argv.pageTemplate);
|
|
20615
20760
|
const relativePagePath = pageComponentRelativePath(slug);
|
|
20616
|
-
const filePath =
|
|
20761
|
+
const filePath = path61.join(dir, relativePagePath);
|
|
20617
20762
|
const isUpdate = argv.pageUpdate === true;
|
|
20618
20763
|
if (isUpdate) {
|
|
20619
20764
|
if (!await fileExists3(filePath)) {
|
|
@@ -20646,7 +20791,7 @@ async function makeConfig(argv) {
|
|
|
20646
20791
|
argv.pageContent,
|
|
20647
20792
|
pageTemplate
|
|
20648
20793
|
);
|
|
20649
|
-
await mkdir12(
|
|
20794
|
+
await mkdir12(path61.dirname(filePath), { recursive: true });
|
|
20650
20795
|
await writeFile15(filePath, tsx, "utf8");
|
|
20651
20796
|
const configResult = await wireNewDevPortalPageInConfig(
|
|
20652
20797
|
dir,
|
|
@@ -20659,7 +20804,7 @@ async function makeConfig(argv) {
|
|
|
20659
20804
|
pagePath: relativePagePath,
|
|
20660
20805
|
pageTemplate,
|
|
20661
20806
|
configUpdated: configResult.updated,
|
|
20662
|
-
configPath: configResult.configPath ?
|
|
20807
|
+
configPath: configResult.configPath ? path61.relative(dir, configResult.configPath) : null
|
|
20663
20808
|
};
|
|
20664
20809
|
changes.push("page_add");
|
|
20665
20810
|
}
|
|
@@ -20813,14 +20958,14 @@ var deploy_default = {
|
|
|
20813
20958
|
|
|
20814
20959
|
// src/cli/dev/handler.ts
|
|
20815
20960
|
init_joinUrl();
|
|
20816
|
-
import
|
|
20961
|
+
import path64 from "node:path";
|
|
20817
20962
|
|
|
20818
20963
|
// src/vite/dev-server.ts
|
|
20819
20964
|
init_logger();
|
|
20820
20965
|
import fs11 from "node:fs/promises";
|
|
20821
20966
|
import http from "node:http";
|
|
20822
20967
|
import https from "node:https";
|
|
20823
|
-
import
|
|
20968
|
+
import path63 from "node:path";
|
|
20824
20969
|
import { createHttpTerminator } from "http-terminator";
|
|
20825
20970
|
import {
|
|
20826
20971
|
createServer as createViteServer,
|
|
@@ -20853,7 +20998,7 @@ init_loader();
|
|
|
20853
20998
|
// src/vite/pagefind-dev-index.ts
|
|
20854
20999
|
init_invariant();
|
|
20855
21000
|
init_joinUrl();
|
|
20856
|
-
import
|
|
21001
|
+
import path62 from "node:path";
|
|
20857
21002
|
import { createIndex as createIndex2 } from "pagefind";
|
|
20858
21003
|
import { isRunnableDevEnvironment } from "vite";
|
|
20859
21004
|
async function* buildPagefindDevIndex(vite, config2) {
|
|
@@ -20906,7 +21051,7 @@ async function* buildPagefindDevIndex(vite, config2) {
|
|
|
20906
21051
|
path: urlPath
|
|
20907
21052
|
};
|
|
20908
21053
|
}
|
|
20909
|
-
const outputPath =
|
|
21054
|
+
const outputPath = path62.join(vite.config.publicDir, "pagefind");
|
|
20910
21055
|
await pagefindIndex.writeFiles({ outputPath });
|
|
20911
21056
|
yield { type: "complete", success: true, indexed };
|
|
20912
21057
|
}
|
|
@@ -20925,9 +21070,9 @@ var DevServer = class {
|
|
|
20925
21070
|
this.protocol = "https";
|
|
20926
21071
|
const { dir } = this.options;
|
|
20927
21072
|
const [key, cert, ca] = await Promise.all([
|
|
20928
|
-
fs11.readFile(
|
|
20929
|
-
fs11.readFile(
|
|
20930
|
-
config2.https.ca ? fs11.readFile(
|
|
21073
|
+
fs11.readFile(path63.resolve(dir, config2.https.key)),
|
|
21074
|
+
fs11.readFile(path63.resolve(dir, config2.https.cert)),
|
|
21075
|
+
config2.https.ca ? fs11.readFile(path63.resolve(dir, config2.https.ca)) : void 0
|
|
20931
21076
|
]);
|
|
20932
21077
|
return https.createServer({ key, cert, ca });
|
|
20933
21078
|
}
|
|
@@ -20944,7 +21089,7 @@ var DevServer = class {
|
|
|
20944
21089
|
);
|
|
20945
21090
|
const server = await this.createNodeServer(config2);
|
|
20946
21091
|
if (config2.search?.type === "pagefind" && viteConfig.publicDir !== false) {
|
|
20947
|
-
const publicRoot =
|
|
21092
|
+
const publicRoot = path63.resolve(
|
|
20948
21093
|
this.options.dir,
|
|
20949
21094
|
typeof viteConfig.publicDir === "string" ? viteConfig.publicDir : "public"
|
|
20950
21095
|
);
|
|
@@ -20961,7 +21106,7 @@ var DevServer = class {
|
|
|
20961
21106
|
// built-in transform middleware which would treat the path as a static asset.
|
|
20962
21107
|
name: "apitogo:entry-client",
|
|
20963
21108
|
configureServer(server2) {
|
|
20964
|
-
const entryPath =
|
|
21109
|
+
const entryPath = path63.posix.join(
|
|
20965
21110
|
server2.config.base,
|
|
20966
21111
|
"/__z/entry.client.tsx"
|
|
20967
21112
|
);
|
|
@@ -21126,7 +21271,7 @@ init_package_json();
|
|
|
21126
21271
|
async function dev(argv) {
|
|
21127
21272
|
const packageJson2 = getZudokuPackageJson();
|
|
21128
21273
|
process.env.NODE_ENV = "development";
|
|
21129
|
-
const dir =
|
|
21274
|
+
const dir = path64.resolve(process.cwd(), argv.dir);
|
|
21130
21275
|
const server = new DevServer({
|
|
21131
21276
|
dir,
|
|
21132
21277
|
argPort: argv.port,
|
|
@@ -21209,11 +21354,11 @@ var dev_default = {
|
|
|
21209
21354
|
};
|
|
21210
21355
|
|
|
21211
21356
|
// src/cli/init/handler.ts
|
|
21212
|
-
import
|
|
21357
|
+
import path67 from "node:path";
|
|
21213
21358
|
|
|
21214
21359
|
// src/cli/scaffold/run-scaffold-discovery.ts
|
|
21215
21360
|
import { access as access10, readFile as readFile18, writeFile as writeFile17 } from "node:fs/promises";
|
|
21216
|
-
import
|
|
21361
|
+
import path66 from "node:path";
|
|
21217
21362
|
|
|
21218
21363
|
// src/cli/scaffold/wire-docs.ts
|
|
21219
21364
|
import {
|
|
@@ -21226,7 +21371,7 @@ import {
|
|
|
21226
21371
|
symlink,
|
|
21227
21372
|
writeFile as writeFile16
|
|
21228
21373
|
} from "node:fs/promises";
|
|
21229
|
-
import
|
|
21374
|
+
import path65 from "node:path";
|
|
21230
21375
|
var DOCS_DIR_WHITELIST = [
|
|
21231
21376
|
"docs",
|
|
21232
21377
|
"documents",
|
|
@@ -21263,14 +21408,14 @@ async function isDirectory(filePath) {
|
|
|
21263
21408
|
}
|
|
21264
21409
|
}
|
|
21265
21410
|
function toPosix2(value) {
|
|
21266
|
-
return value.split(
|
|
21411
|
+
return value.split(path65.sep).join(path65.posix.sep);
|
|
21267
21412
|
}
|
|
21268
21413
|
function isWhitelistedDirName(name) {
|
|
21269
21414
|
return DOCS_DIR_WHITELIST.includes(name.toLowerCase());
|
|
21270
21415
|
}
|
|
21271
21416
|
function isInside2(parent, child) {
|
|
21272
|
-
const relative =
|
|
21273
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
21417
|
+
const relative = path65.relative(parent, child);
|
|
21418
|
+
return relative === "" || !relative.startsWith("..") && !path65.isAbsolute(relative);
|
|
21274
21419
|
}
|
|
21275
21420
|
async function collectMarkdownFiles(dir) {
|
|
21276
21421
|
const files = [];
|
|
@@ -21284,7 +21429,7 @@ async function collectMarkdownFiles(dir) {
|
|
|
21284
21429
|
if (entry.name.startsWith(".")) {
|
|
21285
21430
|
continue;
|
|
21286
21431
|
}
|
|
21287
|
-
const full =
|
|
21432
|
+
const full = path65.join(dir, entry.name);
|
|
21288
21433
|
if (entry.isDirectory()) {
|
|
21289
21434
|
if (SKIP_SEARCH_DIRS.has(entry.name) || entry.isSymbolicLink()) {
|
|
21290
21435
|
continue;
|
|
@@ -21299,11 +21444,11 @@ async function collectMarkdownFiles(dir) {
|
|
|
21299
21444
|
return files;
|
|
21300
21445
|
}
|
|
21301
21446
|
async function collectSearchRoots(siteDirectory) {
|
|
21302
|
-
const site =
|
|
21303
|
-
const parent =
|
|
21447
|
+
const site = path65.resolve(siteDirectory);
|
|
21448
|
+
const parent = path65.dirname(site);
|
|
21304
21449
|
const roots = [];
|
|
21305
21450
|
const add = (dir) => {
|
|
21306
|
-
const resolved =
|
|
21451
|
+
const resolved = path65.resolve(dir);
|
|
21307
21452
|
if (!roots.includes(resolved)) {
|
|
21308
21453
|
roots.push(resolved);
|
|
21309
21454
|
}
|
|
@@ -21316,7 +21461,7 @@ async function collectSearchRoots(siteDirectory) {
|
|
|
21316
21461
|
if (!entry.isDirectory() || SKIP_SEARCH_DIRS.has(entry.name)) {
|
|
21317
21462
|
continue;
|
|
21318
21463
|
}
|
|
21319
|
-
add(
|
|
21464
|
+
add(path65.join(parent, entry.name));
|
|
21320
21465
|
}
|
|
21321
21466
|
} catch {
|
|
21322
21467
|
}
|
|
@@ -21325,13 +21470,13 @@ async function collectSearchRoots(siteDirectory) {
|
|
|
21325
21470
|
return roots;
|
|
21326
21471
|
}
|
|
21327
21472
|
async function discoverNearbyDocsDirectories(siteDirectory) {
|
|
21328
|
-
const site =
|
|
21329
|
-
const sitePages =
|
|
21473
|
+
const site = path65.resolve(siteDirectory);
|
|
21474
|
+
const sitePages = path65.join(site, PAGES_DIR);
|
|
21330
21475
|
const searchedDirectories = await collectSearchRoots(site);
|
|
21331
21476
|
const directories = [];
|
|
21332
21477
|
const seen = /* @__PURE__ */ new Set();
|
|
21333
21478
|
const consider = async (dir) => {
|
|
21334
|
-
const resolved =
|
|
21479
|
+
const resolved = path65.resolve(dir);
|
|
21335
21480
|
if (resolved === site || seen.has(resolved) || isInside2(sitePages, resolved)) {
|
|
21336
21481
|
return;
|
|
21337
21482
|
}
|
|
@@ -21348,7 +21493,7 @@ async function discoverNearbyDocsDirectories(siteDirectory) {
|
|
|
21348
21493
|
directories.push({ sourceDirectory: resolved, files });
|
|
21349
21494
|
};
|
|
21350
21495
|
for (const root of searchedDirectories) {
|
|
21351
|
-
if (isWhitelistedDirName(
|
|
21496
|
+
if (isWhitelistedDirName(path65.basename(root))) {
|
|
21352
21497
|
await consider(root);
|
|
21353
21498
|
}
|
|
21354
21499
|
try {
|
|
@@ -21360,7 +21505,7 @@ async function discoverNearbyDocsDirectories(siteDirectory) {
|
|
|
21360
21505
|
if (!isWhitelistedDirName(entry.name)) {
|
|
21361
21506
|
continue;
|
|
21362
21507
|
}
|
|
21363
|
-
await consider(
|
|
21508
|
+
await consider(path65.join(root, entry.name));
|
|
21364
21509
|
}
|
|
21365
21510
|
} catch {
|
|
21366
21511
|
}
|
|
@@ -21371,8 +21516,8 @@ function slugifyDirName(name) {
|
|
|
21371
21516
|
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "docs";
|
|
21372
21517
|
}
|
|
21373
21518
|
async function allocateLinkName(pagesDir, sourceDirectory, used) {
|
|
21374
|
-
const base = slugifyDirName(
|
|
21375
|
-
const parent = slugifyDirName(
|
|
21519
|
+
const base = slugifyDirName(path65.basename(sourceDirectory));
|
|
21520
|
+
const parent = slugifyDirName(path65.basename(path65.dirname(sourceDirectory)));
|
|
21376
21521
|
const candidates = [base, `${parent}-${base}`];
|
|
21377
21522
|
let index = 2;
|
|
21378
21523
|
while (true) {
|
|
@@ -21380,7 +21525,7 @@ async function allocateLinkName(pagesDir, sourceDirectory, used) {
|
|
|
21380
21525
|
if (used.has(name)) {
|
|
21381
21526
|
continue;
|
|
21382
21527
|
}
|
|
21383
|
-
const target =
|
|
21528
|
+
const target = path65.join(pagesDir, name);
|
|
21384
21529
|
if (await pathExists5(target)) {
|
|
21385
21530
|
const stat4 = await lstat(target);
|
|
21386
21531
|
if (!stat4.isDirectory() || !await isManagedLinkDir(target)) {
|
|
@@ -21411,8 +21556,8 @@ async function alreadyLinked(linkPath, sourcePath) {
|
|
|
21411
21556
|
return false;
|
|
21412
21557
|
}
|
|
21413
21558
|
const current = await readlink(linkPath);
|
|
21414
|
-
const resolved =
|
|
21415
|
-
return resolved ===
|
|
21559
|
+
const resolved = path65.resolve(path65.dirname(linkPath), current);
|
|
21560
|
+
return resolved === path65.resolve(sourcePath);
|
|
21416
21561
|
} catch {
|
|
21417
21562
|
return false;
|
|
21418
21563
|
}
|
|
@@ -21424,8 +21569,8 @@ async function linkMarkdownFile(sourcePath, linkPath) {
|
|
|
21424
21569
|
if (await pathExists5(linkPath)) {
|
|
21425
21570
|
return "skipped";
|
|
21426
21571
|
}
|
|
21427
|
-
await mkdir13(
|
|
21428
|
-
const relativeTarget =
|
|
21572
|
+
await mkdir13(path65.dirname(linkPath), { recursive: true });
|
|
21573
|
+
const relativeTarget = path65.relative(path65.dirname(linkPath), sourcePath);
|
|
21429
21574
|
await symlink(
|
|
21430
21575
|
relativeTarget,
|
|
21431
21576
|
linkPath,
|
|
@@ -21440,7 +21585,7 @@ async function applyDocsNavigation(siteDirectory, routes) {
|
|
|
21440
21585
|
if (routes.length === 0) {
|
|
21441
21586
|
return;
|
|
21442
21587
|
}
|
|
21443
|
-
const configPath =
|
|
21588
|
+
const configPath = path65.join(siteDirectory, CONFIG_FILENAME);
|
|
21444
21589
|
if (!await pathExists5(configPath)) {
|
|
21445
21590
|
return;
|
|
21446
21591
|
}
|
|
@@ -21456,8 +21601,8 @@ async function applyDocsNavigation(siteDirectory, routes) {
|
|
|
21456
21601
|
`, "utf8");
|
|
21457
21602
|
}
|
|
21458
21603
|
async function discoverAndWireDocs(siteDirectory) {
|
|
21459
|
-
const site =
|
|
21460
|
-
const pagesDir =
|
|
21604
|
+
const site = path65.resolve(siteDirectory);
|
|
21605
|
+
const pagesDir = path65.join(site, PAGES_DIR);
|
|
21461
21606
|
const { directories, searchedDirectories } = await discoverNearbyDocsDirectories(site);
|
|
21462
21607
|
if (directories.length === 0) {
|
|
21463
21608
|
return {
|
|
@@ -21479,14 +21624,14 @@ async function discoverAndWireDocs(siteDirectory) {
|
|
|
21479
21624
|
directory.sourceDirectory,
|
|
21480
21625
|
usedNames
|
|
21481
21626
|
);
|
|
21482
|
-
const linkDirectory =
|
|
21627
|
+
const linkDirectory = path65.join(pagesDir, linkName);
|
|
21483
21628
|
const linked = [];
|
|
21484
21629
|
const skipped = [];
|
|
21485
21630
|
for (const sourcePath of directory.files) {
|
|
21486
21631
|
const relativeSource = toPosix2(
|
|
21487
|
-
|
|
21632
|
+
path65.relative(directory.sourceDirectory, sourcePath)
|
|
21488
21633
|
);
|
|
21489
|
-
const linkPath =
|
|
21634
|
+
const linkPath = path65.join(linkDirectory, relativeSource);
|
|
21490
21635
|
const result = await linkMarkdownFile(sourcePath, linkPath);
|
|
21491
21636
|
if (result === "skipped") {
|
|
21492
21637
|
skipped.push({
|
|
@@ -21495,7 +21640,7 @@ async function discoverAndWireDocs(siteDirectory) {
|
|
|
21495
21640
|
});
|
|
21496
21641
|
continue;
|
|
21497
21642
|
}
|
|
21498
|
-
const relativeLink = toPosix2(
|
|
21643
|
+
const relativeLink = toPosix2(path65.relative(site, linkPath));
|
|
21499
21644
|
const route = toRoutePath(relativeLink, PAGES_DIR);
|
|
21500
21645
|
linked.push({ sourcePath, linkPath, route, relativeSource });
|
|
21501
21646
|
routes.push(route);
|
|
@@ -21528,11 +21673,11 @@ async function discoverAndWireDocs(siteDirectory) {
|
|
|
21528
21673
|
};
|
|
21529
21674
|
}
|
|
21530
21675
|
function siteRelative(siteDirectory, filePath) {
|
|
21531
|
-
const relative = toPosix2(
|
|
21676
|
+
const relative = toPosix2(path65.relative(siteDirectory, filePath));
|
|
21532
21677
|
if (!relative) {
|
|
21533
21678
|
return ".";
|
|
21534
21679
|
}
|
|
21535
|
-
if (
|
|
21680
|
+
if (path65.isAbsolute(relative)) {
|
|
21536
21681
|
return toPosix2(filePath);
|
|
21537
21682
|
}
|
|
21538
21683
|
if (relative.startsWith("..")) {
|
|
@@ -21599,7 +21744,7 @@ async function pathExists6(filePath) {
|
|
|
21599
21744
|
}
|
|
21600
21745
|
async function wireOpenApiIntoJsonConfig(siteDirectory, openApiPath) {
|
|
21601
21746
|
const input3 = toSiteRelativeOpenApiInput(siteDirectory, openApiPath);
|
|
21602
|
-
const jsonConfigPath =
|
|
21747
|
+
const jsonConfigPath = path66.join(siteDirectory, "apitogo.config.json");
|
|
21603
21748
|
const raw = await readFile18(jsonConfigPath, "utf8");
|
|
21604
21749
|
const siteConfig = JSON.parse(raw);
|
|
21605
21750
|
const updated = applyOpenApiToSiteConfig(siteConfig, {
|
|
@@ -21651,7 +21796,7 @@ async function discoverAndWireOpenApiLite(siteDirectory, mode) {
|
|
|
21651
21796
|
wired: false
|
|
21652
21797
|
};
|
|
21653
21798
|
}
|
|
21654
|
-
const jsonConfigPath =
|
|
21799
|
+
const jsonConfigPath = path66.join(siteDirectory, "apitogo.config.json");
|
|
21655
21800
|
if (!await pathExists6(jsonConfigPath)) {
|
|
21656
21801
|
return {
|
|
21657
21802
|
openApiDiscovery: {
|
|
@@ -21712,8 +21857,8 @@ function slugifyName2(name) {
|
|
|
21712
21857
|
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "dev-portal-site";
|
|
21713
21858
|
}
|
|
21714
21859
|
function resolveInitOutputDirectory(dirArg, name) {
|
|
21715
|
-
const resolved =
|
|
21716
|
-
const base =
|
|
21860
|
+
const resolved = path67.resolve(process.cwd(), dirArg);
|
|
21861
|
+
const base = path67.basename(resolved);
|
|
21717
21862
|
const isDot = dirArg === "." || dirArg === "./" || base === "." || resolved === process.cwd();
|
|
21718
21863
|
if (isDot) {
|
|
21719
21864
|
const fromName = name?.trim();
|
|
@@ -21723,7 +21868,7 @@ function resolveInitOutputDirectory(dirArg, name) {
|
|
|
21723
21868
|
);
|
|
21724
21869
|
}
|
|
21725
21870
|
return {
|
|
21726
|
-
outputDirectory:
|
|
21871
|
+
outputDirectory: path67.resolve(process.cwd(), slugifyName2(fromName)),
|
|
21727
21872
|
siteName: fromName
|
|
21728
21873
|
};
|
|
21729
21874
|
}
|
|
@@ -21967,9 +22112,9 @@ var remove_default = {
|
|
|
21967
22112
|
};
|
|
21968
22113
|
|
|
21969
22114
|
// src/cli/status/handler.ts
|
|
21970
|
-
import
|
|
22115
|
+
import path68 from "node:path";
|
|
21971
22116
|
async function status(argv) {
|
|
21972
|
-
const sourceDirectory =
|
|
22117
|
+
const sourceDirectory = path68.resolve(process.cwd(), argv.dir);
|
|
21973
22118
|
const config2 = loadConfig();
|
|
21974
22119
|
const client = new PlatformApiClient(config2);
|
|
21975
22120
|
let whoamiJson;
|
|
@@ -22049,7 +22194,7 @@ var status_default = {
|
|
|
22049
22194
|
};
|
|
22050
22195
|
|
|
22051
22196
|
// src/cli/teardown/handler.ts
|
|
22052
|
-
import
|
|
22197
|
+
import path69 from "node:path";
|
|
22053
22198
|
function resultLooksFailed3(payload) {
|
|
22054
22199
|
try {
|
|
22055
22200
|
const parsed = JSON.parse(payload);
|
|
@@ -22065,7 +22210,7 @@ async function teardown(argv) {
|
|
|
22065
22210
|
);
|
|
22066
22211
|
return;
|
|
22067
22212
|
}
|
|
22068
|
-
const sourceDirectory =
|
|
22213
|
+
const sourceDirectory = path69.resolve(process.cwd(), argv.dir);
|
|
22069
22214
|
const config2 = loadConfig();
|
|
22070
22215
|
const client = new PlatformApiClient(config2);
|
|
22071
22216
|
let projectId = argv.projectId?.trim();
|
|
@@ -22130,7 +22275,7 @@ var teardown_default = {
|
|
|
22130
22275
|
};
|
|
22131
22276
|
|
|
22132
22277
|
// src/cli/common/outdated.ts
|
|
22133
|
-
import { existsSync as
|
|
22278
|
+
import { existsSync as existsSync5, mkdirSync } from "node:fs";
|
|
22134
22279
|
import { readFile as readFile19, writeFile as writeFile18 } from "node:fs/promises";
|
|
22135
22280
|
import { join } from "node:path";
|
|
22136
22281
|
import colors10 from "picocolors";
|
|
@@ -22198,12 +22343,12 @@ function box(message, {
|
|
|
22198
22343
|
|
|
22199
22344
|
// src/cli/common/xdg/lib.ts
|
|
22200
22345
|
import { homedir } from "node:os";
|
|
22201
|
-
import
|
|
22346
|
+
import path70 from "node:path";
|
|
22202
22347
|
function defineDirectoryWithFallback(xdgName, fallback) {
|
|
22203
22348
|
if (process.env[xdgName]) {
|
|
22204
22349
|
return process.env[xdgName];
|
|
22205
22350
|
} else {
|
|
22206
|
-
return
|
|
22351
|
+
return path70.join(homedir(), fallback);
|
|
22207
22352
|
}
|
|
22208
22353
|
}
|
|
22209
22354
|
var XDG_CONFIG_HOME = defineDirectoryWithFallback(
|
|
@@ -22218,15 +22363,15 @@ var XDG_STATE_HOME = defineDirectoryWithFallback(
|
|
|
22218
22363
|
"XDG_DATA_HOME",
|
|
22219
22364
|
".local/state"
|
|
22220
22365
|
);
|
|
22221
|
-
var ZUDOKU_XDG_CONFIG_HOME =
|
|
22366
|
+
var ZUDOKU_XDG_CONFIG_HOME = path70.join(
|
|
22222
22367
|
XDG_CONFIG_HOME,
|
|
22223
22368
|
CLI_XDG_FOLDER_NAME
|
|
22224
22369
|
);
|
|
22225
|
-
var ZUDOKU_XDG_DATA_HOME =
|
|
22370
|
+
var ZUDOKU_XDG_DATA_HOME = path70.join(
|
|
22226
22371
|
XDG_DATA_HOME,
|
|
22227
22372
|
CLI_XDG_FOLDER_NAME
|
|
22228
22373
|
);
|
|
22229
|
-
var ZUDOKU_XDG_STATE_HOME =
|
|
22374
|
+
var ZUDOKU_XDG_STATE_HOME = path70.join(
|
|
22230
22375
|
XDG_STATE_HOME,
|
|
22231
22376
|
CLI_XDG_FOLDER_NAME
|
|
22232
22377
|
);
|
|
@@ -22271,12 +22416,12 @@ async function getLatestVersion() {
|
|
|
22271
22416
|
return void 0;
|
|
22272
22417
|
}
|
|
22273
22418
|
async function getVersionCheckInfo() {
|
|
22274
|
-
if (!
|
|
22419
|
+
if (!existsSync5(ZUDOKU_XDG_STATE_HOME)) {
|
|
22275
22420
|
mkdirSync(ZUDOKU_XDG_STATE_HOME, { recursive: true });
|
|
22276
22421
|
}
|
|
22277
22422
|
const versionCheckPath = join(ZUDOKU_XDG_STATE_HOME, VERSION_CHECK_FILE);
|
|
22278
22423
|
let versionCheckInfo;
|
|
22279
|
-
if (
|
|
22424
|
+
if (existsSync5(versionCheckPath)) {
|
|
22280
22425
|
try {
|
|
22281
22426
|
versionCheckInfo = await readFile19(versionCheckPath, "utf-8").then(
|
|
22282
22427
|
JSON.parse
|