@lukoweb/apitogo 0.1.102 → 0.1.104
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/cli.js +1 -1
- package/dist/cli/cli.js +873 -869
- package/dist/declarations/lib/components/SiteTitle.d.ts +4 -0
- package/docs/cli/commands.md +3 -3
- package/docs/cli/go-live.md +14 -14
- package/docs/cli/overview.md +19 -19
- package/docs/cli/setup.md +31 -28
- package/docs/cli/shape.md +12 -12
- package/docs/configuration/authentication.md +2 -2
- package/docs/configuration/make-config.mdx +4 -5
- package/docs/configuration/manifest.md +2 -2
- package/docs/configuration/navigation.mdx +1 -1
- package/docs/configuration/overview.md +1 -1
- package/docs/configuration/plans.md +6 -6
- package/docs/deploy/apitogo.md +3 -3
- package/docs/deployment.md +2 -2
- package/docs/guides/custom-pages.md +1 -1
- package/docs/guides/environment-variables.md +1 -1
- package/docs/markdown/frontmatter.md +2 -2
- package/docs/mcp/go-live.md +1 -1
- package/package.json +3 -3
- package/src/lib/components/Header.tsx +2 -4
- package/src/lib/components/SiteTitle.tsx +17 -5
package/dist/cli/cli.js
CHANGED
|
@@ -8,23 +8,6 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
// src/cli/common/package-json.ts
|
|
12
|
-
import { readFileSync } from "node:fs";
|
|
13
|
-
import path from "node:path";
|
|
14
|
-
import { fileURLToPath } from "node:url";
|
|
15
|
-
var getPackageJsonPath, getPackageJson, getZudokuPackageJson, getZudokuRootDir;
|
|
16
|
-
var init_package_json = __esm({
|
|
17
|
-
"src/cli/common/package-json.ts"() {
|
|
18
|
-
getPackageJsonPath = (pkg) => fileURLToPath(import.meta.resolve(`${pkg}/package.json`)).replaceAll(
|
|
19
|
-
path.sep,
|
|
20
|
-
path.posix.sep
|
|
21
|
-
);
|
|
22
|
-
getPackageJson = (pkgPath) => JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
23
|
-
getZudokuPackageJson = () => getPackageJson(getPackageJsonPath("@lukoweb/apitogo"));
|
|
24
|
-
getZudokuRootDir = () => path.dirname(getPackageJsonPath("@lukoweb/apitogo"));
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
11
|
// src/cli/common/logger.ts
|
|
29
12
|
import { createLogger } from "vite";
|
|
30
13
|
var logger, loggerError, isExpectedWarning, wrapWarnFilter;
|
|
@@ -52,6 +35,23 @@ var init_logger = __esm({
|
|
|
52
35
|
}
|
|
53
36
|
});
|
|
54
37
|
|
|
38
|
+
// src/cli/common/package-json.ts
|
|
39
|
+
import { readFileSync } from "node:fs";
|
|
40
|
+
import path2 from "node:path";
|
|
41
|
+
import { fileURLToPath } from "node:url";
|
|
42
|
+
var getPackageJsonPath, getPackageJson, getZudokuPackageJson, getZudokuRootDir;
|
|
43
|
+
var init_package_json = __esm({
|
|
44
|
+
"src/cli/common/package-json.ts"() {
|
|
45
|
+
getPackageJsonPath = (pkg) => fileURLToPath(import.meta.resolve(`${pkg}/package.json`)).replaceAll(
|
|
46
|
+
path2.sep,
|
|
47
|
+
path2.posix.sep
|
|
48
|
+
);
|
|
49
|
+
getPackageJson = (pkgPath) => JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
50
|
+
getZudokuPackageJson = () => getPackageJson(getPackageJsonPath("@lukoweb/apitogo"));
|
|
51
|
+
getZudokuRootDir = () => path2.dirname(getPackageJsonPath("@lukoweb/apitogo"));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
55
|
// src/lib/authentication/auth-header-nav.ts
|
|
56
56
|
function withoutLoginNavigation(navigation) {
|
|
57
57
|
return navigation.filter(
|
|
@@ -751,13 +751,13 @@ var init_apitogo_config_core = __esm({
|
|
|
751
751
|
});
|
|
752
752
|
|
|
753
753
|
// src/config/apitogo-config-loader.node.ts
|
|
754
|
-
import { existsSync, readFileSync as readFileSync2 } from "node:fs";
|
|
755
|
-
import
|
|
754
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
755
|
+
import path3 from "node:path";
|
|
756
756
|
function loadApitogoConfig(rootDir = process.cwd()) {
|
|
757
|
-
const configPath =
|
|
758
|
-
if (!
|
|
757
|
+
const configPath = path3.join(path3.resolve(rootDir), APITOGO_CONFIG_FILENAME);
|
|
758
|
+
if (!existsSync2(configPath)) {
|
|
759
759
|
throw new Error(
|
|
760
|
-
`Missing ${APITOGO_CONFIG_FILENAME} in ${
|
|
760
|
+
`Missing ${APITOGO_CONFIG_FILENAME} in ${path3.resolve(rootDir)}`
|
|
761
761
|
);
|
|
762
762
|
}
|
|
763
763
|
const raw = readFileSync2(configPath, "utf8");
|
|
@@ -1086,7 +1086,7 @@ var init_landing_manifest = __esm({
|
|
|
1086
1086
|
});
|
|
1087
1087
|
|
|
1088
1088
|
// src/config/local-manifest.ts
|
|
1089
|
-
import
|
|
1089
|
+
import path4 from "node:path";
|
|
1090
1090
|
import { z as z4 } from "zod";
|
|
1091
1091
|
function isPricingEnabled(manifest) {
|
|
1092
1092
|
return manifest?.pricing?.enabled === true;
|
|
@@ -1137,8 +1137,8 @@ function resolveManifestEnv(viteMode) {
|
|
|
1137
1137
|
return viteMode === "production" ? "production" : "development";
|
|
1138
1138
|
}
|
|
1139
1139
|
function manifestPathsForEnv(rootDir, _env) {
|
|
1140
|
-
const resolvedRoot =
|
|
1141
|
-
const configPath =
|
|
1140
|
+
const resolvedRoot = path4.resolve(rootDir);
|
|
1141
|
+
const configPath = path4.join(resolvedRoot, APITOGO_CONFIG_FILENAME);
|
|
1142
1142
|
return {
|
|
1143
1143
|
basePath: configPath,
|
|
1144
1144
|
overridePath: configPath,
|
|
@@ -1829,7 +1829,7 @@ var init_shadcn_registry = __esm({
|
|
|
1829
1829
|
|
|
1830
1830
|
// src/vite/plugin-theme.ts
|
|
1831
1831
|
import { createRequire } from "node:module";
|
|
1832
|
-
import
|
|
1832
|
+
import path5 from "node:path";
|
|
1833
1833
|
import { normalizeTheme } from "shiki";
|
|
1834
1834
|
var THEME_VARIABLES, uncamelize, processColorValue, generateCss, generateRegistryCss, processCustomCss, MAIN_REPLACE, DEFAULT_THEME_REPLACE, GOOGLE_FONTS, getGoogleFontUrl, processFont, processFontConfig, DEFAULT_FONT_SANS, DEFAULT_FONT_MONO, DEFAULT_FONT_HEADING, processFonts, MODULE_SOURCE_PACKAGES, resolveModuleSourceDirs, virtualModuleId, resolvedVirtualModuleId, viteThemePlugin;
|
|
1835
1835
|
var init_plugin_theme = __esm({
|
|
@@ -2008,7 +2008,7 @@ var init_plugin_theme = __esm({
|
|
|
2008
2008
|
resolveModuleSourceDirs = (config2) => {
|
|
2009
2009
|
if (config2.__meta.mode === "internal") {
|
|
2010
2010
|
return MODULE_SOURCE_PACKAGES.map(
|
|
2011
|
-
(pkg) =>
|
|
2011
|
+
(pkg) => path5.join(
|
|
2012
2012
|
config2.__meta.moduleDir,
|
|
2013
2013
|
"..",
|
|
2014
2014
|
pkg.replace("@lukoweb/apitogo-", ""),
|
|
@@ -2017,12 +2017,12 @@ var init_plugin_theme = __esm({
|
|
|
2017
2017
|
);
|
|
2018
2018
|
}
|
|
2019
2019
|
const require2 = createRequire(
|
|
2020
|
-
|
|
2020
|
+
path5.join(config2.__meta.rootDir, "package.json")
|
|
2021
2021
|
);
|
|
2022
2022
|
const dirs = [];
|
|
2023
2023
|
for (const pkg of MODULE_SOURCE_PACKAGES) {
|
|
2024
2024
|
try {
|
|
2025
|
-
dirs.push(
|
|
2025
|
+
dirs.push(path5.dirname(require2.resolve(pkg)));
|
|
2026
2026
|
} catch {
|
|
2027
2027
|
}
|
|
2028
2028
|
}
|
|
@@ -2148,7 +2148,7 @@ ${rootVars.join("\n")}
|
|
|
2148
2148
|
...config2.__meta.dependencies,
|
|
2149
2149
|
...config2.__pluginDirs ?? [],
|
|
2150
2150
|
...resolveModuleSourceDirs(config2)
|
|
2151
|
-
].map((file) =>
|
|
2151
|
+
].map((file) => path5.relative(path5.dirname(id), file))
|
|
2152
2152
|
);
|
|
2153
2153
|
const code = [...files].map((file) => `@source "${file}";`);
|
|
2154
2154
|
code.push("@theme inline {");
|
|
@@ -4439,7 +4439,7 @@ __export(ZudokuConfig_exports, {
|
|
|
4439
4439
|
ZudokuConfig: () => ZudokuConfig,
|
|
4440
4440
|
validateConfig: () => validateConfig
|
|
4441
4441
|
});
|
|
4442
|
-
import
|
|
4442
|
+
import colors4 from "picocolors";
|
|
4443
4443
|
import { isValidElement as isValidElement2 } from "react";
|
|
4444
4444
|
import { z as z9 } from "zod";
|
|
4445
4445
|
function validateConfig(config2, configPath) {
|
|
@@ -4451,8 +4451,8 @@ function validateConfig(config2, configPath) {
|
|
|
4451
4451
|
${z9.prettifyError(validationResult.error)}`
|
|
4452
4452
|
);
|
|
4453
4453
|
}
|
|
4454
|
-
console.log(
|
|
4455
|
-
console.log(
|
|
4454
|
+
console.log(colors4.yellow("Validation errors:"));
|
|
4455
|
+
console.log(colors4.yellow(z9.prettifyError(validationResult.error)));
|
|
4456
4456
|
}
|
|
4457
4457
|
}
|
|
4458
4458
|
var ThemeSchema, ApiCatalogCategorySchema, LanguageOption, AiAssistantCustomSchema, AiAssistantPresets, AiAssistantsSchema, ApiOptionsSchema, ApiConfigSchema, VersionConfigSchema, ApiSchema, ApiKeysSchema, LogoSchema, FooterSocialIcons, FooterSocialSchema, FooterSchema, SiteMapSchema, DEFAULT_DOCS_FILES, LlmsConfigSchema, DocsConfigSchema, Redirect, SearchSchema, AuthenticationSchema, MetadataSchema, FontConfigSchema, FontsConfigSchema, CssObject, ThemeConfigSchema, SiteSchema, PlacementPosition, HeaderConfigSchema, ApiCatalogSchema, CdnUrlSchema, BaseConfigSchema, ZudokuConfig;
|
|
@@ -4990,8 +4990,8 @@ var init_ZudokuConfig = __esm({
|
|
|
4990
4990
|
|
|
4991
4991
|
// src/config/loader.ts
|
|
4992
4992
|
import { stat as stat2 } from "node:fs/promises";
|
|
4993
|
-
import
|
|
4994
|
-
import
|
|
4993
|
+
import path6 from "node:path";
|
|
4994
|
+
import colors5 from "picocolors";
|
|
4995
4995
|
import {
|
|
4996
4996
|
runnerImport,
|
|
4997
4997
|
loadEnv as viteLoadEnv
|
|
@@ -5017,7 +5017,7 @@ function mergeJsonConfigWithRuntimeOverrides(fileConfig, importedConfig) {
|
|
|
5017
5017
|
}
|
|
5018
5018
|
async function getConfigFilePath(rootDir) {
|
|
5019
5019
|
for (const fileName of zudokuConfigFiles) {
|
|
5020
|
-
const filepath =
|
|
5020
|
+
const filepath = path6.join(rootDir, fileName);
|
|
5021
5021
|
if (await fileExists(filepath)) {
|
|
5022
5022
|
return filepath;
|
|
5023
5023
|
}
|
|
@@ -5181,7 +5181,7 @@ async function loadZudokuConfig(configEnv, rootDir) {
|
|
|
5181
5181
|
};
|
|
5182
5182
|
if (!process.env.APITOGO_JSON_ONLY) {
|
|
5183
5183
|
logger.info(
|
|
5184
|
-
|
|
5184
|
+
colors5.cyan(`loaded config file `) + colors5.dim(config.__meta.configPath),
|
|
5185
5185
|
{ timestamp: true }
|
|
5186
5186
|
);
|
|
5187
5187
|
}
|
|
@@ -5249,9 +5249,9 @@ var llms_exports = {};
|
|
|
5249
5249
|
__export(llms_exports, {
|
|
5250
5250
|
generateLlmsTxtFiles: () => generateLlmsTxtFiles
|
|
5251
5251
|
});
|
|
5252
|
-
import { writeFile as
|
|
5253
|
-
import
|
|
5254
|
-
import
|
|
5252
|
+
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
5253
|
+
import path29 from "node:path";
|
|
5254
|
+
import colors9 from "picocolors";
|
|
5255
5255
|
async function generateLlmsTxtFiles({
|
|
5256
5256
|
markdownFileInfos,
|
|
5257
5257
|
outputUrls,
|
|
@@ -5284,61 +5284,377 @@ async function generateLlmsTxtFiles({
|
|
|
5284
5284
|
llmsTxtParts.push(`- [${linkTitle}](${mdUrl})${description}`);
|
|
5285
5285
|
}
|
|
5286
5286
|
}
|
|
5287
|
-
const llmsTxt2 = llmsTxtParts.join("\n");
|
|
5288
|
-
await
|
|
5289
|
-
if (process.env.APITOGO_JSON_ONLY !== "1") {
|
|
5290
|
-
console.log(
|
|
5291
|
-
}
|
|
5287
|
+
const llmsTxt2 = llmsTxtParts.join("\n");
|
|
5288
|
+
await writeFile5(path29.join(baseOutputDir, "llms.txt"), llmsTxt2, "utf-8");
|
|
5289
|
+
if (process.env.APITOGO_JSON_ONLY !== "1") {
|
|
5290
|
+
console.log(colors9.blue("\u2713 generated llms.txt"));
|
|
5291
|
+
}
|
|
5292
|
+
}
|
|
5293
|
+
if (llmsTxtFull) {
|
|
5294
|
+
const llmsFullParts = [];
|
|
5295
|
+
llmsFullParts.push(`# ${title}
|
|
5296
|
+
`);
|
|
5297
|
+
llmsFullParts.push("> Complete documentation for Large Language Models\n");
|
|
5298
|
+
for (const info of markdownFileInfos) {
|
|
5299
|
+
llmsFullParts.push(`
|
|
5300
|
+
---
|
|
5301
|
+
`);
|
|
5302
|
+
llmsFullParts.push(`## Document: ${info.title ?? info.routePath}
|
|
5303
|
+
`);
|
|
5304
|
+
if (info.description) {
|
|
5305
|
+
llmsFullParts.push(`${info.description}
|
|
5306
|
+
`);
|
|
5307
|
+
}
|
|
5308
|
+
llmsFullParts.push(`URL: ${joinUrl(baseUrl, info.routePath)}
|
|
5309
|
+
`);
|
|
5310
|
+
llmsFullParts.push(`
|
|
5311
|
+
${info.content}
|
|
5312
|
+
`);
|
|
5313
|
+
}
|
|
5314
|
+
const llmsFull = llmsFullParts.join("\n");
|
|
5315
|
+
await writeFile5(
|
|
5316
|
+
path29.join(baseOutputDir, "llms-full.txt"),
|
|
5317
|
+
llmsFull,
|
|
5318
|
+
"utf-8"
|
|
5319
|
+
);
|
|
5320
|
+
if (process.env.APITOGO_JSON_ONLY !== "1") {
|
|
5321
|
+
console.log(colors9.blue("\u2713 generated llms-full.txt"));
|
|
5322
|
+
}
|
|
5323
|
+
}
|
|
5324
|
+
}
|
|
5325
|
+
var init_llms = __esm({
|
|
5326
|
+
"src/vite/llms.ts"() {
|
|
5327
|
+
init_joinUrl();
|
|
5328
|
+
}
|
|
5329
|
+
});
|
|
5330
|
+
|
|
5331
|
+
// src/cli/cli.ts
|
|
5332
|
+
import * as Sentry2 from "@sentry/node";
|
|
5333
|
+
import { hideBin } from "yargs/helpers";
|
|
5334
|
+
|
|
5335
|
+
// src/cli/common/analytics/lib.ts
|
|
5336
|
+
import { PostHog } from "posthog-node";
|
|
5337
|
+
|
|
5338
|
+
// src/cli/common/constants.ts
|
|
5339
|
+
var CLI_XDG_FOLDER_NAME = "apitogo";
|
|
5340
|
+
var VERSION_CHECK_FILE = "version.json";
|
|
5341
|
+
var SENTRY_DSN = void 0;
|
|
5342
|
+
var MAX_WAIT_PENDING_TIME_MS = 1e3;
|
|
5343
|
+
var POST_HOG_CAPTURE_KEY = void 0;
|
|
5344
|
+
|
|
5345
|
+
// src/cli/common/machine-id/lib.ts
|
|
5346
|
+
import { execSync } from "node:child_process";
|
|
5347
|
+
import { createHash } from "node:crypto";
|
|
5348
|
+
var win32RegBinPath = {
|
|
5349
|
+
skipped: "",
|
|
5350
|
+
native: "%windir%\\System32",
|
|
5351
|
+
mixed: "%windir%\\sysnative\\cmd.exe /c %windir%\\System32"
|
|
5352
|
+
};
|
|
5353
|
+
var guid = {
|
|
5354
|
+
darwin: "ioreg -rd1 -c IOPlatformExpertDevice",
|
|
5355
|
+
win32: `${win32RegBinPath[isWindowsProcessMixedOrNativeArchitecture()]}\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid`,
|
|
5356
|
+
linux: "( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :"
|
|
5357
|
+
};
|
|
5358
|
+
function isWindowsProcessMixedOrNativeArchitecture() {
|
|
5359
|
+
if (process.platform !== "win32") {
|
|
5360
|
+
return "skipped";
|
|
5361
|
+
}
|
|
5362
|
+
if (process.arch === "ia32" && process.env.PROCESSOR_ARCHITEW6432) {
|
|
5363
|
+
return "mixed";
|
|
5364
|
+
}
|
|
5365
|
+
return "native";
|
|
5366
|
+
}
|
|
5367
|
+
function hash(guid2) {
|
|
5368
|
+
return createHash("sha256").update(guid2).digest("hex");
|
|
5369
|
+
}
|
|
5370
|
+
function expose(result) {
|
|
5371
|
+
switch (process.platform) {
|
|
5372
|
+
case "darwin":
|
|
5373
|
+
return result.split("IOPlatformUUID")[1].split("\n")[0].replace(/=|\s+]"/gi, "").toLowerCase();
|
|
5374
|
+
case "win32":
|
|
5375
|
+
return result.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi, "").toLowerCase();
|
|
5376
|
+
case "linux":
|
|
5377
|
+
return result.toString().replace(/\r+|\n+|\s+/gi, "").toLowerCase();
|
|
5378
|
+
case "freebsd":
|
|
5379
|
+
return result.toString().replace(/\r+|\n+|\s+/gi, "").toLowerCase();
|
|
5380
|
+
default:
|
|
5381
|
+
throw new Error(`Unsupported platform: ${process.platform}`);
|
|
5382
|
+
}
|
|
5383
|
+
}
|
|
5384
|
+
function machineId() {
|
|
5385
|
+
switch (process.platform) {
|
|
5386
|
+
case "darwin":
|
|
5387
|
+
case "win32":
|
|
5388
|
+
case "linux":
|
|
5389
|
+
return hash(expose(execSync(guid[process.platform]).toString()));
|
|
5390
|
+
default:
|
|
5391
|
+
return "e16fc483-5593-4d71-b485-a6533693da9b";
|
|
5392
|
+
}
|
|
5393
|
+
}
|
|
5394
|
+
|
|
5395
|
+
// src/cli/common/analytics/lib.ts
|
|
5396
|
+
var _postHog;
|
|
5397
|
+
function init() {
|
|
5398
|
+
if (process.env.ZUDOKU_DO_NOT_TRACK || !POST_HOG_CAPTURE_KEY) {
|
|
5399
|
+
return void 0;
|
|
5400
|
+
}
|
|
5401
|
+
_postHog = new PostHog(POST_HOG_CAPTURE_KEY, {
|
|
5402
|
+
host: "https://app.posthog.com",
|
|
5403
|
+
flushAt: 1,
|
|
5404
|
+
flushInterval: 1
|
|
5405
|
+
});
|
|
5406
|
+
return _postHog;
|
|
5407
|
+
}
|
|
5408
|
+
async function captureEvent({
|
|
5409
|
+
event,
|
|
5410
|
+
properties,
|
|
5411
|
+
groups,
|
|
5412
|
+
sendFeatureFlags,
|
|
5413
|
+
timestamp,
|
|
5414
|
+
disableGeoip
|
|
5415
|
+
}) {
|
|
5416
|
+
if (_postHog === void 0) {
|
|
5417
|
+
init();
|
|
5418
|
+
}
|
|
5419
|
+
if (_postHog) {
|
|
5420
|
+
properties = properties ?? {};
|
|
5421
|
+
properties.$set_once = properties.$set_once ?? {};
|
|
5422
|
+
if (process.env.CI) {
|
|
5423
|
+
properties.ci = process.env.CI;
|
|
5424
|
+
}
|
|
5425
|
+
_postHog.capture({
|
|
5426
|
+
distinctId: machineId(),
|
|
5427
|
+
event,
|
|
5428
|
+
properties,
|
|
5429
|
+
groups,
|
|
5430
|
+
sendFeatureFlags,
|
|
5431
|
+
timestamp,
|
|
5432
|
+
disableGeoip
|
|
5433
|
+
});
|
|
5434
|
+
}
|
|
5435
|
+
}
|
|
5436
|
+
async function shutdownAnalytics() {
|
|
5437
|
+
return _postHog?.shutdown();
|
|
5438
|
+
}
|
|
5439
|
+
|
|
5440
|
+
// src/cli/common/outdated.ts
|
|
5441
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
5442
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
5443
|
+
import { join } from "node:path";
|
|
5444
|
+
import colors3 from "picocolors";
|
|
5445
|
+
import { gt } from "semver";
|
|
5446
|
+
|
|
5447
|
+
// src/cli/common/json-only-deploy.ts
|
|
5448
|
+
function isDeployJsonOnlyArgv() {
|
|
5449
|
+
const args = process.argv;
|
|
5450
|
+
let cmdIdx = -1;
|
|
5451
|
+
for (const cmd of ["deploy", "remove"]) {
|
|
5452
|
+
const i = args.indexOf(cmd);
|
|
5453
|
+
if (i !== -1) {
|
|
5454
|
+
cmdIdx = i;
|
|
5455
|
+
break;
|
|
5456
|
+
}
|
|
5457
|
+
}
|
|
5458
|
+
if (cmdIdx === -1) {
|
|
5459
|
+
return false;
|
|
5460
|
+
}
|
|
5461
|
+
return args.slice(cmdIdx).some((a) => a === "--json-only" || a.startsWith("--json-only="));
|
|
5462
|
+
}
|
|
5463
|
+
|
|
5464
|
+
// src/cli/common/output.ts
|
|
5465
|
+
import * as Sentry from "@sentry/node";
|
|
5466
|
+
import colors from "picocolors";
|
|
5467
|
+
function printDiagnosticsToConsole(message) {
|
|
5468
|
+
console.error(colors.bold(colors.blue(message)));
|
|
5469
|
+
}
|
|
5470
|
+
function printWarningToConsole(message) {
|
|
5471
|
+
console.error(message);
|
|
5472
|
+
}
|
|
5473
|
+
async function printCriticalFailureToConsoleAndExit(message) {
|
|
5474
|
+
console.error(colors.bold(colors.red(message)));
|
|
5475
|
+
await Sentry.close(MAX_WAIT_PENDING_TIME_MS).then(() => {
|
|
5476
|
+
process.exit(1);
|
|
5477
|
+
});
|
|
5478
|
+
}
|
|
5479
|
+
function printJsonOnlyErrorAndExit(message) {
|
|
5480
|
+
console.log(JSON.stringify({ error: message }));
|
|
5481
|
+
process.exit(1);
|
|
5482
|
+
}
|
|
5483
|
+
function printResultToConsole(message) {
|
|
5484
|
+
console.log(colors.bold(colors.green(message)));
|
|
5485
|
+
}
|
|
5486
|
+
|
|
5487
|
+
// src/cli/common/utils/box.ts
|
|
5488
|
+
import colors2 from "picocolors";
|
|
5489
|
+
import stripAnsi from "strip-ansi";
|
|
5490
|
+
var border = ["\u2500", "\u256D", "\u256E", "\u2502", "\u2502", "\u2570", "\u256F"];
|
|
5491
|
+
var nothing = ["\u2500", "", "", "", "", "", ""];
|
|
5492
|
+
function box(message, {
|
|
5493
|
+
borderColor,
|
|
5494
|
+
padding = 1,
|
|
5495
|
+
textAlignment = "center",
|
|
5496
|
+
terminalColumns: cols = process.stdout.columns || process.env.COLUMNS && parseInt(process.env.COLUMNS, 10) || 80
|
|
5497
|
+
} = {}) {
|
|
5498
|
+
const lines = message.split(/\r?\n/).map((line) => [line, stripAnsi(line).length]);
|
|
5499
|
+
const maxLine = lines.reduce((p, [, len]) => Math.max(p, len), 0);
|
|
5500
|
+
const borderColorFn = borderColor && colors2[borderColor] || colors2.yellow;
|
|
5501
|
+
const clampedSidePadding = Math.max(1, padding * 3);
|
|
5502
|
+
const narrowMode = maxLine + 2 + clampedSidePadding * 2 > cols;
|
|
5503
|
+
const sidePadding = narrowMode ? 0 : clampedSidePadding;
|
|
5504
|
+
const innerWidth = Math.min(maxLine + sidePadding * 2, cols);
|
|
5505
|
+
const [hr, topLeft, topRight, left, right, bottomLeft, bottomRight] = narrowMode ? nothing : border;
|
|
5506
|
+
const spacerRow = narrowMode ? "\n".repeat(padding) : `${borderColorFn(`${left}${" ".repeat(innerWidth)}${right}`)}
|
|
5507
|
+
`.repeat(
|
|
5508
|
+
padding
|
|
5509
|
+
);
|
|
5510
|
+
const renderLine = ([line, len]) => {
|
|
5511
|
+
let leftPadding = 0;
|
|
5512
|
+
let rightPadding = 0;
|
|
5513
|
+
if (!narrowMode) {
|
|
5514
|
+
leftPadding = sidePadding;
|
|
5515
|
+
rightPadding = sidePadding;
|
|
5516
|
+
if (textAlignment === "center") {
|
|
5517
|
+
leftPadding += Math.floor((maxLine - len) / 2);
|
|
5518
|
+
rightPadding += maxLine - len - leftPadding + sidePadding;
|
|
5519
|
+
} else if (textAlignment === "right") {
|
|
5520
|
+
leftPadding += maxLine - len;
|
|
5521
|
+
} else if (textAlignment === "left") {
|
|
5522
|
+
rightPadding += maxLine - len;
|
|
5523
|
+
}
|
|
5524
|
+
}
|
|
5525
|
+
return borderColorFn(left) + " ".repeat(leftPadding) + line + " ".repeat(rightPadding) + borderColorFn(right);
|
|
5526
|
+
};
|
|
5527
|
+
return borderColorFn(`${topLeft}${hr?.repeat(innerWidth)}${topRight}`) + "\n" + spacerRow + lines.map(renderLine).join("\n") + "\n" + spacerRow + borderColorFn(`${bottomLeft}${hr?.repeat(innerWidth)}${bottomRight}`);
|
|
5528
|
+
}
|
|
5529
|
+
|
|
5530
|
+
// src/cli/common/xdg/lib.ts
|
|
5531
|
+
import { homedir } from "node:os";
|
|
5532
|
+
import path from "node:path";
|
|
5533
|
+
function defineDirectoryWithFallback(xdgName, fallback) {
|
|
5534
|
+
if (process.env[xdgName]) {
|
|
5535
|
+
return process.env[xdgName];
|
|
5536
|
+
} else {
|
|
5537
|
+
return path.join(homedir(), fallback);
|
|
5538
|
+
}
|
|
5539
|
+
}
|
|
5540
|
+
var XDG_CONFIG_HOME = defineDirectoryWithFallback(
|
|
5541
|
+
"XDG_CONFIG_HOME",
|
|
5542
|
+
".config"
|
|
5543
|
+
);
|
|
5544
|
+
var XDG_DATA_HOME = defineDirectoryWithFallback(
|
|
5545
|
+
"XDG_DATA_HOME",
|
|
5546
|
+
".local/share"
|
|
5547
|
+
);
|
|
5548
|
+
var XDG_STATE_HOME = defineDirectoryWithFallback(
|
|
5549
|
+
"XDG_DATA_HOME",
|
|
5550
|
+
".local/state"
|
|
5551
|
+
);
|
|
5552
|
+
var ZUDOKU_XDG_CONFIG_HOME = path.join(
|
|
5553
|
+
XDG_CONFIG_HOME,
|
|
5554
|
+
CLI_XDG_FOLDER_NAME
|
|
5555
|
+
);
|
|
5556
|
+
var ZUDOKU_XDG_DATA_HOME = path.join(
|
|
5557
|
+
XDG_DATA_HOME,
|
|
5558
|
+
CLI_XDG_FOLDER_NAME
|
|
5559
|
+
);
|
|
5560
|
+
var ZUDOKU_XDG_STATE_HOME = path.join(
|
|
5561
|
+
XDG_STATE_HOME,
|
|
5562
|
+
CLI_XDG_FOLDER_NAME
|
|
5563
|
+
);
|
|
5564
|
+
|
|
5565
|
+
// src/cli/common/outdated.ts
|
|
5566
|
+
async function warnIfOutdatedVersion(currentVersion) {
|
|
5567
|
+
if (isDeployJsonOnlyArgv()) {
|
|
5568
|
+
return false;
|
|
5569
|
+
}
|
|
5570
|
+
if (!process.env.ZUDOKU_OVERRIDE_CI_TO_TEST && (process.env.CI || process.env.ZUDOKU_DISABLE_UPDATE_CHECK)) {
|
|
5571
|
+
return false;
|
|
5572
|
+
}
|
|
5573
|
+
const versionCheckInfo = await getVersionCheckInfo();
|
|
5574
|
+
if (!versionCheckInfo.latestVersion) {
|
|
5575
|
+
return false;
|
|
5576
|
+
}
|
|
5577
|
+
const shouldWarn = gt(versionCheckInfo.latestVersion, currentVersion) && !process.env.ZUDOKU_INTERNAL_DEV;
|
|
5578
|
+
if (shouldWarn) {
|
|
5579
|
+
printWarningToConsole(
|
|
5580
|
+
box(
|
|
5581
|
+
`Update available! ${colors3.gray(`v${currentVersion}`)} \u226B ${colors3.green(
|
|
5582
|
+
`v${versionCheckInfo.latestVersion}`
|
|
5583
|
+
)}
|
|
5584
|
+
Run ${colors3.cyan("npm install apitogo@latest")} to update.
|
|
5585
|
+
|
|
5586
|
+
${colors3.gray("Upgrade to receive the latest features and fixes.")}`
|
|
5587
|
+
)
|
|
5588
|
+
);
|
|
5589
|
+
}
|
|
5590
|
+
return shouldWarn;
|
|
5591
|
+
}
|
|
5592
|
+
async function getLatestVersion() {
|
|
5593
|
+
const response = await fetch(
|
|
5594
|
+
"https://api.github.com/repos/lukoweb/apitogo-doc-tool/releases?per_page=1"
|
|
5595
|
+
);
|
|
5596
|
+
if (response.status === 200) {
|
|
5597
|
+
const result = await response.json();
|
|
5598
|
+
if (Array.isArray(result) && result.length > 0) {
|
|
5599
|
+
return result[0].tag_name.substring(1);
|
|
5600
|
+
}
|
|
5601
|
+
}
|
|
5602
|
+
return void 0;
|
|
5603
|
+
}
|
|
5604
|
+
async function getVersionCheckInfo() {
|
|
5605
|
+
if (!existsSync(ZUDOKU_XDG_STATE_HOME)) {
|
|
5606
|
+
mkdirSync(ZUDOKU_XDG_STATE_HOME, { recursive: true });
|
|
5607
|
+
}
|
|
5608
|
+
const versionCheckPath = join(ZUDOKU_XDG_STATE_HOME, VERSION_CHECK_FILE);
|
|
5609
|
+
let versionCheckInfo;
|
|
5610
|
+
if (existsSync(versionCheckPath)) {
|
|
5611
|
+
try {
|
|
5612
|
+
versionCheckInfo = await readFile(versionCheckPath, "utf-8").then(
|
|
5613
|
+
JSON.parse
|
|
5614
|
+
);
|
|
5615
|
+
} catch {
|
|
5616
|
+
}
|
|
5617
|
+
if (versionCheckInfo) {
|
|
5618
|
+
if (typeof versionCheckInfo.lastCheck !== "number" || typeof versionCheckInfo.latestVersion !== "string") {
|
|
5619
|
+
versionCheckInfo = void 0;
|
|
5620
|
+
}
|
|
5621
|
+
}
|
|
5292
5622
|
}
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
llmsFullParts.push(`
|
|
5300
|
-
---
|
|
5301
|
-
`);
|
|
5302
|
-
llmsFullParts.push(`## Document: ${info.title ?? info.routePath}
|
|
5303
|
-
`);
|
|
5304
|
-
if (info.description) {
|
|
5305
|
-
llmsFullParts.push(`${info.description}
|
|
5306
|
-
`);
|
|
5307
|
-
}
|
|
5308
|
-
llmsFullParts.push(`URL: ${joinUrl(baseUrl, info.routePath)}
|
|
5309
|
-
`);
|
|
5310
|
-
llmsFullParts.push(`
|
|
5311
|
-
${info.content}
|
|
5312
|
-
`);
|
|
5623
|
+
let shouldCheck = true;
|
|
5624
|
+
if (versionCheckInfo) {
|
|
5625
|
+
const now = Date.now();
|
|
5626
|
+
const lastCheck = versionCheckInfo.lastCheck;
|
|
5627
|
+
if (now - lastCheck < 1e3 * 60 * 60 * 24) {
|
|
5628
|
+
shouldCheck = false;
|
|
5313
5629
|
}
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5630
|
+
}
|
|
5631
|
+
if (!versionCheckInfo || shouldCheck) {
|
|
5632
|
+
const latestVersion = await getLatestVersion();
|
|
5633
|
+
versionCheckInfo = {
|
|
5634
|
+
lastCheck: Date.now(),
|
|
5635
|
+
latestVersion
|
|
5636
|
+
};
|
|
5637
|
+
await writeFile(
|
|
5638
|
+
versionCheckPath,
|
|
5639
|
+
JSON.stringify(versionCheckInfo),
|
|
5318
5640
|
"utf-8"
|
|
5319
5641
|
);
|
|
5320
|
-
if (process.env.APITOGO_JSON_ONLY !== "1") {
|
|
5321
|
-
console.log(colors6.blue("\u2713 generated llms-full.txt"));
|
|
5322
|
-
}
|
|
5323
5642
|
}
|
|
5643
|
+
return versionCheckInfo;
|
|
5324
5644
|
}
|
|
5325
|
-
var init_llms = __esm({
|
|
5326
|
-
"src/vite/llms.ts"() {
|
|
5327
|
-
init_joinUrl();
|
|
5328
|
-
}
|
|
5329
|
-
});
|
|
5330
5645
|
|
|
5331
5646
|
// src/cli/cli.ts
|
|
5332
|
-
|
|
5333
|
-
|
|
5647
|
+
init_package_json();
|
|
5648
|
+
|
|
5649
|
+
// src/cli/create-cli.ts
|
|
5334
5650
|
import yargs from "yargs/yargs";
|
|
5335
5651
|
|
|
5336
5652
|
// src/cli/build/handler.ts
|
|
5337
|
-
import
|
|
5653
|
+
import path33 from "node:path";
|
|
5338
5654
|
|
|
5339
5655
|
// src/vite/build.ts
|
|
5340
|
-
import { mkdir as mkdir5, readFile as
|
|
5341
|
-
import
|
|
5656
|
+
import { mkdir as mkdir5, readFile as readFile4, rename, rm as rm2, writeFile as writeFile6 } from "node:fs/promises";
|
|
5657
|
+
import path31 from "node:path";
|
|
5342
5658
|
import { build as esbuild } from "esbuild";
|
|
5343
5659
|
import { build as viteBuild, mergeConfig as mergeConfig3 } from "vite";
|
|
5344
5660
|
|
|
@@ -5474,9 +5790,9 @@ init_invariant();
|
|
|
5474
5790
|
init_joinUrl();
|
|
5475
5791
|
|
|
5476
5792
|
// src/vite/config.ts
|
|
5477
|
-
import
|
|
5793
|
+
import path26 from "node:path";
|
|
5478
5794
|
import dotenv from "dotenv";
|
|
5479
|
-
import
|
|
5795
|
+
import colors7 from "picocolors";
|
|
5480
5796
|
import {
|
|
5481
5797
|
loadConfigFromFile,
|
|
5482
5798
|
mergeConfig as mergeConfig2
|
|
@@ -5485,7 +5801,7 @@ import {
|
|
|
5485
5801
|
// package.json
|
|
5486
5802
|
var package_default = {
|
|
5487
5803
|
name: "@lukoweb/apitogo",
|
|
5488
|
-
version: "0.1.
|
|
5804
|
+
version: "0.1.104",
|
|
5489
5805
|
type: "module",
|
|
5490
5806
|
sideEffects: [
|
|
5491
5807
|
"**/*.css",
|
|
@@ -5508,8 +5824,8 @@ var package_default = {
|
|
|
5508
5824
|
"docs"
|
|
5509
5825
|
],
|
|
5510
5826
|
bin: {
|
|
5511
|
-
|
|
5512
|
-
|
|
5827
|
+
apitogo: "./cli.js",
|
|
5828
|
+
zudoku: "./cli.js"
|
|
5513
5829
|
},
|
|
5514
5830
|
exports: {
|
|
5515
5831
|
".": "./src/index.ts",
|
|
@@ -5915,24 +6231,24 @@ async function loadDevPortalViteDefines(rootDir, mode) {
|
|
|
5915
6231
|
|
|
5916
6232
|
// src/vite/package-root.ts
|
|
5917
6233
|
init_file_exists();
|
|
5918
|
-
import
|
|
6234
|
+
import path7 from "node:path";
|
|
5919
6235
|
var findPackageRoot = async (startDir) => {
|
|
5920
6236
|
let dir = startDir;
|
|
5921
|
-
while (dir !==
|
|
5922
|
-
if (await fileExists(
|
|
5923
|
-
dir =
|
|
6237
|
+
while (dir !== path7.dirname(dir)) {
|
|
6238
|
+
if (await fileExists(path7.join(dir, "package.json"))) return dir;
|
|
6239
|
+
dir = path7.dirname(dir);
|
|
5924
6240
|
}
|
|
5925
6241
|
};
|
|
5926
6242
|
|
|
5927
6243
|
// src/vite/pagefind-dev-stub.ts
|
|
5928
6244
|
import fs from "node:fs/promises";
|
|
5929
|
-
import
|
|
6245
|
+
import path8 from "node:path";
|
|
5930
6246
|
var NOT_BUILT_YET = 'throw new Error("NOT_BUILT_YET");';
|
|
5931
6247
|
async function ensurePagefindDevStub(publicDir) {
|
|
5932
|
-
const pagefindPath =
|
|
6248
|
+
const pagefindPath = path8.join(publicDir, "pagefind/pagefind.js");
|
|
5933
6249
|
const exists = await fs.stat(pagefindPath).catch(() => false);
|
|
5934
6250
|
if (!exists) {
|
|
5935
|
-
await fs.mkdir(
|
|
6251
|
+
await fs.mkdir(path8.dirname(pagefindPath), { recursive: true });
|
|
5936
6252
|
await fs.writeFile(pagefindPath, NOT_BUILT_YET);
|
|
5937
6253
|
}
|
|
5938
6254
|
}
|
|
@@ -5944,7 +6260,7 @@ import react from "@vitejs/plugin-react";
|
|
|
5944
6260
|
// src/vite/css/plugin.ts
|
|
5945
6261
|
init_loader();
|
|
5946
6262
|
init_plugin_theme();
|
|
5947
|
-
import
|
|
6263
|
+
import path9 from "node:path";
|
|
5948
6264
|
import { isCSSRequest as isCSSRequest2 } from "vite";
|
|
5949
6265
|
|
|
5950
6266
|
// src/vite/css/collect.ts
|
|
@@ -5979,7 +6295,7 @@ var VIRTUAL_ENTRY = "virtual:ssr-css.css";
|
|
|
5979
6295
|
function vitePluginSsrCss(pluginOpts) {
|
|
5980
6296
|
let server;
|
|
5981
6297
|
const config2 = getCurrentConfig();
|
|
5982
|
-
const virtualHref =
|
|
6298
|
+
const virtualHref = path9.join(
|
|
5983
6299
|
config2.basePath ?? "",
|
|
5984
6300
|
`/@id/__x00__${VIRTUAL_ENTRY}?direct`
|
|
5985
6301
|
);
|
|
@@ -6116,7 +6432,7 @@ var plugin_api_keys_default = viteApiKeysPlugin;
|
|
|
6116
6432
|
|
|
6117
6433
|
// src/vite/plugin-api.ts
|
|
6118
6434
|
import fs3 from "node:fs/promises";
|
|
6119
|
-
import
|
|
6435
|
+
import path15 from "node:path";
|
|
6120
6436
|
import { deepEqual as deepEqual2 } from "fast-equals";
|
|
6121
6437
|
import { runnerImport as runnerImport3 } from "vite";
|
|
6122
6438
|
init_package_json();
|
|
@@ -6125,7 +6441,7 @@ init_loader();
|
|
|
6125
6441
|
// src/config/validators/BuildSchema.ts
|
|
6126
6442
|
init_file_exists();
|
|
6127
6443
|
init_loader();
|
|
6128
|
-
import
|
|
6444
|
+
import path10 from "node:path";
|
|
6129
6445
|
import { runnerImport as runnerImport2 } from "vite";
|
|
6130
6446
|
import { z as z10 } from "zod";
|
|
6131
6447
|
var BuildProcessorSchema = z10.custom((val) => typeof val === "function");
|
|
@@ -6154,7 +6470,7 @@ var buildConfigFiles = [
|
|
|
6154
6470
|
];
|
|
6155
6471
|
async function getBuildConfigFilePath(rootDir) {
|
|
6156
6472
|
for (const fileName of buildConfigFiles) {
|
|
6157
|
-
const filepath =
|
|
6473
|
+
const filepath = path10.join(rootDir, fileName);
|
|
6158
6474
|
if (await fileExists(filepath)) {
|
|
6159
6475
|
return filepath;
|
|
6160
6476
|
}
|
|
@@ -7168,7 +7484,7 @@ var ensureArray = (value) => Array.isArray(value) ? value : [value];
|
|
|
7168
7484
|
|
|
7169
7485
|
// src/vite/api/SchemaManager.ts
|
|
7170
7486
|
import fs2 from "node:fs/promises";
|
|
7171
|
-
import
|
|
7487
|
+
import path11 from "node:path";
|
|
7172
7488
|
import {
|
|
7173
7489
|
$RefParser as $RefParser2
|
|
7174
7490
|
} from "@apidevtools/json-schema-ref-parser";
|
|
@@ -7358,18 +7674,18 @@ var SchemaManager = class {
|
|
|
7358
7674
|
];
|
|
7359
7675
|
}
|
|
7360
7676
|
getPathForFile = (input3, params) => {
|
|
7361
|
-
const filePath =
|
|
7677
|
+
const filePath = path11.resolve(this.config.__meta.rootDir, input3);
|
|
7362
7678
|
const apis = ensureArray(this.config.apis ?? []);
|
|
7363
7679
|
for (const apiConfig of apis) {
|
|
7364
7680
|
if (!apiConfig || apiConfig.type !== "file" || !apiConfig.path) continue;
|
|
7365
7681
|
const match = normalizeInputs(apiConfig.input).some(
|
|
7366
|
-
(i) =>
|
|
7682
|
+
(i) => path11.resolve(this.config.__meta.rootDir, i.input) === filePath && deepEqual(i.params, params)
|
|
7367
7683
|
);
|
|
7368
7684
|
if (match) return apiConfig.path;
|
|
7369
7685
|
}
|
|
7370
7686
|
};
|
|
7371
7687
|
processSchema = async (input3) => {
|
|
7372
|
-
const filePath =
|
|
7688
|
+
const filePath = path11.resolve(this.config.__meta.rootDir, input3.input);
|
|
7373
7689
|
const params = input3.params;
|
|
7374
7690
|
const configuredPath = this.getPathForFile(input3.input, params);
|
|
7375
7691
|
if (!configuredPath) {
|
|
@@ -7405,9 +7721,9 @@ var SchemaManager = class {
|
|
|
7405
7721
|
const processedTime = Date.now();
|
|
7406
7722
|
const code = generateCode(processedSchema, filePath);
|
|
7407
7723
|
const prefixPath = slugify(configuredPath);
|
|
7408
|
-
const processedFilePath =
|
|
7724
|
+
const processedFilePath = path11.posix.join(
|
|
7409
7725
|
this.storeDir,
|
|
7410
|
-
`${prefixPath}-${
|
|
7726
|
+
`${prefixPath}-${path11.basename(filePath)}${paramsSuffix(params)}.js`
|
|
7411
7727
|
);
|
|
7412
7728
|
const importKey = processedFilePath;
|
|
7413
7729
|
await fs2.writeFile(processedFilePath, code);
|
|
@@ -7456,7 +7772,7 @@ var SchemaManager = class {
|
|
|
7456
7772
|
};
|
|
7457
7773
|
getAllTrackedFiles = () => Array.from(this.referencedBy.keys());
|
|
7458
7774
|
getFilesToReprocess = (changedFile) => {
|
|
7459
|
-
const resolvedPath =
|
|
7775
|
+
const resolvedPath = path11.resolve(this.config.__meta.rootDir, changedFile);
|
|
7460
7776
|
const referencedBy = this.referencedBy.get(resolvedPath);
|
|
7461
7777
|
if (!referencedBy) return [];
|
|
7462
7778
|
const filesToProcess = referencedBy.size === 0 ? [resolvedPath] : Array.from(referencedBy);
|
|
@@ -7485,7 +7801,7 @@ var SchemaManager = class {
|
|
|
7485
7801
|
version: "",
|
|
7486
7802
|
path: input3.path ?? "",
|
|
7487
7803
|
label: input3.label,
|
|
7488
|
-
inputPath:
|
|
7804
|
+
inputPath: path11.resolve(this.config.__meta.rootDir, input3.input),
|
|
7489
7805
|
params: input3.params,
|
|
7490
7806
|
importKey: "",
|
|
7491
7807
|
downloadUrl: "",
|
|
@@ -7528,7 +7844,7 @@ var SchemaManager = class {
|
|
|
7528
7844
|
};
|
|
7529
7845
|
createSchemaPath = (inputPath, versionPath, apiPath, params) => {
|
|
7530
7846
|
const suffix = paramsSuffix(params);
|
|
7531
|
-
const extension = suffix ? ".json" :
|
|
7847
|
+
const extension = suffix ? ".json" : path11.extname(inputPath);
|
|
7532
7848
|
return joinUrl(
|
|
7533
7849
|
this.config.basePath,
|
|
7534
7850
|
apiPath,
|
|
@@ -7551,8 +7867,8 @@ var SchemaManager = class {
|
|
|
7551
7867
|
// src/vite/plugin-config-reload.ts
|
|
7552
7868
|
init_logger();
|
|
7553
7869
|
init_loader();
|
|
7554
|
-
import
|
|
7555
|
-
import
|
|
7870
|
+
import path14 from "node:path";
|
|
7871
|
+
import colors6 from "picocolors";
|
|
7556
7872
|
|
|
7557
7873
|
// src/vite/plugin-navigation.ts
|
|
7558
7874
|
init_loader();
|
|
@@ -7561,14 +7877,14 @@ import { stringify as stringify3 } from "javascript-stringify";
|
|
|
7561
7877
|
import { isElement } from "react-is";
|
|
7562
7878
|
|
|
7563
7879
|
// src/config/validators/NavigationSchema.ts
|
|
7564
|
-
import
|
|
7880
|
+
import path12 from "node:path";
|
|
7565
7881
|
import { glob } from "glob";
|
|
7566
7882
|
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
7567
7883
|
import { mdxFromMarkdown } from "mdast-util-mdx";
|
|
7568
7884
|
import { mdxjs } from "micromark-extension-mdxjs";
|
|
7569
7885
|
|
|
7570
7886
|
// src/lib/util/readFrontmatter.ts
|
|
7571
|
-
import { readFile } from "node:fs/promises";
|
|
7887
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
7572
7888
|
import matter from "gray-matter";
|
|
7573
7889
|
import { parse, stringify as stringify2 } from "yaml";
|
|
7574
7890
|
var yaml = {
|
|
@@ -7576,7 +7892,7 @@ var yaml = {
|
|
|
7576
7892
|
stringify: (obj) => stringify2(obj)
|
|
7577
7893
|
};
|
|
7578
7894
|
var readFrontmatter = async (filePath) => {
|
|
7579
|
-
const content = await
|
|
7895
|
+
const content = await readFile2(filePath, "utf-8");
|
|
7580
7896
|
const normalizedContent = content.replace(/\r\n/g, "\n");
|
|
7581
7897
|
return matter(normalizedContent, { engines: { yaml } });
|
|
7582
7898
|
};
|
|
@@ -7612,7 +7928,7 @@ var extractRichH1 = (content) => {
|
|
|
7612
7928
|
}
|
|
7613
7929
|
};
|
|
7614
7930
|
var isNavigationItem = (item) => item !== void 0;
|
|
7615
|
-
var toPosixPath = (filePath) => filePath.split(
|
|
7931
|
+
var toPosixPath = (filePath) => filePath.split(path12.win32.sep).join(path12.posix.sep);
|
|
7616
7932
|
var NavigationResolver = class {
|
|
7617
7933
|
rootDir;
|
|
7618
7934
|
globPatterns;
|
|
@@ -7744,14 +8060,14 @@ var NavigationResolver = class {
|
|
|
7744
8060
|
init_invariant();
|
|
7745
8061
|
|
|
7746
8062
|
// src/vite/debug.ts
|
|
7747
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
7748
|
-
import
|
|
8063
|
+
import { mkdir, writeFile as writeFile2 } from "node:fs/promises";
|
|
8064
|
+
import path13 from "node:path";
|
|
7749
8065
|
async function writePluginDebugCode(rootDir, pluginName, code, extension = "js") {
|
|
7750
8066
|
if (process.env.ZUDOKU_BUILD_DEBUG) {
|
|
7751
|
-
const debugDir =
|
|
8067
|
+
const debugDir = path13.join(rootDir, "dist", "debug");
|
|
7752
8068
|
await mkdir(debugDir, { recursive: true });
|
|
7753
|
-
await
|
|
7754
|
-
|
|
8069
|
+
await writeFile2(
|
|
8070
|
+
path13.join(debugDir, `${pluginName}.${extension}`),
|
|
7755
8071
|
typeof code === "string" ? code : code.join("\n")
|
|
7756
8072
|
);
|
|
7757
8073
|
}
|
|
@@ -7859,8 +8175,8 @@ var viteConfigReloadPlugin = () => ({
|
|
|
7859
8175
|
invalidate(server);
|
|
7860
8176
|
reload(server);
|
|
7861
8177
|
logger.info(
|
|
7862
|
-
|
|
7863
|
-
`Config ${
|
|
8178
|
+
colors6.blue(
|
|
8179
|
+
`Config ${path14.basename(currentConfig.__meta.configPath)} changed. Reloading...`
|
|
7864
8180
|
),
|
|
7865
8181
|
{ timestamp: true }
|
|
7866
8182
|
);
|
|
@@ -7874,11 +8190,11 @@ var viteApiPlugin = async () => {
|
|
|
7874
8190
|
const resolvedVirtualModuleId5 = `\0${virtualModuleId4}`;
|
|
7875
8191
|
const initialConfig = getCurrentConfig();
|
|
7876
8192
|
const zuploProcessors = ZuploEnv.isZuplo ? await runnerImport3(
|
|
7877
|
-
|
|
8193
|
+
path15.resolve(getZudokuRootDir(), "src/zuplo/with-zuplo-processors.ts")
|
|
7878
8194
|
).then((m) => m.module.default(initialConfig.__meta.rootDir)) : [];
|
|
7879
8195
|
const buildConfig = await getBuildConfig();
|
|
7880
8196
|
const buildProcessors = buildConfig?.processors ?? [];
|
|
7881
|
-
const tmpStoreDir =
|
|
8197
|
+
const tmpStoreDir = path15.posix.join(
|
|
7882
8198
|
initialConfig.__meta.rootDir,
|
|
7883
8199
|
"node_modules/.apitogo/processed"
|
|
7884
8200
|
);
|
|
@@ -7910,7 +8226,7 @@ var viteApiPlugin = async () => {
|
|
|
7910
8226
|
const inputPath = pathMap.get(req.url);
|
|
7911
8227
|
if (!inputPath) return next();
|
|
7912
8228
|
const content = await fs3.readFile(inputPath, "utf-8");
|
|
7913
|
-
const mimeType =
|
|
8229
|
+
const mimeType = path15.extname(inputPath).toLowerCase() === ".json" ? "application/json" : "application/x-yaml";
|
|
7914
8230
|
res.setHeader("Content-Type", `${mimeType}; charset=utf-8`);
|
|
7915
8231
|
return res.end(content);
|
|
7916
8232
|
});
|
|
@@ -8098,8 +8414,8 @@ var viteApiPlugin = async () => {
|
|
|
8098
8414
|
if (process.env.NODE_ENV !== "production") return;
|
|
8099
8415
|
for (const [urlPath, inputPath] of pathMap) {
|
|
8100
8416
|
const content = await fs3.readFile(inputPath, "utf-8");
|
|
8101
|
-
const outputPath =
|
|
8102
|
-
await fs3.mkdir(
|
|
8417
|
+
const outputPath = path15.join(config2.__meta.rootDir, "dist", urlPath);
|
|
8418
|
+
await fs3.mkdir(path15.dirname(outputPath), { recursive: true });
|
|
8103
8419
|
await fs3.writeFile(outputPath, content, "utf-8");
|
|
8104
8420
|
}
|
|
8105
8421
|
}
|
|
@@ -8142,7 +8458,7 @@ var plugin_auth_default = viteAuthPlugin;
|
|
|
8142
8458
|
|
|
8143
8459
|
// src/vite/plugin-component.ts
|
|
8144
8460
|
init_loader();
|
|
8145
|
-
import
|
|
8461
|
+
import path16 from "node:path";
|
|
8146
8462
|
var viteAliasPlugin = () => {
|
|
8147
8463
|
return {
|
|
8148
8464
|
name: "zudoku-component-plugin",
|
|
@@ -8170,7 +8486,7 @@ var viteAliasPlugin = () => {
|
|
|
8170
8486
|
];
|
|
8171
8487
|
const aliases = replacements.map(([find, replacement]) => ({
|
|
8172
8488
|
find,
|
|
8173
|
-
replacement:
|
|
8489
|
+
replacement: path16.posix.join(config2.__meta.moduleDir, replacement)
|
|
8174
8490
|
}));
|
|
8175
8491
|
return config2.__meta.mode === "internal" || config2.__meta.mode === "standalone" ? { resolve: { alias: aliases } } : void 0;
|
|
8176
8492
|
}
|
|
@@ -8181,11 +8497,11 @@ var plugin_component_default = viteAliasPlugin;
|
|
|
8181
8497
|
// src/vite/plugin-config.ts
|
|
8182
8498
|
init_package_json();
|
|
8183
8499
|
init_loader();
|
|
8184
|
-
import
|
|
8500
|
+
import path17 from "node:path";
|
|
8185
8501
|
import { normalizePath } from "vite";
|
|
8186
8502
|
var virtualModuleId3 = "virtual:zudoku-config";
|
|
8187
8503
|
var resolvedVirtualModuleId3 = `\0${virtualModuleId3}`;
|
|
8188
|
-
var browserConfigLoaderPath =
|
|
8504
|
+
var browserConfigLoaderPath = path17.join(
|
|
8189
8505
|
getZudokuRootDir(),
|
|
8190
8506
|
"src/config/apitogo-config-loader.browser.ts"
|
|
8191
8507
|
);
|
|
@@ -8356,7 +8672,7 @@ var viteDocMetadataPlugin = () => ({
|
|
|
8356
8672
|
|
|
8357
8673
|
// src/vite/plugin-docs.ts
|
|
8358
8674
|
init_loader();
|
|
8359
|
-
import
|
|
8675
|
+
import path18 from "node:path";
|
|
8360
8676
|
import { glob as glob3 } from "glob";
|
|
8361
8677
|
import globParent from "glob-parent";
|
|
8362
8678
|
init_ZudokuConfig();
|
|
@@ -8425,7 +8741,7 @@ var globMarkdownFiles = async (config2, options = { absolute: false }) => {
|
|
|
8425
8741
|
if (process.env.NODE_ENV !== "development") {
|
|
8426
8742
|
const draftStatuses = await Promise.all(
|
|
8427
8743
|
globbedFiles.map(async (file) => {
|
|
8428
|
-
const absolutePath =
|
|
8744
|
+
const absolutePath = path18.resolve(config2.__meta.rootDir, file);
|
|
8429
8745
|
const { data } = await readFrontmatter(absolutePath);
|
|
8430
8746
|
return { file, isDraft: data.draft === true };
|
|
8431
8747
|
})
|
|
@@ -8438,9 +8754,9 @@ var globMarkdownFiles = async (config2, options = { absolute: false }) => {
|
|
|
8438
8754
|
if (draftFiles.has(file)) {
|
|
8439
8755
|
continue;
|
|
8440
8756
|
}
|
|
8441
|
-
const relativePath =
|
|
8757
|
+
const relativePath = path18.posix.relative(parent, file);
|
|
8442
8758
|
const routePath = ensureLeadingSlash(relativePath.replace(/\.mdx?$/, ""));
|
|
8443
|
-
const filePath = options.absolute ?
|
|
8759
|
+
const filePath = options.absolute ? path18.resolve(config2.__meta.rootDir, file) : file;
|
|
8444
8760
|
fileMapping[routePath] = filePath;
|
|
8445
8761
|
}
|
|
8446
8762
|
}
|
|
@@ -8504,7 +8820,7 @@ var viteDocsPlugin = () => {
|
|
|
8504
8820
|
const globbedDocuments = {};
|
|
8505
8821
|
for (const [routePath, file] of Object.entries(fileMapping)) {
|
|
8506
8822
|
const importPath = ensureLeadingSlash(
|
|
8507
|
-
|
|
8823
|
+
path18.posix.join(globImportBasePath, file)
|
|
8508
8824
|
);
|
|
8509
8825
|
globbedDocuments[routePath] = importPath;
|
|
8510
8826
|
}
|
|
@@ -8530,7 +8846,7 @@ var plugin_docs_default = viteDocsPlugin;
|
|
|
8530
8846
|
// src/vite/plugin-local-manifest.ts
|
|
8531
8847
|
init_apitogo_config_loader();
|
|
8532
8848
|
init_local_manifest();
|
|
8533
|
-
import
|
|
8849
|
+
import path19 from "node:path";
|
|
8534
8850
|
var APITOGO_LOCAL_MANIFEST_VIRTUAL_ID = "virtual:apitogo-local-manifest";
|
|
8535
8851
|
var resolvedVirtualModuleId4 = `\0${APITOGO_LOCAL_MANIFEST_VIRTUAL_ID}`;
|
|
8536
8852
|
var viteLocalManifestPlugin = () => {
|
|
@@ -8580,8 +8896,8 @@ var viteLocalManifestPlugin = () => {
|
|
|
8580
8896
|
server.watcher.add(watchPath);
|
|
8581
8897
|
}
|
|
8582
8898
|
server.watcher.on("change", async (changedPath) => {
|
|
8583
|
-
const resolvedChanged =
|
|
8584
|
-
if (!watchPaths.some((p) =>
|
|
8899
|
+
const resolvedChanged = path19.resolve(changedPath);
|
|
8900
|
+
if (!watchPaths.some((p) => path19.resolve(p) === resolvedChanged)) {
|
|
8585
8901
|
return;
|
|
8586
8902
|
}
|
|
8587
8903
|
const module = server.moduleGraph.getModuleById(
|
|
@@ -8607,8 +8923,8 @@ var plugin_local_manifest_default = viteLocalManifestPlugin;
|
|
|
8607
8923
|
init_loader();
|
|
8608
8924
|
init_ProtectedRoutesSchema();
|
|
8609
8925
|
init_joinUrl();
|
|
8610
|
-
import { mkdir as mkdir2, writeFile as
|
|
8611
|
-
import
|
|
8926
|
+
import { mkdir as mkdir2, writeFile as writeFile3 } from "node:fs/promises";
|
|
8927
|
+
import path20 from "node:path";
|
|
8612
8928
|
import { matchPath } from "react-router";
|
|
8613
8929
|
var processMarkdownFile = async (filePath) => {
|
|
8614
8930
|
const { content: markdownContent, data: frontmatter } = await readFrontmatter(filePath);
|
|
@@ -8696,7 +9012,7 @@ var viteMarkdownExportPlugin = () => {
|
|
|
8696
9012
|
if (process.env.NODE_ENV !== "production" || Object.keys(markdownFiles).length === 0 || !needsMdFiles) {
|
|
8697
9013
|
return;
|
|
8698
9014
|
}
|
|
8699
|
-
const distDir =
|
|
9015
|
+
const distDir = path20.join(
|
|
8700
9016
|
config2.__meta.rootDir,
|
|
8701
9017
|
"dist",
|
|
8702
9018
|
config2.basePath ?? ""
|
|
@@ -8717,19 +9033,19 @@ var viteMarkdownExportPlugin = () => {
|
|
|
8717
9033
|
content: finalMarkdown
|
|
8718
9034
|
});
|
|
8719
9035
|
const segments = routePath === "/" ? ["index"] : routePath.split("/").filter(Boolean);
|
|
8720
|
-
const outputPath = `${
|
|
8721
|
-
await mkdir2(
|
|
8722
|
-
await
|
|
9036
|
+
const outputPath = `${path20.join(distDir, ...segments)}.md`;
|
|
9037
|
+
await mkdir2(path20.dirname(outputPath), { recursive: true });
|
|
9038
|
+
await writeFile3(outputPath, finalMarkdown, "utf-8");
|
|
8723
9039
|
} catch (error) {
|
|
8724
9040
|
console.warn(`Failed to export markdown for ${routePath}:`, error);
|
|
8725
9041
|
}
|
|
8726
9042
|
}
|
|
8727
9043
|
if (config2.docs?.llms?.llmsTxt || config2.docs?.llms?.llmsTxtFull) {
|
|
8728
|
-
const markdownInfoPath =
|
|
9044
|
+
const markdownInfoPath = path20.join(
|
|
8729
9045
|
config2.__meta.rootDir,
|
|
8730
9046
|
"node_modules/.apitogo/markdown-info.json"
|
|
8731
9047
|
);
|
|
8732
|
-
await
|
|
9048
|
+
await writeFile3(
|
|
8733
9049
|
markdownInfoPath,
|
|
8734
9050
|
JSON.stringify(markdownFileInfos, null, 2),
|
|
8735
9051
|
"utf-8"
|
|
@@ -8877,9 +9193,9 @@ var remarkCodeTabs = () => (tree) => {
|
|
|
8877
9193
|
};
|
|
8878
9194
|
|
|
8879
9195
|
// src/vite/mdx/remark-inject-filepath.ts
|
|
8880
|
-
import
|
|
9196
|
+
import path21 from "node:path";
|
|
8881
9197
|
var remarkInjectFilepath = (rootDir) => (tree, vfile) => {
|
|
8882
|
-
const relativePath =
|
|
9198
|
+
const relativePath = path21.relative(rootDir, vfile.path).split(path21.sep).join(path21.posix.sep);
|
|
8883
9199
|
tree.children.unshift(exportMdxjsConst("__filepath", relativePath));
|
|
8884
9200
|
};
|
|
8885
9201
|
|
|
@@ -8966,18 +9282,18 @@ var remarkLastModified = () => {
|
|
|
8966
9282
|
};
|
|
8967
9283
|
|
|
8968
9284
|
// src/vite/mdx/remark-link-rewrite.ts
|
|
8969
|
-
import
|
|
9285
|
+
import path22 from "node:path";
|
|
8970
9286
|
import { visit as visit5 } from "unist-util-visit";
|
|
8971
9287
|
var remarkLinkRewrite = (basePath = "") => (tree) => {
|
|
8972
9288
|
visit5(tree, "link", (node) => {
|
|
8973
9289
|
if (!node.url) return;
|
|
8974
9290
|
if (node.url.startsWith("http") || node.url.startsWith("mailto:")) return;
|
|
8975
9291
|
node.url = node.url.replace(/\\/g, "/");
|
|
8976
|
-
const base =
|
|
9292
|
+
const base = path22.posix.join(basePath);
|
|
8977
9293
|
if (basePath && node.url.startsWith(base)) {
|
|
8978
9294
|
node.url = node.url.slice(base.length);
|
|
8979
9295
|
} else if (!node.url.startsWith("/") && !node.url.startsWith("#")) {
|
|
8980
|
-
node.url =
|
|
9296
|
+
node.url = path22.posix.join("..", node.url);
|
|
8981
9297
|
}
|
|
8982
9298
|
node.url = node.url.replace(/\.mdx?(#.*)?$/, "$1");
|
|
8983
9299
|
});
|
|
@@ -9197,14 +9513,14 @@ var plugin_mdx_default = viteMdxPlugin;
|
|
|
9197
9513
|
|
|
9198
9514
|
// src/vite/plugin-modules.ts
|
|
9199
9515
|
init_loader();
|
|
9200
|
-
import
|
|
9516
|
+
import path23 from "node:path";
|
|
9201
9517
|
import { normalizePath as normalizePath2 } from "vite";
|
|
9202
|
-
var getLandingModuleImport = (moduleDir, mode) => mode === "internal" ? normalizePath2(
|
|
9203
|
-
var getUserPanelModuleImport = (moduleDir, mode) => mode === "internal" ? normalizePath2(
|
|
9518
|
+
var getLandingModuleImport = (moduleDir, mode) => mode === "internal" ? normalizePath2(path23.join(moduleDir, "../module-landing/src/index.tsx")) : "@lukoweb/apitogo-module-landing";
|
|
9519
|
+
var getUserPanelModuleImport = (moduleDir, mode) => mode === "internal" ? normalizePath2(path23.join(moduleDir, "../module-user-panel/src/index.tsx")) : "@lukoweb/apitogo-module-user-panel";
|
|
9204
9520
|
var getBillingPluginImport = (moduleDir, mode) => mode === "internal" ? normalizePath2(
|
|
9205
|
-
|
|
9521
|
+
path23.join(moduleDir, "../plugin-dev-portal-billing/src/index.ts")
|
|
9206
9522
|
) : "@lukoweb/apitogo-plugin-dev-portal-billing";
|
|
9207
|
-
var resolveProjectPageImport = (rootDir, pagePath) => normalizePath2(
|
|
9523
|
+
var resolveProjectPageImport = (rootDir, pagePath) => normalizePath2(path23.resolve(rootDir, pagePath));
|
|
9208
9524
|
var viteModulesPlugin = () => {
|
|
9209
9525
|
const virtualModuleId4 = "virtual:zudoku-modules-plugin";
|
|
9210
9526
|
const resolvedVirtualModuleId5 = `\0${virtualModuleId4}`;
|
|
@@ -9344,20 +9660,20 @@ var plugin_modules_default = viteModulesPlugin;
|
|
|
9344
9660
|
|
|
9345
9661
|
// src/vite/plugin-offroot-resolve.ts
|
|
9346
9662
|
init_loader();
|
|
9347
|
-
import
|
|
9663
|
+
import path24 from "node:path";
|
|
9348
9664
|
function stripQuery(id) {
|
|
9349
9665
|
const query = id.indexOf("?");
|
|
9350
9666
|
return query === -1 ? id : id.slice(0, query);
|
|
9351
9667
|
}
|
|
9352
9668
|
function isInside(parent, child) {
|
|
9353
|
-
const relative =
|
|
9354
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
9669
|
+
const relative = path24.relative(path24.resolve(parent), path24.resolve(child));
|
|
9670
|
+
return relative === "" || !relative.startsWith("..") && !path24.isAbsolute(relative);
|
|
9355
9671
|
}
|
|
9356
9672
|
function isBareSpecifier(source) {
|
|
9357
|
-
return !source.startsWith("\0") && !source.startsWith(".") && !source.startsWith("/") && !
|
|
9673
|
+
return !source.startsWith("\0") && !source.startsWith(".") && !source.startsWith("/") && !path24.isAbsolute(source);
|
|
9358
9674
|
}
|
|
9359
9675
|
function isInsideNodeModules(filePath) {
|
|
9360
|
-
return filePath.split(
|
|
9676
|
+
return filePath.split(path24.sep).includes("node_modules");
|
|
9361
9677
|
}
|
|
9362
9678
|
function shouldResolveFromSiteRoot(source, importer, rootDir) {
|
|
9363
9679
|
if (!importer || !isBareSpecifier(source)) {
|
|
@@ -9378,7 +9694,7 @@ function viteOffrootResolvePlugin() {
|
|
|
9378
9694
|
if (!shouldResolveFromSiteRoot(source, importer, rootDir)) {
|
|
9379
9695
|
return;
|
|
9380
9696
|
}
|
|
9381
|
-
return this.resolve(source,
|
|
9697
|
+
return this.resolve(source, path24.join(rootDir, "package.json"), {
|
|
9382
9698
|
...options,
|
|
9383
9699
|
skipSelf: true
|
|
9384
9700
|
});
|
|
@@ -9388,7 +9704,7 @@ function viteOffrootResolvePlugin() {
|
|
|
9388
9704
|
|
|
9389
9705
|
// src/vite/plugin-search.ts
|
|
9390
9706
|
init_loader();
|
|
9391
|
-
import
|
|
9707
|
+
import path25 from "node:path";
|
|
9392
9708
|
var viteSearchPlugin = () => {
|
|
9393
9709
|
const virtualModuleId4 = "virtual:zudoku-search-plugin";
|
|
9394
9710
|
const resolvedVirtualModuleId5 = `\0${virtualModuleId4}`;
|
|
@@ -9406,7 +9722,7 @@ var viteSearchPlugin = () => {
|
|
|
9406
9722
|
return resolvedVirtualModuleId5;
|
|
9407
9723
|
}
|
|
9408
9724
|
if (id === "/pagefind/pagefind.js" && resolvedViteConfig?.publicDir) {
|
|
9409
|
-
return
|
|
9725
|
+
return path25.join(resolvedViteConfig.publicDir, "pagefind/pagefind.js");
|
|
9410
9726
|
}
|
|
9411
9727
|
},
|
|
9412
9728
|
async load(id) {
|
|
@@ -9546,17 +9862,17 @@ function vitePlugin() {
|
|
|
9546
9862
|
}
|
|
9547
9863
|
|
|
9548
9864
|
// src/vite/config.ts
|
|
9549
|
-
var browserConfigLoaderPath2 =
|
|
9865
|
+
var browserConfigLoaderPath2 = path26.join(
|
|
9550
9866
|
getZudokuRootDir(),
|
|
9551
9867
|
"src/config/apitogo-config-loader.browser.ts"
|
|
9552
9868
|
);
|
|
9553
9869
|
var resolveMergedPublicDir = (rootDir, merged) => {
|
|
9554
9870
|
if (merged.publicDir === false) return void 0;
|
|
9555
9871
|
const rel = typeof merged.publicDir === "string" ? merged.publicDir : "public";
|
|
9556
|
-
return
|
|
9872
|
+
return path26.resolve(rootDir, rel);
|
|
9557
9873
|
};
|
|
9558
|
-
var getAppClientEntryPath = () =>
|
|
9559
|
-
var getAppServerEntryPath = () =>
|
|
9874
|
+
var getAppClientEntryPath = () => path26.posix.join(getZudokuRootDir(), "src/app/entry.client.tsx");
|
|
9875
|
+
var getAppServerEntryPath = () => path26.posix.join(getZudokuRootDir(), "src/app/entry.server.tsx");
|
|
9560
9876
|
var hasLoggedCdnInfo = false;
|
|
9561
9877
|
var MEDIA_REGEX = /\.(a?png|jpe?g|gif|bmp|svg|webp|tiff|ico|webm|ogg|mp3|wav|m4a|avif|mp4)/i;
|
|
9562
9878
|
var defineEnvVars = (vars) => Object.fromEntries(
|
|
@@ -9573,9 +9889,9 @@ async function getViteConfig(dir, configEnv) {
|
|
|
9573
9889
|
const cdnUrl = CdnUrlSchema.parse(config2.cdnUrl);
|
|
9574
9890
|
const base = cdnUrl?.base ? joinUrl(cdnUrl.base, config2.basePath) : config2.basePath;
|
|
9575
9891
|
if (cdnUrl && !hasLoggedCdnInfo) {
|
|
9576
|
-
logger.info(
|
|
9577
|
-
logger.info(
|
|
9578
|
-
logger.info(
|
|
9892
|
+
logger.info(colors7.blue(`Using CDN URL:`));
|
|
9893
|
+
logger.info(colors7.blue(` base: `) + colors7.dim(cdnUrl.base));
|
|
9894
|
+
logger.info(colors7.blue(` media: `) + colors7.dim(cdnUrl.media));
|
|
9579
9895
|
hasLoggedCdnInfo = true;
|
|
9580
9896
|
}
|
|
9581
9897
|
const publicVarsProcessEnvDefine = Object.fromEntries(
|
|
@@ -9586,7 +9902,7 @@ async function getViteConfig(dir, configEnv) {
|
|
|
9586
9902
|
);
|
|
9587
9903
|
if (ZuploEnv.isZuplo) {
|
|
9588
9904
|
dotenv.config({
|
|
9589
|
-
path:
|
|
9905
|
+
path: path26.resolve(config2.__meta.rootDir, "../.env.zuplo"),
|
|
9590
9906
|
quiet: true
|
|
9591
9907
|
});
|
|
9592
9908
|
}
|
|
@@ -9611,11 +9927,11 @@ async function getViteConfig(dir, configEnv) {
|
|
|
9611
9927
|
client: {
|
|
9612
9928
|
resolve: {
|
|
9613
9929
|
alias: {
|
|
9614
|
-
[
|
|
9930
|
+
[path26.join(
|
|
9615
9931
|
getZudokuRootDir(),
|
|
9616
9932
|
"src/config/apitogo-config-loader.node.ts"
|
|
9617
9933
|
)]: browserConfigLoaderPath2,
|
|
9618
|
-
[
|
|
9934
|
+
[path26.join(
|
|
9619
9935
|
getZudokuRootDir(),
|
|
9620
9936
|
"src/config/apitogo-config-loader.node.js"
|
|
9621
9937
|
)]: browserConfigLoaderPath2
|
|
@@ -9648,7 +9964,7 @@ async function getViteConfig(dir, configEnv) {
|
|
|
9648
9964
|
middlewareMode: true,
|
|
9649
9965
|
open: true,
|
|
9650
9966
|
fs: {
|
|
9651
|
-
allow: [dir,
|
|
9967
|
+
allow: [dir, path26.dirname(dir)]
|
|
9652
9968
|
},
|
|
9653
9969
|
watch: {
|
|
9654
9970
|
ignored: [
|
|
@@ -9664,8 +9980,8 @@ async function getViteConfig(dir, configEnv) {
|
|
|
9664
9980
|
ssr: configEnv.isSsrBuild,
|
|
9665
9981
|
sourcemap: true,
|
|
9666
9982
|
target: "es2022",
|
|
9667
|
-
outDir:
|
|
9668
|
-
|
|
9983
|
+
outDir: path26.resolve(
|
|
9984
|
+
path26.join(
|
|
9669
9985
|
dir,
|
|
9670
9986
|
"dist",
|
|
9671
9987
|
config2.basePath ?? "",
|
|
@@ -9684,7 +10000,7 @@ async function getViteConfig(dir, configEnv) {
|
|
|
9684
10000
|
},
|
|
9685
10001
|
experimental: {
|
|
9686
10002
|
renderBuiltUrl(filename) {
|
|
9687
|
-
if (cdnUrl?.base && [".js", ".css"].includes(
|
|
10003
|
+
if (cdnUrl?.base && [".js", ".css"].includes(path26.extname(filename))) {
|
|
9688
10004
|
return joinUrl(cdnUrl.base, filename);
|
|
9689
10005
|
}
|
|
9690
10006
|
if (cdnUrl?.media && MEDIA_REGEX.test(filename)) {
|
|
@@ -9697,7 +10013,7 @@ async function getViteConfig(dir, configEnv) {
|
|
|
9697
10013
|
esbuildOptions: {
|
|
9698
10014
|
target: "es2022"
|
|
9699
10015
|
},
|
|
9700
|
-
entries: [
|
|
10016
|
+
entries: [path26.posix.join(getZudokuRootDir(), "src/{app,lib}/**")],
|
|
9701
10017
|
exclude: [
|
|
9702
10018
|
"@lukoweb/apitogo",
|
|
9703
10019
|
"@lukoweb/apitogo-plugin-dev-portal-billing"
|
|
@@ -9741,7 +10057,7 @@ async function getViteConfig(dir, configEnv) {
|
|
|
9741
10057
|
if (!loaded) continue;
|
|
9742
10058
|
mergedViteConfig = mergeConfig2(mergedViteConfig, loaded.config, true);
|
|
9743
10059
|
if (root === dir) {
|
|
9744
|
-
logger.info(
|
|
10060
|
+
logger.info(colors7.blue(`merged with custom user Vite config`), {
|
|
9745
10061
|
timestamp: true
|
|
9746
10062
|
});
|
|
9747
10063
|
}
|
|
@@ -9802,8 +10118,8 @@ ${cssLinks}
|
|
|
9802
10118
|
init_package_json();
|
|
9803
10119
|
init_joinUrl();
|
|
9804
10120
|
import assert from "node:assert";
|
|
9805
|
-
import { cp, mkdir as mkdir3, writeFile as
|
|
9806
|
-
import
|
|
10121
|
+
import { cp, mkdir as mkdir3, writeFile as writeFile4 } from "node:fs/promises";
|
|
10122
|
+
import path27 from "node:path";
|
|
9807
10123
|
var pkgJson = getZudokuPackageJson();
|
|
9808
10124
|
function generateOutput({
|
|
9809
10125
|
config: config2,
|
|
@@ -9860,10 +10176,10 @@ async function writeOutput(dir, {
|
|
|
9860
10176
|
rewrites
|
|
9861
10177
|
}) {
|
|
9862
10178
|
const output2 = generateOutput({ config: config2, redirects, rewrites });
|
|
9863
|
-
const outputDir = process.env.VERCEL ?
|
|
10179
|
+
const outputDir = process.env.VERCEL ? path27.join(dir, ".vercel/output") : path27.join(dir, "dist/.output");
|
|
9864
10180
|
await mkdir3(outputDir, { recursive: true });
|
|
9865
|
-
const outputFile =
|
|
9866
|
-
await
|
|
10181
|
+
const outputFile = path27.join(outputDir, "config.json");
|
|
10182
|
+
await writeFile4(outputFile, JSON.stringify(output2, null, 2), "utf-8");
|
|
9867
10183
|
if (process.env.VERCEL) {
|
|
9868
10184
|
console.log("Wrote Vercel output to", outputDir);
|
|
9869
10185
|
}
|
|
@@ -9872,12 +10188,12 @@ async function writeOutput(dir, {
|
|
|
9872
10188
|
// src/vite/prerender/prerender.ts
|
|
9873
10189
|
init_logger();
|
|
9874
10190
|
init_file_exists();
|
|
9875
|
-
import { readFile as
|
|
10191
|
+
import { readFile as readFile3, rm } from "node:fs/promises";
|
|
9876
10192
|
import os from "node:os";
|
|
9877
|
-
import
|
|
10193
|
+
import path30 from "node:path";
|
|
9878
10194
|
import { pathToFileURL } from "node:url";
|
|
9879
10195
|
import { createIndex } from "pagefind";
|
|
9880
|
-
import
|
|
10196
|
+
import colors10 from "picocolors";
|
|
9881
10197
|
import PiscinaImport from "piscina";
|
|
9882
10198
|
init_transform_config();
|
|
9883
10199
|
init_invariant();
|
|
@@ -9914,10 +10230,10 @@ function throttle(fn) {
|
|
|
9914
10230
|
|
|
9915
10231
|
// src/vite/sitemap.ts
|
|
9916
10232
|
init_joinUrl();
|
|
9917
|
-
import { createWriteStream, existsSync as
|
|
10233
|
+
import { createWriteStream, existsSync as existsSync3 } from "node:fs";
|
|
9918
10234
|
import { mkdir as mkdir4 } from "node:fs/promises";
|
|
9919
|
-
import
|
|
9920
|
-
import
|
|
10235
|
+
import path28 from "node:path";
|
|
10236
|
+
import colors8 from "picocolors";
|
|
9921
10237
|
import { SitemapStream } from "sitemap";
|
|
9922
10238
|
async function generateSitemap({
|
|
9923
10239
|
outputUrls,
|
|
@@ -9930,11 +10246,11 @@ async function generateSitemap({
|
|
|
9930
10246
|
return;
|
|
9931
10247
|
}
|
|
9932
10248
|
const sitemap = new SitemapStream({ hostname: config2.siteUrl });
|
|
9933
|
-
const outputDir =
|
|
9934
|
-
if (!
|
|
10249
|
+
const outputDir = path28.resolve(baseOutputDir, config2.outDir ?? "");
|
|
10250
|
+
if (!existsSync3(outputDir)) {
|
|
9935
10251
|
await mkdir4(outputDir, { recursive: true });
|
|
9936
10252
|
}
|
|
9937
|
-
const sitemapOutputPath =
|
|
10253
|
+
const sitemapOutputPath = path28.join(outputDir, "sitemap.xml");
|
|
9938
10254
|
const writeStream = createWriteStream(sitemapOutputPath);
|
|
9939
10255
|
sitemap.pipe(writeStream);
|
|
9940
10256
|
let lastmod;
|
|
@@ -9958,7 +10274,7 @@ async function generateSitemap({
|
|
|
9958
10274
|
writeStream.on("error", reject);
|
|
9959
10275
|
});
|
|
9960
10276
|
console.debug(
|
|
9961
|
-
|
|
10277
|
+
colors8.blue(`\u2713 wrote sitemap to ${colors8.bold(sitemapOutputPath)}`)
|
|
9962
10278
|
);
|
|
9963
10279
|
}
|
|
9964
10280
|
|
|
@@ -10020,12 +10336,12 @@ var prerender = async ({
|
|
|
10020
10336
|
serverConfigFilename,
|
|
10021
10337
|
writeRedirects = true
|
|
10022
10338
|
}) => {
|
|
10023
|
-
const distDir =
|
|
10339
|
+
const distDir = path30.join(dir, "dist", basePath);
|
|
10024
10340
|
const serverConfigPath = pathToFileURL(
|
|
10025
|
-
|
|
10341
|
+
path30.join(distDir, "server", serverConfigFilename)
|
|
10026
10342
|
).href;
|
|
10027
10343
|
const entryServerPath = pathToFileURL(
|
|
10028
|
-
|
|
10344
|
+
path30.join(distDir, "server/entry.server.js")
|
|
10029
10345
|
).href;
|
|
10030
10346
|
const rawConfig = await import(serverConfigPath).then(
|
|
10031
10347
|
(m) => m.default
|
|
@@ -10050,12 +10366,12 @@ var prerender = async ({
|
|
|
10050
10366
|
const writeProgress = throttle(
|
|
10051
10367
|
(count, total, urlPath) => {
|
|
10052
10368
|
if (quietDeployJson) return;
|
|
10053
|
-
writeLine(`prerendering (${count}/${total}) ${
|
|
10369
|
+
writeLine(`prerendering (${count}/${total}) ${colors10.dim(urlPath)}`);
|
|
10054
10370
|
}
|
|
10055
10371
|
);
|
|
10056
10372
|
if (!isTTY() && !quietDeployJson) {
|
|
10057
10373
|
logger.info(
|
|
10058
|
-
|
|
10374
|
+
colors10.dim(
|
|
10059
10375
|
`prerendering ${paths.length} routes using ${maxThreads} workers...`
|
|
10060
10376
|
)
|
|
10061
10377
|
);
|
|
@@ -10099,7 +10415,7 @@ var prerender = async ({
|
|
|
10099
10415
|
const now = performance.now();
|
|
10100
10416
|
if (now - lastLogTime >= LOG_INTERVAL_MS) {
|
|
10101
10417
|
logger.info(
|
|
10102
|
-
|
|
10418
|
+
colors10.blue(
|
|
10103
10419
|
`prerendered ${completedCount}/${paths.length} routes using ${maxThreads} workers`
|
|
10104
10420
|
)
|
|
10105
10421
|
);
|
|
@@ -10110,20 +10426,20 @@ var prerender = async ({
|
|
|
10110
10426
|
})
|
|
10111
10427
|
);
|
|
10112
10428
|
const pagefindWriteResult = await pagefindIndex?.writeFiles({
|
|
10113
|
-
outputPath:
|
|
10429
|
+
outputPath: path30.join(distDir, "pagefind")
|
|
10114
10430
|
});
|
|
10115
10431
|
const seconds = ((performance.now() - start) / 1e3).toFixed(1);
|
|
10116
10432
|
const message = `\u2713 finished prerendering ${paths.length} routes in ${seconds} seconds using ${maxThreads} workers`;
|
|
10117
10433
|
if (!quietDeployJson) {
|
|
10118
10434
|
if (isTTY()) {
|
|
10119
|
-
writeLine(
|
|
10435
|
+
writeLine(colors10.blue(`${message}
|
|
10120
10436
|
`));
|
|
10121
10437
|
} else {
|
|
10122
|
-
logger.info(
|
|
10438
|
+
logger.info(colors10.blue(message));
|
|
10123
10439
|
}
|
|
10124
10440
|
if (pagefindWriteResult?.outputPath) {
|
|
10125
10441
|
logger.info(
|
|
10126
|
-
|
|
10442
|
+
colors10.blue(
|
|
10127
10443
|
`\u2713 pagefind index built: ${pagefindWriteResult.outputPath}`
|
|
10128
10444
|
)
|
|
10129
10445
|
);
|
|
@@ -10142,13 +10458,13 @@ var prerender = async ({
|
|
|
10142
10458
|
const { generateLlmsTxtFiles: generateLlmsTxtFiles2 } = await Promise.resolve().then(() => (init_llms(), llms_exports));
|
|
10143
10459
|
const docsConfig = DocsConfigSchema2.parse(config2.docs);
|
|
10144
10460
|
const llmsConfig = docsConfig.llms ?? {};
|
|
10145
|
-
const markdownInfoPath =
|
|
10461
|
+
const markdownInfoPath = path30.join(
|
|
10146
10462
|
dir,
|
|
10147
10463
|
"node_modules/.apitogo/markdown-info.json"
|
|
10148
10464
|
);
|
|
10149
10465
|
let markdownFileInfos = [];
|
|
10150
10466
|
if (await fileExists(markdownInfoPath)) {
|
|
10151
|
-
const markdownInfoContent = await
|
|
10467
|
+
const markdownInfoContent = await readFile3(markdownInfoPath, "utf-8");
|
|
10152
10468
|
markdownFileInfos = JSON.parse(markdownInfoContent);
|
|
10153
10469
|
}
|
|
10154
10470
|
if (llmsConfig.llmsTxt || llmsConfig.llmsTxtFull) {
|
|
@@ -10233,7 +10549,7 @@ async function runBuild(options) {
|
|
|
10233
10549
|
html,
|
|
10234
10550
|
basePath: config2.basePath
|
|
10235
10551
|
});
|
|
10236
|
-
await rm2(
|
|
10552
|
+
await rm2(path31.join(clientOutDir, "index.html"), { force: true });
|
|
10237
10553
|
} else {
|
|
10238
10554
|
await runPrerender({
|
|
10239
10555
|
dir,
|
|
@@ -10257,9 +10573,9 @@ var runPrerender = async (options) => {
|
|
|
10257
10573
|
serverConfigFilename,
|
|
10258
10574
|
writeRedirects: process.env.VERCEL === void 0
|
|
10259
10575
|
});
|
|
10260
|
-
const indexHtml =
|
|
10576
|
+
const indexHtml = path31.join(clientOutDir, "index.html");
|
|
10261
10577
|
if (!workerResults.find((r) => r.outputPath === indexHtml)) {
|
|
10262
|
-
await
|
|
10578
|
+
await writeFile6(indexHtml, html, "utf-8");
|
|
10263
10579
|
}
|
|
10264
10580
|
const statusPages = workerResults.flatMap(
|
|
10265
10581
|
(r) => /400|404|500\.html$/.test(r.outputPath) ? r.outputPath : []
|
|
@@ -10267,15 +10583,15 @@ var runPrerender = async (options) => {
|
|
|
10267
10583
|
for (const statusPage of statusPages) {
|
|
10268
10584
|
await rename(
|
|
10269
10585
|
statusPage,
|
|
10270
|
-
|
|
10586
|
+
path31.join(dir, DIST_DIR, path31.basename(statusPage))
|
|
10271
10587
|
);
|
|
10272
10588
|
}
|
|
10273
10589
|
await rm2(serverOutDir, { recursive: true, force: true });
|
|
10274
10590
|
if (process.env.VERCEL) {
|
|
10275
|
-
await mkdir5(
|
|
10591
|
+
await mkdir5(path31.join(dir, ".vercel/output/static"), { recursive: true });
|
|
10276
10592
|
await rename(
|
|
10277
|
-
|
|
10278
|
-
|
|
10593
|
+
path31.join(dir, DIST_DIR),
|
|
10594
|
+
path31.join(dir, ".vercel/output/static")
|
|
10279
10595
|
);
|
|
10280
10596
|
}
|
|
10281
10597
|
await writeOutput(dir, {
|
|
@@ -10284,8 +10600,8 @@ var runPrerender = async (options) => {
|
|
|
10284
10600
|
rewrites
|
|
10285
10601
|
});
|
|
10286
10602
|
if (ZuploEnv.isZuplo && issuer) {
|
|
10287
|
-
await
|
|
10288
|
-
|
|
10603
|
+
await writeFile6(
|
|
10604
|
+
path31.join(dir, DIST_DIR, ".output/zuplo.json"),
|
|
10289
10605
|
JSON.stringify({ issuer }, null, 2),
|
|
10290
10606
|
"utf-8"
|
|
10291
10607
|
);
|
|
@@ -10297,17 +10613,17 @@ var runPrerender = async (options) => {
|
|
|
10297
10613
|
};
|
|
10298
10614
|
var bundleSSREntry = async (options) => {
|
|
10299
10615
|
const { dir, adapter, serverOutDir, serverConfigFilename, html, basePath } = options;
|
|
10300
|
-
const tempEntryPath =
|
|
10616
|
+
const tempEntryPath = path31.join(dir, "__ssr-entry.ts");
|
|
10301
10617
|
const packageRoot = getZudokuRootDir();
|
|
10302
|
-
const templateContent = await
|
|
10303
|
-
|
|
10618
|
+
const templateContent = await readFile4(
|
|
10619
|
+
path31.join(packageRoot, "src/vite/ssr-templates", `${adapter}.ts`),
|
|
10304
10620
|
"utf-8"
|
|
10305
10621
|
);
|
|
10306
10622
|
const entryContent = templateContent.replace('"__TEMPLATE__"', JSON.stringify(html)).replace('"__CONFIG_FILE__"', JSON.stringify(`./${serverConfigFilename}`)).replace(
|
|
10307
10623
|
'"__BASE_PATH__"',
|
|
10308
10624
|
basePath ? JSON.stringify(basePath) : "undefined"
|
|
10309
10625
|
);
|
|
10310
|
-
await
|
|
10626
|
+
await writeFile6(tempEntryPath, entryContent, "utf-8");
|
|
10311
10627
|
try {
|
|
10312
10628
|
await esbuild({
|
|
10313
10629
|
entryPoints: [tempEntryPath],
|
|
@@ -10315,9 +10631,9 @@ var bundleSSREntry = async (options) => {
|
|
|
10315
10631
|
platform: adapter === "node" ? "node" : "neutral",
|
|
10316
10632
|
target: "es2022",
|
|
10317
10633
|
format: "esm",
|
|
10318
|
-
outfile:
|
|
10634
|
+
outfile: path31.join(serverOutDir, "entry.js"),
|
|
10319
10635
|
external: ["./entry.server.js", `./${serverConfigFilename}`],
|
|
10320
|
-
nodePaths: [
|
|
10636
|
+
nodePaths: [path31.join(packageRoot, "node_modules")],
|
|
10321
10637
|
banner: { js: "// Bundled SSR entry" }
|
|
10322
10638
|
});
|
|
10323
10639
|
} finally {
|
|
@@ -10327,48 +10643,14 @@ var bundleSSREntry = async (options) => {
|
|
|
10327
10643
|
|
|
10328
10644
|
// src/cli/build/handler.ts
|
|
10329
10645
|
init_logger();
|
|
10330
|
-
|
|
10331
|
-
// src/cli/common/output.ts
|
|
10332
|
-
import * as Sentry from "@sentry/node";
|
|
10333
|
-
import colors8 from "picocolors";
|
|
10334
|
-
|
|
10335
|
-
// src/cli/common/constants.ts
|
|
10336
|
-
var CLI_XDG_FOLDER_NAME = "apitogo";
|
|
10337
|
-
var VERSION_CHECK_FILE = "version.json";
|
|
10338
|
-
var SENTRY_DSN = void 0;
|
|
10339
|
-
var MAX_WAIT_PENDING_TIME_MS = 1e3;
|
|
10340
|
-
var POST_HOG_CAPTURE_KEY = void 0;
|
|
10341
|
-
|
|
10342
|
-
// src/cli/common/output.ts
|
|
10343
|
-
function printDiagnosticsToConsole(message) {
|
|
10344
|
-
console.error(colors8.bold(colors8.blue(message)));
|
|
10345
|
-
}
|
|
10346
|
-
function printWarningToConsole(message) {
|
|
10347
|
-
console.error(message);
|
|
10348
|
-
}
|
|
10349
|
-
async function printCriticalFailureToConsoleAndExit(message) {
|
|
10350
|
-
console.error(colors8.bold(colors8.red(message)));
|
|
10351
|
-
await Sentry.close(MAX_WAIT_PENDING_TIME_MS).then(() => {
|
|
10352
|
-
process.exit(1);
|
|
10353
|
-
});
|
|
10354
|
-
}
|
|
10355
|
-
function printJsonOnlyErrorAndExit(message) {
|
|
10356
|
-
console.log(JSON.stringify({ error: message }));
|
|
10357
|
-
process.exit(1);
|
|
10358
|
-
}
|
|
10359
|
-
function printResultToConsole(message) {
|
|
10360
|
-
console.log(colors8.bold(colors8.green(message)));
|
|
10361
|
-
}
|
|
10362
|
-
|
|
10363
|
-
// src/cli/build/handler.ts
|
|
10364
10646
|
init_package_json();
|
|
10365
10647
|
|
|
10366
10648
|
// src/cli/preview/handler.ts
|
|
10367
|
-
import
|
|
10649
|
+
import path32 from "node:path";
|
|
10368
10650
|
import { preview as vitePreview } from "vite";
|
|
10369
10651
|
var DEFAULT_PREVIEW_PORT = 4e3;
|
|
10370
10652
|
async function preview(argv) {
|
|
10371
|
-
const dir =
|
|
10653
|
+
const dir = path32.resolve(process.cwd(), argv.dir);
|
|
10372
10654
|
const viteConfig = await getViteConfig(dir, {
|
|
10373
10655
|
command: "serve",
|
|
10374
10656
|
mode: "production",
|
|
@@ -10402,14 +10684,14 @@ async function preview(argv) {
|
|
|
10402
10684
|
|
|
10403
10685
|
// src/cli/build/handler.ts
|
|
10404
10686
|
async function build(argv) {
|
|
10405
|
-
const
|
|
10687
|
+
const packageJson3 = getZudokuPackageJson();
|
|
10406
10688
|
const jsonOnly = argv.jsonOnly === true || process.env.APITOGO_JSON_ONLY === "1";
|
|
10407
10689
|
if (!jsonOnly) {
|
|
10408
|
-
printDiagnosticsToConsole(`Starting API ToGo build v${
|
|
10690
|
+
printDiagnosticsToConsole(`Starting API ToGo build v${packageJson3.version}`);
|
|
10409
10691
|
printDiagnosticsToConsole("");
|
|
10410
10692
|
printDiagnosticsToConsole("");
|
|
10411
10693
|
}
|
|
10412
|
-
const dir =
|
|
10694
|
+
const dir = path33.resolve(process.cwd(), argv.dir);
|
|
10413
10695
|
try {
|
|
10414
10696
|
await runBuild({
|
|
10415
10697
|
dir,
|
|
@@ -10434,107 +10716,9 @@ async function build(argv) {
|
|
|
10434
10716
|
}
|
|
10435
10717
|
}
|
|
10436
10718
|
|
|
10437
|
-
// src/cli/common/analytics/lib.ts
|
|
10438
|
-
import { PostHog } from "posthog-node";
|
|
10439
|
-
|
|
10440
|
-
// src/cli/common/machine-id/lib.ts
|
|
10441
|
-
import { execSync } from "node:child_process";
|
|
10442
|
-
import { createHash } from "node:crypto";
|
|
10443
|
-
var win32RegBinPath = {
|
|
10444
|
-
skipped: "",
|
|
10445
|
-
native: "%windir%\\System32",
|
|
10446
|
-
mixed: "%windir%\\sysnative\\cmd.exe /c %windir%\\System32"
|
|
10447
|
-
};
|
|
10448
|
-
var guid = {
|
|
10449
|
-
darwin: "ioreg -rd1 -c IOPlatformExpertDevice",
|
|
10450
|
-
win32: `${win32RegBinPath[isWindowsProcessMixedOrNativeArchitecture()]}\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid`,
|
|
10451
|
-
linux: "( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :"
|
|
10452
|
-
};
|
|
10453
|
-
function isWindowsProcessMixedOrNativeArchitecture() {
|
|
10454
|
-
if (process.platform !== "win32") {
|
|
10455
|
-
return "skipped";
|
|
10456
|
-
}
|
|
10457
|
-
if (process.arch === "ia32" && process.env.PROCESSOR_ARCHITEW6432) {
|
|
10458
|
-
return "mixed";
|
|
10459
|
-
}
|
|
10460
|
-
return "native";
|
|
10461
|
-
}
|
|
10462
|
-
function hash(guid2) {
|
|
10463
|
-
return createHash("sha256").update(guid2).digest("hex");
|
|
10464
|
-
}
|
|
10465
|
-
function expose(result) {
|
|
10466
|
-
switch (process.platform) {
|
|
10467
|
-
case "darwin":
|
|
10468
|
-
return result.split("IOPlatformUUID")[1].split("\n")[0].replace(/=|\s+]"/gi, "").toLowerCase();
|
|
10469
|
-
case "win32":
|
|
10470
|
-
return result.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi, "").toLowerCase();
|
|
10471
|
-
case "linux":
|
|
10472
|
-
return result.toString().replace(/\r+|\n+|\s+/gi, "").toLowerCase();
|
|
10473
|
-
case "freebsd":
|
|
10474
|
-
return result.toString().replace(/\r+|\n+|\s+/gi, "").toLowerCase();
|
|
10475
|
-
default:
|
|
10476
|
-
throw new Error(`Unsupported platform: ${process.platform}`);
|
|
10477
|
-
}
|
|
10478
|
-
}
|
|
10479
|
-
function machineId() {
|
|
10480
|
-
switch (process.platform) {
|
|
10481
|
-
case "darwin":
|
|
10482
|
-
case "win32":
|
|
10483
|
-
case "linux":
|
|
10484
|
-
return hash(expose(execSync(guid[process.platform]).toString()));
|
|
10485
|
-
default:
|
|
10486
|
-
return "e16fc483-5593-4d71-b485-a6533693da9b";
|
|
10487
|
-
}
|
|
10488
|
-
}
|
|
10489
|
-
|
|
10490
|
-
// src/cli/common/analytics/lib.ts
|
|
10491
|
-
var _postHog;
|
|
10492
|
-
function init() {
|
|
10493
|
-
if (process.env.ZUDOKU_DO_NOT_TRACK || !POST_HOG_CAPTURE_KEY) {
|
|
10494
|
-
return void 0;
|
|
10495
|
-
}
|
|
10496
|
-
_postHog = new PostHog(POST_HOG_CAPTURE_KEY, {
|
|
10497
|
-
host: "https://app.posthog.com",
|
|
10498
|
-
flushAt: 1,
|
|
10499
|
-
flushInterval: 1
|
|
10500
|
-
});
|
|
10501
|
-
return _postHog;
|
|
10502
|
-
}
|
|
10503
|
-
async function captureEvent({
|
|
10504
|
-
event,
|
|
10505
|
-
properties,
|
|
10506
|
-
groups,
|
|
10507
|
-
sendFeatureFlags,
|
|
10508
|
-
timestamp,
|
|
10509
|
-
disableGeoip
|
|
10510
|
-
}) {
|
|
10511
|
-
if (_postHog === void 0) {
|
|
10512
|
-
init();
|
|
10513
|
-
}
|
|
10514
|
-
if (_postHog) {
|
|
10515
|
-
properties = properties ?? {};
|
|
10516
|
-
properties.$set_once = properties.$set_once ?? {};
|
|
10517
|
-
if (process.env.CI) {
|
|
10518
|
-
properties.ci = process.env.CI;
|
|
10519
|
-
}
|
|
10520
|
-
_postHog.capture({
|
|
10521
|
-
distinctId: machineId(),
|
|
10522
|
-
event,
|
|
10523
|
-
properties,
|
|
10524
|
-
groups,
|
|
10525
|
-
sendFeatureFlags,
|
|
10526
|
-
timestamp,
|
|
10527
|
-
disableGeoip
|
|
10528
|
-
});
|
|
10529
|
-
}
|
|
10530
|
-
}
|
|
10531
|
-
async function shutdownAnalytics() {
|
|
10532
|
-
return _postHog?.shutdown();
|
|
10533
|
-
}
|
|
10534
|
-
|
|
10535
10719
|
// src/cli/cmds/build.ts
|
|
10536
10720
|
var build_default = {
|
|
10537
|
-
desc: "Build",
|
|
10721
|
+
desc: "Build the local portal for production",
|
|
10538
10722
|
command: "build",
|
|
10539
10723
|
builder: (yargs2) => yargs2.option("dir", {
|
|
10540
10724
|
type: "string",
|
|
@@ -10567,14 +10751,14 @@ var build_default = {
|
|
|
10567
10751
|
};
|
|
10568
10752
|
|
|
10569
10753
|
// src/cli/check/handler.ts
|
|
10570
|
-
import
|
|
10754
|
+
import path40 from "node:path";
|
|
10571
10755
|
|
|
10572
10756
|
// src/cli/platform/client/platform-api.ts
|
|
10573
10757
|
import { basename } from "node:path";
|
|
10574
10758
|
|
|
10575
10759
|
// src/cli/platform/client/deploy-server.ts
|
|
10576
|
-
import { readFile as
|
|
10577
|
-
import
|
|
10760
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
10761
|
+
import path34 from "node:path";
|
|
10578
10762
|
var UPLOAD_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
10579
10763
|
var DeployServerError = class extends Error {
|
|
10580
10764
|
statusCode;
|
|
@@ -10586,8 +10770,8 @@ var DeployServerError = class extends Error {
|
|
|
10586
10770
|
};
|
|
10587
10771
|
async function uploadDevPortalArchive(params) {
|
|
10588
10772
|
const { endpointUrl, apiKey, deploymentToken, env, archivePath } = params;
|
|
10589
|
-
const fileBuffer = await
|
|
10590
|
-
const fileName =
|
|
10773
|
+
const fileBuffer = await readFile5(archivePath);
|
|
10774
|
+
const fileName = path34.basename(archivePath);
|
|
10591
10775
|
const form = new FormData();
|
|
10592
10776
|
form.append("deploymentToken", deploymentToken);
|
|
10593
10777
|
form.append("env", env);
|
|
@@ -11191,7 +11375,7 @@ function resolveDevPortalDeployConfig(config2) {
|
|
|
11191
11375
|
}
|
|
11192
11376
|
|
|
11193
11377
|
// src/cli/platform/tools/check-publish-readiness.ts
|
|
11194
|
-
import
|
|
11378
|
+
import path39 from "node:path";
|
|
11195
11379
|
|
|
11196
11380
|
// src/cli/platform/helpers/dev-portal-backend.ts
|
|
11197
11381
|
function deriveProvisioningState(backend) {
|
|
@@ -11273,9 +11457,9 @@ function formatDevPortalBackendResponse(projectId, backend) {
|
|
|
11273
11457
|
}
|
|
11274
11458
|
|
|
11275
11459
|
// src/cli/platform/helpers/dev-portal-manifest.ts
|
|
11276
|
-
import { existsSync as
|
|
11277
|
-
import { access, mkdir as mkdir6, readFile as
|
|
11278
|
-
import
|
|
11460
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
11461
|
+
import { access, mkdir as mkdir6, readFile as readFile6, writeFile as writeFile7 } from "node:fs/promises";
|
|
11462
|
+
import path35 from "node:path";
|
|
11279
11463
|
|
|
11280
11464
|
// src/cli/make-config/header-pricing-nav.ts
|
|
11281
11465
|
var HEADER_PRICING_PATH = "/pricing";
|
|
@@ -11335,7 +11519,7 @@ function isPlanFree(plan) {
|
|
|
11335
11519
|
return (plan.priceAmount ?? 0) <= 0;
|
|
11336
11520
|
}
|
|
11337
11521
|
function manifestFilePath(siteDirectory) {
|
|
11338
|
-
return
|
|
11522
|
+
return path35.join(path35.resolve(siteDirectory), APITOGO_CONFIG_FILENAME2);
|
|
11339
11523
|
}
|
|
11340
11524
|
var STORED_MANIFEST_KEYS = [
|
|
11341
11525
|
"authentication",
|
|
@@ -11796,29 +11980,29 @@ function resolveBackendOpenApiPath(openApiPath, options) {
|
|
|
11796
11980
|
if (!trimmed) {
|
|
11797
11981
|
return void 0;
|
|
11798
11982
|
}
|
|
11799
|
-
if (
|
|
11983
|
+
if (path35.isAbsolute(trimmed)) {
|
|
11800
11984
|
return trimmed;
|
|
11801
11985
|
}
|
|
11802
|
-
const siteResolved =
|
|
11803
|
-
if (
|
|
11986
|
+
const siteResolved = path35.resolve(options.siteDirectory, trimmed);
|
|
11987
|
+
if (existsSync4(siteResolved)) {
|
|
11804
11988
|
return siteResolved;
|
|
11805
11989
|
}
|
|
11806
11990
|
const backendDir = options.backendSourceDirectory?.trim();
|
|
11807
11991
|
if (backendDir) {
|
|
11808
|
-
const backendResolved =
|
|
11809
|
-
if (
|
|
11992
|
+
const backendResolved = path35.resolve(backendDir, trimmed);
|
|
11993
|
+
if (existsSync4(backendResolved)) {
|
|
11810
11994
|
return backendResolved;
|
|
11811
11995
|
}
|
|
11812
11996
|
}
|
|
11813
11997
|
return siteResolved;
|
|
11814
11998
|
}
|
|
11815
11999
|
function toSiteRelativeOpenApiInput(siteDirectory, openApiAbsolutePath) {
|
|
11816
|
-
const relative =
|
|
11817
|
-
const posix = relative.split(
|
|
12000
|
+
const relative = path35.relative(path35.resolve(siteDirectory), path35.resolve(openApiAbsolutePath));
|
|
12001
|
+
const posix = relative.split(path35.sep).join("/");
|
|
11818
12002
|
if (!posix || posix === ".") {
|
|
11819
12003
|
return "./";
|
|
11820
12004
|
}
|
|
11821
|
-
if (
|
|
12005
|
+
if (path35.isAbsolute(posix) || posix.startsWith("..")) {
|
|
11822
12006
|
return posix;
|
|
11823
12007
|
}
|
|
11824
12008
|
return posix.startsWith("./") ? posix : `./${posix}`;
|
|
@@ -11857,7 +12041,7 @@ function applyOpenApiToSiteConfig(config2, options) {
|
|
|
11857
12041
|
async function readManifest(siteDirectory) {
|
|
11858
12042
|
const filePath = manifestFilePath(siteDirectory);
|
|
11859
12043
|
if (await pathExists(filePath)) {
|
|
11860
|
-
const raw = await
|
|
12044
|
+
const raw = await readFile6(filePath, "utf8");
|
|
11861
12045
|
const config2 = JSON.parse(raw);
|
|
11862
12046
|
return extractManifestFromConfig(config2);
|
|
11863
12047
|
}
|
|
@@ -11865,22 +12049,22 @@ async function readManifest(siteDirectory) {
|
|
|
11865
12049
|
}
|
|
11866
12050
|
async function writeManifest(siteDirectory, manifest) {
|
|
11867
12051
|
const filePath = manifestFilePath(siteDirectory);
|
|
11868
|
-
await mkdir6(
|
|
12052
|
+
await mkdir6(path35.dirname(filePath), { recursive: true });
|
|
11869
12053
|
let config2 = {};
|
|
11870
12054
|
if (await pathExists(filePath)) {
|
|
11871
|
-
const raw = await
|
|
12055
|
+
const raw = await readFile6(filePath, "utf8");
|
|
11872
12056
|
config2 = JSON.parse(raw);
|
|
11873
12057
|
}
|
|
11874
12058
|
const { oidc: _oidc, stripe: _stripe, ...safeManifest } = manifest;
|
|
11875
12059
|
config2 = applyManifestToConfig(config2, safeManifest);
|
|
11876
|
-
await
|
|
12060
|
+
await writeFile7(filePath, `${JSON.stringify(config2, null, 2)}
|
|
11877
12061
|
`, "utf8");
|
|
11878
12062
|
return filePath;
|
|
11879
12063
|
}
|
|
11880
12064
|
|
|
11881
12065
|
// src/cli/platform/helpers/dev-portal-secrets.ts
|
|
11882
|
-
import { access as access2, appendFile, mkdir as mkdir7, readFile as
|
|
11883
|
-
import
|
|
12066
|
+
import { access as access2, appendFile, mkdir as mkdir7, readFile as readFile7, unlink, writeFile as writeFile8 } from "node:fs/promises";
|
|
12067
|
+
import path36 from "node:path";
|
|
11884
12068
|
var ENV_FILENAME = ".env";
|
|
11885
12069
|
var COLLAPSED_UPPERCASE_ALIASES2 = {
|
|
11886
12070
|
SECRETKEY: "secretKey",
|
|
@@ -11982,7 +12166,7 @@ function applyEnvOverrides2(config2, env) {
|
|
|
11982
12166
|
}
|
|
11983
12167
|
async function readEnvFile(filePath) {
|
|
11984
12168
|
try {
|
|
11985
|
-
const raw = await
|
|
12169
|
+
const raw = await readFile7(filePath, "utf8");
|
|
11986
12170
|
const env = {};
|
|
11987
12171
|
for (const line of raw.split("\n")) {
|
|
11988
12172
|
const trimmed = line.trim();
|
|
@@ -11999,10 +12183,10 @@ async function readEnvFile(filePath) {
|
|
|
11999
12183
|
}
|
|
12000
12184
|
}
|
|
12001
12185
|
async function loadSiteEnv(siteDirectory) {
|
|
12002
|
-
const resolvedDirectory =
|
|
12186
|
+
const resolvedDirectory = path36.resolve(siteDirectory);
|
|
12003
12187
|
const merged = { ...process.env };
|
|
12004
12188
|
for (const fileName of [ENV_FILENAME, ".env.local"]) {
|
|
12005
|
-
Object.assign(merged, await readEnvFile(
|
|
12189
|
+
Object.assign(merged, await readEnvFile(path36.join(resolvedDirectory, fileName)));
|
|
12006
12190
|
}
|
|
12007
12191
|
return merged;
|
|
12008
12192
|
}
|
|
@@ -12038,7 +12222,7 @@ function buildAuthSecretsJson(secrets, options) {
|
|
|
12038
12222
|
return payload;
|
|
12039
12223
|
}
|
|
12040
12224
|
function envFilePath(siteDirectory) {
|
|
12041
|
-
return
|
|
12225
|
+
return path36.join(path36.resolve(siteDirectory), ENV_FILENAME);
|
|
12042
12226
|
}
|
|
12043
12227
|
function createEnvContent() {
|
|
12044
12228
|
return [
|
|
@@ -12098,7 +12282,7 @@ function validateSecretsForPublish(manifest, secrets, emailOptions) {
|
|
|
12098
12282
|
}
|
|
12099
12283
|
async function siteEnvFileHasEntries(siteDirectory) {
|
|
12100
12284
|
for (const fileName of [ENV_FILENAME, ".env.local"]) {
|
|
12101
|
-
const loaded = await readEnvFile(
|
|
12285
|
+
const loaded = await readEnvFile(path36.join(siteDirectory, fileName));
|
|
12102
12286
|
if (Object.keys(loaded).length > 0) {
|
|
12103
12287
|
return true;
|
|
12104
12288
|
}
|
|
@@ -12106,7 +12290,7 @@ async function siteEnvFileHasEntries(siteDirectory) {
|
|
|
12106
12290
|
return false;
|
|
12107
12291
|
}
|
|
12108
12292
|
async function resolvePublishConfig(siteDirectory, emailOptions) {
|
|
12109
|
-
const resolvedDirectory =
|
|
12293
|
+
const resolvedDirectory = path36.resolve(siteDirectory);
|
|
12110
12294
|
const manifestRaw = await readManifest(resolvedDirectory);
|
|
12111
12295
|
if (!manifestRaw) {
|
|
12112
12296
|
throw new Error("apitogo.config.json not found in sourceDirectory.");
|
|
@@ -12135,20 +12319,20 @@ function envFileHasActiveAssignments(content) {
|
|
|
12135
12319
|
});
|
|
12136
12320
|
}
|
|
12137
12321
|
async function writeScaffoldEnv(siteDirectory) {
|
|
12138
|
-
const resolvedDirectory =
|
|
12322
|
+
const resolvedDirectory = path36.resolve(siteDirectory);
|
|
12139
12323
|
const filesWritten = [];
|
|
12140
12324
|
const envPath = envFilePath(resolvedDirectory);
|
|
12141
12325
|
try {
|
|
12142
12326
|
await access2(envPath);
|
|
12143
12327
|
} catch {
|
|
12144
12328
|
await mkdir7(resolvedDirectory, { recursive: true });
|
|
12145
|
-
await
|
|
12329
|
+
await writeFile8(envPath, createEnvContent(), "utf8");
|
|
12146
12330
|
filesWritten.push(ENV_FILENAME);
|
|
12147
12331
|
}
|
|
12148
12332
|
for (const legacyName of [".env.example"]) {
|
|
12149
|
-
const legacyPath =
|
|
12333
|
+
const legacyPath = path36.join(resolvedDirectory, legacyName);
|
|
12150
12334
|
try {
|
|
12151
|
-
const legacy = await
|
|
12335
|
+
const legacy = await readFile7(legacyPath, "utf8");
|
|
12152
12336
|
if (!envFileHasActiveAssignments(legacy)) {
|
|
12153
12337
|
await unlink(legacyPath);
|
|
12154
12338
|
filesWritten.push(`removed:${legacyName}`);
|
|
@@ -12156,10 +12340,10 @@ async function writeScaffoldEnv(siteDirectory) {
|
|
|
12156
12340
|
} catch {
|
|
12157
12341
|
}
|
|
12158
12342
|
}
|
|
12159
|
-
const gitignorePath =
|
|
12343
|
+
const gitignorePath = path36.join(resolvedDirectory, ".gitignore");
|
|
12160
12344
|
let gitignore = "";
|
|
12161
12345
|
try {
|
|
12162
|
-
gitignore = await
|
|
12346
|
+
gitignore = await readFile7(gitignorePath, "utf8");
|
|
12163
12347
|
} catch {
|
|
12164
12348
|
gitignore = "";
|
|
12165
12349
|
}
|
|
@@ -12171,7 +12355,7 @@ async function writeScaffoldEnv(siteDirectory) {
|
|
|
12171
12355
|
if (!hasEntry) {
|
|
12172
12356
|
const suffix = gitignore.length === 0 ? "" : gitignore.endsWith("\n") ? "" : "\n";
|
|
12173
12357
|
if (gitignore.length === 0) {
|
|
12174
|
-
await
|
|
12358
|
+
await writeFile8(gitignorePath, `${entry}
|
|
12175
12359
|
`, "utf8");
|
|
12176
12360
|
} else {
|
|
12177
12361
|
await appendFile(gitignorePath, `${suffix}${entry}
|
|
@@ -12190,13 +12374,13 @@ var writeScaffoldSecretsArtifacts = writeScaffoldEnv;
|
|
|
12190
12374
|
var SECRETS_COLLECTION_INSTRUCTION = "For go-live, plans must already be in apitogo.config.json \u2014 ask the user what plans they want before calling update_dev_portal_manifest; never add Free+Pro defaults unless they explicitly request them. The user must save auth secrets (OIDC provider secrets, and Stripe if paid plans) in .env using APITOGO_CONFIG_AUTHENTICATION__* keys. Native auth email is provisioned by the platform \u2014 do not ask for an ACS connection string. Share .env and required fields from publishPrerequisites.missingFields. Never ask for or accept secret values in chat. When the user confirms secrets are saved locally, call check_dev_portal_publish_readiness, then publish_dev_portal.";
|
|
12191
12375
|
|
|
12192
12376
|
// src/cli/platform/helpers/dev-portal-site-validation.ts
|
|
12193
|
-
import { readFile as
|
|
12377
|
+
import { readFile as readFile8 } from "node:fs/promises";
|
|
12194
12378
|
import { createRequire as createRequire2 } from "node:module";
|
|
12195
|
-
import
|
|
12379
|
+
import path37 from "node:path";
|
|
12196
12380
|
init_gateway_limits();
|
|
12197
12381
|
var cachedFallbackTs;
|
|
12198
12382
|
async function loadTypeScriptForSite(sourceDirectory) {
|
|
12199
|
-
const require2 = createRequire2(
|
|
12383
|
+
const require2 = createRequire2(path37.join(path37.resolve(sourceDirectory), "package.json"));
|
|
12200
12384
|
try {
|
|
12201
12385
|
return require2("typescript");
|
|
12202
12386
|
} catch {
|
|
@@ -12240,7 +12424,7 @@ async function referencedFileExists(sourceDirectory, reference) {
|
|
|
12240
12424
|
if (/^https?:\/\//i.test(reference)) {
|
|
12241
12425
|
return true;
|
|
12242
12426
|
}
|
|
12243
|
-
return pathExists(
|
|
12427
|
+
return pathExists(path37.resolve(sourceDirectory, reference.replace(/^\.\//, "")));
|
|
12244
12428
|
}
|
|
12245
12429
|
async function validateSiteConfigStructure(config2, sourceDirectory) {
|
|
12246
12430
|
const errors = [];
|
|
@@ -12346,17 +12530,17 @@ var DEFAULT_TSX_CANDIDATES = [
|
|
|
12346
12530
|
"landing/LandingPage.tsx"
|
|
12347
12531
|
];
|
|
12348
12532
|
async function validateDevPortalSiteConfig(sourceDirectory, options) {
|
|
12349
|
-
const resolvedDir =
|
|
12533
|
+
const resolvedDir = path37.resolve(sourceDirectory);
|
|
12350
12534
|
const issues = [];
|
|
12351
12535
|
const checkedFiles = [];
|
|
12352
12536
|
const skippedChecks = [];
|
|
12353
|
-
const jsonPath =
|
|
12537
|
+
const jsonPath = path37.join(resolvedDir, APITOGO_CONFIG_FILENAME2);
|
|
12354
12538
|
if (await pathExists(jsonPath)) {
|
|
12355
12539
|
checkedFiles.push(APITOGO_CONFIG_FILENAME2);
|
|
12356
12540
|
let parsed;
|
|
12357
12541
|
let parseFailed = false;
|
|
12358
12542
|
try {
|
|
12359
|
-
parsed = JSON.parse(await
|
|
12543
|
+
parsed = JSON.parse(await readFile8(jsonPath, "utf8"));
|
|
12360
12544
|
} catch (error) {
|
|
12361
12545
|
parseFailed = true;
|
|
12362
12546
|
issues.push({
|
|
@@ -12379,7 +12563,7 @@ async function validateDevPortalSiteConfig(sourceDirectory, options) {
|
|
|
12379
12563
|
);
|
|
12380
12564
|
const existingTsxFiles = [];
|
|
12381
12565
|
for (const relativeFile of tsxFiles) {
|
|
12382
|
-
if (await pathExists(
|
|
12566
|
+
if (await pathExists(path37.join(resolvedDir, relativeFile))) {
|
|
12383
12567
|
existingTsxFiles.push(relativeFile);
|
|
12384
12568
|
}
|
|
12385
12569
|
}
|
|
@@ -12392,7 +12576,7 @@ async function validateDevPortalSiteConfig(sourceDirectory, options) {
|
|
|
12392
12576
|
} else {
|
|
12393
12577
|
for (const relativeFile of existingTsxFiles) {
|
|
12394
12578
|
checkedFiles.push(relativeFile);
|
|
12395
|
-
const content = await
|
|
12579
|
+
const content = await readFile8(path37.join(resolvedDir, relativeFile), "utf8");
|
|
12396
12580
|
issues.push(
|
|
12397
12581
|
...checkTsxSyntax(ts, relativeFile, content).map((message) => ({
|
|
12398
12582
|
file: relativeFile,
|
|
@@ -12427,8 +12611,8 @@ function buildSiteValidationResponseFields(result) {
|
|
|
12427
12611
|
|
|
12428
12612
|
// src/cli/platform/helpers/npm-build.ts
|
|
12429
12613
|
import { spawn } from "node:child_process";
|
|
12430
|
-
import { access as access3, readFile as
|
|
12431
|
-
import
|
|
12614
|
+
import { access as access3, readFile as readFile9 } from "node:fs/promises";
|
|
12615
|
+
import path38 from "node:path";
|
|
12432
12616
|
var BUILD_LOG_TAIL_BYTES = 8192;
|
|
12433
12617
|
var MIN_NODE_MAJOR = 20;
|
|
12434
12618
|
var NpmBuildError = class extends Error {
|
|
@@ -12473,9 +12657,9 @@ async function pathExists2(filePath) {
|
|
|
12473
12657
|
return false;
|
|
12474
12658
|
}
|
|
12475
12659
|
}
|
|
12476
|
-
function runCommand(
|
|
12660
|
+
function runCommand(command2, args, cwd, env) {
|
|
12477
12661
|
return new Promise((resolve, reject) => {
|
|
12478
|
-
const child = spawn(
|
|
12662
|
+
const child = spawn(command2, args, {
|
|
12479
12663
|
cwd,
|
|
12480
12664
|
env: env ? { ...process.env, ...env } : process.env,
|
|
12481
12665
|
shell: process.platform === "win32"
|
|
@@ -12493,13 +12677,13 @@ function runCommand(command, args, cwd, env) {
|
|
|
12493
12677
|
}
|
|
12494
12678
|
async function runNpmInstall(sourceDirectory, options) {
|
|
12495
12679
|
assertNodeVersion(options?.nodeVersion);
|
|
12496
|
-
const cwd =
|
|
12497
|
-
const packageJsonPath =
|
|
12680
|
+
const cwd = path38.resolve(sourceDirectory);
|
|
12681
|
+
const packageJsonPath = path38.join(cwd, "package.json");
|
|
12498
12682
|
if (!await pathExists2(packageJsonPath)) {
|
|
12499
12683
|
throw new Error(`package.json not found in sourceDirectory: ${cwd}`);
|
|
12500
12684
|
}
|
|
12501
12685
|
const startedAt = Date.now();
|
|
12502
|
-
const lockPath =
|
|
12686
|
+
const lockPath = path38.join(cwd, "package-lock.json");
|
|
12503
12687
|
const installArgs = await pathExists2(lockPath) ? ["ci"] : ["install"];
|
|
12504
12688
|
const install = await runCommand("npm", installArgs, cwd);
|
|
12505
12689
|
const installLog = install.output;
|
|
@@ -12517,8 +12701,8 @@ async function runNpmInstall(sourceDirectory, options) {
|
|
|
12517
12701
|
}
|
|
12518
12702
|
async function runNpmBuild(sourceDirectory, options) {
|
|
12519
12703
|
assertNodeVersion(options?.nodeVersion);
|
|
12520
|
-
const cwd =
|
|
12521
|
-
const packageJsonPath =
|
|
12704
|
+
const cwd = path38.resolve(sourceDirectory);
|
|
12705
|
+
const packageJsonPath = path38.join(cwd, "package.json");
|
|
12522
12706
|
if (!await pathExists2(packageJsonPath)) {
|
|
12523
12707
|
throw new Error(`package.json not found in sourceDirectory: ${cwd}`);
|
|
12524
12708
|
}
|
|
@@ -12535,8 +12719,8 @@ async function runNpmBuild(sourceDirectory, options) {
|
|
|
12535
12719
|
build2.exitCode
|
|
12536
12720
|
);
|
|
12537
12721
|
}
|
|
12538
|
-
const distPath =
|
|
12539
|
-
const indexPath =
|
|
12722
|
+
const distPath = path38.join(cwd, "dist");
|
|
12723
|
+
const indexPath = path38.join(distPath, "index.html");
|
|
12540
12724
|
if (!await pathExists2(indexPath)) {
|
|
12541
12725
|
throw new NpmBuildError(
|
|
12542
12726
|
`Build completed but dist/index.html was not found at ${indexPath}`,
|
|
@@ -12888,7 +13072,7 @@ function validateManifestForPlatformPublish(manifest) {
|
|
|
12888
13072
|
|
|
12889
13073
|
// src/cli/platform/tools/check-publish-readiness.ts
|
|
12890
13074
|
async function checkPublishReadiness(client, _config, args) {
|
|
12891
|
-
const sourceDirectory =
|
|
13075
|
+
const sourceDirectory = path39.resolve(args.sourceDirectory);
|
|
12892
13076
|
const manifest = await readManifest(sourceDirectory) ?? createScaffoldManifest();
|
|
12893
13077
|
const emailOptions = await resolveEmailOptionsForPublish(
|
|
12894
13078
|
client,
|
|
@@ -12966,7 +13150,7 @@ async function checkPublishReadiness(client, _config, args) {
|
|
|
12966
13150
|
|
|
12967
13151
|
// src/cli/check/handler.ts
|
|
12968
13152
|
async function check(argv) {
|
|
12969
|
-
const sourceDirectory =
|
|
13153
|
+
const sourceDirectory = path40.resolve(process.cwd(), argv.dir);
|
|
12970
13154
|
const config2 = loadConfig();
|
|
12971
13155
|
const client = new PlatformApiClient(config2);
|
|
12972
13156
|
let result;
|
|
@@ -13010,18 +13194,18 @@ var check_default = {
|
|
|
13010
13194
|
|
|
13011
13195
|
// src/cli/make-config/handler.ts
|
|
13012
13196
|
import { constants as constants2 } from "node:fs";
|
|
13013
|
-
import { access as access8, mkdir as mkdir10, readFile as
|
|
13014
|
-
import
|
|
13197
|
+
import { access as access8, mkdir as mkdir10, readFile as readFile14, writeFile as writeFile13 } from "node:fs/promises";
|
|
13198
|
+
import path51 from "node:path";
|
|
13015
13199
|
import { stdin as input2 } from "node:process";
|
|
13016
13200
|
import { glob as glob5 } from "glob";
|
|
13017
13201
|
|
|
13018
13202
|
// src/cli/scaffold/dev-portal-config-pages.ts
|
|
13019
|
-
import { access as access4, readFile as
|
|
13020
|
-
import
|
|
13203
|
+
import { access as access4, readFile as readFile10, rename as rename2, rm as rm3, writeFile as writeFile9 } from "node:fs/promises";
|
|
13204
|
+
import path41 from "node:path";
|
|
13021
13205
|
async function writeConfigAtomically(filePath, content) {
|
|
13022
13206
|
const temporaryPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
13023
13207
|
try {
|
|
13024
|
-
await
|
|
13208
|
+
await writeFile9(temporaryPath, content, "utf8");
|
|
13025
13209
|
await rename2(temporaryPath, filePath);
|
|
13026
13210
|
} catch (error) {
|
|
13027
13211
|
await rm3(temporaryPath, { force: true });
|
|
@@ -13030,7 +13214,7 @@ async function writeConfigAtomically(filePath, content) {
|
|
|
13030
13214
|
}
|
|
13031
13215
|
async function resolveApitogoConfigPath(sourceDirectory) {
|
|
13032
13216
|
for (const filename of ["apitogo.config.tsx", "apitogo.config.jsx"]) {
|
|
13033
|
-
const configPath =
|
|
13217
|
+
const configPath = path41.join(sourceDirectory, filename);
|
|
13034
13218
|
try {
|
|
13035
13219
|
await access4(configPath);
|
|
13036
13220
|
return configPath;
|
|
@@ -13754,7 +13938,7 @@ async function wireNewDevPortalPageInConfig(sourceDirectory, slug, label) {
|
|
|
13754
13938
|
if (!configPath) {
|
|
13755
13939
|
return { updated: false };
|
|
13756
13940
|
}
|
|
13757
|
-
const original = await
|
|
13941
|
+
const original = await readFile10(configPath, "utf8");
|
|
13758
13942
|
const patched = patchApitogoConfigForNewPage(original, slug, label, {
|
|
13759
13943
|
typescript: configPath.endsWith(".tsx")
|
|
13760
13944
|
});
|
|
@@ -13766,18 +13950,18 @@ async function wireNewDevPortalPageInConfig(sourceDirectory, slug, label) {
|
|
|
13766
13950
|
}
|
|
13767
13951
|
|
|
13768
13952
|
// src/cli/scaffold/wire-openapi.ts
|
|
13769
|
-
import { access as access6, readFile as
|
|
13770
|
-
import
|
|
13953
|
+
import { access as access6, readFile as readFile12, writeFile as writeFile11 } from "node:fs/promises";
|
|
13954
|
+
import path46 from "node:path";
|
|
13771
13955
|
|
|
13772
13956
|
// src/cli/platform/helpers/openapi.ts
|
|
13773
13957
|
import { promises as fs5 } from "node:fs";
|
|
13774
|
-
import
|
|
13958
|
+
import path43 from "node:path";
|
|
13775
13959
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
13776
13960
|
import YAML from "yaml";
|
|
13777
13961
|
|
|
13778
13962
|
// src/cli/scaffold/discover-openapi-files.ts
|
|
13779
13963
|
import { promises as fs4 } from "node:fs";
|
|
13780
|
-
import
|
|
13964
|
+
import path42 from "node:path";
|
|
13781
13965
|
var OPENAPI_BASENAMES = [
|
|
13782
13966
|
"openapi.yaml",
|
|
13783
13967
|
"openapi.yml",
|
|
@@ -13799,13 +13983,13 @@ var SKIP_OPENAPI_SEARCH_DIRS = /* @__PURE__ */ new Set([
|
|
|
13799
13983
|
".apitogo"
|
|
13800
13984
|
]);
|
|
13801
13985
|
async function collectFromDir(dir, searchedDirectories, candidates) {
|
|
13802
|
-
const resolved =
|
|
13986
|
+
const resolved = path42.resolve(dir);
|
|
13803
13987
|
if (searchedDirectories.includes(resolved)) {
|
|
13804
13988
|
return;
|
|
13805
13989
|
}
|
|
13806
13990
|
searchedDirectories.push(resolved);
|
|
13807
13991
|
for (const name of OPENAPI_BASENAMES) {
|
|
13808
|
-
const candidate =
|
|
13992
|
+
const candidate = path42.join(resolved, name);
|
|
13809
13993
|
try {
|
|
13810
13994
|
await fs4.access(candidate);
|
|
13811
13995
|
candidates.push(candidate);
|
|
@@ -13820,8 +14004,8 @@ async function collectSiteOpenApiFiles(siteDirectory) {
|
|
|
13820
14004
|
return { candidates: [...new Set(candidates)], searchedDirectories };
|
|
13821
14005
|
}
|
|
13822
14006
|
async function collectNearbyOpenApiFiles(siteDirectory) {
|
|
13823
|
-
const site =
|
|
13824
|
-
const parent =
|
|
14007
|
+
const site = path42.resolve(siteDirectory);
|
|
14008
|
+
const parent = path42.dirname(site);
|
|
13825
14009
|
const searchedDirectories = [];
|
|
13826
14010
|
const candidates = [];
|
|
13827
14011
|
if (parent && parent !== site) {
|
|
@@ -13832,8 +14016,8 @@ async function collectNearbyOpenApiFiles(siteDirectory) {
|
|
|
13832
14016
|
if (!entry.isDirectory() || SKIP_OPENAPI_SEARCH_DIRS.has(entry.name)) {
|
|
13833
14017
|
continue;
|
|
13834
14018
|
}
|
|
13835
|
-
const sibling =
|
|
13836
|
-
if (
|
|
14019
|
+
const sibling = path42.join(parent, entry.name);
|
|
14020
|
+
if (path42.resolve(sibling) === site) {
|
|
13837
14021
|
continue;
|
|
13838
14022
|
}
|
|
13839
14023
|
await collectFromDir(sibling, searchedDirectories, candidates);
|
|
@@ -13861,7 +14045,7 @@ function parseOpenApiObject(doc) {
|
|
|
13861
14045
|
};
|
|
13862
14046
|
}
|
|
13863
14047
|
function liteParseOpenApi(content, filePath) {
|
|
13864
|
-
const ext =
|
|
14048
|
+
const ext = path42.extname(filePath).toLowerCase();
|
|
13865
14049
|
if (ext === ".json") {
|
|
13866
14050
|
try {
|
|
13867
14051
|
const parsed = JSON.parse(content);
|
|
@@ -13926,9 +14110,9 @@ async function discoverNearbyOpenApi(siteDirectory) {
|
|
|
13926
14110
|
};
|
|
13927
14111
|
}
|
|
13928
14112
|
async function validateOpenApiFile(filePath) {
|
|
13929
|
-
const resolved =
|
|
14113
|
+
const resolved = path43.resolve(filePath);
|
|
13930
14114
|
const content = await fs5.readFile(resolved, "utf8");
|
|
13931
|
-
const ext =
|
|
14115
|
+
const ext = path43.extname(resolved).toLowerCase();
|
|
13932
14116
|
let parsed;
|
|
13933
14117
|
try {
|
|
13934
14118
|
parsed = ext === ".json" ? JSON.parse(content) : YAML.parse(content);
|
|
@@ -13970,13 +14154,13 @@ async function validateOpenApiFile(filePath) {
|
|
|
13970
14154
|
}
|
|
13971
14155
|
|
|
13972
14156
|
// src/cli/scaffold/scaffold-dev-portal-site.ts
|
|
13973
|
-
import { mkdir as mkdir8, readFile as
|
|
13974
|
-
import
|
|
14157
|
+
import { mkdir as mkdir8, readFile as readFile11, writeFile as writeFile10 } from "node:fs/promises";
|
|
14158
|
+
import path45 from "node:path";
|
|
13975
14159
|
|
|
13976
14160
|
// src/cli/scaffold/create-apitogo-cli.ts
|
|
13977
14161
|
import { spawn as spawn2 } from "node:child_process";
|
|
13978
14162
|
import { access as access5, rm as rm4 } from "node:fs/promises";
|
|
13979
|
-
import
|
|
14163
|
+
import path44 from "node:path";
|
|
13980
14164
|
|
|
13981
14165
|
// src/cli/scaffold/apitogo-npm-packages.ts
|
|
13982
14166
|
var DEFAULT_CREATE_APITOGO_PACKAGE2 = "@lukoweb/create-apitogo@latest";
|
|
@@ -14077,9 +14261,9 @@ function resolveDocToolPath(explicit) {
|
|
|
14077
14261
|
return value || void 0;
|
|
14078
14262
|
}
|
|
14079
14263
|
function splitOutputDirectory(outputDirectory) {
|
|
14080
|
-
const resolvedOutputDirectory =
|
|
14081
|
-
const projectName =
|
|
14082
|
-
const parentDirectory =
|
|
14264
|
+
const resolvedOutputDirectory = path44.resolve(outputDirectory);
|
|
14265
|
+
const projectName = path44.basename(resolvedOutputDirectory);
|
|
14266
|
+
const parentDirectory = path44.dirname(resolvedOutputDirectory);
|
|
14083
14267
|
if (!projectName || projectName === "." || projectName === "..") {
|
|
14084
14268
|
throw new Error(
|
|
14085
14269
|
"outputDirectory must be a named folder (e.g. ./dev-portal-site), not the current directory."
|
|
@@ -14105,7 +14289,7 @@ async function directoryHasEntries(dir) {
|
|
|
14105
14289
|
}
|
|
14106
14290
|
}
|
|
14107
14291
|
function resolveLocalCreateApitogoEntry(docToolPath) {
|
|
14108
|
-
return
|
|
14292
|
+
return path44.resolve(docToolPath, "packages/create-zudoku/dist/index.js");
|
|
14109
14293
|
}
|
|
14110
14294
|
async function resolveCreateApitogoInvocation(options) {
|
|
14111
14295
|
const docToolPath = resolveDocToolPath(options.docToolPath);
|
|
@@ -14130,9 +14314,9 @@ async function resolveCreateApitogoInvocation(options) {
|
|
|
14130
14314
|
args: [pkg]
|
|
14131
14315
|
};
|
|
14132
14316
|
}
|
|
14133
|
-
function runCommand2(
|
|
14317
|
+
function runCommand2(command2, args, cwd) {
|
|
14134
14318
|
return new Promise((resolve, reject) => {
|
|
14135
|
-
const child = spawn2(
|
|
14319
|
+
const child = spawn2(command2, args, {
|
|
14136
14320
|
cwd,
|
|
14137
14321
|
env: process.env,
|
|
14138
14322
|
shell: process.platform === "win32"
|
|
@@ -14187,7 +14371,7 @@ async function runCreateApitogoDevPortal(options) {
|
|
|
14187
14371
|
result.exitCode
|
|
14188
14372
|
);
|
|
14189
14373
|
}
|
|
14190
|
-
if (!await pathExists3(
|
|
14374
|
+
if (!await pathExists3(path44.join(resolvedOutputDirectory, "package.json"))) {
|
|
14191
14375
|
throw new CreateApitogoCliError(
|
|
14192
14376
|
`create-apitogo completed but package.json was not found at ${resolvedOutputDirectory}`,
|
|
14193
14377
|
result.output,
|
|
@@ -14243,7 +14427,7 @@ function ensureRequiredApitogoModules(pkg, options) {
|
|
|
14243
14427
|
]
|
|
14244
14428
|
]) {
|
|
14245
14429
|
if (options.docToolPath) {
|
|
14246
|
-
deps[moduleName] = `file:${
|
|
14430
|
+
deps[moduleName] = `file:${path45.join(options.docToolPath, localPath)}`;
|
|
14247
14431
|
continue;
|
|
14248
14432
|
}
|
|
14249
14433
|
deps[moduleName] = `npm:${moduleName}@${moduleAliasVersion}`;
|
|
@@ -14272,7 +14456,7 @@ function rewritePackageJson(raw, options) {
|
|
|
14272
14456
|
if (!deps) continue;
|
|
14273
14457
|
for (const [dep, relativePath] of Object.entries(DOC_TOOL_LOCAL_PACKAGE_PATHS)) {
|
|
14274
14458
|
if (dep in deps) {
|
|
14275
|
-
deps[dep] = `file:${
|
|
14459
|
+
deps[dep] = `file:${path45.join(options.docToolPath, relativePath)}`;
|
|
14276
14460
|
linkedWorkspacePackage = true;
|
|
14277
14461
|
}
|
|
14278
14462
|
}
|
|
@@ -14369,24 +14553,24 @@ function patchDashboardPageConfig(content) {
|
|
|
14369
14553
|
);
|
|
14370
14554
|
}
|
|
14371
14555
|
async function ensureAccountPlansPage(outputDirectory) {
|
|
14372
|
-
const pagePath =
|
|
14556
|
+
const pagePath = path45.join(outputDirectory, ACCOUNT_PLANS_PAGE_PATH);
|
|
14373
14557
|
try {
|
|
14374
|
-
await
|
|
14558
|
+
await readFile11(pagePath, "utf8");
|
|
14375
14559
|
return void 0;
|
|
14376
14560
|
} catch {
|
|
14377
|
-
await mkdir8(
|
|
14378
|
-
await
|
|
14561
|
+
await mkdir8(path45.dirname(pagePath), { recursive: true });
|
|
14562
|
+
await writeFile10(pagePath, ACCOUNT_PLANS_PAGE);
|
|
14379
14563
|
return ACCOUNT_PLANS_PAGE_PATH;
|
|
14380
14564
|
}
|
|
14381
14565
|
}
|
|
14382
14566
|
async function ensureDashboardPage(outputDirectory) {
|
|
14383
|
-
const pagePath =
|
|
14567
|
+
const pagePath = path45.join(outputDirectory, DASHBOARD_PAGE_PATH);
|
|
14384
14568
|
try {
|
|
14385
|
-
await
|
|
14569
|
+
await readFile11(pagePath, "utf8");
|
|
14386
14570
|
return void 0;
|
|
14387
14571
|
} catch {
|
|
14388
|
-
await mkdir8(
|
|
14389
|
-
await
|
|
14572
|
+
await mkdir8(path45.dirname(pagePath), { recursive: true });
|
|
14573
|
+
await writeFile10(pagePath, DASHBOARD_PAGE);
|
|
14390
14574
|
return DASHBOARD_PAGE_PATH;
|
|
14391
14575
|
}
|
|
14392
14576
|
}
|
|
@@ -14436,12 +14620,12 @@ function patchApitogoConfig(content, options) {
|
|
|
14436
14620
|
async function patchScaffoldedSite(outputDirectory, options) {
|
|
14437
14621
|
const title = options.branding?.title ?? options.siteName;
|
|
14438
14622
|
const filesWritten = [];
|
|
14439
|
-
const packageJsonPath =
|
|
14623
|
+
const packageJsonPath = path45.join(outputDirectory, "package.json");
|
|
14440
14624
|
if (options.patchPackageJson !== false) {
|
|
14441
|
-
const
|
|
14442
|
-
await
|
|
14625
|
+
const packageJson3 = await readFile11(packageJsonPath, "utf8");
|
|
14626
|
+
await writeFile10(
|
|
14443
14627
|
packageJsonPath,
|
|
14444
|
-
rewritePackageJson(
|
|
14628
|
+
rewritePackageJson(packageJson3, {
|
|
14445
14629
|
siteName: options.siteName,
|
|
14446
14630
|
docToolPath: options.docToolPath,
|
|
14447
14631
|
createApitogoPackage: options.createApitogoPackage
|
|
@@ -14449,9 +14633,9 @@ async function patchScaffoldedSite(outputDirectory, options) {
|
|
|
14449
14633
|
);
|
|
14450
14634
|
filesWritten.push("package.json");
|
|
14451
14635
|
}
|
|
14452
|
-
const configPath =
|
|
14453
|
-
const configContent = await
|
|
14454
|
-
await
|
|
14636
|
+
const configPath = path45.join(outputDirectory, "apitogo.config.tsx");
|
|
14637
|
+
const configContent = await readFile11(configPath, "utf8");
|
|
14638
|
+
await writeFile10(
|
|
14455
14639
|
configPath,
|
|
14456
14640
|
patchDashboardPageConfig(
|
|
14457
14641
|
patchAccountPlansPageConfig(
|
|
@@ -14544,8 +14728,8 @@ async function discoverOpenApiByMode(siteDirectory, mode) {
|
|
|
14544
14728
|
return discoverNearbyOpenApi(siteDirectory);
|
|
14545
14729
|
}
|
|
14546
14730
|
async function wireDevPortalOpenApi(sourceDirectory, openApiPath) {
|
|
14547
|
-
const resolvedSource =
|
|
14548
|
-
const resolvedOpenApi =
|
|
14731
|
+
const resolvedSource = path46.resolve(sourceDirectory);
|
|
14732
|
+
const resolvedOpenApi = path46.resolve(openApiPath);
|
|
14549
14733
|
const input3 = toSiteRelativeOpenApiInput(resolvedSource, resolvedOpenApi);
|
|
14550
14734
|
const validation = await validateOpenApiFile(resolvedOpenApi);
|
|
14551
14735
|
if (!validation.valid) {
|
|
@@ -14557,24 +14741,24 @@ async function wireDevPortalOpenApi(sourceDirectory, openApiPath) {
|
|
|
14557
14741
|
}
|
|
14558
14742
|
const jsonConfigPath = manifestFilePath(resolvedSource);
|
|
14559
14743
|
if (await pathExists4(jsonConfigPath)) {
|
|
14560
|
-
const raw = await
|
|
14744
|
+
const raw = await readFile12(jsonConfigPath, "utf8");
|
|
14561
14745
|
const siteConfig = JSON.parse(raw);
|
|
14562
14746
|
const updated = applyOpenApiToSiteConfig(siteConfig, {
|
|
14563
14747
|
input: input3,
|
|
14564
14748
|
apiPath: "api"
|
|
14565
14749
|
});
|
|
14566
|
-
await
|
|
14750
|
+
await writeFile11(
|
|
14567
14751
|
jsonConfigPath,
|
|
14568
14752
|
`${JSON.stringify(updated, null, 2)}
|
|
14569
14753
|
`,
|
|
14570
14754
|
"utf8"
|
|
14571
14755
|
);
|
|
14572
14756
|
} else {
|
|
14573
|
-
const tsxConfigPath =
|
|
14574
|
-
const configContent = await
|
|
14757
|
+
const tsxConfigPath = path46.join(resolvedSource, "apitogo.config.tsx");
|
|
14758
|
+
const configContent = await readFile12(tsxConfigPath, "utf8");
|
|
14575
14759
|
try {
|
|
14576
14760
|
const patched = patchApitogoConfigOpenApiToFile(configContent, input3);
|
|
14577
|
-
await
|
|
14761
|
+
await writeFile11(tsxConfigPath, patched);
|
|
14578
14762
|
} catch (error) {
|
|
14579
14763
|
return {
|
|
14580
14764
|
status: "failed",
|
|
@@ -14658,10 +14842,10 @@ async function discoverAndWireOpenApi(siteDirectory, mode) {
|
|
|
14658
14842
|
// src/cli/make-config/interactive.ts
|
|
14659
14843
|
import { createInterface } from "node:readline/promises";
|
|
14660
14844
|
import { stdin as input, stdout as output } from "node:process";
|
|
14661
|
-
import
|
|
14845
|
+
import path48 from "node:path";
|
|
14662
14846
|
|
|
14663
14847
|
// src/cli/make-config/json-config.ts
|
|
14664
|
-
import
|
|
14848
|
+
import path47 from "node:path";
|
|
14665
14849
|
var APITOGO_JSON_FILENAME = "apitogo.config.json";
|
|
14666
14850
|
var DOCUMENTATION_NAV_LABEL2 = "Documentation";
|
|
14667
14851
|
var API_REFERENCE_PATH = "/api";
|
|
@@ -14705,12 +14889,7 @@ function createDefaultApitogoJsonConfig(options) {
|
|
|
14705
14889
|
return {
|
|
14706
14890
|
site: {
|
|
14707
14891
|
title: options.title,
|
|
14708
|
-
showTitleInHeader:
|
|
14709
|
-
logo: {
|
|
14710
|
-
src: { light: "/logo-light.svg", dark: "/logo-dark.svg" },
|
|
14711
|
-
alt: "API ToGo",
|
|
14712
|
-
width: "160px"
|
|
14713
|
-
}
|
|
14892
|
+
showTitleInHeader: true
|
|
14714
14893
|
},
|
|
14715
14894
|
authentication: {
|
|
14716
14895
|
enabled: true,
|
|
@@ -14869,7 +15048,7 @@ function createDefaultApitogoJsonConfig(options) {
|
|
|
14869
15048
|
};
|
|
14870
15049
|
}
|
|
14871
15050
|
function applyConfigPatches(config2, patches) {
|
|
14872
|
-
|
|
15051
|
+
const next = { ...config2 };
|
|
14873
15052
|
if (patches.site) {
|
|
14874
15053
|
next.site = deepMerge(
|
|
14875
15054
|
isPlainObject3(next.site) ? next.site : {},
|
|
@@ -15029,9 +15208,9 @@ function openapiInputForConfig(specRelativePosix) {
|
|
|
15029
15208
|
return `./${specRelativePosix}`;
|
|
15030
15209
|
}
|
|
15031
15210
|
function toRelativeOpenApiInput(projectDir, inputPath) {
|
|
15032
|
-
const resolved =
|
|
15033
|
-
const relative =
|
|
15034
|
-
const posix = relative.split(
|
|
15211
|
+
const resolved = path47.isAbsolute(inputPath) ? inputPath : path47.resolve(projectDir, inputPath);
|
|
15212
|
+
const relative = path47.relative(projectDir, resolved);
|
|
15213
|
+
const posix = relative.split(path47.sep).join(path47.posix.sep);
|
|
15035
15214
|
if (!posix) {
|
|
15036
15215
|
throw new Error("OpenAPI path must point to a file.");
|
|
15037
15216
|
}
|
|
@@ -15404,7 +15583,7 @@ async function promptMakeConfigInteractive(options) {
|
|
|
15404
15583
|
continue;
|
|
15405
15584
|
}
|
|
15406
15585
|
const routePath = `/${slug}`;
|
|
15407
|
-
const relativePath =
|
|
15586
|
+
const relativePath = path48.posix.join(options.pagesDir, `${slug}.tsx`);
|
|
15408
15587
|
const page = {
|
|
15409
15588
|
slug,
|
|
15410
15589
|
title: pageTitle.trim(),
|
|
@@ -15496,8 +15675,8 @@ export default function ${componentName}() {
|
|
|
15496
15675
|
// src/cli/make-config/scaffold-project.ts
|
|
15497
15676
|
init_package_json();
|
|
15498
15677
|
import { constants } from "node:fs";
|
|
15499
|
-
import { access as access7, mkdir as mkdir9, readFile as
|
|
15500
|
-
import
|
|
15678
|
+
import { access as access7, mkdir as mkdir9, readFile as readFile13, writeFile as writeFile12 } from "node:fs/promises";
|
|
15679
|
+
import path49 from "node:path";
|
|
15501
15680
|
import { glob as glob4 } from "glob";
|
|
15502
15681
|
|
|
15503
15682
|
// src/cli/make-config/branding-assets.ts
|
|
@@ -15521,9 +15700,9 @@ var OPENAPI_GLOBS = [
|
|
|
15521
15700
|
"openapi.yaml",
|
|
15522
15701
|
"openapi.yml"
|
|
15523
15702
|
];
|
|
15524
|
-
var toPosix = (p) => p.split(
|
|
15703
|
+
var toPosix = (p) => p.split(path49.sep).join("/");
|
|
15525
15704
|
var sanitizePackageName = (dir) => {
|
|
15526
|
-
const base =
|
|
15705
|
+
const base = path49.basename(path49.resolve(dir));
|
|
15527
15706
|
const s = base.toLowerCase().replace(/[^a-z0-9-_.]/g, "-").replace(/^-+|-+$/g, "");
|
|
15528
15707
|
return s || "apitogo-site";
|
|
15529
15708
|
};
|
|
@@ -15533,7 +15712,7 @@ var apitogoVersionRange = () => {
|
|
|
15533
15712
|
};
|
|
15534
15713
|
async function findOpenApiSpecPath(dir) {
|
|
15535
15714
|
for (const rel of OPENAPI_GLOBS) {
|
|
15536
|
-
const full =
|
|
15715
|
+
const full = path49.join(dir, rel);
|
|
15537
15716
|
try {
|
|
15538
15717
|
await access7(full, constants.R_OK);
|
|
15539
15718
|
return toPosix(rel);
|
|
@@ -15548,7 +15727,7 @@ async function findOpenApiSpecPath(dir) {
|
|
|
15548
15727
|
return extra[0] ? toPosix(extra[0]) : null;
|
|
15549
15728
|
}
|
|
15550
15729
|
async function ensurePackageJson(dir) {
|
|
15551
|
-
const pkgPath =
|
|
15730
|
+
const pkgPath = path49.join(dir, "package.json");
|
|
15552
15731
|
const apitogoVer = apitogoVersionRange();
|
|
15553
15732
|
const baseDeps = {
|
|
15554
15733
|
react: ">=19.0.0",
|
|
@@ -15583,11 +15762,11 @@ async function ensurePackageJson(dir) {
|
|
|
15583
15762
|
typescript: "^5"
|
|
15584
15763
|
}
|
|
15585
15764
|
};
|
|
15586
|
-
await
|
|
15765
|
+
await writeFile12(pkgPath, `${JSON.stringify(pkg2, null, 2)}
|
|
15587
15766
|
`, "utf8");
|
|
15588
15767
|
return true;
|
|
15589
15768
|
}
|
|
15590
|
-
const raw = await
|
|
15769
|
+
const raw = await readFile13(pkgPath, "utf8");
|
|
15591
15770
|
let pkg;
|
|
15592
15771
|
try {
|
|
15593
15772
|
pkg = JSON.parse(raw);
|
|
@@ -15610,12 +15789,12 @@ async function ensurePackageJson(dir) {
|
|
|
15610
15789
|
for (const [k, v] of Object.entries(baseDeps)) {
|
|
15611
15790
|
if (!deps[k]) deps[k] = v;
|
|
15612
15791
|
}
|
|
15613
|
-
await
|
|
15792
|
+
await writeFile12(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
15614
15793
|
`, "utf8");
|
|
15615
15794
|
return false;
|
|
15616
15795
|
}
|
|
15617
15796
|
async function ensureTsconfigJson(dir) {
|
|
15618
|
-
const tsPath =
|
|
15797
|
+
const tsPath = path49.join(dir, "tsconfig.json");
|
|
15619
15798
|
try {
|
|
15620
15799
|
await access7(tsPath, constants.R_OK);
|
|
15621
15800
|
return false;
|
|
@@ -15645,7 +15824,7 @@ async function ensureTsconfigJson(dir) {
|
|
|
15645
15824
|
"user-panel"
|
|
15646
15825
|
]
|
|
15647
15826
|
};
|
|
15648
|
-
await
|
|
15827
|
+
await writeFile12(tsPath, `${JSON.stringify(tsconfig, null, 2)}
|
|
15649
15828
|
`, "utf8");
|
|
15650
15829
|
return true;
|
|
15651
15830
|
}
|
|
@@ -15664,46 +15843,46 @@ var fileExists2 = async (filePath) => {
|
|
|
15664
15843
|
}
|
|
15665
15844
|
};
|
|
15666
15845
|
async function ensurePortalStubFiles(dir) {
|
|
15667
|
-
const landingPath =
|
|
15846
|
+
const landingPath = path49.join(dir, "landing", "LandingPage.tsx");
|
|
15668
15847
|
if (!await fileExists2(landingPath)) {
|
|
15669
|
-
await mkdir9(
|
|
15670
|
-
await
|
|
15848
|
+
await mkdir9(path49.join(dir, "landing"), { recursive: true });
|
|
15849
|
+
await writeFile12(landingPath, LANDING_PAGE_SOURCE, "utf8");
|
|
15671
15850
|
}
|
|
15672
|
-
const plansPath =
|
|
15851
|
+
const plansPath = path49.join(dir, "user-panel", "AccountPlansPage.tsx");
|
|
15673
15852
|
if (!await fileExists2(plansPath)) {
|
|
15674
|
-
await mkdir9(
|
|
15675
|
-
await
|
|
15853
|
+
await mkdir9(path49.join(dir, "user-panel"), { recursive: true });
|
|
15854
|
+
await writeFile12(plansPath, ACCOUNT_PLANS_PAGE_SOURCE, "utf8");
|
|
15676
15855
|
}
|
|
15677
|
-
const dashboardPath =
|
|
15856
|
+
const dashboardPath = path49.join(dir, "user-panel", "DashboardPage.tsx");
|
|
15678
15857
|
if (!await fileExists2(dashboardPath)) {
|
|
15679
|
-
await mkdir9(
|
|
15680
|
-
await
|
|
15858
|
+
await mkdir9(path49.join(dir, "user-panel"), { recursive: true });
|
|
15859
|
+
await writeFile12(dashboardPath, DASHBOARD_PAGE_SOURCE, "utf8");
|
|
15681
15860
|
}
|
|
15682
15861
|
await ensurePublicBrandingFiles(dir);
|
|
15683
15862
|
}
|
|
15684
15863
|
async function ensurePublicBrandingFiles(dir) {
|
|
15685
|
-
const destDir =
|
|
15864
|
+
const destDir = path49.join(dir, "public");
|
|
15686
15865
|
await mkdir9(destDir, { recursive: true });
|
|
15687
15866
|
for (const { name, content } of BRANDING_ASSETS) {
|
|
15688
|
-
const dest =
|
|
15867
|
+
const dest = path49.join(destDir, name);
|
|
15689
15868
|
if (await fileExists2(dest)) {
|
|
15690
15869
|
continue;
|
|
15691
15870
|
}
|
|
15692
|
-
await
|
|
15871
|
+
await writeFile12(dest, content, "utf8");
|
|
15693
15872
|
}
|
|
15694
15873
|
}
|
|
15695
15874
|
async function ensureThinConfigTsx(dir) {
|
|
15696
|
-
const tsxPath =
|
|
15875
|
+
const tsxPath = path49.join(dir, "apitogo.config.tsx");
|
|
15697
15876
|
if (await fileExists2(tsxPath)) {
|
|
15698
15877
|
return false;
|
|
15699
15878
|
}
|
|
15700
|
-
await
|
|
15879
|
+
await writeFile12(tsxPath, THIN_WRAPPER_SOURCE, "utf8");
|
|
15701
15880
|
return true;
|
|
15702
15881
|
}
|
|
15703
15882
|
|
|
15704
15883
|
// src/cli/platform/helpers/openapi-action-keys.ts
|
|
15705
|
-
import { existsSync as
|
|
15706
|
-
import
|
|
15884
|
+
import { existsSync as existsSync5, readFileSync as readFileSync3 } from "node:fs";
|
|
15885
|
+
import path50 from "node:path";
|
|
15707
15886
|
import YAML2 from "yaml";
|
|
15708
15887
|
var HTTP_METHODS = [
|
|
15709
15888
|
"get",
|
|
@@ -15772,7 +15951,7 @@ function extractGatewayActionKeysFromOpenApiDocument(document) {
|
|
|
15772
15951
|
function extractGatewayActionKeysFromOpenApiFile(filePath) {
|
|
15773
15952
|
try {
|
|
15774
15953
|
const raw = readFileSync3(filePath, "utf8");
|
|
15775
|
-
const ext =
|
|
15954
|
+
const ext = path50.extname(filePath).toLowerCase();
|
|
15776
15955
|
const parsed = ext === ".json" ? JSON.parse(raw) : YAML2.parse(raw);
|
|
15777
15956
|
return extractGatewayActionKeysFromOpenApiDocument(parsed);
|
|
15778
15957
|
} catch {
|
|
@@ -15793,8 +15972,8 @@ function resolveConfigOpenApiFilePath(siteDirectory, config2) {
|
|
|
15793
15972
|
}
|
|
15794
15973
|
}
|
|
15795
15974
|
for (const candidate of candidates) {
|
|
15796
|
-
const resolved =
|
|
15797
|
-
if (
|
|
15975
|
+
const resolved = path50.isAbsolute(candidate) ? candidate : path50.resolve(siteDirectory, candidate);
|
|
15976
|
+
if (existsSync5(resolved)) {
|
|
15798
15977
|
return resolved;
|
|
15799
15978
|
}
|
|
15800
15979
|
}
|
|
@@ -15808,8 +15987,8 @@ function loadOpenApiActionKeysForSite(siteDirectory, config2) {
|
|
|
15808
15987
|
return extractGatewayActionKeysFromOpenApiFile(filePath);
|
|
15809
15988
|
}
|
|
15810
15989
|
function loadOpenApiActionKeysFromSiteDirectory(siteDirectory) {
|
|
15811
|
-
const configPath =
|
|
15812
|
-
if (!
|
|
15990
|
+
const configPath = path50.join(siteDirectory, "apitogo.config.json");
|
|
15991
|
+
if (!existsSync5(configPath)) {
|
|
15813
15992
|
return [];
|
|
15814
15993
|
}
|
|
15815
15994
|
try {
|
|
@@ -15833,7 +16012,7 @@ function withDefaultIncludedActionKeys(plan, actionKeys) {
|
|
|
15833
16012
|
}
|
|
15834
16013
|
|
|
15835
16014
|
// src/cli/make-config/handler.ts
|
|
15836
|
-
var toPosixPath2 = (value) => value.split(
|
|
16015
|
+
var toPosixPath2 = (value) => value.split(path51.sep).join(path51.posix.sep);
|
|
15837
16016
|
var fileExists3 = async (filePath) => {
|
|
15838
16017
|
try {
|
|
15839
16018
|
await access8(filePath, constants2.F_OK);
|
|
@@ -15843,7 +16022,7 @@ var fileExists3 = async (filePath) => {
|
|
|
15843
16022
|
}
|
|
15844
16023
|
};
|
|
15845
16024
|
var readJsonConfig = async (filePath) => {
|
|
15846
|
-
const raw = await
|
|
16025
|
+
const raw = await readFile14(filePath, "utf8");
|
|
15847
16026
|
const parsed = JSON.parse(raw);
|
|
15848
16027
|
if (!isPlainObject3(parsed)) {
|
|
15849
16028
|
throw new Error(`${APITOGO_JSON_FILENAME} must be a JSON object.`);
|
|
@@ -15889,13 +16068,13 @@ async function persistConfig(config2, ctx) {
|
|
|
15889
16068
|
force: ctx.force
|
|
15890
16069
|
})
|
|
15891
16070
|
};
|
|
15892
|
-
await
|
|
16071
|
+
await writeFile13(ctx.jsonPath, `${JSON.stringify(next, null, 2)}
|
|
15893
16072
|
`, "utf8");
|
|
15894
|
-
const tsxPath =
|
|
16073
|
+
const tsxPath = path51.join(ctx.dir, "apitogo.config.tsx");
|
|
15895
16074
|
if (await fileExists3(tsxPath) && tsxRoutes.length > 0) {
|
|
15896
|
-
const tsxSource = await
|
|
16075
|
+
const tsxSource = await readFile14(tsxPath, "utf8");
|
|
15897
16076
|
if (isManagedConfigWrapper(tsxSource)) {
|
|
15898
|
-
await
|
|
16077
|
+
await writeFile13(
|
|
15899
16078
|
tsxPath,
|
|
15900
16079
|
buildThinWrapperWithCustomPages(tsxRoutes),
|
|
15901
16080
|
"utf8"
|
|
@@ -15918,7 +16097,7 @@ function mergeBackendFlag(config2, backend) {
|
|
|
15918
16097
|
return next;
|
|
15919
16098
|
}
|
|
15920
16099
|
async function makeConfig(argv) {
|
|
15921
|
-
const dir =
|
|
16100
|
+
const dir = path51.resolve(process.cwd(), argv.dir);
|
|
15922
16101
|
const pagesDir = toPosixPath2(
|
|
15923
16102
|
argv.pagesDir.replace(/^[./]+/, "").replace(/\/+$/, "")
|
|
15924
16103
|
);
|
|
@@ -15938,14 +16117,14 @@ async function makeConfig(argv) {
|
|
|
15938
16117
|
printDiagnosticsToConsole("Created tsconfig.json.");
|
|
15939
16118
|
}
|
|
15940
16119
|
await ensurePortalStubFiles(dir);
|
|
15941
|
-
const jsonPath =
|
|
16120
|
+
const jsonPath = path51.join(dir, APITOGO_JSON_FILENAME);
|
|
15942
16121
|
let createdJson = false;
|
|
15943
16122
|
let config2;
|
|
15944
16123
|
if (await fileExists3(jsonPath)) {
|
|
15945
16124
|
config2 = await readJsonConfig(jsonPath);
|
|
15946
16125
|
} else {
|
|
15947
16126
|
config2 = createDefaultApitogoJsonConfig({
|
|
15948
|
-
title: titleFromDirectoryName(
|
|
16127
|
+
title: titleFromDirectoryName(path51.basename(dir)),
|
|
15949
16128
|
pagesDir
|
|
15950
16129
|
});
|
|
15951
16130
|
createdJson = true;
|
|
@@ -15994,9 +16173,9 @@ async function makeConfig(argv) {
|
|
|
15994
16173
|
return;
|
|
15995
16174
|
}
|
|
15996
16175
|
if (action2.kind === "page") {
|
|
15997
|
-
const pagePath =
|
|
15998
|
-
await mkdir10(
|
|
15999
|
-
await
|
|
16176
|
+
const pagePath = path51.join(dir, action2.page.relativePath);
|
|
16177
|
+
await mkdir10(path51.dirname(pagePath), { recursive: true });
|
|
16178
|
+
await writeFile13(
|
|
16000
16179
|
pagePath,
|
|
16001
16180
|
buildStarterDocsPageTsx(action2.page.slug, action2.page.title),
|
|
16002
16181
|
"utf8"
|
|
@@ -16062,7 +16241,7 @@ async function makeConfig(argv) {
|
|
|
16062
16241
|
if (argv.openapi) {
|
|
16063
16242
|
const wire = await wireDevPortalOpenApi(
|
|
16064
16243
|
dir,
|
|
16065
|
-
|
|
16244
|
+
path51.resolve(dir, argv.openapi)
|
|
16066
16245
|
);
|
|
16067
16246
|
if (wire.status !== "succeeded") {
|
|
16068
16247
|
throw new Error(
|
|
@@ -16091,7 +16270,7 @@ async function makeConfig(argv) {
|
|
|
16091
16270
|
const slug = normalizePageSlug(argv.pageSlug);
|
|
16092
16271
|
const pageTemplate = normalizePageTemplate(argv.pageTemplate);
|
|
16093
16272
|
const relativePagePath = pageComponentRelativePath(slug);
|
|
16094
|
-
const filePath =
|
|
16273
|
+
const filePath = path51.join(dir, relativePagePath);
|
|
16095
16274
|
const isUpdate = argv.pageUpdate === true;
|
|
16096
16275
|
if (isUpdate) {
|
|
16097
16276
|
if (!await fileExists3(filePath)) {
|
|
@@ -16105,7 +16284,7 @@ async function makeConfig(argv) {
|
|
|
16105
16284
|
argv.pageContent,
|
|
16106
16285
|
pageTemplate
|
|
16107
16286
|
);
|
|
16108
|
-
await
|
|
16287
|
+
await writeFile13(filePath, tsx, "utf8");
|
|
16109
16288
|
pageResult = {
|
|
16110
16289
|
action: "updated",
|
|
16111
16290
|
slug,
|
|
@@ -16124,8 +16303,8 @@ async function makeConfig(argv) {
|
|
|
16124
16303
|
argv.pageContent,
|
|
16125
16304
|
pageTemplate
|
|
16126
16305
|
);
|
|
16127
|
-
await mkdir10(
|
|
16128
|
-
await
|
|
16306
|
+
await mkdir10(path51.dirname(filePath), { recursive: true });
|
|
16307
|
+
await writeFile13(filePath, tsx, "utf8");
|
|
16129
16308
|
const configResult = await wireNewDevPortalPageInConfig(
|
|
16130
16309
|
dir,
|
|
16131
16310
|
slug,
|
|
@@ -16137,7 +16316,7 @@ async function makeConfig(argv) {
|
|
|
16137
16316
|
pagePath: relativePagePath,
|
|
16138
16317
|
pageTemplate,
|
|
16139
16318
|
configUpdated: configResult.updated,
|
|
16140
|
-
configPath: configResult.configPath ?
|
|
16319
|
+
configPath: configResult.configPath ? path51.relative(dir, configResult.configPath) : null
|
|
16141
16320
|
};
|
|
16142
16321
|
changes.push("page_add");
|
|
16143
16322
|
}
|
|
@@ -16265,7 +16444,7 @@ var config_default = {
|
|
|
16265
16444
|
// src/cli/cmds/configure-github-workflow.ts
|
|
16266
16445
|
var REMOVED = "apitogo configure-github-workflow was removed. Multi-env SWA deploy is deprecated; use `apitogo deploy`.";
|
|
16267
16446
|
var configure_github_workflow_default = {
|
|
16268
|
-
|
|
16447
|
+
describe: false,
|
|
16269
16448
|
command: "configure-github-workflow",
|
|
16270
16449
|
builder: (yargs2) => yargs2,
|
|
16271
16450
|
handler: async (argv) => {
|
|
@@ -16278,7 +16457,7 @@ var configure_github_workflow_default = {
|
|
|
16278
16457
|
};
|
|
16279
16458
|
|
|
16280
16459
|
// src/cli/apply/handler.ts
|
|
16281
|
-
import
|
|
16460
|
+
import path62 from "node:path";
|
|
16282
16461
|
|
|
16283
16462
|
// src/cli/platform/tools/dev-portal-publish.ts
|
|
16284
16463
|
init_gateway_limits();
|
|
@@ -17437,16 +17616,16 @@ async function validateDevPortalReadiness(client, projectId, options) {
|
|
|
17437
17616
|
}
|
|
17438
17617
|
|
|
17439
17618
|
// src/cli/platform/helpers/publish-ledger.ts
|
|
17440
|
-
import { mkdir as mkdir11, readFile as
|
|
17441
|
-
import
|
|
17619
|
+
import { mkdir as mkdir11, readFile as readFile15, writeFile as writeFile14 } from "node:fs/promises";
|
|
17620
|
+
import path52 from "node:path";
|
|
17442
17621
|
var PUBLISH_LEDGER_RELATIVE_PATH = ".apitogo/publish-state.json";
|
|
17443
17622
|
function publishLedgerPath(siteDirectory) {
|
|
17444
|
-
return
|
|
17623
|
+
return path52.join(path52.resolve(siteDirectory), PUBLISH_LEDGER_RELATIVE_PATH);
|
|
17445
17624
|
}
|
|
17446
17625
|
async function readPublishLedger(siteDirectory) {
|
|
17447
17626
|
const filePath = publishLedgerPath(siteDirectory);
|
|
17448
17627
|
try {
|
|
17449
|
-
const raw = await
|
|
17628
|
+
const raw = await readFile15(filePath, "utf8");
|
|
17450
17629
|
const parsed = JSON.parse(raw);
|
|
17451
17630
|
if (parsed?.version !== 1 || !Array.isArray(parsed.steps)) {
|
|
17452
17631
|
return null;
|
|
@@ -17458,13 +17637,13 @@ async function readPublishLedger(siteDirectory) {
|
|
|
17458
17637
|
}
|
|
17459
17638
|
async function writePublishLedger(siteDirectory, ledger) {
|
|
17460
17639
|
const filePath = publishLedgerPath(siteDirectory);
|
|
17461
|
-
await mkdir11(
|
|
17640
|
+
await mkdir11(path52.dirname(filePath), { recursive: true });
|
|
17462
17641
|
const next = {
|
|
17463
17642
|
...ledger,
|
|
17464
17643
|
version: 1,
|
|
17465
17644
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
17466
17645
|
};
|
|
17467
|
-
await
|
|
17646
|
+
await writeFile14(filePath, `${JSON.stringify(next, null, 2)}
|
|
17468
17647
|
`, "utf8");
|
|
17469
17648
|
return filePath;
|
|
17470
17649
|
}
|
|
@@ -17529,11 +17708,11 @@ async function waitForGatewayActionsRegistered(client, projectId, options) {
|
|
|
17529
17708
|
// src/cli/platform/helpers/deploy-artifact-hash.ts
|
|
17530
17709
|
import { createHash as createHash2 } from "node:crypto";
|
|
17531
17710
|
import { createReadStream, promises as fs7 } from "node:fs";
|
|
17532
|
-
import
|
|
17711
|
+
import path54 from "node:path";
|
|
17533
17712
|
|
|
17534
17713
|
// src/cli/platform/helpers/package-files.ts
|
|
17535
17714
|
import { promises as fs6 } from "node:fs";
|
|
17536
|
-
import
|
|
17715
|
+
import path53 from "node:path";
|
|
17537
17716
|
import ignore from "ignore";
|
|
17538
17717
|
var DEFAULT_EXCLUDES = /* @__PURE__ */ new Set([
|
|
17539
17718
|
"node_modules",
|
|
@@ -17546,7 +17725,7 @@ var DEFAULT_EXCLUDES = /* @__PURE__ */ new Set([
|
|
|
17546
17725
|
async function loadGitignore(rootDir) {
|
|
17547
17726
|
const ig = ignore();
|
|
17548
17727
|
ig.add(["node_modules/", ".git/", "dist/", "bin/", "obj/"]);
|
|
17549
|
-
const gitignorePath =
|
|
17728
|
+
const gitignorePath = path53.join(rootDir, ".gitignore");
|
|
17550
17729
|
try {
|
|
17551
17730
|
const content = await fs6.readFile(gitignorePath, "utf8");
|
|
17552
17731
|
ig.add(content);
|
|
@@ -17555,11 +17734,11 @@ async function loadGitignore(rootDir) {
|
|
|
17555
17734
|
return ig;
|
|
17556
17735
|
}
|
|
17557
17736
|
async function collectFiles(rootDir, relativeDir, ig, files) {
|
|
17558
|
-
const absDir =
|
|
17737
|
+
const absDir = path53.join(rootDir, relativeDir);
|
|
17559
17738
|
const entries = await fs6.readdir(absDir, { withFileTypes: true });
|
|
17560
17739
|
for (const entry of entries) {
|
|
17561
|
-
const rel = relativeDir ?
|
|
17562
|
-
const relPosix = rel.split(
|
|
17740
|
+
const rel = relativeDir ? path53.join(relativeDir, entry.name) : entry.name;
|
|
17741
|
+
const relPosix = rel.split(path53.sep).join("/");
|
|
17563
17742
|
if (DEFAULT_EXCLUDES.has(entry.name) && !relativeDir) {
|
|
17564
17743
|
continue;
|
|
17565
17744
|
}
|
|
@@ -17574,7 +17753,7 @@ async function collectFiles(rootDir, relativeDir, ig, files) {
|
|
|
17574
17753
|
}
|
|
17575
17754
|
}
|
|
17576
17755
|
async function collectPackageableFiles(sourceDirectory) {
|
|
17577
|
-
const resolved =
|
|
17756
|
+
const resolved = path53.resolve(sourceDirectory);
|
|
17578
17757
|
const stat4 = await fs6.stat(resolved).catch(() => null);
|
|
17579
17758
|
if (!stat4?.isDirectory()) {
|
|
17580
17759
|
throw new Error(`sourceDirectory is not a directory: ${resolved}`);
|
|
@@ -17600,19 +17779,19 @@ async function sha256File(filePath) {
|
|
|
17600
17779
|
return hash2.digest("hex");
|
|
17601
17780
|
}
|
|
17602
17781
|
async function hashDirectoryContents(rootDirectory) {
|
|
17603
|
-
const resolved =
|
|
17782
|
+
const resolved = path54.resolve(rootDirectory);
|
|
17604
17783
|
const files = (await collectPackageableFiles(resolved)).sort((a, b) => a.localeCompare(b));
|
|
17605
17784
|
const hash2 = createHash2("sha256");
|
|
17606
17785
|
for (const rel of files) {
|
|
17607
17786
|
hash2.update(rel);
|
|
17608
17787
|
hash2.update("\0");
|
|
17609
|
-
hash2.update(await fs7.readFile(
|
|
17788
|
+
hash2.update(await fs7.readFile(path54.join(resolved, rel)));
|
|
17610
17789
|
hash2.update("\0");
|
|
17611
17790
|
}
|
|
17612
17791
|
return hash2.digest("hex");
|
|
17613
17792
|
}
|
|
17614
17793
|
async function hashDevPortalSiteSources(siteDirectory, options) {
|
|
17615
|
-
const resolved =
|
|
17794
|
+
const resolved = path54.resolve(siteDirectory);
|
|
17616
17795
|
const hash2 = createHash2("sha256");
|
|
17617
17796
|
const candidates = [
|
|
17618
17797
|
"apitogo.config.json",
|
|
@@ -17622,7 +17801,7 @@ async function hashDevPortalSiteSources(siteDirectory, options) {
|
|
|
17622
17801
|
"zudoku.config.tsx"
|
|
17623
17802
|
];
|
|
17624
17803
|
for (const name of candidates) {
|
|
17625
|
-
const full =
|
|
17804
|
+
const full = path54.join(resolved, name);
|
|
17626
17805
|
try {
|
|
17627
17806
|
hash2.update(name);
|
|
17628
17807
|
hash2.update("\0");
|
|
@@ -17632,7 +17811,7 @@ async function hashDevPortalSiteSources(siteDirectory, options) {
|
|
|
17632
17811
|
}
|
|
17633
17812
|
}
|
|
17634
17813
|
for (const dir of ["pages", "landing", "src"]) {
|
|
17635
|
-
const full =
|
|
17814
|
+
const full = path54.join(resolved, dir);
|
|
17636
17815
|
try {
|
|
17637
17816
|
const st = await fs7.stat(full);
|
|
17638
17817
|
if (!st.isDirectory()) continue;
|
|
@@ -17654,8 +17833,8 @@ async function hashDevPortalSiteSources(siteDirectory, options) {
|
|
|
17654
17833
|
}
|
|
17655
17834
|
|
|
17656
17835
|
// src/cli/platform/helpers/openapi-gateway-servers.ts
|
|
17657
|
-
import { mkdir as mkdir12, readFile as
|
|
17658
|
-
import
|
|
17836
|
+
import { mkdir as mkdir12, readFile as readFile16, writeFile as writeFile15 } from "node:fs/promises";
|
|
17837
|
+
import path55 from "node:path";
|
|
17659
17838
|
import YAML3 from "yaml";
|
|
17660
17839
|
var GATEWAY_URL_ENV_KEY = "APITOGO_GATEWAY_URL";
|
|
17661
17840
|
var PUBLISH_OPENAPI_RELATIVE = ".apitogo/openapi-publish.json";
|
|
@@ -17686,8 +17865,8 @@ async function resolveProjectGatewayUrl(client, projectId) {
|
|
|
17686
17865
|
return null;
|
|
17687
17866
|
}
|
|
17688
17867
|
async function readOpenApiDocument(filePath) {
|
|
17689
|
-
const content = await
|
|
17690
|
-
const ext =
|
|
17868
|
+
const content = await readFile16(filePath, "utf8");
|
|
17869
|
+
const ext = path55.extname(filePath).toLowerCase();
|
|
17691
17870
|
const parsed = ext === ".json" ? JSON.parse(content) : YAML3.parse(content);
|
|
17692
17871
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
17693
17872
|
throw new Error(`OpenAPI document must be an object: ${filePath}`);
|
|
@@ -17695,20 +17874,20 @@ async function readOpenApiDocument(filePath) {
|
|
|
17695
17874
|
return parsed;
|
|
17696
17875
|
}
|
|
17697
17876
|
async function materializePublishOpenApiWithGateway(siteDirectory, sourceOpenApiPath, gatewayUrl) {
|
|
17698
|
-
const site =
|
|
17699
|
-
const source =
|
|
17877
|
+
const site = path55.resolve(siteDirectory);
|
|
17878
|
+
const source = path55.resolve(sourceOpenApiPath);
|
|
17700
17879
|
const relativeInput = PUBLISH_OPENAPI_RELATIVE;
|
|
17701
|
-
const outputPath =
|
|
17880
|
+
const outputPath = path55.join(site, ...relativeInput.split("/"));
|
|
17702
17881
|
const doc = await readOpenApiDocument(source);
|
|
17703
17882
|
const rewritten = withGatewayServers(doc, gatewayUrl);
|
|
17704
|
-
await mkdir12(
|
|
17705
|
-
await
|
|
17883
|
+
await mkdir12(path55.dirname(outputPath), { recursive: true });
|
|
17884
|
+
await writeFile15(outputPath, `${JSON.stringify(rewritten, null, 2)}
|
|
17706
17885
|
`, "utf8");
|
|
17707
17886
|
return { outputPath, relativeInput };
|
|
17708
17887
|
}
|
|
17709
17888
|
async function pointSiteApisAtPublishOpenApi(siteDirectory, relativeInput) {
|
|
17710
|
-
const configPath =
|
|
17711
|
-
const raw = await
|
|
17889
|
+
const configPath = path55.join(path55.resolve(siteDirectory), APITOGO_CONFIG_FILENAME2);
|
|
17890
|
+
const raw = await readFile16(configPath, "utf8");
|
|
17712
17891
|
const config2 = JSON.parse(raw);
|
|
17713
17892
|
const previousApis = config2.apis;
|
|
17714
17893
|
const previousBackend = config2.backend;
|
|
@@ -17721,11 +17900,11 @@ async function pointSiteApisAtPublishOpenApi(siteDirectory, relativeInput) {
|
|
|
17721
17900
|
const backend = config2.backend && typeof config2.backend === "object" ? { ...config2.backend } : {};
|
|
17722
17901
|
backend.openApiPath = relativeInput;
|
|
17723
17902
|
config2.backend = backend;
|
|
17724
|
-
await
|
|
17903
|
+
await writeFile15(configPath, `${JSON.stringify(config2, null, 2)}
|
|
17725
17904
|
`, "utf8");
|
|
17726
17905
|
return {
|
|
17727
17906
|
restore: async () => {
|
|
17728
|
-
const currentRaw = await
|
|
17907
|
+
const currentRaw = await readFile16(configPath, "utf8");
|
|
17729
17908
|
const current = JSON.parse(currentRaw);
|
|
17730
17909
|
if (previousApis === void 0) {
|
|
17731
17910
|
delete current.apis;
|
|
@@ -17737,20 +17916,20 @@ async function pointSiteApisAtPublishOpenApi(siteDirectory, relativeInput) {
|
|
|
17737
17916
|
} else {
|
|
17738
17917
|
current.backend = previousBackend;
|
|
17739
17918
|
}
|
|
17740
|
-
await
|
|
17919
|
+
await writeFile15(configPath, `${JSON.stringify(current, null, 2)}
|
|
17741
17920
|
`, "utf8");
|
|
17742
17921
|
}
|
|
17743
17922
|
};
|
|
17744
17923
|
}
|
|
17745
17924
|
async function prepareOpenApiServersForGatewayBuild(options) {
|
|
17746
|
-
const siteDirectory =
|
|
17925
|
+
const siteDirectory = path55.resolve(options.siteDirectory);
|
|
17747
17926
|
let openApiPath = resolveBackendOpenApiPath(options.manifest?.backend?.openApiPath, {
|
|
17748
17927
|
siteDirectory,
|
|
17749
17928
|
backendSourceDirectory: options.manifest?.backend?.sourceDirectory
|
|
17750
17929
|
});
|
|
17751
17930
|
if (!openApiPath) {
|
|
17752
17931
|
try {
|
|
17753
|
-
const raw = await
|
|
17932
|
+
const raw = await readFile16(path55.join(siteDirectory, APITOGO_CONFIG_FILENAME2), "utf8");
|
|
17754
17933
|
const config2 = JSON.parse(raw);
|
|
17755
17934
|
const input3 = Array.isArray(config2.apis) ? config2.apis[0]?.input?.trim() : void 0;
|
|
17756
17935
|
openApiPath = resolveBackendOpenApiPath(input3, { siteDirectory });
|
|
@@ -17772,7 +17951,7 @@ async function prepareOpenApiServersForGatewayBuild(options) {
|
|
|
17772
17951
|
// src/cli/platform/helpers/backend-packaging.ts
|
|
17773
17952
|
import { mkdtemp, readdir, rm as rm5 } from "node:fs/promises";
|
|
17774
17953
|
import { tmpdir } from "node:os";
|
|
17775
|
-
import
|
|
17954
|
+
import path56 from "node:path";
|
|
17776
17955
|
import { spawn as spawn3 } from "node:child_process";
|
|
17777
17956
|
async function directoryHasRuntimeConfig(dir) {
|
|
17778
17957
|
if (!await pathExists(dir)) {
|
|
@@ -17816,20 +17995,20 @@ function runDotnetPublish(projectDir, outputDir) {
|
|
|
17816
17995
|
async function findCsproj(projectDir) {
|
|
17817
17996
|
const entries = await readdir(projectDir);
|
|
17818
17997
|
const csproj = entries.find((name) => name.endsWith(".csproj"));
|
|
17819
|
-
return csproj ?
|
|
17998
|
+
return csproj ? path56.join(projectDir, csproj) : null;
|
|
17820
17999
|
}
|
|
17821
18000
|
async function prepareBackendPackagingDirectory(args) {
|
|
17822
|
-
const sourceDirectory =
|
|
18001
|
+
const sourceDirectory = path56.resolve(args.sourceDirectory);
|
|
17823
18002
|
if (args.publishDirectory?.trim()) {
|
|
17824
18003
|
return {
|
|
17825
|
-
directory:
|
|
18004
|
+
directory: path56.resolve(args.publishDirectory),
|
|
17826
18005
|
packagingMode: "published"
|
|
17827
18006
|
};
|
|
17828
18007
|
}
|
|
17829
18008
|
if (await directoryHasRuntimeConfig(sourceDirectory)) {
|
|
17830
18009
|
return { directory: sourceDirectory, packagingMode: "published" };
|
|
17831
18010
|
}
|
|
17832
|
-
const publishSubdir =
|
|
18011
|
+
const publishSubdir = path56.join(sourceDirectory, "publish");
|
|
17833
18012
|
if (await directoryHasRuntimeConfig(publishSubdir)) {
|
|
17834
18013
|
return { directory: publishSubdir, packagingMode: "published" };
|
|
17835
18014
|
}
|
|
@@ -17840,8 +18019,8 @@ async function prepareBackendPackagingDirectory(args) {
|
|
|
17840
18019
|
if (!csproj) {
|
|
17841
18020
|
return { directory: sourceDirectory, packagingMode: "source" };
|
|
17842
18021
|
}
|
|
17843
|
-
const tempRoot = await mkdtemp(
|
|
17844
|
-
const outputDir =
|
|
18022
|
+
const tempRoot = await mkdtemp(path56.join(tmpdir(), "apitogo-dotnet-publish-"));
|
|
18023
|
+
const outputDir = path56.join(tempRoot, "publish");
|
|
17845
18024
|
const result = await runDotnetPublish(sourceDirectory, outputDir);
|
|
17846
18025
|
if (result.exitCode !== 0) {
|
|
17847
18026
|
await rm5(tempRoot, { recursive: true, force: true });
|
|
@@ -17887,12 +18066,12 @@ function formatJobStatusResponse(options) {
|
|
|
17887
18066
|
// src/cli/platform/helpers/zip.ts
|
|
17888
18067
|
import { createReadStream as createReadStream2, createWriteStream as createWriteStream2, promises as fs8 } from "node:fs";
|
|
17889
18068
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
17890
|
-
import
|
|
18069
|
+
import path57 from "node:path";
|
|
17891
18070
|
import { ZipArchive } from "archiver";
|
|
17892
18071
|
async function packageBackendDirectory(sourceDirectory) {
|
|
17893
|
-
const resolved =
|
|
18072
|
+
const resolved = path57.resolve(sourceDirectory);
|
|
17894
18073
|
const files = await collectPackageableFiles(resolved);
|
|
17895
|
-
const zipPath =
|
|
18074
|
+
const zipPath = path57.join(
|
|
17896
18075
|
tmpdir2(),
|
|
17897
18076
|
`apitogo-backend-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`
|
|
17898
18077
|
);
|
|
@@ -17904,7 +18083,7 @@ async function packageBackendDirectory(sourceDirectory) {
|
|
|
17904
18083
|
output2.on("error", reject);
|
|
17905
18084
|
archive.pipe(output2);
|
|
17906
18085
|
for (const rel of files) {
|
|
17907
|
-
archive.append(createReadStream2(
|
|
18086
|
+
archive.append(createReadStream2(path57.join(resolved, rel)), { name: rel.split(path57.sep).join("/") });
|
|
17908
18087
|
}
|
|
17909
18088
|
void archive.finalize();
|
|
17910
18089
|
});
|
|
@@ -19287,12 +19466,12 @@ async function resolveProjectIdForPublish(client, config2, args, wait, progress,
|
|
|
19287
19466
|
|
|
19288
19467
|
// src/cli/platform/tools/dev-portal.ts
|
|
19289
19468
|
import { promises as fs10 } from "node:fs";
|
|
19290
|
-
import
|
|
19469
|
+
import path60 from "node:path";
|
|
19291
19470
|
|
|
19292
19471
|
// src/cli/platform/helpers/tarball.ts
|
|
19293
19472
|
import { createReadStream as createReadStream3, createWriteStream as createWriteStream3, promises as fs9 } from "node:fs";
|
|
19294
19473
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
19295
|
-
import
|
|
19474
|
+
import path58 from "node:path";
|
|
19296
19475
|
import { TarArchive } from "archiver";
|
|
19297
19476
|
var DEV_PORTAL_DEPLOY_ARCHIVE_ROOT = "dist";
|
|
19298
19477
|
function normalizeArchiveRoot(archiveRoot) {
|
|
@@ -19303,10 +19482,10 @@ function normalizeArchiveRoot(archiveRoot) {
|
|
|
19303
19482
|
return `${trimmed}/`;
|
|
19304
19483
|
}
|
|
19305
19484
|
async function packageDirectoryAsTarGz(sourceDirectory, options) {
|
|
19306
|
-
const resolved =
|
|
19485
|
+
const resolved = path58.resolve(sourceDirectory);
|
|
19307
19486
|
const files = await collectPackageableFiles(resolved);
|
|
19308
19487
|
const entryPrefix = options?.archiveRoot ? normalizeArchiveRoot(options.archiveRoot) : "";
|
|
19309
|
-
const archivePath =
|
|
19488
|
+
const archivePath = path58.join(
|
|
19310
19489
|
tmpdir3(),
|
|
19311
19490
|
`apitogo-docs-${Date.now()}-${Math.random().toString(36).slice(2)}.tgz`
|
|
19312
19491
|
);
|
|
@@ -19318,8 +19497,8 @@ async function packageDirectoryAsTarGz(sourceDirectory, options) {
|
|
|
19318
19497
|
output2.on("error", reject);
|
|
19319
19498
|
archive.pipe(output2);
|
|
19320
19499
|
for (const rel of files) {
|
|
19321
|
-
const entryName = entryPrefix + rel.split(
|
|
19322
|
-
archive.append(createReadStream3(
|
|
19500
|
+
const entryName = entryPrefix + rel.split(path58.sep).join("/");
|
|
19501
|
+
archive.append(createReadStream3(path58.join(resolved, rel)), { name: entryName });
|
|
19323
19502
|
}
|
|
19324
19503
|
void archive.finalize();
|
|
19325
19504
|
});
|
|
@@ -19442,8 +19621,8 @@ async function snapshotBackendUpdateJobIds(client, projectId) {
|
|
|
19442
19621
|
}
|
|
19443
19622
|
|
|
19444
19623
|
// src/cli/platform/helpers/dev-portal-site-api-url.ts
|
|
19445
|
-
import { readdir as readdir2, readFile as
|
|
19446
|
-
import
|
|
19624
|
+
import { readdir as readdir2, readFile as readFile17, writeFile as writeFile16 } from "node:fs/promises";
|
|
19625
|
+
import path59 from "node:path";
|
|
19447
19626
|
var SITE_API_BASE_URL_ENV_KEY = "VITE_APITOGO_AUTHENTICATION_API_BASE_URL";
|
|
19448
19627
|
var PLACEHOLDER_HOST_MARKERS = [
|
|
19449
19628
|
"dp-example.azurecontainerapps.io",
|
|
@@ -19461,10 +19640,10 @@ function isPlaceholderDevPortalApiUrl(apiBaseUrl) {
|
|
|
19461
19640
|
return PLACEHOLDER_HOST_MARKERS.some((marker) => normalized.includes(marker));
|
|
19462
19641
|
}
|
|
19463
19642
|
async function readSiteApiBaseUrl(sourceDirectory) {
|
|
19464
|
-
const resolved =
|
|
19643
|
+
const resolved = path59.resolve(sourceDirectory);
|
|
19465
19644
|
for (const envFile of [".env", ".env.production"]) {
|
|
19466
19645
|
try {
|
|
19467
|
-
const content = await
|
|
19646
|
+
const content = await readFile17(path59.join(resolved, envFile), "utf8");
|
|
19468
19647
|
const lines = [...content.matchAll(ENV_LINE_GLOBAL_RE)];
|
|
19469
19648
|
if (lines.length === 0) {
|
|
19470
19649
|
continue;
|
|
@@ -19489,25 +19668,25 @@ async function readSiteApiBaseUrl(sourceDirectory) {
|
|
|
19489
19668
|
return null;
|
|
19490
19669
|
}
|
|
19491
19670
|
async function patchSiteApiBaseUrl(sourceDirectory, apiBaseUrl) {
|
|
19492
|
-
const resolved =
|
|
19671
|
+
const resolved = path59.resolve(sourceDirectory);
|
|
19493
19672
|
const line = `${SITE_API_BASE_URL_ENV_KEY}=${apiBaseUrl}`;
|
|
19494
19673
|
let patchedExisting = false;
|
|
19495
19674
|
for (const envFile of [".env.production", ".env"]) {
|
|
19496
|
-
const envPath =
|
|
19675
|
+
const envPath = path59.join(resolved, envFile);
|
|
19497
19676
|
try {
|
|
19498
|
-
const content = await
|
|
19677
|
+
const content = await readFile17(envPath, "utf8");
|
|
19499
19678
|
const withoutAssignments = content.replace(ENV_LINE_GLOBAL_RE, "").replace(/\n{3,}/g, "\n\n").trimEnd();
|
|
19500
19679
|
const patched = withoutAssignments ? `${withoutAssignments}
|
|
19501
19680
|
${line}
|
|
19502
19681
|
` : `${line}
|
|
19503
19682
|
`;
|
|
19504
|
-
await
|
|
19683
|
+
await writeFile16(envPath, patched);
|
|
19505
19684
|
patchedExisting = true;
|
|
19506
19685
|
} catch {
|
|
19507
19686
|
}
|
|
19508
19687
|
}
|
|
19509
19688
|
if (!patchedExisting) {
|
|
19510
|
-
await
|
|
19689
|
+
await writeFile16(path59.join(resolved, ".env"), `${line}
|
|
19511
19690
|
`);
|
|
19512
19691
|
}
|
|
19513
19692
|
}
|
|
@@ -19515,7 +19694,7 @@ function tryProjectId(explicit, manifestProjectId, config2) {
|
|
|
19515
19694
|
return explicit?.trim() || manifestProjectId?.trim() || config2.defaultProjectId?.trim() || void 0;
|
|
19516
19695
|
}
|
|
19517
19696
|
async function ensureLiveSiteApiBaseUrlForBuild(_client, config2, args, resolveFromProject) {
|
|
19518
|
-
const sourceDirectory =
|
|
19697
|
+
const sourceDirectory = path59.resolve(args.sourceDirectory);
|
|
19519
19698
|
const explicit = args.apiBaseUrl?.trim();
|
|
19520
19699
|
if (explicit && !isPlaceholderDevPortalApiUrl(explicit)) {
|
|
19521
19700
|
await patchSiteApiBaseUrl(sourceDirectory, explicit);
|
|
@@ -19551,7 +19730,7 @@ async function* walkFiles(root) {
|
|
|
19551
19730
|
return;
|
|
19552
19731
|
}
|
|
19553
19732
|
for (const entry of entries) {
|
|
19554
|
-
const full =
|
|
19733
|
+
const full = path59.join(root, entry.name);
|
|
19555
19734
|
if (entry.isDirectory()) {
|
|
19556
19735
|
if (entry.name === "node_modules" || entry.name === ".git") {
|
|
19557
19736
|
continue;
|
|
@@ -19563,8 +19742,8 @@ async function* walkFiles(root) {
|
|
|
19563
19742
|
}
|
|
19564
19743
|
}
|
|
19565
19744
|
async function assertDeployableDistHasLiveApiBaseUrl(distDirectory, expectedApiBaseUrl) {
|
|
19566
|
-
const dist =
|
|
19567
|
-
const siteRoot =
|
|
19745
|
+
const dist = path59.resolve(distDirectory);
|
|
19746
|
+
const siteRoot = path59.dirname(dist);
|
|
19568
19747
|
const fromEnv = expectedApiBaseUrl?.trim() || await readSiteApiBaseUrl(siteRoot) || await readSiteApiBaseUrl(dist);
|
|
19569
19748
|
if (!fromEnv || isPlaceholderDevPortalApiUrl(fromEnv)) {
|
|
19570
19749
|
throw new Error(
|
|
@@ -19575,7 +19754,7 @@ async function assertDeployableDistHasLiveApiBaseUrl(distDirectory, expectedApiB
|
|
|
19575
19754
|
let found = false;
|
|
19576
19755
|
let foundPlaceholder = false;
|
|
19577
19756
|
for await (const file of walkFiles(dist)) {
|
|
19578
|
-
const content = await
|
|
19757
|
+
const content = await readFile17(file, "utf8");
|
|
19579
19758
|
if (content.includes(needle)) {
|
|
19580
19759
|
found = true;
|
|
19581
19760
|
}
|
|
@@ -19819,7 +19998,7 @@ function validateDeployArchiveInput(args) {
|
|
|
19819
19998
|
async function resolveDevPortalArchive(args) {
|
|
19820
19999
|
validateDeployArchiveInput(args);
|
|
19821
20000
|
if (args.archivePath?.trim()) {
|
|
19822
|
-
const archivePath =
|
|
20001
|
+
const archivePath = path60.resolve(args.archivePath.trim());
|
|
19823
20002
|
const stat4 = await fs10.stat(archivePath).catch(() => null);
|
|
19824
20003
|
if (!stat4?.isFile()) {
|
|
19825
20004
|
throw new Error(`archivePath is not a file: ${archivePath}`);
|
|
@@ -19887,10 +20066,10 @@ async function handleDeployDevPortal(client, config2, args, progress) {
|
|
|
19887
20066
|
}
|
|
19888
20067
|
|
|
19889
20068
|
// src/cli/platform/tools/dev-portal-site-build.ts
|
|
19890
|
-
import
|
|
20069
|
+
import path61 from "node:path";
|
|
19891
20070
|
async function handleBuildDevPortalSite(client, config2, args, progress) {
|
|
19892
20071
|
const buildProgress = progress?.child("Build dev portal site");
|
|
19893
|
-
const sourceDirectory =
|
|
20072
|
+
const sourceDirectory = path61.resolve(args.sourceDirectory);
|
|
19894
20073
|
await buildProgress?.onStep("Ensuring live portal API URL");
|
|
19895
20074
|
const apiBaseUrl = await ensureLiveSiteApiBaseUrlForBuild(
|
|
19896
20075
|
client,
|
|
@@ -20864,7 +21043,7 @@ function resultLooksFailed(payload) {
|
|
|
20864
21043
|
}
|
|
20865
21044
|
}
|
|
20866
21045
|
async function apply(argv) {
|
|
20867
|
-
const sourceDirectory =
|
|
21046
|
+
const sourceDirectory = path62.resolve(process.cwd(), argv.dir);
|
|
20868
21047
|
const config2 = loadConfig();
|
|
20869
21048
|
const client = new PlatformApiClient(config2);
|
|
20870
21049
|
let only;
|
|
@@ -20950,11 +21129,11 @@ var deploy_default = {
|
|
|
20950
21129
|
};
|
|
20951
21130
|
|
|
20952
21131
|
// src/cli/init/handler.ts
|
|
20953
|
-
import
|
|
21132
|
+
import path65 from "node:path";
|
|
20954
21133
|
|
|
20955
21134
|
// src/cli/scaffold/run-scaffold-discovery.ts
|
|
20956
|
-
import { access as access10, readFile as
|
|
20957
|
-
import
|
|
21135
|
+
import { access as access10, readFile as readFile19, writeFile as writeFile18 } from "node:fs/promises";
|
|
21136
|
+
import path64 from "node:path";
|
|
20958
21137
|
|
|
20959
21138
|
// src/cli/scaffold/wire-docs.ts
|
|
20960
21139
|
import {
|
|
@@ -20962,12 +21141,12 @@ import {
|
|
|
20962
21141
|
lstat,
|
|
20963
21142
|
mkdir as mkdir13,
|
|
20964
21143
|
readdir as readdir3,
|
|
20965
|
-
readFile as
|
|
21144
|
+
readFile as readFile18,
|
|
20966
21145
|
readlink,
|
|
20967
21146
|
symlink,
|
|
20968
|
-
writeFile as
|
|
21147
|
+
writeFile as writeFile17
|
|
20969
21148
|
} from "node:fs/promises";
|
|
20970
|
-
import
|
|
21149
|
+
import path63 from "node:path";
|
|
20971
21150
|
var DOCS_DIR_WHITELIST = [
|
|
20972
21151
|
"docs",
|
|
20973
21152
|
"documents",
|
|
@@ -21004,14 +21183,14 @@ async function isDirectory(filePath) {
|
|
|
21004
21183
|
}
|
|
21005
21184
|
}
|
|
21006
21185
|
function toPosix2(value) {
|
|
21007
|
-
return value.split(
|
|
21186
|
+
return value.split(path63.sep).join(path63.posix.sep);
|
|
21008
21187
|
}
|
|
21009
21188
|
function isWhitelistedDirName(name) {
|
|
21010
21189
|
return DOCS_DIR_WHITELIST.includes(name.toLowerCase());
|
|
21011
21190
|
}
|
|
21012
21191
|
function isInside2(parent, child) {
|
|
21013
|
-
const relative =
|
|
21014
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
21192
|
+
const relative = path63.relative(parent, child);
|
|
21193
|
+
return relative === "" || !relative.startsWith("..") && !path63.isAbsolute(relative);
|
|
21015
21194
|
}
|
|
21016
21195
|
async function collectMarkdownFiles(dir) {
|
|
21017
21196
|
const files = [];
|
|
@@ -21025,7 +21204,7 @@ async function collectMarkdownFiles(dir) {
|
|
|
21025
21204
|
if (entry.name.startsWith(".")) {
|
|
21026
21205
|
continue;
|
|
21027
21206
|
}
|
|
21028
|
-
const full =
|
|
21207
|
+
const full = path63.join(dir, entry.name);
|
|
21029
21208
|
if (entry.isDirectory()) {
|
|
21030
21209
|
if (SKIP_SEARCH_DIRS.has(entry.name) || entry.isSymbolicLink()) {
|
|
21031
21210
|
continue;
|
|
@@ -21040,11 +21219,11 @@ async function collectMarkdownFiles(dir) {
|
|
|
21040
21219
|
return files;
|
|
21041
21220
|
}
|
|
21042
21221
|
async function collectSearchRoots(siteDirectory) {
|
|
21043
|
-
const site =
|
|
21044
|
-
const parent =
|
|
21222
|
+
const site = path63.resolve(siteDirectory);
|
|
21223
|
+
const parent = path63.dirname(site);
|
|
21045
21224
|
const roots = [];
|
|
21046
21225
|
const add = (dir) => {
|
|
21047
|
-
const resolved =
|
|
21226
|
+
const resolved = path63.resolve(dir);
|
|
21048
21227
|
if (!roots.includes(resolved)) {
|
|
21049
21228
|
roots.push(resolved);
|
|
21050
21229
|
}
|
|
@@ -21057,7 +21236,7 @@ async function collectSearchRoots(siteDirectory) {
|
|
|
21057
21236
|
if (!entry.isDirectory() || SKIP_SEARCH_DIRS.has(entry.name)) {
|
|
21058
21237
|
continue;
|
|
21059
21238
|
}
|
|
21060
|
-
add(
|
|
21239
|
+
add(path63.join(parent, entry.name));
|
|
21061
21240
|
}
|
|
21062
21241
|
} catch {
|
|
21063
21242
|
}
|
|
@@ -21066,13 +21245,13 @@ async function collectSearchRoots(siteDirectory) {
|
|
|
21066
21245
|
return roots;
|
|
21067
21246
|
}
|
|
21068
21247
|
async function discoverNearbyDocsDirectories(siteDirectory) {
|
|
21069
|
-
const site =
|
|
21070
|
-
const sitePages =
|
|
21248
|
+
const site = path63.resolve(siteDirectory);
|
|
21249
|
+
const sitePages = path63.join(site, PAGES_DIR);
|
|
21071
21250
|
const searchedDirectories = await collectSearchRoots(site);
|
|
21072
21251
|
const directories = [];
|
|
21073
21252
|
const seen = /* @__PURE__ */ new Set();
|
|
21074
21253
|
const consider = async (dir) => {
|
|
21075
|
-
const resolved =
|
|
21254
|
+
const resolved = path63.resolve(dir);
|
|
21076
21255
|
if (resolved === site || seen.has(resolved) || isInside2(sitePages, resolved)) {
|
|
21077
21256
|
return;
|
|
21078
21257
|
}
|
|
@@ -21089,7 +21268,7 @@ async function discoverNearbyDocsDirectories(siteDirectory) {
|
|
|
21089
21268
|
directories.push({ sourceDirectory: resolved, files });
|
|
21090
21269
|
};
|
|
21091
21270
|
for (const root of searchedDirectories) {
|
|
21092
|
-
if (isWhitelistedDirName(
|
|
21271
|
+
if (isWhitelistedDirName(path63.basename(root))) {
|
|
21093
21272
|
await consider(root);
|
|
21094
21273
|
}
|
|
21095
21274
|
try {
|
|
@@ -21101,7 +21280,7 @@ async function discoverNearbyDocsDirectories(siteDirectory) {
|
|
|
21101
21280
|
if (!isWhitelistedDirName(entry.name)) {
|
|
21102
21281
|
continue;
|
|
21103
21282
|
}
|
|
21104
|
-
await consider(
|
|
21283
|
+
await consider(path63.join(root, entry.name));
|
|
21105
21284
|
}
|
|
21106
21285
|
} catch {
|
|
21107
21286
|
}
|
|
@@ -21112,8 +21291,8 @@ function slugifyDirName(name) {
|
|
|
21112
21291
|
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "docs";
|
|
21113
21292
|
}
|
|
21114
21293
|
async function allocateLinkName(pagesDir, sourceDirectory, used) {
|
|
21115
|
-
const base = slugifyDirName(
|
|
21116
|
-
const parent = slugifyDirName(
|
|
21294
|
+
const base = slugifyDirName(path63.basename(sourceDirectory));
|
|
21295
|
+
const parent = slugifyDirName(path63.basename(path63.dirname(sourceDirectory)));
|
|
21117
21296
|
const candidates = [base, `${parent}-${base}`];
|
|
21118
21297
|
let index = 2;
|
|
21119
21298
|
while (true) {
|
|
@@ -21121,7 +21300,7 @@ async function allocateLinkName(pagesDir, sourceDirectory, used) {
|
|
|
21121
21300
|
if (used.has(name)) {
|
|
21122
21301
|
continue;
|
|
21123
21302
|
}
|
|
21124
|
-
const target =
|
|
21303
|
+
const target = path63.join(pagesDir, name);
|
|
21125
21304
|
if (await pathExists5(target)) {
|
|
21126
21305
|
const stat4 = await lstat(target);
|
|
21127
21306
|
if (!stat4.isDirectory() || !await isManagedLinkDir(target)) {
|
|
@@ -21152,8 +21331,8 @@ async function alreadyLinked(linkPath, sourcePath) {
|
|
|
21152
21331
|
return false;
|
|
21153
21332
|
}
|
|
21154
21333
|
const current = await readlink(linkPath);
|
|
21155
|
-
const resolved =
|
|
21156
|
-
return resolved ===
|
|
21334
|
+
const resolved = path63.resolve(path63.dirname(linkPath), current);
|
|
21335
|
+
return resolved === path63.resolve(sourcePath);
|
|
21157
21336
|
} catch {
|
|
21158
21337
|
return false;
|
|
21159
21338
|
}
|
|
@@ -21165,8 +21344,8 @@ async function linkMarkdownFile(sourcePath, linkPath) {
|
|
|
21165
21344
|
if (await pathExists5(linkPath)) {
|
|
21166
21345
|
return "skipped";
|
|
21167
21346
|
}
|
|
21168
|
-
await mkdir13(
|
|
21169
|
-
const relativeTarget =
|
|
21347
|
+
await mkdir13(path63.dirname(linkPath), { recursive: true });
|
|
21348
|
+
const relativeTarget = path63.relative(path63.dirname(linkPath), sourcePath);
|
|
21170
21349
|
await symlink(
|
|
21171
21350
|
relativeTarget,
|
|
21172
21351
|
linkPath,
|
|
@@ -21181,11 +21360,11 @@ async function applyDocsNavigation(siteDirectory, routes) {
|
|
|
21181
21360
|
if (routes.length === 0) {
|
|
21182
21361
|
return;
|
|
21183
21362
|
}
|
|
21184
|
-
const configPath =
|
|
21363
|
+
const configPath = path63.join(siteDirectory, CONFIG_FILENAME);
|
|
21185
21364
|
if (!await pathExists5(configPath)) {
|
|
21186
21365
|
return;
|
|
21187
21366
|
}
|
|
21188
|
-
const raw = await
|
|
21367
|
+
const raw = await readFile18(configPath, "utf8");
|
|
21189
21368
|
const parsed = JSON.parse(raw);
|
|
21190
21369
|
if (!isPlainObject4(parsed)) {
|
|
21191
21370
|
return;
|
|
@@ -21193,12 +21372,12 @@ async function applyDocsNavigation(siteDirectory, routes) {
|
|
|
21193
21372
|
parsed.navigation = mergeDocumentationNavigation(parsed.navigation, routes, {
|
|
21194
21373
|
force: false
|
|
21195
21374
|
});
|
|
21196
|
-
await
|
|
21375
|
+
await writeFile17(configPath, `${JSON.stringify(parsed, null, 2)}
|
|
21197
21376
|
`, "utf8");
|
|
21198
21377
|
}
|
|
21199
21378
|
async function discoverAndWireDocs(siteDirectory) {
|
|
21200
|
-
const site =
|
|
21201
|
-
const pagesDir =
|
|
21379
|
+
const site = path63.resolve(siteDirectory);
|
|
21380
|
+
const pagesDir = path63.join(site, PAGES_DIR);
|
|
21202
21381
|
const { directories, searchedDirectories } = await discoverNearbyDocsDirectories(site);
|
|
21203
21382
|
if (directories.length === 0) {
|
|
21204
21383
|
return {
|
|
@@ -21220,14 +21399,14 @@ async function discoverAndWireDocs(siteDirectory) {
|
|
|
21220
21399
|
directory.sourceDirectory,
|
|
21221
21400
|
usedNames
|
|
21222
21401
|
);
|
|
21223
|
-
const linkDirectory =
|
|
21402
|
+
const linkDirectory = path63.join(pagesDir, linkName);
|
|
21224
21403
|
const linked = [];
|
|
21225
21404
|
const skipped = [];
|
|
21226
21405
|
for (const sourcePath of directory.files) {
|
|
21227
21406
|
const relativeSource = toPosix2(
|
|
21228
|
-
|
|
21407
|
+
path63.relative(directory.sourceDirectory, sourcePath)
|
|
21229
21408
|
);
|
|
21230
|
-
const linkPath =
|
|
21409
|
+
const linkPath = path63.join(linkDirectory, relativeSource);
|
|
21231
21410
|
const result = await linkMarkdownFile(sourcePath, linkPath);
|
|
21232
21411
|
if (result === "skipped") {
|
|
21233
21412
|
skipped.push({
|
|
@@ -21236,7 +21415,7 @@ async function discoverAndWireDocs(siteDirectory) {
|
|
|
21236
21415
|
});
|
|
21237
21416
|
continue;
|
|
21238
21417
|
}
|
|
21239
|
-
const relativeLink = toPosix2(
|
|
21418
|
+
const relativeLink = toPosix2(path63.relative(site, linkPath));
|
|
21240
21419
|
const route = toRoutePath(relativeLink, PAGES_DIR);
|
|
21241
21420
|
linked.push({ sourcePath, linkPath, route, relativeSource });
|
|
21242
21421
|
routes.push(route);
|
|
@@ -21269,11 +21448,11 @@ async function discoverAndWireDocs(siteDirectory) {
|
|
|
21269
21448
|
};
|
|
21270
21449
|
}
|
|
21271
21450
|
function siteRelative(siteDirectory, filePath) {
|
|
21272
|
-
const relative = toPosix2(
|
|
21451
|
+
const relative = toPosix2(path63.relative(siteDirectory, filePath));
|
|
21273
21452
|
if (!relative) {
|
|
21274
21453
|
return ".";
|
|
21275
21454
|
}
|
|
21276
|
-
if (
|
|
21455
|
+
if (path63.isAbsolute(relative)) {
|
|
21277
21456
|
return toPosix2(filePath);
|
|
21278
21457
|
}
|
|
21279
21458
|
if (relative.startsWith("..")) {
|
|
@@ -21340,8 +21519,8 @@ async function pathExists6(filePath) {
|
|
|
21340
21519
|
}
|
|
21341
21520
|
async function wireOpenApiIntoJsonConfig(siteDirectory, openApiPath) {
|
|
21342
21521
|
const input3 = toSiteRelativeOpenApiInput(siteDirectory, openApiPath);
|
|
21343
|
-
const jsonConfigPath =
|
|
21344
|
-
const raw = await
|
|
21522
|
+
const jsonConfigPath = path64.join(siteDirectory, "apitogo.config.json");
|
|
21523
|
+
const raw = await readFile19(jsonConfigPath, "utf8");
|
|
21345
21524
|
const siteConfig = JSON.parse(raw);
|
|
21346
21525
|
const updated = applyOpenApiToSiteConfig(siteConfig, {
|
|
21347
21526
|
input: input3,
|
|
@@ -21349,7 +21528,7 @@ async function wireOpenApiIntoJsonConfig(siteDirectory, openApiPath) {
|
|
|
21349
21528
|
});
|
|
21350
21529
|
const backend = updated.backend && typeof updated.backend === "object" && !Array.isArray(updated.backend) ? { ...updated.backend } : {};
|
|
21351
21530
|
updated.backend = { ...backend, openApiPath: input3 };
|
|
21352
|
-
await
|
|
21531
|
+
await writeFile18(
|
|
21353
21532
|
jsonConfigPath,
|
|
21354
21533
|
`${JSON.stringify(updated, null, 2)}
|
|
21355
21534
|
`,
|
|
@@ -21368,7 +21547,7 @@ async function discoverAndWireOpenApiLite(siteDirectory, mode) {
|
|
|
21368
21547
|
const invalidCandidates = [];
|
|
21369
21548
|
let selected;
|
|
21370
21549
|
for (const candidate of search.candidates) {
|
|
21371
|
-
const content = await
|
|
21550
|
+
const content = await readFile19(candidate, "utf8");
|
|
21372
21551
|
const parsed = liteParseOpenApi(content, candidate);
|
|
21373
21552
|
if (parsed.valid) {
|
|
21374
21553
|
selected = {
|
|
@@ -21392,7 +21571,7 @@ async function discoverAndWireOpenApiLite(siteDirectory, mode) {
|
|
|
21392
21571
|
wired: false
|
|
21393
21572
|
};
|
|
21394
21573
|
}
|
|
21395
|
-
const jsonConfigPath =
|
|
21574
|
+
const jsonConfigPath = path64.join(siteDirectory, "apitogo.config.json");
|
|
21396
21575
|
if (!await pathExists6(jsonConfigPath)) {
|
|
21397
21576
|
return {
|
|
21398
21577
|
openApiDiscovery: {
|
|
@@ -21453,8 +21632,8 @@ function slugifyName2(name) {
|
|
|
21453
21632
|
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "dev-portal-site";
|
|
21454
21633
|
}
|
|
21455
21634
|
function resolveInitOutputDirectory(dirArg, name) {
|
|
21456
|
-
const resolved =
|
|
21457
|
-
const base =
|
|
21635
|
+
const resolved = path65.resolve(process.cwd(), dirArg);
|
|
21636
|
+
const base = path65.basename(resolved);
|
|
21458
21637
|
const isDot = dirArg === "." || dirArg === "./" || base === "." || resolved === process.cwd();
|
|
21459
21638
|
if (isDot) {
|
|
21460
21639
|
const fromName = name?.trim();
|
|
@@ -21464,7 +21643,7 @@ function resolveInitOutputDirectory(dirArg, name) {
|
|
|
21464
21643
|
);
|
|
21465
21644
|
}
|
|
21466
21645
|
return {
|
|
21467
|
-
outputDirectory:
|
|
21646
|
+
outputDirectory: path65.resolve(process.cwd(), slugifyName2(fromName)),
|
|
21468
21647
|
siteName: fromName
|
|
21469
21648
|
};
|
|
21470
21649
|
}
|
|
@@ -21614,7 +21793,7 @@ var init_default = {
|
|
|
21614
21793
|
// src/cli/cmds/preview.ts
|
|
21615
21794
|
var REMOVED2 = "apitogo preview was removed. Use `apitogo build --preview` or `apitogo run`.";
|
|
21616
21795
|
var preview_default = {
|
|
21617
|
-
|
|
21796
|
+
describe: false,
|
|
21618
21797
|
command: "preview",
|
|
21619
21798
|
builder: (yargs2) => yargs2,
|
|
21620
21799
|
handler: async (argv) => {
|
|
@@ -21698,7 +21877,7 @@ var project_create_default = {
|
|
|
21698
21877
|
// src/cli/cmds/remove.ts
|
|
21699
21878
|
var REMOVED3 = "apitogo remove was removed. Use `apitogo teardown --yes` to delete the platform project.";
|
|
21700
21879
|
var remove_default = {
|
|
21701
|
-
|
|
21880
|
+
describe: false,
|
|
21702
21881
|
command: "remove",
|
|
21703
21882
|
builder: (yargs2) => yargs2,
|
|
21704
21883
|
handler: async (argv) => {
|
|
@@ -21709,14 +21888,14 @@ var remove_default = {
|
|
|
21709
21888
|
|
|
21710
21889
|
// src/cli/dev/handler.ts
|
|
21711
21890
|
init_joinUrl();
|
|
21712
|
-
import
|
|
21891
|
+
import path68 from "node:path";
|
|
21713
21892
|
|
|
21714
21893
|
// src/vite/dev-server.ts
|
|
21715
21894
|
init_logger();
|
|
21716
21895
|
import fs11 from "node:fs/promises";
|
|
21717
21896
|
import http from "node:http";
|
|
21718
21897
|
import https from "node:https";
|
|
21719
|
-
import
|
|
21898
|
+
import path67 from "node:path";
|
|
21720
21899
|
import { createHttpTerminator } from "http-terminator";
|
|
21721
21900
|
import {
|
|
21722
21901
|
createServer as createViteServer,
|
|
@@ -21749,7 +21928,7 @@ init_loader();
|
|
|
21749
21928
|
// src/vite/pagefind-dev-index.ts
|
|
21750
21929
|
init_invariant();
|
|
21751
21930
|
init_joinUrl();
|
|
21752
|
-
import
|
|
21931
|
+
import path66 from "node:path";
|
|
21753
21932
|
import { createIndex as createIndex2 } from "pagefind";
|
|
21754
21933
|
import { isRunnableDevEnvironment } from "vite";
|
|
21755
21934
|
async function* buildPagefindDevIndex(vite, config2) {
|
|
@@ -21802,7 +21981,7 @@ async function* buildPagefindDevIndex(vite, config2) {
|
|
|
21802
21981
|
path: urlPath
|
|
21803
21982
|
};
|
|
21804
21983
|
}
|
|
21805
|
-
const outputPath =
|
|
21984
|
+
const outputPath = path66.join(vite.config.publicDir, "pagefind");
|
|
21806
21985
|
await pagefindIndex.writeFiles({ outputPath });
|
|
21807
21986
|
yield { type: "complete", success: true, indexed };
|
|
21808
21987
|
}
|
|
@@ -21821,9 +22000,9 @@ var DevServer = class {
|
|
|
21821
22000
|
this.protocol = "https";
|
|
21822
22001
|
const { dir } = this.options;
|
|
21823
22002
|
const [key, cert, ca] = await Promise.all([
|
|
21824
|
-
fs11.readFile(
|
|
21825
|
-
fs11.readFile(
|
|
21826
|
-
config2.https.ca ? fs11.readFile(
|
|
22003
|
+
fs11.readFile(path67.resolve(dir, config2.https.key)),
|
|
22004
|
+
fs11.readFile(path67.resolve(dir, config2.https.cert)),
|
|
22005
|
+
config2.https.ca ? fs11.readFile(path67.resolve(dir, config2.https.ca)) : void 0
|
|
21827
22006
|
]);
|
|
21828
22007
|
return https.createServer({ key, cert, ca });
|
|
21829
22008
|
}
|
|
@@ -21840,7 +22019,7 @@ var DevServer = class {
|
|
|
21840
22019
|
);
|
|
21841
22020
|
const server = await this.createNodeServer(config2);
|
|
21842
22021
|
if (config2.search?.type === "pagefind" && viteConfig.publicDir !== false) {
|
|
21843
|
-
const publicRoot =
|
|
22022
|
+
const publicRoot = path67.resolve(
|
|
21844
22023
|
this.options.dir,
|
|
21845
22024
|
typeof viteConfig.publicDir === "string" ? viteConfig.publicDir : "public"
|
|
21846
22025
|
);
|
|
@@ -21857,7 +22036,7 @@ var DevServer = class {
|
|
|
21857
22036
|
// built-in transform middleware which would treat the path as a static asset.
|
|
21858
22037
|
name: "apitogo:entry-client",
|
|
21859
22038
|
configureServer(server2) {
|
|
21860
|
-
const entryPath =
|
|
22039
|
+
const entryPath = path67.posix.join(
|
|
21861
22040
|
server2.config.base,
|
|
21862
22041
|
"/__z/entry.client.tsx"
|
|
21863
22042
|
);
|
|
@@ -22020,9 +22199,9 @@ var DevServer = class {
|
|
|
22020
22199
|
// src/cli/dev/handler.ts
|
|
22021
22200
|
init_package_json();
|
|
22022
22201
|
async function dev(argv) {
|
|
22023
|
-
const
|
|
22202
|
+
const packageJson3 = getZudokuPackageJson();
|
|
22024
22203
|
process.env.NODE_ENV = "development";
|
|
22025
|
-
const dir =
|
|
22204
|
+
const dir = path68.resolve(process.cwd(), argv.dir);
|
|
22026
22205
|
const server = new DevServer({
|
|
22027
22206
|
dir,
|
|
22028
22207
|
argPort: argv.port,
|
|
@@ -22037,7 +22216,7 @@ async function dev(argv) {
|
|
|
22037
22216
|
printDiagnosticsToConsole("Ctrl+C to exit");
|
|
22038
22217
|
printDiagnosticsToConsole("");
|
|
22039
22218
|
printDiagnosticsToConsole(
|
|
22040
|
-
`\u{1F680} Running API ToGo v${
|
|
22219
|
+
`\u{1F680} Running API ToGo v${packageJson3.version}: ${url}`
|
|
22041
22220
|
);
|
|
22042
22221
|
printDiagnosticsToConsole("");
|
|
22043
22222
|
let hasExited = false;
|
|
@@ -22106,9 +22285,9 @@ var run_default = {
|
|
|
22106
22285
|
};
|
|
22107
22286
|
|
|
22108
22287
|
// src/cli/status/handler.ts
|
|
22109
|
-
import
|
|
22288
|
+
import path69 from "node:path";
|
|
22110
22289
|
async function status(argv) {
|
|
22111
|
-
const sourceDirectory =
|
|
22290
|
+
const sourceDirectory = path69.resolve(process.cwd(), argv.dir);
|
|
22112
22291
|
const config2 = loadConfig();
|
|
22113
22292
|
const client = new PlatformApiClient(config2);
|
|
22114
22293
|
let whoamiJson;
|
|
@@ -22188,7 +22367,7 @@ var status_default = {
|
|
|
22188
22367
|
};
|
|
22189
22368
|
|
|
22190
22369
|
// src/cli/teardown/handler.ts
|
|
22191
|
-
import
|
|
22370
|
+
import path70 from "node:path";
|
|
22192
22371
|
function resultLooksFailed3(payload) {
|
|
22193
22372
|
try {
|
|
22194
22373
|
const parsed = JSON.parse(payload);
|
|
@@ -22204,7 +22383,7 @@ async function teardown(argv) {
|
|
|
22204
22383
|
);
|
|
22205
22384
|
return;
|
|
22206
22385
|
}
|
|
22207
|
-
const sourceDirectory =
|
|
22386
|
+
const sourceDirectory = path70.resolve(process.cwd(), argv.dir);
|
|
22208
22387
|
const config2 = loadConfig();
|
|
22209
22388
|
const client = new PlatformApiClient(config2);
|
|
22210
22389
|
let projectId = argv.projectId?.trim();
|
|
@@ -22268,190 +22447,7 @@ var teardown_default = {
|
|
|
22268
22447
|
}
|
|
22269
22448
|
};
|
|
22270
22449
|
|
|
22271
|
-
// src/cli/
|
|
22272
|
-
import { existsSync as existsSync5, mkdirSync } from "node:fs";
|
|
22273
|
-
import { readFile as readFile19, writeFile as writeFile18 } from "node:fs/promises";
|
|
22274
|
-
import { join } from "node:path";
|
|
22275
|
-
import colors10 from "picocolors";
|
|
22276
|
-
import { gt } from "semver";
|
|
22277
|
-
|
|
22278
|
-
// src/cli/common/json-only-deploy.ts
|
|
22279
|
-
function isDeployJsonOnlyArgv() {
|
|
22280
|
-
const args = process.argv;
|
|
22281
|
-
let cmdIdx = -1;
|
|
22282
|
-
for (const cmd of ["deploy", "remove"]) {
|
|
22283
|
-
const i = args.indexOf(cmd);
|
|
22284
|
-
if (i !== -1) {
|
|
22285
|
-
cmdIdx = i;
|
|
22286
|
-
break;
|
|
22287
|
-
}
|
|
22288
|
-
}
|
|
22289
|
-
if (cmdIdx === -1) {
|
|
22290
|
-
return false;
|
|
22291
|
-
}
|
|
22292
|
-
return args.slice(cmdIdx).some((a) => a === "--json-only" || a.startsWith("--json-only="));
|
|
22293
|
-
}
|
|
22294
|
-
|
|
22295
|
-
// src/cli/common/utils/box.ts
|
|
22296
|
-
import colors9 from "picocolors";
|
|
22297
|
-
import stripAnsi from "strip-ansi";
|
|
22298
|
-
var border = ["\u2500", "\u256D", "\u256E", "\u2502", "\u2502", "\u2570", "\u256F"];
|
|
22299
|
-
var nothing = ["\u2500", "", "", "", "", "", ""];
|
|
22300
|
-
function box(message, {
|
|
22301
|
-
borderColor,
|
|
22302
|
-
padding = 1,
|
|
22303
|
-
textAlignment = "center",
|
|
22304
|
-
terminalColumns: cols = process.stdout.columns || process.env.COLUMNS && parseInt(process.env.COLUMNS, 10) || 80
|
|
22305
|
-
} = {}) {
|
|
22306
|
-
const lines = message.split(/\r?\n/).map((line) => [line, stripAnsi(line).length]);
|
|
22307
|
-
const maxLine = lines.reduce((p, [, len]) => Math.max(p, len), 0);
|
|
22308
|
-
const borderColorFn = borderColor && colors9[borderColor] || colors9.yellow;
|
|
22309
|
-
const clampedSidePadding = Math.max(1, padding * 3);
|
|
22310
|
-
const narrowMode = maxLine + 2 + clampedSidePadding * 2 > cols;
|
|
22311
|
-
const sidePadding = narrowMode ? 0 : clampedSidePadding;
|
|
22312
|
-
const innerWidth = Math.min(maxLine + sidePadding * 2, cols);
|
|
22313
|
-
const [hr, topLeft, topRight, left, right, bottomLeft, bottomRight] = narrowMode ? nothing : border;
|
|
22314
|
-
const spacerRow = narrowMode ? "\n".repeat(padding) : `${borderColorFn(`${left}${" ".repeat(innerWidth)}${right}`)}
|
|
22315
|
-
`.repeat(
|
|
22316
|
-
padding
|
|
22317
|
-
);
|
|
22318
|
-
const renderLine = ([line, len]) => {
|
|
22319
|
-
let leftPadding = 0;
|
|
22320
|
-
let rightPadding = 0;
|
|
22321
|
-
if (!narrowMode) {
|
|
22322
|
-
leftPadding = sidePadding;
|
|
22323
|
-
rightPadding = sidePadding;
|
|
22324
|
-
if (textAlignment === "center") {
|
|
22325
|
-
leftPadding += Math.floor((maxLine - len) / 2);
|
|
22326
|
-
rightPadding += maxLine - len - leftPadding + sidePadding;
|
|
22327
|
-
} else if (textAlignment === "right") {
|
|
22328
|
-
leftPadding += maxLine - len;
|
|
22329
|
-
} else if (textAlignment === "left") {
|
|
22330
|
-
rightPadding += maxLine - len;
|
|
22331
|
-
}
|
|
22332
|
-
}
|
|
22333
|
-
return borderColorFn(left) + " ".repeat(leftPadding) + line + " ".repeat(rightPadding) + borderColorFn(right);
|
|
22334
|
-
};
|
|
22335
|
-
return borderColorFn(`${topLeft}${hr?.repeat(innerWidth)}${topRight}`) + "\n" + spacerRow + lines.map(renderLine).join("\n") + "\n" + spacerRow + borderColorFn(`${bottomLeft}${hr?.repeat(innerWidth)}${bottomRight}`);
|
|
22336
|
-
}
|
|
22337
|
-
|
|
22338
|
-
// src/cli/common/xdg/lib.ts
|
|
22339
|
-
import { homedir } from "node:os";
|
|
22340
|
-
import path70 from "node:path";
|
|
22341
|
-
function defineDirectoryWithFallback(xdgName, fallback) {
|
|
22342
|
-
if (process.env[xdgName]) {
|
|
22343
|
-
return process.env[xdgName];
|
|
22344
|
-
} else {
|
|
22345
|
-
return path70.join(homedir(), fallback);
|
|
22346
|
-
}
|
|
22347
|
-
}
|
|
22348
|
-
var XDG_CONFIG_HOME = defineDirectoryWithFallback(
|
|
22349
|
-
"XDG_CONFIG_HOME",
|
|
22350
|
-
".config"
|
|
22351
|
-
);
|
|
22352
|
-
var XDG_DATA_HOME = defineDirectoryWithFallback(
|
|
22353
|
-
"XDG_DATA_HOME",
|
|
22354
|
-
".local/share"
|
|
22355
|
-
);
|
|
22356
|
-
var XDG_STATE_HOME = defineDirectoryWithFallback(
|
|
22357
|
-
"XDG_DATA_HOME",
|
|
22358
|
-
".local/state"
|
|
22359
|
-
);
|
|
22360
|
-
var ZUDOKU_XDG_CONFIG_HOME = path70.join(
|
|
22361
|
-
XDG_CONFIG_HOME,
|
|
22362
|
-
CLI_XDG_FOLDER_NAME
|
|
22363
|
-
);
|
|
22364
|
-
var ZUDOKU_XDG_DATA_HOME = path70.join(
|
|
22365
|
-
XDG_DATA_HOME,
|
|
22366
|
-
CLI_XDG_FOLDER_NAME
|
|
22367
|
-
);
|
|
22368
|
-
var ZUDOKU_XDG_STATE_HOME = path70.join(
|
|
22369
|
-
XDG_STATE_HOME,
|
|
22370
|
-
CLI_XDG_FOLDER_NAME
|
|
22371
|
-
);
|
|
22372
|
-
|
|
22373
|
-
// src/cli/common/outdated.ts
|
|
22374
|
-
async function warnIfOutdatedVersion(currentVersion) {
|
|
22375
|
-
if (isDeployJsonOnlyArgv()) {
|
|
22376
|
-
return false;
|
|
22377
|
-
}
|
|
22378
|
-
if (!process.env.ZUDOKU_OVERRIDE_CI_TO_TEST && (process.env.CI || process.env.ZUDOKU_DISABLE_UPDATE_CHECK)) {
|
|
22379
|
-
return false;
|
|
22380
|
-
}
|
|
22381
|
-
const versionCheckInfo = await getVersionCheckInfo();
|
|
22382
|
-
if (!versionCheckInfo.latestVersion) {
|
|
22383
|
-
return false;
|
|
22384
|
-
}
|
|
22385
|
-
const shouldWarn = gt(versionCheckInfo.latestVersion, currentVersion) && !process.env.ZUDOKU_INTERNAL_DEV;
|
|
22386
|
-
if (shouldWarn) {
|
|
22387
|
-
printWarningToConsole(
|
|
22388
|
-
box(
|
|
22389
|
-
`Update available! ${colors10.gray(`v${currentVersion}`)} \u226B ${colors10.green(
|
|
22390
|
-
`v${versionCheckInfo.latestVersion}`
|
|
22391
|
-
)}
|
|
22392
|
-
Run ${colors10.cyan("npm install apitogo@latest")} to update.
|
|
22393
|
-
|
|
22394
|
-
${colors10.gray("Upgrade to receive the latest features and fixes.")}`
|
|
22395
|
-
)
|
|
22396
|
-
);
|
|
22397
|
-
}
|
|
22398
|
-
return shouldWarn;
|
|
22399
|
-
}
|
|
22400
|
-
async function getLatestVersion() {
|
|
22401
|
-
const response = await fetch(
|
|
22402
|
-
"https://api.github.com/repos/lukoweb/apitogo-doc-tool/releases?per_page=1"
|
|
22403
|
-
);
|
|
22404
|
-
if (response.status === 200) {
|
|
22405
|
-
const result = await response.json();
|
|
22406
|
-
if (Array.isArray(result) && result.length > 0) {
|
|
22407
|
-
return result[0].tag_name.substring(1);
|
|
22408
|
-
}
|
|
22409
|
-
}
|
|
22410
|
-
return void 0;
|
|
22411
|
-
}
|
|
22412
|
-
async function getVersionCheckInfo() {
|
|
22413
|
-
if (!existsSync5(ZUDOKU_XDG_STATE_HOME)) {
|
|
22414
|
-
mkdirSync(ZUDOKU_XDG_STATE_HOME, { recursive: true });
|
|
22415
|
-
}
|
|
22416
|
-
const versionCheckPath = join(ZUDOKU_XDG_STATE_HOME, VERSION_CHECK_FILE);
|
|
22417
|
-
let versionCheckInfo;
|
|
22418
|
-
if (existsSync5(versionCheckPath)) {
|
|
22419
|
-
try {
|
|
22420
|
-
versionCheckInfo = await readFile19(versionCheckPath, "utf-8").then(
|
|
22421
|
-
JSON.parse
|
|
22422
|
-
);
|
|
22423
|
-
} catch {
|
|
22424
|
-
}
|
|
22425
|
-
if (versionCheckInfo) {
|
|
22426
|
-
if (typeof versionCheckInfo.lastCheck !== "number" || typeof versionCheckInfo.latestVersion !== "string") {
|
|
22427
|
-
versionCheckInfo = void 0;
|
|
22428
|
-
}
|
|
22429
|
-
}
|
|
22430
|
-
}
|
|
22431
|
-
let shouldCheck = true;
|
|
22432
|
-
if (versionCheckInfo) {
|
|
22433
|
-
const now = Date.now();
|
|
22434
|
-
const lastCheck = versionCheckInfo.lastCheck;
|
|
22435
|
-
if (now - lastCheck < 1e3 * 60 * 60 * 24) {
|
|
22436
|
-
shouldCheck = false;
|
|
22437
|
-
}
|
|
22438
|
-
}
|
|
22439
|
-
if (!versionCheckInfo || shouldCheck) {
|
|
22440
|
-
const latestVersion = await getLatestVersion();
|
|
22441
|
-
versionCheckInfo = {
|
|
22442
|
-
lastCheck: Date.now(),
|
|
22443
|
-
latestVersion
|
|
22444
|
-
};
|
|
22445
|
-
await writeFile18(
|
|
22446
|
-
versionCheckPath,
|
|
22447
|
-
JSON.stringify(versionCheckInfo),
|
|
22448
|
-
"utf-8"
|
|
22449
|
-
);
|
|
22450
|
-
}
|
|
22451
|
-
return versionCheckInfo;
|
|
22452
|
-
}
|
|
22453
|
-
|
|
22454
|
-
// src/cli/cli.ts
|
|
22450
|
+
// src/cli/create-cli.ts
|
|
22455
22451
|
init_package_json();
|
|
22456
22452
|
|
|
22457
22453
|
// src/cli/common/version-check.ts
|
|
@@ -22472,10 +22468,10 @@ var warnPackageVersionMismatch = () => {
|
|
|
22472
22468
|
if (process.env.ZUDOKU_ENV === "internal") {
|
|
22473
22469
|
return;
|
|
22474
22470
|
}
|
|
22475
|
-
const
|
|
22471
|
+
const packageJson3 = getZudokuPackageJson();
|
|
22476
22472
|
const reactPath = getPackageJsonPath("react");
|
|
22477
22473
|
const reactDomPath = getPackageJsonPath("react-dom");
|
|
22478
|
-
const required =
|
|
22474
|
+
const required = packageJson3.peerDependencies;
|
|
22479
22475
|
const installed = {
|
|
22480
22476
|
react: getPackageJson(reactPath).version,
|
|
22481
22477
|
"react-dom": getPackageJson(reactDomPath).version
|
|
@@ -22511,27 +22507,35 @@ To fix, run:
|
|
|
22511
22507
|
process.exit(1);
|
|
22512
22508
|
};
|
|
22513
22509
|
|
|
22510
|
+
// src/cli/create-cli.ts
|
|
22511
|
+
var packageJson = getZudokuPackageJson();
|
|
22512
|
+
var command = (module) => module;
|
|
22513
|
+
function createApitogoCli(argv) {
|
|
22514
|
+
return yargs(argv).scriptName("apitogo").option("zuplo", {
|
|
22515
|
+
type: "boolean",
|
|
22516
|
+
description: "Enable Zuplo mode",
|
|
22517
|
+
global: true,
|
|
22518
|
+
hidden: true
|
|
22519
|
+
}).middleware((parsed) => {
|
|
22520
|
+
if (parsed.zuplo) {
|
|
22521
|
+
process.env.ZUPLO = "1";
|
|
22522
|
+
printDiagnosticsToConsole("Running in Zuplo mode");
|
|
22523
|
+
}
|
|
22524
|
+
}).middleware(warnPackageVersionMismatch).command(command(init_default)).command(command(config_default)).command(command(run_default)).command(command(build_default)).command(command(check_default)).command(command(project_create_default)).command(command(deploy_default)).command(command(status_default)).command(command(teardown_default)).command(command(remove_default)).command(command(preview_default)).command(command(configure_github_workflow_default)).demandCommand().strictCommands().version(packageJson?.version).fail(false).help();
|
|
22525
|
+
}
|
|
22526
|
+
|
|
22514
22527
|
// src/cli/cli.ts
|
|
22515
22528
|
process.env.ZUDOKU_ENV = process.env.ZUDOKU_INTERNAL_DEV ? "internal" : "module";
|
|
22516
|
-
var
|
|
22529
|
+
var packageJson2 = getZudokuPackageJson();
|
|
22517
22530
|
if (SENTRY_DSN) {
|
|
22518
22531
|
Sentry2.init({
|
|
22519
22532
|
dsn: SENTRY_DSN,
|
|
22520
|
-
release:
|
|
22533
|
+
release: packageJson2?.version
|
|
22521
22534
|
});
|
|
22522
22535
|
}
|
|
22523
|
-
var cli =
|
|
22524
|
-
type: "boolean",
|
|
22525
|
-
description: "Enable Zuplo mode",
|
|
22526
|
-
global: true
|
|
22527
|
-
}).middleware((argv) => {
|
|
22528
|
-
if (argv.zuplo) {
|
|
22529
|
-
process.env.ZUPLO = "1";
|
|
22530
|
-
printDiagnosticsToConsole("Running in Zuplo mode");
|
|
22531
|
-
}
|
|
22532
|
-
}).middleware(warnPackageVersionMismatch).command(init_default).command(config_default).command(run_default).command(build_default).command(check_default).command(project_create_default).command(deploy_default).command(status_default).command(teardown_default).command(remove_default).command(preview_default).command(configure_github_workflow_default).demandCommand().strictCommands().version(packageJson?.version).fail(false).help();
|
|
22536
|
+
var cli = createApitogoCli(hideBin(process.argv));
|
|
22533
22537
|
try {
|
|
22534
|
-
void warnIfOutdatedVersion(
|
|
22538
|
+
void warnIfOutdatedVersion(packageJson2?.version);
|
|
22535
22539
|
await cli.argv;
|
|
22536
22540
|
void Sentry2.close(MAX_WAIT_PENDING_TIME_MS).then(() => {
|
|
22537
22541
|
process.exit(0);
|